aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.editorconfig16
-rw-r--r--.gitignore25
-rw-r--r--.gitmodules3
-rw-r--r--.travis.yml130
-rw-r--r--BUGS4
-rw-r--r--CONTRIBUTING.md319
-rw-r--r--COPYING.md361
-rw-r--r--COPYRIGHT108
-rw-r--r--INSTALL.md363
-rw-r--r--MANUAL.txt4209
-rw-r--r--Makefile56
-rw-r--r--README.md146
-rw-r--r--RELEASE-CHECKLIST33
-rw-r--r--RELEASE-CHECKLIST.md27
-rw-r--r--Setup.hs66
-rw-r--r--appveyor.yml54
-rw-r--r--benchmark/benchmark-pandoc.hs86
-rw-r--r--benchmark/weigh-pandoc.hs37
-rw-r--r--changelog10953
-rw-r--r--data/LaTeXMathML.js198
-rw-r--r--data/bash_completion.tpl78
-rw-r--r--data/docx/[Content_Types].xml2
-rw-r--r--data/docx/_rels/.rels2
-rw-r--r--data/docx/docProps/app.xml18
-rw-r--r--data/docx/docProps/core.xml2
-rw-r--r--data/docx/word/_rels/document.xml.rels2
-rw-r--r--data/docx/word/_rels/footnotes.xml.rels2
-rw-r--r--data/docx/word/document.xml2
-rw-r--r--data/docx/word/fontTable.xml52
-rw-r--r--data/docx/word/footnotes.xml26
-rw-r--r--data/docx/word/numbering.xml2
-rw-r--r--data/docx/word/settings.xml47
-rw-r--r--data/docx/word/styles.xml396
-rw-r--r--data/docx/word/theme/theme1.xml2
-rw-r--r--data/docx/word/webSettings.xml5
-rw-r--r--data/dzslides/template.html683
-rw-r--r--data/epub.css18
-rw-r--r--data/make-reference-files.hs27
-rw-r--r--data/odt/Configurations2/accelerator/current.xml0
-rw-r--r--data/odt/META-INF/manifest.xml12
-rw-r--r--data/odt/Thumbnails/thumbnail.pngbin0 -> 785 bytes
-rw-r--r--data/odt/content.xml2
-rw-r--r--data/odt/manifest.rdf18
-rw-r--r--data/odt/meta.xml18
-rw-r--r--data/odt/mimetype1
-rw-r--r--data/odt/settings.xml2
-rw-r--r--data/odt/styles.xml1104
-rw-r--r--data/sample.lua345
-rw-r--r--data/templates/README.markdown (renamed from README.markdown)0
-rw-r--r--data/templates/default.asciidoc (renamed from default.asciidoc)0
-rw-r--r--data/templates/default.beamer (renamed from default.beamer)0
-rw-r--r--data/templates/default.commonmark (renamed from default.commonmark)0
-rw-r--r--data/templates/default.context (renamed from default.context)0
-rw-r--r--data/templates/default.docbook4 (renamed from default.docbook4)0
-rw-r--r--data/templates/default.docbook5 (renamed from default.docbook5)0
-rw-r--r--data/templates/default.dokuwiki (renamed from default.dokuwiki)0
-rw-r--r--data/templates/default.dzslides (renamed from default.dzslides)0
-rw-r--r--data/templates/default.epub2 (renamed from default.epub2)0
-rw-r--r--data/templates/default.epub3 (renamed from default.epub3)0
-rw-r--r--data/templates/default.haddock (renamed from default.haddock)0
-rw-r--r--data/templates/default.html4 (renamed from default.html4)0
-rw-r--r--data/templates/default.html5 (renamed from default.html5)0
-rw-r--r--data/templates/default.icml (renamed from default.icml)0
-rw-r--r--data/templates/default.latex (renamed from default.latex)0
-rw-r--r--data/templates/default.man (renamed from default.man)0
-rw-r--r--data/templates/default.markdown (renamed from default.markdown)0
-rw-r--r--data/templates/default.mediawiki (renamed from default.mediawiki)0
-rw-r--r--data/templates/default.opendocument (renamed from default.opendocument)0
-rw-r--r--data/templates/default.opml (renamed from default.opml)0
-rw-r--r--data/templates/default.org (renamed from default.org)0
-rw-r--r--data/templates/default.plain (renamed from default.plain)0
-rw-r--r--data/templates/default.revealjs (renamed from default.revealjs)0
-rw-r--r--data/templates/default.rst (renamed from default.rst)0
-rw-r--r--data/templates/default.rtf (renamed from default.rtf)0
-rw-r--r--data/templates/default.s5 (renamed from default.s5)0
-rw-r--r--data/templates/default.slideous (renamed from default.slideous)0
-rw-r--r--data/templates/default.slidy (renamed from default.slidy)0
-rw-r--r--data/templates/default.tei (renamed from default.tei)0
-rw-r--r--data/templates/default.texinfo (renamed from default.texinfo)0
-rw-r--r--data/templates/default.textile (renamed from default.textile)0
-rw-r--r--data/templates/default.zimwiki (renamed from default.zimwiki)0
-rw-r--r--deb/GlobalSignDomainValidationCA-SHA256-G2.pem26
-rw-r--r--deb/Makefile14
-rw-r--r--deb/Vagrantfile75
-rw-r--r--deb/control.in20
-rw-r--r--deb/haskell.org.pem30
-rwxr-xr-xdeb/make_deb.sh56
-rw-r--r--doc/customizing-pandoc.md18
-rw-r--r--doc/using-the-pandoc-api.md28
-rw-r--r--lib/fonts/Makefile6
-rw-r--r--lib/fonts/parseUnicodeMapping.hs40
-rw-r--r--lib/fonts/symbol.txt256
-rw-r--r--macos/distribution.xml.in30
-rwxr-xr-xmacos/make_macos_package.sh75
-rwxr-xr-xmacos/uninstall-pandoc.pl79
-rw-r--r--man/capitalizeHeaders.hs20
-rw-r--r--man/pandoc.15092
-rw-r--r--man/pandoc.1.template10
-rw-r--r--man/removeLinks.hs9
-rw-r--r--man/removeNotes.hs9
-rw-r--r--pandoc.cabal559
-rw-r--r--pandoc.hs37
-rw-r--r--prelude/Prelude.hs26
-rw-r--r--src/Text/Pandoc.hs380
-rw-r--r--src/Text/Pandoc/App.hs1444
-rw-r--r--src/Text/Pandoc/Asciify.hs422
-rw-r--r--src/Text/Pandoc/CSS.hs43
-rw-r--r--src/Text/Pandoc/Class.hs539
-rw-r--r--src/Text/Pandoc/Compat/Time.hs30
-rw-r--r--src/Text/Pandoc/Data.hsb15
-rw-r--r--src/Text/Pandoc/Emoji.hs906
-rw-r--r--src/Text/Pandoc/Error.hs76
-rw-r--r--src/Text/Pandoc/Extensions.hs267
-rw-r--r--src/Text/Pandoc/Highlighting.hs223
-rw-r--r--src/Text/Pandoc/ImageSize.hs547
-rw-r--r--src/Text/Pandoc/Logging.hs232
-rw-r--r--src/Text/Pandoc/MIME.hs527
-rw-r--r--src/Text/Pandoc/MediaBag.hs113
-rw-r--r--src/Text/Pandoc/Options.hs217
-rw-r--r--src/Text/Pandoc/PDF.hs369
-rw-r--r--src/Text/Pandoc/Parsing.hs1329
-rw-r--r--src/Text/Pandoc/Pretty.hs557
-rw-r--r--src/Text/Pandoc/Process.hs98
-rw-r--r--src/Text/Pandoc/Readers/CommonMark.hs128
-rw-r--r--src/Text/Pandoc/Readers/DocBook.hs1055
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs626
-rw-r--r--src/Text/Pandoc/Readers/Docx/Combine.hs154
-rw-r--r--src/Text/Pandoc/Readers/Docx/Lists.hs229
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse.hs1044
-rw-r--r--src/Text/Pandoc/Readers/Docx/StyleMap.hs108
-rw-r--r--src/Text/Pandoc/Readers/Docx/Util.hs47
-rw-r--r--src/Text/Pandoc/Readers/EPUB.hs279
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs1136
-rw-r--r--src/Text/Pandoc/Readers/Haddock.hs160
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs1437
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs2119
-rw-r--r--src/Text/Pandoc/Readers/MediaWiki.hs677
-rw-r--r--src/Text/Pandoc/Readers/Native.hs71
-rw-r--r--src/Text/Pandoc/Readers/OPML.hs103
-rw-r--r--src/Text/Pandoc/Readers/Odt.hs113
-rw-r--r--src/Text/Pandoc/Readers/Odt/Arrows/State.hs253
-rw-r--r--src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs495
-rw-r--r--src/Text/Pandoc/Readers/Odt/Base.hs43
-rw-r--r--src/Text/Pandoc/Readers/Odt/ContentReader.hs929
-rw-r--r--src/Text/Pandoc/Readers/Odt/Generic/Fallible.hs260
-rw-r--r--src/Text/Pandoc/Readers/Odt/Generic/Namespaces.hs62
-rw-r--r--src/Text/Pandoc/Readers/Odt/Generic/SetMap.hs48
-rw-r--r--src/Text/Pandoc/Readers/Odt/Generic/Utils.hs171
-rw-r--r--src/Text/Pandoc/Readers/Odt/Generic/XMLConverter.hs1063
-rw-r--r--src/Text/Pandoc/Readers/Odt/Namespaces.hs110
-rw-r--r--src/Text/Pandoc/Readers/Odt/StyleReader.hs744
-rw-r--r--src/Text/Pandoc/Readers/Org.hs62
-rw-r--r--src/Text/Pandoc/Readers/Org/BlockStarts.hs137
-rw-r--r--src/Text/Pandoc/Readers/Org/Blocks.hs979
-rw-r--r--src/Text/Pandoc/Readers/Org/ExportSettings.hs172
-rw-r--r--src/Text/Pandoc/Readers/Org/Inlines.hs880
-rw-r--r--src/Text/Pandoc/Readers/Org/Meta.hs218
-rw-r--r--src/Text/Pandoc/Readers/Org/ParserState.hs259
-rw-r--r--src/Text/Pandoc/Readers/Org/Parsing.hs217
-rw-r--r--src/Text/Pandoc/Readers/Org/Shared.hs97
-rw-r--r--src/Text/Pandoc/Readers/RST.hs1354
-rw-r--r--src/Text/Pandoc/Readers/TWiki.hs525
-rw-r--r--src/Text/Pandoc/Readers/Textile.hs729
-rw-r--r--src/Text/Pandoc/Readers/Txt2Tags.hs596
-rw-r--r--src/Text/Pandoc/SelfContained.hs181
-rw-r--r--src/Text/Pandoc/Shared.hs883
-rw-r--r--src/Text/Pandoc/Slides.hs63
-rw-r--r--src/Text/Pandoc/Templates.hs77
-rw-r--r--src/Text/Pandoc/UTF8.hs121
-rw-r--r--src/Text/Pandoc/UUID.hs78
-rw-r--r--src/Text/Pandoc/Writers/AsciiDoc.hs470
-rw-r--r--src/Text/Pandoc/Writers/CommonMark.hs190
-rw-r--r--src/Text/Pandoc/Writers/ConTeXt.hs481
-rw-r--r--src/Text/Pandoc/Writers/Custom.hs322
-rw-r--r--src/Text/Pandoc/Writers/Docbook.hs440
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs1302
-rw-r--r--src/Text/Pandoc/Writers/DokuWiki.hs522
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs1257
-rw-r--r--src/Text/Pandoc/Writers/FB2.hs617
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs1069
-rw-r--r--src/Text/Pandoc/Writers/Haddock.hs370
-rw-r--r--src/Text/Pandoc/Writers/ICML.hs584
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs1388
-rw-r--r--src/Text/Pandoc/Writers/Man.hs381
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs1147
-rw-r--r--src/Text/Pandoc/Writers/Math.hs49
-rw-r--r--src/Text/Pandoc/Writers/MediaWiki.hs442
-rw-r--r--src/Text/Pandoc/Writers/Native.hs79
-rw-r--r--src/Text/Pandoc/Writers/ODT.hs210
-rw-r--r--src/Text/Pandoc/Writers/OPML.hs103
-rw-r--r--src/Text/Pandoc/Writers/OpenDocument.hs626
-rw-r--r--src/Text/Pandoc/Writers/Org.hs411
-rw-r--r--src/Text/Pandoc/Writers/RST.hs556
-rw-r--r--src/Text/Pandoc/Writers/RTF.hs412
-rw-r--r--src/Text/Pandoc/Writers/Shared.hs183
-rw-r--r--src/Text/Pandoc/Writers/TEI.hs324
-rw-r--r--src/Text/Pandoc/Writers/Texinfo.hs498
-rw-r--r--src/Text/Pandoc/Writers/Textile.hs486
-rw-r--r--src/Text/Pandoc/Writers/ZimWiki.hs396
-rw-r--r--src/Text/Pandoc/XML.hs115
-rw-r--r--stack.full.yaml25
-rw-r--r--stack.pkg.yaml22
-rw-r--r--stack.yaml12
-rw-r--r--test/Tests/Command.hs93
-rw-r--r--test/Tests/Helpers.hs136
-rw-r--r--test/Tests/Old.hs248
-rw-r--r--test/Tests/Readers/Docx.hs344
-rw-r--r--test/Tests/Readers/EPUB.hs39
-rw-r--r--test/Tests/Readers/HTML.hs33
-rw-r--r--test/Tests/Readers/LaTeX.hs226
-rw-r--r--test/Tests/Readers/Markdown.hs461
-rw-r--r--test/Tests/Readers/Odt.hs165
-rw-r--r--test/Tests/Readers/Org.hs1724
-rw-r--r--test/Tests/Readers/RST.hs174
-rw-r--r--test/Tests/Readers/Txt2Tags.hs436
-rw-r--r--test/Tests/Shared.hs40
-rw-r--r--test/Tests/Writers/AsciiDoc.hs55
-rw-r--r--test/Tests/Writers/ConTeXt.hs70
-rw-r--r--test/Tests/Writers/Docbook.hs302
-rw-r--r--test/Tests/Writers/Docx.hs151
-rw-r--r--test/Tests/Writers/HTML.hs43
-rw-r--r--test/Tests/Writers/LaTeX.hs175
-rw-r--r--test/Tests/Writers/Markdown.hs266
-rw-r--r--test/Tests/Writers/Native.hs21
-rw-r--r--test/Tests/Writers/Org.hs25
-rw-r--r--test/Tests/Writers/Plain.hs21
-rw-r--r--test/Tests/Writers/RST.hs107
-rw-r--r--test/Tests/Writers/TEI.hs43
-rw-r--r--test/bodybg.gifbin0 -> 10119 bytes
-rw-r--r--test/command/3422.md9
-rw-r--r--test/command/3432a.md19
-rw-r--r--test/command/512.md41
-rw-r--r--test/command/latex-tabular-column-specs.md24
-rw-r--r--test/command/parse-raw.md27
-rw-r--r--test/command/smart.md45
-rw-r--r--test/docbook-reader.docbook1561
-rw-r--r--test/docbook-reader.native397
-rw-r--r--test/docbook-xref.docbook70
-rw-r--r--test/docbook-xref.native29
-rw-r--r--test/docx/adjacent_links.docxbin0 -> 8538 bytes
-rw-r--r--test/docx/adjacent_links.native1
-rw-r--r--test/docx/already_auto_ident.docxbin0 -> 8463 bytes
-rw-r--r--test/docx/already_auto_ident.native2
-rw-r--r--test/docx/block_quotes.docxbin0 -> 41855 bytes
-rw-r--r--test/docx/block_quotes_parse_indent.native8
-rw-r--r--test/docx/char_styles.docxbin0 -> 30134 bytes
-rw-r--r--test/docx/char_styles.native4
-rw-r--r--test/docx/codeblock.docxbin0 -> 8465 bytes
-rw-r--r--test/docx/codeblock.native3
-rw-r--r--test/docx/comments.docxbin0 -> 17109 bytes
-rw-r--r--test/docx/comments.native4
-rw-r--r--test/docx/comments_no_comments.native4
-rw-r--r--test/docx/comments_warning.docxbin0 -> 17078 bytes
-rw-r--r--test/docx/custom-style-reference.docxbin0 -> 14846 bytes
-rw-r--r--test/docx/custom-style-roundtrip-end.native5
-rw-r--r--test/docx/custom-style-roundtrip-start.native5
-rw-r--r--test/docx/deep_normalize.docxbin0 -> 29246 bytes
-rw-r--r--test/docx/deep_normalize.native6
-rw-r--r--test/docx/definition_list.docxbin0 -> 8455 bytes
-rw-r--r--test/docx/definition_list.native7
-rw-r--r--test/docx/drop_cap.docxbin0 -> 26931 bytes
-rw-r--r--test/docx/drop_cap.native4
-rw-r--r--test/docx/dummy_item_after_list_item.docxbin0 -> 70197 bytes
-rw-r--r--test/docx/dummy_item_after_list_item.native3
-rw-r--r--test/docx/dummy_item_after_paragraph.docxbin0 -> 70234 bytes
-rw-r--r--test/docx/dummy_item_after_paragraph.native3
-rw-r--r--test/docx/enumerated_headings.docxbin0 -> 12539 bytes
-rw-r--r--test/docx/enumerated_headings.native4
-rw-r--r--test/docx/german_styled_lists.docxbin0 -> 43957 bytes
-rw-r--r--test/docx/german_styled_lists.native6
-rw-r--r--test/docx/hanging_indent.docxbin0 -> 29924 bytes
-rw-r--r--test/docx/hanging_indent.native3
-rw-r--r--test/docx/headers.docxbin0 -> 29659 bytes
-rw-r--r--test/docx/headers.native13
-rw-r--r--test/docx/i18n_blocks.docxbin0 -> 13680 bytes
-rw-r--r--test/docx/i18n_blocks.native8
-rw-r--r--test/docx/image.docxbin0 -> 35407 bytes
-rw-r--r--test/docx/image_no_embed.native2
-rw-r--r--test/docx/image_no_embed_writer.native2
-rw-r--r--test/docx/image_vml.docxbin0 -> 23559 bytes
-rw-r--r--test/docx/image_vml.native4
-rw-r--r--test/docx/inline_code.docxbin0 -> 8379 bytes
-rw-r--r--test/docx/inline_code.native1
-rw-r--r--test/docx/inline_formatting.docxbin0 -> 32322 bytes
-rw-r--r--test/docx/inline_formatting.native5
-rw-r--r--test/docx/inline_formatting_writer.native5
-rw-r--r--test/docx/inline_images.docxbin0 -> 15875 bytes
-rw-r--r--test/docx/inline_images.native2
-rw-r--r--test/docx/inline_images_writer.native2
-rw-r--r--test/docx/link_in_notes.docxbin0 -> 27357 bytes
-rw-r--r--test/docx/link_in_notes.native1
-rw-r--r--test/docx/links.docxbin0 -> 45115 bytes
-rw-r--r--test/docx/links.native7
-rw-r--r--test/docx/links_writer.native6
-rw-r--r--test/docx/lists.docxbin0 -> 31775 bytes
-rw-r--r--test/docx/lists.native18
-rw-r--r--test/docx/lists_writer.native17
-rw-r--r--test/docx/metadata.docxbin0 -> 39538 bytes
-rw-r--r--test/docx/metadata.native2
-rw-r--r--test/docx/metadata_after_normal.docxbin0 -> 56276 bytes
-rw-r--r--test/docx/metadata_after_normal.native7
-rw-r--r--test/docx/nested_anchors_in_header.docxbin0 -> 17535 bytes
-rw-r--r--test/docx/nested_anchors_in_header.native10
-rw-r--r--test/docx/normalize.docxbin0 -> 25791 bytes
-rw-r--r--test/docx/normalize.native2
-rw-r--r--test/docx/notes.docxbin0 -> 30734 bytes
-rw-r--r--test/docx/notes.native2
-rw-r--r--test/docx/numbered_header.docxbin0 -> 26129 bytes
-rw-r--r--test/docx/numbered_header.native1
-rw-r--r--test/docx/special_punctuation.docxbin0 -> 8408 bytes
-rw-r--r--test/docx/special_punctuation.native2
-rw-r--r--test/docx/table_one_row.docxbin0 -> 25251 bytes
-rw-r--r--test/docx/table_one_row.native7
-rw-r--r--test/docx/table_with_list_cell.docxbin0 -> 32615 bytes
-rw-r--r--test/docx/table_with_list_cell.native11
-rw-r--r--test/docx/tables.docxbin0 -> 49780 bytes
-rw-r--r--test/docx/tables.native36
-rw-r--r--test/docx/tabs.docxbin0 -> 12919 bytes
-rw-r--r--test/docx/tabs.native2
-rw-r--r--test/docx/track_changes_deletion.docxbin0 -> 13350 bytes
-rw-r--r--test/docx/track_changes_deletion_accept.native1
-rw-r--r--test/docx/track_changes_deletion_all.native1
-rw-r--r--test/docx/track_changes_deletion_reject.native1
-rw-r--r--test/docx/track_changes_insertion.docxbin0 -> 12956 bytes
-rw-r--r--test/docx/track_changes_insertion_accept.native1
-rw-r--r--test/docx/track_changes_insertion_all.native1
-rw-r--r--test/docx/track_changes_insertion_reject.native1
-rw-r--r--test/docx/track_changes_move.docxbin0 -> 26151 bytes
-rw-r--r--test/docx/track_changes_move_accept.native3
-rw-r--r--test/docx/track_changes_move_all.native4
-rw-r--r--test/docx/track_changes_move_reject.native3
-rw-r--r--test/docx/trailing_spaces_in_formatting.docxbin0 -> 12916 bytes
-rw-r--r--test/docx/trailing_spaces_in_formatting.native1
-rw-r--r--test/docx/unicode.docxbin0 -> 11506 bytes
-rw-r--r--test/docx/unicode.native1
-rw-r--r--test/docx/verbatim_subsuper.docxbin0 -> 10353 bytes
-rw-r--r--test/docx/verbatim_subsuper.native8
-rw-r--r--test/dokuwiki_external_images.dokuwiki1
-rw-r--r--test/dokuwiki_external_images.native1
-rw-r--r--test/dokuwiki_inline_formatting.dokuwiki14
-rw-r--r--test/dokuwiki_inline_formatting.native7
-rw-r--r--test/dokuwiki_multiblock_table.dokuwiki4
-rw-r--r--test/dokuwiki_multiblock_table.native13
-rw-r--r--test/epub/features.epubbin0 -> 66370 bytes
-rw-r--r--test/epub/features.native93
-rw-r--r--test/epub/formatting.epubbin0 -> 13460 bytes
-rw-r--r--test/epub/formatting.native402
-rw-r--r--test/epub/img.epubbin0 -> 61768 bytes
-rw-r--r--test/epub/wasteland.epubbin0 -> 101870 bytes
-rw-r--r--test/epub/wasteland.native941
-rw-r--r--test/fb2/basic.fb23
-rw-r--r--test/fb2/basic.markdown33
-rw-r--r--test/fb2/images-embedded.fb22
-rw-r--r--test/fb2/images-embedded.html14
-rw-r--r--test/fb2/images.fb22
-rw-r--r--test/fb2/images.markdown13
-rw-r--r--test/fb2/math.fb22
-rw-r--r--test/fb2/math.markdown10
-rw-r--r--test/fb2/test-small.pngbin0 -> 4090 bytes
-rw-r--r--test/fb2/test.jpgbin0 -> 153610 bytes
-rw-r--r--test/fb2/titles.fb23
-rw-r--r--test/fb2/titles.markdown10
-rw-r--r--test/haddock-reader.haddock65
-rw-r--r--test/haddock-reader.native31
-rw-r--r--test/html-reader.html708
-rw-r--r--test/html-reader.native463
-rw-r--r--test/insert1
-rw-r--r--test/lalune.jpgbin0 -> 16270 bytes
-rw-r--r--test/latex-reader.latex848
-rw-r--r--test/latex-reader.native375
-rw-r--r--test/lhs-test-markdown.native8
-rw-r--r--test/lhs-test.fragment.html+lhs15
-rw-r--r--test/lhs-test.html66
-rw-r--r--test/lhs-test.html+lhs66
-rw-r--r--test/lhs-test.latex121
-rw-r--r--test/lhs-test.latex+lhs83
-rw-r--r--test/lhs-test.markdown21
-rw-r--r--test/lhs-test.markdown+lhs19
-rw-r--r--test/lhs-test.native8
-rw-r--r--test/lhs-test.rst23
-rw-r--r--test/lhs-test.rst+lhs21
-rw-r--r--test/markdown-citations.native17
-rw-r--r--test/markdown-citations.txt39
-rw-r--r--test/markdown-reader-more.native198
-rw-r--r--test/markdown-reader-more.txt320
-rw-r--r--test/media/rId25.jpgbin0 -> 1332 bytes
-rw-r--r--test/media/rId26.jpgbin0 -> 1332 bytes
-rw-r--r--test/media/rId27.jpgbin0 -> 1332 bytes
-rw-r--r--test/mediawiki-reader.native262
-rw-r--r--test/mediawiki-reader.wiki396
-rw-r--r--test/movie.jpgbin0 -> 1046 bytes
-rw-r--r--test/odt/markdown/bold.md1
-rw-r--r--test/odt/markdown/citation.md1
-rw-r--r--test/odt/markdown/endnote.md3
-rw-r--r--test/odt/markdown/externalLink.md1
-rw-r--r--test/odt/markdown/footnote.md3
-rw-r--r--test/odt/markdown/headers.md9
-rw-r--r--test/odt/markdown/horizontalRule.md1
-rw-r--r--test/odt/markdown/image.md1
-rw-r--r--test/odt/markdown/imageIndex.md6
-rw-r--r--test/odt/markdown/imageWithCaption.md1
-rw-r--r--test/odt/markdown/italic.md1
-rw-r--r--test/odt/markdown/listBlocks.md6
-rw-r--r--test/odt/markdown/paragraph.md5
-rw-r--r--test/odt/markdown/strikeout.md1
-rw-r--r--test/odt/markdown/trackedChanges.md1
-rw-r--r--test/odt/markdown/underlined.md1
-rw-r--r--test/odt/native/blockquote.native1
-rw-r--r--test/odt/native/image.native1
-rw-r--r--test/odt/native/imageIndex.native1
-rw-r--r--test/odt/native/imageWithCaption.native1
-rw-r--r--test/odt/native/inlinedCode.native1
-rw-r--r--test/odt/native/orderedListMixed.native1
-rw-r--r--test/odt/native/orderedListRoman.native1
-rw-r--r--test/odt/native/orderedListSimple.native1
-rw-r--r--test/odt/native/referenceToChapter.native1
-rw-r--r--test/odt/native/referenceToListItem.native1
-rw-r--r--test/odt/native/referenceToText.native1
-rw-r--r--test/odt/native/simpleTable.native1
-rw-r--r--test/odt/native/simpleTableWithCaption.native1
-rw-r--r--test/odt/native/tableWithContents.native1
-rw-r--r--test/odt/native/textMixedStyles.native5
-rw-r--r--test/odt/native/unicode.native1
-rw-r--r--test/odt/native/unorderedList.native1
-rw-r--r--test/odt/odt/blockquote.odtbin0 -> 8594 bytes
-rw-r--r--test/odt/odt/bold.odtbin0 -> 10377 bytes
-rw-r--r--test/odt/odt/citation.odtbin0 -> 10842 bytes
-rw-r--r--test/odt/odt/endnote.odtbin0 -> 10950 bytes
-rw-r--r--test/odt/odt/expression.odtbin0 -> 10916 bytes
-rw-r--r--test/odt/odt/expressionUnevaluated.odtbin0 -> 10829 bytes
-rw-r--r--test/odt/odt/externalLink.odtbin0 -> 10735 bytes
-rw-r--r--test/odt/odt/footnote.odtbin0 -> 10843 bytes
-rw-r--r--test/odt/odt/formula.odtbin0 -> 14252 bytes
-rw-r--r--test/odt/odt/headers.odtbin0 -> 10515 bytes
-rw-r--r--test/odt/odt/hiddenTextByStyle.odtbin0 -> 10798 bytes
-rw-r--r--test/odt/odt/hiddenTextByVariable.odtbin0 -> 10788 bytes
-rw-r--r--test/odt/odt/horizontalRule.odtbin0 -> 10130 bytes
-rw-r--r--test/odt/odt/image.odtbin0 -> 33360 bytes
-rw-r--r--test/odt/odt/imageIndex.odtbin0 -> 34417 bytes
-rw-r--r--test/odt/odt/imageWithCaption.odtbin0 -> 33811 bytes
-rw-r--r--test/odt/odt/inlinedCode.odtbin0 -> 10141 bytes
-rw-r--r--test/odt/odt/italic.odtbin0 -> 10426 bytes
-rw-r--r--test/odt/odt/listBlocks.odtbin0 -> 10565 bytes
-rw-r--r--test/odt/odt/orderedListMixed.odtbin0 -> 11970 bytes
-rw-r--r--test/odt/odt/orderedListRoman.odtbin0 -> 11730 bytes
-rw-r--r--test/odt/odt/orderedListSimple.odtbin0 -> 11817 bytes
-rw-r--r--test/odt/odt/paragraph.odtbin0 -> 8538 bytes
-rw-r--r--test/odt/odt/referenceAllInOne.odtbin0 -> 10878 bytes
-rw-r--r--test/odt/odt/referenceToChapter.odtbin0 -> 10487 bytes
-rw-r--r--test/odt/odt/referenceToListItem.odtbin0 -> 10855 bytes
-rw-r--r--test/odt/odt/referenceToText.odtbin0 -> 10208 bytes
-rw-r--r--test/odt/odt/simpleTable.odtbin0 -> 10705 bytes
-rw-r--r--test/odt/odt/simpleTableWithCaption.odtbin0 -> 10396 bytes
-rw-r--r--test/odt/odt/strikeout.odtbin0 -> 10582 bytes
-rw-r--r--test/odt/odt/table.odtbin0 -> 10763 bytes
-rw-r--r--test/odt/odt/tableWithCaption.odtbin0 -> 10623 bytes
-rw-r--r--test/odt/odt/tableWithContents.odtbin0 -> 8817 bytes
-rw-r--r--test/odt/odt/textMixedStyles.odtbin0 -> 10571 bytes
-rw-r--r--test/odt/odt/trackedChanges.odtbin0 -> 11135 bytes
-rw-r--r--test/odt/odt/underlined.odtbin0 -> 10513 bytes
-rw-r--r--test/odt/odt/unicode.odtbin0 -> 11787 bytes
-rw-r--r--test/odt/odt/unorderedList.odtbin0 -> 9505 bytes
-rw-r--r--test/odt/odt/variable.odtbin0 -> 10851 bytes
-rw-r--r--test/opml-reader.native66
-rw-r--r--test/opml-reader.opml83
-rw-r--r--test/pipe-tables.native115
-rw-r--r--test/pipe-tables.txt82
-rw-r--r--test/rst-reader.native335
-rw-r--r--test/rst-reader.rst633
-rw-r--r--test/s5-basic.html56
-rw-r--r--test/s5-fancy.html257
-rw-r--r--test/s5-fragment.html9
-rw-r--r--test/s5-inserts.html34
-rw-r--r--test/s5.native8
-rw-r--r--test/tables-rstsubset.native114
-rw-r--r--test/tables.asciidoc67
-rw-r--r--test/tables.context175
-rw-r--r--test/tables.docbook4432
-rw-r--r--test/tables.docbook5432
-rw-r--r--test/tables.dokuwiki47
-rw-r--r--test/tables.fb23
-rw-r--r--test/tables.haddock76
-rw-r--r--test/tables.html4204
-rw-r--r--test/tables.html5204
-rw-r--r--test/tables.icml757
-rw-r--r--test/tables.latex168
-rw-r--r--test/tables.man267
-rw-r--r--test/tables.markdown78
-rw-r--r--test/tables.mediawiki146
-rw-r--r--test/tables.native114
-rw-r--r--test/tables.opendocument397
-rw-r--r--test/tables.org51
-rw-r--r--test/tables.plain78
-rw-r--r--test/tables.rst90
-rw-r--r--test/tables.rtf360
-rw-r--r--test/tables.tei171
-rw-r--r--test/tables.texinfo158
-rw-r--r--test/tables.textile167
-rw-r--r--test/tables.txt75
-rw-r--r--test/tables.zimwiki56
-rw-r--r--test/test-pandoc.hs69
-rw-r--r--test/testsuite.native411
-rw-r--r--test/testsuite.txt730
-rw-r--r--test/textile-reader.native176
-rw-r--r--test/textile-reader.textile278
-rw-r--r--test/twiki-reader.native174
-rw-r--r--test/twiki-reader.twiki221
-rw-r--r--test/txt2tags.native552
-rw-r--r--test/txt2tags.t2t797
-rw-r--r--test/writer.asciidoc693
-rw-r--r--test/writer.context888
-rw-r--r--test/writer.docbook41422
-rw-r--r--test/writer.docbook51397
-rw-r--r--test/writer.dokuwiki642
-rw-r--r--test/writer.fb23
-rw-r--r--test/writer.haddock660
-rw-r--r--test/writer.html4546
-rw-r--r--test/writer.html5548
-rw-r--r--test/writer.icml3317
-rw-r--r--test/writer.latex967
-rw-r--r--test/writer.man795
-rw-r--r--test/writer.markdown746
-rw-r--r--test/writer.mediawiki653
-rw-r--r--test/writer.native411
-rw-r--r--test/writer.opendocument1539
-rw-r--r--test/writer.opml72
-rw-r--r--test/writer.org855
-rw-r--r--test/writer.plain695
-rw-r--r--test/writer.rst892
-rw-r--r--test/writer.rtf451
-rw-r--r--test/writer.tei861
-rw-r--r--test/writer.texinfo1061
-rw-r--r--test/writer.textile723
-rw-r--r--test/writer.zimwiki623
-rw-r--r--test/writers-lang-and-dir.context109
-rw-r--r--test/writers-lang-and-dir.latex149
-rw-r--r--test/writers-lang-and-dir.native23
-rw-r--r--tools/extract-changes.hs9
-rwxr-xr-xtools/github-upload.sh18
-rw-r--r--trypandoc/Makefile14
-rw-r--r--trypandoc/index.html143
-rw-r--r--trypandoc/trypandoc.hs101
-rw-r--r--windows/AdvancedWelcomeEulaDlg_Custom.wxs90
-rw-r--r--windows/Pandoc-en-us.wxl14
-rw-r--r--windows/WixUI_Advanced_Custom.wxs142
-rw-r--r--windows/make-windows-installer.bat29
-rw-r--r--windows/pandoc.wxs188
547 files changed, 117852 insertions, 0 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..5f40572b0
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,16 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_style = space
+indent_size = 2
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.{markdown,md}]
+trim_trailing_whitespace = false
+
+[tests/*]
+insert_final_newline = false
+trim_trailing_whitespace = false
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..32ef66e8b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,25 @@
+*~
+deb/.vagrant
+dist/*
+MANUAL.*
+!MANUAL.txt
+.configure-stamp
+.cabal-sandbox
+cabal.sandbox.config
+pandoc.cabal.orig
+man/man?/*.1
+man/man?/*.5
+man/man?/*.html
+*.diff
+*.o
+*.hi
+*.pyc
+/COPYING.rtf
+/COPYRIGHT.txt
+/cabal-dev/
+/windows/*.msi
+/windows/*.wixpdb
+windows/*.wixobj
+data/reference.docx
+data/reference.odt
+.stack-work
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 000000000..dea005e41
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "templates"]
+ path = data/templates
+ url = https://github.com/jgm/pandoc-templates.git
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 000000000..8f3bdf536
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,130 @@
+# This .travis.yml is modified from the sample at
+# https://docs.haskellstack.org/en/stable/GUIDE/#travis-with-caching
+
+# Use new container infrastructure to enable caching
+sudo: false
+
+# Do not choose a language; we provide our own build tools.
+language: generic
+
+# Caching so the next build will be fast too.
+cache:
+ directories:
+ - $HOME/.ghc
+ - $HOME/.cabal
+ - $HOME/.stack
+
+# The different configurations we want to test. We have BUILD=cabal which uses
+# cabal-install, and BUILD=stack which uses Stack. More documentation on each
+# of those below.
+#
+# We set the compiler values here to tell Travis to use a different
+# cache file per set of arguments.
+#
+# If you need to have different apt packages for each combination in the
+# matrix, you can use a line such as:
+# addons: {apt: {packages: [libfcgi-dev,libgmp-dev]}}
+#
+# fast_finish: build successful when every builds not in allow_failure are finished
+# i.e. not waiting any of the allow_failure to finish
+matrix:
+ include:
+ # We grab the appropriate GHC and cabal-install versions from hvr's PPA. See:
+ # https://github.com/hvr/multi-ghc-travis
+ - env: BUILD=cabal GHCVER=7.8.4 CABALVER=1.18
+ compiler: ": #GHC 7.8.4"
+ addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4,happy-1.19.5], sources: [hvr-ghc]}}
+ - env: BUILD=cabal GHCVER=7.10.3 CABALVER=1.22
+ compiler: ": #GHC 7.10.3"
+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5], sources: [hvr-ghc]}}
+
+ - env: BUILD=cabal GHCVER=8.0.2 CABALVER=1.24
+ compiler: ": #GHC 8.0.2"
+ addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.2,happy-1.19.5], sources: [hvr-ghc]}}
+
+ # Build with the newest GHC and cabal-install. This is an accepted failure,
+ # see below.
+ - env: BUILD=cabal GHCVER=head CABALVER=head
+ compiler: ": #GHC HEAD"
+ addons: {apt: {packages: [cabal-install-head,ghc-head], sources: [hvr-ghc]}}
+
+ # The Stack builds. We can pass in arbitrary Stack arguments via the ARGS
+ # variable, such as using --stack-yaml to point to a different file.
+ - env: BUILD=stack ARGS="--resolver lts-8"
+ compiler: ": #stack 8.0.2"
+ addons: {apt: {packages: [ghc-8.0.2], sources: [hvr-ghc]}}
+
+ # Nightly builds are allowed to fail
+ - env: BUILD=stack ARGS="--resolver nightly"
+ compiler: ": #stack nightly"
+ addons: {apt: {packages: [libgmp-dev]}}
+
+ - env: BUILD=stack ARGS="--resolver lts-8"
+ compiler: ": #stack 8.0.2 osx"
+ os: osx
+
+ # - env: BUILD=stack ARGS="--resolver nightly"
+ # compiler: ": #stack nightly osx"
+ # os: osx
+
+ allow_failures:
+ - env: BUILD=cabal GHCVER=head CABALVER=head
+ - env: BUILD=stack ARGS="--resolver nightly"
+
+ fast_finish: true
+
+before_install:
+# Using compiler above sets CC to an invalid value, so unset it
+- unset CC
+
+# We want to always allow newer versions of packages when building on GHC HEAD
+- CABALARGS=""
+- if [ "x$GHCVER" = "xhead" ]; then CABALARGS=--allow-newer; fi
+- export PATH=$PATH:/opt/happy/1.19.5/bin/:/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.local/bin
+# Download and unpack the stack executable
+- |
+ if [[ $BUILD == "stack" ]]; then
+ mkdir -p ~/.local/bin
+ if [ `uname` = "Darwin" ]
+ then
+ curl --insecure -L https://www.stackage.org/stack/osx-x86_64 | tar xz --strip-components=1 --include '*/stack' -C ~/.local/bin
+ else
+ curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
+ fi
+ fi
+
+install:
+- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
+- if [ -f configure.ac ]; then autoreconf -i; fi
+- |
+ case "$BUILD" in
+ stack)
+ ulimit -n 4096
+ stack --no-terminal --install-ghc $ARGS test --flag 'aeson:fast' --only-dependencies --fast
+ ;;
+ cabal)
+ cabal --version
+ travis_retry cabal update
+ cabal install -j --only-dependencies -ffast --enable-tests --enable-benchmarks --force-reinstalls --ghc-options=-O0 --reorder-goals --max-backjumps=-1 $CABALARGS
+ ;;
+ esac
+
+script:
+- |
+ case "$BUILD" in
+ stack)
+ ulimit -n 4096
+ stack --no-terminal $ARGS test --flag 'aeson:fast' --haddock --no-haddock-deps --ghc-options="-O0 -Wall -fno-warn-unused-do-bind -Werror"
+ ;;
+ cabal)
+ cabal configure --enable-tests --enable-benchmarks -v2 -ffast --ghc-options="-O0 -Wall -fno-warn-unused-do-bind -Werror" && \
+ cabal build -j && \
+ cabal check && \
+ cabal test -j && \
+ cabal copy && \
+ cabal sdist && \
+ SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz && \
+ cd dist && \
+ cabal install -j -v2 -ffast --ghc-options="-O0 -Wall -fno-warn-unused-do-bind -Werror" --force-reinstall "$SRC_TGZ"
+ ;;
+ esac
diff --git a/BUGS b/BUGS
new file mode 100644
index 000000000..037e4c799
--- /dev/null
+++ b/BUGS
@@ -0,0 +1,4 @@
+To view a list of known bugs, or to enter a bug report, please use
+Pandoc's issue tracker: <https://github.com/jgm/pandoc/issues>.
+
+See also CONTRIBUTING.md.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..9feb0b6a0
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,319 @@
+Contributing to pandoc
+======================
+
+Found a bug?
+------------
+
+Bug reports are welcome! Please report all bugs on pandoc's github
+[issue tracker].
+
+Before you submit a bug report, search the (open *and* closed) issues to make
+sure the issue hasn't come up before. Also, check the [User's Guide] and [FAQs]
+for anything relevant.
+
+Make sure you can reproduce the bug with the latest released version of pandoc
+(or, even better, the development version).
+
+Your report should give detailed, *reproducible* instructions, including
+
+ * the pandoc version (check using `pandoc -v`)
+ * the exact command line used
+ * the exact input used
+ * the output received
+ * the output you expected instead
+
+A small test case (just a few lines) is ideal. If your input is large,
+try to whittle it down to a *minimum working example*.
+
+Out of scope?
+-------------
+
+A less than perfect conversion does not necessarily mean there's
+a bug in pandoc. Quoting from the MANUAL:
+
+> Because Pandoc's intermediate representation of a document is less
+> expressive than many of the formats it converts between, one should
+> not expect perfect conversions between every format and every other.
+> Pandoc attempts to preserve the structural elements of a document, but
+> not formatting details such as margin size. And some document elements,
+> such as complex tables, may not fit into Pandoc's simple document
+> model. While conversions from Pandoc's Markdown to all formats aspire
+> to be perfect, conversions from formats more expressive than Pandoc's
+> Markdown can be expected to be lossy.
+
+For example, both docx and odt can represent margin size, but because
+pandoc's internal document model does not contain a representation of
+margin size, this information will be lost on converting from docx
+to odt. (You can, however, customize margin size using `--reference-odt`.)
+
+So before submitting a bug report, consider whether it might be
+"out of scope." If it concerns a feature of documents that isn't
+representable in pandoc's Markdown, then it very likely is.
+(If in doubt, you can always ask on pandoc-discuss.)
+
+Fixing bugs from the issue tracker
+----------------------------------
+
+Almost all the bugs on the issue tracker have one or more associated
+tags. These are used to indicate the *complexity* and *nature* of a
+bug. There is not yet a way to indicate priority. An up to date
+summary of issues can be found [here](https://github.com/jgm/pandoc/labels).
+
+* [beginner-friendly] — The perfect starting point for new contributors. The
+ issue is generic and can be resolved without deep knowledge of the code
+ base.
+* [enhancement] — A feature which would be desirable. We recommend
+ you discuss any proposed enhancement on pandoc-discuss before
+ writing code.
+* [bug] — A problem which needs to be fixed.
+* [complexity:low] — The fix should only be a couple of lines.
+* [complexity:high] — The fix might require structural changes or in depth
+ knowledge of the code base.
+* [new:reader] — A request to add a new input format.
+* [new:writer] — A request to add a new output format.
+* [docs] — A discrepency, or ambiguity in the documentation.
+* [status:in-progress] — Someone is actively working on or planning to work on the
+ ticket.
+* [status:more-discussion-needed] — It is unclear what the correct approach
+ to solving the ticket is. Before starting on tickets such as this it
+ would be advisable to post on the ticket.
+* [status:more-info-needed] — We require more information from a user before
+ we can classify a report properly.
+
+Issues related to a specific format are tagged accordingly, e.g. feature request
+or bug reports related to Markdown are labelled with [format:markdown].
+
+Have an idea for a new feature?
+-------------------------------
+
+First, search [pandoc-discuss] and the issue tracker (both open and closed
+issues) to make sure that the idea has not been discussed before.
+
+Explain the rationale for the feature you're requesting. Why would this
+feature be useful? Consider also any possible drawbacks, including backwards
+compatibility, new library dependencies, and performance issues.
+
+It is best to discuss a potential new feature on [pandoc-discuss]
+before opening an issue.
+
+Patches and pull requests
+-------------------------
+
+Patches and pull requests are welcome. Before you put time into a nontrivial
+patch, it is a good idea to discuss it on [pandoc-discuss], especially if it is
+for a new feature (rather than fixing a bug).
+
+Please follow these guidelines:
+
+1. Each patch (commit) should make a single logical change (fix a bug, add
+ a feature, clean up some code, add documentation). Everything
+ related to that change should be included (including tests and
+ documentation), and nothing unrelated should be included.
+
+2. The first line of the commit message should be a short description
+ of the whole commit (ideally <= 50 characters). Then there should
+ be a blank line, followed by a more detailed description of the
+ change.
+
+3. Follow the stylistic conventions you find in the existing
+ pandoc code. Use spaces, not tabs, and wrap code to 80 columns.
+ Always include type signatures for top-level functions.
+ Consider installing [EditorConfig], this will help you to follow the
+ coding style prevalent in pandoc.
+
+4. Your code should compile without warnings (`-Wall` clean).
+
+5. Run the tests to make sure your code does not introduce new bugs.
+ (See below under [Tests](#tests).) All tests should pass.
+
+6. It is a good idea to add test cases for the bug you are fixing. (See
+ below under [Tests](#tests).) If you are adding a new writer or reader,
+ you must include tests.
+
+7. If you are adding a new feature, include updates to MANUAL.txt.
+
+8. All code must be released under the general license governing pandoc
+ (GPL v2).
+
+9. It is better not to introduce new dependencies. Dependencies on
+ external C libraries should especially be avoided.
+
+10. We aim for compatibility with ghc versions from 7.8.3 to the
+ latest release. All pull requests and commits are tested
+ automatically on travis-ci.org, using GHC versions in the
+ `Tested-With` stanza of `pandoc.cabal`. We currently relax
+ the "`-Wall` clean" requirement for GHC 7.10.x, because
+ there are so many warnings relating to the addition of type
+ classes to the Prelude.
+
+Tests
+-----
+
+Tests can be run as follows:
+
+ cabal install --only-dependencies --enable-tests
+ cabal configure --enable-tests
+ cabal build
+ cabal test
+
+or, if you're using [stack],
+
+ stack setup
+ stack test
+
+The test program is `tests/test-pandoc.hs`.
+
+Benchmarks
+----------
+
+To run benchmarks with cabal:
+
+ cabal configure --enable-benchmarks
+ cabal build
+ cabal bench
+
+With stack:
+
+ stack bench
+
+You can also build pandoc with the `weigh-pandoc` flag and
+run `weigh-pandoc` to get some statistics on memory usage.
+(Eventually this should be incorporated into the benchmark
+suite.)
+
+Using the REPL
+--------------
+
+With a recent version of cabal, you can do `cabal repl` and get
+a ghci REPL for working with pandoc. With [stack], use
+`cabal ghci`.
+
+We recommend using the following `.ghci` file (which can be
+placed in the source directory):
+
+```
+:set -fobject-code
+:set -XTypeSynonymInstances
+:set -XScopedTypeVariables
+:set -XOverloadedStrings
+```
+
+Profiling
+---------
+
+To use the GHC profiler with cabal:
+
+ cabal clean
+ cabal install --enable-library-profiling --enable-executable-profiling
+ pandoc +RTS -p -RTS [file]...
+ less pandoc.prof
+
+With stack:
+
+ stack clean
+ stack install --profile
+ pandoc +RTS -p -RTS [file]...
+ less pandoc.prof
+
+The code
+--------
+
+Pandoc has a publicly accessible git repository on
+github: <http://github.com/jgm/pandoc>. To get a local copy of the source:
+
+ git clone git://github.com/jgm/pandoc.git
+
+Note: after cloning the repository (and in the future after pulling from it),
+you should do
+
+ git submodule update --init
+
+to pull in changes to the templates (`data/templates/`). You can automate this
+by creating a file `.git/hooks/post-merge` with the contents:
+
+ #!/bin/sh
+ git submodule update --init
+
+and making it executable:
+
+ chmod +x .git/hooks/post-merge
+
+The source for the main pandoc program is `pandoc.hs`. The source for
+the pandoc library is in `src/`, the source for the tests is in
+`tests/`, and the source for the benchmarks is in `benchmark/`.
+
+The modules `Text.Pandoc.Definition`, `Text.Pandoc.Builder`, and
+`Text.Pandoc.Generic` are in a separate library `pandoc-types`. The code can
+be found in a <http://github.com/jgm/pandoc-types>.
+
+To build pandoc, you will need a working installation of the
+[Haskell platform].
+
+The library is structured as follows:
+
+ - `Text.Pandoc` is a top-level module that exports what is needed
+ by most users of the library. Any patches that add new readers
+ or writers will need to make changes here, too.
+ - `Text.Pandoc.Definition` (in `pandoc-types`) defines the types
+ used for representing a pandoc document.
+ - `Text.Pandoc.Builder` (in `pandoc-types`) provides functions for
+ building pandoc documents programatically.
+ - `Text.Pandoc.Generics` (in `pandoc-types`) provides functions allowing
+ you to promote functions that operate on parts of pandoc documents
+ to functions that operate on whole pandoc documents, walking the
+ tree automatically.
+ - `Text.Pandoc.Readers.*` are the readers, and `Text.Pandoc.Writers.*`
+ are the writers.
+ - `Text.Pandoc.Biblio` is a utility module for formatting citations
+ using citeproc-hs.
+ - `Text.Pandoc.Data` is used to embed data files when the `embed_data_files`
+ cabal flag is used. It is generated from `src/Text/Pandoc/Data.hsb` using
+ the preprocessor [hsb2hs].
+ - `Text.Pandoc.Highlighting` contains the interface to the
+ skylighting library, which is used for code syntax highlighting.
+ - `Text.Pandoc.ImageSize` is a utility module containing functions for
+ calculating image sizes from the contents of image files.
+ - `Text.Pandoc.MIME` contains functions for associating MIME types
+ with extensions.
+ - `Text.Pandoc.Options` defines reader and writer options.
+ - `Text.Pandoc.PDF` contains functions for producing a PDF from a
+ LaTeX source.
+ - `Text.Pandoc.Parsing` contains parsing functions used in multiple readers.
+ - `Text.Pandoc.Pretty` is a pretty-printing library specialized to
+ the needs of pandoc.
+ - `Text.Pandoc.SelfContained` contains functions for making an HTML
+ file "self-contained," by importing remotely linked images, CSS,
+ and javascript and turning them into `data:` URLs.
+ - `Text.Pandoc.Shared` is a grab-bag of shared utility functions.
+ - `Text.Pandoc.Writers.Shared` contains utilities used in writers only.
+ - `Text.Pandoc.Slides` contains functions for splitting a markdown document
+ into slides, using the conventions described in the MANUAL.
+ - `Text.Pandoc.Templates` defines pandoc's templating system.
+ - `Text.Pandoc.UTF8` contains functions for converting text to and from
+ UTF8 bytestrings (strict and lazy).
+ - `Text.Pandoc.Asciify` contains functions to derive ascii versions of
+ identifiers that use accented characters.
+ - `Text.Pandoc.UUID` contains functions for generating UUIDs.
+ - `Text.Pandoc.XML` contains functions for formatting XML.
+
+[pandoc-discuss]: http://groups.google.com/group/pandoc-discuss
+[issue tracker]: https://github.com/jgm/pandoc/issues
+[User's Guide]: http://pandoc.org/MANUAL.html
+[FAQs]: http://pandoc.org/faqs.html
+[EditorConfig]: http://editorconfig.org/
+[Haskell platform]: http://www.haskell.org/platform/
+[hsb2hs]: http://hackage.haskell.org/package/hsb2hs
+[beginner-friendly]: https://github.com/jgm/pandoc/labels/beginner-friendly
+[enhancement]: https://github.com/jgm/pandoc/labels/enhancement
+[bug]: https://github.com/jgm/pandoc/labels/bug
+[complexity:low]: https://github.com/jgm/pandoc/labels/complexity:low
+[complexity:high]: https://github.com/jgm/pandoc/labels/complexity:high
+[docs]: https://github.com/jgm/pandoc/labels/docs
+[format:markdown]: https://github.com/jgm/pandoc/labels/format:markdown
+[new:reader]: https://github.com/jgm/pandoc/labels/new:reader
+[new:writer]: https://github.com/jgm/pandoc/labels/new:writer
+[status:in-progress]: https://github.com/jgm/pandoc/labels/status:in-progress
+[status:more-discussion-needed]: https://github.com/jgm/pandoc/labels/status:more-discussion-needed
+[status:more-info-needed]: https://github.com/jgm/pandoc/labels/status:more-info-needed
+[stack]: https://github.com/commercialhaskell/stack
+
diff --git a/COPYING.md b/COPYING.md
new file mode 100644
index 000000000..af5153d8f
--- /dev/null
+++ b/COPYING.md
@@ -0,0 +1,361 @@
+### GNU GENERAL PUBLIC LICENSE
+
+Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+### Preamble
+
+The licenses for most software are designed to take away your freedom
+to share and change it. By contrast, the GNU General Public License is
+intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on,
+we want its recipients to know that what they have is not the
+original, so that any problems introduced by others will not reflect
+on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at
+all.
+
+The precise terms and conditions for copying, distribution and
+modification follow.
+
+### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+**0.** This License applies to any program or other work which
+contains a notice placed by the copyright holder saying it may be
+distributed under the terms of this General Public License. The
+"Program", below, refers to any such program or work, and a "work
+based on the Program" means either the Program or any derivative work
+under copyright law: that is to say, a work containing the Program or
+a portion of it, either verbatim or with modifications and/or
+translated into another language. (Hereinafter, translation is
+included without limitation in the term "modification".) Each licensee
+is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the Program
+(independent of having been made by running the Program). Whether that
+is true depends on what the Program does.
+
+**1.** You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a
+fee.
+
+**2.** You may modify your copy or copies of the Program or any
+portion of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+
+**a)** You must cause the modified files to carry prominent notices
+stating that you changed the files and the date of any change.
+
+
+**b)** You must cause any work that you distribute or publish, that in
+whole or in part contains or is derived from the Program or any part
+thereof, to be licensed as a whole at no charge to all third parties
+under the terms of this License.
+
+
+**c)** If the modified program normally reads commands interactively
+when run, you must cause it, when started running for such interactive
+use in the most ordinary way, to print or display an announcement
+including an appropriate copyright notice and a notice that there is
+no warranty (or else, saying that you provide a warranty) and that
+users may redistribute the program under these conditions, and telling
+the user how to view a copy of this License. (Exception: if the
+Program itself is interactive but does not normally print such an
+announcement, your work based on the Program is not required to print
+an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+**3.** You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+
+**a)** Accompany it with the complete corresponding machine-readable
+source code, which must be distributed under the terms of Sections 1
+and 2 above on a medium customarily used for software interchange; or,
+
+
+**b)** Accompany it with a written offer, valid for at least three
+years, to give any third party, for a charge no more than your cost of
+physically performing source distribution, a complete machine-readable
+copy of the corresponding source code, to be distributed under the
+terms of Sections 1 and 2 above on a medium customarily used for
+software interchange; or,
+
+
+**c)** Accompany it with the information you received as to the offer
+to distribute corresponding source code. (This alternative is allowed
+only for noncommercial distribution and only if you received the
+program in object code or executable form with such an offer, in
+accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+**4.** You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt otherwise
+to copy, modify, sublicense or distribute the Program is void, and
+will automatically terminate your rights under this License. However,
+parties who have received copies, or rights, from you under this
+License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+**5.** You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+**6.** Each time you redistribute the Program (or any work based on
+the Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+**7.** If, as a consequence of a court judgment or allegation of
+patent infringement or for any other reason (not limited to patent
+issues), conditions are imposed on you (whether by court order,
+agreement or otherwise) that contradict the conditions of this
+License, they do not excuse you from the conditions of this License.
+If you cannot distribute so as to satisfy simultaneously your
+obligations under this License and any other pertinent obligations,
+then as a consequence you may not distribute the Program at all. For
+example, if a patent license would not permit royalty-free
+redistribution of the Program by all those who receive copies directly
+or indirectly through you, then the only way you could satisfy both it
+and this License would be to refrain entirely from distribution of the
+Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+**8.** If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+**9.** The Free Software Foundation may publish revised and/or new
+versions of the General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Program does not specify a
+version number of this License, you may choose any version ever
+published by the Free Software Foundation.
+
+**10.** If you wish to incorporate parts of the Program into other
+free programs whose distribution conditions are different, write to
+the author to ask for permission. For software which is copyrighted by
+the Free Software Foundation, write to the Free Software Foundation;
+we sometimes make exceptions for this. Our decision will be guided by
+the two goals of preserving the free status of all derivatives of our
+free software and of promoting the sharing and reuse of software
+generally.
+
+**NO WARRANTY**
+
+**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+### END OF TERMS AND CONDITIONS
+
+### How to Apply These Terms to Your New Programs
+
+If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these
+terms.
+
+To do so, attach the following notices to the program. It is safest to
+attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ one line to give the program's name and an idea of what it does.
+ Copyright (C) yyyy name of author
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+Also add information on how to contact you by electronic and paper
+mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
+ type `show w'. This is free software, and you are welcome
+ to redistribute it under certain conditions; type `show c'
+ for details.
+
+The hypothetical commands \`show w' and \`show c' should show the
+appropriate parts of the General Public License. Of course, the
+commands you use may be called something other than \`show w' and
+\`show c'; they could even be mouse-clicks or menu items--whatever
+suits your program.
+
+You should also get your employer (if you work as a programmer) or
+your school, if any, to sign a "copyright disclaimer" for the program,
+if necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright
+ interest in the program `Gnomovision'
+ (which makes passes at compilers) written
+ by James Hacker.
+
+ signature of Ty Coon, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library,
+you may consider it more useful to permit linking proprietary
+applications with the library. If this is what you want to do, use the
+[GNU Lesser General Public
+License](http://www.gnu.org/licenses/lgpl.html) instead of this
+License. \ No newline at end of file
diff --git a/COPYRIGHT b/COPYRIGHT
new file mode 100644
index 000000000..70781a2de
--- /dev/null
+++ b/COPYRIGHT
@@ -0,0 +1,108 @@
+Pandoc
+Copyright (C) 2006-2017 John MacFarlane <jgm at berkeley dot edu>
+
+This code is released under the [GPL], version 2 or later:
+
+ 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+The GNU General Public License is available in the file COPYING.md in
+the source distribution. On Debian systems, the complete text of the
+GPL can be found in `/usr/share/common-licenses/GPL`.
+
+[GPL]: http://www.gnu.org/copyleft/gpl.html
+
+Pandoc's complete source code is available from the [Pandoc home page].
+
+[Pandoc home page]: http://pandoc.org
+
+Pandoc includes some code from other authors. The copyright and license
+statements for these sources are included below. All are GPL-compatible
+licenses.
+
+----------------------------------------------------------------------
+src/Text/Pandoc/Writers/Texinfo.hs
+Copyright (C) 2008-2015 John MacFarlane and Peter Wang
+
+Released under the GNU General Public License version 2 or later.
+
+----------------------------------------------------------------------
+src/Text/Pandoc/Writers/OpenDocument.hs
+Copyright (C) 2008-2015 Andrea Rossato and John MacFarlane
+
+Released under the GNU General Public License version 2 or later.
+
+----------------------------------------------------------------------
+src/Text/Pandoc/Writers/Org.hs
+Copyright (C) 2010-2015 Puneeth Chaganti and John MacFarlane
+
+Released under the GNU General Public License version 2 or later.
+
+----------------------------------------------------------------------
+src/Text/Pandoc/Readers/Textile.hs
+Copyright (C) 2010-2015 Paul Rivier and John MacFarlane
+
+Released under the GNU General Public License version 2 or later.
+
+----------------------------------------------------------------------
+src/Text/Pandoc/Readers/Org.hs
+tests/Tests/Readers/Org.hs
+Copyright (C) 2014-2015 Albert Krewinkel
+
+Released under the GNU General Public License version 2 or later.
+
+----------------------------------------------------------------------
+data/LaTeXMathML.js
+Adapted by Jeff Knisely and Douglas Woodall from
+ASCIIMathML.js v. 1.4.7
+Copyright (C) 2005 Peter Jipsen
+
+Released under the GNU General Public License version 2 or later.
+
+----------------------------------------------------------------------
+data/MathMLinHTML.js
+Copyright (C) 2004 Peter Jipsen http://www.chapman.edu/~jipsen
+
+Released under the GNU General Public License version 2 or later.
+
+------------------------------------------------------------------------
+The dzslides template contains javascript and CSS from Paul Rouget's
+dzslides template.
+http://github.com/paulrouget/dzslides
+
+Released under the Do What the Fuck You Want To Public License.
+
+------------------------------------------------------------------------
+Pandoc embeds a lua interpreter (via hslua).
+
+Copyright © 1994–2015 Lua.org, PUC-Rio.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/INSTALL.md b/INSTALL.md
new file mode 100644
index 000000000..4f833b471
--- /dev/null
+++ b/INSTALL.md
@@ -0,0 +1,363 @@
+# Installing pandoc
+
+## Windows
+
+ - There is a package installer at pandoc's [download page].
+
+ - For PDF output, you'll also need to install LaTeX.
+ We recommend [MiKTeX](http://miktex.org/).
+
+ - If you'd prefer, you can extract the pandoc and pandoc-citeproc
+ executables from the MSI and copy them directly to any directory,
+ without running the installer. Here is an example showing how to
+ extract the executables from the pandoc-1.19.1 installer and copy
+ them to `C:\Utils\Console\`:
+
+ mkdir "%TEMP%\pandoc\"
+ start /wait msiexec.exe /a pandoc-1.19.1-windows.msi /qn targetdir="%TEMP%\pandoc\"
+ copy /y "%TEMP%\pandoc\pandoc.exe" C:\Utils\Console\
+ copy /y "%TEMP%\pandoc\pandoc-citeproc.exe" C:\Utils\Console\
+ rmdir /s /q "%TEMP%\pandoc\"
+
+## MacOS
+
+ - There is a package installer at pandoc's [download page].
+ If you later want to uninstall the package, you can do so
+ by downloading [this script][uninstaller]
+ and running it with `perl uninstall-pandoc.pl`.
+
+ - It is possible to extract the pandoc and pandoc-citeproc
+ executables from the MacOS pkg file, if you'd rather not run
+ the installer. To do this (for the version 1.19.1 package):
+
+ mkdir pandoc-extract
+ cd pandoc-extract
+ xar -x ../pandoc-1.19.1-osx.pkg
+ cat pandoc.pkg/Payload | gunzip -dc | cpio -i
+ # executables are now in ./usr/bin/, man pages in ./usr/share/man
+
+ - You can also install pandoc using
+ [homebrew](http://brew.sh): `brew install pandoc`.
+
+ - 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
+ as needed. If you get errors warning of fonts not found, try
+
+ tlmgr install collection-fontsrecommended
+
+## Linux
+
+ - First, try your package manager.
+ Pandoc is in the [Debian], [Ubuntu], [Slackware],
+ [Arch], [Fedora], [NiXOS], [openSUSE], and [gentoo] repositories.
+ Note, however, that versions in the repositories are often
+ old.
+
+ - For 64-bit [Debian] and [Ubuntu], we provide a debian package
+ on the [download page].
+
+ sudo dpkg -i $DEB
+
+ where `$DEB` is the path to the downloaded deb, will
+ install the `pandoc` and `pandoc-citeproc` executables
+ and man pages.
+
+ - If you use an RPM-based distro, you may be
+ able to install this deb using `alien`, or try
+
+ ar p $DEB data.tar.gz | sudo tar xvz --strip-components 2 -C /usr/local
+
+ - If you'd rather install pandoc in your home directory, say
+ in `$HOME/.local`, then you can extract the files manually
+ from the deb:
+
+ ar p $DEB data.tar.gz | tar xvz --strip-components 2 -C $HOME/.local/
+
+ where, again, `$DEB` is the path to the downloaded deb.
+
+ - If the version in your repository is too old and you cannot
+ use the deb we provide, you can install from source, using the
+ instructions below under [Compiling from source].
+ Note that most distros have the Haskell platform in their
+ package repositories. For example, on Debian/Ubuntu,
+ you can install it with `apt-get install haskell-platform`.
+
+ - 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`.)
+
+## BSD
+
+ - Pandoc is in the [NetBSD] and [FreeBSD ports] repositories.
+
+## Compiling from source
+
+If for some reason a binary package is not available for your
+platform, or if you want to hack on pandoc or use a non-released
+version, you can install from source.
+
+### Getting the pandoc source code
+
+Source tarballs can be found at
+<https://hackage.haskell.org/package/pandoc>. For example, to
+fetch the source for version 1.17.0.3:
+
+ wget https://hackage.haskell.org/package/pandoc-1.17.0.3/pandoc-1.17.0.3.tar.gz
+ tar xvzf pandoc-1.17.0.3.tar.gz
+ cd pandoc-1.17.0.3
+
+Or you can fetch the development code by cloning the repository:
+
+ git clone https://github.com/jgm/pandoc
+ cd pandoc
+ git submodule update --init # to fetch the templates
+
+Note: there may be times when the development code is broken
+or depends on other libraries which must be installed
+separately. Unless you really know what you're doing, install
+the last released version.
+
+### Quick stack method
+
+The easiest way to build pandoc from source is to use [stack]:
+
+1. Install [stack].
+
+2. Change to the pandoc source directory and issue the following commands:
+
+ stack setup
+ stack install --test
+
+ `stack setup` will automatically download the ghc compiler
+ if you don't have it. `stack install` will install the
+ `pandoc` executable into `~/.local/bin`, which you should
+ add to your `PATH`. This process will take a while, and
+ will consume a considerable amount of disk space.
+
+### Quick cabal method
+
+1. Install the [Haskell platform]. This will give you [GHC] and
+ the [cabal-install] build tool. Note that pandoc requires
+ GHC >= 7.8.
+
+2. Update your package database:
+
+ cabal update
+
+3. Use `cabal` to install pandoc and its dependencies:
+
+ cabal install pandoc --enable-tests
+
+ This procedure will install the released version of pandoc,
+ which will be downloaded automatically from HackageDB.
+
+ If you want to install a modified or development version
+ of pandoc instead, switch to the source directory and do
+ as above, but without the 'pandoc':
+
+ cabal install
+
+ Note: If you obtained the source from the git repository (rather
+ than a release tarball), you'll need to do
+
+ git submodule update --init
+
+ to fetch the contents of `data/templates` before `cabal install`.
+
+4. Make sure the `$CABALDIR/bin` directory is in your path. You should
+ now be able to run `pandoc`:
+
+ pandoc --help
+
+ [Not sure where `$CABALDIR` is?](http://www.haskell.org/haskellwiki/Cabal-Install#The_cabal-install_configuration_file)
+
+5. If you want to process citations with pandoc, you will also need to
+ install a separate package, `pandoc-citeproc`. This can be installed
+ using cabal:
+
+ cabal install pandoc-citeproc
+
+ By default `pandoc-citeproc` uses the "i;unicode-casemap" method
+ to sort bibliography entries (RFC 5051). If you would like to
+ use the locale-sensitive unicode collation algorithm instead,
+ specify the `unicode_collation` flag:
+
+ cabal install pandoc-citeproc -funicode_collation
+
+ Note that this requires the `text-icu` library, which in turn
+ depends on the C library `icu4c`. Installation directions
+ vary by platform. Here is how it might work on OSX with homebrew:
+
+ brew install icu4c
+ cabal install --extra-lib-dirs=/usr/local/Cellar/icu4c/51.1/lib \
+ --extra-include-dirs=/usr/local/Cellar/icu4c/51.1/include \
+ -funicode_collation text-icu pandoc-citeproc
+
+6. The `pandoc.1` man page will be installed automatically. cabal shows
+ you where it is installed: you may need to set your `MANPATH`
+ accordingly. If `MANUAL.txt` has been modified, the man page can be
+ rebuilt: `make man/pandoc.1`.
+
+ The `pandoc-citeproc.1` man page will also be installed automatically.
+
+
+### Custom cabal method
+
+This is a step-by-step procedure that offers maximal control
+over the build and installation. Most users should use the
+quick install, but this information may be of use to packagers.
+For more details, see the [Cabal User's Guide]. These instructions
+assume that the pandoc source directory is your working directory.
+
+1. Install dependencies: in addition to the [Haskell platform],
+ you will need a number of additional libraries. You can install
+ them all with
+
+ cabal update
+ cabal install --only-dependencies
+
+2. Configure:
+
+ cabal configure --prefix=DIR --bindir=DIR --libdir=DIR \
+ --datadir=DIR --libsubdir=DIR --datasubdir=DIR --docdir=DIR \
+ --htmldir=DIR --program-prefix=PREFIX --program-suffix=SUFFIX \
+ --mandir=DIR --flags=FLAGSPEC --enable-tests
+
+ All of the options have sensible defaults that can be overridden
+ as needed.
+
+ `FLAGSPEC` is a list of Cabal configuration flags, optionally
+ preceded by a `-` (to force the flag to `false`), and separated
+ by spaces. Pandoc's flags include:
+
+ - `embed_data_files`: embed all data files into the binary (default no).
+ This is helpful if you want to create a relocatable binary.
+ Note: if this option is selected, you need to install the
+ `hsb2hs` preprocessor: `cabal install hsb2hs` (version 0.3.1 or
+ higher is required).
+
+ - `https`: enable support for downloading resources over https
+ (using the `http-client` and `http-client-tls` libraries).
+
+3. Build:
+
+ cabal build
+ cabal test
+
+4. Build API documentation:
+
+ cabal haddock --html-location=URL --hyperlink-source
+
+5. Copy the files:
+
+ cabal copy --destdir=PATH
+
+ The default destdir is `/`.
+
+6. Register pandoc as a GHC package:
+
+ cabal register
+
+ Package managers may want to use the `--gen-script` option to
+ generate a script that can be run to register the package at
+ install time.
+
+### Creating a relocatable binary
+
+It is possible to compile pandoc such that the data files
+pandoc uses are embedded in the binary. The resulting binary
+can be run from any directory and is completely self-contained.
+With cabal, add `-fembed_data_files` to the `cabal configure`
+or `cabal install` commands.
+
+With stack, use `--flag pandoc:embed_data_files`.
+
+
+
+### Running tests
+
+Pandoc comes with an automated test suite.
+To run with cabal, `cabal test`; to run with stack, `stack
+test`.
+
+To run particular tests (pattern-matching on their names), use
+the `-t` option:
+
+ cabal test --test-options='-t markdown'
+
+If you add a new feature to pandoc, please add tests as well, following
+the pattern of the existing tests. The test suite code is in
+`tests/test-pandoc.hs`. If you are adding a new reader or writer, it is
+probably easiest to add some data files to the `tests` directory, and
+modify `tests/Tests/Old.hs`. Otherwise, it is better to modify the module
+under the `tests/Tests` hierarchy corresponding to the pandoc module you
+are changing.
+
+### Running benchmarks
+
+To build and run the benchmarks:
+
+ cabal configure --enable-benchmarks && cabal build
+ cabal bench
+
+or with stack:
+
+ stack bench
+
+To use a smaller sample size so the benchmarks run faster:
+
+ cabal bench --benchmark-options='-s 20'
+
+To run just the markdown benchmarks:
+
+ cabal bench --benchmark-options='markdown'
+
+### Building the whole pandoc ecosystem
+
+Sometimes pandoc's development code depends on unreleased versions
+of dependent libraries. You'll need to build these as well. A
+maximal build method would be
+
+ mkdir pandoc-build
+ cd pandoc-build
+ git clone https://github.com/jgm/pandoc-types
+ git clone https://github.com/jgm/texmath
+ git clone https://github.com/jgm/pandoc-citeproc
+ git clone https://github.com/jgm/pandoc
+ git clone https://github.com/jgm/cmark-hs
+ git clone https://github.com/jgm/zip-archive
+ cd pandoc
+ git submodule update --init
+ stack install --test --install-ghc --stack-yaml stack.full.yaml
+
+To pull in the latest changes, after you've done this and there have been
+changes in the repositories: Visit each repository in pandoc-build
+(pandoc-types, texmath, pandoc-citeproc, pandoc, zip-archive, cmark-hs) and do
+`git pull`. In the pandoc repo, also do `git submodule update` and `stack
+install --test --stack-yaml stack.full.yaml`.
+
+
+[Arch]: https://www.archlinux.org/packages/community/x86_64/pandoc/
+[Cabal User's Guide]: http://www.haskell.org/cabal/release/latest/doc/users-guide/builders.html#setup-configure-paths
+[Debian]: http://packages.debian.org/lenny/pandoc
+[Fedora]: https://apps.fedoraproject.org/packages/pandoc
+[FreeBSD ports]: http://www.freshports.org/textproc/pandoc/
+[GHC]: http://www.haskell.org/ghc/
+[GPL]: http://www.gnu.org/copyleft/gpl.html
+[Haskell platform]: http://hackage.haskell.org/platform/
+[MacPorts]: http://trac.macports.org/browser/trunk/dports/textproc/pandoc/Portfile
+[MacTeX]: https://tug.org/mactex/
+[NetBSD]: http://pkgsrc.se/wip/pandoc
+[NixOS]: http://nixos.org/nixos/
+[Slackware]: http://www.linuxpackages.net/search_view.php?by=name&name=pandoc&ver=
+[Ubuntu]: http://www.ubuntu.com
+[download page]: https://github.com/jgm/pandoc/releases/latest
+[gentoo]: http://packages.gentoo.org/package/app-text/pandoc
+[haskell repository]: https://wiki.archlinux.org/index.php/Haskell_Package_Guidelines#.5Bhaskell.5D
+[openSUSE]: https://software.opensuse.org/package/pandoc
+[source tarball]: http://hackage.haskell.org/package/pandoc
+[stack]: http://docs.haskellstack.org/en/stable/install_and_upgrade.html
+[cabal-install]: http://hackage.haskell.org/trac/hackage/wiki/CabalInstall
+[uninstaller]: https://raw.githubusercontent.com/jgm/pandoc/master/osx/uninstall-pandoc.pl
diff --git a/MANUAL.txt b/MANUAL.txt
new file mode 100644
index 000000000..105ef8b1e
--- /dev/null
+++ b/MANUAL.txt
@@ -0,0 +1,4209 @@
+% Pandoc User's Guide
+% John MacFarlane
+% January 29, 2017
+
+Synopsis
+========
+
+`pandoc` [*options*] [*input-file*]...
+
+Description
+===========
+
+Pandoc is a [Haskell] library for converting from one markup format to
+another, and a command-line tool that uses this library. It can read
+[Markdown], [CommonMark], [PHP Markdown Extra], [GitHub-Flavored Markdown],
+[MultiMarkdown], and (subsets of) [Textile], [reStructuredText], [HTML],
+[LaTeX], [MediaWiki markup], [TWiki markup], [Haddock markup], [OPML], [Emacs
+Org mode], [DocBook], [txt2tags], [EPUB], [ODT] and [Word docx]; and it can
+write plain text, [Markdown], [CommonMark], [PHP Markdown Extra],
+[GitHub-Flavored Markdown], [MultiMarkdown], [reStructuredText], [XHTML],
+[HTML5], [LaTeX] \(including [`beamer`] slide shows\), [ConTeXt], [RTF], [OPML],
+[DocBook], [OpenDocument], [ODT], [Word docx], [GNU Texinfo], [MediaWiki
+markup], [DokuWiki markup], [ZimWiki markup], [Haddock markup],
+[EPUB] \(v2 or v3\), [FictionBook2], [Textile], [groff man] pages,
+[Emacs Org mode], [AsciiDoc], [InDesign ICML], [TEI Simple], and [Slidy],
+[Slideous], [DZSlides], [reveal.js] or [S5] HTML slide shows. It can also
+produce [PDF] output on systems where LaTeX, ConTeXt, or `wkhtmltopdf` is
+installed.
+
+Pandoc's enhanced version of Markdown includes syntax for [footnotes],
+[tables], flexible [ordered lists], [definition lists], [fenced code blocks],
+[superscripts and subscripts], [strikeout], [metadata blocks], automatic tables of
+contents, embedded LaTeX [math], [citations], and [Markdown inside HTML block
+elements][Extension: `markdown_in_html_blocks`]. (These enhancements, described
+further under [Pandoc's Markdown], can be disabled using the
+`markdown_strict` input or output format.)
+
+In contrast to most existing tools for converting Markdown to HTML, which
+use regex substitutions, pandoc has a modular design: it consists of a
+set of readers, which parse text in a given format and produce a native
+representation of the document, and a set of writers, which convert
+this native representation into a target format. Thus, adding an input
+or output format requires only adding a reader or writer.
+
+Because pandoc's intermediate representation of a document is less
+expressive than many of the formats it converts between, one should
+not expect perfect conversions between every format and every other.
+Pandoc attempts to preserve the structural elements of a document, but
+not formatting details such as margin size. And some document elements,
+such as complex tables, may not fit into pandoc's simple document
+model. While conversions from pandoc's Markdown to all formats aspire
+to be perfect, conversions from formats more expressive than pandoc's
+Markdown can be expected to be lossy.
+
+[Markdown]: http://daringfireball.net/projects/markdown/
+[CommonMark]: http://commonmark.org
+[PHP Markdown Extra]: https://michelf.ca/projects/php-markdown/extra/
+[GitHub-Flavored Markdown]: https://help.github.com/articles/github-flavored-markdown/
+[MultiMarkdown]: http://fletcherpenney.net/multimarkdown/
+[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
+[S5]: http://meyerweb.com/eric/tools/s5/
+[Slidy]: http://www.w3.org/Talks/Tools/Slidy/
+[Slideous]: http://goessner.net/articles/slideous/
+[HTML]: http://www.w3.org/html/
+[HTML5]: http://www.w3.org/TR/html5/
+[XHTML]: http://www.w3.org/TR/xhtml1/
+[LaTeX]: http://latex-project.org
+[`beamer`]: https://ctan.org/pkg/beamer
+[Beamer User's Guide]: http://ctan.math.utah.edu/ctan/tex-archive/macros/latex/contrib/beamer/doc/beameruserguide.pdf
+[ConTeXt]: http://www.contextgarden.net/
+[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format
+[DocBook]: http://docbook.org
+[txt2tags]: http://txt2tags.org
+[EPUB]: http://idpf.org/epub
+[OPML]: http://dev.opml.org/spec2.html
+[OpenDocument]: http://opendocument.xml.org
+[ODT]: http://en.wikipedia.org/wiki/OpenDocument
+[Textile]: http://redcloth.org/textile
+[MediaWiki markup]: https://www.mediawiki.org/wiki/Help:Formatting
+[DokuWiki markup]: https://www.dokuwiki.org/dokuwiki
+[ZimWiki markup]: http://zim-wiki.org/manual/Help/Wiki_Syntax.html
+[TWiki markup]: http://twiki.org/cgi-bin/view/TWiki/TextFormattingRules
+[Haddock markup]: https://www.haskell.org/haddock/doc/html/ch03s08.html
+[groff man]: http://man7.org/linux/man-pages/man7/groff_man.7.html
+[Haskell]: https://www.haskell.org
+[GNU Texinfo]: http://www.gnu.org/software/texinfo/
+[Emacs Org mode]: http://orgmode.org
+[AsciiDoc]: http://www.methods.co.nz/asciidoc/
+[DZSlides]: http://paulrouget.com/dzslides/
+[Word docx]: https://en.wikipedia.org/wiki/Office_Open_XML
+[PDF]: https://www.adobe.com/pdf/
+[reveal.js]: http://lab.hakim.se/reveal-js/
+[FictionBook2]: http://www.fictionbook.org/index.php/Eng:XML_Schema_Fictionbook_2.1
+[InDesign ICML]: https://www.adobe.com/content/dam/Adobe/en/devnet/indesign/cs55-docs/IDML/idml-specification.pdf
+[TEI Simple]: https://github.com/TEIC/TEI-Simple
+
+Using `pandoc`
+--------------
+
+If no *input-file* is specified, input is read from *stdin*.
+Otherwise, the *input-files* are concatenated (with a blank
+line between each) and used as input. Output goes to *stdout* by
+default (though output to *stdout* is disabled for the `odt`, `docx`,
+`epub2`, and `epub3` output formats). For output to a file, use the
+`-o` option:
+
+ pandoc -o output.html input.txt
+
+By default, pandoc produces a document fragment, not a standalone
+document with a proper header and footer. To produce a standalone
+document, use the `-s` or `--standalone` flag:
+
+ pandoc -s -o output.html input.txt
+
+For more information on how standalone documents are produced, see
+[Templates], below.
+
+Instead of a file, an absolute URI may be given. In this case
+pandoc will fetch the content using HTTP:
+
+ pandoc -f html -t markdown http://www.fsf.org
+
+It is possible to supply a custom User-Agent string when requesting a
+document from a URL, by setting an environment variable:
+
+ USER_AGENT="Mozilla/5.0" pandoc -f html -t markdown http://www.fsf.org
+
+If multiple input files are given, `pandoc` will concatenate them all (with
+blank lines between them) before parsing. This feature is disabled for
+ binary input formats such as `EPUB`, `odt`, and `docx`.
+
+The format of the input and output can be specified explicitly using
+command-line options. The input format can be specified using the
+`-r/--read` or `-f/--from` options, the output format using the
+`-w/--write` or `-t/--to` options. Thus, to convert `hello.txt` from
+Markdown to LaTeX, you could type:
+
+ pandoc -f markdown -t latex hello.txt
+
+To convert `hello.html` from HTML to Markdown:
+
+ pandoc -f html -t markdown hello.html
+
+Supported output formats are listed below under the `-t/--to` option.
+Supported input formats are listed below under the `-f/--from` option. Note
+that the `rst`, `textile`, `latex`, and `html` readers are not complete;
+there are some constructs that they do not parse.
+
+If the input or output format is not specified explicitly, `pandoc`
+will attempt to guess it from the extensions of
+the input and output filenames. Thus, for example,
+
+ pandoc -o hello.tex hello.txt
+
+will convert `hello.txt` from Markdown to LaTeX. If no output file
+is specified (so that output goes to *stdout*), or if the output file's
+extension is unknown, the output format will default to HTML.
+If no input file is specified (so that input comes from *stdin*), or
+if the input files' extensions are unknown, the input format will
+be assumed to be Markdown unless explicitly specified.
+
+Pandoc uses the UTF-8 character encoding for both input and output.
+If your local character encoding is not UTF-8, you
+should pipe input and output through [`iconv`]:
+
+ iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
+
+Note that in some output formats (such as HTML, LaTeX, ConTeXt,
+RTF, OPML, DocBook, and Texinfo), information about
+the character encoding is included in the document header, which
+will only be included if you use the `-s/--standalone` option.
+
+[`iconv`]: http://www.gnu.org/software/libiconv/
+
+Creating a PDF
+--------------
+
+To produce a PDF, specify an output file with a `.pdf` extension.
+By default, pandoc will use LaTeX to convert it to PDF:
+
+ pandoc test.txt -o test.pdf
+
+Production of a PDF requires that a LaTeX engine be installed (see
+`--latex-engine`, below), and assumes that the following LaTeX packages
+are available: [`amsfonts`], [`amsmath`], [`lm`], [`unicode-math`],
+[`ifxetex`], [`ifluatex`], [`eurosym`], [`listings`] (if the
+`--listings` option is used), [`fancyvrb`], [`longtable`],
+[`booktabs`], [`graphicx`] and [`grffile`] (if the document
+contains images), [`hyperref`], [`ulem`], [`geometry`] (with the
+`geometry` variable set), [`setspace`] (with `linestretch`), and
+[`babel`] (with `lang`). The use of `xelatex` or `lualatex` as
+the LaTeX engine requires [`fontspec`]. `xelatex` uses
+[`polyglossia`] (with `lang`), [`xecjk`], and [`bidi`] (with the
+`dir` variable set). If the `mathspec` variable is set,
+`xelatex` will use [`mathspec`] instead of [`unicode-math`].
+The [`upquote`] and [`microtype`] packages are used if
+available, and [`csquotes`] will be used for [smart punctuation]
+if added to the template or included in any header file. The
+[`natbib`], [`biblatex`], [`bibtex`], and [`biber`] packages can
+optionally be used for [citation rendering]. These are included
+with all recent versions of [TeX Live].
+
+Alternatively, pandoc can use ConTeXt or `wkhtmltopdf` to create a PDF.
+To do this, specify an output file with a `.pdf` extension,
+as before, but add `-t context` or `-t html5` to the command line.
+
+PDF output can be controlled using [variables for LaTeX] (if
+LaTeX is used) and [variables for ConTeXt] (if ConTeXt is used).
+If `wkhtmltopdf` is used, then the variables `margin-left`,
+`margin-right`, `margin-top`, `margin-bottom`, and `papersize`
+will affect the output, as will `--css`.
+
+[`amsfonts`]: https://ctan.org/pkg/amsfonts
+[`amsmath`]: https://ctan.org/pkg/amsmath
+[`lm`]: https://ctan.org/pkg/lm
+[`ifxetex`]: https://ctan.org/pkg/ifxetex
+[`ifluatex`]: https://ctan.org/pkg/ifluatex
+[`eurosym`]: https://ctan.org/pkg/eurosym
+[`listings`]: https://ctan.org/pkg/listings
+[`fancyvrb`]: https://ctan.org/pkg/fancyvrb
+[`longtable`]: https://ctan.org/pkg/longtable
+[`booktabs`]: https://ctan.org/pkg/booktabs
+[`graphicx`]: https://ctan.org/pkg/graphicx
+[`grffile`]: https://ctan.org/pkg/grffile
+[`geometry`]: https://ctan.org/pkg/geometry
+[`setspace`]: https://ctan.org/pkg/setspace
+[`xecjk`]: https://ctan.org/pkg/xecjk
+[`hyperref`]: https://ctan.org/pkg/hyperref
+[`ulem`]: https://ctan.org/pkg/ulem
+[`babel`]: https://ctan.org/pkg/babel
+[`bidi`]: https://ctan.org/pkg/bidi
+[`mathspec`]: https://ctan.org/pkg/mathspec
+[`unicode-math`]: https://ctan.org/pkg/unicode-math
+[`polyglossia`]: https://ctan.org/pkg/polyglossia
+[`fontspec`]: https://ctan.org/pkg/fontspec
+[`upquote`]: https://ctan.org/pkg/upquote
+[`microtype`]: https://ctan.org/pkg/microtype
+[`csquotes`]: https://ctan.org/pkg/csquotes
+[`natbib`]: https://ctan.org/pkg/natbib
+[`biblatex`]: https://ctan.org/pkg/biblatex
+[`bibtex`]: https://ctan.org/pkg/bibtex
+[`biber`]: https://ctan.org/pkg/biber
+[TeX Live]: http://www.tug.org/texlive/
+
+Options
+=======
+
+General options
+---------------
+
+`-f` *FORMAT*, `-r` *FORMAT*, `--from=`*FORMAT*, `--read=`*FORMAT*
+
+: Specify input format. *FORMAT* can be `native` (native Haskell),
+ `json` (JSON version of native AST), `markdown` (pandoc's
+ extended Markdown), `markdown_strict` (original unextended
+ Markdown), `markdown_phpextra` (PHP Markdown Extra), `markdown_github`
+ (GitHub-Flavored Markdown), `markdown_mmd` (MultiMarkdown),
+ `commonmark` (CommonMark Markdown), `textile` (Textile), `rst`
+ (reStructuredText), `html` (HTML), `docbook` (DocBook), `t2t`
+ (txt2tags), `docx` (docx), `odt` (ODT), `epub` (EPUB), `opml` (OPML),
+ `org` (Emacs Org mode), `mediawiki` (MediaWiki markup), `twiki` (TWiki
+ markup), `haddock` (Haddock markup), or `latex` (LaTeX). If
+ `+lhs` is appended to `markdown`, `rst`, `latex`, or `html`, the
+ input will be treated as literate Haskell source: see [Literate
+ Haskell support], below. Markdown
+ syntax extensions can be individually enabled or disabled by
+ appending `+EXTENSION` or `-EXTENSION` to the format name. So, for
+ example, `markdown_strict+footnotes+definition_lists` is strict
+ Markdown with footnotes and definition lists enabled, and
+ `markdown-pipe_tables+hard_line_breaks` is pandoc's Markdown
+ without pipe tables and with hard line breaks. See [Pandoc's
+ Markdown], below, for a list of extensions and
+ their names. See `--list-input-formats` and `--list-extensions`,
+ below.
+
+`-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT*
+
+: Specify output format. *FORMAT* can be `native` (native Haskell),
+ `json` (JSON version of native AST), `plain` (plain text),
+ `markdown` (pandoc's extended Markdown), `markdown_strict`
+ (original unextended Markdown), `markdown_phpextra` (PHP Markdown
+ Extra), `markdown_github` (GitHub-Flavored Markdown), `markdown_mmd`
+ (MultiMarkdown), `commonmark` (CommonMark Markdown), `rst`
+ (reStructuredText), `html4` (XHTML4), `html` or `html5` (HTML5), `latex`
+ (LaTeX), `beamer` (LaTeX beamer slide show), `context` (ConTeXt),
+ `man` (groff man), `mediawiki` (MediaWiki markup),
+ `dokuwiki` (DokuWiki markup), `zimwiki` (ZimWiki markup),
+ `textile` (Textile), `org` (Emacs Org mode),
+ `texinfo` (GNU Texinfo), `opml` (OPML), `docbook` or `docbook4`
+ (DocBook 4), `docbook5` (DocBook 5), `opendocument` (OpenDocument),
+ `odt` (OpenOffice text document), `docx` (Word docx), `haddock`
+ (Haddock markup), `rtf` (rich text format), `epub2` (EPUB v2 book),
+ `epub` or `epub3` (EPUB v3), `fb2` (FictionBook2 e-book),
+ `asciidoc` (AsciiDoc), `icml` (InDesign ICML), `tei` (TEI
+ Simple), `slidy` (Slidy HTML and JavaScript slide show),
+ `slideous` (Slideous HTML and JavaScript slide show),
+ `dzslides` (DZSlides HTML5 + JavaScript slide show),
+ `revealjs` (reveal.js HTML5 + JavaScript slide show), `s5`
+ (S5 HTML and JavaScript slide show), or the path of a custom
+ lua writer (see [Custom writers], below). Note that `odt`,
+ `epub`, and `epub3` output will not be directed to *stdout*;
+ an output filename must be specified using the `-o/--output`
+ option. If `+lhs` is appended to `markdown`, `rst`, `latex`,
+ `beamer`, `html4`, or `html5`, the output will be rendered as
+ literate Haskell source: see [Literate Haskell support],
+ below. Markdown syntax extensions can be individually
+ enabled or disabled by appending `+EXTENSION` or
+ `-EXTENSION` to the format name, as described above under `-f`.
+ See `--list-output-formats` and `--list-extensions`, below.
+
+`-o` *FILE*, `--output=`*FILE*
+
+: Write output to *FILE* instead of *stdout*. If *FILE* is
+ `-`, output will go to *stdout*. (Exception: if the output
+ format is `odt`, `docx`, `epub`, or `epub3`, output to stdout is disabled.)
+
+`--data-dir=`*DIRECTORY*
+
+: Specify the user data directory to search for pandoc data files.
+ If this option is not specified, the default user data directory
+ will be used. This is, in Unix:
+
+ $HOME/.pandoc
+
+ in Windows XP:
+
+ C:\Documents And Settings\USERNAME\Application Data\pandoc
+
+ and in Windows Vista or later:
+
+ C:\Users\USERNAME\AppData\Roaming\pandoc
+
+ You can find the default user data directory on your system by
+ looking at the output of `pandoc --version`.
+ A `reference.odt`, `reference.docx`, `epub.css`, `templates`,
+ `slidy`, `slideous`, or `s5` directory
+ placed in this directory will override pandoc's normal defaults.
+
+`--bash-completion`
+
+: Generate a bash completion script. To enable bash completion
+ with pandoc, add this to your `.bashrc`:
+
+ eval "$(pandoc --bash-completion)"
+
+`--verbose`
+
+: Give verbose debugging output. Currently this only has an effect
+ with PDF output.
+
+`--quiet`
+
+: Suppress warning messages.
+
+`--fail-if-warnings`
+
+: Exit with error status if there are any warnings.
+
+`--log=`*FILE*
+
+: Write log messages in machine-readable JSON format to
+ *FILE*. All messages above DEBUG level will be written,
+ regardless of verbosity settings (`--verbose`, `--quiet`).
+
+`--list-input-formats`
+
+: List supported input formats, one per line.
+
+`--list-output-formats`
+
+: List supported output formats, one per line.
+
+`--list-extensions`
+
+: List supported Markdown extensions, one per line, followed
+ by a `+` or `-` indicating whether it is enabled by default
+ in pandoc's Markdown.
+
+`--list-highlight-languages`
+
+: List supported languages for syntax highlighting, one per
+ line.
+
+`--list-highlight-styles`
+
+: List supported styles for syntax highlighting, one per line.
+ See `--highlight-style`.
+
+`-v`, `--version`
+
+: Print version.
+
+`-h`, `--help`
+
+: Show usage message.
+
+Reader options
+--------------
+
+`--base-header-level=`*NUMBER*
+
+: Specify the base level for headers (defaults to 1).
+
+`--indented-code-classes=`*CLASSES*
+
+: Specify classes to use for indented code blocks--for example,
+ `perl,numberLines` or `haskell`. Multiple classes may be separated
+ by spaces or commas.
+
+`--default-image-extension=`*EXTENSION*
+
+: Specify a default extension to use when image paths/URLs have no
+ extension. This allows you to use the same source for formats that
+ require different kinds of images. Currently this option only affects
+ the Markdown and LaTeX readers.
+
+`--file-scope`
+
+: Parse each file individually before combining for multifile
+ documents. This will allow footnotes in different files with the
+ same identifiers to work as expected. If this option is set,
+ footnotes and links will not work across files. Reading binary
+ files (docx, odt, epub) implies `--file-scope`.
+
+`--filter=`*PROGRAM*
+
+: Specify an executable to be used as a filter transforming the
+ pandoc AST after the input is parsed and before the output is
+ written. The executable should read JSON from stdin and write
+ JSON to stdout. The JSON must be formatted like pandoc's own
+ JSON input and output. The name of the output format will be
+ passed to the filter as the first argument. Hence,
+
+ pandoc --filter ./caps.py -t latex
+
+ is equivalent to
+
+ pandoc -t json | ./caps.py latex | pandoc -f json -t latex
+
+ The latter form may be useful for debugging filters.
+
+ Filters may be written in any language. `Text.Pandoc.JSON`
+ exports `toJSONFilter` to facilitate writing filters in Haskell.
+ Those who would prefer to write filters in python can use the
+ module [`pandocfilters`], installable from PyPI. There are also
+ pandoc filter libraries in [PHP], [perl], and
+ [javascript/node.js].
+
+ In order of preference, pandoc will look for filters in
+
+ 1. a specified full or relative path (executable or
+ non-executable)
+
+ 2. `$DATADIR/filters` (executable or non-executable)
+
+ 3. `$PATH` (executable only)
+
+`-M` *KEY*[`=`*VAL*], `--metadata=`*KEY*[`:`*VAL*]
+
+: Set the metadata field *KEY* to the value *VAL*. A value specified
+ on the command line overrides a value specified in the document.
+ Values will be parsed as YAML boolean or string values. If no value is
+ specified, the value will be treated as Boolean true. Like
+ `--variable`, `--metadata` causes template variables to be set.
+ But unlike `--variable`, `--metadata` affects the metadata of the
+ underlying document (which is accessible from filters and may be
+ printed in some output formats).
+
+`-p`, `--preserve-tabs`
+
+: Preserve tabs instead of converting them to spaces (the default).
+ Note that this will only affect tabs in literal code spans and code
+ blocks; tabs in regular text will be treated as spaces.
+
+`--tab-stop=`*NUMBER*
+
+: Specify the number of spaces per tab (default is 4).
+
+`--track-changes=accept`|`reject`|`all`
+
+: Specifies what to do with insertions, deletions, and comments
+ produced by the MS Word "Track Changes" feature. `accept` (the
+ default), inserts all insertions, and ignores all
+ deletions. `reject` inserts all deletions and ignores
+ insertions. Both `accept` and `reject` ignore comments. `all` puts
+ in insertions, deletions, and comments, wrapped in spans with
+ `insertion`, `deletion`, `comment-start`, and `comment-end`
+ classes, respectively. The author and time of change is
+ included. `all` is useful for scripting: only accepting changes
+ from a certain reviewer, say, or before a certain date. This
+ option only affects the docx reader.
+
+`--extract-media=`*DIR*
+
+: Extract images and other media contained in a docx or epub container
+ to the path *DIR*, creating it if necessary, and adjust the images
+ references in the document so they point to the extracted files.
+ This option only affects the docx and epub readers.
+
+[`pandocfilters`]: https://github.com/jgm/pandocfilters
+[PHP]: https://github.com/vinai/pandocfilters-php
+[perl]: https://metacpan.org/pod/Pandoc::Filter
+[javascript/node.js]: https://github.com/mvhenderson/pandoc-filter-node
+
+General writer options
+----------------------
+
+`-s`, `--standalone`
+
+: Produce output with an appropriate header and footer (e.g. a
+ standalone HTML, LaTeX, TEI, or RTF file, not a fragment). This option
+ is set automatically for `pdf`, `epub`, `epub3`, `fb2`, `docx`, and `odt`
+ output.
+
+`--template=`*FILE*
+
+: Use *FILE* as a custom template for the generated document. Implies
+ `--standalone`. See [Templates], below, for a description
+ of template syntax. If no extension is specified, an extension
+ corresponding to the writer will be added, so that `--template=special`
+ looks for `special.html` for HTML output. If the template is not
+ found, pandoc will search for it in the `templates` subdirectory of
+ the user data directory (see `--data-dir`). If this option is not used,
+ a default template appropriate for the output format will be used (see
+ `-D/--print-default-template`).
+
+`-V` *KEY*[`=`*VAL*], `--variable=`*KEY*[`:`*VAL*]
+
+: Set the template variable *KEY* to the value *VAL* when rendering the
+ document in standalone mode. This is generally only useful when the
+ `--template` option is used to specify a custom template, since
+ pandoc automatically sets the variables used in the default
+ templates. If no *VAL* is specified, the key will be given the
+ value `true`.
+
+`-D` *FORMAT*, `--print-default-template=`*FORMAT*
+
+: Print the system default template for an output *FORMAT*. (See `-t`
+ for a list of possible *FORMAT*s.) Templates in the user data
+ directory are ignored.
+
+`--print-default-data-file=`*FILE*
+
+: Print a system default data file. Files in the user data directory
+ are ignored.
+
+`--dpi`=*NUMBER*
+: Specify the dpi (dots per inch) value for conversion from pixels
+ to inch/centimeters and vice versa. The default is 96dpi.
+ Technically, the correct term would be ppi (pixels per inch).
+
+`--wrap=auto`|`none`|`preserve`
+
+: Determine how text is wrapped in the output (the source
+ code, not the rendered version). With `auto` (the default),
+ pandoc will attempt to wrap lines to the column width specified by
+ `--columns` (default 72). With `none`, pandoc will not wrap
+ lines at all. With `preserve`, pandoc will attempt to
+ preserve the wrapping from the source document (that is,
+ where there are nonsemantic newlines in the source, there
+ will be nonsemantic newlines in the output as well).
+ Automatic wrapping does not currently work in HTML output.
+
+`--columns=`*NUMBER*
+
+: Specify length of lines in characters. This affects text wrapping
+ in the generated source code (see `--wrap`). It also affects
+ calculation of column widths for plain text tables (see [Tables] below).
+
+`--toc`, `--table-of-contents`
+
+: Include an automatically generated table of contents (or, in
+ the case of `latex`, `context`, `docx`, and `rst`, an instruction to create
+ one) in the output document. This option has no effect on `man`,
+ `docbook4`, `docbook5`, `slidy`, `slideous`, `s5`, or `odt` output.
+
+`--toc-depth=`*NUMBER*
+
+: Specify the number of section levels to include in the table
+ of contents. The default is 3 (which means that level 1, 2, and 3
+ headers will be listed in the contents).
+
+`--no-highlight`
+
+: Disables syntax highlighting for code blocks and inlines, even when
+ a language attribute is given.
+
+`--highlight-style=`*STYLE*
+
+: Specifies the coloring style to be used in highlighted source code.
+ Options are `pygments` (the default), `kate`, `monochrome`,
+ `breezeDark`, `espresso`, `zenburn`, `haddock`, and `tango`.
+ For more information on syntax highlighting in pandoc, see
+ [Syntax highlighting], below. See also
+ `--list-highlight-styles`.
+
+`-H` *FILE*, `--include-in-header=`*FILE*
+
+: Include contents of *FILE*, verbatim, at the end of the header.
+ This can be used, for example, to include special
+ CSS or JavaScript in HTML documents. This option can be used
+ repeatedly to include multiple files in the header. They will be
+ included in the order specified. Implies `--standalone`.
+
+`-B` *FILE*, `--include-before-body=`*FILE*
+
+: Include contents of *FILE*, verbatim, at the beginning of the
+ document body (e.g. after the `<body>` tag in HTML, or the
+ `\begin{document}` command in LaTeX). This can be used to include
+ navigation bars or banners in HTML documents. This option can be
+ used repeatedly to include multiple files. They will be included in
+ the order specified. Implies `--standalone`.
+
+`-A` *FILE*, `--include-after-body=`*FILE*
+
+: Include contents of *FILE*, verbatim, at the end of the document
+ body (before the `</body>` tag in HTML, or the
+ `\end{document}` command in LaTeX). This option can be used
+ repeatedly to include multiple files. They will be included in the
+ order specified. Implies `--standalone`.
+
+Options affecting specific writers
+----------------------------------
+
+`--self-contained`
+
+: Produce a standalone HTML file with no external dependencies, using
+ `data:` URIs to incorporate the contents of linked scripts, stylesheets,
+ images, and videos. The resulting file should be "self-contained,"
+ in the sense that it needs no external files and no net access to be
+ displayed properly by a browser. This option works only with HTML output
+ formats, including `html4`, `html5`, `html+lhs`, `html5+lhs`, `s5`,
+ `slidy`, `slideous`, `dzslides`, and `revealjs`. Scripts, images, and
+ stylesheets at absolute URLs will be downloaded; those at relative URLs
+ will be sought relative to the working directory (if the first source
+ file is local) or relative to the base URL (if the first source
+ file is remote). Limitation: resources that are loaded dynamically
+ through JavaScript cannot be incorporated; as a result, `--self-contained`
+ does not work with `--mathjax`, and some advanced features (e.g.
+ zoom or speaker notes) may not work in an offline "self-contained"
+ `reveal.js` slide show.
+
+`--html-q-tags`
+
+: Use `<q>` tags for quotes in HTML.
+
+`--ascii`
+
+: Use only ASCII characters in output. Currently supported only
+ for HTML output (which uses numerical entities instead of
+ UTF-8 when this option is selected).
+
+`--reference-links`
+
+: Use reference-style links, rather than inline links, in writing Markdown
+ or reStructuredText. By default inline links are used. The
+ placement of link references is affected by the
+ `--reference-location` option.
+
+`--reference-location = block`|`section`|`document`
+
+: Specify whether footnotes (and references, if `reference-links` is
+ set) are placed at the end of the current (top-level) block, the
+ current section, or the document. The default is
+ `document`. Currently only affects the markdown writer.
+
+`--atx-headers`
+
+: Use ATX-style headers in Markdown and AsciiDoc output. The default is
+ to use setext-style headers for levels 1-2, and then ATX headers.
+
+`--top-level-division=[default|section|chapter|part]`
+
+: 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, `section` is chosen. When the
+ LaTeX document class is set to `report`, `book`, or `memoir` (unless the
+ `article` option is specified), `chapter` is implied as the setting for this
+ option. If `beamer` is the output format, specifying either `chapter` or
+ `part` will cause top-level headers to become `\part{..}`, while
+ second-level headers remain as their default type.
+
+`-N`, `--number-sections`
+
+: Number section headings in LaTeX, ConTeXt, HTML, or EPUB output.
+ By default, sections are not numbered. Sections with class
+ `unnumbered` will never be numbered, even if `--number-sections`
+ is specified.
+
+`--number-offset=`*NUMBER*[`,`*NUMBER*`,`*...*]
+
+: Offset for section headings in HTML output (ignored in other
+ output formats). The first number is added to the section number for
+ top-level 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 `--number-offset=5`.
+ If your document starts with a level-2 header which you want to
+ be numbered "1.5", specify `--number-offset=1,4`.
+ Offsets are 0 by default. Implies `--number-sections`.
+
+`--listings`
+
+: Use the [`listings`] package for LaTeX code blocks
+
+`-i`, `--incremental`
+
+: Make list items in slide shows display incrementally (one by one).
+ The default is for lists to be displayed all at once.
+
+`--slide-level=`*NUMBER*
+
+: Specifies that headers with the specified level create
+ slides (for `beamer`, `s5`, `slidy`, `slideous`, `dzslides`). 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. The default is to set the slide level
+ based on the contents of the document; see
+ [Structuring the slide show].
+
+`--section-divs`
+
+: Wrap sections in `<div>` tags (or `<section>` tags in HTML5),
+ and attach identifiers to the enclosing `<div>` (or `<section>`)
+ rather than the header itself. See
+ [Header identifiers], below.
+
+`--email-obfuscation=none`|`javascript`|`references`
+
+: Specify a method for obfuscating `mailto:` links in HTML documents.
+ `none` leaves `mailto:` links as they are. `javascript` obfuscates
+ them using JavaScript. `references` obfuscates them by printing their
+ letters as decimal or hexadecimal character references. The default
+ is `none`.
+
+`--id-prefix=`*STRING*
+
+: Specify a prefix to be added to all identifiers and internal links
+ in HTML and DocBook output, and to footnote numbers in Markdown
+ and Haddock output. This is useful for preventing duplicate
+ identifiers when generating fragments to be included in other pages.
+
+`-T` *STRING*, `--title-prefix=`*STRING*
+
+: Specify *STRING* as a prefix at the beginning of the title
+ that appears in the HTML header (but not in the title as it
+ appears at the beginning of the HTML body). Implies
+ `--standalone`.
+
+`-c` *URL*, `--css=`*URL*
+
+: Link to a CSS style sheet. This option can be used repeatedly to
+ include multiple files. They will be included in the order specified.
+
+`--reference-doc=`*FILE*
+
+: Use the specified file as a style reference in producing a
+ docx or ODT file.
+
+ Docx: For best results, the reference docx should be a modified
+ version of a docx file produced using pandoc. The contents
+ of the reference docx are ignored, but its stylesheets and
+ document properties (including margins, page size, header,
+ and footer) are used in the new docx. If no reference docx
+ is specified on the command line, pandoc will look for a
+ file `reference.docx` in the user data directory (see
+ `--data-dir`). If this is not found either, sensible
+ defaults will be used.
+
+ To produce a custom `reference.docx`, first get a copy of
+ the default `reference.docx`: `pandoc
+ --print-default-data-file reference.docx >
+ custom-reference.docx`. Then open `custom-reference.docx`
+ in Word, modify the styles as you wish, and save the file.
+ For best results, do not make changes to this file other
+ than modifying the styles used by pandoc: [paragraph]
+ Normal, Body Text, First Paragraph, Compact, Title,
+ Subtitle, Author, Date, Abstract, Bibliography, Heading 1,
+ Heading 2, Heading 3, Heading 4, Heading 5, Heading 6, Block
+ Text, Footnote Text, Definition Term, Definition, Caption,
+ Table Caption, Image Caption, Figure, Figure With Caption,
+ TOC Heading; [character] Default Paragraph Font, Body Text
+ Char, Verbatim Char, Footnote Reference, Hyperlink; [table]
+ Normal Table.
+
+ ODT: For best results, the reference ODT should be a modified
+ version of an ODT produced using pandoc. The contents of
+ the reference ODT are ignored, but its stylesheets are used
+ in the new ODT. If no reference ODT is specified on the
+ command line, pandoc will look for a file `reference.odt` in
+ the user data directory (see `--data-dir`). If this is not
+ found either, sensible defaults will be used.
+
+ To produce a custom `reference.odt`, first get a copy of
+ the default `reference.odt`: `pandoc
+ --print-default-data-file reference.odt >
+ custom-reference.odt`. Then open `custom-reference.docx` in
+ LibreOffice, modify the styles as you wish, and save the
+ file.
+
+`--epub-stylesheet=`*FILE*
+
+: Use the specified CSS file to style the EPUB. If no stylesheet
+ is specified, pandoc will look for a file `epub.css` in the
+ user data directory (see `--data-dir`). If it is not
+ found there, sensible defaults will be used.
+
+`--epub-cover-image=`*FILE*
+
+: Use the specified image as the EPUB cover. It is recommended
+ that the image be less than 1000px in width and height. Note that
+ in a Markdown source document you can also specify `cover-image`
+ in a YAML metadata block (see [EPUB Metadata], below).
+
+`--epub-metadata=`*FILE*
+
+: Look in the specified XML file for metadata for the EPUB.
+ The file should contain a series of [Dublin Core elements].
+ For example:
+
+ <dc:rights>Creative Commons</dc:rights>
+ <dc:language>es-AR</dc:language>
+
+ By default, pandoc will include the following metadata elements:
+ `<dc:title>` (from the document title), `<dc:creator>` (from the
+ document authors), `<dc:date>` (from the document date, which should
+ be in [ISO 8601 format]), `<dc:language>` (from the `lang`
+ variable, or, if is not set, the locale), and `<dc:identifier
+ id="BookId">` (a randomly generated UUID). Any of these may be
+ overridden by elements in the metadata file.
+
+ Note: if the source document is Markdown, a YAML metadata block
+ in the document can be used instead. See below under
+ [EPUB Metadata].
+
+`--epub-embed-font=`*FILE*
+
+: Embed the specified font in the EPUB. This option can be repeated
+ to embed multiple fonts. Wildcards can also be used: for example,
+ `DejaVuSans-*.ttf`. However, if you use wildcards on the command
+ line, be sure to escape them or put the whole filename in single quotes,
+ to prevent them from being interpreted by the shell. To use the
+ embedded fonts, you will need to add declarations like the following
+ to your CSS (see `--epub-stylesheet`):
+
+ @font-face {
+ font-family: DejaVuSans;
+ font-style: normal;
+ font-weight: normal;
+ src:url("DejaVuSans-Regular.ttf");
+ }
+ @font-face {
+ font-family: DejaVuSans;
+ font-style: normal;
+ font-weight: bold;
+ src:url("DejaVuSans-Bold.ttf");
+ }
+ @font-face {
+ font-family: DejaVuSans;
+ font-style: italic;
+ font-weight: normal;
+ src:url("DejaVuSans-Oblique.ttf");
+ }
+ @font-face {
+ font-family: DejaVuSans;
+ font-style: italic;
+ font-weight: bold;
+ src:url("DejaVuSans-BoldOblique.ttf");
+ }
+ body { font-family: "DejaVuSans"; }
+
+`--epub-chapter-level=`*NUMBER*
+
+: Specify the 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.
+
+`--latex-engine=pdflatex`|`lualatex`|`xelatex`
+
+: Use the specified LaTeX engine when producing PDF output.
+ The default is `pdflatex`. If the engine is not in your PATH,
+ the full path of the engine may be specified here.
+
+`--latex-engine-opt=`*STRING*
+
+: Use the given string as a command-line argument to the `latex-engine`.
+ If used multiple times, the arguments are provided with spaces between
+ them. Note that no check for duplicate options is done.
+
+[Dublin Core elements]: http://dublincore.org/documents/dces/
+[ISO 8601 format]: http://www.w3.org/TR/NOTE-datetime
+
+Citation rendering
+------------------
+
+`--bibliography=`*FILE*
+
+: Set the `bibliography` field in the document's metadata to *FILE*,
+ overriding any value set in the metadata, and process citations
+ using `pandoc-citeproc`. (This is equivalent to
+ `--metadata bibliography=FILE --filter pandoc-citeproc`.)
+ If `--natbib` or `--biblatex` is also supplied, `pandoc-citeproc` is not
+ used, making this equivalent to `--metadata bibliography=FILE`.
+ If you supply this argument multiple times, each *FILE* will be added
+ to bibliography.
+
+`--csl=`*FILE*
+
+: Set the `csl` field in the document's metadata to *FILE*,
+ overriding any value set in the metadata. (This is equivalent to
+ `--metadata csl=FILE`.)
+ This option is only relevant with `pandoc-citeproc`.
+
+`--citation-abbreviations=`*FILE*
+
+: Set the `citation-abbreviations` field in the document's metadata to
+ *FILE*, overriding any value set in the metadata. (This is equivalent to
+ `--metadata citation-abbreviations=FILE`.)
+ This option is only relevant with `pandoc-citeproc`.
+
+`--natbib`
+
+: Use [`natbib`] for citations in LaTeX output. This option is not for use
+ with the `pandoc-citeproc` filter or with PDF output. It is intended for
+ use in producing a LaTeX file that can be processed with [`bibtex`].
+
+`--biblatex`
+
+: Use [`biblatex`] for citations in LaTeX output. This option is not for use
+ with the `pandoc-citeproc` filter or with PDF output. It is intended for
+ use in producing a LaTeX file that can be processed with [`bibtex`] or [`biber`].
+
+Math rendering in HTML
+----------------------
+
+`-m` [*URL*], `--latexmathml`[`=`*URL*]
+
+: Use the [LaTeXMathML] script to display embedded TeX math in HTML output.
+ To insert a link to a local copy of the `LaTeXMathML.js` script,
+ provide a *URL*. If no *URL* is provided, the contents of the
+ script will be inserted directly into the HTML header, preserving
+ portability at the price of efficiency. If you plan to use math on
+ several pages, it is much better to link to a copy of the script,
+ so it can be cached.
+
+`--mathml`
+
+: Convert TeX math to [MathML] (in `docbook4`, `docbook5`,
+ `html4` and `html5`).
+
+`--jsmath`[`=`*URL*]
+
+: Use [jsMath] to display embedded TeX math in HTML output.
+ The *URL* should point to the jsMath load script (e.g.
+ `jsMath/easy/load.js`); if provided, it will be linked to in
+ the header of standalone HTML documents. If a *URL* is not provided,
+ no link to the jsMath load script will be inserted; it is then
+ up to the author to provide such a link in the HTML template.
+
+`--mathjax`[`=`*URL*]
+
+: Use [MathJax] to display embedded TeX math in HTML output.
+ The *URL* should point to the `MathJax.js` load script.
+ If a *URL* is not provided, a link to the MathJax CDN will
+ be inserted.
+
+`--gladtex`
+
+: Enclose TeX math in `<eq>` tags in HTML output. These can then
+ be processed by [gladTeX] to produce links to images of the typeset
+ formulas.
+
+`--mimetex`[`=`*URL*]
+
+: Render TeX math using the [mimeTeX] CGI script. If *URL* is not
+ specified, it is assumed that the script is at `/cgi-bin/mimetex.cgi`.
+
+`--webtex`[`=`*URL*]
+
+: Render TeX formulas using an external script that converts TeX
+ formulas to images. The formula will be concatenated with the URL
+ provided. If *URL* is not specified, the CodeCogs will be used.
+ Note: the `--webtex` option will affect Markdown output
+ as well as HTML, which is useful if you're targeting a
+ version of Markdown without native math support.
+
+`--katex`[`=`*URL*]
+
+: Use [KaTeX] to display embedded TeX math in HTML output.
+ The *URL* should point to the `katex.js` load script. If a *URL* is
+ not provided, a link to the KaTeX CDN will be inserted.
+ Note: [KaTeX] seems to work best with `html5` output.
+
+`--katex-stylesheet=`*URL*
+
+: The *URL* should point to the `katex.css` stylesheet. If this option is
+ not specified, a link to the KaTeX CDN will be inserted. Note that this
+ option does not imply `--katex`.
+
+[MathML]: http://www.w3.org/Math/
+[LaTeXMathML]: http://math.etsu.edu/LaTeXMathML/
+[jsMath]: http://www.math.union.edu/~dpvc/jsmath/
+[MathJax]: https://www.mathjax.org
+[gladTeX]: http://ans.hsh.no/home/mgg/gladtex/
+[mimeTeX]: http://www.forkosh.com/mimetex.html
+[KaTeX]: https://github.com/Khan/KaTeX
+
+Options for wrapper scripts
+---------------------------
+
+`--dump-args`
+
+: Print information about command-line arguments to *stdout*, then exit.
+ This option is intended primarily for use in wrapper scripts.
+ The first line of output contains the name of the output file specified
+ with the `-o` option, or `-` (for *stdout*) if no output file was
+ specified. The remaining lines contain the command-line arguments,
+ one per line, in the order they appear. These do not include regular
+ pandoc options and their arguments, but do include any options appearing
+ after a `--` separator at the end of the line.
+
+`--ignore-args`
+
+: Ignore command-line arguments (for use in wrapper scripts).
+ Regular pandoc options are not ignored. Thus, for example,
+
+ pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1
+
+ is equivalent to
+
+ pandoc -o foo.html -s
+
+Templates
+=========
+
+When the `-s/--standalone` option is used, pandoc uses a template to
+add header and footer material that is needed for a self-standing
+document. To see the default template that is used, just type
+
+ pandoc -D *FORMAT*
+
+where *FORMAT* is the name of the output format. A custom template
+can be specified using the `--template` option. You can also override
+the system default templates for a given output format *FORMAT*
+by putting a file `templates/default.*FORMAT*` in the user data
+directory (see `--data-dir`, above). *Exceptions:*
+
+- For `odt` output, customize the `default.opendocument`
+ template.
+- For `pdf` output, customize the `default.latex` template
+ (or the `default.beamer` template, if you use `-t beamer`,
+ or the `default.context` template, if you use `-t context`).
+- `docx` has no template (however, you can use
+ `--reference-doc` to customize the output).
+
+Templates contain *variables*, which allow for the inclusion of
+arbitrary information at any point in the file. Variables may be set
+within the document using [YAML metadata blocks][Extension:
+`yaml_metadata_block`]. They may also be set at the
+command line using the `-V/--variable` option: variables set in this
+way override metadata fields with the same name.
+
+Variables set by pandoc
+-----------------------
+
+Some variables are set automatically by pandoc. These vary somewhat
+depending on the output format, but include metadata fields as well
+as the following:
+
+`title`, `author`, `date`
+: allow identification of basic aspects of the document. Included
+ in PDF metadata through LaTeX and ConTeXt. These can be set
+ through a [pandoc title block][Extension: `pandoc_title_block`],
+ which allows for multiple authors, or through a YAML metadata block:
+
+ ---
+ author:
+ - Aristotle
+ - Peter Abelard
+ ...
+
+`subtitle`
+: document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, and Word docx;
+ renders in LaTeX only when using a document class that supports
+ `\subtitle`, such as `beamer` or the [KOMA-Script] series (`scrartcl`,
+ `scrreprt`, `scrbook`).[^subtitle]
+
+`institute`
+: author affiliations (in LaTeX and Beamer only). Can be a
+ list, when there are multiple authors.
+
+`abstract`
+: document summary, included in LaTeX, ConTeXt, AsciiDoc, and Word docx
+
+`keywords`
+: list of keywords to be included in HTML, PDF, and AsciiDoc metadata;
+ may be repeated as for `author`, above
+
+`header-includes`
+: contents specified by `-H/--include-in-header` (may have multiple
+ values)
+
+`toc`
+: non-null value if `--toc/--table-of-contents` was specified
+
+`toc-title`
+: title of table of contents (works only with EPUB and docx)
+
+`include-before`
+: contents specified by `-B/--include-before-body` (may have
+ multiple values)
+
+`include-after`
+: contents specified by `-A/--include-after-body` (may have
+ multiple values)
+
+`body`
+: body of document
+
+`meta-json`
+: JSON representation of all of the document's metadata
+
+[^subtitle]: To make `subtitle` work with other LaTeX
+ document classes, you can add the following to `header-includes`:
+
+ \providecommand{\subtitle}[1]{%
+ \usepackage{titling}
+ \posttitle{%
+ \par\large#1\end{center}}
+ }
+
+Language variables
+------------------
+
+`lang`
+: identifies the main language of the document,
+ using a code according to [BCP 47] (e.g. `en` or `en-GB`).
+ For some output formats, pandoc will convert it to an appropriate
+ format stored in the additional variables `babel-lang`,
+ `polyglossia-lang` (LaTeX) and `context-lang` (ConTeXt).
+
+ Native pandoc `span`s and `div`s with the lang attribute
+ (value in BCP 47) can be used to switch the language in
+ that range.
+
+`otherlangs`
+: a list of other languages used in the document
+ in the YAML metadata, according to [BCP 47]. For example:
+ `otherlangs: [en-GB, fr]`.
+ This is automatically generated from the `lang` attributes
+ in all `span`s and `div`s but can be overridden.
+ Currently only used by LaTeX through the generated
+ `babel-otherlangs` and `polyglossia-otherlangs` variables.
+ The LaTeX writer outputs polyglossia commands in the text but
+ the `babel-newcommands` variable contains mappings for them
+ to the corresponding babel.
+
+`dir`
+: the base direction of the document, either `rtl` (right-to-left)
+ or `ltr` (left-to-right).
+
+ For bidirectional documents, native pandoc `span`s and `div`s
+ with the `dir` attribute (value `rtl` or `ltr`) can be used to
+ override the base direction in some output formats.
+ This may not always be necessary if the final renderer
+ (e.g. the browser, when generating HTML) supports the
+ [Unicode Bidirectional Algorithm].
+
+ When using LaTeX for bidirectional documents, only the `xelatex` engine
+ is fully supported (use `--latex-engine=xelatex`).
+
+[BCP 47]: https://tools.ietf.org/html/bcp47
+[Unicode Bidirectional Algorithm]: http://www.w3.org/International/articles/inline-bidi-markup/uba-basics
+
+Variables for slides
+--------------------
+
+Variables are available for [producing slide shows with pandoc],
+including all [reveal.js configuration options].
+
+`titlegraphic`
+: title graphic for Beamer documents
+
+`logo`
+: logo for Beamer documents
+
+`slidy-url`
+: base URL for Slidy documents (defaults to
+ `http://www.w3.org/Talks/Tools/Slidy2`)
+
+`slideous-url`
+: base URL for Slideous documents (defaults to `slideous`)
+
+`s5-url`
+: base URL for S5 documents (defaults to `s5/default`)
+
+`revealjs-url`
+: base URL for reveal.js documents (defaults to `reveal.js`)
+
+`theme`, `colortheme`, `fonttheme`, `innertheme`, `outertheme`
+: themes for LaTeX [`beamer`] documents
+
+`themeoptions`
+: options for LaTeX beamer themes (a list).
+
+`navigation`
+: controls navigation symbols in `beamer` documents
+ (default is `empty` for no navigation symbols; other valid values
+ are `frame`, `vertical`, and `horizontal`).
+
+`section-titles`
+: enables on "title pages" for new sections in `beamer`
+ documents (default = true).
+
+`beamerarticle`
+: when true, the `beamerarticle` package is loaded (for
+ producing an article from beamer slides).
+
+`colorlinks`
+: add color to link text; automatically enabled if any of `linkcolor`, `citecolor`,
+ `urlcolor`, or `toccolor` are set (for beamer only).
+
+`linkcolor`, `citecolor`, `urlcolor`, `toccolor`
+: color for internal links, citation links, external links, and links in table
+ of contents: uses any of the [predefined LaTeX colors] (for beamer only).
+
+[reveal.js configuration options]: https://github.com/hakimel/reveal.js#configuration
+
+Variables for LaTeX
+-------------------
+
+LaTeX variables are used when [creating a PDF].
+
+`papersize`
+: paper size, e.g. `letter`, `A4`
+
+`fontsize`
+: font size for body text (e.g. `10pt`, `12pt`)
+
+`documentclass`
+: document class, e.g. [`article`], [`report`], [`book`], [`memoir`]
+
+`classoption`
+: option for document class, e.g. `oneside`; may be repeated
+ for multiple options
+
+`geometry`
+: option for [`geometry`] package, e.g. `margin=1in`;
+ may be repeated for multiple options
+
+`margin-left`, `margin-right`, `margin-top`, `margin-bottom`
+: sets margins, if `geometry` is not used (otherwise `geometry`
+ overrides these)
+
+`linestretch`
+: adjusts line spacing using the [`setspace`]
+ package, e.g. `1.25`, `1.5`
+
+`fontfamily`
+: font package for use with `pdflatex`:
+ [TeX Live] includes many options, documented in the [LaTeX Font Catalogue].
+ The default is [Latin Modern][`lm`].
+
+`fontfamilyoptions`
+: options for package used as `fontfamily`: e.g. `osf,sc` with
+ `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`
+: 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`
+: 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
+ `Numbers=OldStyle,Numbers=Proportional`. May be repeated for multiple options.
+
+`fontenc`
+: allows font encoding to be specified through `fontenc` package (with `pdflatex`);
+ default is `T1` (see guide to [LaTeX font encodings])
+
+`microtypeoptions`
+: options to pass to the microtype package
+
+`colorlinks`
+: add color to link text; automatically enabled if any of `linkcolor`, `citecolor`,
+ `urlcolor`, or `toccolor` are set
+
+`linkcolor`, `citecolor`, `urlcolor`, `toccolor`
+: color for internal links, citation links, external links, and links in table of contents:
+ uses any of the [predefined LaTeX colors]
+
+`links-as-notes`
+: causes links to be printed as footnotes
+
+`indent`
+: uses document class settings for indentation (the default LaTeX template
+ otherwise removes indentation and adds space between paragraphs)
+
+`subparagraph`
+: disables default behavior of LaTeX template that redefines (sub)paragraphs
+ as sections, changing the appearance of nested headings in some classes
+
+`thanks`
+: specifies contents of acknowledgments footnote after document title.
+
+`toc`
+: include table of contents (can also be set using `--toc/--table-of-contents`)
+
+`toc-depth`
+: level of section to include in table of contents
+
+`secnumdepth`
+: numbering depth for sections, if sections are numbered
+
+`lof`, `lot`
+: include list of figures, list of tables
+
+`bibliography`
+: bibliography to use for resolving references
+
+`biblio-style`
+: bibliography style, when used with `--natbib` and `--biblatex`.
+
+`biblio-title`
+: bibliography title, when used with `--natbib` and `--biblatex`.
+
+`biblatexoptions`
+: list of options for biblatex.
+
+[`article`]: https://ctan.org/pkg/article
+[`report`]: https://ctan.org/pkg/report
+[`book`]: https://ctan.org/pkg/book
+[KOMA-Script]: https://ctan.org/pkg/koma-script
+[`memoir`]: https://ctan.org/pkg/memoir
+[predefined LaTeX colors]: https://en.wikibooks.org/wiki/LaTeX/Colors#Predefined_colors
+[LaTeX Font Catalogue]: http://www.tug.dk/FontCatalogue/
+[`mathpazo`]: https://ctan.org/pkg/mathpazo
+[LaTeX font encodings]: https://ctan.org/pkg/encguide
+
+Variables for ConTeXt
+---------------------
+
+`papersize`
+: paper size, e.g. `letter`, `A4`, `landscape` (see [ConTeXt Paper Setup]);
+ may be repeated for multiple options
+
+`layout`
+: options for page margins and text arrangement (see [ConTeXt Layout]);
+ may be repeated for multiple options
+
+`margin-left`, `margin-right`, `margin-top`, `margin-bottom`
+: sets margins, if `layout` is not used (otherwise `layout`
+ overrides these)
+
+`fontsize`
+: font size for body text (e.g. `10pt`, `12pt`)
+
+`mainfont`, `sansfont`, `monofont`, `mathfont`
+: font families: take the name of any system font (see [ConTeXt Font Switching])
+
+`linkcolor`, `contrastcolor`
+: color for links outside and inside a page, e.g. `red`, `blue` (see [ConTeXt Color])
+
+`linkstyle`
+: typeface style for links, e.g. `normal`, `bold`, `slanted`, `boldslanted`, `type`, `cap`, `small`
+
+`indenting`
+: controls indentation of paragraphs, e.g. `yes,small,next` (see [ConTeXt Indentation]);
+ may be repeated for multiple options
+
+`whitespace`
+: spacing between paragraphs, e.g. `none`, `small` (using [`setupwhitespace`])
+
+`interlinespace`
+: adjusts line spacing, e.g. `4ex` (using [`setupinterlinespace`]);
+ may be repeated for multiple options
+
+`headertext`, `footertext`
+: text to be placed in running header or footer (see [ConTeXt Headers and Footers]);
+ may be repeated up to four times for different placement
+
+`pagenumbering`
+: page number style and location (using [`setuppagenumbering`]);
+ may be repeated for multiple options
+
+`toc`
+: include table of contents (can also be set using `--toc/--table-of-contents`)
+
+`lof`, `lot`
+: include list of figures, list of tables
+
+[ConTeXt Paper Setup]: http://wiki.contextgarden.net/PaperSetup
+[ConTeXt Layout]: http://wiki.contextgarden.net/Layout
+[ConTeXt Font Switching]: http://wiki.contextgarden.net/Font_Switching
+[ConTeXt Color]: http://wiki.contextgarden.net/Color
+[ConTeXt Headers and Footers]: http://wiki.contextgarden.net/Headers_and_Footers
+[ConTeXt Indentation]: http://wiki.contextgarden.net/Indentation
+[`setupwhitespace`]: http://wiki.contextgarden.net/Command/setupwhitespace
+[`setupinterlinespace`]: http://wiki.contextgarden.net/Command/setupinterlinespace
+[`setuppagenumbering`]: http://wiki.contextgarden.net/Command/setuppagenumbering
+
+Variables for man pages
+-----------------------
+
+`section`
+: section number in man pages
+
+`header`
+: header in man pages
+
+`footer`
+: footer in man pages
+
+`adjusting`
+: adjusts text to left (`l`), right (`r`), center (`c`),
+ or both (`b`) margins
+
+`hyphenate`
+: if `true` (the default), hyphenation will be used
+
+Using variables in templates
+----------------------------
+
+Variable names are sequences of alphanumerics, `-`, and `_`,
+starting with a letter. A variable name surrounded by `$` signs
+will be replaced by its value. For example, the string `$title$` in
+
+ <title>$title$</title>
+
+will be replaced by the document title.
+
+To write a literal `$` in a template, use `$$`.
+
+Templates may contain conditionals. The syntax is as follows:
+
+ $if(variable)$
+ X
+ $else$
+ Y
+ $endif$
+
+This will include `X` in the template if `variable` has a non-null
+value; otherwise it will include `Y`. `X` and `Y` are placeholders for
+any valid template text, and may include interpolated variables or other
+conditionals. The `$else$` section may be omitted.
+
+When variables can have multiple values (for example, `author` in
+a multi-author document), you can use the `$for$` keyword:
+
+ $for(author)$
+ <meta name="author" content="$author$" />
+ $endfor$
+
+You can optionally specify a separator to be used between
+consecutive items:
+
+ $for(author)$$author$$sep$, $endfor$
+
+A dot can be used to select a field of a variable that takes
+an object as its value. So, for example:
+
+ $author.name$ ($author.affiliation$)
+
+If you use custom templates, you may need to revise them as pandoc
+changes. We recommend tracking the changes in the default templates,
+and modifying your custom templates accordingly. An easy way to do this
+is to fork the [pandoc-templates] repository and merge in changes after each
+pandoc release.
+
+[pandoc-templates]: https://github.com/jgm/pandoc-templates
+
+Pandoc's Markdown
+=================
+
+Pandoc understands an extended and slightly revised version of
+John Gruber's [Markdown] syntax. This document explains the syntax,
+noting differences from standard Markdown. Except where noted, these
+differences can be suppressed by using the `markdown_strict` format instead
+of `markdown`. An extensions can be enabled by adding `+EXTENSION`
+to the format name and disabled by adding `-EXTENSION`. For example,
+`markdown_strict+footnotes` is strict Markdown with footnotes
+enabled, while `markdown-footnotes-pipe_tables` is pandoc's
+Markdown without footnotes or pipe tables.
+
+Philosophy
+----------
+
+Markdown is designed to be easy to write, and, even more importantly,
+easy to read:
+
+> A Markdown-formatted document should be publishable as-is, as plain
+> text, without looking like it's been marked up with tags or formatting
+> instructions.
+> -- [John Gruber](http://daringfireball.net/projects/markdown/syntax#philosophy)
+
+This principle has guided pandoc's decisions in finding syntax for
+tables, footnotes, and other extensions.
+
+There is, however, one respect in which pandoc's aims are different
+from the original aims of Markdown. Whereas Markdown was originally
+designed with HTML generation in mind, pandoc is designed for multiple
+output formats. Thus, while pandoc allows the embedding of raw HTML,
+it discourages it, and provides other, non-HTMLish ways of representing
+important document elements like definition lists, tables, mathematics, and
+footnotes.
+
+Paragraphs
+----------
+
+A paragraph is one or more lines of text followed by one or more blank lines.
+Newlines are treated as spaces, so you can reflow your paragraphs as you like.
+If you need a hard line break, put two or more spaces at the end of a line.
+
+#### Extension: `escaped_line_breaks` ####
+
+A backslash followed by a newline is also a hard line break.
+Note: in multiline and grid table cells, this is the only way
+to create a hard line break, since trailing spaces in the cells
+are ignored.
+
+Headers
+-------
+
+There are two kinds of headers: Setext and ATX.
+
+### Setext-style headers ###
+
+A setext-style header is a line of text "underlined" with a row of `=` signs
+(for a level one header) or `-` signs (for a level two header):
+
+ A level-one header
+ ==================
+
+ A level-two header
+ ------------------
+
+The header text can contain inline formatting, such as emphasis (see
+[Inline formatting], below).
+
+
+### ATX-style headers ###
+
+An ATX-style header consists of one to six `#` signs and a line of
+text, optionally followed by any number of `#` signs. The number of
+`#` signs at the beginning of the line is the header level:
+
+ ## A level-two header
+
+ ### A level-three header ###
+
+As with setext-style headers, the header text can contain formatting:
+
+ # A level-one header with a [link](/url) and *emphasis*
+
+#### Extension: `blank_before_header` ####
+
+Standard Markdown syntax does not require a blank line before a header.
+Pandoc does require this (except, of course, at the beginning of the
+document). The reason for the requirement is that it is all too easy for a
+`#` to end up at the beginning of a line by accident (perhaps through line
+wrapping). Consider, for example:
+
+ I like several of their flavors of ice cream:
+ #22, for example, and #5.
+
+
+### Header identifiers ###
+
+#### Extension: `header_attributes` ####
+
+Headers can be assigned attributes using this syntax at the end
+of the line containing the header text:
+
+ {#identifier .class .class key=value key=value}
+
+Thus, for example, the following headers will all be assigned the identifier
+`foo`:
+
+ # My header {#foo}
+
+ ## My header ## {#foo}
+
+ My other header {#foo}
+ ---------------
+
+(This syntax is compatible with [PHP Markdown Extra].)
+
+Note that although this syntax allows assignment of classes and key/value
+attributes, writers generally don't use all of this information. Identifiers,
+classes, and key/value attributes are used in HTML and HTML-based formats such
+as EPUB and slidy. Identifiers are used for labels and link anchors in the
+LaTeX, ConTeXt, Textile, and AsciiDoc writers.
+
+Headers with the class `unnumbered` will not be numbered, even if
+`--number-sections` is specified. A single hyphen (`-`) in an attribute
+context is equivalent to `.unnumbered`, and preferable in non-English
+documents. So,
+
+ # My header {-}
+
+is just the same as
+
+ # My header {.unnumbered}
+
+#### Extension: `auto_identifiers` ####
+
+A header without an explicitly specified identifier will be
+automatically assigned a unique identifier based on the header text.
+To derive the identifier from the header text,
+
+ - Remove all formatting, links, etc.
+ - Remove all footnotes.
+ - Remove all punctuation, except underscores, hyphens, and periods.
+ - Replace all spaces and newlines with hyphens.
+ - Convert all alphabetic characters to lowercase.
+ - Remove everything up to the first letter (identifiers may
+ not begin with a number or punctuation mark).
+ - If nothing is left after this, use the identifier `section`.
+
+Thus, for example,
+
+ Header Identifier
+ ------------------------------- ----------------------------
+ `Header identifiers in HTML` `header-identifiers-in-html`
+ `*Dogs*?--in *my* house?` `dogs--in-my-house`
+ `[HTML], [S5], or [RTF]?` `html-s5-or-rtf`
+ `3. Applications` `applications`
+ `33` `section`
+
+These rules should, in most cases, allow one to determine the identifier
+from the header text. The exception is when several headers have the
+same text; in this case, the first will get an identifier as described
+above; the second will get the same identifier with `-1` appended; the
+third with `-2`; and so on.
+
+These identifiers are used to provide link targets in the table of
+contents generated by the `--toc|--table-of-contents` option. They
+also make it easy to provide links from one section of a document to
+another. A link to this section, for example, might look like this:
+
+ See the section on
+ [header identifiers](#header-identifiers-in-html-latex-and-context).
+
+Note, however, that this method of providing links to sections works
+only in HTML, LaTeX, and ConTeXt formats.
+
+If the `--section-divs` option is specified, then each section will
+be wrapped in a `div` (or a `section`, if `html5` was specified),
+and the identifier will be attached to the enclosing `<div>`
+(or `<section>`) tag rather than the header itself. This allows entire
+sections to be manipulated using JavaScript or treated differently in
+CSS.
+
+#### Extension: `implicit_header_references` ####
+
+Pandoc behaves as if reference links have been defined for each header.
+So, to link to a header
+
+ # Header identifiers in HTML
+
+you can simply write
+
+ [Header identifiers in HTML]
+
+or
+
+ [Header identifiers in HTML][]
+
+or
+
+ [the section on header identifiers][header identifiers in
+ HTML]
+
+instead of giving the identifier explicitly:
+
+ [Header identifiers in HTML](#header-identifiers-in-html)
+
+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.
+
+Like regular reference links, these references are case-insensitive.
+
+Explicit link reference definitions always take priority over
+implicit header references. So, in the following example, the
+link will point to `bar`, not to `#foo`:
+
+ # Foo
+
+ [foo]: bar
+
+ See [foo]
+
+Block quotations
+----------------
+
+Markdown uses email conventions for quoting blocks of text.
+A block quotation is one or more paragraphs or other block elements
+(such as lists or headers), with each line preceded by a `>` character
+and an optional space. (The `>` need not start at the left margin, but
+it should not be indented more than three spaces.)
+
+ > This is a block quote. This
+ > paragraph has two lines.
+ >
+ > 1. This is a list inside a block quote.
+ > 2. Second item.
+
+A "lazy" form, which requires the `>` character only on the first
+line of each block, is also allowed:
+
+ > This is a block quote. This
+ paragraph has two lines.
+
+ > 1. This is a list inside a block quote.
+ 2. Second item.
+
+Among the block elements that can be contained in a block quote are
+other block quotes. That is, block quotes can be nested:
+
+ > This is a block quote.
+ >
+ > > A block quote within a block quote.
+
+If the `>` character is followed by an optional space, that space
+will be considered part of the block quote marker and not part of
+the indentation of the contents. Thus, to put an indented code
+block in a block quote, you need five spaces after the `>`:
+
+ > code
+
+#### Extension: `blank_before_blockquote` ####
+
+Standard Markdown syntax does not require a blank line before a block
+quote. Pandoc does require this (except, of course, at the beginning of the
+document). The reason for the requirement is that it is all too easy for a
+`>` to end up at the beginning of a line by accident (perhaps through line
+wrapping). So, unless the `markdown_strict` format is used, the following does
+not produce a nested block quote in pandoc:
+
+ > This is a block quote.
+ >> Nested.
+
+
+Verbatim (code) blocks
+----------------------
+
+### Indented code blocks ###
+
+A block of text indented four spaces (or one tab) is treated as verbatim
+text: that is, special characters do not trigger special formatting,
+and all spaces and line breaks are preserved. For example,
+
+ if (a > 3) {
+ moveShip(5 * gravity, DOWN);
+ }
+
+The initial (four space or one tab) indentation is not considered part
+of the verbatim text, and is removed in the output.
+
+Note: blank lines in the verbatim text need not begin with four spaces.
+
+
+### Fenced code blocks ###
+
+#### Extension: `fenced_code_blocks` ####
+
+In addition to standard indented code blocks, pandoc supports
+*fenced* code blocks. These begin with a row of three or more
+tildes (`~`) and end with a row of tildes that must be at least as long as
+the starting row. Everything between these lines is treated as code. No
+indentation is necessary:
+
+ ~~~~~~~
+ if (a > 3) {
+ moveShip(5 * gravity, DOWN);
+ }
+ ~~~~~~~
+
+Like regular code blocks, fenced code blocks must be separated
+from surrounding text by blank lines.
+
+If the code itself contains a row of tildes or backticks, just use a longer
+row of tildes or backticks at the start and end:
+
+ ~~~~~~~~~~~~~~~~
+ ~~~~~~~~~~
+ code including tildes
+ ~~~~~~~~~~
+ ~~~~~~~~~~~~~~~~
+
+#### Extension: `backtick_code_blocks` ####
+
+Same as `fenced_code_blocks`, but uses backticks (`` ` ``) instead of tildes
+(`~`).
+
+#### Extension: `fenced_code_attributes` ####
+
+Optionally, you may attach attributes to fenced or backtick code block using
+this syntax:
+
+ ~~~~ {#mycode .haskell .numberLines startFrom="100"}
+ qsort [] = []
+ qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
+ qsort (filter (>= x) xs)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Here `mycode` is an identifier, `haskell` and `numberLines` are classes, and
+`startFrom` is an attribute with value `100`. Some output formats can use this
+information to do syntax highlighting. Currently, the only output formats
+that uses this information are HTML and LaTeX. If highlighting is supported
+for your output format and language, then the code block above will appear
+highlighted, with numbered lines. (To see which languages are supported, type
+`pandoc --list-highlight-languages`.) Otherwise, the code block above will
+appear as follows:
+
+ <pre id="mycode" class="haskell numberLines" startFrom="100">
+ <code>
+ ...
+ </code>
+ </pre>
+
+A shortcut form can also be used for specifying the language of
+the code block:
+
+ ```haskell
+ qsort [] = []
+ ```
+
+This is equivalent to:
+
+ ``` {.haskell}
+ qsort [] = []
+ ```
+
+If the `fenced_code_attributes` extension is disabled, but
+input contains class attribute(s) for the code block, the first
+class attribute will be printed after the opening fence as a bare
+word.
+
+To prevent all highlighting, use the `--no-highlight` flag.
+To set the highlighting style, use `--highlight-style`.
+For more information on highlighting, see [Syntax highlighting],
+below.
+
+Line blocks
+-----------
+
+#### Extension: `line_blocks` ####
+
+A line block is a sequence of lines beginning with a vertical bar (`|`)
+followed by a space. The division into lines will be preserved in
+the output, as will any leading spaces; otherwise, the lines will
+be formatted as Markdown. This is useful for verse and addresses:
+
+ | The limerick packs laughs anatomical
+ | In space that is quite economical.
+ | But the good ones I've seen
+ | So seldom are clean
+ | And the clean ones so seldom are comical
+
+ | 200 Main St.
+ | Berkeley, CA 94718
+
+The lines can be hard-wrapped if needed, but the continuation
+line must begin with a space.
+
+ | The Right Honorable Most Venerable and Righteous Samuel L.
+ Constable, Jr.
+ | 200 Main St.
+ | Berkeley, CA 94718
+
+This syntax is borrowed from [reStructuredText].
+
+Lists
+-----
+
+### Bullet lists ###
+
+A bullet list is a list of bulleted list items. A bulleted list
+item begins with a bullet (`*`, `+`, or `-`). Here is a simple
+example:
+
+ * one
+ * two
+ * three
+
+This will produce a "compact" list. If you want a "loose" list, in which
+each item is formatted as a paragraph, put spaces between the items:
+
+ * one
+
+ * two
+
+ * three
+
+The bullets need not be flush with the left margin; they may be
+indented one, two, or three spaces. The bullet must be followed
+by whitespace.
+
+List items look best if subsequent lines are flush with the first
+line (after the bullet):
+
+ * here is my first
+ list item.
+ * and my second.
+
+But Markdown also allows a "lazy" format:
+
+ * here is my first
+ list item.
+ * and my second.
+
+### The four-space rule ###
+
+A list item may contain multiple paragraphs and other block-level
+content. However, subsequent paragraphs must be preceded by a blank line
+and indented four spaces or a tab. The list will look better if the first
+paragraph is aligned with the rest:
+
+ * First paragraph.
+
+ Continued.
+
+ * Second paragraph. With a code block, which must be indented
+ eight spaces:
+
+ { code }
+
+List items may include other lists. In this case the preceding blank
+line is optional. The nested list must be indented four spaces or
+one tab:
+
+ * fruits
+ + apples
+ - macintosh
+ - red delicious
+ + pears
+ + peaches
+ * vegetables
+ + broccoli
+ + chard
+
+As noted above, Markdown allows you to write list items "lazily," instead of
+indenting continuation lines. However, if there are multiple paragraphs or
+other blocks in a list item, the first line of each must be indented.
+
+ + A lazy, lazy, list
+ item.
+
+ + Another one; this looks
+ bad but is legal.
+
+ Second paragraph of second
+ list item.
+
+**Note:** Although the four-space rule for continuation paragraphs
+comes from the official [Markdown syntax guide], the reference implementation,
+`Markdown.pl`, does not follow it. So pandoc will give different results than
+`Markdown.pl` when authors have indented continuation paragraphs fewer than
+four spaces.
+
+The [Markdown syntax guide] is not explicit whether the four-space
+rule applies to *all* block-level content in a list item; it only
+mentions paragraphs and code blocks. But it implies that the rule
+applies to all block-level content (including nested lists), and
+pandoc interprets it that way.
+
+ [Markdown syntax guide]:
+ http://daringfireball.net/projects/markdown/syntax#list
+
+### Ordered lists ###
+
+Ordered lists work just like bulleted lists, except that the items
+begin with enumerators rather than bullets.
+
+In standard Markdown, enumerators are decimal numbers followed
+by a period and a space. The numbers themselves are ignored, so
+there is no difference between this list:
+
+ 1. one
+ 2. two
+ 3. three
+
+and this one:
+
+ 5. one
+ 7. two
+ 1. three
+
+#### Extension: `fancy_lists` ####
+
+Unlike standard Markdown, pandoc allows ordered list items to be marked
+with uppercase and lowercase letters and roman numerals, in addition to
+Arabic numerals. List markers may be enclosed in parentheses or followed by a
+single right-parentheses or period. They must be separated from the
+text that follows by at least one space, and, if the list marker is a
+capital letter with a period, by at least two spaces.[^2]
+
+[^2]: The point of this rule is to ensure that normal paragraphs
+ starting with people's initials, like
+
+ B. Russell was an English philosopher.
+
+ do not get treated as list items.
+
+ This rule will not prevent
+
+ (C) 2007 Joe Smith
+
+ from being interpreted as a list item. In this case, a backslash
+ escape can be used:
+
+ (C\) 2007 Joe Smith
+
+The `fancy_lists` extension also allows '`#`' to be used as an
+ordered list marker in place of a numeral:
+
+ #. one
+ #. two
+
+#### Extension: `startnum` ####
+
+Pandoc also pays attention to the type of list marker used, and to the
+starting number, and both of these are preserved where possible in the
+output format. Thus, the following yields a list with numbers followed
+by a single parenthesis, starting with 9, and a sublist with lowercase
+roman numerals:
+
+ 9) Ninth
+ 10) Tenth
+ 11) Eleventh
+ i. subone
+ ii. subtwo
+ iii. subthree
+
+Pandoc will start a new list each time a different type of list
+marker is used. So, the following will create three lists:
+
+ (2) Two
+ (5) Three
+ 1. Four
+ * Five
+
+If default list markers are desired, use `#.`:
+
+ #. one
+ #. two
+ #. three
+
+
+### Definition lists ###
+
+#### Extension: `definition_lists` ####
+
+Pandoc supports definition lists, using the syntax of
+[PHP Markdown Extra] with some extensions.[^3]
+
+ Term 1
+
+ : Definition 1
+
+ Term 2 with *inline markup*
+
+ : Definition 2
+
+ { some code, part of Definition 2 }
+
+ Third paragraph of definition 2.
+
+Each term must fit on one line, which may optionally be followed by
+a blank line, and must be followed by one or more definitions.
+A definition begins with a colon or tilde, which may be indented one
+or two spaces.
+
+A term may have multiple definitions, and each definition may consist of one or
+more block elements (paragraph, code block, list, etc.), each indented four
+spaces or one tab stop. The body of the definition (including the first line,
+aside from the colon or tilde) should be indented four spaces. However,
+as with other Markdown lists, you can "lazily" omit indentation except
+at the beginning of a paragraph or other block element:
+
+ Term 1
+
+ : Definition
+ with lazy continuation.
+
+ Second paragraph of the definition.
+
+If you leave space before the definition (as in the example above),
+the text of the definition will be treated as a paragraph. In some
+output formats, this will mean greater spacing between term/definition
+pairs. For a more compact definition list, omit the space before the
+definition:
+
+ Term 1
+ ~ Definition 1
+
+ Term 2
+ ~ Definition 2a
+ ~ Definition 2b
+
+Note that space between items in a definition list is required.
+(A variant that loosens this requirement, but disallows "lazy"
+hard wrapping, can be activated with `compact_definition_lists`: see
+[Non-pandoc extensions], below.)
+
+[^3]: I have been influenced by the suggestions of [David Wheeler](http://www.justatheory.com/computers/markup/modest-markdown-proposal.html).
+
+### Numbered example lists ###
+
+#### Extension: `example_lists` ####
+
+The special list marker `@` can be used for sequentially numbered
+examples. The first list item with a `@` marker will be numbered '1',
+the next '2', and so on, throughout the document. The numbered examples
+need not occur in a single list; each new list using `@` will take up
+where the last stopped. So, for example:
+
+ (@) My first example will be numbered (1).
+ (@) My second example will be numbered (2).
+
+ Explanation of examples.
+
+ (@) My third example will be numbered (3).
+
+Numbered examples can be labeled and referred to elsewhere in the
+document:
+
+ (@good) This is a good example.
+
+ As (@good) illustrates, ...
+
+The label can be any string of alphanumeric characters, underscores,
+or hyphens.
+
+
+### Compact and loose lists ###
+
+Pandoc behaves differently from `Markdown.pl` on some "edge
+cases" involving lists. Consider this source:
+
+ + First
+ + Second:
+ - Fee
+ - Fie
+ - Foe
+
+ + Third
+
+Pandoc transforms this into a "compact list" (with no `<p>` tags around
+"First", "Second", or "Third"), while Markdown puts `<p>` tags around
+"Second" and "Third" (but not "First"), because of the blank space
+around "Third". Pandoc follows a simple rule: if the text is followed by
+a blank line, it is treated as a paragraph. Since "Second" is followed
+by a list, and not a blank line, it isn't treated as a paragraph. The
+fact that the list is followed by a blank line is irrelevant. (Note:
+Pandoc works this way even when the `markdown_strict` format is specified. This
+behavior is consistent with the official Markdown syntax description,
+even though it is different from that of `Markdown.pl`.)
+
+
+### Ending a list ###
+
+What if you want to put an indented code block after a list?
+
+ - item one
+ - item two
+
+ { my code block }
+
+Trouble! Here pandoc (like other Markdown implementations) will treat
+`{ my code block }` as the second paragraph of item two, and not as
+a code block.
+
+To "cut off" the list after item two, you can insert some non-indented
+content, like an HTML comment, which won't produce visible output in
+any format:
+
+ - item one
+ - item two
+
+ <!-- end of list -->
+
+ { my code block }
+
+You can use the same trick if you want two consecutive lists instead
+of one big list:
+
+ 1. one
+ 2. two
+ 3. three
+
+ <!-- -->
+
+ 1. uno
+ 2. dos
+ 3. tres
+
+Horizontal rules
+----------------
+
+A line containing a row of three or more `*`, `-`, or `_` characters
+(optionally separated by spaces) produces a horizontal rule:
+
+ * * * *
+
+ ---------------
+
+
+Tables
+------
+
+Four kinds of tables may be used. The first three kinds presuppose the use of
+a fixed-width font, such as Courier. The fourth kind can be used with
+proportionally spaced fonts, as it does not require lining up columns.
+
+#### Extension: `table_captions` ####
+
+A caption may optionally be provided with all 4 kinds of tables (as
+illustrated in the examples below). A caption is a paragraph beginning
+with the string `Table:` (or just `:`), which will be stripped off.
+It may appear either before or after the table.
+
+#### Extension: `simple_tables` ####
+
+Simple tables look like this:
+
+ Right Left Center Default
+ ------- ------ ---------- -------
+ 12 12 12 12
+ 123 123 123 123
+ 1 1 1 1
+
+ Table: Demonstration of simple table syntax.
+
+The 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:[^4]
+
+ - If the dashed line is flush with the header text on the right side
+ but extends beyond it on the left, the column is right-aligned.
+ - If the dashed line is flush with the header text on the left side
+ but extends beyond it on the right, the column is left-aligned.
+ - If the dashed line extends beyond the header text on both sides,
+ the column is centered.
+ - If the dashed line is flush with the header text on both sides,
+ the default alignment is used (in most cases, this will be left).
+
+[^4]: This scheme is due to Michel Fortin, who proposed it on the
+ [Markdown discussion list](http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html).
+
+The table must end with a blank line, or a line of dashes followed by
+a blank line.
+
+The column headers may be omitted, provided a dashed line is used
+to end the table. For example:
+
+ ------- ------ ---------- -------
+ 12 12 12 12
+ 123 123 123 123
+ 1 1 1 1
+ ------- ------ ---------- -------
+
+When 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.
+
+#### Extension: `multiline_tables` ####
+
+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:
+
+ -------------------------------------------------------------
+ Centered Default Right Left
+ Header Aligned Aligned Aligned
+ ----------- ------- --------------- -------------------------
+ First row 12.0 Example of a row that
+ spans multiple lines.
+
+ Second row 5.0 Here's another one. Note
+ the blank line between
+ rows.
+ -------------------------------------------------------------
+
+ Table: Here's the caption. It, too, may span
+ multiple lines.
+
+These work like simple tables, but with the following differences:
+
+ - They must begin with a row of dashes, before the header text
+ (unless the headers are omitted).
+ - They must end with a row of dashes, then a blank line.
+ - The rows must be separated by blank lines.
+
+In multiline tables, the table parser pays attention to the widths of
+the columns, and the writers try to reproduce these relative widths in
+the output. So, if you find that one of the columns is too narrow in the
+output, try widening it in the Markdown source.
+
+Headers may be omitted in multiline tables as well as simple tables:
+
+ ----------- ------- --------------- -------------------------
+ First row 12.0 Example of a row that
+ spans multiple lines.
+
+ Second row 5.0 Here's another one. Note
+ the blank line between
+ rows.
+ ----------- ------- --------------- -------------------------
+
+ : Here's a multiline table without headers.
+
+It is possible for a multiline table to have just one row, but the row
+should be followed by a blank line (and then the row of dashes that ends
+the table), or the table may be interpreted as a simple table.
+
+#### Extension: `grid_tables` ####
+
+Grid tables look like this:
+
+ : Sample grid table.
+
+ +---------------+---------------+--------------------+
+ | Fruit | Price | Advantages |
+ +===============+===============+====================+
+ | Bananas | $1.34 | - built-in wrapper |
+ | | | - bright color |
+ +---------------+---------------+--------------------+
+ | Oranges | $2.10 | - cures scurvy |
+ | | | - tasty |
+ +---------------+---------------+--------------------+
+
+The row of `=`s separates the header from the table body, and can be
+omitted for a headerless table. The cells of grid tables may contain
+arbitrary block elements (multiple paragraphs, code blocks, lists,
+etc.). Cells that span multiple columns or rows are not
+supported. Grid tables can be created easily using [Emacs table mode].
+
+[Emacs table mode]: http://table.sourceforge.net/
+
+Alignments can be specified as with pipe tables, by putting
+colons at the boundaries of the separator line after the
+header:
+
+ +---------------+---------------+--------------------+
+ | Right | Left | Centered |
+ +==============:+:==============+:==================:+
+ | Bananas | $1.34 | built-in wrapper |
+ +---------------+---------------+--------------------+
+
+For headerless tables, the colons go on the top line instead:
+
+ +--------------:+:--------------+:------------------:+
+ | Right | Left | Centered |
+ +---------------+---------------+--------------------+
+
+
+#### Extension: `pipe_tables` ####
+
+Pipe tables look like this:
+
+ | Right | Left | Default | Center |
+ |------:|:-----|---------|:------:|
+ | 12 | 12 | 12 | 12 |
+ | 123 | 123 | 123 | 123 |
+ | 1 | 1 | 1 | 1 |
+
+ : Demonstration of pipe table syntax.
+
+The syntax is identical to [PHP Markdown Extra tables]. The beginning and
+ending pipe characters are optional, but pipes are required between all
+columns. The colons indicate column alignment as shown. The header
+cannot be omitted. To simulate a headerless table, include a header
+with blank cells.
+
+Since the pipes indicate column boundaries, columns need not be vertically
+aligned, as they are in the above example. So, this is a perfectly
+legal (though ugly) pipe table:
+
+ fruit| price
+ -----|-----:
+ apple|2.05
+ pear|1.37
+ orange|3.09
+
+The cells of pipe tables cannot contain block elements like paragraphs
+and lists, and cannot span multiple lines. If a pipe table contains a
+row whose printable content is wider than the column width (see
+`--columns`), then the cell contents will wrap, with the
+relative cell widths determined by the widths of the separator
+lines.
+
+Note: pandoc also recognizes pipe tables of the following
+form, as can be produced by Emacs' orgtbl-mode:
+
+ | One | Two |
+ |-----+-------|
+ | my | table |
+ | is | nice |
+
+The difference is that `+` is used instead of `|`. Other orgtbl features
+are not supported. In particular, to get non-default column alignment,
+you'll need to add colons as above.
+
+[PHP Markdown Extra tables]: https://michelf.ca/projects/php-markdown/extra/#table
+
+Metadata blocks
+---------------
+
+#### Extension: `pandoc_title_block` ####
+
+If the file begins with a title block
+
+ % title
+ % author(s) (separated by semicolons)
+ % date
+
+it will be parsed as bibliographic information, not regular text. (It
+will be used, for example, in the title of standalone LaTeX or HTML
+output.) The block may contain just a title, a title and an author,
+or all three elements. If you want to include an author but no
+title, or a title and a date but no author, you need a blank line:
+
+ %
+ % Author
+
+ % My title
+ %
+ % June 15, 2006
+
+The title may occupy multiple lines, but continuation lines must
+begin with leading space, thus:
+
+ % My title
+ on multiple lines
+
+If a document has multiple authors, the authors may be put on
+separate lines with leading space, or separated by semicolons, or
+both. So, all of the following are equivalent:
+
+ % Author One
+ Author Two
+
+ % Author One; Author Two
+
+ % Author One;
+ Author Two
+
+The date must fit on one line.
+
+All three metadata fields may contain standard inline formatting
+(italics, links, footnotes, etc.).
+
+Title blocks will always be parsed, but they will affect the output only
+when the `--standalone` (`-s`) option is chosen. In HTML output, titles
+will appear twice: once in the document head -- this is the title that
+will appear at the top of the window in a browser -- and once at the
+beginning of the document body. The title in the document head can have
+an optional prefix attached (`--title-prefix` or `-T` option). The title
+in the body appears as an H1 element with class "title", so it can be
+suppressed or reformatted with CSS. If a title prefix is specified with
+`-T` and no title block appears in the document, the title prefix will
+be used by itself as the HTML title.
+
+The man page writer extracts a title, man page section number, and
+other header and footer information from the title line. The title
+is assumed to be the first word on the title line, which may optionally
+end with a (single-digit) section number in parentheses. (There should
+be no space between the title and the parentheses.) Anything after
+this is assumed to be additional footer and header text. A single pipe
+character (`|`) should be used to separate the footer text from the header
+text. Thus,
+
+ % PANDOC(1)
+
+will yield a man page with the title `PANDOC` and section 1.
+
+ % PANDOC(1) Pandoc User Manuals
+
+will also have "Pandoc User Manuals" in the footer.
+
+ % PANDOC(1) Pandoc User Manuals | Version 4.0
+
+will also have "Version 4.0" in the header.
+
+#### Extension: `yaml_metadata_block` ####
+
+A YAML metadata block is a valid YAML object, delimited by a line of three
+hyphens (`---`) at the top and a line of three hyphens (`---`) or three dots
+(`...`) at the bottom. A YAML metadata block may occur anywhere in the
+document, but if it is not at the beginning, it must be preceded by a blank
+line. (Note that, because of the way pandoc concatenates input files when
+several are provided, you may also keep the metadata in a separate YAML file
+and pass it to pandoc as an argument, along with your Markdown files:
+
+ pandoc chap1.md chap2.md chap3.md metadata.yaml -s -o book.html
+
+Just be sure that the YAML file begins with `---` and ends with `---` or
+`...`.)
+
+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.)
+
+A document may contain multiple metadata blocks. The metadata fields will
+be combined through a *left-biased union*: if two metadata blocks attempt
+to set the same field, the value from the first block will be taken.
+
+When pandoc is used with `-t markdown` to create a Markdown document,
+a YAML metadata block will be produced only if the `-s/--standalone`
+option is used. All of the metadata will appear in a single block
+at the beginning of the document.
+
+Note that YAML escaping rules must be followed. Thus, for example,
+if a title contains a colon, it must be quoted. The pipe character
+(`|`) can be used to begin an indented block that will be interpreted
+literally, without need for escaping. This form is necessary
+when the field contains blank lines:
+
+ ---
+ title: 'This is the title: it contains a colon'
+ author:
+ - Author One
+ - Author Two
+ tags: [nothing, nothingness]
+ abstract: |
+ This is the abstract.
+
+ It consists of two paragraphs.
+ ...
+
+Template variables will be set automatically from the metadata. Thus, for
+example, in writing HTML, the variable `abstract` will be set to the HTML
+equivalent of the Markdown in the `abstract` field:
+
+ <p>This is the abstract.</p>
+ <p>It consists of two paragraphs.</p>
+
+Variables can contain arbitrary YAML structures, but the template must match
+this structure. The `author` variable in the default templates expects a
+simple list or string, but can be changed to support more complicated
+structures. The following combination, for example, would add an affiliation
+to the author if one is given:
+
+ ---
+ title: The document title
+ author:
+ - name: Author One
+ affiliation: University of Somewhere
+ - name: Author Two
+ affiliation: University of Nowhere
+ ...
+
+To use the structured authors in the example above, you would need a custom
+template:
+
+ $for(author)$
+ $if(author.name)$
+ $author.name$$if(author.affiliation)$ ($author.affiliation$)$endif$
+ $else$
+ $author$
+ $endif$
+ $endfor$
+
+
+Backslash escapes
+-----------------
+
+#### Extension: `all_symbols_escapable` ####
+
+Except inside a code block or inline code, any punctuation or space
+character preceded by a backslash will be treated literally, even if it
+would normally indicate formatting. Thus, for example, if one writes
+
+ *\*hello\**
+
+one will get
+
+ <em>*hello*</em>
+
+instead of
+
+ <strong>hello</strong>
+
+This rule is easier to remember than standard Markdown's rule,
+which allows only the following characters to be backslash-escaped:
+
+ \`*_{}[]()>#+-.!
+
+(However, if the `markdown_strict` format is used, the standard Markdown rule
+will be used.)
+
+A backslash-escaped space is parsed as a nonbreaking space. It will
+appear in TeX output as `~` and in HTML and XML as `\&#160;` or
+`\&nbsp;`.
+
+A backslash-escaped newline (i.e. a backslash occurring at the end of
+a line) is parsed as a hard line break. It will appear in TeX output as
+`\\` and in HTML as `<br />`. This is a nice alternative to
+Markdown's "invisible" way of indicating hard line breaks using
+two trailing spaces on a line.
+
+Backslash escapes do not work in verbatim contexts.
+
+Inline formatting
+-----------------
+
+### Emphasis ###
+
+To *emphasize* some text, surround it with `*`s or `_`, like this:
+
+ This text is _emphasized with underscores_, and this
+ is *emphasized with asterisks*.
+
+Double `*` or `_` produces **strong emphasis**:
+
+ This is **strong emphasis** and __with underscores__.
+
+A `*` or `_` character surrounded by spaces, or backslash-escaped,
+will not trigger emphasis:
+
+ This is * not emphasized *, and \*neither is this\*.
+
+#### Extension: `intraword_underscores` ####
+
+Because `_` is sometimes used inside words and identifiers,
+pandoc does not interpret a `_` surrounded by alphanumeric
+characters as an emphasis marker. If you want to emphasize
+just part of a word, use `*`:
+
+ feas*ible*, not feas*able*.
+
+
+### Strikeout ###
+
+#### Extension: `strikeout` ####
+
+To strikeout a section of text with a horizontal line, begin and end it
+with `~~`. Thus, for example,
+
+ This ~~is deleted text.~~
+
+
+### Superscripts and subscripts ###
+
+#### Extension: `superscript`, `subscript` ####
+
+Superscripts may be written by surrounding the superscripted text by `^`
+characters; subscripts may be written by surrounding the subscripted
+text by `~` characters. Thus, for example,
+
+ H~2~O is a liquid. 2^10^ is 1024.
+
+If the superscripted or subscripted text contains spaces, these spaces
+must be escaped with backslashes. (This is to prevent accidental
+superscripting and subscripting through the ordinary use of `~` and `^`.)
+Thus, if you want the letter P with 'a cat' in subscripts, use
+`P~a\ cat~`, not `P~a cat~`.
+
+
+### Verbatim ###
+
+To make a short span of text verbatim, put it inside backticks:
+
+ What is the difference between `>>=` and `>>`?
+
+If the verbatim text includes a backtick, use double backticks:
+
+ Here is a literal backtick `` ` ``.
+
+(The spaces after the opening backticks and before the closing
+backticks will be ignored.)
+
+The general rule is that a verbatim span starts with a string
+of consecutive backticks (optionally followed by a space)
+and ends with a string of the same number of backticks (optionally
+preceded by a space).
+
+Note that backslash-escapes (and other Markdown constructs) do not
+work in verbatim contexts:
+
+ This is a backslash followed by an asterisk: `\*`.
+
+#### Extension: `inline_code_attributes` ####
+
+Attributes can be attached to verbatim text, just as with
+[fenced code blocks]:
+
+ `<$>`{.haskell}
+
+### Small caps ###
+
+To write small caps, you can use an HTML span tag:
+
+ <span style="font-variant:small-caps;">Small caps</span>
+
+(The semicolon is optional and there may be space after the
+colon.) This will work in all output formats that support small caps.
+
+Alternatively, you can also use the new `bracketed_spans` syntax:
+
+ [Small caps]{style="font-variant:small-caps;"}
+
+Math
+----
+
+#### Extension: `tex_math_dollars` ####
+
+Anything between two `$` characters will be treated as TeX math. The
+opening `$` must have a non-space character immediately to its right,
+while the closing `$` must have a non-space character immediately to its
+left, and must not be followed immediately by a digit. Thus,
+`$20,000 and $30,000` won't parse as math. If for some reason
+you need to enclose text in literal `$` characters, backslash-escape
+them and they won't be treated as math delimiters.
+
+TeX math will be printed in all output formats. How it is rendered
+depends on the output format:
+
+Markdown, LaTeX, Emacs Org mode, ConTeXt, ZimWiki
+ ~ It will appear verbatim between `$` characters.
+
+reStructuredText
+ ~ It will be rendered using an [interpreted text role `:math:`].
+
+AsciiDoc
+ ~ It will be rendered as `latexmath:[...]`.
+
+Texinfo
+ ~ It will be rendered inside a `@math` command.
+
+groff man
+ ~ It will be rendered verbatim without `$`'s.
+
+MediaWiki, DokuWiki
+ ~ It will be rendered inside `<math>` tags.
+
+Textile
+ ~ It will be rendered inside `<span class="math">` tags.
+
+RTF, OpenDocument, ODT
+ ~ It will be rendered, if possible, using Unicode characters,
+ and will otherwise appear verbatim.
+
+DocBook
+ ~ If the `--mathml` flag is used, it will be rendered using MathML
+ in an `inlineequation` or `informalequation` tag. Otherwise it
+ will be rendered, if possible, using Unicode characters.
+
+Docx
+ ~ It will be rendered using OMML math markup.
+
+FictionBook2
+ ~ If the `--webtex` option is used, formulas are rendered as images
+ using CodeCogs or other compatible web service, downloaded
+ and embedded in the e-book. Otherwise, they will appear verbatim.
+
+HTML, Slidy, DZSlides, S5, EPUB
+ ~ The way math is rendered in HTML will depend on the
+ command-line options selected:
+
+ 1. The default is to render TeX math as far as possible using Unicode
+ characters, as with RTF, DocBook, and OpenDocument output. Formulas
+ are put inside a `span` with `class="math"`, so that they may be
+ styled differently from the surrounding text if needed.
+
+ 2. If the `--latexmathml` option is used, TeX math will be displayed
+ between `$` or `$$` characters and put in `<span>` tags with class `LaTeX`.
+ The [LaTeXMathML] script will be used to render it as formulas.
+ (This trick does not work in all browsers, but it works in Firefox.
+ In browsers that do not support LaTeXMathML, TeX math will appear
+ verbatim between `$` characters.)
+
+ 3. If the `--jsmath` option is used, TeX math will be put inside
+ `<span>` tags (for inline math) or `<div>` tags (for display math)
+ with class `math`. The [jsMath] script will be used to render
+ it.
+
+ 4. If the `--mimetex` option is used, the [mimeTeX] CGI script will
+ be called to generate images for each TeX formula. This should
+ work in all browsers. The `--mimetex` option takes an optional URL
+ as argument. If no URL is specified, it will be assumed that the
+ mimeTeX CGI script is at `/cgi-bin/mimetex.cgi`.
+
+ 5. If the `--gladtex` option is used, TeX formulas will be enclosed
+ in `<eq>` tags in the HTML output. The resulting `htex` file may then
+ be processed by [gladTeX], which will produce image files for each
+ formula and an HTML file with links to these images. So, the
+ procedure is:
+
+ pandoc -s --gladtex myfile.txt -o myfile.htex
+ gladtex -d myfile-images myfile.htex
+ # produces myfile.html and images in myfile-images
+
+ 6. If the `--webtex` option is used, TeX formulas will be converted
+ to `<img>` tags that link to an external script that converts
+ formulas to images. The formula will be URL-encoded and concatenated
+ with the URL provided. If no URL is specified, the CodeCogs
+ will be used (`https://latex.codecogs.com/png.latex?`).
+
+ 7. If the `--mathjax` option is used, TeX math will be displayed
+ between `\(...\)` (for inline math) or `\[...\]` (for display
+ math) and put in `<span>` tags with class `math`.
+ The [MathJax] script will be used to render it as formulas.
+
+[interpreted text role `:math:`]: http://docutils.sourceforge.net/docs/ref/rst/roles.html#math
+
+Raw HTML
+--------
+
+#### Extension: `raw_html` ####
+
+Markdown allows you to insert raw HTML (or DocBook) anywhere in a document
+(except verbatim contexts, where `<`, `>`, and `&` are interpreted
+literally). (Technically this is not an extension, since standard
+Markdown allows it, but it has been made an extension so that it can
+be disabled if desired.)
+
+The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous,
+DZSlides, EPUB, Markdown, Emacs Org mode, and Textile output, and suppressed
+in other formats.
+
+#### Extension: `markdown_in_html_blocks` ####
+
+Standard Markdown allows you to include HTML "blocks": blocks
+of HTML between balanced tags that are separated from the surrounding text
+with blank lines, and start and end at the left margin. Within
+these blocks, everything is interpreted as HTML, not Markdown;
+so (for example), `*` does not signify emphasis.
+
+Pandoc behaves this way when the `markdown_strict` format is used; but
+by default, pandoc interprets material between HTML block tags as Markdown.
+Thus, for example, pandoc will turn
+
+ <table>
+ <tr>
+ <td>*one*</td>
+ <td>[a link](http://google.com)</td>
+ </tr>
+ </table>
+
+into
+
+ <table>
+ <tr>
+ <td><em>one</em></td>
+ <td><a href="http://google.com">a link</a></td>
+ </tr>
+ </table>
+
+whereas `Markdown.pl` will preserve it as is.
+
+There is one exception to this rule: text between `<script>` and
+`<style>` tags is not interpreted as Markdown.
+
+This departure from standard Markdown should make it easier to mix
+Markdown with HTML block elements. For example, one can surround
+a block of Markdown text with `<div>` tags without preventing it
+from being interpreted as Markdown.
+
+#### Extension: `native_divs` ####
+
+Use native pandoc `Div` blocks for content inside `<div>` tags.
+For the most part this should give the same output as
+`markdown_in_html_blocks`, but it makes it easier to write pandoc
+filters to manipulate groups of blocks.
+
+#### Extension: `native_spans` ####
+
+Use native pandoc `Span` blocks for content inside `<span>` tags.
+For the most part this should give the same output as `raw_html`,
+but it makes it easier to write pandoc filters to manipulate groups
+of inlines.
+
+Raw TeX
+-------
+
+#### Extension: `raw_tex` ####
+
+In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be
+included in a document. Inline TeX commands will be preserved and passed
+unchanged to the LaTeX and ConTeXt writers. Thus, for example, you can use
+LaTeX to include BibTeX citations:
+
+ This result was proved in \cite{jones.1967}.
+
+Note that in LaTeX environments, like
+
+ \begin{tabular}{|l|l|}\hline
+ Age & Frequency \\ \hline
+ 18--25 & 15 \\
+ 26--35 & 33 \\
+ 36--45 & 22 \\ \hline
+ \end{tabular}
+
+the material between the begin and end tags will be interpreted as raw
+LaTeX, not as Markdown.
+
+Inline LaTeX is ignored in output formats other than Markdown, LaTeX,
+Emacs Org mode, and ConTeXt.
+
+LaTeX macros
+------------
+
+#### Extension: `latex_macros` ####
+
+For output formats other than LaTeX, pandoc will parse LaTeX `\newcommand` and
+`\renewcommand` definitions and apply the resulting macros to all LaTeX
+math. So, for example, the following will work in all output formats,
+not just LaTeX:
+
+ \newcommand{\tuple}[1]{\langle #1 \rangle}
+
+ $\tuple{a, b, c}$
+
+In LaTeX output, the `\newcommand` definition will simply be passed
+unchanged to the output.
+
+
+Links
+-----
+
+Markdown allows links to be specified in several ways.
+
+### Automatic links ###
+
+If you enclose a URL or email address in pointy brackets, it
+will become a link:
+
+ <http://google.com>
+ <sam@green.eggs.ham>
+
+### Inline links ###
+
+An inline link consists of the link text in square brackets,
+followed by the URL in parentheses. (Optionally, the URL can
+be followed by a link title, in quotes.)
+
+ This is an [inline link](/url), and here's [one with
+ a title](http://fsf.org "click here for a good time!").
+
+There can be no space between the bracketed part and the parenthesized part.
+The link text can contain formatting (such as emphasis), but the title cannot.
+
+Email addresses in inline links are not autodetected, so they have to be
+prefixed with `mailto`:
+
+ [Write me!](mailto:sam@green.eggs.ham)
+
+### Reference links ###
+
+An *explicit* reference link has two parts, the link itself and the link
+definition, which may occur elsewhere in the document (either
+before or after the link).
+
+The link consists of link text in square brackets, followed by a label in
+square brackets. (There can be space between the two.) The link definition
+consists of the bracketed label, followed by a colon and a space, followed by
+the URL, and optionally (after a space) a link title either in quotes or in
+parentheses. The label must not be parseable as a citation (assuming
+the `citations` extension is enabled): citations take precedence over
+link labels.
+
+Here are some examples:
+
+ [my label 1]: /foo/bar.html "My title, optional"
+ [my label 2]: /foo
+ [my label 3]: http://fsf.org (The free software foundation)
+ [my label 4]: /bar#special 'A title in single quotes'
+
+The URL may optionally be surrounded by angle brackets:
+
+ [my label 5]: <http://foo.bar.baz>
+
+The title may go on the next line:
+
+ [my label 3]: http://fsf.org
+ "The free software foundation"
+
+Note that link labels are not case sensitive. So, this will work:
+
+ Here is [my link][FOO]
+
+ [Foo]: /bar/baz
+
+In an *implicit* reference link, the second pair of brackets is
+empty:
+
+ See [my website][].
+
+ [my website]: http://foo.bar.baz
+
+Note: In `Markdown.pl` and most other Markdown implementations,
+reference link definitions cannot occur in nested constructions
+such as list items or block quotes. Pandoc lifts this arbitrary
+seeming restriction. So the following is fine in pandoc, though
+not in most other implementations:
+
+ > My block [quote].
+ >
+ > [quote]: /foo
+
+#### Extension: `shortcut_reference_links` ####
+
+In a *shortcut* reference link, the second pair of brackets may
+be omitted entirely:
+
+ See [my website].
+
+ [my website]: http://foo.bar.baz
+
+### Internal links ###
+
+To link to another section of the same document, use the automatically
+generated identifier (see [Header identifiers]). For example:
+
+ See the [Introduction](#introduction).
+
+or
+
+ See the [Introduction].
+
+ [Introduction]: #introduction
+
+Internal links are currently supported for HTML formats (including
+HTML slide shows and EPUB), LaTeX, and ConTeXt.
+
+Images
+------
+
+A link immediately preceded by a `!` will be treated as an image.
+The link text will be used as the image's alt text:
+
+ ![la lune](lalune.jpg "Voyage to the moon")
+
+ ![movie reel]
+
+ [movie reel]: movie.gif
+
+#### Extension: `implicit_figures` ####
+
+An image occurring by itself in a paragraph will be rendered as
+a figure with a caption.[^5] (In LaTeX, a figure environment will be
+used; in HTML, the image will be placed in a `div` with class
+`figure`, together with a caption in a `p` with class `caption`.)
+The image's alt text will be used as the caption.
+
+ ![This is the caption](/url/of/image.png)
+
+[^5]: This feature is not yet implemented for RTF, OpenDocument, or
+ ODT. In those formats, you'll just get an image in a paragraph by
+ itself, with no caption.
+
+If you just want a regular inline image, just make sure it is not
+the only thing in the paragraph. One way to do this is to insert a
+nonbreaking space after the image:
+
+ ![This image won't be a figure](/url/of/image.png)\
+
+#### Extension: `link_attributes` ####
+
+Attributes can be set on links and images:
+
+ An inline ![image](foo.jpg){#id .class width=30 height=20px}
+ and a reference ![image][ref] with attributes.
+
+ [ref]: foo.jpg "optional title" {#id .class key=val key2="val 2"}
+
+(This syntax is compatible with [PHP Markdown Extra] when only `#id`
+and `.class` are used.)
+
+For HTML and EPUB, all attributes except `width` and `height` (but
+including `srcset` and `sizes`) are passed through as is. The other
+writers ignore attributes that are not supported by their output
+format.
+
+The `width` and `height` attributes on images are treated specially. When
+used without a unit, the unit is assumed to be pixels. However, any of
+the following unit identifiers can be used: `px`, `cm`, `mm`, `in`, `inch`
+and `%`. There must not be any spaces between the number and the unit.
+For example:
+
+```
+![](file.jpg){ width=50% }
+```
+
+- Dimensions are converted to inches for output in page-based formats like
+ LaTeX. Dimensions are converted to pixels for output in HTML-like
+ formats. Use the `--dpi` option to specify the number of pixels per
+ inch. The default is 96dpi.
+- The `%` unit is generally relative to some available space.
+ For example the above example will render to
+ `<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).
+- Some output formats have a notion of a class
+ ([ConTeXt](http://wiki.contextgarden.net/Using_Graphics#Multiple_Image_Settings))
+ or a unique identifier (LaTeX `\caption`), or both (HTML).
+- When no `width` or `height` attributes are specified, the fallback
+ is to look at the image resolution and the dpi metadata embedded in
+ the image file.
+
+Spans
+-----
+
+#### Extension: `bracketed_spans` ####
+
+A bracketed sequence of inlines, as one would use to begin
+a link, will be treated as a span with attributes if it is
+followed immediately by attributes:
+
+ [This is *some text*]{.class key="val"}
+
+Footnotes
+---------
+
+#### Extension: `footnotes` ####
+
+Pandoc's Markdown allows footnotes, using the following syntax:
+
+ Here is a footnote reference,[^1] and another.[^longnote]
+
+ [^1]: Here is the footnote.
+
+ [^longnote]: Here's one with multiple blocks.
+
+ Subsequent paragraphs are indented to show that they
+ belong to the previous footnote.
+
+ { some.code }
+
+ The whole paragraph can be indented, or just the first
+ line. In this way, multi-paragraph footnotes work like
+ multi-paragraph list items.
+
+ This paragraph won't be part of the note, because it
+ isn't indented.
+
+The identifiers in footnote references may not contain spaces, tabs,
+or newlines. These identifiers are used only to correlate the
+footnote reference with the note itself; in the output, footnotes
+will be numbered sequentially.
+
+The footnotes themselves need not be placed at the end of the
+document. They may appear anywhere except inside other block elements
+(lists, block quotes, tables, etc.). Each footnote should be
+separated from surrounding content (including other footnotes)
+by blank lines.
+
+#### Extension: `inline_notes` ####
+
+Inline footnotes are also allowed (though, unlike regular notes,
+they cannot contain multiple paragraphs). The syntax is as follows:
+
+ Here is an inline note.^[Inlines notes are easier to write, since
+ you don't have to pick an identifier and move down to type the
+ note.]
+
+Inline and regular footnotes may be mixed freely.
+
+Typography
+----------
+
+#### Extension: `smart` ####
+
+Interpret straight quotes as curly quotes, `---` as em-dashes,
+`--` as en-dashes, and `...` as ellipses. Nonbreaking spaces are
+inserted after certain abbreviations, such as "Mr." This
+option currently affects the input formats `markdown`,
+`commonmark`, `latex`, `mediawiki`, `org`, `rst`, and `twiki`,
+and the output formats `markdown`, `latex`, and `context`.
+
+Note: If you are *writing* Markdown, then the `smart` extension
+has the reverse effect: what would have been curly quotes comes
+out straight.
+
+In LaTeX, `smart` means to use the standard TeX ligatures
+for quotation marks (` `` ` and ` '' ` for double quotes,
+`` ` `` and `` ' `` for single quotes) and dashes (`--` for
+en-dash and `---` for em-dash). If `smart` is disabled,
+then in reading LaTeX pandoc will parse these characters
+literally. In writing LaTeX, enabling `smart` tells pandoc
+to use the ligatures when possible; if `smart` is disabled
+pandoc will use unicode quotation mark and dash characters.
+
+Citations
+---------
+
+#### Extension: `citations` ####
+
+Using an external filter, `pandoc-citeproc`, pandoc can automatically generate
+citations and a bibliography in a number of styles. Basic usage is
+
+ pandoc --filter pandoc-citeproc myinput.txt
+
+In order to use this feature, you will need to specify a bibliography file
+using the `bibliography` metadata field in a YAML metadata section, or
+`--bibliography` command line argument. You can supply multiple `--bibliography`
+arguments or set `bibliography` metadata field to YAML array, if you want to
+use multiple bibliography files. The bibliography may have any of these
+formats:
+
+ Format File extension
+ ------------ --------------
+ BibLaTeX .bib
+ BibTeX .bibtex
+ Copac .copac
+ CSL JSON .json
+ CSL YAML .yaml
+ EndNote .enl
+ EndNote XML .xml
+ ISI .wos
+ MEDLINE .medline
+ MODS .mods
+ RIS .ris
+
+Note that `.bib` can be used with both BibTeX and BibLaTeX files;
+use `.bibtex` to force BibTeX.
+
+Note that `pandoc-citeproc --bib2json` and `pandoc-citeproc --bib2yaml`
+can produce `.json` and `.yaml` files from any of the supported formats.
+
+In-field markup: In BibTeX and BibLaTeX databases, pandoc-citeproc parses
+a subset of LaTeX markup; in CSL YAML databases, pandoc Markdown; and in CSL JSON databases, an [HTML-like markup][CSL markup specs]:
+
+`<i>...</i>`
+: italics
+
+`<b>...</b>`
+: bold
+
+`<span style="font-variant:small-caps;">...</span>` or `<sc>...</sc>`
+: small capitals
+
+`<sub>...</sub>`
+: subscript
+
+`<sup>...</sup>`
+: superscript
+
+`<span class="nocase">...</span>`
+: prevent a phrase from being capitalized as title case
+
+`pandoc-citeproc -j` and `-y` interconvert the CSL JSON
+and CSL YAML formats as far as possible.
+
+As an alternative to specifying a bibliography file using `--bibliography`
+or the YAML metadata field `bibliography`, you can include
+the citation data directly in the `references` field of the
+document's YAML metadata. The field should contain an array of
+YAML-encoded references, for example:
+
+ ---
+ references:
+ - type: article-journal
+ id: WatsonCrick1953
+ author:
+ - family: Watson
+ given: J. D.
+ - family: Crick
+ given: F. H. C.
+ issued:
+ date-parts:
+ - - 1953
+ - 4
+ - 25
+ title: 'Molecular structure of nucleic acids: a structure for deoxyribose
+ nucleic acid'
+ title-short: Molecular structure of nucleic acids
+ container-title: Nature
+ volume: 171
+ issue: 4356
+ page: 737-738
+ DOI: 10.1038/171737a0
+ URL: http://www.nature.com/nature/journal/v171/n4356/abs/171737a0.html
+ language: en-GB
+ ...
+
+(`pandoc-citeproc --bib2yaml` can produce these from a bibliography file in one
+of the supported formats.)
+
+Citations and references can be formatted using any style supported by the
+[Citation Style Language], listed in the [Zotero Style Repository].
+These files are specified using the `--csl` option or the `csl` metadata field.
+By default, `pandoc-citeproc` will use the [Chicago Manual of Style] author-date
+format. The CSL project provides further information on [finding and editing styles].
+
+To make your citations hyperlinks to the corresponding bibliography
+entries, add `link-citations: true` to your YAML metadata.
+
+Citations go inside square brackets and are separated by semicolons.
+Each citation must have a key, composed of '@' + the citation
+identifier from the database, and may optionally have a prefix,
+a locator, and a suffix. The citation key must begin with a letter, digit,
+or `_`, and may contain alphanumerics, `_`, and internal punctuation
+characters (`:.#$%&-+?<>~/`). Here are some examples:
+
+ Blah blah [see @doe99, pp. 33-35; also @smith04, chap. 1].
+
+ Blah blah [@doe99, pp. 33-35, 38-39 and *passim*].
+
+ Blah blah [@smith04; @doe99].
+
+`pandoc-citeproc` detects locator terms in the [CSL locale files].
+Either abbreviated or unabbreviated forms are accepted. In the `en-US`
+locale, locator terms can be written in either singular or plural forms,
+as `book`, `bk.`/`bks.`; `chapter`, `chap.`/`chaps.`; `column`,
+`col.`/`cols.`; `figure`, `fig.`/`figs.`; `folio`, `fol.`/`fols.`;
+`number`, `no.`/`nos.`; `line`, `l.`/`ll.`; `note`, `n.`/`nn.`; `opus`,
+`op.`/`opp.`; `page`, `p.`/`pp.`; `paragraph`, `para.`/`paras.`; `part`,
+`pt.`/`pts.`; `section`, `sec.`/`secs.`; `sub verbo`, `s.v.`/`s.vv.`;
+`verse`, `v.`/`vv.`; `volume`, `vol.`/`vols.`; `¶`/`¶¶`; `§`/`§§`. If no
+locator term is used, "page" is assumed.
+
+A minus sign (`-`) before the `@` will suppress mention of
+the author in the citation. This can be useful when the
+author is already mentioned in the text:
+
+ Smith says blah [-@smith04].
+
+You can also write an in-text citation, as follows:
+
+ @smith04 says blah.
+
+ @smith04 [p. 33] says blah.
+
+If the style calls for a list of works cited, it will be placed
+at the end of the document. Normally, you will want to end your
+document with an appropriate header:
+
+ last paragraph...
+
+ # References
+
+The bibliography will be inserted after this header. Note that
+the `unnumbered` class will be added to this header, so that the
+section will not be numbered.
+
+If you want to include items in the bibliography without actually
+citing them in the body text, you can define a dummy `nocite` metadata
+field and put the citations there:
+
+ ---
+ nocite: |
+ @item1, @item2
+ ...
+
+ @item3
+
+In this example, the document will contain a citation for `item3`
+only, but the bibliography will contain entries for `item1`, `item2`, and
+`item3`.
+
+It is possible to create a bibliography with all the citations,
+whether or not they appear in the document, by using a wildcard:
+
+ ---
+ nocite: |
+ @*
+ ...
+
+For LaTeX or PDF output, you can also use [`natbib`] or [`biblatex`]
+to render bibliography. In order to do so, specify bibliography files as
+outlined above, and add `--natbib` or `--biblatex` argument to `pandoc`
+invocation. Bear in mind that bibliography files have to be in respective
+format (either BibTeX or BibLaTeX).
+
+For more information, see the [pandoc-citeproc man page].
+
+[CSL markup specs]: http://docs.citationstyles.org/en/1.0/release-notes.html#rich-text-markup-within-fields
+[Chicago Manual of Style]: http://chicagomanualofstyle.org
+[Citation Style Language]: http://citationstyles.org
+[Zotero Style Repository]: https://www.zotero.org/styles
+[finding and editing styles]: http://citationstyles.org/styles/
+[CSL locale files]: https://github.com/citation-style-language/locales
+[pandoc-citeproc man page]: https://github.com/jgm/pandoc-citeproc/blob/master/man/pandoc-citeproc.1.md
+
+Non-pandoc extensions
+---------------------
+
+The following Markdown syntax extensions are not enabled by default
+in pandoc, but may be enabled by adding `+EXTENSION` to the format
+name, where `EXTENSION` is the name of the extension. Thus, for
+example, `markdown+hard_line_breaks` is Markdown with hard line breaks.
+
+#### Extension: `old_dashes` ####
+
+Selects the pandoc <= 1.8.2.1 behavior for parsing smart dashes:
+`-` before a numeral is an en-dash, and `--` is an em-dash.
+This option only has an effect if `smart` is enabled. It is
+selected automatically for `textile` input.
+
+#### Extension: `angle_brackets_escapable` ####
+
+Allow `<` and `>` to be backslash-escaped, as they can be in
+GitHub flavored Markdown but not original Markdown. This is
+implied by pandoc's default `all_symbols_escapable`.
+
+#### Extension: `lists_without_preceding_blankline` ####
+
+Allow a list to occur right after a paragraph, with no intervening
+blank space.
+
+#### Extension: `hard_line_breaks` ####
+
+Causes all newlines within a paragraph to be interpreted as hard line
+breaks instead of spaces.
+
+#### Extension: `ignore_line_breaks` ####
+
+Causes newlines within a paragraph to be ignored, rather than being
+treated as spaces or as hard line breaks. This option is intended for
+use with East Asian languages where spaces are not used between words,
+but text is divided into lines for readability.
+
+#### Extension: `east_asian_line_breaks` ####
+
+Causes newlines within a paragraph to be ignored, rather than
+being treated as spaces or as hard line breaks, when they occur
+between two East Asian wide characters. This is a better choice
+than `ignore_line_breaks` for texts that include a mix of East
+Asian wide characters and other characters.
+
+##### Extension: `emoji` ####
+
+Parses textual emojis like `:smile:` as Unicode emoticons.
+
+#### Extension: `tex_math_single_backslash` ####
+
+Causes anything between `\(` and `\)` to be interpreted as inline
+TeX math, and anything between `\[` and `\]` to be interpreted
+as display TeX math. Note: a drawback of this extension is that
+it precludes escaping `(` and `[`.
+
+#### Extension: `tex_math_double_backslash` ####
+
+Causes anything between `\\(` and `\\)` to be interpreted as inline
+TeX math, and anything between `\\[` and `\\]` to be interpreted
+as display TeX math.
+
+#### Extension: `markdown_attribute` ####
+
+By default, pandoc interprets material inside block-level tags as Markdown.
+This extension changes the behavior so that Markdown is only parsed
+inside block-level tags if the tags have the attribute `markdown=1`.
+
+#### Extension: `mmd_title_block` ####
+
+Enables a [MultiMarkdown] style title block at the top of
+the document, for example:
+
+ Title: My title
+ Author: John Doe
+ Date: September 1, 2008
+ Comment: This is a sample mmd title block, with
+ a field spanning multiple lines.
+
+See the MultiMarkdown documentation for details. If `pandoc_title_block` or
+`yaml_metadata_block` is enabled, it will take precedence over
+`mmd_title_block`.
+
+#### Extension: `abbreviations` ####
+
+Parses PHP Markdown Extra abbreviation keys, like
+
+ *[HTML]: Hypertext Markup Language
+
+Note that the pandoc document model does not support
+abbreviations, so if this extension is enabled, abbreviation keys are
+simply skipped (as opposed to being parsed as paragraphs).
+
+#### Extension: `autolink_bare_uris` ####
+
+Makes all absolute URIs into links, even when not surrounded by
+pointy braces `<...>`.
+
+#### Extension: `ascii_identifiers` ####
+
+Causes the identifiers produced by `auto_identifiers` to be pure ASCII.
+Accents are stripped off of accented Latin letters, and non-Latin
+letters are omitted.
+
+#### Extension: `mmd_link_attributes` ####
+
+Parses multimarkdown style key-value attributes on link
+and image references. This extension should not be confused with the
+[`link_attributes`](#extension-link_attributes) extension.
+
+ This is a reference ![image][ref] with multimarkdown attributes.
+
+ [ref]: http://path.to/image "Image title" width=20px height=30px
+ id=myId class="myClass1 myClass2"
+
+#### Extension: `mmd_header_identifiers` ####
+
+Parses multimarkdown style header identifiers (in square brackets,
+after the header but before any trailing `#`s in an ATX header).
+
+#### Extension: `compact_definition_lists` ####
+
+Activates the definition list syntax of pandoc 1.12.x and earlier.
+This syntax differs from the one described above under [Definition lists]
+in several respects:
+
+ - No blank line is required between consecutive items of the
+ definition list.
+ - To get a "tight" or "compact" list, omit space between consecutive
+ items; the space between a term and its definition does not affect
+ anything.
+ - Lazy wrapping of paragraphs is not allowed: the entire definition must
+ be indented four spaces.[^6]
+
+[^6]: To see why laziness is incompatible with relaxing the requirement
+ of a blank line between items, consider the following example:
+
+ bar
+ : definition
+ foo
+ : definition
+
+ Is this a single list item with two definitions of "bar," the first of
+ which is lazily wrapped, or two list items? To remove the ambiguity
+ we must either disallow lazy wrapping or require a blank line between
+ list items.
+
+Markdown variants
+-----------------
+
+In addition to pandoc's extended Markdown, the following Markdown
+variants are supported:
+
+`markdown_phpextra` (PHP Markdown Extra)
+: `footnotes`, `pipe_tables`, `raw_html`, `markdown_attribute`,
+ `fenced_code_blocks`, `definition_lists`, `intraword_underscores`,
+ `header_attributes`, `link_attributes`, `abbreviations`,
+ `shortcut_reference_links`.
+
+`markdown_github` (GitHub-Flavored Markdown)
+: `pipe_tables`, `raw_html`, `fenced_code_blocks`, `auto_identifiers`,
+ `ascii_identifiers`, `backtick_code_blocks`, `autolink_bare_uris`,
+ `intraword_underscores`, `strikeout`, `hard_line_breaks`, `emoji`,
+ `shortcut_reference_links`, `angle_brackets_escapable`.
+
+`markdown_mmd` (MultiMarkdown)
+: `pipe_tables`, `raw_html`, `markdown_attribute`, `mmd_link_attributes`,
+ `tex_math_double_backslash`, `intraword_underscores`,
+ `mmd_title_block`, `footnotes`, `definition_lists`,
+ `all_symbols_escapable`, `implicit_header_references`,
+ `auto_identifiers`, `mmd_header_identifiers`,
+ `shortcut_reference_links`.
+
+`markdown_strict` (Markdown.pl)
+: `raw_html`
+
+Extensions with formats other than Markdown
+-------------------------------------------
+
+Some of the extensions discussed above can be used with formats
+other than Markdown:
+
+* `auto_identifiers` can be used with `latex`, `rst`, `mediawiki`,
+ and `textile` input (and is used by default).
+
+* `tex_math_dollars`, `tex_math_single_backslash`, and
+ `tex_math_double_backslash` can be used with `html` input.
+ (This is handy for reading web pages formatted using MathJax,
+ for example.)
+
+Producing slide shows with pandoc
+=================================
+
+You can use pandoc to produce an HTML + JavaScript slide presentation
+that can be viewed via a web browser. There are five ways to do this,
+using [S5], [DZSlides], [Slidy], [Slideous], or [reveal.js].
+You can also produce a PDF slide show using LaTeX [`beamer`].
+
+Here's the Markdown source for a simple slide show, `habits.txt`:
+
+ % Habits
+ % John Doe
+ % March 22, 2005
+
+ # In the morning
+
+ ## Getting up
+
+ - Turn off alarm
+ - Get out of bed
+
+ ## Breakfast
+
+ - Eat eggs
+ - Drink coffee
+
+ # In the evening
+
+ ## Dinner
+
+ - Eat spaghetti
+ - Drink wine
+
+ ------------------
+
+ ![picture of spaghetti](images/spaghetti.jpg)
+
+ ## Going to sleep
+
+ - Get in bed
+ - Count sheep
+
+To produce an HTML/JavaScript slide show, simply type
+
+ pandoc -t FORMAT -s habits.txt -o habits.html
+
+where `FORMAT` is either `s5`, `slidy`, `slideous`, `dzslides`, or `revealjs`.
+
+For Slidy, Slideous, reveal.js, and S5, the file produced by pandoc with the
+`-s/--standalone` option embeds a link to JavaScript and CSS files, which are
+assumed to be available at the relative path `s5/default` (for S5), `slideous`
+(for Slideous), `reveal.js` (for reveal.js), or at the Slidy website at
+`w3.org` (for Slidy). (These paths can be changed by setting the `slidy-url`,
+`slideous-url`, `revealjs-url`, or `s5-url` variables; see [Variables for slides],
+above.) For DZSlides, the (relatively short) JavaScript and CSS are included in
+the file by default.
+
+With all HTML slide formats, the `--self-contained` option can be used to
+produce a single file that contains all of the data necessary to display the
+slide show, including linked scripts, stylesheets, images, and videos.
+
+To produce a PDF slide show using beamer, type
+
+ pandoc -t beamer habits.txt -o habits.pdf
+
+Note that a reveal.js slide show can also be converted to a PDF
+by printing it to a file from the browser.
+
+Structuring the slide show
+--------------------------
+
+By default, the *slide level* 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 `--slide-level` option.
+
+The document is carved up into slides according to the following
+rules:
+
+ * A horizontal rule always starts a new slide.
+
+ * A header at the slide level always starts a new slide.
+
+ * Headers *below* the slide level in the hierarchy create
+ headers *within* a slide.
+
+ * Headers *above* the slide level in the hierarchy create
+ "title slides," which just contain the section title
+ and help to break the slide show into sections.
+
+ * A title page is constructed automatically from the document's title
+ block, if present. (In the case of beamer, this can be disabled
+ by commenting out some lines in the default template.)
+
+These rules are designed to support many different styles of slide show. If
+you don't care about structuring your slides into sections and subsections,
+you can just use level 1 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.
+
+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.
+
+Incremental lists
+-----------------
+
+By default, these writers produce lists that display "all at once."
+If you want your lists to display incrementally (one item at a time),
+use the `-i` option. If you want a particular list to depart from the
+default (that is, to display incrementally without the `-i` option and
+all at once with the `-i` option), put it in a block quote:
+
+ > - Eat spaghetti
+ > - Drink wine
+
+In this way incremental and nonincremental lists can be mixed in
+a single document.
+
+Inserting pauses
+----------------
+
+You can add "pauses" within a slide by including a paragraph containing
+three dots, separated by spaces:
+
+ # Slide with a pause
+
+ content before the pause
+
+ . . .
+
+ content after the pause
+
+Styling the slides
+------------------
+
+You can change the style of HTML slides by putting customized CSS files
+in `$DATADIR/s5/default` (for S5), `$DATADIR/slidy` (for Slidy),
+or `$DATADIR/slideous` (for Slideous),
+where `$DATADIR` is the user data directory (see `--data-dir`, above).
+The originals may be found in pandoc's system data directory (generally
+`$CABALDIR/pandoc-VERSION/s5/default`). Pandoc will look there for any
+files it does not find in the user data directory.
+
+For dzslides, the CSS is included in the HTML file itself, and may
+be modified there.
+
+All [reveal.js configuration options] can be set through variables.
+For example, themes can be used by setting the `theme` variable:
+
+ -V theme=moon
+
+Or you can specify a custom stylesheet using the `--css` option.
+
+To style beamer slides, you can specify a `theme`, `colortheme`,
+`fonttheme`, `innertheme`, and `outertheme`, using the `-V` option:
+
+ pandoc -t beamer habits.txt -V theme:Warsaw -o habits.pdf
+
+Note that header attributes will turn into slide attributes
+(on a `<div>` or `<section>`) in HTML slide formats, allowing you
+to style individual slides. In beamer, the only header attribute
+that affects slides is the `allowframebreaks` class, which sets the
+`allowframebreaks` option, causing multiple slides to be created
+if the content overfills the frame. This is recommended especially for
+bibliographies:
+
+ # References {.allowframebreaks}
+
+Speaker notes
+-------------
+
+reveal.js has good support for speaker notes. You can add notes to your
+Markdown document thus:
+
+ <div class="notes">
+ This is my note.
+
+ - It can contain Markdown
+ - like this list
+
+ </div>
+
+To show the notes window, press `s` while viewing the presentation.
+Notes are not yet supported for other slide formats, but the notes
+will not appear on the slides themselves.
+
+Frame attributes in beamer
+--------------------------
+
+Sometimes it is necessary to add the LaTeX `[fragile]` option to
+a frame in beamer (for example, when using the `minted` environment).
+This can be forced by adding the `fragile` class to the header
+introducing the slide:
+
+ # Fragile slide {.fragile}
+
+All of the other frame attributes described in Section 8.1 of
+the [Beamer User's Guide] may also be used: `allowdisplaybreaks`,
+`allowframebreaks`, `b`, `c`, `t`, `environment`, `label`, `plain`,
+`shrink`.
+
+Creating EPUBs with pandoc
+==========================
+
+EPUB Metadata
+-------------
+
+EPUB metadata may be specified using the `--epub-metadata` option, but
+if the source document is Markdown, it is better to use a [YAML metadata
+block][Extension: `yaml_metadata_block`]. Here is an example:
+
+ ---
+ title:
+ - type: main
+ text: My Book
+ - type: subtitle
+ text: An investigation of metadata
+ creator:
+ - role: author
+ text: John Smith
+ - role: editor
+ text: Sarah Jones
+ identifier:
+ - scheme: DOI
+ text: doi:10.234234.234/33
+ publisher: My Press
+ rights: © 2007 John Smith, CC BY-NC
+ ...
+
+The following fields are recognized:
+
+`identifier`
+ ~ Either a string value or an object with fields `text` and
+ `scheme`. Valid values for `scheme` are `ISBN-10`,
+ `GTIN-13`, `UPC`, `ISMN-10`, `DOI`, `LCCN`, `GTIN-14`,
+ `ISBN-13`, `Legal deposit number`, `URN`, `OCLC`,
+ `ISMN-13`, `ISBN-A`, `JP`, `OLCC`.
+
+`title`
+ ~ Either a string value, or an object with fields `file-as` and
+ `type`, or a list of such objects. Valid values for `type` are
+ `main`, `subtitle`, `short`, `collection`, `edition`, `extended`.
+
+`creator`
+ ~ Either a string value, or an object with fields `role`, `file-as`,
+ and `text`, or a list of such objects. Valid values for `role` are
+ [MARC relators], but
+ pandoc will attempt to translate the human-readable versions
+ (like "author" and "editor") to the appropriate marc relators.
+
+`contributor`
+ ~ Same format as `creator`.
+
+`date`
+ ~ A string value in `YYYY-MM-DD` format. (Only the year is necessary.)
+ Pandoc will attempt to convert other common date formats.
+
+`lang` (or legacy: `language`)
+ ~ A string value in [BCP 47] format. Pandoc will default to the local
+ language if nothing is specified.
+
+`subject`
+ ~ A string value or a list of such values.
+
+`description`
+ ~ A string value.
+
+`type`
+ ~ A string value.
+
+`format`
+ ~ A string value.
+
+`relation`
+ ~ A string value.
+
+`coverage`
+ ~ A string value.
+
+`rights`
+ ~ A string value.
+
+`cover-image`
+ ~ A string value (path to cover image).
+
+`stylesheet`
+ ~ A string value (path to CSS stylesheet).
+
+`page-progression-direction`
+ ~ Either `ltr` or `rtl`. Specifies the `page-progression-direction`
+ attribute for the [`spine` element].
+
+[MARC relators]: http://loc.gov/marc/relators/relaterm.html
+[`spine` element]: http://idpf.org/epub/301/spec/epub-publications.html#sec-spine-elem
+
+Linked media
+------------
+
+By default, pandoc will download linked media (including audio and
+video) and include it in the EPUB container, yielding a completely
+self-contained EPUB. If you want to link to external media resources
+instead, use raw HTML in your source and add `data-external="1"` to the tag
+with the `src` attribute. For example:
+
+ <audio controls="1">
+ <source src="http://example.com/music/toccata.mp3"
+ data-external="1" type="audio/mpeg">
+ </source>
+ </audio>
+
+Literate Haskell support
+========================
+
+If you append `+lhs` (or `+literate_haskell`) to an appropriate input or output
+format (`markdown`, `markdown_strict`, `rst`, or `latex` for input or output;
+`beamer`, `html4` or `html5` for output only), pandoc will treat the document as
+literate Haskell source. This means that
+
+ - In Markdown input, "bird track" sections will be parsed as Haskell
+ code rather than block quotations. Text between `\begin{code}`
+ and `\end{code}` will also be treated as Haskell code. For
+ ATX-style headers the character '=' will be used instead of '#'.
+
+ - In Markdown output, code blocks with classes `haskell` and `literate`
+ will be rendered using bird tracks, and block quotations will be
+ indented one space, so they will not be treated as Haskell code.
+ In addition, headers will be rendered setext-style (with underlines)
+ rather than ATX-style (with '#' characters). (This is because ghc
+ treats '#' characters in column 1 as introducing line numbers.)
+
+ - In restructured text input, "bird track" sections will be parsed
+ as Haskell code.
+
+ - In restructured text output, code blocks with class `haskell` will
+ be rendered using bird tracks.
+
+ - In LaTeX input, text in `code` environments will be parsed as
+ Haskell code.
+
+ - In LaTeX output, code blocks with class `haskell` will be rendered
+ inside `code` environments.
+
+ - In HTML output, code blocks with class `haskell` will be rendered
+ with class `literatehaskell` and bird tracks.
+
+Examples:
+
+ pandoc -f markdown+lhs -t html
+
+reads literate Haskell source formatted with Markdown conventions and writes
+ordinary HTML (without bird tracks).
+
+ pandoc -f markdown+lhs -t html+lhs
+
+writes HTML with the Haskell code in bird tracks, so it can be copied
+and pasted as literate Haskell source.
+
+Note that GHC expects the bird tracks in the first column, so indentend literate
+code blocks (e.g. inside an itemized environment) will not be picked up by the
+Haskell compiler.
+
+Syntax highlighting
+===================
+
+Pandoc will automatically highlight syntax in [fenced code blocks] that
+are marked with a language name. The Haskell library [highlighting-kate] is
+used for highlighting, which works in HTML, Docx, and LaTeX/PDF output.
+To see a list of language names that pandoc will recognize, type
+`pandoc --list-highlight-languages`.
+
+The color scheme can be selected using the `--highlight-style` option.
+The default color scheme is `pygments`, which imitates the default color
+scheme used by the Python library pygments (though pygments is not actually
+used to do the highlighting). To see a list of highlight styles,
+type `pandoc --list-highlight-styles`.
+
+To disable highlighting, use the `--no-highlight` option.
+
+[highlighting-kate]: https://github.com/jgm/highlighting-kate
+
+Custom Styles in Docx Output
+============================
+
+By default, pandoc'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 `reference.docx` file. However, if you
+need to apply your own styles to blocks, or match a preexisting set of
+styles, pandoc allows you to define custom styles for blocks and text
+using `div`s and `span`s, respectively.
+
+If you define a `div` or `span` with the attribute `custom-style`,
+pandoc will apply your specified style to the contained elements. So,
+for example,
+
+ <span custom-style="Emphatically">Get out,</span> he said.
+
+would produce a docx file with "Get out," styled with character
+style `Emphatically`. Similarly,
+
+ Dickinson starts the poem simply:
+
+ <div custom-style="Poetry">
+ | A Bird came down the Walk---
+ | He did not know I saw---
+ </div>
+
+would style the two contained lines with the `Poetry` paragraph style.
+
+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.
+
+This feature allows for greatest customization in conjunction with
+[pandoc filters]. If you want all paragraphs after block quotes to be
+indented, you can write a filter to apply the styles necessary. If you
+want all italics to be transformed to the `Emphasis` character style
+(perhaps to change their color), you can write a filter which will
+transform all italicized inlines to inlines within an `Emphasis`
+custom-style `span`.
+
+[pandoc filters]: http://pandoc.org/scripting.html
+
+Custom writers
+==============
+
+Pandoc can be extended with custom writers written in [lua]. (Pandoc
+includes a lua interpreter, so lua need not be installed separately.)
+
+To use a custom writer, simply specify the path to the lua script
+in place of the output format. For example:
+
+ pandoc -t data/sample.lua
+
+Creating a custom writer requires writing a lua function for each
+possible element in a pandoc document. To get a documented example
+which you can modify according to your needs, do
+
+ pandoc --print-default-data-file sample.lua
+
+[lua]: http://www.lua.org
+
+Authors
+=======
+
+© 2006-2016 John MacFarlane (jgm@berkeley.edu). Released under the
+[GPL], version 2 or greater. This software carries no warranty of
+any kind. (See COPYRIGHT for full copyright and warranty notices.)
+
+Contributors include
+Arata Mizuki,
+Aaron Wolen,
+Albert Krewinkel,
+Alex Ivkin,
+Alex Vong,
+Alexander Kondratskiy,
+Alexander Sulfrian,
+Alexander V Vershilov,
+Alfred Wechselberger,
+Andreas Lööw,
+Andrew Dunning,
+Antoine Latter,
+Arata Mizuki,
+Arlo O'Keeffe,
+Artyom Kazak,
+B. Scott Michel,
+Ben Gamari,
+Beni Cherniavsky-Paskin,
+Benoit Schweblin,
+Bjorn Buckwalter,
+Bradley Kuhn,
+Brent Yorgey,
+Bryan O'Sullivan,
+Caleb McDaniel,
+Calvin Beck,
+Carlos Sosa,
+Chris Black,
+Christian Conkle,
+Christoffer Ackelman,
+Christoffer Sawicki,
+Clare Macrae,
+Clint Adams,
+Conal Elliott,
+Craig S. Bosma,
+Daniel Bergey,
+Daniel T. Staal,
+Daniele D'Orazio,
+David Lazar,
+David Röthlisberger,
+Denis Laxalde,
+Douglas Calvert,
+Emanuel Evans,
+Emily Eisenberg,
+Eric Kow,
+Eric Seidel,
+Felix Yan,
+Florian Eitel,
+François Gannaz,
+Freiric Barral,
+Freirich Raabe,
+Frerich Raabe,
+Fyodor Sheremetyev,
+Gabor Pali,
+Gavin Beatty,
+Gottfried Haider,
+Greg Maslov,
+Greg Rundlett,
+Grégory Bataille,
+Gwern Branwen,
+Hans-Peter Deifel,
+Henrik Tramberend,
+Henry de Valence,
+Hubert Plociniczak,
+Ilya V. Portnov,
+Ivo Clarysse,
+J. Lewis Muir,
+Jaime Marquínez Ferrándiz,
+Jakob Voß,
+James Aspnes,
+Jamie F. Olson,
+Jan Larres,
+Jan Schulz,
+Jason Ronallo,
+Jeff Arnold,
+Jeff Runningen,
+Jens Petersen,
+Jesse Rosenthal,
+Joe Hillenbrand,
+John MacFarlane,
+John Muccigrosso,
+Jonas Smedegaard,
+Jonathan Daugherty,
+Jose Luis Duran,
+Josef Svenningsson,
+Julien Cretel,
+Juliusz Gonera,
+Justin Bogner,
+Jérémy Bobbio,
+Kelsey Hightower,
+Kolen Cheung,
+Konstantin Zudov,
+Kristof Bastiaensen,
+Lars-Dominik Braun,
+Luke Plant,
+Mark Szepieniec,
+Mark Wright,
+Martin Linn,
+Masayoshi Takahashi,
+Matej Kollar,
+Mathias Schenner,
+Mathieu Duponchelle,
+Matthew Eddey,
+Matthew Pickering,
+Matthias C. M. Troffaes,
+Mauro Bieg,
+Max Bolingbroke,
+Max Rydahl Andersen,
+Merijn Verstraaten,
+Michael Beaumont,
+Michael Chladek,
+Michael Snoyman,
+Michael Thompson,
+MinRK,
+Morton Fox,
+Nathan Gass,
+Neil Mayhew,
+Nick Bart,
+Nicolas Kaiser,
+Nikolay Yakimov,
+Oliver Matthews,
+Ophir Lifshitz,
+Pablo Rodríguez,
+Paul Rivier,
+Paulo Tanimoto,
+Peter Wang,
+Philippe Ombredanne,
+Phillip Alday,
+Prayag Verma,
+Puneeth Chaganti,
+Ralf Stephan,
+Raniere Silva,
+Recai Oktaş,
+RyanGlScott,
+Scott Morrison,
+Sergei Trofimovich,
+Sergey Astanin,
+Shahbaz Youssefi,
+Shaun Attfield,
+Sidarth Kapur,
+Sidharth Kapur,
+Simon Hengel,
+Sumit Sahrawat,
+Thomas Hodgson,
+Thomas Weißschuh,
+Tim Lin,
+Timothy Humphries,
+Tiziano Müller,
+Todd Sifleet,
+Tom Leese,
+Uli Köhler,
+Václav Zeman,
+Viktor Kronvall,
+Vincent,
+Václav Haisman,
+Václav Zeman,
+Wandmalfarbe,
+Waldir Pimenta,
+Wikiwide,
+Xavier Olive,
+bumper314,
+csforste,
+infinity0x,
+nkalvi,
+qerub,
+robabla,
+roblabla,
+rodja.trappe,
+rski,
+shreevatsa.public,
+takahashim,
+tgkokk,
+thsutton.
+
+[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000..d89f52984
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,56 @@
+version?=$(shell grep '^Version:' pandoc.cabal | awk '{print $$2;}')
+pandoc=$(shell find dist -name pandoc -type f -exec ls -t {} \; | head -1)
+BRANCH?=master
+
+quick:
+ stack install --flag 'pandoc:embed_data_files' --fast --test --test-arguments='-j4'
+
+full:
+ stack install --flag 'pandoc:embed_data_files' --test --test-arguments='-j4' --pedantic
+ stack haddock
+
+test:
+ stack test --test-arguments='-j4'
+
+bench:
+ stack bench
+
+changes_github:
+ pandoc --filter extract-changes.hs changelog -t markdown_github | sed -e 's/\\#/#/g' | pbcopy
+
+dist: man/pandoc.1
+ cabal sdist
+ rm -rf "pandoc-${version}"
+ tar xvzf dist/pandoc-${version}.tar.gz
+ cd pandoc-${version}
+ stack setup && stack test && cd .. && rm -rf "pandoc-${version}"
+
+debpkg: man/pandoc.1
+ make -C deb
+
+macospkg: man/pandoc.1
+ ./macos/make_macos_package.sh
+
+winpkg: pandoc-$(version)-windows.msi
+
+pandoc-$(version)-windows.msi:
+ wget 'https://ci.appveyor.com/api/projects/jgm/pandoc/artifacts/windows/pandoc.msi?branch=$(BRANCH)' -O pandoc.msi && \
+ osslsigncode sign -pkcs12 ~/Private/ComodoCodeSigning.exp2017.p12 -in pandoc.msi -i http://johnmacfarlane.net/ -t http://timestamp.comodoca.com/ -out $@ -askpass
+ rm pandoc.msi
+
+man/pandoc.1: MANUAL.txt man/pandoc.1.template
+ pandoc $< -t man -s --template man/pandoc.1.template \
+ --filter man/capitalizeHeaders.hs \
+ --filter man/removeNotes.hs \
+ --filter man/removeLinks.hs \
+ --variable version="pandoc $(version)" \
+ -o $@
+
+download_stats:
+ curl https://api.github.com/repos/jgm/pandoc/releases | \
+ jq -r '.[] | .assets | .[] | "\(.download_count)\t\(.name)"'
+
+clean:
+ stack clean
+
+.PHONY: deps quick full install clean test bench changes_github macospkg dist prof download_stats
diff --git a/README.md b/README.md
new file mode 100644
index 000000000..4388d4d07
--- /dev/null
+++ b/README.md
@@ -0,0 +1,146 @@
+Pandoc
+======
+
+[![github release](https://img.shields.io/github/release/jgm/pandoc.svg?label=current+release)](https://github.com/jgm/pandoc/releases)
+[![hackage release](https://img.shields.io/hackage/v/pandoc.svg?label=hackage)](http://hackage.haskell.org/package/pandoc)
+[![homebrew](https://img.shields.io/homebrew/v/pandoc.svg)](http://brewformulas.org/Pandoc)
+[![stackage LTS package](http://stackage.org/package/pandoc/badge/lts)](http://stackage.org/lts/package/pandoc)
+[![travis build status](https://img.shields.io/travis/jgm/pandoc/master.svg?label=travis+build)](https://travis-ci.org/jgm/pandoc)
+[![appveyor build status](https://ci.appveyor.com/api/projects/status/nvqs4ct090igjiqc?svg=true)](https://ci.appveyor.com/project/jgm/pandoc)
+[![license](https://img.shields.io/badge/license-GPLv2+-lightgray.svg)](https://www.gnu.org/licenses/gpl.html)
+[![pandoc-discuss on google groups](https://img.shields.io/badge/pandoc-discuss-red.svg?style=social)](https://groups.google.com/forum/#!forum/pandoc-discuss)
+
+
+The universal markup converter
+------------------------------
+
+Pandoc is a [Haskell] library for converting from one markup format to
+another, and a command-line tool that uses this library. It can read
+[Markdown], [CommonMark], [PHP Markdown Extra], [GitHub-Flavored Markdown],
+[MultiMarkdown], and (subsets of) [Textile], [reStructuredText], [HTML],
+[LaTeX], [MediaWiki markup], [TWiki markup], [Haddock markup], [OPML], [Emacs
+Org mode], [DocBook], [txt2tags], [EPUB], [ODT] and [Word docx]; and it can
+write plain text, [Markdown], [CommonMark], [PHP Markdown Extra],
+[GitHub-Flavored Markdown], [MultiMarkdown], [reStructuredText], [XHTML],
+[HTML5], [LaTeX] \(including [`beamer`] slide shows\), [ConTeXt], [RTF], [OPML],
+[DocBook], [OpenDocument], [ODT], [Word docx], [GNU Texinfo], [MediaWiki
+markup], [DokuWiki markup], [ZimWiki markup], [Haddock markup],
+[EPUB] \(v2 or v3\), [FictionBook2], [Textile], [groff man] pages,
+[Emacs Org mode], [AsciiDoc], [InDesign ICML], [TEI Simple], and [Slidy],
+[Slideous], [DZSlides], [reveal.js] or [S5] HTML slide shows. It can also
+produce [PDF] output on systems where LaTeX, ConTeXt, or `wkhtmltopdf` is
+installed.
+
+Pandoc's enhanced version of Markdown includes syntax for [footnotes],
+[tables], flexible [ordered lists], [definition lists], [fenced code blocks],
+[superscripts and subscripts], [strikeout], [metadata blocks], automatic tables of
+contents, embedded LaTeX [math], [citations], and [Markdown inside HTML block
+elements]. (These enhancements, described
+further under [Pandoc's Markdown], can be disabled using the
+`markdown_strict` input or output format.)
+
+In contrast to most existing tools for converting Markdown to HTML, which
+use regex substitutions, pandoc has a modular design: it consists of a
+set of readers, which parse text in a given format and produce a native
+representation of the document, and a set of writers, which convert
+this native representation into a target format. Thus, adding an input
+or output format requires only adding a reader or writer.
+
+Because pandoc's intermediate representation of a document is less
+expressive than many of the formats it converts between, one should
+not expect perfect conversions between every format and every other.
+Pandoc attempts to preserve the structural elements of a document, but
+not formatting details such as margin size. And some document elements,
+such as complex tables, may not fit into pandoc's simple document
+model. While conversions from pandoc's Markdown to all formats aspire
+to be perfect, conversions from formats more expressive than pandoc's
+Markdown can be expected to be lossy.
+
+[Markdown]: http://daringfireball.net/projects/markdown/
+[CommonMark]: http://commonmark.org
+[PHP Markdown Extra]: https://michelf.ca/projects/php-markdown/extra/
+[GitHub-Flavored Markdown]: https://help.github.com/articles/github-flavored-markdown/
+[MultiMarkdown]: http://fletcherpenney.net/multimarkdown/
+[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
+[S5]: http://meyerweb.com/eric/tools/s5/
+[Slidy]: http://www.w3.org/Talks/Tools/Slidy/
+[Slideous]: http://goessner.net/articles/slideous/
+[HTML]: http://www.w3.org/html/
+[HTML5]: http://www.w3.org/TR/html5/
+[XHTML]: http://www.w3.org/TR/xhtml1/
+[LaTeX]: http://latex-project.org
+[`beamer`]: https://ctan.org/pkg/beamer
+[Beamer User's Guide]: http://ctan.math.utah.edu/ctan/tex-archive/macros/latex/contrib/beamer/doc/beameruserguide.pdf
+[ConTeXt]: http://www.contextgarden.net/
+[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format
+[DocBook]: http://docbook.org
+[txt2tags]: http://txt2tags.org
+[EPUB]: http://idpf.org/epub
+[OPML]: http://dev.opml.org/spec2.html
+[OpenDocument]: http://opendocument.xml.org
+[ODT]: http://en.wikipedia.org/wiki/OpenDocument
+[Textile]: http://redcloth.org/textile
+[MediaWiki markup]: https://www.mediawiki.org/wiki/Help:Formatting
+[DokuWiki markup]: https://www.dokuwiki.org/dokuwiki
+[ZimWiki markup]: http://zim-wiki.org/manual/Help/Wiki_Syntax.html
+[TWiki markup]: http://twiki.org/cgi-bin/view/TWiki/TextFormattingRules
+[Haddock markup]: https://www.haskell.org/haddock/doc/html/ch03s08.html
+[groff man]: http://man7.org/linux/man-pages/man7/groff_man.7.html
+[Haskell]: https://www.haskell.org
+[GNU Texinfo]: http://www.gnu.org/software/texinfo/
+[Emacs Org mode]: http://orgmode.org
+[AsciiDoc]: http://www.methods.co.nz/asciidoc/
+[DZSlides]: http://paulrouget.com/dzslides/
+[Word docx]: https://en.wikipedia.org/wiki/Office_Open_XML
+[PDF]: https://www.adobe.com/pdf/
+[reveal.js]: http://lab.hakim.se/reveal-js/
+[FictionBook2]: http://www.fictionbook.org/index.php/Eng:XML_Schema_Fictionbook_2.1
+[InDesign ICML]: https://www.adobe.com/content/dam/Adobe/en/devnet/indesign/cs55-docs/IDML/idml-specification.pdf
+[TEI Simple]: https://github.com/TEIC/TEI-Simple
+
+
+
+
+[footnotes]: http://pandoc.org/MANUAL.html#footnotes
+[tables]: http://pandoc.org/MANUAL.html#tables
+[ordered lists]: http://pandoc.org/MANUAL.html#ordered-lists
+[definition lists]: http://pandoc.org/MANUAL.html#definition-lists
+[fenced code blocks]: http://pandoc.org/MANUAL.html#fenced-code-blocks
+[superscripts and subscripts]: http://pandoc.org/MANUAL.html#superscripts-and-subscripts
+[strikeout]: http://pandoc.org/MANUAL.html#strikeout
+[metadata blocks]: http://pandoc.org/MANUAL.html#metadata-blocks
+[math]: http://pandoc.org/MANUAL.html#math
+[citations]: http://pandoc.org/MANUAL.html#citations
+[Markdown inside HTML block elements]: http://pandoc.org/MANUAL.html#extension-markdown_in_html_blocks
+[Pandoc's Markdown]: http://pandoc.org/MANUAL.html#pandocs-markdown
+
+Installing
+----------
+
+Here's [how to install pandoc](INSTALL.md).
+
+Documentation
+-------------
+
+Pandoc's website contains a full [User's Guide](https://pandoc.org/MANUAL.html).
+It is also available [here](MANUAL.txt) as pandoc-flavored Markdown.
+The website also contains some [examples of the use of
+pandoc](https://pandoc.org/demos.html) and a limited [online
+demo](https://pandoc.org/try).
+
+Contributing
+------------
+
+Pull requests, bug reports, and feature requests are welcome. Please make
+sure to read [the contributor guidelines](CONTRIBUTING.md) before opening a
+new issue.
+
+
+License
+-------
+
+© 2006-2016 John MacFarlane (jgm@berkeley.edu). Released under the
+[GPL], version 2 or greater. This software carries no warranty of
+any kind. (See COPYRIGHT for full copyright and warranty notices.)
+
+[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"
diff --git a/RELEASE-CHECKLIST b/RELEASE-CHECKLIST
new file mode 100644
index 000000000..2882965e1
--- /dev/null
+++ b/RELEASE-CHECKLIST
@@ -0,0 +1,33 @@
+_ Test, on linux, windows, mac (inc. website demos)
+
+_ Finalize changelog
+ git log --pretty='format:%n%n* %s (%an)%n%b%n%h%n' --reverse --name-only 1.17.0.3..HEAD > LOG
+
+_ make man/pandoc.1 and commit if needed
+
+_ Tag release in git
+
+_ Tag templates
+
+_ Generate Windows package (make winpkg)
+
+_ Generate MacOS package (make macospkg)
+
+_ Generate Ubuntu/Debian deb package (make debpkg)
+
+- Add release on github (use 'make changes_github' and upload files)
+
+_ Upload to HackageDB: stack upload .
+
+_ if docs don't build on Hackage:
+ 'cabal install neil && neil docs --username=MYUSERNAME'
+
+_ Update website, including short description of changes ('make changes')
+
+_ Announce on pandoc-announce, pandoc-discuss
+
+_ on server, stack install --flag 'pandoc:trypandoc'
+ and then 'cd trypandoc; sudo make install'
+
+_ recompile gitit
+
diff --git a/RELEASE-CHECKLIST.md b/RELEASE-CHECKLIST.md
new file mode 100644
index 000000000..d3fd70f23
--- /dev/null
+++ b/RELEASE-CHECKLIST.md
@@ -0,0 +1,27 @@
+- [ ] Test, on linux, windows, mac (inc. website demos)
+
+- [ ] Finalize changelog:
+ `git log --pretty='format:%n%n* %s (%an)%n%b%n%h%n' --reverse --name-only 1.17.0.3..HEAD > LOG`
+
+- [ ] `make man/pandoc.1` and commit if needed
+
+- [ ] Tag release in git
+
+- [ ] Tag templates
+
+- [ ] Generate Windows package (`make winpkg`)
+
+- [ ] Generate Mac OSX package (`make osxpkg`)
+
+- [ ] Generate Ubuntu/Debian deb package (`make debpkg`)
+
+- [ ] Add release on github (use `make changes_github` and upload files)
+
+- [ ] Upload to HackageDB
+
+- [ ] Update website (`make update`), including short description of changes (`make changes`)
+
+- [ ] on server, `cabal install --enable-tests -ftrypandoc`
+ and then `cd trypandoc; sudo make install`
+
+- [ ] Announce on pandoc-announce, pandoc-discuss
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
index 000000000..bc6651942
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,66 @@
+{-
+Copyright (C) 2006-2015 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
+-}
+
+import Distribution.Simple
+import Distribution.Simple.PreProcess
+import Distribution.Simple.Setup (ConfigFlags(..), CopyFlags(..), fromFlag)
+import Distribution.PackageDescription (PackageDescription(..), FlagName(..))
+import Distribution.Simple.Utils ( rawSystemExitCode, findProgramVersion )
+import System.Exit
+import Distribution.Simple.Utils (info, notice, installOrdinaryFiles)
+import Distribution.Simple.Program (simpleProgram, Program(..))
+import Distribution.Simple.LocalBuildInfo
+import Control.Monad (when)
+
+main :: IO ()
+main = defaultMainWithHooks $ simpleUserHooks {
+ -- enable hsb2hs preprocessor for .hsb files
+ hookedPreProcessors = [ppBlobSuffixHandler]
+ , hookedPrograms = [(simpleProgram "hsb2hs"){
+ programFindVersion = \verbosity fp ->
+ findProgramVersion "--version" id verbosity fp }]
+ , postCopy = installManPage
+ }
+
+ppBlobSuffixHandler :: PPSuffixHandler
+ppBlobSuffixHandler = ("hsb", \_ lbi ->
+ PreProcessor {
+ platformIndependent = True,
+ runPreProcessor = mkSimplePreProcessor $ \infile outfile verbosity ->
+ do let embedData = case lookup (FlagName "embed_data_files")
+ (configConfigurationsFlags (configFlags lbi)) of
+ Just True -> True
+ _ -> False
+ when embedData $
+ do info verbosity $ "Preprocessing " ++ infile ++ " to " ++ outfile
+ ec <- rawSystemExitCode verbosity "hsb2hs"
+ [infile, infile, outfile]
+ case ec of
+ ExitSuccess -> return ()
+ ExitFailure _ -> error "hsb2hs is needed to build this program"
+ })
+
+installManPage :: Args -> CopyFlags
+ -> PackageDescription -> LocalBuildInfo -> IO ()
+installManPage _ flags pkg lbi = do
+ let verbosity = fromFlag (copyVerbosity flags)
+ let copydest = fromFlag (copyDest flags)
+ let mandest = mandir (absoluteInstallDirs pkg lbi copydest)
+ ++ "/man1"
+ notice verbosity $ "Copying man page to " ++ mandest
+ installOrdinaryFiles verbosity mandest [("man", "pandoc.1")]
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 000000000..373e1bfe4
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,54 @@
+clone_folder: "c:\\stack"
+environment:
+ global:
+ STACK_ROOT: "c:\\sr"
+ STACK_YAML: "c:\\stack\\stack.pkg.yaml"
+ WIXBIN: "c:\\Program Files (x86)\\WiX Toolset v3.10\\bin"
+
+cache:
+ - "c:\\sr" # stack root, short paths == fewer problems
+ - "c:\\stack\\stack.exe"
+ - '%WIXBIN%'
+
+# We don't do a normal C build, but build in test_script via stack
+build: off
+
+install:
+ - '"%WIXBIN%"\candle -? || choco install wixtoolset'
+ - |
+ stack --version || curl -ostack.zip -L --insecure http://www.stackage.org/stack/windows-i386 && 7z x stack.zip stack.exe
+ - stack setup > nul
+
+before_test:
+ # the stack install already fails without the templates...
+ - git submodule update --init
+ # set PATH to where the hsb2hs binary is copied to
+ - cmd: set "PATH=%PATH%;%APPDATA%\\local\\bin"
+ - stack install hsb2hs
+
+test_script:
+ # The ugly echo "" hack is to avoid complaints about 0 being an invalid file
+ # descriptor
+ - echo "" | stack clean
+ - echo "" | stack -j1 --no-terminal test
+ - echo "" | stack -j1 --local-bin-path=.\windows install pandoc pandoc-citeproc
+
+after_test:
+ # .\ in the stack commandline seems to be .\windows\ (where the stack-appveyor.yaml is)
+ - cd windows
+ - 7z a "pandoc.zip" pandoc.exe
+ - .\pandoc.exe -s --toc ..\MANUAL.txt -o MANUAL.html
+ - .\pandoc.exe -s ..\COPYING.md -o COPYING.rtf
+ - copy ..\COPYRIGHT COPYRIGHT.txt
+ - |
+ set VERSION=
+ for /f "tokens=1-2 delims= " %%a in ('.\pandoc.exe --version') do ( if not defined VERSION set "VERSION=%%b" )
+ echo %VERSION%
+ "%WIXBIN%\\candle" -dVERSION=%VERSION% -dBINPATH=. *.wxs -out wixobj\
+ "%WIXBIN%\\light" -sw1076 -ext WixUIExtension -ext WixUtilExtension -cultures:en-us -loc Pandoc-en-us.wxl -out pandoc.msi wixobj\*.wixobj
+
+artifacts:
+ - path: windows\pandoc.zip
+ name: exe
+ - path: windows\pandoc.msi
+ name: msi
diff --git a/benchmark/benchmark-pandoc.hs b/benchmark/benchmark-pandoc.hs
new file mode 100644
index 000000000..c01750b6e
--- /dev/null
+++ b/benchmark/benchmark-pandoc.hs
@@ -0,0 +1,86 @@
+{-
+Copyright (C) 2012-2014 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
+-}
+import Text.Pandoc
+import Text.Pandoc.Class hiding (getCurrentTime)
+import Data.Time (getCurrentTime)
+import qualified Data.ByteString as B
+import qualified Data.Map as Map
+import Criterion.Main
+import Criterion.Types (Config(..))
+import Data.Maybe (mapMaybe)
+import Debug.Trace (trace)
+import System.Environment (getArgs)
+
+readerBench :: Pandoc
+ -> (String, ReaderOptions -> String -> Pandoc)
+ -> Maybe Benchmark
+readerBench doc (name, reader) =
+ case lookup name writers of
+ Just (StringWriter writer) ->
+ let inp = either (error . show) id $ runPure
+ $ writer def{ writerWrapText = WrapAuto} doc
+ in return $ bench (name ++ " reader") $ nf
+ (reader def) inp
+ _ -> trace ("\nCould not find writer for " ++ name ++ "\n") Nothing
+
+writerBench :: Pandoc
+ -> (String, WriterOptions -> Pandoc -> String)
+ -> Benchmark
+writerBench doc (name, writer) = bench (name ++ " writer") $ nf
+ (writer def{ writerWrapText = WrapAuto }) doc
+
+main :: IO ()
+main = do
+ args <- getArgs
+ let matchReader (n, StringReader _) =
+ case args of
+ [] -> True
+ [x] -> x == n
+ (x:y:_) -> x == n && y == "reader"
+ matchReader (_, _) = False
+ let matchWriter (n, StringWriter _) =
+ case args of
+ [] -> True
+ [x] -> x == n
+ (x:y:_) -> x == n && y == "writer"
+ matchWriter (_, _) = False
+ let matchedReaders = filter matchReader readers
+ let matchedWriters = filter matchWriter writers
+ inp <- readFile "tests/testsuite.txt"
+ lalune <- B.readFile "tests/lalune.jpg"
+ movie <- B.readFile "tests/movie.jpg"
+ time <- getCurrentTime
+ let setupFakeFiles = modifyPureState $ \st -> st{ stFiles =
+ FileTree $ Map.fromList [
+ ("lalune.jpg", FileInfo time lalune),
+ ("movie.jpg", FileInfo time movie)
+ ]}
+ let opts = def
+ let doc = either (error . show) id $ runPure $ readMarkdown opts inp
+ let readers' = [(n, \o d ->
+ either (error . show) id $ runPure $ r o d)
+ | (n, StringReader r) <- matchedReaders]
+ let readerBs = mapMaybe (readerBench doc)
+ $ filter (\(n,_) -> n /="haddock") readers'
+ let writers' = [(n, \o d ->
+ either (error . show) id $ runPure $ setupFakeFiles >> w o d)
+ | (n, StringWriter w) <- matchedWriters]
+ let writerBs = map (writerBench doc)
+ $ writers'
+ defaultMainWith defaultConfig{ timeLimit = 6.0 }
+ (writerBs ++ readerBs)
diff --git a/benchmark/weigh-pandoc.hs b/benchmark/weigh-pandoc.hs
new file mode 100644
index 000000000..cf4099721
--- /dev/null
+++ b/benchmark/weigh-pandoc.hs
@@ -0,0 +1,37 @@
+import Weigh
+import Text.Pandoc
+
+main :: IO ()
+main = do
+ doc <- read <$> readFile "tests/testsuite.native"
+ mainWith $ do
+ func "Pandoc document" id doc
+ mapM_
+ (\(n,r) -> weighReader doc n (either (error . show) id . runPure . r def{ readerSmart = True }))
+ [("markdown", readMarkdown)
+ ,("html", readHtml)
+ ,("docbook", readDocBook)
+ ,("latex", readLaTeX)
+ ,("commonmark", readCommonMark)
+ ]
+ mapM_
+ (\(n,w) -> weighWriter doc n (either (error . show) id . runPure . w def))
+ [("markdown", writeMarkdown)
+ ,("html", writeHtmlString)
+ ,("docbook", writeDocbook)
+ ,("latex", writeLaTeX)
+ ,("commonmark", writeCommonMark)
+ ]
+
+weighWriter :: Pandoc -> String -> (Pandoc -> String) -> Weigh ()
+weighWriter doc name writer = func (name ++ " writer") writer doc
+
+weighReader :: Pandoc -> String -> (String -> Pandoc) -> Weigh ()
+weighReader doc name reader = do
+ case lookup name writers of
+ Just (StringWriter writer) ->
+ let inp = either (error . show) id $ runPure $ writer def{ writerWrapText = WrapAuto} doc
+ in func (name ++ " reader") reader inp
+ _ -> return () -- no writer for reader
+
+
diff --git a/changelog b/changelog
new file mode 100644
index 000000000..69b52e94f
--- /dev/null
+++ b/changelog
@@ -0,0 +1,10953 @@
+pandoc (1.19.2)
+
+ * Use skylighting library instead of highlighting-kate for syntax
+ highlighting. Skylighting is faster and more accurate (#3363).
+ Later we'll be able to add features like warning messages, dynamic
+ loading of xml syntax definitions, and dynamic loading of themes.
+
+ * Added a new highlight style, `breezeDark`.
+
+ * Text.Pandoc.Highlighting: Update list of `listings` languages (#3374).
+ This allows more languages to be used when using the `--listings`
+ option.
+
+ * OpenDocument writer:
+
+ + Small refactoring. Removed separate 'parent' parameter in paraStyle.
+ + Don't profilerate text styles unnecessarily (#3371).
+ This change makes the writer create only as many temporary
+ text styles as are absolutely necessary. It also consolidates
+ adjacent nodes with the same style.
+
+ * Org reader (Albert Krewinkel):
+
+ + Allow short hand for single-line raw blocks (Albert Krewinkel,
+ #3366). Single-line raw blocks can be given via `#+FORMAT: raw line`,
+ where `FORMAT` must be one of `latex`, `beamer`, `html`, or `texinfo`.
+ + Accept org-ref citations followed by commas (Albert Krewinkel).
+ Bugfix for an issue which, whenever the citation was immediately
+ followed by a comma, prevented correct parsing of org-ref citations.
+ + Ensure emphasis markup can be nested. Nested emphasis markup (e.g.
+ `/*strong and emphasized*/`) was interpreted incorrectly in that the
+ inner markup was not recognized.
+ + Remove pipe char irking the haddock coverage tool (Albert Krewinkel).
+
+ * Docx reader: Empty header should be list of lists (Jesse Rosenthal).
+ In the past, the docx reader wrote an empty header as an empty list. It
+ should have the same width as a row (and be filled with empty cells).
+
+ * MediaWiki reader:
+
+ + Improved handling of display math (#3362). Sometimes display math is
+ indented with more than one colon. Previously we handled these cases
+ badly, generating definition lists and missing the math.
+ + Fix quotation mark parsing (#3336, tgkokk). Change MediaWiki reader's
+ behavior when the smart option is parsed to match other readers'
+ behavior.
+
+ * Markdown reader:
+
+ + Fixed `-f markdown_github-hard_line_breaks+escaped_line_breaks`
+ (#3341). Previously this did not properly enable escaped line breaks.
+ + Disallow space between inline code and attributes (#3326, #3323,
+ Mauro Bieg).
+
+ * DocBook5 writer: make id attribute xml:id, fixes #3329 (#3330, Mauro Bieg).
+
+ * Added some test cases for ODT reader (#3306, #3308, Hubert Plociniczak).
+
+ * LaTeX writer: allow tables with empty cells to count as "plain."
+ This addresses a problem of too-wide tables when empty cells
+ are used. Thanks to Joost Kremers for reporting the issue.
+
+ * Org writer: prefix footnote numbers with `fn:` (Albert Krewinkel).
+ Unprefixed numbers where used by older org-mode versions, but are no
+ longer supported.
+
+ * HTML writer: don't process pars with empty RawInline, (#1040, #3327,
+ Mauro Bieg).
+
+ * Markdown writer: Fix display math with `--webtex` (#3298).
+
+ * Fix sample.lua so it properly handles raw blocks/inlines (#3358,
+ bumper314).
+
+ * Templates:
+
+ + default.latex: Moved geometry after hyperref (Václav Haisman).
+ Otherwise PDF sizes can be wrong in some circumstances.
+ + Copied a few changes from default.latex to default.beamer
+ (Wandmalfarbe).
+ + default.latex, default.beamer: Changed position of `\VerbatimNotes`
+ and `fancyvrb`. This fixes hyperlinks on footnotes in documents
+ that contain verbatim in notes (#3361). (Note: the beamer template
+ was updated to match the LaTeX template, but at this point verbatim
+ in notes seems not to work in beamer.)
+ + default.latex: Allow passing `microtypeoptions` to microtype
+ (Václav Haisman).
+ + default.latex: Add hyphen option to url package.
+ + default.docbook5: Fix namespace declarations (Mauro Bieg).
+
+ * Moved `make_osx_package.sh` to `osx/` directory.
+
+ * Travis continuous integration:
+
+ + Fix false positives with dist build.
+ + Speed improvements (Kolen Cheung, #3304, #3357).
+
+ * MANUAL.txt:
+
+ + Clarify that blank space is needed around footnotes (#3352).
+ + Fixed typo (#3351, Alexey Rogechev).
+ + Note that `--wrap=auto` does not work in HTML output.
+ + Default `--columns` width is 72, not 80.
+ + Fixed broken links (#3316, Kolen Cheung).
+ + Document usage of `@*` in nocite section (#3333, John Muccigrosso).
+
+ * INSTALL.md:
+
+ + Indent code so it's properly formatted (#3335, Bheesham Persaud).
+ + Added instructions for extracting binary from OSX, Windows packages.
+
+ * CONTRIBUTING.md: Describe labels currently used in issue tracker
+ (Albert Krewinkel). The labels have changed over time, the list of
+ labels is updated to reflect the current set of labels used in the
+ issue tracker.
+
+ * Rearrange and extend badges in README (Albert Krewinkel, #3354)
+
+ * Bumped version bounds for dependencies.
+
+
+pandoc (1.19.1)
+
+ * Set `PANDOC_VERSION` environment variable for filters (#2640).
+ This allows filters to check the pandoc version that produced
+ the JSON they are receiving.
+
+ * Docx reader: Ensure one-row tables don't have header (#3285,
+ Jesse Rosenthal). Tables in MS Word are set by default to have
+ special first-row formatting, which pandoc uses to determine whether
+ or not they have a header. This means that one-row tables will, by
+ default, have only a header -- which we imagine is not what people
+ want. This change ensures that a one-row table is not understood to
+ be a header only. Note that this means that it is impossible to
+ produce a header-only table from docx, even though it is legal
+ pandoc. But we believe that in nearly all cases, it will be an
+ accidental (and unwelcome) result
+
+ * HTML reader:
+
+ + Fixed some bad regressions in HTML table parser (#3280).
+ This regression leads to the introduction of empty rows
+ in some circumstances.
+ + Understand `style=width:` as well as `width` in `col` (#3286).
+
+ * RST reader:
+
+ + Print warnings when keys, substitition, notes not found.
+ Previously the parsers failed and we got raw text. Now we get a
+ link with an empty URL, or empty inlines in the case of a note or
+ substitution.
+
+ + Fix hyperlink aliases (#3283).
+
+ * Man writer: Ensure that periods are escaped at beginning of line
+ (#3270).
+
+ * LaTeX writer: Fix unnumbered headers when used with `--top-level`
+ (#3272, Albert Krewinkel). Fix interaction of top-level divisions
+ `part` or `chapter` with unnumbered headers when emitting LaTeX. Headers
+ are ensured to be written using stared commands (like `\subsection*{}`).
+
+ * LaTeX template: use comma not semicolon to separate keywords for
+ `pdfkeywords`. Thanks to Wandmalfarbe.
+
+ * Markdown writer: Fixed incorrect word wrapping (#3277). Previously pandoc
+ would sometimes wrap lines too early due to this bug.
+
+ * Text.Pandoc.Pretty: Added `afterBreak` [API change]. This makes it
+ possible to insert escape codes for content that needs escaping at the
+ beginning of a line.
+
+ * Removed old MathMLInHTML.js from 2004, which should no longer
+ be needed for MathML with modern browsers.
+
+ * Fixed tests with dynamic linking (#2709).
+
+ * Makefile: Use stack instead of cabal for targets. This is just
+ a convenience for developers.
+
+ * Fixed bash completion of filenames with space (#2749).
+
+ * MANUAL: improved documentation on how to create a custom `reference.docx`.
+
+ * Fix minor spelling typos in the manual (#3273, Anthony Geoghegan)
+
+pandoc (1.19)
+
+ * Changed resolution of filter paths.
+
+ + We now first treat the argument of `--filter` as a full (absolute
+ or relative) path, looking for a program there. If it's found, we
+ run it.
+ + If not, and if it is a simple program name or a relative path, we
+ try resolving it relative to `$DATADIR/filters`.
+ + If this fails, then we treat it as a program name and look in the
+ user's PATH.
+ + Removed a hardcoded '/' that may have caused problems with
+ Windows paths.
+
+ Previously if you did `--filter foo` and you had `foo` in your path and
+ also an executable `foo` in your working directory, the one in the path
+ would be used. Now the one in the working directory is used.
+
+ In addition, when you do `--filter foo/bar.hs`, pandoc will now find a
+ filter `$DATADIR/filters/foo/bar.hs` -- assuming there isn't a
+ `foo/bar.hs` relative to the working directory.
+
+ * Allow `file://` URIs as arguments (#3196). Also improved default reader
+ format detection. Previously with a URI ending in .md or .markdown,
+ pandoc would assume HTML input. Now it treats these as markdown.
+
+ * Allow to overwrite top-level division type heuristics (#3258,
+ Albert Krewinkel). Pandoc uses heuristics to determine the most
+ reasonable top-level division type when emitting LaTeX or
+ Docbook markup. It is now possible to overwrite this implicitly set
+ top-level division via the `top-level-division` command line parameter.
+
+ * Text.Pandoc.Options \[API changes\]:
+
+ + Removed `writerStandalone` field in `WriterOptions`, made
+ `writerTemplate` a `Maybe` value. Previously setting
+ `writerStandalone = True` did nothing unless a template was provided
+ in writerTemplate. Now a fragment will be generated if
+ `writerTemplate` is `Nothing`; otherwise, the specified template
+ will be used and standalone output generated.
+ + `Division` has been renamed `TopLevelDivision` (#3197). The
+ `Section`, `Chapter`, and `Part` constructors were renamed to
+ `TopLevelSection`, `TopLevelChapter`, and
+ `TopLevelPart`, respectively. An additional `TopLevelDefault`
+ constructor was added, which is now also the new default value of
+ the `writerTopLevelDivision` field in `WriterOptions`.
+
+ * Improved error if they give wrong arg to `--top-level-division`.
+
+ * Use new module from texmath to lookup MS font codepoints in Docx reader.
+ Removed unexported module Text.Pandoc.Readers.Docx.Fonts. Its code now
+ lives in texmath (0.9).
+
+ * DocBook reader: Fixed xref lookup (#3243). It previously only worked
+ when the qnames lacked the docbook namespace URI.
+
+ * HTML reader:
+
+ + Improved table parsing (#3027). We now check explicitly for non-1
+ rowspan or colspan attributes, and fail when we encounter them.
+ Previously we checked that each row had the same number of cells,
+ but that could be true even with rowspans/colspans. And there are
+ cases where it isn't true in tables that we can handle fine -- e.g.
+ when a tr element is empty. So now we just pad rows with empty cells
+ when needed.
+ + Treat `<math>` as MathML by default unless something else is
+ explicitly specified in xmlns. Provided it parses as MathML,
+ of course. Also fixed default which should be to inline math if no
+ display attribute is used.
+ + Only treat "a" element as link if it has href (#3226). Otherwise
+ treat as span.
+
+ * Docx reader (Jesse Rosenthal):
+
+ + Add a placeholder value for CHART. We wrap `[CHART]` in a
+ `<span class="chart">`. Note that it maps to inlines because, in
+ docx, anything in a drawing tag can be part of a larger paragraph.
+ + Be more specific in parsing images We not only want `w:drawing`,
+ because that could also include charts. Now we specify
+ `w:drawing/pic:pic`. This shouldn't change behavior at all, but it's
+ a first step toward allowing other sorts of drawing data as well.
+ + Abstract out function to avoid code repetition.
+ + Update tests for img title and alt (#3204).
+ + Handle Alt text and titles in images. We use the "description" field
+ as alt text and the "title" field as title. These can be accessed
+ through the "Format Picture" dialog in Word.
+ + Docx reader utils: handle empty namespace in `elemName`. Previously,
+ if given an empty namespace `(elemName ns "" "foo")` `elemName`
+ would output a QName with a `Just ""` namespace. This is never what
+ we want. Now we output a `Nothing`. If someone *does* want a
+ `Just ""` in the namespace, they can enter the QName
+ value explicitly.
+
+ * ODT reader/writer:
+
+ + Inline code when text has a special style (Hubert Plociniczak). When
+ a piece of text has a text `Source_Text` then we assume that this is
+ a piece of the document that represents a code that needs to
+ be inlined. Adapted the writer to also reflect that change.
+ Previously it was just writing a 'preformatted' text using a
+ non-distinguishable font style. Code blocks are still not recognized
+ by the ODT reader. That's a separate issue.
+ + Infer table's caption from the paragraph (#3224,
+ Hubert Plociniczak). ODT's reader always put empty captions for the
+ parsed tables. This commit
+
+ 1. checks paragraphs that follow the table definition
+ 2. treats specially a paragraph with a style named 'Table'
+ 3. does some postprocessing of the paragraphs that combines tables
+ followed immediately by captions
+
+ The ODT writer used the `TableCaption` style for the caption
+ paragraph. This commit follows the OpenOffice approach which allows
+ for appending captions to table but uses a built-in style named
+ `Table` instead of `TableCaption`. Users of a custom `reference.odt`
+ should change the style's name from `TableCaption` to `Table`.
+
+ * ODT reader: Infer tables' header props from rows (#3199,
+ Hubert Plociniczak). ODT reader simply provided an empty header list
+ which meant that the contents of the whole table, even if not empty, was
+ simply ignored. While we still do not infer headers we at least have to
+ provide default properties of columns.
+
+ * Markdown reader:
+
+ + Allow reference link labels starting with `@...` if `citations`
+ extension disabled (#3209). Example: in
+
+ \[link text\]\[@a\]
+
+ `link text` isn't hyperlinked because `[@a]` is parsed as
+ a citation. Previously this happened whether or not the `citations`
+ extension was enabled. Now it happens only if the `citations`
+ extension is enabled.
+ + Allow alignments to be specified in Markdown grid tables. For
+ example,
+
+ +-------+---------------+--------------------+
+ | Right | Left | Centered |
+ +=========:+:=================+:=============:+
+ | Bananas | $1.34 | built-in wrapper |
+ +-------+---------------+--------------------+
+
+ + Allow Small Caps elements to be created using bracketed spans (as
+ they already can be using HTML-syntax spans) (#3191, Kolen Cheung).
+
+ * LaTeX reader:
+
+ + Don't treat `\vspace` and `\hspace` as block commands (#3256).
+ Fixed an error which came up, for example, with `\vspace` inside
+ a caption. (Captions expect inlines.)
+ + Improved table handling. We can now parse all of the tables emitted
+ by pandoc in our tests. The only thing we don't get yet are
+ alignments and column widths in more complex tables. See #2669.
+ + Limited support for minipage.
+ + Allow for `[]`s inside LaTeX optional args. Fixes cases like:
+ + Handle BVerbatim from fancyvrb (#3203).
+ + Handle hungarumlaut (#3201).
+ + Allow beamer-style `<...>` options in raw LaTeX (also in Markdown)
+ (#3184). This allows use of things like `\only<2,3>{my content}` in
+ Markdown that is going to be converted to beamer.
+
+ * Use pre-wrap for code in dzslides template (Nicolas Porcel). Otherwise
+ overly long code will appear on every slide.
+
+ * Org reader (Albert Krewinkel):
+
+ + Respect column width settings (#3246). Table column properties can
+ optionally specify a column's width with which it is displayed in
+ the buffer. Some exporters, notably the ODT exporter in org-mode
+ v9.0, use these values to calculate relative column widths. The org
+ reader now implements the same behavior. Note that the org-mode
+ LaTeX and HTML exporters in Emacs don't support this feature yet,
+ which should be kept in mind by users who use the column
+ widths parameters.
+ + Allow HTML attribs on non-figure images (#3222). Images which are
+ the only element in a paragraph can still be given HTML attributes,
+ even if the image does not have a caption and is hence not a figure.
+ The following will add set the `width` attribute of the image to
+ `50%`:
+
+ +ATTR\_HTML: :width 50%
+ =======================
+
+ \[\[file:image.jpg\]\]
+
+ + Support `ATTR_HTML` for special blocks (#3182). Special
+ blocks (i.e. blocks with unrecognized names) can be prefixed with an
+ `ATTR_HTML` block attribute. The attributes defined in that
+ meta-directive are added to the `Div` which is used to represent the
+ special block.
+ + Support the `todo` export option. The `todo` export option allows to
+ toggle the inclusion of TODO keywords in the output. Setting this to
+ `nil` causes TODO keywords to be dropped from headlines. The default
+ is to include the keywords.
+ + Add support for todo-markers. Headlines can have optional
+ todo-markers which can be controlled via the `#+TODO`, `#+SEQ_TODO`,
+ or `#+TYP_TODO` meta directive. Multiple such directives can be
+ given, each adding a new set of recognized todo-markers. If no
+ custom todo-markers are defined, the default `TODO` and `DONE`
+ markers are used. Todo-markers are conceptually separate from
+ headline text and are hence excluded when autogenerating
+ headline IDs. The markers are rendered as spans and labelled with
+ two classes: One class is the markers name, the other signals the
+ todo-state of the marker (either `todo` or `done`).
+
+ * LaTeX writer:
+
+ + Use `\autocites*` when "suppress-author" citation used.
+ + Ensure that simple tables have simple cells (#2666). If cells
+ contain more than a single Plain or Para, then we need to set
+ nonzero widths and put contents into minipages.
+ + Remove invalid inlines in sections (#3218, Hubert Plociniczak).
+
+ * Markdown writer:
+
+ + Fix calculation of column widths for aligned multiline tables
+ (#1911, Björn Peemöller). This also fixes excessive CPU and memory
+ usage for tables when `--columns` is set in such a way that cells
+ must be very tiny. Now cells are guaranteed to be big enough so that
+ single words don't need to line break, even if this pushes the line
+ length above the column width.
+ + Use bracketed form for native spans when `bracketed_spans`
+ enabled (#3229).
+ + Fixed inconsistent spacing issue (#3232). Previously a tight bullet
+ sublist got rendered with a blank line after, while a tight ordered
+ sublist did not. Now we don't get the blank line in either case.
+ + Fix escaping of spaces in super/subscript (#3225). Previously two
+ backslashes were inserted, which gave a literal backslash.
+ + Adjust widths in Markdown grid tables so that they match
+ on round-trip.
+
+ * Docx writer:
+
+ + Give full detail when there are errors converting tex math.
+ + Handle title text in images (Jesse Rosenthal). We already handled
+ alt text. This just puts the image "title" into the docx
+ "title" attr.
+ + Fixed XML markup for empty cells (#3238). Previously the Compact
+ style wasn't being applied properly to empty cells.
+
+ * HTML writer:
+
+ + Updated `renderHtml` import from blaze-html.
+
+ * Text.Pandoc.Pretty:
+
+ + Fixed some bugs that caused blank lines in tables (#3251). The bugs
+ caused spurious blank lines in grid tables when we had things like
+ `blankline $$ blankline`.
+ + Add exported function `minOffet` \[API change\] (Björn Peemöller).
+ + Added error message for illegal call to `block` (Björn Peemöller).
+
+ * Text.Pandoc.Shared:
+
+ + Put `warn` in MonadIO.
+ + `fetchItem`: Better handling of protocol-relative URL (#2635). If
+ URL starts with `//` and there is no "base URL" (as there would be
+ if a URL were used on the command line), then default to http:.
+
+ * Export Text.Pandoc.getDefaultExtensions \[API change\] (#3178).
+
+ * In --version, trap error in `getAppUserDataDirectory` (#3241). This
+ fixes a crash with `pandoc --version` on unusual systems with no real
+ user (e.g. SQL Server 2016).
+
+ * Added weigh-pandoc for memory usage diagnostics (#3169).
+
+ * Use correct mime types for woff and woff2 (#3228).
+
+ * Remove make\_travis\_yml.hs (#3235, Kolen Cheung).
+
+ * changelog: Moved an item that was misplaced in the 1.17.2 section to the
+ 1.18 section where it belongs.
+
+ * CONTRIBUTING.md: minor change in wording and punctuation (#3252,
+ Kolen Cheung).
+
+ * Further revisions to manual for `--version` changes (#3244).
+
+
+pandoc (1.18)
+
+ * Added `--list-input-formats`, `--list-output-formats`,
+ `--list-extensions`, `--list-highlight-languages`, and
+ `--list-highlight-styles` (#3173). Removed list of highlighting
+ languages from `--version` output. Removed list of input and output
+ formats from default `--help` output.
+
+ * Added `--reference-location=block|section|document` option
+ (Jesse Rosenthal). This determines whether Markdown link references
+ and footnotes are placed at the end of the document, the end of the
+ section, or the end of the top-level block.
+
+ * Added `--top-level-division=section|chapter|part` (Albert Krewinkel).
+ This determines what a level-1 header corresponds to in LaTeX,
+ ConTeXt, DocBook, and TEI output. The default is `section`.
+ The `--chapters` option has been deprecated in favor of
+ `--top-level-division=chapter`.
+
+ * Added `LineBlock` constructor for `Block` (Albert Krewinkel). This
+ is now used in parsing RST and Markdown line blocks, DocBook
+ `linegroup`/`line` combinations, and Org-mode `VERSE` blocks.
+ Previously `Para` blocks with hard linebreaks were used. `LineBlock`s
+ are handled specially in the following ouput formats: AsciiDoc
+ (as `[verse]` blocks), ConTeXt (`\startlines`/`\endlines`),
+ HTML (`div` with a style), Markdown (line blocks if `line_blocks`
+ is enabled), Org-mode (`VERSE` blocks), RST (line blocks). In
+ other output formats, a paragraph with hard linebreaks is emitted.
+
+ * Allow binary formats to be written to stdout (but not to tty) (#2677).
+ Only works on posix, since we use the unix library to check whether
+ output is to tty. On Windows, pandoc works as before and always requires
+ an output file parameter for binary formats.
+
+ * Changed JSON output format (Jesse Rosenthal). Previously we used
+ generically generated JSON, but this was subject to change depending
+ on the version of aeson pandoc was compiled with. To ensure stability,
+ we switched to using manually written ToJSON and FromJSON
+ instances, and encoding the API version. **Note:** pandoc filter
+ libraries will need to be revised to handle the format change.
+ Here is a summary of the essential changes:
+
+ + The toplevel JSON format is now `{"pandoc-api-version" :
+ [MAJ, MIN, REV], "meta" : META, "blocks": BLOCKS}`
+ instead of `[{"unMeta": META}, [BLOCKS]]`.
+ Decoding fails if the major and minor version numbers don't
+ match.
+ + Leaf nodes no longer have an empty array for their "c" value.
+ Thus, for example, a `Space` is encoded as `{"t":"Space"}`
+ rather than `{"t":"Space","c":[]}` as before.
+
+ * Removed `tests/Tests/Arbitrary.hs` and added a `Text.Pandoc.Arbitrary`
+ module to pandoc-types (Jesse Rosenthal). This makes it easier
+ to use QuickCheck with pandoc types outside of pandoc itself.
+
+ * Add `bracketed_spans` Markdown extension, enabled by default
+ in pandoc `markdown`. This allows you to create a native span
+ using this syntax: `[Here is my span]{#id .class key="val"}`.
+
+ * Added `angle_brackets_escapable` Markdown extension (#2846).
+ This is needed because github flavored Markdown has a slightly
+ different set of escapable symbols than original Markdown;
+ it includes angle brackets.
+
+ * Export `Text.Pandoc.Error` in `Text.Pandoc` [API change].
+
+ * Print highlighting-kate version in `--version`.
+
+ * `Text.Pandoc.Options`:
+
+ + `Extension` has new constructors `Ext_brackted_spans` and
+ `Ext_angle_brackets_escapable` [API change].
+ + Added `ReferenceLocation` type [API change] (Jesse Rosenthal).
+ + Added `writerReferenceLocation` field to `WriterOptions` (Jesse
+ Rosenthal).
+
+ * `--filter`: we now check `$DATADIR/filters` for filters before
+ looking in the path (#3127, Jesse Rosenthal, thanks to Jakob
+ Voß for the idea). Filters placed in this directory need not
+ be executable; if the extension is `.hs`, `.php`, `.pl`, `.js`,
+ or `.rb`, pandoc will run the right interpreter.
+
+ * For `--webtex`, replace deprecated Google Chart API by CodeCogs as
+ default (Kolen Cheung).
+
+ * Removed `raw_tex` extension from `markdown_mmd` defaults (Kolen Cheung).
+
+ * Execute .js filters with node (Jakob Voß).
+
+ * Textile reader:
+
+ + Support `bc..` extended code blocks (#3037). Also, remove trailing
+ newline in code blocks (consistently with Markdown reader).
+ + Improve table parsing. We now handle cell and row attributes, mostly
+ by skipping them. However, alignments are now handled properly.
+ Since in pandoc alignment is per-column, not per-cell, we
+ try to devine column alignments from cell alignments.
+ Table captions are also now parsed, and textile indicators
+ for thead and tfoot no longer cause parse failure. (However,
+ a row designated as tfoot will just be a regular row in pandoc.)
+ + Improve definition list parsing. We now allow multiple terms
+ (which we concatenate with linebreaks). An exponential parsing
+ bug (#3020) is also fixed.
+ + Disallow empty URL in explicit link (#3036).
+
+ * RST reader:
+
+ + Use Div instead of BlockQuote for admonitions (#3031).
+ The Div has class `admonition` and (if relevant) one of the
+ following: `attention`, `caution`, `danger`, `error`, `hint`,
+ `important`, `note`, `tip`, `warning`. **Note:** This will change
+ the rendering of some RST documents! The word ("Warning", "Attention",
+ etc.) is no longer added; that must be done with CSS or a filter.
+ + A Div is now used for `sidebar` as well.
+ + Skip whitespace before note (Jesse Rosenthal, #3163). RST requires a
+ space before a footnote marker. We discard those spaces so that footnotes
+ will be adjacent to the text that comes before it. This is in line with
+ what rst2latex does.
+ + Allow empty lines when parsing line blocks (Albert Krewinkel).
+
+ * Markdown reader:
+
+ + Allow empty lines when parsing line blocks (Albert Krewinkel).
+ + Allow attributes on autolinks (#3183, Daniele D'Orazio).
+
+ * LaTeX reader:
+
+ + More robust parsing of unknown environments (#3026).
+ We no longer fail on things like `^` inside options for tikz.
+ + Be more forgiving of non-standard characters, e.g. `^` outside of math.
+ Some custom environments give these a meaning, so we should try not to
+ fall over when we encounter them.
+ + Drop duplicate `*` in bibtexKeyChars (Albert Krewinkel)
+
+ * MediaWiki reader:
+
+ + Fix for unquoted attribute values in mediawiki tables (#3053).
+ Previously an unquoted attribute value in a table row
+ could cause parsing problems.
+ + Improved treatment of verbatim constructions (#3055).
+ Previously these yielded strings of alternating Code and Space
+ elements; we now incorporate the spaces into the Code. Emphasis
+ etc. is still possible inside these.
+ + Properly interpret XML tags in pre environments (#3042). They are meant
+ to be interpreted as literal text.
+
+ * EPUB reader: don't add root path to data: URIs (#3150).
+ Thanks to @lep for the bug report and patch.
+
+ * Org reader (Albert Krewinkel):
+
+ + Preserve indentation of verse lines (#3064). Leading spaces in verse
+ lines are converted to non-breaking spaces, so indentation is preserved.
+ + Ensure image sources are proper links. Image sources as those in plain
+ images, image links, or figures, must be proper URIs or relative file
+ paths to be recognized as images. This restriction is now enforced
+ for all image sources. This also fixes the reader's usage of uncleaned
+ image sources, leading to `file:` prefixes not being deleted from
+ figure images. Thanks to @bsag for noticing this bug.
+ + Trim verse lines properly (Albert Krewinkel).
+ + Extract meta parsing code to module. Parsing of meta-data is well
+ separable from other block parsing tasks. Moving into new module to
+ get small files and clearly arranged code.
+ + Read markup only for special meta keys. Most meta-keys should be read
+ as normal string values, only a few are interpreted as marked-up text.
+ + Allow multiple, comma-separated authors. Multiple authors can be
+ specified in the `#+AUTHOR` meta line if they are given as a
+ comma-separated list.
+ + Give precedence to later meta lines. The last meta-line of any given
+ type is the significant line. Previously the value of the first line
+ was kept, even if more lines of the same type were encounterd.
+ + Read LaTeX_header as header-includes. LaTeX-specific header commands
+ can be defined in `#+LaTeX_header` lines. They are parsed as
+ format-specific inlines to ensure that they will only show up in LaTeX
+ output.
+ + Set documentclass meta from LaTeX_class.
+ + Set classoption meta from LaTeX_class_options.
+ + Read HTML_head as header-includes. HTML-specific head content can be
+ defined in `#+HTML_head` lines. They are parsed as format-specific
+ inlines to ensure that they will only show up in HTML output.
+ + Respect `author` export option. The `author` option controls whether
+ the author should be included in the final markup. Setting
+ `#+OPTIONS: author:nil` will drop the author from the final meta-data
+ output.
+ + Respect `email` export option. The `email` option controls whether the
+ email meta-field should be included in the final markup. Setting
+ `#+OPTIONS: email:nil` will drop the email field from the final
+ meta-data output.
+ + Respect `creator` export option. The `creator` option controls whether
+ the creator meta-field should be included in the final markup. Setting
+ `#+OPTIONS: creator:nil` will drop the creator field from the final
+ meta-data output. Org-mode recognizes the special value `comment` for
+ this field, causing the creator to be included in a comment. This is
+ difficult to translate to Pandoc internals and is hence interpreted the
+ same as other truish values (i.e. the meta field is kept if it's
+ present).
+ + Respect unnumbered header property (#3095). Sections the `unnumbered`
+ property should, as the name implies, be excluded from the automatic
+ numbering of section provided by some output formats. The Pandoc
+ convention for this is to add an "unnumbered" class to the header. The
+ reader treats properties as key-value pairs per default, so a special
+ case is added to translate the above property to a class instead.
+ + Allow figure with empty caption (Albert Krewinkel, #3161).
+ A `#+CAPTION` attribute before an image is enough to turn an image into
+ a figure. This wasn't the case because the `parseFromString` function,
+ which processes the caption value, would fail on empty values. Adding
+ a newline character to the caption value fixes this.
+
+ * Docx reader:
+
+ + Use XML convenience functions (Jesse Rosenthal).
+ The functions `isElem` and `elemName` (defined in Docx/Util.hs) make
+ the code a lot cleaner than the original XML.Light functions, but they
+ had been used inconsistently. This puts them in wherever applicable.
+ + Handle anchor spans with content in headers. Previously, we would only
+ be able to figure out internal links to a header in a docx if the
+ anchor span was empty. We change that to read the inlines out of the
+ first anchor span in a header.
+ + Let headers use exisiting id. Previously we always generated an id for
+ headers (since they wouldn't bring one from Docx). Now we let it use an
+ existing one if possible. This should allow us to recurs through anchor
+ spans.
+ + Use all anchor spans for header ids. Previously we only used the first
+ anchor span to affect header ids. This allows us to use all the anchor
+ spans in a header, whether they're nested or not (#3088).
+ + Test for nested anchor spans in header. This ensures that anchor spans
+ in header with content (or with other anchor spans inside) will resolve
+ to links to a header id properly.
+
+ * ODT reader (Hubert Plociniczak)
+
+ + Include list's starting value. Previously the starting value of
+ the lists' items has been hardcoded to 1. In reality ODT's list
+ style definition can provide a new starting value in one of its
+ attributes.
+ + Infer caption from the text following the image.
+ Frame can contain other frames with the text boxes.
+ + Add `fig:` to title for Image with a caption (as expected
+ by pandoc's writers).
+ + Basic support for images in ODT documents.
+ + Don't duplicate text for anchors (#3143). When creating an anchor
+ element we were adding its representation as well as the original
+ content, leading to text duplication.
+
+ * DocBook writer:
+
+ + Include an anchor element when a div or span has an id (#3102).
+ Note that DocBook does not have a class attribute, but at least this
+ provides an anchor for internal links.
+
+ * LaTeX writer:
+
+ + Don't use * for unnumbered paragraph, subparagraph. The starred
+ variants don't exist. This helps with part of #3058...it gets rid of
+ the spurious `*`s. But we still have numbers on the 4th and 5th level
+ headers.
+ + Properly escape backticks in verbatim (#3121, Jesse Rosenthal).
+ Otherwise they can cause unintended ligatures like `` ?` ``.
+ + Handle NARRAOW NO-BREAK SPACE into LaTeX (Vaclav Zeman) as `\,`.
+ + Don't include `[htbp]` placement for figures (#3103, Václav Haisman).
+ This allows figure placement defaults to be changed by the user
+ in the template.
+
+ * HTML writer (slide show formats): In slide shows, don't change slide title
+ to level 1 header (#2221).
+
+ * TEI writer: remove heuristic to detect book template (Albert Krewinkel).
+ TEI doesn't have `<book>` elements but only generic `<divN>` division
+ elements. Checking the template for a trailing `</book>` is nonsensical.
+
+ * MediaWiki writer: transform filename with underscores in images (#3052).
+ `foo bar.jpg` becomes `foo_bar.jpg`. This was already done
+ for internal links, but it also needs to happen for images.
+
+ * ICML writer: replace partial function (!!) in table handling (#3175,
+ Mauro Bieg).
+
+ * Man writer: allow section numbers that are not a single digit (#3089).
+
+ * AsciiDoc writer: avoid unnecessary use of "unconstrained" emphasis
+ (#3068). In AsciiDoc, you must use a special form of emphasis
+ (double `__`) for intraword emphasis. Pandoc was previously using
+ this more than necessary.
+
+ * EPUB writer: use stringify instead of plain writer for metadata
+ (#3066). This means that underscores won't be used for emphasis,
+ or CAPS for bold. The metadata fields will just have unadorned
+ text.
+
+ * Docx Writer:
+
+ + Implement user-defined styles (Jesse Rosenthal). Divs and Spans
+ with a `custom-style` key in the attributes will apply the corresponding
+ key to the contained blocks or inlines.
+ + Add ReaderT env to the docx writer (Jesse Rosenthal).
+ + Clean up and streamline RTL behavior (Jesse Rosenthal, #3140).
+ You can set `dir: rtl` in YAML metadata, or use `-M dir=rtl`
+ on the command line. For finer-grained control, you can set
+ the `dir` attribute in Div or Span elements.
+
+ * Org writer (Albert Krewinkel):
+
+ + Remove blank line after figure caption. Org-mode only treats an image
+ as a figure if it is directly preceded by a caption.
+ + Ensure blank line after figure. An Org-mode figure should be surrounded
+ by blank lines. The figure would be recognized regardless, but images
+ in the following line would unintentionally be treated as figures as
+ well.
+ + Ensure link targets are paths or URLs. Org-mode treats links as
+ document internal searches unless the link target looks like a URL or
+ file path, either relative or absolute. This change ensures that this
+ is always the case.
+ + Translate language identifiers. Pandoc and Org-mode use different
+ programming language identifiers. An additional translation between
+ those identifiers is added to avoid unexpected behavior. This fixes a
+ problem where language specific source code would sometimes be output
+ as example code.
+ + Drop space before footnote markers (Albert Krewinkel, #3162).
+ The writer no longer adds an extra space before footnote markers.
+
+ * Markdown writer:
+
+ + Don't emit HTML for tables unless `raw_html` extension is set (#3154).
+ Emit `[TABLE]` if no suitable table formats are enabled and raw HTML
+ is disabled.
+ + Check for the `raw_html` extension before emiting a raw HTML block.
+ + Abstract out note/ref function (Jesse Rosenthal).
+ + Add ReaderT monad for environment variables (Jesse Rosenthal).
+
+ * HTML, EPUB, slidy, revealjs templates: Use `<p>` instead of `<h1>` for
+ subtitle, author, date (#3119). Note that, as a result of this change,
+ authors may need to update CSS.
+
+ * revealjs template: Added `notes-server` option
+ (jgm/pandoc-templates#212, Yoan Blanc).
+
+ * Beamer template:
+
+ + Restore whitespace between paragraphs. This was
+ a regression in the last release (jgm/pandoc-templates#207).
+ + Added `themeoptions` variable (Carsten Gips).
+ + Added `beamerarticle` variable. This causes the `beamerarticle`
+ package to be loaded in beamer, to produce an article from beamer
+ slides. (Carsten Gips)
+ + Added support for `fontfamilies` structured variable
+ (Artem Klevtsov).
+ + Added hypersetup options (Jake Zimmerman).
+
+ * LaTeX template:
+
+ + Added dummy definition for `\institute`.
+ This isn't a standard command, and we want to avoid a crash when
+ `institute` is used with the default template.
+ + Define default figure placement (Václav Haisman), since pandoc
+ no longer includes `[htbp]` for figures. Users with custom templates
+ will want to add this. See #3103.
+ + Use footnote package to fix notes in tables (jgm/pandoc-templates#208,
+ Václav Haisman).
+
+ * Moved template compiling/rendering code to a separate library.
+ `doctemplates`. This allows the pandoc templating system to be
+ used independently.
+
+ * Text.Pandoc.Error: Fix out of index error in `handleError`
+ (Matthew Pickering). The fix is to not try to show the exact line when
+ it would cause an out-of-bounds error as a result of included files.
+
+ * Text.Pandoc.Shared: Add `linesToBlock` function (Albert Krewinkel).
+
+ * Text.Pandoc.Parsing.emailAddress: tighten up parsing of email
+ addresses. Technically `**@user` is a valid email address, but if we
+ allow things like this, we get bad results in markdown flavors
+ that autolink raw email addresses (see #2940). So we exclude a few
+ valid email addresses in order to avoid these more common bad cases.
+
+ * Text.Pandoc.PDF: Don't crash with nonexistent image (#3100). Instead,
+ emit the alt text, emphasized. This accords with what the ODT writer
+ currently does. The user will still get a warning about a nonexistent
+ image.
+
+ * Fix example in API documentation (#3176, Thomas Weißschuh).
+
+ * Tell where to get tarball in INSTALL (#3062).
+
+ * Rename README to MANUAL.txt and add GitHub-friendly README.md
+ (Albert Krewinkel, Kolen Cheung).
+
+ * Replace COPYING with Markdown version COPYING.md from GNU (Kolen Cheung).
+
+ * MANUAL.txt:
+
+ + Put note on structured vars in separate paragraph (#2148, Albert
+ Krewinkel). Make it clearer that structured author variables require a
+ custom template
+ + Note that `--katex` works best with `html5` (#3077).
+ + Fix the LaTeX and EPUB links in manual (Morton Fox).
+ + Document `biblio-title` variable.
+
+ * Improve spacing of footnotes in `--help` output (Waldir Pimenta).
+
+ * Update KaTeX to v0.6.0 (Kolen Cheung).
+
+ * Allow latest dependencies.
+
+ * Use texmath 0.8.6.6 (#3040).
+
+ * Allow http-client 0.4.30, which is the version in stackage lts.
+ Previously we required 0.5.
+ Remove CPP conditionals for earlier versions.
+
+ * Remove support for GHC < 7.8 (Jesse Rosenthal).
+
+ + Remove Compat.Monoid.
+ + Remove an inline monad compatibility macro.
+ + Remove Text.Pandoc.Compat.Except.
+ + Remove directory compat.
+ + Change constraint on mtl.
+ + Remove unnecessary CPP condition in UTF8.
+ + Bump base lower bound to 4.7.
+ + Remove 7.6 build from .travis.yaml.
+ + Bump supported ghc version in CONTRIBUTING.md.
+ + Add note about GHC version support to INSTALL.
+ + Remove GHC 7.6 from list of tested versions (Albert Krewinkel).
+ + Remove TagSoup compat.
+ + Add EOL note to time compat module. Because time 1.4 is a boot library
+ for GHC 7.8, we will support the compatibility module as long as we
+ support 7.8. But we should be clear about when we will no longer need
+ it.
+ + Remove blaze-html CPP conditional.
+ + Remove unnecessary CPP in custom Prelude.
+
+pandoc (1.17.2)
+
+ * Added Zim Wiki writer, template and tests. `zimwiki` is now
+ a valid output format. (Alex Ivkin)
+
+ * Changed email-obfuscation default to no obfuscation (#2988).
+ + `writerEmailObfuscation` in `defaultWriterOptions` is now
+ `NoObfuscation`.
+ + the default for the command-line `--email-obfuscation` option is
+ now `none`.
+
+ * Docbook writer: Declare xlink namespace in Docbook5 output (Ivo Clarysse).
+
+ * Org writer:
+
+ + Support arbitrary raw inlines (Albert Krewinkel).
+ Org mode allows arbitrary raw inlines ("export snippets" in Emacs
+ parlance) to be included as `@@format:raw foreign format text@@`.
+ + Improve Div handling (Albert Krewinkel). Div blocks handling is
+ changed to make the output look more like idiomatic org mode:
+ - Div-wrapped content is output as-is if the div's attribute is the
+ null attribute.
+ - Div containers with an id but neither classes nor key-value pairs
+ are unwrapped and the id is added as an anchor.
+ - Divs with classes associated with greater block elements are
+ wrapped in a `#+BEGIN`...`#+END` block.
+ - The old behavior for Divs with more complex attributes is kept.
+
+ * HTML writer:
+
+ + Better support for raw LaTeX environments (#2758).
+ Previously we just passed all raw TeX through when MathJax was used for
+ HTML math. This passed through too much. With this patch, only raw
+ LaTeX environments that MathJax can handle get passed through.
+ This patch also causes raw LaTeX environments to be treated
+ as math, when possible, with MathML and WebTeX output.
+
+ * Markdown writer: use raw HTML for simple, pipe tables with linebreaks
+ (#2993). Markdown line breaks involve a newline, and simple and pipe
+ tables can't contain one.
+
+ * Make --webtex work with the Markdown writer (#1177).
+ This is a convenient option for people using
+ websites whose Markdown flavors don't provide for math.
+
+ * Docx writer:
+
+ + Set paragraph to FirstPara after display math (Jesse Rosenthal).
+ We treat display math like block quotes, and apply FirstParagraph style
+ to paragraphs that follow them. These can be styled as the user
+ wishes. (But, when the user is using indentation, this allows for
+ paragraphs to continue after display math without indentation.)
+ + Use actual creation time as doc prop (Jesse Rosenthal).
+ Previously, we had used the user-supplied date, if available, for Word's
+ document creation metadata. This could lead to weird results, as in
+ cases where the user post-dates a document (so the modification might be
+ prior to the creation). Here we use the actual computer time to set the
+ document creation.
+
+ * LaTeX writer:
+
+ + Don't URI-escape image source (#2825). Usually this is a local file,
+ and replacing spaces with `%20` ruins things.
+ + Allow 'standout' as a beamer frame option (#3007).
+ `## Slide title {.standout}`.
+
+ * RST reader: Fixed links with no explicit link text. The link
+ `` `<foo>`_ `` should have `foo` as both its link text and its URL.
+ See RST spec at <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#embedded-uris-and-aliases>
+ Closes Debian #828167 -- reported by Christian Heller.
+
+ * Textile reader:
+
+ + Fixed attributes (#2984). Attributes can't be followed by
+ a space. So, `_(class)emph_` but `_(noclass) emph_`.
+ + Fixed exponential parsing bug (#3020).
+ + Fix overly aggressive interpretation as images (#2998).
+ Spaces are not allowed in the image URL in textile.
+
+ * LaTeX reader:
+
+ + Fix `\cite` so it is a NormalCitation not AuthorInText.
+ + Strip off double quotes around image source if present (#2825).
+ Avoids interpreting these as part of the literal filename.
+
+ * Org reader:
+
+ + Add semicolon to list of special chars (Albert Krewinkel)
+ Semicolons are used as special characters in citations syntax. This
+ ensures the correct parsing of Pandoc-style citations: `[prefix; @key;
+ suffix]`. Previously, parsing would have failed unless there was a space
+ or other special character as the last <prefix> character.
+ + Add support for "Berkeley-style" cites (Albert Krewinkel, #1978).
+ A specification for an official Org-mode citation syntax was drafted by
+ Richard Lawrence and enhanced with the help of others on the orgmode
+ mailing list. Basic support for this citation style is added to the
+ reader.
+ + Support arbitrary raw inlines (Albert Krewinkel).
+ Org mode allows arbitrary raw inlines ("export snippets" in Emacs
+ parlance) to be included as `@@format:raw foreign format text@@`.
+ + Remove partial functions (Albert Krewinkel, #2991).
+ Partial functions like `head` lead to avoidable errors and should be
+ avoided. They are replaced with total functions.
+ + Support figure labels (Albert Krewinkel, #2496, #2999).
+ Figure labels given as `#+LABEL: thelabel` are used as the ID of the
+ respective image. This allows e.g. the LaTeX to add proper `\label`
+ markup.
+ + Improve tag and properties type safety (Albert Krewinkel).
+ Specific newtype definitions are used to replace stringly typing of tags
+ and properties. Type safety is increased while readability is improved.
+ + Parse as headlines, convert to blocks (Albert Krewinkel).
+ Emacs org-mode is based on outline-mode, which treats documents as trees
+ with headlines are nodes. The reader is refactored to parse into a
+ similar tree structure. This simplifies transformations acting on
+ document (sub-)trees.
+ * Refactor comment tree handling (Albert Krewinkel).
+ Comment trees were handled after parsing, as pattern matching on lists
+ is easier than matching on sequences. The new method of reading
+ documents as trees allows for more elegant subtree removal.
+ * Support archived trees export options (Albert Krewinkel).
+ Handling of archived trees can be modified using the `arch` option.
+ Archived trees are either dropped, exported completely, or collapsed to
+ include just the header when the `arch` option is nil, non-nil, or
+ `headline`, respectively.
+ * Put export setting parser into module (Albert Krewinkel).
+ Export option parsing is distinct enough from general block parsing to
+ justify putting it into a separate module.
+ * Support headline levels export setting (Albert Krewinkel).
+ The depths of headlines can be modified using the `H` option. Deeper
+ headlines will be converted to lists.
+ * Replace ugly code with view pattern (Albert Krewinkel).
+ Some less-than-smart code required a pragma switching of overlapping
+ pattern warnings in order to compile seamlessly. Using view patterns
+ makes the code easier to read and also doesn't require overlapping
+ pattern checks to be disabled.
+ * Fix parsing of verbatim inlines (Albert Krewinkel, #3016).
+ Org rules for allowed characters before or after markup chars were not
+ checked for verbatim text. This resultet in wrong parsing outcomes of
+ if the verbatim text contained e.g. space enclosed markup characters as
+ part of the text (`=is_substr = True=`). Forcing the parser to update
+ the positions of allowed/forbidden markup border characters fixes this.
+
+ * LaTeX template: fix for obscure hyperref/xelatex issue.
+ Here's a minimal case:
+
+ \documentclass[]{article}
+ \usepackage{hyperref}
+ \begin{document}
+ \section{\%á}
+ \end{document}
+
+ Without this change, this fails on the second invocation of xelatex.
+ This affects inputs this like `# %á` with pdf output via xelatex.
+
+ * trypandoc: call results 'html' instead of 'result'.
+ This is for better compatibility with babelmark2.
+
+ * Document MultiMarkdown as input/output format (Albert Krewinkel, #2973).
+ MultiMarkdown was only mentioned as a supported Markdown dialect but not
+ as a possible input or output format. A brief mention is added
+ everywhere the other supported markdown dialects are mentioned.
+
+ * Document Org mode as a format containing raw HTML (Albert Krewinkel)
+ Raw HTML is kept when the output format is Emacs Org mode.
+
+ * Implement `RawInline` and `RawBlock` in sample lua custom writer (#2985).
+
+ * Text.Pandoc.Shared:
+
+ + Introduce blocksToInlines function (Jesse Rosenthal).
+ This is a lossy function for converting `[Block] -> [Inline]`. Its main
+ use, at the moment, is for docx comments, which can contain arbitrary
+ blocks (except for footnotes), but which will be converted to spans.
+ This is, at the moment, pretty useless for everything but the basic
+ `Para` and `Plain` comments. It can be improved, but the docx reader
+ should probably emit a warning if the comment contains more than this.
+ + Add BlockQuote to blocksToInlines (Jesse Rosenthal).
+ + Add further formats for `normalizeDate` (Jesse Rosenthal).
+ We want to avoid illegal dates -- in particular years with greater than
+ four digits. We attempt to parse series of digits first as `%Y%m%d`, then
+ `%Y%m`, and finally `%Y`.
+ + `normalizeDate` should reject illegal years (Jesse Rosenthal).
+ We only allow years between 1601 and 9999, inclusive. The ISO 8601
+ actually says that years are supposed to start with 1583, but MS Word
+ only allows 1601-9999. This should stop corrupted word files if the date
+ is out of that range, or is parsed incorrectly.
+ + Improve year sanity check in normalizeDate (Jesse Rosenthal).
+ Previously we parsed a list of dates, took the first one, and then
+ tested its year range. That meant that if the first one failed, we
+ returned nothing, regardless of what the others did. Now we test for
+ sanity before running `msum` over the list of Maybe values. Anything
+ failing the test will be Nothing, so will not be a candidate.
+
+ * Docx reader:
+
+ + Add simple comment functionality. (Jesse Rosenthal).
+ This adds simple track-changes comment parsing to the docx reader. It is
+ turned on with `--track-changes=all`. All comments are converted to
+ inlines, which can list some information. In the future a warning will be
+ added for comments with formatting that seems like it will be excessively
+ denatured. Note that comments can extend across blocks. For that reason
+ there are two spans: `comment-start` and `comment-end`. `comment-start`
+ will contain the comment. `comment-end` will always be empty. The two
+ will be associated by a numeric id.
+ + Enable warnings in top-level reader (Jesse Rosenthal).
+ Previously we had only allowed for warnings in the parser. Now we allow
+ for them in the `Docx.hs` as well. The warnings are simply concatenated.
+ + Add warning for advanced comment formatting. (Jesse Rosenthal).
+ We can't guarantee we'll convert every comment correctly, though we'll
+ do the best we can. This warns if the comment includes something other
+ than Para or Plain.
+ + Add tests for warnings. (Jesse Rosenthal).
+ + Add tests for comments (Jesse Rosenthal).
+ We test for comments, using all track-changes options. Note that we
+ should only output comments if `--track-changes=all`. We also test for
+ emitting warnings if there is complicated formatting.
+
+ * README: update to include track-changes comments. (Jesse Rosenthal)
+
+ * Improved Windows installer - don't ignore properties set on command-line.
+ See #2708. Needs testing to see if this resolves the issue.
+ Thanks to @nkalvi.
+
+ * Process markdown extensions on command line in L->R order (#2995).
+ Previously they were processed, very unintuitively, in R->L
+ order, so that `markdown-tex_math_dollars+tex_math_dollars`
+ had `tex_math_dollars` disabled.
+
+ * Added `secnumdepth` variable to LaTeX template (#2920).
+
+ * Include table of contents in README.html in Windows package.
+
+ * Writers: treat SoftBreak as space for stripping (Jesse Rosenthal)
+ In Writers.Shared, we strip leading and trailing spaces for display
+ math. Since SoftBreak's are treated as spaces, we should strip those
+ too.
+
+ * beamer, latex templates: pass biblatexoptions directly in package load.
+ This allows runtime optinos to be used. Fixes jgm/pandoc-citeproc#201
+
+ * CPP workaround for deprecation of `parseUrl` in http-client.
+
+ * Removed some redundant class constraints.
+
+ * make_oxs_package.sh - use OSX env variable.
+
+ * Replaced INSTALL with INSTALL.md, incorporating INSTALL and the
+ old installing page from website.
+
+ * Added `winpkg` target to Makefile. This downloads the windows package
+ from appveyor and signs it using the key.
+
+ * Document Org mode as a format containing raw TeX (Albert Krewinkel).
+ Raw TeX is kept verbatim when the output format is Emacs Org mode.
+
+ * Support math with haddock-library >= 1.4.
+
+ * Removed `-rtsopts` from library stanza. It has no effect, and Hackage
+ wouldn't accept the package.
+
+ * Update library dependency versions.
+
+pandoc (1.17.1)
+
+ * New output format: `docbook5` (Ivo Clarysse).
+
+ * `Text.Pandoc.Options`: Add `writerDocBook5` to `WriterOptions`
+ (API change).
+
+ * Org writer:
+
+ + Add :PROPERTIES: drawer support (Albert Krewinkel, #1962).
+ This allows header attributes to be added to org documents in the form
+ of `:PROPERTIES:` drawers. All available attributes are stored as
+ key/value pairs. This reflects the way the org reader handles
+ `:PROPERTIES:` blocks.
+ + Add drawer capability (Carlos Sosa). For the implementation of the
+ Drawer element in the Org Writer, we make use of a generic Block
+ container with attributes. The presence of a `drawer` class defines
+ that the `Div` constructor is a drawer. The first class defines the
+ drawer name to use. The key-value list in the attributes defines
+ the keys to add inside the Drawer. Lastly, the list of Block elements
+ contains miscellaneous blocks elements to add inside of the Drawer.
+ + Use `CUSTOM_ID` in properties (Albert Krewinkel). The `ID` property is
+ reserved for internal use by Org-mode and should not be used.
+ The `CUSTOM_ID` property is to be used instead, it is converted to the
+ `ID` property for certain export format.
+
+ * LaTeX writer:
+
+ + Ignore `--incremental` unless output format is beamer (#2843).
+ + Fix polyglossia to babel env mapping (Mauro Bieg, #2728).
+ Allow for optional argument in square brackets.
+ + Recognize `la-x-classic` as Classical Latin (Andrew Dunning).
+ This allows one to access the hyphenation patterns in CTAN's
+ hyph-utf8.
+ + Add missing languages from hyph-utf8 (Andrew Dunning).
+ + Improve use of `\strut` with `\minipage` inside tables
+ (Jose Luis Duran). This improves spacing in multiline
+ tables.
+ + Use `{}` around options containing special chars (#2892).
+ + Avoid lazy `foldl`.
+ + Don't escape underscore in labels (#2921). Previously they were
+ escaped as `ux5f`.
+ + brazilian -> brazil for polyglossia (#2953).
+
+ * HTML writer: Ensure mathjax link is added when math appears in footnote
+ (#2881). Previously if a document only had math in a footnote, the
+ MathJax link would not be added.
+
+ * EPUB writer: set `navpage` variable on nav page.
+ This allows templates to treat it differently.
+
+ * DocBook writer:
+
+ + Use docbook5 if `writerDocbook5` is set (Ivo Clarysse).
+ + Properly handle `ulink`/`link` (Ivo Clarysse).
+
+ * EPUB reader:
+
+ + Unescape URIs in spine (#2924).
+ + EPUB reader: normalise link id (Mauro Bieg).
+
+ * Docx Reader:
+
+ + Parse `moveTo` and `moveFrom` (Jesse Rosenthal).
+ `moveTo` and `moveFrom` are track-changes tags that are used when a
+ block of text is moved in the document. We now recognize these tags and
+ treat them the same as `insert` and `delete`, respectively. So,
+ `--track-changes=accept` will show the moved version, while
+ `--track-changes=reject` will show the original version.
+ + Tests for track-changes moving (Jesse Rosenthal).
+
+ * ODT, EPUB, Docx readers: throw `PandocError` on unzip failure
+ (Jesse Rosenthal) Previously, `readDocx`, `readEPUB`, and `readOdt`
+ would error out if zip-archive failed. We change the archive extraction
+ step from `toArchive` to `toArchiveOrFail`, which returns an Either value.
+
+ * Markdown, HTML readers: be more forgiving about unescaped `&` in
+ HTML (#2410). We are now more forgiving about parsing invalid HTML with
+ unescaped `&` as raw HTML. (Previously any unescaped `&`
+ would cause pandoc not to recognize the string as raw HTML.)
+
+ * Markdown reader:
+
+ + Added bracket syntax for native spans (#168).
+ + Fix pandoc title blocks with lines ending in 2 spaces (#2799).
+ + Added `-s` to markdown-reader-more test.
+
+ * HTML reader: fixed bug in `pClose`. This caused exponential parsing
+ behavior in documnets with unclosed tags in `dl`, `dd`, `dt`.
+
+ * MediaWiki reader: Allow spaces before `!` in MediaWiki table header
+ (roblabla).
+
+ * RST reader: Support `:class:` option for code block in RST reader
+ (Sidharth Kapur).
+
+ * Org reader (all Albert Krewinkel, except where noted otherwise):
+
+ + Stop padding short table rows.
+ Emacs Org-mode doesn't add any padding to table rows. The first
+ row (header or first body row) is used to determine the column count,
+ no other magic is performed.
+ + Refactor rows-to-table conversion. This refactors
+ the codes conversing a list table lines to an org table ADT.
+ The old code was simplified and is now slightly less ugly.
+ + Fix handling of empty table cells, rows (Albert Krewinkel, #2616).
+ This fixes Org mode parsing of some corner cases regarding empty cells
+ and rows. Empty cells weren't parsed correctly, e.g. `|||` should be
+ two empty cells, but would be parsed as a single cell containing a pipe
+ character. Empty rows where parsed as alignment rows and dropped from
+ the output.
+ + Fix spacing after LaTeX-style symbols.
+ The org-reader was droping space after unescaped LaTeX-style symbol
+ commands: `\ForAll \Auml` resulted in `∀Ä` but should give `∀ Ä`
+ instead. This seems to be because the LaTeX-reader treats the
+ command-terminating space as part of the command. Dropping the trailing
+ space from the symbol-command fixes this issue.
+ + Print empty table rows. Empty table rows should not
+ be dropped from the output, so row-height is always set to be at least 1.
+ + Move parser state into separate module.
+ The org reader code has become large and confusing. Extracting smaller
+ parts into submodules should help to clean things up.
+ + Add support for sub/superscript export options.
+ Org-mode allows to specify export settings via `#+OPTIONS` lines.
+ Disabling simple sub- and superscripts is one of these export options,
+ this options is now supported.
+ + Support special strings export option Parsing of special strings
+ (like `...` as ellipsis or `--` as en dash) can be toggled using the `-`
+ option.
+ + Support emphasized text export option. Parsing of emphasized text can
+ be toggled using the `*` option. This influences parsing of text marked
+ as emphasized, strong, strikeout, and underline. Parsing of inline math,
+ code, and verbatim text is not affected by this option.
+ + Support smart quotes export option. Reading of smart quotes can be
+ toggled using the `'` option.
+ + Parse but ignore export options. All known export options are parsed
+ but ignored.
+ + Refactor block attribute handling. A parser state attribute was used
+ to keep track of block attributes defined in meta-lines. Global state
+ is undesirable, so block attributes are no longer saved as part of the
+ parser state. Old functions and the respective part of the parser state
+ are removed.
+ + Use custom `anyLine`. Additional state changes need to be made after
+ a newline is parsed, otherwise markup may not be recognized correctly.
+ This fixes a bug where markup after certain block-types would not be
+ recognized.
+ + Add support for `ATTR_HTML` attributes (#1906).
+ Arbitrary key-value pairs can be added to some block types using a
+ `#+ATTR_HTML` line before the block. Emacs Org-mode only includes these
+ when exporting to HTML, but since we cannot make this distinction here,
+ the attributes are always added. The functionality is now supported
+ for figures.
+ + Add `:PROPERTIES:` drawer support (#1877).
+ Headers can have optional `:PROPERTIES:` drawers associated with them.
+ These drawers contain key/value pairs like the header's `id`. The
+ reader adds all listed pairs to the header's attributes; `id` and
+ `class` attributes are handled specially to match the way `Attr` are
+ defined. This also changes behavior of how drawers of unknown type
+ are handled. Instead of including all unknown drawers, those are not
+ read/exported, thereby matching current Emacs behavior.
+ + Use `CUSTOM_ID` in properties. See above on Org writer changes.
+ + Respect drawer export setting. The `d` export option can be used
+ to control which drawers are exported and which are discarded.
+ Basic support for this option is added here.
+ + Ignore leading space in org code blocks (Emanuel Evans, #2862).
+ Also fix up tab handling for leading whitespace in code blocks.
+ + Support new syntax for export blocks. Org-mode version 9
+ uses a new syntax for export blocks. Instead of `#+BEGIN_<FORMAT>`,
+ where `<FORMAT>` is the format of the block's content, the new
+ format uses `#+BEGIN_export <FORMAT>` instead. Both types are
+ supported.
+ + Refactor `BEGIN...END` block parsing.
+ + Fix handling of whitespace in blocks, allowing content to be indented
+ less then the block header.
+ + Support org-ref style citations. The *org-ref* package is an
+ org-mode extension commonly used to manage citations in org
+ documents. Basic support for the `cite:citeKey` and
+ `[[cite:citeKey][prefix text::suffix text]]` syntax is added.
+ + Split code into separate modules, making for cleaner code and
+ better decoupling.
+
+ * Added `docbook5` template.
+
+ * `--mathjax` improvements:
+
+ + Use new CommonHTML output for MathJax (updated default MathJax URL,
+ #2858).
+ + Change default mathjax setup to use `TeX-AMS_CHTML` configuration.
+ This is designed for cases where the input is always TeX and maximal
+ conformity with TeX is desired. It seems to be smaller and load faster
+ than what we used before. See #2858.
+ + Load the full MathJax config to maximize loading speed (KolenCheung).
+
+ * Bumped upper version bounds to allow use of latest packages
+ and compilation with ghc 8.
+
+ * Require texmath 0.8.6.2. Closes several texmath-related bugs (#2775,
+ #2310, #2310, #2824). This fixes behavior of roots, e.g.
+ `\sqrt[3]{x}`, and issues with sub/superscript positioning
+ and matrix column alignment in docx.
+
+ * README:
+
+ + Clarified documentation of `implicit_header_references` (#2904).
+ + Improved documentation of `--columns` option.
+
+ * Added appveyor setup, with artefacts (Jan Schulz).
+
+ * stack.yaml versions: Use proper flags used for texmath, pandoc-citeproc.
+
+ * LaTeX template: support for custom font families (vladipus).
+ Needed for correct polyglossia operation with Cyrillic fonts and perhaps
+ can find some other usages. Example usage in YAML metadata:
+
+ fontfamilies:
+ - name: \cyrillicfont
+ font: Liberation Serif
+ - name: \cyrillicfonttt
+ options: Scale=MatchLowercase
+ font: Liberation
+
+ * Create unsigned msi as build artifact in appveyor build.
+
+ * On travis, test with ghc 8.0.1; drop testing for ghc 7.4.1.
+
+pandoc (1.17.0.3)
+
+ * LaTeX writer: Fixed position of label in figures (#2813).
+ Previously the label wasn't in the right place, and `\ref`
+ wouldn't work properly.
+ * Added .tei test files to pandoc.cabal so they'll be included
+ in tarball (#2811).
+ * Updated copyright dates.
+
+pandoc (1.17.0.2)
+
+ * Fixed serious regression in `htmlInBalanced`, which caused
+ newlines to be omitted in some raw HTML blocks in Markdown
+ (#2804).
+
+pandoc (1.17.0.1)
+
+ * File scope is no longer used when there are no input files (i.e.,
+ when input comes from stdin). Previously file scope was triggered
+ when the `json` reader was specified and input came from `stdin`,
+ and this caused no output to be produced. (Fix due to Jesse Rosenthal;
+ thanks to Fedor Sheremetyev for calling the bug to our attention.)
+ * Improved documentation of templates (#2797).
+
+pandoc (1.17)
+
+ * Added `--file-scope` option (Jesse Rosenthal).
+ By default pandoc operates on multiple files by first concatenating
+ them (around extra line breaks) and then processing the joined file. So
+ it only parses a multi-file document at the document scope. This has the
+ benefit that footnotes and links can be in different files, but for
+ some purposes it is useful to parse the individual files first
+ and then combine their outputs (e.g. when the files use footnotes
+ or links with the same labels). The `--file-scope` option causes
+ pandoc to parse the files first, and then combine the parsed output,
+ instead of combining before parsing. `--file-scope` is selected
+ automatically for binary input files (which cannot be concatenated)
+ and for pandoc json.
+
+ * Add TEI Writer (Chris Forster) and `tei` output format.
+
+ * Added a general `ByteStringReader` with warnings, used by the docx
+ reader (API change, Jesse Rosenthal).
+
+ * Add `readDocxWithWarnings` (API change, Jesse Rosenthal).
+
+ * Changed type of `Shared.uniqueIdent`'s argument from `[String]`
+ to `Set String.` This avoids performance problems in documents with
+ many identically named headers (API change, #2671).
+
+ * Removed `tex_math_single_backslash` from `markdown_github` options
+ (#2707).
+
+ * Make language extensions as well as full language names
+ trigger syntax highlighting. For example, `py` will now work as
+ well as `python` (jgm/highlighting-kate#83).
+
+ * Added `institute` variable to latex, beamer templates (Fraser
+ Tweedale, Josef Svenningsson).
+
+ * Docx reader (Jesse Rosenthal):
+
+ + Handle alternate content. Some word functions (especially graphics)
+ give various choices for content so there can be backwards compatibility.
+ + Don't turn numbered headers into lists.
+ + Docx Reader: Add state to the parser, for warnings
+ + Update feature checklist in source code.
+ + Get rid of `Modifiable` typeclass.
+ + Add tests for adjacent hyperlinks.
+ + Add a "Link" modifier to `Reducible`. We want to make sure that
+ links have their spaces removed, and are appropriately smushed
+ together (#2689).
+
+ * HTML reader:
+
+ + Fixed behavior of base tag (#2777).
+ If the base path does not end with slash, the last component
+ will be replaced. E.g. base = `http://example.com/foo`
+ combines with `bar.html` to give `http://example.com/bar.html`.
+ If the href begins with a slash, the whole path of the base
+ is replaced. E.g. base = `http://example.com/foo/` combines
+ with `/bar.html` to give `http://example.com/bar.html`.
+ + Rewrote `htmlInBalanced`. This version avoids an exponential
+ performance problem with `<script>` tags, and it should be faster
+ in general (#2730).
+ + Properly handle an empty cell in a simple table (#2718).
+ + Handle multiple `<meta>` tags with same name. Put them in a list
+ in the metadata so they are all preserved, rather than (as before)
+ throwing out all but one..
+
+ * Markdown reader:
+
+ + Improved pipe table parsing (#2765).
+ + Allow `+` separators in pipe table cells. We already allowed
+ them in the header, but not in the body rows, for some reason.
+ This gives compatibility with org-mode tables.
+ + Don't cross line boundary parsing pipe table row.
+ Previously an Emph element could be parsed across the newline
+ at the end of the pipe table row.
+ + Use `htmlInBalanced` for `rawVerbatimBlock`, for better
+ performance (#2730).
+ + Fixed bug with smart quotes around tex math.
+
+ * LaTeX reader:
+
+ + Handle interior `$` characters in math (#2743). For example,
+ `$$\hbox{$i$}$$`.
+ + `inlineCommand` now gobbles an empty `{}` after any command (#2687).
+ This gives better results when people write e.g. `\TeX{}` in Markdown.
+ + Properly handle LaTeX "math" environment as inline math (#2171).
+
+ * Textile reader: Support `>`, `<`, `=`, `<>` text alignment attributes.
+ Closes #2674.
+
+ * Org reader (Albert Krewinkel):
+
+ + Prefix even empty figure names with "fig:" (#2643). The
+ convention used by pandoc for figures is to mark them by prefixing
+ the name with `fig:`. The org reader failed to do this if a figure
+ had no name.
+ + Refactor link-target processing (#2684).
+
+ * ConTeXt writer: Fix whitespace at line beginning in line blocks (#2744).
+ Thanks to @c-foster.
+
+ * HTML writer: Don't include alignment attribute for default table columns.
+ Previously these were given "left" alignment. Better to leave off
+ alignment attributes altogether (#2694).
+
+ * Markdown writer: Use hyphens for YAML metadata block bottom line, for
+ better compatibility with other Markdown flavors (Henrik Tramberend).
+
+ * LaTeX writer:
+
+ + Use image identifier to create a label and hypertarget for
+ figures (Mauro Bieg).
+ + Avoid double toprule in headerless table with caption (#2742).
+ + Clean up options parser (Jesse Rosenthal).
+ + Treat `memoir` template with `article` option as article, instead
+ of treating all `memoir` templates as books.
+ + Allow more flexible table alignment (Henrik Tramberend, #2665).
+ New default is not to include `[c]` option (which is the default
+ anyway if no positioning is specified). Now LaTeX emplates can
+ control the overall table alignment in a document by setting the
+ longtable length variables `LTleft` and `LTright`. For example,
+ `\setlength\LTleft\parindent\setlength\LTright\fill`
+ will create left-aligned tables that respect paragraph indentation.
+
+ * Docx writer: Handle image alt text (#2754, Mauro Bieg).
+
+ * Org writer - pass through RawInline with format "org".
+
+ * DokuWiki writer: use `$$` for display math.
+
+ * Custom writer: Pass attributes parameter to CaptionedImage (#2697).
+
+ * Make protocol-relative URIs work again (#2737).
+
+ * make_osx_package.sh: Use env variable for developer id certs.
+
+ * Raise `tagsoup` lower bound to 0.13.7 to fix entity-related
+ problems (#2734).
+
+ * Allow `zip-archive` 0.3.
+
+ * Allow `aeson` 0.11.
+
+pandoc (1.16.0.2)
+
+ * Depend on deepseq rather than deepseq-generics (fpco/stackage#1096).
+
+ * Fixed regression in latex smart quote parsing (#2645).
+ In cases where a match was not found for a quote, everything
+ from the open quote to the end of the paragraph was being dropped.
+
+pandoc (1.16.0.1)
+
+ * Fixed regression with `--latex-engine` (#2618). In 1.16 `--latex-engine`
+ raises an error if a full path is given.
+
+ * Org reader: Fix function dropping subtrees tagged `:noexport`
+ (Albert Krewinkel, #2628):
+
+ * Markdown reader: renormalize table column widths if they exceed 100%
+ (#2626).
+
+ * Textile reader: don't allow block HTML tags in inline contexts.
+ The reader previously did allow this, following redcloth,
+ which happily parses
+
+ Html blocks can be <div>inlined</div> as well.
+
+ as
+
+ <p>Html blocks can be <div>inlined</div> as well.</p>
+
+ This is invalid HTML. The above sample now produces;
+
+ <p>Html blocks can be</p>
+ <div>
+ <p>inlined</p>
+ </div>
+ <p>as well.</p>
+
+ * Improved default template lookup for custom lua scripts (#2625).
+ Previously, if you tried to do `pandoc -s -t /path/to/lua/script.lua`,
+ pandoc would look for the template in
+ `~/.pandoc/templates/default./path/to/lua/script.lua`.
+ With this change it will look in the more reasonable
+ `~/.pandoc/templates/default.script.lua`. This makes it possible to
+ store default templates for custom writers.
+
+ * RST, Markdown writers: Fixed rendering of grid tables with blank rows
+ (#2615).
+
+ * LaTeX writer: restore old treatment of Span (#2624). A Span is
+ now rendered with surrounding `{}`, as it was before 1.16.
+
+ * Entity handling fixes: improved handling of entities like
+ `&lang;` that require a trailing semicolon. Allow uppercase
+ `x` in numerical hexidecimal character references, working
+ around a tagsoup bug.
+
+ * `stack.yaml` - use lts-4.0, but with older aeson to avoid excessive
+ memory use on compile. With aeson 0.10 we were getting an out of
+ memory error on a 2GB Ubuntu 64-bit VM.
+
+ * Improved deb package creation script. Made `DPKGVER` work.
+ Renamed `COMMIT` to `TREE`. You should now be able to do
+ `TREE=1.16.0.1 DPKGVER=2 make deb`.
+
+
+pandoc (1.16)
+
+ * Added `Attr` field to `Link` and `Image` (Mauro Bieg, #261, API change).
+
+ + Added syntax for link and image attributes to pandoc's Markdown.
+ + Updated readers and writers to use link and image attributes
+ when appropriate.
+ + Support image attributes in Docx, Textile, RST readers.
+
+ * Renamed link attribute extensions. The old `link_attributes` is
+ now `mmd_link_attributes`, and `link_attributes` now enables the
+ new pandoc-style link and image attributes (API change).
+ Note: this change could break some existing workflows.
+
+ * Implemented `SoftBreak` and new `--wrap` option (#1701, API change).
+ Added threefold wrapping option.
+
+ + Command line option: deprecated `--no-wrap`, added
+ `--wrap=[auto|none|preserve]`
+ + Added `WrapOption`, exported from `Text.Pandoc.Options`
+ + Changed type of `writerWrapText` in `WriterOptions` from
+ `Bool` to `WrapOption`.
+ + Modified `Text.Pandoc.Shared` functions to allow `SoftBreak`.
+ + Supported `SoftBreak` in readers and writers.
+
+ * Text.Pandoc.Options: Added `writerDpi` to `WriterOptions` (API
+ change, Mauro Bieg).
+
+ * Added `--dpi` command-line option (Mauro Bieg).
+
+ * Rationalized behavior of `--no-tex-ligatures` and `--smart` (#2541).
+ This change makes `--no-tex-ligatures` affect the LaTeX reader
+ as well as the LaTeX and ConTeXt writers. If it is used,
+ the LaTeX reader will parse characters `` ` ``, `'`, and `-`
+ literally, rather than parsing ligatures for quotation marks
+ and dashes. And the LaTeX writer will print unicode quotation
+ mark and dash characters literally, rather than converting
+ them to the standard ASCII ligatures. Note that `--smart` has
+ no effect on the LaTeX reader. `--smart` is still the default
+ for all input formats when LaTeX or ConTeXt is the output format,
+ *unless* `--no-tex-ligatures` is used.
+
+ Some examples to illustrate the logic:
+
+ ```
+ % echo "'hi'" | pandoc -t latex
+ `hi'
+ % echo "'hi'" | pandoc -t latex --no-tex-ligatures
+ 'hi'
+ % echo "'hi'" | pandoc -t latex --no-tex-ligatures --smart
+ ‘hi’
+ % echo "'hi'" | pandoc -f latex --no-tex-ligatures
+ <p>'hi'</p>
+ % echo "'hi'" | pandoc -f latex
+ <p>’hi’</p>
+ ```
+
+ * Removed deprecated options `--offline` and `--html5`.
+
+ * Fixed language code for Czech (`cs` not `cz`) (#2597).
+
+ * Implemented `east_asian_line_breaks` extension (#2586).
+ In `Text.Pandoc.Options`, added `Ext_east_asian_line_breaks` constructor
+ to `Extension` (API change). This extension is like
+ `ignore_line_breaks`, but smarter -- it only ignores line breaks
+ between two East Asian wide characters. This makes it better suited
+ for writing with a mix of East Asian and non-East Asian scripts.
+
+ * Added support for PDF creation via `wkhtmltopdf`.
+ To use this: `pandoc -t html5 -o result.pdf` (and add `--mathjax`
+ if you have math.) Margins can be set using the variables
+ `margin-top`, `margin-bottom`, `margin-left`, `margin-right`.
+ Other styling can be done through CSS.
+
+ * Fixed cite key parsing regression (jgm/pandoc-citeproc#201).
+ We were capturing final colons as in `[@foo: bar]`; the citation id
+ was being parsed as `@foo:`.
+
+ * ICML writer:
+
+ + Fixed image syntax for local files (#2589).
+ + Changed type of `writeICML` (Mauro Bieg).
+ API change: It is now `WriterOptions -> Pandoc -> IO String`.
+ Also handle new image attributes.
+ + Intersperse line breaks instead of appending them to
+ every `ParagraphStyleRange` (Mauro Bieg, #2501).
+ + Add `Cite` style to citations (Mauro Bieg).
+ + Added figure handling (#2590, Mauro Bieg).
+ + Better handling of math. Instead of just printing the raw tex,
+ we now try to fake it with unicode characters.
+
+ * HTML writer: Include `example` class for example lists (#2524).
+
+ * ODT/OpenDocument writer: improved image attributes (Mauro Bieg).
+
+ + Support for percentage widths/heights
+ + Use `Attr` instead of title to get dimensions from ODT walker
+ to `writeOpenDocument`.
+
+ * AsciiDoc writer:
+
+ + Support anchors in spans and divs with id elements
+ (jgm/pandoc-citeproc#143).
+ + Fixed code blocks (#1861).
+
+ * Haddock writer: omit formatting inside links, which isn't supported
+ by Haddock (#2515).
+
+ * MediaWiki writer: Fixed spacing issues in table cells.
+
+ + Start cell on new line unless it's a single Para or Plain
+ (#2606).
+ + For single Para or Plain, insert a space after the `|` to
+ avoid problems when the text begins with a character like
+ `-` (#2604).
+
+ * Beamer writer: mark frame as fragile when it contains verbatim (#1613).
+
+ * LaTeX writer:
+
+ + Add support for GAP highlighting using listings (Raniere Silva).
+ + Consider `header-includes` content as well as templates
+ when determining whether to use csquotes (Andreas Lööw).
+ + Create defaults for geometry using `margin-left` etc.
+ If `geometry` has no value, but `margin-left`, `margin-right`,
+ `margin-top`, and/or `-margin-bottom` are given, a default value
+ for `geometry` is created from these. Note that these variables
+ already affect PDF production via HTML5 with `wkhtmltopdf`.
+
+ * ConTeXt writer: set default layout based on `margin-left`, etc.
+ This sets up `\setuplayout` based on the variables `margin-left`,
+ `margin-right`, `margin-bottom`, and `margin-top`, if no layout
+ is given.
+
+ * Docx writer: better handling of PDF images. Previously we tried
+ to get the image size from the image even if an explicit size was
+ specified. Since we still can't get image size for PDFs, this made
+ it impossible to use PDF images in docx. Now we don't try to get
+ the image size when a size is already explicitly specified.
+
+ * Markdown writer: use raw HTML for link/image attributes when
+ the `link_attributes` extension is unset and `raw_html` is set (#2554).
+
+ * MediaWiki reader: interpret markup inside `<tt>`, `<code>` (#2607).
+
+ * LaTeX reader:
+
+ + Improved smart quote parsing (#2555). This fixes redering of
+ unmatched quotes.
+ + Use curly quotes for unmatched ` (#2555).
+ + Allow blank space between braced arguments of commands (#2592).
+
+ * Markdown reader:
+
+ + Improved pipe table relative widths. Previously pipe table
+ columns got relative widths (based on the header underscore lines)
+ when the source of one of the rows was greater in width than the
+ column width. This gave bad results in some cases where much of
+ the width of the row was due to nonprinting material (e.g. link
+ URLs). Now pandoc only looks at printable width (the width of a
+ plain string version of the source), which should give better results.
+ Thanks to John Muccigrosso for bringing up the issue.
+ + Fixed parsing bug with macros. Previously macro definitions in
+ indented code blocks were being parsed as macro definitions, not code.
+
+ * Textile reader: skip over attribute in image source (#2515).
+ We don't have a place yet for styles or sizes on images, but
+ we can skip the attributes rather than incorrectly taking them
+ to be part of the filename.
+
+ * Docx reader: Handle dummy list items (Jesse Rosenthal).
+ These come up when people create a list item and then delete the
+ bullet. It doesn't refer to any real list item, and we used to ignore
+ it.
+
+ * CommonMark reader/writer rewritten to use latest `cmark`.
+
+ * Fixed Emoji character definitions (#2523). There were many bugs in the
+ definitions.
+
+ * `Text.Pandoc.CSS`:
+
+ + Added `pickStylesToKVs` function to extract multiple properties at
+ once (API change, Mauro Bieg).
+ + Parse CSS that doesn't contain the optional semicolon (Mauro Bieg).
+
+ * `trypandoc`: sort drop-down lists.
+
+ * Beamer template:
+
+ + Made `\euro` conditional on presence of character.
+ for xelatex and lualatex, as it is for pdflatex (Andrew Dunning).
+ + Moved `header-includes` before setting of title (Thomas Hodgson),
+ to match the LaTeX template (jgm/pandoc-templates#168).
+ + Added `section-titles` variable (defaults to true)
+ to enable/suppress section title pages in beamer
+ slide shows (Thomas Hodgson).
+ + Moved beamer themes after fonts, so that themes can
+ change fonts. (Previously the fonts set were being
+ clobbered by lmodern.sty.) (Thomas Hodgson).
+
+ * Beamer/LaTeX template changes (Thomas Hodgson):
+ + Added `thanks` variable
+ + Use `parskip.sty` when `indent` isn't set (fall back to using
+ `setlength` as before if `parskip.sty` isn't available).
+ + Use `biblio-style` with biblatex.
+ + Added `biblatexoptions` variable.
+
+ * LaTeX template changes:
+
+ + Added `paper` after `$papersize$` variable in latex template.
+ Thus you can say `papersize: a4` and the latex will contain
+ `a4paper`. This change may break some existing workflows; if
+ you currently specify `a4paper`, you'll get `a4paperpaper` which
+ is meaningless. However, the change seems worth it, as it will
+ make the `papersize` variable work uniformly across ConTeXt, LaTeX,
+ and html->pdf via wkhtmltopdf.
+ + Only pass options to color package if `colorlinks` is set
+ (Andrew Dunning).
+ + Make definition of `\euro` conditional in xelatex/lualatex,
+ as it is already for pdflatex (Andrew Dunning).
+ + Removed setting of `subject` in PDF metadata.
+ This used to be set to the subtitle, but really the subtitle
+ need not give the subject. Also, `subtitle` can contain formatting,
+ so we'd need, at least, a plain text version for this.
+ + Moved `header-includes` before setting of `\title`, `\author`,
+ etc. This allows these macros to be redefined.
+ + Use `\subtitle` command for `subtitle`, instead of tacking it
+ on to the title as before. We give a no-op fallback definition if it
+ is not defined. This change should produce much better results
+ in classes that support `\subtitle`. With the default article
+ class, which does not define `\subtitle`, subtitles will no
+ longer be printed unless the user defines `\subtitle` and
+ redefines `\maketitle`.
+ + Moved redefinitions of `\paragraph` and `\subparagraph` to
+ before header-includes.
+
+ * Context template:
+
+ + Use `simplefonts` for font loading (Paolo Rodríguez). This is
+ needed for things to work on ConTeXt stable from TeXLive 2015.
+ + Revert use of `\setuphead` in title block (Andrew Dunning,
+ Rik Kabel).
+
+ * Update LaTeX/ConTeXt link colour usage (Andrew Dunning).
+
+ * Fixed man template so disabling hyphenation actually works.
+ The command needs to come after .TH.
+
+ * Added 'navigation' variable to beamer template (#2543).
+ Valid values are `empty` (the default), `horizontal`, `vertical`,
+ and `frame`. Note that this changes the default behavior from
+ `horizontal` to `empty`. Closes #2543.
+
+ * Added `toc` to HTML slide format templates (Andrew Dunning),
+ so that `--toc` creates a contents slide.
+
+ * Added `stack.full.yaml` to build `pandoc-citeproc` as well.
+
+ * Allow pipe tables with no body rows (#2556).
+ Previously this raised a runtime error.
+
+ * Shared: Improved `fetchItem` so that `C:/Blah/Blah.jpg` isn't treated
+ as URL. The Haskell URI parsing routines will accept "C:" as a
+ scheme, so we rule that out manually. This helps with
+ `--self-contained` and absolute Windows paths.
+
+ * Define a `meta-json` variable for all writers (#2019). This contains
+ a JSON version of all the metadata, in the format selected for the
+ writer. So, for example, to get just the YAML metadata, you can run
+ pandoc with the following custom template: `$meta-json$`. The intent
+ is to make it easier for static site generators and other tools to get
+ at the metadata.
+
+ * Document limitations of --self-contained (#2553).
+
+ * Improved Citations section of README (#2551). Added information
+ about `link-citations` and a link to the pandoc-citeproc man page.
+
+ * `ImageSize`: use `safeRead` instead of `readMaybe`, which isn't
+ in base < 4.6.
+
+ * Allow .adoc file extension for AsciiDoc (Andrew Dunning).
+
+ * Improved implicit pandoc-citeproc inclusion.
+ The filter pandoc-citeproc is automatically used when
+ `--bibliography` is specified on the command line, unless
+ `--natbib` or `--biblatex` is used. However, previously this
+ only worked if `--bibliography` was spelled out in full, and not
+ if `--biblio` was used.
+
+ * reveal.js: Interpret pauses correctly for all headers (#2530).
+ Previously, when using headers below the slide level, pauses are left
+ uninterpreted into pauses. In my opinion, unexpected behavior but
+ intentional looking at the code.
+
+ * Remove redundant `center` variable for reveal.js (Andrew Dunning).
+
+ * Parsing: Add `extractIdClass`, modified type of `KeyTable` (Mauro
+ Bieg, API change).
+
+ * ImageSize: Added functions for converting between image dimensions
+ (Mauro Bieg).
+
+ * Use lts-3.18 in stack.yaml. This avoids Windows build
+ issues with the HTTP library.
+
+ * Bump version bounds for dependencies.
+
+pandoc (1.15.2.1)
+
+ * Added two missing test files, and `stack.yaml`, to
+ `extra-source-files` so they're included in the source tarball.
+
+ * reveal.js template: Fixed parallaxBackground options.
+ `parallaxBackgroundHorizontal` and `parallaxBackgroundVertical`
+ need integer values, not strings. (Vaughn Iverson)
+
+pandoc (1.15.2)
+
+ * `pandoc my.md -t context -o my.pdf` will now create a PDF using
+ ConTeXt rather than LaTeX (#2463).
+
+ * Fixed omitted `url(...)` in CSS data-uri with `--self-contained` (#2489).
+
+ * Added `emoji` Markdown extension, enabled by default in `markdown_github`
+ (#2523). Added `Ext_emoji` to `Extension` in `Text.Pandoc.Options`
+ (API change).
+
+ * `Text.Pandoc.Readers.HTML.parseTags`: Fixed over-eager raw HTML inline
+ parsing (#2469). Tightened up the inline HTML parser so it disallows
+ TagWarnings.
+
+ * Derive `Generic` instances for the types in `Text.Pandoc.Options`.
+
+ * Org reader:
+
+ + Fix paragraph/list interaction (Albert Krewinkel, #2464).
+ Paragraphs can be followed by lists, even if there is no blank line
+ between the two blocks. However, this should only be true if the
+ paragraph is not within a list, were the preceding block should be
+ parsed as a plain instead of paragraph (to allow for compact lists).
+ Thanks to @rgaiacs for bringing this up.
+ + Allow toggling header args (Albert Krewinkel, #2269).
+ Org-mode allows to skip the argument of a code block header argument if
+ it's toggling a value. Argument-less headers are now recognized,
+ avoiding weird parsing errors.
+ + Fix markup parsing in headers (Albert Krewinkel, #2504).
+ Markup as the very first item in a header wasn't recognized. This was
+ caused by an incorrect parser state: positions at which inline markup
+ can start need to be marked explicitly by changing the parser state.
+ This wasn't done for headers. The proper function to update the state
+ is now called at the beginning of the header parser, fixing this issue.
+ + Fix emphasis rules for smart parsing (Albert Krewinkel, #2513).
+ Smart quotes, ellipses, and dashes should behave like normal quotes,
+ single dashes, and dots with respect to text markup parsing.
+ + Require whitespace around definition list markers (#2518).
+ This rule was not checked before, resulting in bugs with footnotes
+ and some link types.
+
+ * Markdown reader:
+
+ + Pipe tables with long lines now get relative cell widths (#2471).
+ If a pipe table contains a line longer than the column width (as set by
+ `--columns` or 80 by default), relative widths are computed based on the
+ widths of the separator lines relative to the column width. This should
+ solve persistent problems with long pipe tables in LaTeX/PDF output, and
+ give more flexibility for determining relative column widths in other
+ formats, too. For narrower pipe tables, column widths of 0 are used,
+ telling pandoc not to specify widths explicitly in output formats that
+ permit this.
+ + Improved parser for `mmd_title_block`. We now allow blank metadata
+ fields. These were explicitly disallowed before.
+ + Citation keys can now contain `://`, so URLs and DOIs can be used
+ as citation keys (jgm/pandoc-citeproc#166).
+
+ * Beamer template: fix incompatibility of section slides with natbib.
+ Natbib (and presumably biblatex) bibliography commands create
+ their own section. Since these are in frame environments,
+ we have an incompatibility with the `\AtBeginSection` macro
+ which creates a special frame when a new section occurs.
+ (We can't have a frame inside another frame.) This change disables
+ `\AtBeginSection` inside bibliography slides. Thinks to Yihui Xie for
+ bringing the problem to my attention. This supersedes #145. See
+ discussion there.
+
+ * Textile reader: don't do smart punctuation unless explicitly asked
+ (#2480). Note that although smart punctuation is part of the textile
+ spec, it's not always wanted when converting from textile
+ to, say, Markdown. So it seems better to make this an option.
+
+ * LaTeX reader: Handle `comment` environment (Arata Mizuki).
+ The `comment` environment is handled in a similar way to the
+ `verbatim` environment, except that its content is discarded.
+
+ * Docx reader: Follow relationships correctly in foot/endnotes (#2258,
+ Jesse Rosenthal). This fixes a problem with links in notes.
+
+ * LaTeX and ConTeXt writers: support `lang` attribute on divs and spans
+ (Mauro Bieg). For LaTeX, also collect `lang` and `dir` attributes on
+ spans and divs to set the `lang`, `otherlangs` and `dir` variables if
+ they aren’t set already. See #895.
+
+ * LaTeX writer:
+
+ + Use proper command for `\textarabic` (Mauro Bieg).
+ + Added `de-CH-1901`, fixed `el-polyton` in `toPloyglossia` (Nick Bart).
+ + Use `\hypertarget` and `\hyperlink` for links. This works correctly
+ to link to Div or Span elements. We now don't bother defining `\label`
+ for Div or Span elements. Closes jgm/pandoc-citeproc#174.
+ + Avoid footnotes in list of figures (#1506).
+ + Properly handle footnotes in captions (#1506).
+ + Add `\protect` to `\hyperlink` (#2490). Thanks to Hadrien Mary.
+ + Set `colorlinks` if `linkcolor`, `urlcolor`, `citecolor`, or
+ `toccolor` is set (#2508).
+
+ * Textile writer: support start number in ordered lists (#2465).
+
+ * OpenDocument writer: Allow customization of opendocument
+ automatic styles. Automatic styles can now be inserted in the
+ template, which now provides the enclosing `<office:automatic-styles>`
+ tags (#2520).
+
+ * Docx writer: insert space between footnote reference and note (#2527).
+ This matches Word's default behavior.
+
+ * EPUB writer: don't download linked media when `data-external` attribute
+ set (#2473). By default pandoc downloads all linked media and includes it
+ in the EPUB container. This can be disabled by setting `data-external` on
+ the tags linking to media that should not be downloaded. Example:
+
+ <audio controls="1">
+ <source src="http://example.com/music/toccata.mp3"
+ data-external="1" type="audio/mpeg">
+ </source>
+ </audio>
+
+ * HTML writer: use width on whole table if col widths sum to < 100%.
+ Otherwise some browsers display the table with the columns
+ separated far apart.
+
+ * AsciiDoc template: Fix `author` and `date`; add `keywords`,
+ `abstract` (Andrew Dunning).
+
+ * HTML-based templates (Andrew Dunning):
+
+ + Use en dash instead of hyphen between title prefix and title.
+ + Add `keywords` to metadata.
+ + Add `lang`, `dir`, `quotes` where missing.
+ + Always make author and date display conditional.
+ + Updated dzslides template from source.
+
+ * Man template: make "generated by" comment conditional.
+
+ * LaTeX, Beamer templates:
+
+ + Add `babel-otherlangs` for language divs/spans; `babel-newcommands`,
+ filled by commands that make babel understand the polyglossia-style
+ language directives (Mauro Bieg, #137).
+ + Improved formatting of conditionals; `$for$` is always provided to allow
+ multiple options (Andrew Dunning, #141).
+ + Use `Ligatures=TeX` rather than `Mapping=tex-text` with `fontspec`
+ to improve support for LuaTeX (Andrew Dunning, #135).
+ + Revise `hyperref` usage (Andrew Dunning, #139, #141):
+ - use same options for all LaTeX engines;
+ - add `subtitle` and `keywords` to PDF metadata;
+ - do not override `hyperref` link coloring without user input, effectively making
+ the `hidelinks` option the default (removed as a separate variable);
+ - link colors can be enabled (using a slightly darker version of the old
+ defaults) using a new `colorlinks` variable, automatically used by
+ the LaTeX writer when custom colors are specified;
+ - `pdfborder={0 0 0}` is automatically set by `hyperref` with
+ `colorlinks`, and is only applied if `colorlinks` is disabled.
+
+ * ConTeXt template (Andrew Dunning):
+
+ + New variables for controlling styles: `linkstyle`, `linkcolor`,
+ `linkcontrastcolor`, `layout`, `pagenumbering`, `whitespace`, `indenting`,
+ `interlinespace`, `headertext`, `footertext`, `mainfont`, `sansfont`,
+ `monofont`, `mathfont`, `fontsize`.
+ + Default template no longer supports MkII.
+ + Improve writing of title block (suppressing numbering of first page).
+ + Add `title` `subtitle`, `author`, `date`, `keywords` to PDF metadata.
+ + Support `subtitle`, `abstract`.
+ + Support list of figures (`lof`), list of tables (`lot`).
+ + Disable link styling by default.
+ + Define styles for all section types.
+ + Enable microtype.
+ + Improved formatting of conditionals.
+
+ * Beamer template: added code to prevent slide breaks inside paragraphs
+ (#2422, thanks to Nick Bart). This will matter, in practice, only when
+ `allowframebreaks` is used. It is especially helpful for bibliography
+ slides.
+
+ * OpenDocument template: Add `<office:automatic-styles>` tag around
+ automatic styles. The writer now longer provides this (see #2520).
+
+ * Restored Text.Pandoc.Compat.Monoid.
+
+ * Do not export (<>) from custom Prelude. The Prelude now matches
+ base 4.8 Prelude's API.
+
+ * Don't use custom prelude with ghc 7.10. Use the custom prelude
+ only for earlier versions. This change makes `stack ghci` and
+ `cabal repl` work (#2503), at least with ghc 7.10.
+
+ * Changed § to % in operators from Odt.Arrows.Utils (#2457).
+ This prevents problems building haddocks with "C" locale.
+
+ * Change default for old-locale flag to False.
+
+ * Use stack in deb, osx, and Windows package generators.
+
+ * Added Vagrantfile for building deb in vm.
+ This should help in automating binary package creation. 'make package'
+ will make the package. 'make package COMMIT=blah' will make the package
+ from commit blah.
+
+ * README:
+
+ + Consistent capitalization for pandoc and Markdown.
+ + Fixed `auto_identifiers` examples (Benoit Schweblin).
+ + Improved documentation of template variables (Andrew Dunning).
+
+pandoc (1.15.1.1)
+
+ * `Text.Pandoc.Data`: store paths in dataFiles using posix separators.
+ This way we have uniform separators, whether on Windows or Linux.
+ This should solve a problem where on some Windows versions
+ the data files weren't being found (#2459).
+
+pandoc (1.15.1)
+
+ * `pandocVersion` is now defined in `Text.Pandoc.Shared`
+ and reexported from `Text.Pandoc` (Alex Vong). This allows
+ writers to access it. (Alex Vong) (API change)
+
+ * For `markdown_mmd`, add: `implicit_figures`, `superscripts`,
+ `subscripts` (#2401).
+
+ * Added `odt` as input format (Martin Linnemann). Added new module
+ `Text.Pandoc.Reader.ODT` (API change). Fully implemented features:
+ Paragraphs, Headers, Basic styling, Unordered lists, Ordered lists,
+ External Links, Internal Links, Footnotes, Endnotes, Blockquotes.
+ Partly implemented features: Citations, Tables.
+
+ * Markdown Reader:
+
+ + Add basic tests for each header style (Ophir Lifshitz).
+ + Add implicit header ref tests for headers with spaces (Ophir Lifshitz).
+ + Skip spaces in headers (Ophir Lifshitz).
+ + Handle 'id' and 'class' in parsing key/value attributes (#2396).
+ `# Header {id="myid" class="foo bar"}`
+ is now equivalent to `# Header {#myid .foo .bar}`.
+ + Use '=' instead of '#' for atx-style headers in markdown+lhs.
+ (Kristof Bastiaensen)
+ + Pipe tables: allow indented columns. Previously the left-hand column
+ could not start with 4 or more spaces indent. This was inconvenient
+ for right-aligned left columns. Note that the first (header column)
+ must still have 3 or fewer spaces indentation, or the table will be
+ treated as an indented code block.
+ + Fix regression: allow HTML comments containing `--`.
+ Technically this isn't allowed in an HTML comment, but
+ we've always allowed it, and so do most other implementations.
+ It is handy if e.g. you want to put command line arguments
+ in HTML comments.
+
+ * LaTeX reader:
+
+ + Don't eat excess whitespace after macros with only optional
+ arguments (#2446).
+ + Support longtable (#2411).
+ + Implement `\Cite` (#2335).
+ + Support abstract environment. The abstract populates an
+ `abstract` metadata field.
+ + Properly handle booktabs lines. Lines aren't part of the
+ pandoc table model, so we just ignore them (#2307).
+
+ * HTML reader:
+
+ + Handle type attribute on ol, e.g. `<ol type="i">` (#2313).
+ + Updated for new automatic header attributes.
+ + Add auto identifiers if not present on headers. This makes
+ TOC linking work properly.
+ + Detect `font-variant` with `pickStyleAttrProps` (Ophir Lifshitz).
+ + Test `<ol>` type, class, and inline list-style(-type) CSS
+ (Ophir Lifshitz).
+ + Better handling of "section" elements (#2438). Previously
+ `<section>` tags were just parsed as raw HTML blocks. With
+ this change, section elements are parsed as Div elements with
+ the class "section".
+
+ * MediaWiki reader: handle unquoted table attributes (#2355).
+
+ * DocBook reader:
+
+ + Added proper support for DocBook `xref` elements (Frerich Raabe).
+ Added `dbContent` field to reader state, so we can lookup
+ cross refs.
+ + Handle `informalexample` (#2319).
+
+ * Docx Reader:
+
+ + Create special punctuation test (Ophir Lifshitz).
+ + Parse soft, no-break hyphen elements (Ophir Lifshitz).
+ + Updated headers test (Ophir Lifshitz). Replaced `styles.xml`
+ in `headers.docx` with pandoc's current `styles.xml`, which
+ contains styles for Heading 1 through 6. Added Heading 4
+ through 7 to the test document. Note that Heading 7 is not
+ parsed as a Heading because there is no Heading 7 style.
+
+ * RST reader: better handling of indirect roles.
+ Previously the parser failed on this kind of case
+
+ .. role:: indirect(code)
+
+ .. role:: py(indirect)
+ :language: python
+
+ :py:`hi`
+
+ Now it correctly recognizes `:py:` as a code role.
+
+ * Org reader:
+
+ + Add auto identifiers if not present on headers
+ (#2354, Juliusz Gonera).
+ + Allow verse blocks to contain empty lines (#2402,
+ Albert Krewinkel).
+
+ * EPUB reader: stop mangling external URLs (#2284).
+
+ * RST writer:
+
+ + Don't insert `\ ` when complex expression in matched pairs.
+ E.g. `` [:sup:`3`] `` is okay; you don't need `` [:sup:`3`\ ] ``.
+ + Ensure that `\ ` is inserted when needed before Cite and Span
+ elements that begin with a "complex" element (jgm/pandoc-citeproc#157).
+ + Normalize headers only in "standalone" mode (#2394).
+
+ * Haddock writer: escape `*` and `^` (G. Bataille).
+
+ * Markdown writer:
+
+ + In TOC, add links to headers (#829).
+ + Use unicode super/subscripts for digits in plain output
+ (when the `superscripts` and `subscripts` extensions are
+ not enabled).
+
+ * Docx writer:
+
+ + Moved invalid character stripping to `formattedString`.
+ This avoids an inefficient generic traversal (#2356).
+ + Use user data directory for `reference.docx` archive.
+ This allows the test suite to work without installing pandoc first.
+ It also brings the docx writer in line with the odt writer.
+ + Tests: docx writer tests now use `../data` for data directory.
+ This allows tests to be run without installing first.
+ + Tests: Use real jpg (not empty) for docx tests to avoid warning.
+
+ * LaTeX writer:
+
+ + Fixed detection of 'chapters' from template.
+ If a documentclass isn't specified in metadata, but the
+ template has a hardwired bookish documentclass, act as if
+ `--chapters` was used. This was the default in earlier
+ versions, but it has been broken for a little while.
+ + Correctly recognize book documentclass in metadata (#2395).
+ + Set language-related variables automatically, depending
+ on the value of the `lang` field, which is now always
+ assumed to be in BCP47 format (Mauro Bieg, #1614, #2437).
+ + Add `\protect` to `\hyperdef` in inline context. This way we
+ don't get an error when this is used as a moveable argument (#2136).
+ + Support all frame attributes in Beamer.
+ + Percent-encode more special characters in URLs (#1640, #2377).
+ The special characters are '<','>','|','"','{','}','[',']','^', '`'.
+
+ * HTML writer:
+
+ + Update KaTeX JS and CSS versions (Emily Eisenberg).
+ + For dzslides, add `role="note"` for speaker notes (#1693).
+ + Percent-encode more special characters in URLs (#1640, #2377).
+ The special characters are '<','>','|','"','{','}','[',']','^', '`'.
+ + Render Div with class `section` as `<section>` in HTML5.
+
+ * EPUB writer:
+
+ + In TOC, replace literal `<br/>` with space (#2105).
+ + With `--webtex`, include image file rather than `data:` URI (#2363).
+
+ * Native writer: format Div properly, with blocks separated.
+
+ * Support bidirectional text output with XeLaTeX, ConTeXt and HTML
+ (#2191, Mauro Bieg).
+
+ * Reference Docx:
+
+ + Add missing Header 6 style (steel blue) (Ophir Lifshitz).
+ + Correct `outlineLvl` for Header styles (Ophir Lifshitz).
+
+ * Templates
+
+ + Beamer: Add `innertheme`, `outertheme` variables
+ (Guilhem Bonnefille, #121). Add space after colon in figure caption.
+ Integrate recent font and language updates from LaTeX template;
+ allow use of `mainfont` variable for changing the slide text
+ in XeTeX and LuaTeX (Andrew Dunning, #131).
+ + LaTeX: Add `mainfontoptions`, `sansfontoptions`,
+ `monofontoptions`, `mathfontoptions`, `fontfamilyoptions`
+ (Andrew Dunning, #122). Support handling of bidirectional
+ text (Mauro Bieg, #120). Improve reliability of superscripts/subscripts
+ under XeTeX and prevent letters and numbers from appearing on a
+ different baseline by removing use of the `realscripts` package
+ (via `xltxtra`). To restore use of OpenType characters for these
+ features under XeTeX or LuaTeX, add `\usepackage{realscripts}` to
+ `header-includes` (Andrew Dunning, #130). Remove redundant
+ reference to `xunicode` (Andrew Dunning, #130). Add `fontenc`,
+ `indent`, `subparagraph` variables (Andrew Dunning).
+ Allow use of `hidelinks` variable for `hyperref` package (Hugo Roy,
+ #113). Prevent package clash with `tufte-latex` and other classes that
+ include `hyperref` or `color` (Xavier Olive, #115).
+ + ConTeXt: Support handling of bidirectional text (Mauro Bieg, #120).
+ + LaTeX and ConTeXt: Use more specific language variables.
+ Instead of directly using `lang`, we now use `babel-lang` and
+ `polyglossia-lang` and `context-lang`. These variables are set by
+ the writers to the necessary values, based on the `lang` variable
+ (which now always takes a value in BCP47 format). (Mauro Bieg, #114,
+ #129).
+ + HTML: Support handling of bidirectional text (Mauro Bieg, #120).
+ Move HTML5 shiv after CSS and fix URL (Andrew Dunning).
+ Add dir attribute in html5 (Andrew Dunning).
+ + reveal.js: Add `controls`, `progress` variables (Grégoire Pineau, #127).
+ Add `width`, `height` variables (Andrew Dunning). Update template
+ from 3.1 source (Andrew Dunning). All configuration options are now
+ available as variables, but are only be included if set (reveal.js
+ uses defaults otherwise).
+ + man: Added comment stating that the page is autogenerated by pandoc,
+ giving version. Added `adjusting` and `hyphenate` variables
+ (Alex Vong, #123).
+
+ * epub.css: added selectors for nested emphasis (Pablo Rodriguez).
+
+ * MediaBag: ensure that `/` is always used as path separator.
+
+ * `sample.lua`: define `CaptionedImage`, add newline at end (#2393).
+
+ * Added `--bash-completion` option. This generates a bash completion
+ script. To use: `eval "$(pandoc --bash-completion)"`.
+
+ * Text.Pandoc.Error: Define Typeable and Exception instances
+ for PandocError (#2386).
+
+ * Text.Pandoc.Parsing: `toKey`: strip off outer brackets.
+ This makes keys with extra space at the beginning and end
+ work: e.g.
+
+ [foo]: bar
+
+ [ foo ]
+
+ will now be a link to bar (it wasn't before).
+
+ * Text.Pandoc: disable `auto_identifiers` for epub.
+ The epub writer inserts its own auto identifiers;
+ this is more complex due to splitting into "chapter" files.
+
+ * Renamed Text.Pandoc.Compat.Locale -> Text.Pandoc.Compat.Time.
+ It now reexports Data.Time.
+
+ * Use custom Prelude to avoid compiler warnings.
+
+ + The (non-exported) prelude is in prelude/Prelude.hs.
+ + It exports Monoid and Applicative, like base 4.8 prelude,
+ but works with older base versions.
+ + It exports (<>) for mappend.
+ + It hides 'catch' on older base versions.
+
+ * Added a `stack.ymal` and stack install instructions to INSTALL.
+
+ * Clarified what is "out of scope" in README and CONTRIBUTING.md.
+
+ * Added note to CONTRIBUTING.md about ghc versions and travis.
+
+ * Clarify docs on block quotes. The space after `>` is optional (#2346).
+
+ * Removed obsolete reference to default.csl (#2372).
+
+ * List all styles in manual for `--reference-docx` (Chris Black)
+
+ * Don't capitalize header links in man page.
+
+ * Added section on repl to CONTRIBUTING.md.
+
+ * README: Added space after backslash in image example (#2329).
+
+ * Document details of citation locator terms (Nick Bart).
+
+ * Fixed some internal links in README (#2309).
+
+ * Improve CSL documentation, variables documentations,
+ links, and cross-references in README. (Andrew Dunning)
+
+ * Fix build failure with `--flags=-https` (Sergei Trofimovich).
+
+ * Use `newManager` instead of `withManager` in recent `http-client`.
+ This avoids a deprecation warning.
+
+ * Allow building with latest versions of http-types,
+ HUnit, criterion, syb, aeson.
+
+ * Updated benchmark program for new criterion API.
+
+ * Setup.hs: rewrite so as not to use process, directory, filepath.
+ Using anything outside base is dangerous, since older
+ versions of ghc may link against two different versions.
+
+ * Added appveyor (Windows continuous integration) builds.
+
+ * New `.travis.yml`. Autgenerated using `make_travis_yml.hs`.
+ This script has been modified in a few ways, e.g. to add `GHCOPTS`.
+ `make .travis.yml` regenerates it based on the tested-with
+ field of the cabal file.
+
+pandoc (1.15.0.6)
+
+ * `--self-contained`: Fixed overaggressive CSS minimization (#2301, 2286).
+ Previously `--self-contained` wiped out all spaces in CSS,
+ including semantically significant spaces. This was a regression
+ from 1.14.x.
+
+ * Markdown reader: don't allow bare URI links or autolinks in link
+ label (#2300). Added test cases.
+
+ * `Text.Pandoc.Parsing`, `uri`: Improved bare autolink detection (#2299).
+ Previously we disallowed `-` at the end of an autolink,
+ and disallowed the combination `=-`. This commit liberalizes the
+ rules for allowing punctuation in a bare URI, and adds test cases.
+ One potential drawback is that you can no longer put a bare
+ URI in em dashes like this:
+ `this uri---http://example.com---is an example.`
+ But in this respect we now match github's treatment of bare URIs.
+
+ * HTML writer: support speaker notes in dzslides.
+ With this change `<div class="notes">` and also `<div class="notes"
+ role="note">` will be output if `-t dzslides` is used. So we can
+ have speaker notes in dzslides too. Thanks to maybegeek.
+
+ * Updated dzslides template.
+
+ * Improved documentation of options to print system default files (#2298).
+ `--print-default-data-file` and `--print-default-template`.
+
+ * DokuWiki writer: use `$..$` for Math instead of `<math>..</math>`
+ (Tiziano Müller). MathJax seems currently to be the only maintained
+ math rendering extension for DokuWiki.
+
+ * `Text.Pandoc.Shared`: Changed `hierarchicalize` so it treats references
+ div as top-level header (#2294). This fixes a bug with `--section-divs`,
+ where the final references section added by pandoc-citeproc, enclosed in
+ its own div, got nested in the div for the section previous to it.
+
+ * Allow vector 0.11.
+
+ * Require cmark > 0.4.
+
+pandoc (1.15.0.5)
+
+ * HTML writer: Fixed email javascript obfuscation with `mailto:`
+ URLs (#2280). This fixes a potential security issue. Because
+ single quotes weren't being escaped in the link portion, a
+ specially crafted email address could allow javascript code injection.
+
+ * Markdown/HTML readers: Avoid parsing partial URLs like
+ `<www.pandoc.org/blah#foo>` as HTML tags (#2277).
+
+ * RST reader: allow inline formatting in definition list field
+ names (Lars-Dominik Braun).
+
+ * PDF: Make sure `--latex-engine-opt` goes before the filename
+ on the command line. LaTeX needs the argument to come after
+ the options (#1779).
+
+ * CommonMark writer: fixed tags used for super/subscript.
+
+ * ConTeXt template: activate hanging indent for definition lists
+ (Mauro Bieg).
+
+ * Make cabal require `hsb2hs` >= 0.3.1 if `embed_data_files` specified.
+ This is done by adding `hookedPrograms` in `Setup.hs`, which allows us
+ to include `hsb2hs` in Build-Tools in cabal.
+
+ * Improved Windows installer (thanks to nkalvi).
+
+ + When per-machine installation is chosen, the system path
+ is updated instead of the user's.
+ + An appropriate default is used for per-machine installation
+ directory.
+ + Admin privileges are no longer required for a per-user install
+
+ * Travis: unpack sdist for build to catch packaging bugs.
+
+ * Improved documentation on where user templates go (#2272).
+
+pandoc (1.15.0.4)
+
+ * Added pandoc.1 man page to the repository. It is no longer
+ built as part of the cabal build process. (This proved too
+ fragile.) pandoc.1 can be regenerated (`make man/pandoc.1`)
+ when `README` is changed.
+
+ * Copying of the man page now respects `--destdir` (#2262).
+
+ * Improved error messages for filters. User is now informed if
+ the filter requires an interpreter that isn't found in the path,
+ or if the filter returns an error status.
+
+pandoc (1.15.0.3)
+
+ * Ensure target directory is created when installing man page.
+
+pandoc (1.15.0.2)
+
+ * Added files needed for building man page to Extra-Source-Files.
+
+pandoc (1.15.0.1)
+
+ * Man page is now built and installed as part of the cabal build
+ process. Removed Makefile target for man page.
+
+pandoc (1.15)
+
+ * Man page changes:
+
+ + Removed `--man1`, `--man5` options (breaking change).
+ + Removed `Text.Pandoc.ManPages` module (breaking API change).
+ + Makefile target for `man/man1/pandoc.1`. This uses pandoc to
+ create the man page from README using a custom template and filters.
+ + Added `man/` directory with template and filters needed to build
+ man page.
+ + We no longer have two man pages: `pandoc.1` and `pandoc_markdown.5`.
+ Now there is just pandoc.1, which has all the content from README.
+ This change was needed because of the extensive cross-references
+ between parts of the README.
+ + Removed old `data/pandoc.1.template` and
+ `data/pandoc_markdown.5.template`.
+
+ * OpenDocument writer: Do not add a carriage return after a hard
+ line break (Michael Chladek).
+
+ * ConTeXt writer:
+
+ + use `\goto` for internal links.
+ + Added a `%` at end for `\reference` to avoid spurious space.
+
+ * Ignore sandbox on 'make quick'
+
+pandoc (1.14.1)
+
+ * Added `--man1` and `--man5` options to pandoc, allowing pandoc
+ to generate its own man pages. Man pages are no longer automatically
+ generated in the build process (the process for this was too complex
+ and prone to failure, #2190). The `make-pandoc-man-pages` executable
+ has been removed. The `man/` directory has been removed, and man page
+ templates have been moved to `data/`. NOTE TO PACKAGERS: You will no
+ longer find pandoc's man pages in `man/`, but you can generate them using
+ `pandoc --man1 > pandoc.1` and `pandoc --man5 > pandoc_markdown.5`.
+
+ * Added new unexported module: `Text.Pandoc.ManPages`.
+
+ * `README` now acts like a data file (even though it isn't in
+ `data/`). So, for example, `pandoc --print-default-data-file README`
+ will produce the README.) This change was required for the `--man1`
+ and `--man5` options, since the man pages are produced from the
+ README, but it may be useful for other purposes as well.
+
+ * Allow `reference.docx` and `reference.odt` to be used with
+ `--print-default-data-file` and to shadow defaults if placed in
+ the user data directory. Note that as of 1.14, we no longer
+ include these files as data files; instead, we include their
+ components. This change causes pandoc to behave as if it has
+ these data files; they are constructed on demand when needed
+ using `getDefaultReferenceDocx` and `getDefaultReferenceODT`.
+
+ * Fixed regression in CSS parsing with `--self-contained` (#2224).
+ Pandoc 1.14.0.x used css-text to parse the CSS, but its parser
+ silently drops big sections of CSS. This commit replaces the
+ use of css-text with a small but principled CSS preprocessor,
+ which removes whitespace and comments and replaces `url()` with
+ base 64 data when possible.
+
+ * Use `https://` instead of `//` for MathJax and KaTeX CDN URLs (#1920).
+ This will allow math to work when pages are being viewed locally.
+
+ * `Text.Pandoc.Options`: Export `plainExtensions`.
+ These are the extensions used in `plain` output.
+
+ * LaTeX reader: Don't parse `_` and `^` as sub/superscript outside of
+ math mode; treat them as regular inline text. Normally these will
+ cause an error in LaTeX, but there are contexts (e.g. `alltt`
+ environments) where they are allowed.
+
+ * HTML reader: allow `<body>` to close `<head>`.
+
+ * DocBook reader: support `mediaobject`s and `figures` (#2184, Mauro Bieg).
+
+ * RST reader: Fix reference names with special characters
+ (Lars-Dominik Braun).
+
+ * Textile writer: escape `+` and `-` as entities (#2225).
+
+ * DokuWiki writer: Use proper `<code>` tags for code blocks (#2213).
+
+ * Plain writer: don't use symbols for super/subscript (#2237).
+ Simplified code by using `plainExtensions`.
+
+ * InDesign writer: Properly escape URLs containing more than one
+ colon character (gohai).
+
+ * Docx writer: Make sure we use dist version of `reference.docx`
+ (and not the user's version) for certain settings. Taking some
+ settings values from a user-supplied reference.docx can lead to
+ corruption. This fixes a regression from the last release (#2249).
+
+ * `Text.Pandoc.Shared`: exports `getDefaultReferenceDocx` and
+ `getDefaultReferenceODT` (API change). These functions have been
+ removed from the Docx and ODT writers.
+
+ * LaTeX template (Xavier Olive):
+ + Added `CJKmainfont` and `CJKoptions` variables.
+ + Allow dvipsnames (e.g. `MidnightBlue`) for colors (Xavier Olive).
+
+ * Epub templates: use `author.role`, not `author.type`.
+
+ * Bump cmark version to >= 0.3.4.
+
+ * Improved Windows installer (#2205, thanks to nkalvi).
+ Users can now select a per-user or systemwide install, and can set
+ the installation path. At the end of installation, the install location
+ is given. The install location is also now given in the list of
+ installed programs in Control Panel. Cleaner WiX syntax is used for
+ setting the path.
+
+ * Added `download_stats` target to Makefile.
+
+pandoc (1.14.0.4)
+
+ * Added missing commonmark template.
+
+ * Improved try pandoc (moved button, show raw command).
+
+pandoc (1.14.0.3)
+
+ * Allow compilation with syb 0.5.*.
+
+ * Custom writer: fixed some compiler warnings for ghc < 7.10.
+
+pandoc (1.14.0.2)
+
+ * Allow building with hslua 0.4.
+
+pandoc (1.14.0.1)
+
+ * Fixed problem with building of `reference.docx` and `reference.odt`
+ when the `embed_data_files` flag is used. Instead of having a phase
+ of the build where `reference.docx` and `reference.odt` are created
+ from their constituent data files, we now construct these archives
+ from their constituents when a `docx` or `odt` is built. The
+ constituent files have been moved from `extra-source-files` to
+ `data-files`, and `reference.docx` and `reference.odt` have been
+ removed. Users can create their own `reference.docx` or
+ `reference.odt` by using pandoc to create a simple `docx` or `odt`.
+ `make-reference-files.hs` has been removed, simplifying the build
+ process (#2187)
+
+ * Don't include generated man pages in extra-source-files (#2189).
+
+ * Bumped upper bound for aeson.
+
+ * ConTeXt writer: create internal link anchors for Div elements with
+ identifiers. (This is needed for linked citations to work.)
+
+pandoc (1.14)
+
+ [new features]
+
+ * Added `commonmark` as input and output format.
+
+ * Added `--verbose` flag for debugging output in PDF production (#1840,
+ #1653).
+
+ * Allow wildcards in `--epub-embed-font` arguments (#1939).
+
+ * Added `--latex-engine-opt` option (#969, #1779, Sumit Sahrawat).
+
+ * Added `shortcut_reference_links` extension (Konstantin Zudov, #1977).
+ This is enabled by default for those markdown flavors that
+ support reading shortcut reference links, namely: `markdown`,
+ `markdown_strict`, `markdown_github`, `markdown_php`.
+ If the extension is enabled, the reader parses shortcut reference
+ links like `[foo]`, and the writer creates such links unless doing
+ so would cause problems. Users of markdown flavors that support
+ shortcut reference links should not notice a difference in reading
+ markdown, but the markdown pandoc produces may differ.
+ If shortcut links are not desired, the extension can be disabled
+ in the normal way.
+
+ [behavior changes]
+
+ * `--toc` is now supported for `docx` output (#458, Nikolay Yakimov).
+ A "dirty" TOC is created at the beginning of document.
+ It can be regenerated after the document has been opened.
+
+ * An implicit `--filter pandoc-citeproc` is now triggered only when the
+ `--bibliography` option is used, and not when the `bibliography`
+ field in metadata is specified (#1849).
+
+ * Markdown reader:
+
+ + Reference links with `implicit_header_references` are no longer
+ case-sensitive (#1606).
+ + Definition lists no longer require indentation for first line (#2087).
+ Previously the body of the definition (after the `:` or `~` marker)
+ needed to be in column 4. This commit relaxes that requirement,
+ to better match the behavior of PHP Markdown Extra. So, now
+ this is a valid definition list:
+
+ foo
+ : bar
+ + Resolve a potentially ambiguity with table captions:
+
+ foo
+
+ : bar
+
+ -----
+ table
+ -----
+
+ Is "bar" a definition, or the caption for the table? We'll count
+ it as a caption for the table.
+ + Disallow headerless pipe tables (#1996), to conform to GFM and PHP
+ Markdown Extra. Note: If you have been using headerless pipe tables,
+ this change may cause existing tables to break.
+ + Allow pipe tables with header but no body (#2017).
+ + Allow a digit as first character of a citation key (Matthias Troffaes).
+ See https://github.com/jgm/pandoc-citeproc/issues/97
+
+ * LaTeX reader:
+
+ + Don't limit includes to `.tex` extension (#1882).
+ If the extension is not `.tex`, it must be given explicitly in
+ the `\input` or `\include`.
+
+ * Docx reader:
+
+ + Allow numbering in the style file. This allows inherited styles
+ with numbering (lists) (Jesse Rosenthal).
+
+ * Org reader:
+
+ + Support smart punctuation (Craig Bosma).
+ + Drop trees with a :noexport: tag (Albert Krewinkel). Trees having a
+ `:noexport:` tag set are not exported. This mirrors org-mode.
+ + Put header tags into empty spans (Albert Krewinkel, #2160).
+ Org mode allows headers to be tagged: `* Headline :TAG1:TAG2`.
+ Instead of being interpreted as part of the headline, the tags are now
+ put into the attributes of empty spans. Spans without textual content
+ won't be visible by default, but they are detectable by filters. They
+ can also be styled using CSS when written as HTML.
+ + Generalize code block result parsing (Albert Krewinkel).
+ Previously, only code blocks were recognized as result blocks;
+ now, any kind of block can be the result.
+
+ * Append newline to the LineBreak in Dokuwiki, HTML, EPUB,
+ LaTeX, MediaWiki, OpenDocument, Texinfo writers (#1924, Tim Lin).
+
+ * HTML writer:
+
+ + Add "inline" or "display" class to math spans (#1914).
+ This allows inline and display math to be styled differently.
+ + Include raw latex blocks if `--mathjax` specified (#1938).
+ + Require highlighting-kate >= 0.5.14 (#1903).
+ This ensures that all code blocks will be wrapped in a `div`
+ with class `sourceCode`. Also, the default highlighting CSS
+ now adds `div.sourceCode { x-overflow: auto; }`, which means
+ that code blocks (even with line numbers) will acquire a scroll
+ bar on screens too small to display them (e.g. mobile phones).
+ See also jgm/highlighting-kate#65.
+
+ * LaTeX writer:
+
+ + Use a declaration for tight lists (Jose Luis Duran, Joseph
+ Harriott). Previously, pandoc hard-coded some commands to make
+ tight lists in LaTeX. Now we use a custom command instead,
+ allowing the styling to be changed in a macro in the header.
+ (Note: existing templates may need to be modified to include
+ the definition of this macro. See the current template.)
+ + Beamer output: if the header introducing a slide has the
+ class `fragile`, add the `[fragile]` option to the slide (#2119).
+
+ * MediaWiki writer:
+
+ + Use `File:` instead of the deprecated `Image:` for images and
+ other media files (Greg Rundlett).
+
+ * DocBook writer:
+
+ + Render a `Div (id,_,_) [Para _]` element as a `para` element
+ with an `id` attribute. This makes links to citations work in
+ DocBook with pandoc-citeproc.
+
+ * RST writer:
+
+ + Normalize headings to sequential levels (Nikolay Yakimov).
+ This is pretty much required by docutils.
+ + Treat headings in block quotes, etc as rubrics (Nikolay Yakimov).
+ + Better handling of raw latex inline (#1961). We use
+ `` :raw-latex:`...` `` and add a definition for this role to
+ the template.
+
+ * EPUB writer:
+
+ + Remove `linear=no` from cover `itemref` (#1609).
+ + Don't use `sup` element for epub footnotes (#1995).
+ Instead, just use an a element with class `footnoteRef`.
+ This allows more styling options, and provides better results
+ in some readers (e.g. iBooks, where anything inside the a
+ tag breaks popup footnotes).
+ + Take TOC title from `toc-title` metadata field.
+
+ * Docx writer:
+
+ + Implemented `FirstParagraph` style (Jesse Rosenthal).
+ Following the ODT writer, we add the `FirstParagraph` style to the
+ first text paragraph following an image, blockquote, table, heading,
+ or beginning of document. This allows it to be styled differently.
+ The default is for it to be the same as `Normal`.
+ + Added `BodyText` style (Jesse Rosenthal).
+ We apply a `BodyText` style to all unstyled paragraphs. This is,
+ essentially, the same as `Normal`, except that since not everything
+ inherits from `BodyText` (the metadata won't, for example, or
+ the headers or footnote numbers), we can change the text in the body
+ without having to make exceptions for everything. If we do want to
+ change *everything*, we can still do it through `Normal`.
+ + Altered `Blockquote` style slightly (Jesse Rosenthal).
+ Since `BlockQuote` derives from `BodyText`, we just want to specify
+ by default that it won't indent, regardless of what `BodyText` does.
+ Note that this will not produce any visible difference in the default
+ configuration.
+ + Take TOC title from `toc-title` metadata field (Nikolay Yakimov).
+ + Added a style to figure images (Nikolay Yakimov).
+ Figures with empty captions use style `Figure`.
+ Figures with nonempty captions use style `Figure with Caption`, which
+ is based on `Figure`, and additionally has `keepNext` set.
+
+ * ODT writer:
+
+ + Added figure captions (Nikolay Yakimov). The following styles are
+ used for figures:
+ `Figure` -- for figure with empty caption),
+ `FigureWithCaption` (based on `Figure`) -- for figure with caption,
+ `FigureCaption` (based on `Caption`) -- for figure captions.
+ Also, `TableCaption` (based on `Caption`) is used for table captions.
+
+ [API changes]
+
+ * New `Text.Pandoc.Error` module with `PandocError` type
+ (Matthew Pickering).
+
+ * All readers now return `Either PandocError Pandoc` instead of `Pandoc`
+ (Matthew Pickering). This allows better handling of errors.
+
+ * Added `Text.Pandoc.Writers.CommonMark`, exporting `writeCommonMark`.
+
+ * Added `Text.Pandoc.Readers.CommonMark`, exporting `readCommonMark`.
+
+ * Derive `Data` and `Typeable` instances for `MediaBag`, `Extension`,
+ `ReaderOptions`, `EPUBVersion`, `CiteMethod`, `ObfuscationMethod`,
+ `HTMLSlideVariant`, `TrackChanges`, `WriterOptions` (Shabbaz
+ Youssefi).
+
+ * New `Ext_shortcut_reference_links` constructor for `Extension`
+ (Konstantin Zudov).
+
+ [bug fixes]
+
+ * Markdown reader:
+
+ + Allow smart `'` after inline math (#1909, Nikolay Yakimov).
+ + Check for tex macros after indented code (#1973).
+ + Rewrote `charsInBalancedBrackets` for efficiency.
+ + Make sure a closing `</div>` doesn't get included in a
+ definition list item (#2127).
+ + Don't parse bracketed text as citation if it might be a link,
+ image, or footnote (Nikolay Yakimov).
+ + Require space after key in mmd title block (#2026, Nikolay
+ Yakimov). Require space after key-value delimiter colon in mmd title
+ block.
+ + Require nonempty value in mmd title block (Nikolay Yakimov).
+ + Disable all metadata block extensions when parsing
+ metadata field values (#2026, Nikolay Yakimov). Otherwise we
+ could get a mmd title block inside YAML metadata, for example.
+
+ * HTML reader:
+
+ + Improve self-closing tag detection in `htmlInBalanced` (#2146).
+ + Handle tables with `<th>` in body rows (#1859, Mauro Bieg).
+ + Fixed `htmlTag` (#1820). If the tag parses as a comment, we check
+ to see if the input starts with `<!--`. If not, it's bogus comment
+ mode and we fail `htmlTag`.
+ + Handle `base` tag; if it has an `href` value, this is added to
+ all relative URLs in links and images.
+
+ * DocBook reader:
+
+ + Look inside "info" elements for section titles (#1931).
+
+ * Docx reader:
+
+ + Parse images in deprecated vml format (Jesse Rosenthal).
+ + Allow sub/superscript verbatims (Jesse Rosenthal).
+ Verbatim usually shuts off all other run styles, but we don't want it
+ to shut off sub/superscript.
+
+ * LaTeX reader:
+
+ + Handle `tabular*` environment (#1850).
+ Note that the table width is not actually parsed or taken into
+ account, but pandoc no longer chokes on it.
+ + Ignore options in `\lstinline` rather than raising error (#1997).
+ + Add some test cases for simple tables (Mathias Schenner).
+ + Handle valign argument in tables (Mathias Schenner) (currently
+ we just ignore this).
+ + Allow non-empty colsep in tables (Mathias Schenner).
+ The `tabular` environment allows non-empty column separators
+ with the "@{...}" syntax. Previously, pandoc would fail to
+ parse tables if a non-empty colsep was present. With this
+ commit, these separators are still ignored, but the table gets
+ parsed. A test case is included.
+ + Recognize `\newpage` as a block command.
+ + Allow block content in \title{} (#2001).
+ + Check for block-level newcommand aliases in blockCommand (Nikolay
+ Yakimov).
+ + Guard against paragraph starting with inline macro (Nikolay Yakimov).
+ + Properly gobble spaces after `\\` (#2007).
+
+ * Textile reader:
+
+ + Handle newlines in table cells, and empty cells (#1919).
+
+ * Org reader:
+
+ + Allow image links with non-image targets (Hans-Peter Deifel).
+ This matches behavior of Org-Mode for links like
+ `[[http://example.com][https://www.haskell.org/static/img/logo.png]]`.
+
+ * Docbook writer:
+
+ + Don't print empty id attributes (thanks to Steve Horne).
+
+ * HTML writer:
+
+ + Fixed list-style-type for numbered example lists.
+ Should be "decimal," not "example" (#1902).
+ + Do not omit missing `alt` attribute on `img` tag (#1131,
+ Konstantin Zudov).
+ + Allow multiple colgroups in table (#2122).
+ + In revealjs, ensure that lists in speaker notes don't add "fragment"
+ classes, which can cause additional keypresses to be needed to
+ advance a slide (#1394).
+
+ * LaTeX writer:
+
+ + Don't escape `$` in URL (#1913).
+ + Don't use listings in headers (Matthew Pickering, #1963).
+ + Recognize book documentclass if set in metadata (#1971).
+ This sets `--chapters` implicitly if the documentclass in metadata
+ is a book documentclass. Previously this was done only if a book
+ documentclass was set in a variable.
+ + Add a `\label` in `\hyperdef` for Div, Span (or links don't work).
+ + Make `mainlang` work when `lang` is in metadata (#2174).
+
+ * Texinfo writer:
+
+ + Fix wrapping by using breakable spaces (Tim Lin).
+
+ * RST writer:
+
+ + Fixed toc depth in RST writer. Previously the depth was being
+ rendered as a floating point number with a decimal point.
+
+ * Markdown writer:
+
+ + Improved escaping (#2086). `<` should not be escaped as `\<`, for
+ compatibility with original Markdown. We now escape `<` and `>`
+ with entities. Also, we now backslash-escape square brackets.
+ + Avoid introducing spurious list items through wrapping (#1946).
+ + Don't emit span tags if plain or raw HTML disabled.
+
+ * MediaWiki writer:
+
+ + Convert spaces to underscores in wikilink URL (#1982), like MediaWiki.
+
+ * AsciiDoc writer:
+
+ + Insert some needed blank lines (#1860).
+ + Avoid wrapping after list marker (#1858).
+
+ * EPUB writer:
+
+ + Properly handle internal links to IDs in spans, divs (#1884).
+ + Use plain writer for metadata dc: fields (#2121).
+ This gives better results when we have, e.g. multiple paragraphs.
+ Note that tags aren't allowed in these fields.
+ + Properly handle image links without an extension (#1855).
+ + Improved chapter splitting and internal link rewriting (#1887,
+ #2162, #2163). This will ensure that internal links work and
+ that the references section produced by pandoc-citeproc is
+ in its own chapter.
+ + Fixed handling of svg images (#2183).
+
+ * ICML writer:
+
+ + Better handling of raw blocks and inlines (#1951).
+ Previously these were always escaped and printed verbatim.
+ Now they are ignored unless the format is `icml`, in which
+ case they are passed through unescaped.
+ + Fixed image URIs in ICML output (gohai).
+
+ * Custom writer:
+
+ + Raise error if loadstring returns an error status.
+ + Raise `PandocLuaException` instead of using 'error'.
+ Eventually we'll change the return type so that no exception
+ is involved, but at least this can be trapped.
+ + Use UTF-8 aware bytestring conversion.
+ + Set foreign encoding to UTF-8 (Nikolay Yakimov, #2101, #1634).
+ Also factored out ByteString, since it's only used as an intermediate
+ representation.
+
+ * Docx writer:
+
+ + Copy hyphenation settings from reference.docx (Nikolay Yakimov).
+ + Filter out illegal XML characters (#1992, Matthew Pickering).
+ + Added `noProof` to docx syntax highlighting `SourceCode` style.
+ + Added footnotes id -1 and 0 (Jesse Rosenthal).
+ Word uses, by default, footnotes with id -1 and 0 for separators. If a
+ user modifies `reference.docx`, they will end up with a `settings.xml`
+ file that references these footnotes, but no such footnotes in the
+ document. This will produce a corruption error. Here we add these to the
+ document and `settings.xml` file, so future modifications won't break
+ the file.
+ + Handle lists correctly inside table cells (Jesse Rosenthal).
+ Previously we didn't transform lists inside table cells.
+ + Set firstRow information in tables (Nikolay Yakimov).
+ + Don't replace `SourceCode` style in `reference.docx` if it is defined
+ there (Nikolay Yakimov, #1872). If `--no-highlight` specified, remove
+ any `SourceCode` and `*Tok` styles in `reference.docx`.
+ + Attempt to match international style names (#1607, Nikolay Yakimov).
+ + Set these styles as custom (Nikolay Yakimov): `Author`, `Abstract`,
+ `Compact`, `Image Caption`, `Table Caption`, `Definition Term`,
+ `Definition`, `First Paragraph`.
+ + Rename these styles to correspond with Word `Normal.dotm` (Nikolay
+ Yakimov): `Block Quote -> Block Text`, `Link -> Hyperlink`,
+ `Footnote Ref -> Footnote Reference`.
+ + Added `Caption` style (Nikolay Yakimov).
+ + Changed these styles' inheritance (Nikolay Yakimov):
+ `Image Caption <- Caption`, `Table Caption <- Caption`.
+ + Remove `SourceCode` style from `reference.docx` (#1872).
+ This is added automatically by the docx writer.
+ + Added toc heading style to `reference.docx` (Nikolay Yakimov).
+
+ * `Text.Pandoc.PDF`
+
+ + Don't suggest "Try xelatex" if xelatex already in use (Mauro Bieg,
+ #1832).
+ + More comprehensible errors on image conversion (#2067).
+ EPS can't be supported without shelling out to something like
+ ImageMagick, but at least we can avoid mysterious error messages.
+
+ * `Text.Pandoc.Shared`:
+
+ + Make safeRead safe (#1801, Matthew Pickering).
+ + Addded `mapLeft`, `hush` (Matthew Pickering).
+
+ * `Text.Pandoc.Pretty`:
+
+ + Remove partial function (Matthew Pickering).
+
+ * `Text.Pandoc.SelfContained`:
+
+ + Add `;charset=utf-8` to script mime type if missing (#1842).
+ + Improved building of data URIs (#1940). Now base64 is used except
+ for `text/*` mime types.
+ + `cssURLs` no longer tries to fetch fragment URLs (#2121).
+ + Properly handle data URIs in css urls (#2129).
+ Use a proper CSS parser (adds dependency on `text-css`).
+
+ * `Text.Pandoc.UTF8`:
+
+ + Better handling of bare CRs in input files (#2132).
+ Previously we just stripped them out; now we convert
+ other line ending styles to LF line endings.
+
+ * `Text.Pandoc.ImageSize`:
+
+ + Fixed some exif header parsing bugs (#1834).
+ + Make imageSize return an Either, not a Maybe (#1834).
+ Use `runGetOrFail` (with `binary >= 0.7`) to return `Left` on
+ parse failure (rather than `error`).
+ + Improved warnings when image size can't be determined.
+ + Removed error landmines (Matthew Pickering).
+
+ * Added woff2 to MIME types (Alfred Wechselberger).
+
+ * pandoc: When a binary input format is used, warn that file
+ arguments past the first one are being ignored (Matthew Pickering).
+
+ [template changes]
+
+ * LaTeX template:
+
+ + Degrade gracefully if `\paragraph` not defined.
+ + Include `grffile` together with `graphicx` (#2074).
+ This properly handles filenames containing spaces and dots.
+ + Redefine `\paragraph`, `\subparagraph`... to behave more
+ like section headers (#1658).
+ + Import hyperref before polyglossia to avoid an error with xelatex,
+ "please load package hyperref before bidi package" (Nick Bart).
+ + Added `toccolor` variable to control link color in toc (Kaixhin).
+
+ * LaTeX, Beamer templates:
+
+ + Provide `\tightlist`, which is now used by the LaTeX writer.
+ + Use polyglossia in beamer (#85).
+ + Use `bibliography` instead of `biblio-files`
+ (#1661). Also use `\addbibresource` instead of `\bibliography` for
+ biblatex.
+ + Added `setotherlanguages` in polyglossia. This uses an `otherlang`
+ variable that is derived from a comma-separated list in `lang`;
+ the last language is `mainlang` and the others are `otherlang`.
+
+ * EPUB templates:
+
+ + Use `div`, not `p`, for "rights" on title page.
+ + Added header-includes, include-before, include-after (#1987).
+
+ * OpenDocument template:
+
+ + Use `text:p` instead of `text:h` for title.
+ Using `text:h` causes problems with numbering. Closes #2059.
+ Thansk to @nkalvi for diagnosing this.
+
+ * reveal.js template:
+
+ + Link to non-minified css, js. The minified versions no longer
+ ship with the library.
+ + Correctly include style CSS (#1949).
+ + New configurable options options: `center`, `maxScale`, `slideNuber`
+ (Dmitry Smirnov, pandoc-templates#89).
+ + Moved custom CSS after theme. This allows custom CSS to modify
+ themes, instead of being replaced by them.
+ + Allow `center` to be set to false.
+
+ [under the hood improvements]
+
+ * Removed pre-built `reference.docx` and `reference.odt` (Nikolay
+ Yakimov). Instead the repository now includes the component text files,
+ and the zipped binaries are built from these using a helper
+ program, `make-reference-files`. This should make maintenance of
+ these components easier going forward.
+
+ * `Text.Pandoc.Parsing`:
+
+ + Added new `<+?>` combinator (Nikolay Yakimov).
+ + Added `stateHeaderKeys` to `ParserState`.
+
+ * `make_deb.sh` fixes:
+
+ + Detect architecture.
+ + Add Installed-Size to debian package control file (#1900).
+ + Use `fakeroot` to get permissions right.
+ + Use `mkdir` and `cp` instead of `install`.
+ + Set permissions of directories to 755.
+ + Install in `/usr` rather than `/usr/local`.
+ + Compress man pages.
+ + Combine copyright files for `pandoc`, `pandoc-citeproc`.
+
+ * Added `Text.Pandoc.Compat.Locale` and `old-locale` flag
+ to assist with transition to `time` 1.5.
+
+ * Updated CONTRIBUTING.md with information about issue tags (Matthew
+ Pickering).
+
+ * Updated travis installs to the new sudo-less syntax (Tim Lin).
+
+ * Updated dependency version bounds.
+
+ * EPUB tests: don't use `joinPath`, which varies across platforms.
+ Instead, use a forward-slash to join paths, regardless of the
+ platform. This matches the way `MediaBag` now works.
+
+ * Clarify JSON input and output in usage message (Caleb McDaniel).
+
+ * Improved INSTALL instructions.
+
+ * Always build man pages. Removed make-pandoc-man-pages flag.
+
+ * Makefile: removed man target, now that we generate man pages by default.
+
+ * README:
+
+ + Fixed typos (J. Lewis Muir).
+ + Added documentation on backtick_code_blocks (#2135, Nikolay Yakimov).
+ + Added note on in-field markup in biblio databases (Nick Bart).
+ + Fixed misleading example of raw HTML block.
+ + Various minor formatting and consistency fixes for the program
+ options (Andreas Lööw).
+ + Made definition lists for options all "loose" for consistency.
+ + Added YAML biblio format to table, and note on `pandoc-citeproc`'s
+ `--bib2json` and `--bib2yaml` options (Nick Bart).
+ + Removed obsolete reference to `mods2yaml` (Nick Bart).
+ + Added section on syntax highlighting.
+ + Documented `toccolor` variable.
+
+pandoc (1.13.2.1)
+
+ * Updated to build with ghc 7.10.1.
+
+ * Bumped package upper bounds for filepath, blaze-html,
+ blaze-markup.
+
+pandoc (1.13.2)
+
+ * TWiki Reader: add new new twiki reader (API chaneg, Alexander Sulfrian).
+
+ * Markdown reader:
+
+ + Better handling of paragraph in div (#1591).
+ Previously text that ended a div would be parsed as Plain
+ unless there was a blank line before the closing div tag.
+ + Don't treat a citation as a reference link label (#1763).
+ + Fix autolinks with following punctuation (#1811).
+ The price of this is that autolinked bare URIs can no longer
+ contain `>` characters, but this is not a big issue.
+ + Fix `Ext_lists_without_preceding_blankline` bug (#1636, Artyom).
+ + Allow `startnum` to work without `fancy_lists`. Formerly
+ `pandoc -f markdown-fancy_lists+startnum` did not work properly.
+
+ * RST reader (all Daniel Bergey):
+
+ + Parse quoted literal blocks (#65). RST quoted literal blocks are
+ the same as indented literal blocks (which pandoc already supports)
+ except that the quote character is preserved in each line.
+ + Parse RST class directives. The class directive accepts one or more
+ class names, and creates a Div value with those classes. If the
+ directive has an indented body, the body is parsed as the children of
+ the Div. If not, the first block folowing the directive is made a
+ child of the Div. This differs from the behavior of rst2xml, which
+ does not create a Div element. Instead, the specified classes are
+ applied to each child of the directive. However, most Pandoc Block
+ constructors to not take an Attr argument, so we can't duplicate this
+ behavior.
+ + Warn about skipped directives.
+ + Literal role now produces Code. Code role should have "code" class.
+ + Improved support for custom roles
+
+ - Added `sourceCode` to classes for `:code:` role, and anything
+ inheriting from it.
+ - Add the name of the custom role to classes if the Inline
+ constructor supports Attr.
+ - If the custom role directive does not specify a parent role,
+ inherit from the `:span:` role.
+
+ This differs somewhat from the `rst2xml.py` behavior. If a custom
+ role inherits from another custom role, Pandoc will attach both
+ roles' names as classes. `rst2xml.py` will only use the class of
+ the directly invoked role (though in the case of inheriting from a
+ `:code:` role with a `:language:` defined, it will also provide the
+ inherited language as a class).
+ + Warn about ignored fields in role directives.
+
+ * LaTeX reader:
+
+ + Parse label after caption into a span instead of
+ inserting an additional paragraph of bracketed text (#1747).
+ + Parse math environments as inline when possible (#1821).
+ + Better handling of `\noindent` and `\greektext` (#1783).
+ + Handle `\texorpdfstring` more gracefully.
+ + Handle `\cref` and `\sep` (Wikiwide).
+ + Support `\smartcite` and `\Smartcite` from biblatex.
+
+ * HTML reader:
+
+ + Retain display type of MathML output (#1719, Matthew Pickering).
+ + Recognise `<br>` tags inside `<pre>` blocks (#1620, Matthew Pickering).
+ + Make `embed` tag either block or inline (#1756).
+
+ * DocBook reader:
+
+ + Handle `keycombo`, `keycap` (#1815).
+ + Get string content in inner tags for literal elements (#1816).
+ + Handle `menuchoice` elements better, with a `>` between (#1817).
+ + Include `id` on section headers (#1818).
+ + Document/test "type" as implemented (Brian O'Sullivan).
+ + Add support for calloutlist and callout (Brian O'Sullivan).
+ We treat a calloutlist as a bulleted list. This works well in practice.
+ + Add support for `classname` (Bryan O'Sullivan).
+
+ * Docx reader:
+
+ + Fix window path for image lookup (Jesse Rosenthal).
+ Don't use os-sensitive "combine", since we always want the paths in our
+ zip-archive to use forward-slashes.
+ + Single-item headers in ordered lists are headers (Jesse Rosenthal).
+ When users number their headers, Word understands that as a single item
+ enumerated list. We make the assumption that such a list is, in fact,
+ a header.
+ + Rewrite rewriteLink to work with new headers (Jesse Rosenthal).
+ There could be new top-level headers after making lists, so we have to
+ rewrite links after that.
+ + Use polyglot header list (Jesse Rosenthal).
+ We're just keeping a list of header formats that different languages
+ use as their default styles. At the moment, we have English, German,
+ Danish, and French. We can continue to add to this.
+ This is simpler than parsing the styles file, and perhaps less
+ error-prone, since there seems to be some variations, even within a
+ language, of how a style file will define headers.
+ + Remove header class properly in other langs (Jesse Rosenthal).
+ When we encounter one of the polyglot header styles, we want to remove
+ that from the par styles after we convert to a header. To do that, we
+ have to keep track of the style name, and remove it appropriately.
+ + Account for external link URLs with anchors. Previously, if a URL
+ had an anchor, the reader would incorrectly identify it as an
+ internal link and return only the anchor as URL. (Caleb McDaniel)
+ + Fix for Issue #1692 (i18n styles) (Nikolay Yakimov).
+
+ * Org reader:
+
+ + Added state changing blanklines (Jesse Rosenthal).
+ This allows us to emphasize at the beginning of a new paragraph (or, in
+ general, after blank lines).
+ + Fixed bug with bulleted lists:
+
+ - a
+ - b
+ * c
+
+ was being parsed as a list, even though an unindented `*`
+ should make a heading. See
+ <http://orgmode.org/manual/Plain-lists.html#fn-1>.
+ + Org reader: absolute, relative paths in link (#1741, Albert
+ Krewinkel). The org reader was too restrictive when parsing links;
+ some relative links and links to files given as absolute paths
+ were not recognized correctly.
+ + Org reader: allow empty links (jgm/gitit#471, Albert Krewinkel).
+ This is important for use in gitit, which uses empty links
+ for wikilinks.
+ + Respect indent when parsing Org bullet lists (#1650, Timothy
+ Humphries). Fixes issue with top-level bullet list parsing.
+ + Fix indent issue for definition lists (Timothy Humphries,
+ see #1650, #1698, #1680).
+ + Parse multi-inline terms correctly in definition list (#1649,
+ Matthew Pickering).
+ + Fix rules for emphasis recognition (Albert Krewinkel).
+ Things like `/hello,/` or `/hi'/` were falsy recognized as emphasised
+ strings. This is wrong, as `,` and `'` are forbidden border chars and
+ may not occur on the inner border of emphasized text.
+ + Drop COMMENT document trees (Albert Krewinkel).
+ Document trees under a header starting with the word `COMMENT` are
+ comment trees and should not be exported. Those trees are dropped
+ silently (#1678).
+ + Properly handle links to `file:target` (Albert Krewinkel).
+ Org links like `[[file:target][title]]` were not handled correctly,
+ parsing the link target verbatim. The org reader is changed such that
+ the leading `file:` is dropped from the link target (see #756, #1812).
+ + Parse LaTeX-style MathML entities (#1657, Albert Krewinkel).
+ Org supports special symbols which can be included using LaTeX syntax,
+ but are actually MathML entities. Examples for this are
+ `\nbsp` (non-breaking space), `\Aacute` (the letter A with accent acute)
+ or `\copy` (the copyright sign ©)
+
+ * EPUB reader:
+
+ + URI handling improvements. Now we outsource most of the work to
+ `fetchItem'`. Also, do not include queries in file extensions (#1671).
+
+ * LaTeX writer:
+
+ + Use `\texorpdfstring` for section captions when needed (Vaclav Zeman).
+ + Handle consecutive linebreaks (#1733).
+ + Protect graphics in headers (Jesse Rosenthal).
+ Graphics in `\section`/`\subsection` etc titles need to be `\protect`ed.
+ + Put `~` before header in list item text (Jesse Rosenthal).
+ Because of the built-in line skip, LaTeX can't handle a section header
+ as the first element in a list item.
+ + Avoid using reserved characters as `\lstinline` delimiters (#1595).
+ + Better handling of display math in simple tables (#1754).
+ We convert display math to inline math in simple tables,
+ since LaTeX can't deal with display math in simple tables.
+ + Escape spaces in code (#1694, Bjorn Buckwalter).
+
+ * MediaWiki writer:
+
+ + Fixed links with URL = text. Previously these were rendered as bare
+ words, even if the URL was not an absolute URL (#1825).
+
+ * ICML writer:
+
+ + Don't force all citations into footnotes.
+
+ * RTF writer:
+
+ + Add blankline at end of output (#1732, Matthew Pickering).
+
+ * RST writer:
+
+ + Ensure blank line after figure.
+ + Avoid exces whitespace after last list item (#1777).
+ + Wrap line blocks with spaces before continuations (#1656).
+ + Fixed double-rendering of footnotes in RST tables (#1769).
+
+ * DokuWiki writer:
+
+ + Better handling of block quotes. This change ensures that
+ multiple paragraph blockquotes are rendered using native `>`
+ rather than as HTML (#1738).
+ + Fix external images (#1739). Preface relative links with ":",
+ absolute URIs without. (Timothy Humphries)
+
+ * HTML writer:
+
+ + Use protocol-relative URL for mathjax.
+ + Put newline btw img and caption paragraph.
+ + MathML now outputted with tex annotation (#1635, Matthew Pickering).
+ + Add support for KaTeX HTML math (#1626, Matthew Pickering).
+ This adds `KaTeX` to `HTMLMathMethod` (API change).
+ + Don't double render when `email-obfuscation=none` (#1625, Matthew
+ Pickering).
+ + Make header attributes work outside top level (#1711).
+ Previously they only appeared on top level header elements.
+ Now they work e.g. in blockquotes.
+
+ * ODT writer:
+
+ + Correctly handle images without extensions (#1729).
+ + Strip querystring in ODT write (#1682, Todd Sifleet).
+
+ * FB2 writer:
+
+ + Add newline to output.
+
+ * EPUB writer:
+
+ + Don't add `sourceURL` to absolute URIs (#1669).
+ + Don't use unsupported `opf:title-type` for epub2.
+ + Include "landmarks" section in nav document for epub3 (#1757).
+ + Removed playOrder from navpoint elements in ncx file (#1760).
+ These aren't required, and they make manual modification of epubs
+ difficult.
+ + Extract title even from structured title.
+ + Don't include nav node in spine unless `--toc` was requested.
+ Previously we included it in the spine with `linear="no"`, leading
+ to odd results in some readers (#1593).
+ + Fixed absolute URI detection (#1672).
+ + Correctly resolve relative URIs (#1671).
+ + Use regular page template for `nav.xhtml`, including doctype (#1759).
+
+ * Docx writer:
+
+ + Put docx table captions above tables (#1641, Nikolay Yakimov).
+ + Get the page width from the reference docx file, and use
+ it to scale images that are too large to fit (Grégory Bataille).
+ + Partial fix for #1607 (Nikolay Yakimov). International heading styles
+ are inferred based on `<w:name val="heading #">` fallback, if there
+ are no en-US "Heading#" styles
+ + Look in user data dir for archive `reference.docx`.
+ + Renumber header and footer relationships to avoid collisions (Jesse
+ Rosenthal). We previously took the old relationship names of the
+ headers and footer in secptr. That led to collisions. We now make
+ a map of availabl names in the relationships file, and then rename
+ in secptr.
+
+ * ConTeXt writer:
+
+ + Add function toLabel (Mark Szepieniec).
+ This function can be used to sanitize reference labels so that
+ they do not contain any of the illegal characters \#[]",{}%()|= .
+ Currently only Links have their labels sanitized, because they
+ are the only Elements that use passed labels.
+
+ * `Text.Pandoc.Shared`:
+
+ + Moved import of `toChunks` outside of CPP conditional (#1590).
+ + Fix `inDirectory` to reset to the original directory in case
+ an exception occurs (Freiric Barral).
+
+ * Templates:
+
+ + LaTeX template: load polyglossia before bibtex (jgm/pandoc-templates#70).
+ Thanks to bluebirch.
+ + LaTeX template: Added `\VerbatimFootnotes` if there is verbatim in notes
+ (#1616).
+ + LaTeX template: Add shorthands=off to babel options (#1648).
+ + EPUB, EPUB3 templates: Added `id="cover"` to body of cover page.
+ This aids styling, making it possible for example to set 0 margins
+ on the title page (#1758).
+ + EPUB, EPUB3 templates: Handle structured metadata on titlepage.
+ Previously we just expected 'title', 'subtitle', 'author', 'date'.
+ Now we still support those, but also support the format recommended
+ for epub metadata in the pandoc README:
+
+ ---
+ title:
+ - type: main
+ text: My Book
+ - type: subtitle
+ text: An investigation of metadata
+ creator:
+ - role: author
+ text: John Smith
+ - role: editor
+ text: Sarah Jones
+ identifier:
+ - scheme: DOI
+ text: doi:10.234234.234/33
+ publisher: My Press
+ rights: (c) 2007 John Smith, CC BY-NC
+ ...
+
+ * `Text.Pandoc.Templates.getDefaultTemplate`:
+ don't fail when called with "fb2" (#1660).
+
+ * `Text.Pandoc.Parsing`:
+
+ + Fixed `inlineMath` so it handles `\text{..}` containing `$`.
+ For example: `$x = \text{the $n$th root of $y$}` (#1677).
+ + Change `parseFromString` to fail if not all input is consumed.
+ (Matthew Pickering)
+ + Moved `addWarning` from Markdown reader to `Parsing`, so it can be
+ used by more readers (API change, Daniel Bergey).
+
+ * `Text.Pandoc.Pretty`:
+
+ + Improve performance of `realLength` (Matthew Pickering).
+ + Make CR + BLANKLINE = BLANKLINE. This fixes an extra blank line we
+ were getting at the end of markdown fragments (as well as rst, org,
+ etc.) (#1705).
+
+ * `Text.Pandoc.MIME`:
+
+ + Add mime type for WebVTT (Jason Ronallo).
+ + Changed mime type for `otf` to `application/vnd.ms-opentype` (#1761).
+ This is needed for epub3 validation.
+
+ * `Text.Pandoc.MediaBag`:
+
+ + Fix Windows specific path problems (#1597).
+
+ * `Text.Pandoc.Shared`:
+
+ + Make `collapseFilePath` OS-agnostic (Matthew Pickering).
+
+ * Link the test suite using `-threaded`.
+ This allows the test suite to be run using `+RTS -N`.
+
+ * Added `network` dependency under `network-uri` flag in test section.
+
+ * Give better error messages when someone tries to convert from
+ pdf, doc, odt (#1683).
+
+ * Added `track` to list of tags treated by `--self-contained` (#1664).
+
+pandoc (1.13.1)
+
+ * Fixed `--self-contained` with Windows paths (#1558).
+ Previously `C:\foo.js` was being wrongly interpreted as a URI.
+
+ * HTML reader: improved handling of tags that can be block or inline.
+ Previously a section like this would be enclosed in a paragraph,
+ with RawInline for the video tags (since video is a tag that can
+ be either block or inline):
+
+ <video controls="controls">
+ <source src="../videos/test.mp4" type="video/mp4" />
+ <source src="../videos/test.webm" type="video/webm" />
+ <p>
+ The videos can not be played back on your system.<br/>
+ Try viewing on Youtube (requires Internet connection):
+ <a href="http://youtu.be/etE5urBps_w">Relative Velocity on
+ Youtube</a>.
+ </p>
+ </video>
+
+ This change will cause the video and source tags to be parsed
+ as RawBlock instead, giving better output.
+ The general change is this: when we're parsing a "plain" sequence
+ of inlines, we don't parse anything that COULD be a block-level tag.
+
+ * Docx reader:
+
+ + Be sensitive to user styles. Note that "Hyperlink" is
+ "blacklisted," as we don't want the default underline styling to be
+ inherited by all links by default (Jesse Rosenthal).
+ + Read single paragraph in table cell as `Plain` (Jesse Rosenthal).
+ This makes to docx reader's native output fit with the way the markdown
+ reader understands its markdown output.
+
+ * Textile writer: Extended the range of cases where native textile
+ tables will be used (as opposed to raw HTML): we now handle any
+ alignment type, but only for simple tables with no captions.
+
+ * Txt2Tags reader:
+
+ + Header is now parsed only if standalone flag is set (Matthew Pickering).
+ + The header is now parsed as meta information. The first line is the
+ `title`, the second is the `author` and third line is the `date`
+ (Matthew Pickering).
+ + Corrected formatting of `%%mtime` macro (Matthew Pickering).
+ + Fixed crash when reading from stdin.
+
+ * EPUB writer: Don't use page-progression-direction in EPUB2, which
+ doesn't support it. Also, if page-progression-direction not specified
+ in metadata, don't include the attribute even in EPUB3; not including it
+ is the same as including it with the value "default", as we did before.
+ (#1550)
+
+ * Org writer: Accept example lines with indentation at the beginning
+ (Calvin Beck).
+
+ * DokuWiki writer:
+
+ + Refactor to use Reader monad (Matthew Pickering).
+ + Avoid using raw HTML in table cells; instead, use `\\`
+ instead of newlines (Jesse Rosenthal).
+ + Properly handle HTML table cell alignments, and use spacing
+ to make the tables look prettier (#1566).
+
+ * Docx writer:
+
+ + Bibliography entries get `Bibliography` style (#1559).
+ + Implement change tracking (Jesse Rosenthal).
+
+ * LaTeX writer:
+
+ + Fixed a bug that caused a table caption to repeat across all pages
+ (Jose Luis Duran).
+ + Improved vertical spacing in tables and made it customizable using
+ standard lengths set by booktab. See
+ <https://groups.google.com/forum/#!msg/pandoc-discuss/qMu6_5lYy0o/ZAU7lzAIKw0J>
+ (Jose Luis Duran).
+ + Added `\strut` to fix spacing in multiline tables (Jose Luis Duran).
+ + Use `\tabularnewline` instead of `\\` in table cells (Jose Luis Duran).
+ + Made horizontal rules more flexible (Jose Luis Duran).
+
+ * Text.Pandoc.MIME:
+
+ + Added `MimeType` (type synonym for `String`) and `getMimeTypeDef`.
+ Code cleanups (Artyom Kazak).
+
+ * Templates:
+
+ + LaTeX template: disable microtype protrusion for typewriter font (#1549,
+ thanks lemzwerg).
+
+ * Improved OSX build procedure.
+
+ * Added `network-uri` flag, to deal with split of `network-uri` from
+ `network`.
+
+ * Fix build dependencies for the `trypandoc` flag, so that they are
+ ignored if `trypandoc` flag is set to False (Gabor Pali).
+
+ * Updated README to remove outdated claim that `--self-contained`
+ looks in the user data directory for missing files.
+
+pandoc (1.13.0.1)
+
+ * Docx writer:
+
+ + Fixed regression which bungled list numbering (#1544), causing
+ all lists to appear as basic ordered lists.
+ + Include row width in table rows (Christoffer Ackelman, Viktor Kronvall).
+ Added a property to all table rows where the sum of column widths
+ is specified in pct (fraction of 5000). This helps persuade Word
+ to lay out the table with the widths we specify.
+
+ * Fixed a bug in Windows 8 which caused pandoc not to find the
+ `pandoc-citeproc` filter (#1542).
+
+ * Docx reader: miscellaneous under-the-hood improvements (Jesse Rosenthal).
+ Most significantly, the reader now uses Builder, leading to some
+ performance improvements.
+
+ * HTML reader: Parse appropriately styled span as SmallCaps.
+
+ * Markdown writer: don't escape `$`, `^`, `~` when `tex_math_dollars`,
+ `superscript`, and `subscript` extensions, respectively, are
+ deactivated (#1127).
+
+ * Added `trypandoc` flag to build CGI executable used in the online
+ demo.
+
+ * Makefile: Added 'quick', 'osxpkg' targets.
+
+ * Updated README in templates to indicate templates license.
+ The templates are dual-licensed, BSD3 and GPL2+.
+
+pandoc (1.13)
+
+ [new features]
+
+ * Added `docx` as an input format (Jesse Rosenthal). The docx
+ reader includes conversion of native Word equations to pandoc
+ LaTeX `Math` elements. Metadata is taken from paragraphs at the
+ beginning of the document with styles `Author`, `Title`, `Subtitle`,
+ `Date`, and `Abstract`.
+
+ * Added `epub` as an input format (Matthew Pickering). The epub
+ reader includes conversion of MathML to pandoc LaTeX `Math`
+ elements.
+
+ * Added `t2t` (Txt2Tags) as an input format (Matthew Pickering).
+ Txt2tags is a lightweight markup format described at
+ <http://txt2tags.org/>.
+
+ * Added `dokuwiki` as an output format (Clare Macrae).
+
+ * Added `haddock` as an output format.
+
+ * Added `--extract-media` option to extract media contained in a zip
+ container (docx or epub) while adjusting image paths to point to the
+ extracted images.
+
+ * Added a new markdown extension, `compact_definition_lists`, that
+ restores the syntax for definition lists of pandoc 1.12.x, allowing
+ tight definition lists with no blank space between items, and
+ disallowing lazy wrapping. (See below under behavior changes.)
+
+ * Added an extension `epub_html_exts` for parsing HTML in EPUBs.
+
+ * Added extensions `native_spans` and `native_divs` to activate
+ parsing of material in HTML span or div tags as Pandoc Span
+ inlines or Div blocks.
+
+ * `--trace` now works with the Markdown, HTML, Haddock, EPUB,
+ Textile, and MediaWiki readers. This is an option intended
+ for debugging parsing problems; ordinary users should not need
+ to use it.
+
+ [behavior changes]
+
+ * Changed behavior of the `markdown_attribute` extension, to bring
+ it in line with PHP markdown extra and multimarkdown. Setting
+ `markdown="1"` on an outer tag affects all contained tags,
+ recursively, until it is reversed with `markdown="0"` (#1378).
+
+ * Revised markdown definition list syntax (#1429). Both the reader
+ and writer are affected. This change brings pandoc's definition list
+ syntax into alignment with that used in PHP markdown extra and
+ multimarkdown (with the exception that pandoc is more flexible about
+ the definition markers, allowing tildes as well as colons). Lazily
+ wrapped definitions are now allowed. Blank space is required
+ between list items. The space before a definition is used to determine
+ whether it is a paragraph or a "plain" element. **WARNING: This change
+ may break existing documents!** Either check your documents for
+ definition lists without blank space between items, or use
+ `markdown+compact_definition_lists` for the old behavior.
+
+ * `.numberLines` now works in fenced code blocks even if no language
+ is given (#1287, jgm/highlighting-kate#40).
+
+ * Improvements to `--filter`:
+
+ + Don't search PATH for a filter with an explicit path.
+ This fixed a bug wherein `--filter ./caps.py` would run `caps.py` from
+ the system path, even if there was a `caps.py` in the working directory.
+ + Respect shebang if filter is executable (#1389).
+ + Don't print misleading error message.
+ Previously pandoc would say that a filter was not found,
+ even in a case where the filter had a syntax error.
+
+ * HTML reader:
+
+ + Parse `div` and `span` elements even without `--parse-raw`,
+ provided `native_divs` and `native_spans` extensions are set.
+ Motivation: these now generate native pandoc Div and Span
+ elements, not raw HTML.
+ + Parse EPUB-specific elements if the `epub_html_exts`
+ extension is enabled. These include `switch`, `footnote`,
+ `rearnote`, `noteref`.
+
+ * Org reader:
+
+ + Support for inline LaTeX. Inline LaTeX is now accepted and parsed by the
+ org-mode reader. Both math symbols (like `\tau`) and LaTeX commands (like
+ `\cite{Coffee}`), can be used without any further escaping (Albert
+ Krewinkel).
+
+ * Textile reader and writer:
+
+ + The `raw_tex` extension is no longer set by default. You can
+ enable it with `textile+raw_tex`.
+
+ * DocBook reader:
+
+ + Support `equation`, `informalequation`, `inlineequation` elements with
+ `mml:math` content. This is converted into LaTeX and put into a Pandoc
+ Math inline.
+
+ * Revised `plain` output, largely following the style of Project
+ Gutenberg:
+
+ + Emphasis is rendered with `_underscores_`, strong emphasis
+ with ALL CAPS.
+ + Headings are rendered differently, with space to set them off,
+ not with setext style underlines. Level 1 headers are ALL CAPS.
+ + Math is rendered using unicode when possible, but without the
+ distracting emphasis markers around variables.
+ + Footnotes use a regular `[n]` style.
+
+ * Markdown writer:
+
+ + Horizontal rules are now a line across the whole page.
+ + Prettier pipe tables. Columns are now aligned (#1323).
+ + Respect the `raw_html` extension. `pandoc -t markdown-raw_html`
+ no longer emits any raw HTML, including span and div tags
+ generated by Span and Div elements.
+ + Use span with style for `SmallCaps` (#1360).
+
+ * HTML writer:
+
+ + Autolinks now have class `uri`, and email autolinks have class
+ `email`, so they can be styled.
+
+ * Docx writer:
+
+ + Document formatting is carried over from `reference.docx`.
+ This includes margins, page size, page orientation, header,
+ and footer, including images in headers and footers.
+ + Include abstract (if present) with `Abstract` style (#1451).
+ + Include subtitle (if present) with `Subtitle` style, rather
+ than tacking it on to the title (#1451).
+
+ * Org writer:
+
+ + Write empty span elements with an id attribute as org anchors.
+ For example `Span ("uid",[],[]) []` becomes `<<uid>>`.
+
+ * LaTeX writer:
+
+ + Put table captions above tables, to match the conventional
+ standard. (Previously they appeared below tables.)
+ + Use `\(..\)` instead of `$..$` for inline math (#1464).
+ + Use `\nolinkurl` in email autolinks. This allows them to be styled
+ using `\urlstyle{tt}`. Thanks to Ulrike Fischer for the solution.
+ + Use `\textquotesingle` for `'` in inline code. Otherwise we get
+ curly quotes in the PDF output (#1364).
+ + Use `\footnote<.>{..}` for notes in beamer, so that footnotes
+ do not appear before the overlays in which their markers appear
+ (#1525).
+ + Don't produce a `\label{..}` for a Div or Span element. Do produce
+ a `\hyperdef{..}` (#1519).
+
+ * EPUB writer:
+
+ + If the metadata includes `page-progression-direction` (which can be
+ `ltr` or `rtl`, the `page-progression-direction` attribute will
+ be set in the EPUB spine (#1455).
+
+ * Custom lua writers:
+
+ + Custom writers now work with `--template`.
+ + Removed HTML header scaffolding from `sample.lua`.
+ + Made citation information available in lua writers.
+
+ * `--normalize` and `Text.Pandoc.Shared.normalize` now consolidate
+ adjacent `RawBlock`s when possible.
+
+ [API changes]
+
+ * Added `Text.Pandoc.Readers.Docx`, exporting `readDocx` (Jesse Rosenthal).
+
+ * Added `Text.Pandoc.Readers.EPUB`, exporting `readEPUB` (Matthew
+ Pickering).
+
+ * Added `Text.Pandoc.Readers.Txt2Tags`, exporting `readTxt2Tags` (Matthew
+ Pickering).
+
+ * Added `Text.Pandoc.Writers.DokuWiki`, exporting `writeDokuWiki`
+ (Clare Macrae).
+
+ * Added `Text.Pandoc.Writers.Haddock`, exporting `writeHaddock`.
+
+ * Added `Text.Pandoc.MediaBag`, exporting `MediaBag`, `lookupMedia`,
+ `insertMedia`, `mediaDirectory`, `extractMediaBag`. The docx and epub
+ readers return a pair of a `Pandoc` document and a `MediaBag` with
+ the media resources they contain. This can be extracted using
+ `--extract-media`. Writers that incorporate media (PDF, Docx,
+ ODT, EPUB, RTF, or HTML formats with `--self-contained`) will look
+ for resources in the `MediaBag` generated by the reader, in addition to
+ the file system or web.
+
+ * `Text.Pandoc.Readers.TexMath`: Removed deprecated `readTeXMath`.
+ Renamed `readTeXMath'` to `texMathToInlines`.
+
+ * `Text.Pandoc`: Added `Reader` data type (Matthew Pickering).
+ `readers` now associates names of readers with `Reader`
+ structures. This allows inclusion of readers, like the docx
+ reader, that take binary rather than textual input.
+
+ * `Text.Pandoc.Shared`:
+
+ + Added `capitalize` (Artyom Kazak), and replaced uses of
+ `map toUpper` (which give bad results for many languages).
+ + Added `collapseFilePath`, which removes intermediate `.` and
+ `..` from a path (Matthew Pickering).
+ + Added `fetchItem'`, which works like `fetchItem` but searches
+ a `MediaBag` before looking on the net or file system.
+ + Added `withTempDir`.
+ + Added `removeFormatting`.
+ + Added `extractSpaces` (from HTML reader) and generalized its type
+ so that it can be used by the docx reader (Matthew Pickering).
+ + Added `ordNub`.
+ + Added `normalizeInlines`, `normalizeBlocks`.
+ + `normalize` is now `Pandoc -> Pandoc` instead of
+ `Data a :: a -> a`. Some users may need to change their uses of
+ `normalize` to the newly exported `normalizeInlines` or
+ `normalizeBlocks`.
+
+ * `Text.Pandoc.Options`:
+
+ + Added `writerMediaBag` to `WriterOptions`.
+ + Removed deprecated and no longer used `readerStrict` in
+ `ReaderOptions`. This is handled by `readerExtensions` now.
+ + Added `Ext_compact_definition_lists`.
+ + Added `Ext_epub_html_exts`.
+ + Added `Ext_native_divs` and `Ext_native_spans`.
+ This allows users to turn off the default pandoc behavior of
+ parsing contents of div and span tags in markdown and HTML
+ as native pandoc Div blocks and Span inlines.
+
+ * `Text.Pandoc.Parsing`:
+
+ + Generalized `readWith` to `readWithM` (Matthew Pickering).
+ + Export `runParserT` and `Stream` (Matthew Pickering).
+ + Added `HasQuoteContext` type class (Matthew Pickering).
+ + Generalized types of `mathInline`, `smartPunctuation`, `quoted`,
+ `singleQuoted`, `doubleQuoted`, `failIfInQuoteContext`,
+ `applyMacros` (Matthew Pickering).
+ + Added custom `token` (Matthew Pickering).
+ + Added `stateInHtmlBlock` to `ParserState`. This is used to keep
+ track of the ending tag we're waiting for when we're parsing inside
+ HTML block tags.
+ + Added `stateMarkdownAttribute` to `ParserState`. This is used
+ to keep track of whether the markdown attribute has been set in
+ an enclosing tag.
+ + Generalized type of `registerHeader`, using new type classes
+ `HasReaderOptions`, `HasIdentifierList`, `HasHeaderMap` (Matthew
+ Pickering). These allow certain common functions to be reused
+ even in parsers that use custom state (instead of `ParserState`),
+ such as the MediaWiki reader.
+ + Moved `inlineMath`, `displayMath` from Markdown reader to Parsing,
+ and generalized their types (Matthew Pickering).
+
+ * `Text.Pandoc.Pretty`:
+
+ + Added `nestle`.
+ + Added `blanklines`, which guarantees a certain number of blank lines
+ (and no more).
+
+ [bug fixes]
+
+ * Markdown reader:
+
+ + Fixed parsing of indented code in list items. Indented code
+ at the beginning of a list item must be indented eight spaces
+ from the margin (or edge of the container), or four spaces
+ from the list marker, whichever is greater.
+ + Fixed small bug in HTML parsing with `markdown_attribute`, which
+ caused incorrect tag nesting for input like
+ `<aside markdown="1">*hi*</aside>`.
+ + Fixed regression with intraword underscores (#1121).
+ + Improved parsing of inline links containing quote characters (#1534).
+ + Slight rewrite of `enclosure`/`emphOrStrong` code.
+ + Revamped raw HTML block parsing in markdown (#1330).
+ We no longer include trailing spaces and newlines in the
+ raw blocks. We look for closing tags for elements (but without
+ backtracking). Each block-level tag is its own `RawBlock`;
+ we no longer try to consolidate them (though `--normalize` will do so).
+ + Combine consecutive latex environments. This helps when you have
+ two minipages which can't have blank lines between them (#690, #1196).
+ + Support smallcaps through span.
+ `<span style="font-variant:small-caps;">foo</span>` will be
+ parsed as a `SmallCaps` inline, and will work in all output
+ formats that support small caps (#1360).
+ + Prevent spurious line breaks after list items (#1137). When the
+ `hard_line_breaks` option was specified, pandoc would formerly
+ produce a spurious line break after a tight list item.
+ + Fixed table parsing bug (#1333).
+ + Handle `c++` and `objective-c` as language identifiers in
+ github-style fenced blocks (#1318).
+ + Inline math must have nonspace before final `$` (#1313).
+
+ * LaTeX reader:
+
+ + Handle comments at the end of tables. This resolves the issue
+ illustrated in <http://stackoverflow.com/questions/24009489>.
+ + Correctly handle table rows with too few cells. LaTeX seems to
+ treat them as if they have empty cells at the end (#241).
+ + Handle leading/trailing spaces in `\emph` better.
+ `\emph{ hi }` gets parsed as `[Space, Emph [Str "hi"], Space]`
+ so that we don't get things like `* hi *` in markdown output.
+ Also applies to `\textbf` and some other constructions (#1146).
+ + Don't assume preamble doesn't contain environments (#1338).
+ + Allow (and discard) optional argument for `\caption` (James Aspnes).
+
+ * HTML reader:
+
+ + Fixed major parsing problem with HTML tables. Table cells were
+ being combined into one cell (#1341).
+ + Fixed performance issue with malformed HTML tables.
+ We let a `</table>` tag close an open `<tr>` or `<td>` (#1167).
+ + Allow space between `<col>` and `</col>`.
+ + Added `audio` and `source` in `eitherBlockOrInline`.
+ + Moved `video`, `svg`, `progress`, `script`, `noscript`, `svg` from
+ `blockTags` to `eitherBlockOrInline`.
+ + `map` and `object` were mistakenly in both lists; they have been removed
+ from `blockTags`.
+ + Ignore `DOCTYPE` and `xml` declarations.
+
+ * MediaWiki reader:
+
+ + Don't parse backslash escapes inside `<source>` (#1445).
+ + Tightened up template parsing.
+ The opening `{{` must be followed by an alphanumeric or `:`.
+ This prevents the exponential slowdown in #1033.
+ + Support "Bild" for images.
+
+ * DocBook reader:
+
+ + Better handle elements inside code environments. Pandoc's document
+ model does not allow structure inside code blocks, but at least this way
+ we preserve the text (#1449).
+ + Support `<?asciidoc-br?>` (#1236).
+
+ * Textile reader:
+
+ + Fixed list parsing. Lists can now start without an intervening
+ blank line (#1513).
+ + HTML block-level tags that do not start a line are parsed as
+ inline HTML and do not interrupt paragraphs (as in RedCloth).
+
+ * Org reader:
+
+ + Make tildes create inline code (#1345). Also relabeled `code` and
+ `verbatim` parsers to accord with the org-mode manual.
+ + Respect `:exports` header argument in code blocks (Craig Bosma).
+ + Fixed tight lists with sublists (#1437).
+
+ * EPUB writer:
+
+ + Avoid excess whitespace in `nav.xhtml`. This should improve
+ TOC view in iBooks (#1392).
+ + Fixed regression on cover image.
+ In 1.12.4 and 1.12.4.2, the cover image would not appear properly,
+ because the metadata id was not correct. Now we derive the id from the
+ actual cover image filename, which we preserve rather than using
+ "cover-image."
+ + Keep newlines between block elements. This allows
+ easier diff-ability (#1424).
+ + Use `stringify` instead of custom `plainify`.
+ + Use `renderTags'` for all tag rendering. This properly handles tags
+ that should be self-closing. Previously `<hr/>` would appear in EPUB
+ output as `<hr></hr>` (#1420).
+ + Better handle HTML media tags.
+ + Handle multiple dates with OPF `event` attributes. Note: in EPUB3 we
+ can have only one dc:date, so only the first one is used.
+
+ * LaTeX writer:
+
+ + Correctly handle figures in notes. Notes can't contain figures in
+ LaTeX, so we fake it to avoid an error (#1053).
+ + Fixed strikeout + highlighted code (#1294).
+ Previously strikeout highlighted code caused an error.
+
+ * ConTeXt writer:
+
+ + Improved detection of autolinks with URLs containing escapes.
+
+ * RTF writer:
+
+ + Improved image embedding: `fetchItem'` is now used to get the
+ images, and calculated image sizes are indicated in the RTF.
+ + Avoid extra paragraph tags in metadata (#1421).
+
+ * HTML writer:
+
+ + Deactivate "incremental" inside slide speaker notes (#1394).
+ + Don't include empty items in the table of contents for
+ slide shows. (These would result from creating a slide
+ using a horizontal rule.)
+
+ * MediaWiki writer:
+
+ + Minor renaming of `st` prefixed names.
+
+ * AsciiDoc writer:
+
+ + Double up emphasis and strong emphasis markers in intraword
+ contexts, as required by asciidoc (#1441).
+
+ * Markdown writer:
+
+ + Avoid wrapping that might start a list, blockquote, or header (#1013).
+ + Use Span instead of (hackish) `SmallCaps` in `plainify`.
+ + Don't use braced attributes for fenced code (#1416).
+ If `Ext_fenced_code_attributes` is not set, the first class
+ attribute will be printed after the opening fence as a bare word.
+ + Separate adjacent lists of the same kind with an HTML comment (#1458).
+
+ * PDF writer:
+
+ + Fixed treatment of data uris for images (#1062).
+
+ * Docx writer:
+
+ + Use Compact style for empty table cells (#1353).
+ Otherwise we get overly tall lines when there are empty
+ table cells and the other cells are compact.
+ + Create overrides per-image for `media/` in reference docx.
+ This should be somewhat more robust and cover more types of images.
+ + Improved `entryFromArchive` to avoid an unneeded parse.
+ + Section numbering carries over from reference.docx (#1305).
+ + Simplified `abstractNumId` numbering. Instead of sequential numbering,
+ we assign numbers based on the list marker styles.
+
+ * `Text.Pandoc.Options`:
+
+ + Removed `Ext_fenced_code_attributes` from `markdown_github`
+ extensions.
+
+ * `Text.Pandoc.ImageSize`:
+
+ + Use default instead of failing if image size not found
+ in exif header (#1358).
+ + ignore unknown exif header tag rather than crashing.
+ Some images seem to have tag type of 256, which was causing
+ a runtime error.
+
+ * `Text.Pandoc.Shared`:
+
+ + `fetchItem`: unescape URI encoding before reading local file (#1427).
+ + `fetchItem`: strip a fragment like `?#iefix` from the extension before
+ doing mime lookup, to improve mime type guessing.
+ + Improved logic of `fetchItem`: absolute URIs are fetched from the net;
+ other things are treated as relative URIs if `sourceURL` is `Just _`,
+ otherwise as file paths on the local file system.
+ + `fetchItem` now properly handles links without a protocol (#1477).
+ + `fetchItem` now escapes characters not allowed in URIs before trying
+ to parse the URIs.
+ + Fixed runtime error with `compactify'DL` on certain lists (#1452).
+
+ * `pandoc.hs`: Don't strip path off of `writerSourceURL`: the path is
+ needed to resolve relative URLs when we fetch resources (#750).
+
+ * `Text.Pandoc.Parsing`
+
+ + Simplified `dash` and `ellipsis` (#1419).
+ + Removed `(>>~)` in favor of the equivalent `(<*)` (Matthew Pickering).
+ + Generalized functions to use `ParsecT` (Matthew Pickering).
+ + Added `isbn` and `pmid` to list of recognized schemes (Matthew
+ Pickering).
+
+ [template changes]
+
+ * Added haddock template.
+ * EPUB3: Added `type` attribute to `link` tags. They are supposed to
+ be "advisory" in HTML5, but kindlegen seems to require them.
+ * EPUB3: Put title page in section with `epub:type="titlepage"`.
+ * LaTeX: Made `\subtitle` work properly (#1327).
+ * LaTeX/Beamer: remove conditional around date (#1321).
+ * LaTeX: Added `lot` and `lof` variables, which can be set to
+ get `\listoftables` and `\listoffigures` (#1407). Note that
+ these variables can be set at the command line with `-Vlot -Vlof`
+ or in YAML metadata.
+
+ [under the hood improvements]
+
+ * Rewrote normalize for efficiency (#1385).
+
+ * Rewrote Haddock reader to use `haddock-library` (#1346).
+
+ + This brings pandoc's rendering of haddock markup in line
+ with the new haddock.
+ + Fixed line breaks in `@` code blocks.
+ + alex and happy are no longer build-depends.
+
+ * Added `Text.Pandoc.Compat.Directory` to allow building against
+ different versions of the `directory` library.
+
+ + Added `Text.Pandoc.Compat.Except` to allow building against
+ different verions of `mtl`.
+
+ * Code cleanup in some writers, using Reader monad to avoid
+ passing options parameter around (Matej Kollar).
+
+ * Improved readability in `pandoc.hs`.
+
+ * Miscellaneous code cleanups (Artyom Kazak).
+
+ * Avoid `import Prelude hiding (catch)` (#1309, thanks to Michael
+ Thompson).
+
+ * Changed `http-conduit` flag to `https`. Depend on `http-client`
+ and `http-client-tls` instead of `http-conduit`. (Note: pandoc still
+ depends on `conduit` via `yaml`.)
+
+ * Require `highlighting-kate >= 0.5.8.5` (#1271, #1317, Debian #753299).
+ This change to highlighting-kate means that PHP fragments no longer need
+ to start with `<?php`. It also fixes a serious bug causing failures with
+ ocaml and fsharp.
+
+ * Require latest `texmath`. This fixes `\tilde{E}` and allows
+ `\left` to be used with `]`, `)` etc. (#1319), among many other
+ improvements.
+
+ * Require latest `zip-archive`. This has fixes for unicode path names.
+
+ * Added tests for plain writer.
+
+ * `Text.Pandoc.Templates`:
+
+ + Fail informatively on template syntax errors.
+ With the move from parsec to attoparsec, we lost good error
+ reporting. In fact, since we weren't testing for end of input,
+ malformed templates would fail silently. Here we revert back to
+ Parsec for better error messages.
+ + Use `ordNub` (#1022).
+
+ * Benchmarks:
+
+ + Made benchmarks compile again (Artyom Kazak).
+ + Fixed so that the failure of one benchmark does not prevent others
+ from running (Artyom Kazak).
+ + Use `nfIO` instead of the `getLength` trick to force full evaluation.
+ + Changed benchmark to use only the test suite, so that benchmarks
+ run more quickly.
+
+ * Windows build script:
+
+ + Add `-windows` to file name.
+ + Use one install command for pandoc, pandoc-citeproc.
+ + Force install of pandoc-citeproc.
+
+ * `make_osx_package`: Call zip file `pandoc-VERSION-osx.zip`.
+ The zip should not be named `SOMETHING.pkg.zip`, or OSX finder
+ will extract it into a folder named `SOMETHING.pkg`, which it
+ will interpret as a defective package (#1308).
+
+ * `README`:
+
+ + Made headers for all extensions so they have IDs and can be
+ linked to (Beni Cherniavsky-Paskin).
+ + Fixed typos (Phillip Alday).
+ + Fixed documentation of attributes (#1315).
+ + Clarified documentation on small caps (#1360).
+ + Better documentation for `fenced_code_attributes` extension
+ (Caleb McDaniel).
+ + Documented fact that you can put YAML metadata in a separate file
+ (#1412).
+
+
+pandoc (1.12.4.2)
+
+ * Require highlighting-kate >= 0.5.8. Fixes a performance regression.
+
+ * Shared: `addMetaValue` now behaves slightly differently:
+ if both the new and old values are lists, it concatenates their
+ contents to form a new list.
+
+ * LaTeX reader:
+
+ + Set `bibliography` in metadata from `\bibliography` or
+ `\addbibresource` command.
+ + Don't error on `%foo` with no trailing newline.
+
+ * Org reader:
+
+ + Support code block headers (`#+BEGIN_SRC ...`) (Albert Krewinkel).
+ + Fix parsing of blank lines within blocks (Albert Krewinkel).
+ + Support pandoc citation extension (Albert Krewinkel). This can
+ be turned off by specifying `org-citations` as the input format.
+
+ * Markdown reader:
+
+ + `citeKey` moved to `Text.Pandoc.Parsing` so it can be used by
+ other readers (Albert Krewinkel).
+
+ * `Text.Pandoc.Parsing`:
+
+ + Added `citeKey` (see above).
+ + Added `HasLastStrPosition` type class and `updateLastStrPos`
+ and `notAfterString` functions.
+
+ * Updated copyright notices (Albert Krewinkel).
+
+ * Added default.icml to data files so it installs with the package.
+
+ * OSX package:
+
+ + The binary is now built with options to ensure that it can be
+ used with OSX 10.6+.
+ + Moved OSX package materials to osx directory.
+ + Added OSX package uninstall script, included in the zip container
+ (thanks to Daniel T. Staal).
+
+pandoc (1.12.4)
+
+ * Made it possible to run filters that aren't executable (#1096).
+ Pandoc first tries to find the executable (searching the path
+ if path isn't given). If it fails, but the file exists and has
+ a `.py`, `.pl`, `.rb`, `.hs`, or `.php` extension, pandoc runs the filter
+ using the appropriate interpreter. This should make it easier to
+ use filters on Windows, and make it more convenient for everyone.
+
+ * Added Emacs org-mode reader (Albert Krewinkel).
+
+ * Added InDesign ICML Writer (Mauro Bieg).
+
+ * MediaWiki reader:
+
+ + Accept image links in more languages (Jaime Marquínez Ferrándiz).
+ + Fixed bug in certain nested lists (#1213). If a level 2 list was
+ followed by a level 1 list, the first item of the level 1 list
+ would be lost.
+ + Handle table rows containing just an HTML comment (#1230).
+
+ * LaTeX reader:
+
+ + Give better location information on errors, pointing to line
+ numbers within included files (#1274).
+ + LaTeX reader: Better handling of `table` environment (#1204).
+ Positioning options no longer rendered verbatim.
+ + Better handling of figure and table with caption (#1204).
+ + Handle `@{}` and `p{length}` in tabular. The length is not actually
+ recorded, but at least we get a table (#1180).
+ + Properly handle `\nocite`. It now adds a `nocite` metadata
+ field. Citations there will appear in the bibliography but not
+ in the text (unless you explicitly put a `$nocite$` variable
+ in your template).
+
+ * Markdown reader:
+
+ + Ensure that whole numbers in YAML metadata are rendered without
+ decimal points. (This became necessary with changes to aeson
+ and yaml libraries. aeson >= 0.7 and yaml >= 0.8.8.2 are now required.)
+ + Fixed regression on line breaks in strict mode (#1203).
+ + Small efficiency improvements.
+ + Improved parsing of nested `div`s. Formerly a closing `div` tag
+ would be missed if it came right after other block-level tags.
+ + Avoid backtracking when closing `</div>` not found.
+ + Fixed bug in reference link parsing in `markdown_mmd`.
+ + Fixed a bug in list parsing (#1154). When reading a raw list
+ item, we now strip off up to 4 spaces.
+ + Fixed parsing of empty reference link definitions (#1186).
+ + Made one-column pipe tables work (#1218).
+
+ * Textile reader:
+
+ + Better support for attributes. Instead of being ignored, attributes
+ are now parsed and included in Span inlines. The output will be a bit
+ different from stock textile: e.g. for `*(foo)hi*`, we'll get
+ `<em><span class="foo">hi</span></em>` instead of
+ `<em class="foo">hi</em>`. But at least the data is not lost.
+ + Improved treatment of HTML spans (%) (#1115).
+ + Improved link parsing. In particular we now pick up on attributes.
+ Since pandoc links can't have attributes, we enclose the whole link in
+ a span if there are attributes (#1008).
+ + Implemented correct parsing rules for inline markup (#1175, Matthew
+ Pickering).
+ + Use Builder (Matthew Pickering).
+ + Fixed list parsing bug (#1500).
+ + Don't allow inline formatting to extend over newlines.
+ This matches the behavior of RedCarpet, avoids some ugly bugs,
+ and improves performance.
+
+ * DocBook reader:
+
+ + Better treatment of `formalpara`. We now emit the title (if present)
+ as a separate paragraph with boldface text (#1215).
+ + Set metadata `author` not `authors`.
+ + Added recognition of `authorgroup` and `releaseinfo` elements (#1214,
+ Matthew Pickering).
+ + Converted current meta information parsing in DocBook to a more
+ extensible version which is aware of the more recent meta
+ representation (Matthew Pickering).
+
+ * HTML reader:
+
+ + Require tagsoup 0.13.1, to fix a bug with parsing of script tags
+ (#1248).
+ + Treat processing instructions & declarations as block. Previously
+ these were treated as inline, and included in paragraph tags in HTML
+ or DocBook output, which is generally not what is wanted (#1233).
+ + Updated `closes` with rules from HTML5 spec.
+ + Use Builder (Matthew Pickering, #1162).
+
+ * RST reader:
+
+ + Remove duplicate `http` in PEP links (Albert Krewinkel).
+ + Make rst figures true figures (#1168, CasperVector)
+ + Enhanced Pandoc's support for rST roles (Merijn Verstaaten).
+ rST parser now supports: all built-in rST roles, new role definition,
+ role inheritance, though with some limitations.
+ + Use `author` rather than `authors` in metadata.
+ + Better handling of directives. We now correctly handle field
+ lists that are indented more than three spaces. We treat an
+ `aafig` directive as a code block with attributes, so it can be
+ processed in a filter (#1212).
+
+ * LaTeX writer:
+
+ + Mark span contents with label if span has an ID (Albert Krewinkel).
+ + Made `--toc-depth` work well with books in latex/pdf output (#1210).
+ + Handle line breaks in simple table cells (#1217).
+ + Workaround for level 4-5 headers in quotes. These previously produced
+ invalid LaTeX: `\paragraph` or `\subparagraph` in a `quote` environment.
+ This adds an `mbox{}` in these contexts to work around the problem.
+ See <http://tex.stackexchange.com/a/169833/22451> (#1221).
+ + Use `\/` to avoid en-dash ligature instead of `-{}-` (Vaclav Zeman).
+ This is to fix LuaLaTeX output. The `-{}-` sequence does not avoid the
+ ligature with LuaLaTeX but `\/` does.
+ + Fixed string escaping in `hyperref` and `hyperdef` (#1130).
+
+ * ConTeXt writer: Improved autolinks (#1270).
+
+ * DocBook writer:
+
+ + Improve handling of hard line breaks in Docbook writer
+ (Neil Mayhew). Use a `<literallayout>` for the entire paragraph, not
+ just for the newline character.
+ + Don't let line breaks inside footnotes influence the enclosing
+ paragraph (Neil Mayhew).
+ + Distinguish tight and loose lists in DocBook output, using
+ `spacing="compact"` (Neil Mayhew, #1250).
+
+ * Docx writer: When needed files are not present in the user's
+ `reference.docx`, fall back on the versions in the `reference.docx`
+ in pandoc's data files. This fixes a bug that occurs when a
+ `reference.docx` saved by LibreOffice is used. (#1185)
+
+ * EPUB writer:
+
+ + Include extension in epub ids. This fixes a problem with duplicate
+ extensions for fonts and images with the same base name but different
+ extensions (#1254).
+ + Handle files linked in raw `img` tags (#1170).
+ + Handle media in `audio` source tags (#1170).
+ Note that we now use a `media` directory rather than `images`.
+ + Incorporate files linked in `video` tags (#1170). `src` and `poster`
+ will both be incorporated into `content.opf` and the epub container.
+
+ * HTML writer:
+
+ + Add colgroup around col tags (#877). Also affects EPUB writer.
+ + Fixed bug with unnumbered section headings. Unnumbered section
+ headings (with class `unnumbered`) were getting numbers.
+ + Improved detection of image links. Previously image links with
+ queries were not recognized, causing `<embed>` to be used instead
+ of `<img>`.
+
+ * Man writer: Ensure that terms in definition lists aren't line wrapped
+ (#1195).
+
+ * Markdown writer:
+
+ + Use proper escapes to avoid unwanted lists (#980). Previously we used
+ 0-width spaces, an ugly hack.
+ + Use longer backtick fences if needed (#1206). If the content contains a
+ backtick fence and there are attributes, make sure longer fences are
+ used to delimit the code. Note: This works well in pandoc, but github
+ markdown is more limited, and will interpret the first string of three
+ or more backticks as ending the code block.
+
+ * RST writer: Avoid stack overflow with certain tables (#1197).
+
+ * RTF writer: Fixed table cells containing paragraphs.
+
+ * Custom writer:
+
+ + Correctly handle UTF-8 in custom lua scripts (#1189).
+ + Fix bugs with lua scripts with mixed-case filenames and
+ paths containing `+` or `-` (#1267). Note that `getWriter`
+ in `Text.Pandoc` no longer returns a custom writer on input
+ `foo.lua`.
+
+ * AsciiDoc writer: Handle multiblock and empty table cells
+ (#1245, #1246). Added tests.
+
+ * `Text.Pandoc.Options`: Added `readerTrace` to `ReaderOptions`
+
+ * `Text.Pandoc.Shared`:
+
+ + Added `compactify'DL` (formerly in markdown reader) (Albert Krewinkel).
+ + Fixed bug in `toRomanNumeral`: numbers ending with '9' would
+ be rendered as Roman numerals ending with 'IXIV' (#1249). Thanks to
+ Jesse Rosenthal.
+ + `openURL`: set proxy with value of http_proxy env variable (#1211).
+ Note: proxies with non-root paths are not supported, due to
+ limitations in `http-conduit`.
+
+ * `Text.Pandoc.PDF`:
+
+ + Ensure that temp directories deleted on Windows (#1192). The PDF is
+ now read as a strict bytestring, ensuring that process ownership will
+ be terminated, so the temp directory can be deleted.
+ + Use `/` as path separators in a few places, even on Windows.
+ This seems to be necessary for texlive (#1151, thanks to Tim Lin).
+ + Use `;` for `TEXINPUTS` separator on Windows (#1151).
+ + Changes to error reporting, to handle non-UTF8 error output.
+
+ * `Text.Pandoc.Templates`:
+
+ + Removed unneeded datatype context (Merijn Verstraaten).
+
+ + YAML objects resolve to "true" in conditionals (#1133).
+ Note: If `address` is a YAML object and you just have `$address$`
+ in your template, the word `true` will appear, which may be
+ unexpected. (Previously nothing would appear.)
+
+ * `Text.Pandoc.SelfContained`:
+
+ + `mkSelfContained` now takes just two arguments, `WriterOptions` and
+ the string.
+ * It no longer looks in data files. This only made sense when we
+ had copies of slidy and S5 code there.
+ * `fetchItem'` is used instead of the nearly duplicate `getItem`.
+ + Handle `poster` attribute in `video` tags (#1188).
+
+ * `Text.Pandoc.Parsing`:
+
+ + Made `F` an instance of Applicative (#1138).
+ + Added `stateCaption`.
+ + Added `HasMacros`, simplified other typeclasses.
+ Removed `updateHeaderMap`, `setHeaderMap`, `getHeaderMap`,
+ `updateIdentifierList`, `setIdentifierList`, `getIdentifierList`.
+ + Changed the smart punctuation parser to return `Inlines`
+ rather than `Inline` (Matthew Pickering).
+ + Changed `HasReaderOptions`, `HasHeaderMap`, `HasIdentifierList`
+ from typeclasses of monads to typeclasses of states. This simplifies
+ the instance definitions and provides more flexibility. Generalized
+ type of `getOption` and added a default definition. Removed
+ `askReaderOption`. Added `extractReaderOption`. Added
+ `extractHeaderMap` and `updateHeaderMap` in `HasHeaderMap`.
+ Gave default definitions for `getHeaderMap`, `putHeaderMap`,
+ `modifyHeaderMap`. Added `extractIdentifierList` and
+ `updateIdentifierList` in `HasIdentifierList`. Gave defaults
+ for `getIdentifierList`, `putIdentifierList`, and
+ `modifyIdentifierList`. The ultimate goal here is to allow different
+ parsers to use their own, tailored parser states (instead of
+ `ParserState`) while still using shared functions.
+
+ * Template changes:
+
+ + LaTeX template: Use `fontenc` package only with `pdflatex` (#1164).
+ + LaTeX template: Add `linestretch` and `fontfamily` variables.
+ + LaTeX template: Conditionalize author and date commands.
+ + Beamer template: Consistent styles for figure and table captions
+ (aaronwolen).
+ + LaTeX and beamer template: Adjust widths correctly for oversized
+ images. Use `\setkeys{Gin}{}` to set appropriate defaults for
+ `\includegraphics` (Yihui Xie, Garrick Aden-Buie). Load
+ `upquote` only after `fontenc` (Yihui Xie).
+ + Beamer template: Added caption package (#1200).
+ + Beamer template: changes for better unicode handling (KarolS).
+ + DocBook template: use `authorgroup` if there are authors.
+ + revealjs template: Move `include-after` to end (certainlyakey).
+ + revealjs template: Fixed PDF print function (#1220, kevinkenan).
+
+ * Bumped version bounds of dependencies.
+
+ * Added a `--trace` command line option, for debugging backtracking
+ bugs. So far this only works with the markdown reader.
+
+ * MathMLinHTML: Fixed deprecation warning (#362, gwern, Albert Krewinkel).
+
+ * Updated travis script to test with multiple GHC versions.
+
+ * Force failure of a Travis build if GHC produces warnings (Albert
+ Krewinkel).
+
+ * Add `.editorconfig` (Albert Krewinkel).
+ See <http://editorconfig.org/> for details.
+
+ * Give more useful error message if '-t pdf' is specified (#1155).
+
+ * Added `Cite`, `SmallCaps` to `Arbitrary` instance (#1269).
+
+ * Allow `html4` as a synonym of `html` as a reader (it already works
+ as a writer).
+
+ * README:
+
+ + Added an explanation of how to use YAML metadata to
+ force items to appear in the bibliography without citations in
+ the text (like LaTeX `\nocite`).
+ + Added note to `--bibtex/--natbib`: not for use in making PDF
+ (#1194, thanks to nahoj).
+ + Added explanatory notes about `--natbib` and `--biblatex`.
+ + Added specification of legal syntax for citation keys.
+ + Fixed variable defaults documentation (Albert Krewinkel).
+
+ * Removed copyright statements for files that have been removed
+ (Albert Krewinkel).
+
+ * Moved some doc files from `data-files` to `extra-source-files` (#1123).
+ They aren't needed at runtime. We keep README and COPYRIGHT in data
+ to ensure that they'll be available on all systems on which pandoc
+ is installed.
+
+ * Use cabal sandboxes in Windows build script.
+
+pandoc (1.12.3.3)
+
+ * To changes to source; recompiled tarball with latest alex and
+ happy, so they will work with GHC 7.8.
+
+pandoc (1.12.3.2)
+
+ * Bumped version bounds for blaze-html, blaze-markup.
+
+ * ImageSize: Avoid use of lookAhead, which is not in binary >= 0.6
+ (#1124).
+
+ * Fixed mediawiki ordered list parsing (#1122).
+
+ * HTML reader: Fixed bug reading inline math with `$$` (#225).
+
+ * Added support for LaTeX style literate Haskell code blocks in rST
+ (Merijn Verstraaten).
+
+pandoc (1.12.3.1)
+
+ * Relaxed version constraint on binary, allowing the use of binary 0.5.
+
+pandoc (1.12.3)
+
+ * The `--bibliography` option now sets the `biblio-files` variable.
+ So, if you're using `--natbib` or `--biblatex`, you can just use
+ `--bibliography=foo.bib` instead of `-V bibliofiles=foo`.
+
+ * Don't run pandoc-citeproc filter if `--bibliography` is
+ used together with `--natbib` or `--biblatex` (Florian Eitel).
+
+ * Template changes:
+
+ + Updated beamer template to include booktabs.
+ + Added `abstract` variable to LaTeX template.
+ + Put `header-includes` after `title` in LaTeX template (#908).
+ + Allow use of `\includegraphics[size]` in beamer.
+ This just required porting a macro definition from the default
+ LaTeX template to the default beamer template.
+
+ * `reference.docx`: Include `FootnoteText` style.
+ Otherwise Word ignores the style, even when specified in the `pPr`.
+ (#901)
+
+ * `reference.odt`: Tidied `styles.xml`.
+
+ * Relaxed version bounds for dependencies.
+
+ * Added `withSocketsDo` around http conduit code in `openURL`,
+ so it works on Windows (#1080).
+
+ * Added `Cite` function to `sample.lua`.
+
+ * Markdown reader:
+
+ + Fixed regression in title blocks (#1089).
+ If author field was empty, date was being ignored.
+ + Allow backslash-newline hard line breaks in grid and
+ multiline table cells.
+ + Citation keys may now start with underscores, and may contain
+ underscores adjacent to internal punctuation.
+
+ * LaTeX reader:
+
+ + Add support for `Verb` macro (jrnold) (#1090).
+ + Support babel-style quoting: `` "`..."' ``.
+
+ * Properly handle script blocks in strict mode. (That is,
+ `markdown-markdown_in_html_blocks`.) Previously a spurious
+ `<p>` tag was being added (#1093).
+
+ * Docbook reader: Avoid failure if `tbody` contains no `tr` or `row`
+ elements.
+
+ * LaTeX writer:
+
+ + Factored out function for table cell creation.
+ + Better treatment of footnotes in tables.
+ Notes now appear in the regular sequence, rather than in the
+ table cell. (This was a regression in 1.10.)
+
+ * HTML reader: Parse name/content pairs from meta tags as metadata.
+ Closes #1106.
+
+ * Moved `fixDisplayMath` from Docx writer to `Writer.Shared`.
+
+ * OpenDocument writer: Fixed `RawInline`, `RawBlock` so they don't escape.
+
+ * ODT writer: Use mathml for proper rendering of formulas.
+ Note: LibreOffice's support for this seems a bit buggy. But
+ it should be better than what we had before.
+
+ * RST writer: Ensure no blank line after def in definition list (#992).
+
+ * Markdown writer: Don't use tilde code blocks with braced attributes in
+ `markdown_github` output. A consequence of this change is that the
+ backtick form will be preferred in general if both are enabled. That
+ is good, as it is much more widespread than the tilde form. (#1084)
+
+ * Docx writer: Fixed problem with some modified reference docx files.
+ Include `word/_rels/settings.xml.rels` if it exists, as well as other
+ `rels` files besides the ones pandoc generates explicitly.
+
+ * HTML writer:
+
+ + With `--toc`, headers no longer link to themselves (#1081).
+ + Omit footnotes from TOC entries. Otherwise we get doubled
+ footnotes when headers have notes!
+
+ * EPUB writer:
+
+ + Avoid duplicate notes when headings contain notes.
+ This arose because the headings are copied into the metadata
+ "title" field, and the note gets rendered twice. We strip the
+ note now before putting the heading in "title".
+ + Strip out footnotes from toc entries.
+ + Fixed bug with `--epub-stylesheet`. Now the contents of
+ `writerEpubStylesheet` (set by `--epub-stylesheet`)
+ should again work, and take precedence over a stylesheet specified
+ in the metadata.
+
+ * `Text.Pandoc.MIME`: Added `wmf`, `emf`.
+
+ * `Text.Pandoc.Shared`: `fetchItem` now handles image URLs beginning
+ with `//`.
+
+ * `Text.Pandoc.ImageSize`: Parse EXIF format JPEGs. Previously
+ we could only get size information for JFIF format, which led
+ to squished images in Word documents. Closes #976.
+
+ * Removed old `MarkdownTest_1.0.3` directory (#1104).
+
+pandoc (1.12.2.1)
+
+ * Markdown reader: Fixed regression in list parser, involving
+ continuation lines containing raw HTML (or even verbatim raw HTML).
+
+pandoc (1.12.2)
+
+ * Metadata may now be included in YAML blocks in a markdown document.
+ For example,
+
+ ---
+ title:
+ - type: main
+ text: My Book
+ - type: subtitle
+ text: An investigation of metadata
+ creator:
+ - role: author
+ text: John Smith
+ - role: editor
+ text: Sarah Jones
+ identifier:
+ - scheme: DOI
+ text: doi:10.234234.234/33
+ publisher: My Press
+ rights: (c) 2007 John Smith, CC BY-NC
+ cover-image: img/mypic.jpg
+ ...
+
+ Metadata may still be provided using `--epub-metadata`; it will
+ be merged with the metadata in YAML blocks.
+
+ * EPUB writer:
+
+ + `meta` tags are now used instead of `opf` attributes for EPUB3.
+ + Insert "svg" property as needed in opf (EPUB 3).
+ + Simplify `imageTypeOf` using `getMimeType`.
+ + Add properties attribute to `cover-image` item for EPUB 3.
+ + Don't include node for `cover.xhtml` if no cover!
+ + Ensure that same identifier is used throughout (#1044).
+ If an identifier is given in metadata, we use that; otherwise
+ we generate a random uuid.
+ + Add cover reference to guide element (EPUB 2) (Shaun Attfield).
+ Fixes an issue with Calibre putting the cover at the end of the book
+ if the spine has `linear="no"`. Apparently this is best practice
+ for other converters as well:
+ <http://www.idpf.org/epub/20/spec/OPF_2.0.1_draft.htm#Section2.6>.
+ + Allow `stylesheet` in metadata. The value is a path to the stylesheet.
+ + Allow partial dates: `YYYY`, `YYYY-MM`.
+
+ * Markdown writer: Fix rendering of tight sublists (#1050).
+ Previously a spurious blank line was included after a tight sublist.
+
+ * ODT writer: Add `draw:name` attribute to `draw:frame` elements (#1069).
+ This is reported to be necessary to avoid an error from recent
+ versions of Libre Office when files contain more than one image
+ Thanks to wmanley for reporting and diagnosing the problem.
+
+ * ConTeXt writer: Don't hardcode figure/table placement and numbering.
+ Instead, let this be set in the template, using `\setupfloat`.
+ Thanks to on4aa and Aditya Mahajan for the suggestion (#1067).
+
+ * Implemented CSL flipflopping spans in DOCX, LaTeX, and HTML writers.
+
+ * Fixed bug with markdown intraword emphasis. Closes #1066.
+
+ * Docbook writer: Hierarchicalize block content in metadata.
+ Previously headers just disappeared from block-level metadata
+ when it was used in templates. Now we apply the 'hierarchicalize'
+ transformation. Note that a block headed by a level-2 header will
+ turn into a `<sect1>` element.
+
+ * OpenDocument writer: Skip raw HTML (#1035).
+ Previously it was erroneously included as verbatim text.
+
+ * HTML/EPUB writer, footnotes: Put `<sup>` tag inside `<a>` tags.
+ This allows better control of formatting, since the `<a>`
+ tags have a distinguishing class (#1049).
+
+ * Docx writer:
+
+ + Use mime type info returned by fetchItem.
+ + Fixed core metadata (#1046).
+ Don't create empty date nodes if no date given.
+ Don't create multiple `dc:creator` nodes; instead separate by
+ semicolons.
+ + Fix URL for core-properties in `_rels/.rels` (#1046).
+
+ * Plain writer: don't print `<span>` tags.
+
+ * LaTeX writer:
+
+ + Fix definition lists with internal links in terms (#1032).
+ This fix puts braces around a term that contains an internal
+ link, to avoid problems with square brackets.
+ + Properly escape pdftitle, pdfauthor (#1059).
+ + Use booktabs package for tables (thanks to Jose Luis Duran).
+
+ * Updated beamer template. Now references should work properly
+ (in a slide) when `--biblatex` or `--natbib` is used.
+
+ * LaTeX reader:
+
+ + Parse contents of curly quotes or matched `"` as quotes.
+ + Support `\textnormal` as span with class `nodecor`.
+ This is needed for pandoc-citeproc.
+ + Improved citation parsing. This fixes a run-time error that occured
+ with `\citet{}` (empty list of keys). It also ensures that empty keys
+ don't get produced.
+
+ * MediaWiki reader: Add automatic header identifiers.
+
+ * HTML reader:
+
+ + Use pandoc `Div` and `Span` for raw `<div>`, `<span>` when
+ `--parse-raw`.
+ + Recognize `svg` tags as block level content (thanks to MinRK).
+ + Parse LaTeX math if appropriate options are set.
+
+ * Markdown reader:
+
+ + Yaml block must start immediately after `---`. If there's a blank
+ line after `---`, we interpreted it as a horizontal rule.
+ + Correctly handle empty bullet list items.
+ + Stop parsing "list lines" when we hit a block tag.
+ This fixes exponential slowdown in certain input, e.g.
+ a series of lists followed by `</div>`.
+
+ * Slides: Preserve `<div class="references">` in references slide.
+
+ * `Text.Pandoc.Writer.Shared`:
+
+ + Fixed bug in `tagWithAttrs`. A space was omitted before key-value
+ attributes, leading to invalid HTML.
+ + `normalizeDate`: Allow dates with year only (thanks to Shaun Attfield).
+ + Fixed bug in `openURL` with `data:` URIs. Previously the base-64
+ encoded bytestring was returned. We now decode it so it's a proper
+ image!
+
+ * DocBook reader: Handle numerical attributes starting with decimal.
+ Also use `safeRead` instead of `read`.
+
+ * `Text.Pandoc.Readers.TexMath`: Export `readTeXMath'`, which attends
+ to display/inline. Deprecate `readTeXMath`, and use `readTeXMath'`
+ in all the writers. Require `texmath >= 0.6.5.2`.
+
+ * `Text.Pandoc.MIME`:
+
+ + Add entry for `jfif`.
+ + In looking up extensions, drop the encoding info.
+ E.g. for 'image/jpg;base64' we should lookup 'image/jpg'.
+
+ * Templates: Changed how array variables are resolved. Previously if
+ `foo` is an array (which might be because multiple values were set on
+ the command line), `$foo$` would resolve to the concatenation of the
+ elements of foo. This is rarely useful behavior. It has been changed
+ so that the first value is rendered. Of course, you can still iterate
+ over the values using `$for(foo)$`. This has the result that you can
+ override earlier settings using `-V` by putting new values later on the
+ command line, which is useful for many purposes.
+
+ * `Text.Pandoc`: Don't default to `pandocExtensions` for all writers.
+
+ * Allow "epub2" as synonym for "epub", "html4" for "html".
+
+ * Don't look for slidy files in data files with `--self-contained`.
+
+ * Allow `https:` command line arguments to be downloaded.
+
+ * Fixed `make_osx_package.sh` so data files embedded in `pandoc-citeproc`.
+
+pandoc (1.12.1)
+
+ * `Text.Pandoc.Definition`: Changed default JSON serialization format.
+ Instead of `{"Str": "foo"}`, for example, we now have `{"t": "Str",
+ "c": "foo"}`. This new format is easier to work with outside of Haskell.
+ Incidentally, "t" stands for "tag", "c" for "contents".
+
+ * MediaWiki reader: Trim contents of `<math>` tags, to avoid problems
+ when converting to markdown (#1027).
+
+ * LaTeX reader:
+
+ + Ensure that preamble doesn't contribute to the text of
+ the document.
+ + Fixed character escaping in \url{}. Previously `\~` wasn't handled
+ properly, among others.
+ + Parse `{groups}` as `Span`. This is needed for accurate conversion of
+ bibtex titles, since we need to know what was protected from
+ titlecase conversions.
+
+ * LaTeX writer:
+
+ + Specially escape non-ascii characters in labels.
+ Otherwise we can get compile errors and other bugs when
+ compiled with pdflatex (#1007). Thanks to begemotv2718 for the fix.
+ + Add link anchors for code blocks with identifiers (#1025).
+
+ * Throughout the code, use `isURI` instead of `isAbsoluteURI`.
+ It allows fragments identifiers.
+
+ * Slide formats:
+
+ + A Div element with class "notes" is treated as speaker
+ notes. Currently beamer goes to `\note{}`, revealjs to
+ `<aside class="notes">`, and the notes are simply suppressed in
+ other formats (#925).
+ + Fixed `. . .` (pause) on HTML slide formats. Closes #1029.
+ The old version caused a pause to be inserted before the first
+ material on a slide. This has been fixed.
+ + Removed data files for s5, slideous, slidy.
+ Users of s5 and slideous will have to download the needed
+ files, as has been documented for some time in the README.
+ By default, slidy code will be sought on the web, as before.
+
+ * HTML writer: Insert command to typeset mathjax only in slideous output
+ (#966, #1012).
+
+ * RST writer: Skip spaces after display math. Otherwise we get indentation
+ problems, and part of the next paragraph may be rendered as part of the
+ math.
+
+ * OpenDocument writer: Fix formatting of strikeout code (#995),
+ thanks to wilx. don't use `font-face-decls` variable.
+
+ * Fixed test suite so it works with cabal sandboxes.
+
+pandoc (1.12.0.2)
+
+ * Removed `stringable` dependency.
+
+pandoc (1.12.0.1)
+
+ * Allow `--metadata` to be repeated for the same key to form a list.
+ This also has the effect that `--bibliography` can be repeated,
+ as before.
+
+ * Handle boolean values in `--metadata`. Note that anything not parseable
+ as a YAML boolean or string is treated as a literal string.
+ You can get a string value with "yes", or any of the strings interpretable
+ as booleans, by quoting it:
+
+ -M boolvalue=yes -M stringvalue='"yes"'
+
+ * LaTeX writer: Don't print references if `--natbib` or `--biblatex`
+ option used.
+
+ * DOCX writer: Add `settings.xml` to the zip container. Fixes a bug
+ in which docx files could not be read by some versions of Word
+ and LibreOffice (#990).
+
+ * Fixed a regression involving slide shows with bibliographies.
+ The Div container around references messed up the procedure for carving
+ a document into slides. So we now remove the surrounding Div in
+ `prepSlides`.
+
+ * More informative error message when a filter is not found in path.
+
+ * Depend on pandoc-types 1.12.1. This provide `ToJSONFilter`
+ instances for `Data a => a -> [a]` and `Data a => a -> IO [a]`.
+
+ * Don't use unicode_collation in building OSX package:
+ it adds something like 50MB of dependencies to the package.
+
+ * Declare alex and happy as build-tools (#986).
+
+pandoc (1.12)
+
+ [new features]
+
+ * Much more flexible metadata, including arbitrary fields and structured
+ values. Metadata can be specified flexibly in pandoc markdown using
+ YAML metadata blocks, which may occur anywhere in the document:
+
+ ---
+ title: Here is my title.
+ abstract: |
+ This is the abstract.
+
+ 1. It can contain
+ 2. block content
+ and *inline markup*
+
+ tags: [cat, dog, animal]
+ ...
+
+ Metadata fields automatically populate template variables.
+
+ * Added `opml` (OPML) as input and output format. The `_note` attribute,
+ used in OmniOutliner and supported by multimarkdown, is supported.
+ We treat the contents as markdown blocks under a section header.
+
+ * Added `haddock` (Haddock markup) as input format (David Lazar).
+
+ * Added `revealjs` output format, for reveal.js HTML 5 slide shows.
+ (Thanks to Jamie F. Olson for the initial patch.)
+ Nested vertical stacks are used for hierarchical structure.
+ Results for more than one level of nesting may be odd.
+
+ * Custom writers can now be written in lua.
+
+ pandoc -t data/sample.lua
+
+ will load the script sample.lua and use it as a custom writer.
+ (For a sample, do `pandoc --print-default-data-file sample.lua`.)
+ Note that pandoc embeds a lua interpreter, so lua need not be
+ installed separately.
+
+ * New `--filter/-F` option to make it easier to run "filters"
+ (Pandoc AST transformations that operate on JSON serializations).
+ Filters are always passed the name of the output format, so their
+ behavior can be tailored to it. The repository
+ <https://github.com/jgm/pandocfilters> contains
+ a python module for writing pandoc filters in python, with
+ a number of examples.
+
+ * Added `--metadata/-M` option.
+ This is like `--variable/-V`, but actually adds to metadata, not
+ just variables.
+
+ * Added `--print-default-data-file` option, which allows printing
+ of any of pandoc's data files. (For example,
+ `pandoc --print-default-data-file reference.odt` will print
+ `reference.odt`.)
+
+ * Added syntax for "pauses" in slide shows:
+
+ This gives
+
+ . . .
+
+ me pause.
+
+ * New markdown extensions:
+
+ + `ignore_line_breaks`: causes intra-paragraph line breaks to be ignored,
+ rather than being treated as hard line breaks or spaces. This is useful
+ for some East Asian languages, where spaces aren't used between words,
+ but text is separated into lines for readability.
+ + `yaml_metadata_block`: Parse YAML metadata blocks. (Default.)
+ + `ascii_identifiers`: This will force `auto_identifiers` to use ASCII
+ only. (Default for `markdown_github`.) (#807)
+ + `lists_without_preceding_blankline`: Allow lists to start without
+ preceding blank space. (Default for `markdown_github`.) (#972)
+
+ [behavior changes]
+
+ * `--toc-level` no longer implies `--toc`.
+ Reason: EPUB users who don't want a visible TOC may still want
+ to set the TOC level for in the book navigation.
+
+ * `--help` now prints in and out formats in alphabetical order, and
+ says something about PDF output (#720).
+
+ * `--self-contained` now returns less verbose output (telling you
+ which URLs it is fetching, but not giving the full header). In
+ addition, there are better error messages when fetching a URL fails.
+
+ * Citation support is no longer baked in to core pandoc. Users who
+ need citations will need to install and use a separate filter
+ (`--filter pandoc-citeproc`). This filter will take `bibliography`,
+ `csl`, and `citation-abbreviations` from the metadata, though it
+ may still be specified on the command line as before.
+
+ * A `Cite` element is now created in parsing markdown whether or not
+ there is a matching reference.
+
+ * The `pandoc-citeproc` script will put the bibliography at the
+ end of the document, as before. However, it will be put inside a `Div`
+ element with class "references", allowing users some control
+ over the styling of references. A final header, if any, will
+ be included in the `Div`.
+
+ * The markdown writer will not print a bibliography if the
+ `citations` extension is enabled. (If the citations are formatted
+ as markdown citations, it is redundant to have a bibliography,
+ since one will be generated automatically.)
+
+ * Previously we used to store the directory of the first input file,
+ even if it was local, and used this as a base directory for finding
+ images in ODT, EPUB, Docx, and PDF. This has been confusing to many
+ users. So we now look for images relative to the current
+ working directory, even if the first file argument is in another
+ directory. Note that this change may break some existing workflows.
+ If you have been assuming that relative links will be interpreted
+ relative to the directory of the first file argument, you'll need
+ to make that the current directory before running pandoc. (#942)
+
+ * Better error reporting in some readers, due to changes in `readWith`:
+ the line in which the error occured is printed, with a caret pointing
+ to the column.
+
+ * All slide formats now support incremental slide view for definition lists.
+
+ * Parse `\(..\)` and `\[..\]` as math in MediaWiki reader.
+ Parse `:<math>...</math>` as display math. These notations are used with
+ the MathJax MediaWiki extension.
+
+ * All writers: template variables are set automatically from metadata
+ fields. However, variables specified on the command line with
+ `--variable` will completely shadow metadata fields.
+
+ * If `--variable` is used to set many variables with the same name,
+ a list is created.
+
+ * Man writer: The `title`, `section`, `header`, and `footer` can now
+ all be set individually in metadata. The `description` variable has been
+ removed. Quotes have been added so that spaces are allowed in the
+ title. If you have a title that begins
+
+ COMMAND(1) footer here | header here
+
+ pandoc will still parse it into a title, section, header, and
+ footer. But you can also specify these elements explicitly (#885).
+
+ * Markdown reader
+
+ + Added support for YAML metadata blocks, which can come anywhere
+ in the document (not just at the beginning). A document can contain
+ multiple YAML metadata blocks.
+ + HTML span and div tags are parsed as pandoc Span and Div elements.
+
+ * Markdown writer
+
+ + Allow simple tables to be printed as grid tables,
+ if other table options are disabled. This means you can do
+ `pandoc -t markdown-pipe_tables-simple_tables-multiline_tables`
+ and all tables will render as grid tables.
+ + Support YAML title block (render fields in alphabetical order
+ to make output predictable).
+
+ [API changes]
+
+ * `Meta` in `Text.Pandoc.Definition` has been changed to allow
+ structured metadata. (Note: existing code that pattern-matches
+ on `Meta` will have to be revised.) Metadata can now contain
+ indefinitely many fields, with content that can be a string,
+ a Boolean, a list of `Inline` elements, a list of `Block`
+ elements, or a map or list of these.
+
+ * A new generic block container (`Div`) has been added to `Block`,
+ and a generic inline container (`Span`) has been added to `Inline`.
+ These can take attributes. They will render in HTML, Textile,
+ MediaWiki, Org, RST and and Markdown (with `markdown_in_html`
+ extension) as HTML `<div>` and `<span>` elements; in other formats
+ they will simply pass through their contents. But they can be
+ targeted by scripts.
+
+ * `Format` is now a newtype, not an alias for String.
+ Equality comparisons are case-insensitive.
+
+ * Added `Text.Pandoc.Walk`, which exports hand-written tree-walking
+ functions that are much faster than the SYB functions from
+ `Text.Pandoc.Generic`. These functions are now used where possible
+ in pandoc's code. (`Tests.Walk` verifies that `walk` and `query`
+ match the generic traversals `bottomUp` and `queryWith`.)
+
+ * Added `Text.Pandoc.JSON`, which provides `ToJSON` and `FromJSON`
+ instances for the basic pandoc types. They use GHC generics and
+ should be faster than the old JSON serialization using
+ `Data.Aeson.Generic`.
+
+ * Added `Text.Pandoc.Process`, exporting `pipeProcess`.
+ This is a souped-up version of `readProcessWithErrorcode` that
+ uses lazy bytestrings instead of strings and allows setting
+ environment variables. (Used in `Text.Pandoc.PDF`.)
+
+ * New module `Text.Pandoc.Readers.OPML`.
+
+ * New module `Text.Pandoc.Writers.OPML`.
+
+ * New module `Text.Pandoc.Readers.Haddock` (David Lazar).
+ This is based on Haddock's own lexer/parser.
+
+ * New module `Text.Pandoc.Writers.Custom`.
+
+ * In `Text.Pandoc.Shared`, `openURL` and `fetchItem` now return an
+ Either, for better error handling.
+
+ * Made `stringify` polymorphic in `Text.Pandoc.Shared`.
+
+ * Removed `stripTags` from `Text.Pandoc.XML`.
+
+ * `Text.Pandoc.Templates`:
+
+ + Simplified `Template` type to a newtype.
+ + Removed `Empty`.
+ + Changed type of `renderTemplate`: it now takes a JSON context
+ and a compiled template.
+ + Export `compileTemplate`.
+ + Export `renderTemplate'` that takes a string instead of a compiled
+ template.
+ + Export `varListToJSON`.
+
+ * `Text.Pandoc.PDF` exports `makePDF` instead of `tex2pdf`.
+
+ * `Text.Pandoc`:
+
+ + Made `toJsonFilter` an alias for `toJSONFilter` from `Text.Pandoc.JSON`.
+ + Removed `ToJsonFilter` typeclass. `ToJSONFilter` from
+ `Text.Pandoc.JSON` should be used instead. (Compiling against
+ pandoc-types instead of pandoc will also produce smaller executables.)
+ * Removed the deprecated `jsonFilter` function.
+ + Added `readJSON`, `writeJSON` to the API (#817).
+
+ * `Text.Pandoc.Options`:
+
+ + Added `Ext_lists_without_preceding_blankline`,
+ `Ext_ascii_identifiers`, `Ext_ignore_line_breaks`,
+ `Ext_yaml_metadataBlock` to `Extension`.
+ + Changed `writerSourceDirectory` to `writerSourceURL` and changed the
+ type to a `Maybe`. `writerSourceURL` is set to 'Just url' when the
+ first command-line argument is an absolute URL. (So, relative links
+ will be resolved in relation to the first page.) Otherwise, 'Nothing'.
+ + All bibliography-related fields have been removed from
+ `ReaderOptions` and `WriterOptions`: `writerBiblioFiles`,
+ `readerReferences`, `readerCitationStyle`.
+
+ * The `Text.Pandoc.Biblio` module has been removed. Users of the
+ pandoc library who want citation support will need to use
+ `Text.CSL.Pandoc` from `pandoc-citeproc`.
+
+
+ [bug fixes]
+
+ * In markdown, don't autolink a bare URI that is followed by `</a>`
+ (#937).
+
+ * `Text.Pandoc.Shared`
+
+ + `openURL` now follows redirects (#701), properly handles `data:`
+ URIs, and prints diagnostic output to stderr rather than stdout.
+ + `readDefaultDataFile`: normalize the paths. This fixes bugs in
+ `--self-contained` on pandoc compiled with `embed_data_files` (#833).
+ + Fixed `readDefaultDataFile` so it works on Windows.
+ + Better error messages for `readDefaultDataFile`. Instead of
+ listing the last path tried, which can confuse people who are
+ using `--self-contained`, so now we just list the data file name.
+ + URL-escape pipe characters. Even though these are legal, `Network.URI`
+ doesn't regard them as legal in URLs. So we escape them first (#535).
+
+ * Mathjax in HTML slide shows: include explicit "Typeset" call.
+ This seems to be needed for some formats (e.g. slideous) and won't
+ hurt in others (#966).
+
+ * `Text.Pandoc.PDF`
+
+ + On Windows, create temdir in working directory, since the system
+ temp directory path may contain tildes, which can cause
+ problems in LaTeX (#777).
+ + Put temporary output directory in `TEXINPUTS` (see #917).
+ + `makePDF` tries to download images that are not found locally,
+ if the first argument is a URL (#917).
+ + If compiling with `pdflatex` yields an encoding error, offer
+ the suggestion to use `--latex-engine=xelatex`.
+
+ * Produce automatic header identifiers in parsing textile, RST,
+ and LaTeX, unless `auto_identifiers` extension is disabled (#967).
+
+ * `Text.Pandoc.SelfContained`: Strip off fragment, query of relative URL
+ before treating as a filename. This fixes `--self-contained` when used
+ with CSS files that include web fonts using the method described here:
+ <http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/>
+ (#739). Handle `src` in `embed`, `audio`, `source`, `input` tags.
+
+ * `Text.Pandoc.Parsing`: `uri` parser no longer treats punctuation before
+ percent-encoding, or a `+` character, as final punctuation.
+
+ * `Text.Pandoc.ImageSize`: Handle EPS (#903). This change will make
+ EPS images properly sized on conversion to Word.
+
+ * Slidy: Use slidy.js rather than slidy.js.gz.
+ Reason: some browsers have trouble with the gzipped js file,
+ at least on the local file system (#795).
+
+ * Markdown reader
+
+ + Properly handle blank line at beginning of input (#882).
+ + Fixed bug in unmatched reference links. The input
+ `[*infile*] [*outfile*]` was getting improperly parsed:
+ "infile" was emphasized, but "*outfile*" was literal (#883).
+ + Allow internal `+` in citation identifiers (#856).
+ + Allow `.` or `)` after `#` in ATX headers if no `fancy_lists`.
+ + Do not generate blank title, author, or date metadata elements.
+ Leave these out entirely if they aren't present.
+ + Allow backtick code blocks not to be preceded by blank line (#975).
+
+ * Textile reader:
+
+ + Correctly handle entities.
+ + Improved handling of `<pre>` blocks (#927). Remove internal HTML tags
+ in code blocks, rather than printing them verbatim. Parse attributes
+ on `<pre>` tag for code blocks.
+
+ * HTML reader: Handle non-simple tables (#893). Column widths are read from
+ `col` tags if present, otherwise divided equally.
+
+ * LaTeX reader
+
+ + Support alltt environment (#892).
+ + Support `\textasciitilde`, `\textasciicircum` (#810).
+ + Treat `\textsl` as emphasized text reader (#850).
+ + Skip positional options after `\begin{figure}`.
+ + Support `\v{}` for hacek (#926).
+ + Don't add spurious ", " to citation suffixes.
+ This is added when needed in pandoc-citeproc.
+ + Allow spaces in alignment spec in tables, e.g. `{ l r c }`.
+ + Improved support for accented characters (thanks to Scott Morrison).
+ + Parse label after section command and set id (#951).
+
+ * RST reader:
+
+ + Don't insert paragraphs where docutils doesn't.
+ `rst2html` doesn't add `<p>` tags to list items (even when they are
+ separated by blank lines) unless there are multiple paragraphs in the
+ list. This commit changes the RST reader to conform more closely to
+ what docutils does (#880).
+ + Improved metadata. Treat initial field list as metadata when
+ standalone specified. Previously ALL fields "title", "author",
+ "date" in field lists were treated as metadata, even if not at
+ the beginning. Use `subtitle` metadata field for subtitle.
+ + Fixed 'authors' metadata parsing in reST. Semicolons separate
+ different authors.
+
+ * MediaWiki reader
+
+ + Allow space before table rows.
+ + Fixed regression for `<ref>URL</ref>`.
+ `<` is no longer allowed in URLs, according to the uri parser
+ in `Text.Pandoc.Parsing`. Added a test case.
+ + Correctly handle indented preformatted text without preceding
+ or following blank line.
+ + Fixed `|` links inside table cells. Improved attribute parsing.
+ + Skip attributes on table rows. Previously we just crashed if
+ rows had attributes, now we ignore them.
+ + Ignore attributes on headers.
+ + Allow `Image:` for images (#971).
+ + Parse an image with caption in a paragraph by itself as a figure.
+
+ * LaTeX writer
+
+ + Don't use ligatures in escaping inline code.
+ + Fixed footnote numbers in LaTeX/PDF tables. This fixes a bug
+ wherein notes were numbered incorrectly in tables (#827).
+ + Always create labels for sections. Previously the labels were only
+ created when there were links to the section in the document (#871).
+ + Stop escaping `|` in LaTeX math.
+ This caused problems with array environments (#891).
+ + Change `\` to `/` in paths. `/` works even on Windows in LaTeX.
+ `\` will cause major problems if unescaped.
+ + Write id for code block to label attribute in LaTeX when listings
+ is used (thanks to Florian Eitel).
+ + Scale LaTeX tables so they don't exceed columnwidth.
+ + Avoid problem with footnotes in unnumbered headers (#940).
+
+ * Beamer writer: when creating beamer slides, add `allowframebreaks` option
+ to the slide if it is one of the header classes. It is recommended
+ that your bibliography slide have this attribute:
+
+ # References {.allowframebreaks}
+
+ This causes multiple slides to be created if necessary, depending
+ on the length of the bibliography.
+
+ * ConTeXt writer: Properly handle tables without captions. The old output
+ only worked in MkII. This should work in MkIV as well (#837).
+
+ * MediaWiki writer: Use native mediawiki tables instead of HTML (#720).
+
+ * HTML writer:
+
+ + Fixed `--no-highlight` (Alexander Kondratskiy).
+ + Don't convert to lowercase in email obfuscation (#839).
+ + Ensure proper escaping in `<title>` and `<meta>` fields.
+
+ * AsciiDoc writer:
+
+ + Support `--atx-headers` (Max Rydahl Andersen).
+ + Don't print empty identifier blocks `([[]])` on headers (Max
+ Rydahl Andersen).
+
+ * ODT writer:
+
+ + Fixing wrong numbered-list indentation in open document format
+ (Alexander Kondratskiy) (#369).
+ + `reference.odt`: Added pandoc as "generator" in `meta.xml`.
+ + Minor changes for ODF 1.2 conformance (#939). We leave the
+ nonconforming `contextual-spacing` attribute, which is provided by
+ LibreOffice itself and seems well supported.
+
+ * Docx writer:
+
+ + Fixed rendering of display math in lists.
+ In 1.11 and 1.11.1, display math in lists rendered as a new list
+ item. Now it always appears centered, just as outside of lists,
+ and in proper display math style, no matter how far indented the
+ containing list item is (#784).
+ + Use `w:br` with `w:type` `textWrapping` for linebreaks.
+ Previously we used `w:cr` (#873).
+ + Use Compact style for Plain block elements, to
+ differentiate between tight and loose lists (#775).
+ + Ignore most components of `reference.docx`.
+ We take the `word/styles.xml`, `docProps/app.xml`,
+ `word/theme/theme1.xml`, and `word/fontTable.xml` from
+ `reference.docx`, ignoring everything else. This should help
+ with the corruption problems caused when different versions of
+ Word resave the reference.docx and reorganize things.
+ + Made `--no-highlight` work properly.
+
+ * EPUB writer
+
+ + Don't add `dc:creator` tags if present in EPUB metadata.
+ + Add `id="toc-title"` to `h1` in `nav.xhtml` (#799).
+ + Don't put blank title page in reading sequence.
+ Set `linear="no"` if no title block. Addresses #797.
+ + Download webtex images and include as data URLs.
+ This allows you to use `--webtex` in creating EPUBs.
+ Math with `--webtex` is automatically made self-contained.
+ + In `data/epub.css`, removed highlighting styles (which
+ are no longer needed, since styles are added by the HTML
+ writer according to `--highlighting-style`). Simplified
+ margin fields.
+ + If resource not found, skip it, as in Docx writer (#916).
+
+ * RTF writer:
+
+ + Properly handle characters above the 0000-FFFF range.
+ Uses surrogate pairs. Thanks to Hiromi Ishii for the patch.
+ + Fixed regression with RTF table of contents.
+ + Only autolink absolute URIs. This fixes a regression, #830.
+
+ * Markdown writer:
+
+ + Only autolink absolute URIs. This fixes a regression, #830.
+ + Don't wrap attributes in fenced code blocks.
+ + Write full metadata in MMD style title blocks.
+ + Put multiple authors on separate lines in pandoc titleblock.
+ Also, don't wrap long author entries, as new lines get treated
+ as new authors.
+
+ * `Text.Pandoc.Templates`:
+
+ + Fixed bug retrieving default template for markdown variants.
+ + Templates can now contain "record lookups" in variables;
+ for example, `author.institution` will retrieve the `institution`
+ field of the `author` variable.
+ + More consistent behavior of `$for$`. When `foo` is not a list,
+ `$for(foo)$...$endfor$` should behave like $if(foo)$...$endif$.
+ So if `foo` resolves to "", no output should be produced.
+ See pandoc-templates#39.
+
+ * Citation processing improvements (now part of pandoc-citeproc):
+
+ + Fixed `endWithPunct` The new version correctly sees a sentence
+ ending in '.)' as ending with punctuation. This fixes a bug which
+ led such sentences to receive an extra period at the end: '.).'.
+ Thanks to Steve Petersen for reporting.
+ + Don't interfere with Notes that aren't citation notes.
+ This fixes a bug in which notes not generated from citations were
+ being altered (e.g. first letter capitalized) (#898).
+ + Only capitalize footnote citations when they have a prefix.
+ + Changes in suffix parsing. A suffix beginning with a digit gets 'p'
+ inserted before it before passing to citeproc-hs, so that bare numbers
+ are treated as page numbers by default. A suffix not beginning with
+ punctuation has a space added at the beginning (rather than a comma and
+ space, as was done before for not-author-in-text citations).
+ The result is that `\citep[23]{item1}` in LaTeX will be interpreted
+ properly, with '23' treated as a locator of type 'page'.
+ + Many improvements to citation rendering, due to fixes in citeproc-hs
+ (thanks to Andrea Rossato).
+ + Warnings are issued for undefined citations, which are rendered
+ as `???`.
+ + Fixed hanging behavior when locale files cannot be found.
+
+ [template changes]
+
+ * DocBook: Use DocBook 4.5 doctype.
+
+ * Org: '#+TITLE:' is inserted before the title.
+ Previously the writer did this.
+
+ * LaTeX: Changes to make mathfont work with xelatex.
+ We need the mathspec library, not just fontspec, for this.
+ We also need to set options for setmathfont (#734).
+
+ * LaTeX: Use `tex-ansi` mapping for `monofont`.
+ This ensures that straight quotes appear as straight, rather than
+ being treated as curly. See #889.
+
+ * Made `\includegraphics` more flexible in LaTeX template.
+ Now it can be used with options, if needed. Thanks to Bernhard Weichel.
+
+ * LaTeX/Beamer: Added `classoption` variable.
+ This is intended for class options like `oneside`; it may
+ be repeated with different options. (Thanks to Oliver Matthews.)
+
+ * Beamer: Added `fonttheme` variable. (Thanks to Luis Osa.)
+
+ * LaTeX: Added `biblio-style` variable (#920).
+
+ * DZSlides: title attribute on title section.
+
+ * HTML5: add meta tag to allow scaling by user (Erik Evenson)
+
+ [under-the-hood improvements]
+
+ * Markdown reader:Improved strong/emph parsing, using the strategy of
+ <https://github.com/jgm/Markdown>. The new parsing algorithm requires
+ no backtracking, and no keeping track of nesting levels. It will give
+ different results in some edge cases, but these should not affect normal
+ uses.
+
+ * Added `Text.Pandoc.Compat.Monoid`.
+ This allows pandoc to compile with `base` < 4.5, where `Data.Monoid`
+ doesn't export `<>`. Thanks to Dirk Ullirch for the patch.
+
+ * Added `Text.Pandoc.Compat.TagSoupEntity`.
+ This allows pandoc to compile with `tagsoup` 0.13.x.
+ Thanks to Dirk Ullrich for the patch.
+
+ * Most of `Text.Pandoc.Readers.TeXMath` has been moved to the
+ `texmath` module (0.6.4). (This allows `pandoc-citeproc` to
+ handle simple math in bibliography fields.)
+
+ * Added `Text.Pandoc.Writers.Shared` for shared functions used
+ only in writers. `metaToJSON` is used in writers to create a
+ JSON object for use in the templates from the pandoc metadata
+ and variables. `getField`, `setField`, and `defField` are
+ for working with JSON template contexts.
+
+ * Added `Text.Pandoc.Asciify` utility module.
+ This exports functions to create ASCII-only versions of identifiers.
+
+ * `Text.Pandoc.Parsing`
+
+ + Generalized state type on `readWith` (API change).
+ + Specialize readWith to `String` input. (API change).
+ + In `ParserState`, replace `stateTitle`, `stateAuthors`, `stateDate`
+ with `stateMeta` and `stateMeta'`.
+
+ * `Text.Pandoc.UTF8`: use strict bytestrings in reading. The use of lazy
+ bytestrings seemed to cause problems using pandoc on 64-bit Windows
+ 7/8 (#874).
+
+ * Factored out `registerHeader` from markdown reader, added to
+ `Text.Pandoc.Parsing`.
+
+ * Removed `blaze_html_0_5` flag, require `blaze-html` >= 0.5.
+ Reason: < 0.5 does not provide a monoid instance for Attribute,
+ which is now needed by the HTML writer (#803).
+
+ * Added `http-conduit` flag, which allows fetching https resources.
+ It also brings in a large number of dependencies (`http-conduit`
+ and its dependencies), which is why for now it is an optional flag
+ (#820).
+
+ * Added CONTRIBUTING.md.
+
+ * Improved INSTALL instructions.
+
+ * `make-windows-installer.bat`: Removed explicit paths for executables.
+
+ * `aeson` is now used instead of `json` for JSON.
+
+ * Set default stack size to 16M. This is needed for some large
+ conversions, esp. if pandoc is compiled with 64-bit ghc.
+
+ * Various small documentation improvements.
+ Thanks to achalddave and drothlis for patches.
+
+ * Removed comment that chokes recent versions of CPP (#933).
+
+ * Removed support for GHC version < 7.2, since pandoc-types now
+ requires at least GHC 7.2 for GHC generics.
+
+
+pandoc (1.11.1)
+
+ * Markdown reader:
+
+ + Fixed regression in which parentheses were lost in link URLs.
+ Added tests. Closes #786.
+ + Better handling of unmatched double quotes in `--smart` mode.
+ These occur frequently in fiction, since it is customary not to
+ close quotes in dialogue if the speaker does not change between
+ paragraphs. The unmatched quotes now get turned into literal
+ left double quotes. (No `Quoted` inline is generated, however.)
+ Closes #99 (again).
+
+ * HTML writer: Fixed numbering mismatch between TOC and sections.
+ `--number-offset` now affects TOC numbering as well
+ as section numbering, as it should have all along. Closes #789.
+
+ * Markdown writer: Reverted 1.11 change that caused citations to be rendered
+ as markdown citations, even if `--bibliography` was specified, unless
+ `citation` extension is disabled. Now, formatted citations are always
+ printed if `--bibliography` was specified. If you want to reformat
+ markdown keeping pandoc markdown citations intact, don't use
+ `--bibliography`. Note that citations parsed from LaTeX documents will
+ be rendered as pandoc markdown citations when `--bibliography` is not
+ specified.
+
+ * ODT writer: Fixed regression leading to corrupt ODTs.
+ This was due to a change in the `Show` instance for
+ `Text.Pandoc.Pretty.Doc`. Closes #780.
+
+ * Fixed spacing bugs involving code block attributes in
+ RST reader and Markdown writer. Closes #763.
+
+ * Windows package: Various improvements due to Fyodor Sheremetyev.
+
+ + Automatically set installation path (Program Files or Local App Data).
+ + Set system PATH environment variable when installing for all users.
+ + Pandoc can installed for all users using the following command.
+ `msiexec /i pandoc-1.11.msi ALLUSERS=1`.
+
+ * Bumped QuickCheck version bound.
+
+pandoc (1.11)
+
+ * Added `--number-offset` option. (See README for description.)
+
+ * Added `--default-image-extension` option. (See README for description.)
+
+ * `--number-sections` behavior change: headers with class `unnumbered`
+ will not be numbered.
+
+ * `--version` now reports the default data directory.
+
+ * `Text.Pandoc.Parsing` is no longer exposed. (API change.)
+
+ * `Text.Pandoc.Highlighting` is no longer exposed. (API change.)
+
+ * `Text.Pandoc.Shared`: Changed type of `Element`. `Sec` now includes
+ a field for `Attr` rather than just `String`. (API change.)
+
+ * Added `markdown_github` as input format. This was an accidental
+ omission in 1.10.
+
+ * Added `readerDefaultImageExtension` field to `ReaderOptions`. (API
+ change.)
+
+ * Added `writerNumberOffset` field in `WriterOptions`. (API change.)
+
+ * Beamer template:
+
+ + Fixed captions with longtable. Thanks to Joost Kremers.
+ + Provide `\Oldincludegraphics` as in LaTeX template (Benjamin Bannier).
+
+ * LaTeX template:
+
+ + Load microtype after fonts. Microtype needs to know
+ what fonts are being used. Thanks to dfc for the patch.
+ + Set `secnumdepth` to 5 if `--number-sections` specified.
+ This yields behavior equivalent to the other writers, numbering
+ level 4 and 5 headers too. Closes #753.
+
+ * HTML reader:
+
+ + Handle `<colgroup>` tag.
+ + Preserve all header attributes.
+
+ * LaTeX reader:
+
+ + Parse `\hrule` as `HorizontalRule`. Closes #746.
+ + Parse starred variants of `\section` etc. as headers with
+ attribute `unnumbered`.
+ + Read optional attributes in `lstlisting` and `Verbatim` environments.
+ We convert these to pandoc standard names, e.g. `numberLines`
+ for `numbers=left`, `startFrom=100` from `firstnumber=100`.
+ + Handle language attribute for lstlistings.
+ + Better support for Verbatim and minted environments. Closes #763.
+
+ * Markdown reader:
+
+ + `-` in an attribute context = `.unnumbered`. The point of this
+ is to provide a way to specify unnumbered headers in non-English
+ documents.
+ + Fixed bug parsing key/value attributes. Parsing failed if you
+ had an unquoted attribute immediately before the final '}'.
+ + Make backslash escape work in attributes.
+ + Fix title block parsing. Now if `mmd_title_blocks` is specified,
+ pandoc will parse a MMD title block if it sees one, even if
+ `pandoc_title_blocks` is enabled.
+ + Refactoring: `litChar` now includes entities, so we don't need
+ to use `fromEntities` e.g. on titles.
+ + Allow spaces around borders in pipe tables. Closes #772.
+ + Allow all punctuation in angle-bracket autolinks. Previously
+ things like `----` were disallowed, because the uri parser
+ treated them as trailing punctuation. Closes #768.
+ + Make `implicit_header_references` work properly when
+ headers are given explicit identifiers.
+ + Check for tables before line blocks. Otherwise some pipe
+ tables get treated as line blocks.
+ + Allow `&` in emails (for entities).
+ + Properly handle entities in titles and links. A markdown link
+ `<http://g&ouml;ogle.com>` should be a link to `http://göogle.com`.
+ Closes #723.
+
+ * Textile reader:
+
+ + Handle attributes on headers.
+
+ * LaTeX reader:
+
+ + Add `fig:` as title for images with captions.
+ This is needed for them to be rendered as figures. Closes #766.
+ + Never emit an empty paragraph. See #761.
+ + Handle `\caption` for images in figures. Closes #766.
+ + Parse `\section*`, etc. as unnumbered sections.
+
+ * HTML writer:
+
+ + Support header attributes. The attributes go on
+ the enclosing `section` or `div` tag if `--section-divs` is specified.
+ + Fixed a regression (only now noticed) in html+lhs output.
+ Previously the bird tracks were being omitted.
+
+ * LaTeX writer:
+
+ + Omit lists with no items to avoid LaTeX errors.
+ + Support line numbering with `--listings`.
+ If `numberLines` class is present, we add `numbers=left`;
+ if `startFrom` is present, we add `firstnumber=`. (#763)
+
+ * ConTeXt writer:
+
+ + Removed `\placecontent`. This produced a duplicate toc,
+ in conjunction with `\placelist`.
+ + Use `\title`, `\subject` etc. for headers with
+ `unnumbered` class.
+
+ * Textile writer:
+
+ + Support header attributes.
+
+ * Markdown writer:
+
+ + Use grid tables when needed, and if enabled. Closes #740.
+ + Render citations as pandoc-markdown citations.
+ Previously citations were rendered as citeproc-formatted citations
+ by default. Now we render them as pandoc citations, e.g. `[@item1]`,
+ unless the `citations` extension is disabled.
+ If you still want formatted citations in your markdown output,
+ use `pandoc -t markdown-citations`.
+
+ * RST writer:
+
+ + Support `:number-lines:` in code blocks.
+
+ * Docx writer:
+
+ + Better treatment of display math. Display math inside a
+ paragraph is now put in a separate paragraph, so it will render
+ properly (centered and without extra blank lines around it).
+ Partially addresses #742.
+ + Content types and document rels xml files are now created from
+ scratch, rather than being taken over from `reference.docx`.
+ This fixes problems that arise when you edit the `reference.docx`
+ with Word.
+ + We also now encode mime types for each individual image rather
+ than using defaults. This should allow us to handle a wider
+ range of image types (including PDF). Closes #414.
+ + Changed style names in `reference docx`.
+ `FootnoteReference` -> `FootnoteRef`, `Hyperlink` -> `Link`.
+ The old names got changed by Word when the `reference.docx` was
+ edited. Closes #414.
+
+ * EPUB writer:
+
+ + Fix section numbering. Previously the numbering restarted from 1
+ in each chapter (with `--number-sections`), though the numbers in
+ the table of contents were correct.
+ + Headers with "unnumbered" attribute are not numbered. (Nor do they
+ cause an increment in running numbering.) Section numbers now work
+ properly, even when there is material before the first numbered section.
+ + Include HTML TOC, even in epub2. The TOC is included in `<spine>`,
+ but `linear` is set to `no` unless the `--toc` option is specified.
+ Include `<guide>` element in OPF. This should allow the TOC to
+ be useable in Kindles when converted with kindlegen. Closes #773.
+
+ * `Text.Pandoc.Parsing`: Optimized `oneOfStringsCI`.
+ This dramatically reduces the speed penalty that comes from enabling the
+ `autolink_bare_uris` extension. The penalty is still substantial (in one
+ test, from 0.33s to 0.44s), but nowhere near what it used to be.
+ The RST reader is also much faster now, as it autodetects URIs.
+
+ * `Text.Pandoc.Shared`: `hierarchicalize` will not number section
+ with class "unnumbered". Unnumbered sections get `[]` for their
+ section number.
+
+ * `Text.Pandoc.Pretty`:
+
+ + Fixed `chomp` so it works inside `Prefixed` elements.
+ + Changed `Show` instance so it is better for debugging.
+
+ * `Text.Pandoc.ImageSize`: Added `Pdf` to `ImageType`.
+
+ * `Text.Pandoc.UTF8`: Strip off BOM if present. Closes #743.
+
+ * Windows installer improvements:
+
+ + The installer is now signed with a certificate (thanks to
+ Fyodor Sheremetyev).
+ + WiX is used instead of InnoSetup. The installer is now a
+ standard msi file.
+ + The version number is now auto-detected, and need not be
+ updated separately.
+
+ * OSX installer improvements:
+
+ + The package and pandoc executable are now signed with a
+ certificate (thanks to Fyodor Sheremetyev).
+ + RTF version of license is used.
+ + Use full path for sysctl in `InstallationCheck` script (jonahbull).
+ Closes #580.
+
+ * Converted COPYING to markdown.
+
+ * pandoc.cabal: Require latest versions of highlighting-kate,
+ texmath, citeproc-hs, zip-archive.
+
+pandoc (1.10.1)
+
+ * Markdown reader: various optimizations, leading to a
+ significant performance boost.
+
+ * RST reader: Allow anonymous form of inline links:
+ `` `hello <url>`__ `` Closes #724.
+
+ * Mediawiki reader: Don't require newlines after tables.
+ Thanks to jrunningen for the patch. Closes #733.
+
+ * Fixed LaTeX macro parsing. Now LaTeX macro definitions are preserved
+ when output is LaTeX, and applied when it is another format.
+ Partially addresses #730.
+
+ * Markdown and RST readers: Added parser to `block` that skips blank
+ lines. This fixes a subtle regression involving grid tables with
+ empty cells. Also added test for grid table with empty cells.
+ Closes #732.
+
+ * RST writer: Use `.. code:: language` for code blocks with language.
+ Closes #721.
+
+ * DocBook writer: Fixed output for hard line breaks, adding a newline
+ between `<literallayout>` tags.
+
+ * Markdown writer: Use an autolink when link text matches url.
+ Previously we also checked for a null title, but this
+ test fails for links produced by citeproc-hs in bibliographies.
+ So, if the link has a title, it will be lost on conversion
+ to an autolink, but that seems okay.
+
+ * Markdown writer: Set title, author, date variables as before.
+ These are no longer used in the default template, since we use
+ titleblock, but we set them anyway for those who use custom templates.
+
+ * LaTeX writer: Avoid extra space at start/end of table cell.
+ Thanks to Nick Bart for the suggestion of using @{}.
+
+ * `Text.Pandoc.Parsing`:
+
+ + More efficient version of `anyLine`.
+ + Type of `macro` has changed; the parser now returns `Blocks`
+ instead of `Block`.
+
+ * Relaxed old-time version bound, allowing 1.0.*.
+
+ * Removed obsolete `hsmarkdown` script. Those who need `hsmarkdown`
+ should create a symlink as described in the README.
+
+pandoc (1.10.0.5)
+
+ * Markdown reader: Try `lhsCodeBlock` before `rawTeXBlock`. Otherwise
+ `\begin{code}...\end{code}` isn't handled properly in markdown+lhs.
+ Thanks to Daniel Miot for noticing the bug and suggesting the fix.
+
+ * Markdown reader: Fixed bug with headerless grid tables.
+ The 1.10 code assumed that each table header cell contains exactly one
+ block. That failed for headerless tables (0) and also for tables with
+ multiple blocks in a header cell. The code is fixed and tests provided.
+ Thanks to Andrew Lee for pointing out the bug.
+
+ * Markdown reader: Fixed regressions in fenced code blocks. Closes #722.
+
+ + Tilde code fences can again take a bare language string
+ (`~~~ haskell`), not just curly-bracketed attributes
+ (`~~~ {.haskell}`).
+ + Backtick code blocks can take the curly-bracketed attributes.
+ + Backtick code blocks don't *require* a language.
+ + Consolidated code for the two kinds of fenced code blocks.
+
+ * LaTeX template: Use `\urlstyle{same}` to avoid monospace URLs.
+
+ * Markdown writer: Use proportional font for email autolinks with
+ obfuscation. Closes #714.
+
+ * Corrected name of `blank_before_blockquote` in README. Closes #718.
+
+ * `Text.Pandoc.Shared`: Fixed bug in `uri` parser.
+ The bug prevented an autolink at the end of a string (e.g.
+ at the end of a line block line) from counting as a link. Closes #711.
+
+ * Use the `hsb2hs` preprocessor instead of TH for embed_data_files.
+ This should work on Windows, unlike the TH solution with
+ file-embed.
+
+ * Eliminated use of TH in test suite.
+
+ * Added `Text.Pandoc.Data` (non-exported) to hold the association
+ list of embedded data files, if the `embed_data_files` flag is selected.
+ This isolates the code that needs special treatment with file-embed or
+ `hsb2hs`.
+
+ * Changes to `make-windows-installer.bat`.
+
+ + Exit batch file if any of the cabal-dev installs fail.
+ + There's no longer any need to reinstall `highlighting-kate`.
+ + Don't start with a `cabal update`; leave that to the user.
+ + Force reinstall of pandoc.
+
+ * Fixed EPUB writer so it builds with blaze-html 0.4.x. Thanks to
+ Jens Petersen.
+
+pandoc (1.10.0.4)
+
+ * Fixed bug with escaped % in LaTeX reader. Closes #710.
+
+pandoc (1.10.0.3)
+
+ * Added further missing fb2 tests to cabal file.
+
+pandoc (1.10.0.2)
+
+ * Added fb2 tests to cabal file's extra-source-files.
+
+pandoc (1.10.0.1)
+
+ * Bump version bounds on test-framework packages.
+
+pandoc (1.10)
+
+ [new features]
+
+ * New input formats: `mediawiki` (MediaWiki markup).
+
+ * New output formats: `epub3` (EPUB v3 with MathML),
+ `fb2` (FictionBook2 ebooks).
+
+ * New `--toc-depth` option, specifying how many levels of
+ headers to include in a table of contents.
+
+ * New `--epub-chapter-level` option, specifying the header
+ level at which to divide EPUBs into separate files.
+ Note that this normally affects only performance, not the
+ visual presentation of the EPUB in a reader.
+
+ * Removed the `--strict` option. Instead of using `--strict`,
+ one can now use the format name `markdown_strict` for either input
+ or output. This gives more fine-grained control that `--strict`
+ did, allowing one to convert from pandoc's markdown to strict
+ markdown or vice versa.
+
+ * It is now possible to enable or disable specific syntax
+ extensions by appending them (with `+` or `-`) to the writer
+ or reader name. For example,
+
+ pandoc -f markdown-footnotes+hard_line_breaks
+
+ disables footnotes and enables treating newlines as hard
+ line breaks. The literate Haskell extensions are now implemented
+ this way as well, using either `+lhs` or `+literate_haskell`.
+ For a list of extension names, see the README under
+ "Pandoc's Markdown."
+
+ * The following aliases have been introduced for specific
+ combinations of markdown extensions: `markdown_phpextra`,
+ `markdown_github`, `markdown_mmd`, `markdown_strict`. These aliases
+ work just like regular reader and writer names, and can be modified
+ with extension modifiers as described above. (Note that conversion
+ from one markdown dialect to another does not work perfectly,
+ because there are differences in markdown parsers besides
+ just the extensions, and because pandoc's internal document model is
+ not rich enough to capture all of the extensions.)
+
+ * New `--html-q-tags` option. The previous default was to use `<q>`
+ tags for smart quotes in HTML5. But `<q>` tags are also valid HTML4.
+ Moreover, they are not a robust way of typesetting quotes, since
+ some user agents don't support them, and some CSS resets (e.g.
+ bootstrap) prevent pandoc's quotes CSS from working properly.
+ We now just insert literal quote characters by default in both
+ `html` and `html5` output, but this option is provided for
+ those who still want `<q>` tags.
+
+ * The markdown reader now prints warnings (to stderr) about
+ duplicate link and note references. Closes #375.
+
+ * Markdown syntax extensions:
+
+ + Added pipe tables. Thanks to François Gannaz for the initial patch.
+ These conform to PHP Markdown Extra's pipe table syntax. A subset
+ of org-mode table syntax is also supported, which means that you can
+ use org-mode's nice table editor to create tables.
+
+ + Added support for RST-style line blocks. These are
+ useful for verse and addresses.
+
+ + Attributes can now be specified for headers, using the same
+ syntax as in code blocks. (However, currently only the
+ identifier has any effect in most writers.) For example,
+
+ # My header {#foo}
+
+ See [the header above](#foo).
+
+ + Pandoc will now act as if link references have been defined
+ for all headers without explicit identifiers.
+ So, you can do this:
+
+ # My header
+
+ Link to [My header].
+ Another link to [it][My header].
+
+ Closes #691.
+
+ * LaTeX reader:
+
+ + Command macros now work everywhere, including non-math.
+ Environment macros still not supported.
+ + `\input` now works, as well as `\include`. TEXINPUTS is used.
+ Pandoc looks recursively into included files for more included files.
+
+ [behavior changes]
+
+ * The Markdown reader no longer puts the text of autolinks in a
+ `Code` inline. This means that autolinks will no longer appear
+ in a monospace font.
+
+ * The character `/` can now appear in markdown citation keys.
+
+ * HTML blocks in strict_markdown are no longer required to begin
+ at the left margin. Technically this is required, according to
+ the markdown syntax document, but `Markdown.pl` and other markdown
+ processors are more liberal.
+
+ * The `-V` option has been changed so that if there are duplicate
+ variables, those specified later on the command line take precedence.
+
+ * Tight lists now work in LaTeX and ConTeXt output.
+
+ * The LaTeX writer no longer relien on the `enumerate` package.
+ Instead, it uses standard LaTeX commands to change the list numbering
+ style.
+
+ * The LaTeX writer now uses `longtable` instead of `ctable`. This allows
+ tables to be split over page boundaries.
+
+ * The RST writer now uses a line block to render paragraphs containing
+ linebreaks (which previously weren't supported at all).
+
+ * The markdown writer now applies the `--id-prefix` to footnote IDs.
+ Closes #614.
+
+ * The plain writer no longer uses backslash-escaped line breaks
+ (which are not very "plain").
+
+ * `Text.Pandoc.UTF8`: Better error message for invalid UTF8.
+ Read bytestring and use `Text`'s decodeUtf8 instead of using
+ `System.IO.hGetContents`. This way you get a message saying
+ "invalid UTF-8 stream" instead of "invalid byte sequence."
+ You are also told which byte caused the problem.
+
+ * Docx, ODT, and EPUB writers now download images specified by a URL
+ instead of skipping them or raising an error.
+
+ * EPUB writer:
+
+ + The default CSS now left-aligns headers by default, instead of
+ centering. This is more consistent with the rest of the writers.
+ + A proper multi-level table of contents is now used in `toc.ncx`.
+ There is no longer a subsidiary table of contents at the beginning
+ of each chapter.
+ + Code highlighting now works by default.
+ + Section divs are used by default for better semantic markup.
+ + The title is used instead of "Title Page" in the table of contents.
+ Otherwise we have a hard-coded English string, which looks
+ strange in ebooks written in other languages. Closes #572.
+
+ * HTML writer:
+
+ + Put mathjax in span with class "math". Closes #562.
+ + Put citations in a span with class "citation." In HTML5, also include
+ a `data-cite` attribute with a space-separated list of citation
+ keys.
+
+ * `Text.Pandoc.UTF8`: use universalNewlineMode in reading.
+ This treats both `\r\n` and `\n` as `\n` on input, no matter
+ what platform we're running on.
+
+ * Citation processing is now done in the Markdown and LaTeX
+ readers, not in `pandoc.hs`. This makes it easier for library users
+ to use citations.
+
+ [template changes]
+
+ * HTML: Added css to template to preserve spaces in `<code>` tags.
+ Thanks to Dirk Laurie.
+
+ * Beamer: Remove English-centric strings in section pages.
+ Section pages used to have "Section" and a number as well as the
+ section title. Now they just have the title. Similarly for part
+ and subsection. Closes #566.
+
+ * LaTeX, ConTeXt: Added papersize variable.
+
+ * LaTeX, Beamer templates: Use longtable instead of ctable.
+
+ * LaTeX, Beamer templates: Don't require 'float' package for tables.
+ We don't actually seem to use the '[H]' option.
+
+ * LaTeX: Use `upquote` package if it is available. This fixes
+ straight quotes in verbatim environments.
+
+ * Markdown, plain: Fixed titleblock so it is just a single string.
+ Previously separate title, author, and date variables were used,
+ but this didn't allow different kinds of title blocks.
+
+ * EPUB:
+
+ + Rationalized templates. Previously there were three different
+ templates involved in epub production. There is now just one
+ template, `default.epub` or `default.epub3`. It can now be
+ overridden using `--template`, just like other templates.
+ The titlepage is now folded into the default template.
+ A `titlepage` variable selects it.
+ + UTF-8, lang tag, meta tags, title element.
+
+ * Added scale-to-width feature to beamer template
+
+ [API changes]
+
+ * `Text.Pandoc.Definition`: Added `Attr` field to `Header`.
+ Previously header identifers were autogenerated by the writers.
+ Now they are added in the readers (either automatically or explicitly).
+
+ * `Text.Pandoc.Builder`:
+
+ + `Inlines` and `Blocks` are now synonyms for `Many Inline` and
+ `Many Block`. `Many` is a newtype wrapper around `Seq`, with
+ custom Monoid instances for `Many Inline` and `Many Block. This
+ allows `Many` to be made an instance of `Foldable` and `Traversable`.
+ + The old `Listable` class has been removed.
+ + The module now exports `isNull`, `toList`, `fromList`.
+ + The old `Read` and `Show` instances have been removed; derived
+ instances are now used.
+ + Added `headerWith`.
+
+ * The readers now take a `ReaderOptions` rather than a `ParserState`
+ as a parameter. Indeed, not all parsers use the `ParserState` type;
+ some have a custom state. The motivation for this change was to separate
+ user-specifiable options from the accounting functions of parser state.
+
+ * New module `Text.Pandoc.Options`. This includes the `WriterOptions`
+ formerly in `Text.Pandoc.Shared`, and its associated
+ data types. It also includes a new type `ReaderOptions`, which
+ contains many options formerly in `ParserState`, and its associated
+ data types:
+
+ + `ParserState.stateParseRaw` -> `ReaderOptions.readerParseRaw`.
+ + `ParserState.stateColumns` -> `ReaderOptions.readerColumns`.
+ + `ParserState.stateTabStop` -> `ReaderOptions.readerTabStop`.
+ + `ParserState.stateOldDashes` -> `ReaderOptions.readerOldDashes`.
+ + `ParserState.stateLiterateHaskell` -> `ReaderOptions.readerLiterateHaskell`.
+ + `ParserState.stateCitations` -> `ReaderOptions.readerReferences`.
+ + `ParserState.stateApplyMacros` -> `ReaderOptions.readerApplyMacros`.
+ + `ParserState.stateIndentedCodeClasses` ->
+ `ReaderOptions.readerIndentedCodeClasses`.
+ + Added `ReaderOptions.readerCitationStyle`.
+
+ * `WriterOptions` now includes `writerEpubVersion`, `writerEpubChapterLevel`,
+ `writerEpubStylesheet`, `writerEpubFonts`, `writerReferenceODT`,
+ `writerReferenceDocx`, and `writerTOCDepth`. `writerEPUBMetadata` has
+ been renamed `writerEpubMetadata` for consistency.
+
+ * Changed signatures of `writeODT`, `writeDocx`, `writeEPUB`, since they no
+ longer stylesheet, fonts, reference files as separate parameters.
+
+ * Removed `writerLiterateHaskell` from `WriterOptions`, and
+ `readerLiterateHaskell` from `ReaderOptions`. LHS is now handled
+ by an extension (`Ext_literate_haskell`).
+
+ * Removed deprecated `writerXeTeX`.
+
+ * Removed `writerStrict` from `WriterOptions`. Added `writerExtensions`.
+ Strict is now handled through extensions.
+
+ * `Text.Pandoc.Options` exports `pandocExtensions`, `strictExtensions`,
+ `phpMarkdownExtraExtensions`, `githubMarkdownExtensions`,
+ and `multimarkdownExtensions`, as well as the `Extensions` type.
+
+ * New `Text.Pandoc.Readers.MediaWiki` module, exporting
+ `readMediaWiki`.
+
+ * New `Text.Pandoc.Writers.FB2` module, exporting `writeFB2`
+ (thanks to Sergey Astanin).
+
+ * `Text.Pandoc`:
+
+ + Added `getReader`, `getWriter` to `Text.Pandoc`.
+ + `writers` is now an association list `(String, Writer)`.
+ A `Writer` can be a `PureStringWriter`, an `IOStringWriter`, or
+ an `IOByteStringWriter`. ALL writers are now in the 'writers'
+ list, including the binary writers and FB2 writer. This allows
+ code in `pandoc.hs` to be simplified.
+ + Changed type of `readers`, so all readers are in IO.
+ Users who want pure readers can still get them form the reader
+ modules; this just affects the function `getReader` that looks up
+ a reader based on the format name. The point of this change is to
+ make it possible to print warnings from the parser.
+
+ * `Text.Pandoc.Parsing`:
+
+ + `Text.Parsec` now exports all Parsec functions used in pandoc code.
+ No other module directly imports Parsec. This will make it easier
+ to change the parsing backend in the future, if we want to.
+ + `Text.Parsec` is used instead of `Text.ParserCombinators.Parsec`.
+ + Export the type synonym `Parser`.
+ + Export `widthsFromIndices`, `NoteTable'`, `KeyTable'`, `Key'`, `toKey'`,
+ `withQuoteContext`, `singleQuoteStart`, `singleQuoteEnd`,
+ `doubleQuoteStart`, `doubleQuoteEnd`, `ellipses`, `apostrophe`,
+ `dash`, `nested`, `F(..)`, `askF`, `asksF`, `runF`, `lineBlockLines`.
+ + `ParserState` is no longer an instance of `Show`.
+ + Added `stateSubstitutions` and `stateWarnings` to `ParserState`.
+ + Generalized type of `withQuoteContext`.
+ + Added `guardEnabled`, `guardDisabled`, `getOption`.
+ + Removed `failIfStrict`.
+ + `lookupKeySrc` and `fromKey` are no longer exported.
+
+ * `Data.Default` instances are now provided for `ReaderOptions`,
+ `WriterOptions`, and `ParserState`. `Text.Pandoc` re-exports `def`.
+ Now you can use `def` (which is re-exported by `Text.Pandoc`) instead
+ of `defaultWriterOptions` (which is still defined). Closes #546.
+
+ * `Text.Pandoc.Shared`:
+
+ + Added `safeRead`.
+ + Renamed `removedLeadingTrailingSpace` to `trim`,
+ `removeLeadingSpace` to `triml`, and `removeTrailingSpace` to `trimr`.
+ + Count `\r` as space in `trim` functions.
+ + Moved `renderTags'` from HTML reader and `Text.Pandoc.SelfContained`
+ to `Shared`.
+ + Removed `failUnlessLHS`.
+ + Export `compactify'`, formerly in Markdown reader.
+ + Export `isTightList`.
+ + Do not export `findDataFile`.
+ + `readDataFile` now returns a strict ByteString.
+ + Export `readDataFileUTF8` which returns a String, like the
+ old `readDataFile`.
+ + Export `fetchItem` and `openURL`.
+
+ * `Text.Pandoc.ImageSize`: Use strict, not lazy bytestrings.
+ Removed `readImageSize`.
+
+ * `Text.Pandoc.UTF8`: Export `encodePath`, `decodePath`,
+ `decodeArg`, `toString`, `fromString`, `toStringLazy`,
+ `fromStringLazy`.
+
+ * `Text.Pandoc.UTF8` is now an exposed module.
+
+ * `Text.Pandoc.Biblio`:
+
+ + csl parameter now a `String` rather than a `FilePath`.
+ + Changed type of `processBiblio`. It is no longer in the IO monad.
+ It now takes a `Maybe Style` argument rather than parameters for CSL
+ and abbrev filenames. (`pandoc.hs` now calls the functions to parse
+ the style file and add abbreviations.)
+
+ * Markdown reader now exports `readMarkdownWithWarnings`.
+
+ * `Text.Pandoc.RTF` now exports `writeRTFWithEmbeddedImages` instead of
+ `rtfEmbedImage`.
+
+ [bug fixes]
+
+ * Make `--ascii` work properly with `--self-contained`. Closes #568.
+
+ * Markdown reader:
+
+ + Fixed link parser to avoid exponential slowdowns. Closes #620.
+ Previously the parser would hang on input like this:
+
+ [[[[[[[[[[[[[[[[[[hi
+
+ We fixed this by making the link parser parser characters
+ between balanced brackets (skipping brackets in inline code spans),
+ then parsing the result as an inline list. One change is that
+
+ [hi *there]* bud](/url)
+
+ is now no longer parsed as a link. But in this respect pandoc behaved
+ differently from most other implementations anyway, so that seems okay.
+
+ + Look for raw html/latex blocks before tables.
+ Otherwise the following gets parsed as a table:
+
+ \begin{code}
+ --------------
+ -- My comment.
+ \end{code}
+
+ Closes #578.
+
+ * RST reader:
+
+ + Added support for `:target:` on `.. image::` blocks
+ and substitutions.
+ + Field list fixes:
+
+ - Fixed field lists items with body beginning after a new line
+ (Denis Laxalde).
+ - Allow any char but ':' in names of field lists in RST reader
+ (Denis Laxalde).
+ - Don't allow line breaks in field names.
+ - Require whitespace after field list field names.
+ - Don't create empty definition list for metadata field lists.
+ Previously a field list consisting only of metadata fields (author,
+ title, date) would be parsed as an empty DefinitionList, which is
+ not legal in LaTeX and not needed in any format.
+
+ + Don't recognize inline-markup starts inside words.
+ For example, `2*2 = 4*1` should not contain an emphasized
+ section. Added test case for "Literal symbols". Closes #569.
+ + Allow dashes as separator in simple tables. Closes #555.
+ + Added support for `container`, `compound`, `epigraph`,
+ `rubric`, `highlights`, `pull-quote`.
+ + Added support for `.. code::`.
+ + Made directive labels case-insensitive.
+ + Removed requirement that directives begin at left margin.
+ This was (correctly) not in earlier releases; docutils doesn't
+ make the requirement.
+ + Added support for `replace::` and `unicode::` substitutions.
+ + Ignore unknown interpreted roles.
+ + Renamed image parser to `subst`, since it now handles all
+ substitution references.
+
+ * Textile reader:
+
+ + Allow newlines before pipes in table. Closes #654.
+ + Fixed bug with list items containing line breaks.
+ Now pandoc correctly handles hard line breaks inside list items.
+ Previously they broke list parsing.
+ + Implemented comment blocks.
+ + Fixed bug affected words ending in hyphen.
+ + Properly handle links with surrounding brackets.
+ Square brackets need to be used when the link isn't surrounded by
+ spaces or punctuation, or when the URL ending may be ambiguous.
+ Closes #564.
+ + Removed nullBlock. Better to know about parsing problems than
+ to skip stuff when we get stuck.
+ + Allow ID attributes on headers.
+ + Textile reader: Avoid parsing dashes as strikeout.
+ Previously the input
+
+ text--
+ text--
+ text--
+ text--
+
+ would be parsed with strikeouts rather than dashes. This fixes
+ the problem by requiring that a strikeout delimiting - not be
+ followed by a -. Closes #631.
+ + Expanded list of `stringBreakers`.
+ This fixes a bug on input like "(_hello_)" which should
+ be a parenthesized emphasized "hello".
+ The new list is taken from the PHP source of textile 2.4.
+ + Fixed autolinks. Previously the textile reader and writer
+ incorrectly implented RST-style autolinks for URLs and email
+ addresses. This has been fixed. Now an autolink is done this way:
+ `"$":http://myurl.com`.
+ + Fixed footnotes bug in textile. This affected notes occuring
+ before punctuation, e.g. `foo[1].`. Closes #518.
+
+ * LaTeX reader:
+
+ + Better handling of citation commands.
+ + Better handling of `\noindent`.
+ + Added a 'try' in rawLaTeXBlock, so we can handle `\begin` without `{`.
+ Closes #622.
+ + Made `rawLaTeXInline` try to parse block commands as well. This
+ is usually what we want, given how `rawLaTeXInline` is used in
+ the markdown and textile readers. If a block-level LaTeX command
+ is used in the middle of a paragraph (e.g. `\subtitle` inside a title),
+ we can treat it as raw inline LaTeX.
+ + Handle \slash command. Closes #605.
+ + Basic `\enquote` support.
+ + Fixed parsing of paragraphs beginning with a group. Closes #606.
+ + Use curly quotes for bare straight quotes.
+ + Support obeylines environment. Closes #604.
+ + Guard against "begin", "end" in inlineCommand and
+ blockCommand.
+ + Better error messages for environments. Now it should tell you that
+ it was looking for \end{env}, instead of giving "unknown parse error."
+
+ * HTML reader:
+
+ + Added HTML 5 tags to list of block-level tags.
+ + HTML reader: Fixed bug in `htmlBalanced`, which
+ caused hangs in parsing certain markdown input using
+ strict mode.
+ + Parse `<q>` as `Quoted DoubleQuote`.
+ + Handle nested `<q>` tags properly.
+ + Modified `htmlTag` for fewer false positives.
+ A tag must start with `<` followed by `!`,`?`, `/`, or a letter.
+ This makes it more useful in the wikimedia and markdown parsers.
+
+ * DocBook reader: Support title in "figure" element. Closes #650.
+
+ * MediaWiki writer:
+
+ + Remove newline after `<br/>` in translation of `LineBreak`
+ There's no particular need for a newline (other than making the
+ generated MediaWiki source look nice to a human), and in fact
+ sometimes it is incorrect: in particular, inside an enumeration, list
+ items cannot have embedded newline characters. (Brent Yorgey)
+ + Use `<code>` not `<tt>` for Code.
+
+ * Man writer: Escape `-` as `\-`.
+ Unescaped `-`'s become hyphens, while `\-`'s are left as ascii minus
+ signs. That is preferable for use with command-line options. See
+ <http://lintian.debian.org/tags/hyphen-used-as-minus-sign.html>. Thanks
+ to Andrea Bolognani for bringing the issue to our attention.
+
+ * RST writer:
+
+ + Improved line block output. Use nonbreaking spaces for
+ initial indent (otherwise lost in HTML and LaTeX).
+ Allow multiple paragraphs in a single line block.
+ Allow soft breaks w continuations in line blocks.
+ + Properly handle images with no alt text. Closes #678.
+ + Fixed bug with links with duplicate text. We now (a) use anonymous
+ links for links with inline URLs, and (b) use an inline link instead
+ of a reference link if the reference link would require a label that
+ has already been used for a different link. Closes #511.
+ + Fixed hyperlinked images. Closes #611. Use `:target:`
+ field when you have a simple linked image.
+ + Don't add `:align: center` to figures.
+
+ * Texinfo writer: Fixed internal cross-references.
+ Now we insert anchors after each header, and use `@ref` instead of `@uref`
+ for links. Commas are now escaped as `@comma{}` only when needed;
+ previously all commas were escaped. (This change is needed, in part,
+ because `@ref` commands must be followed by a real comma or period.) Also
+ insert a blank line in from of `@verbatim` environments.
+
+ * DocBook writer:
+
+ + Made --id-prefix work in DocBook as well as HTML.
+ Closes #607.
+ + Don't include empty captions in figures. Closes #581.
+
+ * LaTeX writer:
+
+ + Use `\hspace*` for nonbreaking space after line break,
+ since `~` spaces after a line break are just ignored.
+ Closes #687.
+ + Don't escape `_` in URLs or hyperref identifiers.
+ + Properly escape strings inside \url{}. Closes #576.
+ + Use `[fragile]` only for slides containing code rendered
+ using listings. Closes #649.
+ + Escape `|` as `\vert` in LaTeX math. This avoids a clash with
+ highlighting-kate's macros, which redefine `|` as a short verbatim
+ delimiter. Thanks to Björn Peemöller for raising this issue.
+ + Use minipage rather than parbox for block containers in tables.
+ This allows verbatim code to be included in grid tables.
+ Closes #663.
+ + Prevent paragraphs containing only linebreaks or spaces.
+
+ * HTML writer:
+
+ + Included `highlighting-css` for code spans, too.
+ Previously it was only included if used in a code block. Closes #653.
+ + Improved line breaks with `<dd>` tags. We now put a newline between
+ `</dd>` and `<dd>` when there are multiple definitions.
+ + Changed mathjax cdn url so it doesn't use https. (This caused
+ problems when used with `--self-contained`.) See #609.
+
+ * EPUB writer:
+
+ + `--number-sections` now works properly.
+ + Don't strip meta and link elements in epub metadata.
+ Patch from aberrancy. Closes #589.
+ + Fixed a couple validation bugs.
+ + Use ch001, ch002, etc. for chapter filenames. This improves sorting
+ of chapters in some readers, which apparently sort ch2 after ch10.
+ Closes #610.
+
+ * ODT writer: properly set title property (Arlo O'Keeffe).
+
+ * Docx writer:
+
+ + Fixed bug with nested lists. Previously a list like
+
+ 1. one
+ - a
+ - b
+ 2. two
+
+ would come out with a bullet instead of "2."
+ Thanks to Russell Allen for reporting the bug.
+ + Use `w:cr` in `w:r` instead of `w:br` for linebreaks.
+ This seems to fix a problem viewing pandoc-generated
+ docx files in LibreOffice.
+ + Use integer ids for bookmarks. Closes #626.
+ + Added nsid to abstractNum elements. This helps when merging
+ word documents with numbered or bulleted lists. Closes #627.
+ + Use separate footnotes.xml for notes.
+ This seems to help LibreOffice convert the file, even though
+ it was valid docx before. Closes #637.
+ + Use rIdNN identifiers for r:embed in images.
+ + Avoid reading image files again when we've already processed them.
+ + Fixed typo in `referenc.docx` that prevented image captions from
+ working. Thanks to Huashan Chen.
+
+ * `Text.Pandoc.Parsing`:
+
+ + Fixed bug in `withRaw`, which didn't correctly handle the case
+ where nothing is parsed.
+ + Made `emailAddress` parser more correct. Now it is based on RFC 822,
+ though it still doesn't implement quoted strings in email addresses.
+ + Revised URI parser. It now allows many more schemes, allows
+ uppercase URIs, and better handles trailing punctuation and
+ trailing slashes in bare URIs. Added many tests.
+ + Simplified and improved singleQuoteStart. This makes `'s'`, `'l'`,
+ etc. parse properly. Formerly we had some English-centric heuristics,
+ but they are no longer needed. Closes #698.
+
+ * `Text.Pandoc.Pretty`: Added wide punctuation range to `charWidth`.
+ This fixes bug with Chinese commas in markdown and reST tables, and
+ a bug that caused combining characters to be dropped.
+
+ * `Text.Pandoc.MIME`: Added MIME types for .wof and .eot. Closes #640.
+
+ * `Text.Pandoc.Biblio`:
+
+ + Run `mvPunc` and `deNote` on metadata too.
+ This fixed a bug with notes on titles using footnote styles.
+ + Fixed bug in fetching CSL files from CSL data directory.
+
+ * `pandoc.hs`: Give correct value to `writerSourceDirectory` when a URL
+ is provided. It should be the URL up to the path.
+
+ * Fixed/simplified diff output for tests.
+ Biblio: Make sure mvPunc and deNote run on metadata too.
+ This fixed a bug with notes on titles using footnote styles.
+
+ [under the hood improvements]
+
+ * We no longer depend on `utf8-string`. Instead we use functions
+ defined in `Text.Pandoc.UTF8` that use `Data.Text`'s conversions.
+
+ * Use `safeRead` instead of using `reads` directly (various modules).
+
+ * "Implicit figures" (images alone in a paragraph) are now handled
+ differently. The markdown reader gives their titles the prefix `fig:`; the
+ writers look for this before treating the image as a figure. Though this
+ is a bit of a hack, it has two advantages: (i) implicit figures can be
+ limited to the markdown reader, and (ii) they can be deactivated by turning
+ off the `implicit_figures` extension.
+
+ * `catch` from `Control.Exception` is now used instead of the
+ old Preface `catch`.
+
+ * `Text.Pandoc.Shared`: Improved algorithm for `normalizeSpaces`
+ and `oneOfStrings` (which is now non-backtracking).
+
+ * `Text.Pandoc.Biblio`: Remove workaround for `toCapital`.
+ Now citeproc-hs is fixed upstream, so this is no longer needed.
+ Closes #531.
+
+ * Textile reader: Improved speed of `hyphenedWords`.
+ This speeds up the textile reader by about a factor of 4.
+
+ * Use `Text.Pandoc.Builder` in RST reader, for more flexibility,
+ better performance, and automatic normalization.
+
+ * Major rewrite of markdown reader:
+
+ + Use `Text.Pandoc.Builder` instead of lists. This also
+ means that everything is normalized automatically.
+ + Move to a one-pass parsing strategy, returning values in the reader
+ monad, which are then run (at the end of parsing) against the final
+ parser state.
+
+ * In HTML writer, we now use `toHtml` instead of pre-escaping.
+ We work around the problem that blaze-html unnecessarily escapes `'`
+ by pre-escaping just the `'` characters, instead of the whole string.
+ If blaze-html later stops escaping `'` characters, we can simplify
+ `strToHtml` to `toHtml`. Closes #629.
+
+ * Moved code for embedding images in RTFs from `pandoc.hs` to the
+ RTF writer (which now exports `writeRTFWithEmbeddedImages`).
+
+ * Moved citation processing from `pandoc.hs` into the readers.
+ This makes things more convenient for library users.
+
+ * The man pages are now built by an executable `make-pandoc-man-pages`,
+ which has its own stanza in the cabal file so that dependencies can be
+ handled by Cabal. Special treatment in `Setup.hs` ensures that this
+ executable never gets installed; it is only used to create the man pages.
+
+ * The cabal file has been modified so that the pandoc library is used
+ in building the pandoc executable. (This required moving `pandoc.hs`
+ from `src` to `.`.) This cuts compile time in half.
+
+ * `-O2` is no longer used in building pandoc. The performance improvement
+ it yields is so slight that it is not worth it. (Measured with
+ benchmarks on ghc 7.4.)
+
+ * The `executable` and `library` flags have been removed.
+
+ * `-threaded` has been removed from ghc-options.
+
+ * Version bounds of dependencies have been raised, and the
+ `blaze_html_0_5` flag now defaults to True. Pandoc now compiles on
+ GHC 7.6.
+
+ * We now require base >= 4.2.
+
+ * Integrated the benchmark program into cabal. One can now do:
+
+ cabal configure --enable-benchmarks && cabal build
+ cabal bench --benchmark-option='markdown' --benchmark-option='-s 20'
+
+ The benchmark now uses README + testsuite, so benchmark results
+ from older versions aren't comparable.
+
+ * Integrated test suite with cabal.
+ To run tests, configure with `--enable-tests`, then `cabal test`.
+ You can specify particular tests using `--test-options='-t markdown'`.
+ No output is shown unless tests fail. The Haskell test modules
+ have been moved from `src/` to `tests/`.
+
+ * Moved all data files and templates to the `data/` subdirectory.
+
+ * Added an `embed_data_files` cabal flag. This causes all
+ data files to be embedded in the binary, so that the binary
+ is self-sufficient and can be relocated anywhere, copied on
+ a USB key, etc. The Windows installer now uses this.
+ (Since we no longer have the option to build the executable
+ without the library, this is the only way to get a relocatable
+ binary on Windows.)
+
+ * Removed pcre3.dll from windows package.
+ It isn't needed unless highlighting-kate is compilled with the
+ `pcre-light` flag. By default, regex-prce-builtin is used.
+
+
+pandoc (1.9.4.2)
+
+ * Don't encode/decode file paths if base >= 4.4.
+ Prior to base 4.4, filepaths and command line arguments were treated
+ as unencoded lists of bytes, not unicode strings, so we had to work
+ around that by encoding and decoding them. This commit adds CPP
+ checks for the base version that intelligibly enable encoding/decoding
+ when needed. Fixes a bug with multilingual filenames when pandoc was
+ compiled with ghc 7.4 (#540).
+
+ * Don't generate an empty H1 after hrule slide breaks.
+ We now use a slide-level header with contents `[Str "\0"]` to mark
+ an hrule break. This avoids creation of an empty H1 in these
+ contexts. Closes #484.
+
+ * Docbook reader: Added support for "bold" emphasis. Thanks to Mauro Bieg.
+
+ * In make_osx_package.sh, ensure citeproc-hs is built with the
+ embed_data_files flag.
+
+ * MediaWiki writer: Avoid extra blank lines after sublists (Gavin Beatty).
+
+ * ConTeXt writer: Don't escape `&`, `^`, `<`, `>`, `_`,
+ simplified escapes for `}` and `{` to `\{` and `\}` (Aditya Mahajan).
+
+ * Fixed handling of absolute URLs in CSS imports with `--self-contained`.
+ Closes #535.
+
+ * Added webm to mime types. Closes #543.
+
+ * Added some missing exports and tests to the cabal file
+ (Alexander V Vershilov).
+
+ * Compile with `-rtsopts` and `-threaded` by default.
+
+pandoc (1.9.4.1)
+
+ * Markdown reader: Added `cf.` and `cp.` to list of likely abbreviations.
+
+ * LaTeX template: Added `linkcolor`, `urlcolor` and `links-as-notes`
+ variables. Make TOC links black.
+
+ * LaTeX template improvements.
+
+ + Don't print date unless one is given explicitly in the document.
+ + Simplified templates.
+ + Use fontenc [T1] by default, and lmodern.
+ + Use microtype if available.
+
+ * Biblio:
+
+ + Add comma to beginning of bare suffix, e.g. `@item1 [50]`.
+ Motivation: `@item1 [50]` should be as close as possible to
+ `[@item1, 50]`.
+ + Added workaround for a bug in citeproc-hs 0.3.4 that causes footnotes
+ beginning with a citation to be empty. Closes #531.
+
+ * Fixed documentation on mixed lists. Closes #533.
+
+pandoc (1.9.4)
+
+ * Simplified `Text.Pandoc.Biblio` and fixed bugs with citations inside
+ footnotes and captions. We now handle note citations by inserting
+ footnotes during initial citation processing, and doing a separate
+ pass later to remove notes inside notes.
+
+ * Added 'zenburn' highlight style from highlighting-kate.
+
+ * Added Slideous writer. Slideous is an HTML + javascript slide show
+ format, similar to Slidy, but works with IE 7. (Jonas Smedegaard)
+
+ * LaTeX writer:
+
+ + Ensure we don't have extra blank lines at ends of cells.
+ This can cause LaTeX errors, as they are interpreted as new paragraphs.
+ + More consistent interblock spacing.
+ + Require highlighting-kate >= 0.5.1, for proper highlighted inline
+ code in LaTeX. Closes #527.
+ + Ensure that a Verbatim at the end of a footnote is followed by
+ a newline. (Fixes a regression in the previous version.)
+ + In default template, use black for internal links and TOC.
+ Added commented-out code to use footnotes for links, as would
+ be suitable in print output.
+
+ * Beamer writer: When `--incremental` is used, lists inside
+ a block quote should appear all at once. (This makes Beamer
+ output consistent with the HTML slide show formats.)
+
+ * ConTeXt writer:
+
+ + Escape `%` as `\letterpercent{}` not `\letterpercent `,
+ to avoid gobbling spaces after the `%` sign.
+ + Ensure space after `\stopformula`.
+
+ * Markdown writer:
+
+ + Use `:` form instead of `~` in definition lists, for better
+ compatibility with other markdown implementations.
+ + Don't wrap the term, because it breaks definition lists.
+ + Use a nonzero space to prevent false recognition
+ of list marker in ordered lists. Closes #516.
+
+ * Org writer: Add space before language name. Closes #523.
+
+ * Docx writer: Simplified bullet characters so they work properly
+ with Word 2007. Closes #520.
+
+ * LaTeX reader: Support `\centerline`.
+
+ * RST reader: handle figures. Closes #522.
+
+ * Textile reader: fix for `<notextile>` and `==`. Closes #517.
+ (Paul Rivier)
+
+pandoc (1.9.3)
+
+ * Fixed bug in `fromEntities`. The previous version would turn
+ `hi & low you know;` into `hi &`.
+
+ * HTML reader:
+
+ + Don't skip nonbreaking spaces.
+ Previously a paragraph containing just `&nbsp;` would be rendered
+ as an empty paragraph. Thanks to Paul Vorbach for pointing out the bug.
+ + Support `<col>` and `<caption>` in tables. Closes #486.
+
+ * Markdown reader:
+
+ + Don't recognize references inside delimited code blocks.
+ + Allow list items to begin with lists.
+
+ * Added basic docbook reader (John MacFarlane and Mauro Bieg).
+
+ * LaTeX reader:
+
+ + Handle `\bgroup`, `\egroup`, `\begingroup`, `\endgroup`.
+ + Control sequences can't be followed by a letter.
+ This fixes a bug where `\begingroup` was parsed as `\begin`
+ followed by `group`.
+ + Parse 'dimension' arguments to unknown commands. e.g. `\parindent0pt`
+ + Make `\label` and `\ref` sensitive to `--parse-raw`.
+ If `--parse-raw` is selected, these will be parsed as raw latex
+ inlines, rather than bracketed text.
+ + Don't crash on unknown block commands (like `\vspace{10pt}`)
+ inside `\author`; just skip them. Closes #505.
+
+ * Textile reader:
+
+ + Implemented literal escapes with `==` and `<notextile>`. Closes #473.
+ + Added support for LaTeX blocks and inlines (Paul Rivier).
+ + Better conformance to RedCloth inline parsing (Paul Rivier).
+ + Parse '+text+' as emphasized (should be underlined, but this
+ is better than leaving literal plus characters in the output.
+
+ * Docx writer: Fixed multi-paragraph list items. Previously they each
+ got a list marker. Closes #457.
+
+ * LaTeX writer:
+
+ + Added `--no-tex-ligatures` option to avoid replacing
+ quotation marks and dashes with TeX ligatures.
+ + Use `fixltx2e` package to provide '\textsubscript'.
+ + Improve spacing around LaTeX block environments:
+ quote, verbatim, itemize, description, enumerate.
+ Closes #502.
+ + Use blue instead of pink for URL links in latex/pdf output.
+
+ * ConTeXt writer: Fixed escaping of `%`.
+ In text, `%` needs to be escaped as `\letterpercent`, not `\%`
+ Inside URLs, `%` needs to be escaped as `\%`
+ Thanks to jmarca and adityam for the fix. Closes #492.
+
+ * Texinfo writer: Escape special characters in node titles.
+ This fixes a problem pointed out by Joost Kremers. Pandoc used
+ to escape an '@' in a chapter title, but not in the corresponding
+ node title, leading to invalid texinfo.
+
+ * Fixed document encoding in texinfo template.
+ Resolves Debian Bug #667816.
+
+ * Markdown writer:
+
+ + Don't force delimited code blocks to be flush left.
+ Fixes bug with delimited code blocks inside lists etc.
+ + Escape `<` and `$`.
+
+ * LaTeX writer: Use `\hyperref[ident]{text}` for internal links.
+ Previously we used `\href{\#ident}{text}`, which didn't work on
+ all systems. Thanks to Dirk Laurie.
+
+ * RST writer: Don't wrap link references. Closes #487.
+
+ * Updated to use latest versions of blaze-html, mtl.
+
+
+pandoc (1.9.2)
+
+ * LaTeX reader:
+
+ + Made `lstlisting` work as a proper verbatim environment.
+ + Fixed bug parsing LaTeX tables with one column.
+
+ * LaTeX writer:
+
+ + Use `{}` around `ctable` caption, so that formatting can be used.
+ + Don't require eurosym package unless document has a €.
+
+ * LaTeX template: Added variables for `geometry`, `romanfont`,
+ `sansfont`, `mathfont`, `mainfont` so users can more easily
+ customize fonts.
+
+ * PDF writer:
+
+ + Run latex engine at least two times, to ensure
+ that PDFs will have hyperlinked bookmarks.
+ + Added PDF metadata (title,author) in LaTeX standalone + PDF output.
+
+ * Texinfo writer: retain directories in image paths. (Peter Wang)
+
+ * RST writer: Better handling of inline formatting, in accord
+ with docutils' "inline markup recognition rules" (though we don't
+ implement the unicode rules fully). Now `hi*there*hi` gets
+ rendered properly as `hi\ *there*\ hi`, and unnecessary
+ `\ ` are avoided around `:math:`, `:sub:`, `:sup:`.
+
+ * RST reader:
+
+ + Parse `\ ` as null, not escaped space.
+ + Allow `` :math:`...` `` even when not followed by blank
+ or `\`. This does not implement the complex rule docutils follows,
+ but it should be good enough for most purposes.
+ + Add support for the rST default-role directive. (Greg Maslov)
+
+ * Text.Pandoc.Parsing: Added `stateRstDefaultRole` field to `ParserState`.
+ (Greg Maslov)
+
+ * Markdown reader: Properly handle citations nested in other inline
+ elements.
+
+ * Markdown writer: don't replace empty alt in image with "image".
+
+ * DZSlides: Updated template.html and styles in default template.
+ Removed bizarre CSS for `q` in dzslides template.
+
+ * Avoid repeated `id` attribute in section and header in HTML slides.
+
+ * README improvements: new instructions on internal links,
+ removed misleading note on reST math.
+
+ * Build system:
+
+ + Fixed Windows installer so that dzslides works.
+ + Removed stripansi.sh.
+ + Added .travis.yml for Travis continuous integration support..
+ + Fixed upper bound for zlib (Sergei Trofimovich).
+ + Fixed upper bound for test-framework.
+ + Updated haddocks for haddock-2.10 (Sergei Trofimovich).
+
+pandoc (1.9.1.2)
+
+ * Added `beamer+lhs` as output format.
+
+ * Don't escape `<` in `<style>` tags with `--self-contained`.
+ This fixes a bug which prevented highlighting from working
+ when using `--self-contained`.
+
+ * PDF: run latex engine three times if `--toc` specified.
+ This fixes page numbers in the table of contents.
+
+ * Docx writer: Added TableNormal style to tables.
+
+ * LaTeX math environment fixes. `aligned` is now used instead of
+ the nonexistent `aligned*`. `multline` instead of the nonexistent
+ `multiline`.
+
+ * LaTeX writer: Use `\textasciitilde` for literal `~`.
+
+ * HTML writer: Don't escape contents of EQ tags with --gladtex.
+ This fixes a regression from 1.8.
+
+ * Use `<q>` tags for Quoted items for HTML5 output.
+ The quote style can be changed by modifying the template
+ or including a css file. A default quote style is included.
+
+ * LaTeX reader: Fixed accents (\~{a}, `\c{c}`).
+ Correctly handle \^{}. Support "minted" as a LaTeX verbatim block.
+
+ * Updated LaTeX template for better language support.
+ Use `polyglossia` instead of `babel` with xetex.
+ Set `lang` as documentclass option.
+ `\setmainlanguage` will use the last of a comma-separated
+ list of languages. Thanks to François Gannaz.
+
+ * Fixed default LaTeX template so `\euro` and `€` work. The
+ `eurosym` package is needed if you are using pdflatex.
+
+ * Fixed escaping of period in man writer (thanks to Michael Thompson).
+
+ * Fixed list label positions in beamer.
+
+ * Set `mainlang` variable in context writer.
+ This parallels behavior of latex writer. `mainlang` is the last
+ of a comma-separated list of languages in lang.
+
+ * EPUB language metadat: convert e.g. `en_US` from locale to `en-US`.
+
+ * Changed `-V` so that you can specify a key without a value.
+ Such keys get the value `true`.
+
+ * Fixed permissions on installed man pages - thanks Magnus Therning.
+
+ * Windows installer: require XP or higher. The installer is
+ now compiled on a Windows 7 machine, which fixes a problem
+ using citation functions on Windows 7.
+
+ * OSX package: Check for 64-bit Intel CPU before installing.
+
+pandoc (1.9.1.1)
+
+ * Better handling of raw latex environments in markdown. Now
+
+ \begin{equation}
+ a_1
+ \end{equation}
+
+ turns into a raw latex block as expected.
+
+ * Improvements to LaTeX reader:
+
+ + Skip options after block commands.
+ + Correctly handle `{\\}` in braced.
+ + Added a needed 'try'.
+ + Citations: add `, ` to suffix if it doesn't start with space or
+ punctuation. Otherwise we get no space between the year and the
+ suffix in author-date styles.
+
+ * Added two needed data files for S5. This fixes a problem with
+ `pandoc -t s5 --self-contained`. Also removed `slides.min.js`,
+ which was no longer being used.
+
+ * Fixed some minor problems in `reference.docx`:
+ name on "Date" style, `xCs` instead of `xIs`.
+
+ * Fixed a problem creating docx files using a reference docx
+ modified using Word. The problem seems to be that Word
+ modifies `_rels/.rels`, changing the Type of the Relationship to
+ `docProps/core.xml`. Pandoc now changes this back to the correct
+ value if it has been altered, fixing the problem.
+
+ * Fixed html5 template so it works properly with highlighting.
+
+pandoc (1.9.1)
+
+ * LaTeX reader:
+
+ + Fixed regression in 1.9; properly handle escaped $ in latex math.
+ + Put LaTeX verse environments in blockquotes.
+
+ * Markdown reader:
+
+ + Limit nesting of strong/emph. This avoids exponential lookahead
+ in parasitic cases, like `a**a*a**a*a**a*a**a*a**a*a**a*a**a*a**`.
+ + Improved attributes syntax (inn code blocks/spans):
+ (1) Attributes can contain line breaks. (2) Values in key-value
+ attributes can be surrounded by either double or single quotes, or
+ left unquoted if they contain no spaces.
+
+ * Don't wrap headers in markdown or RST writers.
+
+ * Added `stateMaxNestingLevel` to `ParserState`.
+ We set this to 6, so you can still have `Emph` inside `Emph`,
+ just not indefinitely.
+
+ * More efficient implementation of `nowrap` in `Text.Pandoc.Pretty`.
+
+ * `Text.Pandoc.PDF`: Only run latex twice if `\tableofcontents`
+ is present.
+
+ * Require highlighting-kate >= 0.5.0.2, texmath >= 0.6.0.2.
+
+pandoc (1.9.0.5)
+
+ * Changed cabal file so that build-depends for the test program
+ are not required unless the tests flag is used.
+
+ * LaTeX writer: insert `{}` between adjacent hyphens so they don't
+ form ligatures (dashes) in code spans.
+
+pandoc (1.9.0.4)
+
+ * Raised version bound on test-framework to avoid problems
+ compiling tests on GHC 7.4.1.
+
+ * LaTeX reader: Use raw LaTeX as fallback inline text for Cites,
+ so citations don't just disappear unless you process with
+ citeproc. Ignore `\bibliographystyle`, `\nocite`.
+
+ * Simplified tex2pdf; it will always run latex twice to
+ resolve table of contents and hyperrefs.
+
+pandoc (1.9.0.3)
+
+ * Require Cabal >= 1.10.
+ * Tweaked cabal file to meet Cabal 1.10 requirements.
+
+pandoc (1.9.0.2)
+
+ * Allow build with json 0.4 or 0.5. Otherwise we can't build with
+ ghc 6.12.
+
+pandoc (1.9)
+
+ [new features]
+
+ * Added a Microsoft Word `docx` writer. The writer includes support
+ for highlighted code and for math (which is converted from TeX to OMML,
+ Office's native math markup language, using texmath's new OMML module).
+ A new option `--reference-docx` allows the user to customize the
+ styles.
+
+ * Added an `asciidoc` writer (<http://www.methods.co.nz/asciidoc/>).
+
+ * Better support for slide shows:
+
+ + Added a `dzslides` writer. DZSlides is a lightweight HTML5/javascript
+ slide show format due to Paul Rouget (<http://paulrouget.com/dzslides/>).
+
+ + Added a LaTeX `beamer` writer. Beamer is a LaTeX package for creating
+ slide presentations.
+
+ + New, flexible rules for dividing documents into sections and slides
+ (see the "Structuring the slide show" in the User's Guide). These
+ are backward-compatible with the old rules, but they allow slide
+ shows to be organized into sections and subsections containing
+ multiple slides.
+
+ + A new `--slide-level` option allows users to override defaults
+ and select a slide level below the first header level with content.
+
+ * A new `--self-contained` option produces HTML output that does not
+ depend on an internet connection or the presence of any external
+ files. Linked images, CSS, and javascript is downloaded (or fetched
+ locally) and encoded in `data:` URIs. This is useful for making portable
+ `HTML slide shows. The --offline` option has been deprecated and is now
+ `treated as a synonym or --self-contained`.
+
+ * Support for PDF output:
+
+ + Removed the old `markdown2pdf`.
+ + `pandoc` can now create PDFs (assuming you have latex and a set of
+ appropriate packages installed): just specify an output file with the
+ `.pdf` extension.
+ + A new option `--latex-engine` allows you to specify `pdflatex`,
+ `xelatex`, or `lualatex` as the processor.
+
+ * Highlighting changes:
+
+ + Syntax highlighting is now a standard feature; the `highlighting`
+ flag is no longer needed when compiling.
+ + A new `--no-highlight` option allows highlighting to be disabled.
+ + Highlighting now works in `docx`, `latex`, and `epub`, as well as
+ `html`, `html5`, `dzslides`, `s5`, and `slidy`.
+ + A new `--highlight-style` option selects between various highlighting
+ color themes.
+
+ * Internal links to sections now work in ConTeXt and LaTeX as well as HTML.
+
+ * LaTeX `\include` and `\usepackage` commands are now processed,
+ provided the files are in the working directory.
+
+ * EPUB improvements:
+
+ + Internal and external links now work in EPUB.
+ + Raw HTML is allowed.
+ + New `--epub-embed-font` option.
+ + Customizable templates for EPUB pages offer more control over
+ formatting: `epub-page.html`, `epub-coverimage.html`,
+ `epub-titlepage.html`.
+
+ * `--mathml` now works with DocBook.
+
+ * Added support for math in RST reader and writer. Inline math uses the
+ `` :math:`...` `` construct. Display math uses
+
+ .. math:: ...
+
+ or if the math is multiline,
+
+ .. math::
+
+ ...
+
+ These constructions are now supported now by `rst2latex.py`.
+
+ * GitHub syntax for fenced code blocks is supported in pandoc's
+ markdown. You can now write
+
+ ```ruby
+ x = 2
+ ```
+
+ instead of
+
+ ~~~ {.ruby}
+ x = 2
+ ~~~~
+
+ * Easier scripting: a new `toJsonFilter` function makes it easier to
+ write Haskell scripts to manipulate the Pandoc AST.
+
+ [behavior changes]
+
+ * Fixed parsing of consecutive lists in markdown.
+ Pandoc previously behaved like Markdown.pl for consecutive
+ lists of different styles. Thus, the following would be parsed
+ as a single ordered list, rather than an ordered list followed
+ by an unordered list:
+
+ 1. one
+ 2. two
+
+ - one
+ - two
+
+ This change makes pandoc behave more sensibly, parsing this as
+ two lists. Any change in list type (ordered/unordered) or in
+ list number style will trigger a new list. Thus, the following
+ will also be parsed as two lists:
+
+ 1. one
+ 2. two
+
+ a. one
+ b. two
+
+ Since we regard this as a bug in Markdown.pl, and not something
+ anyone would ever rely on, we do not preserve the old behavior
+ even when `--strict` is selected.
+
+ * Dashes work differently with `--smart`: `---` is always em-dash,
+ and `--` is always en-dash. Pandoc no longer tries to guess when
+ `-` should be en-dash. *Note:* This may change how existing documents
+ look when processed with pandoc. A new option, `--old-dashes`,
+ is provided for legacy documents.
+
+ * The markdown writer now uses setext headers for levels 1-2.
+ The old behavior (ATX headers for all levels) can be restored
+ using the new `--atx-headers` option.
+
+ * Links are now allowed in markdown image captions. They are also
+ allowed in links, but will appear there as regular text. So,
+
+ [link with [link](/url)](/url)
+
+ will turn into
+
+ <p><a href="/url">link with link</a></p>
+
+ * Improved handling of citations using `citeproc-hs-0.3.4`.
+ Added `--citation-abbreviations` option.
+
+ * Citation keys can no longer end with a punctuation character.
+ This means that `@item1.` will be parsed as a citation with key
+ 'item1', followed by a period, instead of a citation with key
+ 'item1.', as was the case previously.
+
+ * In HTML output, citations are now put in a span with class `citation`.
+
+ * The markdown reader now recognizes DocBook block and inline tags.
+ It was always possible to include raw DocBook tags in a markdown
+ document, but now pandoc will be able to distinguish block from
+ inline tags and behave accordingly. Thus, for example,
+
+ <sidebar>
+ hello
+ </sidebar>
+
+ will not be wrapped in `<para>` tags.
+
+ * The LaTeX parser has been completely rewritten; it is now much more
+ accurate, robust, and extensible. However, there are two important
+ changes in how it treats unknown LaTeX. (1) Previously, unknown
+ environments became BlockQuote elements; now, they are treated
+ as "transparent", so `\begin{unknown}xyz\end{unknown}` is the
+ same as `xyz`. (2) Previously, arguments of unknown commands
+ were passed through with their braces; now the braces are stripped
+ off.
+
+ * `--smart` is no longer selected automatically with `man` output.
+
+ * The deprecated `--xetex` option has been removed.
+
+ * The `--html5`/`-5` option has been deprecated. Use `-t html5`
+ instead. `html5` and `html5+lhs` are now separate output formats.
+
+ * Single quotes are no longer escaped in HTML output. They do not
+ need to be escaped outside of attributes.
+
+ * Pandoc will no longer transform leading newlines in code
+ blocks to `<br/>` tags.
+
+ * The ODT writer now sizes images appropriately, using the image
+ size and DPI information embedded in the image.
+
+ * `--standalone` is once again implicitly for a non-text output format
+ (ODT, EPUB). You can again do `pandoc test.txt -o test.odt`
+ and get a standalone ODT file.
+
+ * The Docbook writer now uses `<sect1>`, `<sect2>`, etc. instead of
+ `<section>`.
+
+ * The HTML writer now uses `<del>` for strikeout.
+
+ * In HTML output with `--section-divs`, the classes `section` and
+ `level[1,2,..6]` are put on the `div` tags so they can be styled.
+ In HTML 5 output with `--section-divs`, the classes
+ `level[1,2,...6]` are put on `section` tags.
+
+ * EPUB writer changes:
+
+ + The `lang` variable now sets the language
+ in the metadata (if it is not set, we default to the locale).
+ + EPUB: UTF-8 is used rather than decimal entities.
+
+ * Added `titleslide` class to title slide in S5 template.
+
+ * In HTML, EPUB, and docx metadata, the date is normalized into
+ YYYY-MM-DD format if possible. (This is required for validation.)
+
+ * Attributes in highlighted code blocks are now preserved in HTML.
+ The container element will have the classes, id, and key-value attributes
+ you specified in the delimited code block. Previously these were stripped
+ off.
+
+ * The reference backlink in the HTML writer no longer has a special
+ `footnoteBacklink` class.
+
+ * The HTML template has been split into `html` and `html5` templates.
+
+ * Author and date are treated more consistently in HTML templates.
+ Authors are now `<h2>`, date `<h3>`.
+
+ * URLs are hyphenated in the ConTeXt writer (B. Scott Michel).
+
+ * In `Text.Pandoc.Builder`, `+++` has been replaced by `<>`.
+
+ [bug fixes]
+
+ * Better support for combining characters and East Asian wide characters
+ in markdown and reST.
+
+ * Better handling of single quotes with `--smart`.
+ Previously `D'oh l'*aide*` would be parsed with left and right single
+ quotes instead of apostrophes. This kind of error is now fixed.
+
+ * Highlighting: Use `reads` instead of `read` for better error handling.
+ Fixes crash on `startNum="abc"`.
+
+ * Added blank comment after directives in rst template.
+
+ * Unescape entities in citation `refId`. The `refId`s coming
+ from citeproc contain XML numeric entities, and these don't match with the
+ citation keys parsed by pandoc. Solution is to unescape them.
+
+ * HTML reader: Fixed bug parsing tables with both thead and tbody.
+
+ * Markdown reader:
+
+ + Better handling of escapes in link URLs and titles.
+ + Fixed backslash escapes in reference links.
+ + Fixed bug in table/hrule parsing, by checking that the top
+ line of a table is not followed by a blank line. This bug caused
+ slowdowns on some files with hrules and tables, as pandoc tried to
+ interpret the hrules as the tops of multiline tables.
+ + Fixed bug in code block attribute parser. Previously the ID attribute
+ got lost if it didn't come first. Now attributes can come in any order.
+
+ * RST reader: allow footnotes followed by newline without space characters.
+
+ * LaTeX reader:
+
+ + Ignore empty groups {}, { }.
+ + LaTeX reader: Handle \@.
+ + LaTeX reader: Don't crash on commands like `\itemsep`.
+ + LaTeX reader: Better handling of letter environments.
+
+ * RST writer: Fixed bug involving empty table cells. isSimple was being
+ calculated in a way that assumed there were no non-empty cells.
+
+ * ConTeXt writer:
+
+ + Made `--toc` work even without `--number-sections`.
+ + Escape # in link URLs.
+ + Use buffering for footnotes containing code blocks.
+ + Changed 'descr' to 'description', fixed alignment.
+
+ * LaTeX writer:
+
+ + Escape euro character.
+ + Don't escape ~ inside href{...}.
+ + Escape # in href URLs.
+ + Improved detection of book classes. We now check the
+ `documentclass` variable, and if that is not set, we look through
+ the template itself. Also, we have added the KOMA classes scrreprt
+ and scrbook. You can now make a book using
+ `pandoc -V documentclass:book mybook.txt -o mybook.pdf`
+ + LHS files now set the "listings" variable, so that the definition
+ of the `code` environment will be included in the template.
+ + Links are colored blue by default (this can be changed by
+ modifying `hyperref` settings in the template).
+ + Added `lang` variable to LaTeX template.
+
+ * HTML writer:
+
+ + Fixed bug in HTML template with html5 and mathml.
+ + Don't use self-closing img, br, hr tags for HTML5.
+ + Use `<section>` for footnotes if HTML5.
+ + Update HTML templates to use Content-Style-Type meta tag.
+ + Use separate variables for meta-date, meta-author.
+ This makes footnotes work in author and date fields.
+ + Use 'vertical-align:middle' in WebTeX math for better alignment.
+
+ * S5/slidy writer: Make footnotes appear on separate slide at end.
+
+ * MIME: Added 'layout-cache' to getMimeType. This ensures that the
+ META-INF/manifest.xml for ODT files will have everything it needs, so
+ that ODT files modified by LibreOffice can be used as `--reference-odt`.
+
+ * `Text.Pandoc.Templates`: Return empty string for json template.
+
+ * `Text.Pandoc.Biblio`:
+
+ + Expand citations recursively inside nested inlines.
+ + Treat `\160` as space when parsing locator and suffix.
+ This fixes a bug with "p. 33" when `--smart` is used. Previously
+ the whole "p. 33" would be included in the suffix, with no locator.
+ + Put whole author-in-text citation in a Cite. Previously just the
+ date and other info went in the Cite.
+ + Don't add comma+space to prefix if it ends in punctuation.
+
+ * Updated chicago-author-date.csl. The old version did not work
+ properly for edited volumes with no author.
+
+ * EPUB writer:
+
+ + Add date to EPUB titlepage and metadata.
+ + Added TOC identifier in EPUB page template.
+ + Don't generate superfluous file `cover-image.jpg`.
+
+ [under the hood improvements]
+
+ * Modified `make_osx_package.sh` to use cabal-dev.
+ Items are no longer installed as root.
+ Man pages are zipped and given proper permissions.
+
+ * Modified windows installer generater to use cabal-dev.
+
+ * Setup: Making man pages now works with cabal-dev (at least on OSX). In
+ Setup.hs we now invoke 'runghc' in a way that points it to the correct
+ package databases, instead of always falling back to the default user
+ package db.
+
+ * Updated to work with GHC 7.4.1.
+
+ * Removed dependency on old-time.
+
+ * Removed dependency on dlist.
+
+ * New slidy directory for "self-contained."
+
+ * TeXMath writer: Use unicode thin spaces for thin spaces.
+
+ * Markdown citations: don't strip off initial space in locator.
+
+ [API changes]
+
+ * Removed `Apostrophe`, `EmDash`, `EnDash`, and `Ellipses`
+ from the native `Inline` type in pandoc-types. Now we use `Str`
+ elements with unicode.
+
+ * Improvements to `Text.Pandoc.Builder`:
+
+ + `Inlines` and `Blocks` are now newtypes (not synonyms for
+ sequences).
+ + Instances are defined for `IsString`, `Show`, `Read`, `Monoid`,
+ and a new `Listable` class, which allows these to be manipulated
+ to some extent like lists. Monoid append includes automatic
+ normalization.
+ + `+++` has been replaced by `<>` (mappend).
+
+ * Use blaze-html instead of xhtml for HTML generation.
+ This changes the type of `writeHtml`.
+
+ * `Text.Pandoc.Shared`:
+
+ + Added `warn` and `err`.
+ + Removed `unescapeURI`, modified `escapeURI`.
+ (See under [behavior changes], above.)
+
+ * Changes in URI escaping: Previously the readers escaped URIs by
+ converting unicode characters to octets and then percent encoding.
+ Now unicode characters are left as they are, and `escapeURI` only
+ percent-encodes space characters. This gives more readable
+ URIs, and works well with modern user agents. URIs are no longer unescaped
+ at all on conversion to `markdown`, `asciidoc`, `rst`, `org`.
+
+ * New module `Text.Pandoc.SelfContained`.
+
+ * New module `Text.Pandoc.Docx`.
+
+ * New module `Text.Pandoc.PDF`.
+
+ * Added `writerBeamer` to `WriterOptions`.
+
+ * Added `normalizeDate` to `Text.Pandoc.Shared`.
+
+ * Added `splitStringWithIndices` in `Text.Pandoc.Shared`.
+ This is like `splitWithIndices`, but it is sensitive to distinctions
+ between wide, combining, and regular characters.
+
+ * `Text.Pandoc.Pretty`:
+
+ + Added `chomp` combinator.
+ + Added `beforeNonBreak` combinator. This allows you to include
+ something conditionally on it being before a nonblank.
+ Used for RST inline math.
+ + Added `charWidth` function. All characters marked W or F in the unicode
+ spec EastAsianWidth.txt get width 2.
+ + Added `realLength`, based on `charWidth`. `realLength` is now
+ used in calculating offsets.
+
+ * New module `Text.Pandoc.Slides`, for common functions for breaking
+ a document into slides.
+
+ * Removed `Text.Pandoc.S5`, which is no longer needed.
+
+ * Removed `Text.Pandoc.CharacterReferences`. Moved
+ `characterReference` to `Text.Pandoc.Parsing`.
+ `decodeCharacterReferences` is replaced by `fromEntities`
+ in `Text.Pandoc.XML`.
+
+ * Added `Text.Pandoc.ImageSize`. This is intened for use
+ in `docx` and `odt` writers, so the size and dpi of images
+ can be calculated.
+
+ * Removed `writerAscii` in `WriterOptions`.
+
+ * Added `writerHighlight` to `WriterOptions`.
+
+ * Added `DZSlides` to `HTMLSlideVariant`.
+
+ * `writeEPUB` has a new argument for font files to embed.
+
+ * Added `stateLastStrPos` to `ParserState`. This lets us keep track
+ of whether we're parsing the position immediately after a regular
+ (non-space, non-symbol) string, which is useful for distinguishing
+ apostrophes from single quote starts.
+
+ * `Text.Pandoc.Parsing`:
+
+ + `escaped` now returns a `Char`.
+ + Removed `charsInBalanced'`, added a character parser as
+ a parameter of `charsInBalanced`. This is needed for
+ proper handling of escapes, etc.
+ + Added `withRaw`.
+
+ * Added `toEntities` to `Text.Pandoc.XML`.
+
+ * `Text.Pandoc.Readers.LaTeX`:
+
+ + Export `handleIncludes`.
+ + Export `rawLaTeXBlock` instead of `rawLaTeXEnvironment'`.
+
+ * Added `ToJsonFilter` class and `toJsonFilter` function to
+ `Text.Pandoc`, deprecating the old `jsonFilter` function.
+
+ * `Text.Pandoc.Highlighting`:
+
+ + Removed `highlightHtml`, `defaultHighlightingCss`.
+ + Export `formatLaTeXInline`, `formatLaTeXBlock`, and `highlight`, plus
+ key functions from highlighting-kate.
+ + Changed types of highlighting function. `highlight` returns a
+ `Maybe`, not an `Either`.
+
+pandoc (1.8.2.1)
+
+ * Relaxed cabal consntraints for test-framework (S. Trofimovich).
+
+ * Relaxed cabal constraints for pandoc-types.
+
+ * Adjusted Arbitrary instance to help avoid timeouts in tests.
+
+ * Added `Tests.Writers.Markdown` to cabal file.
+
+pandoc (1.8.2)
+
+ * Added script to produce OS X package.
+
+ * Made `templates` directory a git submodule. This should make it
+ easier for people to revise their custom templates when the default
+ templates change.
+
+ * Changed template naming scheme: `FORMAT.template` -> `default.FORMAT`.
+ **Note:** If you have existing templates in `~/.pandoc/templates`, you
+ must rename them to conform to the new scheme!
+
+ * Fixed smart quotes bug, now handling `'...hi'` properly.
+
+ * RST reader:
+
+ + Partial support for labeled footnotes.
+ + Improved accuracy of `simpleReferenceName` parser.
+
+ * HTML reader:
+
+ + Substitute correct unicode characters for
+ characters in the 128..159 range, which are often found even in
+ HTML that purports to be UTF-8.
+
+ * LaTeX reader: Handle `\subtitle` command (a subtitle is added
+ to the title, after a colon and linebreak). Closes #280.
+
+ * Leaner `reference.odt`.
+
+ * Added unexported module `Text.Pandoc.MIME` for use in
+ the ODT writer.
+
+ * ODT writer: Construct `manifest.xml` based on archive contents.
+ This fixes a bug in ODTs containing images. Recent versions of
+ LibreOffice would reject these as corrupt, because `manifest.xml`
+ did not contain a reference to the image files.
+
+ * LaTeX writer:
+
+ + Make verbatim environments flush to avoid spurious
+ blank lines. Closes #277.
+ + Use `\texttt` and escapes insntead of `\verb!...!`, which
+ is too fragile (doesn't work in command arguments).
+ + Use `\enquote{}` for quotes if the template includes
+ the `csquotes` package. This provides better support for
+ local quoting styles. (Thanks to Andreas Wagner for the idea.)
+
+ * ConTeXt writer: Make `\starttyping`/`\stoptyping` flush with
+ margin, preventing spurious blank lines.
+
+ * Slidy writer:
+
+ + Use non-minimized version of `slidy.css` with `--offline`
+ option, so users can more easily edit it.
+ + Also fixed a bug in the CSS that prevented proper centering
+ of title (now reported and fixed upstream).
+
+ * S5 writer:
+
+ + Replaced `s5/default/slides.js.{comment,packed}` with
+ new compressed `s5/default/slides.min.js`.
+ + Use `data:` protocol to embed S5 CSS in `<link>` tags,
+ when `--offline` is specified. Using inline CSS didn't
+ work with Chrome or Safari. This fixes offline
+ S5 on those browsers.
+
+ * HTML writer: Removed English title on footnote backlinks.
+ This is incongrous in non-English documents.
+
+ * Docbook writer:
+
+ + Use CALS tables. (Some older docbook software does not work
+ well with XHTML tables.) Closes #77.
+ + Use `programlisting` tags (instead of `screen`) for code blocks.
+
+ * `markdown2pdf`:
+
+ + Calls latex with `-halt-on-error -interaction nonstopmode` instead
+ of `-interaction=batchmode`, which essentially just ignored errors,
+ leading to bad results. Better to know when something is wrong.
+ + Fixed issues with non-UTF-8 output of `pdflatex`.
+ + Better error reporting.
+
+ * `--mathjax` now takes an optional URL argument. If it is not
+ provided, pandoc links directly to the (secure) mathjax CDN,
+ as now recommended (thanks to dsanson).
+
+ * Deprecated `--xetex` option in `pandoc`. It is no longer needed,
+ since the LaTeX writer now produces a file that can be processed by
+ `latex`, `pdflatex`, `lualatex`, or `xelatex`.
+
+ * Introduced `--luatex` option to `markdown2pdf`. This causes `lualatex`
+ to be used to create the PDF.
+
+ * If a template specified with `--template` is not found, look for it
+ in `datadir`. Also, if no extension is provided, supply one based
+ on the writer. So now you can put your `special.latex` template in
+ `~/.pandoc/templates`, and use it from any directory via
+ `pandoc -t latex --template special`.
+
+ * Default template improvements:
+
+ + HTML: Display author and date after title.
+ + HTML: Made table of contents more customizable. The container
+ for the TOC is now in the template, so users can insert a header
+ or other styling. (Thanks to Bruce D'Arcus for the suggestion.)
+ + HTML, Slidy, S5: Enclose scripts in CDATA tags.
+ + Slidy, S5: Added `s5-url` and `slidy-url` variables, instead of
+ hard-coding. If you want to put your slidy files in the slidy
+ subdirectory, for example, you can do
+ `pandoc -t slidy -V slidy-url=slidy -s`.
+ + LaTeX: Use `\and` to separate authors in LaTeX documents (reader
+ & writer). Closes #279.
+ + LaTeX: Use different `hyperref` options for `xetex`, fixing
+ problems with unicode bookmarks (thanks to CircleCode).
+ + LaTeX: Removed `ucs` package, use `utf8` rather than `utf8x`
+ with `inputenc`. This covers fewer characters but is more
+ robust with other packages, and `ucs` is unmaintained. Users
+ who need better unicode support should use xelatex or lualatex.
+
+pandoc (1.8.1.2)
+
+ * Added `--epub-cover-image` option.
+
+ * Documented `--biblatex` and `--natbib` options.
+
+ * Allow `--section-divs` with slidy output. Resolves Issue #296.
+
+ * Disallow notes within notes in reST and markdown.
+ These previously caused infinite looping and stack overflows.
+ For example:
+
+ [^1]
+
+ [^1]: See [^1]
+
+ Note references are allowed in reST notes, so this isn't a full
+ implementation of reST. That can come later. For now we need to
+ prevent the stack overflows. Partially resolves Issue #297.
+
+ * EPUB writer: Allow non-plain math methods.
+
+ * Forbid ()s in citation item keys. Resolves Issue #304: problems with
+ `(@item1; @item2)` because the final paren was being parsed as part of
+ the item key.
+
+ * Changed URI parser so it doesn't include trailing punctuation.
+ So, in RST, `http://google.com.` should be parsed as a link followed by a
+ period. The parser is smart enough to recognize balanced parentheses, as
+ often occur in wikipedia links: `http://foo.bar/baz_(bam)`.
+
+ * Markdown+lhs reader: Require space after inverse bird tracks, so that
+ HTML tags can be used freely at the left margin of a markdown+lhs document.
+ Thanks to Conal Elliot for the suggestion.
+
+ * Markdown reader:
+
+ + Improved emph/strong parsing; fixes bug found by Perry Wagle.
+ + Fixed bug in footnote order (reported by CircleCode).
+
+ * RST reader:
+ + Fixed bug in in field lists with multi-line items at the
+ end of the list.
+ + Added parentheses to RST `specialChars`, so
+ `(http://google.com)` will be parsed as a link in parens.
+ Resolves Issue #291.
+ + Allow `|` followed by newline in RST line block.
+
+ * LaTeX reader:
+ + Support `\dots`.
+ + Gobble option & space after linebreak `\\[10pt]`.
+
+ * Textile reader:
+ + Make it possible to have colons after links. (qerub)
+ + Make it possible to have colons after links. (Christoffer Sawicki)
+
+ * HTML reader:
+ + Skip spaces after `<b>`, `<emph>`, etc.
+ + Handle tbody, thead in simple tables. Closes #274.
+ + Implicit `Para`s instead of `Plains` in some contexts.
+
+ * OpenDocument writer: Use special `First paragraph` style for
+ first paragraph after most non-paragraph blocks. This allows users to
+ specify e.g. that only paragraphs after the first paragraph of a block are
+ to be indented. Thanks to Andrea Rossato for the patch. Closes #20.
+
+ * LaTeX writer: use `deVerb` on table and picture captions.
+ Otherwise LaTeX complains about `\verb` inside command argument.
+ Thanks to bbanier for reporting the bug.
+
+ * Markdown writer: Insert HTML comment btw list and indented code block.
+ This prevents the code block from being interpreted as part of the list.
+
+ * EPUB writer: Add a meta element specify the cover.
+ Some EPUB e-readers, such as the Nook, require a meta element inside the
+ OPF metadata block to ensure the cover image is properly displayed.
+ (Kelsey Hightower)
+
+ * HTML writer: Use embed tag for images with non-image extensions.
+ (e.g. PDFs). Closes #264.
+
+ * LaTeX writer: Improved tables.
+
+ + More space between lines, top-align cells.
+ + Use ctable package, which allows footnotes and
+ provides additional options.
+ + Made cell alignments work in multiline tables.
+ + Closes #271, #272.
+
+ * Un-URI-escape image filenames in LaTeX, ConTeXt, RTF, Texinfo.
+ Also do this when copying image files into EPUBs and ODTs.
+ Closes #263.
+
+ * Changed to github issue tracker.
+
+ * Added failing emph/strong markdown test case due to Perry Wagle.
+
+ * Slidy improvements:
+ + Updated to use Slidy2.
+ + Fixed bug, unclosed div tag.
+ + Added `duration` variable in template.
+ Setting this activates the timer.
+ + Use 'titlepage' instead of 'cover' for title div.
+
+pandoc (1.8.1.1)
+
+ * `markdown2pdf`: Removed some debugging lines accidentally included
+ in the 1.8.1 release. With those lines, the temp directory is created
+ in the working directory, and it is not deleted. This fix restores
+ the original behavior.
+
+pandoc (1.8.1)
+
+ * Added `--ascii` option. Currently supported only in HTML writer,
+ which it causes to use numerical entities instead of UTF-8.
+
+ * EPUB writer: `--toc` now works to provide a table of contents
+ at the beginning of each chapter.
+
+ * LaTeX writer: Change figure defaults to `htbp`.
+ This prevents "too many unprocessed floats." Resolves
+ Issue #285.
+
+ * `Text.Pandoc.UTF8`: Encode filenames even when using recent
+ base.
+
+ * `markdown2pdf`: Fixed filename encoding issues. With help from Paulo
+ Tanimoto. Resolves Issue #286.
+
+ * HTML writer: Put line breaks in section divs.
+
+ * `Text.Pandoc.Shared`: Make `writerSectionDivs` default to False.
+
+pandoc (1.8.0.3)
+
+ * Fixed Source-repository stanza in cabal file.
+
+pandoc (1.8.0.2)
+
+ * HTML writer:
+
+ + Stringify alt text instead of converting to HTML.
+ + Break lines after block elements, not inside tags.
+ HTML output now closely resembles that of tidy. Resolves Issue #134.
+
+ * Markdown reader: Fixed bug in footnote block parser (pointed out
+ by Jesse Rosenthal). The problem arose when the blank line
+ at the end of a footnote block contained indenting spaces.
+
+ * Shared: Improved 'normalize' function so it normalizes Spaces too.
+ In normal form, Space elements only occur to separate two non-Space
+ elements. So, we never have [Space], or [, ..., Space].
+
+ * Tests:
+
+ + Improved Arbitrary instance.
+ + Added timeout for test instances.
+
+ * README:
+
+ + Added section on four-space rule for lists. Resolves Issue #283.
+ + Clarified optional arguments on math options.
+
+ * markdown2pdf: Fixed bug with output file extensions.
+ Previously `markdown2pdf test.txt -o test.en.pdf` would produce
+ `test.pdf`, not `test.en.pdf`. Thanks to Paolo Tanimoto for the fix.
+
+pandoc (1.8.0.1)
+
+ * Revised Interact.hs so that it works with the CPP macros
+ in the UTF8 module.
+
+ * Revised Setup.hs so that we don't call MakeManPage.hs unless
+ the man pages are out of date.
+
+pandoc (1.8)
+
+ [new features]
+
+ * Support for citations using Andrea Rossato's `citeproc-hs` 0.3.
+ You can now write, for example,
+
+ Water is wet [see @doe99, pp. 33-35; also @smith04, ch. 1].
+
+ and, when you process your document using `pandoc`, specifying
+ a citation style using `--csl` and a bibliography using `--bibliography`,
+ the citation will be replaced by an appropriately formatted
+ citation, and a list of works cited will be added to the end
+ of the document.
+
+ This means that you can switch effortlessly between different citation
+ and bibliography styles, including footnote, numerical, and author-date
+ formats. The bibliography can be in any of the following formats: MODS,
+ BibTeX, BibLaTeX, RIS, EndNote, EndNote XML, ISI, MEDLINE, Copac, or JSON.
+ See the README for further details.
+
+ Citations are supported in the markdown reader, using a special
+ syntax, and in the LaTeX reader, using natbib or biblatex syntax.
+ (Thanks to Nathan Gass for the natbib and biblatex support.)
+
+ * New `textile` reader and writer. Thanks to Paul Rivier for contributing
+ the `textile` reader, an almost complete implementation of the textile
+ syntax used by the ruby [RedCloth library](http://redcloth.org/textile).
+ Resolves Issue #51.
+
+ * New `org` writer, for Emacs Org-mode, contributed by Puneeth Chaganti.
+
+ * New `json` reader and writer, for reading and writing a JSON
+ representation of the native Pandoc AST. These are much faster
+ than the `native` reader and writer, and should be used for
+ serializing Pandoc to text. To convert between the JSON representation
+ and native Pandoc, use `encodeJSON` and `decodeJSON` from
+ `Text.JSON.Generic`.
+
+ * A new `jsonFilter` function in `Text.Pandoc` makes it easy
+ to write scripts that transform a JSON-encoded pandoc document.
+ For example:
+
+ -- removelinks.hs - removes links from document
+ import Text.Pandoc
+ main = interact $ jsonFilter $ bottomUp removeLink
+ where removeLink (Link xs _) = Emph xs
+ removeLink x = x
+
+ To use this to remove links while translating markdown to LaTeX:
+
+ pandoc -t json | runghc removelinks.hs | pandoc -f json -t latex
+
+ * Attributes are now allowed in inline `Code` elements, for example:
+
+ In this code, `ulist ! [theclass "special"] << elts`{.haskell} is...
+
+ The attribute syntax is the same as for delimited code blocks.
+ `Code` inline has an extra argument place for attributes, just like
+ `CodeBlock`. Inline code will be highlighted in HTML output, if pandoc
+ is compiled with highlighting support. Resolves Issue #119.
+
+ * New `RawBlock` and `RawInline` elements (replacing `RawHtml`,
+ `HtmlInline`, and `TeX`) provide lots of flexibility in writing
+ scripts to transform Pandoc documents. Scripts can now change
+ how each element is rendered in each output format.
+
+ * You can now define LaTeX macros in markdown documents, and pandoc
+ will apply them to TeX math. For example,
+
+ \newcommand{\plus}[2]{#1 + #2}
+ $\plus{3}{4}$
+
+ yields `3+4`. Since the macros are applied in the reader, they
+ will work in every output format, not just LaTeX.
+
+ * LaTeX macros can also be used in LaTeX documents (both in math
+ and in non-math contexts).
+
+ * A new `--mathjax` option has been added for displaying
+ math in HTML using MathJax. Resolves issue #259.
+
+ * Footnotes are now supported in the RST reader. (Note, however,
+ that unlike docutils, pandoc ignores the numeral or symbol used in
+ the note; footnotes are put in an auto-numbered ordered list.)
+ Resolves Issue #258.
+
+ * A new `--normalize` option causes pandoc to normalize the AST
+ before writing the document. This means that, for example,
+ `*hi**there*` will be rendered as `<em>hithere</em>`
+ instead of `<em>hi</em><em>there</em>`. This is not the default,
+ because there is a significant performance penalty.
+
+ * A new `--chapters` command-line option causes headers
+ in DocBook, LaTeX, and ConTeXt to start with "chapter" (level one).
+ Resolves Issue #265.
+
+ * In DocBook output, `<chapter>` is now used for top-level
+ headers if the template contains `<book>`. Resolves Issue #265.
+
+ * A new `--listings` option in `pandoc` and `markdown2pdf` causes
+ the LaTeX writer to use the listings package for code blocks.
+ (Thanks to Josef Svennigsson for the pandoc patch, and Etienne
+ Millon for the markdown2pdf patch.)
+
+ * `markdown2pdf` now supports `--data-dir`.
+
+ * URLs in autolinks now have class "url" so they can be styled.
+
+ * Improved prettyprinting in most formats. Lines will be wrapped
+ more evenly and duplicate blank lines avoided.
+
+ * New `--columns` command-line option sets the column width for
+ line wrapping and relative width calculations for tables.
+
+ * Made `--smart` work in HTML, RST, and Textile readers, as well
+ as markdown.
+
+ * Added `--html5` option for HTML5 output.
+
+ * Added support for listings package in LaTeX reader
+ (Puneeth Chaganti).
+
+ * Added support for simple tables in the LaTeX reader.
+
+ * Added support for simple tables in the HTML reader.
+
+ * Significant performance improvements in many readers and writers.
+
+ [API and program changes]
+
+ * Moved `Text.Pandoc.Definition` from the `pandoc` package to a new
+ auxiliary package, `pandoc-types`. This will make it possible for other
+ programs to supply output in Pandoc format, without depending on the whole
+ pandoc package.
+
+ * Added `Attr` field to `Code`.
+
+ * Removed `RawHtml`, `HtmlInline`, and `TeX` elements; added generic
+ `RawBlock` and `RawInline`.
+
+ * Moved generic functions to `Text.Pandoc.Generic`. Deprecated
+ `processWith`, replacing it with two functions, `bottomUp` and `topDown`.
+ Removed previously deprecated functions `processPandoc` and `queryPandoc`.
+
+ * Added `Text.Pandoc.Builder`, for building `Pandoc` structures.
+
+ * `Text.Pandoc` now exports association lists `readers` and `writers`.
+
+ * Added `Text.Pandoc.Readers.Native`, which exports `readNative`.
+ `readNative` can now read full pandoc documents, block lists, blocks,
+ inline lists, or inlines. It will interpret `Str "hi"`
+ as if it were `Pandoc (Meta [] [] []) [Plain [Str "hi"]]`.
+ This should make testing easier.
+
+ * Removed deprecated `-C/--custom-header` option.
+ Use `--template` instead.
+
+ * `--biblio-file` has been replaced by `--bibliography`.
+ `--biblio-format` has been removed; pandoc now guesses the format
+ from the file extension (see README).
+
+ * pandoc will treat an argument as a URI only if it has an
+ `http(s)` scheme. Previously pandoc would treat some
+ Windows pathnames beginning with `C:/` as URIs.
+
+ * The `--sanitize-html` option and the `stateSanitize` field in
+ `ParserState` have been removed. Sanitization is better done in the
+ resulting HTML using `xss-sanitize`, which is based on pandoc's
+ sanitization, but improved.
+
+ * pandoc now adds a newline to the end of its output in fragment
+ mode (= not `--standalone`).
+
+ * Added support for `lang` in `html` tag in the HTML template,
+ so you can do `pandoc -s -V lang=es`, for example.
+
+ * `highlightHtml` in `Text.Pandoc.Highlighting` now takes
+ a boolean argument that selects between "inline" and
+ "block" HTML.
+
+ * `Text.Pandoc.Writers.RTF` now exports `rtfEmbedImage`.
+ Images are embedded in RTF output when possible (png, jpeg).
+ Resolves Issue #275.
+
+ * Added `Text.Pandoc.Pretty`. This is better suited for pandoc than the
+ `pretty` package. Changed all writers that used
+ `Text.PrettyPrint.HughesPJ` to use `Text.Pandoc.Pretty` instead.
+
+ * Rewrote `writeNative` using the new prettyprinting module. It is
+ now much faster. The output has been made more consistent and compressed.
+ `writeNative` is also now sensitive to writerStandalone`, and will simply
+ `print a block list if writerStandalone` is False.
+
+ * Removed `Text.Pandoc.Blocks`. `Text.Pandoc.Pretty` allows you to define
+ blocks and concatenate them, so a separate module is no longer needed.
+
+ * `Text.Pandoc.Shared`:
+
+ + Added `writerColumns`, `writerChapters`, and `writerHtml5` to
+ `WriterOptions`.
+ + Added `normalize`.
+ + Removed unneeded prettyprinting functions:
+ `wrapped`, `wrapIfNeeded`, `wrappedTeX`, `wrapTeXIfNeeded`, `hang'`,
+ `BlockWrapper`, `wrappedBlocksToDoc`.
+ + Made `splitBy` take a test instead of an element.
+ + Added `findDataFile`, refactored `readDataFile`.
+ + Added `stringify`. Rewrote `inlineListToIdentifier` using `stringify`.
+ + Fixed `inlineListToIdentifier` to treat '\160' as ' '.
+
+ * `Text.Pandoc.Readers.HTML`:
+
+ + Removed `rawHtmlBlock`, `anyHtmlBlockTag`, `anyHtmlInlineTag`,
+ `anyHtmlTag`, `anyHtmlEndTag`, `htmlEndTag`, `extractTagType`,
+ `htmlBlockElement`, `htmlComment`
+ + Added `htmlTag`, `htmlInBalanced`, `isInlineTag`, `isBlockTag`,
+ `isTextTag`
+
+ * Moved `smartPunctuation` from `Text.Pandoc.Readers.Markdown`
+ to `Text.Pandoc.Readers.Parsing`, and parameterized it with
+ an inline parser.
+
+ * Added `nonspaceChar` to `Text.Pandoc.Parsing`.
+
+ * Ellipses are no longer allowed to contain spaces.
+ Previously we allowed '. . .', ' . . . ', etc. This caused
+ too many complications, and removed author's flexibility in
+ combining ellipses with spaces and periods.
+
+ * Allow linebreaks in URLs (treat as spaces). Also, a string of
+ consecutive spaces or tabs is now parsed as a single space. If you have
+ multiple spaces in your URL, use `%20%20`.
+
+ * `Text.Pandoc.Parsing`:
+
+ + Removed `refsMatch`.
+ + Hid `Key` constructor.
+ + Removed custom `Ord` and `Eq` instances for `Key`.
+ + Added `toKey` and `fromKey` to convert between `Key` and `[Inline]`.
+ + Generalized type on `readWith`.
+
+ * Small change in calculation of relative widths of table columns.
+ If the size of the header > the specified column width, use
+ the header size as 100% for purposes of calculating
+ relative widths of columns.
+
+ * Markdown writer now uses some pandoc-specific features when `--strict`
+ is not specified: `\` newline is used for a hard linebreak instead of
+ two spaces then a newline. And delimited code blocks are used when
+ there are attributes.
+
+ * HTML writer: improved gladTeX output by setting ENV appropriately
+ for display or inline math (Jonathan Daugherty).
+
+ * LaTeX writer: Use `\paragraph`, `\subparagraph` for level 4,5 headers.
+
+ * LaTeX reader:
+
+ + `\label{foo}` and `\ref{foo}` now become `{foo}` instead of `(foo)`.
+ + `\index{}` commands are skipped.
+
+ * Added `fontsize` variable to default LaTeX template.
+ This makes it easy to set the font size using `markdown2pdf`:
+ `markdown2pdf -V fontsize=12pt input.txt`.
+
+ * Fixed problem with strikeout in LaTeX headers when using
+ hyperref, by adding a command to the default LaTeX template
+ that disables `\sout` inside pdf strings. Thanks to Joost Kremers
+ for the fix.
+
+ * The `COLUMNS` environment variable no longer has any effect.
+
+ [under-the-hood improvements]
+
+ * Pandoc now compiles with GHC 7. (This alone leads to a
+ significant performance improvement, 15-20%.)
+
+ * Completely rewrote HTML reader using tagsoup as a lexer. The
+ new reader is faster and more accurate. Unlike the
+ old reader, it does not get bogged down on some input
+ (Issues #277, 255). And it handles namespaces in tags
+ (Issue #274).
+
+ * Replaced `escapeStringAsXML` with a faster version.
+
+ * Rewrote `spaceChar` and some other parsers in Text.Pandoc.Parsing
+ for a significant performance boost.
+
+ * Improved performance of all readers by rewriting parsers.
+
+ * Simplified Text.Pandoc.CharacterReferences by using
+ entity lookup functions from TagSoup.
+
+ * `Text.Pandoc.UTF8` now uses the unicode-aware IO functions
+ from `System.IO` if base >= 4.2. This gives support for
+ windows line endings on windows.
+
+ * Remove duplications in documentation by generating the
+ pandoc man page from README, using `MakeManPage.hs`.
+
+ * README now includes a full description of markdown syntax,
+ including non-pandoc-specific parts. A new `pandoc_markdown`
+ man page is extracted from this, so you can look up markdown
+ syntax by doing `man pandoc_markdown`.
+
+ * Completely revised test framework (with help from Nathan Gass).
+ The new test framework is built when the `tests` Cabal flag is set. It
+ includes the old integration tests, but also some new unit and quickcheck
+ tests. Test output has been much improved, and you can now specify a glob
+ pattern after `cabal test` to indicate which tests should be run;
+ for example `cabal test citations` will run all the citation tests.
+
+ * Added a shell script, `stripansi.sh`, for filtering ANSI control
+ sequences from test output: `cabal test | ./stripansi.sh > test.log`.
+
+ * Added `Interact.hs` to make it easier to use ghci while developing.
+ `Interact.hs` loads `ghci` from the `src` directory, specifying
+ all the options needed to load pandoc modules (including
+ specific package dependencies, which it gets by parsing
+ dist/setup-config).
+
+ * Added `Benchmark.hs`, testing all readers + writers using criterion.
+
+ * Added `stats.sh`, to make it easier to collect and archive
+ benchmark and lines-of-code stats.
+
+ * Added upper bounds to all cabal dependencies.
+
+ * Include man pages in extra-source-files. This allows users to
+ install pandoc from the tarball without needing to build the man
+ pages.
+
+ [bug fixes]
+
+ * Filenames are encoded as UTF8. Resolves Issue #252.
+
+ * Handle curly quotes better in `--smart` mode. Previously, curly quotes
+ were just parsed literally, leading to problems in some output formats.
+ Now they are parsed as `Quoted` inlines, if `--smart` is specified.
+ Resolves Issue #270.
+
+ * Text.Pandoc.Parsing: Fixed bug in grid table parser.
+ Spaces at end of line were not being stripped properly,
+ resulting in unintended LineBreaks.
+
+ * Markdown reader:
+
+ + Allow HTML comments as inline elements in markdown.
+ So, `aaa <!-- comment --> bbb` can be a single paragraph.
+ + Fixed superscripts with links: `^[link](/foo)^` gets
+ recognized as a superscripted link, not an inline note followed by
+ garbage.
+ + Fixed regression, making markdown reference keys case-insensitive again.
+ Resolves Issue #272.
+ + Properly handle abbreviations (like `Mr.`) at the end of a line.
+ + Better handling of intraword underscores, avoiding exponential
+ slowdowns in some cases. Resolves Issue #182.
+ + Fixed bug in alignments in tables with blank rows in the header.
+
+ * RST reader:
+
+ + Field lists now allow spaces in field names, and
+ block content in field values. (Thanks to Lachlan Musicman
+ for pointing out the bug.)
+ + Definition list items are now always `Para` instead of
+ `Plain`, matching behavior of `rst2xml.py`.
+ + In image blocks, the description is parsed properly and
+ used for the alt attribute, not also the title.
+ + Skip blank lines at beginning of file. Resolves
+ Debian #611328.
+
+ * LaTeX reader:
+
+ + Improved parsing of preamble.
+ Previously you'd get unexpected behavior on a document that
+ contained `\begin{document}` in, say, a verbatim block.
+ + Allow spaces between `\begin` or `\end` and `{`.
+ + Support `\L` and `\l`.
+ + Skip comments inside paragraphs.
+
+ * LaTeX writer:
+
+ + Escape strings in `\href{..}`.
+ + In nonsimple tables, put cells in `\parbox`.
+
+ * OpenDocument writer: don't print raw TeX.
+
+ * Markdown writer:
+
+ + Fixed bug in `Image`. URI was getting unescaped twice!
+ + Avoid printing extra blank lines at the end if there are
+ no notes or references.
+
+ * LaTeX and ConTeXt: Escape `[` and `]` as `{[}` and `{]}`.
+ This avoids unwanted interpretation as an optional argument.
+
+ * ConTeXt writer: Fixed problem with inline code. Previously
+ `}` would be rendered `\type{}}`. Now we check the string for '}' and '{'.
+ If it contains neither, use `\type{}`; otherwise use `\mono{}`
+ with an escaped version of the string.
+
+ * `:` now allowed in HTML tags. Resolves Issue #274.
+
+pandoc (1.6)
+
+ [ John MacFarlane ]
+
+ * New EPUB and HTML Slidy writers. (Issue #122)
+
+ - EPUB is a standard ebook format, used in Apple's iBooks for
+ the iPad and iPhone, Barnes and Noble's nook reader, the Sony
+ reader, and many other devices.
+ - Slidy, like S5, is a system for producing HTML+javascript slide
+ shows.
+
+ * All input is assumed to be UTF-8, no matter what the locale and ghc
+ version, and all output is UTF-8. This reverts to pre-1.5 behavior.
+ Also, a BOM, if present, is stripped from the input.
+
+ * Markdown now supports grid tables, whose cells can contain
+ arbitrary block elements. (Issue #43)
+
+ * Sequentially numbered example lists in markdown with `@` marker.
+
+ * Markdown table captions can begin with a bare colon and no longer need
+ to include the English word "table." Also, a caption can now occur
+ either before or after the table. (Issue #227)
+
+ * New command-line options:
+
+ - `--epub-stylesheet` allows you to specify a CSS file that will
+ be used to style your ebook.
+ - `--epub-metadata` allows you to specify metadata for the ebook.
+ - `--offline` causes the generated HTML slideshow to include all
+ needed scripts and stylesheets.
+ - `--webtex` causes TeX math to be converted to images using the
+ Google Charts API (unless a different URL is specified).
+ - `--section-divs` causes div tags to be added around each section
+ in an HTML document. (Issue #230, 239)
+
+ * Default behavior of S5 writer in standalone mode has changed:
+ previously, it would include all needed scripts and stylesheets
+ in the generated HTML; now, only links are included unless
+ the `--offline` option is used.
+
+ * Default behavior of HTML writer has changed. Between 1.2 and 1.5,
+ pandoc would enclose sections in div tags with identifiers on the
+ div tags, so that the sections can be manipulated in javascript.
+ This caused undesirable interactions with raw HTML div tags. So,
+ starting with 1.6, the default is to put the identifiers directly
+ on the header tags, and not to include the divs. The `--section-divs`
+ option selects the 1.2-1.5 behavior.
+
+ * API changes:
+
+ - `HTMLMathMethod`: Added `WebTeX`, removed `MimeTeX`.
+ - `WriterOptions`: Added `writerUserDataDir`, `writerSourceDirectory`,
+ `writerEPUBMetadata` fields. Removed `writerIncludeBefore`,
+ `writerIncludeAfter`.
+ - Added `headerShift` to `Text.Pandoc.Shared`.
+ - Moved parsing code and `ParserState` from `Text.Pandoc.Shared`
+ to a new module, `Text.Pandoc.Parsing`.
+ - Added `stateHasChapters` to `ParserState`.
+ - Added `HTMLSlideVariant`.
+ - Made `KeyTable` a map instead of an association list.
+ - Added accessors for `Meta` fields (`docTitle`, `docAuthors`,
+ `docDate`).
+ - `Pandoc`, `Meta`, `Inline`, and `Block` have been given `Ord`
+ instances.
+ - Reference keys now have a type of their own (`Key`), with its
+ own `Ord` instance for case-insensitive comparison.
+ - Added `Text.Pandoc.Writers.EPUB`.
+ - Added `Text.Pandoc.UUID`.
+ - Removed `Text.Pandoc.ODT`, added `Text.Pandoc.Writers.ODT`.
+ Removed `saveOpenDocumentAsODT`, added `writeODT`.
+ - Added `Text.Pandoc.Writers.Native` and `writeNative`.
+ Removed `prettyPandoc`.
+ - Added `Text.Pandoc.UTF8` for portable UTF8 string IO.
+ - Removed `Text.Pandoc.Writers.S5` and the `writeS5` function.
+ Moved `s5Includes` to a new module, `Text.Pandoc.S5`.
+ To write S5, you now use `writeHtml` with `writerSlideVariant`
+ set to `S5Slides` or `SlidySlides`.
+
+ * Template changes. If you use custom templates, please update them,
+ particularly if you use syntax highlighting with pandoc. The old HTML
+ templates hardcoded highlighting CSS that will no longer work with
+ the most recent version of highlighting-kate.
+
+ - HTML template: avoid empty meta tag if no date.
+ - HTML template: Use default highlighting CSS from highlighting-kate
+ instead of hard-coding the CSS into the template.
+ - HTML template: insert-before text goes before the title, and
+ immediately after the <body> tag, as documented. (Issue #241)
+ - Added slidy and s5 templates.
+ - Added amssymb to preamble of latex template. (github Issue 1)
+
+ * Removed excess newlines at the end of output. Note: because output
+ will not contain an extra newline, you may need to make adjustments
+ if you are inserting pandoc's output into a template.
+
+ * In S5 and slidy, horizontal rules now cause a new slide, so you
+ are no longer limited to one slide per section.
+
+ * Improved handling of code in man writer. Inline code is now monospace,
+ not bold, and code blocks now use .nf (no fill) and .IP (indented para).
+
+ * HTML reader parses `<tt>` as Code. (Issue #247)
+
+ * html+lhs output now contains bird tracks, even when compiled without
+ highlighting support. (Issue #242)
+
+ * Colons are now no longer allowed in autogenerated XML/HTML identifiers,
+ since they have a special meaning in XML.
+
+ * Code improvements in ODT writer. Remote images are now replaced with
+ their alt text rather than a broken link.
+
+ * LaTeX reader improvements:
+
+ - Made latex `\section`, `\chapter` parsers more forgiving of
+ whitespace.
+ - Parse `\chapter{}` in latex.
+ - Changed `rawLaTeXInline` to accept `\section`, `\begin`, etc.
+ - Use new `rawLaTeXInline'` in LaTeX reader, and export `rawLaTeXInline`
+ for use in markdown reader.
+ - Fixes bug wherein `\section{foo}` was not recognized as raw TeX
+ in markdown document.
+
+ * LaTeX writer: images are automatically shrunk if they would extend
+ beyond the page margin.
+
+ * Plain, markdown, RST writers now use unicode for smart punctuation.
+
+ * Man writer converts math to unicode when possible, as in other writers.
+
+ * `markdown2pdf` can now recognize citeproc options.
+
+ * Command-line arguments are converted to UTF-8. (Issue #234)
+
+ * `Text.Pandoc.TeXMath` has been rewritten to use texmath's parser.
+ This allows it to handle a wider range of formulas. Also, if a formula
+ cannot be converted, it is left in raw TeX; formulas are no longer
+ partially converted.
+
+ * Unicode curly quotes are left alone when parsing smart quotes. (Issue
+ #143)
+
+ * Cabal file changes:
+
+ - Removed parsec < 3 restriction.
+ - Added 'threaded' flag for architectures where GHC lacks a threaded
+ runtime.
+ - Use 'threaded' only for markdown2pdf; it is not needed for pandoc.
+ - Require highlighting-kate 0.2.7.
+
+ * Use explicit imports from `Data.Generics`. Otherwise we have a
+ conflict with the 'empty' symbol, introduced in syb >= 0.2. (Issue #237)
+
+ * New data files: slidy/slidy.min.js, slidy/slidy.min.css, epub.css.
+
+pandoc (1.5.1.1)
+
+ [ John MacFarlane ]
+
+ * Fixed uniqueIdent in Shared so that header identifiers work as
+ advertized in the README and are are valid XHTML names.
+
+pandoc (1.5.1)
+
+ [ John MacFarlane ]
+
+ * Fixed treatment of unicode characters in URIs.
+ + Shared now exports escapeURI and unescapeURI. These handle
+ UTF8 encoding and decoding as well as URI escaping/unescaping.
+ + Shared: uri and emailAddress now return a pair of the original
+ parsed text and the escaped URI (in the latter case, with
+ the mailto: prefix).
+ + HTML reader: unsanitaryURI has been modified to allow unicode
+ high characters in a URI.
+ + Readers: All link and image URIs are now escaped using
+ escapeURI.
+ + Markdown and RST writers: unescapeURI is used so that URIs
+ in these formats are human-readable.
+
+ * Setup.hs: Don't assume that the build directory is "dist".
+ Instead, get it from localBuildInfo.
+
+ * OpenDocument writer: Use a Map for stTextStyleAttr.
+ This avoids duplicates (and invalid xml). Resolves Issue #222.
+
+pandoc (1.5.0.1)
+
+ [ John MacFarlane ]
+
+ * HTML writer: Fixed error in math writer (with MathML option)
+ that caused an infinite loop for unparsable MathML.
+
+pandoc (1.5)
+
+ [ John MacFarlane ]
+
+ * Added --mathml option. When this is selected, pandoc will convert
+ TeX math into MathML.
+ + Added data/MathMLinHTML.js, which is included when no URL is
+ provided for --mathml. This allows MathML to be displayed (in
+ better browsers) as text/html.
+ + Removed Text.Pandoc.LaTeXMathML. The module was no longer
+ necessary; it was replaced by two lines in pandoc.hs.
+ + Replaced LaTeXMathML.js.commend and LaTeXMathML.js.packed with a
+ single combined file, LaTeXMathML.js.
+
+ * Added --data-dir option.
+ This specifies a user data directory. If not specified, will default
+ to ~/.pandoc on unix or Application Data\pandoc on Windows.
+ Files placed in the user data directory will override system default
+ data files.
+
+ * Added Maybe datadir parameter to readDataFile, saveOpenDocumentAsODT,
+ latexMathMLScript, s5HeaderIncludes, and getDefaultTemplate. If
+ Nothing, no user directory is searched for an override.
+
+ * Added 'plain' output format. This is similar to markdown, but
+ removes links, pictures, inline formatting, and most anything that
+ looks even vaguely markupish. The function writePlain is exported by
+ Text.Pandoc.Writers.Markdown, with which it shares most of its code.
+
+ * Allow multi-line titles and authors in meta block.
+ Titles may span multiple lines, provided continuation lines
+ begin with a space character. Separate authors may be put on
+ multiple lines, provided each line after the first begins with
+ a space character. Each author must fit on one line. Multiple
+ authors on a single line may still be separated by a semicolon.
+ Based on a patch by Justin Bogner.
+
+ * When given an absolute URI as parameter, pandoc will try to fetch
+ the content via HTTP. So you can do:
+ 'pandoc -r html -w markdown http://www.fsf.org'
+ Adds dependency on HTTP.
+
+ * Made HTML reader much more forgiving.
+ + Incorporated idea (from HXT) that an element can be closed
+ by an open tag for another element.
+ + Javascript is partially parsed to make sure that a <script>
+ section is not closed by a </script> in a comment or string.
+ + More lenient non-quoted attribute values.
+ Now we accept anything but a space character, quote, or <>.
+ This helps in parsing e.g. www.google.com!
+ + Bare & signs are now parsed as a string. This is a common
+ HTML mistake.
+ + Skip a bare < in malformed HTML.
+
+ * Removed html2markdown and hsmarkdown.
+ + html2markdown is no longer needed, since you can now pass URI
+ arguments to pandoc and directly convert web pages. (Note,
+ however, that pandoc assumes the pages are UTF8. html2markdown
+ made an attempt to guess the encoding and convert them.)
+ + hsmarkdown is pointless -- a large executable that could be
+ replaced by 'pandoc --strict'.
+
+ * In most writers, an image in a paragraph by itself is now rendered
+ as a figure, with the alt text as the caption. (Texinfo, HTML, RST,
+ MediaWiki, Docbook, LaTeX, ConTeXt, HTML.) Other images are
+ rendered inline.
+
+ * Depend on extensible-exceptions. This allows pandoc to be compiled
+ on GHC 6.8.
+
+ * Added --base-header-level option. For example, --base-header-level=2
+ will change level 1 headers to level 2, level 2 to level 3, etc.
+ Closes Debian #563416.
+
+ * Incomplete support for RST tables (simple and grid).
+ Thanks to Eric Kow. Colspans and rowspans not yet supported.
+
+ * Added accessors (docTitle, docAuthors, docDate) to Meta type.
+
+ * MediaWiki writer: format links with relative URLs as wikilinks.
+ The new rule: If the link target is an absolute URL, an external
+ link is created. Otherwise, a wikilink is created.
+
+ * Text.Pandoc.Shared: Export uniqueIdent, and don't allow tilde in
+ identifier. Note: This may break links to sections that involve
+ tildes.
+
+ * Markdown(+lhs) reader: handle "inverse bird tracks."
+ Inverse bird tracks (<) are used for haskell example code that is not
+ part of the literate Haskell program. Resolves Issue #211.
+
+ * LaTeX reader:
+ + Recognize '\ ' (interword space).
+ + Recognize nonbreaking space '~'.
+ + Ignore \section, \pdfannot, \pdfstringdef. Ignore alt title in
+ section headers. Don't treat \section as inline LaTeX.
+ Resolves Issue #202.
+ + LaTeX reader: allow any special character to be escaped.
+ Resolves Issue #221.
+ + LaTeX reader: treat \paragraph and \subparagraph as level 4, 5
+ headers. Resolves Issue #207.
+
+ * Use template variables for include-before/after.
+ + These options now imply -s; previously they worked also in fragment
+ mode.
+ + Users can now adjust position of include-before and include-after
+ text in the templates.
+ + Default position of include-before moved back (as it was before 1.4)
+ before table of contents.
+ + Resolves Issue #217.
+
+ * Don't print an empty table header: (all writers).
+ Resolves Issue #210.
+
+ * HTML, Docbook writer: Use tbody, thead, and cols in tables.
+
+ * HTML writer: Don't include TOC div if table of contents is empty.
+
+ * Markdown writer: Fixed citations.
+ Previously the markdown writer printed raw citation codes, e.g.
+ [geach1970], rather than the expanded citations provided by
+ citeproc, e.g. (Geach 1970). Now it prints the expanded citations.
+ This means that the document produced can be processed as a markdown
+ document without citeproc. Thanks to dsanson for reporting, and
+ Andrea Rossato for the patch.
+
+ * Improved and simplified title block in context template.
+ Previously it caused an error if there was no title.
+ This method should also be easier for users to customize.
+
+ * Markdown reader:
+ + Treat p., pp., sec., ch., as abbreviations in smart mode.
+ + Disallow blank lines in inline code span.
+ + Allow footnotes to be indented < 4 spaces.
+ This fixes a regression. A test case has been added.
+ + Escape spaces in URLs as %20. Previously they were incorrectly
+ escaped as +, which is appropriate only for the query part of
+ a URL. Resolves Issue #220.
+ + Require two spaces after capital letter + period for list item.
+ Otherwise "E. coli" starts a list. This might change the semantics
+ of some existing documents, since previously the two-space
+ requirement was only enforced when the second word started
+ with a capital letter. But it is consistent with the existing
+ documentation and follows the principle of least surprise.
+ Resolves Issue #212.
+
+ * LaTeX template: redefine labelwidth when using enumerate package.
+ Otherwise the list labels (numbers) often extend past the left
+ margin, which looks bad.
+
+ * Mediawiki writer: Don't print a "== Notes ==" header before
+ references. This is too English-centric. Writers can provide their
+ own header at the end of the document.
+
+ * Promoted mediawiki headers. '= head =' is now level 1, '== head =='
+ level 2, etc. This seems to be correct; it's only by convention
+ that wikipedia articles have level 2 headers at most.
+ Patch due to Eric Kow.
+
+ * RunTests.hs: Set LANG to a UTF-8 locale. Use 'pandoc --data-dir=' so
+ data files don't need to have been installed. This removes the need to
+ set HOME.
+
+ * HTML reader:
+ + Handle spaces before <html>. Resolves Issue #216.
+ + Be forgiving in parsing a bare list within a list.
+ The following is not valid xhtml, but the intent is clear:
+ <ol>
+ <li>one</li>
+ <ol><li>sub</li></ol>
+ <li>two</li>
+ </ol>
+ We'll treat the <ol> as if it's in a <li>. Resolves Issue #215.
+
+ * Updated INSTALL instructions. cabal method is now promoted.
+
+ * Updated markdown2pdf man page. It no longer says all pandoc options
+ are accepted.
+
+ * README/man pages: Removed advice to pipe through tidy before HTML
+ reader. This is obsolete, now that we have a forgiving HTML parser.
+
+ * LaTeX writer: set numbersections template variable, so
+ the section numbering options work again.
+
+ * Removed obsolete Makefile.
+
+ * Website: renamed index.txt.in -> index.txt.
+
+ * New batch file to make-windows-installer.
+ + Removed old Makefile.windows
+ + Added make-windows-installer.bat
+ + Modified default installer name in pandoc-setup.iss
+
+ * Removed freebsd and macports directories.
+ They are no longer up to date.
+
+ * Setup.hs:
+ + Made man page building sensitive to build verbosity.
+ + Improved detection of highlighting support in test hook.
+ + Install wrapper scripts into cabal bin directory.
+ + Also simplified installManpages.
+ + Setup.hs: install manpages to mandir. Code borrowed from darcs.
+
+ * Changed default of writerXeTeX to False.
+
+ * HTML writer: don't include empty UL if --toc but no sections.
+ Resolves Issue #199.
+
+ * LaTeX writer:
+
+ + If book, report, or memoir documentclass, use \chapter{}
+ for first-level headers. Otherwise use \section{}.
+ + Removed stLink, link template variable. Reason: we now always
+ include hyperref in the template.
+
+ * LaTeX template:
+
+ + Only show \author if there are some.
+ + Always include hyperref package. It is used not just for links but
+ for toc, section heading bookmarks, footnotes, etc. Also added
+ unicode=true on hyperref options.
+
+ * markdown2pdf: always do at least two runs. hyperref bookmarks
+ require this.
+
+ * cabal file: Removed unneeded dependency on template-haskell.
+
+ * Windows installer - fixed bug in data file locations.
+ Resolves Issue #197.
+
+ * Deprecated --custom-header in documentation.
+ Removed old "Custom Headers" section in README.
+
+pandoc (1.4)
+
+ [ John MacFarlane ]
+
+ * Pandoc will now compile with either GHC 6.10 or 6.12.
+ + Don't use System.IO.UTF8 when compiling with 6.12
+ + Use -fno-warn-unused-do-bind option when compiling with 6.12
+
+ * Replaced old headers with templates. Now users have much more
+ control over the way documents appear in --standalone mode,
+ and writer code is simplified. Resolves Issues #59, 147.
+ Every effort has been made to retain backwards compatibilty.
+ So, the --custom-header option should still work as before.
+
+ + Added Text.Pandoc.Templates. This provides functions for
+ retrieving default templates and for rendering templates.
+ + System templates (in the pandoc data directory) can be
+ overridden by user templates in $HOME/.pandoc/templates.
+ + Removed Text.Pandoc.DefaultHeaders.
+ + Removed data/headers directory.
+ + Added templates directory.
+ + Added writerTemplate and writerVariables fields to WriterOptions.
+ + Removed writerTitlePrefix, writerHeader fields from WriterOptions.
+ + Changed --print-default-header to --print-default-template.
+ + Added --template option.
+ + Added -V/--variable option to set custom template variables.
+
+ * Pandoc no longer requires Template Haskell. Resolves Issue #186.
+
+ + Removed need for TH in ODT module. Instead get reference.odt from
+ data file at run time.
+ + Removed TH dependency from S5 module. S5 module now exports
+ s5HeaderIncludes, which pandoc.hs includes if writer is s5 and
+ standalone.
+ + Refactored LaTeXMathML not to use TH.
+
+ * Meta is now Meta [Inline] [[Inline]] [Inline] rather than
+ Meta [Inline] [String] String. Authors and date in Meta are now lists
+ of Inline elements rather than raw strings. This means that they can
+ be formatted and can include footnotes. NOTE: This may be a breaking
+ change for those using pandoc as a library.
+
+ * Added readDataFile to Text.Pandoc.Shared. This retrieves
+ a data file from the user pandoc data directory (~/.pandoc
+ on unix), or, if not found there, from the system data
+ directory ($CABALDIR/shared/pandoc-VERSION/). All data
+ files, including templates, LaTeXMathML.js, s5 styles,
+ and reference.odt, can be overridden by the user.
+
+ * s5 files moved from data/ui/default to s5/default.
+
+ * Use unicode instead of entities in HTML and XML output. Resolves
+ Issue #163.
+
+ * Prettier HTML footnote references: put anchor inside sup,
+ instead of other way. Resolves Issue #191. Thanks to
+ infinity0x.
+
+ * Added --xetex option to pandoc and markdown2pdf.
+ If --xetex is specified, pandoc produces latex suitable for
+ processing by xelatex, and markdown2pdf uses xelatex to create
+ the PDF. Resolves Issue #185.
+
+ * RTF writer: multiple authors now occupy multiple paragraphs rather
+ than using a line break.
+
+ * Man writer: now the "--after-body" will come after the "AUTHORS"
+ section, whereas before it would come before it. This is a
+ slight break from backwards compatibility.
+
+ * Added --reference-odt option, so users may customize the styles
+ used in pandoc-generated ODT files. Users may also place a
+ default reference.odt in the ~\.pandoc directory.
+
+ * ODT writer:
+ + Indented and line-broke styles.xml so it can be modified more easily.
+ + Omitted some unnecessary style declarations.
+ + Don't wrap text in OpenDocument writer. The tags are too long, making
+ wrapping ugly and pointless.
+
+ * LaTeX reader: use \\ to separate multiple authors.
+
+ * Markdown reader: use ; as separator between authors.
+ This allows you to use ',' within author names: e.g. "John Jones, Jr."
+
+ * S5 writer: use linebreak to separate authors in title page.
+
+ * RST reader: Allow :: before lhs code block. The RST spec requires the
+ :: before verbatim blocks. This :: should not be treated as literal
+ colons. Resolves Issue #189.
+
+ * Documented pandoc 1.3's new definition list syntax in README.
+ (An oversight in the last release.)
+
+ * markdown2pdf.hs:
+ + interpret ! in a log as an error line.
+ + --toc now works properly.
+
+ * Changes in RunTests.hs:
+ + Use the Diff library rather than a local copy of Diff.hs.
+ (This vastly increases performance.) This change means that 'cabal
+ test' presupposes that the Diff library is installed.
+ + Removed tests/Diff.hs from cabal file.
+ + Changed RunTests to use local environment. We need at least HOME, so
+ pandoc can find its data directory.
+
+ * Updated windows installer to install data files in the app directory.
+
+ * Windows installer now installs portable wrappers hsmarkdown and
+ markdown2pdf.
+
+pandoc (1.3)
+
+ [ John MacFarlane ]
+
+ * Added --id-prefix option (Issue #41). This adds a prefix to all
+ automatically generated HTML identifiers, which helps prevent
+ duplicate identifiers when you're generating a fragment (say a blog
+ post).
+
+ * Added --indented-code-classes option. This specifies classes
+ to use for indented code blocks. (Patch due to buttock; Issue #87.)
+
+ * --number-sections now affects HTML output as well as ConTeXt and LaTeX
+ (Issue #150).
+
+ * Improved syntax for markdown definition lists (Issue #24).
+ Definition lists are now more compatible with PHP Markdown Extra.
+ + You can have multiple definitions for a term (but still not
+ multiple terms).
+ + Multi-block definitions no longer need a column before each block
+ (indeed, this will now cause multiple definitions).
+ + The marker no longer needs to be flush with the left margin,
+ but can be indented at or two spaces. Also, ~ as well as :
+ can be used as the marker (this suggestion due to David
+ Wheeler.)
+ + There can now be a blank line between the term and the
+ definitions.
+
+ * Better looking simple tables. Resolves Issue #180.
+ + Markdown reader: simple tables are now given column widths of 0.
+ + Column width of 0 is interpreted as meaning: use default column width.
+ + Writers now include explicit column width information only
+ for multiline tables. (Exception: RTF writer, which requires
+ column widths. In this case, columns are given equal widths,
+ adding up to the text width.)
+ + Simple tables should now look better in most output formats.
+
+ * Allow markdown tables without headers (Issue #50).
+ The new syntax is described in README. Also allow optional line of
+ dashes at bottom of simple tables.
+
+ * Compensate for width of final table column (Issue #144).
+
+ * Treat a backslash followed by a newline as a hard line break
+ in markdown. Resolves Issue #154. This is a nice alternative
+ to markdown's "invisible" way of indicating hardline breaks
+ using lines that end with two spaces.
+
+ * Improved performance of markdown reader by ~10% by eliminating the
+ need for a separate parsing pass for notes. Raw notes are now stored
+ on the first pass (which parses references), then parsed when the
+ note is inserted into the AST. The stateNotes field in ParserState
+ is now a list of [(String, String)] pairs instead of [(String,
+ [Block])].
+
+ * In markdown reader, treat 4 or more * or _ in a row as literal
+ text. (Trying to parse long strings of * or _ as strong or emph
+ leads to exponential performance problems.)
+
+ * Markdown reader: Use + rather than %20 for spaces in URLs.
+
+ * Fixed htmlComment parser, adding a needed 'try'.
+
+ * Don't print raw HTML in man output.
+
+ * Allow . _ and ~ in header identifiers.
+
+ * Specially mark code blocks that were "literate" in the input.
+ They can then be treated differently in the writers. This allows
+ authors to distinguish bits of the literate program they are writing
+ from source code examples, even if the examples are marked as
+ Haskell for highlighting. (Issue #174.)
+
+ * Modified html+lhs output to use "haskell" highlighter instead
+ of "literateHaskell". The highlighting module now adds bird tracks
+ after highlighting (for HTML output), if the code block has the
+ "literate" class. This gives better results, because kate's
+ haskell highlighter is much better than the literateHaskell
+ highlighter.
+
+ * Fixed handling of footnotes in titles (HTML) and headers (LaTeX).
+ (Issue #137.)
+
+ * Support for "..code-block" directive in RST reader. Not core
+ RST, but used in Sphinx for code blocks annotated with syntax
+ information. Thanks to Luke Plant for the patch.
+
+ * Added "head" to list of block-level HTML tags. Resolves
+ Issue #108.
+
+ * Added stripTags to Text.Pandoc.XML. This is used in the HTML writer.
+
+ * Set utf-8 encoding in texinfo headers.
+
+ * Docbook writer: add ids to sections. Use link for internal links.
+ (Issue #60.)
+
+ * Blank lines after lists in MediaWiki writer.
+
+ * Properly handle commented-out list items in markdown.
+ Resolves Issue #142. Example:
+
+ - a
+ <!--
+ - b
+ -->
+ - c
+
+ * Changed heuristic in compactify. compactify has to decide whether a
+ Para that ends a list is a Para intentionally, or just because of
+ the blank lines at the end of every list. In the latter case the
+ Para is turned to a Plain. The old heuristic was: change final Para
+ to Plain iff the other items all end in Plain. This produces bad
+ results when, for example, an item contains just a Plain and an HTML
+ comment, as it does in the list above. The new heuristic: change
+ final Para to Plain iff the other items don't contain a Para.
+
+ * Added % as an rst underline character. Resolves Issue #173.
+
+ * Fix inline math parser so that \$ is allowed in math.
+ Resolves Issue #169.
+
+ * Translate \int (integral) into unicode when using unicode math
+ method. Resolves Issue #177.
+
+ * markdown2pdf.hs improvements:
+ + Use System.IO.UTF8.
+ + Print error messages on last attempt.
+ + Do not create a backup when overwriting a PDF (Issue #166).
+ + Accept --longopt=val options.
+ + Added man/man1/markdown2pdf.1 to extra-tmp-files in cabal, so that
+ it is properly cleaned.
+
+ * Added haddock comments warning that readers assume \n line endings.
+
+ * Updated COPYRIGHT file.
+
+ * Makefile: Changed EXECSBASE so it doesn't pull in hsmarkdown &
+ markdown2pdf. Otherwise strip tries to strip shell scripts when you
+ install using 'make'.
+
+ * Changed Makefile so it doesn't build Haskell wrappers.
+
+ * Fixed Makefile so it doesn't try to build man pages in build-doc.
+
+ * Install pcre3.dll in Windows install script; this allows us to
+ package a version of pandoc with highlighting support.
+
+pandoc (1.2.1)
+
+ [ John MacFarlane ]
+
+ * Fixed regression with --preserveTabs. Brought back optPreserveTabs.
+ The trick of setting tabStop to 0 to mean "preserve tabs" had a bad
+ side effect: strings of 0 spaces were interpreted as indentation.
+ So, with --preserve-tabs, unindented paragraphs were treated as
+ code. Resolves Issue #138.
+
+ * HTML writer: wrap sections in divs. Resolves Issue #70.
+
+ + hierarchicalize has been rationalized; it builds a hierarchical
+ representation of the document from the headers, and simultaneously
+ gives each section a unique identifier based on the heading title.
+ + Identifiers are now attached to the divs rather than
+ to the headers themselves.
+ + Table of content backlinks go to the beginning of the table, rather
+ than to the section reference that was clicked.
+ + Code for constructing identifiers has been moved to Text.Pandoc.Shared
+ from the HTML writer, since it is now consumed only by
+ hierarchicalize.
+ + In --strict mode, pandoc just prints bare headings, as before
+ (unless --toc has been specified).
+ + In s5 output, it does not wrap sections in divs, as that seems to
+ confuse the s5 javascript.
+
+ * Man writer: break lines at end of each sentence. groff expects this
+ and treats '.' and '?' differently when followed by line ending as
+ opposed to ordinary space. Also, don't escape periods. Instead, use
+ zero-width character \& to avoid unwanted interpretation of periods
+ at start of line. Resolves Issue #148.
+
+ * Markdown writer: Added '#' and '>' to list of characters to be
+ escaped in markdown output. Removed '<', as it is not an officially
+ escapable character. This partially resolves Issue #96.
+
+ * Make --smart the default for man output format. Otherwise we have
+ trouble dividing lists of endlines into sentences.
+
+ * DocBook writer: Use language attribute to indicate source language
+ in code blocks.
+
+ * RST reader:
+
+ + Allow # to continue list, even if the list was started with an
+ explicit marker. For example:
+
+ A. my list
+ #. continued
+
+ Resolves Issue #140.
+ + Allow continuation lines in line blocks. Also added test cases for
+ line blocks for RST reader. Resolves Issue #149.
+ + Allow explicit links with spaces in URL: `link <to this>`_
+
+ * Improved LaTeX reader's coverage of math modes. Remove displaymath*
+ (which is not in LaTeX) and recognize all the amsmath environments
+ that are alternatives to eqnarray, namely equation, equation*,
+ gather, gather*, gathered, multline, multline*, align, align*,
+ alignat, alignat*, aligned, alignedat, split. Resolves Issue #103.
+ Thanks to shreevatsa.public for the patch.
+
+ * Markdown reader:
+
+ + Allow -, _, :, . in markdown attribute names. These are legal in
+ XML attribute names.
+ + Use non-breaking spaces in abbreviations.
+ + Markdown reader: improved efficiency of abbreviation parsing.
+ Instead of a separate abbrev parser, we just check for
+ abbreviations each time we parse a string. This gives a huge
+ performance boost with -S. Resolves Issue #141.
+
+ * Improved efficiency of shared parsers: hexNum, htmlComment,
+ whitespace, indentSpaces.
+
+ * Export HTMLMathMethod in Text.Pandoc.
+
+ * Export languagesByExtension in Text.Pandoc.Highlighting.
+
+ * Added new Haskell version of markdown2pdf, due to
+ Paulo Tanimoto. This should be more portable than the old
+ shell script.
+
+ * Made 'pandoc -v' more explicit about compiler options.
+ Resolves Issue #139.
+
+ * pandoc.hs: Made --strict compatible with --standalone, --toc.
+
+ * Use Paths_pandoc to get version number, instead of hard-coding it
+ into Text/Pandoc.hs.
+
+pandoc (1.2)
+
+ [ John MacFarlane ]
+
+ * Added support for literate Haskell. lhs support is triggered by
+ '+lhs' suffixes in formats. For example, 'latex+lhs' is literate
+ Haskell LaTeX. '.lhs' files are treated by default as literate
+ markdown.
+
+ + Added stateLiterateHaskell to parser state.
+ + Added parser for lhsCodeBlock to Markdown, RST, LaTeX readers.
+ + Added parser for |inline lhs| to LaTeX reader.
+ + Added writerLiterateHaskell to WriterOptions.
+ + Added lhs support to Markdown, RST, LaTeX, HTML writers.
+ + Added definition of code environment to LaTeX header.
+ + Added tests (run only if highlighting support compiled in).
+ + Documented lhs features in man page and README.
+
+ * In Text.Pandoc.Definition, added processWith, processWithM,
+ and queryWith, and deprecated processPandoc and queryPandoc
+ for these more general functions.
+
+ * Fixed bug in mediawiki writer: improper closing tags in tables.
+ Thanks to Benct Philip Jonsson for reporting the bug.
+
+ * Added --email-obfuscation option.
+
+ + Added writer option for email obfuscation.
+ + Implemented email obfuscation options in HTML writer.
+ + Added option to option parser.
+ + Documented in README and pandoc man page.
+ + Resolves Issue #97.
+
+ * LaTeX writer: fixed bug with empty table cells.
+ Resolves Issue #107. Thanks to rodja.trappe for the patch.
+
+ * Fixed bug with header spacing in Markdown and RST writers.
+ A null header (Meta [] [] []) should not cause a blank line
+ at the beginning of output. But a blank line is needed between
+ a non-null header and the main text.
+
+ * Markdown reader: Relax spacing rules for $$ in display math. Now
+ space and newlines are allowed after the opening $$ and before the
+ closing $$. However, the display math cannot contain an entirely
+ blank line. Resolves Issue #105.
+
+ * Markdown reader: Gobble space after Plain blocks containing only
+ raw html inline. Otherwise following header blocks are not parsed
+ correctly, since the parser sees blank space before them. Resolves
+ Issue #124.
+
+ * Markdown reader: Allow " as well as '' to end a latex double-quote.
+
+ * Conditionally depend on syb and base >= 4 if ghc >= 6.10.
+ Resolves Issue #109.
+
+ * Fixed problems in RST and markdown output due to bug in pretty-1.0.1.0
+
+ + Added hang' function to Text.Pandoc.Shared; this will be used instead
+ of hang, which doesn't work properly in pretty-1.0.1.0. When pretty
+ is upgraded, we can go back to hang.
+ See http://article.gmane.org/gmane.comp.lang.haskell.general/16687
+ + Use hang' (and some different techniques) in RST and markdown writers.
+ Some output is now a bit different.
+
+ * Brought citeproc support up to date for citeproc-hs-0.2.
+ (Patch by Andrea Rossato.)
+
+ * Moved all haskell source to src subdirectory. Renamed Main.hs to
+ pandoc.hs.
+
+ * Rewrote hsmarkdown in Haskell for portability (src/hsmarkdown.hs).
+ For now, keeping the old shell script too.
+
+ * Added TemplateHaskell to Extensions for executable, removed
+ -threaded for library. Thanks to duncan.coutts for the bug report.
+ Resolves Issue #121.
+
+ * Moved some Extra-Source-Files to Data-Files.
+
+ * Moved tabFilter to Shared.
+
+ * In pandoc.hs, removed optPreserveTabs; instead, tabstop of 0 means
+ preserve tabs.
+
+ * Minor code cleanup based on hlint suggestions.
+
+pandoc (1.1)
+
+ [ John MacFarlane ]
+
+ * Main.hs:
+
+ + Changed date on copyright message in Main.hs.
+ + Have the '-v' option print syntax highlighting languages
+ separated by commas, and wrapped in lines, instead of in five
+ columns as before.
+
+ * Added --jsmath option. Resolves Issue #68.
+
+ + Added --jsmath option to Main.hs
+ + Added JsMath to HTMLMathMethod in Text.Pandoc.Shared.
+ + Handle math appropriately in HTML writer when JsMath selected.
+ + Documented the option in README and man page.
+
+ * Text.Pandoc.Shared: Changed compactify to use a better heuristic
+ for tight and loose lists. Final Para is changed to Plain if all
+ other list items *end* with a Plain block. Addresses Issue #99.
+
+ * HTML reader:
+
+ + Added colons to protocols in unsanitaryURI. Closes Issue #88.
+ + HTML reader: Don't interpret contents of <pre> blocks as markdown.
+ Added rawVerbatimBlock parser. Resolves Issue #94.
+
+ * Markdown reader:
+
+ + Allow URLs with spaces in them in links and references, but escape
+ them as "%20".
+ + Allow blank space at the end of horizontal rules.
+
+ * RST reader: Modified 'unknownDirective' parser to handle comment
+ blocks correctly, and added tests for comment blocks. Resolves Issue
+ #86. Closes Debian Bug #500662.
+
+ * HTML writer:
+
+ + Include classes on tr elements in HTML output:
+ "header", "odd", "even". This allows tables to be styled with
+ lines in alternating colors. Resolves Issue #91.
+ + Enclose all LaTeXMathML bits in <span class="LaTeX">.
+ This prevents parts of the document that are not math from being
+ interpreted as math by LaTeXMathML.js.
+
+ * OpenDocument and ODT writers: Added support for HorizontalRule elements,
+ which were formerly ignored. Resolves Issue #95.
+
+ * Text.Pandoc.Shared: Modified wrappedTeX to eliminate the line break
+ between a footnote and immediately following nonspace characters in
+ LaTeX and ConTeXt output. (This gets interpreted as a space, which
+ is not desired in cases like "text^[note]---".) Resolves Issue #93.
+
+ * Windows installer: Don't require admin privileges to run
+ installer. Modified pandoc-setup.iss, and changed modpath.iss to
+ modify HKCU path if user lacks admin privileges. Also fixed case
+ where oldpath is empty (previously this led to the new path
+ beginning with a semicolon).
+
+ * Updated INSTALL instructions for Arch packages and OS X install using
+ cabal-install.
+
+ * Removed the (now unneeded) debian directory.
+ Removed empty Codec and System directories.
+
+ * Moved odt-styles/ to data/. Removed unneeded variable in Makefile.
+
+ * Modified Setup.hs so that the "test" target returns an error status
+ when tests fail, and "build" returns a success status if
+ the build succeeds. Resolves Issue #100.
+
+ * Added BUGS to files in tarball.
+
+
+pandoc (1.0.0.1)
+
+ [ John MacFarlane ]
+
+ * Removed spurious reference to pdf output format from pandoc(1) man page.
+
+pandoc (1.0)
+
+ [ Andrea Rossato ]
+
+ * Added new OpenDocument writer.
+
+ * Added support for SmallCaps inline element.
+
+ * Added support for integrating pandoc with citeproc-hs.
+
+ + Added Cite element to definition and writers.
+ + Added Text.Pandoc.Biblio module
+ + Note: This support is included only if the 'citeproc'
+ Cabal configuration flag is set.
+
+ * Made Pandoc data structure an instance of Typeable.
+ Added new processPandoc and queryPandoc functions, to query
+ or transform matching elements in a Pandoc structure.
+
+ [ Peter Wang ]
+
+ * Added new Texinfo writer.
+
+ [ John MacFarlane ]
+
+ * Changes to Texinfo writer:
+
+ + No space between paragraph and following @verbatim (provides more
+ pleasing appearance in text formats)
+ + Blank line consistently after list environments.
+ + Removed deVerb.
+ + Use @code instead of @verb for inline code (this solves the character
+ escaping problem for texi2dvi and texi2pdf).
+ + Added news of Texinfo writer to README.
+ + Added Texinfo to list of formats in man page, and removed extra 'groff'.
+ + Added texi & texinfo extensions to Main.hs, and fixed bug in determining
+ default output extension.
+ + Modified disallowedInNode in Texinfo writer to correct list of disallowed characters.
+
+ * Added tests for OpenDocument writer.
+
+ * Added ODT writer (using zip-archive library to package output of
+ OpenDocument writer). Added odt-styles directory with default ODT styles.
+
+ * Added new mediawiki writer and tests.
+
+ * Markdown reader: Added support for delimited code blocks, with optional
+ syntax highlighting using highlighting-kate (if the 'highlighting'
+ configuration option is selected).
+
+ + Currently highlighting is supported only in the HTML writer.
+ + Delimited code blocks can have attributes; using the language name as
+ class triggers highlighting.
+ + New Attributes parameter in CodeBlock structure.
+ + --version now indicates whether syntax highlighting support is compiled
+ in, and prints a list of supported languages
+
+ * Removed debian directory. Pandoc is no longer a native debian package.
+
+ * Changes to build process: pandoc can now be built from the repository
+ using Cabal. No unix tools are needed (so, pandoc can be built on Windows
+ without Cygwin).
+
+ + Include shell scripts themselves in repo, rather than generating from wrappers.
+ Removed wrappers directory and wrappers Makefile target.
+ + Text/Pandoc/ASCIIMathML.hs, Text/Pandoc/DefaultHeaders.hs,
+ and Text/Pandoc/Writers/S5.hs are no longer built in Makefile
+ from templates in the templates/ directory. Instead, they use template
+ haskell to read data at compile time from the relevant files in data/.
+ Template haskell functions go in a new module, Text.Pandoc.TH.
+ + man pages are now generated in Setup.hs hook, not by Makefile
+ + Makefile 'tarball' target now calls Cabal's 'sdist'
+ + Added "Extra-Source-Files" to pandoc.cabal, so sdist contains everything needed
+ + Added "Build-Type" field to pandoc.cabal to avoid warning.
+ + Added to "Extra-source-files" and "Extra-tmp-files" in pandoc.cabal,
+ so 'sdist' and 'clean' will work properly.
+ + Setup.hs now generates man pages in a postbuild hook.
+ + Added dependency-checking to Setup.hs, so it only rebuilds things
+ that need rebuilding.
+ + Added 'library' and 'executable' configuration flags.
+ Cabal can now be told to build just the library or just the executable.
+ + CABALOPTS may now be specified with 'make' to pass Cabal configuration flags.
+ For example: CABALOPTS=-fhighlighting make
+
+ * Rewrote test suite so it doesn't depend on perl or unix tools.
+
+ + Replaced old runtests.pl with a Haskell script RunTests.hs.
+ + Added Diff.hs module to be used by RunTests.hs instead of unix 'diff'.
+ + Added test hook to Setup.hs, so tests may be run from cabal.
+ + Changed Makefile's 'test' target to run tests via cabal.
+ + Removed old generate.sh.
+ + Since we no longer have 'sed' to filter out raw HTML sections
+ from the docbook writer test, or raw LaTeX sections from the
+ context writer test, we now just include these sections.
+ They can be taken out if it is necessary to process the files.
+ + Updated latex and context writer tests to remove extra spaces
+ after '\\item'
+ + Added a markdown table reader test.
+ + Added markdown-reader-more.txt to test suite, for additional test cases
+ for raw ConTeXt environments and more.
+
+ * Compatibility fixes for CPP, Cabal, and haddock:
+
+ + Use CPP in "Extensions" field in pandoc.cabal.
+ + Removed use of backslash string continuations in source files.
+
+ * Removed pandoc.cabal.ghc66. We now require Cabal >= 1.2, GHC >= 6.8,
+ base >= 3.
+
+ * Require parsec < 3.
+ The compatibility module in parsec 3.0.0 gives far worse performance than
+ parsec 2.1. Eventually pandoc will be upgraded to use the new bytestring
+ version of parsec, and then we'll go to parsec 3.0.0.
+
+ * Removed Text.Regex dependencies by rewriting using plain Haskell
+ (Text.Pandoc.Writers.RTF, Text.Pandoc.Writers.HTML, Main.hs)
+
+ * Moved Text.Pandoc.Writers.DefaultHeaders -> Text.Pandoc.DefaultHeaders.
+
+ * Makefile:
+
+ + Added 'configure' as dependency of 'uninstall-all'.
+ (It uses the Cabal build program.)
+ + Makefile: only use --with-hc-pkg if GHC_PKG is defined.
+ Note that Cabal will automatically choose the ghc-pkg appropriate
+ for the compiler selected, so normally specifying GHC by itself
+ is sufficient.
+
+ * Removed Text.Pandoc.UTF8 module; instead, depend on utf8-string and use
+ its IO and conversion functions.
+
+ * Added -Wall to ghc-options in pandoc.cabal. Cleaned up modules so that
+ everything is -Wall clean.
+
+ + Added pragma to HTML writer to avoid deprecation warning for use of "start" attribute.
+ + Added pragma to Text/Pandoc/Shared.hs to get rid of "orphan instance" warnings.
+ (These are caused by the Lift instance for ByteString.)
+
+ * Changed the comment used to replace unsafe HTML if sanitize-html option
+ selected.
+
+ * Made -c/--css option repeatable on the command line (like -H, -A, -B).
+
+ * Moved XML-formatting functions to new unexported module Text.Pandoc.XML.
+
+ * Escape '\160' as "&#160;", not "&nbsp;" in XML.
+ "nbsp" isn't a predefined XML entity.
+
+ * Fixed bug in RST reader, which would choke on: "p. one\ntwo\n".
+ Added some try's in ordered list parsers.
+
+ * Man writer: don't escape " as \".
+
+ * Allow newline before URL in markdown link references. Resolves Issue #81.
+ Added tests for this issue in new "markdown-reader-more" tests.
+ Changed RunTests.hs to run these tests.
+
+ * Support for display math. Resolves Issue #47.
+
+ + Added a DisplayMath/InlineMath selector to Math inlines.
+ + Markdown parser yields DisplayMath for $$...$$.
+ + LaTeX parser yields DisplayMath when appropriate. Removed
+ mathBlock parsers, since the same effect is achieved by the math
+ inline parsers, now that they handle display math.
+ + Writers handle DisplayMath as appropriate for the format.
+ + Modified tests accordingly; added new tests for display math.
+
+ * Use LaTeXMathML instead of ASCIIMathML. LaTeXMathML is closer
+ to LaTeX in its display of math, and supports many non-math LaTeX environments.
+
+ + Changed -m option to use LaTeXMathML rather than ASCIIMathML.
+ + Modified HTML writer to print raw TeX when LaTeXMathML is
+ being used instead of suppressing it.
+ + Removed ASCIIMathML files from data/ and added LaTeXMathML.
+ + Replaced ASCIIMathML with LaTeXMathML in source files.
+ + Modified README and pandoc man page source.
+ + Added --latexmathml option (kept --asciimathml as a synonym
+ for backwards compatibility)
+
+ * Markdown reader: Parse setext headers before atx headers.
+ Test case:
+ # hi
+ ====
+ parsed by Markdown.pl as an H1 header with contents "# hi".
+
+ * Markdown reader: Treat "mixed" lists the same way as Markdown.pl does.
+ The marker on the first list item determines the type of the whole
+ list. Thus, a list like
+ 1. one
+ - two
+ * three
+ gets parsed as a single ordered list. (Previous versions of pandoc
+ treated this as an ordered list with an unordered sublist.)
+
+ * Markdown smart typography:
+
+ + Em dashes no longer eat surrounding whitespace. Resolves Issue #69.
+ + Use nonbreaking spaces after known abbreviations in markdown parser.
+ Thus, for example, "Mr. Brown" comes out as "Mr.~Brown" in LaTeX, and does
+ not produce a sentence-separating space. Resolves Issue #75.
+
+ * Markdown writer: Print unicode \160 literally, rather than as &nbsp;.
+
+ * Treat '\ ' in (extended) markdown as nonbreaking space.
+ Print nonbreaking space appropriately in each writer (e.g. ~ in LaTeX).
+
+ * The '--sanitize-html' option now examines URIs in markdown links
+ and images, and in HTML href and src attributes. If the URI scheme
+ is not on a whitelist of safe schemes, it is rejected. The main point
+ is to prevent cross-site scripting attacks using 'javascript:' URIs.
+ See http://www.mail-archive.com/markdown-discuss@six.pairlist.net/msg01186.html
+ and http://ha.ckers.org/xss.html. Resolves Issue #62.
+
+ * HTML writer:
+
+ + Override Text.XHtml's stringToHtml function,
+ so that characters below 0xff are not converted to numerical entity
+ references. Also convert '\160' to "&nbsp;". This should aid readability
+ and editability of the HTML source. It does presuppose that the HTML
+ will be served as UTF-8.
+ + In code blocks, change leading newlines to <br /> tags.
+ (Some browsers ignore them.) Resolves Issue #71.
+ See http://six.pairlist.net/pipermail/markdown-discuss/2008-May/001297.html
+ + Use style attributes rather than css classes for strikethrough
+ and ordered list styles. This works better when fragments, rather than
+ standalone documents, are generated.
+
+ * HTML reader: Count anything that isn't a known block (HTML) tag as an
+ inline tag (rather than the other way around). Added "html", "head", and
+ "body" to list of block tags. Resolves Issue #66, allowing
+ <lj> to count as an inline tag.
+
+ * RTF writer: Fixed bug. Extra spaces were being printed after emphasized,
+ boldface, and other inline elements. Resolves Issue #64.
+
+ * LaTeX reader: improvements in raw LaTeX parsing.
+
+ + "loose punctuation" (like {}) parsed as Space
+ + Para elements must contain more than Str "" and Space elements
+ + Added parser for "\ignore" command used in literate haskell.
+ + Reworked unknownCommand and rawLaTeXInline: when not in "parse raw"
+ mode, these parsers simply strip off the command part and allow
+ the arguments to be parsed normally. So, for example,
+ \blorg{\emph{hi}} will be parsed as Emph "hi" rather than
+ Str "{\\emph{hi}}".
+ + Parse lhs "code" environments as verbatim.
+ Refactored parsers for verbatim environments.
+ + Removed specialEnvironment parser.
+ + parse '{}', if present, after \textless, \textgreater,
+ \textbar, \textbackslash, \ldots.
+ + Parse unescaped special characters verbatim rather than
+ changing them to spaces. This way arguments of unknown
+ commands will appear in braces.
+
+ * Parse raw ConTeXt environments as TeX in markdown reader.
+ Resolves Issue #73.
+
+ * Moved BlockWrapper and wrappedBlocksToDoc from ConTeXt writer to Shared.
+
+ * Made some structural changes to parsing of raw LaTeX environments.
+ Previously there was a special block parser for LaTeX environments.
+ It returned a Para element containing the raw TeX inline. This has
+ been removed, and the raw LaTeX environment parser is now used in the
+ rawLaTeXInline parser. The effect is exactly the same, except that we
+ can now handle consecutive LaTeX and ConTeXt environments not separated
+ by spaces. This new flexibility is required by the example in
+ Issue #73:
+
+ \placeformula \startformula
+ L_{1} = L_{2}
+ \stopformula
+
+ API change: The LaTeX reader now exports rawLaTeXEnvironment' (which
+ returns a string) rather than rawLaTeXEnvironment (which returns a block
+ element). This is more likely to be useful in other applications.
+
+ * Use \textsubscr instead of \textsubscript for LaTeX subscript macro.
+ \textsubscript conflicts with a definition in the memoir class.
+ Resolves Issue #65.
+
+ * Removed unneeded space after "\\item" in LaTeX and ConTeXt output.
+
+ * Added amsmath package to default LaTeX header. Resolves Issue #48.
+
+ * Added \setupitemize[autointro] to ConTeXt header, to prevent orphaned
+ list introduction lines.
+
+ * Changed Float to Double in definition of Table element.
+ (Double is more efficient in GHC.)
+
+ * Fixed bug in Markdown parser: regular $s triggering math mode.
+ For example: "shoes ($20) and socks ($5)."
+ The fix consists in two new restrictions:
+
+ + the $ that ends a math span may not be directly followed by a digit.
+ + no blank lines may be included within a math span.
+
+ Thanks to Joseph Reagle for noticing the bug.
+
+ * Use Data.List's 'intercalate' instead of custom 'joinWithSep'.
+ Removed 'joinWithSep' from Text.Pandoc.Shared.
+
+ * Updated README and man pages. Acknowledge contributors in README.
+ Added paragraph to README about producing S5 with separate CSS/javascript.
+
+ * Updated INSTALL to reflect new build system (including configuration
+ options) and document new dependencies. Added note to INSTALL that
+ Cabal >= 1.2 is required for build. Resolves Issue #74.
+
+ * Fixed some haddock documentation errors.
+
+ * Small fix to markdown2pdf man page: only input needs to be piped through iconv.
+
+pandoc (0.46) unstable; urgency=low
+
+ [ John MacFarlane ]
+
+ * Made -H, -A, and -B options cumulative: if they are specified
+ multiple times, multiple files will be included.
+
+ * Added optional HTML sanitization using a whitelist.
+ When this option is specified (--sanitize-html on the command line),
+ unsafe HTML tags will be replaced by HTML comments, and unsafe HTML
+ attributes will be removed. This option should be especially useful
+ for those who want to use pandoc libraries in web applications, where
+ users will provide the input.
+
+ + Main.hs: Added --sanitize-html option.
+
+ + Text.Pandoc.Shared: Added stateSanitizeHTML to ParserState.
+
+ + Text.Pandoc.Readers.HTML:
+ - Added whitelists of sanitaryTags and sanitaryAttributes.
+ - Added parsers to check these lists (and state) to see if a given
+ tag or attribute should be counted unsafe.
+ - Modified anyHtmlTag and anyHtmlEndTag to replace unsafe tags
+ with comments.
+ - Modified htmlAttribute to remove unsafe attributes.
+ - Modified htmlScript and htmlStyle to remove these elements if
+ unsafe.
+
+ + Modified README and man pages to document new option.
+
+ * Improved handling of email addresses in markdown and reStructuredText.
+ Consolidated uri and email address parsers. (Resolves Issue #37.)
+
+ + New emailAddress and uri parsers in Text.Pandoc.Shared.
+ - uri parser uses parseURI from Network.URI.
+ - emailAddress parser properly handles email addresses with periods
+ in them.
+
+ + Removed uri and emailAddress parsers from Text.Pandoc.Readers.RST
+ and Text.Pandoc.Readers.Markdown.
+
+ * Markdown reader:
+
+ + Fixed emph parser so that "*hi **there***" is parsed as a Strong
+ nested in an Emph. (A '*' is only recognized as the end of the
+ emphasis if it's not the beginning of a strong emphasis.)
+
+ + Moved blockQuote parser before list parsers for performance.
+
+ + Modified 'source' parser to allow backslash-escapes in URLs.
+ So, for example, [my](/url\(1\)) yields a link to /url(1).
+ Resolves Issue #34.
+
+ + Disallowed links within links. (Resolves Issue #35.)
+ - Replaced inlinesInBalanced with inlinesInBalancedBrackets, which
+ instead of hard-coding the inline parser takes an inline parser
+ as a parameter.
+ - Modified reference and inlineNote to use inlinesInBalancedBrackets.
+ - Removed unneeded inlineString function.
+ - Added inlineNonLink parser, which is now used in the definition of
+ reference.
+ - Added inlineParsers list and redefined inline and inlineNonLink parsers
+ in terms of it.
+ - Added failIfLink parser.
+
+ + Better handling of parentheses in URLs and quotation marks in titles.
+ - 'source' parser first tries to parse URL with balanced parentheses;
+ if that doesn't work, it tries to parse everything beginning with
+ '(' and ending with ')'.
+ - source parser now uses an auxiliary function source'.
+ - linkTitle parser simplified and improved, under assumption that it
+ will be called in context of source'.
+
+ + Make 'block' conditional on strictness state, instead of using
+ failIfStrict in block parsers. Use a different ordering of parsers
+ in strict mode (raw HTML block before paragraph) for performance.
+ In non-strict mode use rawHtmlBlocks instead of htmlBlock.
+ Simplified htmlBlock, since we know it's only called in strict
+ mode.
+
+ + Improved handling of raw HTML. (Resolves Issue #36.)
+ - Tags that can be either block or inline (e.g. <ins>) should
+ be treated as block when appropriate and as inline when
+ appropriate. Thus, for example,
+ <ins>hi</ins>
+ should be treated as a paragraph with inline <ins> tags, while
+ <ins>
+ hi
+ </ins>
+ should be treated as a paragraph within <ins> tags.
+ - Moved htmlBlock after para in list of block parsers. This ensures
+ that tags that can be either block or inline get parsed as inline
+ when appropriate.
+ - Modified rawHtmlInline' so that block elements aren't treated as
+ inline.
+ - Modified para parser so that paragraphs containing only HTML tags and
+ blank space are not allowed. Treat these as raw HTML blocks instead.
+
+ + Fixed bug wherein HTML preceding a code block could cause it to
+ be parsed as a paragraph. The problem is that the HTML parser
+ used to eat all blank space after an HTML block, including the
+ indentation of the code block. (Resolves Issue #39.)
+ - In Text.Pandoc.Readers.HTML, removed parsing of following space
+ from rawHtmlBlock.
+ - In Text.Pandoc.Readers.Markdown, modified rawHtmlBlocks so that
+ indentation is eaten *only* on the first line after the HTML
+ block. This means that in
+ <div>
+ foo
+ <div>
+ the foo won't be treated as a code block, but in
+ <div>
+
+ foo
+
+ </div>
+ it will. This seems the right approach for least surprise.
+
+ * RST reader:
+
+ + Fixed bug in parsing explicit links (resolves Issue #44).
+ The problem was that we were looking for inlines until a '<' character
+ signaled the start of the URL; so, if you hit a reference-style link,
+ it would keep looking til the end of the document. Fix: change
+ inline => (notFollowedBy (char '`') >> inline). Note that this won't
+ allow code inlines in links, but these aren't allowed in resT anyway.
+
+ + Cleaned up parsing of reference names in key blocks and links.
+ Allow nonquoted reference links to contain isolated '.', '-', '_', so
+ so that strings like 'a_b_' count as links.
+
+ + Removed unnecessary check for following link in str.
+ This is unnecessary now that link is above str in the definition of
+ 'inline'.
+
+ * HTML reader:
+
+ + Modified rawHtmlBlock so it parses </html> and </body> tags.
+ This allows these tags to be handled correctly in Markdown.
+ HTML reader now uses rawHtmlBlock', which excludes </html> and </body>,
+ since these are handled in parseHtml. (Resolves Issue #38.)
+
+ + Fixed bug (emph parser was looking for `<IT>` tag, not `<I>`).
+
+ + Don't interpret contents of style tags as markdown.
+ (Resolves Issue #40.)
+ - Added htmlStyle, analagous to htmlScript.
+ - Use htmlStyle in htmlBlockElement and rawHtmlInline.
+ - Moved "script" from the list of tags that can be either block or
+ inline to the list of block tags.
+
+ + Modified rawHtmlBlock to use anyHtmlBlockTag instead of anyHtmlTag
+ and anyHtmlEndTag. This fixes a bug in markdown parsing, where
+ inline tags would be included in raw HTML blocks.
+
+ + Modified anyHtmlBlockTag to test for (not inline) rather than
+ directly for block. This allows us to handle e.g. docbook in
+ the markdown reader.
+
+ * LaTeX reader: Properly recognize --parse-raw in rawLaTeXInline.
+ Updated LaTeX reader test to use --parse-raw.
+
+ * HTML writer:
+
+ + Modified rules for automatic HTML header identifiers to
+ ensure that identifiers begin with an alphabetic character.
+ The new rules are described in README. (Resolves Issue #33.)
+
+ + Changed handling of titles in HTML writer so you don't get
+ "titleprefix - " followed by nothing.
+
+ * ConTeXt writer: Use wrappers around Doc elements to ensure proper
+ spacing. Each block element is wrapped with either Pad or Reg.
+ Pad'ed elements are guaranteed to have a blank line in between.
+
+ * RST writer:
+
+ + Refactored RST writer to use a record instead of a tuple for state,
+ and to include options in state so it doesn't need to be passed as
+ a parameter.
+
+ + Use an interpreted text role to render math in restructuredText.
+ See http://www.american.edu/econ/itex2mml/mathhack.rst for the
+ strategy.
+
+ [ Recai Oktaş ]
+
+ * Debian packaging changes:
+
+ + Remove the empty 'include' directory in -dev package, which lintian
+ complains about.
+ + Bump Standarts-Version to 3.7.3.
+ + Use new 'Homepage:' field to specify the upstream URL on suggestion of
+ lintian.
+
+ -- Recai Oktaş <roktas@debian.org> Tue, 08 Jan 2008 05:13:31 +0200
+
+pandoc (0.45) unstable; urgency=low
+
+ [ John MacFarlane ]
+
+ * Simplified parsing of reference keys and notes in markdown and RST
+ readers: The Reference data structure from Text.Pandoc.Shared is no
+ longer needed, since referenceKey and noteBlock parses return strings
+ (as many blank lines as were occupied by the key or note) and update
+ state themselves. getPosition and setPosition are now used to ensure
+ that error messages will give the correct line number. This yields
+ cleaner (and slightly faster) code, with more accurate parsing error
+ messages.
+
+ * Added new Math inline element:
+
+ + Markdown and LaTeX readers now convert TeX math into Math elements,
+ not TeX.
+ + This allows math to be treated differently from raw TeX in output.
+ TeX elements are no longer printed in output formats other than
+ Markdown, LaTeX, and ConTeXt. But Math elements are always printed.
+
+ * New default handling of math in writers:
+
+ + New module Text.Pandoc.Readers.TeXMath exports readTeXMath, which
+ parses raw TeX math and outputs a string of Pandoc inlines that
+ tries to render it as far as possible using unicode characters,
+ lapsing into literal TeX when needed.
+ + readTeXMath is now used for default HTML output in HTML, S5, RTF,
+ and Docbook, if no other method for displaying math in HTML is
+ specified. Enclosing $'s are no longer printed by default.
+ + By default, math is put inside `<span class="math">`. This way it can be
+ distinguished from the surrounding text, e.g. put in a different
+ font.
+
+ * New --gladtex and --mimetex options for display of math in HTML:
+
+ + If --gladtex is specified, math is output between `<eq>` tags, so
+ it can be processed by gladTeX.
+ + If --mimetex is specified, math is put in `<img>` tags with a link
+ to the mimetex CGI script (or any other script that takes TeX math
+ as input and outputs an image). The URL of the script may be
+ specified, but defaults to /cgi-bin/mimetex.cgi.
+ + HTMLMathMethod structure in WriterOptions keeps track of how to
+ display math in HTML output.
+ + Updated README with a description of the four options for displaying
+ math in HTML.
+
+ * HTML reader:
+
+ + Fixed bug: parser for minimized attributes should not swallow
+ trailing spaces.
+ + Simplified HTML attribute parsing.
+ + Changed parsing of code blocks in HTML reader: `<code>` tag is no
+ longer needed. `<pre>` suffices. All HTML tags in the code block
+ (e.g. for syntax highlighting) are skipped, because they are not
+ portable to other output formats. A `<code>...</code>` block not
+ surrounded by `<pre>` now counts as inline HTML, not a code block.
+ + Remove just one leading and one trailing newline from contents of
+ `<pre>...</pre>` in codeBlock parser.
+
+ * Markdown reader:
+
+ + Removed support for box-style block quotes.
+ + Require space before title in links and references.
+ This fixes a bug in parsing URLs like http://silly/url(withparen).
+ + Improved and simplified setextHeader parser.
+ + Fixed logic in smart quote parsing, adding some needed 'try'
+ statements.
+ + Fixed smart quote parsing so that unicode characters 8216 and 8217
+ are recognized as single quotes, and 8220 and 8221 as double quotes.
+
+ * RST reader:
+
+ + Fixed bug in parsing of code blocks. Previously a full tab indent
+ was required, but RST allows code to be indented any amount.
+ Resolves Issue #27.
+ + Allow field lists to be indented.
+ + Parse the contents of field lists instead of treating as a raw string.
+ + Represent field lists as definition lists instead of blockquotes.
+ + Fixed bug in which metadata would be overridden if the document
+ contained multiple field lists.
+ + Parse fields associated with '.. image::' blocks, and use 'alt'
+ field, if given, for image alt and title attributes.
+
+ * LaTeX reader:
+
+ + Modified specialChar so that '"' characters are parsed.
+ + Fixed a bug in parsing of \[ \] math blocks (thanks to Mark Kalderon).
+
+ * HTML writer:
+
+ + Changes in handling of math (see above).
+ + Don't produce HTML for table of contents if there are
+ no headers. (This would be an empty list, which is invalid XHTML.)
+
+ * Markdown writer:
+
+ + Don't print title attribute if title is empty. (This differs from
+ the behavior of Markdown.pl, and agrees with PHP Markdown. But John
+ Gruber has indicated that he prefers this behavior.) Adjusted test
+ suite accordingly.
+ + Fixed incorrect line wrapping in paragraphs including hard line
+ breaks. Resolves Issue #25.
+ + Fixed bug in markdown writer: If an ordered list item began with
+ a marker greater than 3 characters in width, and the item took more
+ than one line, it would appear on the line after the list marker,
+ e.g.:
+
+ (12)
+ My list item.
+ Multiline.
+
+ Now it works as follows:
+
+ (12) My list item.
+ Multiline.
+
+ * RST writer
+
+ + Fixed bug in RST writer's handling of ordered lists. Previously,
+ list items with multiple lines would not always line up with
+ single-line list items. Now, list items are nested the length of
+ the list marker + 1. This looks better and ensures that list items
+ all line up. (Note that list markers are padded to the length of
+ the longest list marker in the series.)
+ + Use 3-space indent for unordered lists.
+ + If label for a link reference contains a colon, surround it by `
+ signs so it won't be interpreted as the end of the link label.
+
+ * LaTeX writer:
+
+ + Cleaner output for footnotes. Footnotes now always begin on a new
+ line, and the final } is on a line by itself only when it needs to
+ be (i.e. only when the note ends with a Verbatim environment).
+ + Added writer options to state, so state doesn't need to be passed as
+ a parameter.
+ + Text wrapping now provided, using wrapTeXIfNeeded.
+
+ * ConTeXt writer: many improvements for more idiomatic ConTeXt output
+ (thanks to Idris Samawi Hamid for suggestions).
+
+ + PrettyPrint module now used for output.
+ + Writer options are now in state, so they don't have to be passed as
+ a parameter.
+ + Text wrapping now provided, using wrapTeXIfNeeded.
+ + Better treatment of footnotes: footnotes are always on lines by
+ themselves, and the final } is on a line by itself only when
+ it needs to be (after \stoptyping).
+ + Use \subject, \subsubject, ... or \section, \subsection, ... for headings,
+ depending on whether --number-sections option is selected.
+ + Extra blank line inserted after \stopitemize
+ + Use new, "official" definition of blockquote environment. Also, use
+ blank line after \startblockquote to balance blank line at the end.
+ + Both itemized and enumerated lists are now generated using
+ \start-stopitemize, with appropriate options. Removed definitions
+ of ltxenum and ltxitem, which are no longer needed. Provided
+ defaults for itemized lists in the preamble. State keeps track of
+ ordered list level, so that when default numbering is specified,
+ the appropriate scheme can be used.
+ + Changed \useurl to \useURL.
+ + Changed link color from red to blue.
+ + Use \subsubsubsubsection etc., since these are supported
+ (up to at least sub x 5).
+
+ * Text.Pandoc.Shared:
+
+ + Save and restore position in parseFromString, so that accurate
+ error messages can be given.
+ + Improved efficiency of romanNumeral parser.
+ + Added wrappedTeX and wrapTeXIfNeeded functions. These ensure
+ that footnotes occur on lines by themselves (to make them
+ easier to see and move) and do not screw up line wrapping.
+
+ * Text.Pandoc.UTF8: modified fromUTF8 to strip out the BOM
+ if present. Windows Notepad and other applications insert a
+ BOM at the beginning of a UTF8 file.
+
+ * Main.hs (tabFilter): Treat '\r' at end of line as newline (in
+ addition to "\r\n" and '\n').
+
+ * Added a writer option for wrapped text and a command-line option
+ '--no-wrap', which disables text wrapping and minimizes whitespace
+ in HTML. (Resolves Issue #26.)
+
+ + Added support for '--no-wrap' to Main.hs.
+ + Added wrapIfNeeded function to Text.Pandoc.Shared.
+ + Use wrapIfNeeded instead of wrapped in the RST, Man, Docbook, and
+ Markdown writers.
+ + Added render and renderFragment helpers to HTML writer.
+
+ * Modified html2markdown to run tidy only if the HTML cannot be
+ parsed. Previously html2markdown piped all input through tidy
+ before passing it to pandoc. This caused problems on certain pages
+ (e.g. http://daringfireball.com/markdown) which have well-formed
+ XHTML that causes tidy to choke. The solution is to pipe through
+ tidy only if pandoc cannot parse the input by itself. This means
+ that a temp file is now always used, even when input comes from a
+ local file or standard input.
+
+ * Removed 'version' constant from Main.hs; added 'pandocVersion' to
+ Text.Pandoc library.
+
+ * pandoc.cabal:
+
+ + Modified to work with GHC 6.8 and Cabal configurations. (For GHC
+ 6.8, pretty and containers must be added to Build-Depends, and it
+ is desirable to use the -O2 compiler option.) Cabal configurations
+ allows one to select options depending on the compiler version.
+ For GHC 6.6, the splitBase option can be disabled.
+ + pandoc.cabal.ghc66 is provided for users with older versions of
+ Cabal, which do not support configurations.
+ + Use Ghc-Prof-Options to ensure that '-auto-all' is used when
+ '--enable-(executable|library)-profiling' is specified. Updated
+ PROFILING instructions accordingly.
+
+ * Makefile:
+
+ + Makefile now checks GHC version. If GHC is 6.6, pandoc.cabal.ghc66
+ is copied to pandoc.cabal, and the old pandoc.cabal is copied
+ to pandoc.cabal.orig. Otherwise, pandoc.cabal is copied to
+ pandoc.cabal.orig but otherwise unmodified. This way, the Makefile
+ will work properly with either GHC 6.6 or 6.8.
+ + Changed BUILDCONF to point to dist/setup-config, not .setup-config.
+ This is where current versions of Cabal put it.
+ + Added $(BUILDCMD) target, so setup doesn't get compiled every time.
+ + Removed dependency of templates on ./templates, which is circular
+ now that templates is a subdirectory of the top-level.
+
+ * MacPorts Portfile:
+
+ + Modified to install the pandoc library in addition to programs.
+ + Installation must be done manually rather than using Makefile's
+ install-all.
+ + Note that the library must be registered in the activate phase,
+ after the library files have been copied out of the destroot.
+ Cabal generates a 'register.sh' script that will do this.
+
+ * debian/control: Added libghc6-network-dev, libghc6-xhtml-dev, and
+ libghc6-mtl-dev as dependencies for libghc6-pandoc-dev.
+ Closes: #445235
+
+ * debian/rules: Converted to UTF-8.
+
+ * Changed pandoc home page to http://johnmacfarlane.net/pandoc/.
+
+ * Updated ASCIIMathML.js to latest version.
+
+ * Directory structure:
+
+ + Moved everything from src into the top-level directory.
+ + Changed references to source directory in Makefile and
+ pandoc.cabal.*.
+ + Moved ASCIIMathML.js, headers, and ui into templates directory.
+ + Modified fillTemplates.pl to reflect new paths.
+
+ [ Recai Oktaş ]
+
+ * Makefile: Fixed the issue of having two copies of the library
+ documentation under some usage scenarios.
+
+ * Replaced 'ghc' with '$(GHC)' in Makefile, and made GHC
+ and GHC_PKG configurable through the environment, to support
+ unusual ghc installations. For example:
+ GHC=/opt/ghc/bin/ghc GHC_PKG=/opt/ghc/bin/ghc-pkg make
+
+ -- Recai Oktaş <roktas@debian.org> Sun, 07 Oct 2007 20:51:43 +0300
+
+pandoc (0.44) unstable; urgency=low
+
+ [ John MacFarlane ]
+
+ * Fixed bug in HTML writer: when --toc was used, anchors were put around
+ headers, which is invalid XHTML (block content within inline element).
+ Now the anchors are put inside the header tags. Resolves Issue #23.
+
+ * Added xmlns attribute to html element in html writer tests.
+ This attribute is added by more recent versions of the
+ xhtml library (>= 3000), and is required for valid XHTML.
+
+ [ Recai Oktaş ]
+
+ * On configure, compile 'Setup.hs' to 'setup' and use 'setup' as the build
+ command instead of 'runhaskell', which, on some platforms (such as s390,
+ alpha, m68k), throws the following error:
+
+ runhaskell Setup.hs configure --prefix=/usr
+ ghc-6.6.1: not built for interactive use
+
+ This causes a serious FTBFS bug. Closes: #440668.
+
+ -- Recai Oktaş <roktas@debian.org> Mon, 03 Sep 2007 18:24:02 +0300
+
+pandoc (0.43) unstable; urgency=low
+
+ [ John MacFarlane ]
+
+ * The focus of this release is performance. The markdown parser
+ is about five times faster than in 0.42, based on benchmarks
+ with the TextMate manual.
+
+ * Main.hs: Replaced CRFilter and tabFilter with single function
+ tabFilter, which operates on the whole string rather than breaking
+ it into lines, and handles dos-style line-endings as well as tabs.
+
+ * Added separate LaTeX reader and native reader tests; removed
+ round-trip tests.
+
+ * Text.Pandoc.Shared:
+
+ + Removed tabsToSpaces and tabsInLine (they were used only in Main.hs.)
+ + General code cleanup (to elimante warnings when compiling with -Wall.)
+ + Added 'wrapped' function, which helps wrap text into paragraphs,
+ using the prettyprinting library.
+ + Rewrote charsInBalanced and charsInBalanced'.
+ - Documented restriction: open and close must be distinct characters.
+ - Rearranged options for greater efficiency.
+ - Bug fix: Changed inner call to charsInBalanced inside
+ charsInBalanced' to charsInBalanced'.
+ + anyLine now requires that the line end with a newline (not eof).
+ This is a harmless assumption, since we always add newlines to the
+ end of a block before parsing with anyLine, and it yields a 10% speed
+ boost.
+ + Removed unnecessary 'try' in anyLine.
+ + Removed unneeded 'try' from romanNumeral parser.
+ + Use notFollowedBy instead of notFollowedBy' in charsInBalanced.
+ + Removed unneeded 'try' in parseFromString.
+ + Removed unneeded 'try' from stringAnyCase. (Now it behaves
+ like 'string'.)
+ + Changed definition of 'enclosed' in Text.Pandoc.Shared so that
+ 'try' is not automatically applied to the 'end' parser. Added
+ 'try' in calls to 'enclosed' where needed. Slight speed increase.
+
+ * Writers:
+
+ + Replaced individual wrapping routines in RST, Man, and Markdown
+ writers with 'wrapped' from Text.Pandoc.Shared.
+ + Rewrote LaTeX writer to use the prettyprinting library,
+ so we get word wrapping, etc.
+ + Modified latex writer tests for new latex writer using prettyprinter.
+ + Fixed bug in LaTeX writer: autolinks would not cause
+ '\usepackage{url}' to be put in the document header. Also, changes
+ to state in enumerated list items would be overwritten.
+ + In Markdown writer, escape paragraphs that begin with ordered list
+ markers, so they don't get interpreted as ordered lists.
+
+ * Text.Pandoc.Reades.LaTeX:
+
+ + Fixed bug in LaTeX reader, which wrongly assumed that the roman
+ numeral after "enum" in "setcounter" would consist entirely of
+ "i"s. 'enumiv' is legitimate.
+ + LaTeX command and environment names can't contain numbers.
+ + Rearranged order of parsers in inline for slight speed improvement.
+ + Added '`' to special characters and 'unescapedChar'.
+
+ * Text.Pandoc.Readers.RST:
+
+ + Removed unneeded try's in RST reader; also minor code cleanup.
+ + Removed tabchar.
+ + Rearranged parsers in inline (doubled speed).
+
+ * Text.Pandoc.Readers.Markdown:
+
+ + Skip notes parsing if running in strict mode. (This yields a nice
+ speed improvement in strict mode.)
+ + Simplify autolink parsing code, using Network.URI to test for
+ URIs. Added dependency on network library to debian/control and
+ pandoc.cabal.
+ + More perspicuous definition of nonindentSpaces.
+ + Removed unneeded 'try' in 'rawLine'.
+ + Combined linebreak and whitespace into a new whitespace parser, to
+ avoid unnecessary reparsing of space characters.
+ + Removed unnecessary 'try' in 'codeBlock', 'ellipses', 'noteMarker',
+ 'multilineRow', 'dashedLine', 'rawHtmlBlocks'.
+ + Use lookAhead in parsers for setext headers and definition lists
+ to see if the next line begins appropriately; if not, don't waste
+ any more time parsing.
+ + Don't require blank lines after code block. (It's sufficient to
+ end code block with a nonindented line.)
+ + Changed definition of 'emph': italics with '_' must not
+ be followed by an alphanumeric character. This is to help
+ prevent interpretation of e.g. `[LC_TYPE]: my_type` as
+ `[LC<em>TYPE]:my</em>type`.
+ + Improved Markdown.pl-compatibility in referenceLink: the two parts
+ of a reference-style link may be separated by one space, but not
+ more... [a] [link], [not] [a link].
+ + Fixed markdown inline code parsing so it better accords with
+ Markdown.pl: the marker for the end of the code section is a clump
+ of the same number of `'s with which the section began, followed
+ by a non-` character. So, for example,
+ ` h ``` i ` -> `<code>h ``` i</code>`.
+ + Split 'title' into 'linkTitle' and 'referenceTitle', since the
+ rules are slightly different.
+ + Rewrote 'para' for greater efficiency.
+ + Rewrote link parsers for greater efficiency.
+ + Removed redundant 'referenceLink' in definition of inline (it's
+ already in 'link').
+ + Refactored escapeChar so it doesn't need 'try'.
+ + Refactored hrule for performance in Markdown reader.
+ + More intelligent rearranging of 'inline' so that most frequently
+ used parsers are tried first.
+ + Removed tabchar parser, as whitespace handles tabs anyway.
+
+ * Text.Pandoc.CharacterReferences:
+
+ + Refactored.
+ + Removed unnecessary 'try's for a speed improvement.
+ + Removed unnecessary '&' and ';' from the entity table.
+
+ * Build process:
+
+ + Makefile: Get VERSION from cabal file, not Main.hs.
+ + Modified MacPorts Portfile:
+ - Depend on haddock
+ - Build and install libraries and library documentation in
+ addition to pandoc executable
+ - Added template item for md5 sum in Portfile.in.
+ - Incorporated changes from MacPorts repository (r28278).
+ + FreeBSD port: Don't try to generate distinfo in Makefile.
+ It can be made using 'make makesum' in FreeBSD.
+ + Make both freebsd and macports targets depend on tarball.
+
+ * Website and documentation:
+
+ + Updated INSTALL instructions.
+ + Added pandocwiki demo to website.
+ + Removed local references to Portfile, since pandoc is now in the
+ MacPorts repository.
+
+ -- Recai Oktaş <roktas@debian.org> Sun, 02 Sep 2007 15:50:11 +0300
+
+pandoc (0.42) unstable; urgency=low
+
+ [ John MacFarlane ]
+
+ * Main.hs: Use utf8 conversion on the extra files loaded with
+ the -H, -C, -B, and -A options. This fixes problems with unicode
+ characters in these files.
+
+ * Exposed Text.Pandoc.ASCIIMathML, since it is imported in
+ Text.Pandoc.Readers.HTML and without it we get a linking error when
+ using the library.
+
+ * Markdown reader:
+
+ + Added new rule for enhanced markdown ordered lists: if the list
+ marker is a capital letter followed by a period (including a
+ single-letter capital roman numeral), then it must be followed by
+ at least two spaces. The point of this is to avoid accidentally
+ treating people's initials as list markers: a paragraph might begin,
+ "B. Russell was an English philosopher," and this shouldn't be
+ treated as a list. Documented change in README.
+ + Blocks that start with "p. " and a digit are no longer treated
+ as ordered lists (it's a page number).
+ + Added a needed 'try' to listItem.
+ + Removed check for a following setext header in endline.
+ A full test is too inefficient (doubles benchmark time), and the
+ substitute we had before is not 100% accurate.
+ + Don't use Code elements for autolinks if --strict specified.
+
+ * LaTeX writer: When a footnote ends with a Verbatim environment, the
+ close } of the footnote cannot occur on the same line or an error occurs.
+ Fixed this by adding a newline before the closing } of every footnote.
+
+ * HTML writer:
+ + Removed incorrect "{}" around style information in HTML tables.
+ Column widths now work properly in HTML.
+ + If --strict option is specified (and --toc is not), don't include
+ identifiers in headers, for better Markdown compatibility.
+
+ * Build process:
+
+ + Separated $(web_dest) and website targets.
+ + In website, index.txt is now constructed from template index.txt.in.
+ + Added freebsd target to Markefile. This creates the freebsd Makefile
+ from Makefile.in, and creates distinfo. Removed Makefile and distinfo
+ from the repository.
+ + Added macport target to Makefile. Portfile is built from template
+ Portfile.in.
+ + Removed OSX package targets. (Too many difficulties involving
+ dependencies on dynamic libraries.)
+ + More complete INSTALL instructions for all architectures.
+
+ * Website:
+ + Added a programming demo, pandocwiki.
+
+ [ Recai Oktaş ]
+
+ * Do not forget to close pandoc's ITP. Closes: #391666
+
+ -- Recai Oktaş <roktas@debian.org> Sun, 26 Aug 2007 22:51:32 +0300
+
+pandoc (0.41) unstable; urgency=low
+
+ [ John MacFarlane ]
+
+ * Fixed bugs in HTML reader:
+ + Skip material at end *only if* `</html>` is present (previously,
+ only part of the document would be parsed if an error was
+ found; now a proper error message is given).
+ + Added new constant eitherBlockOrInline with elements that may
+ count either as block-level or as inline. Modified isInline and
+ isBlock to take this into account.
+ + Modified rawHtmlBlock to accept any tag (even an inline tag):
+ this is innocuous, because rawHtmlBlock is tried only if a regular
+ inline element can't be parsed.
+ + Added a necessary 'try' in definition of 'para'.
+
+ * Fixed bug in markdown ordered list parsing. The problem was that
+ anyOrderedListStart did not check for a space following the
+ ordered list marker. So in 'A.B. 2007' the parser would be
+ expecting a list item, but would not find one, causing an error.
+ Fixed a similar bug in the RST reader. Resolves Issue #22.
+
+ * Refactored RST and Markdown readers using parseFromString.
+
+ * LaTeX reader will now skip anything after \end{document}.
+
+ * Fixed blockquote output in markdown writer: previously, block
+ quotes in indented contexts would be indented only in the first
+ line.
+
+ * Added note to INSTALL about variations in versions of the xhtml
+ library that can lead to failed tests (thanks to Leif LeBaron).
+
+ -- Recai Oktaş <roktas@debian.org> Sun, 19 Aug 2007 23:26:07 +0300
+
+pandoc (0.4) unstable; urgency=low
+
+ [ John MacFarlane ]
+
+ * Added two new output formats: groff man pages and ConTeXt. By
+ default, output files with extensions ".ctx" and ".context" are
+ assumed to be ConTeXt, and output files with single-digit extensions
+ are assumed to be man pages.
+
+ * Enhanced ordered lists (documented in README, under Lists):
+ + The OrderedList block element now stores information about
+ list number style, list number delimiter, and starting number.
+ + The readers parse this information when possible.
+ + The writers use this information to style ordered lists.
+ + The enhancement can be disabled using the --strict option.
+
+ * Added support for tables (with a new Table block element). Two kinds
+ of tables are supported: a simple table with one-line rows, and a
+ more complex variety with multiline rows. All output formats are
+ supported, but only markdown tables are parsed at the moment. The
+ syntax is documented in README.
+
+ * Added support for definition lists (with a new DefinitionList block
+ element). All output and input formats are supported. The syntax is
+ documented in README.
+
+ * Added support for superscripts and subscripts (with new Superscript
+ and Subscript inline elements). All input and output
+ formats. The syntax is documented in README.
+
+ * Added support for strikeout (with a new Strikeout inline element).
+ All input and output formats are supported. Thanks to Bradley Kuhn,
+ who contributed a patch. The syntax is documented in README. Resolves
+ Issue #18.
+
+ * Added a --toc|--table-of-contents option. This causes an automatically
+ generated table of contents (or an instruction that creates one) to
+ be inserted at the beginning of the document. Not supported in S5,
+ DocBook, or man page writers.
+
+ * Modified the -m|--asciimathml option:
+
+ + If an optional URL argument is provided, a link is inserted
+ instead of the contents of the ASCIIMathML.js script.
+ + Nothing is inserted unless the document actually contains
+ LaTeX math.
+
+ * Removed Blank block element as unnecessary.
+
+ * Removed Key and Note blocks from the Pandoc data structure. All
+ links are now stored as explicit links, and note contents are
+ stored with the (inline) notes.
+
+ + All link Targets are now explicit (URL, title) pairs; there
+ is no longer a 'Ref' target.
+ + Markdown and RST parsers now need to extract data from key and
+ note blocks and insert them into the relevant inline elements.
+ Other parsers have been simplified, since there is no longer any need
+ to construct separate key and note blocks.
+ + Markdown, RST, and HTML writers need to construct lists of
+ notes; Markdown and RST writers need to construct lists of link
+ references (when the --reference-links option is specified); and
+ the RST writer needs to construct a list of image substitution
+ references. All writers have been rewritten to use the State monad
+ when state is required.
+ + Several functions (generateReference, keyTable,
+ replaceReferenceLinks, replaceRefLinksBlockList, and some auxiliaries
+ used by them) have been removed from Text.Pandoc.Shared, since
+ they are no longer needed. New functions and data structures
+ (Reference, isNoteBlock, isKeyBlock, isLineClump) have been
+ added. The functions inTags, selfClosingTag, inTagsSimple, and
+ inTagsIndented have been moved to the DocBook writer, since that
+ is now the only module that uses them. NoteTable is now exported
+ in Text.Pandoc.Shared.
+ + Added stateKeys and stateNotes to ParserState; removed stateKeyBlocks,
+ stateKeysUsed, stateNoteBlocks, stateNoteIdentifiers, stateInlineLinks.
+ + Added writerNotes and writerReferenceLinks to WriterOptions.
+
+ * Added Text.Pandoc module that exports basic readers, writers,
+ definitions, and utility functions. This should export everything
+ needed for most uses of Pandoc libraries. The haddock documentation
+ includes a short example program.
+
+ * Text.Pandoc.ASCIIMathML is no longer an exported module.
+
+ * Added Text.Pandoc.Blocks module to help in printing markdown
+ and RST tables. This module provides functions for working with
+ fixed-width blocks of text--e.g., placing them side by side, as
+ in a table row.
+
+ * Refactored to avoid reliance on Haskell's Text.Regex library, which
+ (a) is slow, and (b) does not properly handle unicode. This fixed
+ some strange bugs, e.g. in parsing S-cedilla, and improved performance.
+
+ + Replaced 'gsub' with a general list function 'substitute'
+ that does not rely on Text.Regex.
+ + Rewrote extractTagType in HTML reader so that it doesn't use
+ regexs.
+ + In Markdown reader, replaced email regex test with a custom email
+ autolink parser (autoLinkEmail). Also replaced selfClosingTag regex
+ with a custom function isSelfClosingTag.
+ + Modified Docbook writer so that it doesn't rely on Text.Regex for
+ detecting 'mailto' links.
+ + Removed escapePreservingRegex and reamped entity-handling
+ functions in Text.Pandoc.Shared and Text.Pandoc.CharacterReferences to
+ avoid reliance on Text.Regex (see below on character reference
+ handling changes).
+
+ * Renamed Text.Pandoc.Entities as Text.Pandoc.CharacterReferences.
+
+ * Changed handling of XML entities. Entities are now parsed (and unicode
+ characters returned) in the Markdown and HTML readers, rather than being
+ handled in the writers. In HTML and Docbook writers, UTF-8 is now used
+ instead of entities for characters above 128. This makes the HTML and
+ DocBook output much more readable and more easily editable.
+
+ + Removed sgmlHexEntity, sgmlDecimalEntity, sgmlNamedEntity, and
+ sgmlCharacterEntity regexes from Text.Pandoc.Shared.
+ + Renamed escapeSGMLChar to escapeCharForXML. Added escapeStringForXML.
+ Moved both functions to Text.Pandoc.Writers.Docbook.
+ + Added characterReference parser to Text.Pandoc.CharacterReferences.
+ This parses a string and return a unicode character.
+ + Rewrote decodeCharacterReferences to use the new parser instead of
+ Text.Regex.
+ + Added new charRef parser for Markdown and HTML, which replaces the
+ old 'entity' parser. Added '&' as a special character in Markdown reader.
+ + Modified HTML and Markdown readers to call decodeEntities on all raw
+ strings (e.g. authors, dates, link titles), to ensure that no
+ unprocessed entities are included in the native representation of
+ the document. (In the HTML reader, most of this work is done by a
+ change in extractAttributeName.)
+ + In XML and Markdown output, escape unicode nonbreaking space as '&nbsp;',
+ since a unicode non-breaking space is impossible to distinguish visually
+ from a regular space. (Resolves Issue #3.)
+ + Removed encodeEntitiesNumerical.
+ + Use Data.Map for entityTable and (new) reverseEntityTable, for a
+ slight performance boost over the old association list.
+ + Removed unneeded decodeEntities from 'str' parser in HTML and
+ Markdown readers.
+
+ * Text.Pandoc.UTF8: Renamed encodeUTF8 to toUTF8, decodeUTF8 to
+ fromUTF8, for clarity.
+
+ * Replaced old haskell98 module names replaced by hierarchical module
+ names, e.g. List by Data.List. Removed haskell98 from dependencies
+ in pandoc.cabal, and added mtl (needed for state monad). Substituted
+ xhtml for html.
+
+ * Refactored and cleaned up character escaping in writers, using
+ backslashEscapes and escapeStringUsing functions.
+
+ * Instead of adding "\n\n" to the end of an input string in Main.hs,
+ this is now done in the readers. This makes the libraries behave
+ the way you'd expect from the pandoc program. Resolves Issue #10.
+
+ * URLs and email addresses in autolinks are now typeset as Code.
+
+ * In Main.hs, changed putStr to putStrLn -- mainly because MacOS X
+ doesn't display the whole output unless there's a line ending.
+
+ * Major code cleanup in all modules, for greater consistency, concision,
+ and readability.
+
+ * HTML reader:
+
+ + Fixed several bugs (extractTagType, attribute parsing).
+ + Remove Null blocks in lists of blocks when possible.
+ + Allow HTML comments as raw HTML inline.
+
+ * Markdown reader:
+
+ + Ordered list items may no longer begin with uppercase letters, or
+ letters greater than 'n'. (This prevents first initials and page
+ reference, e.g. 'p. 400', from being parsed as beginning lists.)
+ Also, numbers beginning list items may no longer end with ')',
+ which is now allowed only after letters. Note: These changes
+ may cause documents to be parsed differently. Users should take
+ care in upgrading.
+ + Changed autoLink parsing to conform better to Markdown.pl's
+ behavior. `<google.com>` is not treated as a link, but
+ `<http://google.com>`, `<ftp://google.com>`, and
+ `<mailto:google@google.com>` are.
+ + Cleaned up handling of embedded quotes in link titles. Now these are
+ stored as a '"' character, not as '&quot;'.
+ + Use lookAhead parser for the 'first pass' (looking for reference keys),
+ instead of parsing normally, then using setInput to reset input. This
+ yields a slight performance boost.
+ + Fixed several bugs in smart quote recognition.
+ + Fixed bug in indentSpaces (which didn't properly handle
+ cases with mixed spaces and tabs).
+ + Consolidated 'text', 'special', and 'inline' into 'inline'.
+ + Fixed bug which allowed URL and title to be separated by multiple blank
+ lines in links and reference keys. They can be on separate lines but
+ can't have blank lines between them.
+ + Correctly handle bracketed text inside inline footnotes and links,using
+ new function inlinesInBalanced. Resolves Issue #14.
+ + Fixed bug in footnotes: links in footnotes were not being
+ processed. Solution: three-stage parse. First, get all the
+ reference keys and add information to state. Next, get all the
+ notes and add information to state. (Reference keys may be needed
+ at this stage.) Finally, parse everything else.
+ + Replaced named constants like 'emphStart' with literals.
+ + Removed an extra occurance of escapedChar in definition of inline.
+
+ * RST reader:
+
+ + Allow the URI in a RST hyperlink target to start on the line
+ after the reference key.
+ + Added 'try' in front of 'string', where needed, or used a different
+ parser. This fixes a bug where ````` would not be correctly parsed as
+ a verbatim `.
+ + Fixed slow performance in parsing inline literals in RST reader. The
+ problem was that ``#`` was seen by 'inline' as a potential link or image.
+ Fix: inserted 'notFollowedBy (char '`')' in link parsers.
+ Resolves Issue #8.
+ + Use lookAhead instead of getInput/setInput in RST reader. Removed
+ unneeded getState call, since lookAhead automatically saves and
+ restores the parser state.
+ + Allow hyperlink target URIs to be split over multiple lines, and
+ to start on the line after the reference. Resolves Issue #7.
+ + Fixed handling of autolinks.
+
+ * LaTeX reader:
+
+ + Replaced 'choice [(try (string ...), ...]' idiom with 'oneOfStrings',
+ for clarity.
+ + Added clauses for tilde and caret. Tilde is \ensuremath{\sim}, and
+ caret is \^{}, not \^ as before.
+ + Added parsing for \url.
+ + Parse \texttt{} as code, provided there's nothing fancy inside.
+
+ * HTML writer:
+
+ + Modified HTML writer to use the Text.XHtml library. This results
+ in cleaner, faster code, and it makes it easier to use Pandoc in
+ other projects, like wikis, which use Text.XHtml. Two functions are
+ now provided, writeHtml and writeHtmlString: the former outputs an
+ Html structure, the latter a rendered string. The S5 writer is also
+ changed, in parallel ways (writeS5, writeS5String).
+ + The Html header is now written programmatically, so it has been
+ removed from the 'headers' directory. The S5 header is still
+ needed, but the doctype and some of the meta declarations have
+ been removed, since they are written programatically. This change
+ introduces a new dependency on the xhtml package.
+ + Fixed two bugs in email obfuscation involving improper escaping
+ of '&' in the `<noscript>` section and in `--strict` mode. Resolves
+ Issue #9.
+ + Fixed another bug in email obfuscation: If the text to be obfuscated
+ contains an entity, this needs to be decoded before obfuscation.
+ Thanks to thsutton for the patch. Resolves Issue #15.
+ + Changed the way the backlink is displayed in HTML footnotes.
+ Instead of appearing on a line by itself, it now generally
+ appears on the last line of the note. (Exception: when the
+ note does not end with a Plain or Para block.) This saves space
+ and looks better.
+ + Added automatic unique identifiers to headers:
+ - The identifier is derived from the header via a scheme
+ documented in README.
+ - WriterState now includes a list of header identifiers and a table
+ of contents in addition to notes.
+ - The function uniqueIdentifiers creates a list of unique identifiers
+ from a list of inline lists (e.g. headers).
+ - This list is part of WriterState and gets consumed by blockToHtml
+ each time a header is encountered.
+ + Include CSS for .strikethrough class in header only if strikethrough
+ text appears in the document.
+ + If the 'strict' option is specified, elements that do not appear in
+ standard markdown (like definition lists) are passed through as
+ raw HTML.
+ + Simplified treatment of autolinks, using pattern matching instead of
+ conditionals.
+
+ * Markdown writer:
+
+ + Links in markdown output are now printed as inline links by default,
+ rather than reference links. A --reference-links option has been added
+ that forces links to be printed as reference links. Resolves Issue #4.
+ + Use autolinks when possible. Instead of `[site.com](site.com)`,
+ use `<site.com>`.
+
+ * LaTeX writer:
+
+ + Rewrote to use the State monad. The preamble now includes only those
+ packages that are actually required, given the document's content.
+ Thus, for example, if strikeout is not used, ulem is not required.
+ Modified LaTeXHeader accordingly.
+ + Modified LaTeX writer to insert '\,' between consecutive quotes.
+ + Removed unused function tableRowColumnWidths.
+ + Simplified code for escaping special characters.
+ + Leave extra blank line after \maketitle.
+ + Include empty '\author{}' when no author specified to avoid LaTeX
+ errors.
+ + Include fancyvrb code in header only if needed -- that is, only
+ if there is actually code in a footnote.
+ + Use \url{} for autolinks.
+ + Include [mathletters] option in ucs package, so that basic unicode
+ Greek letters will work correctly.
+
+ * RST writer: Force blank line before lists, so that sublists will
+ be handled correctly.
+
+ * Docbook writer: Fixed a bug: email links with text, like
+ [foo](me@bar.baz), were being incorrectly treated as autolinks.
+
+ * Removed Text.ParserCombinators.Pandoc and moved all its functions to
+ Text.Pandoc.Shared.
+
+ * Text.Pandoc.Shared:
+
+ + Added defaultWriterOptions.
+ + Added writerTableOfContents to WriterOptions.
+ + Added writerIgnoreNotes option to WriterOptions. This is needed
+ for processing header blocks for a table of contents, since notes on
+ headers should not appear in the TOC.
+ + Added prettyprinting for native Table format.
+ + Removed some unneeded imports.
+ + Moved escape and nullBlock parsers from
+ Text.ParserCombinators.Pandoc, since the latter is for
+ general-purpose parsers that don't depend on Text.Pandoc.Definition.
+ + Moved isHeaderBlock from Text.Pandoc.Writers.HTML.
+ + Moved Element, headerAtLeast, and hierarchicalize from Docbook
+ writer, because HTML writer now uses these in constructing a table
+ of contents.
+ + Added clauses for new inline elements (Strikeout, Superscript,
+ Subscript) to refsMatch.
+ + Removed backslashEscape; added new functions escapeStringUsing and
+ backslashEscapes.
+ + Moved failIfStrict from markdown reader, since it is now used also
+ by the HTML reader.
+ + Added a 'try' to the definition of indentSpaces.
+ + In definition of 'reference', added check to make sure it's not a note
+ reference.
+ + Added functions: camelCaseToHyphenated, toRomanNumeral,
+ anyOrderedListMarker, orderedListmarker, orderedListMarkers,
+ charsInBalanced', withHorizDisplacement, romanNumeral
+ + Fixed a bug in the anyLine parser. Previously it would parse an empty
+ string "", but it should fail on an empty string, or we get an error
+ when it is used inside "many" combinators.
+ + Removed followedBy' parser, replacing it with the lookAhead parser from
+ Parsec.
+ + Added some needed 'try's before multicharacter parsers, especially in
+ 'option' contexts.
+ + Removed the 'try' from the 'end' parser in 'enclosed', so that
+ 'enclosed' behaves like 'option', 'manyTill', etc.
+ + Added lineClump parser, which parses a raw line block up to and
+ including any following blank lines.
+ + Renamed parseFromStr to parseFromString.
+ + Added a 'try' to the 'end' parser in 'enclosed'. This makes errors in
+ the use of 'enclosed' less likely. Removed some now-unnecessary 'try's
+ in calling code.
+ + Removed unneeded 'try' in blanklines.
+ + Removed endsWith function and rewrote calling functions to use
+ isSuffixOf instead.
+ + Added >>~ combinator.
+ + Fixed bug in normalizeSpaces: Space:Str "":Space should compress to
+ Space.
+
+ * Refactored runtests.pl; added separate tests for tables.
+
+ * Shell scripts:
+
+ + Added -asxhtml flag to tidy in html2markdown. This will
+ perhaps help the parser, which expects closing tags.
+ + Modified markdown2pdf to run pdflatex a second time if --toc or
+ --table-of-contents was specified; otherwise the table of
+ contents won't appear.
+ + Modified markdown2pdf to print a helpful message if the 'ulem'
+ LaTeX package is required and not found.
+
+ * Changes to build process:
+
+ + Dropped support for compilation with GHC 6.4. GHC 6.6 or higher
+ is now required.
+ + Removed cabalize and Pandoc.cabal.in. The repository now contains
+ pandoc.cabal itself.
+ + Pandoc.cabal has been changed to pandoc.cabal, because HackageDB
+ likes the cabal file to have the same name as the tarball.
+ + Expanded and revised the package description in pandoc.cabal.
+ Revised the package synopsis.
+ + The tarball built by 'make tarball' now contains files built from
+ templates (including man pages and shell scripts), so pandoc can
+ be built directly using Cabal tools, without preprocessing.
+ + Executable binaries are now stripped before installing.
+ + Man pages are now generated from markdown sources, using pandoc's
+ man page writer.
+ + Use HTML version of README (instead of RTF) in Mac OS X installer.
+ + Instead of testing for the existence of a pandoc symlink in build-exec,
+ use ln -f.
+
+ * Documentation:
+
+ + Updated README and man pages with information on new features.
+ + Updated INSTALL instructions with some useful clarifications and
+ links.
+ + Updated web content.
+
+ * Added FreeBSD port.
+
+ [ Recai Oktaş ]
+
+ * debian/control:
+
+ + Changed pandoc's Build-Depends to include libghc6-mtl-dev and
+ libghc6-xhtml-dev. Removed libghc6-html-dev.
+ + Suggest texlive-latex-recommended | tetex-extra instead of
+ tetex-bin. This brings in fancyvrb and unicode support.
+
+ -- Recai Oktaş <roktas@debian.org> Tue, 16 Jan 2007 00:37:21 +0200
+
+pandoc (0.3) unstable; urgency=low
+
+ [ John MacFarlane ]
+
+ * Changes in pandoc options:
+
+ + Allow options to follow or precede arguments.
+ + Changed '--smartypants' to '--smart' and adjusted symbols accordingly.
+ + Added '--strict' option.
+ + Added '-o/--output' option.
+ + Added '--dump-args' and '--ignore-args' options (for use in wrappers).
+ + Modified '-v' and '-h' output to go to STDERR, not STDOUT, and return
+ error conditions. This is helpful for writing wrappers.
+ + Added copyright message to '-v' output, modeled after FSF messages.
+ + Reformatted usage message so that it doesn't wrap illegibly.
+ + Removed extra blanks after '-h' and '-D' output.
+
+ * Added docbook writer.
+
+ * Added implicit setting of default input and output format based
+ on input and output filename extensions. These defaults are
+ overridden if explicit input and output formats are specified using
+ '-t', '-f', '-r', or '-w' options. Documented in pandoc(1) man page
+ and README.
+
+ * Allow ordered list items to begin with (single) letters, as well
+ as numbers. The list item marker may now be terminated either by
+ '.' or by ')'. This extension to standard markdown is documented
+ in README.
+
+ * Revised footnote syntax. (See README for full details.) The
+ '[^1]' format now standard in markdown extensions is supported,
+ as are inline footnotes with this syntax: '^[My note.]'.
+ The earlier footnote syntax '^(1)' is no longer supported.
+
+ * Improved HTML representation of footnotes. All footnotes
+ are now auto-numbered and appear in an ordered list at the
+ end of the HTML document. Since the default appearance is now
+ acceptable, the old footnote styles have been removed from the
+ HTML header.
+
+ * Bug fixes:
+
+ + Fixed a serious bug in the markdown, LaTeX, and RST readers.
+ These readers ran 'runParser' on processed chunks of text to handle
+ embedded block lists in lists and quotation blocks. But then
+ any changes made to the parser state in these chunks was lost,
+ as the state is local to the parser. So, for example, footnotes
+ didn't work in quotes or list items. The fix: instead of calling
+ runParser on some raw text, use setInput to make it the input, then
+ parse it, then use setInput to restore the input to what it was
+ before. This is shorter and more elegant, and it fixes the problem.
+ + Fixed bug in notFollowedBy' combinator (adding 'try' before
+ 'parser'). Adjusted code that uses this combinator accordingly.
+ + Fixed bug in RTF writer that caused improper indentation on
+ footnotes occurring in indented blocks like lists.
+ + Fixed parsing of metadata in LaTeX reader. Now the title, author,
+ and date are parsed correctly. Everything else in the preamble
+ is skipped.
+ + Modified escapedChar in LaTeX reader to allow a '\' at the end of a
+ line to count as escaped whitespace.
+ + Modified LaTeX reader to produce inline links rather than reference
+ links. Otherwise, links in footnotes aren't handled properly.
+ + Fixed handling of titles in links in Markdown reader, so that
+ embedded quotation marks are now handled properly.
+ + Fixed Markdown reader's handling of embedded brackets in links.
+ + Fixed Markdown reader so that it only parses bracketed material
+ as a reference link if there is actually a corresponding key.
+ + Revised inline code parsing in Markdown reader to conform to
+ markdown standard. Now any number of `s can begin inline code,
+ which will end with the same number of `s. For example, to
+ have two backticks as code, write ``` `` ```. Modified Markdown
+ writer accordingly.
+ + Fixed bug in text-wrapping routine in Markdown and RST writers.
+ Now LineBreaks no longer cause wrapping problems.
+ + Supported hexadecimal numerical entity references as well as
+ decimal ones.
+ + Fixed bug in Markdown reader's handling of underscores and other
+ inline formatting markers inside reference labels: for example,
+ in '[A_B]: /url/a_b', the material between underscores was being
+ parsed as emphasized inlines.
+ + Changed Markdown reader's handling of backslash escapes so that
+ only non-alphanumeric characters can be escaped. Strict mode
+ follows Markdown.pl in only allowing a select group of punctuation
+ characters to be escaped.
+ + Modified HTML reader to skip a newline following a `<br>` tag.
+ Otherwise the newline will be treated as a space at the beginning
+ of the next line.
+
+ * Made handling of code blocks more consistent. Previously, some
+ readers allowed trailing newlines, while others stripped them.
+ Now, all readers strip trailing newlines in code blocks. Writers
+ insert a newline at the end of code blocks as needed.
+
+ * Modified readers to make spacing at the end of output more consistent.
+
+ * Minor improvements to LaTeX reader:
+
+ + '\thanks' now treated like a footnote.
+ + Simplified parsing of LaTeX command arguments and options.
+ commandArgs now returns a list of arguments OR options (in
+ whatever order they appear). The brackets are included, and
+ a new stripFirstAndLast function is provided to strip them off
+ when needed. This fixes a problem in dealing with \newcommand
+ and \newenvironment.
+
+ * Revised RTF writer:
+
+ + Default font is now Helvetica.
+ + An '\f0' is added to each '\pard', so that font resizing works
+ correctly.
+
+ * Moved handling of "smart typography" from the writers to the Markdown
+ and LaTeX readers. This allows great simplification of the writers
+ and more accurate smart quotes, dashes, and ellipses. DocBook can
+ now use `<quote>`. The '--smart' option now toggles an option in
+ the parser state rather than a writer option. Several new kinds
+ of inline elements have been added: Quoted, Ellipses, Apostrophe,
+ EmDash, EnDash.
+
+ * Changes in HTML writer:
+
+ + Include title block in header even when title is null.
+ + Made javascript obfuscation of emails even more obfuscatory,
+ by combining it with entity obfuscation.
+
+ * Changed default ASCIIMathML text color to black.
+
+ * Test suite:
+
+ + Added --strip-trailing-cr option to diff in runtests.pl, for
+ compatibility with Windows.
+ + Added regression tests with footnotes in quote blocks and lists.
+
+ * Makefile changes:
+
+ + osx-pkg target creates a Mac OS X package (directory). New osx
+ directory contains files needed for construction of the package.
+ + osx-dmg target creates a compressed disk image containing the package.
+ + win-pkg target creates Windows binary package.
+ + tarball target creates distribution source tarball.
+ + website target generates pandoc's website automatically, including
+ demos. New 'web' directory containts files needed for construction
+ of the website (which will be created as the 'pandoc' subdirectory
+ of 'web').
+ + Makefile checks to see if we're running Windows/Cygwin; if so,
+ a '.exe' extension is added to each executable in EXECS.
+
+ * Removed all wrappers except markdown2pdf and html2markdown.
+
+ * Added new wrapper hsmarkdown, to be used as a drop-in replacement
+ for Markdown.pl. hsmarkdown calls pandoc with the '--strict'
+ option and disables other options.
+
+ * Added code to html2markdown that tries to determine the character
+ encoding of an HTML file, by parsing the "Content-type" meta tag.
+
+ + If the encoding can't be determined, then if the content is local,
+ the local encoding is used; if it comes from a URL, UTF-8 is used
+ by default.
+ + If input is from STDIN, don't try to determine character encoding.
+ + Encoding can be specified explicitly using '-e' option.
+
+ * Improved warning messages in wrappers:
+
+ + Print warning if iconv not available
+ + More user-friendly error messages in markdown2pdf, when
+ pdflatex fails.
+
+ * Code cleanup:
+
+ + Renamed 'Text/Pandoc/HtmlEntities' module to
+ 'Text/Pandoc/Entities'. Also changed function names so as
+ not to be HTML-specific.
+ + Refactored SGML string escaping functions from HTML and Docbook
+ writers into Text/Pandoc/Shared. (escapeSGML, stringToSGML)
+ + Removed 'BlockQuoteContext' from ParserContext, as it isn't
+ used anywhere.
+ + Removed splitBySpace and replaced it with a general, polymorphic
+ splitBy function.
+ + Refactored LaTeX reader for clarity (added isArg function).
+ + Converted some CR's to LF's in src/ui/default/print.css.
+ + Added license text to top of source files.
+ + Added module data for haddock to source files.
+ + Reformatted code for consistency.
+
+ * Rewrote documentation and man pages. Split README into INSTALL
+ and README.
+
+ * Split LICENSE into COPYING and COPYRIGHT.
+
+ * Removed TODO, since we now maintain ToDo on the wiki.
+
+ * Made COPYRIGHT in top level a symlink to debian/copyright, to avoid
+ duplication.
+
+ [ Recai Oktaş ]
+
+ * Revamped build process to conform to debian standards and created
+ a proper debian package. Closes: #391666.
+
+ * Modified build process to support GHC 6.6.
+
+ + The package can still be compiled using GHC 6.4.2, though because
+ of dependencies the "make deb" target works only with GHC 6.6+.
+ + The script 'cabalize' is used to create an appropriate
+ 'Pandoc.cabal' from 'Pandoc.cabal.in', depending on the GHC and
+ Cabal versions.
+
+ * Refactored template processing (fillTemplates.pl).
+
+ * Modified wrapper scripts to make them more robust and portable.
+ To avoid code duplication and ensure consistency, wrappers are
+ generated via a templating system from templates in src/wrappers.
+
+ + Wrappers now accept multiple filenames, when appropriate.
+ + Spaces and tabs allowed in filenames.
+ + getopts shell builtin is used for portable option parsing.
+ + Improved html2markdown's web grabber code, making it more robust,
+ configurable and verbose. Added '-e', '-g' options.
+
+ -- Recai Oktaş <roktas@debian.org> Fri, 05 Jan 2007 09:41:19 +0200
+
+pandoc (0.2) unstable; urgency=low
+
+ * Fixed unicode/utf-8 translation
+
+ -- John MacFarlane <jgm@berkeley.edu> Mon, 14 Aug 2006 00:00:00 -0400
+
+pandoc (0.1) unstable; urgency=low
+
+ * Initial creation of debian package
+
+ -- John MacFarlane <jgm@berkeley.edu> Mon, 14 Aug 2006 00:00:00 -0400
diff --git a/data/LaTeXMathML.js b/data/LaTeXMathML.js
new file mode 100644
index 000000000..4957624de
--- /dev/null
+++ b/data/LaTeXMathML.js
@@ -0,0 +1,198 @@
+/*
+LaTeXMathML.js from http://math.etsu.edu/LaTeXMathML/
+Adapted by Jeff Knisely and Douglas Woodall from ASCIIMathML.js v. 1.4.7,
+(c) 2005 Peter Jipsen http://www.chapman.edu/~jipsen.
+Released under the GNU General Public License version 2 or later.
+See the GNU General Public License (at http://www.gnu.org/copyleft/gpl.html)
+for more details.
+*/
+var checkForMathML=true;var notifyIfNoMathML=true;var alertIfNoMathML=false;var mathcolor="";var mathfontfamily="";var showasciiformulaonhover=true;var isIE=document.createElementNS==null;if(document.getElementById==null)
+alert("This webpage requires a recent browser such as \nMozilla/Netscape 7+ or Internet Explorer 6+MathPlayer")
+function AMcreateElementXHTML(t){if(isIE)return document.createElement(t);else return document.createElementNS("http://www.w3.org/1999/xhtml",t);}
+function AMnoMathMLNote(){var nd=AMcreateElementXHTML("h3");nd.setAttribute("align","center")
+nd.appendChild(AMcreateElementXHTML("p"));nd.appendChild(document.createTextNode("To view the "));var an=AMcreateElementXHTML("a");an.appendChild(document.createTextNode("LaTeXMathML"));an.setAttribute("href","http://www.maths.nott.ac.uk/personal/drw/lm.html");nd.appendChild(an);nd.appendChild(document.createTextNode(" notation use Internet Explorer 6+"));an=AMcreateElementXHTML("a");an.appendChild(document.createTextNode("MathPlayer"));an.setAttribute("href","http://www.dessci.com/en/products/mathplayer/download.htm");nd.appendChild(an);nd.appendChild(document.createTextNode(" or Netscape/Mozilla/Firefox"));nd.appendChild(AMcreateElementXHTML("p"));return nd;}
+function AMisMathMLavailable(){if(navigator.appName.slice(0,8)=="Netscape")
+if(navigator.appVersion.slice(0,1)>="5")return null;else return AMnoMathMLNote();else if(navigator.appName.slice(0,9)=="Microsoft")
+try{var ActiveX=new ActiveXObject("MathPlayer.Factory.1");return null;}catch(e){return AMnoMathMLNote();}
+else return AMnoMathMLNote();}
+var AMcal=[0xEF35,0x212C,0xEF36,0xEF37,0x2130,0x2131,0xEF38,0x210B,0x2110,0xEF39,0xEF3A,0x2112,0x2133,0xEF3B,0xEF3C,0xEF3D,0xEF3E,0x211B,0xEF3F,0xEF40,0xEF41,0xEF42,0xEF43,0xEF44,0xEF45,0xEF46];var AMfrk=[0xEF5D,0xEF5E,0x212D,0xEF5F,0xEF60,0xEF61,0xEF62,0x210C,0x2111,0xEF63,0xEF64,0xEF65,0xEF66,0xEF67,0xEF68,0xEF69,0xEF6A,0x211C,0xEF6B,0xEF6C,0xEF6D,0xEF6E,0xEF6F,0xEF70,0xEF71,0x2128];var AMbbb=[0xEF8C,0xEF8D,0x2102,0xEF8E,0xEF8F,0xEF90,0xEF91,0x210D,0xEF92,0xEF93,0xEF94,0xEF95,0xEF96,0x2115,0xEF97,0x2119,0x211A,0x211D,0xEF98,0xEF99,0xEF9A,0xEF9B,0xEF9C,0xEF9D,0xEF9E,0x2124];var CONST=0,UNARY=1,BINARY=2,INFIX=3,LEFTBRACKET=4,RIGHTBRACKET=5,SPACE=6,UNDEROVER=7,DEFINITION=8,TEXT=9,BIG=10,LONG=11,STRETCHY=12,MATRIX=13;var AMsqrt={input:"\\sqrt",tag:"msqrt",output:"sqrt",ttype:UNARY},AMroot={input:"\\root",tag:"mroot",output:"root",ttype:BINARY},AMfrac={input:"\\frac",tag:"mfrac",output:"/",ttype:BINARY},AMover={input:"\\stackrel",tag:"mover",output:"stackrel",ttype:BINARY},AMatop={input:"\\atop",tag:"mfrac",output:"",ttype:INFIX},AMchoose={input:"\\choose",tag:"mfrac",output:"",ttype:INFIX},AMsub={input:"_",tag:"msub",output:"_",ttype:INFIX},AMsup={input:"^",tag:"msup",output:"^",ttype:INFIX},AMtext={input:"\\mathrm",tag:"mtext",output:"text",ttype:TEXT},AMmbox={input:"\\mbox",tag:"mtext",output:"mbox",ttype:TEXT};var AMsymbols=[{input:"\\alpha",tag:"mi",output:"\u03B1",ttype:CONST},{input:"\\beta",tag:"mi",output:"\u03B2",ttype:CONST},{input:"\\gamma",tag:"mi",output:"\u03B3",ttype:CONST},{input:"\\delta",tag:"mi",output:"\u03B4",ttype:CONST},{input:"\\epsilon",tag:"mi",output:"\u03B5",ttype:CONST},{input:"\\varepsilon",tag:"mi",output:"\u025B",ttype:CONST},{input:"\\zeta",tag:"mi",output:"\u03B6",ttype:CONST},{input:"\\eta",tag:"mi",output:"\u03B7",ttype:CONST},{input:"\\theta",tag:"mi",output:"\u03B8",ttype:CONST},{input:"\\vartheta",tag:"mi",output:"\u03D1",ttype:CONST},{input:"\\iota",tag:"mi",output:"\u03B9",ttype:CONST},{input:"\\kappa",tag:"mi",output:"\u03BA",ttype:CONST},{input:"\\lambda",tag:"mi",output:"\u03BB",ttype:CONST},{input:"\\mu",tag:"mi",output:"\u03BC",ttype:CONST},{input:"\\nu",tag:"mi",output:"\u03BD",ttype:CONST},{input:"\\xi",tag:"mi",output:"\u03BE",ttype:CONST},{input:"\\pi",tag:"mi",output:"\u03C0",ttype:CONST},{input:"\\varpi",tag:"mi",output:"\u03D6",ttype:CONST},{input:"\\rho",tag:"mi",output:"\u03C1",ttype:CONST},{input:"\\varrho",tag:"mi",output:"\u03F1",ttype:CONST},{input:"\\varsigma",tag:"mi",output:"\u03C2",ttype:CONST},{input:"\\sigma",tag:"mi",output:"\u03C3",ttype:CONST},{input:"\\tau",tag:"mi",output:"\u03C4",ttype:CONST},{input:"\\upsilon",tag:"mi",output:"\u03C5",ttype:CONST},{input:"\\phi",tag:"mi",output:"\u03C6",ttype:CONST},{input:"\\varphi",tag:"mi",output:"\u03D5",ttype:CONST},{input:"\\chi",tag:"mi",output:"\u03C7",ttype:CONST},{input:"\\psi",tag:"mi",output:"\u03C8",ttype:CONST},{input:"\\omega",tag:"mi",output:"\u03C9",ttype:CONST},{input:"\\Gamma",tag:"mo",output:"\u0393",ttype:CONST},{input:"\\Delta",tag:"mo",output:"\u0394",ttype:CONST},{input:"\\Theta",tag:"mo",output:"\u0398",ttype:CONST},{input:"\\Lambda",tag:"mo",output:"\u039B",ttype:CONST},{input:"\\Xi",tag:"mo",output:"\u039E",ttype:CONST},{input:"\\Pi",tag:"mo",output:"\u03A0",ttype:CONST},{input:"\\Sigma",tag:"mo",output:"\u03A3",ttype:CONST},{input:"\\Upsilon",tag:"mo",output:"\u03A5",ttype:CONST},{input:"\\Phi",tag:"mo",output:"\u03A6",ttype:CONST},{input:"\\Psi",tag:"mo",output:"\u03A8",ttype:CONST},{input:"\\Omega",tag:"mo",output:"\u03A9",ttype:CONST},{input:"\\frac12",tag:"mo",output:"\u00BD",ttype:CONST},{input:"\\frac14",tag:"mo",output:"\u00BC",ttype:CONST},{input:"\\frac34",tag:"mo",output:"\u00BE",ttype:CONST},{input:"\\frac13",tag:"mo",output:"\u2153",ttype:CONST},{input:"\\frac23",tag:"mo",output:"\u2154",ttype:CONST},{input:"\\frac15",tag:"mo",output:"\u2155",ttype:CONST},{input:"\\frac25",tag:"mo",output:"\u2156",ttype:CONST},{input:"\\frac35",tag:"mo",output:"\u2157",ttype:CONST},{input:"\\frac45",tag:"mo",output:"\u2158",ttype:CONST},{input:"\\frac16",tag:"mo",output:"\u2159",ttype:CONST},{input:"\\frac56",tag:"mo",output:"\u215A",ttype:CONST},{input:"\\frac18",tag:"mo",output:"\u215B",ttype:CONST},{input:"\\frac38",tag:"mo",output:"\u215C",ttype:CONST},{input:"\\frac58",tag:"mo",output:"\u215D",ttype:CONST},{input:"\\frac78",tag:"mo",output:"\u215E",ttype:CONST},{input:"\\pm",tag:"mo",output:"\u00B1",ttype:CONST},{input:"\\mp",tag:"mo",output:"\u2213",ttype:CONST},{input:"\\triangleleft",tag:"mo",output:"\u22B2",ttype:CONST},{input:"\\triangleright",tag:"mo",output:"\u22B3",ttype:CONST},{input:"\\cdot",tag:"mo",output:"\u22C5",ttype:CONST},{input:"\\star",tag:"mo",output:"\u22C6",ttype:CONST},{input:"\\ast",tag:"mo",output:"\u002A",ttype:CONST},{input:"\\times",tag:"mo",output:"\u00D7",ttype:CONST},{input:"\\div",tag:"mo",output:"\u00F7",ttype:CONST},{input:"\\circ",tag:"mo",output:"\u2218",ttype:CONST},{input:"\\bullet",tag:"mo",output:"\u2022",ttype:CONST},{input:"\\oplus",tag:"mo",output:"\u2295",ttype:CONST},{input:"\\ominus",tag:"mo",output:"\u2296",ttype:CONST},{input:"\\otimes",tag:"mo",output:"\u2297",ttype:CONST},{input:"\\bigcirc",tag:"mo",output:"\u25CB",ttype:CONST},{input:"\\oslash",tag:"mo",output:"\u2298",ttype:CONST},{input:"\\odot",tag:"mo",output:"\u2299",ttype:CONST},{input:"\\land",tag:"mo",output:"\u2227",ttype:CONST},{input:"\\wedge",tag:"mo",output:"\u2227",ttype:CONST},{input:"\\lor",tag:"mo",output:"\u2228",ttype:CONST},{input:"\\vee",tag:"mo",output:"\u2228",ttype:CONST},{input:"\\cap",tag:"mo",output:"\u2229",ttype:CONST},{input:"\\cup",tag:"mo",output:"\u222A",ttype:CONST},{input:"\\sqcap",tag:"mo",output:"\u2293",ttype:CONST},{input:"\\sqcup",tag:"mo",output:"\u2294",ttype:CONST},{input:"\\uplus",tag:"mo",output:"\u228E",ttype:CONST},{input:"\\amalg",tag:"mo",output:"\u2210",ttype:CONST},{input:"\\bigtriangleup",tag:"mo",output:"\u25B3",ttype:CONST},{input:"\\bigtriangledown",tag:"mo",output:"\u25BD",ttype:CONST},{input:"\\dag",tag:"mo",output:"\u2020",ttype:CONST},{input:"\\dagger",tag:"mo",output:"\u2020",ttype:CONST},{input:"\\ddag",tag:"mo",output:"\u2021",ttype:CONST},{input:"\\ddagger",tag:"mo",output:"\u2021",ttype:CONST},{input:"\\lhd",tag:"mo",output:"\u22B2",ttype:CONST},{input:"\\rhd",tag:"mo",output:"\u22B3",ttype:CONST},{input:"\\unlhd",tag:"mo",output:"\u22B4",ttype:CONST},{input:"\\unrhd",tag:"mo",output:"\u22B5",ttype:CONST},{input:"\\sum",tag:"mo",output:"\u2211",ttype:UNDEROVER},{input:"\\prod",tag:"mo",output:"\u220F",ttype:UNDEROVER},{input:"\\bigcap",tag:"mo",output:"\u22C2",ttype:UNDEROVER},{input:"\\bigcup",tag:"mo",output:"\u22C3",ttype:UNDEROVER},{input:"\\bigwedge",tag:"mo",output:"\u22C0",ttype:UNDEROVER},{input:"\\bigvee",tag:"mo",output:"\u22C1",ttype:UNDEROVER},{input:"\\bigsqcap",tag:"mo",output:"\u2A05",ttype:UNDEROVER},{input:"\\bigsqcup",tag:"mo",output:"\u2A06",ttype:UNDEROVER},{input:"\\coprod",tag:"mo",output:"\u2210",ttype:UNDEROVER},{input:"\\bigoplus",tag:"mo",output:"\u2A01",ttype:UNDEROVER},{input:"\\bigotimes",tag:"mo",output:"\u2A02",ttype:UNDEROVER},{input:"\\bigodot",tag:"mo",output:"\u2A00",ttype:UNDEROVER},{input:"\\biguplus",tag:"mo",output:"\u2A04",ttype:UNDEROVER},{input:"\\int",tag:"mo",output:"\u222B",ttype:CONST},{input:"\\oint",tag:"mo",output:"\u222E",ttype:CONST},{input:":=",tag:"mo",output:":=",ttype:CONST},{input:"\\lt",tag:"mo",output:"<",ttype:CONST},{input:"\\gt",tag:"mo",output:">",ttype:CONST},{input:"\\ne",tag:"mo",output:"\u2260",ttype:CONST},{input:"\\neq",tag:"mo",output:"\u2260",ttype:CONST},{input:"\\le",tag:"mo",output:"\u2264",ttype:CONST},{input:"\\leq",tag:"mo",output:"\u2264",ttype:CONST},{input:"\\leqslant",tag:"mo",output:"\u2264",ttype:CONST},{input:"\\ge",tag:"mo",output:"\u2265",ttype:CONST},{input:"\\geq",tag:"mo",output:"\u2265",ttype:CONST},{input:"\\geqslant",tag:"mo",output:"\u2265",ttype:CONST},{input:"\\equiv",tag:"mo",output:"\u2261",ttype:CONST},{input:"\\ll",tag:"mo",output:"\u226A",ttype:CONST},{input:"\\gg",tag:"mo",output:"\u226B",ttype:CONST},{input:"\\doteq",tag:"mo",output:"\u2250",ttype:CONST},{input:"\\prec",tag:"mo",output:"\u227A",ttype:CONST},{input:"\\succ",tag:"mo",output:"\u227B",ttype:CONST},{input:"\\preceq",tag:"mo",output:"\u227C",ttype:CONST},{input:"\\succeq",tag:"mo",output:"\u227D",ttype:CONST},{input:"\\subset",tag:"mo",output:"\u2282",ttype:CONST},{input:"\\supset",tag:"mo",output:"\u2283",ttype:CONST},{input:"\\subseteq",tag:"mo",output:"\u2286",ttype:CONST},{input:"\\supseteq",tag:"mo",output:"\u2287",ttype:CONST},{input:"\\sqsubset",tag:"mo",output:"\u228F",ttype:CONST},{input:"\\sqsupset",tag:"mo",output:"\u2290",ttype:CONST},{input:"\\sqsubseteq",tag:"mo",output:"\u2291",ttype:CONST},{input:"\\sqsupseteq",tag:"mo",output:"\u2292",ttype:CONST},{input:"\\sim",tag:"mo",output:"\u223C",ttype:CONST},{input:"\\simeq",tag:"mo",output:"\u2243",ttype:CONST},{input:"\\approx",tag:"mo",output:"\u2248",ttype:CONST},{input:"\\cong",tag:"mo",output:"\u2245",ttype:CONST},{input:"\\Join",tag:"mo",output:"\u22C8",ttype:CONST},{input:"\\bowtie",tag:"mo",output:"\u22C8",ttype:CONST},{input:"\\in",tag:"mo",output:"\u2208",ttype:CONST},{input:"\\ni",tag:"mo",output:"\u220B",ttype:CONST},{input:"\\owns",tag:"mo",output:"\u220B",ttype:CONST},{input:"\\propto",tag:"mo",output:"\u221D",ttype:CONST},{input:"\\vdash",tag:"mo",output:"\u22A2",ttype:CONST},{input:"\\dashv",tag:"mo",output:"\u22A3",ttype:CONST},{input:"\\models",tag:"mo",output:"\u22A8",ttype:CONST},{input:"\\perp",tag:"mo",output:"\u22A5",ttype:CONST},{input:"\\smile",tag:"mo",output:"\u2323",ttype:CONST},{input:"\\frown",tag:"mo",output:"\u2322",ttype:CONST},{input:"\\asymp",tag:"mo",output:"\u224D",ttype:CONST},{input:"\\notin",tag:"mo",output:"\u2209",ttype:CONST},{input:"\\begin{eqnarray}",output:"X",ttype:MATRIX,invisible:true},{input:"\\begin{array}",output:"X",ttype:MATRIX,invisible:true},{input:"\\\\",output:"}&{",ttype:DEFINITION},{input:"\\end{eqnarray}",output:"}}",ttype:DEFINITION},{input:"\\end{array}",output:"}}",ttype:DEFINITION},{input:"\\big",tag:"mo",output:"X",atval:"1.2",ieval:"2.2",ttype:BIG},{input:"\\Big",tag:"mo",output:"X",atval:"1.6",ieval:"2.6",ttype:BIG},{input:"\\bigg",tag:"mo",output:"X",atval:"2.2",ieval:"3.2",ttype:BIG},{input:"\\Bigg",tag:"mo",output:"X",atval:"2.9",ieval:"3.9",ttype:BIG},{input:"\\left",tag:"mo",output:"X",ttype:LEFTBRACKET},{input:"\\right",tag:"mo",output:"X",ttype:RIGHTBRACKET},{input:"{",output:"{",ttype:LEFTBRACKET,invisible:true},{input:"}",output:"}",ttype:RIGHTBRACKET,invisible:true},{input:"(",tag:"mo",output:"(",atval:"1",ttype:STRETCHY},{input:"[",tag:"mo",output:"[",atval:"1",ttype:STRETCHY},{input:"\\lbrack",tag:"mo",output:"[",atval:"1",ttype:STRETCHY},{input:"\\{",tag:"mo",output:"{",atval:"1",ttype:STRETCHY},{input:"\\lbrace",tag:"mo",output:"{",atval:"1",ttype:STRETCHY},{input:"\\langle",tag:"mo",output:"\u2329",atval:"1",ttype:STRETCHY},{input:"\\lfloor",tag:"mo",output:"\u230A",atval:"1",ttype:STRETCHY},{input:"\\lceil",tag:"mo",output:"\u2308",atval:"1",ttype:STRETCHY},{input:")",tag:"mo",output:")",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"]",tag:"mo",output:"]",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"\\rbrack",tag:"mo",output:"]",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"\\}",tag:"mo",output:"}",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"\\rbrace",tag:"mo",output:"}",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"\\rangle",tag:"mo",output:"\u232A",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"\\rfloor",tag:"mo",output:"\u230B",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"\\rceil",tag:"mo",output:"\u2309",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"|",tag:"mo",output:"\u2223",atval:"1",ttype:STRETCHY},{input:"\\|",tag:"mo",output:"\u2225",atval:"1",ttype:STRETCHY},{input:"\\vert",tag:"mo",output:"\u2223",atval:"1",ttype:STRETCHY},{input:"\\Vert",tag:"mo",output:"\u2225",atval:"1",ttype:STRETCHY},{input:"\\mid",tag:"mo",output:"\u2223",atval:"1",ttype:STRETCHY},{input:"\\parallel",tag:"mo",output:"\u2225",atval:"1",ttype:STRETCHY},{input:"/",tag:"mo",output:"/",atval:"1.01",ttype:STRETCHY},{input:"\\backslash",tag:"mo",output:"\u2216",atval:"1",ttype:STRETCHY},{input:"\\setminus",tag:"mo",output:"\\",ttype:CONST},{input:"\\!",tag:"mspace",atname:"width",atval:"-0.167em",ttype:SPACE},{input:"\\,",tag:"mspace",atname:"width",atval:"0.167em",ttype:SPACE},{input:"\\>",tag:"mspace",atname:"width",atval:"0.222em",ttype:SPACE},{input:"\\:",tag:"mspace",atname:"width",atval:"0.222em",ttype:SPACE},{input:"\\;",tag:"mspace",atname:"width",atval:"0.278em",ttype:SPACE},{input:"~",tag:"mspace",atname:"width",atval:"0.333em",ttype:SPACE},{input:"\\quad",tag:"mspace",atname:"width",atval:"1em",ttype:SPACE},{input:"\\qquad",tag:"mspace",atname:"width",atval:"2em",ttype:SPACE},{input:"\\prime",tag:"mo",output:"\u2032",ttype:CONST},{input:"'",tag:"mo",output:"\u02B9",ttype:CONST},{input:"''",tag:"mo",output:"\u02BA",ttype:CONST},{input:"'''",tag:"mo",output:"\u2034",ttype:CONST},{input:"''''",tag:"mo",output:"\u2057",ttype:CONST},{input:"\\ldots",tag:"mo",output:"\u2026",ttype:CONST},{input:"\\cdots",tag:"mo",output:"\u22EF",ttype:CONST},{input:"\\vdots",tag:"mo",output:"\u22EE",ttype:CONST},{input:"\\ddots",tag:"mo",output:"\u22F1",ttype:CONST},{input:"\\forall",tag:"mo",output:"\u2200",ttype:CONST},{input:"\\exists",tag:"mo",output:"\u2203",ttype:CONST},{input:"\\Re",tag:"mo",output:"\u211C",ttype:CONST},{input:"\\Im",tag:"mo",output:"\u2111",ttype:CONST},{input:"\\aleph",tag:"mo",output:"\u2135",ttype:CONST},{input:"\\hbar",tag:"mo",output:"\u210F",ttype:CONST},{input:"\\ell",tag:"mo",output:"\u2113",ttype:CONST},{input:"\\wp",tag:"mo",output:"\u2118",ttype:CONST},{input:"\\emptyset",tag:"mo",output:"\u2205",ttype:CONST},{input:"\\infty",tag:"mo",output:"\u221E",ttype:CONST},{input:"\\surd",tag:"mo",output:"\\sqrt{}",ttype:DEFINITION},{input:"\\partial",tag:"mo",output:"\u2202",ttype:CONST},{input:"\\nabla",tag:"mo",output:"\u2207",ttype:CONST},{input:"\\triangle",tag:"mo",output:"\u25B3",ttype:CONST},{input:"\\therefore",tag:"mo",output:"\u2234",ttype:CONST},{input:"\\angle",tag:"mo",output:"\u2220",ttype:CONST},{input:"\\diamond",tag:"mo",output:"\u22C4",ttype:CONST},{input:"\\Diamond",tag:"mo",output:"\u25C7",ttype:CONST},{input:"\\neg",tag:"mo",output:"\u00AC",ttype:CONST},{input:"\\lnot",tag:"mo",output:"\u00AC",ttype:CONST},{input:"\\bot",tag:"mo",output:"\u22A5",ttype:CONST},{input:"\\top",tag:"mo",output:"\u22A4",ttype:CONST},{input:"\\square",tag:"mo",output:"\u25AB",ttype:CONST},{input:"\\Box",tag:"mo",output:"\u25A1",ttype:CONST},{input:"\\wr",tag:"mo",output:"\u2240",ttype:CONST},{input:"\\arccos",tag:"mi",output:"arccos",ttype:UNARY,func:true},{input:"\\arcsin",tag:"mi",output:"arcsin",ttype:UNARY,func:true},{input:"\\arctan",tag:"mi",output:"arctan",ttype:UNARY,func:true},{input:"\\arg",tag:"mi",output:"arg",ttype:UNARY,func:true},{input:"\\cos",tag:"mi",output:"cos",ttype:UNARY,func:true},{input:"\\cosh",tag:"mi",output:"cosh",ttype:UNARY,func:true},{input:"\\cot",tag:"mi",output:"cot",ttype:UNARY,func:true},{input:"\\coth",tag:"mi",output:"coth",ttype:UNARY,func:true},{input:"\\csc",tag:"mi",output:"csc",ttype:UNARY,func:true},{input:"\\deg",tag:"mi",output:"deg",ttype:UNARY,func:true},{input:"\\det",tag:"mi",output:"det",ttype:UNARY,func:true},{input:"\\dim",tag:"mi",output:"dim",ttype:UNARY,func:true},{input:"\\exp",tag:"mi",output:"exp",ttype:UNARY,func:true},{input:"\\gcd",tag:"mi",output:"gcd",ttype:UNARY,func:true},{input:"\\hom",tag:"mi",output:"hom",ttype:UNARY,func:true},{input:"\\inf",tag:"mo",output:"inf",ttype:UNDEROVER},{input:"\\ker",tag:"mi",output:"ker",ttype:UNARY,func:true},{input:"\\lg",tag:"mi",output:"lg",ttype:UNARY,func:true},{input:"\\lim",tag:"mo",output:"lim",ttype:UNDEROVER},{input:"\\liminf",tag:"mo",output:"liminf",ttype:UNDEROVER},{input:"\\limsup",tag:"mo",output:"limsup",ttype:UNDEROVER},{input:"\\ln",tag:"mi",output:"ln",ttype:UNARY,func:true},{input:"\\log",tag:"mi",output:"log",ttype:UNARY,func:true},{input:"\\max",tag:"mo",output:"max",ttype:UNDEROVER},{input:"\\min",tag:"mo",output:"min",ttype:UNDEROVER},{input:"\\Pr",tag:"mi",output:"Pr",ttype:UNARY,func:true},{input:"\\sec",tag:"mi",output:"sec",ttype:UNARY,func:true},{input:"\\sin",tag:"mi",output:"sin",ttype:UNARY,func:true},{input:"\\sinh",tag:"mi",output:"sinh",ttype:UNARY,func:true},{input:"\\sup",tag:"mo",output:"sup",ttype:UNDEROVER},{input:"\\tan",tag:"mi",output:"tan",ttype:UNARY,func:true},{input:"\\tanh",tag:"mi",output:"tanh",ttype:UNARY,func:true},{input:"\\gets",tag:"mo",output:"\u2190",ttype:CONST},{input:"\\leftarrow",tag:"mo",output:"\u2190",ttype:CONST},{input:"\\to",tag:"mo",output:"\u2192",ttype:CONST},{input:"\\rightarrow",tag:"mo",output:"\u2192",ttype:CONST},{input:"\\leftrightarrow",tag:"mo",output:"\u2194",ttype:CONST},{input:"\\uparrow",tag:"mo",output:"\u2191",ttype:CONST},{input:"\\downarrow",tag:"mo",output:"\u2193",ttype:CONST},{input:"\\updownarrow",tag:"mo",output:"\u2195",ttype:CONST},{input:"\\Leftarrow",tag:"mo",output:"\u21D0",ttype:CONST},{input:"\\Rightarrow",tag:"mo",output:"\u21D2",ttype:CONST},{input:"\\Leftrightarrow",tag:"mo",output:"\u21D4",ttype:CONST},{input:"\\iff",tag:"mo",output:"~\\Longleftrightarrow~",ttype:DEFINITION},{input:"\\Uparrow",tag:"mo",output:"\u21D1",ttype:CONST},{input:"\\Downarrow",tag:"mo",output:"\u21D3",ttype:CONST},{input:"\\Updownarrow",tag:"mo",output:"\u21D5",ttype:CONST},{input:"\\mapsto",tag:"mo",output:"\u21A6",ttype:CONST},{input:"\\longleftarrow",tag:"mo",output:"\u2190",ttype:LONG},{input:"\\longrightarrow",tag:"mo",output:"\u2192",ttype:LONG},{input:"\\longleftrightarrow",tag:"mo",output:"\u2194",ttype:LONG},{input:"\\Longleftarrow",tag:"mo",output:"\u21D0",ttype:LONG},{input:"\\Longrightarrow",tag:"mo",output:"\u21D2",ttype:LONG},{input:"\\Longleftrightarrow",tag:"mo",output:"\u21D4",ttype:LONG},{input:"\\longmapsto",tag:"mo",output:"\u21A6",ttype:CONST},AMsqrt,AMroot,AMfrac,AMover,AMsub,AMsup,AMtext,AMmbox,AMatop,AMchoose,{input:"\\acute",tag:"mover",output:"\u00B4",ttype:UNARY,acc:true},{input:"\\grave",tag:"mover",output:"\u0060",ttype:UNARY,acc:true},{input:"\\breve",tag:"mover",output:"\u02D8",ttype:UNARY,acc:true},{input:"\\check",tag:"mover",output:"\u02C7",ttype:UNARY,acc:true},{input:"\\dot",tag:"mover",output:".",ttype:UNARY,acc:true},{input:"\\ddot",tag:"mover",output:"..",ttype:UNARY,acc:true},{input:"\\mathring",tag:"mover",output:"\u00B0",ttype:UNARY,acc:true},{input:"\\vec",tag:"mover",output:"\u20D7",ttype:UNARY,acc:true},{input:"\\overrightarrow",tag:"mover",output:"\u20D7",ttype:UNARY,acc:true},{input:"\\overleftarrow",tag:"mover",output:"\u20D6",ttype:UNARY,acc:true},{input:"\\hat",tag:"mover",output:"\u005E",ttype:UNARY,acc:true},{input:"\\widehat",tag:"mover",output:"\u0302",ttype:UNARY,acc:true},{input:"\\tilde",tag:"mover",output:"~",ttype:UNARY,acc:true},{input:"\\widetilde",tag:"mover",output:"\u02DC",ttype:UNARY,acc:true},{input:"\\bar",tag:"mover",output:"\u203E",ttype:UNARY,acc:true},{input:"\\overbrace",tag:"mover",output:"\uFE37",ttype:UNARY,acc:true},{input:"\\overbracket",tag:"mover",output:"\u23B4",ttype:UNARY,acc:true},{input:"\\overline",tag:"mover",output:"\u00AF",ttype:UNARY,acc:true},{input:"\\underbrace",tag:"munder",output:"\uFE38",ttype:UNARY,acc:true},{input:"\\underbracket",tag:"munder",output:"\u23B5",ttype:UNARY,acc:true},{input:"\\underline",tag:"munder",output:"\u00AF",ttype:UNARY,acc:true},{input:"\\displaystyle",tag:"mstyle",atname:"displaystyle",atval:"true",ttype:UNARY},{input:"\\textstyle",tag:"mstyle",atname:"displaystyle",atval:"false",ttype:UNARY},{input:"\\scriptstyle",tag:"mstyle",atname:"scriptlevel",atval:"1",ttype:UNARY},{input:"\\scriptscriptstyle",tag:"mstyle",atname:"scriptlevel",atval:"2",ttype:UNARY},{input:"\\textrm",tag:"mstyle",output:"\\mathrm",ttype:DEFINITION},{input:"\\mathbf",tag:"mstyle",atname:"mathvariant",atval:"bold",ttype:UNARY},{input:"\\textbf",tag:"mstyle",atname:"mathvariant",atval:"bold",ttype:UNARY},{input:"\\mathit",tag:"mstyle",atname:"mathvariant",atval:"italic",ttype:UNARY},{input:"\\textit",tag:"mstyle",atname:"mathvariant",atval:"italic",ttype:UNARY},{input:"\\mathtt",tag:"mstyle",atname:"mathvariant",atval:"monospace",ttype:UNARY},{input:"\\texttt",tag:"mstyle",atname:"mathvariant",atval:"monospace",ttype:UNARY},{input:"\\mathsf",tag:"mstyle",atname:"mathvariant",atval:"sans-serif",ttype:UNARY},{input:"\\mathbb",tag:"mstyle",atname:"mathvariant",atval:"double-struck",ttype:UNARY,codes:AMbbb},{input:"\\mathcal",tag:"mstyle",atname:"mathvariant",atval:"script",ttype:UNARY,codes:AMcal},{input:"\\mathfrak",tag:"mstyle",atname:"mathvariant",atval:"fraktur",ttype:UNARY,codes:AMfrk},{input:"\\textcolor",tag:"mstyle",atname:"mathvariant",atval:"mathcolor",ttype:BINARY},{input:"\\colorbox",tag:"mstyle",atname:"mathvariant",atval:"background",ttype:BINARY}];function compareNames(s1,s2){if(s1.input>s2.input)return 1
+else return-1;}
+var AMnames=[];function AMinitSymbols(){AMsymbols.sort(compareNames);for(i=0;i<AMsymbols.length;i++)AMnames[i]=AMsymbols[i].input;}
+var AMmathml="http://www.w3.org/1998/Math/MathML";function AMcreateElementMathML(t){if(isIE)return document.createElement("m:"+t);else return document.createElementNS(AMmathml,t);}
+function AMcreateMmlNode(t,frag){if(isIE)var node=document.createElement("m:"+t);else var node=document.createElementNS(AMmathml,t);node.appendChild(frag);return node;}
+function newcommand(oldstr,newstr){AMsymbols=AMsymbols.concat([{input:oldstr,tag:"mo",output:newstr,ttype:DEFINITION}]);}
+function AMremoveCharsAndBlanks(str,n){var st;st=str.slice(n);for(var i=0;i<st.length&&st.charCodeAt(i)<=32;i=i+1);return st.slice(i);}
+function AMposition(arr,str,n){if(n==0){var h,m;n=-1;h=arr.length;while(n+1<h){m=(n+h)>>1;if(arr[m]<str)n=m;else h=m;}
+return h;}else
+for(var i=n;i<arr.length&&arr[i]<str;i++);return i;}
+function AMgetSymbol(str){var k=0;var j=0;var mk;var st;var tagst;var match="";var more=true;for(var i=1;i<=str.length&&more;i++){st=str.slice(0,i);j=k;k=AMposition(AMnames,st,j);if(k<AMnames.length&&str.slice(0,AMnames[k].length)==AMnames[k]){match=AMnames[k];mk=k;i=match.length;}
+more=k<AMnames.length&&str.slice(0,AMnames[k].length)>=AMnames[k];}
+AMpreviousSymbol=AMcurrentSymbol;if(match!=""){AMcurrentSymbol=AMsymbols[mk].ttype;return AMsymbols[mk];}
+AMcurrentSymbol=CONST;k=1;st=str.slice(0,1);if("0"<=st&&st<="9")tagst="mn";else tagst=(("A">st||st>"Z")&&("a">st||st>"z")?"mo":"mi");return{input:st,tag:tagst,output:st,ttype:CONST};}
+var AMpreviousSymbol,AMcurrentSymbol;function AMparseSexpr(str){var symbol,node,result,result2,i,st,newFrag=document.createDocumentFragment();str=AMremoveCharsAndBlanks(str,0);symbol=AMgetSymbol(str);if(symbol==null||symbol.ttype==RIGHTBRACKET)
+return[null,str,null];if(symbol.ttype==DEFINITION){str=symbol.output+AMremoveCharsAndBlanks(str,symbol.input.length);symbol=AMgetSymbol(str);if(symbol==null||symbol.ttype==RIGHTBRACKET)
+return[null,str,null];}
+str=AMremoveCharsAndBlanks(str,symbol.input.length);switch(symbol.ttype){case SPACE:node=AMcreateElementMathML(symbol.tag);node.setAttribute(symbol.atname,symbol.atval);return[node,str,symbol.tag];case UNDEROVER:if(isIE){if(symbol.input.substr(0,4)=="\\big"){str="\\"+symbol.input.substr(4)+str;symbol=AMgetSymbol(str);symbol.ttype=UNDEROVER;str=AMremoveCharsAndBlanks(str,symbol.input.length);}}
+return[AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)),str,symbol.tag];case CONST:var output=symbol.output;if(isIE){if(symbol.input=="'")
+output="\u2032";else if(symbol.input=="''")
+output="\u2033";else if(symbol.input=="'''")
+output="\u2033\u2032";else if(symbol.input=="''''")
+output="\u2033\u2033";else if(symbol.input=="\\square")
+output="\u25A1";else if(symbol.input.substr(0,5)=="\\frac"){var denom=symbol.input.substr(6,1);if(denom=="5"||denom=="6"){str=symbol.input.replace(/\\frac/,"\\frac ")+str;return[node,str,symbol.tag];}}}
+node=AMcreateMmlNode(symbol.tag,document.createTextNode(output));return[node,str,symbol.tag];case LONG:node=AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output));node.setAttribute("minsize","1.5");node.setAttribute("maxsize","1.5");node=AMcreateMmlNode("mover",node);node.appendChild(AMcreateElementMathML("mspace"));return[node,str,symbol.tag];case STRETCHY:if(isIE&&symbol.input=="\\backslash")
+symbol.output="\\";node=AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output));if(symbol.input=="|"||symbol.input=="\\vert"||symbol.input=="\\|"||symbol.input=="\\Vert"){node.setAttribute("lspace","0em");node.setAttribute("rspace","0em");}
+node.setAttribute("maxsize",symbol.atval);if(symbol.rtag!=null)
+return[node,str,symbol.rtag];else
+return[node,str,symbol.tag];case BIG:var atval=symbol.atval;if(isIE)
+atval=symbol.ieval;symbol=AMgetSymbol(str);if(symbol==null)
+return[null,str,null];str=AMremoveCharsAndBlanks(str,symbol.input.length);node=AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output));if(isIE){var space=AMcreateElementMathML("mspace");space.setAttribute("height",atval+"ex");node=AMcreateMmlNode("mrow",node);node.appendChild(space);}else{node.setAttribute("minsize",atval);node.setAttribute("maxsize",atval);}
+return[node,str,symbol.tag];case LEFTBRACKET:if(symbol.input=="\\left"){symbol=AMgetSymbol(str);if(symbol!=null){if(symbol.input==".")
+symbol.invisible=true;str=AMremoveCharsAndBlanks(str,symbol.input.length);}}
+result=AMparseExpr(str,true,false);if(symbol==null||(typeof symbol.invisible=="boolean"&&symbol.invisible))
+node=AMcreateMmlNode("mrow",result[0]);else{node=AMcreateMmlNode("mo",document.createTextNode(symbol.output));node=AMcreateMmlNode("mrow",node);node.appendChild(result[0]);}
+return[node,result[1],result[2]];case MATRIX:if(symbol.input=="\\begin{array}"){var mask="";symbol=AMgetSymbol(str);str=AMremoveCharsAndBlanks(str,0);if(symbol==null)
+mask="l";else{str=AMremoveCharsAndBlanks(str,symbol.input.length);if(symbol.input!="{")
+mask="l";else do{symbol=AMgetSymbol(str);if(symbol!=null){str=AMremoveCharsAndBlanks(str,symbol.input.length);if(symbol.input!="}")
+mask=mask+symbol.input;}}while(symbol!=null&&symbol.input!=""&&symbol.input!="}");}
+result=AMparseExpr("{"+str,true,true);node=AMcreateMmlNode("mtable",result[0]);mask=mask.replace(/l/g,"left ");mask=mask.replace(/r/g,"right ");mask=mask.replace(/c/g,"center ");node.setAttribute("columnalign",mask);node.setAttribute("displaystyle","false");if(isIE)
+return[node,result[1],null];var lspace=AMcreateElementMathML("mspace");lspace.setAttribute("width","0.167em");var rspace=AMcreateElementMathML("mspace");rspace.setAttribute("width","0.167em");var node1=AMcreateMmlNode("mrow",lspace);node1.appendChild(node);node1.appendChild(rspace);return[node1,result[1],null];}else{result=AMparseExpr("{"+str,true,true);node=AMcreateMmlNode("mtable",result[0]);if(isIE)
+node.setAttribute("columnspacing","0.25em");else
+node.setAttribute("columnspacing","0.167em");node.setAttribute("columnalign","right center left");node.setAttribute("displaystyle","true");node=AMcreateMmlNode("mrow",node);return[node,result[1],null];}
+case TEXT:if(str.charAt(0)=="{")i=str.indexOf("}");else i=0;if(i==-1)
+i=str.length;st=str.slice(1,i);if(st.charAt(0)==" "){node=AMcreateElementMathML("mspace");node.setAttribute("width","0.33em");newFrag.appendChild(node);}
+newFrag.appendChild(AMcreateMmlNode(symbol.tag,document.createTextNode(st)));if(st.charAt(st.length-1)==" "){node=AMcreateElementMathML("mspace");node.setAttribute("width","0.33em");newFrag.appendChild(node);}
+str=AMremoveCharsAndBlanks(str,i+1);return[AMcreateMmlNode("mrow",newFrag),str,null];case UNARY:result=AMparseSexpr(str);if(result[0]==null)return[AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)),str];if(typeof symbol.func=="boolean"&&symbol.func){st=str.charAt(0);if(st=="^"||st=="_"||st==","){return[AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)),str,symbol.tag];}else{node=AMcreateMmlNode("mrow",AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)));if(isIE){var space=AMcreateElementMathML("mspace");space.setAttribute("width","0.167em");node.appendChild(space);}
+node.appendChild(result[0]);return[node,result[1],symbol.tag];}}
+if(symbol.input=="\\sqrt"){if(isIE){var space=AMcreateElementMathML("mspace");space.setAttribute("height","1.2ex");space.setAttribute("width","0em");node=AMcreateMmlNode(symbol.tag,result[0])
+node.appendChild(space);return[node,result[1],symbol.tag];}else
+return[AMcreateMmlNode(symbol.tag,result[0]),result[1],symbol.tag];}else if(typeof symbol.acc=="boolean"&&symbol.acc){node=AMcreateMmlNode(symbol.tag,result[0]);var output=symbol.output;if(isIE){if(symbol.input=="\\hat")
+output="\u0302";else if(symbol.input=="\\widehat")
+output="\u005E";else if(symbol.input=="\\bar")
+output="\u00AF";else if(symbol.input=="\\grave")
+output="\u0300";else if(symbol.input=="\\tilde")
+output="\u0303";}
+var node1=AMcreateMmlNode("mo",document.createTextNode(output));if(symbol.input=="\\vec"||symbol.input=="\\check")
+node1.setAttribute("maxsize","1.2");if(isIE&&symbol.input=="\\bar")
+node1.setAttribute("maxsize","0.5");if(symbol.input=="\\underbrace"||symbol.input=="\\underline")
+node1.setAttribute("accentunder","true");else
+node1.setAttribute("accent","true");node.appendChild(node1);if(symbol.input=="\\overbrace"||symbol.input=="\\underbrace")
+node.ttype=UNDEROVER;return[node,result[1],symbol.tag];}else{if(!isIE&&typeof symbol.codes!="undefined"){for(i=0;i<result[0].childNodes.length;i++)
+if(result[0].childNodes[i].nodeName=="mi"||result[0].nodeName=="mi"){st=(result[0].nodeName=="mi"?result[0].firstChild.nodeValue:result[0].childNodes[i].firstChild.nodeValue);var newst=[];for(var j=0;j<st.length;j++)
+if(st.charCodeAt(j)>64&&st.charCodeAt(j)<91)newst=newst+
+String.fromCharCode(symbol.codes[st.charCodeAt(j)-65]);else newst=newst+st.charAt(j);if(result[0].nodeName=="mi")
+result[0]=AMcreateElementMathML("mo").appendChild(document.createTextNode(newst));else result[0].replaceChild(AMcreateElementMathML("mo").appendChild(document.createTextNode(newst)),result[0].childNodes[i]);}}
+node=AMcreateMmlNode(symbol.tag,result[0]);node.setAttribute(symbol.atname,symbol.atval);if(symbol.input=="\\scriptstyle"||symbol.input=="\\scriptscriptstyle")
+node.setAttribute("displaystyle","false");return[node,result[1],symbol.tag];}
+case BINARY:result=AMparseSexpr(str);if(result[0]==null)return[AMcreateMmlNode("mo",document.createTextNode(symbol.input)),str,null];result2=AMparseSexpr(result[1]);if(result2[0]==null)return[AMcreateMmlNode("mo",document.createTextNode(symbol.input)),str,null];if(symbol.input=="\\textcolor"||symbol.input=="\\colorbox"){var tclr=str.match(/\{\s*([#\w]+)\s*\}/);str=str.replace(/\{\s*[#\w]+\s*\}/,"");if(tclr!=null){if(IsColorName.test(tclr[1].toLowerCase())){tclr=LaTeXColor[tclr[1].toLowerCase()];}else{tclr=tclr[1];}
+node=AMcreateElementMathML("mstyle");node.setAttribute(symbol.atval,tclr);node.appendChild(result2[0]);return[node,result2[1],symbol.tag];}}
+if(symbol.input=="\\root"||symbol.input=="\\stackrel")newFrag.appendChild(result2[0]);newFrag.appendChild(result[0]);if(symbol.input=="\\frac")newFrag.appendChild(result2[0]);return[AMcreateMmlNode(symbol.tag,newFrag),result2[1],symbol.tag];case INFIX:str=AMremoveCharsAndBlanks(str,symbol.input.length);return[AMcreateMmlNode("mo",document.createTextNode(symbol.output)),str,symbol.tag];default:return[AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)),str,symbol.tag];}}
+function AMparseIexpr(str){var symbol,sym1,sym2,node,result,tag,underover;str=AMremoveCharsAndBlanks(str,0);sym1=AMgetSymbol(str);result=AMparseSexpr(str);node=result[0];str=result[1];tag=result[2];symbol=AMgetSymbol(str);if(symbol.ttype==INFIX){str=AMremoveCharsAndBlanks(str,symbol.input.length);result=AMparseSexpr(str);if(result[0]==null)
+result[0]=AMcreateMmlNode("mo",document.createTextNode("\u25A1"));str=result[1];tag=result[2];if(symbol.input=="_"||symbol.input=="^"){sym2=AMgetSymbol(str);tag=null;underover=((sym1.ttype==UNDEROVER)||(node.ttype==UNDEROVER));if(symbol.input=="_"&&sym2.input=="^"){str=AMremoveCharsAndBlanks(str,sym2.input.length);var res2=AMparseSexpr(str);str=res2[1];tag=res2[2];node=AMcreateMmlNode((underover?"munderover":"msubsup"),node);node.appendChild(result[0]);node.appendChild(res2[0]);}else if(symbol.input=="_"){node=AMcreateMmlNode((underover?"munder":"msub"),node);node.appendChild(result[0]);}else{node=AMcreateMmlNode((underover?"mover":"msup"),node);node.appendChild(result[0]);}
+node=AMcreateMmlNode("mrow",node);}else{node=AMcreateMmlNode(symbol.tag,node);if(symbol.input=="\\atop"||symbol.input=="\\choose")
+node.setAttribute("linethickness","0ex");node.appendChild(result[0]);if(symbol.input=="\\choose")
+node=AMcreateMmlNode("mfenced",node);}}
+return[node,str,tag];}
+function AMparseExpr(str,rightbracket,matrix){var symbol,node,result,i,tag,newFrag=document.createDocumentFragment();do{str=AMremoveCharsAndBlanks(str,0);result=AMparseIexpr(str);node=result[0];str=result[1];tag=result[2];symbol=AMgetSymbol(str);if(node!=undefined){if((tag=="mn"||tag=="mi")&&symbol!=null&&typeof symbol.func=="boolean"&&symbol.func){var space=AMcreateElementMathML("mspace");space.setAttribute("width","0.167em");node=AMcreateMmlNode("mrow",node);node.appendChild(space);}
+newFrag.appendChild(node);}}while((symbol.ttype!=RIGHTBRACKET)&&symbol!=null&&symbol.output!="");tag=null;if(symbol.ttype==RIGHTBRACKET){if(symbol.input=="\\right"){str=AMremoveCharsAndBlanks(str,symbol.input.length);symbol=AMgetSymbol(str);if(symbol!=null&&symbol.input==".")
+symbol.invisible=true;if(symbol!=null)
+tag=symbol.rtag;}
+if(symbol!=null)
+str=AMremoveCharsAndBlanks(str,symbol.input.length);var len=newFrag.childNodes.length;if(matrix&&len>0&&newFrag.childNodes[len-1].nodeName=="mrow"&&len>1&&newFrag.childNodes[len-2].nodeName=="mo"&&newFrag.childNodes[len-2].firstChild.nodeValue=="&"){var pos=[];var m=newFrag.childNodes.length;for(i=0;matrix&&i<m;i=i+2){pos[i]=[];node=newFrag.childNodes[i];for(var j=0;j<node.childNodes.length;j++)
+if(node.childNodes[j].firstChild.nodeValue=="&")
+pos[i][pos[i].length]=j;}
+var row,frag,n,k,table=document.createDocumentFragment();for(i=0;i<m;i=i+2){row=document.createDocumentFragment();frag=document.createDocumentFragment();node=newFrag.firstChild;n=node.childNodes.length;k=0;for(j=0;j<n;j++){if(typeof pos[i][k]!="undefined"&&j==pos[i][k]){node.removeChild(node.firstChild);row.appendChild(AMcreateMmlNode("mtd",frag));k++;}else frag.appendChild(node.firstChild);}
+row.appendChild(AMcreateMmlNode("mtd",frag));if(newFrag.childNodes.length>2){newFrag.removeChild(newFrag.firstChild);newFrag.removeChild(newFrag.firstChild);}
+table.appendChild(AMcreateMmlNode("mtr",row));}
+return[table,str];}
+if(typeof symbol.invisible!="boolean"||!symbol.invisible){node=AMcreateMmlNode("mo",document.createTextNode(symbol.output));newFrag.appendChild(node);}}
+return[newFrag,str,tag];}
+function AMparseMath(str){var result,node=AMcreateElementMathML("mstyle");var cclr=str.match(/\\color\s*\{\s*([#\w]+)\s*\}/);str=str.replace(/\\color\s*\{\s*[#\w]+\s*\}/g,"");if(cclr!=null){if(IsColorName.test(cclr[1].toLowerCase())){cclr=LaTeXColor[cclr[1].toLowerCase()];}else{cclr=cclr[1];}
+node.setAttribute("mathcolor",cclr);}else{if(mathcolor!="")node.setAttribute("mathcolor",mathcolor);};if(mathfontfamily!="")node.setAttribute("fontfamily",mathfontfamily);node.appendChild(AMparseExpr(str.replace(/^\s+/g,""),false,false)[0]);node=AMcreateMmlNode("math",node);if(showasciiformulaonhover)
+node.setAttribute("title",str.replace(/\s+/g," "));if(false){var fnode=AMcreateElementXHTML("font");fnode.setAttribute("face",mathfontfamily);fnode.appendChild(node);return fnode;}
+return node;}
+function AMstrarr2docFrag(arr,linebreaks){var newFrag=document.createDocumentFragment();var expr=false;for(var i=0;i<arr.length;i++){if(expr)newFrag.appendChild(AMparseMath(arr[i]));else{var arri=(linebreaks?arr[i].split("\n\n"):[arr[i]]);newFrag.appendChild(AMcreateElementXHTML("span").appendChild(document.createTextNode(arri[0])));for(var j=1;j<arri.length;j++){newFrag.appendChild(AMcreateElementXHTML("p"));newFrag.appendChild(AMcreateElementXHTML("span").appendChild(document.createTextNode(arri[j])));}}
+expr=!expr;}
+return newFrag;}
+function AMprocessNodeR(n,linebreaks){var mtch,str,arr,frg,i;if(n.childNodes.length==0){if((n.nodeType!=8||linebreaks)&&n.parentNode.nodeName!="form"&&n.parentNode.nodeName!="FORM"&&n.parentNode.nodeName!="textarea"&&n.parentNode.nodeName!="TEXTAREA"&&n.parentNode.nodeName!="pre"&&n.parentNode.nodeName!="PRE"){str=n.nodeValue;if(!(str==null)){str=str.replace(/\r\n\r\n/g,"\n\n");str=str.replace(/\x20+/g," ");str=str.replace(/\s*\r\n/g," ");mtch=(str.indexOf("\$")==-1?false:true);str=str.replace(/([^\\])\$/g,"$1 \$");str=str.replace(/^\$/," \$");arr=str.split(" \$");for(i=0;i<arr.length;i++)
+arr[i]=arr[i].replace(/\\\$/g,"\$");if(arr.length>1||mtch){if(checkForMathML){checkForMathML=false;var nd=AMisMathMLavailable();AMnoMathML=nd!=null;if(AMnoMathML&&notifyIfNoMathML)
+if(alertIfNoMathML)
+alert("To view the ASCIIMathML notation use Internet Explorer 6 +\nMathPlayer (free from www.dessci.com)\nor Firefox/Mozilla/Netscape");else AMbody.insertBefore(nd,AMbody.childNodes[0]);}
+if(!AMnoMathML){frg=AMstrarr2docFrag(arr,n.nodeType==8);var len=frg.childNodes.length;n.parentNode.replaceChild(frg,n);return len-1;}else return 0;}}}else return 0;}else if(n.nodeName!="math"){for(i=0;i<n.childNodes.length;i++)
+i+=AMprocessNodeR(n.childNodes[i],linebreaks);}
+return 0;}
+function AMprocessNode(n,linebreaks,spanclassAM){var frag,st;if(spanclassAM!=null){frag=document.getElementsByTagName("span")
+for(var i=0;i<frag.length;i++)
+if(frag[i].className=="AM")
+AMprocessNodeR(frag[i],linebreaks);}else{try{st=n.innerHTML;}catch(err){}
+if(st==null||st.indexOf("\$")!=-1)
+AMprocessNodeR(n,linebreaks);}
+if(isIE){frag=document.getElementsByTagName('math');for(var i=0;i<frag.length;i++)frag[i].update()}}
+var inAppendix=false;var sectionCntr=0;var IEcommentWarning=true;var biblist=[];var bibcntr=0;var LaTeXCounter=[];LaTeXCounter["definition"]=0;LaTeXCounter["proposition"]=0;LaTeXCounter["lemma"]=0;LaTeXCounter["theorem"]=0;LaTeXCounter["corollary"]=0;LaTeXCounter["example"]=0;LaTeXCounter["exercise"]=0;LaTeXCounter["subsection"]=0;LaTeXCounter["subsubsection"]=0;LaTeXCounter["figure"]=0;LaTeXCounter["equation"]=0;LaTeXCounter["table"]=0;var LaTeXColor=[];LaTeXColor["greenyellow"]="#D9FF4F";LaTeXColor["yellow"]="#FFFF00";LaTeXColor["goldenrod"]="#FFE529";LaTeXColor["dandelion"]="#FFB529";LaTeXColor["apricot"]="#FFAD7A";LaTeXColor["peach"]="#FF804D";LaTeXColor["melon"]="#FF8A80";LaTeXColor["yelloworange"]="#FF9400";LaTeXColor["orange"]="#FF6321";LaTeXColor["burntorange"]="#FF7D00";LaTeXColor["bittersweet"]="#C20300";LaTeXColor["redorange"]="#FF3B21";LaTeXColor["mahogany"]="#A60000";LaTeXColor["maroon"]="#AD0000";LaTeXColor["brickred"]="#B80000";LaTeXColor["red"]="#FF0000";LaTeXColor["orangered"]="#FF0080";LaTeXColor["rubinered"]="#FF00DE";LaTeXColor["wildstrawberry"]="#FF0A9C";LaTeXColor["salmon"]="#FF789E";LaTeXColor["carnationpink"]="#FF5EFF";LaTeXColor["magenta"]="#FF00FF";LaTeXColor["violetred"]="#FF30FF";LaTeXColor["rhodamine"]="#FF2EFF";LaTeXColor["mulberry"]="#A314FA";LaTeXColor["redviolet"]="#9600A8";LaTeXColor["fuchsia"]="#7303EB";LaTeXColor["lavender"]="#FF85FF";LaTeXColor["thistle"]="#E069FF";LaTeXColor["orchid"]="#AD5CFF";LaTeXColor["darkorchid"]="#9933CC";LaTeXColor["purple"]="#8C24FF";LaTeXColor["plum"]="#8000FF";LaTeXColor["violet"]="#361FFF";LaTeXColor["royalpurple"]="#401AFF";LaTeXColor["blueviolet"]="#1A0DF5";LaTeXColor["periwinkle"]="#6E73FF";LaTeXColor["cadetblue"]="#616EC4";LaTeXColor["cornflowerblue"]="#59DEFF";LaTeXColor["midnightblue"]="#007091";LaTeXColor["navyblue"]="#0F75FF";LaTeXColor["royalblue"]="#0080FF";LaTeXColor["blue"]="#0000FF";LaTeXColor["cerulean"]="#0FE3FF";LaTeXColor["cyan"]="#00FFFF";LaTeXColor["processblue"]="#0AFFFF";LaTeXColor["skyblue"]="#61FFE0";LaTeXColor["turquoise"]="#26FFCC";LaTeXColor["tealblue"]="#1FFAA3";LaTeXColor["aquamarine"]="#2EFFB2";LaTeXColor["bluegreen"]="#26FFAB";LaTeXColor["emerald"]="#00FF80";LaTeXColor["junglegreen"]="#03FF7A";LaTeXColor["seagreen"]="#4FFF80";LaTeXColor["green"]="#00FF00";LaTeXColor["forestgreen"]="#00E000";LaTeXColor["pinegreen"]="#00BF29";LaTeXColor["limegreen"]="#80FF00";LaTeXColor["yellowgreen"]="#8FFF42";LaTeXColor["springgreen"]="#BDFF3D";LaTeXColor["olivegreen"]="#009900";LaTeXColor["rawsienna"]="#8C0000";LaTeXColor["sepia"]="#4D0000";LaTeXColor["brown"]="#660000";LaTeXColor["tan"]="#DB9470";LaTeXColor["gray"]="#808080";LaTeXColor["grey"]="#808080";LaTeXColor["black"]="#000000";LaTeXColor["white"]="#FFFFFF";var IsColorName=/^(?:greenyellow|yellow|goldenrod|dandelion|apricot|peach|melon|yelloworange|orange|burntorange|bittersweet|redorange|mahogany|maroon|brickred|red|orangered|rubinered|wildstrawberry|salmon|carnationpink|magenta|violetred|rhodamine|mulberry|redviolet|fuchsia|lavender|thistle|orchid|darkorchid|purple|plum|violet|royalpurple|blueviolet|periwinkle|cadetblue|cornflowerblue|midnightblue|navyblue|royalblue|blue|cerulean|cyan|processblue|skyblue|turquoise|tealblue|aquamarine|bluegreen|emerald|junglegreen|seagreen|green|forestgreen|pinegreen|limegreen|yellowgreen|springgreen|olivegreen|rawsienna|sepia|brown|tan|gray|grey|black|white)$/;var IsCounter=/^(?:definition|proposition|lemma|theorem|corollary|example|exercise|subsection|subsubsection|figure|equation|table)$/;var IsLaTeXElement=/^(?:displayequation|title|author|address|date|abstract|keyword|section|subsection|subsubsection|ref|cite|thebibliography|definition|proposition|lemma|theorem|corollary|example|exercise|itemize|enumerate|enddefinition|endproposition|endlemma|endtheorem|endcorollary|endexample|endexercise|enditemize|endenumerate|LaTeXMathMLlabel|LaTeXMathML|smallskip|medskip|bigskip|quote|quotation|endquote|endquotation|center|endcenter|description|enddescription|inlinemath)$/;var IsTextOnlyArea=/^(?:form|textarea|pre)$/i;var tableid=0;function makeNumberString(cntr){if(sectionCntr>0){if(inAppendix){return"A"+sectionCntr+"."+cntr;}else{return sectionCntr+"."+cntr;}}else{return""+cntr;}};function LaTeXpreProcess(thebody){var TheBody=thebody;if(TheBody.hasChildNodes()){if(!(IsLaTeXElement.test(TheBody.className)))
+{for(var i=0;i<TheBody.childNodes.length;i++){LaTeXpreProcess(TheBody.childNodes[i])}}}
+else{if(TheBody.nodeType==3&&!(IsTextOnlyArea.test(TheBody.parentNode.nodeName)))
+{var str=TheBody.nodeValue;if(!(str==null)){str=str.replace(/\\%/g,"<per>");str=str.replace(/%[^\n]*(?=\n)/g,"");str=str.replace(/%[^\r]*(?=\r)/g,"");str=str.replace(/%[^\n]*$/,"")
+if(isIE&&str.match(/%/g)!=null&&IEcommentWarning){alert("Comments may not have parsed properly. Try putting in <pre class='LaTeX><div>..</div></pre> structure.");IEcommentWarning=false;}
+str=str.replace(/<per>/g,"%");if(str.match(/XXX[\s\S]*/)!=null){var tmp=str.match(/XXX[\s\S]*/)[0];var tmpstr=tmp.charCodeAt(7)+"::"+tmp.charCodeAt(8)+"::"+tmp.charCodeAt(9)+"::"+tmp.charCodeAt(10)+"::"+tmp.charCodeAt(11)+"::"+tmp.charCodeAt(12)+"::"+tmp.charCodeAt(13);alert(tmpstr);}
+str=str.replace(/([^\\])\\(\s)/g,"$1\u00A0$2");str=str.replace(/\\quad/g,"\u2001");str=str.replace(/\\qquad/g,"\u2001\u2001");str=str.replace(/\\enspace/g,"\u2002");str=str.replace(/\\;/g,"\u2004");str=str.replace(/\\:/g,"\u2005");str=str.replace(/\\,/g,"\u2006");str=str.replace(/\\thinspace/g,"\u200A");str=str.replace(/([^\\])~/g,"$1\u00A0");str=str.replace(/\\~/g,"~");str=str.replace(/\\\[/g," <DEQ> $\\displaystyle{");str=str.replace(/\\\]/g,"}$ <DEQ> ");str=str.replace(/\$\$/g,"${$<DEQ>$}$");str=str.replace(/\\begin\s*\{\s*array\s*\}/g,"\\begin{array}");str=str.replace(/\\end\s*\{\s*array\s*\}/g,"\\end{array}");str=str.replace(/\\begin\s*\{\s*eqnarray\s*\}/g," <DEQ>eqno$\\begin{eqnarray}");str=str.replace(/\\end\s*\{\s*eqnarray\s*\}/g,"\\end{eqnarray}$<DEQ> ");str=str.replace(/\\begin\s*\{\s*eqnarray\*\s*\}/g," <DEQ>$\\begin{eqnarray}");str=str.replace(/\\end\s*\{\s*eqnarray\*\s*\}/g,"\\end{eqnarray}$<DEQ> ");str=str.replace(/\\begin\s*\{\s*displaymath\s*\}/g," <DEQ> $\\displaystyle{");str=str.replace(/\\end\s*\{\s*displaymath\s*\}/g,"}$ <DEQ> ");str=str.replace(/\\begin\s*\{\s*equation\s*\*\s*\}/g," <DEQ> $\\displaystyle{");str=str.replace(/\\end\s*\{\s*equation\s*\*\s*\}/g,"}$ <DEQ> ");str=str.replace(/\\begin\s*\{\s*equation\s*\}/g," <DEQ>eqno$\\displaystyle{");str=str.replace(/\\end\s*\{\s*equation\s*\}/g,"}$ <DEQ> ");str=str.split("<DEQ>");var newFrag=document.createDocumentFragment();for(var i=0;i<str.length;i++){if(i%2){var DEQtable=document.createElement("table");DEQtable.className='displayequation';var DEQtbody=document.createElement("tbody");var DEQtr=document.createElement("tr");var DEQtdeq=document.createElement("td");DEQtdeq.className='eq';str[i]=str[i].replace(/\$\}\$/g,"$\\displaystyle{");str[i]=str[i].replace(/\$\{\$/g,"}");var lbl=str[i].match(/\\label\s*\{\s*(\w+)\s*\}/);var ISeqno=str[i].match(/^eqno/);str[i]=str[i].replace(/^eqno/," ");str[i]=str[i].replace(/\\label\s*\{\s*\w+\s*\}/," ");DEQtdeq.appendChild(document.createTextNode(str[i]));DEQtr.appendChild(DEQtdeq);str[i]=str[i].replace(/\\nonumber/g,"");if(ISeqno!=null||lbl!=null){var DEQtdno=document.createElement("td");DEQtdno.className='eqno';LaTeXCounter["equation"]++;var eqnoString=makeNumberString(LaTeXCounter["equation"]);var DEQanchor=document.createElement("a");if(lbl!=null){DEQanchor.id=lbl[1]};DEQanchor.className="eqno";var anchorSpan=document.createElement("span");anchorSpan.className="eqno";anchorSpan.style.display="none";anchorSpan.appendChild(document.createTextNode(eqnoString));DEQanchor.appendChild(anchorSpan);DEQtdno.appendChild(DEQanchor);var DEQspan=document.createElement("span");DEQspan.className="eqno";DEQspan.appendChild(document.createTextNode("("+eqnoString+")"));DEQtdno.appendChild(DEQspan);DEQtr.appendChild(DEQtdno);}
+DEQtbody.appendChild(DEQtr);DEQtable.appendChild(DEQtbody);newFrag.appendChild(DEQtable);}
+else{str[i]=str[i].replace(/\$\}\$/g,"");str[i]=str[i].replace(/\$\{\$/g,"");str[i]=str[i].replace(/\\maketitle/g,"");str[i]=str[i].replace(/\\begin\s*\{\s*document\s*\}/g,"");str[i]=str[i].replace(/\\end\s*\{\s*document\s*\}/g,"");str[i]=str[i].replace(/\\documentclass[^\}]*?\}/g,"");str[i]=str[i].replace(/\\usepackage[^\}]*?\}/g,"");str[i]=str[i].replace(/\\noindent/g,"");str[i]=str[i].replace(/\\notag/g,"");str[i]=str[i].replace(/\\ref\s*\{\s*(\w+)\}/g," \\[ref\\]$1\\[ ");str[i]=str[i].replace(/\\url\s*\{\s*([^\}\n]+)\}/g," \\[url\\]$1\\[ ");str[i]=str[i].replace(/\\href\s*\{\s*([^\}]+)\}\s*\{\s*([^\}]+)\}/g," \\[href\\]$1\\]$2\\[ ");str[i]=str[i].replace(/\\cite\s*\{\s*(\w+)\}/g," \\[cite\\]$1\\[ ");str[i]=str[i].replace(/\\qed/g,"\u220E");str[i]=str[i].replace(/\\endproof/g,"\u220E");str[i]=str[i].replace(/\\proof/g,"\\textbf{Proof: }");str[i]=str[i].replace(/\\n(?=\s)/g," \\[br\\] \\[ ");str[i]=str[i].replace(/\\newline/g," \\[br\\] \\[ ");str[i]=str[i].replace(/\\linebreak/g," \\[br\\] \\[ ");str[i]=str[i].replace(/\\smallskip/g," \\[logicalbreak\\]smallskip\\[ ");str[i]=str[i].replace(/\\medskip/g," \\[logicalbreak\\]medskip\\[ ");str[i]=str[i].replace(/\\bigskip/g," \\[logicalbreak\\]bigskip\\[ ");str[i]=str[i].replace(/[\n\r]+[ \f\n\r\t\v\u2028\u2029]*[\n\r]+/g," \\[logicalbreak\\]LaTeXMathML\\[ ");if(isIE){str[i]=str[i].replace(/\r/g," ");}
+str[i]=str[i].replace(/\\bibitem\s*([^\{]*\{\s*\w*\s*\})/g," \\[bibitem\\]$1\\[ ");str[i]=str[i].replace(/\\bibitem\s*/g," \\[bibitem\\] \\[ ");str[i]=str[i].replace(/\\item\s*\[\s*(\w+)\s*\]/g," \\[alistitem\\]$1\\[ ");str[i]=str[i].replace(/\\item\s*/g," \\[alistitem\\] \\[ ");str[i]=str[i].replace(/\\appendix/g," \\[appendix\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*figure\s*\}([\s\S]+?)\\end\s*\{\s*figure\s*\}/g," \\[figure\\]$1\\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*table\s*\}([\s\S]+?)\\end\s*\{\s*table\s*\}/g," \\[table\\]$1\\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*theorem\s*\}/g," \\[theorem\\]Theorem \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*theorem\s*\}/g," \\[endtheorem\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*definition\s*\}/g," \\[definition\\]Definition \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*definition\s*\}/g," \\[enddefinition\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*lemma\s*\}/g," \\[lemma\\]Lemma \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*lemma\s*\}/g," \\[endlemma\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*corollary\s*\}/g," \\[corollary\\]Corollary \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*corollary\s*\}/g," \\[endcorollary\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*proposition\s*\}/g," \\[proposition\\]Proposition \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*proposition\s*\}/g," \\[endproposition\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*example\s*\}/g," \\[example\\]Example \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*example\s*\}/g," \\[endexample\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*exercise\s*\}/g," \\[exercise\\]Exercise \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*exercise\s*\}/g," \\[endexercise\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*thebibliography\s*\}\s*\{\s*\w+\s*\}/g," \\[thebibliography\\]References \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*thebibliography\s*\}/g," \\[thebibliography\\]References \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*thebibliography\s*\}/g," \\[endthebibliography\\]References \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*proof\s*\}/g," \\[proof\\]Proof: \\[ ");if(isIE){str[i]=str[i].replace(/\\end\s*\{\s*proof\s*\}/g,"\u220E \\[endproof\\] \\[ ");}else{str[i]=str[i].replace(/\\end\s*\{\s*proof\s*\}/g," \\[endproof\\] \\[ ");}
+str[i]=str[i].replace(/\\title\s*\{\s*([^\}]+)\}/g," \\[title\\] \\[$1 \\[endtitle\\] \\[ ");str[i]=str[i].replace(/\\author\s*\{\s*([^\}]+)\}/g," \\[author\\] \\[$1 \\[endauthor\\] \\[ ");str[i]=str[i].replace(/\\address\s*\{\s*([^\}]+)\}/g," \\[address\\] \\[$1 \\[endaddress\\] \\[ ");str[i]=str[i].replace(/\\date\s*\{\s*([^\}]+)\}/g," \\[date\\] \\[$1 \\[enddate\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*keyword\s*\}/g," \\[keyword\\] \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*keyword\s*\}/g," \\[endkeyword\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*abstract\s*\}/g," \\[abstract\\] \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*abstract\s*\}/g," \\[endabstract\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*(?!array|tabular)(\w+)\s*\}/g," \\[$1\\] \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*(?!array|tabular)(\w+)\s*\}/g," \\[end$1\\] \\[ ");var sectionIndex=str[i].search(/\\section\s*\{\s*[\s\S]+\}/);while(sectionIndex>=0){str[i]=str[i].replace(/\\section\s*\{/," \\[section\\]");var delimcnt=1;for(var ii=sectionIndex;ii<str[i].length;ii++){if(str[i].charAt(ii)=="{"){delimcnt++};if(str[i].charAt(ii)=="}"){delimcnt--};if(delimcnt==0){str[i]=str[i].substring(0,ii)+"\\[ "+str[i].substring(ii+1,str[i].length);break;}};sectionIndex=str[i].search(/\\section\s*\{\s*[\s\S]+\}/);}
+sectionIndex=str[i].search(/\\subsection\s*\{\s*[\s\S]+\}/);while(sectionIndex>=0){str[i]=str[i].replace(/\\subsection\s*\{/," \\[subsection\\]");var delimcnt=1;for(var ii=sectionIndex;ii<str[i].length;ii++){if(str[i].charAt(ii)=="{"){delimcnt++};if(str[i].charAt(ii)=="}"){delimcnt--};if(delimcnt==0){str[i]=str[i].substring(0,ii)+"\\[ "+str[i].substring(ii+1,str[i].length);break;}};sectionIndex=str[i].search(/\\subsection\s*\{\s*[\s\S]+\}/);}
+sectionIndex=str[i].search(/\\subsubsection\s*\{\s*[\s\S]+\}/);while(sectionIndex>=0){str[i]=str[i].replace(/\\subsubsection\s*\{/," \\[subsubsection\\]");var delimcnt=1;for(var ii=sectionIndex;ii<str[i].length;ii++){if(str[i].charAt(ii)=="{"){delimcnt++};if(str[i].charAt(ii)=="}"){delimcnt--};if(delimcnt==0){str[i]=str[i].substring(0,ii)+"\\[ "+str[i].substring(ii+1,str[i].length);break;}};sectionIndex=str[i].search(/\\subsubsection\s*\{\s*[\s\S]+\}/);}
+var CatToNextEven="";var strtmp=str[i].split("\\[");for(var j=0;j<strtmp.length;j++){if(j%2){var strtmparray=strtmp[j].split("\\]");switch(strtmparray[0]){case"section":var nodeTmp=document.createElement("H2");nodeTmp.className='section';sectionCntr++;for(var div in LaTeXCounter){LaTeXCounter[div]=0};var nodeAnchor=document.createElement("a");if(inAppendix){nodeAnchor.className='appendixsection';}else{nodeAnchor.className='section';}
+var nodeNumString=makeNumberString("");var anchorSpan=document.createElement("span");anchorSpan.className="section";anchorSpan.style.display="none";anchorSpan.appendChild(document.createTextNode(nodeNumString));nodeAnchor.appendChild(anchorSpan);nodeTmp.appendChild(nodeAnchor);var nodeSpan=document.createElement("span");nodeSpan.className='section';nodeSpan.appendChild(document.createTextNode(nodeNumString+" "));nodeTmp.appendChild(nodeSpan);nodeTmp.appendChild(document.createTextNode(strtmparray[1]));newFrag.appendChild(nodeTmp);break;case"subsection":var nodeTmp=document.createElement("H3");nodeTmp.className='subsection';LaTeXCounter["subsection"]++;LaTeXCounter["subsubsection"]=0;var nodeAnchor=document.createElement("a");nodeAnchor.className='subsection';var nodeNumString=makeNumberString(LaTeXCounter["subsection"]);var anchorSpan=document.createElement("span");anchorSpan.className="subsection";anchorSpan.style.display="none";anchorSpan.appendChild(document.createTextNode(nodeNumString));nodeAnchor.appendChild(anchorSpan);nodeTmp.appendChild(nodeAnchor);var nodeSpan=document.createElement("span");nodeSpan.className='subsection';nodeSpan.appendChild(document.createTextNode(nodeNumString+". "));nodeTmp.appendChild(nodeSpan);nodeTmp.appendChild(document.createTextNode(strtmparray[1]));newFrag.appendChild(nodeTmp);break;case"subsubsection":var nodeTmp=document.createElement("H4");nodeTmp.className='subsubsection';LaTeXCounter["subsubsection"]++;var nodeAnchor=document.createElement("a");nodeAnchor.className='subsubsection';var nodeNumString=makeNumberString(LaTeXCounter["subsection"]+"."+LaTeXCounter["subsubsection"]);var anchorSpan=document.createElement("span");anchorSpan.className="subsubsection";anchorSpan.style.display="none";anchorSpan.appendChild(document.createTextNode(nodeNumString));nodeAnchor.appendChild(anchorSpan);nodeTmp.appendChild(nodeAnchor);var nodeSpan=document.createElement("span");nodeSpan.className='subsubsection';nodeSpan.appendChild(document.createTextNode(nodeNumString+". "));nodeTmp.appendChild(nodeSpan);nodeTmp.appendChild(document.createTextNode(strtmparray[1]));newFrag.appendChild(nodeTmp);break;case"href":var nodeTmp=document.createElement("a");nodeTmp.className='LaTeXMathML';nodeTmp.href=strtmparray[1];nodeTmp.appendChild(document.createTextNode(strtmparray[2]));newFrag.appendChild(nodeTmp);break;case"url":var nodeTmp=document.createElement("a");nodeTmp.className='LaTeXMathML';nodeTmp.href=strtmparray[1];nodeTmp.appendChild(document.createTextNode(strtmparray[1]));newFrag.appendChild(nodeTmp);break;case"figure":var nodeTmp=document.createElement("table");nodeTmp.className='figure';var FIGtbody=document.createElement("tbody");var FIGlbl=strtmparray[1].match(/\\label\s*\{\s*(\w+)\s*\}/);strtmparray[1]=strtmparray[1].replace(/\\label\s*\{\w+\}/g,"");var capIndex=strtmparray[1].search(/\\caption\s*\{[\s\S]+\}/);var FIGcap="";if(capIndex>=0){var tmp=strtmparray[1];var delimcnt=0;var capstart=-1;for(var pos=capIndex;pos<tmp.length;pos++){if(tmp.charAt(pos)=="{"){delimcnt++};if(tmp.charAt(pos)=="}"){delimcnt--};if(delimcnt==1&&capstart<0){capstart=pos+1};if(delimcnt==0&&capstart>0){capend=pos-1;FIGcap=tmp.substring(capstart,pos);break}}}
+var FIGtr2=document.createElement("tr");var FIGtd2=document.createElement("td");FIGtd2.className="caption";var FIGanchor=document.createElement("a");FIGanchor.className="figure";if(FIGlbl!=null){FIGanchor.id=FIGlbl[1];}
+LaTeXCounter["figure"]++;var fignmbr=makeNumberString(LaTeXCounter["figure"]);var anchorSpan=document.createElement("span");anchorSpan.className="figure";anchorSpan.style.display="none";anchorSpan.appendChild(document.createTextNode(fignmbr));FIGanchor.appendChild(anchorSpan);FIGtd2.appendChild(FIGanchor);var FIGspan=document.createElement("span");FIGspan.className="figure";FIGspan.appendChild(document.createTextNode("Figure "+fignmbr+". "));FIGtd2.appendChild(FIGspan);FIGtd2.appendChild(document.createTextNode(""+FIGcap));FIGtr2.appendChild(FIGtd2);FIGtbody.appendChild(FIGtr2);var IsSpecial=false;var FIGinfo=strtmparray[1].match(/\\includegraphics\s*\{([^\}]+)\}/);if(FIGinfo==null){FIGinfo=strtmparray[1].match(/\\includegraphics\s*\[[^\]]*\]\s*\{\s*([^\}]+)\s*\}/);}
+if(FIGinfo==null){FIGinfo=strtmparray[1].match(/\\special\s*\{\s*([^\}]+)\}/);IsSpecial=true};if(FIGinfo!=null){var FIGtr1=document.createElement("tr");var FIGtd1=document.createElement("td");FIGtd1.className="image";var FIGimg=document.createElement("img");var FIGsrc=FIGinfo[1];FIGimg.src=FIGsrc;FIGimg.alt="Figure "+FIGsrc+" did not load";FIGimg.title="Figure "+fignmbr+". "+FIGcap;FIGimg.id="figure"+fignmbr;FIGtd1.appendChild(FIGimg);FIGtr1.appendChild(FIGtd1);FIGtbody.appendChild(FIGtr1);}
+nodeTmp.appendChild(FIGtbody);newFrag.appendChild(nodeTmp);break;case"table":var nodeTmp=document.createElement("table");if(strtmparray[1].search(/\\centering/)>=0){nodeTmp.className='LaTeXtable centered';nodeTmp.align="center";}else{nodeTmp.className='LaTeXtable';};tableid++;nodeTmp.id="LaTeXtable"+tableid;var TABlbl=strtmparray[1].match(/\\label\s*\{\s*(\w+)\s*\}/);strtmparray[1]=strtmparray[1].replace(/\\label\s*\{\w+\}/g,"");var capIndex=strtmparray[1].search(/\\caption\s*\{[\s\S]+\}/);var TABcap="";if(capIndex>=0){var tmp=strtmparray[1];var delimcnt=0;var capstart=-1;for(var pos=capIndex;pos<tmp.length;pos++){if(tmp.charAt(pos)=="{"){delimcnt++};if(tmp.charAt(pos)=="}"){delimcnt--};if(delimcnt==1&&capstart<0){capstart=pos+1};if(delimcnt==0&&capstart>0){capend=pos-1;TABcap=tmp.substring(capstart,pos);break}}}
+if(TABcap!=""){var TABtbody=document.createElement("tbody");var TABcaption=document.createElement("caption");TABcaption.className="LaTeXtable centered";var TABanchor=document.createElement("a");TABanchor.className="LaTeXtable";if(TABlbl!=null){TABanchor.id=TABlbl[1];}
+LaTeXCounter["table"]++;var tabnmbr=makeNumberString(LaTeXCounter["table"]);var anchorSpan=document.createElement("span");anchorSpan.className="LaTeXtable";anchorSpan.style.display="none";anchorSpan.appendChild(document.createTextNode(tabnmbr));TABanchor.appendChild(anchorSpan);TABcaption.appendChild(TABanchor);var TABspan=document.createElement("span");TABspan.className="LaTeXtable";TABspan.appendChild(document.createTextNode("Table "+tabnmbr+". "));TABcaption.appendChild(TABspan);TABcaption.appendChild(document.createTextNode(""+TABcap));nodeTmp.appendChild(TABcaption);}
+var TABinfo=strtmparray[1].match(/\\begin\s*\{\s*tabular\s*\}([\s\S]+)\\end\s*\{\s*tabular\s*\}/);if(TABinfo!=null){var TABtbody=document.createElement('tbody');var TABrow=null;var TABcell=null;var row=0;var col=0;var TABalign=TABinfo[1].match(/^\s*\{([^\}]+)\}/);TABinfo=TABinfo[1].replace(/^\s*\{[^\}]+\}/,"");TABinfo=TABinfo.replace(/\\hline/g,"");TABalign[1]=TABalign[1].replace(/\|/g,"");TABalign[1]=TABalign[1].replace(/\s/g,"");TABinfo=TABinfo.split("\\\\");for(row=0;row<TABinfo.length;row++){TABrow=document.createElement("tr");TABinfo[row]=TABinfo[row].split("&");for(col=0;col<TABinfo[row].length;col++){TABcell=document.createElement("td");switch(TABalign[1].charAt(col)){case"l":TABcell.align="left";break;case"c":TABcell.align="center";break;case"r":TABcell.align="right";break;default:TABcell.align="left";};TABcell.appendChild(document.createTextNode(TABinfo[row][col]));TABrow.appendChild(TABcell);}
+TABtbody.appendChild(TABrow);}
+nodeTmp.appendChild(TABtbody);}
+newFrag.appendChild(nodeTmp);break;case"logicalbreak":var nodeTmp=document.createElement("p");nodeTmp.className=strtmparray[1];nodeTmp.appendChild(document.createTextNode("\u00A0"));newFrag.appendChild(nodeTmp);break;case"appendix":inAppendix=true;sectionCntr=0;break;case"alistitem":var EndDiv=document.createElement("div");EndDiv.className="endlistitem";newFrag.appendChild(EndDiv);var BegDiv=document.createElement("div");BegDiv.className="listitem";if(strtmparray[1]!=" "){var BegSpan=document.createElement("span");BegSpan.className="listitemmarker";var boldBegSpan=document.createElement("b");boldBegSpan.appendChild(document.createTextNode(strtmparray[1]+" "));BegSpan.appendChild(boldBegSpan);BegDiv.appendChild(BegSpan);}
+newFrag.appendChild(BegDiv);break;case"br":newFrag.appendChild(document.createElement("br"));break;case"bibitem":newFrag.appendChild(document.createElement("br"));var nodeTmp=document.createElement("a");nodeTmp.className='bibitem';var nodeSpan=document.createElement("span");nodeSpan.className='bibitem';bibcntr++;var lbl=strtmparray[1].match(/\{\s*(\w+)\s*\}/);strtmparray[1]=strtmparray[1].replace(/\s*\{\s*\w+\s*\}/g,"");strtmparray[1]=strtmparray[1].replace(/^\s*\[/,"");strtmparray[1]=strtmparray[1].replace(/\s*\]$/,"");strtmparray[1]=strtmparray[1].replace(/^\s+|\s+$/g,"");if(lbl==null){biblist[bibcntr]="bibitem"+bibcntr}else{biblist[bibcntr]=lbl[1];};nodeTmp.name=biblist[bibcntr];nodeTmp.id=biblist[bibcntr];if(strtmparray[1]!=""){nodeSpan.appendChild(document.createTextNode(strtmparray[1]));}else{nodeSpan.appendChild(document.createTextNode("["+bibcntr+"]"));}
+nodeTmp.appendChild(nodeSpan);newFrag.appendChild(nodeTmp);break;case"cite":var nodeTmp=document.createElement("a");nodeTmp.className='cite';nodeTmp.name='cite';nodeTmp.href="#"+strtmparray[1];newFrag.appendChild(nodeTmp);break;case"ref":var nodeTmp=document.createElement("a");nodeTmp.className='ref';nodeTmp.name='ref';nodeTmp.href="#"+strtmparray[1];newFrag.appendChild(nodeTmp);break;default:var nodeTmp=document.createElement("div");nodeTmp.className=strtmparray[0];if(IsCounter.test(strtmparray[0])){LaTeXCounter[strtmparray[0]]++;var nodeAnchor=document.createElement("a");nodeAnchor.className=strtmparray[0];var divnum=makeNumberString(LaTeXCounter[strtmparray[0]]);var anchorSpan=document.createElement("span");anchorSpan.className=strtmparray[0];anchorSpan.appendChild(document.createTextNode(divnum));anchorSpan.style.display="none";nodeAnchor.appendChild(anchorSpan);nodeTmp.appendChild(nodeAnchor);var nodeSpan=document.createElement("span");nodeSpan.className=strtmparray[0];nodeSpan.appendChild(document.createTextNode(strtmparray[1]+" "+divnum+". "));nodeTmp.appendChild(nodeSpan);}
+if(isIE){if(strtmparray[0]==("thebibliography"||"abstract"||"keyword"||"proof")){var nodeSpan=document.createElement("span");nodeSpan.className=strtmparray[0];nodeSpan.appendChild(document.createTextNode(strtmparray[1]));nodeTmp.appendChild(nodeSpan);}}
+if(strtmparray[0]=="endenumerate"||strtmparray[0]=="enditemize"||strtmparray[0]=="enddescription"){var endDiv=document.createElement("div");endDiv.className="endlistitem";newFrag.appendChild(endDiv);}
+newFrag.appendChild(nodeTmp);if(strtmparray[0]=="enumerate"||strtmparray[0]=="itemize"||strtmparray[0]=="description"){var endDiv=document.createElement("div");endDiv.className="listitem";newFrag.appendChild(endDiv);}}}else{strtmp[j]=strtmp[j].replace(/\\\$/g,"<per>");strtmp[j]=strtmp[j].replace(/\$([^\$]+)\$/g," \\[$1\\[ ");strtmp[j]=strtmp[j].replace(/<per>/g,"\\$");strtmp[j]=strtmp[j].replace(/\\begin\s*\{\s*math\s*\}([\s\S]+?)\\end\s*\{\s*math\s*\}/g," \\[$1\\[ ");var strtmptmp=strtmp[j].split("\\[");for(var jjj=0;jjj<strtmptmp.length;jjj++){if(jjj%2){var nodeTmp=document.createElement("span");nodeTmp.className='inlinemath';nodeTmp.appendChild(document.createTextNode("$"+strtmptmp[jjj]+"$"));newFrag.appendChild(nodeTmp);}else{var TagIndex=strtmptmp[jjj].search(/\\\w+/);var tmpIndex=TagIndex;while(tmpIndex>-1){if(/^\\textcolor/.test(strtmptmp[jjj].substring(TagIndex,strtmptmp[jjj].length))){strtmptmp[jjj]=strtmptmp[jjj].replace(/\\textcolor\s*\{\s*(\w+)\s*\}\s*/," \\[textcolor\\]$1\\]|");}else{if(/^\\colorbox/.test(strtmptmp[jjj].substring(TagIndex,strtmptmp[jjj].length))){strtmptmp[jjj]=strtmptmp[jjj].replace(/\\colorbox\s*\{\s*(\w+)\s*\}\s*/," \\[colorbox\\]$1\\]|");}else{strtmptmp[jjj]=strtmptmp[jjj].substring(0,TagIndex)+strtmptmp[jjj].substring(TagIndex,strtmptmp[jjj].length).replace(/\\\s*(\w+)\s*/," \\[$1\\]|");}}
+TagIndex+=strtmptmp[jjj].substring(TagIndex,strtmptmp[jjj].length).search(/\|/);TagIndex++;strtmptmp[jjj]=strtmptmp[jjj].replace(/\\\]\|/,"\\] ");if(strtmptmp[jjj].charAt(TagIndex)=="{"){strtmptmp[jjj]=strtmptmp[jjj].substring(0,TagIndex)+strtmptmp[jjj].substring(TagIndex+1,strtmptmp[jjj].length);var delimcnt=1;for(var kk=TagIndex;kk<strtmptmp[jjj].length;kk++){if(strtmptmp[jjj].charAt(kk)=="{"){delimcnt++};if(strtmptmp[jjj].charAt(kk)=="}"){delimcnt--};if(delimcnt==0){break;}}
+strtmptmp[jjj]=strtmptmp[jjj].substring(0,kk)+"\\[ "+strtmptmp[jjj].substring(kk+1,strtmptmp[jjj].length);TagIndex=kk+3;}else{strtmptmp[jjj]=strtmptmp[jjj].substring(0,TagIndex)+"\\[ "+strtmptmp[jjj].substring(TagIndex+1,strtmptmp[jjj].length);TagIndex=TagIndex+3;}
+if(TagIndex<strtmptmp[jjj].length){tmpIndex=strtmptmp[jjj].substring(TagIndex,strtmptmp[jjj].length).search(/\\\w+/);}
+else{tmpIndex=-1};TagIndex+=tmpIndex;}
+strtmptmp[jjj]=strtmptmp[jjj].replace(/\\\\\s*\\\\/g,"\\\\");strtmptmp[jjj]=strtmptmp[jjj].replace(/\\\\/g," \\[br\\] \\[ ");strtmptmp[jjj]=strtmptmp[jjj].replace(/\\label\s*\{\s*(\w+)\s*\}/g," \\[a\\]$1\\[ ");var strlbls=strtmptmp[jjj].split("\\[");for(var jj=0;jj<strlbls.length;jj++){if(jj%2){var strtmparray=strlbls[jj].split("\\]");switch(strtmparray[0]){case"textcolor":var nodeTmp=document.createElement("span");nodeTmp.className='LaTeXColor';if(IsColorName.test(strtmparray[1].toLowerCase())){nodeTmp.style.color=LaTeXColor[strtmparray[1].toLowerCase()];}else{nodeTmp.style.color=strtmparray[1];};nodeTmp.appendChild(document.createTextNode(strtmparray[2]));newFrag.appendChild(nodeTmp);break;case"colorbox":var nodeTmp=document.createElement("span");nodeTmp.className='LaTeXColor';if(IsColorName.test(strtmparray[1].toLowerCase())){nodeTmp.style.background=LaTeXColor[strtmparray[1].toLowerCase()];}else{nodeTmp.style.background=strtmparray[1];};nodeTmp.appendChild(document.createTextNode(strtmparray[2]));newFrag.appendChild(nodeTmp);break;case"br":newFrag.appendChild(document.createElement("br"));break;case"a":var nodeTmp=document.createElement("a");nodeTmp.className='LaTeXMathMLlabel';nodeTmp.id=strtmparray[1];nodeTmp.style.display="none";newFrag.appendChild(nodeTmp);break;default:var nodeTmp=document.createElement("span");nodeTmp.className=strtmparray[0];nodeTmp.appendChild(document.createTextNode(strtmparray[1]))
+newFrag.appendChild(nodeTmp);}}else{newFrag.appendChild(document.createTextNode(strlbls[jj]));}}}}}}}};TheBody.parentNode.replaceChild(newFrag,TheBody);}}}
+return TheBody;}
+function LaTeXDivsAndRefs(thebody){var TheBody=thebody;var EndDivClass=null;var AllDivs=TheBody.getElementsByTagName("div");var lbl2id="";var lblnode=null;for(var i=AllDivs.length-1;i>=0;i--){EndDivClass=AllDivs[i].className.match(/end\w+/);if(EndDivClass!=null){EndDivClass=EndDivClass[0];var DivClass=EndDivClass.substring(3,EndDivClass.length);var EndDivNode=AllDivs[i];break;}}
+while(EndDivClass!=null){var newFrag=document.createDocumentFragment();var RootNode=EndDivNode.parentNode;var ClassCount=1;while(EndDivNode.previousSibling!=null&&ClassCount>0){switch(EndDivNode.previousSibling.className){case EndDivClass:ClassCount++;newFrag.insertBefore(EndDivNode.previousSibling,newFrag.firstChild);break;case DivClass:if(EndDivNode.previousSibling.nodeName=="DIV"){ClassCount--;if(lbl2id!=""){EndDivNode.previousSibling.id=lbl2id;lbl2id=""}
+if(ClassCount==0){RootNode=EndDivNode.previousSibling;}else{newFrag.insertBefore(EndDivNode.previousSibling,newFrag.firstChild);}};break;case'LaTeXMathMLlabel':lbl2id=EndDivNode.previousSibling.id;EndDivNode.parentNode.removeChild(EndDivNode.previousSibling);break;default:newFrag.insertBefore(EndDivNode.previousSibling,newFrag.firstChild);}}
+RootNode.appendChild(newFrag);EndDivNode.parentNode.removeChild(EndDivNode);AllDivs=TheBody.getElementsByTagName("DIV");for(i=AllDivs.length-1;i>=0;i--){EndDivClass=AllDivs[i].className.match(/end\w+/);if(EndDivClass!=null){ClassCount=0;EndDivClass=EndDivClass[0];DivClass=EndDivClass.substring(3,EndDivClass.length);EndDivNode=AllDivs[i];RootNode=EndDivNode.parentNode;break;}}}
+var AllDivs=TheBody.getElementsByTagName("div");var DIV2LI=null;for(var i=0;i<AllDivs.length;i++){if(AllDivs[i].className=="itemize"||AllDivs[i].className=="enumerate"||AllDivs[i].className=="description"){if(AllDivs[i].className=="itemize"){RootNode=document.createElement("UL");}else{RootNode=document.createElement("OL");}
+RootNode.className='LaTeXMathML';if(AllDivs[i].hasChildNodes()){AllDivs[i].removeChild(AllDivs[i].firstChild)};while(AllDivs[i].hasChildNodes()){if(AllDivs[i].firstChild.hasChildNodes()){DIV2LI=document.createElement("LI");while(AllDivs[i].firstChild.hasChildNodes()){DIV2LI.appendChild(AllDivs[i].firstChild.firstChild);}
+if(DIV2LI.firstChild.className=="listitemmarker"){DIV2LI.style.listStyleType="none";}
+RootNode.appendChild(DIV2LI)}
+AllDivs[i].removeChild(AllDivs[i].firstChild);}
+AllDivs[i].appendChild(RootNode);}}
+var AllAnchors=TheBody.getElementsByTagName("a");for(var i=0;i<AllAnchors.length;i++){if(AllAnchors[i].className=="ref"||AllAnchors[i].className=="cite"){var label=AllAnchors[i].href.match(/\#(\w+)/);if(label!=null){var labelNode=document.getElementById(label[1]);if(labelNode!=null){var TheSpans=labelNode.getElementsByTagName("SPAN");if(TheSpans!=null){var refNode=TheSpans[0].cloneNode(true);refNode.style.display="inline"
+refNode.className=AllAnchors[i].className;AllAnchors[i].appendChild(refNode);}}}}}
+return TheBody;}
+var AMbody;var AMnoMathML=false,AMtranslated=false;function translate(spanclassAM){if(!AMtranslated){AMtranslated=true;AMinitSymbols();var LaTeXContainers=[];var AllContainers=document.getElementsByTagName('*');var ExtendName="";for(var k=0,l=0;k<AllContainers.length;k++){ExtendName=" "+AllContainers[k].className+" ";if(ExtendName.match(/\sLaTeX\s/)!=null){LaTeXContainers[l]=AllContainers[k];l++;}};if(LaTeXContainers.length>0){for(var m=0;m<LaTeXContainers.length;m++){AMbody=LaTeXContainers[m];try{AMbody=LaTeXDivsAndRefs(LaTeXpreProcess(AMbody));}catch(err){alert("Unknown Error: Defaulting to Original LaTeXMathML");}
+if(AMbody.tagName=="PRE"){var PreChilds=document.createDocumentFragment();var DivChilds=document.createElement("DIV");while(AMbody.hasChildNodes()){DivChilds.appendChild(AMbody.firstChild);}
+PreChilds.appendChild(DivChilds);AMbody.parentNode.replaceChild(PreChilds,AMbody);AMbody=DivChilds;}
+AMprocessNode(AMbody,false,spanclassAM);}}else{AMbody=document.getElementsByTagName("body")[0];try{AMbody=LaTeXDivsAndRefs(LaTeXpreProcess(AMbody));}catch(err){alert("Unknown Error: Defaulting to Original LaTeXMathML");}
+AMprocessNode(AMbody,false,spanclassAM);}}}
+if(isIE){document.write("<object id=\"mathplayer\" classid=\"clsid:32F66A20-7614-11D4-BD11-00104BD3F987\"></object>");document.write("<?import namespace=\"m\" implementation=\"#mathplayer\"?>");}
+function generic()
+{translate();};if(typeof window.addEventListener!='undefined')
+{window.addEventListener('load',generic,false);}
+else if(typeof document.addEventListener!='undefined')
+{document.addEventListener('load',generic,false);}
+else if(typeof window.attachEvent!='undefined')
+{window.attachEvent('onload',generic);}
+else
+{if(typeof window.onload=='function')
+{var existing=onload;window.onload=function()
+{existing();generic();};}
+else
+{window.onload=generic;}}
diff --git a/data/bash_completion.tpl b/data/bash_completion.tpl
new file mode 100644
index 000000000..317fd5095
--- /dev/null
+++ b/data/bash_completion.tpl
@@ -0,0 +1,78 @@
+# This script enables bash autocompletion for pandoc. To enable
+# bash completion, add this to your .bashrc:
+# eval "$(pandoc --bash-completion)"
+
+_pandoc()
+{
+ local cur prev opts lastc informats outformats datadir
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+ # These should be filled in by pandoc:
+ opts="%s"
+ informats="%s"
+ outformats="%s"
+ highlight_styles="%s"
+ datadir="%s"
+
+ case "${prev}" in
+ --from|-f|--read|-r)
+ COMPREPLY=( $(compgen -W "${informats}" -- ${cur}) )
+ return 0
+ ;;
+ --to|-t|--write|-w|-D|--print-default-template)
+ COMPREPLY=( $(compgen -W "${outformats}" -- ${cur}) )
+ return 0
+ ;;
+ --email-obfuscation)
+ COMPREPLY=( $(compgen -W "references javascript none" -- ${cur}) )
+ return 0
+ ;;
+ --latex-engine)
+ COMPREPLY=( $(compgen -W "pdflatex lualatex xelatex" -- ${cur}) )
+ return 0
+ ;;
+ --print-default-data-file)
+ COMPREPLY=( $(compgen -W "reference.odt reference.docx $(find ${datadir} | sed -e 's/.*\/data\///')" -- ${cur}) )
+ return 0
+ ;;
+ --wrap)
+ COMPREPLY=( $(compgen -W "auto none preserve" -- ${cur}) )
+ return 0
+ ;;
+ --track-changes)
+ COMPREPLY=( $(compgen -W "accept reject all" -- ${cur}) )
+ return 0
+ ;;
+ --reference-location)
+ COMPREPLY=( $(compgen -W "block section document" -- ${cur}) )
+ return 0
+ ;;
+ --top-level-division)
+ COMPREPLY=( $(compgen -W "section chapter part" -- ${cur}) )
+ return 0
+ ;;
+ --highlight-style)
+ COMPREPLY=( $(compgen -W "${highlight_styles}" -- ${cur}) )
+ return 0
+ ;;
+ *)
+ ;;
+ esac
+
+ case "${cur}" in
+ -*)
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+ *)
+ local IFS=$'\n'
+ COMPREPLY=( $(compgen -X '' -f "${cur}") )
+ return 0
+ ;;
+ esac
+
+}
+
+complete -o filenames -o bashdefault -F _pandoc pandoc
diff --git a/data/docx/[Content_Types].xml b/data/docx/[Content_Types].xml
new file mode 100644
index 000000000..9c5756aed
--- /dev/null
+++ b/data/docx/[Content_Types].xml
@@ -0,0 +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/footnotes.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" /></Types>
diff --git a/data/docx/_rels/.rels b/data/docx/_rels/.rels
new file mode 100644
index 000000000..44e5daa3d
--- /dev/null
+++ b/data/docx/_rels/.rels
@@ -0,0 +1,2 @@
+<?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> \ No newline at end of file
diff --git a/data/docx/docProps/app.xml b/data/docx/docProps/app.xml
new file mode 100644
index 000000000..1764f14d7
--- /dev/null
+++ b/data/docx/docProps/app.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
+ <Words>83</Words>
+ <SharedDoc>false</SharedDoc>
+ <HyperlinksChanged>false</HyperlinksChanged>
+ <Lines>12</Lines>
+ <AppVersion>12.0000</AppVersion>
+ <LinksUpToDate>false</LinksUpToDate>
+ <Application>Microsoft Word 12.0.0</Application>
+ <CharactersWithSpaces>583</CharactersWithSpaces>
+ <Template>Normal.dotm</Template>
+ <DocSecurity>0</DocSecurity>
+ <TotalTime>6</TotalTime>
+ <ScaleCrop>false</ScaleCrop>
+ <Characters>475</Characters>
+ <Paragraphs>8</Paragraphs>
+ <Pages>1</Pages>
+</Properties> \ No newline at end of file
diff --git a/data/docx/docProps/core.xml b/data/docx/docProps/core.xml
new file mode 100644
index 000000000..2274766e4
--- /dev/null
+++ b/data/docx/docProps/core.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:title></dc:title><dc:creator></dc:creator></cp:coreProperties> \ No newline at end of file
diff --git a/data/docx/word/_rels/document.xml.rels b/data/docx/word/_rels/document.xml.rels
new file mode 100644
index 000000000..ca0c57b63
--- /dev/null
+++ b/data/docx/word/_rels/document.xml.rels
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" Id="rId1" Target="numbering.xml" /><Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Id="rId2" Target="styles.xml" /><Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Id="rId3" Target="settings.xml" /><Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" Id="rId4" Target="webSettings.xml" /><Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Id="rId5" Target="fontTable.xml" /><Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Id="rId6" Target="theme/theme1.xml" /><Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes" Id="rId7" Target="footnotes.xml" /></Relationships>
diff --git a/data/docx/word/_rels/footnotes.xml.rels b/data/docx/word/_rels/footnotes.xml.rels
new file mode 100644
index 000000000..be7e70853
--- /dev/null
+++ b/data/docx/word/_rels/footnotes.xml.rels
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships" /> \ No newline at end of file
diff --git a/data/docx/word/document.xml b/data/docx/word/document.xml
new file mode 100644
index 000000000..7199034da
--- /dev/null
+++ b/data/docx/word/document.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"><w:body><w:p><w:r><w:t xml:space="preserve">Hello world.</w:t></w:r></w:p></w:body></w:document>
diff --git a/data/docx/word/fontTable.xml b/data/docx/word/fontTable.xml
new file mode 100644
index 000000000..fce61de9c
--- /dev/null
+++ b/data/docx/word/fontTable.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<w:fonts xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
+&#9;<w:font w:name="Symbol">
+&#9;&#9;<w:panose1 w:val="02000500000000000000" />
+&#9;&#9;<w:charset w:val="02" />
+&#9;&#9;<w:family w:val="auto" />
+&#9;&#9;<w:pitch w:val="variable" />
+&#9;&#9;<w:sig w:usb0="00000000" w:usb1="00000000" w:usb2="00010000" w:usb3="00000000" w:csb0="80000000" w:csb1="00000000" />
+&#9;</w:font>
+&#9;<w:font w:name="Times New Roman">
+&#9;&#9;<w:panose1 w:val="02020603050405020304" />
+&#9;&#9;<w:charset w:val="00" />
+&#9;&#9;<w:family w:val="auto" />
+&#9;&#9;<w:pitch w:val="variable" />
+&#9;&#9;<w:sig w:usb0="00000003" w:usb1="00000000" w:usb2="00000000" w:usb3="00000000" w:csb0="00000001" w:csb1="00000000" />
+&#9;</w:font>
+&#9;<w:font w:name="Courier New">
+&#9;&#9;<w:panose1 w:val="02070309020205020404" />
+&#9;&#9;<w:charset w:val="00" />
+&#9;&#9;<w:family w:val="auto" />
+&#9;&#9;<w:pitch w:val="variable" />
+&#9;&#9;<w:sig w:usb0="00000003" w:usb1="00000000" w:usb2="00000000" w:usb3="00000000" w:csb0="00000001" w:csb1="00000000" />
+&#9;</w:font>
+&#9;<w:font w:name="Wingdings">
+&#9;&#9;<w:panose1 w:val="05020102010804080708" />
+&#9;&#9;<w:charset w:val="02" />
+&#9;&#9;<w:family w:val="auto" />
+&#9;&#9;<w:pitch w:val="variable" />
+&#9;&#9;<w:sig w:usb0="00000000" w:usb1="00000000" w:usb2="00010000" w:usb3="00000000" w:csb0="80000000" w:csb1="00000000" />
+&#9;</w:font>
+&#9;<w:font w:name="Cambria">
+&#9;&#9;<w:panose1 w:val="02040503050406030204" />
+&#9;&#9;<w:charset w:val="00" />
+&#9;&#9;<w:family w:val="auto" />
+&#9;&#9;<w:pitch w:val="variable" />
+&#9;&#9;<w:sig w:usb0="00000003" w:usb1="00000000" w:usb2="00000000" w:usb3="00000000" w:csb0="00000001" w:csb1="00000000" />
+&#9;</w:font>
+&#9;<w:font w:name="Calibri">
+&#9;&#9;<w:panose1 w:val="020F0502020204030204" />
+&#9;&#9;<w:charset w:val="00" />
+&#9;&#9;<w:family w:val="auto" />
+&#9;&#9;<w:pitch w:val="variable" />
+&#9;&#9;<w:sig w:usb0="00000003" w:usb1="00000000" w:usb2="00000000" w:usb3="00000000" w:csb0="00000001" w:csb1="00000000" />
+&#9;</w:font>
+&#9;<w:font w:name="Arial">
+&#9;&#9;<w:panose1 w:val="020B0604020202020204" />
+&#9;&#9;<w:charset w:val="00" />
+&#9;&#9;<w:family w:val="auto" />
+&#9;&#9;<w:pitch w:val="variable" />
+&#9;&#9;<w:sig w:usb0="00000003" w:usb1="00000000" w:usb2="00000000" w:usb3="00000000" w:csb0="00000001" w:csb1="00000000" />
+&#9;</w:font>
+</w:fonts> \ No newline at end of file
diff --git a/data/docx/word/footnotes.xml b/data/docx/word/footnotes.xml
new file mode 100644
index 000000000..db82d9462
--- /dev/null
+++ b/data/docx/word/footnotes.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<w:footnotes xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
+xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
+xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
+xmlns:o="urn:schemas-microsoft-com:office:office"
+xmlns:v="urn:schemas-microsoft-com:vml"
+xmlns:w10="urn:schemas-microsoft-com:office:word"
+xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
+xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"
+xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing">
+
+ <w:footnote w:type="continuationSeparator" w:id="0">
+ <w:p>
+ <w:r>
+ <w:continuationSeparator />
+ </w:r>
+ </w:p>
+ </w:footnote>
+ <w:footnote w:type="separator" w:id="-1">
+ <w:p>
+ <w:r>
+ <w:separator />
+ </w:r>
+ </w:p>
+ </w:footnote>
+</w:footnotes>
diff --git a/data/docx/word/numbering.xml b/data/docx/word/numbering.xml
new file mode 100644
index 000000000..b9e91371b
--- /dev/null
+++ b/data/docx/word/numbering.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<w:numbering xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:abstractNum w:abstractNumId="0"><w:nsid w:val="e17f69ba" /><w:multiLevelType w:val="multilevel" /><w:lvl w:ilvl="0"><w:numFmt w:val="bullet" /><w:lvlText w:val=" " /><w:lvlJc w:val="left" /><w:pPr><w:tabs><w:tab w:val="num" w:pos="0" /></w:tabs><w:ind w:left="480" w:hanging="480" /></w:pPr></w:lvl><w:lvl w:ilvl="1"><w:numFmt w:val="bullet" /><w:lvlText w:val=" " /><w:lvlJc w:val="left" /><w:pPr><w:tabs><w:tab w:val="num" w:pos="720" /></w:tabs><w:ind w:left="1200" w:hanging="480" /></w:pPr></w:lvl><w:lvl w:ilvl="2"><w:numFmt w:val="bullet" /><w:lvlText w:val=" " /><w:lvlJc w:val="left" /><w:pPr><w:tabs><w:tab w:val="num" w:pos="1440" /></w:tabs><w:ind w:left="1920" w:hanging="480" /></w:pPr></w:lvl><w:lvl w:ilvl="3"><w:numFmt w:val="bullet" /><w:lvlText w:val=" " /><w:lvlJc w:val="left" /><w:pPr><w:tabs><w:tab w:val="num" w:pos="2160" /></w:tabs><w:ind w:left="2640" w:hanging="480" /></w:pPr></w:lvl><w:lvl w:ilvl="4"><w:numFmt w:val="bullet" /><w:lvlText w:val=" " /><w:lvlJc w:val="left" /><w:pPr><w:tabs><w:tab w:val="num" w:pos="2880" /></w:tabs><w:ind w:left="3360" w:hanging="480" /></w:pPr></w:lvl><w:lvl w:ilvl="5"><w:numFmt w:val="bullet" /><w:lvlText w:val=" " /><w:lvlJc w:val="left" /><w:pPr><w:tabs><w:tab w:val="num" w:pos="3600" /></w:tabs><w:ind w:left="4080" w:hanging="480" /></w:pPr></w:lvl><w:lvl w:ilvl="6"><w:numFmt w:val="bullet" /><w:lvlText w:val=" " /><w:lvlJc w:val="left" /><w:pPr><w:tabs><w:tab w:val="num" w:pos="4320" /></w:tabs><w:ind w:left="4800" w:hanging="480" /></w:pPr></w:lvl></w:abstractNum><w:num w:numId="1"><w:abstractNumId w:val="0" /></w:num></w:numbering> \ No newline at end of file
diff --git a/data/docx/word/settings.xml b/data/docx/word/settings.xml
new file mode 100644
index 000000000..425e6f7b5
--- /dev/null
+++ b/data/docx/word/settings.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<w:settings xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:sl="http://schemas.openxmlformats.org/schemaLibrary/2006/main">
+ <w:zoom w:percent="90" />
+ <w:embedSystemFonts />
+ <w:proofState w:spelling="clean" w:grammar="clean" />
+ <w:stylePaneFormatFilter w:val="0004" />
+ <w:footnotePr>
+ <w:footnote w:id="-1" />
+ <w:footnote w:id="0" />
+ </w:footnotePr>
+ <w:doNotTrackMoves />
+ <w:defaultTabStop w:val="720" />
+ <w:drawingGridHorizontalSpacing w:val="360" />
+ <w:drawingGridVerticalSpacing w:val="360" />
+ <w:displayHorizontalDrawingGridEvery w:val="0" />
+ <w:displayVerticalDrawingGridEvery w:val="0" />
+ <w:characterSpacingControl w:val="doNotCompress" />
+ <w:savePreviewPicture />
+ <w:rsids>
+ <w:rsidRoot w:val="00590D07" />
+ <w:rsid w:val="00011C8B" />
+ <w:rsid w:val="004E29B3" />
+ <w:rsid w:val="00590D07" />
+ <w:rsid w:val="00784D58" />
+ <w:rsid w:val="008D6863" />
+ <w:rsid w:val="00B86B75" />
+ <w:rsid w:val="00BC48D5" />
+ <w:rsid w:val="00C36279" />
+ <w:rsid w:val="00E315A3" />
+ </w:rsids>
+ <m:mathPr>
+ <m:mathFont m:val="Lucida Grande" />
+ <m:brkBin m:val="before" />
+ <m:brkBinSub m:val="--" />
+ <m:smallFrac m:val="false" />
+ <m:dispDef m:val="false" />
+ <m:lMargin m:val="0" />
+ <m:rMargin m:val="0" />
+ <m:wrapRight />
+ <m:intLim m:val="subSup" />
+ <m:naryLim m:val="subSup" />
+ </m:mathPr>
+ <w:themeFontLang w:val="en-US" />
+ <w:clrSchemeMapping w:bg1="light1" w:t1="dark1" w:bg2="light2" w:t2="dark2" w:accent1="accent1" w:accent2="accent2" w:accent3="accent3" w:accent4="accent4" w:accent5="accent5" w:accent6="accent6" w:hyperlink="hyperlink" w:followedHyperlink="followedHyperlink" />
+ <w:decimalSymbol w:val="." />
+ <w:listSeparator w:val="," />
+</w:settings>
diff --git a/data/docx/word/styles.xml b/data/docx/word/styles.xml
new file mode 100644
index 000000000..d19c4c7fb
--- /dev/null
+++ b/data/docx/word/styles.xml
@@ -0,0 +1,396 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<w:styles xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
+ <w:docDefaults>
+ <w:rPrDefault>
+ <w:rPr>
+ <w:rFonts w:asciiTheme="minorHAnsi" w:eastAsiaTheme="minorHAnsi" w:hAnsiTheme="minorHAnsi" w:cstheme="minorBidi" />
+ <w:sz w:val="24" />
+ <w:szCs w:val="24" />
+ <w:lang w:val="en-US" w:eastAsia="en-US" w:bidi="ar-SA" />
+ </w:rPr>
+ </w:rPrDefault>
+ <w:pPrDefault>
+ <w:pPr>
+ <w:spacing w:after="200" />
+ </w:pPr>
+ </w:pPrDefault>
+ </w:docDefaults>
+ <w:latentStyles w:defLockedState="0" w:defUIPriority="0" w:defSemiHidden="0" w:defUnhideWhenUsed="0" w:defQFormat="0" w:count="276" />
+ <w:style w:type="paragraph" w:default="1" w:styleId="Normal">
+ <w:name w:val="Normal" />
+ <w:qFormat />
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="BodyText">
+ <w:name w:val="Body Text" />
+ <w:basedOn w:val="Normal" />
+ <w:link w:val="BodyTextChar" />
+ <w:pPr>
+ <w:spacing w:before="180" w:after="180" />
+ </w:pPr>
+ <w:qFormat />
+ </w:style>
+ <w:style w:type="paragraph" w:customStyle="1" w:styleId="FirstParagraph">
+ <w:name w:val="First Paragraph" />
+ <w:basedOn w:val="BodyText" />
+ <w:next w:val="BodyText" />
+ <w:qFormat />
+ </w:style>
+ <w:style w:type="paragraph" w:customStyle="1" w:styleId="Compact">
+ <w:name w:val="Compact" />
+ <w:basedOn w:val="BodyText" />
+ <w:qFormat />
+ <w:pPr>
+ <w:spacing w:before="36" w:after="36" />
+ </w:pPr>
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="Title">
+ <w:name w:val="Title" />
+ <w:basedOn w:val="Normal" />
+ <w:next w:val="BodyText" />
+ <w:qFormat />
+ <w:pPr>
+ <w:keepNext />
+ <w:keepLines />
+ <w:spacing w:before="480" w:after="240" />
+ <w:jc w:val="center" />
+ </w:pPr>
+ <w:rPr>
+ <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
+ <w:b />
+ <w:bCs />
+ <w:color w:val="345A8A" w:themeColor="accent1" w:themeShade="B5" />
+ <w:sz w:val="36" />
+ <w:szCs w:val="36" />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="Subtitle">
+ <w:name w:val="Subtitle" />
+ <w:basedOn w:val="Title" />
+ <w:next w:val="BodyText" />
+ <w:qFormat />
+ <w:pPr>
+ <w:keepNext />
+ <w:keepLines />
+ <w:spacing w:before="240" w:after="240" />
+ <w:jc w:val="center" />
+ </w:pPr>
+ <w:rPr>
+ <w:sz w:val="30" />
+ <w:szCs w:val="30" />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="paragraph" w:customStyle="1" w:styleId="Author">
+ <w:name w:val="Author" />
+ <w:next w:val="BodyText" />
+ <w:qFormat />
+ <w:pPr>
+ <w:keepNext />
+ <w:keepLines />
+ <w:jc w:val="center" />
+ </w:pPr>
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="Date">
+ <w:name w:val="Date" />
+ <w:next w:val="BodyText" />
+ <w:qFormat />
+ <w:pPr>
+ <w:keepNext />
+ <w:keepLines />
+ <w:jc w:val="center" />
+ </w:pPr>
+ </w:style>
+ <w:style w:type="paragraph" w:customStyle="1" w:styleId="Abstract">
+ <w:name w:val="Abstract" />
+ <w:basedOn w:val="Normal" />
+ <w:next w:val="BodyText" />
+ <w:qFormat />
+ <w:pPr>
+ <w:keepNext />
+ <w:keepLines />
+ <w:spacing w:before="300" w:after="300" />
+ </w:pPr>
+ <w:rPr>
+ <w:sz w:val="20" />
+ <w:szCs w:val="20" />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="Bibliography">
+ <w:name w:val="Bibliography" />
+ <w:basedOn w:val="Normal" />
+ <w:next w:val="Bibliography" />
+ <w:qFormat />
+ <w:pPr />
+ <w:rPr />
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="Heading1">
+ <w:name w:val="Heading 1" />
+ <w:basedOn w:val="Normal" />
+ <w:next w:val="BodyText" />
+ <w:uiPriority w:val="9" />
+ <w:qFormat />
+ <w:pPr>
+ <w:keepNext />
+ <w:keepLines />
+ <w:spacing w:before="480" w:after="0" />
+ <w:outlineLvl w:val="0" />
+ </w:pPr>
+ <w:rPr>
+ <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
+ <w:b />
+ <w:bCs />
+ <w:color w:val="345A8A" w:themeColor="accent1" w:themeShade="B5" />
+ <w:sz w:val="32" />
+ <w:szCs w:val="32" />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="Heading2">
+ <w:name w:val="Heading 2" />
+ <w:basedOn w:val="Normal" />
+ <w:next w:val="BodyText" />
+ <w:uiPriority w:val="9" />
+ <w:unhideWhenUsed />
+ <w:qFormat />
+ <w:pPr>
+ <w:keepNext />
+ <w:keepLines />
+ <w:spacing w:before="200" w:after="0" />
+ <w:outlineLvl w:val="1" />
+ </w:pPr>
+ <w:rPr>
+ <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
+ <w:b />
+ <w:bCs />
+ <w:color w:val="4F81BD" w:themeColor="accent1" />
+ <w:sz w:val="32" />
+ <w:szCs w:val="32" />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="Heading3">
+ <w:name w:val="Heading 3" />
+ <w:basedOn w:val="Normal" />
+ <w:next w:val="BodyText" />
+ <w:uiPriority w:val="9" />
+ <w:unhideWhenUsed />
+ <w:qFormat />
+ <w:pPr>
+ <w:keepNext />
+ <w:keepLines />
+ <w:spacing w:before="200" w:after="0" />
+ <w:outlineLvl w:val="2" />
+ </w:pPr>
+ <w:rPr>
+ <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
+ <w:b />
+ <w:bCs />
+ <w:color w:val="4F81BD" w:themeColor="accent1" />
+ <w:sz w:val="28" />
+ <w:szCs w:val="28" />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="Heading4">
+ <w:name w:val="Heading 4" />
+ <w:basedOn w:val="Normal" />
+ <w:next w:val="BodyText" />
+ <w:uiPriority w:val="9" />
+ <w:unhideWhenUsed />
+ <w:qFormat />
+ <w:pPr>
+ <w:keepNext />
+ <w:keepLines />
+ <w:spacing w:before="200" w:after="0" />
+ <w:outlineLvl w:val="3" />
+ </w:pPr>
+ <w:rPr>
+ <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
+ <w:b />
+ <w:bCs />
+ <w:color w:val="4F81BD" w:themeColor="accent1" />
+ <w:sz w:val="24" />
+ <w:szCs w:val="24" />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="Heading5">
+ <w:name w:val="Heading 5" />
+ <w:basedOn w:val="Normal" />
+ <w:next w:val="BodyText" />
+ <w:uiPriority w:val="9" />
+ <w:unhideWhenUsed />
+ <w:qFormat />
+ <w:pPr>
+ <w:keepNext />
+ <w:keepLines />
+ <w:spacing w:before="200" w:after="0" />
+ <w:outlineLvl w:val="4" />
+ </w:pPr>
+ <w:rPr>
+ <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
+ <w:i />
+ <w:iCs />
+ <w:color w:val="4F81BD" w:themeColor="accent1" />
+ <w:sz w:val="24" />
+ <w:szCs w:val="24" />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="Heading6">
+ <w:name w:val="Heading 6" />
+ <w:basedOn w:val="Normal" />
+ <w:next w:val="BodyText" />
+ <w:uiPriority w:val="9" />
+ <w:unhideWhenUsed />
+ <w:qFormat />
+ <w:pPr>
+ <w:keepNext />
+ <w:keepLines />
+ <w:spacing w:before="200" w:after="0" />
+ <w:outlineLvl w:val="5" />
+ </w:pPr>
+ <w:rPr>
+ <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
+ <w:color w:val="4F81BD" w:themeColor="accent1" />
+ <w:sz w:val="24" />
+ <w:szCs w:val="24" />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="BlockText">
+ <w:name w:val="Block Text" />
+ <w:basedOn w:val="BodyText" />
+ <w:next w:val="BodyText" />
+ <w:uiPriority w:val="9" />
+ <w:unhideWhenUsed />
+ <w:qFormat />
+ <w:pPr>
+ <w:spacing w:before="100" w:after="100" />
+ <w:ind w:firstLine="0" />
+ </w:pPr>
+ <w:rPr>
+ <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
+ <w:bCs />
+ <w:sz w:val="20" />
+ <w:szCs w:val="20" />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="FootnoteText">
+ <w:name w:val="Footnote Text" />
+ <w:basedOn w:val="Normal" />
+ <w:next w:val="FootnoteText" />
+ <w:uiPriority w:val="9" />
+ <w:unhideWhenUsed />
+ <w:qFormat />
+ </w:style>
+ <w:style w:type="character" w:default="1" w:styleId="DefaultParagraphFont">
+ <w:name w:val="Default Paragraph Font" />
+ <w:semiHidden />
+ <w:unhideWhenUsed />
+ </w:style>
+ <w:style w:type="table" w:default="1" w:styleId="TableNormal">
+ <w:name w:val="Normal Table" />
+ <w:semiHidden />
+ <w:unhideWhenUsed />
+ <w:qFormat />
+ <w:tblPr>
+ <w:tblInd w:w="0" w:type="dxa" />
+ <w:tblCellMar>
+ <w:top w:w="0" w:type="dxa" />
+ <w:left w:w="108" w:type="dxa" />
+ <w:bottom w:w="0" w:type="dxa" />
+ <w:right w:w="108" w:type="dxa" />
+ </w:tblCellMar>
+ </w:tblPr>
+ </w:style>
+ <w:style w:type="paragraph" w:customStyle="1" w:styleId="DefinitionTerm">
+ <w:name w:val="Definition Term" />
+ <w:basedOn w:val="Normal" />
+ <w:next w:val="Definition" />
+ <w:pPr>
+ <w:keepNext />
+ <w:keepLines />
+ <w:spacing w:after="0" />
+ </w:pPr>
+ <w:rPr>
+ <w:b />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="paragraph" w:customStyle="1" w:styleId="Definition">
+ <w:name w:val="Definition" />
+ <w:basedOn w:val="Normal" />
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="Caption">
+ <w:name w:val="Caption" />
+ <w:basedOn w:val="Normal" />
+ <w:link w:val="BodyTextChar" />
+ <w:pPr>
+ <w:spacing w:before="0" w:after="120" />
+ </w:pPr>
+ <w:rPr>
+ <w:i />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="paragraph" w:customStyle="1" w:styleId="TableCaption">
+ <w:name w:val="Table Caption" />
+ <w:basedOn w:val="Caption" />
+ <w:pPr>
+ <w:keepNext />
+ </w:pPr>
+ </w:style>
+ <w:style w:type="paragraph" w:customStyle="1" w:styleId="ImageCaption">
+ <w:name w:val="Image Caption" />
+ <w:basedOn w:val="Caption" />
+ </w:style>
+ <w:style w:type="paragraph" w:customStyle="1" w:styleId="Figure">
+ <w:name w:val="Figure" />
+ <w:basedOn w:val="Normal" />
+ </w:style>
+ <w:style w:type="paragraph" w:customStyle="1" w:styleId="FigureWithCaption">
+ <w:name w:val="Figure with Caption" />
+ <w:basedOn w:val="Figure" />
+ <w:pPr>
+ <w:keepNext />
+ </w:pPr>
+ </w:style>
+ <w:style w:type="character" w:customStyle="1" w:styleId="BodyTextChar">
+ <w:name w:val="Body Text Char" />
+ <w:basedOn w:val="DefaultParagraphFont" />
+ <w:link w:val="BodyText" />
+ </w:style>
+ <w:style w:type="character" w:customStyle="1" w:styleId="VerbatimChar">
+ <w:name w:val="Verbatim Char" />
+ <w:basedOn w:val="BodyTextChar" />
+ <w:rPr>
+ <w:rFonts w:ascii="Consolas" w:hAnsi="Consolas" />
+ <w:sz w:val="22" />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="character" w:styleId="FootnoteReference">
+ <w:name w:val="Footnote Reference" />
+ <w:basedOn w:val="BodyTextChar" />
+ <w:rPr>
+ <w:vertAlign w:val="superscript" />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="character" w:styleId="Hyperlink">
+ <w:name w:val="Hyperlink" />
+ <w:basedOn w:val="BodyTextChar" />
+ <w:rPr>
+ <w:color w:val="4F81BD" w:themeColor="accent1" />
+ </w:rPr>
+ </w:style>
+ <w:style w:type="paragraph" w:styleId="TOCHeading">
+ <w:name w:val="TOC Heading" />
+ <w:basedOn w:val="Heading1" />
+ <w:next w:val="BodyText" />
+ <w:uiPriority w:val="39" />
+ <w:unhideWhenUsed />
+ <w:qFormat />
+ <w:pPr>
+ <w:spacing w:before="240" w:line="259" w:lineRule="auto" />
+ <w:outlineLvl w:val="9" />
+ </w:pPr>
+ <w:rPr>
+ <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
+ <w:b w:val="0" />
+ <w:bCs w:val="0" />
+ <w:color w:val="365F91" w:themeColor="accent1"
+ w:themeShade="BF" />
+ </w:rPr>
+ </w:style>
+</w:styles>
diff --git a/data/docx/word/theme/theme1.xml b/data/docx/word/theme/theme1.xml
new file mode 100644
index 000000000..a6f7240c4
--- /dev/null
+++ b/data/docx/word/theme/theme1.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000" /></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF" /></a:lt1><a:dk2><a:srgbClr val="1F497D" /></a:dk2><a:lt2><a:srgbClr val="EEECE1" /></a:lt2><a:accent1><a:srgbClr val="4F81BD" /></a:accent1><a:accent2><a:srgbClr val="C0504D" /></a:accent2><a:accent3><a:srgbClr val="9BBB59" /></a:accent3><a:accent4><a:srgbClr val="8064A2" /></a:accent4><a:accent5><a:srgbClr val="4BACC6" /></a:accent5><a:accent6><a:srgbClr val="F79646" /></a:accent6><a:hlink><a:srgbClr val="0000FF" /></a:hlink><a:folHlink><a:srgbClr val="800080" /></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Calibri" /><a:ea typeface="" /><a:cs typeface="" /><a:font script="Jpan" typeface="MS ゴシック" /><a:font script="Hang" typeface="맑은 고딕" /><a:font script="Hans" typeface="宋体" /><a:font script="Hant" typeface="新細明體" /><a:font script="Arab" typeface="Times New Roman" /><a:font script="Hebr" typeface="Times New Roman" /><a:font script="Thai" typeface="Angsana New" /><a:font script="Ethi" typeface="Nyala" /><a:font script="Beng" typeface="Vrinda" /><a:font script="Gujr" typeface="Shruti" /><a:font script="Khmr" typeface="MoolBoran" /><a:font script="Knda" typeface="Tunga" /><a:font script="Guru" typeface="Raavi" /><a:font script="Cans" typeface="Euphemia" /><a:font script="Cher" typeface="Plantagenet Cherokee" /><a:font script="Yiii" typeface="Microsoft Yi Baiti" /><a:font script="Tibt" typeface="Microsoft Himalaya" /><a:font script="Thaa" typeface="MV Boli" /><a:font script="Deva" typeface="Mangal" /><a:font script="Telu" typeface="Gautami" /><a:font script="Taml" typeface="Latha" /><a:font script="Syrc" typeface="Estrangelo Edessa" /><a:font script="Orya" typeface="Kalinga" /><a:font script="Mlym" typeface="Kartika" /><a:font script="Laoo" typeface="DokChampa" /><a:font script="Sinh" typeface="Iskoola Pota" /><a:font script="Mong" typeface="Mongolian Baiti" /><a:font script="Viet" typeface="Times New Roman" /><a:font script="Uigh" typeface="Microsoft Uighur" /></a:majorFont><a:minorFont><a:latin typeface="Cambria" /><a:ea typeface="" /><a:cs typeface="" /><a:font script="Jpan" typeface="MS 明朝" /><a:font script="Hang" typeface="맑은 고딕" /><a:font script="Hans" typeface="宋体" /><a:font script="Hant" typeface="新細明體" /><a:font script="Arab" typeface="Arial" /><a:font script="Hebr" typeface="Arial" /><a:font script="Thai" typeface="Cordia New" /><a:font script="Ethi" typeface="Nyala" /><a:font script="Beng" typeface="Vrinda" /><a:font script="Gujr" typeface="Shruti" /><a:font script="Khmr" typeface="DaunPenh" /><a:font script="Knda" typeface="Tunga" /><a:font script="Guru" typeface="Raavi" /><a:font script="Cans" typeface="Euphemia" /><a:font script="Cher" typeface="Plantagenet Cherokee" /><a:font script="Yiii" typeface="Microsoft Yi Baiti" /><a:font script="Tibt" typeface="Microsoft Himalaya" /><a:font script="Thaa" typeface="MV Boli" /><a:font script="Deva" typeface="Mangal" /><a:font script="Telu" typeface="Gautami" /><a:font script="Taml" typeface="Latha" /><a:font script="Syrc" typeface="Estrangelo Edessa" /><a:font script="Orya" typeface="Kalinga" /><a:font script="Mlym" typeface="Kartika" /><a:font script="Laoo" typeface="DokChampa" /><a:font script="Sinh" typeface="Iskoola Pota" /><a:font script="Mong" typeface="Mongolian Baiti" /><a:font script="Viet" typeface="Arial" /><a:font script="Uigh" typeface="Microsoft Uighur" /></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr" /></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000" /><a:satMod val="300000" /></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000" /><a:satMod val="300000" /></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000" /><a:satMod val="350000" /></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1" /></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="100000" /><a:shade val="100000" /><a:satMod val="130000" /></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="50000" /><a:shade val="100000" /><a:satMod val="350000" /></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0" /></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000" /><a:satMod val="105000" /></a:schemeClr></a:solidFill><a:prstDash val="solid" /></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr" /></a:solidFill><a:prstDash val="solid" /></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr" /></a:solidFill><a:prstDash val="solid" /></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000" /></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000" /></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000" /></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0" /></a:camera><a:lightRig rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000" /></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400" /></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr" /></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000" /><a:satMod val="350000" /></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000" /><a:shade val="99000" /><a:satMod val="350000" /></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000" /><a:satMod val="255000" /></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000" /></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000" /><a:satMod val="300000" /></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000" /><a:satMod val="200000" /></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000" /></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults><a:spDef><a:spPr /><a:bodyPr /><a:lstStyle /><a:style><a:lnRef idx="1"><a:schemeClr val="accent1" /></a:lnRef><a:fillRef idx="3"><a:schemeClr val="accent1" /></a:fillRef><a:effectRef idx="2"><a:schemeClr val="accent1" /></a:effectRef><a:fontRef idx="minor"><a:schemeClr val="lt1" /></a:fontRef></a:style></a:spDef><a:lnDef><a:spPr /><a:bodyPr /><a:lstStyle /><a:style><a:lnRef idx="2"><a:schemeClr val="accent1" /></a:lnRef><a:fillRef idx="0"><a:schemeClr val="accent1" /></a:fillRef><a:effectRef idx="1"><a:schemeClr val="accent1" /></a:effectRef><a:fontRef idx="minor"><a:schemeClr val="tx1" /></a:fontRef></a:style></a:lnDef></a:objectDefaults><a:extraClrSchemeLst /></a:theme> \ No newline at end of file
diff --git a/data/docx/word/webSettings.xml b/data/docx/word/webSettings.xml
new file mode 100644
index 000000000..570ca8e1a
--- /dev/null
+++ b/data/docx/word/webSettings.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ns0:webSettings xmlns:ns0="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
+ <ns0:allowPNG />
+ <ns0:doNotSaveAsSingleFile />
+</ns0:webSettings> \ No newline at end of file
diff --git a/data/dzslides/template.html b/data/dzslides/template.html
new file mode 100644
index 000000000..56ef8963e
--- /dev/null
+++ b/data/dzslides/template.html
@@ -0,0 +1,683 @@
+<!DOCTYPE html>
+
+<meta charset="utf-8">
+<title>The Title Of Your Presentation</title>
+
+<!-- Your Slides -->
+<!-- One section is one slide -->
+
+<section>
+ <!-- This is the first slide -->
+ <h1>My Presentation</h1>
+ <footer>by John Doe</footer>
+</section>
+
+<section>
+ <p>Some random text: But I've never been to the moon! You can see how I lived before I met you. Also Zoidberg.
+ I could if you hadn't turned on the light and shut off my stereo.</p>
+</section>
+
+<section>
+ <h3>An incremental list</h3>
+ <ul class="incremental">
+ <li>Item 1
+ <li>Item 2
+ <li>Item 3
+ <ul class="incremental">
+ <li> Item 3.1
+ <li> Item 3.2
+ </ul>
+ </ul>
+ <div role="note">Some notes. They are only visible using onstage shell.</div>
+</section>
+
+<section>
+ <blockquote>
+ Who's brave enough to fly into something we all keep calling a death sphere?
+ </blockquote>
+ <details>
+ <p>In the onstage shell, notes scroll rather than overflow:</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ac dui eu est feugiat lacinia sit amet nec leo. Mauris eu ipsum leo. Nulla mi odio, cursus sed sollicitudin non, fringilla id magna. Suspendisse sit amet posuere elit. Maecenas iaculis, turpis a placerat imperdiet, libero lorem feugiat nisi, nec tincidunt diam nibh sit amet massa. Vestibulum quis adipiscing tellus. Maecenas sollicitudin sodales pulvinar. Donec dui ipsum, bibendum facilisis consequat interdum, tempus ut mauris. Aliquam ut dolor nec odio scelerisque bibendum quis in neque. Aliquam dui dui, pulvinar quis fermentum quis, gravida eu augue. Nunc tristique dolor a urna pulvinar bibendum. Curabitur mollis cursus neque, in scelerisque metus porta non. Donec tempor enim in nibh vestibulum et convallis nisi malesuada. Duis ut lectus sed metus venenatis porttitor id pharetra quam. Suspendisse sapien turpis, ornare in molestie et, gravida eget turpis.
+ </p>
+ </details>
+</section>
+
+<section>
+ <h2>Part two</h2>
+</section>
+
+<section>
+ <figure> <!-- Figures are used to display images and videos fullpage -->
+ <img src="http://placekitten.com/g/800/600">
+ <figcaption>An image</figcaption>
+ </figure>
+ <div role="note">Kittens are so cute!</div>
+</section>
+
+<section>
+ <figure> <!-- Videos are automatically played -->
+ <video src="http://videos-cdn.mozilla.net/brand/Mozilla_Firefox_Manifesto_v0.2_640.webm" poster="http://www.mozilla.org/images/about/poster.jpg"></video>
+ <figcaption>A video</figcaption>
+ </figure>
+</section>
+
+<section>
+ <h2>End!</h2>
+</section>
+
+<!-- Your Style -->
+<!-- Define the style of your presentation -->
+
+<!-- Maybe a font from http://www.google.com/webfonts ? -->
+<link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet'>
+
+<style>
+ html, .view body { background-color: black; counter-reset: slideidx; }
+ body, .view section { background-color: white; border-radius: 12px }
+ /* A section is a slide. It's size is 800x600, and this will never change */
+ section, .view head > title {
+ /* The font from Google */
+ font-family: 'Oswald', arial, serif;
+ font-size: 30px;
+ }
+
+ .view section:after {
+ counter-increment: slideidx;
+ content: counter(slideidx, decimal-leading-zero);
+ position: absolute; bottom: -80px; right: 100px;
+ color: white;
+ }
+
+ .view head > title {
+ color: white;
+ text-align: center;
+ margin: 1em 0 1em 0;
+ }
+
+ h1, h2 {
+ margin-top: 200px;
+ text-align: center;
+ font-size: 80px;
+ }
+ h3 {
+ margin: 100px 0 50px 100px;
+ }
+
+ ul {
+ margin: 50px 200px;
+ }
+ li > ul {
+ margin: 15px 50px;
+ }
+
+ p {
+ margin: 75px;
+ font-size: 50px;
+ }
+
+ blockquote {
+ height: 100%;
+ background-color: black;
+ color: white;
+ font-size: 60px;
+ padding: 50px;
+ }
+ blockquote:before {
+ content: open-quote;
+ }
+ blockquote:after {
+ content: close-quote;
+ }
+
+ /* Figures are displayed full-page, with the caption
+ on top of the image/video */
+ figure {
+ background-color: black;
+ width: 100%;
+ height: 100%;
+ }
+ figure > * {
+ position: absolute;
+ }
+ figure > img, figure > video {
+ width: 100%; height: 100%;
+ }
+ figcaption {
+ margin: 70px;
+ font-size: 50px;
+ }
+
+ footer {
+ position: absolute;
+ bottom: 0;
+ width: 100%;
+ padding: 40px;
+ text-align: right;
+ background-color: #F3F4F8;
+ border-top: 1px solid #CCC;
+ }
+
+ /* Transition effect */
+ /* Feel free to change the transition effect for original
+ animations. See here:
+ https://developer.mozilla.org/en/CSS/CSS_transitions
+ How to use CSS3 Transitions: */
+ section {
+ -moz-transition: left 400ms linear 0s;
+ -webkit-transition: left 400ms linear 0s;
+ -ms-transition: left 400ms linear 0s;
+ transition: left 400ms linear 0s;
+ }
+ .view section {
+ -moz-transition: none;
+ -webkit-transition: none;
+ -ms-transition: none;
+ transition: none;
+ }
+
+ .view section[aria-selected] {
+ border: 5px red solid;
+ }
+
+ /* Before */
+ section { left: -150%; }
+ /* Now */
+ section[aria-selected] { left: 0; }
+ /* After */
+ section[aria-selected] ~ section { left: +150%; }
+
+ /* Incremental elements */
+
+ /* By default, visible */
+ .incremental > * { opacity: 1; }
+
+ /* The current item */
+ .incremental > *[aria-selected] { opacity: 1; }
+
+ /* The items to-be-selected */
+ .incremental > *[aria-selected] ~ * { opacity: 0; }
+
+ /* The progressbar, at the bottom of the slides, show the global
+ progress of the presentation. */
+ #progress-bar {
+ height: 2px;
+ background: #AAA;
+ }
+</style>
+
+<!-- {{{{ dzslides core
+#
+#
+# __ __ __ . __ ___ __
+# | \ / /__` | | | \ |__ /__`
+# |__/ /_ .__/ |___ | |__/ |___ .__/ core :€
+#
+#
+# The following block of code is not supposed to be edited.
+# But if you want to change the behavior of these slides,
+# feel free to hack it!
+#
+-->
+
+<div id="progress-bar"></div>
+
+<!-- Default Style -->
+<style>
+ * { margin: 0; padding: 0; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
+ [role="note"] { display: none; }
+ body {
+ width: 800px; height: 600px;
+ margin-left: -400px; margin-top: -300px;
+ position: absolute; top: 50%; left: 50%;
+ overflow: hidden;
+ display: none;
+ }
+ .view body {
+ position: static;
+ margin: 0; padding: 0;
+ width: 100%; height: 100%;
+ display: inline-block;
+ overflow: visible; overflow-x: hidden;
+ /* undo Dz.onresize */
+ transform: none !important;
+ -moz-transform: none !important;
+ -webkit-transform: none !important;
+ -o-transform: none !important;
+ -ms-transform: none !important;
+ }
+ .view head, .view head > title { display: block }
+ section {
+ position: absolute;
+ pointer-events: none;
+ width: 100%; height: 100%;
+ }
+ .view section {
+ pointer-events: auto;
+ position: static;
+ width: 800px; height: 600px;
+ margin: -150px -200px;
+ float: left;
+
+ transform: scale(.4);
+ -moz-transform: scale(.4);
+ -webkit-transform: scale(.4);
+ -o-transform: scale(.4);
+ -ms-transform: scale(.4);
+ }
+ .view section > * { pointer-events: none; }
+ section[aria-selected] { pointer-events: auto; }
+ html { overflow: hidden; }
+ html.view { overflow: visible; }
+ body.loaded { display: block; }
+ .incremental {visibility: hidden; }
+ .incremental[active] {visibility: visible; }
+ #progress-bar{
+ bottom: 0;
+ position: absolute;
+ -moz-transition: width 400ms linear 0s;
+ -webkit-transition: width 400ms linear 0s;
+ -ms-transition: width 400ms linear 0s;
+ transition: width 400ms linear 0s;
+ }
+ .view #progress-bar {
+ display: none;
+ }
+</style>
+
+<script>
+ var Dz = {
+ remoteWindows: [],
+ idx: -1,
+ step: 0,
+ html: null,
+ slides: null,
+ progressBar : null,
+ params: {
+ autoplay: "1"
+ }
+ };
+
+ Dz.init = function() {
+ document.body.className = "loaded";
+ this.slides = Array.prototype.slice.call($$("body > section"));
+ this.progressBar = $("#progress-bar");
+ this.html = document.body.parentNode;
+ this.setupParams();
+ this.onhashchange();
+ this.setupTouchEvents();
+ this.onresize();
+ this.setupView();
+ }
+
+ Dz.setupParams = function() {
+ var p = window.location.search.substr(1).split('&');
+ p.forEach(function(e, i, a) {
+ var keyVal = e.split('=');
+ Dz.params[keyVal[0]] = decodeURIComponent(keyVal[1]);
+ });
+ // Specific params handling
+ if (!+this.params.autoplay)
+ $$.forEach($$("video"), function(v){ v.controls = true });
+ }
+
+ Dz.onkeydown = function(aEvent) {
+ // Don't intercept keyboard shortcuts
+ if (aEvent.altKey
+ || aEvent.ctrlKey
+ || aEvent.metaKey
+ || aEvent.shiftKey) {
+ return;
+ }
+ if ( aEvent.keyCode == 37 // left arrow
+ || aEvent.keyCode == 38 // up arrow
+ || aEvent.keyCode == 33 // page up
+ ) {
+ aEvent.preventDefault();
+ this.back();
+ }
+ if ( aEvent.keyCode == 39 // right arrow
+ || aEvent.keyCode == 40 // down arrow
+ || aEvent.keyCode == 34 // page down
+ ) {
+ aEvent.preventDefault();
+ this.forward();
+ }
+ if (aEvent.keyCode == 35) { // end
+ aEvent.preventDefault();
+ this.goEnd();
+ }
+ if (aEvent.keyCode == 36) { // home
+ aEvent.preventDefault();
+ this.goStart();
+ }
+ if (aEvent.keyCode == 32) { // space
+ aEvent.preventDefault();
+ this.toggleContent();
+ }
+ if (aEvent.keyCode == 70) { // f
+ aEvent.preventDefault();
+ this.goFullscreen();
+ }
+ if (aEvent.keyCode == 79) { // o
+ aEvent.preventDefault();
+ this.toggleView();
+ }
+ }
+
+ /* Touch Events */
+
+ Dz.setupTouchEvents = function() {
+ var orgX, newX;
+ var tracking = false;
+
+ var db = document.body;
+ db.addEventListener("touchstart", start.bind(this), false);
+ db.addEventListener("touchmove", move.bind(this), false);
+
+ function start(aEvent) {
+ aEvent.preventDefault();
+ tracking = true;
+ orgX = aEvent.changedTouches[0].pageX;
+ }
+
+ function move(aEvent) {
+ if (!tracking) return;
+ newX = aEvent.changedTouches[0].pageX;
+ if (orgX - newX > 100) {
+ tracking = false;
+ this.forward();
+ } else {
+ if (orgX - newX < -100) {
+ tracking = false;
+ this.back();
+ }
+ }
+ }
+ }
+
+ Dz.setupView = function() {
+ document.body.addEventListener("click", function ( e ) {
+ if (!Dz.html.classList.contains("view")) return;
+ if (!e.target || e.target.nodeName != "SECTION") return;
+
+ Dz.html.classList.remove("view");
+ Dz.setCursor(Dz.slides.indexOf(e.target) + 1);
+ }, false);
+ }
+
+ /* Adapt the size of the slides to the window */
+
+ Dz.onresize = function() {
+ var db = document.body;
+ var sx = db.clientWidth / window.innerWidth;
+ var sy = db.clientHeight / window.innerHeight;
+ var transform = "scale(" + (1/Math.max(sx, sy)) + ")";
+
+ db.style.MozTransform = transform;
+ db.style.WebkitTransform = transform;
+ db.style.OTransform = transform;
+ db.style.msTransform = transform;
+ db.style.transform = transform;
+ }
+
+
+ Dz.getNotes = function(aIdx) {
+ var s = $("section:nth-of-type(" + aIdx + ")");
+ var d = s.$("[role='note']");
+ return d ? d.innerHTML : "";
+ }
+
+ Dz.onmessage = function(aEvent) {
+ var argv = aEvent.data.split(" "), argc = argv.length;
+ argv.forEach(function(e, i, a) { a[i] = decodeURIComponent(e) });
+ var win = aEvent.source;
+ if (argv[0] === "REGISTER" && argc === 1) {
+ this.remoteWindows.push(win);
+ this.postMsg(win, "REGISTERED", document.title, this.slides.length);
+ this.postMsg(win, "CURSOR", this.idx + "." + this.step);
+ return;
+ }
+ if (argv[0] === "BACK" && argc === 1)
+ this.back();
+ if (argv[0] === "FORWARD" && argc === 1)
+ this.forward();
+ if (argv[0] === "START" && argc === 1)
+ this.goStart();
+ if (argv[0] === "END" && argc === 1)
+ this.goEnd();
+ if (argv[0] === "TOGGLE_CONTENT" && argc === 1)
+ this.toggleContent();
+ if (argv[0] === "SET_CURSOR" && argc === 2)
+ window.location.hash = "#" + argv[1];
+ if (argv[0] === "GET_CURSOR" && argc === 1)
+ this.postMsg(win, "CURSOR", this.idx + "." + this.step);
+ if (argv[0] === "GET_NOTES" && argc === 1)
+ this.postMsg(win, "NOTES", this.getNotes(this.idx));
+ }
+
+ Dz.toggleContent = function() {
+ // If a Video is present in this new slide, play it.
+ // If a Video is present in the previous slide, stop it.
+ var s = $("section[aria-selected]");
+ if (s) {
+ var video = s.$("video");
+ if (video) {
+ if (video.ended || video.paused) {
+ video.play();
+ } else {
+ video.pause();
+ }
+ }
+ }
+ }
+
+ Dz.setCursor = function(aIdx, aStep) {
+ // If the user change the slide number in the URL bar, jump
+ // to this slide.
+ aStep = (aStep != 0 && typeof aStep !== "undefined") ? "." + aStep : ".0";
+ window.location.hash = "#" + aIdx + aStep;
+ }
+
+ Dz.onhashchange = function() {
+ var cursor = window.location.hash.split("#"),
+ newidx = 1,
+ newstep = 0;
+ if (cursor.length == 2) {
+ newidx = ~~cursor[1].split(".")[0];
+ newstep = ~~cursor[1].split(".")[1];
+ if (newstep > Dz.slides[newidx - 1].$$('.incremental > *').length) {
+ newstep = 0;
+ newidx++;
+ }
+ }
+ this.setProgress(newidx, newstep);
+ if (newidx != this.idx) {
+ this.setSlide(newidx);
+ }
+ if (newstep != this.step) {
+ this.setIncremental(newstep);
+ }
+ for (var i = 0; i < this.remoteWindows.length; i++) {
+ this.postMsg(this.remoteWindows[i], "CURSOR", this.idx + "." + this.step);
+ }
+ }
+
+ Dz.back = function() {
+ if (this.idx == 1 && this.step == 0) {
+ return;
+ }
+ if (this.step == 0) {
+ this.setCursor(this.idx - 1,
+ this.slides[this.idx - 2].$$('.incremental > *').length);
+ } else {
+ this.setCursor(this.idx, this.step - 1);
+ }
+ }
+
+ Dz.forward = function() {
+ if (this.idx >= this.slides.length &&
+ this.step >= this.slides[this.idx - 1].$$('.incremental > *').length) {
+ return;
+ }
+ if (this.step >= this.slides[this.idx - 1].$$('.incremental > *').length) {
+ this.setCursor(this.idx + 1, 0);
+ } else {
+ this.setCursor(this.idx, this.step + 1);
+ }
+ }
+
+ Dz.goStart = function() {
+ this.setCursor(1, 0);
+ }
+
+ Dz.goEnd = function() {
+ var lastIdx = this.slides.length;
+ var lastStep = this.slides[lastIdx - 1].$$('.incremental > *').length;
+ this.setCursor(lastIdx, lastStep);
+ }
+
+ Dz.toggleView = function() {
+ this.html.classList.toggle("view");
+
+ if (this.html.classList.contains("view")) {
+ $("section[aria-selected]").scrollIntoView(true);
+ }
+ }
+
+ Dz.setSlide = function(aIdx) {
+ this.idx = aIdx;
+ var old = $("section[aria-selected]");
+ var next = $("section:nth-of-type("+ this.idx +")");
+ if (old) {
+ old.removeAttribute("aria-selected");
+ var video = old.$("video");
+ if (video) {
+ video.pause();
+ }
+ }
+ if (next) {
+ next.setAttribute("aria-selected", "true");
+ if (this.html.classList.contains("view")) {
+ next.scrollIntoView();
+ }
+ var video = next.$("video");
+ if (video && !!+this.params.autoplay) {
+ video.play();
+ }
+ } else {
+ // That should not happen
+ this.idx = -1;
+ // console.warn("Slide doesn't exist.");
+ }
+ }
+
+ Dz.setIncremental = function(aStep) {
+ this.step = aStep;
+ var old = this.slides[this.idx - 1].$('.incremental > *[aria-selected]');
+ if (old) {
+ old.removeAttribute('aria-selected');
+ }
+ var incrementals = $$('.incremental');
+ if (this.step <= 0) {
+ $$.forEach(incrementals, function(aNode) {
+ aNode.removeAttribute('active');
+ });
+ return;
+ }
+ var next = this.slides[this.idx - 1].$$('.incremental > *')[this.step - 1];
+ if (next) {
+ next.setAttribute('aria-selected', true);
+ next.parentNode.setAttribute('active', true);
+ var found = false;
+ $$.forEach(incrementals, function(aNode) {
+ if (aNode != next.parentNode)
+ if (found)
+ aNode.removeAttribute('active');
+ else
+ aNode.setAttribute('active', true);
+ else
+ found = true;
+ });
+ } else {
+ setCursor(this.idx, 0);
+ }
+ return next;
+ }
+
+ Dz.goFullscreen = function() {
+ var html = $('html'),
+ requestFullscreen = html.requestFullscreen || html.requestFullScreen || html.mozRequestFullScreen || html.webkitRequestFullScreen;
+ if (requestFullscreen) {
+ requestFullscreen.apply(html);
+ }
+ }
+
+ Dz.setProgress = function(aIdx, aStep) {
+ var slide = $("section:nth-of-type("+ aIdx +")");
+ if (!slide)
+ return;
+ var steps = slide.$$('.incremental > *').length + 1,
+ slideSize = 100 / (this.slides.length - 1),
+ stepSize = slideSize / steps;
+ this.progressBar.style.width = ((aIdx - 1) * slideSize + aStep * stepSize) + '%';
+ }
+
+ Dz.postMsg = function(aWin, aMsg) { // [arg0, [arg1...]]
+ aMsg = [aMsg];
+ for (var i = 2; i < arguments.length; i++)
+ aMsg.push(encodeURIComponent(arguments[i]));
+ aWin.postMessage(aMsg.join(" "), "*");
+ }
+
+ function init() {
+ Dz.init();
+ window.onkeydown = Dz.onkeydown.bind(Dz);
+ window.onresize = Dz.onresize.bind(Dz);
+ window.onhashchange = Dz.onhashchange.bind(Dz);
+ window.onmessage = Dz.onmessage.bind(Dz);
+ }
+
+ window.onload = init;
+</script>
+
+
+<script> // Helpers
+ if (!Function.prototype.bind) {
+ Function.prototype.bind = function (oThis) {
+
+ // closest thing possible to the ECMAScript 5 internal IsCallable
+ // function
+ if (typeof this !== "function")
+ throw new TypeError(
+ "Function.prototype.bind - what is trying to be fBound is not callable"
+ );
+
+ var aArgs = Array.prototype.slice.call(arguments, 1),
+ fToBind = this,
+ fNOP = function () {},
+ fBound = function () {
+ return fToBind.apply( this instanceof fNOP ? this : oThis || window,
+ aArgs.concat(Array.prototype.slice.call(arguments)));
+ };
+
+ fNOP.prototype = this.prototype;
+ fBound.prototype = new fNOP();
+
+ return fBound;
+ };
+ }
+
+ var $ = (HTMLElement.prototype.$ = function(aQuery) {
+ return this.querySelector(aQuery);
+ }).bind(document);
+
+ var $$ = (HTMLElement.prototype.$$ = function(aQuery) {
+ return this.querySelectorAll(aQuery);
+ }).bind(document);
+
+ $$.forEach = function(nodeList, fun) {
+ Array.prototype.forEach.call(nodeList, fun);
+ }
+
+</script>
+<!-- vim: set fdm=marker: }}} -->
diff --git a/data/epub.css b/data/epub.css
new file mode 100644
index 000000000..594a1e01e
--- /dev/null
+++ b/data/epub.css
@@ -0,0 +1,18 @@
+/* This defines styles and classes used in the book */
+body { margin: 5%; text-align: justify; font-size: medium; }
+code { font-family: monospace; }
+h1 { text-align: left; }
+h2 { text-align: left; }
+h3 { text-align: left; }
+h4 { text-align: left; }
+h5 { text-align: left; }
+h6 { text-align: left; }
+h1.title { }
+h2.author { }
+h3.date { }
+ol.toc { padding: 0; margin-left: 1em; }
+ol.toc li { list-style-type: none; margin: 0; padding: 0; }
+a.footnoteRef { vertical-align: super; }
+em, em em em, em em em em em { font-style: italic;}
+em em, em em em em { font-style: normal; }
+
diff --git a/data/make-reference-files.hs b/data/make-reference-files.hs
new file mode 100644
index 000000000..77e518496
--- /dev/null
+++ b/data/make-reference-files.hs
@@ -0,0 +1,27 @@
+import System.Environment
+import System.Directory
+import Codec.Archive.Zip
+import qualified Data.ByteString.Lazy as BS
+import qualified Control.Exception as E
+import System.IO.Error (isDoesNotExistError)
+import System.FilePath
+
+mkzip :: String -> IO ()
+mkzip fmt = do
+ let dir = "data" </> fmt
+ output = "data" </> "reference" <.> fmt
+ cd <- getCurrentDirectory
+ setCurrentDirectory dir
+ archive <- addFilesToArchive [OptRecursive] emptyArchive ["."]
+ setCurrentDirectory cd
+ removeIfExists output
+ BS.writeFile output $ fromArchive archive
+
+removeIfExists :: FilePath -> IO ()
+removeIfExists fileName = removeFile fileName `E.catch` handleExists
+ where handleExists e
+ | isDoesNotExistError e = return ()
+ | otherwise = E.throwIO e
+
+main :: IO ()
+main = getArgs >>= mkzip . (!!0)
diff --git a/data/odt/Configurations2/accelerator/current.xml b/data/odt/Configurations2/accelerator/current.xml
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/data/odt/Configurations2/accelerator/current.xml
diff --git a/data/odt/META-INF/manifest.xml b/data/odt/META-INF/manifest.xml
new file mode 100644
index 000000000..2796993a5
--- /dev/null
+++ b/data/odt/META-INF/manifest.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2">
+ <manifest:file-entry manifest:full-path="/" manifest:version="1.2" manifest:media-type="application/vnd.oasis.opendocument.text"/>
+ <manifest:file-entry manifest:full-path="meta.xml" manifest:media-type="text/xml"/>
+ <manifest:file-entry manifest:full-path="settings.xml" manifest:media-type="text/xml"/>
+ <manifest:file-entry manifest:full-path="content.xml" manifest:media-type="text/xml"/>
+ <manifest:file-entry manifest:full-path="Thumbnails/thumbnail.png" manifest:media-type="image/png"/>
+ <manifest:file-entry manifest:full-path="manifest.rdf" manifest:media-type="application/rdf+xml"/>
+ <manifest:file-entry manifest:full-path="Configurations2/accelerator/current.xml" manifest:media-type=""/>
+ <manifest:file-entry manifest:full-path="Configurations2/" manifest:media-type="application/vnd.sun.xml.ui.configuration"/>
+ <manifest:file-entry manifest:full-path="styles.xml" manifest:media-type="text/xml"/>
+</manifest:manifest> \ No newline at end of file
diff --git a/data/odt/Thumbnails/thumbnail.png b/data/odt/Thumbnails/thumbnail.png
new file mode 100644
index 000000000..63de13060
--- /dev/null
+++ b/data/odt/Thumbnails/thumbnail.png
Binary files differ
diff --git a/data/odt/content.xml b/data/odt/content.xml
new file mode 100644
index 000000000..3bf335bb6
--- /dev/null
+++ b/data/odt/content.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2"><office:scripts/><office:font-face-decls><style:font-face style:name="StarSymbol" svg:font-family="StarSymbol"/><style:font-face style:name="Tahoma1" svg:font-family="Tahoma"/><style:font-face style:name="Courier New" svg:font-family="&apos;Courier New&apos;" style:font-family-generic="modern" style:font-pitch="fixed"/><style:font-face style:name="Times New Roman" svg:font-family="&apos;Times New Roman&apos;" style:font-family-generic="roman" style:font-pitch="variable"/><style:font-face style:name="Arial" svg:font-family="Arial" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="Lucida Sans Unicode" svg:font-family="&apos;Lucida Sans Unicode&apos;" style:font-family-generic="system" style:font-pitch="variable"/><style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-family-generic="system" style:font-pitch="variable"/></office:font-face-decls><office:automatic-styles><style:style style:name="P1" style:family="paragraph" style:parent-style-name="Footer"><style:paragraph-properties fo:text-align="center" style:justify-single-word="false"/></style:style></office:automatic-styles><office:body><office:text><text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="Illustration"/><text:sequence-decl text:display-outline-level="0" text:name="Table"/><text:sequence-decl text:display-outline-level="0" text:name="Text"/><text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></text:sequence-decls><text:p text:style-name="Standard">Hello World!</text:p></office:text></office:body></office:document-content> \ No newline at end of file
diff --git a/data/odt/manifest.rdf b/data/odt/manifest.rdf
new file mode 100644
index 000000000..927e206bb
--- /dev/null
+++ b/data/odt/manifest.rdf
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <rdf:Description rdf:about="styles.xml">
+ <rdf:type rdf:resource="http://docs.oasis-open.org/ns/office/1.2/meta/odf#StylesFile"/>
+ </rdf:Description>
+ <rdf:Description rdf:about="">
+ <ns0:hasPart xmlns:ns0="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#" rdf:resource="styles.xml"/>
+ </rdf:Description>
+ <rdf:Description rdf:about="content.xml">
+ <rdf:type rdf:resource="http://docs.oasis-open.org/ns/office/1.2/meta/odf#ContentFile"/>
+ </rdf:Description>
+ <rdf:Description rdf:about="">
+ <ns0:hasPart xmlns:ns0="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#" rdf:resource="content.xml"/>
+ </rdf:Description>
+ <rdf:Description rdf:about="">
+ <rdf:type rdf:resource="http://docs.oasis-open.org/ns/office/1.2/meta/pkg#Document"/>
+ </rdf:Description>
+</rdf:RDF>
diff --git a/data/odt/meta.xml b/data/odt/meta.xml
new file mode 100644
index 000000000..7fdd4d98c
--- /dev/null
+++ b/data/odt/meta.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document-meta
+ xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ 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">
+ <office:meta>
+ <meta:document-statistic
+ meta:table-count="0" meta:image-count="0" meta:object-count="0"
+ meta:page-count="1" meta:paragraph-count="2" meta:word-count="3"
+ meta:character-count="14"
+ meta:non-whitespace-character-count="12"/>
+ <meta:generator>Pandoc</meta:generator>
+ </office:meta>
+</office:document-meta>
diff --git a/data/odt/mimetype b/data/odt/mimetype
new file mode 100644
index 000000000..2e95b81c9
--- /dev/null
+++ b/data/odt/mimetype
@@ -0,0 +1 @@
+application/vnd.oasis.opendocument.text \ No newline at end of file
diff --git a/data/odt/settings.xml b/data/odt/settings.xml
new file mode 100644
index 000000000..20bc19d14
--- /dev/null
+++ b/data/odt/settings.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document-settings xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" office:version="1.2"><office:settings><config:config-item-set config:name="ooo:view-settings"><config:config-item config:name="ViewAreaTop" config:type="int">0</config:config-item><config:config-item config:name="ViewAreaLeft" config:type="int">0</config:config-item><config:config-item config:name="ViewAreaWidth" config:type="int">21747</config:config-item><config:config-item config:name="ViewAreaHeight" config:type="int">10874</config:config-item><config:config-item config:name="ShowRedlineChanges" config:type="boolean">true</config:config-item><config:config-item config:name="InBrowseMode" config:type="boolean">false</config:config-item><config:config-item-map-indexed config:name="Views"><config:config-item-map-entry><config:config-item config:name="ViewId" config:type="string">view2</config:config-item><config:config-item config:name="ViewLeft" config:type="int">3041</config:config-item><config:config-item config:name="ViewTop" config:type="int">3041</config:config-item><config:config-item config:name="VisibleLeft" config:type="int">0</config:config-item><config:config-item config:name="VisibleTop" config:type="int">0</config:config-item><config:config-item config:name="VisibleRight" config:type="int">21745</config:config-item><config:config-item config:name="VisibleBottom" config:type="int">10873</config:config-item><config:config-item config:name="ZoomType" config:type="short">0</config:config-item><config:config-item config:name="ViewLayoutColumns" config:type="short">0</config:config-item><config:config-item config:name="ViewLayoutBookMode" config:type="boolean">false</config:config-item><config:config-item config:name="ZoomFactor" config:type="short">100</config:config-item><config:config-item config:name="IsSelectedFrame" config:type="boolean">false</config:config-item></config:config-item-map-entry></config:config-item-map-indexed></config:config-item-set><config:config-item-set config:name="ooo:configuration-settings"><config:config-item config:name="ChartAutoUpdate" config:type="boolean">true</config:config-item><config:config-item config:name="IsLabelDocument" config:type="boolean">false</config:config-item><config:config-item config:name="MathBaselineAlignment" config:type="boolean">false</config:config-item><config:config-item config:name="Rsid" config:type="int">1473719</config:config-item><config:config-item config:name="OutlineLevelYieldsNumbering" config:type="boolean">false</config:config-item><config:config-item config:name="PrintLeftPages" config:type="boolean">true</config:config-item><config:config-item config:name="DoNotJustifyLinesWithManualBreak" config:type="boolean">false</config:config-item><config:config-item config:name="ClippedPictures" config:type="boolean">false</config:config-item><config:config-item config:name="AlignTabStopPosition" config:type="boolean">true</config:config-item><config:config-item config:name="PrintTextPlaceholder" config:type="boolean">false</config:config-item><config:config-item config:name="UseOldNumbering" config:type="boolean">false</config:config-item><config:config-item config:name="CurrentDatabaseCommand" config:type="string"/><config:config-item config:name="ProtectForm" config:type="boolean">false</config:config-item><config:config-item config:name="PrintBlackFonts" config:type="boolean">false</config:config-item><config:config-item config:name="PrintProspectRTL" config:type="boolean">false</config:config-item><config:config-item config:name="BackgroundParaOverDrawings" config:type="boolean">false</config:config-item><config:config-item config:name="FloattableNomargins" config:type="boolean">false</config:config-item><config:config-item config:name="SmallCapsPercentage66" config:type="boolean">false</config:config-item><config:config-item config:name="PrintControls" config:type="boolean">true</config:config-item><config:config-item config:name="EmbedSystemFonts" config:type="boolean">false</config:config-item><config:config-item config:name="CharacterCompressionType" config:type="short">0</config:config-item><config:config-item config:name="PrintHiddenText" config:type="boolean">false</config:config-item><config:config-item config:name="UseFormerTextWrapping" config:type="boolean">false</config:config-item><config:config-item config:name="IsKernAsianPunctuation" config:type="boolean">false</config:config-item><config:config-item config:name="PrintProspect" config:type="boolean">false</config:config-item><config:config-item config:name="PrintEmptyPages" config:type="boolean">false</config:config-item><config:config-item config:name="UnbreakableNumberings" config:type="boolean">false</config:config-item><config:config-item config:name="UseFormerObjectPositioning" config:type="boolean">false</config:config-item><config:config-item config:name="ConsiderTextWrapOnObjPos" config:type="boolean">false</config:config-item><config:config-item config:name="TableRowKeep" config:type="boolean">false</config:config-item><config:config-item config:name="PrintReversed" config:type="boolean">false</config:config-item><config:config-item config:name="TabsRelativeToIndent" config:type="boolean">true</config:config-item><config:config-item config:name="PrintRightPages" config:type="boolean">true</config:config-item><config:config-item config:name="PrintPaperFromSetup" config:type="boolean">false</config:config-item><config:config-item config:name="AddFrameOffsets" config:type="boolean">false</config:config-item><config:config-item config:name="AddParaSpacingToTableCells" config:type="boolean">true</config:config-item><config:config-item config:name="UpdateFromTemplate" config:type="boolean">true</config:config-item><config:config-item config:name="AddExternalLeading" config:type="boolean">true</config:config-item><config:config-item config:name="PrintSingleJobs" config:type="boolean">false</config:config-item><config:config-item config:name="PrinterIndependentLayout" config:type="string">high-resolution</config:config-item><config:config-item config:name="RsidRoot" config:type="int">1473719</config:config-item><config:config-item config:name="LinkUpdateMode" config:type="short">1</config:config-item><config:config-item config:name="PrintAnnotationMode" config:type="short">0</config:config-item><config:config-item config:name="TabOverMargin" config:type="boolean">false</config:config-item><config:config-item config:name="UseOldPrinterMetrics" config:type="boolean">false</config:config-item><config:config-item config:name="RedlineProtectionKey" config:type="base64Binary"/><config:config-item config:name="PrinterSetup" config:type="base64Binary"/><config:config-item config:name="IgnoreFirstLineIndentInNumbering" config:type="boolean">false</config:config-item><config:config-item config:name="CollapseEmptyCellPara" config:type="boolean">true</config:config-item><config:config-item config:name="PrinterName" config:type="string"/><config:config-item config:name="EmbedFonts" config:type="boolean">false</config:config-item><config:config-item config:name="InvertBorderSpacing" config:type="boolean">false</config:config-item><config:config-item config:name="PrintPageBackground" config:type="boolean">true</config:config-item><config:config-item config:name="DoNotCaptureDrawObjsOnPage" config:type="boolean">false</config:config-item><config:config-item config:name="TabOverflow" config:type="boolean">true</config:config-item><config:config-item config:name="ApplyUserData" config:type="boolean">true</config:config-item><config:config-item config:name="TabAtLeftIndentForParagraphsInList" config:type="boolean">false</config:config-item><config:config-item config:name="UnxForceZeroExtLeading" config:type="boolean">false</config:config-item><config:config-item config:name="SaveVersionOnClose" config:type="boolean">false</config:config-item><config:config-item config:name="PrintFaxName" config:type="string"/><config:config-item config:name="StylesNoDefault" config:type="boolean">false</config:config-item><config:config-item config:name="AddParaTableSpacing" config:type="boolean">true</config:config-item><config:config-item config:name="PrintDrawings" config:type="boolean">true</config:config-item><config:config-item config:name="LoadReadonly" config:type="boolean">false</config:config-item><config:config-item config:name="PrintGraphics" config:type="boolean">true</config:config-item><config:config-item config:name="FieldAutoUpdate" config:type="boolean">true</config:config-item><config:config-item config:name="AllowPrintJobCancel" config:type="boolean">true</config:config-item><config:config-item config:name="UseFormerLineSpacing" config:type="boolean">false</config:config-item><config:config-item config:name="SaveGlobalDocumentLinks" config:type="boolean">false</config:config-item><config:config-item config:name="CurrentDatabaseDataSource" config:type="string"/><config:config-item config:name="IgnoreTabsAndBlanksForLineCalculation" config:type="boolean">false</config:config-item><config:config-item config:name="CurrentDatabaseCommandType" config:type="int">0</config:config-item><config:config-item config:name="DoNotResetParaAttrsForNumFont" config:type="boolean">false</config:config-item><config:config-item config:name="ClipAsCharacterAnchoredWriterFlyFrames" config:type="boolean">false</config:config-item><config:config-item config:name="PrintTables" config:type="boolean">true</config:config-item><config:config-item config:name="AddParaTableSpacingAtStart" config:type="boolean">true</config:config-item></config:config-item-set></office:settings></office:document-settings> \ No newline at end of file
diff --git a/data/odt/styles.xml b/data/odt/styles.xml
new file mode 100644
index 000000000..623a89051
--- /dev/null
+++ b/data/odt/styles.xml
@@ -0,0 +1,1104 @@
+<?xml version="1.0" encoding="utf-8"?>
+<office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
+xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
+xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
+xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
+xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
+xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
+xmlns:xlink="http://www.w3.org/1999/xlink"
+xmlns:dc="http://purl.org/dc/elements/1.1/"
+xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
+xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
+xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
+xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
+xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
+xmlns:math="http://www.w3.org/1998/Math/MathML"
+xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
+xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
+xmlns:ooo="http://openoffice.org/2004/office"
+xmlns:ooow="http://openoffice.org/2004/writer"
+xmlns:oooc="http://openoffice.org/2004/calc"
+xmlns:dom="http://www.w3.org/2001/xml-events"
+xmlns:rpt="http://openoffice.org/2005/report"
+xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
+xmlns:xhtml="http://www.w3.org/1999/xhtml"
+xmlns:grddl="http://www.w3.org/2003/g/data-view#"
+xmlns:officeooo="http://openoffice.org/2009/office"
+xmlns:tableooo="http://openoffice.org/2009/table"
+xmlns:drawooo="http://openoffice.org/2010/draw"
+xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
+xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2">
+ <office:font-face-decls>
+ <style:font-face style:name="StarSymbol"
+ svg:font-family="StarSymbol" />
+ <style:font-face style:name="Tahoma1"
+ svg:font-family="Tahoma" />
+ <style:font-face style:name="Courier New"
+ svg:font-family="'Courier New'"
+ style:font-family-generic="modern" style:font-pitch="fixed" />
+ <style:font-face style:name="Times New Roman"
+ svg:font-family="'Times New Roman'"
+ style:font-family-generic="roman"
+ style:font-pitch="variable" />
+ <style:font-face style:name="Arial" svg:font-family="Arial"
+ style:font-family-generic="swiss"
+ style:font-pitch="variable" />
+ <style:font-face style:name="Lucida Sans Unicode"
+ svg:font-family="'Lucida Sans Unicode'"
+ style:font-family-generic="system"
+ style:font-pitch="variable" />
+ <style:font-face style:name="Tahoma" svg:font-family="Tahoma"
+ style:font-family-generic="system"
+ style:font-pitch="variable" />
+ </office:font-face-decls>
+ <office:styles>
+ <style:default-style style:family="graphic">
+ <style:graphic-properties fo:wrap-option="wrap"
+ draw:shadow-offset-x="0.1181in"
+ draw:shadow-offset-y="0.1181in"
+ draw:start-line-spacing-horizontal="0.1114in"
+ draw:start-line-spacing-vertical="0.1114in"
+ draw:end-line-spacing-horizontal="0.1114in"
+ draw:end-line-spacing-vertical="0.1114in"
+ style:flow-with-text="false" />
+ <style:paragraph-properties style:text-autospace="ideograph-alpha"
+ style:line-break="strict" style:writing-mode="lr-tb"
+ style:font-independent-line-spacing="false">
+ <style:tab-stops />
+ </style:paragraph-properties>
+ <style:text-properties style:use-window-font-color="true"
+ fo:font-size="12pt" fo:language="en" fo:country="US"
+ style:letter-kerning="true" style:font-size-asian="12pt"
+ style:language-asian="zxx" style:country-asian="none"
+ style:font-size-complex="12pt" style:language-complex="zxx"
+ style:country-complex="none" />
+ </style:default-style>
+ <style:default-style style:family="paragraph">
+ <style:paragraph-properties fo:hyphenation-ladder-count="no-limit"
+ style:text-autospace="ideograph-alpha"
+ style:punctuation-wrap="hanging" style:line-break="strict"
+ style:tab-stop-distance="0.4925in"
+ style:writing-mode="page" />
+ <style:text-properties style:use-window-font-color="true"
+ style:font-name="Times New Roman" fo:font-size="12pt"
+ fo:language="en" fo:country="US" style:letter-kerning="true"
+ style:font-name-asian="Lucida Sans Unicode"
+ style:font-size-asian="12pt" style:language-asian="zxx"
+ style:country-asian="none" style:font-name-complex="Tahoma"
+ style:font-size-complex="12pt" style:language-complex="zxx"
+ style:country-complex="none" fo:hyphenate="false"
+ fo:hyphenation-remain-char-count="2"
+ fo:hyphenation-push-char-count="2" />
+ </style:default-style>
+ <style:default-style style:family="table">
+ <style:table-properties table:border-model="collapsing" />
+ </style:default-style>
+ <style:default-style style:family="table-row">
+ <style:table-row-properties fo:keep-together="auto" />
+ </style:default-style>
+ <style:style style:name="Standard" style:family="paragraph"
+ style:class="text" />
+ <style:style style:name="Heading" style:family="paragraph"
+ style:parent-style-name="Standard"
+ style:next-style-name="Text_20_body" style:class="text">
+ <style:paragraph-properties fo:margin-top="0.1665in"
+ fo:margin-bottom="0.0835in" style:contextual-spacing="false"
+ fo:keep-with-next="always" />
+ <style:text-properties style:font-name="Arial"
+ fo:font-size="14pt"
+ style:font-name-asian="Lucida Sans Unicode"
+ style:font-size-asian="14pt" style:font-name-complex="Tahoma"
+ style:font-size-complex="14pt" />
+ </style:style>
+ <style:style style:name="Text_20_body"
+ style:display-name="Text body" style:family="paragraph"
+ style:parent-style-name="Standard" style:class="text">
+ <style:paragraph-properties fo:margin-top="0.0598in"
+ fo:margin-bottom="0.0598in"
+ style:contextual-spacing="false" />
+ </style:style>
+ <style:style style:name="List" style:family="paragraph"
+ style:parent-style-name="Text_20_body" style:class="list">
+ <style:text-properties style:font-name-complex="Tahoma1" />
+ </style:style>
+ <style:style style:name="Caption" style:family="paragraph"
+ style:parent-style-name="Standard" style:class="extra">
+ <style:paragraph-properties fo:margin-top="0.0835in"
+ fo:margin-bottom="0.0835in" style:contextual-spacing="false"
+ text:number-lines="false" text:line-number="0" />
+ <style:text-properties fo:font-size="12pt"
+ fo:font-style="italic" style:font-size-asian="12pt"
+ style:font-style-asian="italic"
+ style:font-name-complex="Tahoma1"
+ style:font-size-complex="12pt"
+ style:font-style-complex="italic" />
+ </style:style>
+ <style:style style:name="Table" style:family="paragraph"
+ style:parent-style-name="Caption" style:class="extra">
+ </style:style>
+ <style:style style:name="FigureCaption" style:family="paragraph"
+ style:parent-style-name="Caption" style:class="extra">
+ </style:style>
+ <style:style style:name="Figure" style:family="paragraph"
+ style:parent-style-name="Standard" style:class="extra">
+ <style:paragraph-properties text:number-lines="false"
+ text:line-number="0" />
+ </style:style>
+ <style:style style:name="FigureWithCaption" style:family="paragraph"
+ style:parent-style-name="Figure" style:class="extra">
+ <style:paragraph-properties text:number-lines="false"
+ text:line-number="0" fo:keep-with-next="always" />
+ </style:style>
+ <style:style style:name="Index" style:family="paragraph"
+ style:parent-style-name="Standard" style:class="index">
+ <style:paragraph-properties text:number-lines="false"
+ text:line-number="0" />
+ <style:text-properties style:font-name-complex="Tahoma1" />
+ </style:style>
+ <style:style style:name="Heading_20_1"
+ style:display-name="Heading 1" style:family="paragraph"
+ style:parent-style-name="Heading"
+ style:next-style-name="Text_20_body"
+ style:default-outline-level="1" style:class="text">
+ <style:text-properties fo:font-size="115%"
+ fo:font-weight="bold" style:font-size-asian="115%"
+ style:font-weight-asian="bold" style:font-size-complex="115%"
+ style:font-weight-complex="bold" />
+ </style:style>
+ <style:style style:name="Heading_20_2"
+ style:display-name="Heading 2" style:family="paragraph"
+ style:parent-style-name="Heading"
+ style:next-style-name="Text_20_body"
+ style:default-outline-level="2" style:class="text">
+ <style:text-properties fo:font-size="14pt"
+ fo:font-style="italic" fo:font-weight="bold"
+ style:font-size-asian="14pt" style:font-style-asian="italic"
+ style:font-weight-asian="bold" style:font-size-complex="14pt"
+ style:font-style-complex="italic"
+ style:font-weight-complex="bold" />
+ </style:style>
+ <style:style style:name="Heading_20_3"
+ style:display-name="Heading 3" style:family="paragraph"
+ style:parent-style-name="Heading"
+ style:next-style-name="Text_20_body"
+ style:default-outline-level="3" style:class="text">
+ <style:text-properties fo:font-size="14pt"
+ fo:font-weight="bold" style:font-size-asian="14pt"
+ style:font-weight-asian="bold" style:font-size-complex="14pt"
+ style:font-weight-complex="bold" />
+ </style:style>
+ <style:style style:name="Heading_20_4"
+ style:display-name="Heading 4" style:family="paragraph"
+ style:parent-style-name="Heading"
+ style:next-style-name="Text_20_body"
+ style:default-outline-level="4" style:class="text">
+ <style:text-properties fo:font-size="85%"
+ fo:font-style="italic" fo:font-weight="bold"
+ style:font-size-asian="85%" style:font-style-asian="italic"
+ style:font-weight-asian="bold" style:font-size-complex="85%"
+ style:font-style-complex="italic"
+ style:font-weight-complex="bold" />
+ </style:style>
+ <style:style style:name="Heading_20_5"
+ style:display-name="Heading 5" style:family="paragraph"
+ style:parent-style-name="Heading"
+ style:next-style-name="Text_20_body"
+ style:default-outline-level="5" style:class="text">
+ <style:text-properties fo:font-size="85%"
+ fo:font-weight="bold" style:font-size-asian="85%"
+ style:font-weight-asian="bold" style:font-size-complex="85%"
+ style:font-weight-complex="bold" />
+ </style:style>
+ <style:style style:name="Heading_20_6"
+ style:display-name="Heading 6" style:family="paragraph"
+ style:parent-style-name="Heading"
+ style:next-style-name="Text_20_body"
+ style:default-outline-level="6" style:class="text">
+ <style:text-properties fo:font-size="75%"
+ fo:font-weight="bold" style:font-size-asian="75%"
+ style:font-weight-asian="bold" style:font-size-complex="75%"
+ style:font-weight-complex="bold" />
+ </style:style>
+ <style:style style:name="Quotations" style:family="paragraph"
+ style:parent-style-name="Standard" style:class="html">
+ <style:paragraph-properties fo:margin-left="0.3937in"
+ fo:margin-right="0.3937in" fo:margin-top="0.1in"
+ fo:margin-bottom="0.1in" style:contextual-spacing="false"
+ fo:text-indent="0in" style:auto-text-indent="false" />
+ </style:style>
+ <style:style style:name="Preformatted_20_Text"
+ style:display-name="Preformatted Text" style:family="paragraph"
+ style:parent-style-name="Standard" style:class="html">
+ <style:paragraph-properties fo:margin-top="0in"
+ fo:margin-bottom="0in" style:contextual-spacing="false" />
+ <style:text-properties style:font-name="Courier New"
+ fo:font-size="10pt" style:font-name-asian="Courier New"
+ style:font-size-asian="10pt"
+ style:font-name-complex="Courier New"
+ style:font-size-complex="10pt" />
+ </style:style>
+ <style:style style:name="Source_Text" style:family="text">
+ <style:text-properties style:font-name="Courier New"
+ fo:font-size="10pt" style:font-name-asian="Courier New"
+ style:font-size-asian="10pt"
+ style:font-name-complex="Courier New"
+ style:font-size-complex="10pt" />
+ </style:style>
+ <style:style style:name="Definition_20_Term"
+ style:display-name="Definition Term" style:family="paragraph"
+ style:parent-style-name="Standard"
+ style:next-style-name="Definition_20_Definition">
+ <style:paragraph-properties fo:margin-top="0.0598in"
+ fo:margin-bottom="0.0598in"
+ style:contextual-spacing="false" />
+ </style:style>
+ <style:style style:name="Definition_20_Definition"
+ style:display-name="Definition Definition"
+ style:family="paragraph" style:parent-style-name="Standard"
+ style:next-style-name="Text_20_body">
+ <style:paragraph-properties fo:margin-left="0.5in"
+ fo:margin-right="0in" fo:text-indent="0in"
+ style:auto-text-indent="false" />
+ </style:style>
+ <style:style style:name="Table_20_Contents"
+ style:display-name="Table Contents" style:family="paragraph"
+ style:parent-style-name="Standard" style:class="extra">
+ <style:paragraph-properties fo:margin-left="0.0299in"
+ fo:margin-right="0.0299in" fo:text-indent="0in"
+ style:auto-text-indent="false" text:number-lines="false"
+ text:line-number="0" />
+ </style:style>
+ <style:style style:name="Table_20_Heading"
+ style:display-name="Table Heading" style:family="paragraph"
+ style:parent-style-name="Table_20_Contents"
+ style:class="extra">
+ <style:paragraph-properties fo:margin-left="0.0299in"
+ fo:margin-right="0.0299in" fo:text-align="start"
+ style:justify-single-word="false" fo:text-indent="0in"
+ style:auto-text-indent="false" style:shadow="none"
+ text:number-lines="false" text:line-number="0" />
+ <style:text-properties fo:font-weight="bold"
+ style:font-weight-asian="bold"
+ style:font-weight-complex="bold" />
+ </style:style>
+ <style:style style:name="Footnote" style:family="paragraph"
+ style:parent-style-name="Standard" style:class="extra">
+ <style:paragraph-properties fo:margin-left="0.1965in"
+ fo:margin-right="0in" fo:text-indent="-0.1965in"
+ style:auto-text-indent="false" text:number-lines="false"
+ text:line-number="0" />
+ <style:text-properties fo:font-size="10pt"
+ style:font-size-asian="10pt"
+ style:font-size-complex="10pt" />
+ </style:style>
+ <style:style style:name="Footer" style:family="paragraph"
+ style:parent-style-name="Standard" style:class="extra">
+ <style:paragraph-properties text:number-lines="false"
+ text:line-number="0">
+ <style:tab-stops>
+ <style:tab-stop style:position="3.25in"
+ style:type="center" />
+ <style:tab-stop style:position="6.5in"
+ style:type="right" />
+ </style:tab-stops>
+ </style:paragraph-properties>
+ </style:style>
+ <style:style style:name="Definition_20_Term_20_Tight"
+ style:display-name="Definition Term Tight"
+ style:family="paragraph" style:parent-style-name="Standard"
+ style:next-style-name="Definition_20_Definition_20_Tight">
+ <style:paragraph-properties fo:margin-top="0.0799in"
+ fo:margin-bottom="0.0799in"
+ style:contextual-spacing="false" />
+ </style:style>
+ <style:style style:name="Definition_20_Definition_20_Tight"
+ style:display-name="Definition Definition Tight"
+ style:family="paragraph" style:parent-style-name="Standard">
+ <style:paragraph-properties fo:margin-left="0.5in"
+ fo:margin-right="0in" fo:margin-top="0in"
+ fo:margin-bottom="0in" style:contextual-spacing="false"
+ fo:text-indent="0in" style:auto-text-indent="false" />
+ </style:style>
+ <style:style style:name="Date" style:family="paragraph"
+ style:parent-style-name="Standard"
+ style:next-style-name="Text_20_body">
+ <style:text-properties fo:font-style="italic" />
+ </style:style>
+ <style:style style:name="Author" style:family="paragraph"
+ style:parent-style-name="Standard" style:next-style-name="Date"
+ style:master-page-name="">
+ <style:paragraph-properties style:page-number="auto" />
+ <style:text-properties fo:font-style="italic" />
+ </style:style>
+ <style:style style:name="Horizontal_20_Line"
+ style:display-name="Horizontal Line" style:family="paragraph"
+ style:parent-style-name="Standard"
+ style:next-style-name="Text_20_body" style:class="html">
+ <style:paragraph-properties fo:margin-top="0in"
+ fo:margin-bottom="0.1965in" style:contextual-spacing="false"
+ style:border-line-width-bottom="0.0008in 0.0138in 0.0008in"
+ fo:padding="0in" fo:border-left="none" fo:border-right="none"
+ fo:border-top="none" fo:border-bottom="1.11pt double #808080"
+ text:number-lines="false" text:line-number="0"
+ style:join-border="false" />
+ <style:text-properties fo:font-size="6pt"
+ style:font-size-asian="6pt" style:font-size-complex="6pt" />
+ </style:style>
+ <style:style style:name="First_20_paragraph"
+ style:display-name="First paragraph" style:family="paragraph"
+ style:parent-style-name="Standard"
+ style:next-style-name="Text_20_body" style:class="text" />
+ <style:style style:name="Numbering_20_Symbols"
+ style:display-name="Numbering Symbols" style:family="text" />
+ <style:style style:name="Bullet_20_Symbols"
+ style:display-name="Bullet Symbols" style:family="text">
+ <style:text-properties style:font-name="StarSymbol"
+ fo:font-size="9pt" style:font-name-asian="StarSymbol"
+ style:font-size-asian="9pt"
+ style:font-name-complex="StarSymbol"
+ style:font-size-complex="9pt" />
+ </style:style>
+ <style:style style:name="Emphasis" style:family="text">
+ <style:text-properties fo:font-style="italic"
+ style:font-style-asian="italic"
+ style:font-style-complex="italic" />
+ </style:style>
+ <style:style style:name="Strong_20_Emphasis"
+ style:display-name="Strong Emphasis" style:family="text">
+ <style:text-properties fo:font-weight="bold"
+ style:font-weight-asian="bold"
+ style:font-weight-complex="bold" />
+ </style:style>
+ <style:style style:name="Strikeout" style:family="text">
+ <style:text-properties style:text-line-through-style="solid" />
+ </style:style>
+ <style:style style:name="Superscript" style:family="text">
+ <style:text-properties style:text-position="super 58%" />
+ </style:style>
+ <style:style style:name="Subscript" style:family="text">
+ <style:text-properties style:text-position="sub 58%" />
+ </style:style>
+ <style:style style:name="Citation" style:family="text">
+ <style:text-properties fo:font-style="italic"
+ style:font-style-asian="italic"
+ style:font-style-complex="italic" />
+ </style:style>
+ <style:style style:name="Teletype" style:family="text">
+ <style:text-properties style:font-name="Courier New"
+ style:font-name-asian="Courier New"
+ style:font-name-complex="Courier New" />
+ </style:style>
+
+ <style:style style:name="Internet_20_link"
+ style:display-name="Internet link" style:family="text">
+ <style:text-properties fo:color="#000080"
+ style:text-underline-style="solid"
+ style:text-underline-width="auto"
+ style:text-underline-color="font-color" />
+ </style:style>
+ <style:style style:name="Footnote_20_Symbol"
+ style:display-name="Footnote Symbol" style:family="text" />
+ <style:style style:name="Footnote_20_anchor"
+ style:display-name="Footnote anchor" style:family="text">
+ <style:text-properties style:text-position="super 58%" />
+ </style:style>
+ <style:style style:name="Definition" style:family="text" />
+ <text:outline-style style:name="Outline">
+ <text:outline-level-style text:level="1" style:num-format="">
+ <style:list-level-properties text:min-label-distance="0.15in" />
+ </text:outline-level-style>
+ <text:outline-level-style text:level="2" style:num-format="">
+ <style:list-level-properties text:min-label-distance="0.15in" />
+ </text:outline-level-style>
+ <text:outline-level-style text:level="3" style:num-format="">
+ <style:list-level-properties text:min-label-distance="0.15in" />
+ </text:outline-level-style>
+ <text:outline-level-style text:level="4" style:num-format="">
+ <style:list-level-properties text:min-label-distance="0.15in" />
+ </text:outline-level-style>
+ <text:outline-level-style text:level="5" style:num-format="">
+ <style:list-level-properties text:min-label-distance="0.15in" />
+ </text:outline-level-style>
+ <text:outline-level-style text:level="6" style:num-format="">
+ <style:list-level-properties text:min-label-distance="0.15in" />
+ </text:outline-level-style>
+ <text:outline-level-style text:level="7" style:num-format="">
+ <style:list-level-properties text:min-label-distance="0.15in" />
+ </text:outline-level-style>
+ <text:outline-level-style text:level="8" style:num-format="">
+ <style:list-level-properties text:min-label-distance="0.15in" />
+ </text:outline-level-style>
+ <text:outline-level-style text:level="9" style:num-format="">
+ <style:list-level-properties text:min-label-distance="0.15in" />
+ </text:outline-level-style>
+ <text:outline-level-style text:level="10"
+ style:num-format="">
+ <style:list-level-properties text:min-label-distance="0.15in" />
+ </text:outline-level-style>
+ </text:outline-style>
+ <text:list-style style:name="Numbering_20_1"
+ style:display-name="Numbering 1">
+ <text:list-level-style-number text:level="1"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="1">
+ <style:list-level-properties text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="2"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="1">
+ <style:list-level-properties text:space-before="0.1972in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="3"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="1">
+ <style:list-level-properties text:space-before="0.3937in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="4"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="1">
+ <style:list-level-properties text:space-before="0.5909in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="5"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="1">
+ <style:list-level-properties text:space-before="0.7874in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="6"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="1">
+ <style:list-level-properties text:space-before="0.9846in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="7"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="1">
+ <style:list-level-properties text:space-before="1.1815in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="8"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="1">
+ <style:list-level-properties text:space-before="1.3787in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="9"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="1">
+ <style:list-level-properties text:space-before="1.5752in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="10"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="1">
+ <style:list-level-properties text:space-before="1.7724in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ </text:list-style>
+ <text:list-style style:name="Numbering_20_2"
+ style:display-name="Numbering 2">
+ <text:list-level-style-number text:level="1"
+ text:style-name="Numbering_20_Symbols" style:num-format="1">
+ <style:list-level-properties text:min-label-width="0.1965in" />
+ </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="2">
+ <style:list-level-properties text:space-before="0.1965in"
+ text:min-label-width="0.1965in" />
+ </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="3">
+ <style:list-level-properties text:space-before="0.3929in"
+ text:min-label-width="0.3937in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="4"
+ text:style-name="Numbering_20_Symbols" style:num-format="1"
+ text:start-value="4">
+ <style:list-level-properties text:space-before="0.7866in"
+ text:min-label-width="0.4925in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="5"
+ text:style-name="Numbering_20_Symbols" style:num-format="1"
+ text:start-value="5">
+ <style:list-level-properties text:space-before="1.2791in"
+ text:min-label-width="0.5902in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="6"
+ text:style-name="Numbering_20_Symbols" style:num-format="1"
+ text:start-value="6">
+ <style:list-level-properties text:space-before="1.8693in"
+ text:min-label-width="0.7091in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="7"
+ text:style-name="Numbering_20_Symbols" style:num-format="1"
+ text:start-value="7">
+ <style:list-level-properties text:space-before="2.5783in"
+ text:min-label-width="0.9055in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="8"
+ text:style-name="Numbering_20_Symbols" style:num-format="1"
+ text:start-value="8">
+ <style:list-level-properties text:space-before="3.4839in"
+ text:min-label-width="1.0236in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="9"
+ text:style-name="Numbering_20_Symbols" style:num-format="1"
+ text:start-value="9">
+ <style:list-level-properties text:space-before="4.5075in"
+ text:min-label-width="1.1028in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="10"
+ text:style-name="Numbering_20_Symbols" style:num-format="1"
+ text:start-value="10">
+ <style:list-level-properties text:space-before="5.6102in"
+ text:min-label-width="1.2209in" />
+ </text:list-level-style-number>
+ </text:list-style>
+ <text:list-style style:name="Numbering_20_3"
+ style:display-name="Numbering 3">
+ <text:list-level-style-number text:level="1"
+ text:style-name="Numbering_20_Symbols" style:num-format="1">
+ <style:list-level-properties text:min-label-width="1.1811in" />
+ </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="2">
+ <style:list-level-properties text:space-before="1.1815in"
+ text:min-label-width="1.1811in" />
+ </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="3">
+ <style:list-level-properties text:space-before="2.3626in"
+ text:min-label-width="1.1811in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="4"
+ text:style-name="Numbering_20_Symbols" style:num-format="1"
+ text:start-value="4">
+ <style:list-level-properties text:space-before="3.5441in"
+ text:min-label-width="1.1811in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="5"
+ text:style-name="Numbering_20_Symbols" style:num-format="1"
+ text:start-value="5">
+ <style:list-level-properties text:space-before="4.7252in"
+ text:min-label-width="1.1811in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="6"
+ text:style-name="Numbering_20_Symbols" style:num-format="1"
+ text:start-value="6">
+ <style:list-level-properties text:space-before="5.9063in"
+ text:min-label-width="1.1811in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="7"
+ text:style-name="Numbering_20_Symbols" style:num-format="1"
+ text:start-value="7">
+ <style:list-level-properties text:space-before="7.0878in"
+ text:min-label-width="1.1811in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="8"
+ text:style-name="Numbering_20_Symbols" style:num-format="1"
+ text:start-value="8">
+ <style:list-level-properties text:space-before="8.2689in"
+ text:min-label-width="1.1811in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="9"
+ text:style-name="Numbering_20_Symbols" style:num-format="1"
+ text:start-value="9">
+ <style:list-level-properties text:space-before="9.45in"
+ text:min-label-width="1.1811in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="10"
+ text:style-name="Numbering_20_Symbols" style:num-format="1"
+ text:start-value="10">
+ <style:list-level-properties text:space-before="10.6315in"
+ text:min-label-width="1.1811in" />
+ </text:list-level-style-number>
+ </text:list-style>
+ <text:list-style style:name="Numbering_20_4"
+ style:display-name="Numbering 4">
+ <text:list-level-style-number text:level="1"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="I">
+ <style:list-level-properties text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="2"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="I" text:start-value="2">
+ <style:list-level-properties text:space-before="0.1972in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="3"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="I" text:start-value="3">
+ <style:list-level-properties text:space-before="0.3937in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="4"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="I" text:start-value="4">
+ <style:list-level-properties text:space-before="0.5909in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="5"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="I" text:start-value="5">
+ <style:list-level-properties text:space-before="0.7874in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="6"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="I" text:start-value="6">
+ <style:list-level-properties text:space-before="0.9846in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="7"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="I" text:start-value="7">
+ <style:list-level-properties text:space-before="1.1815in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="8"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="I" text:start-value="8">
+ <style:list-level-properties text:space-before="1.3787in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="9"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="I" text:start-value="9">
+ <style:list-level-properties text:space-before="1.5752in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="10"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="I" text:start-value="10">
+ <style:list-level-properties text:space-before="1.7724in"
+ text:min-label-width="0.1965in" />
+ </text:list-level-style-number>
+ </text:list-style>
+ <text:list-style style:name="Numbering_20_5"
+ style:display-name="Numbering 5">
+ <text:list-level-style-number text:level="1"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="1">
+ <style:list-level-properties text:min-label-width="0.1575in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="2"
+ text:style-name="Numbering_20_Symbols" style:num-suffix="."
+ style:num-format="1" text:start-value="2"
+ text:display-levels="2">
+ <style:list-level-properties text:space-before="0.1772in"
+ text:min-label-width="0.2563in" />
+ </text:list-level-style-number>
+ <text:list-level-style-number text:level="3"
+ text:style-name="Numbering_20_Symbols" style:num-suffix=")"
+ style:num-format="a" text:start-value="3">
+ <style:list-level-properties text:space-before="0.4331in"
+ text:min-label-width="0.1772in" />
+ </text:list-level-style-number>
+ <text:list-level-style-bullet text:level="4"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="0.6319in"
+ text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="5"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="0.7874in"
+ text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="6"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="0.9429in"
+ text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="7"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="1.0988in"
+ text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="8"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="1.2543in"
+ text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="9"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="1.4098in"
+ text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="10"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="1.5654in"
+ text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ </text:list-style>
+ <text:list-style style:name="List_20_1"
+ style:display-name="List 1">
+ <text:list-level-style-bullet text:level="1"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="2"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="0.1579in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="3"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="0.3146in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="4"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="0.4724in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="5"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="0.6299in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="6"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="0.7878in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="7"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="0.9445in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="8"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="1.1024in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="9"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="1.2598in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="10"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="•">
+ <style:list-level-properties text:space-before="1.4177in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ </text:list-style>
+ <text:list-style style:name="List_20_2"
+ style:display-name="List 2">
+ <text:list-level-style-bullet text:level="1"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="–">
+ <style:list-level-properties text:min-label-width="0.1181in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="2"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="–">
+ <style:list-level-properties text:space-before="0.1181in"
+ text:min-label-width="0.1181in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="3"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="–">
+ <style:list-level-properties text:space-before="0.2362in"
+ text:min-label-width="0.1181in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="4"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="–">
+ <style:list-level-properties text:space-before="0.3539in"
+ text:min-label-width="0.1181in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="5"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="–">
+ <style:list-level-properties text:space-before="0.472in"
+ text:min-label-width="0.1181in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="6"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="–">
+ <style:list-level-properties text:space-before="0.5902in"
+ text:min-label-width="0.1181in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="7"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="–">
+ <style:list-level-properties text:space-before="0.7091in"
+ text:min-label-width="0.1181in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="8"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="–">
+ <style:list-level-properties text:space-before="0.8272in"
+ text:min-label-width="0.1181in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="9"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="–">
+ <style:list-level-properties text:space-before="0.9453in"
+ text:min-label-width="0.1181in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="10"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="–">
+ <style:list-level-properties text:space-before="1.063in"
+ text:min-label-width="0.1181in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ </text:list-style>
+ <text:list-style style:name="List_20_3"
+ style:display-name="List 3">
+ <text:list-level-style-bullet text:level="1"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="☑">
+ <style:list-level-properties text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="2"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="□">
+ <style:list-level-properties text:space-before="0.1555in"
+ text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="3"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="☑">
+ <style:list-level-properties text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="4"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="□">
+ <style:list-level-properties text:space-before="0.1555in"
+ text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="5"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="☑">
+ <style:list-level-properties text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="6"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="□">
+ <style:list-level-properties text:space-before="0.1555in"
+ text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="7"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="☑">
+ <style:list-level-properties text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="8"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="□">
+ <style:list-level-properties text:space-before="0.1555in"
+ text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="9"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="☑">
+ <style:list-level-properties text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="10"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="□">
+ <style:list-level-properties text:space-before="0.1555in"
+ text:min-label-width="0.1555in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ </text:list-style>
+ <text:list-style style:name="List_20_4"
+ style:display-name="List 4">
+ <text:list-level-style-bullet text:level="1"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="➢">
+ <style:list-level-properties text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="2"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="">
+ <style:list-level-properties text:space-before="0.1579in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="3"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="">
+ <style:list-level-properties text:space-before="0.3146in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="4"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="">
+ <style:list-level-properties text:space-before="0.4724in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="5"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="">
+ <style:list-level-properties text:space-before="0.6299in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="6"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="">
+ <style:list-level-properties text:space-before="0.7878in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="7"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="">
+ <style:list-level-properties text:space-before="0.9445in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="8"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="">
+ <style:list-level-properties text:space-before="1.1024in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="9"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="">
+ <style:list-level-properties text:space-before="1.2598in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="10"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="">
+ <style:list-level-properties text:space-before="1.4177in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ </text:list-style>
+ <text:list-style style:name="List_20_5"
+ style:display-name="List 5">
+ <text:list-level-style-bullet text:level="1"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="✗">
+ <style:list-level-properties text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="2"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="✗">
+ <style:list-level-properties text:space-before="0.1579in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="3"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="✗">
+ <style:list-level-properties text:space-before="0.3146in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="4"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="✗">
+ <style:list-level-properties text:space-before="0.4724in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="5"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="✗">
+ <style:list-level-properties text:space-before="0.6299in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="6"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="✗">
+ <style:list-level-properties text:space-before="0.7878in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="7"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="✗">
+ <style:list-level-properties text:space-before="0.9445in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="8"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="✗">
+ <style:list-level-properties text:space-before="1.1024in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="9"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="✗">
+ <style:list-level-properties text:space-before="1.2598in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="10"
+ text:style-name="Numbering_20_Symbols" text:bullet-char="✗">
+ <style:list-level-properties text:space-before="1.4177in"
+ text:min-label-width="0.1575in" />
+ <style:text-properties style:font-name="StarSymbol" />
+ </text:list-level-style-bullet>
+ </text:list-style>
+ <text:notes-configuration text:note-class="footnote"
+ text:citation-style-name="Footnote_20_Symbol"
+ text:citation-body-style-name="Footnote_20_anchor"
+ style:num-format="1" text:start-value="0"
+ text:footnotes-position="page"
+ text:start-numbering-at="document" />
+ <text:notes-configuration text:note-class="endnote"
+ style:num-format="i" text:start-value="0" />
+ <text:linenumbering-configuration text:number-lines="false"
+ text:offset="0.1965in" style:num-format="1"
+ text:number-position="left" text:increment="5" />
+ </office:styles>
+ <office:automatic-styles>
+ <style:style style:name="MP1" style:family="paragraph"
+ style:parent-style-name="Footer">
+ <style:paragraph-properties fo:text-align="center"
+ style:justify-single-word="false" />
+ </style:style>
+ <style:page-layout style:name="Mpm1">
+ <style:page-layout-properties fo:page-width="8.5in"
+ fo:page-height="11in" style:num-format="1"
+ style:print-orientation="portrait" fo:margin-top="1in"
+ fo:margin-bottom="1in" fo:margin-left="1in"
+ fo:margin-right="1in" style:writing-mode="lr-tb"
+ style:footnote-max-height="0in">
+ <style:footnote-sep style:width="0.0071in"
+ style:distance-before-sep="0.0398in"
+ style:distance-after-sep="0.0398in" style:line-style="none"
+ style:adjustment="left" style:rel-width="25%"
+ style:color="#000000" />
+ </style:page-layout-properties>
+ <style:header-style />
+ <style:footer-style>
+ <style:header-footer-properties fo:min-height="0.4in"
+ fo:margin-left="0in" fo:margin-right="0in"
+ fo:margin-top="0.2in" style:dynamic-spacing="false" />
+ </style:footer-style>
+ </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+ <style:master-page style:name="Standard"
+ style:page-layout-name="Mpm1">
+ <style:footer>
+ <text:p text:style-name="MP1">
+ <text:page-number text:select-page="current">
+ 1</text:page-number>
+ </text:p>
+ </style:footer>
+ </style:master-page>
+ </office:master-styles>
+</office:document-styles>
diff --git a/data/sample.lua b/data/sample.lua
new file mode 100644
index 000000000..1e3a08731
--- /dev/null
+++ b/data/sample.lua
@@ -0,0 +1,345 @@
+-- This is a sample custom writer for pandoc. It produces output
+-- 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.
+--
+-- Invoke with: pandoc -t sample.lua
+--
+-- Note: you need not have lua installed on your system to use this
+-- custom writer. However, if you do have lua installed, you can
+-- use it to test changes to the script. 'lua sample.lua' will
+-- produce informative error messages if your code contains
+-- syntax errors.
+
+-- Character escaping
+local function escape(s, in_attribute)
+ return s:gsub("[<>&\"']",
+ function(x)
+ if x == '<' then
+ return '&lt;'
+ elseif x == '>' then
+ return '&gt;'
+ elseif x == '&' then
+ return '&amp;'
+ elseif x == '"' then
+ return '&quot;'
+ elseif x == "'" then
+ return '&#39;'
+ else
+ return x
+ end
+ end)
+end
+
+-- Helper function to convert an attributes table into
+-- a string that can be put into HTML tags.
+local function attributes(attr)
+ local attr_table = {}
+ for x,y in pairs(attr) do
+ if y and y ~= "" then
+ table.insert(attr_table, ' ' .. x .. '="' .. escape(y,true) .. '"')
+ end
+ end
+ 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 = {}
+
+-- Blocksep is used to separate block elements.
+function Blocksep()
+ return "\n\n"
+end
+
+-- This function is called once for the whole document. Parameters:
+-- body is a string, metadata is a table, variables is a table.
+-- This gives you a fragment. You could use the metadata table to
+-- fill variables in a custom lua template. Or, pass `--template=...`
+-- to pandoc, and pandoc will add do the template processing as
+-- usual.
+function Doc(body, metadata, variables)
+ local buffer = {}
+ local function add(s)
+ table.insert(buffer, s)
+ end
+ add(body)
+ if #notes > 0 then
+ add('<ol class="footnotes">')
+ for _,note in pairs(notes) do
+ add(note)
+ end
+ add('</ol>')
+ end
+ return table.concat(buffer,'\n') .. '\n'
+end
+
+-- The functions that follow render corresponding pandoc elements.
+-- s is always a string, attr is always a table of attributes, and
+-- items is always an array of strings (the items in a list).
+-- Comments indicate the types of other variables.
+
+function Str(s)
+ return escape(s)
+end
+
+function Space()
+ return " "
+end
+
+function SoftBreak()
+ return "\n"
+end
+
+function LineBreak()
+ return "<br/>"
+end
+
+function Emph(s)
+ return "<em>" .. s .. "</em>"
+end
+
+function Strong(s)
+ return "<strong>" .. s .. "</strong>"
+end
+
+function Subscript(s)
+ return "<sub>" .. s .. "</sub>"
+end
+
+function Superscript(s)
+ return "<sup>" .. s .. "</sup>"
+end
+
+function SmallCaps(s)
+ return '<span style="font-variant: small-caps;">' .. s .. '</span>'
+end
+
+function Strikeout(s)
+ return '<del>' .. s .. '</del>'
+end
+
+function Link(s, src, tit, attr)
+ return "<a href='" .. escape(src,true) .. "' title='" ..
+ escape(tit,true) .. "'>" .. s .. "</a>"
+end
+
+function Image(s, src, tit, attr)
+ return "<img src='" .. escape(src,true) .. "' title='" ..
+ escape(tit,true) .. "'/>"
+end
+
+function Code(s, attr)
+ return "<code" .. attributes(attr) .. ">" .. escape(s) .. "</code>"
+end
+
+function InlineMath(s)
+ return "\\(" .. escape(s) .. "\\)"
+end
+
+function DisplayMath(s)
+ return "\\[" .. escape(s) .. "\\]"
+end
+
+function Note(s)
+ local num = #notes + 1
+ -- insert the back reference right before the final closing tag.
+ s = string.gsub(s,
+ '(.*)</', '%1 <a href="#fnref' .. num .. '">&#8617;</a></')
+ -- add a list item with the note to the note table.
+ table.insert(notes, '<li id="fn' .. num .. '">' .. s .. '</li>')
+ -- return the footnote reference, linked to the note.
+ return '<a id="fnref' .. num .. '" href="#fn' .. num ..
+ '"><sup>' .. num .. '</sup></a>'
+end
+
+function Span(s, attr)
+ return "<span" .. attributes(attr) .. ">" .. s .. "</span>"
+end
+
+function RawInline(format, str)
+ if format == "html" then
+ return str
+ else
+ return ''
+ end
+end
+
+function Cite(s, cs)
+ local ids = {}
+ for _,cit in ipairs(cs) do
+ table.insert(ids, cit.citationId)
+ end
+ return "<span class=\"cite\" data-citation-ids=\"" .. table.concat(ids, ",") ..
+ "\">" .. s .. "</span>"
+end
+
+function Plain(s)
+ return s
+end
+
+function Para(s)
+ return "<p>" .. s .. "</p>"
+end
+
+-- lev is an integer, the header level.
+function Header(lev, s, attr)
+ return "<h" .. lev .. attributes(attr) .. ">" .. s .. "</h" .. lev .. ">"
+end
+
+function BlockQuote(s)
+ return "<blockquote>\n" .. s .. "\n</blockquote>"
+end
+
+function HorizontalRule()
+ return "<hr/>"
+end
+
+function LineBlock(ls)
+ return '<div style="white-space: pre-line;">' .. table.concat(ls, '\n') ..
+ '</div>'
+end
+
+function CodeBlock(s, attr)
+ -- 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 .. '"/>'
+ -- otherwise treat as code (one could pipe through a highlighter)
+ else
+ return "<pre><code" .. attributes(attr) .. ">" .. escape(s) ..
+ "</code></pre>"
+ end
+end
+
+function BulletList(items)
+ local buffer = {}
+ for _, item in pairs(items) do
+ table.insert(buffer, "<li>" .. item .. "</li>")
+ end
+ return "<ul>\n" .. table.concat(buffer, "\n") .. "\n</ul>"
+end
+
+function OrderedList(items)
+ local buffer = {}
+ for _, item in pairs(items) do
+ table.insert(buffer, "<li>" .. item .. "</li>")
+ end
+ return "<ol>\n" .. table.concat(buffer, "\n") .. "\n</ol>"
+end
+
+-- Revisit association list STackValue instance.
+function DefinitionList(items)
+ local buffer = {}
+ for _,item in pairs(items) do
+ for k, v in pairs(item) do
+ table.insert(buffer,"<dt>" .. k .. "</dt>\n<dd>" ..
+ table.concat(v,"</dd>\n<dd>") .. "</dd>")
+ end
+ end
+ return "<dl>\n" .. table.concat(buffer, "\n") .. "\n</dl>"
+end
+
+-- Convert pandoc alignment to something HTML can use.
+-- align is AlignLeft, AlignRight, AlignCenter, or AlignDefault.
+function html_align(align)
+ if align == 'AlignLeft' then
+ return 'left'
+ elseif align == 'AlignRight' then
+ return 'right'
+ elseif align == 'AlignCenter' then
+ return 'center'
+ else
+ return 'left'
+ end
+end
+
+function CaptionedImage(src, tit, caption, attr)
+ return '<div class="figure">\n<img src="' .. escape(src,true) ..
+ '" title="' .. escape(tit,true) .. '"/>\n' ..
+ '<p class="caption">' .. caption .. '</p>\n</div>'
+end
+
+-- Caption is a string, aligns is an array of strings,
+-- widths is an array of floats, headers is an array of
+-- strings, rows is an array of arrays of strings.
+function Table(caption, aligns, widths, headers, rows)
+ local buffer = {}
+ local function add(s)
+ table.insert(buffer, s)
+ end
+ add("<table>")
+ if caption ~= "" then
+ add("<caption>" .. caption .. "</caption>")
+ end
+ if widths and widths[1] ~= 0 then
+ for _, w in pairs(widths) do
+ add('<col width="' .. string.format("%d%%", w * 100) .. '" />')
+ end
+ end
+ local header_row = {}
+ local empty_header = true
+ for i, h in pairs(headers) do
+ local align = html_align(aligns[i])
+ table.insert(header_row,'<th align="' .. align .. '">' .. h .. '</th>')
+ empty_header = empty_header and h == ""
+ end
+ if empty_header then
+ head = ""
+ else
+ add('<tr class="header">')
+ for _,h in pairs(header_row) do
+ add(h)
+ end
+ add('</tr>')
+ end
+ local class = "even"
+ for _, row in pairs(rows) do
+ class = (class == "even" and "odd") or "even"
+ add('<tr class="' .. class .. '">')
+ for i,c in pairs(row) do
+ add('<td align="' .. html_align(aligns[i]) .. '">' .. c .. '</td>')
+ end
+ add('</tr>')
+ end
+ add('</table')
+ return table.concat(buffer,'\n')
+end
+
+function RawBlock(format, str)
+ if format == "html" then
+ return str
+ else
+ return ''
+ end
+end
+
+function Div(s, attr)
+ return "<div" .. attributes(attr) .. ">\n" .. s .. "</div>"
+end
+
+-- The following code will produce runtime warnings when you haven't defined
+-- all of the functions you need for the custom writer, so it's useful
+-- to include when you're working on a writer.
+local meta = {}
+meta.__index =
+ function(_, key)
+ io.stderr:write(string.format("WARNING: Undefined function '%s'\n",key))
+ return function() return "" end
+ end
+setmetatable(_G, meta)
+
diff --git a/README.markdown b/data/templates/README.markdown
index bf10f5b53..bf10f5b53 100644
--- a/README.markdown
+++ b/data/templates/README.markdown
diff --git a/default.asciidoc b/data/templates/default.asciidoc
index 27215469a..27215469a 100644
--- a/default.asciidoc
+++ b/data/templates/default.asciidoc
diff --git a/default.beamer b/data/templates/default.beamer
index 4f2cae89a..4f2cae89a 100644
--- a/default.beamer
+++ b/data/templates/default.beamer
diff --git a/default.commonmark b/data/templates/default.commonmark
index 95d7e52cc..95d7e52cc 100644
--- a/default.commonmark
+++ b/data/templates/default.commonmark
diff --git a/default.context b/data/templates/default.context
index 4a3457934..4a3457934 100644
--- a/default.context
+++ b/data/templates/default.context
diff --git a/default.docbook4 b/data/templates/default.docbook4
index 5313c4083..5313c4083 100644
--- a/default.docbook4
+++ b/data/templates/default.docbook4
diff --git a/default.docbook5 b/data/templates/default.docbook5
index 415ccf9c3..415ccf9c3 100644
--- a/default.docbook5
+++ b/data/templates/default.docbook5
diff --git a/default.dokuwiki b/data/templates/default.dokuwiki
index 5d210fa7d..5d210fa7d 100644
--- a/default.dokuwiki
+++ b/data/templates/default.dokuwiki
diff --git a/default.dzslides b/data/templates/default.dzslides
index 97d518931..97d518931 100644
--- a/default.dzslides
+++ b/data/templates/default.dzslides
diff --git a/default.epub2 b/data/templates/default.epub2
index afcf96a3e..afcf96a3e 100644
--- a/default.epub2
+++ b/data/templates/default.epub2
diff --git a/default.epub3 b/data/templates/default.epub3
index 8a12e0fb3..8a12e0fb3 100644
--- a/default.epub3
+++ b/data/templates/default.epub3
diff --git a/default.haddock b/data/templates/default.haddock
index 36d66c276..36d66c276 100644
--- a/default.haddock
+++ b/data/templates/default.haddock
diff --git a/default.html4 b/data/templates/default.html4
index 8caea26c8..8caea26c8 100644
--- a/default.html4
+++ b/data/templates/default.html4
diff --git a/default.html5 b/data/templates/default.html5
index 5641ecb80..5641ecb80 100644
--- a/default.html5
+++ b/data/templates/default.html5
diff --git a/default.icml b/data/templates/default.icml
index b93fa87ba..b93fa87ba 100644
--- a/default.icml
+++ b/data/templates/default.icml
diff --git a/default.latex b/data/templates/default.latex
index 030ab90f1..030ab90f1 100644
--- a/default.latex
+++ b/data/templates/default.latex
diff --git a/default.man b/data/templates/default.man
index 44b59198b..44b59198b 100644
--- a/default.man
+++ b/data/templates/default.man
diff --git a/default.markdown b/data/templates/default.markdown
index 95d7e52cc..95d7e52cc 100644
--- a/default.markdown
+++ b/data/templates/default.markdown
diff --git a/default.mediawiki b/data/templates/default.mediawiki
index 5d210fa7d..5d210fa7d 100644
--- a/default.mediawiki
+++ b/data/templates/default.mediawiki
diff --git a/default.opendocument b/data/templates/default.opendocument
index bb01d4bbb..bb01d4bbb 100644
--- a/default.opendocument
+++ b/data/templates/default.opendocument
diff --git a/default.opml b/data/templates/default.opml
index c3566d3b0..c3566d3b0 100644
--- a/default.opml
+++ b/data/templates/default.opml
diff --git a/default.org b/data/templates/default.org
index 860342ea6..860342ea6 100644
--- a/default.org
+++ b/data/templates/default.org
diff --git a/default.plain b/data/templates/default.plain
index 95d7e52cc..95d7e52cc 100644
--- a/default.plain
+++ b/data/templates/default.plain
diff --git a/default.revealjs b/data/templates/default.revealjs
index 1d356ef8d..1d356ef8d 100644
--- a/default.revealjs
+++ b/data/templates/default.revealjs
diff --git a/default.rst b/data/templates/default.rst
index 30005d19b..30005d19b 100644
--- a/default.rst
+++ b/data/templates/default.rst
diff --git a/default.rtf b/data/templates/default.rtf
index 59e132b3f..59e132b3f 100644
--- a/default.rtf
+++ b/data/templates/default.rtf
diff --git a/default.s5 b/data/templates/default.s5
index 6ab482864..6ab482864 100644
--- a/default.s5
+++ b/data/templates/default.s5
diff --git a/default.slideous b/data/templates/default.slideous
index 30c93567d..30c93567d 100644
--- a/default.slideous
+++ b/data/templates/default.slideous
diff --git a/default.slidy b/data/templates/default.slidy
index cccf3537d..cccf3537d 100644
--- a/default.slidy
+++ b/data/templates/default.slidy
diff --git a/default.tei b/data/templates/default.tei
index 3778dccd5..3778dccd5 100644
--- a/default.tei
+++ b/data/templates/default.tei
diff --git a/default.texinfo b/data/templates/default.texinfo
index 458d4fdda..458d4fdda 100644
--- a/default.texinfo
+++ b/data/templates/default.texinfo
diff --git a/default.textile b/data/templates/default.textile
index 69bd05b56..69bd05b56 100644
--- a/default.textile
+++ b/data/templates/default.textile
diff --git a/default.zimwiki b/data/templates/default.zimwiki
index 30824bd9f..30824bd9f 100644
--- a/default.zimwiki
+++ b/data/templates/default.zimwiki
diff --git a/deb/GlobalSignDomainValidationCA-SHA256-G2.pem b/deb/GlobalSignDomainValidationCA-SHA256-G2.pem
new file mode 100644
index 000000000..b9130c350
--- /dev/null
+++ b/deb/GlobalSignDomainValidationCA-SHA256-G2.pem
@@ -0,0 +1,26 @@
+-----BEGIN CERTIFICATE-----
+MIIEYzCCA0ugAwIBAgILBAAAAAABRE7wPiAwDQYJKoZIhvcNAQELBQAwVzELMAkG
+A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv
+b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw0xNDAyMjAxMDAw
+MDBaFw0yNDAyMjAxMDAwMDBaMGAxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i
+YWxTaWduIG52LXNhMTYwNAYDVQQDEy1HbG9iYWxTaWduIERvbWFpbiBWYWxpZGF0
+aW9uIENBIC0gU0hBMjU2IC0gRzIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
+AoIBAQCp3cwOs+IyOd1JIqgTaZOHiOEM7nF9vZCHll1Z8syz0lhXV/lG72wm2DZC
+jn4wsy+aPlN7H262okxFHzzTFZMcie089Ffeyr3sBppqKqAZUn9R0XQ5CJ+r69eG
+ExWXrjbDVGYOWvKgc4Ux47JkFGr/paKOJLu9hVIVonnu8LXuPbj0fYC82ZA1ZbgX
+qa2zmJ+gfn1u+z+tfMIbWTaW2jcyS0tdNQJjjtunz2LuzC7Ujcm9PGqRcqIip3It
+INH6yjfaGJjmFiRxJUvE5XuJUgkC/VkrBG7KB4HUs9ra2+PMgKhWBwZ8lgg3nds4
+tmI0kWIHdAE42HIw4uuQcSZiwFfzAgMBAAGjggElMIIBITAOBgNVHQ8BAf8EBAMC
+AQYwEgYDVR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQU6k581IAt5RWBhiaMgm3A
+mKTPlw8wRwYDVR0gBEAwPjA8BgRVHSAAMDQwMgYIKwYBBQUHAgEWJmh0dHBzOi8v
+d3d3Lmdsb2JhbHNpZ24uY29tL3JlcG9zaXRvcnkvMDMGA1UdHwQsMCowKKAmoCSG
+Imh0dHA6Ly9jcmwuZ2xvYmFsc2lnbi5uZXQvcm9vdC5jcmwwPQYIKwYBBQUHAQEE
+MTAvMC0GCCsGAQUFBzABhiFodHRwOi8vb2NzcC5nbG9iYWxzaWduLmNvbS9yb290
+cjEwHwYDVR0jBBgwFoAUYHtmGkUNl8qJUC99BM00qP/8/UswDQYJKoZIhvcNAQEL
+BQADggEBANdFnqDc4ONhWgt9d4QXLWVagpqNoycqhffJ7+mG/dRHzQFSlsVDvTex
+4bjyqdKKEYRxkRWJ3AKdC8tsM4U0KJ4gsrGX3G0LEME8zV/qXdeYMcU0mVwAYVXE
+GwJbxeOJyLS4bx448lYm6UHvPc2smU9ZSlctS32ux4j71pg79eXw6ImJuYsDy1oj
+H6T9uOr7Lp2uanMJvPzVoLVEgqtEkS5QLlfBQ9iRBIvpES5ftD953x77PzAAi1Pj
+tywdO02L3ORkHQRYM68bVeerDL8wBHTk8w4vMDmNSwSMHnVmZkngvkA0x1xaUZK6
+EjxS1QSCVS1npd+3lXzuP8MIugS+wEY=
+-----END CERTIFICATE-----
diff --git a/deb/Makefile b/deb/Makefile
new file mode 100644
index 000000000..18f7d4425
--- /dev/null
+++ b/deb/Makefile
@@ -0,0 +1,14 @@
+TREE?=HEAD
+DEBPKGVER?=1
+VAGRANTBOX?=debian/wheezy64
+
+.PHONY: package clean
+
+package:
+ VAGRANTBOX=$(VAGRANTBOX) vagrant up
+ vagrant ssh -c 'rm -rf pandoc && git clone https://github.com/jgm/pandoc && cd pandoc && git checkout -b work $(TREE) && git submodule update --init && DEBPKGVER=$(DEBPKGVER) sh -ev ./deb/make_deb.sh && cp *.deb /vagrant_data/'
+ vagrant halt
+
+clean:
+ vagrant destroy
+ -rm pandoc pandoc-citeproc
diff --git a/deb/Vagrantfile b/deb/Vagrantfile
new file mode 100644
index 000000000..182549c8c
--- /dev/null
+++ b/deb/Vagrantfile
@@ -0,0 +1,75 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+# All Vagrant configuration is done below. The "2" in Vagrant.configure
+# configures the configuration version (we support older styles for
+# backwards compatibility). Please don't change it unless you know what
+# you're doing.
+Vagrant.configure(2) do |config|
+ # The most common configuration options are documented and commented below.
+ # For a complete reference, please see the online documentation at
+ # https://docs.vagrantup.com.
+
+ # Every Vagrant development environment requires a box. You can search for
+ # boxes at https://atlas.hashicorp.com/search.
+ config.vm.box = ENV['VAGRANTBOX'] || "ubuntu/precise64"
+
+ # Disable automatic box update checking. If you disable this, then
+ # boxes will only be checked for updates when the user runs
+ # `vagrant box outdated`. This is not recommended.
+ # config.vm.box_check_update = false
+
+ # Create a forwarded port mapping which allows access to a specific port
+ # within the machine from a port on the host machine. In the example below,
+ # accessing "localhost:8080" will access port 80 on the guest machine.
+ # config.vm.network "forwarded_port", guest: 80, host: 8080
+
+ # Create a private network, which allows host-only access to the machine
+ # using a specific IP.
+ # config.vm.network "private_network", ip: "192.168.33.10"
+
+ # Create a public network, which generally matched to bridged network.
+ # Bridged networks make the machine appear as another physical device on
+ # your network.
+ # config.vm.network "public_network"
+
+ # Share an additional folder to the guest VM. The first argument is
+ # the path on the host to the actual folder. The second argument is
+ # the path on the guest to mount the folder. And the optional third
+ # argument is a set of non-required options.
+ config.vm.synced_folder "..", "/vagrant_data"
+
+ # Provider-specific configuration so you can fine-tune various
+ # backing providers for Vagrant. These expose provider-specific options.
+ # Example for VirtualBox:
+ #
+ config.vm.provider "virtualbox" do |vb|
+ # Display the VirtualBox GUI when booting the machine
+ # vb.gui = true
+
+ # Customize the amount of memory on the VM:
+ vb.memory = "2048"
+ end
+ #
+ # View the documentation for the provider you are using for more
+ # information on available options.
+
+ # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
+ # such as FTP and Heroku are also available. See the documentation at
+ # https://docs.vagrantup.com/v2/push/atlas.html for more information.
+ # config.push.define "atlas" do |push|
+ # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
+ # end
+
+ # Enable provisioning with a shell script. Additional provisioners such as
+ # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
+ # documentation for more information about their specific syntax and use.
+ config.vm.provision "shell", inline: <<-SHELL
+ wget -q https://s3.amazonaws.com/download.fpcomplete.com/debian/fpco.key
+ sudo apt-key add fpco.key
+ echo 'deb http://download.fpcomplete.com/ubuntu/precise stable main'|sudo tee /etc/apt/sources.list.d/fpco.list
+ sudo apt-get update
+ sudo apt-get install -y stack build-essential debhelper dh-make curl
+ sudo cp /vagrant_data/deb/*.pem /etc/ssl/certs/
+ SHELL
+end
diff --git a/deb/control.in b/deb/control.in
new file mode 100644
index 000000000..549f9c115
--- /dev/null
+++ b/deb/control.in
@@ -0,0 +1,20 @@
+Package: pandoc
+Version: VERSION
+Section: text
+Priority: optional
+Architecture: ARCHITECTURE
+Installed-Size: INSTALLED_SIZE
+Depends: libc6 (>= 2.13), libgmp10, zlib1g (>= 1:1.1.4)
+Maintainer: John MacFarlane <jgm@berkeley.edu>
+Description: general markup converter
+ Pandoc is a Haskell library for converting from one markup
+ format to another, and a command-line tool that uses
+ this library. It can read markdown and (subsets of) HTML,
+ reStructuredText, LaTeX, DocBook, MediaWiki markup, Twiki markup,
+ Haddock markup, OPML, Emacs Org-Mode, txt2tags and Textile, and
+ it can write markdown, reStructuredText, HTML, LaTeX, ConTeXt,
+ Docbook, OPML, OpenDocument, ODT, Word docx, RTF, MediaWiki,
+ DokuWiki, Textile, groff man pages, plain text, Emacs Org-Mode,
+ AsciiDoc, Haddock markup, EPUB (v2 and v3), FictionBook2,
+ InDesign ICML, and several kinds of HTML/javascript
+ slide shows (S5, Slidy, Slideous, DZSlides, reveal.js).
diff --git a/deb/haskell.org.pem b/deb/haskell.org.pem
new file mode 100644
index 000000000..05bdffb9a
--- /dev/null
+++ b/deb/haskell.org.pem
@@ -0,0 +1,30 @@
+-----BEGIN CERTIFICATE-----
+MIIFMjCCBBqgAwIBAgISESGwJtbMWHI+x6Mmm0FEK3WqMA0GCSqGSIb3DQEBCwUA
+MGAxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTYwNAYD
+VQQDEy1HbG9iYWxTaWduIERvbWFpbiBWYWxpZGF0aW9uIENBIC0gU0hBMjU2IC0g
+RzIwHhcNMTUxMTExMjE0NjUzWhcNMTYxMjE1MDYyODEwWjA7MSEwHwYDVQQLExhE
+b21haW4gQ29udHJvbCBWYWxpZGF0ZWQxFjAUBgNVBAMMDSouaGFza2VsbC5vcmcw
+ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDNixwKSAJbYPGflK3nO/hH
+CxigkOiKQr9q47aY9S8l0vU9ISC0eiuKkFD42ia5GzeqyBsGF4HoSF0MtBivShJz
+oxt6xFtmagKRX6VB3Qo41+36IKnqmvWE5CAoNIyoy9+ZgfKQKOaIjQzFd4edYxfa
+AQgEypRjod/BjY4NlAOILXa1L7cNQp29QkouODU5oW9mT/TWh3gNIO7cjqq+GHxh
+7/itRt7I6CJOPhEZa3UaA27yNbDsJK8dxGXeGqkUVqdoff98zO4LygyNxwIguWbD
+ektP8472N9tR4G2e/f3tnWPFzmSFIUYQPQQZsWbMi5lBVAL1IX3kgO8qgyJOQeWN
+AgMBAAGjggIJMIICBTAOBgNVHQ8BAf8EBAMCBaAwSQYDVR0gBEIwQDA+BgZngQwB
+AgEwNDAyBggrBgEFBQcCARYmaHR0cHM6Ly93d3cuZ2xvYmFsc2lnbi5jb20vcmVw
+b3NpdG9yeS8wYgYDVR0RBFswWYINKi5oYXNrZWxsLm9yZ4IYYXV0b2Rpc2NvdmVy
+Lmhhc2tlbGwub3JnghBtYWlsLmhhc2tlbGwub3Jngg9vd2EuaGFza2VsbC5vcmeC
+C2hhc2tlbGwub3JnMAkGA1UdEwQCMAAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsG
+AQUFBwMCMEMGA1UdHwQ8MDowOKA2oDSGMmh0dHA6Ly9jcmwuZ2xvYmFsc2lnbi5j
+b20vZ3MvZ3Nkb21haW52YWxzaGEyZzIuY3JsMIGUBggrBgEFBQcBAQSBhzCBhDBH
+BggrBgEFBQcwAoY7aHR0cDovL3NlY3VyZS5nbG9iYWxzaWduLmNvbS9jYWNlcnQv
+Z3Nkb21haW52YWxzaGEyZzJyMS5jcnQwOQYIKwYBBQUHMAGGLWh0dHA6Ly9vY3Nw
+Mi5nbG9iYWxzaWduLmNvbS9nc2RvbWFpbnZhbHNoYTJnMjAdBgNVHQ4EFgQUsWoN
+IkHc+WhdtDwGB4pRHYZu+x4wHwYDVR0jBBgwFoAU6k581IAt5RWBhiaMgm3AmKTP
+lw8wDQYJKoZIhvcNAQELBQADggEBADrupN5ncMzXJLUxtIkhZKJUOQByrkVqmlvO
+me3tsAQn2YccC1YPE7wlkMttV8h8JN3/CWlvcSwfncXPzDF4lV7tuunapmAJLTxz
+Iz4tCIMzKVaGaivxYe9dml9LtiicsAOo29ZGE4E+mTHXR0EBjylKn4RS5f6XLawC
+wvdzYEH6nw6XbD6PlvYjZekIcky1lZ99cqsBoYiht0PQEcj8LWcBW79o1UWYEaXv
+q8b47QhFYMQ+IKwfIo3PSWjotIBw35lnrfKlrWvqyRA5t+ollH+6X1vdYOibupts
+rUdXZCfeWcwhFiJVOrq7kxpQLNZsPq8nm55Ao2tRGsrDMwsuZhc=
+-----END CERTIFICATE-----
diff --git a/deb/make_deb.sh b/deb/make_deb.sh
new file mode 100755
index 000000000..a92c47784
--- /dev/null
+++ b/deb/make_deb.sh
@@ -0,0 +1,56 @@
+MACHINE=$(uname -m)
+case "$MACHINE" in
+ x86_64) ARCHITECTURE=amd64;;
+ i686) ARCHITECTURE=i386;;
+ i386) ARCHITECTURE=i386;;
+esac
+
+LOCAL=$HOME/.local
+VERSION=$(grep -e '^Version' pandoc.cabal | awk '{print $2}')
+DEBPKGVER=${DEBPKGVER:-1}
+DEBVER=$VERSION-$DEBPKGVER
+BASE=pandoc-$DEBVER-$ARCHITECTURE
+DIST=`pwd`/$BASE
+DEST=$DIST/usr
+ME=$(whoami)
+COPYRIGHT=$DEST/share/doc/pandoc/copyright
+
+PATH=$LOCAL/bin:$PATH
+
+mkdir -p $LOCAL/bin
+mkdir -p $DEST/bin
+mkdir -p $DEST/share/man/man1
+mkdir -p $DEST/share/doc/pandoc
+
+stack install --install-ghc --stack-yaml stack.pkg.yaml --local-bin-path $LOCAL/bin hsb2hs
+stack install --install-ghc --stack-yaml stack.pkg.yaml --local-bin-path $LOCAL/bin pandoc pandoc-citeproc
+
+make man/pandoc.1
+# get pandoc-citeproc man page:
+PANDOC_CITEPROC_VERSION=`pandoc-citeproc --version | awk '{print $2;}'`
+curl https://raw.githubusercontent.com/jgm/pandoc-citeproc/${PANDOC_CITEPROC_VERSION}/man/man1/pandoc-citeproc.1 > $DEST/share/man/man1/pandoc-citeproc.1
+
+
+mkdir -p $DEST/share/doc/pandoc-citeproc
+find $DIST -type d | xargs chmod 755
+strip $LOCAL/bin/pandoc
+strip $LOCAL/bin/pandoc-citeproc
+cp $LOCAL/bin/pandoc $DEST/bin/
+cp $LOCAL/bin/pandoc-citeproc $DEST/bin/
+cp man/pandoc.1 $DEST/share/man/man1/pandoc.1
+gzip -9 $DEST/share/man/man1/pandoc.1
+gzip -9 $DEST/share/man/man1/pandoc-citeproc.1
+cp COPYRIGHT $COPYRIGHT
+echo "" >> $COPYRIGHT
+echo "pandoc-citeproc" >> $COPYRIGHT
+curl https://raw.githubusercontent.com/jgm/pandoc-citeproc/${PANDOC_CITEPROC_VERSION}/LICENSE >> $COPYRIGHT
+
+INSTALLED_SIZE=$(du -B 1024 -s $DEST | awk '{print $1}')
+mkdir $DIST/DEBIAN
+perl -pe "s/VERSION/$DEBVER/" deb/control.in | \
+ perl -pe "s/ARCHITECTURE/$ARCHITECTURE/" | \
+ perl -pe "s/INSTALLED_SIZE/$INSTALLED_SIZE/" \
+ > $DIST/DEBIAN/control
+
+fakeroot dpkg-deb --build $DIST
+rm -rf $DIST
diff --git a/doc/customizing-pandoc.md b/doc/customizing-pandoc.md
new file mode 100644
index 000000000..37b77cf1f
--- /dev/null
+++ b/doc/customizing-pandoc.md
@@ -0,0 +1,18 @@
+# Customizing pandoc
+
+## Templates
+
+## Reference docx/odt
+
+## Custom lua writers
+
+## Custom syntax highlighting
+
+syntax definitions, styles
+
+## Filters
+
+including documentation of the JSON serialization format and
+AST definition
+
+
diff --git a/doc/using-the-pandoc-api.md b/doc/using-the-pandoc-api.md
new file mode 100644
index 000000000..b567db968
--- /dev/null
+++ b/doc/using-the-pandoc-api.md
@@ -0,0 +1,28 @@
+# Using the pandoc API
+
+## Concepts
+
+## Basic usage
+
+## The Pandoc structure
+
+## Reader options
+
+## Writer options
+
+## The PandocMonad class
+
+custom PandocMonad instances
+
+## Builder
+
+example: report from CSV data
+
+## Generic transformations
+
+Walk and syb for AST transformations
+
+## Filters
+
+writing filters in Haskell
+
diff --git a/lib/fonts/Makefile b/lib/fonts/Makefile
new file mode 100644
index 000000000..5693ee054
--- /dev/null
+++ b/lib/fonts/Makefile
@@ -0,0 +1,6 @@
+symbol.hs: symbol.txt
+ runghc parseUnicodeMapping.hs symbol.txt
+
+.PHONY: clean
+clean:
+ -rm symbol.hs
diff --git a/lib/fonts/parseUnicodeMapping.hs b/lib/fonts/parseUnicodeMapping.hs
new file mode 100644
index 000000000..4f7ff692b
--- /dev/null
+++ b/lib/fonts/parseUnicodeMapping.hs
@@ -0,0 +1,40 @@
+import System.FilePath
+import Text.Parsec
+import Data.Char
+import System.Environment
+import Control.Applicative hiding (many)
+import Data.List
+
+main :: IO ()
+main = (head <$> getArgs) >>= parseUnicodeMapping
+
+
+parseUnicodeMapping :: FilePath -> IO ()
+parseUnicodeMapping fname = do
+ fin <- readFile fname
+ let mapname = dropExtension . takeFileName $ fname
+ let res = runParse fin
+ let header = "-- Generated from " ++ fname ++ "\n" ++
+ mapname ++ " :: [(Char, Char)]\n" ++ mapname ++" =\n [ "
+ let footer = "]"
+ writeFile (replaceExtension fname ".hs")
+ (header ++ (concat $ intersperse "\n , " (map show res)) ++ footer)
+
+type Unicode = Char
+
+runParse :: String -> [(Char, Unicode)]
+runParse s= either (error . show) id (parse parseMap "" s)
+
+anyline = manyTill anyChar newline
+
+getHexChar :: Parsec String () Char
+getHexChar = do
+ [(c,_)] <- readLitChar . ("\\x" ++) <$> many1 hexDigit
+ return c
+
+parseMap :: Parsec String () [(Char, Unicode)]
+parseMap = do
+ skipMany (char '#' >> anyline)
+ many (flip (,) <$> getHexChar <* tab <*> getHexChar <* anyline)
+
+
diff --git a/lib/fonts/symbol.txt b/lib/fonts/symbol.txt
new file mode 100644
index 000000000..b98baf6cf
--- /dev/null
+++ b/lib/fonts/symbol.txt
@@ -0,0 +1,256 @@
+#
+# Name: Adobe Symbol Encoding to Unicode
+# Unicode version: 2.0
+# Table version: 1.0
+# Date: 2011 July 12
+#
+# Copyright (c) 1991-2011 Unicode, Inc. All Rights reserved.
+#
+# This file is provided as-is by Unicode, Inc. (The Unicode Consortium). No
+# claims are made as to fitness for any particular purpose. No warranties of
+# any kind are expressed or implied. The recipient agrees to determine
+# applicability of information provided. If this file has been provided on
+# magnetic media by Unicode, Inc., the sole remedy for any claim will be
+# exchange of defective media within 90 days of receipt.
+#
+# Unicode, Inc. hereby grants the right to freely use the information
+# supplied in this file in the creation of products supporting the
+# Unicode Standard, and to make copies of this file in any form for
+# internal or external distribution as long as this notice remains
+# attached.
+#
+# Format: 4 tab-delimited fields:
+#
+# (1) The Unicode value (in hexadecimal)
+# (2) The Symbol Encoding code point (in hexadecimal)
+# (3) # Unicode name
+# (4) # PostScript character name
+#
+# General Notes:
+#
+# The Unicode values in this table were produced as the result of applying
+# the algorithm described in the section "Populating a Unicode space" in the
+# document "Unicode and Glyph Names," at
+# http://partners.adobe.com/asn/developer/typeforum/unicodegn.html
+# to the characters in Symbol. Note that some characters, such as "space",
+# are mapped to 2 Unicode values. 29 characters have assignments in the
+# Corporate Use Subarea; these are indicated by "(CUS)" in field 4. Refer to
+# the above document for more details.
+#
+# 2011 July 12: The above link is no longer valid. For comparable,
+# more current information, see the document, "Glyph", at:
+# <http://www.adobe.com/devnet/opentype/archives/glyph.html>
+#
+# Revision History:
+#
+# [v1.0, 2011 July 12]
+# Updated terms of use to current wording.
+# Updated contact information and document link.
+# No changes to the mapping data.
+#
+# [v0.2, 30 March 1999]
+# Different algorithm to produce Unicode values (see notes above) results in
+# some character codes being mapped to 2 Unicode values; use of Corporate
+# Use subarea values; addition of the euro character; changed assignments of
+# some characters such as the COPYRIGHT SIGNs and RADICAL EXTENDER. Updated
+# Unicode names to Unicode 2.0 names.
+#
+# [v0.1, 5 May 1995] First release.
+#
+# Use the Unicode reporting form <http://www.unicode.org/reporting.html>
+# for any questions or comments or to report errors in the data.
+#
+0020 20 # SPACE # space
+00A0 20 # NO-BREAK SPACE # space
+0021 21 # EXCLAMATION MARK # exclam
+2200 22 # FOR ALL # universal
+0023 23 # NUMBER SIGN # numbersign
+2203 24 # THERE EXISTS # existential
+0025 25 # PERCENT SIGN # percent
+0026 26 # AMPERSAND # ampersand
+220B 27 # CONTAINS AS MEMBER # suchthat
+0028 28 # LEFT PARENTHESIS # parenleft
+0029 29 # RIGHT PARENTHESIS # parenright
+2217 2A # ASTERISK OPERATOR # asteriskmath
+002B 2B # PLUS SIGN # plus
+002C 2C # COMMA # comma
+2212 2D # MINUS SIGN # minus
+002E 2E # FULL STOP # period
+002F 2F # SOLIDUS # slash
+0030 30 # DIGIT ZERO # zero
+0031 31 # DIGIT ONE # one
+0032 32 # DIGIT TWO # two
+0033 33 # DIGIT THREE # three
+0034 34 # DIGIT FOUR # four
+0035 35 # DIGIT FIVE # five
+0036 36 # DIGIT SIX # six
+0037 37 # DIGIT SEVEN # seven
+0038 38 # DIGIT EIGHT # eight
+0039 39 # DIGIT NINE # nine
+003A 3A # COLON # colon
+003B 3B # SEMICOLON # semicolon
+003C 3C # LESS-THAN SIGN # less
+003D 3D # EQUALS SIGN # equal
+003E 3E # GREATER-THAN SIGN # greater
+003F 3F # QUESTION MARK # question
+2245 40 # APPROXIMATELY EQUAL TO # congruent
+0391 41 # GREEK CAPITAL LETTER ALPHA # Alpha
+0392 42 # GREEK CAPITAL LETTER BETA # Beta
+03A7 43 # GREEK CAPITAL LETTER CHI # Chi
+0394 44 # GREEK CAPITAL LETTER DELTA # Delta
+2206 44 # INCREMENT # Delta
+0395 45 # GREEK CAPITAL LETTER EPSILON # Epsilon
+03A6 46 # GREEK CAPITAL LETTER PHI # Phi
+0393 47 # GREEK CAPITAL LETTER GAMMA # Gamma
+0397 48 # GREEK CAPITAL LETTER ETA # Eta
+0399 49 # GREEK CAPITAL LETTER IOTA # Iota
+03D1 4A # GREEK THETA SYMBOL # theta1
+039A 4B # GREEK CAPITAL LETTER KAPPA # Kappa
+039B 4C # GREEK CAPITAL LETTER LAMDA # Lambda
+039C 4D # GREEK CAPITAL LETTER MU # Mu
+039D 4E # GREEK CAPITAL LETTER NU # Nu
+039F 4F # GREEK CAPITAL LETTER OMICRON # Omicron
+03A0 50 # GREEK CAPITAL LETTER PI # Pi
+0398 51 # GREEK CAPITAL LETTER THETA # Theta
+03A1 52 # GREEK CAPITAL LETTER RHO # Rho
+03A3 53 # GREEK CAPITAL LETTER SIGMA # Sigma
+03A4 54 # GREEK CAPITAL LETTER TAU # Tau
+03A5 55 # GREEK CAPITAL LETTER UPSILON # Upsilon
+03C2 56 # GREEK SMALL LETTER FINAL SIGMA # sigma1
+03A9 57 # GREEK CAPITAL LETTER OMEGA # Omega
+2126 57 # OHM SIGN # Omega
+039E 58 # GREEK CAPITAL LETTER XI # Xi
+03A8 59 # GREEK CAPITAL LETTER PSI # Psi
+0396 5A # GREEK CAPITAL LETTER ZETA # Zeta
+005B 5B # LEFT SQUARE BRACKET # bracketleft
+2234 5C # THEREFORE # therefore
+005D 5D # RIGHT SQUARE BRACKET # bracketright
+22A5 5E # UP TACK # perpendicular
+005F 5F # LOW LINE # underscore
+F8E5 60 # RADICAL EXTENDER # radicalex (CUS)
+03B1 61 # GREEK SMALL LETTER ALPHA # alpha
+03B2 62 # GREEK SMALL LETTER BETA # beta
+03C7 63 # GREEK SMALL LETTER CHI # chi
+03B4 64 # GREEK SMALL LETTER DELTA # delta
+03B5 65 # GREEK SMALL LETTER EPSILON # epsilon
+03C6 66 # GREEK SMALL LETTER PHI # phi
+03B3 67 # GREEK SMALL LETTER GAMMA # gamma
+03B7 68 # GREEK SMALL LETTER ETA # eta
+03B9 69 # GREEK SMALL LETTER IOTA # iota
+03D5 6A # GREEK PHI SYMBOL # phi1
+03BA 6B # GREEK SMALL LETTER KAPPA # kappa
+03BB 6C # GREEK SMALL LETTER LAMDA # lambda
+00B5 6D # MICRO SIGN # mu
+03BC 6D # GREEK SMALL LETTER MU # mu
+03BD 6E # GREEK SMALL LETTER NU # nu
+03BF 6F # GREEK SMALL LETTER OMICRON # omicron
+03C0 70 # GREEK SMALL LETTER PI # pi
+03B8 71 # GREEK SMALL LETTER THETA # theta
+03C1 72 # GREEK SMALL LETTER RHO # rho
+03C3 73 # GREEK SMALL LETTER SIGMA # sigma
+03C4 74 # GREEK SMALL LETTER TAU # tau
+03C5 75 # GREEK SMALL LETTER UPSILON # upsilon
+03D6 76 # GREEK PI SYMBOL # omega1
+03C9 77 # GREEK SMALL LETTER OMEGA # omega
+03BE 78 # GREEK SMALL LETTER XI # xi
+03C8 79 # GREEK SMALL LETTER PSI # psi
+03B6 7A # GREEK SMALL LETTER ZETA # zeta
+007B 7B # LEFT CURLY BRACKET # braceleft
+007C 7C # VERTICAL LINE # bar
+007D 7D # RIGHT CURLY BRACKET # braceright
+223C 7E # TILDE OPERATOR # similar
+20AC A0 # EURO SIGN # Euro
+03D2 A1 # GREEK UPSILON WITH HOOK SYMBOL # Upsilon1
+2032 A2 # PRIME # minute
+2264 A3 # LESS-THAN OR EQUAL TO # lessequal
+2044 A4 # FRACTION SLASH # fraction
+2215 A4 # DIVISION SLASH # fraction
+221E A5 # INFINITY # infinity
+0192 A6 # LATIN SMALL LETTER F WITH HOOK # florin
+2663 A7 # BLACK CLUB SUIT # club
+2666 A8 # BLACK DIAMOND SUIT # diamond
+2665 A9 # BLACK HEART SUIT # heart
+2660 AA # BLACK SPADE SUIT # spade
+2194 AB # LEFT RIGHT ARROW # arrowboth
+2190 AC # LEFTWARDS ARROW # arrowleft
+2191 AD # UPWARDS ARROW # arrowup
+2192 AE # RIGHTWARDS ARROW # arrowright
+2193 AF # DOWNWARDS ARROW # arrowdown
+00B0 B0 # DEGREE SIGN # degree
+00B1 B1 # PLUS-MINUS SIGN # plusminus
+2033 B2 # DOUBLE PRIME # second
+2265 B3 # GREATER-THAN OR EQUAL TO # greaterequal
+00D7 B4 # MULTIPLICATION SIGN # multiply
+221D B5 # PROPORTIONAL TO # proportional
+2202 B6 # PARTIAL DIFFERENTIAL # partialdiff
+2022 B7 # BULLET # bullet
+00F7 B8 # DIVISION SIGN # divide
+2260 B9 # NOT EQUAL TO # notequal
+2261 BA # IDENTICAL TO # equivalence
+2248 BB # ALMOST EQUAL TO # approxequal
+2026 BC # HORIZONTAL ELLIPSIS # ellipsis
+F8E6 BD # VERTICAL ARROW EXTENDER # arrowvertex (CUS)
+F8E7 BE # HORIZONTAL ARROW EXTENDER # arrowhorizex (CUS)
+21B5 BF # DOWNWARDS ARROW WITH CORNER LEFTWARDS # carriagereturn
+2135 C0 # ALEF SYMBOL # aleph
+2111 C1 # BLACK-LETTER CAPITAL I # Ifraktur
+211C C2 # BLACK-LETTER CAPITAL R # Rfraktur
+2118 C3 # SCRIPT CAPITAL P # weierstrass
+2297 C4 # CIRCLED TIMES # circlemultiply
+2295 C5 # CIRCLED PLUS # circleplus
+2205 C6 # EMPTY SET # emptyset
+2229 C7 # INTERSECTION # intersection
+222A C8 # UNION # union
+2283 C9 # SUPERSET OF # propersuperset
+2287 CA # SUPERSET OF OR EQUAL TO # reflexsuperset
+2284 CB # NOT A SUBSET OF # notsubset
+2282 CC # SUBSET OF # propersubset
+2286 CD # SUBSET OF OR EQUAL TO # reflexsubset
+2208 CE # ELEMENT OF # element
+2209 CF # NOT AN ELEMENT OF # notelement
+2220 D0 # ANGLE # angle
+2207 D1 # NABLA # gradient
+F6DA D2 # REGISTERED SIGN SERIF # registerserif (CUS)
+F6D9 D3 # COPYRIGHT SIGN SERIF # copyrightserif (CUS)
+F6DB D4 # TRADE MARK SIGN SERIF # trademarkserif (CUS)
+220F D5 # N-ARY PRODUCT # product
+221A D6 # SQUARE ROOT # radical
+22C5 D7 # DOT OPERATOR # dotmath
+00AC D8 # NOT SIGN # logicalnot
+2227 D9 # LOGICAL AND # logicaland
+2228 DA # LOGICAL OR # logicalor
+21D4 DB # LEFT RIGHT DOUBLE ARROW # arrowdblboth
+21D0 DC # LEFTWARDS DOUBLE ARROW # arrowdblleft
+21D1 DD # UPWARDS DOUBLE ARROW # arrowdblup
+21D2 DE # RIGHTWARDS DOUBLE ARROW # arrowdblright
+21D3 DF # DOWNWARDS DOUBLE ARROW # arrowdbldown
+25CA E0 # LOZENGE # lozenge
+2329 E1 # LEFT-POINTING ANGLE BRACKET # angleleft
+F8E8 E2 # REGISTERED SIGN SANS SERIF # registersans (CUS)
+F8E9 E3 # COPYRIGHT SIGN SANS SERIF # copyrightsans (CUS)
+F8EA E4 # TRADE MARK SIGN SANS SERIF # trademarksans (CUS)
+2211 E5 # N-ARY SUMMATION # summation
+F8EB E6 # LEFT PAREN TOP # parenlefttp (CUS)
+F8EC E7 # LEFT PAREN EXTENDER # parenleftex (CUS)
+F8ED E8 # LEFT PAREN BOTTOM # parenleftbt (CUS)
+F8EE E9 # LEFT SQUARE BRACKET TOP # bracketlefttp (CUS)
+F8EF EA # LEFT SQUARE BRACKET EXTENDER # bracketleftex (CUS)
+F8F0 EB # LEFT SQUARE BRACKET BOTTOM # bracketleftbt (CUS)
+F8F1 EC # LEFT CURLY BRACKET TOP # bracelefttp (CUS)
+F8F2 ED # LEFT CURLY BRACKET MID # braceleftmid (CUS)
+F8F3 EE # LEFT CURLY BRACKET BOTTOM # braceleftbt (CUS)
+F8F4 EF # CURLY BRACKET EXTENDER # braceex (CUS)
+232A F1 # RIGHT-POINTING ANGLE BRACKET # angleright
+222B F2 # INTEGRAL # integral
+2320 F3 # TOP HALF INTEGRAL # integraltp
+F8F5 F4 # INTEGRAL EXTENDER # integralex (CUS)
+2321 F5 # BOTTOM HALF INTEGRAL # integralbt
+F8F6 F6 # RIGHT PAREN TOP # parenrighttp (CUS)
+F8F7 F7 # RIGHT PAREN EXTENDER # parenrightex (CUS)
+F8F8 F8 # RIGHT PAREN BOTTOM # parenrightbt (CUS)
+F8F9 F9 # RIGHT SQUARE BRACKET TOP # bracketrighttp (CUS)
+F8FA FA # RIGHT SQUARE BRACKET EXTENDER # bracketrightex (CUS)
+F8FB FB # RIGHT SQUARE BRACKET BOTTOM # bracketrightbt (CUS)
+F8FC FC # RIGHT CURLY BRACKET TOP # bracerighttp (CUS)
+F8FD FD # RIGHT CURLY BRACKET MID # bracerightmid (CUS)
+F8FE FE # RIGHT CURLY BRACKET BOTTOM # bracerightbt (CUS)
diff --git a/macos/distribution.xml.in b/macos/distribution.xml.in
new file mode 100644
index 000000000..145fc0f21
--- /dev/null
+++ b/macos/distribution.xml.in
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<installer-gui-script minSpecVersion="1">
+ <title>pandoc</title>
+ <organization>net.johnmacfarlane.pandoc</organization>
+ <domains enable_localSystem="true" enable_anywhere="true" />
+ <options customize="allow" require-scripts="false" rootVolumeOnly="false" />
+ <!-- Define documents displayed at various steps -->
+ <!-- <welcome file="welcome.html" mime-type="text/html" /> -->
+ <license file="license.html" mime-type="text/html" />
+ <!-- <conclusion file="conclusion.html" mime-type="text/html" /> -->
+ <options hostArchitectures="x86_64" />
+ <!-- List all component packages -->
+ <pkg-ref id="net.johnmacfarlane.pandoc"
+ version="PANDOCVERSION"
+ auth="root">pandoc.pkg</pkg-ref>
+ <!-- List them again here. They can now be organized
+ as a hierarchy if you want. -->
+ <choices-outline>
+ <line choice="net.johnmacfarlane.pandoc"/>
+ </choices-outline>
+ <!-- Define each choice above -->
+ <choice
+ id="net.johnmacfarlane.pandoc"
+ visible="false"
+ title="pandoc"
+ description="pandoc - universal text converter"
+ start_selected="true">
+ <pkg-ref id="net.johnmacfarlane.pandoc"/>
+ </choice>
+</installer-gui-script>
diff --git a/macos/make_macos_package.sh b/macos/make_macos_package.sh
new file mode 100755
index 000000000..911219f14
--- /dev/null
+++ b/macos/make_macos_package.sh
@@ -0,0 +1,75 @@
+#!/bin/bash -e
+
+LOCALBIN=$HOME/.local/bin
+DIST=`pwd`/macos_package
+MACOS=`pwd`/macos
+VERSION=$(grep -e '^Version' pandoc.cabal | awk '{print $2}')
+RESOURCES=$DIST/Resources
+ROOT=$DIST/pandoc
+DEST=$ROOT/usr/local
+SCRIPTS=$MACOS/macos-resources
+BASE=pandoc-$VERSION
+ME=$(whoami)
+PACKAGEMAKER=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
+DEVELOPER_ID_APPLICATION=${DEVELOPER_ID_APPLICATION:-Developer ID Application: John Macfarlane}
+DEVELOPER_ID_INSTALLER=${DEVELOPER_ID_INSTALLER:-Developer ID Installer: John Macfarlane}
+
+# We need this for hsb2hs:
+PATH=$LOCALBIN:$PATH
+export MACMACOS_DEPLOYMENT_TARGET=10.7
+
+# echo Removing old files...
+rm -rf $DIST
+mkdir -p $DIST
+mkdir -p $RESOURCES
+stack setup
+which hsb2hs || stack install hsb2hs
+which cpphs || stack install cpphs
+
+echo Building pandoc...
+stack clean
+stack install --stack-yaml=stack.pkg.yaml --local-bin-path . pandoc pandoc-citeproc
+
+echo Getting man pages...
+make man/pandoc.1
+
+# get pandoc-citeproc man page:
+PANDOC_CITEPROC_VERSION=`pandoc-citeproc --version | awk '{print $2;}'`
+PANDOC_CITEPROC_TARBALL=https://hackage.haskell.org/package/pandoc-citeproc-${PANDOC_CITEPROC_VERSION}/pandoc-citeproc-${PANDOC_CITEPROC_VERSION}.tar.gz
+curl ${PANDOC_CITEPROC_TARBALL} | tar xzC $DIST
+PANDOC_CITEPROC_PATH=$DIST/pandoc-citeproc-${PANDOC_CITEPROC_VERSION}
+
+mkdir -p $DEST/bin
+mkdir -p $DEST/share/man/man1
+for f in pandoc pandoc-citeproc; do
+ cp $MACOS/$f $DEST/bin/;
+done
+cp $PANDOC_CITEPROC_PATH/man/man1/pandoc-citeproc.1 $DEST/share/man/man1/
+cp man/pandoc.1 $DEST/share/man/man1/
+
+chown -R $ME:staff $DIST
+
+echo Copying license...
+$MACOS/pandoc --data data -t html5 -s COPYING.md -o $RESOURCES/license.html
+
+# Removing executable signing because of a problem that arose in El Capitan
+# "source=obsolete resource envelope"
+
+#echo Signing pandoc executable...
+
+#codesign --force --sign "${DEVELOPER_ID_APPLICATION}" $DEST/bin/pandoc
+# make sure it's valid... returns nonzero exit code if it isn't:
+#spctl --assess --type execute $DEST/bin/pandoc
+
+echo Creating MacOS package...
+
+sed -e "s/PANDOCVERSION/$VERSION/" $MACOS/distribution.xml.in > $MACOS/distribution.xml
+
+pkgbuild --root $DIST/pandoc --identifier net.johnmacfarlane.pandoc --version 1.13 --ownership recommended $DIST/pandoc.pkg
+productbuild --distribution $MACOS/distribution.xml --resources $DIST/Resources --package-path $DIST --version $VERSION --sign "${DEVELOPER_ID_INSTALLER}" $BASE-MacOS.pkg
+
+# verify signature
+spctl --assess --type install $BASE-MacOS.pkg
+
+# cleanup
+rm -r $DIST $MACOS/pandoc $MACOS/pandoc-citeproc
diff --git a/macos/uninstall-pandoc.pl b/macos/uninstall-pandoc.pl
new file mode 100755
index 000000000..a5194d9bd
--- /dev/null
+++ b/macos/uninstall-pandoc.pl
@@ -0,0 +1,79 @@
+#!/usr/bin/perl
+
+# Script to remove all files installed by the OSX pandoc installer
+# and unregister the package. Modified from a script contributed
+# by Daniel T. Staal.
+
+use warnings;
+use strict;
+
+use File::Spec;
+
+# The main info: this is the list of files to remove and the pkg_id.
+my $pkg_id = 'net.johnmacfarlane.pandoc';
+
+# Find which, if any, volume Pandoc is installed on.
+my $volume;
+
+# First check /, then other volumes on the box.
+my $cur_test = `pkgutil --pkgs=$pkg_id`;
+if ( $cur_test =~ m/$pkg_id/ ) {
+ $volume = '/';
+} else {
+ opendir( my $dh, '/Volumes' ) or die "Can't list Volumes: $!\n";
+ foreach my $dir ( readdir($dh) ) {
+ next if $dir =~ m/^\./; # Skip dotfiles.
+
+ my $path = File::Spec->rel2abs( $dir, '/Volumes' );
+ next if !( -d $path ); # Skip anything that isn't a directory.
+
+ my $cur_test = `pkgutil --pkgs=$pkg_id --volume '$path'`;
+ if ( $cur_test =~ m/$pkg_id/ ) {
+ $volume = $path;
+ last;
+ }
+ }
+}
+
+die "Pandoc not installed.\n" if !( defined($volume) );
+
+# Get the list of files to remove.
+my @pkg_files = `pkgutil --volume '$volume' --only-files --files '$pkg_id'`;
+@pkg_files = map { chomp; File::Spec->rel2abs($_, $volume) } @pkg_files;
+
+# Confirm uninistall with the user.
+print "The following files will be deleted:\n\n";
+print join("\n", @pkg_files);
+print "\n\n";
+print "Do you want to proceed and uninstall pandoc (Y/N)?";
+my $input = <STDIN>;
+
+if ($input =~ m/^[Yy]/) {
+
+ # Actually remove the files.
+ foreach my $file (@pkg_files) {
+ if ( -e $file ) {
+ if ( system( 'sudo', 'rm', $file ) == 0 ) {
+ warn "Deleted $file\n";
+ } else {
+ warn "Unable to delete $file: $?\n";
+ die "Aborting Uninstall.\n";
+ }
+ } else {
+ warn "File $file does not exist. Skipping.\n";
+ }
+ }
+
+ # Clean up the install.
+ if (system('sudo', 'pkgutil', '--forget', $pkg_id, '--volume', $volume) != 0) {
+ die "Unable to clean up install: $?\n";
+ }
+
+} else {
+
+ print "OK, aborting uninstall.\n";
+ exit;
+}
+
+print "Pandoc has been successfully uninstalled.\n";
+exit;
diff --git a/man/capitalizeHeaders.hs b/man/capitalizeHeaders.hs
new file mode 100644
index 000000000..863381c1f
--- /dev/null
+++ b/man/capitalizeHeaders.hs
@@ -0,0 +1,20 @@
+import Text.Pandoc.JSON
+import Text.Pandoc.Walk
+import Data.Char (toUpper)
+
+main :: IO ()
+main = toJSONFilter capitalizeHeaders
+
+capitalizeHeaders :: Block -> Block
+capitalizeHeaders (Header 1 attr xs) = Header 1 attr $ walk capitalize xs
+capitalizeHeaders x = x
+
+capitalize :: Inline -> Inline
+capitalize (Str xs) = Str $ map toUpper xs
+capitalize x = x
+
+{-
+capitalizeHeaderLinks :: Inline -> Inline
+capitalizeHeaderLinks (Link xs t@('#':_,_)) = Link (walk capitalize xs) t
+capitalizeHeaderLinks x = x
+-}
diff --git a/man/pandoc.1 b/man/pandoc.1
new file mode 100644
index 000000000..a9cb65854
--- /dev/null
+++ b/man/pandoc.1
@@ -0,0 +1,5092 @@
+.\"t
+.TH PANDOC 1 "January 29, 2017" "pandoc 1.19.2"
+.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.
+It can read Markdown, CommonMark, PHP Markdown Extra, GitHub\-Flavored
+Markdown, MultiMarkdown, and (subsets of) Textile, reStructuredText,
+HTML, LaTeX, MediaWiki markup, TWiki markup, Haddock markup, OPML, Emacs
+Org mode, DocBook, txt2tags, EPUB, ODT and Word docx; and it can write
+plain text, Markdown, CommonMark, PHP Markdown Extra, GitHub\-Flavored
+Markdown, MultiMarkdown, reStructuredText, XHTML, HTML5, LaTeX
+(including \f[C]beamer\f[] slide shows), ConTeXt, RTF, OPML, DocBook,
+OpenDocument, ODT, Word docx, GNU Texinfo, MediaWiki markup, DokuWiki
+markup, ZimWiki markup, Haddock markup, EPUB (v2 or v3), FictionBook2,
+Textile, groff man pages, Emacs Org mode, AsciiDoc, InDesign ICML, TEI
+Simple, and Slidy, Slideous, DZSlides, reveal.js or S5 HTML slide shows.
+It can also produce PDF output on systems where LaTeX, ConTeXt, or
+\f[C]wkhtmltopdf\f[] is installed.
+.PP
+Pandoc's enhanced version of Markdown includes syntax for footnotes,
+tables, flexible ordered lists, definition lists, fenced code blocks,
+superscripts and subscripts, strikeout, metadata blocks, automatic
+tables of contents, embedded LaTeX math, citations, and Markdown inside
+HTML block elements.
+(These enhancements, described further under Pandoc's Markdown, can be
+disabled using the \f[C]markdown_strict\f[] input or output format.)
+.PP
+In contrast to most existing tools for converting Markdown to HTML,
+which use regex substitutions, pandoc has a modular design: it consists
+of a set of readers, which parse text in a given format and produce a
+native representation of the document, and a set of writers, which
+convert this native representation into a target format.
+Thus, adding an input or output format requires only adding a reader or
+writer.
+.PP
+Because pandoc's intermediate representation of a document is less
+expressive than many of the formats it converts between, one should not
+expect perfect conversions between every format and every other.
+Pandoc attempts to preserve the structural elements of a document, but
+not formatting details such as margin size.
+And some document elements, such as complex tables, may not fit into
+pandoc's simple document model.
+While conversions from pandoc's Markdown to all formats aspire to be
+perfect, conversions from formats more expressive than pandoc's Markdown
+can be expected to be lossy.
+.SS Using \f[C]pandoc\f[]
+.PP
+If no \f[I]input\-file\f[] is specified, input is read from
+\f[I]stdin\f[].
+Otherwise, the \f[I]input\-files\f[] are concatenated (with a blank line
+between each) and used as input.
+Output goes to \f[I]stdout\f[] by default (though output to
+\f[I]stdout\f[] is disabled for the \f[C]odt\f[], \f[C]docx\f[],
+\f[C]epub\f[], and \f[C]epub3\f[] output formats).
+For output to a file, use the \f[C]\-o\f[] option:
+.IP
+.nf
+\f[C]
+pandoc\ \-o\ output.html\ input.txt
+\f[]
+.fi
+.PP
+By default, pandoc produces a document fragment, not a standalone
+document with a proper header and footer.
+To produce a standalone document, 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
+Instead of a file, an absolute URI may be given.
+In this case pandoc will fetch the content using HTTP:
+.IP
+.nf
+\f[C]
+pandoc\ \-f\ html\ \-t\ markdown\ http://www.fsf.org
+\f[]
+.fi
+.PP
+If multiple input files are given, \f[C]pandoc\f[] will concatenate them
+all (with blank lines between them) before parsing.
+This feature is disabled for binary input formats such as \f[C]EPUB\f[],
+\f[C]odt\f[], and \f[C]docx\f[].
+.PP
+The format of the input and output can be specified explicitly using
+command\-line options.
+The input format can be specified using the \f[C]\-r/\-\-read\f[] or
+\f[C]\-f/\-\-from\f[] options, the output format using the
+\f[C]\-w/\-\-write\f[] or \f[C]\-t/\-\-to\f[] options.
+Thus, to convert \f[C]hello.txt\f[] from Markdown to LaTeX, you could
+type:
+.IP
+.nf
+\f[C]
+pandoc\ \-f\ markdown\ \-t\ latex\ hello.txt
+\f[]
+.fi
+.PP
+To convert \f[C]hello.html\f[] from HTML to Markdown:
+.IP
+.nf
+\f[C]
+pandoc\ \-f\ html\ \-t\ markdown\ hello.html
+\f[]
+.fi
+.PP
+Supported output formats are listed below under the \f[C]\-t/\-\-to\f[]
+option.
+Supported input formats are listed below under the \f[C]\-f/\-\-from\f[]
+option.
+Note that the \f[C]rst\f[], \f[C]textile\f[], \f[C]latex\f[], and
+\f[C]html\f[] readers are not complete; there are some constructs that
+they do not parse.
+.PP
+If the input or output format is not specified explicitly,
+\f[C]pandoc\f[] will attempt to guess it from the extensions of the
+input and output filenames.
+Thus, for example,
+.IP
+.nf
+\f[C]
+pandoc\ \-o\ hello.tex\ hello.txt
+\f[]
+.fi
+.PP
+will convert \f[C]hello.txt\f[] from Markdown to LaTeX.
+If no output file is specified (so that output goes to \f[I]stdout\f[]),
+or if the output file'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' extensions are unknown, the input format will be
+assumed to be Markdown unless explicitly specified.
+.PP
+Pandoc uses the UTF\-8 character encoding for both input and output.
+If your local character encoding is not UTF\-8, you should pipe input
+and output through \f[C]iconv\f[]:
+.IP
+.nf
+\f[C]
+iconv\ \-t\ utf\-8\ input.txt\ |\ pandoc\ |\ iconv\ \-f\ utf\-8
+\f[]
+.fi
+.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.
+By default, pandoc will use LaTeX to convert it to PDF:
+.IP
+.nf
+\f[C]
+pandoc\ test.txt\ \-o\ test.pdf
+\f[]
+.fi
+.PP
+Production of a PDF requires that a LaTeX engine be installed (see
+\f[C]\-\-latex\-engine\f[], below), and assumes that the following LaTeX
+packages are available: \f[C]amsfonts\f[], \f[C]amsmath\f[],
+\f[C]lm\f[], \f[C]ifxetex\f[], \f[C]ifluatex\f[], \f[C]eurosym\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]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]mathspec\f[],
+\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).
+The \f[C]upquote\f[] and \f[C]microtype\f[] packages are used if
+available, and \f[C]csquotes\f[] will be used for smart punctuation if
+added to the template or included in any header file.
+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.
+These are included with all recent versions of TeX Live.
+.PP
+Alternatively, pandoc can use ConTeXt or \f[C]wkhtmltopdf\f[] to create
+a PDF.
+To do this, specify an output file with a \f[C]\&.pdf\f[] extension, as
+before, but add \f[C]\-t\ context\f[] or \f[C]\-t\ html5\f[] to the
+command line.
+.PP
+PDF output can be controlled using variables for LaTeX (if LaTeX is
+used) and variables for ConTeXt (if ConTeXt is used).
+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[], and \f[C]papersize\f[] will affect the output,
+as will \f[C]\-\-css\f[].
+.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 \f[C]native\f[] (native Haskell), \f[C]json\f[]
+(JSON version of native AST), \f[C]markdown\f[] (pandoc's extended
+Markdown), \f[C]markdown_strict\f[] (original unextended Markdown),
+\f[C]markdown_phpextra\f[] (PHP Markdown Extra),
+\f[C]markdown_github\f[] (GitHub\-Flavored Markdown),
+\f[C]markdown_mmd\f[] (MultiMarkdown), \f[C]commonmark\f[] (CommonMark
+Markdown), \f[C]textile\f[] (Textile), \f[C]rst\f[] (reStructuredText),
+\f[C]html\f[] (HTML), \f[C]docbook\f[] (DocBook), \f[C]t2t\f[]
+(txt2tags), \f[C]docx\f[] (docx), \f[C]odt\f[] (ODT), \f[C]epub\f[]
+(EPUB), \f[C]opml\f[] (OPML), \f[C]org\f[] (Emacs Org mode),
+\f[C]mediawiki\f[] (MediaWiki markup), \f[C]twiki\f[] (TWiki markup),
+\f[C]haddock\f[] (Haddock markup), or \f[C]latex\f[] (LaTeX).
+If \f[C]+lhs\f[] is appended to \f[C]markdown\f[], \f[C]rst\f[],
+\f[C]latex\f[], or \f[C]html\f[], the input will be treated as literate
+Haskell source: see Literate Haskell support, below.
+Markdown syntax extensions can be individually enabled or disabled by
+appending \f[C]+EXTENSION\f[] or \f[C]\-EXTENSION\f[] to the format
+name.
+So, for example, \f[C]markdown_strict+footnotes+definition_lists\f[] is
+strict Markdown with footnotes and definition lists enabled, and
+\f[C]markdown\-pipe_tables+hard_line_breaks\f[] is pandoc's Markdown
+without pipe tables and with hard line breaks.
+See Pandoc's Markdown, below, for a list of extensions and their names.
+See \f[C]\-\-list\-input\-formats\f[] and \f[C]\-\-list\-extensions\f[],
+below.
+.RS
+.RE
+.TP
+.B \f[C]\-t\f[] \f[I]FORMAT\f[], \f[C]\-w\f[] \f[I]FORMAT\f[], \f[C]\-\-to=\f[]\f[I]FORMAT\f[], \f[C]\-\-write=\f[]\f[I]FORMAT\f[]
+Specify output format.
+\f[I]FORMAT\f[] can be \f[C]native\f[] (native Haskell), \f[C]json\f[]
+(JSON version of native AST), \f[C]plain\f[] (plain text),
+\f[C]markdown\f[] (pandoc's extended Markdown), \f[C]markdown_strict\f[]
+(original unextended Markdown), \f[C]markdown_phpextra\f[] (PHP Markdown
+Extra), \f[C]markdown_github\f[] (GitHub\-Flavored Markdown),
+\f[C]markdown_mmd\f[] (MultiMarkdown), \f[C]commonmark\f[] (CommonMark
+Markdown), \f[C]rst\f[] (reStructuredText), \f[C]html\f[] (XHTML),
+\f[C]html5\f[] (HTML5), \f[C]latex\f[] (LaTeX), \f[C]beamer\f[] (LaTeX
+beamer slide show), \f[C]context\f[] (ConTeXt), \f[C]man\f[] (groff
+man), \f[C]mediawiki\f[] (MediaWiki markup), \f[C]dokuwiki\f[] (DokuWiki
+markup), \f[C]zimwiki\f[] (ZimWiki markup), \f[C]textile\f[] (Textile),
+\f[C]org\f[] (Emacs Org mode), \f[C]texinfo\f[] (GNU Texinfo),
+\f[C]opml\f[] (OPML), \f[C]docbook\f[] (DocBook 4), \f[C]docbook5\f[]
+(DocBook 5), \f[C]opendocument\f[] (OpenDocument), \f[C]odt\f[]
+(OpenOffice text document), \f[C]docx\f[] (Word docx), \f[C]haddock\f[]
+(Haddock markup), \f[C]rtf\f[] (rich text format), \f[C]epub\f[] (EPUB
+v2 book), \f[C]epub3\f[] (EPUB v3), \f[C]fb2\f[] (FictionBook2 e\-book),
+\f[C]asciidoc\f[] (AsciiDoc), \f[C]icml\f[] (InDesign ICML),
+\f[C]tei\f[] (TEI Simple), \f[C]slidy\f[] (Slidy HTML and JavaScript
+slide show), \f[C]slideous\f[] (Slideous HTML and JavaScript slide
+show), \f[C]dzslides\f[] (DZSlides HTML5 + JavaScript slide show),
+\f[C]revealjs\f[] (reveal.js HTML5 + JavaScript slide show), \f[C]s5\f[]
+(S5 HTML and JavaScript slide show), or the path of a custom lua writer
+(see Custom writers, below).
+Note that \f[C]odt\f[], \f[C]epub\f[], and \f[C]epub3\f[] output will
+not be directed to \f[I]stdout\f[]; an output filename must be specified
+using the \f[C]\-o/\-\-output\f[] option.
+If \f[C]+lhs\f[] is appended to \f[C]markdown\f[], \f[C]rst\f[],
+\f[C]latex\f[], \f[C]beamer\f[], \f[C]html\f[], or \f[C]html5\f[], the
+output will be rendered as literate Haskell source: see Literate Haskell
+support, below.
+Markdown syntax extensions can be individually enabled or disabled by
+appending \f[C]+EXTENSION\f[] or \f[C]\-EXTENSION\f[] to the format
+name, as described above under \f[C]\-f\f[].
+See \f[C]\-\-list\-output\-formats\f[] and
+\f[C]\-\-list\-extensions\f[], below.
+.RS
+.RE
+.TP
+.B \f[C]\-o\f[] \f[I]FILE\f[], \f[C]\-\-output=\f[]\f[I]FILE\f[]
+Write output to \f[I]FILE\f[] instead of \f[I]stdout\f[].
+If \f[I]FILE\f[] is \f[C]\-\f[], output will go to \f[I]stdout\f[].
+(Exception: if the output format is \f[C]odt\f[], \f[C]docx\f[],
+\f[C]epub\f[], or \f[C]epub3\f[], output to stdout is disabled.)
+.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'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]\-\-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[]
+List supported Markdown extensions, one per line, followed by a
+\f[C]+\f[] or \f[C]\-\f[] indicating whether it is enabled by default in
+pandoc's Markdown.
+.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]\-R\f[], \f[C]\-\-parse\-raw\f[]
+Parse untranslatable HTML codes and LaTeX environments as raw HTML or
+LaTeX, instead of ignoring them.
+Affects only HTML and LaTeX input.
+Raw HTML can be printed in Markdown, reStructuredText, Emacs Org mode,
+HTML, Slidy, Slideous, DZSlides, reveal.js, and S5 output; raw LaTeX can
+be printed in Markdown, reStructuredText, Emacs Org mode, LaTeX, and
+ConTeXt output.
+The default is for the readers to omit untranslatable HTML codes and
+LaTeX environments.
+(The LaTeX reader does pass through untranslatable LaTeX
+\f[I]commands\f[], even if \f[C]\-R\f[] is not specified.)
+.RS
+.RE
+.TP
+.B \f[C]\-S\f[], \f[C]\-\-smart\f[]
+Produce typographically correct output, converting straight quotes to
+curly quotes, \f[C]\-\-\-\f[] to em\-dashes, \f[C]\-\-\f[] to
+en\-dashes, and \f[C]\&...\f[] to ellipses.
+Nonbreaking spaces are inserted after certain abbreviations, such as
+\[lq]Mr.\[rq] (Note: This option is selected automatically when the
+output format is \f[C]latex\f[] or \f[C]context\f[], unless
+\f[C]\-\-no\-tex\-ligatures\f[] is used.
+It has no effect for \f[C]latex\f[] input.)
+.RS
+.RE
+.TP
+.B \f[C]\-\-old\-dashes\f[]
+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 is selected automatically for \f[C]textile\f[] input.
+.RS
+.RE
+.TP
+.B \f[C]\-\-base\-header\-level=\f[]\f[I]NUMBER\f[]
+Specify the base level for headers (defaults to 1).
+.RS
+.RE
+.TP
+.B \f[C]\-\-indented\-code\-classes=\f[]\f[I]CLASSES\f[]
+Specify classes to use for indented code blocks\[en]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]\-\-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'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)
+.IP "3." 3
+\f[C]$PATH\f[] (executable only)
+.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.
+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).
+.RS
+.RE
+.TP
+.B \f[C]\-\-normalize\f[]
+Normalize the document after reading: merge adjacent \f[C]Str\f[] or
+\f[C]Emph\f[] elements, for example, and remove repeated
+\f[C]Space\f[]s.
+.RS
+.RE
+.TP
+.B \f[C]\-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 \[lq]Track Changes\[rq] 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.
+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 a docx or epub container 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.
+This option only affects the docx and epub readers.
+.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.
+.RS
+.RE
+.TP
+.B \f[C]\-\-template=\f[]\f[I]FILE\f[]
+Use \f[I]FILE\f[] as a custom template for the generated document.
+Implies \f[C]\-\-standalone\f[].
+See Templates, below, for a description of template syntax.
+If 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]\-\-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]\-\-no\-wrap\f[]
+Deprecated synonym for \f[C]\-\-wrap=none\f[].
+.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[], and \f[C]rst\f[], an
+instruction to create one) in the output document.
+This option has no effect on \f[C]man\f[], \f[C]docbook\f[],
+\f[C]docbook5\f[], \f[C]slidy\f[], \f[C]slideous\f[], \f[C]s5\f[], or
+\f[C]odt\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]\-\-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[]
+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
+.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
+.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.
+The resulting file should be \[lq]self\-contained,\[rq] 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]html\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).
+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
+\[lq]self\-contained\[rq] \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 only for HTML output (which uses numerical entities
+instead of UTF\-8 when this option is selected).
+.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.
+.RS
+.RE
+.TP
+.B \f[C]\-\-chapters\f[]
+Deprecated synonym for \f[C]\-\-top\-level\-division=chapter\f[].
+.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 \[lq]6\[rq], specify
+\f[C]\-\-number\-offset=5\f[].
+If your document starts with a level\-2 header which you want to be
+numbered \[lq]1.5\[rq], 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]\-\-no\-tex\-ligatures\f[]
+Do not use the TeX ligatures for quotation marks, apostrophes, and
+dashes (\f[C]`...\[aq]\f[], \f[C]``..\[aq]\[aq]\f[], \f[C]\-\-\f[],
+\f[C]\-\-\-\f[]) when writing or reading LaTeX or ConTeXt.
+In reading LaTeX, parse the characters \f[C]`\f[], \f[C]\[aq]\f[], and
+\f[C]\-\f[] literally, rather than parsing ligatures for quotation marks
+and dashes.
+In writing LaTeX or ConTeXt, print unicode quotation mark and dash
+characters literally, rather than converting them to the standard ASCII
+TeX ligatures.
+Note: normally \f[C]\-\-smart\f[] is selected automatically for LaTeX
+and ConTeXt output, but it must be specified explicitly if
+\f[C]\-\-no\-tex\-ligatures\f[] is selected.
+If you use literal curly quotes, dashes, and ellipses in your source,
+then you may want to use \f[C]\-\-no\-tex\-ligatures\f[] without
+\f[C]\-\-smart\f[].
+.RS
+.RE
+.TP
+.B \f[C]\-\-listings\f[]
+Use the \f[C]listings\f[] package for LaTeX code blocks
+.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.
+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]<div>\f[] tags (or \f[C]<section>\f[] tags in
+HTML5), and attach identifiers to the enclosing \f[C]<div>\f[] (or
+\f[C]<section>\f[]) rather than the header itself.
+See 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 automatically generated identifiers
+in HTML and DocBook output, and to footnote numbers in Markdown 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
+.RE
+.TP
+.B \f[C]\-\-reference\-odt=\f[]\f[I]FILE\f[]
+Use the specified file as a style reference in producing an ODT.
+For best results, the reference ODT should be a modified version of an
+ODT produced using pandoc.
+The contents of the reference ODT are ignored, but its stylesheets are
+used in the new ODT.
+If no reference ODT is specified on the command line, pandoc will look
+for a file \f[C]reference.odt\f[] in the user data directory (see
+\f[C]\-\-data\-dir\f[]).
+If this is not found either, sensible defaults will be used.
+.RS
+.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.docx\f[] in LibreOffice, modify the
+styles as you wish, and save the file.
+.RE
+.TP
+.B \f[C]\-\-reference\-docx=\f[]\f[I]FILE\f[]
+Use the specified file as a style reference in producing a docx file.
+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, Block Text, Footnote Text, Definition Term, Definition,
+Caption, Table Caption, Image Caption, Figure, Figure With Caption, TOC
+Heading; [character] Default Paragraph Font, Body Text Char, Verbatim
+Char, Footnote Reference, Hyperlink; [table] Normal Table.
+.RE
+.TP
+.B \f[C]\-\-epub\-stylesheet=\f[]\f[I]FILE\f[]
+Use the specified CSS file to style the EPUB.
+If no stylesheet is specified, pandoc will look for a file
+\f[C]epub.css\f[] in the user data directory (see
+\f[C]\-\-data\-dir\f[]).
+If it is not found there, sensible defaults will be used.
+.RS
+.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]\-\-epub\-stylesheet\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
+\[lq]chapter\[rq] 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]\-\-latex\-engine=pdflatex\f[]|\f[C]lualatex\f[]|\f[C]xelatex\f[]
+Use the specified LaTeX 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]\-\-latex\-engine\-opt=\f[]\f[I]STRING\f[]
+Use the given string as a command\-line argument to the
+\f[C]latex\-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'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'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'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
+.TP
+.B \f[C]\-m\f[] [\f[I]URL\f[]], \f[C]\-\-latexmathml\f[][\f[C]=\f[]\f[I]URL\f[]]
+Use the LaTeXMathML script to display embedded TeX math in HTML output.
+To insert a link to a local copy of the \f[C]LaTeXMathML.js\f[] script,
+provide a \f[I]URL\f[].
+If no \f[I]URL\f[] is provided, the contents of the script will be
+inserted directly into the HTML header, preserving portability at the
+price of efficiency.
+If you plan to use math on several pages, it is much better to link to a
+copy of the script, so it can be cached.
+.RS
+.RE
+.TP
+.B \f[C]\-\-mathml\f[][\f[C]=\f[]\f[I]URL\f[]]
+Convert TeX math to MathML (in \f[C]docbook\f[], \f[C]docbook5\f[],
+\f[C]html\f[] and \f[C]html5\f[]).
+In standalone \f[C]html\f[] output, a small JavaScript (or a link to
+such a script if a \f[I]URL\f[] is supplied) will be inserted that
+allows the MathML to be viewed on some browsers.
+.RS
+.RE
+.TP
+.B \f[C]\-\-jsmath\f[][\f[C]=\f[]\f[I]URL\f[]]
+Use jsMath to display embedded TeX math in HTML output.
+The \f[I]URL\f[] should point to the jsMath load script (e.g.
+\f[C]jsMath/easy/load.js\f[]); if provided, it will be linked to in the
+header of standalone HTML documents.
+If a \f[I]URL\f[] is not provided, no link to the jsMath load script
+will be inserted; it is then up to the author to provide such a link in
+the HTML template.
+.RS
+.RE
+.TP
+.B \f[C]\-\-mathjax\f[][\f[C]=\f[]\f[I]URL\f[]]
+Use MathJax to display embedded TeX math in HTML output.
+The \f[I]URL\f[] should point to the \f[C]MathJax.js\f[] load script.
+If a \f[I]URL\f[] is not provided, a link to the MathJax CDN will be
+inserted.
+.RS
+.RE
+.TP
+.B \f[C]\-\-gladtex\f[]
+Enclose TeX math in \f[C]<eq>\f[] tags in HTML output.
+These can then be processed by gladTeX to produce links to images of the
+typeset formulas.
+.RS
+.RE
+.TP
+.B \f[C]\-\-mimetex\f[][\f[C]=\f[]\f[I]URL\f[]]
+Render TeX math using the mimeTeX CGI script.
+If \f[I]URL\f[] is not specified, it is assumed that the script is at
+\f[C]/cgi\-bin/mimetex.cgi\f[].
+.RS
+.RE
+.TP
+.B \f[C]\-\-webtex\f[][\f[C]=\f[]\f[I]URL\f[]]
+Render TeX formulas using an external script that converts TeX formulas
+to images.
+The formula will be concatenated with the URL provided.
+If \f[I]URL\f[] is not specified, the CodeCogs will be used.
+Note: the \f[C]\-\-webtex\f[] option will affect Markdown output as well
+as HTML, which is useful if you'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[] should point to the \f[C]katex.js\f[] load script.
+If a \f[I]URL\f[] is not provided, a link to the KaTeX CDN will be
+inserted.
+Note: KaTeX seems to work best with \f[C]html5\f[] output.
+.RS
+.RE
+.TP
+.B \f[C]\-\-katex\-stylesheet=\f[]\f[I]URL\f[]
+The \f[I]URL\f[] should point to the \f[C]katex.css\f[] stylesheet.
+If this option is not specified, a link to the KaTeX CDN will be
+inserted.
+Note that this option does not imply \f[C]\-\-katex\f[].
+.RS
+.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.beamer\f[] template, if you use
+\f[C]\-t\ beamer\f[], or the \f[C]default.context\f[] template, if you
+use \f[C]\-t\ context\f[]).
+.IP \[bu] 2
+\f[C]docx\f[] has no template (however, you can use
+\f[C]\-\-reference\-docx\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.
+Variables may be set within the document using YAML metadata blocks.
+They may also be set at the command line using the
+\f[C]\-V/\-\-variable\f[] option: variables set in this way override
+metadata fields with the same name.
+.SS Variables set by pandoc
+.PP
+Some variables are set automatically by pandoc.
+These vary somewhat depending on the output format, but include metadata
+fields as well as the following:
+.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 and docx)
+.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's metadata
+.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 \f[C]span\f[]s and \f[C]div\f[]s with the lang attribute
+(value in BCP 47) can be used to switch the language in that range.
+.RE
+.TP
+.B \f[C]otherlangs\f[]
+a list of other languages used in the document in the YAML metadata,
+according to BCP 47.
+For example: \f[C]otherlangs:\ [en\-GB,\ fr]\f[].
+This is automatically generated from the \f[C]lang\f[] attributes in all
+\f[C]span\f[]s and \f[C]div\f[]s but can be overridden.
+Currently only used by LaTeX through the generated
+\f[C]babel\-otherlangs\f[] and \f[C]polyglossia\-otherlangs\f[]
+variables.
+The LaTeX writer outputs polyglossia commands in the text but the
+\f[C]babel\-newcommands\f[] variable contains mappings for them to the
+corresponding babel.
+.RS
+.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]\-\-latex\-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]slidy\-url\f[]
+base URL for Slidy documents (defaults to
+\f[C]http://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 \[lq]title pages\[rq] 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]colorlinks\f[]
+add color to link text; automatically enabled if any of
+\f[C]linkcolor\f[], \f[C]citecolor\f[], \f[C]urlcolor\f[], or
+\f[C]toccolor\f[] are set (for beamer only).
+.RS
+.RE
+.TP
+.B \f[C]linkcolor\f[], \f[C]citecolor\f[], \f[C]urlcolor\f[], \f[C]toccolor\f[]
+color for internal links, citation links, external links, and links in
+table of contents: uses any of the predefined LaTeX colors (for beamer
+only).
+.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]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]citecolor\f[], \f[C]urlcolor\f[], or
+\f[C]toccolor\f[] are set
+.RS
+.RE
+.TP
+.B \f[C]linkcolor\f[], \f[C]citecolor\f[], \f[C]urlcolor\f[], \f[C]toccolor\f[]
+color for internal links, citation links, external links, and links in
+table of contents: uses any of the predefined LaTeX colors
+.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
+.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
+.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 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
+non\-null value; otherwise it will include \f[C]Y\f[].
+\f[C]X\f[] and \f[C]Y\f[] are placeholders for any valid template text,
+and may include interpolated variables or other conditionals.
+The \f[C]$else$\f[] section may be omitted.
+.PP
+When variables can have multiple values (for example, \f[C]author\f[] in
+a multi\-author document), you can use the \f[C]$for$\f[] keyword:
+.IP
+.nf
+\f[C]
+$for(author)$
+<meta\ name="author"\ content="$author$"\ />
+$endfor$
+\f[]
+.fi
+.PP
+You can optionally specify a separator to be used between consecutive
+items:
+.IP
+.nf
+\f[C]
+$for(author)$$author$$sep$,\ $endfor$
+\f[]
+.fi
+.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.
+.SH PANDOC'S MARKDOWN
+.PP
+Pandoc understands an extended and slightly revised version of John
+Gruber's Markdown syntax.
+This document explains the syntax, noting differences from standard
+Markdown.
+Except where noted, these differences can be suppressed by using the
+\f[C]markdown_strict\f[] format instead of \f[C]markdown\f[].
+An extensions 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]markdown_strict+footnotes\f[] is strict Markdown with
+footnotes enabled, while \f[C]markdown\-footnotes\-pipe_tables\f[] is
+pandoc's Markdown without footnotes or pipe tables.
+.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's been marked up with tags or formatting
+instructions.
+\[en] John Gruber
+.RE
+.PP
+This principle has guided pandoc's decisions in finding syntax for
+tables, footnotes, and other extensions.
+.PP
+There is, however, one respect in which pandoc's aims are different from
+the original aims of Markdown.
+Whereas Markdown was originally designed with HTML generation in mind,
+pandoc is designed for multiple output formats.
+Thus, while pandoc allows the embedding of raw HTML, it discourages it,
+and provides other, non\-HTMLish ways of representing important document
+elements like definition lists, tables, mathematics, and footnotes.
+.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 \[lq]underlined\[rq] 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 Header identifiers
+.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'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]auto_identifiers\f[]
+.PP
+A header without an explicitly specified identifier will be
+automatically assigned a unique identifier based on the header text.
+To derive the identifier from the header text,
+.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]div\f[] (or a \f[C]section\f[], if
+\f[C]\-\-html5\f[] was specified), and the identifier will be attached
+to the enclosing \f[C]<div>\f[] (or \f[C]<section>\f[]) tag rather than
+the header itself.
+This allows entire sections to be manipulated using JavaScript or
+treated differently in CSS.
+.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 \[lq]lazy\[rq] 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
+and LaTeX.
+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
+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 \[lq]compact\[rq] list.
+If you want a \[lq]loose\[rq] 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 \[lq]lazy\[rq] format:
+.IP
+.nf
+\f[C]
+*\ here\ is\ my\ first
+list\ item.
+*\ and\ my\ second.
+\f[]
+.fi
+.SS The four\-space rule
+.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 four spaces or a tab.
+The list will look better if the first paragraph is aligned with the
+rest:
+.IP
+.nf
+\f[C]
+\ \ *\ First\ paragraph.
+
+\ \ \ \ Continued.
+
+\ \ *\ Second\ paragraph.\ With\ a\ code\ block,\ which\ must\ be\ indented
+\ \ \ \ eight\ spaces:
+
+\ \ \ \ \ \ \ \ {\ code\ }
+\f[]
+.fi
+.PP
+List items may include other lists.
+In this case the preceding blank line is optional.
+The nested list must be indented four spaces or one tab:
+.IP
+.nf
+\f[C]
+*\ fruits
+\ \ \ \ +\ apples
+\ \ \ \ \ \ \ \ \-\ macintosh
+\ \ \ \ \ \ \ \ \-\ red\ delicious
+\ \ \ \ +\ pears
+\ \ \ \ +\ peaches
+*\ vegetables
+\ \ \ \ +\ broccoli
+\ \ \ \ +\ chard
+\f[]
+.fi
+.PP
+As noted above, Markdown allows you to write list items
+\[lq]lazily,\[rq] 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
+.PP
+\f[B]Note:\f[] Although the four\-space rule for continuation paragraphs
+comes from the official Markdown syntax guide, the reference
+implementation, \f[C]Markdown.pl\f[], does not follow it.
+So pandoc will give different results than \f[C]Markdown.pl\f[] when
+authors have indented continuation paragraphs fewer than four spaces.
+.PP
+The Markdown syntax guide is not explicit whether the four\-space rule
+applies to \f[I]all\f[] block\-level content in a list item; it only
+mentions paragraphs and code blocks.
+But it implies that the rule applies to all block\-level content
+(including nested lists), and pandoc interprets it that way.
+.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 `\f[C]#\f[]' 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 \[lq]lazily\[rq] 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 \[lq]lazy\[rq]
+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 `1', the
+next `2', and so on, throughout the document.
+The numbered examples need not occur in a single list; each new list
+using \f[C]\@\f[] will take up where the last stopped.
+So, for example:
+.IP
+.nf
+\f[C]
+(\@)\ \ My\ first\ example\ will\ be\ numbered\ (1).
+(\@)\ \ My\ second\ example\ will\ be\ numbered\ (2).
+
+Explanation\ of\ examples.
+
+(\@)\ \ My\ third\ example\ will\ be\ numbered\ (3).
+\f[]
+.fi
+.PP
+Numbered examples can be labeled and referred to elsewhere in the
+document:
+.IP
+.nf
+\f[C]
+(\@good)\ \ This\ is\ a\ good\ example.
+
+As\ (\@good)\ illustrates,\ ...
+\f[]
+.fi
+.PP
+The label can be any string of alphanumeric characters, underscores, or
+hyphens.
+.SS Compact and loose lists
+.PP
+Pandoc behaves differently from \f[C]Markdown.pl\f[] on some \[lq]edge
+cases\[rq] involving lists.
+Consider this source:
+.IP
+.nf
+\f[C]
++\ \ \ First
++\ \ \ Second:
+\ \ \ \ \-\ \ \ Fee
+\ \ \ \ \-\ \ \ Fie
+\ \ \ \ \-\ \ \ Foe
+
++\ \ \ Third
+\f[]
+.fi
+.PP
+Pandoc transforms this into a \[lq]compact list\[rq] (with no
+\f[C]<p>\f[] tags around \[lq]First\[rq], \[lq]Second\[rq], or
+\[lq]Third\[rq]), while Markdown puts \f[C]<p>\f[] tags around
+\[lq]Second\[rq] and \[lq]Third\[rq] (but not \[lq]First\[rq]), because
+of the blank space around \[lq]Third\[rq].
+Pandoc follows a simple rule: if the text is followed by a blank line,
+it is treated as a paragraph.
+Since \[lq]Second\[rq] is followed by a list, and not a blank line, it
+isn't treated as a paragraph.
+The fact that the list is followed by a blank line is irrelevant.
+(Note: Pandoc works this way even when the \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 \[lq]cut off\[rq] the list after item two, you can insert some
+non\-indented content, like an HTML comment, which won't produce visible
+output in any format:
+.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 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 cell contents will
+wrap, with the relative cell widths determined by the widths of the
+separator lines.
+.PP
+Note: pandoc also recognizes pipe tables of the following form, as can
+be produced by Emacs' 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'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
+\[en] this is the title that will appear at the top of the window in a
+browser \[en] 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
+\[lq]title\[rq], 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 \[lq]Pandoc User Manuals\[rq] in the footer.
+.IP
+.nf
+\f[C]
+%\ PANDOC(1)\ Pandoc\ User\ Manuals\ |\ Version\ 4.0
+\f[]
+.fi
+.PP
+will also have \[lq]Version 4.0\[rq] 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[].)
+.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.)
+.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:
+.IP
+.nf
+\f[C]
+\-\-\-
+title:\ \ \[aq]This\ is\ the\ title:\ it\ contains\ a\ colon\[aq]
+author:
+\-\ Author\ One
+\-\ Author\ Two
+tags:\ [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
+.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'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]\\&#160;\f[] or \f[C]\\&nbsp;\f[].
+.PP
+A backslash\-escaped newline (i.e.\ a backslash occurring at the end of
+a line) is parsed as a hard line break.
+It will appear in TeX output as \f[C]\\\\\f[] and in HTML as
+\f[C]<br\ />\f[].
+This is a nice alternative to Markdown's \[lq]invisible\[rq] way of
+indicating hard line breaks using two trailing spaces on a line.
+.PP
+Backslash escapes do not work in verbatim contexts.
+.SS Smart punctuation
+.SS Extension
+.PP
+If the \f[C]\-\-smart\f[] option is specified, pandoc will produce
+typographically correct output, converting straight quotes to curly
+quotes, \f[C]\-\-\-\f[] to em\-dashes, \f[C]\-\-\f[] to en\-dashes, and
+\f[C]\&...\f[] to ellipses.
+Nonbreaking spaces are inserted after certain abbreviations, such as
+\[lq]Mr.\[rq]
+.PP
+Note: if your LaTeX template or any included header file call for the
+\f[C]csquotes\f[] package, pandoc will detect this automatically and use
+\f[C]\\enquote{...}\f[] for quoted text.
+.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 `a cat' 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, you can use an HTML span tag:
+.IP
+.nf
+\f[C]
+<span\ style="font\-variant:small\-caps;">Small\ caps</span>
+\f[]
+.fi
+.PP
+(The semicolon is optional and there may be space after the colon.) This
+will work in all output formats that support small caps.
+.PP
+Alternatively, you can also use the new \f[C]bracketed_spans\f[] syntax:
+.IP
+.nf
+\f[C]
+[Small\ caps]{style="font\-variant:small\-caps;"}
+\f[]
+.fi
+.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'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't be treated as math
+delimiters.
+.PP
+TeX math will be printed in all output formats.
+How it is rendered depends on the output format:
+.TP
+.B Markdown, LaTeX, Emacs Org mode, ConTeXt, ZimWiki
+It will appear verbatim between \f[C]$\f[] characters.
+.RS
+.RE
+.TP
+.B reStructuredText
+It will be rendered using an interpreted text role \f[C]:math:\f[].
+.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[]'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, ODT
+It will be rendered, if possible, using Unicode characters, and will
+otherwise appear verbatim.
+.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:
+.RS
+.IP "1." 3
+The default is to render TeX math as far as possible using Unicode
+characters, as with RTF, DocBook, and OpenDocument output.
+Formulas are put inside a \f[C]span\f[] with \f[C]class="math"\f[], so
+that they may be styled differently from the surrounding text if needed.
+.IP "2." 3
+If the \f[C]\-\-latexmathml\f[] option is used, TeX math will be
+displayed between \f[C]$\f[] or \f[C]$$\f[] characters and put in
+\f[C]<span>\f[] tags with class \f[C]LaTeX\f[].
+The LaTeXMathML script will be used to render it as formulas.
+(This trick does not work in all browsers, but it works in Firefox.
+In browsers that do not support LaTeXMathML, TeX math will appear
+verbatim between \f[C]$\f[] characters.)
+.IP "3." 3
+If the \f[C]\-\-jsmath\f[] option is used, TeX math will be put inside
+\f[C]<span>\f[] tags (for inline math) or \f[C]<div>\f[] tags (for
+display math) with class \f[C]math\f[].
+The jsMath script will be used to render it.
+.IP "4." 3
+If the \f[C]\-\-mimetex\f[] option is used, the mimeTeX CGI script will
+be called to generate images for each TeX formula.
+This should work in all browsers.
+The \f[C]\-\-mimetex\f[] option takes an optional URL as argument.
+If no URL is specified, it will be assumed that the mimeTeX CGI script
+is at \f[C]/cgi\-bin/mimetex.cgi\f[].
+.IP "5." 3
+If the \f[C]\-\-gladtex\f[] option is used, TeX formulas will be
+enclosed in \f[C]<eq>\f[] tags in the HTML output.
+The resulting \f[C]htex\f[] file may then be processed by gladTeX, which
+will produce image files for each formula and an HTML file with links to
+these images.
+So, the procedure is:
+.RS 4
+.IP
+.nf
+\f[C]
+pandoc\ \-s\ \-\-gladtex\ myfile.txt\ \-o\ myfile.htex
+gladtex\ \-d\ myfile\-images\ myfile.htex
+#\ produces\ myfile.html\ and\ images\ in\ myfile\-images
+\f[]
+.fi
+.RE
+.IP "6." 3
+If the \f[C]\-\-webtex\f[] option is used, TeX formulas will be
+converted to \f[C]<img>\f[] tags that link to an external script that
+converts formulas to images.
+The formula will be URL\-encoded and concatenated with the URL provided.
+If no URL is specified, the CodeCogs will be used
+(\f[C]https://latex.codecogs.com/png.latex?\f[]).
+.IP "7." 3
+If the \f[C]\-\-mathjax\f[] option is used, TeX math will be displayed
+between \f[C]\\(...\\)\f[] (for inline math) or \f[C]\\[...\\]\f[] (for
+display math) and put in \f[C]<span>\f[] tags with class \f[C]math\f[].
+The MathJax script will be used to render it as formulas.
+.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 \[lq]blocks\[rq]: 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 Raw TeX
+.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 LaTeX macros
+.SS Extension: \f[C]latex_macros\f[]
+.PP
+For output formats other than LaTeX, pandoc will parse LaTeX
+\f[C]\\newcommand\f[] and \f[C]\\renewcommand\f[] definitions and apply
+the resulting macros to all LaTeX math.
+So, for example, the following will work in all output formats, not just
+LaTeX:
+.IP
+.nf
+\f[C]
+\\newcommand{\\tuple}[1]{\\langle\ #1\ \\rangle}
+
+$\\tuple{a,\ b,\ c}$
+\f[]
+.fi
+.PP
+In LaTeX output, the \f[C]\\newcommand\f[] definition will simply be
+passed unchanged to the output.
+.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 can be space between the two.) 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's alt text:
+.IP
+.nf
+\f[C]
+![la\ lune](lalune.jpg\ "Voyage\ to\ the\ moon")
+
+![movie\ reel]
+
+[movie\ reel]:\ movie.gif
+\f[]
+.fi
+.SS Extension: \f[C]implicit_figures\f[]
+.PP
+An image occurring by itself in a paragraph will be rendered as a figure
+with a caption. (In LaTeX, a figure environment will be used; in HTML,
+the image will be placed in a \f[C]div\f[] with class \f[C]figure\f[],
+together with a caption in a \f[C]p\f[] with class \f[C]caption\f[].)
+The image's alt text will be used as the caption.
+.IP
+.nf
+\f[C]
+![This\ is\ the\ caption](/url/of/image.png)
+\f[]
+.fi
+.PP
+If you just want a regular inline image, just make sure it is not the
+only thing in the paragraph.
+One way to do this is to insert a nonbreaking space after the image:
+.IP
+.nf
+\f[C]
+![This\ image\ won\[aq]t\ be\ a\ figure](/url/of/image.png)\\\
+\f[]
+.fi
+.SS Extension: \f[C]link_attributes\f[]
+.PP
+Attributes can be set on links and images:
+.IP
+.nf
+\f[C]
+An\ inline\ ![image](foo.jpg){#id\ .class\ width=30\ height=20px}
+and\ a\ reference\ ![image][ref]\ with\ attributes.
+
+[ref]:\ foo.jpg\ "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]
+![](file.jpg){\ 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 Spans
+.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 span 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'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'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 `\@' + 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, \[lq]page\[rq] 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 or PDF output, you can also use \f[C]natbib\f[] or
+\f[C]biblatex\f[] to render 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]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'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]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]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 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 \[lq]tight\[rq] or \[lq]compact\[rq] 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'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[].
+.RS
+.RE
+.TP
+.B \f[C]markdown_github\f[] (GitHub\-Flavored Markdown)
+\f[C]pipe_tables\f[], \f[C]raw_html\f[], \f[C]fenced_code_blocks\f[],
+\f[C]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
+.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[].
+.RS
+.RE
+.TP
+.B \f[C]markdown_strict\f[] (Markdown.pl)
+\f[C]raw_html\f[]
+.RS
+.RE
+.SS Extensions with formats other than Markdown
+.PP
+Some of the extensions discussed above can be used with formats other
+than Markdown:
+.IP \[bu] 2
+\f[C]auto_identifiers\f[] can be used with \f[C]latex\f[], \f[C]rst\f[],
+\f[C]mediawiki\f[], and \f[C]textile\f[] input (and is used by default).
+.IP \[bu] 2
+\f[C]tex_math_dollars\f[], \f[C]tex_math_single_backslash\f[], and
+\f[C]tex_math_double_backslash\f[] can be used with \f[C]html\f[] input.
+(This is handy for reading web pages formatted using MathJax, for
+example.)
+.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[].
+.PP
+Here'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
+
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
+
+![picture\ of\ spaghetti](images/spaghetti.jpg)
+
+##\ 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.
+.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
+\[lq]title slides,\[rq] which just contain the section title and help to
+break the slide show into sections.
+.IP \[bu] 2
+A title page is constructed automatically from the document's title
+block, if present.
+(In the case of beamer, this can be disabled by commenting out some
+lines in the default template.)
+.PP
+These rules are designed to support many different styles of slide show.
+If you don't care about structuring your slides into sections and
+subsections, you can just use level 1 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 \[lq]all at
+once.\[rq] If you want your lists to display incrementally (one item at
+a time), use the \f[C]\-i\f[] option.
+If you want a particular list to depart from the default (that is, to
+display incrementally without the \f[C]\-i\f[] option and all at once
+with the \f[C]\-i\f[] option), put it in a block quote:
+.IP
+.nf
+\f[C]
+>\ \-\ Eat\ spaghetti
+>\ \-\ Drink\ wine
+\f[]
+.fi
+.PP
+In this way incremental and nonincremental lists can be mixed in a
+single document.
+.SS Inserting pauses
+.PP
+You can add \[lq]pauses\[rq] 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'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
+reveal.js has good support for speaker notes.
+You can add notes to your Markdown document thus:
+.IP
+.nf
+\f[C]
+<div\ class="notes">
+This\ is\ my\ note.
+
+\-\ It\ can\ contain\ Markdown
+\-\ like\ this\ list
+
+</div>
+\f[]
+.fi
+.PP
+To show the notes window, press \f[C]s\f[] while viewing the
+presentation.
+Notes are not yet supported for other slide formats, but the notes will
+not appear on the slides themselves.
+.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'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[].
+.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
+\&...
+\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 \[lq]author\[rq]
+and \[lq]editor\[rq]) 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
+.SS Linked media
+.PP
+By default, pandoc will download linked media (including audio and
+video) 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 LITERATE HASKELL SUPPORT
+.PP
+If you append \f[C]+lhs\f[] (or \f[C]+literate_haskell\f[]) to an
+appropriate input or output format (\f[C]markdown\f[],
+\f[C]markdown_strict\f[], \f[C]rst\f[], or \f[C]latex\f[] for input or
+output; \f[C]beamer\f[], \f[C]html\f[] or \f[C]html5\f[] for output
+only), pandoc will treat the document as literate Haskell source.
+This means that
+.IP \[bu] 2
+In Markdown input, \[lq]bird track\[rq] 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 `=' will be used instead of `#'.
+.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 `#' characters).
+(This is because ghc treats `#' characters in column 1 as introducing
+line numbers.)
+.IP \[bu] 2
+In restructured text input, \[lq]bird track\[rq] sections will be parsed
+as Haskell code.
+.IP \[bu] 2
+In restructured text output, code blocks with class \f[C]haskell\f[]
+will be rendered using bird tracks.
+.IP \[bu] 2
+In LaTeX input, text in \f[C]code\f[] environments will be parsed as
+Haskell code.
+.IP \[bu] 2
+In LaTeX output, code blocks with class \f[C]haskell\f[] will be
+rendered inside \f[C]code\f[] environments.
+.IP \[bu] 2
+In HTML output, code blocks with class \f[C]haskell\f[] will be rendered
+with class \f[C]literatehaskell\f[] and bird tracks.
+.PP
+Examples:
+.IP
+.nf
+\f[C]
+pandoc\ \-f\ markdown+lhs\ \-t\ html
+\f[]
+.fi
+.PP
+reads literate Haskell source formatted with Markdown conventions and
+writes ordinary HTML (without bird tracks).
+.IP
+.nf
+\f[C]
+pandoc\ \-f\ markdown+lhs\ \-t\ html+lhs
+\f[]
+.fi
+.PP
+writes HTML with the Haskell code in bird tracks, so it can be copied
+and pasted as literate Haskell source.
+.SH SYNTAX HIGHLIGHTING
+.PP
+Pandoc will automatically highlight syntax in fenced code blocks that
+are marked with a language name.
+The Haskell library highlighting\-kate is used for highlighting, which
+works in HTML, Docx, 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
+To disable highlighting, use the \f[C]\-\-no\-highlight\f[] option.
+.SH CUSTOM STYLES IN DOCX OUTPUT
+.PP
+By default, pandoc'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,
+.IP
+.nf
+\f[C]
+<span\ custom\-style="Emphatically">Get\ out,</span>\ he\ said.
+\f[]
+.fi
+.PP
+would produce a docx file with \[lq]Get out,\[rq] styled with character
+style \f[C]Emphatically\f[].
+Similarly,
+.IP
+.nf
+\f[C]
+Dickinson\ starts\ the\ poem\ simply:
+
+<div\ custom\-style="Poetry">
+|\ A\ Bird\ came\ down\ the\ Walk\-\-\-
+|\ He\ did\ not\ know\ I\ saw\-\-\-
+</div>
+\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
+© 2006\-2016 John MacFarlane (jgm\@berkeley.edu).
+Released under the GPL, version 2 or greater.
+This software carries no warranty of any kind.
+(See COPYRIGHT for full copyright and warranty notices.)
+.PP
+Contributors include Arata Mizuki, Aaron Wolen, Albert Krewinkel, Alex
+Ivkin, Alex Vong, Alexander Kondratskiy, Alexander Sulfrian, Alexander V
+Vershilov, Alfred Wechselberger, Andreas Lööw, Andrew Dunning, Antoine
+Latter, Arata Mizuki, Arlo O'Keeffe, Artyom Kazak, B.
+Scott Michel, Ben Gamari, Beni Cherniavsky\-Paskin, Benoit Schweblin,
+Bjorn Buckwalter, Bradley Kuhn, Brent Yorgey, Bryan O'Sullivan, Caleb
+McDaniel, Calvin Beck, Carlos Sosa, Chris Black, Christian Conkle,
+Christoffer Ackelman, Christoffer Sawicki, Clare Macrae, Clint Adams,
+Conal Elliott, Craig S.
+Bosma, Daniel Bergey, Daniel T.
+Staal, Daniele D'Orazio, David Lazar, David Röthlisberger, Denis
+Laxalde, Douglas Calvert, Emanuel Evans, Emily Eisenberg, Eric Kow, Eric
+Seidel, Felix Yan, Florian Eitel, François Gannaz, Freiric Barral,
+Freirich Raabe, Frerich Raabe, Fyodor Sheremetyev, Gabor Pali, Gavin
+Beatty, Gottfried Haider, Greg Maslov, Greg Rundlett, Grégory Bataille,
+Gwern Branwen, Hans\-Peter Deifel, Henrik Tramberend, Henry de Valence,
+Hubert Plociniczak, Ilya V.
+Portnov, Ivo Clarysse, J.
+Lewis Muir, Jaime Marquínez Ferrándiz, Jakob Voß, James Aspnes, Jamie F.
+Olson, Jan Larres, Jan Schulz, Jason Ronallo, Jeff Arnold, Jeff
+Runningen, Jens Petersen, Jesse Rosenthal, Joe Hillenbrand, John
+MacFarlane, John Muccigrosso, Jonas Smedegaard, Jonathan Daugherty, Jose
+Luis Duran, Josef Svenningsson, Julien Cretel, Juliusz Gonera, Justin
+Bogner, Jérémy Bobbio, Kelsey Hightower, Kolen Cheung, Konstantin Zudov,
+Kristof Bastiaensen, Lars\-Dominik Braun, Luke Plant, Mark Szepieniec,
+Mark Wright, Martin Linn, Masayoshi Takahashi, Matej Kollar, Mathias
+Schenner, Mathieu Duponchelle, Matthew Eddey, Matthew Pickering,
+Matthias C.
+M.
+Troffaes, Mauro Bieg, Max Bolingbroke, Max Rydahl Andersen, Merijn
+Verstraaten, Michael Beaumont, Michael Chladek, Michael Snoyman, Michael
+Thompson, MinRK, Morton Fox, Nathan Gass, Neil Mayhew, Nick Bart,
+Nicolas Kaiser, Nikolay Yakimov, Oliver Matthews, Ophir Lifshitz, Pablo
+Rodríguez, Paul Rivier, Paulo Tanimoto, Peter Wang, Philippe Ombredanne,
+Phillip Alday, Prayag Verma, Puneeth Chaganti, Ralf Stephan, Raniere
+Silva, Recai Oktaş, RyanGlScott, Scott Morrison, Sergei Trofimovich,
+Sergey Astanin, Shahbaz Youssefi, Shaun Attfield, Sidarth Kapur,
+Sidharth Kapur, Simon Hengel, Sumit Sahrawat, Thomas Hodgson, Thomas
+Weißschuh, Tim Lin, Timothy Humphries, Tiziano Müller, Todd Sifleet, Tom
+Leese, Uli Köhler, Václav Zeman, Viktor Kronvall, Vincent, Václav
+Haisman, Václav Zeman, Wandmalfarbe, Waldir Pimenta, Wikiwide, Xavier
+Olive, bumper314, csforste, infinity0x, nkalvi, qerub, robabla,
+roblabla, rodja.trappe, rski, shreevatsa.public, takahashim, tgkokk,
+thsutton.
+.PP
+The Pandoc source code and all documentation may be downloaded
+from <http://pandoc.org>.
diff --git a/man/pandoc.1.template b/man/pandoc.1.template
new file mode 100644
index 000000000..6a1c26a52
--- /dev/null
+++ b/man/pandoc.1.template
@@ -0,0 +1,10 @@
+$if(has-tables)$
+.\"t
+$endif$
+.TH PANDOC 1 "$date$" "$version$"
+.SH NAME
+pandoc - general markup converter
+$body$
+.PP
+The Pandoc source code and all documentation may be downloaded
+from <http://pandoc.org>.
diff --git a/man/removeLinks.hs b/man/removeLinks.hs
new file mode 100644
index 000000000..52414ebd0
--- /dev/null
+++ b/man/removeLinks.hs
@@ -0,0 +1,9 @@
+import Text.Pandoc.JSON
+
+main :: IO ()
+main = toJSONFilter removeLinks
+
+removeLinks :: Inline -> [Inline]
+removeLinks (Link _ l _) = l
+removeLinks x = [x]
+
diff --git a/man/removeNotes.hs b/man/removeNotes.hs
new file mode 100644
index 000000000..e61cb932a
--- /dev/null
+++ b/man/removeNotes.hs
@@ -0,0 +1,9 @@
+import Text.Pandoc.JSON
+
+main :: IO ()
+main = toJSONFilter removeNotes
+
+removeNotes :: Inline -> Inline
+removeNotes (Note _) = Str ""
+removeNotes x = x
+
diff --git a/pandoc.cabal b/pandoc.cabal
new file mode 100644
index 000000000..a4390b77e
--- /dev/null
+++ b/pandoc.cabal
@@ -0,0 +1,559 @@
+Name: pandoc
+Version: 2.0
+Cabal-Version: >= 1.10
+Build-Type: Custom
+License: GPL
+License-File: COPYING.md
+Copyright: (c) 2006-2017 John MacFarlane
+Author: John MacFarlane <jgm@berkeley.edu>
+Maintainer: John MacFarlane <jgm@berkeley.edu>
+Bug-Reports: https://github.com/jgm/pandoc/issues
+Stability: alpha
+Homepage: http://pandoc.org
+Category: Text
+Tested-With: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2
+Synopsis: Conversion between markup formats
+Description: Pandoc is a Haskell library for converting from one markup
+ format to another, and a command-line tool that uses
+ this library. It can read several dialects of Markdown and
+ (subsets of) HTML, reStructuredText, LaTeX, DocBook,
+ MediaWiki markup, TWiki markup, Haddock markup, OPML,
+ Emacs Org-Mode, txt2tags, Word Docx, ODT, and Textile, and
+ it can write Markdown, reStructuredText, XHTML, HTML 5,
+ LaTeX, ConTeXt, DocBook, OPML, TEI, OpenDocument, ODT,
+ Word docx, RTF, MediaWiki, DokuWiki, ZimWiki, Textile,
+ groff man pages, plain text, Emacs Org-Mode, AsciiDoc,
+ Haddock markup, EPUB (v2 and v3), FictionBook2, InDesign ICML,
+ 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
+ readers, which parse text in a given format and produce a
+ native representation of the document, and a set of writers,
+ which convert this native representation into a target
+ format. Thus, adding an input or output format requires
+ only adding a reader or writer.
+Data-Files:
+ -- templates
+ data/templates/default.html4
+ data/templates/default.html5
+ data/templates/default.docbook4
+ data/templates/default.docbook5
+ data/templates/default.tei
+ data/templates/default.beamer
+ data/templates/default.opendocument
+ data/templates/default.icml
+ data/templates/default.opml
+ data/templates/default.latex
+ data/templates/default.context
+ data/templates/default.texinfo
+ data/templates/default.man
+ data/templates/default.markdown
+ data/templates/default.commonmark
+ data/templates/default.rst
+ data/templates/default.plain
+ data/templates/default.mediawiki
+ data/templates/default.dokuwiki
+ data/templates/default.zimwiki
+ data/templates/default.rtf
+ data/templates/default.s5
+ data/templates/default.slidy
+ data/templates/default.slideous
+ data/templates/default.revealjs
+ data/templates/default.dzslides
+ data/templates/default.asciidoc
+ data/templates/default.haddock
+ data/templates/default.textile
+ data/templates/default.org
+ data/templates/default.epub2
+ data/templates/default.epub3
+ -- source files for reference.docx
+ data/docx/[Content_Types].xml
+ data/docx/_rels/.rels
+ data/docx/docProps/app.xml
+ data/docx/docProps/core.xml
+ data/docx/word/document.xml
+ data/docx/word/fontTable.xml
+ data/docx/word/footnotes.xml
+ data/docx/word/numbering.xml
+ data/docx/word/settings.xml
+ data/docx/word/webSettings.xml
+ data/docx/word/styles.xml
+ data/docx/word/_rels/document.xml.rels
+ data/docx/word/_rels/footnotes.xml.rels
+ data/docx/word/theme/theme1.xml
+ -- source files for reference.odt
+ data/odt/mimetype
+ data/odt/manifest.rdf
+ data/odt/styles.xml
+ data/odt/content.xml
+ data/odt/meta.xml
+ data/odt/settings.xml
+ data/odt/Configurations2/accelerator/current.xml
+ data/odt/Thumbnails/thumbnail.png
+ data/odt/META-INF/manifest.xml
+ -- stylesheet for EPUB writer
+ data/epub.css
+ -- data for LaTeXMathML writer
+ data/LaTeXMathML.js
+ -- data for dzslides writer
+ data/dzslides/template.html
+ -- sample lua custom writer
+ data/sample.lua
+ -- bash completion template
+ data/bash_completion.tpl
+ -- documentation
+ MANUAL.txt, COPYRIGHT
+Extra-Source-Files:
+ -- documentation
+ INSTALL.md, BUGS, README.md, CONTRIBUTING.md, changelog
+ man/pandoc.1
+ -- stack build plan
+ stack.yaml
+ -- files needed to build man page
+ man/capitalizeHeaders.hs
+ man/removeNotes.hs
+ man/removeLinks.hs
+ man/pandoc.1.template
+ -- trypandoc
+ trypandoc/Makefile
+ trypandoc/index.html
+ -- tests
+ test/bodybg.gif
+ test/*.native
+ test/command/*.md
+ test/docbook-reader.docbook
+ test/docbook-xref.docbook
+ test/html-reader.html
+ test/opml-reader.opml
+ test/haddock-reader.haddock
+ test/insert
+ test/lalune.jpg
+ test/movie.jpg
+ test/media/rId25.jpg
+ test/media/rId26.jpg
+ test/media/rId27.jpg
+ test/latex-reader.latex
+ test/textile-reader.textile
+ test/markdown-reader-more.txt
+ test/markdown-citations.txt
+ test/textile-reader.textile
+ test/mediawiki-reader.wiki
+ test/rst-reader.rst
+ test/s5-basic.html
+ test/s5-fancy.html
+ test/s5-fragment.html
+ test/s5-inserts.html
+ test/tables.context
+ test/tables.docbook4
+ test/tables.docbook5
+ test/tables.dokuwiki
+ test/tables.zimwiki
+ test/tables.icml
+ test/tables.html4
+ test/tables.html5
+ test/tables.latex
+ test/tables.man
+ test/tables.plain
+ test/tables.markdown
+ test/tables.mediawiki
+ test/tables.tei
+ test/tables.textile
+ test/tables.opendocument
+ test/tables.org
+ test/tables.asciidoc
+ test/tables.haddock
+ test/tables.texinfo
+ test/tables.rst
+ test/tables.rtf
+ test/tables.txt
+ test/tables.fb2
+ test/testsuite.txt
+ test/writer.latex
+ test/writer.context
+ test/writer.docbook4
+ test/writer.docbook5
+ test/writer.html4
+ test/writer.html5
+ test/writer.man
+ test/writer.markdown
+ test/writer.plain
+ test/writer.mediawiki
+ test/writer.textile
+ test/writer.opendocument
+ test/writer.org
+ test/writer.asciidoc
+ test/writer.haddock
+ test/writer.rst
+ test/writer.icml
+ test/writer.rtf
+ test/writer.tei
+ test/writer.texinfo
+ test/writer.fb2
+ test/writer.opml
+ test/writer.dokuwiki
+ test/writer.zimwiki
+ test/writers-lang-and-dir.latex
+ test/writers-lang-and-dir.context
+ test/dokuwiki_inline_formatting.dokuwiki
+ test/lhs-test.markdown
+ test/lhs-test.markdown+lhs
+ test/lhs-test.rst
+ test/lhs-test.rst+lhs
+ test/lhs-test.latex
+ test/lhs-test.latex+lhs
+ test/lhs-test.html
+ test/lhs-test.html+lhs
+ test/lhs-test.fragment.html+lhs
+ test/pipe-tables.txt
+ test/dokuwiki_external_images.dokuwiki
+ test/dokuwiki_external_images.native
+ test/dokuwiki_multiblock_table.dokuwiki
+ test/dokuwiki_multiblock_table.native
+ test/fb2/*.markdown
+ test/fb2/*.fb2
+ test/fb2/images-embedded.html
+ test/fb2/images-embedded.fb2
+ test/fb2/test-small.png
+ test/fb2/test.jpg
+ test/docx/*.docx
+ test/docx/*.native
+ test/epub/*.epub
+ test/epub/*.native
+ test/txt2tags.t2t
+ test/twiki-reader.twiki
+ test/odt/odt/*.odt
+ test/odt/markdown/*.md
+ test/odt/native/*.native
+Source-repository head
+ type: git
+ location: git://github.com/jgm/pandoc.git
+
+Flag embed_data_files
+ Description: Embed data files in binary for relocatable executable.
+ Default: False
+
+Flag trypandoc
+ Description: Build trypandoc cgi executable.
+ Default: False
+
+Flag weigh-pandoc
+ Description: Build weigh-pandoc to measure memory usage.
+ Default: False
+
+Flag https
+ Description: Enable support for downloading of resources over https.
+ Default: True
+
+Flag network-uri
+ Description: Get Network.URI from the network-uri package
+ Default: True
+
+Flag old-locale
+ Description: Use old-locale and time < 1.5
+ Default: False
+
+Library
+ Build-Depends: base >= 4.7 && <5,
+ syb >= 0.1 && < 0.7,
+ containers >= 0.1 && < 0.6,
+ unordered-containers >= 0.2 && < 0.3,
+ array >= 0.3 && < 0.6,
+ parsec >= 3.1 && < 3.2,
+ mtl >= 2.2 && < 2.3,
+ filepath >= 1.1 && < 1.5,
+ process >= 1.2.3 && < 1.5,
+ directory >= 1 && < 1.4,
+ bytestring >= 0.9 && < 0.11,
+ text >= 0.11 && < 1.3,
+ zip-archive >= 0.2.3.4 && < 0.4,
+ HTTP >= 4000.0.5 && < 4000.4,
+ texmath >= 0.9 && < 0.10,
+ xml >= 1.3.12 && < 1.4,
+ random >= 1 && < 1.2,
+ extensible-exceptions >= 0.1 && < 0.2,
+ pandoc-types >= 1.17 && < 1.18,
+ aeson >= 0.7 && < 1.2,
+ aeson-pretty >= 0.8 && < 0.9,
+ tagsoup >= 0.13.7 && < 0.15,
+ base64-bytestring >= 0.1 && < 1.1,
+ zlib >= 0.5 && < 0.7,
+ skylighting >= 0.2 && < 0.4,
+ data-default >= 0.4 && < 0.8,
+ temporary >= 1.1 && < 1.3,
+ blaze-html >= 0.5 && < 0.10,
+ blaze-markup >= 0.5.1 && < 0.9,
+ yaml >= 0.8.8.2 && < 0.9,
+ scientific >= 0.2 && < 0.4,
+ vector >= 0.10 && < 0.13,
+ hslua >= 0.3 && < 0.5,
+ binary >= 0.5 && < 0.9,
+ SHA >= 1.6 && < 1.7,
+ haddock-library >= 1.1 && < 1.5,
+ old-time,
+ deepseq >= 1.3 && < 1.5,
+ JuicyPixels >= 3.1.6.1 && < 3.3,
+ Glob >= 0.7 && < 0.8,
+ cmark >= 0.5 && < 0.6,
+ doctemplates >= 0.1 && < 0.2,
+ free >= 4
+ if os(windows)
+ Cpp-options: -D_WINDOWS
+ else
+ Build-Depends: unix >= 2.4 && < 2.8
+ if flag(old-locale)
+ Build-Depends: old-locale >= 1 && < 1.1,
+ time >= 1.2 && < 1.5
+ else
+ Build-Depends: time >= 1.5 && < 1.7
+ if flag(network-uri)
+ Build-Depends: network-uri >= 2.6 && < 2.7, network >= 2.6
+ else
+ Build-Depends: network >= 2 && < 2.6
+ if flag(https)
+ Build-Depends: http-client >= 0.4.30 && < 0.6,
+ http-client-tls >= 0.2.4 && < 0.4,
+ http-types >= 0.8 && < 0.10
+ cpp-options: -DHTTP_CLIENT
+ if flag(embed_data_files)
+ cpp-options: -DEMBED_DATA_FILES
+ Build-Tools: hsb2hs >= 0.3.1
+ other-modules: Text.Pandoc.Data
+ if os(darwin)
+ Build-Tools: cpphs >= 1.19
+ ghc-options: -pgmP cpphs -optP --cpp
+ if os(windows)
+ Cpp-options: -D_WINDOWS
+ Ghc-Options: -Wall -fno-warn-unused-do-bind
+ Ghc-Prof-Options: -fprof-auto-exported
+ Default-Language: Haskell98
+ Other-Extensions: PatternGuards, OverloadedStrings,
+ ScopedTypeVariables, GeneralizedNewtypeDeriving,
+ RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,
+ FlexibleInstances
+ Hs-Source-Dirs: src
+ if impl(ghc < 7.10)
+ Hs-Source-Dirs: prelude
+ Other-Modules: Prelude
+
+ Exposed-Modules: Text.Pandoc,
+ Text.Pandoc.App,
+ Text.Pandoc.Options,
+ Text.Pandoc.Extensions,
+ Text.Pandoc.Pretty,
+ Text.Pandoc.Shared,
+ Text.Pandoc.MediaBag,
+ Text.Pandoc.Error,
+ Text.Pandoc.Readers.HTML,
+ Text.Pandoc.Readers.LaTeX,
+ Text.Pandoc.Readers.Markdown,
+ Text.Pandoc.Readers.CommonMark,
+ Text.Pandoc.Readers.MediaWiki,
+ Text.Pandoc.Readers.RST,
+ Text.Pandoc.Readers.Org,
+ Text.Pandoc.Readers.DocBook,
+ Text.Pandoc.Readers.OPML,
+ Text.Pandoc.Readers.Textile,
+ Text.Pandoc.Readers.Native,
+ Text.Pandoc.Readers.Haddock,
+ Text.Pandoc.Readers.TWiki,
+ Text.Pandoc.Readers.Txt2Tags,
+ Text.Pandoc.Readers.Docx,
+ Text.Pandoc.Readers.Odt,
+ Text.Pandoc.Readers.EPUB,
+ Text.Pandoc.Writers.Native,
+ Text.Pandoc.Writers.Docbook,
+ Text.Pandoc.Writers.OPML,
+ Text.Pandoc.Writers.HTML,
+ Text.Pandoc.Writers.ICML,
+ Text.Pandoc.Writers.LaTeX,
+ Text.Pandoc.Writers.ConTeXt,
+ Text.Pandoc.Writers.OpenDocument,
+ Text.Pandoc.Writers.Texinfo,
+ Text.Pandoc.Writers.Man,
+ Text.Pandoc.Writers.Markdown,
+ Text.Pandoc.Writers.CommonMark,
+ Text.Pandoc.Writers.Haddock,
+ Text.Pandoc.Writers.RST,
+ Text.Pandoc.Writers.Org,
+ Text.Pandoc.Writers.AsciiDoc,
+ Text.Pandoc.Writers.Custom,
+ Text.Pandoc.Writers.Textile,
+ Text.Pandoc.Writers.MediaWiki,
+ Text.Pandoc.Writers.DokuWiki,
+ Text.Pandoc.Writers.ZimWiki,
+ Text.Pandoc.Writers.RTF,
+ Text.Pandoc.Writers.ODT,
+ Text.Pandoc.Writers.Docx,
+ Text.Pandoc.Writers.EPUB,
+ Text.Pandoc.Writers.FB2,
+ Text.Pandoc.Writers.TEI,
+ Text.Pandoc.Writers.Math,
+ Text.Pandoc.PDF,
+ Text.Pandoc.UTF8,
+ Text.Pandoc.Templates,
+ Text.Pandoc.XML,
+ Text.Pandoc.SelfContained,
+ Text.Pandoc.Highlighting,
+ Text.Pandoc.Logging,
+ Text.Pandoc.Process,
+ Text.Pandoc.MIME,
+ Text.Pandoc.Class
+ Other-Modules: Text.Pandoc.Readers.Docx.Lists,
+ Text.Pandoc.Readers.Docx.Combine,
+ Text.Pandoc.Readers.Docx.Parse,
+ Text.Pandoc.Readers.Docx.Util,
+ Text.Pandoc.Readers.Docx.StyleMap,
+ Text.Pandoc.Readers.Odt.Base,
+ Text.Pandoc.Readers.Odt.Namespaces,
+ Text.Pandoc.Readers.Odt.StyleReader,
+ Text.Pandoc.Readers.Odt.ContentReader,
+ Text.Pandoc.Readers.Odt.Generic.Fallible,
+ Text.Pandoc.Readers.Odt.Generic.SetMap,
+ Text.Pandoc.Readers.Odt.Generic.Utils,
+ Text.Pandoc.Readers.Odt.Generic.Namespaces,
+ Text.Pandoc.Readers.Odt.Generic.XMLConverter,
+ Text.Pandoc.Readers.Odt.Arrows.State,
+ Text.Pandoc.Readers.Odt.Arrows.Utils,
+ Text.Pandoc.Readers.Org.BlockStarts,
+ Text.Pandoc.Readers.Org.Blocks,
+ Text.Pandoc.Readers.Org.ExportSettings,
+ Text.Pandoc.Readers.Org.Inlines,
+ Text.Pandoc.Readers.Org.Meta,
+ Text.Pandoc.Readers.Org.ParserState,
+ Text.Pandoc.Readers.Org.Parsing,
+ Text.Pandoc.Readers.Org.Shared,
+ Text.Pandoc.Writers.Shared,
+ Text.Pandoc.Asciify,
+ Text.Pandoc.CSS,
+ Text.Pandoc.Emoji,
+ Text.Pandoc.Parsing,
+ Text.Pandoc.UUID,
+ Text.Pandoc.ImageSize,
+ Text.Pandoc.Slides,
+ Text.Pandoc.Compat.Time,
+ Paths_pandoc
+
+ Buildable: True
+
+Executable pandoc
+ Build-Depends: pandoc,
+ base >= 4.2 && < 5
+ Ghc-Options: -rtsopts -with-rtsopts=-K16m -Wall -fno-warn-unused-do-bind
+ Ghc-Prof-Options: -fprof-auto-exported -rtsopts -with-rtsopts=-K16m
+
+ Default-Language: Haskell98
+ Other-Extensions: PatternGuards, OverloadedStrings,
+ ScopedTypeVariables, GeneralizedNewtypeDeriving,
+ RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,
+ FlexibleInstances
+ Hs-Source-Dirs: .
+ if impl(ghc < 7.10)
+ Hs-Source-Dirs: prelude
+ Other-Modules: Prelude
+ Main-Is: pandoc.hs
+ Buildable: True
+ Other-Modules: Paths_pandoc
+
+Executable trypandoc
+ Main-Is: trypandoc.hs
+ Hs-Source-Dirs: trypandoc
+ if impl(ghc < 7.10)
+ Hs-Source-Dirs: prelude
+ Other-Modules: Prelude
+ default-language: Haskell2010
+ if flag(trypandoc)
+ Build-Depends: base, aeson, pandoc,
+ text, wai-extra, wai >= 0.3, http-types
+ Buildable: True
+ else
+ Buildable: False
+
+Executable weigh-pandoc
+ Main-Is: weigh-pandoc.hs
+ Hs-Source-Dirs: benchmark
+ if impl(ghc < 7.10)
+ Hs-Source-Dirs: prelude
+ Other-Modules: Prelude
+ if flag(weigh-pandoc)
+ Build-Depends: pandoc,
+ base >= 4.2 && < 5,
+ weigh >= 0.0 && < 0.1,
+ mtl >= 2.2 && < 2.3
+ Buildable: True
+ else
+ Buildable: False
+ Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind
+ Default-Language: Haskell98
+
+Test-Suite test-pandoc
+ Type: exitcode-stdio-1.0
+ Main-Is: test-pandoc.hs
+ Hs-Source-Dirs: test
+ if impl(ghc < 7.10)
+ Hs-Source-Dirs: prelude
+ Other-Modules: Prelude
+ Build-Depends: base >= 4.2 && < 5,
+ syb >= 0.1 && < 0.7,
+ pandoc,
+ pandoc-types >= 1.17 && < 1.18,
+ bytestring >= 0.9 && < 0.11,
+ text >= 0.11 && < 1.3,
+ directory >= 1 && < 1.4,
+ filepath >= 1.1 && < 1.5,
+ process >= 1.2.3 && < 1.5,
+ skylighting >= 0.2 && < 0.4,
+ Diff >= 0.2 && < 0.4,
+ test-framework >= 0.3 && < 0.9,
+ test-framework-hunit >= 0.2 && < 0.4,
+ test-framework-quickcheck2 >= 0.2.9 && < 0.4,
+ QuickCheck >= 2.4 && < 2.10,
+ HUnit >= 1.2 && < 1.6,
+ containers >= 0.1 && < 0.6,
+ ansi-terminal >= 0.5 && < 0.7,
+ executable-path >= 0.0 && < 0.1,
+ zip-archive >= 0.2.3.4 && < 0.4,
+ mtl >= 2.2 && < 2.3
+ Other-Modules: Tests.Old
+ Tests.Command
+ Tests.Helpers
+ Tests.Shared
+ Tests.Readers.LaTeX
+ Tests.Readers.HTML
+ Tests.Readers.Markdown
+ Tests.Readers.Org
+ Tests.Readers.RST
+ Tests.Readers.Docx
+ Tests.Readers.Odt
+ Tests.Readers.Txt2Tags
+ Tests.Readers.EPUB
+ Tests.Writers.Native
+ Tests.Writers.ConTeXt
+ Tests.Writers.Docbook
+ Tests.Writers.HTML
+ Tests.Writers.Markdown
+ Tests.Writers.Org
+ Tests.Writers.Plain
+ Tests.Writers.AsciiDoc
+ Tests.Writers.LaTeX
+ Tests.Writers.Docx
+ Tests.Writers.RST
+ Tests.Writers.TEI
+ Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind -threaded
+ Default-Language: Haskell98
+
+benchmark benchmark-pandoc
+ Type: exitcode-stdio-1.0
+ Main-Is: benchmark-pandoc.hs
+ Hs-Source-Dirs: benchmark
+ if impl(ghc < 7.10)
+ Hs-Source-Dirs: prelude
+ Other-Modules: Prelude
+ Build-Depends: pandoc,
+ time, bytestring, containers,
+ base >= 4.2 && < 5,
+ syb >= 0.1 && < 0.7,
+ criterion >= 1.0 && < 1.2
+ Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind
+ Default-Language: Haskell98
diff --git a/pandoc.hs b/pandoc.hs
new file mode 100644
index 000000000..298161249
--- /dev/null
+++ b/pandoc.hs
@@ -0,0 +1,37 @@
+{-# LANGUAGE CPP, TupleSections, ScopedTypeVariables, PatternGuards #-}
+{-
+Copyright (C) 2006-2016 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 : Main
+ Copyright : Copyright (C) 2006-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley@edu>
+ Stability : alpha
+ Portability : portable
+
+Parses command-line options and calls the appropriate readers and
+writers.
+-}
+module Main where
+import Text.Pandoc.App (defaultOpts, convertWithOpts, parseOptions, options)
+
+main :: IO ()
+main = parseOptions options defaultOpts >>= convertWithOpts
+
diff --git a/prelude/Prelude.hs b/prelude/Prelude.hs
new file mode 100644
index 000000000..34f133d83
--- /dev/null
+++ b/prelude/Prelude.hs
@@ -0,0 +1,26 @@
+{-# LANGUAGE PackageImports #-}
+{-# LANGUAGE CPP #-}
+
+-- This custom Prelude emulates the API of the prelude
+-- with base 4.8.
+
+module Prelude
+(
+ module P
+#if MIN_VERSION_base(4,8,0)
+#else
+, Monoid(..)
+, Applicative(..)
+, (<$>)
+, (<$)
+#endif
+)
+where
+
+#if MIN_VERSION_base(4,8,0)
+import "base" Prelude as P
+#else
+import "base" Prelude as P
+import Control.Applicative
+import Data.Monoid
+#endif
diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs
new file mode 100644
index 000000000..47b891eb3
--- /dev/null
+++ b/src/Text/Pandoc.hs
@@ -0,0 +1,380 @@
+{-# LANGUAGE ScopedTypeVariables, FlexibleInstances, GADTs #-}
+{-
+Copyright (C) 2006-2016 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
+ Copyright : Copyright (C) 2006-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+This helper module exports the main writers, readers, and data
+structure definitions from the Pandoc libraries.
+
+A typical application will chain together a reader and a writer
+to convert strings from one format to another. For example, the
+following simple program will act as a filter converting markdown
+fragments to reStructuredText, using reference-style links instead of
+inline links:
+
+> module Main where
+> import Text.Pandoc
+>
+> markdownToRST :: String -> Either PandocError String
+> markdownToRST =
+> writeRST def {writerReferenceLinks = True} . readMarkdown def
+>
+> main = getContents >>= either error return markdownToRST >>= putStrLn
+
+Note: all of the readers assume that the input text has @'\n'@
+line endings. So if you get your input text from a web form,
+you should remove @'\r'@ characters using @filter (/='\r')@.
+
+-}
+
+module Text.Pandoc
+ (
+ -- * Definitions
+ module Text.Pandoc.Definition
+ -- * Generics
+ , module Text.Pandoc.Generic
+ -- * Options
+ , module Text.Pandoc.Options
+ -- * Logging
+ , module Text.Pandoc.Logging
+ -- * Typeclass
+ , PandocMonad
+ , runIO
+ , runPure
+ , runIOorExplode
+ , setVerbosity
+ -- * Error handling
+ , module Text.Pandoc.Error
+ -- * Lists of readers and writers
+ , readers
+ -- , writers
+ , writers
+ -- * Readers: converting /to/ Pandoc format
+ , Reader (..)
+ , readDocx
+ , readOdt
+ , readMarkdown
+ , readCommonMark
+ , readMediaWiki
+ , readRST
+ , readOrg
+ , readLaTeX
+ , readHtml
+ , readTextile
+ , readDocBook
+ , readOPML
+ , readHaddock
+ , readNative
+ , readJSON
+ , readTWiki
+ , readTxt2Tags
+ , readEPUB
+ -- * Writers: converting /from/ Pandoc format
+ , Writer(..)
+ , writeNative
+ , writeJSON
+ , writeMarkdown
+ , writePlain
+ , writeRST
+ , writeLaTeX
+ , writeBeamer
+ , writeConTeXt
+ , writeTexinfo
+ , writeHtml4
+ , writeHtml4String
+ , writeHtml5
+ , writeHtml5String
+ , writeRevealJs
+ , writeS5
+ , writeSlidy
+ , writeSlideous
+ , writeDZSlides
+ , writeICML
+ , writeDocbook4
+ , writeDocbook5
+ , writeOPML
+ , writeOpenDocument
+ , writeMan
+ , writeMediaWiki
+ , writeDokuWiki
+ , writeZimWiki
+ , writeTextile
+ , writeRTF
+ , writeODT
+ , writeDocx
+ , writeEPUB2
+ , writeEPUB3
+ , writeFB2
+ , writeOrg
+ , writeAsciiDoc
+ , writeHaddock
+ , writeCommonMark
+ , writeCustom
+ , writeTEI
+ -- * Rendering templates and default templates
+ , module Text.Pandoc.Templates
+ -- * Miscellaneous
+ , getReader
+ , getWriter
+ , getDefaultExtensions
+ , pandocVersion
+ ) where
+
+import Text.Pandoc.Definition
+import Text.Pandoc.Generic
+import Text.Pandoc.Readers.Markdown
+import Text.Pandoc.Readers.CommonMark
+import Text.Pandoc.Readers.MediaWiki
+import Text.Pandoc.Readers.RST
+import Text.Pandoc.Readers.Org
+import Text.Pandoc.Readers.DocBook
+import Text.Pandoc.Readers.OPML
+import Text.Pandoc.Readers.LaTeX
+import Text.Pandoc.Readers.HTML
+import Text.Pandoc.Readers.Textile
+import Text.Pandoc.Readers.Native
+import Text.Pandoc.Readers.Haddock
+import Text.Pandoc.Readers.TWiki
+import Text.Pandoc.Readers.Docx
+import Text.Pandoc.Readers.Odt
+import Text.Pandoc.Readers.Txt2Tags
+import Text.Pandoc.Readers.EPUB
+import Text.Pandoc.Writers.Native
+import Text.Pandoc.Writers.Markdown
+import Text.Pandoc.Writers.RST
+import Text.Pandoc.Writers.LaTeX
+import Text.Pandoc.Writers.ConTeXt
+import Text.Pandoc.Writers.Texinfo
+import Text.Pandoc.Writers.HTML
+import Text.Pandoc.Writers.ODT
+import Text.Pandoc.Writers.Docx
+import Text.Pandoc.Writers.EPUB
+import Text.Pandoc.Writers.FB2
+import Text.Pandoc.Writers.ICML
+import Text.Pandoc.Writers.Docbook
+import Text.Pandoc.Writers.OPML
+import Text.Pandoc.Writers.OpenDocument
+import Text.Pandoc.Writers.Man
+import Text.Pandoc.Writers.RTF
+import Text.Pandoc.Writers.MediaWiki
+import Text.Pandoc.Writers.DokuWiki
+import Text.Pandoc.Writers.ZimWiki
+import Text.Pandoc.Writers.Textile
+import Text.Pandoc.Writers.Org
+import Text.Pandoc.Writers.AsciiDoc
+import Text.Pandoc.Writers.Haddock
+import Text.Pandoc.Writers.CommonMark
+import Text.Pandoc.Writers.Custom
+import Text.Pandoc.Writers.TEI
+import Text.Pandoc.Templates
+import Text.Pandoc.Options
+import Text.Pandoc.Logging
+import Text.Pandoc.Shared (safeRead, mapLeft, pandocVersion)
+import Text.Pandoc.Error
+import Text.Pandoc.Class
+import Data.Aeson
+import qualified Data.ByteString.Lazy as BL
+import Data.List (intercalate)
+import Text.Parsec
+import Text.Parsec.Error
+import qualified Text.Pandoc.UTF8 as UTF8
+import Control.Monad.Except (throwError)
+
+parseFormatSpec :: String
+ -> Either ParseError (String, Extensions -> Extensions)
+parseFormatSpec = parse formatSpec ""
+ where formatSpec = do
+ name <- formatName
+ extMods <- many extMod
+ return (name, \x -> foldl (flip ($)) x extMods)
+ formatName = many1 $ noneOf "-+"
+ extMod = do
+ polarity <- oneOf "-+"
+ name <- many $ noneOf "-+"
+ ext <- case safeRead ("Ext_" ++ name) of
+ Just n -> return n
+ Nothing
+ | name == "lhs" -> return Ext_literate_haskell
+ | otherwise -> fail $ "Unknown extension: " ++ name
+ return $ case polarity of
+ '-' -> disableExtension ext
+ _ -> enableExtension ext
+
+data Reader m = StringReader (ReaderOptions -> String -> m Pandoc)
+ | ByteStringReader (ReaderOptions -> BL.ByteString -> m Pandoc)
+
+-- | Association list of formats and readers.
+readers :: PandocMonad m => [(String, Reader m)]
+readers = [ ("native" , StringReader readNative)
+ ,("json" , StringReader $ \o s ->
+ case readJSON o s of
+ Right doc -> return doc
+ Left _ -> throwError $ PandocParseError "JSON parse error")
+ ,("markdown" , StringReader readMarkdown)
+ ,("markdown_strict" , StringReader readMarkdown)
+ ,("markdown_phpextra" , StringReader readMarkdown)
+ ,("markdown_github" , StringReader readMarkdown)
+ ,("markdown_mmd", StringReader readMarkdown)
+ ,("commonmark" , StringReader readCommonMark)
+ ,("rst" , StringReader readRST)
+ ,("mediawiki" , StringReader readMediaWiki)
+ ,("docbook" , StringReader readDocBook)
+ ,("opml" , StringReader readOPML)
+ ,("org" , StringReader readOrg)
+ ,("textile" , StringReader readTextile) -- TODO : textile+lhs
+ ,("html" , StringReader readHtml)
+ ,("latex" , StringReader readLaTeX)
+ ,("haddock" , StringReader readHaddock)
+ ,("twiki" , StringReader readTWiki)
+ ,("docx" , ByteStringReader readDocx)
+ ,("odt" , ByteStringReader readOdt)
+ ,("t2t" , StringReader readTxt2Tags)
+ ,("epub" , ByteStringReader readEPUB)
+ ]
+
+data Writer m = StringWriter (WriterOptions -> Pandoc -> m String)
+ | ByteStringWriter (WriterOptions -> Pandoc -> m BL.ByteString)
+
+-- | Association list of formats and writers.
+writers :: PandocMonad m => [ ( String, Writer m) ]
+writers = [
+ ("native" , StringWriter writeNative)
+ ,("json" , StringWriter $ \o d -> return $ writeJSON o d)
+ ,("docx" , ByteStringWriter writeDocx)
+ ,("odt" , ByteStringWriter writeODT)
+ ,("epub" , ByteStringWriter writeEPUB3)
+ ,("epub2" , ByteStringWriter writeEPUB2)
+ ,("epub3" , ByteStringWriter writeEPUB3)
+ ,("fb2" , StringWriter writeFB2)
+ ,("html" , StringWriter writeHtml5String)
+ ,("html4" , StringWriter writeHtml4String)
+ ,("html5" , StringWriter writeHtml5String)
+ ,("icml" , StringWriter writeICML)
+ ,("s5" , StringWriter writeS5)
+ ,("slidy" , StringWriter writeSlidy)
+ ,("slideous" , StringWriter writeSlideous)
+ ,("dzslides" , StringWriter writeDZSlides)
+ ,("revealjs" , StringWriter writeRevealJs)
+ ,("docbook" , StringWriter writeDocbook5)
+ ,("docbook4" , StringWriter writeDocbook4)
+ ,("docbook5" , StringWriter writeDocbook5)
+ ,("opml" , StringWriter writeOPML)
+ ,("opendocument" , StringWriter writeOpenDocument)
+ ,("latex" , StringWriter writeLaTeX)
+ ,("beamer" , StringWriter writeBeamer)
+ ,("context" , StringWriter writeConTeXt)
+ ,("texinfo" , StringWriter writeTexinfo)
+ ,("man" , StringWriter writeMan)
+ ,("markdown" , StringWriter writeMarkdown)
+ ,("markdown_strict" , StringWriter writeMarkdown)
+ ,("markdown_phpextra" , StringWriter writeMarkdown)
+ ,("markdown_github" , StringWriter writeMarkdown)
+ ,("markdown_mmd" , StringWriter writeMarkdown)
+ ,("plain" , StringWriter writePlain)
+ ,("rst" , StringWriter writeRST)
+ ,("mediawiki" , StringWriter writeMediaWiki)
+ ,("dokuwiki" , StringWriter writeDokuWiki)
+ ,("zimwiki" , StringWriter writeZimWiki)
+ ,("textile" , StringWriter writeTextile)
+ ,("rtf" , StringWriter writeRTF)
+ ,("org" , StringWriter writeOrg)
+ ,("asciidoc" , StringWriter writeAsciiDoc)
+ ,("haddock" , StringWriter writeHaddock)
+ ,("commonmark" , StringWriter writeCommonMark)
+ ,("tei" , StringWriter writeTEI)
+ ]
+
+getDefaultExtensions :: String -> Extensions
+getDefaultExtensions "markdown_strict" = strictExtensions
+getDefaultExtensions "markdown_phpextra" = phpMarkdownExtraExtensions
+getDefaultExtensions "markdown_mmd" = multimarkdownExtensions
+getDefaultExtensions "markdown_github" = githubMarkdownExtensions
+getDefaultExtensions "markdown" = pandocExtensions
+getDefaultExtensions "plain" = plainExtensions
+getDefaultExtensions "org" = extensionsFromList
+ [Ext_citations,
+ Ext_auto_identifiers]
+getDefaultExtensions "html" = extensionsFromList
+ [Ext_auto_identifiers,
+ Ext_native_divs,
+ Ext_native_spans]
+getDefaultExtensions "html4" = getDefaultExtensions "html"
+getDefaultExtensions "html5" = getDefaultExtensions "html"
+getDefaultExtensions "epub" = extensionsFromList
+ [Ext_raw_html,
+ Ext_native_divs,
+ Ext_native_spans,
+ Ext_epub_html_exts]
+getDefaultExtensions "epub2" = getDefaultExtensions "epub"
+getDefaultExtensions "epub3" = getDefaultExtensions "epub"
+getDefaultExtensions "latex" = extensionsFromList
+ [Ext_smart,
+ Ext_auto_identifiers]
+getDefaultExtensions "context" = extensionsFromList
+ [Ext_smart,
+ Ext_auto_identifiers]
+getDefaultExtensions "textile" = extensionsFromList
+ [Ext_old_dashes,
+ Ext_smart,
+ Ext_raw_html,
+ Ext_auto_identifiers]
+getDefaultExtensions _ = extensionsFromList
+ [Ext_auto_identifiers]
+
+-- | Retrieve reader based on formatSpec (format+extensions).
+getReader :: PandocMonad m => String -> Either String (Reader m)
+getReader s =
+ case parseFormatSpec s of
+ Left e -> Left $ intercalate "\n" [m | Message m <- errorMessages e]
+ Right (readerName, setExts) ->
+ case lookup readerName readers of
+ Nothing -> Left $ "Unknown reader: " ++ readerName
+ Just (StringReader r) -> Right $ StringReader $ \o ->
+ r o{ readerExtensions = setExts $
+ getDefaultExtensions readerName }
+ Just (ByteStringReader r) -> Right $ ByteStringReader $ \o ->
+ r o{ readerExtensions = setExts $
+ getDefaultExtensions readerName }
+
+getWriter :: PandocMonad m => String -> Either String (Writer m)
+getWriter s
+ = case parseFormatSpec s of
+ Left e -> Left $ intercalate "\n" [m | Message m <- errorMessages e]
+ Right (writerName, setExts) ->
+ case lookup writerName writers of
+ Nothing -> Left $ "Unknown writer: " ++ writerName
+ Just (StringWriter r) -> Right $ StringWriter $
+ \o -> r o{ writerExtensions = setExts $
+ getDefaultExtensions writerName }
+ Just (ByteStringWriter r) -> Right $ ByteStringWriter $
+ \o -> r o{ writerExtensions = setExts $
+ getDefaultExtensions writerName }
+
+readJSON :: ReaderOptions -> String -> Either PandocError Pandoc
+readJSON _ = mapLeft PandocParseError . eitherDecode' . UTF8.fromStringLazy
+
+writeJSON :: WriterOptions -> Pandoc -> String
+writeJSON _ = UTF8.toStringLazy . encode
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
new file mode 100644
index 000000000..be8f26811
--- /dev/null
+++ b/src/Text/Pandoc/App.hs
@@ -0,0 +1,1444 @@
+{-# LANGUAGE CPP, TupleSections, ScopedTypeVariables, PatternGuards #-}
+{-
+Copyright (C) 2006-2016 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-2016 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(..)
+ , defaultOpts
+ , parseOptions
+ , options
+ ) where
+import Text.Pandoc
+import Text.Pandoc.Builder (setMeta)
+import Text.Pandoc.PDF (makePDF)
+import Text.Pandoc.Walk (walk)
+import Text.Pandoc.Shared ( tabFilter, readDataFileUTF8,
+ headerShift, err, openURL, safeRead,
+ readDataFile )
+import Text.Pandoc.MediaBag ( mediaDirectory, extractMediaBag, MediaBag )
+import Text.Pandoc.XML ( toEntities )
+import Text.Pandoc.Highlighting (highlightingStyles)
+import Text.Pandoc.SelfContained ( makeSelfContained )
+import Text.Pandoc.Process (pipeProcess)
+import Skylighting ( Style, defaultSyntaxMap, Syntax(..) )
+import Text.Printf
+import System.Environment ( getEnvironment, getProgName, getArgs )
+import Control.Applicative ((<|>))
+import System.Exit ( ExitCode (..), exitSuccess )
+import System.FilePath
+import Data.Char ( toLower, toUpper )
+import Data.List ( intercalate, isPrefixOf, isSuffixOf, sort )
+import System.Directory ( getAppUserDataDirectory, findExecutable,
+ doesFileExist, Permissions(..), getPermissions )
+import System.IO ( stdout, stderr )
+import System.IO.Error ( isDoesNotExistError )
+import qualified Control.Exception as E
+import Control.Exception.Extensible ( throwIO )
+import qualified Text.Pandoc.UTF8 as UTF8
+import Control.Monad
+import Control.Monad.Trans
+import Data.Maybe (fromMaybe, isNothing, isJust)
+import Data.Foldable (foldrM)
+import Network.URI (parseURI, isURI, URI(..))
+import qualified Data.ByteString.Lazy as B
+import qualified Data.ByteString as BS
+import qualified Data.Map as M
+import Data.Aeson (eitherDecode', encode)
+import Data.Yaml (decode)
+import qualified Data.Yaml as Yaml
+import qualified Data.Text as T
+import System.Console.GetOpt
+import Text.Pandoc.Class (withMediaBag, PandocIO, getLog)
+import Paths_pandoc (getDataDir)
+#ifndef _WINDOWS
+import System.Posix.Terminal (queryTerminal)
+import System.Posix.IO (stdOutput)
+#endif
+
+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 [] unrecognizedOpts
+
+ unless (null errors && null unknownOptionErrors) $
+ err 2 $ 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 })
+
+convertWithOpts :: Opt -> IO ()
+convertWithOpts opts = do
+ let args = optInputFiles opts
+ let outputFile = optOutputFile opts
+ let filters = optFilters opts
+ let verbosity = optVerbosity opts
+
+ when (optDumpArgs opts) $
+ do UTF8.hPutStrLn stdout outputFile
+ mapM_ (UTF8.hPutStrLn stdout) args
+ exitSuccess
+
+ epubStylesheet <- case optEpubStylesheet opts of
+ Nothing -> return Nothing
+ Just fp -> Just <$> UTF8.readFile fp
+
+ epubMetadata <- case optEpubMetadata opts of
+ Nothing -> return Nothing
+ Just fp -> Just <$> UTF8.readFile fp
+
+ let csscdn = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css"
+ let mathMethod =
+ case (optKaTeXJS opts, optKaTeXStylesheet opts) of
+ (Nothing, _) -> optHTMLMathMethod opts
+ (Just js, ss) -> KaTeX js (fromMaybe csscdn ss)
+
+
+ -- --bibliography implies -F pandoc-citeproc for backwards compatibility:
+ let needsCiteproc = isJust (lookup "bibliography" (optMetadata opts)) &&
+ optCiteMethod opts `notElem` [Natbib, Biblatex] &&
+ "pandoc-citeproc" `notElem` map takeBaseName filters
+ let filters' = if needsCiteproc then "pandoc-citeproc" : filters
+ else filters
+
+ let sources = case args 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
+ Nothing -> defaultReaderName
+ (if any isURI sources
+ then "html"
+ else "markdown") sources
+ Just x -> map toLower x
+
+ let writerName = case optWriter opts of
+ Nothing -> defaultWriterName outputFile
+ Just x -> map toLower x
+ let format = takeWhile (`notElem` ['+','-'])
+ $ takeFileName writerName -- in case path to lua script
+
+ let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"
+
+ let laTeXOutput = format `elem` ["latex", "beamer"]
+ let conTeXtOutput = format == "context"
+ let html5Output = format == "html5" || format == "html"
+
+ -- disabling the custom writer for now
+ writer <- if ".lua" `isSuffixOf` format
+ -- note: use non-lowercased version writerName
+ then error "custom writers disabled for now"
+ else case getWriter writerName of
+ Left e -> err 9 $
+ if format == "pdf"
+ then e ++
+ "\nTo create a pdf with pandoc, use " ++
+ "the latex or beamer writer and specify\n" ++
+ "an output file with .pdf extension " ++
+ "(pandoc -t latex -o filename.pdf)."
+ else e
+ Right w -> return (w :: Writer PandocIO)
+
+ -- TODO: we have to get the input and the output into the state for
+ -- the sake of the text2tags reader.
+ reader <- case getReader readerName of
+ Right r -> return (r :: Reader PandocIO)
+ Left e -> err 7 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
+
+ templ <- case optTemplate opts of
+ _ | not standalone -> return Nothing
+ Nothing -> do
+ deftemp <- getDefaultTemplate datadir format
+ case deftemp of
+ Left e -> throwIO e
+ Right t -> return (Just t)
+ Just tp -> do
+ -- strip off extensions
+ let tp' = case takeExtension tp of
+ "" -> tp <.> format
+ _ -> tp
+ Just <$> E.catch (UTF8.readFile tp')
+ (\e -> if isDoesNotExistError e
+ then E.catch
+ (readDataFileUTF8 datadir
+ ("templates" </> tp'))
+ (\e' -> let _ = (e' :: E.SomeException)
+ in throwIO e')
+ else throwIO e)
+
+ let addStringAsVariable varname s vars = return $ (varname, s) : vars
+
+ let addContentsAsVariable varname fp vars = do
+ s <- UTF8.readFile fp
+ return $ (varname, s) : vars
+
+ -- 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
+
+ variables <- return (optVariables opts)
+ >>=
+ 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 -> case mathMethod of
+ LaTeXMathML Nothing -> do
+ s <- readDataFileUTF8 datadir "LaTeXMathML.js"
+ return $ ("mathml-script", s) : vars
+ _ -> return vars)
+ >>=
+ (\vars -> if format == "dzslides"
+ then do
+ dztempl <- readDataFileUTF8 datadir
+ ("dzslides" </> "template.html")
+ let dzline = "<!-- {{{{ dzslides core"
+ let dzcore = unlines
+ $ dropWhile (not . (dzline `isPrefixOf`))
+ $ lines dztempl
+ return $ ("dzslides-core", dzcore) : vars
+ else return vars)
+
+ let sourceURL = case sources of
+ [] -> Nothing
+ (x:_) -> case parseURI x of
+ Just u
+ | uriScheme u `elem` ["http:","https:"] ->
+ Just $ show u{ uriQuery = "",
+ uriFragment = "" }
+ _ -> Nothing
+
+ let readerOpts = def{ readerStandalone = standalone
+ , readerColumns = optColumns opts
+ , readerTabStop = optTabStop opts
+ , readerIndentedCodeClasses = optIndentedCodeClasses opts
+ , readerApplyMacros = not laTeXOutput
+ , readerDefaultImageExtension =
+ optDefaultImageExtension opts
+ , readerTrackChanges = optTrackChanges opts
+ }
+
+ highlightStyle <- lookupHighlightStyle $ optHighlightStyle opts
+
+ let writerOptions = def { writerTemplate = templ,
+ writerVariables = variables,
+ writerTabStop = optTabStop opts,
+ writerTableOfContents = optTableOfContents opts,
+ writerHTMLMathMethod = mathMethod,
+ writerIncremental = optIncremental opts,
+ writerCiteMethod = optCiteMethod opts,
+ writerNumberSections = optNumberSections opts,
+ writerNumberOffset = optNumberOffset opts,
+ writerSectionDivs = optSectionDivs opts,
+ writerReferenceLinks = optReferenceLinks opts,
+ writerReferenceLocation = optReferenceLocation opts,
+ writerDpi = optDpi opts,
+ writerWrapText = optWrapText opts,
+ writerColumns = optColumns opts,
+ writerEmailObfuscation = optEmailObfuscation opts,
+ writerIdentifierPrefix = optIdentifierPrefix opts,
+ writerSourceURL = sourceURL,
+ writerUserDataDir = datadir,
+ writerHtmlQTags = optHtmlQTags opts,
+ writerTopLevelDivision = optTopLevelDivision opts,
+ writerListings = optListings opts,
+ writerSlideLevel = optSlideLevel opts,
+ writerHighlightStyle = highlightStyle,
+ writerSetextHeaders = optSetextHeaders opts,
+ writerEpubMetadata = epubMetadata,
+ writerEpubStylesheet = epubStylesheet,
+ writerEpubFonts = optEpubFonts opts,
+ writerEpubChapterLevel = optEpubChapterLevel opts,
+ writerTOCDepth = optTOCDepth opts,
+ writerReferenceDoc = optReferenceDoc opts,
+ writerLaTeXArgs = optLaTeXEngineArgs opts
+ }
+
+
+#ifdef _WINDOWS
+ let istty = True
+#else
+ istty <- queryTerminal stdOutput
+#endif
+ when (istty && not (isTextFormat format) && outputFile == "-") $
+ err 5 $ "Cannot write " ++ format ++ " output to stdout.\n" ++
+ "Specify an output file using the -o option."
+
+
+ let transforms = case optBaseHeaderLevel opts of
+ x | x > 1 -> [headerShift (x - 1)]
+ | otherwise -> []
+
+ let convertTabs = tabFilter (if optPreserveTabs opts || readerName == "t2t"
+ then 0
+ else optTabStop opts)
+
+ readSources :: (Functor m, MonadIO m) => [FilePath] -> m String
+ readSources srcs = convertTabs . intercalate "\n" <$>
+ mapM readSource srcs
+
+ let runIO' :: PandocIO a -> IO a
+ runIO' f = do
+ (res, reports) <- runIOorExplode $ do
+ 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) $
+ err 3 "Failing because there were warnings."
+ return res
+
+ let sourceToDoc :: [FilePath] -> PandocIO (Pandoc, MediaBag)
+ sourceToDoc sources' =
+ case reader of
+ StringReader r
+ | optFileScope opts || readerName == "json" -> do
+ pairs <- mapM
+ (readSource >=> withMediaBag . r readerOpts) sources
+ return (mconcat (map fst pairs), mconcat (map snd pairs))
+ | otherwise ->
+ readSources sources' >>= withMediaBag . r readerOpts
+ ByteStringReader r -> do
+ pairs <- mapM (readFile' >=>
+ withMediaBag . r readerOpts) sources
+ return (mconcat (map fst pairs), mconcat (map snd pairs))
+
+ runIO' $ do
+ (doc, media) <- sourceToDoc sources
+ doc' <- (maybe return (extractMedia media) (optExtractMedia opts) >=>
+ return . flip (foldr addMetadata) (optMetadata opts) >=>
+ applyTransforms transforms >=>
+ applyFilters datadir filters' [format]) doc
+
+ case writer of
+ -- StringWriter f -> f writerOptions doc' >>= writerFn outputFile
+ ByteStringWriter f -> f writerOptions doc' >>= writeFnBinary outputFile
+ StringWriter f
+ | pdfOutput -> do
+ -- make sure writer is latex or beamer or context or html5
+ unless (laTeXOutput || conTeXtOutput || html5Output) $
+ err 47 $ "cannot produce pdf output with " ++ format ++
+ " writer"
+
+ let pdfprog = case () of
+ _ | conTeXtOutput -> "context"
+ _ | html5Output -> "wkhtmltopdf"
+ _ -> optLaTeXEngine opts
+ -- check for pdf creating program
+ mbPdfProg <- liftIO $ findExecutable pdfprog
+ when (isNothing mbPdfProg) $
+ err 41 $ pdfprog ++ " not found. " ++
+ pdfprog ++ " is needed for pdf output."
+
+ res <- makePDF pdfprog f writerOptions verbosity media doc'
+ case res of
+ Right pdf -> writeFnBinary outputFile pdf
+ Left err' -> liftIO $ do
+ B.hPutStr stderr err'
+ B.hPut stderr $ B.pack [10]
+ err 43 "Error producing PDF"
+ | otherwise -> do
+ let htmlFormat = format `elem`
+ ["html","html4","html5","s5","slidy","slideous","dzslides","revealjs"]
+ selfcontain = if optSelfContained opts && htmlFormat
+ then makeSelfContained writerOptions media
+ else return
+ handleEntities = if htmlFormat && optAscii opts
+ then toEntities
+ else id
+ output <- f writerOptions doc'
+ selfcontain (output ++ ['\n' | not standalone]) >>=
+ writerFn outputFile . handleEntities
+
+type Transform = Pandoc -> Pandoc
+
+isTextFormat :: String -> Bool
+isTextFormat s = s `notElem` ["odt","docx","epub","epub3"]
+
+externalFilter :: MonadIO m => FilePath -> [String] -> Pandoc -> m Pandoc
+externalFilter f args' d = liftIO $ do
+ exists <- doesFileExist f
+ isExecutable <- if exists
+ then executable <$> getPermissions f
+ else return True
+ let (f', args'') = if exists
+ then case map toLower (takeExtension f) of
+ _ | isExecutable -> ("." </> f, args')
+ ".py" -> ("python", f:args')
+ ".hs" -> ("runhaskell", f:args')
+ ".pl" -> ("perl", f:args')
+ ".rb" -> ("ruby", f:args')
+ ".php" -> ("php", f:args')
+ ".js" -> ("node", f:args')
+ _ -> (f, args')
+ else (f, args')
+ unless (exists && isExecutable) $ do
+ mbExe <- findExecutable f'
+ when (isNothing mbExe) $
+ err 83 $ "Error running filter " ++ f ++ ":\n" ++
+ "Could not find executable '" ++ f' ++ "'."
+ env <- getEnvironment
+ let env' = Just $ ("PANDOC_VERSION", pandocVersion) : env
+ (exitcode, outbs) <- E.handle filterException $
+ pipeProcess env' f' args'' $ encode d
+ case exitcode of
+ ExitSuccess -> return $ either error id $ eitherDecode' outbs
+ ExitFailure ec -> err 83 $ "Error running filter " ++ f ++ "\n" ++
+ "Filter returned error status " ++ show ec
+ where filterException :: E.SomeException -> IO a
+ filterException e = err 83 $ "Error running filter " ++ f ++ "\n" ++
+ show e
+
+-- | 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
+ , optOutputFile :: 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
+ , optTopLevelDivision :: TopLevelDivision -- ^ Type of the top-level divisions
+ , optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
+ , optReferenceDoc :: Maybe FilePath -- ^ Path of reference doc
+ , optEpubStylesheet :: Maybe FilePath -- ^ EPUB stylesheet
+ , 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
+ , 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 :: [FilePath] -- ^ Filters to apply
+ , optEmailObfuscation :: ObfuscationMethod
+ , optIdentifierPrefix :: String
+ , 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
+ , optLaTeXEngine :: String -- ^ Program to use for latex -> pdf
+ , optLaTeXEngineArgs :: [String] -- ^ Flags to pass to the latex-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
+ , optKaTeXStylesheet :: Maybe String -- ^ Path to stylesheet for KaTeX
+ , optKaTeXJS :: Maybe String -- ^ Path to js file for KaTeX
+ , 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
+ }
+
+-- | 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 = []
+ , optOutputFile = "-" -- "-" means stdout
+ , optInputFiles = []
+ , optNumberSections = False
+ , optNumberOffset = [0,0,0,0,0,0]
+ , optSectionDivs = False
+ , optIncremental = False
+ , optSelfContained = False
+ , optHtmlQTags = False
+ , optHighlightStyle = Just "pygments"
+ , optTopLevelDivision = TopLevelDefault
+ , optHTMLMathMethod = PlainMath
+ , optReferenceDoc = Nothing
+ , optEpubStylesheet = Nothing
+ , optEpubMetadata = Nothing
+ , optEpubFonts = []
+ , optEpubChapterLevel = 1
+ , optEpubCoverImage = Nothing
+ , optTOCDepth = 3
+ , optDumpArgs = False
+ , optIgnoreArgs = False
+ , optVerbosity = WARNING
+ , optLogFile = Nothing
+ , optFailIfWarnings = False
+ , optReferenceLinks = False
+ , optReferenceLocation = EndOfDocument
+ , optDpi = 96
+ , optWrapText = WrapAuto
+ , optColumns = 72
+ , optFilters = []
+ , optEmailObfuscation = NoObfuscation
+ , optIdentifierPrefix = ""
+ , optIndentedCodeClasses = []
+ , optDataDir = Nothing
+ , optCiteMethod = Citeproc
+ , optListings = False
+ , optLaTeXEngine = "pdflatex"
+ , optLaTeXEngineArgs = []
+ , optSlideLevel = Nothing
+ , optSetextHeaders = True
+ , optAscii = False
+ , optDefaultImageExtension = ""
+ , optExtractMedia = Nothing
+ , optTrackChanges = AcceptChanges
+ , optFileScope = False
+ , optKaTeXStylesheet = Nothing
+ , optKaTeXJS = Nothing
+ , optTitlePrefix = Nothing
+ , optCss = []
+ , optIncludeBeforeBody = []
+ , optIncludeAfterBody = []
+ , optIncludeInHeader = []
+ }
+
+addMetadata :: (String, String) -> Pandoc -> Pandoc
+addMetadata (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
+
+readMetaValue :: String -> MetaValue
+readMetaValue s = case decode (UTF8.fromString s) of
+ Just (Yaml.String t) -> MetaString $ T.unpack t
+ Just (Yaml.Bool 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"
+ ".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
+ _ -> 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"
+ ".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"
+ ".pdf" -> "latex"
+ ".fb2" -> "fb2"
+ ".opml" -> "opml"
+ ".icml" -> "icml"
+ ".tei.xml" -> "tei"
+ ".tei" -> "tei"
+ ['.',y] | y `elem` ['1'..'9'] -> "man"
+ _ -> "html"
+
+-- Transformations of a Pandoc document post-parsing:
+
+extractMedia :: MonadIO m => MediaBag -> FilePath -> Pandoc -> m Pandoc
+extractMedia media dir d =
+ case [fp | (fp, _, _) <- mediaDirectory media] of
+ [] -> return d
+ fps -> do
+ extractMediaBag True dir media
+ return $ walk (adjustImagePath dir fps) d
+
+adjustImagePath :: FilePath -> [FilePath] -> Inline -> Inline
+adjustImagePath dir paths (Image attr lab (src, tit))
+ | src `elem` paths = Image attr lab (dir ++ "/" ++ src, tit)
+adjustImagePath _ _ x = x
+
+applyTransforms :: Monad m => [Transform] -> Pandoc -> m Pandoc
+applyTransforms transforms d = return $ foldr ($) d transforms
+
+ -- First we check to see if a filter is found. If not, and if it's
+ -- not an absolute path, we check to see whether it's in `userdir/filters`.
+ -- If not, we leave it unchanged.
+expandFilterPath :: MonadIO m => Maybe FilePath -> FilePath -> m FilePath
+expandFilterPath mbDatadir fp = liftIO $ do
+ fpExists <- doesFileExist fp
+ if fpExists
+ then return fp
+ else case mbDatadir of
+ Just datadir | isRelative fp -> do
+ let filterPath = (datadir </> "filters" </> fp)
+ filterPathExists <- doesFileExist filterPath
+ if filterPathExists
+ then return filterPath
+ else return fp
+ _ -> return fp
+
+applyFilters :: MonadIO m
+ => Maybe FilePath -> [FilePath] -> [String] -> Pandoc -> m Pandoc
+applyFilters mbDatadir filters args d = do
+ expandedFilters <- mapM (expandFilterPath mbDatadir) filters
+ foldrM ($) d $ map (flip externalFilter args) expandedFilters
+
+readSource :: MonadIO m => FilePath -> m String
+readSource "-" = liftIO UTF8.getContents
+readSource src = case parseURI src of
+ Just u | uriScheme u `elem` ["http:","https:"] ->
+ readURI src
+ | uriScheme u == "file:" ->
+ liftIO $ UTF8.readFile (uriPath u)
+ _ -> liftIO $ UTF8.readFile src
+
+readURI :: MonadIO m => FilePath -> m String
+readURI src = do
+ res <- liftIO $ openURL src
+ case res of
+ Left e -> liftIO $ throwIO e
+ Right (bs,_) -> return $ UTF8.toString bs
+
+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 => FilePath -> String -> m ()
+writerFn "-" = liftIO . UTF8.putStr
+writerFn f = liftIO . UTF8.writeFile f
+
+lookupHighlightStyle :: Maybe String -> IO (Maybe Style)
+lookupHighlightStyle Nothing = return Nothing
+lookupHighlightStyle (Just s) =
+ case lookup (map toLower s) highlightingStyles of
+ Just sty -> return (Just sty)
+ Nothing -> err 68 $ "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 arg })
+ "FORMAT")
+ ""
+
+ , Option "tw" ["to","write"]
+ (ReqArg
+ (\arg opt -> return opt { optWriter = Just arg })
+ "FORMAT")
+ ""
+
+ , Option "o" ["output"]
+ (ReqArg
+ (\arg opt -> return opt { optOutputFile = arg })
+ "FILENAME")
+ "" -- "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 -> do
+ return opt{ optBaseHeaderLevel = t }
+ _ -> err 19
+ "base-header-level must be 1-5")
+ "NUMBER")
+ "" -- "Headers base level"
+
+ , 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 = arg : optFilters opt })
+ "PROGRAM")
+ "" -- "External JSON 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 }
+ _ -> err 31
+ "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
+ _ -> err 6
+ ("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 })
+ "FILENAME")
+ "" -- "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 "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 <- getDefaultTemplate Nothing arg
+ case templ of
+ Right t -> UTF8.hPutStr stdout t
+ Left e -> error $ show e
+ exitSuccess)
+ "FORMAT")
+ "" -- "Print default template for FORMAT"
+
+ , Option "" ["print-default-data-file"]
+ (ReqArg
+ (\arg _ -> do
+ readDataFile Nothing arg >>= BS.hPutStr stdout
+ exitSuccess)
+ "FILE")
+ "" -- "Print default data file"
+
+ , Option "" ["dpi"]
+ (ReqArg
+ (\arg opt ->
+ case safeRead arg of
+ Just t | t > 0 -> return opt { optDpi = t }
+ _ -> err 31
+ "dpi must be a number greater than 0")
+ "NUMBER")
+ "" -- "Dpi (default 96)"
+
+ , Option "" ["wrap"]
+ (ReqArg
+ (\arg opt ->
+ case safeRead ("Wrap" ++ uppercaseFirstLetter arg) of
+ Just o -> return opt { optWrapText = o }
+ Nothing -> err 77 "--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 }
+ _ -> err 33
+ "columns must be a number greater than 0")
+ "NUMBER")
+ "" -- "Length of line in characters"
+
+ , 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 }
+ _ -> err 57
+ "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")
+ "" -- "Style for highlighted code"
+
+ , Option "H" ["include-in-header"]
+ (ReqArg
+ (\arg opt -> return opt{ optIncludeInHeader =
+ arg : optIncludeInHeader opt,
+ optStandalone = True })
+ "FILENAME")
+ "" -- "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 })
+ "FILENAME")
+ "" -- "File to include before document body"
+
+ , Option "A" ["include-after-body"]
+ (ReqArg
+ (\arg opt -> return opt{ optIncludeAfterBody =
+ arg : optIncludeAfterBody opt,
+ optStandalone = True })
+ "FILENAME")
+ "" -- "File to include after document body"
+
+ , 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
+ _ -> err 6
+ ("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 }
+ _ -> err 76 ("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 }
+ _ -> err 57 "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 }
+ _ -> err 39
+ "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
+ _ -> err 6
+ ("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 })
+ "FILENAME")
+ "" -- "Path of custom reference doc"
+
+ , Option "" ["epub-stylesheet"]
+ (ReqArg
+ (\arg opt -> return opt { optEpubStylesheet = Just arg })
+ "FILENAME")
+ "" -- "Path of epub.css"
+
+ , Option "" ["epub-cover-image"]
+ (ReqArg
+ (\arg opt ->
+ return opt { optVariables =
+ ("epub-cover-image", arg) : optVariables opt })
+ "FILENAME")
+ "" -- "Path of epub cover image"
+
+ , Option "" ["epub-metadata"]
+ (ReqArg
+ (\arg opt -> return opt { optEpubMetadata = Just arg })
+ "FILENAME")
+ "" -- "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 }
+ _ -> err 59
+ "chapter level must be a number between 1 and 6")
+ "NUMBER")
+ "" -- "Header level at which to split chapters in EPUB"
+
+ , Option "" ["latex-engine"]
+ (ReqArg
+ (\arg opt -> do
+ let b = takeBaseName arg
+ if b `elem` ["pdflatex", "lualatex", "xelatex"]
+ then return opt { optLaTeXEngine = arg }
+ else err 45 "latex-engine must be pdflatex, lualatex, or xelatex.")
+ "PROGRAM")
+ "" -- "Name of latex program to use in generating PDF"
+
+ , Option "" ["latex-engine-opt"]
+ (ReqArg
+ (\arg opt -> do
+ let oldArgs = optLaTeXEngineArgs opt
+ return opt { optLaTeXEngineArgs = arg : oldArgs })
+ "STRING")
+ "" -- "Flags to pass to the LaTeX 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 "m" ["latexmathml", "asciimathml"]
+ (OptArg
+ (\arg opt ->
+ return opt { optHTMLMathMethod = LaTeXMathML arg })
+ "URL")
+ "" -- "Use LaTeXMathML script in html output"
+
+ , Option "" ["mathml"]
+ (NoArg
+ (\opt ->
+ return opt { optHTMLMathMethod = MathML }))
+ "" -- "Use mathml for HTML math"
+
+ , Option "" ["mimetex"]
+ (OptArg
+ (\arg opt -> do
+ let url' = case arg of
+ Just u -> u ++ "?"
+ Nothing -> "/cgi-bin/mimetex.cgi?"
+ return opt { optHTMLMathMethod = WebTeX url' })
+ "URL")
+ "" -- "Use mimetex 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 "" ["jsmath"]
+ (OptArg
+ (\arg opt -> return opt { optHTMLMathMethod = JsMath arg})
+ "URL")
+ "" -- "Use jsMath for HTML math"
+
+ , Option "" ["mathjax"]
+ (OptArg
+ (\arg opt -> do
+ let url' = fromMaybe "https://cdn.mathjax.org/mathjax/latest/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
+ { optKaTeXJS =
+ arg <|> Just "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.js"})
+ "URL")
+ "" -- Use KaTeX for HTML Math
+
+ , Option "" ["katex-stylesheet"]
+ (ReqArg
+ (\arg opt ->
+ return opt { optKaTeXStylesheet = Just arg })
+ "URL")
+ "" -- Set the KaTeX Stylesheet location
+
+ , Option "" ["gladtex"]
+ (NoArg
+ (\opt -> return opt { optHTMLMathMethod = GladTeX }))
+ "" -- "Use gladtex for HTML math"
+
+ , Option "" ["trace"]
+ (NoArg
+ (\opt -> return opt { optVerbosity = DEBUG }))
+ "" -- "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
+ ddir <- getDataDir
+ tpl <- readDataFileUTF8 Nothing "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 readers'names)
+ (unwords writers'names)
+ (unwords $ map fst highlightingStyles)
+ ddir
+ exitSuccess ))
+ "" -- "Print bash completion script"
+
+ , Option "" ["list-input-formats"]
+ (NoArg
+ (\_ -> do
+ mapM_ (UTF8.hPutStrLn stdout) readers'names
+ exitSuccess ))
+ ""
+
+ , Option "" ["list-output-formats"]
+ (NoArg
+ (\_ -> do
+ mapM_ (UTF8.hPutStrLn stdout) writers'names
+ exitSuccess ))
+ ""
+
+ , Option "" ["list-extensions"]
+ (NoArg
+ (\_ -> do
+ let showExt x = drop 4 (show x) ++
+ if extensionEnabled x pandocExtensions
+ then " +"
+ else " -"
+ mapM_ (UTF8.hPutStrLn stdout . showExt)
+ ([minBound..maxBound] :: [Extension])
+ exitSuccess ))
+ ""
+
+ , 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) $
+ map 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"
+
+ ]
+
+-- Returns usage message
+usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
+usageMessage programName = usageInfo (programName ++ " [OPTIONS] [FILES]")
+
+copyrightMessage :: String
+copyrightMessage = intercalate "\n" [
+ "",
+ "Copyright (C) 2006-2017 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 "-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 "--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 "-R" = handleUnrecognizedOption "--parse-raw"
+handleUnrecognizedOption x =
+ (("Unknown option " ++ x ++ ".") :)
+
+uppercaseFirstLetter :: String -> String
+uppercaseFirstLetter (c:cs) = toUpper c : cs
+uppercaseFirstLetter [] = []
+
+readers'names :: [String]
+readers'names = sort (map fst (readers :: [(String, Reader PandocIO)]))
+
+writers'names :: [String]
+writers'names = 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")
+
diff --git a/src/Text/Pandoc/Asciify.hs b/src/Text/Pandoc/Asciify.hs
new file mode 100644
index 000000000..8eb1ba663
--- /dev/null
+++ b/src/Text/Pandoc/Asciify.hs
@@ -0,0 +1,422 @@
+{-
+Copyright (C) 2013-2016 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.Asciify
+ Copyright : Copyright (C) 2013-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Function to convert accented latin letters to their unaccented
+ascii equivalents (used in constructing HTML identifiers).
+-}
+module Text.Pandoc.Asciify (toAsciiChar)
+where
+import qualified Data.Map as M
+import Data.Char (isAscii)
+
+toAsciiChar :: Char -> Maybe Char
+toAsciiChar c | isAscii c = Just c
+ | otherwise = M.lookup c asciiMap
+
+asciiMap :: M.Map Char Char
+asciiMap = M.fromList
+ [('\192','A')
+ ,('\193','A')
+ ,('\194','A')
+ ,('\195','A')
+ ,('\196','A')
+ ,('\197','A')
+ ,('\199','C')
+ ,('\200','E')
+ ,('\201','E')
+ ,('\202','E')
+ ,('\203','E')
+ ,('\204','I')
+ ,('\205','I')
+ ,('\206','I')
+ ,('\207','I')
+ ,('\209','N')
+ ,('\210','O')
+ ,('\211','O')
+ ,('\212','O')
+ ,('\213','O')
+ ,('\214','O')
+ ,('\217','U')
+ ,('\218','U')
+ ,('\219','U')
+ ,('\220','U')
+ ,('\221','Y')
+ ,('\224','a')
+ ,('\225','a')
+ ,('\226','a')
+ ,('\227','a')
+ ,('\228','a')
+ ,('\229','a')
+ ,('\231','c')
+ ,('\232','e')
+ ,('\233','e')
+ ,('\234','e')
+ ,('\235','e')
+ ,('\236','i')
+ ,('\237','i')
+ ,('\238','i')
+ ,('\239','i')
+ ,('\241','n')
+ ,('\242','o')
+ ,('\243','o')
+ ,('\244','o')
+ ,('\245','o')
+ ,('\246','o')
+ ,('\249','u')
+ ,('\250','u')
+ ,('\251','u')
+ ,('\252','u')
+ ,('\253','y')
+ ,('\255','y')
+ ,('\256','A')
+ ,('\257','a')
+ ,('\258','A')
+ ,('\259','a')
+ ,('\260','A')
+ ,('\261','a')
+ ,('\262','C')
+ ,('\263','c')
+ ,('\264','C')
+ ,('\265','c')
+ ,('\266','C')
+ ,('\267','c')
+ ,('\268','C')
+ ,('\269','c')
+ ,('\270','D')
+ ,('\271','d')
+ ,('\274','E')
+ ,('\275','e')
+ ,('\276','E')
+ ,('\277','e')
+ ,('\278','E')
+ ,('\279','e')
+ ,('\280','E')
+ ,('\281','e')
+ ,('\282','E')
+ ,('\283','e')
+ ,('\284','G')
+ ,('\285','g')
+ ,('\286','G')
+ ,('\287','g')
+ ,('\288','G')
+ ,('\289','g')
+ ,('\290','G')
+ ,('\291','g')
+ ,('\292','H')
+ ,('\293','h')
+ ,('\296','I')
+ ,('\297','i')
+ ,('\298','I')
+ ,('\299','i')
+ ,('\300','I')
+ ,('\301','i')
+ ,('\302','I')
+ ,('\303','i')
+ ,('\304','I')
+ ,('\308','J')
+ ,('\309','j')
+ ,('\310','K')
+ ,('\311','k')
+ ,('\313','L')
+ ,('\314','l')
+ ,('\315','L')
+ ,('\316','l')
+ ,('\317','L')
+ ,('\318','l')
+ ,('\323','N')
+ ,('\324','n')
+ ,('\325','N')
+ ,('\326','n')
+ ,('\327','N')
+ ,('\328','n')
+ ,('\332','O')
+ ,('\333','o')
+ ,('\334','O')
+ ,('\335','o')
+ ,('\336','O')
+ ,('\337','o')
+ ,('\340','R')
+ ,('\341','r')
+ ,('\342','R')
+ ,('\343','r')
+ ,('\344','R')
+ ,('\345','r')
+ ,('\346','S')
+ ,('\347','s')
+ ,('\348','S')
+ ,('\349','s')
+ ,('\350','S')
+ ,('\351','s')
+ ,('\352','S')
+ ,('\353','s')
+ ,('\354','T')
+ ,('\355','t')
+ ,('\356','T')
+ ,('\357','t')
+ ,('\360','U')
+ ,('\361','u')
+ ,('\362','U')
+ ,('\363','u')
+ ,('\364','U')
+ ,('\365','u')
+ ,('\366','U')
+ ,('\367','u')
+ ,('\368','U')
+ ,('\369','u')
+ ,('\370','U')
+ ,('\371','u')
+ ,('\372','W')
+ ,('\373','w')
+ ,('\374','Y')
+ ,('\375','y')
+ ,('\376','Y')
+ ,('\377','Z')
+ ,('\378','z')
+ ,('\379','Z')
+ ,('\380','z')
+ ,('\381','Z')
+ ,('\382','z')
+ ,('\416','O')
+ ,('\417','o')
+ ,('\431','U')
+ ,('\432','u')
+ ,('\461','A')
+ ,('\462','a')
+ ,('\463','I')
+ ,('\464','i')
+ ,('\465','O')
+ ,('\466','o')
+ ,('\467','U')
+ ,('\468','u')
+ ,('\486','G')
+ ,('\487','g')
+ ,('\488','K')
+ ,('\489','k')
+ ,('\490','O')
+ ,('\491','o')
+ ,('\496','j')
+ ,('\500','G')
+ ,('\501','g')
+ ,('\504','N')
+ ,('\505','n')
+ ,('\512','A')
+ ,('\513','a')
+ ,('\514','A')
+ ,('\515','a')
+ ,('\516','E')
+ ,('\517','e')
+ ,('\518','E')
+ ,('\519','e')
+ ,('\520','I')
+ ,('\521','i')
+ ,('\522','I')
+ ,('\523','i')
+ ,('\524','O')
+ ,('\525','o')
+ ,('\526','O')
+ ,('\527','o')
+ ,('\528','R')
+ ,('\529','r')
+ ,('\530','R')
+ ,('\531','r')
+ ,('\532','U')
+ ,('\533','u')
+ ,('\534','U')
+ ,('\535','u')
+ ,('\536','S')
+ ,('\537','s')
+ ,('\538','T')
+ ,('\539','t')
+ ,('\542','H')
+ ,('\543','h')
+ ,('\550','A')
+ ,('\551','a')
+ ,('\552','E')
+ ,('\553','e')
+ ,('\558','O')
+ ,('\559','o')
+ ,('\562','Y')
+ ,('\563','y')
+ ,('\894',';')
+ ,('\7680','A')
+ ,('\7681','a')
+ ,('\7682','B')
+ ,('\7683','b')
+ ,('\7684','B')
+ ,('\7685','b')
+ ,('\7686','B')
+ ,('\7687','b')
+ ,('\7690','D')
+ ,('\7691','d')
+ ,('\7692','D')
+ ,('\7693','d')
+ ,('\7694','D')
+ ,('\7695','d')
+ ,('\7696','D')
+ ,('\7697','d')
+ ,('\7698','D')
+ ,('\7699','d')
+ ,('\7704','E')
+ ,('\7705','e')
+ ,('\7706','E')
+ ,('\7707','e')
+ ,('\7710','F')
+ ,('\7711','f')
+ ,('\7712','G')
+ ,('\7713','g')
+ ,('\7714','H')
+ ,('\7715','h')
+ ,('\7716','H')
+ ,('\7717','h')
+ ,('\7718','H')
+ ,('\7719','h')
+ ,('\7720','H')
+ ,('\7721','h')
+ ,('\7722','H')
+ ,('\7723','h')
+ ,('\7724','I')
+ ,('\7725','i')
+ ,('\7728','K')
+ ,('\7729','k')
+ ,('\7730','K')
+ ,('\7731','k')
+ ,('\7732','K')
+ ,('\7733','k')
+ ,('\7734','L')
+ ,('\7735','l')
+ ,('\7738','L')
+ ,('\7739','l')
+ ,('\7740','L')
+ ,('\7741','l')
+ ,('\7742','M')
+ ,('\7743','m')
+ ,('\7744','M')
+ ,('\7745','m')
+ ,('\7746','M')
+ ,('\7747','m')
+ ,('\7748','N')
+ ,('\7749','n')
+ ,('\7750','N')
+ ,('\7751','n')
+ ,('\7752','N')
+ ,('\7753','n')
+ ,('\7754','N')
+ ,('\7755','n')
+ ,('\7764','P')
+ ,('\7765','p')
+ ,('\7766','P')
+ ,('\7767','p')
+ ,('\7768','R')
+ ,('\7769','r')
+ ,('\7770','R')
+ ,('\7771','r')
+ ,('\7774','R')
+ ,('\7775','r')
+ ,('\7776','S')
+ ,('\7777','s')
+ ,('\7778','S')
+ ,('\7779','s')
+ ,('\7786','T')
+ ,('\7787','t')
+ ,('\7788','T')
+ ,('\7789','t')
+ ,('\7790','T')
+ ,('\7791','t')
+ ,('\7792','T')
+ ,('\7793','t')
+ ,('\7794','U')
+ ,('\7795','u')
+ ,('\7796','U')
+ ,('\7797','u')
+ ,('\7798','U')
+ ,('\7799','u')
+ ,('\7804','V')
+ ,('\7805','v')
+ ,('\7806','V')
+ ,('\7807','v')
+ ,('\7808','W')
+ ,('\7809','w')
+ ,('\7810','W')
+ ,('\7811','w')
+ ,('\7812','W')
+ ,('\7813','w')
+ ,('\7814','W')
+ ,('\7815','w')
+ ,('\7816','W')
+ ,('\7817','w')
+ ,('\7818','X')
+ ,('\7819','x')
+ ,('\7820','X')
+ ,('\7821','x')
+ ,('\7822','Y')
+ ,('\7823','y')
+ ,('\7824','Z')
+ ,('\7825','z')
+ ,('\7826','Z')
+ ,('\7827','z')
+ ,('\7828','Z')
+ ,('\7829','z')
+ ,('\7830','h')
+ ,('\7831','t')
+ ,('\7832','w')
+ ,('\7833','y')
+ ,('\7840','A')
+ ,('\7841','a')
+ ,('\7842','A')
+ ,('\7843','a')
+ ,('\7864','E')
+ ,('\7865','e')
+ ,('\7866','E')
+ ,('\7867','e')
+ ,('\7868','E')
+ ,('\7869','e')
+ ,('\7880','I')
+ ,('\7881','i')
+ ,('\7882','I')
+ ,('\7883','i')
+ ,('\7884','O')
+ ,('\7885','o')
+ ,('\7886','O')
+ ,('\7887','o')
+ ,('\7908','U')
+ ,('\7909','u')
+ ,('\7910','U')
+ ,('\7911','u')
+ ,('\7922','Y')
+ ,('\7923','y')
+ ,('\7924','Y')
+ ,('\7925','y')
+ ,('\7926','Y')
+ ,('\7927','y')
+ ,('\7928','Y')
+ ,('\7929','y')
+ ,('\8175','`')
+ ,('\8490','K')
+ ,('\8800','=')
+ ,('\8814','<')
+ ,('\8815','>')
+ ]
diff --git a/src/Text/Pandoc/CSS.hs b/src/Text/Pandoc/CSS.hs
new file mode 100644
index 000000000..f479ed9d0
--- /dev/null
+++ b/src/Text/Pandoc/CSS.hs
@@ -0,0 +1,43 @@
+module Text.Pandoc.CSS ( foldOrElse
+ , pickStyleAttrProps
+ , pickStylesToKVs
+ )
+where
+
+import Text.Pandoc.Shared (trim)
+import Text.Parsec
+import Text.Parsec.String
+
+ruleParser :: Parser (String, String)
+ruleParser = do
+ p <- many1 (noneOf ":") <* char ':'
+ v <- many1 (noneOf ":;") <* (optional $ char ';') <* spaces
+ return (trim p, trim v)
+
+styleAttrParser :: Parser [(String, String)]
+styleAttrParser = many1 ruleParser
+
+orElse :: Eq a => a -> a -> a -> a
+orElse v x y = if v == x then y else x
+
+foldOrElse :: Eq a => a -> [a] -> a
+foldOrElse v xs = foldr (orElse v) v xs
+
+eitherToMaybe :: Either a b -> Maybe b
+eitherToMaybe (Right x) = Just x
+eitherToMaybe _ = Nothing
+
+-- | takes a list of keys/properties and a CSS string and
+-- returns the corresponding key-value-pairs.
+pickStylesToKVs :: [String] -> String -> [(String, String)]
+pickStylesToKVs props styleAttr =
+ case parse styleAttrParser "" styleAttr of
+ Left _ -> []
+ Right styles -> filter (\s -> fst s `elem` props) styles
+
+-- | takes a list of key/property synonyms and a CSS string and maybe
+-- returns the value of the first match (in order of the supplied list)
+pickStyleAttrProps :: [String] -> String -> Maybe String
+pickStyleAttrProps lookupProps styleAttr = do
+ styles <- eitherToMaybe $ parse styleAttrParser "" styleAttr
+ foldOrElse Nothing $ map (flip lookup styles) lookupProps
diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs
new file mode 100644
index 000000000..fb148666c
--- /dev/null
+++ b/src/Text/Pandoc/Class.hs
@@ -0,0 +1,539 @@
+{-# LANGUAGE DeriveFunctor, DeriveDataTypeable, TypeSynonymInstances,
+FlexibleInstances, GeneralizedNewtypeDeriving, FlexibleContexts #-}
+
+{-
+Copyright (C) 2016 Jesse Rosenthal <jrosenthal@jhu.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.Class
+ Copyright : Copyright (C) 2016 Jesse Rosenthal
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>
+ Stability : alpha
+ Portability : portable
+
+Typeclass for pandoc readers and writers, allowing both IO and pure instances.
+-}
+
+module Text.Pandoc.Class ( PandocMonad(..)
+ , CommonState(..)
+ , PureState(..)
+ , getPureState
+ , getsPureState
+ , putPureState
+ , modifyPureState
+ , getPOSIXTime
+ , getZonedTime
+ , readFileFromDirs
+ , report
+ , getLog
+ , setVerbosity
+ , getMediaBag
+ , setMediaBag
+ , insertMedia
+ , fetchItem
+ , getInputFiles
+ , getOutputFile
+ , PandocIO(..)
+ , PandocPure(..)
+ , FileTree(..)
+ , FileInfo(..)
+ , runIO
+ , runIOorExplode
+ , runPure
+ , withMediaBag
+ ) where
+
+import Prelude hiding (readFile)
+import System.Random (StdGen, next, mkStdGen)
+import qualified System.Random as IO (newStdGen)
+import Codec.Archive.Zip (Archive, fromArchive, emptyArchive)
+import Data.Unique (hashUnique)
+import qualified Data.Unique as IO (newUnique)
+import qualified Text.Pandoc.Shared as IO ( readDataFile
+ , openURL )
+import qualified Text.Pandoc.UTF8 as UTF8
+import Text.Pandoc.Compat.Time (UTCTime)
+import Text.Pandoc.Logging
+import Text.Parsec (ParsecT)
+import qualified Text.Pandoc.Compat.Time as IO (getCurrentTime)
+import Text.Pandoc.MIME (MimeType, getMimeType)
+import Data.Time.Clock.POSIX ( utcTimeToPOSIXSeconds
+ , posixSecondsToUTCTime
+ , POSIXTime )
+import Data.Time.LocalTime (TimeZone, ZonedTime, utcToZonedTime, utc)
+import Network.URI ( escapeURIString, nonStrictRelativeTo,
+ unEscapeString, parseURIReference, isAllowedInURI,
+ parseURI, URI(..) )
+import qualified Data.Time.LocalTime as IO (getCurrentTimeZone)
+import Text.Pandoc.MediaBag (MediaBag, lookupMedia)
+import qualified Text.Pandoc.MediaBag as MB
+import qualified Data.ByteString as B
+import qualified Data.ByteString.Lazy as BL
+import qualified System.Environment as IO (lookupEnv)
+import System.FilePath.Glob (match, compile)
+import System.FilePath ((</>), takeExtension, dropExtension)
+import qualified System.FilePath.Glob as IO (glob)
+import qualified System.Directory as IO (getModificationTime)
+import Control.Monad as M (fail)
+import Control.Monad.Reader (ReaderT)
+import Control.Monad.State
+import Control.Monad.Except
+import Control.Monad.Writer (WriterT)
+import Control.Monad.RWS (RWST)
+import Data.Word (Word8)
+import Data.Default
+import System.IO.Error
+import System.IO (stderr)
+import qualified Data.Map as M
+import Text.Pandoc.Error
+import Text.Printf (printf)
+
+class (Functor m, Applicative m, Monad m, MonadError PandocError m)
+ => PandocMonad m where
+ lookupEnv :: String -> m (Maybe String)
+ getCurrentTime :: m UTCTime
+ getCurrentTimeZone :: m TimeZone
+ newStdGen :: m StdGen
+ newUniqueHash :: m Int
+ openURL :: String -> m (B.ByteString, Maybe MimeType)
+ readFileLazy :: FilePath -> m BL.ByteString
+ readFileStrict :: FilePath -> m B.ByteString
+ readDataFile :: Maybe FilePath
+ -> FilePath
+ -> m B.ByteString
+ glob :: String -> m [FilePath]
+ getModificationTime :: FilePath -> m UTCTime
+ getCommonState :: m CommonState
+ putCommonState :: CommonState -> m ()
+
+ getsCommonState :: (CommonState -> a) -> m a
+ getsCommonState f = f <$> getCommonState
+
+ modifyCommonState :: (CommonState -> CommonState) -> m ()
+ modifyCommonState f = getCommonState >>= putCommonState . f
+
+ logOutput :: LogMessage -> m ()
+
+-- Functions defined for all PandocMonad instances
+
+setVerbosity :: PandocMonad m => Verbosity -> m ()
+setVerbosity verbosity =
+ modifyCommonState $ \st -> st{ stVerbosity = verbosity }
+
+getLog :: PandocMonad m => m [LogMessage]
+getLog = reverse <$> getsCommonState stLog
+
+report :: PandocMonad m => LogMessage -> m ()
+report msg = do
+ verbosity <- getsCommonState stVerbosity
+ let level = messageVerbosity msg
+ when (level <= verbosity) $ do
+ logOutput msg
+ unless (level == DEBUG) $
+ modifyCommonState $ \st -> st{ stLog = msg : stLog st }
+
+setMediaBag :: PandocMonad m => MediaBag -> m ()
+setMediaBag mb = modifyCommonState $ \st -> st{stMediaBag = mb}
+
+getMediaBag :: PandocMonad m => m MediaBag
+getMediaBag = getsCommonState stMediaBag
+
+insertMedia :: PandocMonad m => FilePath -> Maybe MimeType -> BL.ByteString -> m ()
+insertMedia fp mime bs = do
+ mb <- getsCommonState stMediaBag
+ let mb' = MB.insertMedia fp mime bs mb
+ modifyCommonState $ \st -> st{stMediaBag = mb' }
+
+getInputFiles :: PandocMonad m => m (Maybe [FilePath])
+getInputFiles = getsCommonState stInputFiles
+
+getOutputFile :: PandocMonad m => m (Maybe FilePath)
+getOutputFile = getsCommonState stOutputFile
+
+getPOSIXTime :: (PandocMonad m) => m POSIXTime
+getPOSIXTime = utcTimeToPOSIXSeconds <$> getCurrentTime
+
+getZonedTime :: (PandocMonad m) => m ZonedTime
+getZonedTime = do
+ t <- getCurrentTime
+ tz <- getCurrentTimeZone
+ return $ utcToZonedTime tz t
+
+-- | Read file, checking in any number of directories.
+readFileFromDirs :: PandocMonad m => [FilePath] -> FilePath -> m (Maybe String)
+readFileFromDirs [] _ = return Nothing
+readFileFromDirs (d:ds) f = catchError
+ ((Just . UTF8.toStringLazy) <$> readFileLazy (d </> f))
+ (\_ -> readFileFromDirs ds f)
+
+--
+
+data CommonState = CommonState { stLog :: [LogMessage]
+ , stMediaBag :: MediaBag
+ , stInputFiles :: Maybe [FilePath]
+ , stOutputFile :: Maybe FilePath
+ , stVerbosity :: Verbosity
+ }
+
+instance Default CommonState where
+ def = CommonState { stLog = []
+ , stMediaBag = mempty
+ , stInputFiles = Nothing
+ , stOutputFile = Nothing
+ , stVerbosity = WARNING
+ }
+
+runIO :: PandocIO a -> IO (Either PandocError a)
+runIO ma = flip evalStateT def $ runExceptT $ unPandocIO ma
+
+withMediaBag :: PandocMonad m => m a -> m (a, MediaBag)
+withMediaBag ma = ((,)) <$> ma <*> getMediaBag
+
+runIOorExplode :: PandocIO a -> IO a
+runIOorExplode ma = runIO ma >>= handleError
+
+newtype PandocIO a = PandocIO {
+ unPandocIO :: ExceptT PandocError (StateT CommonState IO) a
+ } deriving ( MonadIO
+ , Functor
+ , Applicative
+ , Monad
+ , MonadError PandocError
+ )
+
+instance PandocMonad PandocIO where
+ lookupEnv = liftIO . IO.lookupEnv
+ getCurrentTime = liftIO IO.getCurrentTime
+ getCurrentTimeZone = liftIO IO.getCurrentTimeZone
+ newStdGen = liftIO IO.newStdGen
+ newUniqueHash = hashUnique <$> (liftIO IO.newUnique)
+ openURL u = do
+ eitherRes <- liftIO $ (tryIOError $ IO.openURL u)
+ case eitherRes of
+ Right (Right res) -> return res
+ Right (Left _) -> throwError $ PandocFileReadError u
+ Left _ -> throwError $ PandocFileReadError u
+ readFileLazy s = do
+ eitherBS <- liftIO (tryIOError $ BL.readFile s)
+ case eitherBS of
+ Right bs -> return bs
+ Left _ -> throwError $ PandocFileReadError s
+ readFileStrict s = do
+ eitherBS <- liftIO (tryIOError $ B.readFile s)
+ case eitherBS of
+ Right bs -> return bs
+ Left _ -> throwError $ PandocFileReadError s
+ -- TODO: Make this more sensitive to the different sorts of failure
+ readDataFile mfp fname = do
+ eitherBS <- liftIO (tryIOError $ IO.readDataFile mfp fname)
+ case eitherBS of
+ Right bs -> return bs
+ Left _ -> throwError $ PandocFileReadError fname
+ glob = liftIO . IO.glob
+ getModificationTime fp = do
+ eitherMtime <- liftIO (tryIOError $ IO.getModificationTime fp)
+ case eitherMtime of
+ Right mtime -> return mtime
+ Left _ -> throwError $ PandocFileReadError fp
+ getCommonState = PandocIO $ lift get
+ putCommonState x = PandocIO $ lift $ put x
+ logOutput msg =
+ liftIO $ UTF8.hPutStrLn stderr $ printf "%-7s %s"
+ (show (messageVerbosity msg)) (showLogMessage msg)
+
+-- | Specialized version of parseURIReference that disallows
+-- single-letter schemes. Reason: these are usually windows absolute
+-- paths.
+parseURIReference' :: String -> Maybe URI
+parseURIReference' s =
+ case parseURIReference s of
+ Just u
+ | length (uriScheme u) > 2 -> Just u
+ | null (uriScheme u) -> Just u -- protocol-relative
+ _ -> Nothing
+
+-- | Fetch an image or other item from the local filesystem or the net.
+-- Returns raw content and maybe mime type.
+fetchItem :: PandocMonad m
+ => Maybe String
+ -> String
+ -> m (B.ByteString, Maybe MimeType)
+fetchItem sourceURL s = do
+ mediabag <- getMediaBag
+ case lookupMedia s mediabag of
+ Just (mime, bs) -> return $ (BL.toStrict bs, Just mime)
+ Nothing -> downloadOrRead sourceURL s
+
+downloadOrRead :: PandocMonad m
+ => Maybe String
+ -> String
+ -> m (B.ByteString, Maybe MimeType)
+downloadOrRead sourceURL s = do
+ case (sourceURL >>= parseURIReference' .
+ ensureEscaped, ensureEscaped s) of
+ (Just u, s') -> -- try fetching from relative path at source
+ case parseURIReference' s' of
+ Just u' -> openURL $ show $ u' `nonStrictRelativeTo` u
+ Nothing -> openURL s' -- will throw error
+ (Nothing, s'@('/':'/':_)) -> -- protocol-relative URI
+ case parseURIReference' s' of
+ Just u' -> openURL $ show $ u' `nonStrictRelativeTo` httpcolon
+ Nothing -> openURL s' -- will throw error
+ (Nothing, s') ->
+ case parseURI s' of -- requires absolute URI
+ -- We don't want to treat C:/ as a scheme:
+ Just u' | length (uriScheme u') > 2 -> openURL (show u')
+ Just u' | uriScheme u' == "file:" ->
+ readLocalFile $ dropWhile (=='/') (uriPath u')
+ _ -> readLocalFile fp -- get from local file system
+ where readLocalFile f = do
+ cont <- readFileStrict f
+ return (cont, mime)
+ httpcolon = URI{ uriScheme = "http:",
+ uriAuthority = Nothing,
+ uriPath = "",
+ uriQuery = "",
+ uriFragment = "" }
+ dropFragmentAndQuery = takeWhile (\c -> c /= '?' && c /= '#')
+ fp = unEscapeString $ dropFragmentAndQuery s
+ mime = case takeExtension fp of
+ ".gz" -> getMimeType $ dropExtension fp
+ ".svgz" -> getMimeType $ dropExtension fp ++ ".svg"
+ x -> getMimeType x
+ ensureEscaped = escapeURIString isAllowedInURI . map convertSlash
+ convertSlash '\\' = '/'
+ convertSlash x = x
+
+data PureState = PureState { stStdGen :: StdGen
+ , stWord8Store :: [Word8] -- should be
+ -- inifinite,
+ -- i.e. [1..]
+ , stUniqStore :: [Int] -- should be
+ -- inifinite and
+ -- contain every
+ -- element at most
+ -- once, e.g. [1..]
+ , stEnv :: [(String, String)]
+ , stTime :: UTCTime
+ , stTimeZone :: TimeZone
+ , stReferenceDocx :: Archive
+ , stReferenceODT :: Archive
+ , stFiles :: FileTree
+ , stUserDataDir :: FileTree
+ , stCabalDataDir :: FileTree
+ , stFontFiles :: [FilePath]
+ }
+
+instance Default PureState where
+ def = PureState { stStdGen = mkStdGen 1848
+ , stWord8Store = [1..]
+ , stUniqStore = [1..]
+ , stEnv = [("USER", "pandoc-user")]
+ , stTime = posixSecondsToUTCTime 0
+ , stTimeZone = utc
+ , stReferenceDocx = emptyArchive
+ , stReferenceODT = emptyArchive
+ , stFiles = mempty
+ , stUserDataDir = mempty
+ , stCabalDataDir = mempty
+ , stFontFiles = []
+ }
+
+
+getPureState :: PandocPure PureState
+getPureState = PandocPure $ lift $ lift $ get
+
+getsPureState :: (PureState -> a) -> PandocPure a
+getsPureState f = f <$> getPureState
+
+putPureState :: PureState -> PandocPure ()
+putPureState ps= PandocPure $ lift $ lift $ put ps
+
+modifyPureState :: (PureState -> PureState) -> PandocPure ()
+modifyPureState f = PandocPure $ lift $ lift $ modify f
+
+
+data FileInfo = FileInfo { infoFileMTime :: UTCTime
+ , infoFileContents :: B.ByteString
+ }
+
+newtype FileTree = FileTree {unFileTree :: M.Map FilePath FileInfo}
+ deriving (Monoid)
+
+getFileInfo :: FilePath -> FileTree -> Maybe FileInfo
+getFileInfo fp tree = M.lookup fp $ unFileTree tree
+
+
+newtype PandocPure a = PandocPure {
+ unPandocPure :: ExceptT PandocError
+ (StateT CommonState (State PureState)) a
+ } deriving ( Functor
+ , Applicative
+ , Monad
+ , MonadError PandocError
+ )
+
+runPure :: PandocPure a -> Either PandocError a
+runPure x = flip evalState def $
+ flip evalStateT def $
+ runExceptT $
+ unPandocPure x
+
+instance PandocMonad PandocPure where
+ lookupEnv s = do
+ env <- getsPureState stEnv
+ return (lookup s env)
+
+ getCurrentTime = getsPureState stTime
+
+ getCurrentTimeZone = getsPureState stTimeZone
+
+ newStdGen = do
+ g <- getsPureState stStdGen
+ let (_, nxtGen) = next g
+ modifyPureState $ \st -> st { stStdGen = nxtGen }
+ return g
+
+ newUniqueHash = do
+ uniqs <- getsPureState stUniqStore
+ case uniqs of
+ u : us -> do
+ modifyPureState $ \st -> st { stUniqStore = us }
+ return u
+ _ -> M.fail "uniq store ran out of elements"
+ openURL _ = throwError $ PandocSomeError "Cannot open URL in PandocPure"
+ readFileLazy fp = do
+ fps <- getsPureState stFiles
+ case infoFileContents <$> getFileInfo fp fps of
+ Just bs -> return (BL.fromStrict bs)
+ Nothing -> throwError $ PandocFileReadError fp
+ readFileStrict fp = do
+ fps <- getsPureState stFiles
+ case infoFileContents <$> getFileInfo fp fps of
+ Just bs -> return bs
+ Nothing -> throwError $ PandocFileReadError fp
+ readDataFile Nothing "reference.docx" = do
+ (B.concat . BL.toChunks . fromArchive) <$> getsPureState stReferenceDocx
+ readDataFile Nothing "reference.odt" = do
+ (B.concat . BL.toChunks . fromArchive) <$> getsPureState stReferenceODT
+ readDataFile Nothing fname = do
+ let fname' = if fname == "MANUAL.txt" then fname else "data" </> fname
+ readFileStrict fname'
+ readDataFile (Just userDir) fname = do
+ userDirFiles <- getsPureState stUserDataDir
+ case infoFileContents <$> (getFileInfo (userDir </> fname) userDirFiles) of
+ Just bs -> return bs
+ Nothing -> readDataFile Nothing fname
+
+ glob s = do
+ fontFiles <- getsPureState stFontFiles
+ return (filter (match (compile s)) fontFiles)
+
+ getModificationTime fp = do
+ fps <- getsPureState stFiles
+ case infoFileMTime <$> (getFileInfo fp fps) of
+ Just tm -> return tm
+ Nothing -> throwError $ PandocFileReadError fp
+
+ getCommonState = PandocPure $ lift $ get
+ putCommonState x = PandocPure $ lift $ put x
+
+ logOutput _msg = return ()
+
+instance PandocMonad m => PandocMonad (ParsecT s st m) where
+ lookupEnv = lift . lookupEnv
+ getCurrentTime = lift getCurrentTime
+ getCurrentTimeZone = lift getCurrentTimeZone
+ newStdGen = lift newStdGen
+ newUniqueHash = lift newUniqueHash
+ openURL = lift . openURL
+ readFileLazy = lift . readFileLazy
+ readFileStrict = lift . readFileStrict
+ readDataFile mbuserdir = lift . readDataFile mbuserdir
+ glob = lift . glob
+ getModificationTime = lift . getModificationTime
+ getCommonState = lift getCommonState
+ putCommonState = lift . putCommonState
+ logOutput = lift . logOutput
+
+instance PandocMonad m => PandocMonad (ReaderT r m) where
+ lookupEnv = lift . lookupEnv
+ getCurrentTime = lift getCurrentTime
+ getCurrentTimeZone = lift getCurrentTimeZone
+ newStdGen = lift newStdGen
+ newUniqueHash = lift newUniqueHash
+ openURL = lift . openURL
+ readFileLazy = lift . readFileLazy
+ readFileStrict = lift . readFileStrict
+ readDataFile mbuserdir = lift . readDataFile mbuserdir
+ glob = lift . glob
+ getModificationTime = lift . getModificationTime
+ getCommonState = lift getCommonState
+ putCommonState = lift . putCommonState
+ logOutput = lift . logOutput
+
+instance (PandocMonad m, Monoid w) => PandocMonad (WriterT w m) where
+ lookupEnv = lift . lookupEnv
+ getCurrentTime = lift getCurrentTime
+ getCurrentTimeZone = lift getCurrentTimeZone
+ newStdGen = lift newStdGen
+ newUniqueHash = lift newUniqueHash
+ openURL = lift . openURL
+ readFileLazy = lift . readFileLazy
+ readFileStrict = lift . readFileStrict
+ readDataFile mbuserdir = lift . readDataFile mbuserdir
+ glob = lift . glob
+ getModificationTime = lift . getModificationTime
+ getCommonState = lift getCommonState
+ putCommonState = lift . putCommonState
+ logOutput = lift . logOutput
+
+instance (PandocMonad m, Monoid w) => PandocMonad (RWST r w st m) where
+ lookupEnv = lift . lookupEnv
+ getCurrentTime = lift getCurrentTime
+ getCurrentTimeZone = lift getCurrentTimeZone
+ newStdGen = lift newStdGen
+ newUniqueHash = lift newUniqueHash
+ openURL = lift . openURL
+ readFileLazy = lift . readFileLazy
+ readFileStrict = lift . readFileStrict
+ readDataFile mbuserdir = lift . readDataFile mbuserdir
+ glob = lift . glob
+ getModificationTime = lift . getModificationTime
+ getCommonState = lift getCommonState
+ putCommonState = lift . putCommonState
+ logOutput = lift . logOutput
+
+instance PandocMonad m => PandocMonad (StateT st m) where
+ lookupEnv = lift . lookupEnv
+ getCurrentTime = lift getCurrentTime
+ getCurrentTimeZone = lift getCurrentTimeZone
+ newStdGen = lift newStdGen
+ newUniqueHash = lift newUniqueHash
+ openURL = lift . openURL
+ readFileLazy = lift . readFileLazy
+ readFileStrict = lift . readFileStrict
+ readDataFile mbuserdir = lift . readDataFile mbuserdir
+ glob = lift . glob
+ getModificationTime = lift . getModificationTime
+ getCommonState = lift getCommonState
+ putCommonState = lift . putCommonState
+ logOutput = lift . logOutput
+
diff --git a/src/Text/Pandoc/Compat/Time.hs b/src/Text/Pandoc/Compat/Time.hs
new file mode 100644
index 000000000..b1cde82a4
--- /dev/null
+++ b/src/Text/Pandoc/Compat/Time.hs
@@ -0,0 +1,30 @@
+{-# LANGUAGE CPP #-}
+
+{-
+This compatibility module is needed because, in time 1.5, the
+`defaultTimeLocale` function was moved from System.Locale (in the
+old-locale library) into Data.Time.
+
+We support both behaviors because time 1.4 is a boot library for GHC
+7.8. time 1.5 is a boot library for GHC 7.10.
+
+When support is dropped for GHC 7.8, this module may be obsoleted.
+-}
+
+#if MIN_VERSION_time(1,5,0)
+module Text.Pandoc.Compat.Time (
+ module Data.Time
+)
+where
+import Data.Time
+
+#else
+module Text.Pandoc.Compat.Time (
+ module Data.Time,
+ defaultTimeLocale
+)
+where
+import Data.Time
+import System.Locale ( defaultTimeLocale )
+
+#endif
diff --git a/src/Text/Pandoc/Data.hsb b/src/Text/Pandoc/Data.hsb
new file mode 100644
index 000000000..8786647c5
--- /dev/null
+++ b/src/Text/Pandoc/Data.hsb
@@ -0,0 +1,15 @@
+{-# LANGUAGE OverloadedStrings #-}
+-- to be processed using hsb2hs
+module Text.Pandoc.Data (dataFiles) where
+import qualified Data.ByteString as B
+import System.FilePath (splitDirectories)
+import qualified System.FilePath.Posix as Posix
+
+-- We ensure that the data files are stored using Posix
+-- path separators (/), even on Windows.
+dataFiles :: [(FilePath, B.ByteString)]
+dataFiles = map (\(fp, contents) ->
+ (Posix.joinPath (splitDirectories fp), contents)) dataFiles'
+
+dataFiles' :: [(FilePath, B.ByteString)]
+dataFiles' = ("MANUAL.txt", %blob "MANUAL.txt") : %blobs "data"
diff --git a/src/Text/Pandoc/Emoji.hs b/src/Text/Pandoc/Emoji.hs
new file mode 100644
index 000000000..c9f368abc
--- /dev/null
+++ b/src/Text/Pandoc/Emoji.hs
@@ -0,0 +1,906 @@
+{-
+Copyright (C) 2015 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.Emoji
+ Copyright : Copyright (C) 2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Emoji symbol lookup from canonical string identifier.
+-}
+module Text.Pandoc.Emoji ( emojis ) where
+import qualified Data.Map as M
+
+emojis :: M.Map String String
+emojis = M.fromList
+ [("+1","\128077")
+ ,("-1","\128078")
+ ,("100","\128175")
+ ,("1234","\128290")
+ ,("8ball","\127921")
+ ,("a","\127344\65039")
+ ,("ab","\127374")
+ ,("abc","\128292")
+ ,("abcd","\128289")
+ ,("accept","\127569")
+ ,("aerial_tramway","\128673")
+ ,("airplane","\9992\65039")
+ ,("alarm_clock","\9200")
+ ,("alien","\128125")
+ ,("ambulance","\128657")
+ ,("anchor","\9875")
+ ,("angel","\128124")
+ ,("anger","\128162")
+ ,("angry","\128544")
+ ,("anguished","\128551")
+ ,("ant","\128028")
+ ,("apple","\127822")
+ ,("aquarius","\9810")
+ ,("aries","\9800")
+ ,("arrow_backward","\9664\65039")
+ ,("arrow_double_down","\9196")
+ ,("arrow_double_up","\9195")
+ ,("arrow_down","\11015\65039")
+ ,("arrow_down_small","\128317")
+ ,("arrow_forward","\9654\65039")
+ ,("arrow_heading_down","\10549\65039")
+ ,("arrow_heading_up","\10548\65039")
+ ,("arrow_left","\11013\65039")
+ ,("arrow_lower_left","\8601\65039")
+ ,("arrow_lower_right","\8600\65039")
+ ,("arrow_right","\10145\65039")
+ ,("arrow_right_hook","\8618\65039")
+ ,("arrow_up","\11014\65039")
+ ,("arrow_up_down","\8597\65039")
+ ,("arrow_up_small","\128316")
+ ,("arrow_upper_left","\8598\65039")
+ ,("arrow_upper_right","\8599\65039")
+ ,("arrows_clockwise","\128259")
+ ,("arrows_counterclockwise","\128260")
+ ,("art","\127912")
+ ,("articulated_lorry","\128667")
+ ,("astonished","\128562")
+ ,("athletic_shoe","\128095")
+ ,("atm","\127975")
+ ,("b","\127345\65039")
+ ,("baby","\128118")
+ ,("baby_bottle","\127868")
+ ,("baby_chick","\128036")
+ ,("baby_symbol","\128700")
+ ,("back","\128281")
+ ,("baggage_claim","\128708")
+ ,("balloon","\127880")
+ ,("ballot_box_with_check","\9745\65039")
+ ,("bamboo","\127885")
+ ,("banana","\127820")
+ ,("bangbang","\8252\65039")
+ ,("bank","\127974")
+ ,("bar_chart","\128202")
+ ,("barber","\128136")
+ ,("baseball","\9918\65039")
+ ,("basketball","\127936")
+ ,("bath","\128704")
+ ,("bathtub","\128705")
+ ,("battery","\128267")
+ ,("bear","\128059")
+ ,("bee","\128029")
+ ,("beer","\127866")
+ ,("beers","\127867")
+ ,("beetle","\128030")
+ ,("beginner","\128304")
+ ,("bell","\128276")
+ ,("bento","\127857")
+ ,("bicyclist","\128692")
+ ,("bike","\128690")
+ ,("bikini","\128089")
+ ,("bird","\128038")
+ ,("birthday","\127874")
+ ,("black_circle","\9899")
+ ,("black_joker","\127183")
+ ,("black_large_square","\11035")
+ ,("black_medium_small_square","\9726")
+ ,("black_medium_square","\9724\65039")
+ ,("black_nib","\10002\65039")
+ ,("black_small_square","\9642\65039")
+ ,("black_square_button","\128306")
+ ,("blossom","\127804")
+ ,("blowfish","\128033")
+ ,("blue_book","\128216")
+ ,("blue_car","\128665")
+ ,("blue_heart","\128153")
+ ,("blush","\128522")
+ ,("boar","\128023")
+ ,("boat","\9973")
+ ,("bomb","\128163")
+ ,("book","\128214")
+ ,("bookmark","\128278")
+ ,("bookmark_tabs","\128209")
+ ,("books","\128218")
+ ,("boom","\128165")
+ ,("boot","\128098")
+ ,("bouquet","\128144")
+ ,("bow","\128583")
+ ,("bowling","\127923")
+ ,("boy","\128102")
+ ,("bread","\127838")
+ ,("bride_with_veil","\128112")
+ ,("bridge_at_night","\127753")
+ ,("briefcase","\128188")
+ ,("broken_heart","\128148")
+ ,("bug","\128027")
+ ,("bulb","\128161")
+ ,("bullettrain_front","\128645")
+ ,("bullettrain_side","\128644")
+ ,("bus","\128652")
+ ,("busstop","\128655")
+ ,("bust_in_silhouette","\128100")
+ ,("busts_in_silhouette","\128101")
+ ,("cactus","\127797")
+ ,("cake","\127856")
+ ,("calendar","\128198")
+ ,("calling","\128242")
+ ,("camel","\128043")
+ ,("camera","\128247")
+ ,("cancer","\9803")
+ ,("candy","\127852")
+ ,("capital_abcd","\128288")
+ ,("capricorn","\9809")
+ ,("car","\128663")
+ ,("card_index","\128199")
+ ,("carousel_horse","\127904")
+ ,("cat","\128049")
+ ,("cat2","\128008")
+ ,("cd","\128191")
+ ,("chart","\128185")
+ ,("chart_with_downwards_trend","\128201")
+ ,("chart_with_upwards_trend","\128200")
+ ,("checkered_flag","\127937")
+ ,("cherries","\127826")
+ ,("cherry_blossom","\127800")
+ ,("chestnut","\127792")
+ ,("chicken","\128020")
+ ,("children_crossing","\128696")
+ ,("chocolate_bar","\127851")
+ ,("christmas_tree","\127876")
+ ,("church","\9962")
+ ,("cinema","\127910")
+ ,("circus_tent","\127914")
+ ,("city_sunrise","\127751")
+ ,("city_sunset","\127750")
+ ,("cl","\127377")
+ ,("clap","\128079")
+ ,("clapper","\127916")
+ ,("clipboard","\128203")
+ ,("clock1","\128336")
+ ,("clock10","\128345")
+ ,("clock1030","\128357")
+ ,("clock11","\128346")
+ ,("clock1130","\128358")
+ ,("clock12","\128347")
+ ,("clock1230","\128359")
+ ,("clock130","\128348")
+ ,("clock2","\128337")
+ ,("clock230","\128349")
+ ,("clock3","\128338")
+ ,("clock330","\128350")
+ ,("clock4","\128339")
+ ,("clock430","\128351")
+ ,("clock5","\128340")
+ ,("clock530","\128352")
+ ,("clock6","\128341")
+ ,("clock630","\128353")
+ ,("clock7","\128342")
+ ,("clock730","\128354")
+ ,("clock8","\128343")
+ ,("clock830","\128355")
+ ,("clock9","\128344")
+ ,("clock930","\128356")
+ ,("closed_book","\128213")
+ ,("closed_lock_with_key","\128272")
+ ,("closed_umbrella","\127746")
+ ,("cloud","\9729\65039")
+ ,("clubs","\9827\65039")
+ ,("cn","\127464\127475")
+ ,("cocktail","\127864")
+ ,("coffee","\9749")
+ ,("cold_sweat","\128560")
+ ,("collision","\128165")
+ ,("computer","\128187")
+ ,("confetti_ball","\127882")
+ ,("confounded","\128534")
+ ,("confused","\128533")
+ ,("congratulations","\12951\65039")
+ ,("construction","\128679")
+ ,("construction_worker","\128119")
+ ,("convenience_store","\127978")
+ ,("cookie","\127850")
+ ,("cool","\127378")
+ ,("cop","\128110")
+ ,("copyright","\169\65039")
+ ,("corn","\127805")
+ ,("couple","\128107")
+ ,("couple_with_heart","\128145")
+ ,("couplekiss","\128143")
+ ,("cow","\128046")
+ ,("cow2","\128004")
+ ,("credit_card","\128179")
+ ,("crescent_moon","\127769")
+ ,("crocodile","\128010")
+ ,("crossed_flags","\127884")
+ ,("crown","\128081")
+ ,("cry","\128546")
+ ,("crying_cat_face","\128575")
+ ,("crystal_ball","\128302")
+ ,("cupid","\128152")
+ ,("curly_loop","\10160")
+ ,("currency_exchange","\128177")
+ ,("curry","\127835")
+ ,("custard","\127854")
+ ,("customs","\128707")
+ ,("cyclone","\127744")
+ ,("dancer","\128131")
+ ,("dancers","\128111")
+ ,("dango","\127841")
+ ,("dart","\127919")
+ ,("dash","\128168")
+ ,("date","\128197")
+ ,("de","\127465\127466")
+ ,("deciduous_tree","\127795")
+ ,("department_store","\127980")
+ ,("diamond_shape_with_a_dot_inside","\128160")
+ ,("diamonds","\9830\65039")
+ ,("disappointed","\128542")
+ ,("disappointed_relieved","\128549")
+ ,("dizzy","\128171")
+ ,("dizzy_face","\128565")
+ ,("do_not_litter","\128687")
+ ,("dog","\128054")
+ ,("dog2","\128021")
+ ,("dollar","\128181")
+ ,("dolls","\127886")
+ ,("dolphin","\128044")
+ ,("door","\128682")
+ ,("doughnut","\127849")
+ ,("dragon","\128009")
+ ,("dragon_face","\128050")
+ ,("dress","\128087")
+ ,("dromedary_camel","\128042")
+ ,("droplet","\128167")
+ ,("dvd","\128192")
+ ,("e-mail","\128231")
+ ,("ear","\128066")
+ ,("ear_of_rice","\127806")
+ ,("earth_africa","\127757")
+ ,("earth_americas","\127758")
+ ,("earth_asia","\127759")
+ ,("egg","\127859")
+ ,("eggplant","\127814")
+ ,("eight","8\65039\8419")
+ ,("eight_pointed_black_star","\10036\65039")
+ ,("eight_spoked_asterisk","\10035\65039")
+ ,("electric_plug","\128268")
+ ,("elephant","\128024")
+ ,("email","\9993\65039")
+ ,("end","\128282")
+ ,("envelope","\9993\65039")
+ ,("envelope_with_arrow","\128233")
+ ,("es","\127466\127480")
+ ,("euro","\128182")
+ ,("european_castle","\127984")
+ ,("european_post_office","\127972")
+ ,("evergreen_tree","\127794")
+ ,("exclamation","\10071")
+ ,("expressionless","\128529")
+ ,("eyeglasses","\128083")
+ ,("eyes","\128064")
+ ,("facepunch","\128074")
+ ,("factory","\127981")
+ ,("fallen_leaf","\127810")
+ ,("family","\128106")
+ ,("fast_forward","\9193")
+ ,("fax","\128224")
+ ,("fearful","\128552")
+ ,("feet","\128062")
+ ,("ferris_wheel","\127905")
+ ,("file_folder","\128193")
+ ,("fire","\128293")
+ ,("fire_engine","\128658")
+ ,("fireworks","\127878")
+ ,("first_quarter_moon","\127763")
+ ,("first_quarter_moon_with_face","\127771")
+ ,("fish","\128031")
+ ,("fish_cake","\127845")
+ ,("fishing_pole_and_fish","\127907")
+ ,("fist","\9994")
+ ,("five","5\65039\8419")
+ ,("flags","\127887")
+ ,("flashlight","\128294")
+ ,("flipper","\128044")
+ ,("floppy_disk","\128190")
+ ,("flower_playing_cards","\127924")
+ ,("flushed","\128563")
+ ,("foggy","\127745")
+ ,("football","\127944")
+ ,("footprints","\128099")
+ ,("fork_and_knife","\127860")
+ ,("fountain","\9970")
+ ,("four","4\65039\8419")
+ ,("four_leaf_clover","\127808")
+ ,("fr","\127467\127479")
+ ,("free","\127379")
+ ,("fried_shrimp","\127844")
+ ,("fries","\127839")
+ ,("frog","\128056")
+ ,("frowning","\128550")
+ ,("fuelpump","\9981")
+ ,("full_moon","\127765")
+ ,("full_moon_with_face","\127773")
+ ,("game_die","\127922")
+ ,("gb","\127468\127463")
+ ,("gem","\128142")
+ ,("gemini","\9802")
+ ,("ghost","\128123")
+ ,("gift","\127873")
+ ,("gift_heart","\128157")
+ ,("girl","\128103")
+ ,("globe_with_meridians","\127760")
+ ,("goat","\128016")
+ ,("golf","\9971")
+ ,("grapes","\127815")
+ ,("green_apple","\127823")
+ ,("green_book","\128215")
+ ,("green_heart","\128154")
+ ,("grey_exclamation","\10069")
+ ,("grey_question","\10068")
+ ,("grimacing","\128556")
+ ,("grin","\128513")
+ ,("grinning","\128512")
+ ,("guardsman","\128130")
+ ,("guitar","\127928")
+ ,("gun","\128299")
+ ,("haircut","\128135")
+ ,("hamburger","\127828")
+ ,("hammer","\128296")
+ ,("hamster","\128057")
+ ,("hand","\9995")
+ ,("handbag","\128092")
+ ,("hankey","\128169")
+ ,("hash","#\65039\8419")
+ ,("hatched_chick","\128037")
+ ,("hatching_chick","\128035")
+ ,("headphones","\127911")
+ ,("hear_no_evil","\128585")
+ ,("heart","\10084\65039")
+ ,("heart_decoration","\128159")
+ ,("heart_eyes","\128525")
+ ,("heart_eyes_cat","\128571")
+ ,("heartbeat","\128147")
+ ,("heartpulse","\128151")
+ ,("hearts","\9829\65039")
+ ,("heavy_check_mark","\10004\65039")
+ ,("heavy_division_sign","\10135")
+ ,("heavy_dollar_sign","\128178")
+ ,("heavy_exclamation_mark","\10071")
+ ,("heavy_minus_sign","\10134")
+ ,("heavy_multiplication_x","\10006\65039")
+ ,("heavy_plus_sign","\10133")
+ ,("helicopter","\128641")
+ ,("herb","\127807")
+ ,("hibiscus","\127802")
+ ,("high_brightness","\128262")
+ ,("high_heel","\128096")
+ ,("hocho","\128298")
+ ,("honey_pot","\127855")
+ ,("honeybee","\128029")
+ ,("horse","\128052")
+ ,("horse_racing","\127943")
+ ,("hospital","\127973")
+ ,("hotel","\127976")
+ ,("hotsprings","\9832\65039")
+ ,("hourglass","\8987")
+ ,("hourglass_flowing_sand","\9203")
+ ,("house","\127968")
+ ,("house_with_garden","\127969")
+ ,("hushed","\128559")
+ ,("ice_cream","\127848")
+ ,("icecream","\127846")
+ ,("id","\127380")
+ ,("ideograph_advantage","\127568")
+ ,("imp","\128127")
+ ,("inbox_tray","\128229")
+ ,("incoming_envelope","\128232")
+ ,("information_desk_person","\128129")
+ ,("information_source","\8505\65039")
+ ,("innocent","\128519")
+ ,("interrobang","\8265\65039")
+ ,("iphone","\128241")
+ ,("it","\127470\127481")
+ ,("izakaya_lantern","\127982")
+ ,("jack_o_lantern","\127875")
+ ,("japan","\128510")
+ ,("japanese_castle","\127983")
+ ,("japanese_goblin","\128122")
+ ,("japanese_ogre","\128121")
+ ,("jeans","\128086")
+ ,("joy","\128514")
+ ,("joy_cat","\128569")
+ ,("jp","\127471\127477")
+ ,("key","\128273")
+ ,("keycap_ten","\128287")
+ ,("kimono","\128088")
+ ,("kiss","\128139")
+ ,("kissing","\128535")
+ ,("kissing_cat","\128573")
+ ,("kissing_closed_eyes","\128538")
+ ,("kissing_heart","\128536")
+ ,("kissing_smiling_eyes","\128537")
+ ,("knife","\128298")
+ ,("koala","\128040")
+ ,("koko","\127489")
+ ,("kr","\127472\127479")
+ ,("lantern","\127982")
+ ,("large_blue_circle","\128309")
+ ,("large_blue_diamond","\128311")
+ ,("large_orange_diamond","\128310")
+ ,("last_quarter_moon","\127767")
+ ,("last_quarter_moon_with_face","\127772")
+ ,("laughing","\128518")
+ ,("leaves","\127811")
+ ,("ledger","\128210")
+ ,("left_luggage","\128709")
+ ,("left_right_arrow","\8596\65039")
+ ,("leftwards_arrow_with_hook","\8617\65039")
+ ,("lemon","\127819")
+ ,("leo","\9804")
+ ,("leopard","\128006")
+ ,("libra","\9806")
+ ,("light_rail","\128648")
+ ,("link","\128279")
+ ,("lips","\128068")
+ ,("lipstick","\128132")
+ ,("lock","\128274")
+ ,("lock_with_ink_pen","\128271")
+ ,("lollipop","\127853")
+ ,("loop","\10175")
+ ,("loud_sound","\128266")
+ ,("loudspeaker","\128226")
+ ,("love_hotel","\127977")
+ ,("love_letter","\128140")
+ ,("low_brightness","\128261")
+ ,("m","\9410\65039")
+ ,("mag","\128269")
+ ,("mag_right","\128270")
+ ,("mahjong","\126980")
+ ,("mailbox","\128235")
+ ,("mailbox_closed","\128234")
+ ,("mailbox_with_mail","\128236")
+ ,("mailbox_with_no_mail","\128237")
+ ,("man","\128104")
+ ,("man_with_gua_pi_mao","\128114")
+ ,("man_with_turban","\128115")
+ ,("mans_shoe","\128094")
+ ,("maple_leaf","\127809")
+ ,("mask","\128567")
+ ,("massage","\128134")
+ ,("meat_on_bone","\127830")
+ ,("mega","\128227")
+ ,("melon","\127816")
+ ,("memo","\128221")
+ ,("mens","\128697")
+ ,("metro","\128647")
+ ,("microphone","\127908")
+ ,("microscope","\128300")
+ ,("milky_way","\127756")
+ ,("minibus","\128656")
+ ,("minidisc","\128189")
+ ,("mobile_phone_off","\128244")
+ ,("money_with_wings","\128184")
+ ,("moneybag","\128176")
+ ,("monkey","\128018")
+ ,("monkey_face","\128053")
+ ,("monorail","\128669")
+ ,("moon","\127764")
+ ,("mortar_board","\127891")
+ ,("mount_fuji","\128507")
+ ,("mountain_bicyclist","\128693")
+ ,("mountain_cableway","\128672")
+ ,("mountain_railway","\128670")
+ ,("mouse","\128045")
+ ,("mouse2","\128001")
+ ,("movie_camera","\127909")
+ ,("moyai","\128511")
+ ,("muscle","\128170")
+ ,("mushroom","\127812")
+ ,("musical_keyboard","\127929")
+ ,("musical_note","\127925")
+ ,("musical_score","\127932")
+ ,("mute","\128263")
+ ,("nail_care","\128133")
+ ,("name_badge","\128219")
+ ,("necktie","\128084")
+ ,("negative_squared_cross_mark","\10062")
+ ,("neutral_face","\128528")
+ ,("new","\127381")
+ ,("new_moon","\127761")
+ ,("new_moon_with_face","\127770")
+ ,("newspaper","\128240")
+ ,("ng","\127382")
+ ,("night_with_stars","\127747")
+ ,("nine","9\65039\8419")
+ ,("no_bell","\128277")
+ ,("no_bicycles","\128691")
+ ,("no_entry","\9940")
+ ,("no_entry_sign","\128683")
+ ,("no_good","\128581")
+ ,("no_mobile_phones","\128245")
+ ,("no_mouth","\128566")
+ ,("no_pedestrians","\128695")
+ ,("no_smoking","\128685")
+ ,("non-potable_water","\128689")
+ ,("nose","\128067")
+ ,("notebook","\128211")
+ ,("notebook_with_decorative_cover","\128212")
+ ,("notes","\127926")
+ ,("nut_and_bolt","\128297")
+ ,("o","\11093")
+ ,("o2","\127358\65039")
+ ,("ocean","\127754")
+ ,("octopus","\128025")
+ ,("oden","\127842")
+ ,("office","\127970")
+ ,("ok","\127383")
+ ,("ok_hand","\128076")
+ ,("ok_woman","\128582")
+ ,("older_man","\128116")
+ ,("older_woman","\128117")
+ ,("on","\128283")
+ ,("oncoming_automobile","\128664")
+ ,("oncoming_bus","\128653")
+ ,("oncoming_police_car","\128660")
+ ,("oncoming_taxi","\128662")
+ ,("one","1\65039\8419")
+ ,("open_book","\128214")
+ ,("open_file_folder","\128194")
+ ,("open_hands","\128080")
+ ,("open_mouth","\128558")
+ ,("ophiuchus","\9934")
+ ,("orange_book","\128217")
+ ,("outbox_tray","\128228")
+ ,("ox","\128002")
+ ,("package","\128230")
+ ,("page_facing_up","\128196")
+ ,("page_with_curl","\128195")
+ ,("pager","\128223")
+ ,("palm_tree","\127796")
+ ,("panda_face","\128060")
+ ,("paperclip","\128206")
+ ,("parking","\127359\65039")
+ ,("part_alternation_mark","\12349\65039")
+ ,("partly_sunny","\9925")
+ ,("passport_control","\128706")
+ ,("paw_prints","\128062")
+ ,("peach","\127825")
+ ,("pear","\127824")
+ ,("pencil","\128221")
+ ,("pencil2","\9999\65039")
+ ,("penguin","\128039")
+ ,("pensive","\128532")
+ ,("performing_arts","\127917")
+ ,("persevere","\128547")
+ ,("person_frowning","\128589")
+ ,("person_with_blond_hair","\128113")
+ ,("person_with_pouting_face","\128590")
+ ,("phone","\9742\65039")
+ ,("pig","\128055")
+ ,("pig2","\128022")
+ ,("pig_nose","\128061")
+ ,("pill","\128138")
+ ,("pineapple","\127821")
+ ,("pisces","\9811")
+ ,("pizza","\127829")
+ ,("point_down","\128071")
+ ,("point_left","\128072")
+ ,("point_right","\128073")
+ ,("point_up","\9757\65039")
+ ,("point_up_2","\128070")
+ ,("police_car","\128659")
+ ,("poodle","\128041")
+ ,("poop","\128169")
+ ,("post_office","\127971")
+ ,("postal_horn","\128239")
+ ,("postbox","\128238")
+ ,("potable_water","\128688")
+ ,("pouch","\128093")
+ ,("poultry_leg","\127831")
+ ,("pound","\128183")
+ ,("pouting_cat","\128574")
+ ,("pray","\128591")
+ ,("princess","\128120")
+ ,("punch","\128074")
+ ,("purple_heart","\128156")
+ ,("purse","\128091")
+ ,("pushpin","\128204")
+ ,("put_litter_in_its_place","\128686")
+ ,("question","\10067")
+ ,("rabbit","\128048")
+ ,("rabbit2","\128007")
+ ,("racehorse","\128014")
+ ,("radio","\128251")
+ ,("radio_button","\128280")
+ ,("rage","\128545")
+ ,("railway_car","\128643")
+ ,("rainbow","\127752")
+ ,("raised_hand","\9995")
+ ,("raised_hands","\128588")
+ ,("raising_hand","\128587")
+ ,("ram","\128015")
+ ,("ramen","\127836")
+ ,("rat","\128000")
+ ,("recycle","\9851\65039")
+ ,("red_car","\128663")
+ ,("red_circle","\128308")
+ ,("registered","\174\65039")
+ ,("relaxed","\9786\65039")
+ ,("relieved","\128524")
+ ,("repeat","\128257")
+ ,("repeat_one","\128258")
+ ,("restroom","\128699")
+ ,("revolving_hearts","\128158")
+ ,("rewind","\9194")
+ ,("ribbon","\127872")
+ ,("rice","\127834")
+ ,("rice_ball","\127833")
+ ,("rice_cracker","\127832")
+ ,("rice_scene","\127889")
+ ,("ring","\128141")
+ ,("rocket","\128640")
+ ,("roller_coaster","\127906")
+ ,("rooster","\128019")
+ ,("rose","\127801")
+ ,("rotating_light","\128680")
+ ,("round_pushpin","\128205")
+ ,("rowboat","\128675")
+ ,("ru","\127479\127482")
+ ,("rugby_football","\127945")
+ ,("runner","\127939")
+ ,("running","\127939")
+ ,("running_shirt_with_sash","\127933")
+ ,("sa","\127490\65039")
+ ,("sagittarius","\9808")
+ ,("sailboat","\9973")
+ ,("sake","\127862")
+ ,("sandal","\128097")
+ ,("santa","\127877")
+ ,("satellite","\128225")
+ ,("satisfied","\128518")
+ ,("saxophone","\127927")
+ ,("school","\127979")
+ ,("school_satchel","\127890")
+ ,("scissors","\9986\65039")
+ ,("scorpius","\9807")
+ ,("scream","\128561")
+ ,("scream_cat","\128576")
+ ,("scroll","\128220")
+ ,("seat","\128186")
+ ,("secret","\12953\65039")
+ ,("see_no_evil","\128584")
+ ,("seedling","\127793")
+ ,("seven","7\65039\8419")
+ ,("shaved_ice","\127847")
+ ,("sheep","\128017")
+ ,("shell","\128026")
+ ,("ship","\128674")
+ ,("shirt","\128085")
+ ,("shit","\128169")
+ ,("shoe","\128094")
+ ,("shower","\128703")
+ ,("signal_strength","\128246")
+ ,("six","6\65039\8419")
+ ,("six_pointed_star","\128303")
+ ,("ski","\127935")
+ ,("skull","\128128")
+ ,("sleeping","\128564")
+ ,("sleepy","\128554")
+ ,("slot_machine","\127920")
+ ,("small_blue_diamond","\128313")
+ ,("small_orange_diamond","\128312")
+ ,("small_red_triangle","\128314")
+ ,("small_red_triangle_down","\128315")
+ ,("smile","\128516")
+ ,("smile_cat","\128568")
+ ,("smiley","\128515")
+ ,("smiley_cat","\128570")
+ ,("smiling_imp","\128520")
+ ,("smirk","\128527")
+ ,("smirk_cat","\128572")
+ ,("smoking","\128684")
+ ,("snail","\128012")
+ ,("snake","\128013")
+ ,("snowboarder","\127938")
+ ,("snowflake","\10052\65039")
+ ,("snowman","\9924")
+ ,("sob","\128557")
+ ,("soccer","\9917")
+ ,("soon","\128284")
+ ,("sos","\127384")
+ ,("sound","\128265")
+ ,("space_invader","\128126")
+ ,("spades","\9824\65039")
+ ,("spaghetti","\127837")
+ ,("sparkle","\10055\65039")
+ ,("sparkler","\127879")
+ ,("sparkles","\10024")
+ ,("sparkling_heart","\128150")
+ ,("speak_no_evil","\128586")
+ ,("speaker","\128264")
+ ,("speech_balloon","\128172")
+ ,("speedboat","\128676")
+ ,("star","\11088")
+ ,("star2","\127775")
+ ,("stars","\127776")
+ ,("station","\128649")
+ ,("statue_of_liberty","\128509")
+ ,("steam_locomotive","\128642")
+ ,("stew","\127858")
+ ,("straight_ruler","\128207")
+ ,("strawberry","\127827")
+ ,("stuck_out_tongue","\128539")
+ ,("stuck_out_tongue_closed_eyes","\128541")
+ ,("stuck_out_tongue_winking_eye","\128540")
+ ,("sun_with_face","\127774")
+ ,("sunflower","\127803")
+ ,("sunglasses","\128526")
+ ,("sunny","\9728\65039")
+ ,("sunrise","\127749")
+ ,("sunrise_over_mountains","\127748")
+ ,("surfer","\127940")
+ ,("sushi","\127843")
+ ,("suspension_railway","\128671")
+ ,("sweat","\128531")
+ ,("sweat_drops","\128166")
+ ,("sweat_smile","\128517")
+ ,("sweet_potato","\127840")
+ ,("swimmer","\127946")
+ ,("symbols","\128291")
+ ,("syringe","\128137")
+ ,("tada","\127881")
+ ,("tanabata_tree","\127883")
+ ,("tangerine","\127818")
+ ,("taurus","\9801")
+ ,("taxi","\128661")
+ ,("tea","\127861")
+ ,("telephone","\9742\65039")
+ ,("telephone_receiver","\128222")
+ ,("telescope","\128301")
+ ,("tennis","\127934")
+ ,("tent","\9978")
+ ,("thought_balloon","\128173")
+ ,("three","3\65039\8419")
+ ,("thumbsdown","\128078")
+ ,("thumbsup","\128077")
+ ,("ticket","\127915")
+ ,("tiger","\128047")
+ ,("tiger2","\128005")
+ ,("tired_face","\128555")
+ ,("tm","\8482\65039")
+ ,("toilet","\128701")
+ ,("tokyo_tower","\128508")
+ ,("tomato","\127813")
+ ,("tongue","\128069")
+ ,("top","\128285")
+ ,("tophat","\127913")
+ ,("tractor","\128668")
+ ,("traffic_light","\128677")
+ ,("train","\128651")
+ ,("train2","\128646")
+ ,("tram","\128650")
+ ,("triangular_flag_on_post","\128681")
+ ,("triangular_ruler","\128208")
+ ,("trident","\128305")
+ ,("triumph","\128548")
+ ,("trolleybus","\128654")
+ ,("trophy","\127942")
+ ,("tropical_drink","\127865")
+ ,("tropical_fish","\128032")
+ ,("truck","\128666")
+ ,("trumpet","\127930")
+ ,("tshirt","\128085")
+ ,("tulip","\127799")
+ ,("turtle","\128034")
+ ,("tv","\128250")
+ ,("twisted_rightwards_arrows","\128256")
+ ,("two","2\65039\8419")
+ ,("two_hearts","\128149")
+ ,("two_men_holding_hands","\128108")
+ ,("two_women_holding_hands","\128109")
+ ,("u5272","\127545")
+ ,("u5408","\127540")
+ ,("u55b6","\127546")
+ ,("u6307","\127535")
+ ,("u6708","\127543\65039")
+ ,("u6709","\127542")
+ ,("u6e80","\127541")
+ ,("u7121","\127514")
+ ,("u7533","\127544")
+ ,("u7981","\127538")
+ ,("u7a7a","\127539")
+ ,("uk","\127468\127463")
+ ,("umbrella","\9748")
+ ,("unamused","\128530")
+ ,("underage","\128286")
+ ,("unlock","\128275")
+ ,("up","\127385")
+ ,("us","\127482\127480")
+ ,("v","\9996\65039")
+ ,("vertical_traffic_light","\128678")
+ ,("vhs","\128252")
+ ,("vibration_mode","\128243")
+ ,("video_camera","\128249")
+ ,("video_game","\127918")
+ ,("violin","\127931")
+ ,("virgo","\9805")
+ ,("volcano","\127755")
+ ,("vs","\127386")
+ ,("walking","\128694")
+ ,("waning_crescent_moon","\127768")
+ ,("waning_gibbous_moon","\127766")
+ ,("warning","\9888\65039")
+ ,("watch","\8986")
+ ,("water_buffalo","\128003")
+ ,("watermelon","\127817")
+ ,("wave","\128075")
+ ,("wavy_dash","\12336\65039")
+ ,("waxing_crescent_moon","\127762")
+ ,("waxing_gibbous_moon","\127764")
+ ,("wc","\128702")
+ ,("weary","\128553")
+ ,("wedding","\128146")
+ ,("whale","\128051")
+ ,("whale2","\128011")
+ ,("wheelchair","\9855")
+ ,("white_check_mark","\9989")
+ ,("white_circle","\9898")
+ ,("white_flower","\128174")
+ ,("white_large_square","\11036")
+ ,("white_medium_small_square","\9725")
+ ,("white_medium_square","\9723\65039")
+ ,("white_small_square","\9643\65039")
+ ,("white_square_button","\128307")
+ ,("wind_chime","\127888")
+ ,("wine_glass","\127863")
+ ,("wink","\128521")
+ ,("wolf","\128058")
+ ,("woman","\128105")
+ ,("womans_clothes","\128090")
+ ,("womans_hat","\128082")
+ ,("womens","\128698")
+ ,("worried","\128543")
+ ,("wrench","\128295")
+ ,("x","\10060")
+ ,("yellow_heart","\128155")
+ ,("yen","\128180")
+ ,("yum","\128523")
+ ,("zap","\9889")
+ ,("zero","0\65039\8419")
+ ,("zzz","\128164")
+ ]
+
diff --git a/src/Text/Pandoc/Error.hs b/src/Text/Pandoc/Error.hs
new file mode 100644
index 000000000..65f912c88
--- /dev/null
+++ b/src/Text/Pandoc/Error.hs
@@ -0,0 +1,76 @@
+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
+{-
+Copyright (C) 2006-2016 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.Error
+ Copyright : Copyright (C) 2006-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+This module provides a standard way to deal with possible errors encounted
+during parsing.
+
+-}
+module Text.Pandoc.Error (
+ PandocError(..),
+ handleError) where
+
+import Text.Parsec.Error
+import Text.Parsec.Pos hiding (Line)
+import Data.Generics (Typeable)
+import GHC.Generics (Generic)
+import Control.Exception (Exception)
+import Text.Pandoc.Shared (err)
+
+type Input = String
+
+data PandocError = PandocFileReadError FilePath
+ | PandocShouldNeverHappenError String
+ | PandocSomeError String
+ | PandocParseError String
+ | PandocParsecError Input ParseError
+ | PandocMakePDFError String
+ deriving (Show, Typeable, Generic)
+
+instance Exception PandocError
+
+-- | Handle PandocError by exiting with an error message.
+handleError :: Either PandocError a -> IO a
+handleError (Right r) = return r
+handleError (Left e) =
+ case e of
+ PandocFileReadError fp -> err 61 $ "problem reading " ++ fp
+ PandocShouldNeverHappenError s -> err 62 s
+ PandocSomeError s -> err 63 s
+ PandocParseError s -> err 64 s
+ PandocParsecError input err' ->
+ let errPos = errorPos err'
+ errLine = sourceLine errPos
+ errColumn = sourceColumn errPos
+ ls = lines input ++ [""]
+ errorInFile = if length ls > errLine - 1
+ then concat ["\n", (ls !! (errLine - 1))
+ ,"\n", replicate (errColumn - 1) ' '
+ ,"^"]
+ else ""
+ in err 65 $ "\nError at " ++ show err' ++ errorInFile
+ PandocMakePDFError s -> err 65 s
+
diff --git a/src/Text/Pandoc/Extensions.hs b/src/Text/Pandoc/Extensions.hs
new file mode 100644
index 000000000..d5e59e8e1
--- /dev/null
+++ b/src/Text/Pandoc/Extensions.hs
@@ -0,0 +1,267 @@
+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
+{-
+Copyright (C) 2012-2016 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.Extensions
+ Copyright : Copyright (C) 2012-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Data structures and functions for representing markup extensions.
+-}
+module Text.Pandoc.Extensions ( Extension(..)
+ , Extensions
+ , emptyExtensions
+ , extensionsFromList
+ , extensionEnabled
+ , enableExtension
+ , disableExtension
+ , pandocExtensions
+ , plainExtensions
+ , strictExtensions
+ , phpMarkdownExtraExtensions
+ , githubMarkdownExtensions
+ , multimarkdownExtensions )
+where
+import Data.Bits (testBit, setBit, clearBit)
+import Data.Data (Data)
+import Data.Typeable (Typeable)
+import GHC.Generics (Generic)
+
+newtype Extensions = Extensions Integer
+ deriving (Show, Read, Eq, Ord, Data, Typeable, Generic)
+
+extensionsFromList :: [Extension] -> Extensions
+extensionsFromList = foldr enableExtension emptyExtensions
+
+emptyExtensions :: Extensions
+emptyExtensions = Extensions 0
+
+extensionEnabled :: Extension -> Extensions -> Bool
+extensionEnabled x (Extensions exts) = testBit exts (fromEnum x)
+
+enableExtension :: Extension -> Extensions -> Extensions
+enableExtension x (Extensions exts) = Extensions (setBit exts (fromEnum x))
+
+disableExtension :: Extension -> Extensions -> Extensions
+disableExtension x (Extensions exts) = Extensions (clearBit exts (fromEnum x))
+
+-- | Individually selectable syntax extensions.
+data Extension =
+ Ext_footnotes -- ^ Pandoc/PHP/MMD style footnotes
+ | Ext_inline_notes -- ^ Pandoc-style inline notes
+ | Ext_pandoc_title_block -- ^ Pandoc title block
+ | Ext_yaml_metadata_block -- ^ YAML metadata block
+ | Ext_mmd_title_block -- ^ Multimarkdown metadata block
+ | Ext_table_captions -- ^ Pandoc-style table captions
+ | Ext_implicit_figures -- ^ A paragraph with just an image is a figure
+ | Ext_simple_tables -- ^ Pandoc-style simple tables
+ | Ext_multiline_tables -- ^ Pandoc-style multiline tables
+ | Ext_grid_tables -- ^ Grid tables (pandoc, reST)
+ | Ext_pipe_tables -- ^ Pipe tables (as in PHP markdown extra)
+ | Ext_citations -- ^ Pandoc/citeproc citations
+ | Ext_raw_tex -- ^ Allow raw TeX (other than math)
+ | Ext_raw_html -- ^ Allow raw HTML
+ | Ext_tex_math_dollars -- ^ TeX math between $..$ or $$..$$
+ | Ext_tex_math_single_backslash -- ^ TeX math btw \(..\) \[..\]
+ | Ext_tex_math_double_backslash -- ^ TeX math btw \\(..\\) \\[..\\]
+ | Ext_latex_macros -- ^ Parse LaTeX macro definitions (for math only)
+ | Ext_fenced_code_blocks -- ^ Parse fenced code blocks
+ | Ext_fenced_code_attributes -- ^ Allow attributes on fenced code blocks
+ | Ext_backtick_code_blocks -- ^ GitHub style ``` code blocks
+ | Ext_inline_code_attributes -- ^ Allow attributes on inline code
+ | Ext_markdown_in_html_blocks -- ^ Interpret as markdown inside HTML blocks
+ | Ext_native_divs -- ^ Use Div blocks for contents of <div> tags
+ | Ext_native_spans -- ^ Use Span inlines for contents of <span>
+ | Ext_bracketed_spans -- ^ Bracketed spans with attributes
+ | Ext_markdown_attribute -- ^ Interpret text inside HTML as markdown
+ -- iff container has attribute 'markdown'
+ | Ext_escaped_line_breaks -- ^ Treat a backslash at EOL as linebreak
+ | Ext_link_attributes -- ^ link and image attributes
+ | Ext_mmd_link_attributes -- ^ MMD style reference link attributes
+ | Ext_autolink_bare_uris -- ^ Make all absolute URIs into links
+ | Ext_fancy_lists -- ^ Enable fancy list numbers and delimiters
+ | Ext_lists_without_preceding_blankline -- ^ Allow lists without preceding blank
+ | Ext_startnum -- ^ Make start number of ordered list significant
+ | Ext_definition_lists -- ^ Definition lists as in pandoc, mmd, php
+ | Ext_compact_definition_lists -- ^ Definition lists without
+ -- space between items, and disallow laziness
+ | Ext_example_lists -- ^ Markdown-style numbered examples
+ | Ext_all_symbols_escapable -- ^ Make all non-alphanumerics escapable
+ | Ext_angle_brackets_escapable -- ^ Make < and > escapable
+ | Ext_intraword_underscores -- ^ Treat underscore inside word as literal
+ | Ext_blank_before_blockquote -- ^ Require blank line before a blockquote
+ | Ext_blank_before_header -- ^ Require blank line before a header
+ | Ext_strikeout -- ^ Strikeout using ~~this~~ syntax
+ | Ext_superscript -- ^ Superscript using ^this^ syntax
+ | Ext_subscript -- ^ Subscript using ~this~ syntax
+ | Ext_hard_line_breaks -- ^ All newlines become hard line breaks
+ | Ext_ignore_line_breaks -- ^ Newlines in paragraphs are ignored
+ | Ext_east_asian_line_breaks -- ^ Newlines in paragraphs are ignored between
+ -- East Asian wide characters
+ | Ext_literate_haskell -- ^ Enable literate Haskell conventions
+ | Ext_abbreviations -- ^ PHP markdown extra abbreviation definitions
+ | Ext_emoji -- ^ Support emoji like :smile:
+ | Ext_auto_identifiers -- ^ Automatic identifiers for headers
+ | Ext_ascii_identifiers -- ^ ascii-only identifiers for headers
+ | Ext_header_attributes -- ^ Explicit header attributes {#id .class k=v}
+ | Ext_mmd_header_identifiers -- ^ Multimarkdown style header identifiers [myid]
+ | Ext_implicit_header_references -- ^ Implicit reference links for headers
+ | Ext_line_blocks -- ^ RST style line blocks
+ | Ext_epub_html_exts -- ^ Recognise the EPUB extended version of HTML
+ | Ext_shortcut_reference_links -- ^ Shortcut reference links
+ | Ext_smart -- ^ "Smart" quotes, apostrophes, ellipses, dashes
+ | Ext_old_dashes -- ^ -- = em, - before number = en
+ deriving (Show, Read, Enum, Eq, Ord, Bounded, Data, Typeable, Generic)
+
+pandocExtensions :: Extensions
+pandocExtensions = extensionsFromList
+ [ Ext_footnotes
+ , Ext_inline_notes
+ , Ext_pandoc_title_block
+ , Ext_yaml_metadata_block
+ , Ext_table_captions
+ , Ext_implicit_figures
+ , Ext_simple_tables
+ , Ext_multiline_tables
+ , Ext_grid_tables
+ , Ext_pipe_tables
+ , Ext_citations
+ , Ext_raw_tex
+ , Ext_raw_html
+ , Ext_tex_math_dollars
+ , Ext_latex_macros
+ , Ext_fenced_code_blocks
+ , Ext_fenced_code_attributes
+ , Ext_backtick_code_blocks
+ , Ext_inline_code_attributes
+ , Ext_markdown_in_html_blocks
+ , Ext_native_divs
+ , Ext_native_spans
+ , Ext_bracketed_spans
+ , Ext_escaped_line_breaks
+ , Ext_fancy_lists
+ , Ext_startnum
+ , Ext_definition_lists
+ , Ext_example_lists
+ , Ext_all_symbols_escapable
+ , Ext_intraword_underscores
+ , Ext_blank_before_blockquote
+ , Ext_blank_before_header
+ , Ext_strikeout
+ , Ext_superscript
+ , Ext_subscript
+ , Ext_auto_identifiers
+ , Ext_header_attributes
+ , Ext_link_attributes
+ , Ext_implicit_header_references
+ , Ext_line_blocks
+ , Ext_shortcut_reference_links
+ , Ext_smart
+ ]
+
+plainExtensions :: Extensions
+plainExtensions = extensionsFromList
+ [ Ext_table_captions
+ , Ext_implicit_figures
+ , Ext_simple_tables
+ , Ext_multiline_tables
+ , Ext_grid_tables
+ , Ext_latex_macros
+ , Ext_fancy_lists
+ , Ext_startnum
+ , Ext_definition_lists
+ , Ext_example_lists
+ , Ext_intraword_underscores
+ , Ext_blank_before_blockquote
+ , Ext_blank_before_header
+ , Ext_strikeout
+ ]
+
+phpMarkdownExtraExtensions :: Extensions
+phpMarkdownExtraExtensions = extensionsFromList
+ [ Ext_footnotes
+ , Ext_pipe_tables
+ , Ext_raw_html
+ , Ext_markdown_attribute
+ , Ext_fenced_code_blocks
+ , Ext_definition_lists
+ , Ext_intraword_underscores
+ , Ext_header_attributes
+ , Ext_link_attributes
+ , Ext_abbreviations
+ , Ext_shortcut_reference_links
+ ]
+
+githubMarkdownExtensions :: Extensions
+githubMarkdownExtensions = extensionsFromList
+ [ Ext_angle_brackets_escapable
+ , Ext_pipe_tables
+ , Ext_raw_html
+ , Ext_fenced_code_blocks
+ , Ext_auto_identifiers
+ , Ext_ascii_identifiers
+ , Ext_backtick_code_blocks
+ , Ext_autolink_bare_uris
+ , Ext_intraword_underscores
+ , Ext_strikeout
+ , Ext_hard_line_breaks
+ , Ext_emoji
+ , Ext_lists_without_preceding_blankline
+ , Ext_shortcut_reference_links
+ ]
+
+multimarkdownExtensions :: Extensions
+multimarkdownExtensions = extensionsFromList
+ [ Ext_pipe_tables
+ , Ext_raw_html
+ , Ext_markdown_attribute
+ , Ext_mmd_link_attributes
+ -- , Ext_raw_tex
+ -- Note: MMD's raw TeX syntax requires raw TeX to be
+ -- enclosed in HTML comment
+ , Ext_tex_math_double_backslash
+ , Ext_intraword_underscores
+ , Ext_mmd_title_block
+ , Ext_footnotes
+ , Ext_definition_lists
+ , Ext_all_symbols_escapable
+ , Ext_implicit_header_references
+ , Ext_auto_identifiers
+ , Ext_mmd_header_identifiers
+ , Ext_implicit_figures
+ -- Note: MMD's syntax for superscripts and subscripts
+ -- is a bit more permissive than pandoc's, allowing
+ -- e^2 and a~1 instead of e^2^ and a~1~, so even with
+ -- these options we don't have full support for MMD
+ -- superscripts and subscripts, but there's no reason
+ -- not to include these:
+ , Ext_superscript
+ , Ext_subscript
+ ]
+
+strictExtensions :: Extensions
+strictExtensions = extensionsFromList
+ [ Ext_raw_html
+ , Ext_shortcut_reference_links
+ ]
+
diff --git a/src/Text/Pandoc/Highlighting.hs b/src/Text/Pandoc/Highlighting.hs
new file mode 100644
index 000000000..df060915c
--- /dev/null
+++ b/src/Text/Pandoc/Highlighting.hs
@@ -0,0 +1,223 @@
+{-
+Copyright (C) 2008-2016 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.Highlighting
+ Copyright : Copyright (C) 2008-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Exports functions for syntax highlighting.
+-}
+
+module Text.Pandoc.Highlighting ( highlightingStyles
+ , languages
+ , languagesByExtension
+ , highlight
+ , formatLaTeXInline
+ , formatLaTeXBlock
+ , styleToLaTeX
+ , formatHtmlInline
+ , formatHtmlBlock
+ , styleToCss
+ , pygments
+ , espresso
+ , zenburn
+ , tango
+ , kate
+ , monochrome
+ , haddock
+ , Style
+ , fromListingsLanguage
+ , toListingsLanguage
+ ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Shared (safeRead)
+import Skylighting
+import Data.Maybe (fromMaybe)
+import Data.Char (toLower)
+import qualified Data.Map as M
+import Control.Monad
+import qualified Data.Text as T
+
+highlightingStyles :: [(String, Style)]
+highlightingStyles =
+ [("pygments", pygments),
+ ("tango", tango),
+ ("espresso", espresso),
+ ("zenburn", zenburn),
+ ("kate", kate),
+ ("monochrome", monochrome),
+ ("breezedark", breezeDark),
+ ("haddock", haddock)]
+
+languages :: [String]
+languages = [T.unpack (T.toLower (sName s)) | s <- M.elems defaultSyntaxMap]
+
+languagesByExtension :: String -> [String]
+languagesByExtension ext =
+ [T.unpack (T.toLower (sName s)) | s <- syntaxesByExtension defaultSyntaxMap ext]
+
+highlight :: (FormatOptions -> [SourceLine] -> a) -- ^ Formatter
+ -> Attr -- ^ Attributes of the CodeBlock
+ -> String -- ^ Raw contents of the CodeBlock
+ -> Maybe a -- ^ Maybe the formatted result
+highlight formatter (_, classes, keyvals) rawCode =
+ let firstNum = fromMaybe 1 (safeRead (fromMaybe "1" $ lookup "startFrom" keyvals))
+ fmtOpts = defaultFormatOpts{
+ startNumber = firstNum,
+ numberLines = any (`elem`
+ ["number","numberLines", "number-lines"]) classes }
+ tokenizeOpts = TokenizerConfig{ syntaxMap = defaultSyntaxMap
+ , traceOutput = False }
+ classes' = map T.pack classes
+ rawCode' = T.pack rawCode
+ in case msum (map (\l -> lookupSyntax l defaultSyntaxMap) classes') of
+ Nothing
+ | numberLines fmtOpts -> Just
+ $ formatter fmtOpts{ codeClasses = [],
+ containerClasses = classes' }
+ $ map (\ln -> [(NormalTok, ln)]) $ T.lines rawCode'
+ | otherwise -> Nothing
+ Just syntax ->
+ case tokenize tokenizeOpts syntax rawCode' of
+ Right slines -> Just $
+ formatter fmtOpts{ codeClasses =
+ [T.toLower (sShortname syntax)],
+ containerClasses = classes' } slines
+ Left _ -> Nothing
+
+-- Functions for correlating latex listings package's language names
+-- with skylighting language names:
+
+langToListingsMap :: M.Map String String
+langToListingsMap = M.fromList langsList
+
+listingsToLangMap :: M.Map String String
+listingsToLangMap = M.fromList $ map switch langsList
+ where switch (a,b) = (b,a)
+
+langsList :: [(String, String)]
+langsList =
+ [("abap","ABAP"),
+ ("acm","ACM"),
+ ("acmscript","ACMscript"),
+ ("acsl","ACSL"),
+ ("ada","Ada"),
+ ("algol","Algol"),
+ ("ant","Ant"),
+ ("assembler","Assembler"),
+ ("gnuassembler","Assembler"),
+ ("awk","Awk"),
+ ("bash","bash"),
+ ("monobasic","Basic"),
+ ("purebasic","Basic"),
+ ("c","C"),
+ ("cpp","C++"),
+ ("c++","C++"),
+ ("ocaml","Caml"),
+ ("cil","CIL"),
+ ("clean","Clean"),
+ ("cobol","Cobol"),
+ ("comal80","Comal80"),
+ ("command.com","command.com"),
+ ("comsol","Comsol"),
+ ("csh","csh"),
+ ("delphi","Delphi"),
+ ("elan","Elan"),
+ ("erlang","erlang"),
+ ("euphoria","Euphoria"),
+ ("fortran","Fortran"),
+ ("gap","GAP"),
+ ("gcl","GCL"),
+ ("gnuplot","Gnuplot"),
+ ("hansl","hansl"),
+ ("haskell","Haskell"),
+ ("html","HTML"),
+ ("idl","IDL"),
+ ("inform","inform"),
+ ("java","Java"),
+ ("jvmis","JVMIS"),
+ ("ksh","ksh"),
+ ("lingo","Lingo"),
+ ("lisp","Lisp"),
+ ("commonlisp","Lisp"),
+ ("llvm","LLVM"),
+ ("logo","Logo"),
+ ("lua","Lua"),
+ ("make","make"),
+ ("makefile","make"),
+ ("mathematica","Mathematica"),
+ ("matlab","Matlab"),
+ ("mercury","Mercury"),
+ ("metapost","MetaPost"),
+ ("miranda","Miranda"),
+ ("mizar","Mizar"),
+ ("ml","ML"),
+ ("modula2","Modula-2"),
+ ("mupad","MuPAD"),
+ ("nastran","NASTRAN"),
+ ("oberon2","Oberon-2"),
+ ("ocl","OCL"),
+ ("octave","Octave"),
+ ("oz","Oz"),
+ ("pascal","Pascal"),
+ ("perl","Perl"),
+ ("php","PHP"),
+ ("pli","PL/I"),
+ ("plasm","Plasm"),
+ ("postscript","PostScript"),
+ ("pov","POV"),
+ ("prolog","Prolog"),
+ ("promela","Promela"),
+ ("pstricks","PSTricks"),
+ ("python","Python"),
+ ("r","R"),
+ ("reduce","Reduce"),
+ ("rexx","Rexx"),
+ ("rsl","RSL"),
+ ("ruby","Ruby"),
+ ("s","S"),
+ ("sas","SAS"),
+ ("scala","Scala"),
+ ("scilab","Scilab"),
+ ("sh","sh"),
+ ("shelxl","SHELXL"),
+ ("simula","Simula"),
+ ("sparql","SPARQL"),
+ ("sql","SQL"),
+ ("tcl","tcl"),
+ ("tex","TeX"),
+ ("latex","TeX"),
+ ("vbscript","VBScript"),
+ ("verilog","Verilog"),
+ ("vhdl","VHDL"),
+ ("vrml","VRML"),
+ ("xml","XML"),
+ ("xslt","XSLT")]
+
+-- | Determine listings language name from skylighting language name.
+toListingsLanguage :: String -> Maybe String
+toListingsLanguage lang = M.lookup (map toLower lang) langToListingsMap
+
+-- | Determine skylighting language name from listings language name.
+fromListingsLanguage :: String -> Maybe String
+fromListingsLanguage lang = M.lookup lang listingsToLangMap
diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs
new file mode 100644
index 000000000..cc22c06ca
--- /dev/null
+++ b/src/Text/Pandoc/ImageSize.hs
@@ -0,0 +1,547 @@
+{-# LANGUAGE OverloadedStrings, ScopedTypeVariables, CPP #-}
+{-# OPTIONS_GHC -fno-warn-type-defaults #-}
+{-
+ Copyright (C) 2011-2016 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.ImageSize
+Copyright : Copyright (C) 2011-2016 John MacFarlane
+License : GNU GPL, version 2 or above
+
+Maintainer : John MacFarlane <jgm@berkeley.edu>
+Stability : alpha
+Portability : portable
+
+Functions for determining the size of a PNG, JPEG, or GIF image.
+-}
+module Text.Pandoc.ImageSize ( ImageType(..)
+ , imageType
+ , imageSize
+ , sizeInPixels
+ , sizeInPoints
+ , desiredSizeInPoints
+ , Dimension(..)
+ , Direction(..)
+ , dimension
+ , inInch
+ , inPoints
+ , numUnit
+ , showInInch
+ , showInPixel
+ , showFl
+ ) where
+import Data.ByteString (ByteString, unpack)
+import qualified Data.ByteString.Char8 as B
+import qualified Data.ByteString.Lazy as BL
+import Data.Char (isDigit)
+import Control.Monad
+import Data.Bits
+import Data.Binary
+import Data.Binary.Get
+import Text.Pandoc.Shared (safeRead)
+import Data.Default (Default)
+import Numeric (showFFloat)
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import qualified Data.Map as M
+import Control.Monad.Except
+import Data.Maybe (fromMaybe)
+
+-- quick and dirty functions to get image sizes
+-- algorithms borrowed from wwwis.pl
+
+data ImageType = Png | Gif | Jpeg | Pdf | Eps deriving Show
+data Direction = Width | Height
+instance Show Direction where
+ show Width = "width"
+ show Height = "height"
+
+data Dimension = Pixel Integer
+ | Centimeter Double
+ | Inch Double
+ | Percent Double
+instance Show Dimension where
+ show (Pixel a) = show a ++ "px"
+ show (Centimeter a) = showFl a ++ "cm"
+ show (Inch a) = showFl a ++ "in"
+ show (Percent a) = show a ++ "%"
+
+data ImageSize = ImageSize{
+ pxX :: Integer
+ , pxY :: Integer
+ , dpiX :: Integer
+ , dpiY :: Integer
+ } deriving (Read, Show, Eq)
+instance Default ImageSize where
+ def = ImageSize 300 200 72 72
+
+showFl :: (RealFloat a) => a -> String
+showFl a = showFFloat (Just 5) a ""
+
+imageType :: ByteString -> Maybe ImageType
+imageType img = case B.take 4 img of
+ "\x89\x50\x4e\x47" -> return Png
+ "\x47\x49\x46\x38" -> return Gif
+ "\xff\xd8\xff\xe0" -> return Jpeg -- JFIF
+ "\xff\xd8\xff\xe1" -> return Jpeg -- Exif
+ "%PDF" -> return Pdf
+ "%!PS"
+ | (B.take 4 $ B.drop 1 $ B.dropWhile (/=' ') img) == "EPSF"
+ -> return Eps
+ _ -> mzero
+
+imageSize :: ByteString -> Either String ImageSize
+imageSize img =
+ case imageType img of
+ Just Png -> mbToEither "could not determine PNG size" $ pngSize img
+ Just Gif -> mbToEither "could not determine GIF size" $ gifSize img
+ Just Jpeg -> jpegSize img
+ Just Eps -> mbToEither "could not determine EPS size" $ epsSize img
+ Just Pdf -> Left "could not determine PDF size" -- TODO
+ Nothing -> Left "could not determine image type"
+ where mbToEither msg Nothing = Left msg
+ mbToEither _ (Just x) = Right x
+
+defaultSize :: (Integer, Integer)
+defaultSize = (72, 72)
+
+sizeInPixels :: ImageSize -> (Integer, Integer)
+sizeInPixels s = (pxX s, pxY s)
+
+-- | Calculate (height, width) in points using the image file's dpi metadata,
+-- using 72 Points == 1 Inch.
+sizeInPoints :: ImageSize -> (Double, Double)
+sizeInPoints s = (pxXf * 72 / dpiXf, pxYf * 72 / dpiYf)
+ where
+ pxXf = fromIntegral $ pxX s
+ pxYf = fromIntegral $ pxY s
+ dpiXf = fromIntegral $ dpiX s
+ dpiYf = fromIntegral $ dpiY s
+
+-- | Calculate (height, width) in points, considering the desired dimensions in the
+-- attribute, while falling back on the image file's dpi metadata if no dimensions
+-- are specified in the attribute (or only dimensions in percentages).
+desiredSizeInPoints :: WriterOptions -> Attr -> ImageSize -> (Double, Double)
+desiredSizeInPoints opts attr s =
+ case (getDim Width, getDim Height) of
+ (Just w, Just h) -> (w, h)
+ (Just w, Nothing) -> (w, w / ratio)
+ (Nothing, Just h) -> (h * ratio, h)
+ (Nothing, Nothing) -> sizeInPoints s
+ where
+ ratio = fromIntegral (pxX s) / fromIntegral (pxY s)
+ getDim dir = case (dimension dir attr) of
+ Just (Percent _) -> Nothing
+ Just dim -> Just $ inPoints opts dim
+ Nothing -> Nothing
+
+inPoints :: WriterOptions -> Dimension -> Double
+inPoints opts dim = 72 * inInch opts dim
+
+inInch :: WriterOptions -> Dimension -> Double
+inInch opts dim =
+ case dim of
+ (Pixel a) -> fromIntegral a / (fromIntegral $ writerDpi opts)
+ (Centimeter a) -> a * 0.3937007874
+ (Inch a) -> a
+ (Percent _) -> 0
+
+-- | Convert a Dimension to a String denoting its equivalent in inches, for example "2.00000".
+-- Note: Dimensions in percentages are converted to the empty string.
+showInInch :: WriterOptions -> Dimension -> String
+showInInch _ (Percent _) = ""
+showInInch opts dim = showFl $ inInch opts dim
+
+-- | Convert a Dimension to a String denoting its equivalent in pixels, for example "600".
+-- Note: Dimensions in percentages are converted to the empty string.
+showInPixel :: WriterOptions -> Dimension -> String
+showInPixel opts dim =
+ case dim of
+ (Pixel a) -> show a
+ (Centimeter a) -> show (floor $ dpi * a * 0.3937007874 :: Int)
+ (Inch a) -> show (floor $ dpi * a :: Int)
+ (Percent _) -> ""
+ where
+ dpi = fromIntegral $ writerDpi opts
+
+-- | Maybe split a string into a leading number and trailing unit, e.g. "3cm" to Just (3.0, "cm")
+numUnit :: String -> Maybe (Double, String)
+numUnit s =
+ let (nums, unit) = span (\c -> isDigit c || ('.'==c)) s
+ in case safeRead nums of
+ Just n -> Just (n, unit)
+ Nothing -> Nothing
+
+-- | Read a Dimension from an Attr attribute.
+-- `dimension Width attr` might return `Just (Pixel 3)` or for example `Just (Centimeter 2.0)`, etc.
+dimension :: Direction -> Attr -> Maybe Dimension
+dimension dir (_, _, kvs) =
+ case dir of
+ Width -> extractDim "width"
+ Height -> extractDim "height"
+ where
+ extractDim key =
+ case lookup key kvs of
+ Just str ->
+ case numUnit str of
+ Just (num, unit) -> toDim num unit
+ Nothing -> Nothing
+ Nothing -> Nothing
+ toDim a "cm" = Just $ Centimeter a
+ toDim a "mm" = Just $ Centimeter (a / 10)
+ toDim a "in" = Just $ Inch a
+ toDim a "inch" = Just $ Inch a
+ toDim a "%" = Just $ Percent a
+ toDim a "px" = Just $ Pixel (floor a::Integer)
+ toDim a "" = Just $ Pixel (floor a::Integer)
+ toDim _ _ = Nothing
+
+epsSize :: ByteString -> Maybe ImageSize
+epsSize img = do
+ let ls = takeWhile ("%" `B.isPrefixOf`) $ B.lines img
+ let ls' = dropWhile (not . ("%%BoundingBox:" `B.isPrefixOf`)) ls
+ case ls' of
+ [] -> mzero
+ (x:_) -> case B.words x of
+ (_:_:_:ux:uy:[]) -> do
+ ux' <- safeRead $ B.unpack ux
+ uy' <- safeRead $ B.unpack uy
+ return ImageSize{
+ pxX = ux'
+ , pxY = uy'
+ , dpiX = 72
+ , dpiY = 72 }
+ _ -> mzero
+
+pngSize :: ByteString -> Maybe ImageSize
+pngSize img = do
+ let (h, rest) = B.splitAt 8 img
+ guard $ h == "\x8a\x4d\x4e\x47\x0d\x0a\x1a\x0a" ||
+ h == "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a"
+ let (i, rest') = B.splitAt 4 $ B.drop 4 rest
+ guard $ i == "MHDR" || i == "IHDR"
+ let (sizes, rest'') = B.splitAt 8 rest'
+ (x,y) <- case map fromIntegral $ unpack $ sizes of
+ ([w1,w2,w3,w4,h1,h2,h3,h4] :: [Integer]) -> return
+ ((shift w1 24) + (shift w2 16) + (shift w3 8) + w4,
+ (shift h1 24) + (shift h2 16) + (shift h3 8) + h4)
+ _ -> Nothing -- "PNG parse error"
+ let (dpix, dpiy) = findpHYs rest''
+ return $ ImageSize { pxX = x, pxY = y, dpiX = dpix, dpiY = dpiy }
+
+findpHYs :: ByteString -> (Integer, Integer)
+findpHYs x =
+ if B.null x || "IDAT" `B.isPrefixOf` x
+ then (72,72) -- default, no pHYs
+ else if "pHYs" `B.isPrefixOf` x
+ then let [x1,x2,x3,x4,y1,y2,y3,y4,u] = map fromIntegral
+ $ unpack $ B.take 9 $ B.drop 4 x
+ factor = if u == 1 -- dots per meter
+ then \z -> z * 254 `div` 10000
+ else const 72
+ in ( factor $ (shift x1 24) + (shift x2 16) + (shift x3 8) + x4,
+ factor $ (shift y1 24) + (shift y2 16) + (shift y3 8) + y4 )
+ else findpHYs $ B.drop 1 x -- read another byte
+
+gifSize :: ByteString -> Maybe ImageSize
+gifSize img = do
+ let (h, rest) = B.splitAt 6 img
+ guard $ h == "GIF87a" || h == "GIF89a"
+ case map fromIntegral $ unpack $ B.take 4 rest of
+ [w2,w1,h2,h1] -> return ImageSize {
+ pxX = shift w1 8 + w2,
+ pxY = shift h1 8 + h2,
+ dpiX = 72,
+ dpiY = 72
+ }
+ _ -> Nothing -- "GIF parse error"
+
+jpegSize :: ByteString -> Either String ImageSize
+jpegSize img =
+ let (hdr, rest) = B.splitAt 4 img
+ in if B.length rest < 14
+ then Left "unable to determine JPEG size"
+ else case hdr of
+ "\xff\xd8\xff\xe0" -> jfifSize rest
+ "\xff\xd8\xff\xe1" -> exifSize rest
+ _ -> Left "unable to determine JPEG size"
+
+jfifSize :: ByteString -> Either String ImageSize
+jfifSize rest =
+ let [dpiDensity,dpix1,dpix2,dpiy1,dpiy2] = map fromIntegral
+ $ unpack $ B.take 5 $ B.drop 9 $ rest
+ factor = case dpiDensity of
+ 1 -> id
+ 2 -> \x -> (x * 254 `div` 10)
+ _ -> const 72
+ dpix = factor (shift dpix1 8 + dpix2)
+ dpiy = factor (shift dpiy1 8 + dpiy2)
+ in case findJfifSize rest of
+ Left msg -> Left msg
+ Right (w,h) -> Right $ ImageSize { pxX = w
+ , pxY = h
+ , dpiX = dpix
+ , dpiY = dpiy }
+
+findJfifSize :: ByteString -> Either String (Integer,Integer)
+findJfifSize bs =
+ let bs' = B.dropWhile (=='\xff') $ B.dropWhile (/='\xff') bs
+ in case B.uncons bs' of
+ Just (c,bs'') | c >= '\xc0' && c <= '\xc3' ->
+ case map fromIntegral $ unpack $ B.take 4 $ B.drop 3 bs'' of
+ [h1,h2,w1,w2] -> Right (shift w1 8 + w2, shift h1 8 + h2)
+ _ -> Left "JFIF parse error"
+ Just (_,bs'') ->
+ case map fromIntegral $ unpack $ B.take 2 bs'' of
+ [c1,c2] ->
+ let len = shift c1 8 + c2
+ -- skip variables
+ in findJfifSize $ B.drop len bs''
+ _ -> Left "JFIF parse error"
+ Nothing -> Left "Did not find JFIF length record"
+
+runGet' :: Get (Either String a) -> BL.ByteString -> Either String a
+runGet' p bl =
+#if MIN_VERSION_binary(0,7,0)
+ case runGetOrFail p bl of
+ Left (_,_,msg) -> Left msg
+ Right (_,_,x) -> x
+#else
+ runGet p bl
+#endif
+
+
+exifSize :: ByteString -> Either String ImageSize
+exifSize bs = runGet' header $ bl
+ where bl = BL.fromChunks [bs]
+ header = runExceptT $ exifHeader bl
+-- NOTE: It would be nicer to do
+-- runGet ((Just <$> exifHeader) <|> return Nothing)
+-- which would prevent pandoc from raising an error when an exif header can't
+-- be parsed. But we only get an Alternative instance for Get in binary 0.6,
+-- and binary 0.5 ships with ghc 7.6.
+
+exifHeader :: BL.ByteString -> ExceptT String Get ImageSize
+exifHeader hdr = do
+ _app1DataSize <- lift getWord16be
+ exifHdr <- lift getWord32be
+ unless (exifHdr == 0x45786966) $ throwError "Did not find exif header"
+ zeros <- lift getWord16be
+ unless (zeros == 0) $ throwError "Expected zeros after exif header"
+ -- beginning of tiff header -- we read whole thing to use
+ -- in getting data from offsets:
+ let tiffHeader = BL.drop 8 hdr
+ byteAlign <- lift getWord16be
+ let bigEndian = byteAlign == 0x4d4d
+ let (getWord16, getWord32, getWord64) =
+ if bigEndian
+ then (getWord16be, getWord32be, getWord64be)
+ else (getWord16le, getWord32le, getWord64le)
+ let getRational = do
+ num <- getWord32
+ den <- getWord32
+ return $ fromIntegral num / fromIntegral den
+ tagmark <- lift getWord16
+ unless (tagmark == 0x002a) $ throwError "Failed alignment sanity check"
+ ifdOffset <- lift getWord32
+ lift $ skip (fromIntegral ifdOffset - 8) -- skip to IDF
+ numentries <- lift getWord16
+ let ifdEntry :: ExceptT String Get (TagType, DataFormat)
+ ifdEntry = do
+ tag <- fromMaybe UnknownTagType . flip M.lookup tagTypeTable
+ <$> lift getWord16
+ dataFormat <- lift getWord16
+ numComponents <- lift getWord32
+ (fmt, bytesPerComponent) <-
+ case dataFormat of
+ 1 -> return (UnsignedByte <$> getWord8, 1)
+ 2 -> return (AsciiString <$>
+ getLazyByteString
+ (fromIntegral numComponents), 1)
+ 3 -> return (UnsignedShort <$> getWord16, 2)
+ 4 -> return (UnsignedLong <$> getWord32, 4)
+ 5 -> return (UnsignedRational <$> getRational, 8)
+ 6 -> return (SignedByte <$> getWord8, 1)
+ 7 -> return (Undefined <$> getLazyByteString
+ (fromIntegral numComponents), 1)
+ 8 -> return (SignedShort <$> getWord16, 2)
+ 9 -> return (SignedLong <$> getWord32, 4)
+ 10 -> return (SignedRational <$> getRational, 8)
+ 11 -> return (SingleFloat <$> getWord32 {- TODO -}, 4)
+ 12 -> return (DoubleFloat <$> getWord64 {- TODO -}, 8)
+ _ -> throwError $ "Unknown data format " ++ show dataFormat
+ let totalBytes = fromIntegral $ numComponents * bytesPerComponent
+ payload <- if totalBytes <= 4 -- data is right here
+ then lift $ fmt <* skip (4 - totalBytes)
+ else do -- get data from offset
+ offs <- lift getWord32
+ let bytesAtOffset =
+ BL.take (fromIntegral totalBytes)
+ $ BL.drop (fromIntegral offs) tiffHeader
+ case runGet' (Right <$> fmt) bytesAtOffset of
+ Left msg -> throwError msg
+ Right x -> return x
+ return (tag, payload)
+ entries <- sequence $ replicate (fromIntegral numentries) ifdEntry
+ subentries <- case lookup ExifOffset entries of
+ Just (UnsignedLong offset') -> do
+ pos <- lift bytesRead
+ lift $ skip (fromIntegral offset' - (fromIntegral pos - 8))
+ numsubentries <- lift getWord16
+ sequence $
+ replicate (fromIntegral numsubentries) ifdEntry
+ _ -> return []
+ let allentries = entries ++ subentries
+ (wdth, hght) <- case (lookup ExifImageWidth allentries,
+ lookup ExifImageHeight allentries) of
+ (Just (UnsignedLong w), Just (UnsignedLong h)) ->
+ return (fromIntegral w, fromIntegral h)
+ _ -> return defaultSize
+ -- we return a default width and height when
+ -- the exif header doesn't contain these
+ let resfactor = case lookup ResolutionUnit allentries of
+ Just (UnsignedShort 1) -> (100 / 254)
+ _ -> 1
+ let xres = maybe 72 (\(UnsignedRational x) -> floor $ x * resfactor)
+ $ lookup XResolution allentries
+ let yres = maybe 72 (\(UnsignedRational x) -> floor $ x * resfactor)
+ $ lookup YResolution allentries
+ return $ ImageSize{
+ pxX = wdth
+ , pxY = hght
+ , dpiX = xres
+ , dpiY = yres }
+
+data DataFormat = UnsignedByte Word8
+ | AsciiString BL.ByteString
+ | UnsignedShort Word16
+ | UnsignedLong Word32
+ | UnsignedRational Rational
+ | SignedByte Word8
+ | Undefined BL.ByteString
+ | SignedShort Word16
+ | SignedLong Word32
+ | SignedRational Rational
+ | SingleFloat Word32
+ | DoubleFloat Word64
+ deriving (Show)
+
+data TagType = ImageDescription
+ | Make
+ | Model
+ | Orientation
+ | XResolution
+ | YResolution
+ | ResolutionUnit
+ | Software
+ | DateTime
+ | WhitePoint
+ | PrimaryChromaticities
+ | YCbCrCoefficients
+ | YCbCrPositioning
+ | ReferenceBlackWhite
+ | Copyright
+ | ExifOffset
+ | ExposureTime
+ | FNumber
+ | ExposureProgram
+ | ISOSpeedRatings
+ | ExifVersion
+ | DateTimeOriginal
+ | DateTimeDigitized
+ | ComponentConfiguration
+ | CompressedBitsPerPixel
+ | ShutterSpeedValue
+ | ApertureValue
+ | BrightnessValue
+ | ExposureBiasValue
+ | MaxApertureValue
+ | SubjectDistance
+ | MeteringMode
+ | LightSource
+ | Flash
+ | FocalLength
+ | MakerNote
+ | UserComment
+ | FlashPixVersion
+ | ColorSpace
+ | ExifImageWidth
+ | ExifImageHeight
+ | RelatedSoundFile
+ | ExifInteroperabilityOffset
+ | FocalPlaneXResolution
+ | FocalPlaneYResolution
+ | FocalPlaneResolutionUnit
+ | SensingMethod
+ | FileSource
+ | SceneType
+ | UnknownTagType
+ deriving (Show, Eq, Ord)
+
+tagTypeTable :: M.Map Word16 TagType
+tagTypeTable = M.fromList
+ [ (0x010e, ImageDescription)
+ , (0x010f, Make)
+ , (0x0110, Model)
+ , (0x0112, Orientation)
+ , (0x011a, XResolution)
+ , (0x011b, YResolution)
+ , (0x0128, ResolutionUnit)
+ , (0x0131, Software)
+ , (0x0132, DateTime)
+ , (0x013e, WhitePoint)
+ , (0x013f, PrimaryChromaticities)
+ , (0x0211, YCbCrCoefficients)
+ , (0x0213, YCbCrPositioning)
+ , (0x0214, ReferenceBlackWhite)
+ , (0x8298, Copyright)
+ , (0x8769, ExifOffset)
+ , (0x829a, ExposureTime)
+ , (0x829d, FNumber)
+ , (0x8822, ExposureProgram)
+ , (0x8827, ISOSpeedRatings)
+ , (0x9000, ExifVersion)
+ , (0x9003, DateTimeOriginal)
+ , (0x9004, DateTimeDigitized)
+ , (0x9101, ComponentConfiguration)
+ , (0x9102, CompressedBitsPerPixel)
+ , (0x9201, ShutterSpeedValue)
+ , (0x9202, ApertureValue)
+ , (0x9203, BrightnessValue)
+ , (0x9204, ExposureBiasValue)
+ , (0x9205, MaxApertureValue)
+ , (0x9206, SubjectDistance)
+ , (0x9207, MeteringMode)
+ , (0x9208, LightSource)
+ , (0x9209, Flash)
+ , (0x920a, FocalLength)
+ , (0x927c, MakerNote)
+ , (0x9286, UserComment)
+ , (0xa000, FlashPixVersion)
+ , (0xa001, ColorSpace)
+ , (0xa002, ExifImageWidth)
+ , (0xa003, ExifImageHeight)
+ , (0xa004, RelatedSoundFile)
+ , (0xa005, ExifInteroperabilityOffset)
+ , (0xa20e, FocalPlaneXResolution)
+ , (0xa20f, FocalPlaneYResolution)
+ , (0xa210, FocalPlaneResolutionUnit)
+ , (0xa217, SensingMethod)
+ , (0xa300, FileSource)
+ , (0xa301, SceneType)
+ ]
diff --git a/src/Text/Pandoc/Logging.hs b/src/Text/Pandoc/Logging.hs
new file mode 100644
index 000000000..1f98d019e
--- /dev/null
+++ b/src/Text/Pandoc/Logging.hs
@@ -0,0 +1,232 @@
+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric, OverloadedStrings #-}
+{-
+Copyright (C) 2016-17 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.Logging
+ Copyright : Copyright (C) 2006-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+This module provides data types and functions for warnings
+and info messages.
+
+-}
+module Text.Pandoc.Logging (
+ Verbosity(..)
+ , LogMessage(..)
+ , encodeLogMessages
+ , showLogMessage
+ , messageVerbosity
+ ) where
+
+import Text.Parsec.Pos
+import Data.Data (Data)
+import Data.Generics (Typeable)
+import GHC.Generics (Generic)
+import qualified Data.Text as Text
+import Data.Aeson
+import Text.Pandoc.Definition
+import Data.Aeson.Encode.Pretty (encodePretty', keyOrder,
+ defConfig, Config(..))
+import qualified Data.ByteString.Lazy as BL
+
+-- | Verbosity level.
+data Verbosity = ERROR | WARNING | INFO | DEBUG
+ deriving (Show, Read, Eq, Data, Enum, Ord, Bounded, Typeable, Generic)
+
+instance ToJSON Verbosity where
+ toJSON x = toJSON (show x)
+
+data LogMessage =
+ SkippedContent String SourcePos
+ | CouldNotParseYamlMetadata String SourcePos
+ | DuplicateLinkReference String SourcePos
+ | DuplicateNoteReference String SourcePos
+ | ReferenceNotFound String SourcePos
+ | CircularReference String SourcePos
+ | ParsingUnescaped String SourcePos
+ | CouldNotLoadIncludeFile String SourcePos
+ | ParsingTrace String SourcePos
+ | InlineNotRendered Inline
+ | BlockNotRendered Block
+ | DocxParserWarning String
+ | CouldNotFetchResource String String
+ | CouldNotDetermineImageSize String String
+ | CouldNotDetermineMimeType String
+ | CouldNotConvertTeXMath String String
+ deriving (Show, Eq, Data, Ord, Typeable, Generic)
+
+instance ToJSON LogMessage where
+ toJSON x = object $ "verbosity" .= toJSON (messageVerbosity x) :
+ case x of
+ SkippedContent s pos ->
+ ["type" .= String "SkippedContent",
+ "contents" .= Text.pack s,
+ "source" .= Text.pack (sourceName pos),
+ "line" .= sourceLine pos,
+ "column" .= sourceColumn pos]
+ CouldNotParseYamlMetadata s pos ->
+ ["type" .= String "YamlSectionNotAnObject",
+ "message" .= Text.pack s,
+ "source" .= Text.pack (sourceName pos),
+ "line" .= toJSON (sourceLine pos),
+ "column" .= toJSON (sourceColumn pos)]
+ DuplicateLinkReference s pos ->
+ ["type" .= String "DuplicateLinkReference",
+ "contents" .= Text.pack s,
+ "source" .= Text.pack (sourceName pos),
+ "line" .= toJSON (sourceLine pos),
+ "column" .= toJSON (sourceColumn pos)]
+ DuplicateNoteReference s pos ->
+ ["type" .= String "DuplicateNoteReference",
+ "contents" .= Text.pack s,
+ "source" .= Text.pack (sourceName pos),
+ "line" .= toJSON (sourceLine pos),
+ "column" .= toJSON (sourceColumn pos)]
+ ReferenceNotFound s pos ->
+ ["type" .= String "ReferenceNotFound",
+ "contents" .= Text.pack s,
+ "source" .= Text.pack (sourceName pos),
+ "line" .= toJSON (sourceLine pos),
+ "column" .= toJSON (sourceColumn pos)]
+ CircularReference s pos ->
+ ["type" .= String "CircularReference",
+ "contents" .= Text.pack s,
+ "source" .= Text.pack (sourceName pos),
+ "line" .= toJSON (sourceLine pos),
+ "column" .= toJSON (sourceColumn pos)]
+ ParsingUnescaped s pos ->
+ ["type" .= String "ParsingUnescaped",
+ "contents" .= Text.pack s,
+ "source" .= Text.pack (sourceName pos),
+ "line" .= toJSON (sourceLine pos),
+ "column" .= toJSON (sourceColumn pos)]
+ CouldNotLoadIncludeFile fp pos ->
+ ["type" .= String "CouldNotLoadIncludeFile",
+ "path" .= Text.pack fp,
+ "source" .= Text.pack (sourceName pos),
+ "line" .= toJSON (sourceLine pos),
+ "column" .= toJSON (sourceColumn pos)]
+ ParsingTrace s pos ->
+ ["type" .= String "ParsingTrace",
+ "contents" .= Text.pack s,
+ "source" .= Text.pack (sourceName pos),
+ "line" .= sourceLine pos,
+ "column" .= sourceColumn pos]
+ InlineNotRendered il ->
+ ["type" .= String "InlineNotRendered",
+ "contents" .= toJSON il]
+ BlockNotRendered bl ->
+ ["type" .= String "BlockNotRendered",
+ "contents" .= toJSON bl]
+ DocxParserWarning s ->
+ ["type" .= String "DocxParserWarning",
+ "contents" .= Text.pack s]
+ CouldNotFetchResource fp s ->
+ ["type" .= String "CouldNotFetchResource",
+ "path" .= Text.pack fp,
+ "message" .= Text.pack s]
+ CouldNotDetermineImageSize fp s ->
+ ["type" .= String "CouldNotDetermineImageSize",
+ "path" .= Text.pack fp,
+ "message" .= Text.pack s]
+ CouldNotDetermineMimeType fp ->
+ ["type" .= String "CouldNotDetermineMimeType",
+ "path" .= Text.pack fp]
+ CouldNotConvertTeXMath s msg ->
+ ["type" .= String "CouldNotConvertTeXMath",
+ "contents" .= Text.pack s,
+ "message" .= Text.pack msg]
+
+showPos :: SourcePos -> String
+showPos pos = sn ++ "line " ++
+ show (sourceLine pos) ++ " column " ++ show (sourceColumn pos)
+ where sn = if sourceName pos == "source" || sourceName pos == ""
+ then ""
+ else sourceName pos ++ " "
+
+encodeLogMessages :: [LogMessage] -> BL.ByteString
+encodeLogMessages ms =
+ encodePretty' defConfig{ confCompare =
+ keyOrder [ "type", "verbosity", "contents", "message", "path",
+ "source", "line", "column" ] } ms
+
+showLogMessage :: LogMessage -> String
+showLogMessage msg =
+ case msg of
+ SkippedContent s pos ->
+ "Skipped '" ++ s ++ "' at " ++ showPos pos
+ CouldNotParseYamlMetadata s pos ->
+ "Could not parse YAML metadata at " ++ showPos pos ++
+ if null s then "" else (": " ++ s)
+ DuplicateLinkReference s pos ->
+ "Duplicate link reference '" ++ s ++ "' at " ++ showPos pos
+ DuplicateNoteReference s pos ->
+ "Duplicate note reference '" ++ s ++ "' at " ++ showPos pos
+ ReferenceNotFound s pos ->
+ "Reference not found for '" ++ s ++ "' at " ++ showPos pos
+ CircularReference s pos ->
+ "Circular reference '" ++ s ++ "' at " ++ showPos pos
+ ParsingUnescaped s pos ->
+ "Parsing unescaped '" ++ s ++ "' at " ++ showPos pos
+ CouldNotLoadIncludeFile fp pos ->
+ "Could not load include file '" ++ fp ++ "' at " ++ showPos pos
+ ParsingTrace s pos ->
+ "Parsing trace at " ++ showPos pos ++ ": " ++ s
+ InlineNotRendered il ->
+ "Not rendering " ++ show il
+ BlockNotRendered bl ->
+ "Not rendering " ++ show bl
+ DocxParserWarning s ->
+ "Docx parser warning: " ++ s
+ CouldNotFetchResource fp s ->
+ "Could not fetch resource '" ++ fp ++ "'" ++
+ if null s then "" else (": " ++ s)
+ CouldNotDetermineImageSize fp s ->
+ "Could not determine image size for '" ++ fp ++ "'" ++
+ if null s then "" else (": " ++ s)
+ CouldNotDetermineMimeType fp ->
+ "Could not determine mime type for '" ++ fp ++ "'"
+ CouldNotConvertTeXMath s m ->
+ "Could not convert TeX math '" ++ s ++ "', rendering as TeX" ++
+ if null m then "" else (':':'\n':m)
+
+messageVerbosity:: LogMessage -> Verbosity
+messageVerbosity msg =
+ case msg of
+ SkippedContent{} -> INFO
+ CouldNotParseYamlMetadata{} -> WARNING
+ DuplicateLinkReference{} -> WARNING
+ DuplicateNoteReference{} -> WARNING
+ ReferenceNotFound{} -> WARNING
+ CircularReference{} -> WARNING
+ CouldNotLoadIncludeFile{} -> WARNING
+ ParsingUnescaped{} -> INFO
+ ParsingTrace{} -> DEBUG
+ InlineNotRendered{} -> INFO
+ BlockNotRendered{} -> INFO
+ DocxParserWarning{} -> WARNING
+ CouldNotFetchResource{} -> WARNING
+ CouldNotDetermineImageSize{} -> WARNING
+ CouldNotDetermineMimeType{} -> WARNING
+ CouldNotConvertTeXMath{} -> WARNING
+
+
diff --git a/src/Text/Pandoc/MIME.hs b/src/Text/Pandoc/MIME.hs
new file mode 100644
index 000000000..a08091217
--- /dev/null
+++ b/src/Text/Pandoc/MIME.hs
@@ -0,0 +1,527 @@
+{-
+Copyright (C) 2011-2016 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.MIME
+ Copyright : Copyright (C) 2011-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Mime type lookup for ODT writer.
+-}
+module Text.Pandoc.MIME ( MimeType, getMimeType, getMimeTypeDef,
+ extensionFromMimeType )where
+import System.FilePath
+import Data.Char ( toLower )
+import Data.List (isPrefixOf, isSuffixOf)
+import Data.Maybe (fromMaybe)
+import qualified Data.Map as M
+
+type MimeType = String
+
+-- | Determine mime type appropriate for file path.
+getMimeType :: FilePath -> Maybe MimeType
+getMimeType fp
+ -- ODT
+ | fp == "layout-cache" =
+ Just "application/binary"
+ | "Formula-" `isPrefixOf` fp && "/" `isSuffixOf` fp =
+ Just "application/vnd.oasis.opendocument.formula"
+ -- generic
+ | otherwise = M.lookup (map toLower $ drop 1 $ takeExtension fp) mimeTypes
+
+-- | Determime mime type appropriate for file path, defaulting to
+-- “application/octet-stream” if nothing else fits.
+getMimeTypeDef :: FilePath -> MimeType
+getMimeTypeDef = fromMaybe "application/octet-stream" . getMimeType
+
+extensionFromMimeType :: MimeType -> Maybe String
+extensionFromMimeType mimetype =
+ M.lookup (takeWhile (/=';') mimetype) reverseMimeTypes
+ -- note: we just look up the basic mime type, dropping the content-encoding etc.
+
+reverseMimeTypes :: M.Map MimeType String
+reverseMimeTypes = M.fromList $ map (\(k,v) -> (v,k)) mimeTypesList
+
+mimeTypes :: M.Map String MimeType
+mimeTypes = M.fromList mimeTypesList
+
+mimeTypesList :: [(String, MimeType)]
+mimeTypesList = -- List borrowed from happstack-server.
+ [("gz","application/x-gzip")
+ ,("cabal","application/x-cabal")
+ ,("%","application/x-trash")
+ ,("323","text/h323")
+ ,("3gp","video/3gpp")
+ ,("7z","application/x-7z-compressed")
+ ,("abw","application/x-abiword")
+ ,("ai","application/postscript")
+ ,("aif","audio/x-aiff")
+ ,("aifc","audio/x-aiff")
+ ,("aiff","audio/x-aiff")
+ ,("alc","chemical/x-alchemy")
+ ,("art","image/x-jg")
+ ,("asc","text/plain")
+ ,("asf","video/x-ms-asf")
+ ,("asn","chemical/x-ncbi-asn1")
+ ,("aso","chemical/x-ncbi-asn1-binary")
+ ,("asx","video/x-ms-asf")
+ ,("atom","application/atom")
+ ,("atomcat","application/atomcat+xml")
+ ,("atomsrv","application/atomserv+xml")
+ ,("au","audio/basic")
+ ,("avi","video/x-msvideo")
+ ,("b","chemical/x-molconn-Z")
+ ,("bak","application/x-trash")
+ ,("bat","application/x-msdos-program")
+ ,("bcpio","application/x-bcpio")
+ ,("bib","text/x-bibtex")
+ ,("bin","application/octet-stream")
+ ,("bmp","image/x-ms-bmp")
+ ,("boo","text/x-boo")
+ ,("book","application/x-maker")
+ ,("bsd","chemical/x-crossfire")
+ ,("c","text/x-csrc")
+ ,("c++","text/x-c++src")
+ ,("c3d","chemical/x-chem3d")
+ ,("cab","application/x-cab")
+ ,("cac","chemical/x-cache")
+ ,("cache","chemical/x-cache")
+ ,("cap","application/cap")
+ ,("cascii","chemical/x-cactvs-binary")
+ ,("cat","application/vnd.ms-pki.seccat")
+ ,("cbin","chemical/x-cactvs-binary")
+ ,("cbr","application/x-cbr")
+ ,("cbz","application/x-cbz")
+ ,("cc","text/x-c++src")
+ ,("cdf","application/x-cdf")
+ ,("cdr","image/x-coreldraw")
+ ,("cdt","image/x-coreldrawtemplate")
+ ,("cdx","chemical/x-cdx")
+ ,("cdy","application/vnd.cinderella")
+ ,("cef","chemical/x-cxf")
+ ,("cer","chemical/x-cerius")
+ ,("chm","chemical/x-chemdraw")
+ ,("chrt","application/x-kchart")
+ ,("cif","chemical/x-cif")
+ ,("class","application/java-vm")
+ ,("cls","text/x-tex")
+ ,("cmdf","chemical/x-cmdf")
+ ,("cml","chemical/x-cml")
+ ,("cod","application/vnd.rim.cod")
+ ,("com","application/x-msdos-program")
+ ,("cpa","chemical/x-compass")
+ ,("cpio","application/x-cpio")
+ ,("cpp","text/x-c++src")
+ ,("cpt","application/mac-compactpro")
+ ,("crl","application/x-pkcs7-crl")
+ ,("crt","application/x-x509-ca-cert")
+ ,("csf","chemical/x-cache-csf")
+ ,("csh","application/x-csh")
+ ,("csm","chemical/x-csml")
+ ,("csml","chemical/x-csml")
+ ,("css","text/css")
+ ,("csv","text/csv")
+ ,("ctab","chemical/x-cactvs-binary")
+ ,("ctx","chemical/x-ctx")
+ ,("cu","application/cu-seeme")
+ ,("cub","chemical/x-gaussian-cube")
+ ,("cxf","chemical/x-cxf")
+ ,("cxx","text/x-c++src")
+ ,("d","text/x-dsrc")
+ ,("dat","chemical/x-mopac-input")
+ ,("dcr","application/x-director")
+ ,("deb","application/x-debian-package")
+ ,("dif","video/dv")
+ ,("diff","text/x-diff")
+ ,("dir","application/x-director")
+ ,("djv","image/vnd.djvu")
+ ,("djvu","image/vnd.djvu")
+ ,("dl","video/dl")
+ ,("dll","application/x-msdos-program")
+ ,("dmg","application/x-apple-diskimage")
+ ,("dms","application/x-dms")
+ ,("doc","application/msword")
+ ,("dot","application/msword")
+ ,("dv","video/dv")
+ ,("dvi","application/x-dvi")
+ ,("dx","chemical/x-jcamp-dx")
+ ,("dxr","application/x-director")
+ ,("emb","chemical/x-embl-dl-nucleotide")
+ ,("embl","chemical/x-embl-dl-nucleotide")
+ ,("emf","image/x-emf")
+ ,("eml","message/rfc822")
+ ,("ent","chemical/x-ncbi-asn1-ascii")
+ ,("eot","application/vnd.ms-fontobject")
+ ,("eps","application/postscript")
+ ,("etx","text/x-setext")
+ ,("exe","application/x-msdos-program")
+ ,("ez","application/andrew-inset")
+ ,("fb","application/x-maker")
+ ,("fbdoc","application/x-maker")
+ ,("fch","chemical/x-gaussian-checkpoint")
+ ,("fchk","chemical/x-gaussian-checkpoint")
+ ,("fig","application/x-xfig")
+ ,("flac","application/x-flac")
+ ,("fli","video/fli")
+ ,("fm","application/x-maker")
+ ,("frame","application/x-maker")
+ ,("frm","application/x-maker")
+ ,("fs","text/plain")
+ ,("gal","chemical/x-gaussian-log")
+ ,("gam","chemical/x-gamess-input")
+ ,("gamin","chemical/x-gamess-input")
+ ,("gau","chemical/x-gaussian-input")
+ ,("gcd","text/x-pcs-gcd")
+ ,("gcf","application/x-graphing-calculator")
+ ,("gcg","chemical/x-gcg8-sequence")
+ ,("gen","chemical/x-genbank")
+ ,("gf","application/x-tex-gf")
+ ,("gif","image/gif")
+ ,("gjc","chemical/x-gaussian-input")
+ ,("gjf","chemical/x-gaussian-input")
+ ,("gl","video/gl")
+ ,("gnumeric","application/x-gnumeric")
+ ,("gpt","chemical/x-mopac-graph")
+ ,("gsf","application/x-font")
+ ,("gsm","audio/x-gsm")
+ ,("gtar","application/x-gtar")
+ ,("h","text/x-chdr")
+ ,("h++","text/x-c++hdr")
+ ,("hdf","application/x-hdf")
+ ,("hh","text/x-c++hdr")
+ ,("hin","chemical/x-hin")
+ ,("hpp","text/x-c++hdr")
+ ,("hqx","application/mac-binhex40")
+ ,("hs","text/x-haskell")
+ ,("hta","application/hta")
+ ,("htc","text/x-component")
+ ,("htm","text/html")
+ ,("html","text/html")
+ ,("hxx","text/x-c++hdr")
+ ,("ica","application/x-ica")
+ ,("ice","x-conference/x-cooltalk")
+ ,("ico","image/x-icon")
+ ,("ics","text/calendar")
+ ,("icz","text/calendar")
+ ,("ief","image/ief")
+ ,("iges","model/iges")
+ ,("igs","model/iges")
+ ,("iii","application/x-iphone")
+ ,("inp","chemical/x-gamess-input")
+ ,("ins","application/x-internet-signup")
+ ,("iso","application/x-iso9660-image")
+ ,("isp","application/x-internet-signup")
+ ,("ist","chemical/x-isostar")
+ ,("istr","chemical/x-isostar")
+ ,("jad","text/vnd.sun.j2me.app-descriptor")
+ ,("jar","application/java-archive")
+ ,("java","text/x-java")
+ ,("jdx","chemical/x-jcamp-dx")
+ ,("jmz","application/x-jmol")
+ ,("jng","image/x-jng")
+ ,("jnlp","application/x-java-jnlp-file")
+ ,("jpe","image/jpeg")
+ ,("jpeg","image/jpeg")
+ ,("jfif","image/jpeg")
+ ,("jpg","image/jpeg")
+ ,("js","application/x-javascript")
+ ,("kar","audio/midi")
+ ,("key","application/pgp-keys")
+ ,("kil","application/x-killustrator")
+ ,("kin","chemical/x-kinemage")
+ ,("kml","application/vnd.google-earth.kml+xml")
+ ,("kmz","application/vnd.google-earth.kmz")
+ ,("kpr","application/x-kpresenter")
+ ,("kpt","application/x-kpresenter")
+ ,("ksp","application/x-kspread")
+ ,("kwd","application/x-kword")
+ ,("kwt","application/x-kword")
+ ,("latex","application/x-latex")
+ ,("lha","application/x-lha")
+ ,("lhs","text/x-literate-haskell")
+ ,("lsf","video/x-la-asf")
+ ,("lsx","video/x-la-asf")
+ ,("ltx","text/x-tex")
+ ,("lyx","application/x-lyx")
+ ,("lzh","application/x-lzh")
+ ,("lzx","application/x-lzx")
+ ,("m3u","audio/mpegurl")
+ ,("m4a","audio/mpeg")
+ ,("m4v","video/x-m4v")
+ ,("maker","application/x-maker")
+ ,("man","application/x-troff-man")
+ ,("mcif","chemical/x-mmcif")
+ ,("mcm","chemical/x-macmolecule")
+ ,("mdb","application/msaccess")
+ ,("me","application/x-troff-me")
+ ,("mesh","model/mesh")
+ ,("mid","audio/midi")
+ ,("midi","audio/midi")
+ ,("mif","application/x-mif")
+ ,("mm","application/x-freemind")
+ ,("mmd","chemical/x-macromodel-input")
+ ,("mmf","application/vnd.smaf")
+ ,("mml","text/mathml")
+ ,("mmod","chemical/x-macromodel-input")
+ ,("mng","video/x-mng")
+ ,("moc","text/x-moc")
+ ,("mol","chemical/x-mdl-molfile")
+ ,("mol2","chemical/x-mol2")
+ ,("moo","chemical/x-mopac-out")
+ ,("mop","chemical/x-mopac-input")
+ ,("mopcrt","chemical/x-mopac-input")
+ ,("mov","video/quicktime")
+ ,("movie","video/x-sgi-movie")
+ ,("mp2","audio/mpeg")
+ ,("mp3","audio/mpeg")
+ ,("mp4","video/mp4")
+ ,("mpc","chemical/x-mopac-input")
+ ,("mpe","video/mpeg")
+ ,("mpeg","video/mpeg")
+ ,("mpega","audio/mpeg")
+ ,("mpg","video/mpeg")
+ ,("mpga","audio/mpeg")
+ ,("ms","application/x-troff-ms")
+ ,("msh","model/mesh")
+ ,("msi","application/x-msi")
+ ,("mvb","chemical/x-mopac-vib")
+ ,("mxu","video/vnd.mpegurl")
+ ,("nb","application/mathematica")
+ ,("nc","application/x-netcdf")
+ ,("nwc","application/x-nwc")
+ ,("o","application/x-object")
+ ,("oda","application/oda")
+ ,("odb","application/vnd.oasis.opendocument.database")
+ ,("odc","application/vnd.oasis.opendocument.chart")
+ ,("odf","application/vnd.oasis.opendocument.formula")
+ ,("odg","application/vnd.oasis.opendocument.graphics")
+ ,("odi","application/vnd.oasis.opendocument.image")
+ ,("odm","application/vnd.oasis.opendocument.text-master")
+ ,("odp","application/vnd.oasis.opendocument.presentation")
+ ,("ods","application/vnd.oasis.opendocument.spreadsheet")
+ ,("odt","application/vnd.oasis.opendocument.text")
+ ,("oga","audio/ogg")
+ ,("ogg","application/ogg")
+ ,("ogv","video/ogg")
+ ,("ogx","application/ogg")
+ ,("old","application/x-trash")
+ ,("otg","application/vnd.oasis.opendocument.graphics-template")
+ ,("oth","application/vnd.oasis.opendocument.text-web")
+ ,("otp","application/vnd.oasis.opendocument.presentation-template")
+ ,("ots","application/vnd.oasis.opendocument.spreadsheet-template")
+ ,("otf","application/vnd.ms-opentype")
+ ,("ott","application/vnd.oasis.opendocument.text-template")
+ ,("oza","application/x-oz-application")
+ ,("p","text/x-pascal")
+ ,("p7r","application/x-pkcs7-certreqresp")
+ ,("pac","application/x-ns-proxy-autoconfig")
+ ,("pas","text/x-pascal")
+ ,("pat","image/x-coreldrawpattern")
+ ,("patch","text/x-diff")
+ ,("pbm","image/x-portable-bitmap")
+ ,("pcap","application/cap")
+ ,("pcf","application/x-font")
+ ,("pcf.Z","application/x-font")
+ ,("pcx","image/pcx")
+ ,("pdb","chemical/x-pdb")
+ ,("pdf","application/pdf")
+ ,("pfa","application/x-font")
+ ,("pfb","application/x-font")
+ ,("pgm","image/x-portable-graymap")
+ ,("pgn","application/x-chess-pgn")
+ ,("pgp","application/pgp-signature")
+ ,("php","application/x-httpd-php")
+ ,("php3","application/x-httpd-php3")
+ ,("php3p","application/x-httpd-php3-preprocessed")
+ ,("php4","application/x-httpd-php4")
+ ,("phps","application/x-httpd-php-source")
+ ,("pht","application/x-httpd-php")
+ ,("phtml","application/x-httpd-php")
+ ,("pk","application/x-tex-pk")
+ ,("pl","text/x-perl")
+ ,("pls","audio/x-scpls")
+ ,("pm","text/x-perl")
+ ,("png","image/png")
+ ,("pnm","image/x-portable-anymap")
+ ,("pot","text/plain")
+ ,("ppm","image/x-portable-pixmap")
+ ,("pps","application/vnd.ms-powerpoint")
+ ,("ppt","application/vnd.ms-powerpoint")
+ ,("prf","application/pics-rules")
+ ,("prt","chemical/x-ncbi-asn1-ascii")
+ ,("ps","application/postscript")
+ ,("psd","image/x-photoshop")
+ ,("py","text/x-python")
+ ,("pyc","application/x-python-code")
+ ,("pyo","application/x-python-code")
+ ,("qt","video/quicktime")
+ ,("qtl","application/x-quicktimeplayer")
+ ,("ra","audio/x-pn-realaudio")
+ ,("ram","audio/x-pn-realaudio")
+ ,("rar","application/rar")
+ ,("ras","image/x-cmu-raster")
+ ,("rd","chemical/x-mdl-rdfile")
+ ,("rdf","application/rdf+xml")
+ ,("rgb","image/x-rgb")
+ ,("rhtml","application/x-httpd-eruby")
+ ,("rm","audio/x-pn-realaudio")
+ ,("roff","application/x-troff")
+ ,("ros","chemical/x-rosdal")
+ ,("rpm","application/x-redhat-package-manager")
+ ,("rss","application/rss+xml")
+ ,("rtf","application/rtf")
+ ,("rtx","text/richtext")
+ ,("rxn","chemical/x-mdl-rxnfile")
+ ,("sct","text/scriptlet")
+ ,("sd","chemical/x-mdl-sdfile")
+ ,("sd2","audio/x-sd2")
+ ,("sda","application/vnd.stardivision.draw")
+ ,("sdc","application/vnd.stardivision.calc")
+ ,("sdd","application/vnd.stardivision.impress")
+ ,("sdf","application/vnd.stardivision.math")
+ ,("sds","application/vnd.stardivision.chart")
+ ,("sdw","application/vnd.stardivision.writer")
+ ,("ser","application/java-serialized-object")
+ ,("sgf","application/x-go-sgf")
+ ,("sgl","application/vnd.stardivision.writer-global")
+ ,("sh","application/x-sh")
+ ,("shar","application/x-shar")
+ ,("shtml","text/html")
+ ,("sid","audio/prs.sid")
+ ,("sik","application/x-trash")
+ ,("silo","model/mesh")
+ ,("sis","application/vnd.symbian.install")
+ ,("sisx","x-epoc/x-sisx-app")
+ ,("sit","application/x-stuffit")
+ ,("sitx","application/x-stuffit")
+ ,("skd","application/x-koan")
+ ,("skm","application/x-koan")
+ ,("skp","application/x-koan")
+ ,("skt","application/x-koan")
+ ,("smi","application/smil")
+ ,("smil","application/smil")
+ ,("snd","audio/basic")
+ ,("spc","chemical/x-galactic-spc")
+ ,("spl","application/futuresplash")
+ ,("spx","audio/ogg")
+ ,("src","application/x-wais-source")
+ ,("stc","application/vnd.sun.xml.calc.template")
+ ,("std","application/vnd.sun.xml.draw.template")
+ ,("sti","application/vnd.sun.xml.impress.template")
+ ,("stl","application/vnd.ms-pki.stl")
+ ,("stw","application/vnd.sun.xml.writer.template")
+ ,("sty","text/x-tex")
+ ,("sv4cpio","application/x-sv4cpio")
+ ,("sv4crc","application/x-sv4crc")
+ ,("svg","image/svg+xml")
+ -- removed for now, since it causes problems with
+ -- extensionFromMimeType: see #2183.
+ -- ,("svgz","image/svg+xml")
+ ,("sw","chemical/x-swissprot")
+ ,("swf","application/x-shockwave-flash")
+ ,("swfl","application/x-shockwave-flash")
+ ,("sxc","application/vnd.sun.xml.calc")
+ ,("sxd","application/vnd.sun.xml.draw")
+ ,("sxg","application/vnd.sun.xml.writer.global")
+ ,("sxi","application/vnd.sun.xml.impress")
+ ,("sxm","application/vnd.sun.xml.math")
+ ,("sxw","application/vnd.sun.xml.writer")
+ ,("t","application/x-troff")
+ ,("tar","application/x-tar")
+ ,("taz","application/x-gtar")
+ ,("tcl","application/x-tcl")
+ ,("tex","text/x-tex")
+ ,("texi","application/x-texinfo")
+ ,("texinfo","application/x-texinfo")
+ ,("text","text/plain")
+ ,("tgf","chemical/x-mdl-tgf")
+ ,("tgz","application/x-gtar")
+ ,("tif","image/tiff")
+ ,("tiff","image/tiff")
+ ,("tk","text/x-tcl")
+ ,("tm","text/texmacs")
+ ,("torrent","application/x-bittorrent")
+ ,("tr","application/x-troff")
+ ,("ts","text/texmacs")
+ ,("tsp","application/dsptype")
+ ,("tsv","text/tab-separated-values")
+ ,("ttf","application/x-font-truetype")
+ ,("txt","text/plain")
+ ,("udeb","application/x-debian-package")
+ ,("uls","text/iuls")
+ ,("ustar","application/x-ustar")
+ ,("val","chemical/x-ncbi-asn1-binary")
+ ,("vcd","application/x-cdlink")
+ ,("vcf","text/x-vcard")
+ ,("vcs","text/x-vcalendar")
+ ,("vmd","chemical/x-vmd")
+ ,("vms","chemical/x-vamas-iso14976")
+ ,("vrm","x-world/x-vrml")
+ ,("vrml","model/vrml")
+ ,("vs","text/plain")
+ ,("vsd","application/vnd.visio")
+ ,("vtt","text/vtt")
+ ,("wad","application/x-doom")
+ ,("wav","audio/x-wav")
+ ,("wax","audio/x-ms-wax")
+ ,("wbmp","image/vnd.wap.wbmp")
+ ,("wbxml","application/vnd.wap.wbxml")
+ ,("webm","video/webm")
+ ,("wk","application/x-123")
+ ,("wm","video/x-ms-wm")
+ ,("wma","audio/x-ms-wma")
+ ,("wmd","application/x-ms-wmd")
+ ,("wmf","image/x-wmf")
+ ,("wml","text/vnd.wap.wml")
+ ,("wmlc","application/vnd.wap.wmlc")
+ ,("wmls","text/vnd.wap.wmlscript")
+ ,("wmlsc","application/vnd.wap.wmlscriptc")
+ ,("wmv","video/x-ms-wmv")
+ ,("wmx","video/x-ms-wmx")
+ ,("wmz","application/x-ms-wmz")
+ ,("woff","application/font-woff")
+ ,("woff2","font/woff2")
+ ,("wp5","application/wordperfect5.1")
+ ,("wpd","application/wordperfect")
+ ,("wrl","model/vrml")
+ ,("wsc","text/scriptlet")
+ ,("wvx","video/x-ms-wvx")
+ ,("wz","application/x-wingz")
+ ,("xbm","image/x-xbitmap")
+ ,("xcf","application/x-xcf")
+ ,("xht","application/xhtml+xml")
+ ,("xhtml","application/xhtml+xml")
+ ,("xlb","application/vnd.ms-excel")
+ ,("xls","application/vnd.ms-excel")
+ ,("xlt","application/vnd.ms-excel")
+ ,("xml","application/xml")
+ ,("xpi","application/x-xpinstall")
+ ,("xpm","image/x-xpixmap")
+ ,("xsl","application/xml")
+ ,("xtel","chemical/x-xtel")
+ ,("xul","application/vnd.mozilla.xul+xml")
+ ,("xwd","image/x-xwindowdump")
+ ,("xyz","chemical/x-xyz")
+ ,("zip","application/zip")
+ ,("zmt","chemical/x-mopac-input")
+ ]
+
diff --git a/src/Text/Pandoc/MediaBag.hs b/src/Text/Pandoc/MediaBag.hs
new file mode 100644
index 000000000..fe99be5fe
--- /dev/null
+++ b/src/Text/Pandoc/MediaBag.hs
@@ -0,0 +1,113 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-}
+{-
+Copyright (C) 2014 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.MediaBag
+ Copyright : Copyright (C) 2014 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Definition of a MediaBag object to hold binary resources, and an
+interface for interacting with it.
+-}
+module Text.Pandoc.MediaBag (
+ MediaBag,
+ lookupMedia,
+ insertMedia,
+ mediaDirectory,
+ extractMediaBag
+ ) where
+import System.FilePath
+import qualified System.FilePath.Posix as Posix
+import System.Directory (createDirectoryIfMissing)
+import qualified Data.Map as M
+import qualified Data.ByteString.Lazy as BL
+import Control.Monad (when)
+import Control.Monad.Trans (MonadIO(..))
+import Text.Pandoc.MIME (MimeType, getMimeTypeDef)
+import qualified Text.Pandoc.UTF8 as UTF8
+import Data.Maybe (fromMaybe)
+import System.IO (stderr)
+import Data.Data (Data)
+import Data.Typeable (Typeable)
+
+-- | A container for a collection of binary resources, with names and
+-- mime types. Note that a 'MediaBag' is a Monoid, so 'mempty'
+-- can be used for an empty 'MediaBag', and '<>' can be used to append
+-- two 'MediaBag's.
+newtype MediaBag = MediaBag (M.Map [String] (MimeType, BL.ByteString))
+ deriving (Monoid, Data, Typeable)
+
+instance Show MediaBag where
+ show bag = "MediaBag " ++ show (mediaDirectory bag)
+
+-- | Insert a media item into a 'MediaBag', replacing any existing
+-- value with the same name.
+insertMedia :: FilePath -- ^ relative path and canonical name of resource
+ -> Maybe MimeType -- ^ mime type (Nothing = determine from extension)
+ -> BL.ByteString -- ^ contents of resource
+ -> MediaBag
+ -> MediaBag
+insertMedia fp mbMime contents (MediaBag mediamap) =
+ MediaBag (M.insert (splitDirectories fp) (mime, contents) mediamap)
+ where mime = fromMaybe fallback mbMime
+ fallback = case takeExtension fp of
+ ".gz" -> getMimeTypeDef $ dropExtension fp
+ _ -> getMimeTypeDef fp
+
+-- | Lookup a media item in a 'MediaBag', returning mime type and contents.
+lookupMedia :: FilePath
+ -> MediaBag
+ -> Maybe (MimeType, BL.ByteString)
+lookupMedia fp (MediaBag mediamap) = M.lookup (splitDirectories fp) mediamap
+
+-- | Get a list of the file paths stored in a 'MediaBag', with
+-- their corresponding mime types and the lengths in bytes of the contents.
+mediaDirectory :: MediaBag -> [(String, MimeType, Int)]
+mediaDirectory (MediaBag mediamap) =
+ M.foldWithKey (\fp (mime,contents) ->
+ (((Posix.joinPath fp), mime, fromIntegral $ BL.length contents):)) [] mediamap
+
+-- | Extract contents of MediaBag to a given directory. Print informational
+-- messages if 'verbose' is true.
+-- TODO: eventually we may want to put this into PandocMonad
+-- In PandocPure, it could write to the fake file system...
+extractMediaBag :: MonadIO m
+ => Bool
+ -> FilePath
+ -> MediaBag
+ -> m ()
+extractMediaBag verbose dir (MediaBag mediamap) = liftIO $ do
+ sequence_ $ M.foldWithKey
+ (\fp (_ ,contents) ->
+ ((writeMedia verbose dir (Posix.joinPath fp, contents)):)) [] mediamap
+
+writeMedia :: Bool -> FilePath -> (FilePath, BL.ByteString) -> IO ()
+writeMedia verbose dir (subpath, bs) = do
+ -- we join and split to convert a/b/c to a\b\c on Windows;
+ -- in zip containers all paths use /
+ let fullpath = dir </> normalise subpath
+ createDirectoryIfMissing True $ takeDirectory fullpath
+ when verbose $ UTF8.hPutStrLn stderr $ "pandoc: extracting " ++ fullpath
+ BL.writeFile fullpath bs
+
+
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
new file mode 100644
index 000000000..bc62f87d0
--- /dev/null
+++ b/src/Text/Pandoc/Options.hs
@@ -0,0 +1,217 @@
+{-# LANGUAGE DeriveDataTypeable, DeriveGeneric #-}
+{-
+Copyright (C) 2012-2016 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.Options
+ Copyright : Copyright (C) 2012-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Data structures and functions for representing parser and writer
+options.
+-}
+module Text.Pandoc.Options ( module Text.Pandoc.Extensions
+ , ReaderOptions(..)
+ , HTMLMathMethod (..)
+ , CiteMethod (..)
+ , ObfuscationMethod (..)
+ , HTMLSlideVariant (..)
+ , EPUBVersion (..)
+ , WrapOption (..)
+ , TopLevelDivision (..)
+ , WriterOptions (..)
+ , TrackChanges (..)
+ , ReferenceLocation (..)
+ , def
+ , isEnabled
+ ) where
+import Text.Pandoc.Extensions
+import Data.Default
+import Text.Pandoc.Highlighting (Style, pygments)
+import Data.Data (Data)
+import Data.Typeable (Typeable)
+import GHC.Generics (Generic)
+
+data ReaderOptions = ReaderOptions{
+ readerExtensions :: Extensions -- ^ Syntax extensions
+ , readerStandalone :: Bool -- ^ Standalone document with header
+ , readerColumns :: Int -- ^ Number of columns in terminal
+ , readerTabStop :: Int -- ^ Tab stop
+ , readerApplyMacros :: Bool -- ^ Apply macros to TeX math
+ , readerIndentedCodeClasses :: [String] -- ^ Default classes for
+ -- indented code blocks
+ , readerDefaultImageExtension :: String -- ^ Default extension for images
+ , readerTrackChanges :: TrackChanges
+} deriving (Show, Read, Data, Typeable, Generic)
+
+instance Default ReaderOptions
+ where def = ReaderOptions{
+ readerExtensions = emptyExtensions
+ , readerStandalone = False
+ , readerColumns = 80
+ , readerTabStop = 4
+ , readerApplyMacros = True
+ , readerIndentedCodeClasses = []
+ , readerDefaultImageExtension = ""
+ , readerTrackChanges = AcceptChanges
+ }
+
+--
+-- Writer options
+--
+
+data EPUBVersion = EPUB2 | EPUB3 deriving (Eq, Show, Read, Data, Typeable, Generic)
+
+data HTMLMathMethod = PlainMath
+ | LaTeXMathML (Maybe String) -- url of LaTeXMathML.js
+ | JsMath (Maybe String) -- url of jsMath load script
+ | GladTeX
+ | WebTeX String -- url of TeX->image script.
+ | MathML
+ | MathJax String -- url of MathJax.js
+ | KaTeX String String -- url of stylesheet and katex.js
+ deriving (Show, Read, Eq, Data, Typeable, Generic)
+
+data CiteMethod = Citeproc -- use citeproc to render them
+ | Natbib -- output natbib cite commands
+ | Biblatex -- output biblatex cite commands
+ deriving (Show, Read, Eq, Data, Typeable, Generic)
+
+-- | Methods for obfuscating email addresses in HTML.
+data ObfuscationMethod = NoObfuscation
+ | ReferenceObfuscation
+ | JavascriptObfuscation
+ deriving (Show, Read, Eq, Data, Typeable, Generic)
+
+-- | Varieties of HTML slide shows.
+data HTMLSlideVariant = S5Slides
+ | SlidySlides
+ | SlideousSlides
+ | DZSlides
+ | RevealJsSlides
+ | NoSlides
+ deriving (Show, Read, Eq, Data, Typeable, Generic)
+
+-- | Options for accepting or rejecting MS Word track-changes.
+data TrackChanges = AcceptChanges
+ | RejectChanges
+ | AllChanges
+ deriving (Show, Read, Eq, Data, Typeable, Generic)
+
+-- | Options for wrapping text in the output.
+data WrapOption = WrapAuto -- ^ Automatically wrap to width
+ | WrapNone -- ^ No non-semantic newlines
+ | WrapPreserve -- ^ Preserve wrapping of input source
+ deriving (Show, Read, Eq, Data, Typeable, Generic)
+
+-- | Options defining the type of top-level headers.
+data TopLevelDivision = TopLevelPart -- ^ Top-level headers become parts
+ | TopLevelChapter -- ^ Top-level headers become chapters
+ | TopLevelSection -- ^ Top-level headers become sections
+ | TopLevelDefault -- ^ Top-level type is determined via
+ -- heuristics
+ deriving (Show, Read, Eq, Data, Typeable, Generic)
+
+-- | Locations for footnotes and references in markdown output
+data ReferenceLocation = EndOfBlock -- ^ End of block
+ | EndOfSection -- ^ prior to next section header (or end of document)
+ | EndOfDocument -- ^ at end of document
+ deriving (Show, Read, Eq, Data, Typeable, Generic)
+
+-- | Options for writers
+data WriterOptions = WriterOptions
+ { writerTemplate :: Maybe String -- ^ Template to use
+ , writerVariables :: [(String, String)] -- ^ Variables to set in template
+ , writerTabStop :: Int -- ^ Tabstop for conversion btw spaces and tabs
+ , writerTableOfContents :: Bool -- ^ Include table of contents
+ , writerIncremental :: Bool -- ^ True if lists should be incremental
+ , writerHTMLMathMethod :: HTMLMathMethod -- ^ How to print math in HTML
+ , writerNumberSections :: Bool -- ^ Number sections in LaTeX
+ , writerNumberOffset :: [Int] -- ^ Starting number for section, subsection, ...
+ , writerSectionDivs :: Bool -- ^ Put sections in div tags in HTML
+ , writerExtensions :: Extensions -- ^ Markdown extensions that can be used
+ , writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
+ , writerDpi :: Int -- ^ Dpi for pixel to/from inch/cm conversions
+ , writerWrapText :: WrapOption -- ^ Option for wrapping text
+ , writerColumns :: Int -- ^ Characters in a line (for text wrapping)
+ , writerEmailObfuscation :: ObfuscationMethod -- ^ How to obfuscate emails
+ , writerIdentifierPrefix :: String -- ^ Prefix for section & note ids in HTML
+ -- and for footnote marks in markdown
+ , writerSourceURL :: Maybe String -- ^ Absolute URL + directory of 1st source file
+ , writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory
+ , writerCiteMethod :: CiteMethod -- ^ How to print cites
+ , writerHtmlQTags :: Bool -- ^ Use @<q>@ tags for quotes in HTML
+ , writerSlideLevel :: Maybe Int -- ^ Force header level of slides
+ , writerTopLevelDivision :: TopLevelDivision -- ^ Type of top-level divisions
+ , writerListings :: Bool -- ^ Use listings package for code
+ , writerHighlightStyle :: Maybe Style -- ^ Style to use for highlighting
+ -- (Nothing = no highlighting)
+ , writerSetextHeaders :: Bool -- ^ Use setext headers for levels 1-2 in markdown
+ , writerEpubMetadata :: Maybe String -- ^ Metadata to include in EPUB
+ , writerEpubStylesheet :: Maybe String -- ^ EPUB stylesheet specified at command line
+ , writerEpubFonts :: [FilePath] -- ^ Paths to fonts to embed
+ , writerEpubChapterLevel :: Int -- ^ Header level for chapters (separate files)
+ , writerTOCDepth :: Int -- ^ Number of levels to include in TOC
+ , writerReferenceDoc :: Maybe FilePath -- ^ Path to reference document if specified
+ , writerLaTeXArgs :: [String] -- ^ Flags to pass to latex-engine
+ , writerReferenceLocation :: ReferenceLocation -- ^ Location of footnotes and references for writing markdown
+ } deriving (Show, Data, Typeable, Generic)
+
+instance Default WriterOptions where
+ def = WriterOptions { writerTemplate = Nothing
+ , writerVariables = []
+ , writerTabStop = 4
+ , writerTableOfContents = False
+ , writerIncremental = False
+ , writerHTMLMathMethod = PlainMath
+ , writerNumberSections = False
+ , writerNumberOffset = [0,0,0,0,0,0]
+ , writerSectionDivs = False
+ , writerExtensions = emptyExtensions
+ , writerReferenceLinks = False
+ , writerDpi = 96
+ , writerWrapText = WrapAuto
+ , writerColumns = 72
+ , writerEmailObfuscation = NoObfuscation
+ , writerIdentifierPrefix = ""
+ , writerSourceURL = Nothing
+ , writerUserDataDir = Nothing
+ , writerCiteMethod = Citeproc
+ , writerHtmlQTags = False
+ , writerSlideLevel = Nothing
+ , writerTopLevelDivision = TopLevelDefault
+ , writerListings = False
+ , writerHighlightStyle = Just pygments
+ , writerSetextHeaders = True
+ , writerEpubMetadata = Nothing
+ , writerEpubStylesheet = Nothing
+ , writerEpubFonts = []
+ , writerEpubChapterLevel = 1
+ , writerTOCDepth = 3
+ , writerReferenceDoc = Nothing
+ , writerLaTeXArgs = []
+ , writerReferenceLocation = EndOfDocument
+ }
+
+-- | Returns True if the given extension is enabled.
+isEnabled :: Extension -> WriterOptions -> Bool
+isEnabled ext opts = ext `extensionEnabled` (writerExtensions opts)
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
new file mode 100644
index 000000000..1b3b4eb88
--- /dev/null
+++ b/src/Text/Pandoc/PDF.hs
@@ -0,0 +1,369 @@
+{-# LANGUAGE OverloadedStrings, CPP, ScopedTypeVariables #-}
+{-
+Copyright (C) 2012-2016 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.PDF
+ Copyright : Copyright (C) 2012-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of LaTeX documents to PDF.
+-}
+module Text.Pandoc.PDF ( makePDF ) where
+
+import Data.ByteString.Lazy (ByteString)
+import qualified Data.ByteString.Lazy as B
+import qualified Data.ByteString.Lazy.Char8 as BC
+import qualified Data.ByteString as BS
+import Data.Monoid ((<>))
+import System.Exit (ExitCode (..))
+import System.FilePath
+import System.IO (stdout)
+import System.IO.Temp (withTempFile)
+import System.Directory
+import Data.Digest.Pure.SHA (showDigest, sha1)
+import System.Environment
+import Control.Monad (unless, when, (<=<))
+import qualified Control.Exception as E
+import Data.List (isInfixOf)
+import Data.Maybe (fromMaybe)
+import qualified Text.Pandoc.UTF8 as UTF8
+import Text.Pandoc.Definition
+import Text.Pandoc.MediaBag
+import Text.Pandoc.Walk (walkM)
+import Text.Pandoc.Shared (warn, withTempDir, inDirectory, stringify)
+import Text.Pandoc.Writers.Shared (getField, metaToJSON)
+import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..))
+import Text.Pandoc.Logging (Verbosity(..))
+import Text.Pandoc.MIME (extensionFromMimeType, getMimeType)
+import Text.Pandoc.Process (pipeProcess)
+import Control.Monad.Trans (MonadIO(..))
+import qualified Data.ByteString.Lazy as BL
+import qualified Codec.Picture as JP
+#ifdef _WINDOWS
+import Data.List (intercalate)
+#endif
+import Text.Pandoc.Class (PandocIO, runIOorExplode, fetchItem, setMediaBag, runIO)
+
+#ifdef _WINDOWS
+changePathSeparators :: FilePath -> FilePath
+changePathSeparators = intercalate "/" . splitDirectories
+#endif
+
+makePDF :: MonadIO m
+ => String -- ^ pdf creator (pdflatex, lualatex,
+ -- xelatex, context, wkhtmltopdf)
+ -> (WriterOptions -> Pandoc -> PandocIO String) -- ^ writer
+ -> WriterOptions -- ^ options
+ -> Verbosity -- ^ verbosity level
+ -> MediaBag -- ^ media
+ -> Pandoc -- ^ document
+ -> m (Either ByteString ByteString)
+makePDF "wkhtmltopdf" writer opts verbosity _ doc@(Pandoc meta _) = liftIO $ do
+ let mathArgs = case writerHTMLMathMethod opts of
+ -- with MathJax, wait til all math is rendered:
+ MathJax _ -> ["--run-script", "MathJax.Hub.Register.StartupHook('End Typeset', function() { window.status = 'mathjax_loaded' });",
+ "--window-status", "mathjax_loaded"]
+ _ -> []
+ meta' <- metaToJSON opts (return . stringify) (return . stringify) meta
+ let toArgs (f, mbd) = maybe [] (\d -> ['-':'-':f, d]) mbd
+ let args = mathArgs ++
+ concatMap toArgs
+ [("page-size", getField "papersize" meta')
+ ,("title", getField "title" meta')
+ ,("margin-bottom", fromMaybe (Just "1.2in")
+ (getField "margin-bottom" meta'))
+ ,("margin-top", fromMaybe (Just "1.25in")
+ (getField "margin-top" meta'))
+ ,("margin-right", fromMaybe (Just "1.25in")
+ (getField "margin-right" meta'))
+ ,("margin-left", fromMaybe (Just "1.25in")
+ (getField "margin-left" meta'))
+ ]
+ source <- runIOorExplode $ writer opts doc
+ html2pdf verbosity args source
+makePDF program writer opts verbosity mediabag doc =
+ liftIO $ withTempDir "tex2pdf." $ \tmpdir -> do
+ doc' <- handleImages opts mediabag tmpdir doc
+ source <- runIOorExplode $ writer opts doc'
+ let args = writerLaTeXArgs opts
+ case takeBaseName program of
+ "context" -> context2pdf verbosity tmpdir source
+ prog | prog `elem` ["pdflatex", "lualatex", "xelatex"]
+ -> tex2pdf' verbosity args tmpdir program source
+ _ -> return $ Left $ UTF8.fromStringLazy $ "Unknown program " ++ program
+
+handleImages :: WriterOptions
+ -> MediaBag
+ -> FilePath -- ^ temp dir to store images
+ -> Pandoc -- ^ document
+ -> IO Pandoc
+handleImages opts mediabag tmpdir =
+ walkM (convertImages tmpdir) <=< walkM (handleImage' opts mediabag tmpdir)
+
+handleImage' :: WriterOptions
+ -> MediaBag
+ -> FilePath
+ -> Inline
+ -> IO Inline
+handleImage' opts mediabag tmpdir (Image attr ils (src,tit)) = do
+ exists <- doesFileExist src
+ if exists
+ then return $ Image attr ils (src,tit)
+ else do
+ res <- runIO $ do
+ setMediaBag mediabag
+ fetchItem (writerSourceURL opts) src
+ case res of
+ Right (contents, Just mime) -> do
+ let ext = fromMaybe (takeExtension src) $
+ extensionFromMimeType mime
+ let basename = showDigest $ sha1 $ BL.fromChunks [contents]
+ let fname = tmpdir </> basename <.> ext
+ BS.writeFile fname contents
+ return $ Image attr ils (fname,tit)
+ _ -> do
+ warn $ "Could not find image `" ++ src ++ "', skipping..."
+ -- return alt text
+ return $ Emph ils
+handleImage' _ _ _ x = return x
+
+convertImages :: FilePath -> Inline -> IO Inline
+convertImages tmpdir (Image attr ils (src, tit)) = do
+ img <- convertImage tmpdir src
+ newPath <-
+ case img of
+ Left e -> src <$ warn e
+ Right fp -> return fp
+ return (Image attr ils (newPath, tit))
+convertImages _ x = return x
+
+-- Convert formats which do not work well in pdf to png
+convertImage :: FilePath -> FilePath -> IO (Either String FilePath)
+convertImage tmpdir fname =
+ case mime of
+ Just "image/png" -> doNothing
+ Just "image/jpeg" -> doNothing
+ Just "application/pdf" -> doNothing
+ _ -> JP.readImage fname >>= \res ->
+ case res of
+ Left _ -> return $ Left $ "Unable to convert `" ++
+ fname ++ "' for use with pdflatex."
+ Right img ->
+ E.catch (Right fileOut <$ JP.savePngImage fileOut img) $
+ \(e :: E.SomeException) -> return (Left (show e))
+ where
+ fileOut = replaceDirectory (replaceExtension fname ".png") tmpdir
+ mime = getMimeType fname
+ doNothing = return (Right fname)
+
+tex2pdf' :: Verbosity -- ^ Verbosity level
+ -> [String] -- ^ Arguments to the latex-engine
+ -> FilePath -- ^ temp directory for output
+ -> String -- ^ tex program
+ -> String -- ^ tex source
+ -> IO (Either ByteString ByteString)
+tex2pdf' verbosity args tmpDir program source = do
+ let numruns = if "\\tableofcontents" `isInfixOf` source
+ then 3 -- to get page numbers
+ else 2 -- 1 run won't give you PDF bookmarks
+ (exit, log', mbPdf) <- runTeXProgram verbosity program args 1 numruns tmpDir source
+ case (exit, mbPdf) of
+ (ExitFailure _, _) -> do
+ let logmsg = extractMsg log'
+ let extramsg =
+ case logmsg of
+ x | "! Package inputenc Error" `BC.isPrefixOf` x
+ && program /= "xelatex"
+ -> "\nTry running pandoc with --latex-engine=xelatex."
+ _ -> ""
+ return $ Left $ logmsg <> extramsg
+ (ExitSuccess, Nothing) -> return $ Left ""
+ (ExitSuccess, Just pdf) -> return $ Right pdf
+
+-- parsing output
+
+extractMsg :: ByteString -> ByteString
+extractMsg log' = do
+ let msg' = dropWhile (not . ("!" `BC.isPrefixOf`)) $ BC.lines log'
+ let (msg'',rest) = break ("l." `BC.isPrefixOf`) msg'
+ let lineno = take 1 rest
+ if null msg'
+ then log'
+ else BC.unlines (msg'' ++ lineno)
+
+extractConTeXtMsg :: ByteString -> ByteString
+extractConTeXtMsg log' = do
+ let msg' = take 1 $
+ dropWhile (not . ("tex error" `BC.isPrefixOf`)) $ BC.lines log'
+ if null msg'
+ then log'
+ else BC.unlines msg'
+
+-- running tex programs
+
+-- Run a TeX program on an input bytestring and return (exit code,
+-- contents of stdout, contents of produced PDF if any). Rerun
+-- a fixed number of times to resolve references.
+runTeXProgram :: Verbosity -> String -> [String] -> Int -> Int -> FilePath
+ -> String -> IO (ExitCode, ByteString, Maybe ByteString)
+runTeXProgram verbosity program args runNumber numRuns tmpDir source = do
+ let file = tmpDir </> "input.tex"
+ exists <- doesFileExist file
+ unless exists $ UTF8.writeFile file source
+#ifdef _WINDOWS
+ -- note: we want / even on Windows, for TexLive
+ let tmpDir' = changePathSeparators tmpDir
+ let file' = changePathSeparators file
+#else
+ let tmpDir' = tmpDir
+ let file' = file
+#endif
+ let programArgs = ["-halt-on-error", "-interaction", "nonstopmode",
+ "-output-directory", tmpDir'] ++ args ++ [file']
+ env' <- getEnvironment
+ let sep = [searchPathSeparator]
+ let texinputs = maybe (tmpDir' ++ sep) ((tmpDir' ++ sep) ++)
+ $ lookup "TEXINPUTS" env'
+ let env'' = ("TEXINPUTS", texinputs) :
+ [(k,v) | (k,v) <- env', k /= "TEXINPUTS"]
+ when (verbosity >= INFO && runNumber == 1) $ do
+ putStrLn "[makePDF] temp dir:"
+ putStrLn tmpDir'
+ putStrLn "[makePDF] Command line:"
+ putStrLn $ program ++ " " ++ unwords (map show programArgs)
+ putStr "\n"
+ putStrLn "[makePDF] Environment:"
+ mapM_ print env''
+ putStr "\n"
+ putStrLn $ "[makePDF] Contents of " ++ file' ++ ":"
+ B.readFile file' >>= B.putStr
+ putStr "\n"
+ (exit, out) <- pipeProcess (Just env'') program programArgs BL.empty
+ when (verbosity >= INFO) $ do
+ putStrLn $ "[makePDF] Run #" ++ show runNumber
+ B.hPutStr stdout out
+ putStr "\n"
+ if runNumber <= numRuns
+ then runTeXProgram verbosity program args (runNumber + 1) numRuns tmpDir source
+ else do
+ let pdfFile = replaceDirectory (replaceExtension file ".pdf") tmpDir
+ pdfExists <- doesFileExist pdfFile
+ pdf <- if pdfExists
+ -- We read PDF as a strict bytestring to make sure that the
+ -- temp directory is removed on Windows.
+ -- See https://github.com/jgm/pandoc/issues/1192.
+ then (Just . B.fromChunks . (:[])) `fmap` BS.readFile pdfFile
+ else return Nothing
+ return (exit, out, pdf)
+
+html2pdf :: Verbosity -- ^ Verbosity level
+ -> [String] -- ^ Args to wkhtmltopdf
+ -> String -- ^ HTML5 source
+ -> IO (Either ByteString ByteString)
+html2pdf verbosity args source = do
+ file <- withTempFile "." "html2pdf.html" $ \fp _ -> return fp
+ pdfFile <- withTempFile "." "html2pdf.pdf" $ \fp _ -> return fp
+ UTF8.writeFile file source
+ let programArgs = args ++ [file, pdfFile]
+ env' <- getEnvironment
+ when (verbosity >= INFO) $ do
+ putStrLn "[makePDF] Command line:"
+ putStrLn $ "wkhtmltopdf" ++ " " ++ unwords (map show programArgs)
+ putStr "\n"
+ putStrLn "[makePDF] Environment:"
+ mapM_ print env'
+ putStr "\n"
+ putStrLn $ "[makePDF] Contents of " ++ file ++ ":"
+ B.readFile file >>= B.putStr
+ putStr "\n"
+ (exit, out) <- pipeProcess (Just env') "wkhtmltopdf" programArgs BL.empty
+ removeFile file
+ when (verbosity >= INFO) $ do
+ B.hPutStr stdout out
+ putStr "\n"
+ pdfExists <- doesFileExist pdfFile
+ mbPdf <- if pdfExists
+ -- We read PDF as a strict bytestring to make sure that the
+ -- temp directory is removed on Windows.
+ -- See https://github.com/jgm/pandoc/issues/1192.
+ then do
+ res <- (Just . B.fromChunks . (:[])) `fmap` BS.readFile pdfFile
+ removeFile pdfFile
+ return res
+ else return Nothing
+ return $ case (exit, mbPdf) of
+ (ExitFailure _, _) -> Left out
+ (ExitSuccess, Nothing) -> Left ""
+ (ExitSuccess, Just pdf) -> Right pdf
+
+context2pdf :: Verbosity -- ^ Verbosity level
+ -> FilePath -- ^ temp directory for output
+ -> String -- ^ ConTeXt source
+ -> IO (Either ByteString ByteString)
+context2pdf verbosity tmpDir source = inDirectory tmpDir $ do
+ let file = "input.tex"
+ UTF8.writeFile file source
+#ifdef _WINDOWS
+ -- note: we want / even on Windows, for TexLive
+ let tmpDir' = changePathSeparators tmpDir
+#else
+ let tmpDir' = tmpDir
+#endif
+ let programArgs = "--batchmode" : [file]
+ env' <- getEnvironment
+ let sep = [searchPathSeparator]
+ let texinputs = maybe (".." ++ sep) ((".." ++ sep) ++)
+ $ lookup "TEXINPUTS" env'
+ let env'' = ("TEXINPUTS", texinputs) :
+ [(k,v) | (k,v) <- env', k /= "TEXINPUTS"]
+ when (verbosity >= INFO) $ do
+ putStrLn "[makePDF] temp dir:"
+ putStrLn tmpDir'
+ putStrLn "[makePDF] Command line:"
+ putStrLn $ "context" ++ " " ++ unwords (map show programArgs)
+ putStr "\n"
+ putStrLn "[makePDF] Environment:"
+ mapM_ print env''
+ putStr "\n"
+ putStrLn $ "[makePDF] Contents of " ++ file ++ ":"
+ B.readFile file >>= B.putStr
+ putStr "\n"
+ (exit, out) <- pipeProcess (Just env'') "context" programArgs BL.empty
+ when (verbosity >= INFO) $ do
+ B.hPutStr stdout out
+ putStr "\n"
+ let pdfFile = replaceExtension file ".pdf"
+ pdfExists <- doesFileExist pdfFile
+ mbPdf <- if pdfExists
+ -- We read PDF as a strict bytestring to make sure that the
+ -- temp directory is removed on Windows.
+ -- See https://github.com/jgm/pandoc/issues/1192.
+ then (Just . B.fromChunks . (:[])) `fmap` BS.readFile pdfFile
+ else return Nothing
+ case (exit, mbPdf) of
+ (ExitFailure _, _) -> do
+ let logmsg = extractConTeXtMsg out
+ return $ Left logmsg
+ (ExitSuccess, Nothing) -> return $ Left ""
+ (ExitSuccess, Just pdf) -> return $ Right pdf
+
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
new file mode 100644
index 000000000..400d07f2a
--- /dev/null
+++ b/src/Text/Pandoc/Parsing.hs
@@ -0,0 +1,1329 @@
+{-# LANGUAGE
+ FlexibleContexts
+, GeneralizedNewtypeDeriving
+, TypeSynonymInstances
+, MultiParamTypeClasses
+, FlexibleInstances
+, IncoherentInstances #-}
+
+{-
+Copyright (C) 2006-2016 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.Parsing
+ Copyright : Copyright (C) 2006-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+A utility library with parsers used in pandoc readers.
+-}
+module Text.Pandoc.Parsing ( anyLine,
+ many1Till,
+ notFollowedBy',
+ oneOfStrings,
+ oneOfStringsCI,
+ spaceChar,
+ nonspaceChar,
+ skipSpaces,
+ blankline,
+ blanklines,
+ enclosed,
+ stringAnyCase,
+ parseFromString,
+ lineClump,
+ charsInBalanced,
+ romanNumeral,
+ emailAddress,
+ uri,
+ mathInline,
+ mathDisplay,
+ withHorizDisplacement,
+ withRaw,
+ escaped,
+ characterReference,
+ anyOrderedListMarker,
+ orderedListMarker,
+ charRef,
+ lineBlockLines,
+ tableWith,
+ widthsFromIndices,
+ gridTableWith,
+ readWith,
+ readWithM,
+ testStringWith,
+ guardEnabled,
+ guardDisabled,
+ updateLastStrPos,
+ notAfterString,
+ logMessage,
+ reportLogMessages,
+ ParserState (..),
+ HasReaderOptions (..),
+ HasHeaderMap (..),
+ HasIdentifierList (..),
+ HasMacros (..),
+ HasLogMessages (..),
+ HasLastStrPosition (..),
+ defaultParserState,
+ HeaderType (..),
+ ParserContext (..),
+ QuoteContext (..),
+ HasQuoteContext (..),
+ NoteTable,
+ NoteTable',
+ KeyTable,
+ SubstTable,
+ Key (..),
+ toKey,
+ registerHeader,
+ smartPunctuation,
+ singleQuoteStart,
+ singleQuoteEnd,
+ doubleQuoteStart,
+ doubleQuoteEnd,
+ ellipses,
+ apostrophe,
+ dash,
+ nested,
+ citeKey,
+ macro,
+ applyMacros',
+ Parser,
+ ParserT,
+ F(..),
+ runF,
+ askF,
+ asksF,
+ token,
+ (<+?>),
+ extractIdClass,
+ insertIncludedFile,
+ -- * Re-exports from Text.Pandoc.Parsec
+ Stream,
+ runParser,
+ runParserT,
+ parse,
+ anyToken,
+ getInput,
+ setInput,
+ unexpected,
+ char,
+ letter,
+ digit,
+ alphaNum,
+ skipMany,
+ skipMany1,
+ spaces,
+ space,
+ anyChar,
+ satisfy,
+ newline,
+ string,
+ count,
+ eof,
+ noneOf,
+ oneOf,
+ lookAhead,
+ notFollowedBy,
+ many,
+ many1,
+ manyTill,
+ (<|>),
+ (<?>),
+ choice,
+ try,
+ sepBy,
+ sepBy1,
+ sepEndBy,
+ sepEndBy1,
+ endBy,
+ endBy1,
+ option,
+ optional,
+ optionMaybe,
+ getState,
+ setState,
+ updateState,
+ SourcePos,
+ getPosition,
+ setPosition,
+ sourceColumn,
+ sourceLine,
+ setSourceColumn,
+ setSourceLine,
+ newPos
+ )
+where
+
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Text.Pandoc.Builder (Blocks, Inlines, rawBlock, HasMeta(..))
+import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.XML (fromEntities)
+import qualified Text.Pandoc.UTF8 as UTF8 (putStrLn)
+import Text.Parsec hiding (token)
+import Text.Parsec.Pos (newPos)
+import Data.Char ( toLower, toUpper, ord, chr, isAscii, isAlphaNum,
+ isHexDigit, isSpace, isPunctuation )
+import Data.List ( intercalate, transpose, isSuffixOf )
+import Text.Pandoc.Shared
+import qualified Data.Map as M
+import Text.TeXMath.Readers.TeX.Macros (applyMacros, Macro,
+ parseMacroDefinitions)
+import Text.HTML.TagSoup.Entity ( lookupEntity )
+import Text.Pandoc.Asciify (toAsciiChar)
+import Data.Monoid ((<>))
+import Text.Pandoc.Class (PandocMonad, readFileFromDirs, report)
+import Text.Pandoc.Logging
+import Data.Default
+import qualified Data.Set as Set
+import Control.Monad.Reader
+import Control.Monad.Identity
+import Data.Maybe (catMaybes)
+
+import Text.Pandoc.Error
+import Control.Monad.Except
+
+type Parser t s = Parsec t s
+
+type ParserT = ParsecT
+
+newtype F a = F { unF :: Reader ParserState a } deriving (Monad, Applicative, Functor)
+
+runF :: F a -> ParserState -> a
+runF = runReader . unF
+
+askF :: F ParserState
+askF = F ask
+
+asksF :: (ParserState -> a) -> F a
+asksF f = F $ asks f
+
+instance Monoid a => Monoid (F a) where
+ mempty = return mempty
+ mappend = liftM2 mappend
+ mconcat = liftM mconcat . sequence
+
+-- | Parse any line of text
+anyLine :: Stream [Char] m Char => ParserT [Char] st m [Char]
+anyLine = do
+ -- This is much faster than:
+ -- manyTill anyChar newline
+ inp <- getInput
+ pos <- getPosition
+ case break (=='\n') inp of
+ (this, '\n':rest) -> do
+ -- needed to persuade parsec that this won't match an empty string:
+ anyChar
+ setInput rest
+ setPosition $ incSourceLine (setSourceColumn pos 1) 1
+ return this
+ _ -> mzero
+
+-- | Like @manyTill@, but reads at least one item.
+many1Till :: Stream s m t
+ => ParserT s st m a
+ -> ParserT s st m end
+ -> ParserT s st m [a]
+many1Till p end = do
+ first <- p
+ rest <- manyTill p end
+ return (first:rest)
+
+-- | A more general form of @notFollowedBy@. This one allows any
+-- type of parser to be specified, and succeeds only if that parser fails.
+-- It does not consume any input.
+notFollowedBy' :: (Show b, Stream s m a) => ParserT s st m b -> ParserT s st m ()
+notFollowedBy' p = try $ join $ do a <- try p
+ return (unexpected (show a))
+ <|>
+ return (return ())
+-- (This version due to Andrew Pimlott on the Haskell mailing list.)
+
+oneOfStrings' :: Stream s m Char => (Char -> Char -> Bool) -> [String] -> ParserT s st m String
+oneOfStrings' _ [] = fail "no strings"
+oneOfStrings' matches strs = try $ do
+ c <- anyChar
+ let strs' = [xs | (x:xs) <- strs, x `matches` c]
+ case strs' of
+ [] -> fail "not found"
+ _ -> (c:) <$> oneOfStrings' matches strs'
+ <|> if "" `elem` strs'
+ then return [c]
+ else fail "not found"
+
+-- | Parses one of a list of strings. If the list contains
+-- two strings one of which is a prefix of the other, the longer
+-- string will be matched if possible.
+oneOfStrings :: Stream s m Char => [String] -> ParserT s st m String
+oneOfStrings = oneOfStrings' (==)
+
+-- | Parses one of a list of strings (tried in order), case insensitive.
+oneOfStringsCI :: Stream s m Char => [String] -> ParserT s st m String
+oneOfStringsCI = oneOfStrings' ciMatch
+ where ciMatch x y = toLower' x == toLower' y
+ -- this optimizes toLower by checking common ASCII case
+ -- first, before calling the expensive unicode-aware
+ -- function:
+ toLower' c | c >= 'A' && c <= 'Z' = chr (ord c + 32)
+ | isAscii c = c
+ | otherwise = toLower c
+
+-- | Parses a space or tab.
+spaceChar :: Stream s m Char => ParserT s st m Char
+spaceChar = satisfy $ \c -> c == ' ' || c == '\t'
+
+-- | Parses a nonspace, nonnewline character.
+nonspaceChar :: Stream s m Char => ParserT s st m Char
+nonspaceChar = satisfy $ flip notElem ['\t', '\n', ' ', '\r']
+
+-- | Skips zero or more spaces or tabs.
+skipSpaces :: Stream s m Char => ParserT s st m ()
+skipSpaces = skipMany spaceChar
+
+-- | Skips zero or more spaces or tabs, then reads a newline.
+blankline :: Stream s m Char => ParserT s st m Char
+blankline = try $ skipSpaces >> newline
+
+-- | Parses one or more blank lines and returns a string of newlines.
+blanklines :: Stream s m Char => ParserT s st m [Char]
+blanklines = many1 blankline
+
+-- | Parses material enclosed between start and end parsers.
+enclosed :: 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 space >> many1Till parser end
+
+-- | Parse string, case insensitive.
+stringAnyCase :: Stream s m Char => [Char] -> ParserT s st m String
+stringAnyCase [] = string ""
+stringAnyCase (x:xs) = do
+ firstChar <- char (toUpper x) <|> char (toLower x)
+ rest <- stringAnyCase xs
+ return (firstChar:rest)
+
+-- | Parse contents of 'str' using 'parser' and return result.
+parseFromString :: Monad m => ParserT String st m a -> String -> ParserT String st m a
+parseFromString parser str = do
+ oldPos <- getPosition
+ oldInput <- getInput
+ setInput str
+ result <- parser
+ spaces
+ eof
+ setInput oldInput
+ setPosition oldPos
+ return result
+
+-- | Parse raw line block up to and including blank lines.
+lineClump :: Stream [Char] m Char => ParserT [Char] st m String
+lineClump = blanklines
+ <|> (many1 (notFollowedBy blankline >> anyLine) >>= return . unlines)
+
+-- | Parse a string of characters between an open character
+-- and a close character, including text between balanced
+-- pairs of open and close, which must be different. For example,
+-- @charsInBalanced '(' ')' anyChar@ will parse "(hello (there))"
+-- and return "hello (there)".
+charsInBalanced :: Stream s m Char => Char -> Char -> ParserT s st m Char
+ -> ParserT s st m String
+charsInBalanced open close parser = try $ do
+ char open
+ let isDelim c = c == open || c == close
+ raw <- many $ many1 (notFollowedBy (satisfy isDelim) >> parser)
+ <|> (do res <- charsInBalanced open close parser
+ return $ [open] ++ res ++ [close])
+ char close
+ return $ concat raw
+
+-- old charsInBalanced would be:
+-- charsInBalanced open close (noneOf "\n" <|> char '\n' >> notFollowedBy blankline)
+-- old charsInBalanced' would be:
+-- charsInBalanced open close anyChar
+
+-- Auxiliary functions for romanNumeral:
+
+lowercaseRomanDigits :: [Char]
+lowercaseRomanDigits = ['i','v','x','l','c','d','m']
+
+uppercaseRomanDigits :: [Char]
+uppercaseRomanDigits = map toUpper lowercaseRomanDigits
+
+-- | Parses a roman numeral (uppercase or lowercase), returns number.
+romanNumeral :: Stream s m Char => Bool -- ^ Uppercase if true
+ -> ParserT s st m Int
+romanNumeral upperCase = do
+ let romanDigits = if upperCase
+ then uppercaseRomanDigits
+ else lowercaseRomanDigits
+ lookAhead $ oneOf romanDigits
+ let [one, five, ten, fifty, hundred, fivehundred, thousand] =
+ map char romanDigits
+ thousands <- many thousand >>= (return . (1000 *) . length)
+ ninehundreds <- option 0 $ try $ hundred >> thousand >> return 900
+ fivehundreds <- many fivehundred >>= (return . (500 *) . length)
+ fourhundreds <- option 0 $ try $ hundred >> fivehundred >> return 400
+ hundreds <- many hundred >>= (return . (100 *) . length)
+ nineties <- option 0 $ try $ ten >> hundred >> return 90
+ fifties <- many fifty >>= (return . (50 *) . length)
+ forties <- option 0 $ try $ ten >> fifty >> return 40
+ tens <- many ten >>= (return . (10 *) . length)
+ nines <- option 0 $ try $ one >> ten >> return 9
+ fives <- many five >>= (return . (5 *) . length)
+ fours <- option 0 $ try $ one >> five >> return 4
+ ones <- many one >>= (return . length)
+ let total = thousands + ninehundreds + fivehundreds + fourhundreds +
+ hundreds + nineties + fifties + forties + tens + nines +
+ fives + fours + ones
+ if total == 0
+ then fail "not a roman numeral"
+ else return total
+
+-- Parsers for email addresses and URIs
+
+-- | Parses an email address; returns original and corresponding
+-- escaped mailto: URI.
+emailAddress :: Stream s m Char => ParserT s st m (String, String)
+emailAddress = try $ toResult <$> mailbox <*> (char '@' *> domain)
+ where toResult mbox dom = let full = fromEntities $ mbox ++ '@':dom
+ in (full, escapeURI $ "mailto:" ++ full)
+ mailbox = intercalate "." <$> (emailWord `sepby1` dot)
+ domain = intercalate "." <$> (subdomain `sepby1` dot)
+ dot = char '.'
+ subdomain = many1 $ alphaNum <|> innerPunct
+ -- this excludes some valid email addresses, since an
+ -- email could contain e.g. '__', but gives better results
+ -- for our purposes, when combined with markdown parsing:
+ innerPunct = try (satisfy (\c -> isEmailPunct c || c == '@')
+ <* notFollowedBy space
+ <* notFollowedBy (satisfy isPunctuation))
+ -- technically an email address could begin with a symbol,
+ -- but allowing this creates too many problems.
+ -- See e.g. https://github.com/jgm/pandoc/issues/2940
+ emailWord = do x <- satisfy isAlphaNum
+ xs <- many (satisfy isEmailChar)
+ return (x:xs)
+ isEmailChar c = isAlphaNum c || isEmailPunct c
+ isEmailPunct c = c `elem` "!\"#$%&'*+-/=?^_{|}~;"
+ -- note: sepBy1 from parsec consumes input when sep
+ -- succeeds and p fails, so we use this variant here.
+ sepby1 p sep = (:) <$> p <*> (many (try $ sep >> p))
+
+
+-- Schemes from http://www.iana.org/assignments/uri-schemes.html plus
+-- the unofficial schemes coap, doi, javascript, isbn, pmid
+schemes :: [String]
+schemes = ["coap","doi","javascript","aaa","aaas","about","acap","cap","cid",
+ "crid","data","dav","dict","dns","file","ftp","geo","go","gopher",
+ "h323","http","https","iax","icap","im","imap","info","ipp","iris",
+ "iris.beep","iris.xpc","iris.xpcs","iris.lwz","ldap","mailto","mid",
+ "msrp","msrps","mtqp","mupdate","news","nfs","ni","nih","nntp",
+ "opaquelocktoken","pop","pres","rtsp","service","session","shttp","sieve",
+ "sip","sips","sms","snmp","soap.beep","soap.beeps","tag","tel","telnet",
+ "tftp","thismessage","tn3270","tip","tv","urn","vemmi","ws","wss","xcon",
+ "xcon-userid","xmlrpc.beep","xmlrpc.beeps","xmpp","z39.50r","z39.50s",
+ "adiumxtra","afp","afs","aim","apt","attachment","aw","beshare","bitcoin",
+ "bolo","callto","chrome","chrome-extension","com-eventbrite-attendee",
+ "content", "cvs","dlna-playsingle","dlna-playcontainer","dtn","dvb",
+ "ed2k","facetime","feed","finger","fish","gg","git","gizmoproject",
+ "gtalk","hcp","icon","ipn","irc","irc6","ircs","itms","jar","jms",
+ "keyparc","lastfm","ldaps","magnet","maps","market","message","mms",
+ "ms-help","msnim","mumble","mvn","notes","oid","palm","paparazzi",
+ "platform","proxy","psyc","query","res","resource","rmi","rsync",
+ "rtmp","secondlife","sftp","sgn","skype","smb","soldat","spotify",
+ "ssh","steam","svn","teamspeak","things","udp","unreal","ut2004",
+ "ventrilo","view-source","webcal","wtai","wyciwyg","xfire","xri",
+ "ymsgr", "isbn", "pmid"]
+
+uriScheme :: Stream s m Char => ParserT s st m String
+uriScheme = oneOfStringsCI schemes
+
+-- | Parses a URI. Returns pair of original and URI-escaped version.
+uri :: Stream [Char] m Char => ParserT [Char] st m (String, String)
+uri = try $ do
+ scheme <- uriScheme
+ char ':'
+ -- We allow sentence punctuation except at the end, since
+ -- we don't want the trailing '.' in 'http://google.com.' We want to allow
+ -- 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' <- option str $ char '/' >> return (str ++ "/")
+ let uri' = scheme ++ ":" ++ fromEntities str'
+ return (uri', escapeURI uri')
+
+mathInlineWith :: Stream s m Char => String -> String -> ParserT s st m String
+mathInlineWith op cl = try $ do
+ string op
+ notFollowedBy space
+ words' <- many1Till (count 1 (noneOf " \t\n\\")
+ <|> (char '\\' >>
+ -- This next clause is needed because \text{..} can
+ -- contain $, \(\), etc.
+ (try (string "text" >>
+ (("\\text" ++) <$> inBalancedBraces 0 ""))
+ <|> (\c -> ['\\',c]) <$> anyChar))
+ <|> do (blankline <* notFollowedBy' blankline) <|>
+ (oneOf " \t" <* skipMany (oneOf " \t"))
+ notFollowedBy (char '$')
+ return " "
+ ) (try $ string cl)
+ notFollowedBy digit -- to prevent capture of $5
+ return $ concat words'
+ where
+ inBalancedBraces :: Stream s m Char => Int -> String -> ParserT s st m String
+ inBalancedBraces 0 "" = do
+ c <- anyChar
+ if c == '{'
+ then inBalancedBraces 1 "{"
+ else mzero
+ inBalancedBraces 0 s = return $ reverse s
+ inBalancedBraces numOpen ('\\':xs) = do
+ c <- anyChar
+ inBalancedBraces numOpen (c:'\\':xs)
+ inBalancedBraces numOpen xs = do
+ c <- anyChar
+ case c of
+ '}' -> inBalancedBraces (numOpen - 1) (c:xs)
+ '{' -> inBalancedBraces (numOpen + 1) (c:xs)
+ _ -> inBalancedBraces numOpen (c:xs)
+
+mathDisplayWith :: Stream s m Char => String -> String -> ParserT s st m String
+mathDisplayWith op cl = try $ do
+ string op
+ many1Till (noneOf "\n" <|> (newline <* notFollowedBy' blankline)) (try $ string cl)
+
+mathDisplay :: (HasReaderOptions st, Stream s m Char)
+ => ParserT s st m String
+mathDisplay =
+ (guardEnabled Ext_tex_math_dollars >> mathDisplayWith "$$" "$$")
+ <|> (guardEnabled Ext_tex_math_single_backslash >>
+ mathDisplayWith "\\[" "\\]")
+ <|> (guardEnabled Ext_tex_math_double_backslash >>
+ mathDisplayWith "\\\\[" "\\\\]")
+
+mathInline :: (HasReaderOptions st , Stream s m Char)
+ => ParserT s st m String
+mathInline =
+ (guardEnabled Ext_tex_math_dollars >> mathInlineWith "$" "$")
+ <|> (guardEnabled Ext_tex_math_single_backslash >>
+ mathInlineWith "\\(" "\\)")
+ <|> (guardEnabled Ext_tex_math_double_backslash >>
+ mathInlineWith "\\\\(" "\\\\)")
+
+-- | Applies a parser, returns tuple of its results and its horizontal
+-- displacement (the difference between the source column at the end
+-- and the source column at the beginning). Vertical displacement
+-- (source row) is ignored.
+withHorizDisplacement :: Stream s m Char
+ => ParserT s st m a -- ^ Parser to apply
+ -> ParserT s st m (a, Int) -- ^ (result, displacement)
+withHorizDisplacement parser = do
+ pos1 <- getPosition
+ result <- parser
+ pos2 <- getPosition
+ return (result, sourceColumn pos2 - sourceColumn pos1)
+
+-- | Applies a parser and returns the raw string that was parsed,
+-- along with the value produced by the parser.
+withRaw :: Stream [Char] m Char => ParsecT [Char] st m a -> ParsecT [Char] st m (a, [Char])
+withRaw parser = do
+ pos1 <- getPosition
+ inp <- getInput
+ result <- parser
+ pos2 <- getPosition
+ let (l1,c1) = (sourceLine pos1, sourceColumn pos1)
+ let (l2,c2) = (sourceLine pos2, sourceColumn pos2)
+ let inplines = take ((l2 - l1) + 1) $ lines inp
+ let raw = case inplines of
+ [] -> ""
+ [l] -> take (c2 - c1) l
+ ls -> unlines (init ls) ++ take (c2 - 1) (last ls)
+ return (result, raw)
+
+-- | Parses backslash, then applies character parser.
+escaped :: Stream s m Char
+ => ParserT s st m Char -- ^ Parser for character to escape
+ -> ParserT s st m Char
+escaped parser = try $ char '\\' >> parser
+
+-- | Parse character entity.
+characterReference :: Stream s m Char => ParserT s st m Char
+characterReference = try $ do
+ char '&'
+ ent <- many1Till nonspaceChar (char ';')
+ let ent' = case ent of
+ '#':'X':xs -> '#':'x':xs -- workaround tagsoup bug
+ '#':_ -> ent
+ _ -> ent ++ ";"
+ case lookupEntity ent' of
+ Just (c : _) -> return c
+ _ -> fail "entity not found"
+
+-- | Parses an uppercase roman numeral and returns (UpperRoman, number).
+upperRoman :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)
+upperRoman = do
+ num <- romanNumeral True
+ return (UpperRoman, num)
+
+-- | Parses a lowercase roman numeral and returns (LowerRoman, number).
+lowerRoman :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)
+lowerRoman = do
+ num <- romanNumeral False
+ return (LowerRoman, num)
+
+-- | Parses a decimal numeral and returns (Decimal, number).
+decimal :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)
+decimal = do
+ num <- many1 digit
+ return (Decimal, read num)
+
+-- | Parses a '@' and optional label and
+-- returns (DefaultStyle, [next example number]). The next
+-- example number is incremented in parser state, and the label
+-- (if present) is added to the label table.
+exampleNum :: Stream s m Char
+ => ParserT s ParserState m (ListNumberStyle, Int)
+exampleNum = do
+ char '@'
+ lab <- many (alphaNum <|> satisfy (\c -> c == '_' || c == '-'))
+ st <- getState
+ let num = stateNextExample st
+ let newlabels = if null lab
+ then stateExamples st
+ else M.insert lab num $ stateExamples st
+ updateState $ \s -> s{ stateNextExample = num + 1
+ , stateExamples = newlabels }
+ return (Example, num)
+
+-- | Parses a '#' returns (DefaultStyle, 1).
+defaultNum :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)
+defaultNum = do
+ char '#'
+ return (DefaultStyle, 1)
+
+-- | Parses a lowercase letter and returns (LowerAlpha, number).
+lowerAlpha :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)
+lowerAlpha = do
+ ch <- oneOf ['a'..'z']
+ return (LowerAlpha, ord ch - ord 'a' + 1)
+
+-- | Parses an uppercase letter and returns (UpperAlpha, number).
+upperAlpha :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)
+upperAlpha = do
+ ch <- oneOf ['A'..'Z']
+ return (UpperAlpha, ord ch - ord 'A' + 1)
+
+-- | Parses a roman numeral i or I
+romanOne :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)
+romanOne = (char 'i' >> return (LowerRoman, 1)) <|>
+ (char 'I' >> return (UpperRoman, 1))
+
+-- | Parses an ordered list marker and returns list attributes.
+anyOrderedListMarker :: Stream s m Char => ParserT s ParserState m ListAttributes
+anyOrderedListMarker = choice $
+ [delimParser numParser | delimParser <- [inPeriod, inOneParen, inTwoParens],
+ numParser <- [decimal, exampleNum, defaultNum, romanOne,
+ lowerAlpha, lowerRoman, upperAlpha, upperRoman]]
+
+-- | Parses a list number (num) followed by a period, returns list attributes.
+inPeriod :: Stream s m Char
+ => ParserT s st m (ListNumberStyle, Int)
+ -> ParserT s st m ListAttributes
+inPeriod num = try $ do
+ (style, start) <- num
+ char '.'
+ let delim = if style == DefaultStyle
+ then DefaultDelim
+ else Period
+ return (start, style, delim)
+
+-- | Parses a list number (num) followed by a paren, returns list attributes.
+inOneParen :: Stream s m Char
+ => ParserT s st m (ListNumberStyle, Int)
+ -> ParserT s st m ListAttributes
+inOneParen num = try $ do
+ (style, start) <- num
+ char ')'
+ return (start, style, OneParen)
+
+-- | Parses a list number (num) enclosed in parens, returns list attributes.
+inTwoParens :: Stream s m Char
+ => ParserT s st m (ListNumberStyle, Int)
+ -> ParserT s st m ListAttributes
+inTwoParens num = try $ do
+ char '('
+ (style, start) <- num
+ char ')'
+ return (start, style, TwoParens)
+
+-- | Parses an ordered list marker with a given style and delimiter,
+-- returns number.
+orderedListMarker :: Stream s m Char
+ => ListNumberStyle
+ -> ListNumberDelim
+ -> ParserT s ParserState m Int
+orderedListMarker style delim = do
+ let num = defaultNum <|> -- # can continue any kind of list
+ case style of
+ DefaultStyle -> decimal
+ Example -> exampleNum
+ Decimal -> decimal
+ UpperRoman -> upperRoman
+ LowerRoman -> lowerRoman
+ UpperAlpha -> upperAlpha
+ LowerAlpha -> lowerAlpha
+ let context = case delim of
+ DefaultDelim -> inPeriod
+ Period -> inPeriod
+ OneParen -> inOneParen
+ TwoParens -> inTwoParens
+ (start, _, _) <- context num
+ return start
+
+-- | Parses a character reference and returns a Str element.
+charRef :: Stream s m Char => ParserT s st m Inline
+charRef = do
+ c <- characterReference
+ return $ Str [c]
+
+lineBlockLine :: Stream [Char] m Char => ParserT [Char] st m String
+lineBlockLine = try $ do
+ char '|'
+ char ' '
+ white <- many (spaceChar >> return '\160')
+ notFollowedBy newline
+ line <- anyLine
+ continuations <- many (try $ char ' ' >> anyLine)
+ return $ white ++ unwords (line : continuations)
+
+blankLineBlockLine :: Stream [Char] m Char => ParserT [Char] st m Char
+blankLineBlockLine = try (char '|' >> blankline)
+
+-- | Parses an RST-style line block and returns a list of strings.
+lineBlockLines :: Stream [Char] m Char => ParserT [Char] st m [String]
+lineBlockLines = try $ do
+ lines' <- many1 (lineBlockLine <|> ((:[]) <$> blankLineBlockLine))
+ skipMany1 $ blankline <|> blankLineBlockLine
+ return lines'
+
+-- | Parse a table using 'headerParser', 'rowParser',
+-- 'lineParser', and 'footerParser'.
+tableWith :: Stream s m Char
+ => ParserT s ParserState m ([Blocks], [Alignment], [Int])
+ -> ([Int] -> ParserT s ParserState m [Blocks])
+ -> ParserT s ParserState m sep
+ -> ParserT s ParserState m end
+ -> ParserT s ParserState m Blocks
+tableWith headerParser rowParser lineParser footerParser = try $ do
+ (heads, aligns, indices) <- headerParser
+ lines' <- rowParser indices `sepEndBy1` lineParser
+ footerParser
+ numColumns <- getOption readerColumns
+ let widths = if (indices == [])
+ then replicate (length aligns) 0.0
+ else widthsFromIndices numColumns indices
+ return $ B.table mempty (zip aligns widths) heads lines'
+
+-- Calculate relative widths of table columns, based on indices
+widthsFromIndices :: Int -- Number of columns on terminal
+ -> [Int] -- Indices
+ -> [Double] -- Fractional relative sizes of columns
+widthsFromIndices _ [] = []
+widthsFromIndices numColumns' indices =
+ let numColumns = max numColumns' (if null indices then 0 else last indices)
+ lengths' = zipWith (-) indices (0:indices)
+ lengths = reverse $
+ case reverse lengths' of
+ [] -> []
+ [x] -> [x]
+ -- compensate for the fact that intercolumn
+ -- spaces are counted in widths of all columns
+ -- but the last...
+ (x:y:zs) -> if x < y && y - x <= 2
+ then y:y:zs
+ else x:y:zs
+ totLength = sum lengths
+ quotient = if totLength > numColumns
+ then fromIntegral totLength
+ else fromIntegral numColumns
+ fracs = map (\l -> (fromIntegral l) / quotient) lengths in
+ tail fracs
+
+---
+
+-- Parse a grid table: starts with row of '-' on top, then header
+-- (which may be grid), then the rows,
+-- which may be grid, separated by blank lines, and
+-- ending with a footer (dashed line followed by blank line).
+gridTableWith :: Stream [Char] m Char
+ => ParserT [Char] ParserState m Blocks -- ^ Block list parser
+ -> Bool -- ^ Headerless table
+ -> ParserT [Char] ParserState m Blocks
+gridTableWith blocks headless =
+ tableWith (gridTableHeader headless blocks) (gridTableRow blocks)
+ (gridTableSep '-') gridTableFooter
+
+gridTableSplitLine :: [Int] -> String -> [String]
+gridTableSplitLine indices line = map removeFinalBar $ tail $
+ splitStringByIndices (init indices) $ trimr line
+
+gridPart :: Stream s m Char => Char -> ParserT s st m (Int, Int)
+gridPart ch = do
+ dashes <- many1 (char ch)
+ char '+'
+ return (length dashes, length dashes + 1)
+
+gridDashedLines :: Stream s m Char => Char -> ParserT s st m [(Int,Int)]
+gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) <* blankline
+
+removeFinalBar :: String -> String
+removeFinalBar =
+ reverse . dropWhile (`elem` " \t") . dropWhile (=='|') . reverse
+
+-- | Separator between rows of grid table.
+gridTableSep :: Stream s m Char => Char -> ParserT s ParserState m Char
+gridTableSep ch = try $ gridDashedLines ch >> return '\n'
+
+-- | Parse header for a grid table.
+gridTableHeader :: Stream [Char] m Char
+ => Bool -- ^ Headerless table
+ -> ParserT [Char] ParserState m Blocks
+ -> ParserT [Char] ParserState m ([Blocks], [Alignment], [Int])
+gridTableHeader headless blocks = try $ do
+ optional blanklines
+ dashes <- gridDashedLines '-'
+ rawContent <- if headless
+ then return $ repeat ""
+ else many1
+ (notFollowedBy (gridTableSep '=') >> char '|' >>
+ many1Till anyChar newline)
+ if headless
+ then return ()
+ else gridTableSep '=' >> return ()
+ let lines' = map snd dashes
+ let indices = scanl (+) 0 lines'
+ let aligns = replicate (length lines') AlignDefault
+ -- RST does not have a notion of alignments
+ let rawHeads = if headless
+ then replicate (length dashes) ""
+ else map (intercalate " ") $ transpose
+ $ map (gridTableSplitLine indices) rawContent
+ heads <- mapM (parseFromString blocks) $ map trim rawHeads
+ return (heads, aligns, indices)
+
+gridTableRawLine :: Stream s m Char => [Int] -> ParserT s ParserState m [String]
+gridTableRawLine indices = do
+ char '|'
+ line <- many1Till anyChar newline
+ return (gridTableSplitLine indices line)
+
+-- | Parse row of grid table.
+gridTableRow :: Stream [Char] m Char
+ => ParserT [Char] ParserState m Blocks
+ -> [Int]
+ -> ParserT [Char] ParserState m [Blocks]
+gridTableRow blocks indices = do
+ colLines <- many1 (gridTableRawLine indices)
+ let cols = map ((++ "\n") . unlines . removeOneLeadingSpace) $
+ transpose colLines
+ mapM (liftM compactifyCell . parseFromString blocks) cols
+
+removeOneLeadingSpace :: [String] -> [String]
+removeOneLeadingSpace xs =
+ if all startsWithSpace xs
+ then map (drop 1) xs
+ else xs
+ where startsWithSpace "" = True
+ startsWithSpace (y:_) = y == ' '
+
+compactifyCell :: Blocks -> Blocks
+compactifyCell bs = head $ compactify [bs]
+
+-- | Parse footer for a grid table.
+gridTableFooter :: Stream s m Char => ParserT s ParserState m [Char]
+gridTableFooter = blanklines
+
+---
+
+-- | Removes the ParsecT layer from the monad transformer stack
+readWithM :: (Monad m)
+ => ParserT [Char] st m a -- ^ parser
+ -> st -- ^ initial state
+ -> String -- ^ input
+ -> m (Either PandocError a)
+readWithM parser state input =
+ mapLeft (PandocParsecError input) `liftM` runParserT parser state "source" input
+
+
+-- | Parse a string with a given parser and state
+readWith :: Parser [Char] st a
+ -> st
+ -> String
+ -> Either PandocError a
+readWith p t inp = runIdentity $ readWithM p t inp
+
+-- | Parse a string with @parser@ (for testing).
+testStringWith :: (Show a)
+ => ParserT [Char] ParserState Identity a
+ -> [Char]
+ -> IO ()
+testStringWith parser str = UTF8.putStrLn $ show $
+ readWith parser defaultParserState str
+
+-- | Parsing options.
+data ParserState = ParserState
+ { stateOptions :: ReaderOptions, -- ^ User options
+ stateParserContext :: ParserContext, -- ^ Inside list?
+ stateQuoteContext :: QuoteContext, -- ^ Inside quoted environment?
+ stateAllowLinks :: Bool, -- ^ Allow parsing of links
+ stateMaxNestingLevel :: Int, -- ^ Max # of nested Strong/Emph
+ stateLastStrPos :: Maybe SourcePos, -- ^ Position after last str parsed
+ stateKeys :: KeyTable, -- ^ List of reference keys
+ stateHeaderKeys :: KeyTable, -- ^ List of implicit header ref keys
+ stateSubstitutions :: SubstTable, -- ^ List of substitution references
+ stateNotes :: NoteTable, -- ^ List of notes (raw bodies)
+ stateNotes' :: NoteTable', -- ^ List of notes (parsed bodies)
+ stateMeta :: Meta, -- ^ Document metadata
+ stateMeta' :: F Meta, -- ^ Document metadata
+ stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used
+ stateHeaders :: M.Map Inlines String, -- ^ List of headers and ids (used for implicit ref links)
+ stateIdentifiers :: Set.Set String, -- ^ Header identifiers used
+ stateNextExample :: Int, -- ^ Number of next example
+ stateExamples :: M.Map String Int, -- ^ Map from example labels to numbers
+ stateHasChapters :: Bool, -- ^ True if \chapter encountered
+ stateMacros :: [Macro], -- ^ List of macros defined so far
+ stateRstDefaultRole :: String, -- ^ Current rST default interpreted text role
+ stateRstCustomRoles :: M.Map String (String, Maybe String, Attr), -- ^ Current rST custom text roles
+ -- Triple represents: 1) Base role, 2) Optional format (only for :raw:
+ -- roles), 3) Additional classes (rest of Attr is unused)).
+ stateCaption :: Maybe Inlines, -- ^ Caption in current environment
+ stateInHtmlBlock :: Maybe String, -- ^ Tag type of HTML block being parsed
+ stateContainers :: [String], -- ^ parent include files
+ stateLogMessages :: [LogMessage], -- ^ log messages
+ stateMarkdownAttribute :: Bool -- ^ True if in markdown=1 context
+ }
+
+instance Default ParserState where
+ def = defaultParserState
+
+instance HasMeta ParserState where
+ setMeta field val st =
+ st{ stateMeta = setMeta field val $ stateMeta st }
+ deleteMeta field st =
+ st{ stateMeta = deleteMeta field $ stateMeta st }
+
+class HasReaderOptions st where
+ extractReaderOptions :: st -> ReaderOptions
+ getOption :: (Stream s m t) => (ReaderOptions -> b) -> ParserT s st m b
+ -- default
+ getOption f = (f . extractReaderOptions) <$> getState
+
+class HasQuoteContext st m where
+ getQuoteContext :: (Stream s m t) => ParsecT s st m QuoteContext
+ withQuoteContext :: QuoteContext -> ParsecT s st m a -> ParsecT s st m a
+
+instance Monad m => HasQuoteContext ParserState m where
+ getQuoteContext = stateQuoteContext <$> getState
+ withQuoteContext context parser = do
+ oldState <- getState
+ let oldQuoteContext = stateQuoteContext oldState
+ setState oldState { stateQuoteContext = context }
+ result <- parser
+ newState <- getState
+ setState newState { stateQuoteContext = oldQuoteContext }
+ return result
+
+instance HasReaderOptions ParserState where
+ extractReaderOptions = stateOptions
+
+class HasHeaderMap st where
+ extractHeaderMap :: st -> M.Map Inlines String
+ updateHeaderMap :: (M.Map Inlines String -> M.Map Inlines String) ->
+ st -> st
+
+instance HasHeaderMap ParserState where
+ extractHeaderMap = stateHeaders
+ updateHeaderMap f st = st{ stateHeaders = f $ stateHeaders st }
+
+class HasIdentifierList st where
+ extractIdentifierList :: st -> Set.Set String
+ updateIdentifierList :: (Set.Set String -> Set.Set String) -> st -> st
+
+instance HasIdentifierList ParserState where
+ extractIdentifierList = stateIdentifiers
+ updateIdentifierList f st = st{ stateIdentifiers = f $ stateIdentifiers st }
+
+class HasMacros st where
+ extractMacros :: st -> [Macro]
+ updateMacros :: ([Macro] -> [Macro]) -> st -> st
+
+instance HasMacros ParserState where
+ extractMacros = stateMacros
+ updateMacros f st = st{ stateMacros = f $ stateMacros st }
+
+class HasLastStrPosition st where
+ setLastStrPos :: SourcePos -> st -> st
+ getLastStrPos :: st -> Maybe SourcePos
+
+instance HasLastStrPosition ParserState where
+ setLastStrPos pos st = st{ stateLastStrPos = Just pos }
+ getLastStrPos st = stateLastStrPos st
+
+class HasLogMessages st where
+ addLogMessage :: LogMessage -> st -> st
+ getLogMessages :: st -> [LogMessage]
+
+instance HasLogMessages ParserState where
+ addLogMessage msg st = st{ stateLogMessages = msg : stateLogMessages st }
+ getLogMessages st = reverse $ stateLogMessages st
+
+defaultParserState :: ParserState
+defaultParserState =
+ ParserState { stateOptions = def,
+ stateParserContext = NullState,
+ stateQuoteContext = NoQuote,
+ stateAllowLinks = True,
+ stateMaxNestingLevel = 6,
+ stateLastStrPos = Nothing,
+ stateKeys = M.empty,
+ stateHeaderKeys = M.empty,
+ stateSubstitutions = M.empty,
+ stateNotes = [],
+ stateNotes' = [],
+ stateMeta = nullMeta,
+ stateMeta' = return nullMeta,
+ stateHeaderTable = [],
+ stateHeaders = M.empty,
+ stateIdentifiers = Set.empty,
+ stateNextExample = 1,
+ stateExamples = M.empty,
+ stateHasChapters = False,
+ stateMacros = [],
+ stateRstDefaultRole = "title-reference",
+ stateRstCustomRoles = M.empty,
+ stateCaption = Nothing,
+ stateInHtmlBlock = Nothing,
+ stateContainers = [],
+ stateLogMessages = [],
+ stateMarkdownAttribute = False
+ }
+
+-- | Add a log message.
+logMessage :: (Stream s m a, HasLogMessages st)
+ => LogMessage -> ParserT s st m ()
+logMessage msg = updateState (addLogMessage msg)
+
+-- | Report all the accumulated log messages, according to verbosity level.
+reportLogMessages :: (PandocMonad m, HasLogMessages st) => ParserT s st m ()
+reportLogMessages = do
+ msgs <- getLogMessages <$> getState
+ mapM_ report msgs
+
+-- | Succeed only if the extension is enabled.
+guardEnabled :: (Stream s m a, HasReaderOptions st) => Extension -> ParserT s st m ()
+guardEnabled ext = getOption readerExtensions >>= guard . extensionEnabled ext
+
+-- | Succeed only if the extension is disabled.
+guardDisabled :: (Stream s m a, HasReaderOptions st) => Extension -> ParserT s st m ()
+guardDisabled ext = getOption readerExtensions >>= guard . not . extensionEnabled ext
+
+-- | Update the position on which the last string ended.
+updateLastStrPos :: (Stream s m a, HasLastStrPosition st) => ParserT s st m ()
+updateLastStrPos = getPosition >>= updateState . setLastStrPos
+
+-- | Whether we are right after the end of a string.
+notAfterString :: (Stream s m a, HasLastStrPosition st) => ParserT s st m Bool
+notAfterString = do
+ pos <- getPosition
+ st <- getState
+ return $ getLastStrPos st /= Just pos
+
+data HeaderType
+ = SingleHeader Char -- ^ Single line of characters underneath
+ | DoubleHeader Char -- ^ Lines of characters above and below
+ deriving (Eq, Show)
+
+data ParserContext
+ = ListItemState -- ^ Used when running parser on list item contents
+ | NullState -- ^ Default state
+ deriving (Eq, Show)
+
+data QuoteContext
+ = InSingleQuote -- ^ Used when parsing inside single quotes
+ | InDoubleQuote -- ^ Used when parsing inside double quotes
+ | NoQuote -- ^ Used when not parsing inside quotes
+ deriving (Eq, Show)
+
+type NoteTable = [(String, String)]
+
+type NoteTable' = [(String, F Blocks)] -- used in markdown reader
+
+newtype Key = Key String deriving (Show, Read, Eq, Ord)
+
+toKey :: String -> Key
+toKey = Key . map toLower . unwords . words . unbracket
+ where unbracket ('[':xs) | "]" `isSuffixOf` xs = take (length xs - 1) xs
+ unbracket xs = xs
+
+type KeyTable = M.Map Key (Target, Attr)
+
+type SubstTable = M.Map Key Inlines
+
+-- | Add header to the list of headers in state, together
+-- with its associated identifier. If the identifier is null
+-- and the auto_identifers extension is set, generate a new
+-- unique identifier, and update the list of identifiers
+-- in state.
+registerHeader :: (Stream s m a, HasReaderOptions st, HasHeaderMap st, HasIdentifierList st)
+ => Attr -> Inlines -> ParserT s st m Attr
+registerHeader (ident,classes,kvs) header' = do
+ ids <- extractIdentifierList <$> getState
+ exts <- getOption readerExtensions
+ let insert' = M.insertWith (\_new old -> old)
+ if null ident && Ext_auto_identifiers `extensionEnabled` exts
+ then do
+ let id' = uniqueIdent (B.toList header') ids
+ let id'' = if Ext_ascii_identifiers `extensionEnabled` exts
+ then catMaybes $ map toAsciiChar id'
+ else id'
+ updateState $ updateIdentifierList $ Set.insert id'
+ updateState $ updateIdentifierList $ Set.insert id''
+ updateState $ updateHeaderMap $ insert' header' id'
+ return (id'',classes,kvs)
+ else do
+ unless (null ident) $
+ updateState $ updateHeaderMap $ insert' header' ident
+ return (ident,classes,kvs)
+
+smartPunctuation :: (HasReaderOptions st, HasLastStrPosition st, HasQuoteContext st m, Stream s m Char)
+ => ParserT s st m Inlines
+ -> ParserT s st m Inlines
+smartPunctuation inlineParser = do
+ guardEnabled Ext_smart
+ choice [ quoted inlineParser, apostrophe, dash, ellipses ]
+
+apostrophe :: Stream s m Char => ParserT s st m Inlines
+apostrophe = (char '\'' <|> char '\8217') >> return (B.str "\x2019")
+
+quoted :: (HasLastStrPosition st, HasQuoteContext st m, Stream s m Char)
+ => ParserT s st m Inlines
+ -> ParserT s st m Inlines
+quoted inlineParser = doubleQuoted inlineParser <|> singleQuoted inlineParser
+
+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
+
+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
+
+failIfInQuoteContext :: (HasQuoteContext st m, Stream s m t)
+ => QuoteContext
+ -> ParserT s st m ()
+failIfInQuoteContext context = do
+ context' <- getQuoteContext
+ if context' == context
+ then fail "already inside quotes"
+ else return ()
+
+charOrRef :: Stream s m Char => String -> ParserT s st m Char
+charOrRef cs =
+ oneOf cs <|> try (do c <- characterReference
+ guard (c `elem` cs)
+ return c)
+
+singleQuoteStart :: (HasLastStrPosition st, HasQuoteContext st m, Stream s m Char)
+ => ParserT s st m ()
+singleQuoteStart = do
+ failIfInQuoteContext InSingleQuote
+ -- single quote start can't be right after str
+ guard =<< notAfterString
+ () <$ charOrRef "'\8216\145"
+
+singleQuoteEnd :: Stream s m Char
+ => ParserT s st m ()
+singleQuoteEnd = try $ do
+ charOrRef "'\8217\146"
+ notFollowedBy alphaNum
+
+doubleQuoteStart :: (HasQuoteContext st m, Stream s m Char)
+ => ParserT s st m ()
+doubleQuoteStart = do
+ failIfInQuoteContext InDoubleQuote
+ try $ do charOrRef "\"\8220\147"
+ notFollowedBy . satisfy $ flip elem [' ', '\t', '\n']
+
+doubleQuoteEnd :: Stream s m Char
+ => ParserT s st m ()
+doubleQuoteEnd = void (charOrRef "\"\8221\148")
+
+ellipses :: Stream s m Char
+ => ParserT s st m Inlines
+ellipses = try (string "..." >> return (B.str "\8230"))
+
+dash :: (HasReaderOptions st, Stream s m Char)
+ => ParserT s st m Inlines
+dash = try $ do
+ oldDashes <- extensionEnabled Ext_old_dashes <$> getOption readerExtensions
+ if oldDashes
+ then do
+ char '-'
+ (char '-' >> return (B.str "\8212"))
+ <|> (lookAhead digit >> return (B.str "\8211"))
+ else do
+ string "--"
+ (char '-' >> return (B.str "\8212"))
+ <|> return (B.str "\8211")
+
+-- This is used to prevent exponential blowups for things like:
+-- a**a*a**a*a**a*a**a*a**a*a**a*a**
+nested :: Stream s m a
+ => ParserT s ParserState m a
+ -> ParserT s ParserState m a
+nested p = do
+ nestlevel <- stateMaxNestingLevel <$> getState
+ guard $ nestlevel > 0
+ updateState $ \st -> st{ stateMaxNestingLevel = stateMaxNestingLevel st - 1 }
+ res <- p
+ updateState $ \st -> st{ stateMaxNestingLevel = nestlevel }
+ return res
+
+citeKey :: (Stream s m Char, HasLastStrPosition st)
+ => ParserT s st m (Bool, String)
+citeKey = try $ do
+ guard =<< notAfterString
+ suppress_author <- option False (char '-' *> return True)
+ char '@'
+ firstChar <- alphaNum <|> char '_' <|> char '*' -- @* for wildcard in nocite
+ let regchar = satisfy (\c -> isAlphaNum c || c == '_')
+ let internal p = try $ p <* lookAhead regchar
+ rest <- many $ regchar <|> internal (oneOf ":.#$%&-+?<>~/") <|>
+ try (oneOf ":/" <* lookAhead (char '/'))
+ let key = firstChar:rest
+ return (suppress_author, key)
+
+
+token :: (Stream s m t)
+ => (t -> String)
+ -> (t -> SourcePos)
+ -> (t -> Maybe a)
+ -> ParsecT s st m a
+token pp pos match = tokenPrim pp (\_ t _ -> pos t) match
+
+--
+-- Macros
+--
+
+-- | Parse a \newcommand or \renewcommand macro definition.
+macro :: (Stream [Char] m Char, HasMacros st, HasReaderOptions st)
+ => ParserT [Char] st m Blocks
+macro = do
+ apply <- getOption readerApplyMacros
+ inp <- getInput
+ case parseMacroDefinitions inp of
+ ([], _) -> mzero
+ (ms, rest) -> do def' <- count (length inp - length rest) anyChar
+ if apply
+ then do
+ updateState $ \st ->
+ updateMacros (ms ++) st
+ return mempty
+ else return $ rawBlock "latex" def'
+
+-- | Apply current macros to string.
+applyMacros' :: (HasReaderOptions st, HasMacros st, Stream [Char] m Char)
+ => String
+ -> ParserT [Char] st m String
+applyMacros' target = do
+ apply <- getOption readerApplyMacros
+ if apply
+ then do macros <- extractMacros <$> getState
+ return $ applyMacros macros target
+ else return target
+
+infixr 5 <+?>
+(<+?>) :: (Monoid a) => ParserT s st m a -> ParserT s st m a -> ParserT s st m a
+a <+?> b = a >>= flip fmap (try b <|> return mempty) . (<>)
+
+extractIdClass :: Attr -> Attr
+extractIdClass (ident, cls, kvs) = (ident', cls', kvs')
+ where
+ ident' = case (lookup "id" kvs) of
+ Just v -> v
+ Nothing -> ident
+ cls' = case (lookup "class" kvs) of
+ Just cl -> words cl
+ Nothing -> cls
+ kvs' = filter (\(k,_) -> k /= "id" || k /= "class") kvs
+
+insertIncludedFile :: PandocMonad m
+ => ParserT String ParserState m Blocks
+ -> [FilePath] -> FilePath
+ -> ParserT String ParserState m Blocks
+insertIncludedFile blocks dirs f = do
+ oldPos <- getPosition
+ oldInput <- getInput
+ containers <- stateContainers <$> getState
+ when (f `elem` containers) $
+ throwError $ PandocParseError $ "Include file loop at " ++ show oldPos
+ updateState $ \s -> s{ stateContainers = f : stateContainers s }
+ mbcontents <- readFileFromDirs dirs f
+ contents <- case mbcontents of
+ Just s -> return s
+ Nothing -> do
+ report $ CouldNotLoadIncludeFile f oldPos
+ return ""
+ setPosition $ newPos f 1 1
+ setInput contents
+ bs <- blocks
+ setInput oldInput
+ setPosition oldPos
+ updateState $ \s -> s{ stateContainers = tail $ stateContainers s }
+ return bs
diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs
new file mode 100644
index 000000000..256f38b0c
--- /dev/null
+++ b/src/Text/Pandoc/Pretty.hs
@@ -0,0 +1,557 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving, CPP #-}
+{-
+Copyright (C) 2010-2016 John MacFarlane <jgm@berkeley.edu>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111(-1)307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Pretty
+ Copyright : Copyright (C) 2010-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+A prettyprinting library for the production of text documents,
+including wrapped text, indentated blocks, and tables.
+-}
+
+module Text.Pandoc.Pretty (
+ Doc
+ , render
+ , cr
+ , blankline
+ , blanklines
+ , space
+ , text
+ , char
+ , prefixed
+ , flush
+ , nest
+ , hang
+ , beforeNonBlank
+ , nowrap
+ , afterBreak
+ , offset
+ , minOffset
+ , height
+ , lblock
+ , cblock
+ , rblock
+ , (<>)
+ , (<+>)
+ , ($$)
+ , ($+$)
+ , isEmpty
+ , empty
+ , cat
+ , hcat
+ , hsep
+ , vcat
+ , vsep
+ , nestle
+ , chomp
+ , inside
+ , braces
+ , brackets
+ , parens
+ , quotes
+ , doubleQuotes
+ , charWidth
+ , realLength
+ )
+
+where
+import Data.Sequence (Seq, fromList, (<|), singleton, mapWithIndex, viewl, ViewL(..))
+import qualified Data.Sequence as Seq
+import Data.Foldable (toList)
+import Data.List (intersperse)
+import Data.String
+import Control.Monad.State
+import Data.Char (isSpace)
+import Data.Monoid ((<>))
+
+data RenderState a = RenderState{
+ output :: [a] -- ^ In reverse order
+ , prefix :: String
+ , usePrefix :: Bool
+ , lineLength :: Maybe Int -- ^ 'Nothing' means no wrapping
+ , column :: Int
+ , newlines :: Int -- ^ Number of preceding newlines
+ }
+
+type DocState a = State (RenderState a) ()
+
+data D = Text Int String
+ | Block Int [String]
+ | Prefixed String Doc
+ | BeforeNonBlank Doc
+ | Flush Doc
+ | BreakingSpace
+ | AfterBreak String
+ | CarriageReturn
+ | NewLine
+ | BlankLines Int -- number of blank lines
+ deriving (Show)
+
+newtype Doc = Doc { unDoc :: Seq D }
+ deriving (Monoid, Show)
+
+instance IsString Doc where
+ fromString = text
+
+isBlank :: D -> Bool
+isBlank BreakingSpace = True
+isBlank CarriageReturn = True
+isBlank NewLine = True
+isBlank (BlankLines _) = True
+isBlank (Text _ (c:_)) = isSpace c
+isBlank _ = False
+
+-- | True if the document is empty.
+isEmpty :: Doc -> Bool
+isEmpty = Seq.null . unDoc
+
+-- | The empty document.
+empty :: Doc
+empty = mempty
+
+-- | Concatenate a list of 'Doc's.
+cat :: [Doc] -> Doc
+cat = mconcat
+
+-- | Same as 'cat'.
+hcat :: [Doc] -> Doc
+hcat = mconcat
+
+-- | Concatenate a list of 'Doc's, putting breakable spaces
+-- between them.
+infixr 6 <+>
+(<+>) :: Doc -> Doc -> Doc
+(<+>) x y = if isEmpty x
+ then y
+ else if isEmpty y
+ then x
+ else x <> space <> y
+
+-- | Same as 'cat', but putting breakable spaces between the
+-- 'Doc's.
+hsep :: [Doc] -> Doc
+hsep = foldr (<+>) empty
+
+infixr 5 $$
+-- | @a $$ b@ puts @a@ above @b@.
+($$) :: Doc -> Doc -> Doc
+($$) x y = if isEmpty x
+ then y
+ else if isEmpty y
+ then x
+ else x <> cr <> y
+
+infixr 5 $+$
+-- | @a $+$ b@ puts @a@ above @b@, with a blank line between.
+($+$) :: Doc -> Doc -> Doc
+($+$) x y = if isEmpty x
+ then y
+ else if isEmpty y
+ then x
+ else x <> blankline <> y
+
+-- | List version of '$$'.
+vcat :: [Doc] -> Doc
+vcat = foldr ($$) empty
+
+-- | List version of '$+$'.
+vsep :: [Doc] -> Doc
+vsep = foldr ($+$) empty
+
+-- | Removes leading blank lines from a 'Doc'.
+nestle :: Doc -> Doc
+nestle (Doc d) = Doc $ go d
+ where go x = case viewl x of
+ (BlankLines _ :< rest) -> go rest
+ (NewLine :< rest) -> go rest
+ _ -> x
+
+-- | Chomps trailing blank space off of a 'Doc'.
+chomp :: Doc -> Doc
+chomp d = Doc (fromList dl')
+ where dl = toList (unDoc d)
+ dl' = reverse $ go $ reverse dl
+ go [] = []
+ go (BreakingSpace : xs) = go xs
+ go (CarriageReturn : xs) = go xs
+ go (NewLine : xs) = go xs
+ go (BlankLines _ : xs) = go xs
+ go (Prefixed s d' : xs) = Prefixed s (chomp d') : xs
+ go xs = xs
+
+outp :: (IsString a) => Int -> String -> DocState a
+outp off s | off < 0 = do -- offset < 0 means newline characters
+ st' <- get
+ let rawpref = prefix st'
+ when (column st' == 0 && usePrefix st' && not (null rawpref)) $ do
+ let pref = reverse $ dropWhile isSpace $ reverse rawpref
+ modify $ \st -> st{ output = fromString pref : output st
+ , column = column st + realLength pref }
+ let numnewlines = length $ takeWhile (=='\n') $ reverse s
+ modify $ \st -> st { output = fromString s : output st
+ , column = 0
+ , newlines = newlines st + numnewlines }
+outp off s = do -- offset >= 0 (0 might be combining char)
+ st' <- get
+ let pref = prefix st'
+ when (column st' == 0 && usePrefix st' && not (null pref)) $ do
+ modify $ \st -> st{ output = fromString pref : output st
+ , column = column st + realLength pref }
+ modify $ \st -> st{ output = fromString s : output st
+ , column = column st + off
+ , newlines = 0 }
+
+-- | Renders a 'Doc'. @render (Just n)@ will use
+-- a line length of @n@ to reflow text on breakable spaces.
+-- @render Nothing@ will not reflow text.
+render :: (IsString a) => Maybe Int -> Doc -> a
+render linelen doc = fromString . mconcat . reverse . output $
+ execState (renderDoc doc) startingState
+ where startingState = RenderState{
+ output = mempty
+ , prefix = ""
+ , usePrefix = True
+ , lineLength = linelen
+ , column = 0
+ , newlines = 2 }
+
+renderDoc :: (IsString a, Monoid a)
+ => Doc -> DocState a
+renderDoc = renderList . toList . unDoc
+
+data IsBlock = IsBlock Int [String]
+
+-- This would be nicer with a pattern synonym
+-- pattern VBlock i s <- mkIsBlock -> Just (IsBlock ..)
+
+renderList :: (IsString a, Monoid a)
+ => [D] -> DocState a
+renderList [] = return ()
+renderList (Text off s : xs) = do
+ outp off s
+ renderList xs
+
+renderList (Prefixed pref d : xs) = do
+ st <- get
+ let oldPref = prefix st
+ put st{ prefix = prefix st ++ pref }
+ renderDoc d
+ modify $ \s -> s{ prefix = oldPref }
+ renderList xs
+
+renderList (Flush d : xs) = do
+ st <- get
+ let oldUsePrefix = usePrefix st
+ put st{ usePrefix = False }
+ renderDoc d
+ modify $ \s -> s{ usePrefix = oldUsePrefix }
+ renderList xs
+
+renderList (BeforeNonBlank d : xs) =
+ case xs of
+ (x:_) | isBlank x -> renderList xs
+ | otherwise -> renderDoc d >> renderList xs
+ [] -> renderList xs
+
+renderList [BlankLines _] = return ()
+
+renderList (BlankLines m : BlankLines n : xs) =
+ renderList (BlankLines (max m n) : xs)
+
+renderList (BlankLines num : xs) = do
+ st <- get
+ case output st of
+ _ | newlines st > num -> return ()
+ | otherwise -> replicateM_ (1 + num - newlines st) (outp (-1) "\n")
+ renderList xs
+
+renderList (CarriageReturn : BlankLines m : xs) =
+ renderList (BlankLines m : xs)
+
+renderList (CarriageReturn : xs) = do
+ st <- get
+ if newlines st > 0 || null xs
+ then renderList xs
+ else do
+ outp (-1) "\n"
+ renderList xs
+
+renderList (NewLine : xs) = do
+ outp (-1) "\n"
+ renderList xs
+
+renderList (BreakingSpace : CarriageReturn : xs) = renderList (CarriageReturn:xs)
+renderList (BreakingSpace : NewLine : xs) = renderList (NewLine:xs)
+renderList (BreakingSpace : BlankLines n : xs) = renderList (BlankLines n:xs)
+renderList (BreakingSpace : BreakingSpace : xs) = renderList (BreakingSpace:xs)
+renderList (BreakingSpace : xs) = do
+ let isText (Text _ _) = True
+ isText (Block _ _) = True
+ isText (AfterBreak _) = True
+ isText _ = False
+ let isBreakingSpace BreakingSpace = True
+ isBreakingSpace _ = False
+ let xs' = dropWhile isBreakingSpace xs
+ let next = takeWhile isText xs'
+ st <- get
+ let off = sum $ map offsetOf next
+ case lineLength st of
+ Just l | column st + 1 + off > l -> do
+ outp (-1) "\n"
+ renderList xs'
+ _ -> do
+ outp 1 " "
+ renderList xs'
+
+renderList (AfterBreak s : xs) = do
+ st <- get
+ if newlines st > 0
+ then outp (realLength s) s
+ else return ()
+ renderList xs
+
+renderList (Block i1 s1 : Block i2 s2 : xs) =
+ renderList (mergeBlocks False (IsBlock i1 s1) (IsBlock i2 s2) : xs)
+
+renderList (Block i1 s1 : BreakingSpace : Block i2 s2 : xs) =
+ renderList (mergeBlocks True (IsBlock i1 s1) (IsBlock i2 s2) : xs)
+
+renderList (Block _width lns : xs) = do
+ st <- get
+ let oldPref = prefix st
+ case column st - realLength oldPref of
+ n | n > 0 -> modify $ \s -> s{ prefix = oldPref ++ replicate n ' ' }
+ _ -> return ()
+ renderList $ intersperse CarriageReturn (map (Text 0) lns)
+ modify $ \s -> s{ prefix = oldPref }
+ renderList xs
+
+mergeBlocks :: Bool -> IsBlock -> IsBlock -> D
+mergeBlocks addSpace (IsBlock w1 lns1) (IsBlock w2 lns2) =
+ Block (w1 + w2 + if addSpace then 1 else 0) $
+ zipWith (\l1 l2 -> pad w1 l1 ++ l2) lns1' (map sp lns2')
+ where (lns1', lns2') = case (length lns1, length lns2) of
+ (x, y) | x > y -> (lns1,
+ lns2 ++ replicate (x - y) "")
+ | x < y -> (lns1 ++ replicate (y - x) "",
+ lns2)
+ | otherwise -> (lns1, lns2)
+ pad n s = s ++ replicate (n - realLength s) ' '
+ sp "" = ""
+ sp xs = if addSpace then (' ' : xs) else xs
+
+offsetOf :: D -> Int
+offsetOf (Text o _) = o
+offsetOf (Block w _) = w
+offsetOf BreakingSpace = 1
+offsetOf _ = 0
+
+-- | A literal string.
+text :: String -> Doc
+text = Doc . toChunks
+ where toChunks :: String -> Seq D
+ toChunks [] = mempty
+ toChunks s = case break (=='\n') s of
+ ([], _:ys) -> NewLine <| toChunks ys
+ (xs, _:ys) -> Text (realLength xs) xs <|
+ (NewLine <| toChunks ys)
+ (xs, []) -> singleton $ Text (realLength xs) xs
+
+-- | A character.
+char :: Char -> Doc
+char c = text [c]
+
+-- | A breaking (reflowable) space.
+space :: Doc
+space = Doc $ singleton BreakingSpace
+
+-- | A carriage return. Does nothing if we're at the beginning of
+-- a line; otherwise inserts a newline.
+cr :: Doc
+cr = Doc $ singleton CarriageReturn
+
+-- | Inserts a blank line unless one exists already.
+-- (@blankline <> blankline@ has the same effect as @blankline@.
+blankline :: Doc
+blankline = Doc $ singleton (BlankLines 1)
+
+-- | Inserts a blank lines unless they exists already.
+-- (@blanklines m <> blanklines n@ has the same effect as @blankline (max m n)@.
+blanklines :: Int -> Doc
+blanklines n = Doc $ singleton (BlankLines n)
+
+-- | Uses the specified string as a prefix for every line of
+-- the inside document (except the first, if not at the beginning
+-- of the line).
+prefixed :: String -> Doc -> Doc
+prefixed pref doc = Doc $ singleton $ Prefixed pref doc
+
+-- | Makes a 'Doc' flush against the left margin.
+flush :: Doc -> Doc
+flush doc = Doc $ singleton $ Flush doc
+
+-- | Indents a 'Doc' by the specified number of spaces.
+nest :: Int -> Doc -> Doc
+nest ind = prefixed (replicate ind ' ')
+
+-- | A hanging indent. @hang ind start doc@ prints @start@,
+-- then @doc@, leaving an indent of @ind@ spaces on every
+-- line but the first.
+hang :: Int -> Doc -> Doc -> Doc
+hang ind start doc = start <> nest ind doc
+
+-- | @beforeNonBlank d@ conditionally includes @d@ unless it is
+-- followed by blank space.
+beforeNonBlank :: Doc -> Doc
+beforeNonBlank d = Doc $ singleton (BeforeNonBlank d)
+
+-- | Makes a 'Doc' non-reflowable.
+nowrap :: Doc -> Doc
+nowrap doc = Doc $ mapWithIndex replaceSpace $ unDoc doc
+ where replaceSpace _ BreakingSpace = Text 1 " "
+ replaceSpace _ x = x
+
+-- | Content to print only if it comes at the beginning of a line,
+-- to be used e.g. for escaping line-initial `.` in groff 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
+
+-- | Returns the minimal width of a 'Doc' when reflowed at breakable spaces.
+minOffset :: Doc -> Int
+minOffset d = maximum (0: map realLength (lines $ render (Just 0) d))
+
+-- | @lblock n d@ is a block of width @n@ characters, with
+-- text derived from @d@ and aligned to the left.
+lblock :: Int -> Doc -> Doc
+lblock = block id
+
+-- | Like 'lblock' but aligned to the right.
+rblock :: Int -> Doc -> Doc
+rblock w = block (\s -> replicate (w - realLength s) ' ' ++ s) w
+
+-- | Like 'lblock' but aligned centered.
+cblock :: Int -> Doc -> Doc
+cblock w = block (\s -> replicate ((w - realLength s) `div` 2) ' ' ++ s) w
+
+-- | Returns the height of a block or other 'Doc'.
+height :: Doc -> Int
+height = length . lines . render Nothing
+
+block :: (String -> String) -> Int -> Doc -> Doc
+block filler width d
+ | width < 1 && not (isEmpty d) = error "Text.Pandoc.Pretty.block: width < 1"
+ | otherwise = Doc $ singleton $ Block width $ map filler
+ $ chop width $ render (Just width) d
+
+chop :: Int -> String -> [String]
+chop _ [] = []
+chop n cs = case break (=='\n') cs of
+ (xs, ys) -> if len <= n
+ then case ys of
+ [] -> [xs]
+ ['\n'] -> [xs]
+ (_:zs) -> xs : chop n zs
+ else take n xs : chop n (drop n xs ++ ys)
+ where len = realLength xs
+
+-- | Encloses a 'Doc' inside a start and end 'Doc'.
+inside :: Doc -> Doc -> Doc -> Doc
+inside start end contents =
+ start <> contents <> end
+
+-- | Puts a 'Doc' in curly braces.
+braces :: Doc -> Doc
+braces = inside (char '{') (char '}')
+
+-- | Puts a 'Doc' in square brackets.
+brackets :: Doc -> Doc
+brackets = inside (char '[') (char ']')
+
+-- | Puts a 'Doc' in parentheses.
+parens :: Doc -> Doc
+parens = inside (char '(') (char ')')
+
+-- | Wraps a 'Doc' in single quotes.
+quotes :: Doc -> Doc
+quotes = inside (char '\'') (char '\'')
+
+-- | Wraps a 'Doc' in double quotes.
+doubleQuotes :: Doc -> Doc
+doubleQuotes = inside (char '"') (char '"')
+
+-- | Returns width of a character in a monospace font: 0 for a combining
+-- character, 1 for a regular character, 2 for an East Asian wide character.
+charWidth :: Char -> Int
+charWidth c =
+ case c of
+ _ | c < '\x0300' -> 1
+ | c >= '\x0300' && c <= '\x036F' -> 0 -- combining
+ | c >= '\x0370' && c <= '\x10FC' -> 1
+ | c >= '\x1100' && c <= '\x115F' -> 2
+ | c >= '\x1160' && c <= '\x11A2' -> 1
+ | c >= '\x11A3' && c <= '\x11A7' -> 2
+ | c >= '\x11A8' && c <= '\x11F9' -> 1
+ | c >= '\x11FA' && c <= '\x11FF' -> 2
+ | c >= '\x1200' && c <= '\x2328' -> 1
+ | c >= '\x2329' && c <= '\x232A' -> 2
+ | c >= '\x232B' && c <= '\x2E31' -> 1
+ | c >= '\x2E80' && c <= '\x303E' -> 2
+ | c == '\x303F' -> 1
+ | c >= '\x3041' && c <= '\x3247' -> 2
+ | c >= '\x3248' && c <= '\x324F' -> 1 -- ambiguous
+ | c >= '\x3250' && c <= '\x4DBF' -> 2
+ | c >= '\x4DC0' && c <= '\x4DFF' -> 1
+ | c >= '\x4E00' && c <= '\xA4C6' -> 2
+ | c >= '\xA4D0' && c <= '\xA95F' -> 1
+ | c >= '\xA960' && c <= '\xA97C' -> 2
+ | c >= '\xA980' && c <= '\xABF9' -> 1
+ | c >= '\xAC00' && c <= '\xD7FB' -> 2
+ | c >= '\xD800' && c <= '\xDFFF' -> 1
+ | c >= '\xE000' && c <= '\xF8FF' -> 1 -- ambiguous
+ | c >= '\xF900' && c <= '\xFAFF' -> 2
+ | c >= '\xFB00' && c <= '\xFDFD' -> 1
+ | c >= '\xFE00' && c <= '\xFE0F' -> 1 -- ambiguous
+ | c >= '\xFE10' && c <= '\xFE19' -> 2
+ | c >= '\xFE20' && c <= '\xFE26' -> 1
+ | c >= '\xFE30' && c <= '\xFE6B' -> 2
+ | c >= '\xFE70' && c <= '\xFEFF' -> 1
+ | c >= '\xFF01' && c <= '\xFF60' -> 2
+ | c >= '\xFF61' && c <= '\x16A38' -> 1
+ | c >= '\x1B000' && c <= '\x1B001' -> 2
+ | c >= '\x1D000' && c <= '\x1F1FF' -> 1
+ | c >= '\x1F200' && c <= '\x1F251' -> 2
+ | c >= '\x1F300' && c <= '\x1F773' -> 1
+ | c >= '\x20000' && c <= '\x3FFFD' -> 2
+ | otherwise -> 1
+
+-- | Get real length of string, taking into account combining and double-wide
+-- characters.
+realLength :: String -> Int
+realLength = foldr (\a b -> charWidth a + b) 0
diff --git a/src/Text/Pandoc/Process.hs b/src/Text/Pandoc/Process.hs
new file mode 100644
index 000000000..294a38a1b
--- /dev/null
+++ b/src/Text/Pandoc/Process.hs
@@ -0,0 +1,98 @@
+{-
+Copyright (C) 2013-2016 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.Process
+ Copyright : Copyright (C) 2013-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+ByteString variant of 'readProcessWithExitCode'.
+-}
+module Text.Pandoc.Process (pipeProcess)
+where
+import System.Process
+import System.Exit (ExitCode (..))
+import Control.Exception
+import System.IO (hClose, hFlush)
+import Control.Concurrent (putMVar, takeMVar, newEmptyMVar, forkIO)
+import Control.Monad (unless)
+import qualified Data.ByteString.Lazy as BL
+
+{- |
+Version of 'System.Process.readProcessWithExitCode' that uses lazy bytestrings
+instead of strings and allows setting environment variables.
+
+@readProcessWithExitCode@ creates an external process, reads its
+standard output strictly, waits until the process
+terminates, and then returns the 'ExitCode' of the process
+and the standard output. stderr is inherited from the parent.
+
+If an asynchronous exception is thrown to the thread executing
+@readProcessWithExitCode@, the forked process will be terminated and
+@readProcessWithExitCode@ will wait (block) until the process has been
+terminated.
+-}
+
+pipeProcess
+ :: Maybe [(String, String)] -- ^ environment variables
+ -> FilePath -- ^ Filename of the executable (see 'proc' for details)
+ -> [String] -- ^ any arguments
+ -> BL.ByteString -- ^ standard input
+ -> IO (ExitCode,BL.ByteString) -- ^ exitcode, stdout
+pipeProcess mbenv cmd args input =
+ mask $ \restore -> do
+ (Just inh, Just outh, Nothing, pid) <- createProcess (proc cmd args)
+ { env = mbenv,
+ std_in = CreatePipe,
+ std_out = CreatePipe,
+ std_err = Inherit }
+ flip onException
+ (do hClose inh; hClose outh;
+ terminateProcess pid; waitForProcess pid) $ restore $ do
+ -- fork off a thread to start consuming stdout
+ out <- BL.hGetContents outh
+ waitOut <- forkWait $ evaluate $ BL.length out
+
+ -- now write and flush any input
+ let writeInput = do
+ unless (BL.null input) $ do
+ BL.hPutStr inh input
+ hFlush inh
+ hClose inh
+
+ writeInput
+
+ -- wait on the output
+ waitOut
+
+ hClose outh
+
+ -- wait on the process
+ ex <- waitForProcess pid
+
+ return (ex, out)
+
+forkWait :: IO a -> IO (IO a)
+forkWait a = do
+ res <- newEmptyMVar
+ _ <- mask $ \restore -> forkIO $ try (restore a) >>= putMVar res
+ return (takeMVar res >>= either (\ex -> throwIO (ex :: SomeException)) return)
diff --git a/src/Text/Pandoc/Readers/CommonMark.hs b/src/Text/Pandoc/Readers/CommonMark.hs
new file mode 100644
index 000000000..b0bcbd580
--- /dev/null
+++ b/src/Text/Pandoc/Readers/CommonMark.hs
@@ -0,0 +1,128 @@
+{-
+Copyright (C) 2015 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.CommonMark
+ Copyright : Copyright (C) 2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of CommonMark-formatted plain text to 'Pandoc' document.
+
+CommonMark is a strongly specified variant of Markdown: http://commonmark.org.
+-}
+module Text.Pandoc.Readers.CommonMark (readCommonMark)
+where
+
+import CMark
+import Data.Text (unpack, pack)
+import Data.List (groupBy)
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Text.Pandoc.Class (PandocMonad)
+
+-- | Parse a CommonMark formatted string into a 'Pandoc' structure.
+readCommonMark :: PandocMonad m => ReaderOptions -> String -> m Pandoc
+readCommonMark opts s = return $
+ nodeToPandoc $ commonmarkToNode opts' $ pack s
+ where opts' = if extensionEnabled Ext_smart (readerExtensions opts)
+ then [optNormalize, optSmart]
+ else [optNormalize]
+
+nodeToPandoc :: Node -> Pandoc
+nodeToPandoc (Node _ DOCUMENT nodes) =
+ Pandoc nullMeta $ foldr addBlock [] nodes
+nodeToPandoc n = -- shouldn't happen
+ Pandoc nullMeta $ foldr addBlock [] [n]
+
+addBlocks :: [Node] -> [Block]
+addBlocks = foldr addBlock []
+
+addBlock :: Node -> [Block] -> [Block]
+addBlock (Node _ PARAGRAPH nodes) =
+ (Para (addInlines nodes) :)
+addBlock (Node _ THEMATIC_BREAK _) =
+ (HorizontalRule :)
+addBlock (Node _ BLOCK_QUOTE nodes) =
+ (BlockQuote (addBlocks nodes) :)
+addBlock (Node _ (HTML_BLOCK t) _) =
+ (RawBlock (Format "html") (unpack t) :)
+-- Note: the cmark parser will never generate CUSTOM_BLOCK,
+-- so we don't need to handle it:
+addBlock (Node _ (CUSTOM_BLOCK _onEnter _onExit) _nodes) =
+ id
+addBlock (Node _ (CODE_BLOCK info t) _) =
+ (CodeBlock ("", take 1 (words (unpack info)), []) (unpack t) :)
+addBlock (Node _ (HEADING lev) nodes) =
+ (Header lev ("",[],[]) (addInlines nodes) :)
+addBlock (Node _ (LIST listAttrs) nodes) =
+ (constructor (map (setTightness . addBlocks . children) nodes) :)
+ where constructor = case listType listAttrs of
+ BULLET_LIST -> BulletList
+ ORDERED_LIST -> OrderedList
+ (start, DefaultStyle, delim)
+ start = listStart listAttrs
+ setTightness = if listTight listAttrs
+ then map paraToPlain
+ else id
+ paraToPlain (Para xs) = Plain (xs)
+ paraToPlain x = x
+ delim = case listDelim listAttrs of
+ PERIOD_DELIM -> Period
+ PAREN_DELIM -> OneParen
+addBlock (Node _ ITEM _) = id -- handled in LIST
+addBlock _ = id
+
+children :: Node -> [Node]
+children (Node _ _ ns) = ns
+
+addInlines :: [Node] -> [Inline]
+addInlines = foldr addInline []
+
+addInline :: Node -> [Inline] -> [Inline]
+addInline (Node _ (TEXT t) _) = (map toinl clumps ++)
+ where raw = unpack t
+ clumps = groupBy samekind raw
+ samekind ' ' ' ' = True
+ samekind ' ' _ = False
+ samekind _ ' ' = False
+ samekind _ _ = True
+ toinl (' ':_) = Space
+ toinl xs = Str xs
+addInline (Node _ LINEBREAK _) = (LineBreak :)
+addInline (Node _ SOFTBREAK _) = (SoftBreak :)
+addInline (Node _ (HTML_INLINE t) _) =
+ (RawInline (Format "html") (unpack t) :)
+-- Note: the cmark parser will never generate CUSTOM_BLOCK,
+-- so we don't need to handle it:
+addInline (Node _ (CUSTOM_INLINE _onEnter _onExit) _nodes) =
+ id
+addInline (Node _ (CODE t) _) =
+ (Code ("",[],[]) (unpack t) :)
+addInline (Node _ EMPH nodes) =
+ (Emph (addInlines nodes) :)
+addInline (Node _ STRONG nodes) =
+ (Strong (addInlines nodes) :)
+addInline (Node _ (LINK url title) nodes) =
+ (Link nullAttr (addInlines nodes) (unpack url, unpack title) :)
+addInline (Node _ (IMAGE url title) nodes) =
+ (Image nullAttr (addInlines nodes) (unpack url, unpack title) :)
+addInline _ = id
diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs
new file mode 100644
index 000000000..bef256a93
--- /dev/null
+++ b/src/Text/Pandoc/Readers/DocBook.hs
@@ -0,0 +1,1055 @@
+module Text.Pandoc.Readers.DocBook ( readDocBook ) where
+import Data.Char (toUpper)
+import Text.Pandoc.Shared (safeRead)
+import Text.Pandoc.Options
+import Text.Pandoc.Definition
+import Text.Pandoc.Builder
+import Text.XML.Light
+import Text.HTML.TagSoup.Entity (lookupEntity)
+import Data.Either (rights)
+import Data.Generics
+import Data.Char (isSpace)
+import Control.Monad.State
+import Data.List (intersperse)
+import Data.Maybe (fromMaybe)
+import Text.TeXMath (readMathML, writeTeX)
+import Data.Default
+import Data.Foldable (asum)
+import Text.Pandoc.Class (PandocMonad)
+
+{-
+
+List of all DocBook tags, with [x] indicating implemented,
+[o] meaning intentionally left unimplemented (pass through):
+
+[o] abbrev - An abbreviation, especially one followed by a period
+[x] abstract - A summary
+[o] accel - A graphical user interface (GUI) keyboard shortcut
+[x] ackno - Acknowledgements in an Article
+[o] acronym - An often pronounceable word made from the initial
+[o] action - A response to a user event
+[o] address - A real-world address, generally a postal address
+[ ] affiliation - The institutional affiliation of an individual
+[ ] alt - Text representation for a graphical element
+[o] anchor - A spot in the document
+[x] answer - An answer to a question posed in a QandASet
+[x] appendix - An appendix in a Book or Article
+[x] appendixinfo - Meta-information for an Appendix
+[o] application - The name of a software program
+[x] area - A region defined for a Callout in a graphic or code example
+[x] areaset - A set of related areas in a graphic or code example
+[x] areaspec - A collection of regions in a graphic or code example
+[ ] arg - An argument in a CmdSynopsis
+[x] article - An article
+[x] articleinfo - Meta-information for an Article
+[ ] artpagenums - The page numbers of an article as published
+[x] attribution - The source of a block quote or epigraph
+[ ] audiodata - Pointer to external audio data
+[ ] audioobject - A wrapper for audio data and its associated meta-information
+[x] author - The name of an individual author
+[ ] authorblurb - A short description or note about an author
+[x] authorgroup - Wrapper for author information when a document has
+ multiple authors or collabarators
+[x] authorinitials - The initials or other short identifier for an author
+[o] beginpage - The location of a page break in a print version of the document
+[ ] bibliocoverage - The spatial or temporal coverage of a document
+[x] bibliodiv - A section of a Bibliography
+[x] biblioentry - An entry in a Bibliography
+[x] bibliography - A bibliography
+[ ] bibliographyinfo - Meta-information for a Bibliography
+[ ] biblioid - An identifier for a document
+[o] bibliolist - A wrapper for a set of bibliography entries
+[ ] bibliomisc - Untyped bibliographic information
+[x] bibliomixed - An entry in a Bibliography
+[ ] bibliomset - A cooked container for related bibliographic information
+[ ] biblioref - A cross reference to a bibliographic entry
+[ ] bibliorelation - The relationship of a document to another
+[ ] biblioset - A raw container for related bibliographic information
+[ ] bibliosource - The source of a document
+[ ] blockinfo - Meta-information for a block element
+[x] blockquote - A quotation set off from the main text
+[x] book - A book
+[x] bookinfo - Meta-information for a Book
+[x] bridgehead - A free-floating heading
+[x] callout - A “called out” description of a marked Area
+[x] calloutlist - A list of Callouts
+[x] caption - A caption
+[x] caution - A note of caution
+[x] chapter - A chapter, as of a book
+[x] chapterinfo - Meta-information for a Chapter
+[ ] citation - An inline bibliographic reference to another published work
+[ ] citebiblioid - A citation of a bibliographic identifier
+[ ] citerefentry - A citation to a reference page
+[ ] citetitle - The title of a cited work
+[ ] city - The name of a city in an address
+[x] classname - The name of a class, in the object-oriented programming sense
+[ ] classsynopsis - The syntax summary for a class definition
+[ ] classsynopsisinfo - Information supplementing the contents of
+ a ClassSynopsis
+[ ] cmdsynopsis - A syntax summary for a software command
+[ ] co - The location of a callout embedded in text
+[x] code - An inline code fragment
+[x] col - Specifications for a column in an HTML table
+[x] colgroup - A group of columns in an HTML table
+[ ] collab - Identifies a collaborator
+[ ] collabname - The name of a collaborator
+[ ] colophon - Text at the back of a book describing facts about its production
+[x] colspec - Specifications for a column in a table
+[x] command - The name of an executable program or other software command
+[x] computeroutput - Data, generally text, displayed or presented by a computer
+[ ] confdates - The dates of a conference for which a document was written
+[ ] confgroup - A wrapper for document meta-information about a conference
+[ ] confnum - An identifier, frequently numerical, associated with a conference for which a document was written
+[ ] confsponsor - The sponsor of a conference for which a document was written
+[ ] conftitle - The title of a conference for which a document was written
+[x] constant - A programming or system constant
+[ ] constraint - A constraint in an EBNF production
+[ ] constraintdef - The definition of a constraint in an EBNF production
+[ ] constructorsynopsis - A syntax summary for a constructor
+[ ] contractnum - The contract number of a document
+[ ] contractsponsor - The sponsor of a contract
+[ ] contrib - A summary of the contributions made to a document by a
+ credited source
+[ ] copyright - Copyright information about a document
+[ ] coref - A cross reference to a co
+[ ] corpauthor - A corporate author, as opposed to an individual
+[ ] corpcredit - A corporation or organization credited in a document
+[ ] corpname - The name of a corporation
+[ ] country - The name of a country
+[ ] database - The name of a database, or part of a database
+[x] date - The date of publication or revision of a document
+[ ] dedication - A wrapper for the dedication section of a book
+[ ] destructorsynopsis - A syntax summary for a destructor
+[ ] edition - The name or number of an edition of a document
+[ ] editor - The name of the editor of a document
+[x] email - An email address
+[x] emphasis - Emphasized text
+[x] entry - A cell in a table
+[ ] entrytbl - A subtable appearing in place of an Entry in a table
+[ ] envar - A software environment variable
+[x] epigraph - A short inscription at the beginning of a document or component
+ note: also handle embedded attribution tag
+[x] equation - A displayed mathematical equation
+[ ] errorcode - An error code
+[ ] errorname - An error name
+[ ] errortext - An error message.
+[ ] errortype - The classification of an error message
+[ ] example - A formal example, with a title
+[ ] exceptionname - The name of an exception
+[ ] fax - A fax number
+[ ] fieldsynopsis - The name of a field in a class definition
+[x] figure - A formal figure, generally an illustration, with a title
+[x] filename - The name of a file
+[ ] firstname - The first name of a person
+[ ] firstterm - The first occurrence of a term
+[x] footnote - A footnote
+[ ] footnoteref - A cross reference to a footnote (a footnote mark)
+[x] foreignphrase - A word or phrase in a language other than the primary
+ language of the document
+[x] formalpara - A paragraph with a title
+[ ] funcdef - A function (subroutine) name and its return type
+[ ] funcparams - Parameters for a function referenced through a function
+ pointer in a synopsis
+[ ] funcprototype - The prototype of a function
+[ ] funcsynopsis - The syntax summary for a function definition
+[ ] funcsynopsisinfo - Information supplementing the FuncDefs of a FuncSynopsis
+[x] function - The name of a function or subroutine, as in a
+ programming language
+[x] glossary - A glossary
+[x] glossaryinfo - Meta-information for a Glossary
+[x] glossdef - A definition in a GlossEntry
+[x] glossdiv - A division in a Glossary
+[x] glossentry - An entry in a Glossary or GlossList
+[x] glosslist - A wrapper for a set of GlossEntrys
+[x] glosssee - A cross-reference from one GlossEntry to another
+[x] glossseealso - A cross-reference from one GlossEntry to another
+[x] glossterm - A glossary term
+[ ] graphic - A displayed graphical object (not an inline)
+ Note: in DocBook v5 `graphic` is discarded
+[ ] graphicco - A graphic that contains callout areas
+ Note: in DocBook v5 `graphicco` is discarded
+[ ] group - A group of elements in a CmdSynopsis
+[ ] guibutton - The text on a button in a GUI
+[ ] guiicon - Graphic and/or text appearing as a icon in a GUI
+[ ] guilabel - The text of a label in a GUI
+[x] guimenu - The name of a menu in a GUI
+[x] guimenuitem - The name of a terminal menu item in a GUI
+[x] guisubmenu - The name of a submenu in a GUI
+[ ] hardware - A physical part of a computer system
+[ ] highlights - A summary of the main points of the discussed component
+[ ] holder - The name of the individual or organization that holds a copyright
+[o] honorific - The title of a person
+[ ] html:form - An HTML form
+[x] imagedata - Pointer to external image data (only `fileref` attribute
+ implemented but not `entityref` which would require parsing of the DTD)
+[x] imageobject - A wrapper for image data and its associated meta-information
+[ ] imageobjectco - A wrapper for an image object with callouts
+[x] important - An admonition set off from the text
+[x] index - An index
+[x] indexdiv - A division in an index
+[x] indexentry - An entry in an index
+[x] indexinfo - Meta-information for an Index
+[x] indexterm - A wrapper for terms to be indexed
+[x] info - A wrapper for information about a component or other block. (DocBook v5)
+[x] informalequation - A displayed mathematical equation without a title
+[x] informalexample - A displayed example without a title
+[ ] informalfigure - A untitled figure
+[ ] informaltable - A table without a title
+[ ] initializer - The initializer for a FieldSynopsis
+[x] inlineequation - A mathematical equation or expression occurring inline
+[ ] inlinegraphic - An object containing or pointing to graphical data
+ that will be rendered inline
+[x] inlinemediaobject - An inline media object (video, audio, image, and so on)
+[ ] interface - An element of a GUI
+[ ] interfacename - The name of an interface
+[ ] invpartnumber - An inventory part number
+[ ] isbn - The International Standard Book Number of a document
+[ ] issn - The International Standard Serial Number of a periodical
+[ ] issuenum - The number of an issue of a journal
+[x] itemizedlist - A list in which each entry is marked with a bullet or
+ other dingbat
+[ ] itermset - A set of index terms in the meta-information of a document
+[ ] jobtitle - The title of an individual in an organization
+[x] keycap - The text printed on a key on a keyboard
+[ ] keycode - The internal, frequently numeric, identifier for a key
+ on a keyboard
+[x] keycombo - A combination of input actions
+[ ] keysym - The symbolic name of a key on a keyboard
+[ ] keyword - One of a set of keywords describing the content of a document
+[ ] keywordset - A set of keywords describing the content of a document
+[ ] label - A label on a Question or Answer
+[ ] legalnotice - A statement of legal obligations or requirements
+[ ] lhs - The left-hand side of an EBNF production
+[ ] lineage - The portion of a person's name indicating a relationship to
+ ancestors
+[ ] lineannotation - A comment on a line in a verbatim listing
+[x] link - A hypertext link
+[x] listitem - A wrapper for the elements of a list item
+[x] literal - Inline text that is some literal value
+[x] literallayout - A block of text in which line breaks and white space are
+ to be reproduced faithfully
+[ ] lot - A list of the titles of formal objects (as tables or figures) in
+ a document
+[ ] lotentry - An entry in a list of titles
+[ ] manvolnum - A reference volume number
+[x] markup - A string of formatting markup in text that is to be
+ represented literally
+[ ] mathphrase - A mathematical phrase, an expression that can be represented
+ with ordinary text and a small amount of markup
+[ ] medialabel - A name that identifies the physical medium on which some
+ information resides
+[x] mediaobject - A displayed media object (video, audio, image, etc.)
+[ ] mediaobjectco - A media object that contains callouts
+[x] member - An element of a simple list
+[x] menuchoice - A selection or series of selections from a menu
+[ ] methodname - The name of a method
+[ ] methodparam - Parameters to a method
+[ ] methodsynopsis - A syntax summary for a method
+[x] mml:math - A MathML equation
+[ ] modespec - Application-specific information necessary for the
+ completion of an OLink
+[ ] modifier - Modifiers in a synopsis
+[ ] mousebutton - The conventional name of a mouse button
+[ ] msg - A message in a message set
+[ ] msgaud - The audience to which a message in a message set is relevant
+[ ] msgentry - A wrapper for an entry in a message set
+[ ] msgexplan - Explanatory material relating to a message in a message set
+[ ] msginfo - Information about a message in a message set
+[ ] msglevel - The level of importance or severity of a message in a message set
+[ ] msgmain - The primary component of a message in a message set
+[ ] msgorig - The origin of a message in a message set
+[ ] msgrel - A related component of a message in a message set
+[ ] msgset - A detailed set of messages, usually error messages
+[ ] msgsub - A subcomponent of a message in a message set
+[ ] msgtext - The actual text of a message component in a message set
+[ ] nonterminal - A non-terminal in an EBNF production
+[x] note - A message set off from the text
+[ ] objectinfo - Meta-information for an object
+[ ] olink - A link that addresses its target indirectly, through an entity
+[ ] ooclass - A class in an object-oriented programming language
+[ ] ooexception - An exception in an object-oriented programming language
+[ ] oointerface - An interface in an object-oriented programming language
+[x] option - An option for a software command
+[x] optional - Optional information
+[x] orderedlist - A list in which each entry is marked with a sequentially
+ incremented label
+[ ] orgdiv - A division of an organization
+[ ] orgname - The name of an organization other than a corporation
+[ ] otheraddr - Uncategorized information in address
+[ ] othercredit - A person or entity, other than an author or editor,
+ credited in a document
+[ ] othername - A component of a persons name that is not a first name,
+ surname, or lineage
+[ ] package - A package
+[ ] pagenums - The numbers of the pages in a book, for use in a bibliographic
+ entry
+[x] para - A paragraph
+[ ] paramdef - Information about a function parameter in a programming language
+[x] parameter - A value or a symbolic reference to a value
+[ ] part - A division in a book
+[ ] partinfo - Meta-information for a Part
+[ ] partintro - An introduction to the contents of a part
+[ ] personblurb - A short description or note about a person
+[ ] personname - The personal name of an individual
+[ ] phone - A telephone number
+[ ] phrase - A span of text
+[ ] pob - A post office box in an address
+[ ] postcode - A postal code in an address
+[x] preface - Introductory matter preceding the first chapter of a book
+[ ] prefaceinfo - Meta-information for a Preface
+[ ] primary - The primary word or phrase under which an index term should be
+ sorted
+[ ] primaryie - A primary term in an index entry, not in the text
+[ ] printhistory - The printing history of a document
+[ ] procedure - A list of operations to be performed in a well-defined sequence
+[ ] production - A production in a set of EBNF productions
+[ ] productionrecap - A cross-reference to an EBNF production
+[ ] productionset - A set of EBNF productions
+[ ] productname - The formal name of a product
+[ ] productnumber - A number assigned to a product
+[x] programlisting - A literal listing of all or part of a program
+[ ] programlistingco - A program listing with associated areas used in callouts
+[x] prompt - A character or string indicating the start of an input field in
+ a computer display
+[ ] property - A unit of data associated with some part of a computer system
+[ ] pubdate - The date of publication of a document
+[ ] publisher - The publisher of a document
+[ ] publishername - The name of the publisher of a document
+[ ] pubsnumber - A number assigned to a publication other than an ISBN or ISSN
+ or inventory part number
+[x] qandadiv - A titled division in a QandASet
+[o] qandaentry - A question/answer set within a QandASet
+[o] qandaset - A question-and-answer set
+[x] question - A question in a QandASet
+[x] quote - An inline quotation
+[ ] refclass - The scope or other indication of applicability of a
+ reference entry
+[ ] refdescriptor - A description of the topic of a reference page
+[ ] refentry - A reference page (originally a UNIX man-style reference page)
+[ ] refentryinfo - Meta-information for a Refentry
+[ ] refentrytitle - The title of a reference page
+[ ] reference - A collection of reference entries
+[ ] referenceinfo - Meta-information for a Reference
+[ ] refmeta - Meta-information for a reference entry
+[ ] refmiscinfo - Meta-information for a reference entry other than the title
+ and volume number
+[ ] refname - The name of (one of) the subject(s) of a reference page
+[ ] refnamediv - The name, purpose, and classification of a reference page
+[ ] refpurpose - A short (one sentence) synopsis of the topic of a reference
+ page
+[x] refsect1 - A major subsection of a reference entry
+[x] refsect1info - Meta-information for a RefSect1
+[x] refsect2 - A subsection of a RefSect1
+[x] refsect2info - Meta-information for a RefSect2
+[x] refsect3 - A subsection of a RefSect2
+[x] refsect3info - Meta-information for a RefSect3
+[x] refsection - A recursive section in a refentry
+[x] refsectioninfo - Meta-information for a refsection
+[ ] refsynopsisdiv - A syntactic synopsis of the subject of the reference page
+[ ] refsynopsisdivinfo - Meta-information for a RefSynopsisDiv
+[x] releaseinfo - Information about a particular release of a document
+[ ] remark - A remark (or comment) intended for presentation in a draft
+ manuscript
+[ ] replaceable - Content that may or must be replaced by the user
+[ ] returnvalue - The value returned by a function
+[ ] revdescription - A extended description of a revision to a document
+[ ] revhistory - A history of the revisions to a document
+[ ] revision - An entry describing a single revision in the history of the
+ revisions to a document
+[ ] revnumber - A document revision number
+[ ] revremark - A description of a revision to a document
+[ ] rhs - The right-hand side of an EBNF production
+[x] row - A row in a table
+[ ] sbr - An explicit line break in a command synopsis
+[x] screen - Text that a user sees or might see on a computer screen
+[o] screenco - A screen with associated areas used in callouts
+[o] screeninfo - Information about how a screen shot was produced
+[ ] screenshot - A representation of what the user sees or might see on a
+ computer screen
+[ ] secondary - A secondary word or phrase in an index term
+[ ] secondaryie - A secondary term in an index entry, rather than in the text
+[x] sect1 - A top-level section of document
+[x] sect1info - Meta-information for a Sect1
+[x] sect2 - A subsection within a Sect1
+[x] sect2info - Meta-information for a Sect2
+[x] sect3 - A subsection within a Sect2
+[x] sect3info - Meta-information for a Sect3
+[x] sect4 - A subsection within a Sect3
+[x] sect4info - Meta-information for a Sect4
+[x] sect5 - A subsection within a Sect4
+[x] sect5info - Meta-information for a Sect5
+[x] section - A recursive section
+[x] sectioninfo - Meta-information for a recursive section
+[x] see - Part of an index term directing the reader instead to another entry
+ in the index
+[x] seealso - Part of an index term directing the reader also to another entry
+ in the index
+[ ] seealsoie - A See also entry in an index, rather than in the text
+[ ] seeie - A See entry in an index, rather than in the text
+[x] seg - An element of a list item in a segmented list
+[x] seglistitem - A list item in a segmented list
+[x] segmentedlist - A segmented list, a list of sets of elements
+[x] segtitle - The title of an element of a list item in a segmented list
+[ ] seriesvolnums - Numbers of the volumes in a series of books
+[ ] set - A collection of books
+[ ] setindex - An index to a set of books
+[ ] setindexinfo - Meta-information for a SetIndex
+[ ] setinfo - Meta-information for a Set
+[ ] sgmltag - A component of SGML markup
+[ ] shortaffil - A brief description of an affiliation
+[ ] shortcut - A key combination for an action that is also accessible through
+ a menu
+[ ] sidebar - A portion of a document that is isolated from the main
+ narrative flow
+[ ] sidebarinfo - Meta-information for a Sidebar
+[x] simpara - A paragraph that contains only text and inline markup, no block
+ elements
+[x] simplelist - An undecorated list of single words or short phrases
+[ ] simplemsgentry - A wrapper for a simpler entry in a message set
+[ ] simplesect - A section of a document with no subdivisions
+[ ] spanspec - Formatting information for a spanned column in a table
+[ ] state - A state or province in an address
+[ ] step - A unit of action in a procedure
+[ ] stepalternatives - Alternative steps in a procedure
+[ ] street - A street address in an address
+[ ] structfield - A field in a structure (in the programming language sense)
+[ ] structname - The name of a structure (in the programming language sense)
+[ ] subject - One of a group of terms describing the subject matter of a
+ document
+[ ] subjectset - A set of terms describing the subject matter of a document
+[ ] subjectterm - A term in a group of terms describing the subject matter of
+ a document
+[x] subscript - A subscript (as in H2O, the molecular formula for water)
+[ ] substeps - A wrapper for steps that occur within steps in a procedure
+[x] subtitle - The subtitle of a document
+[x] superscript - A superscript (as in x2, the mathematical notation for x
+ multiplied by itself)
+[ ] surname - A family name; in western cultures the last name
+[ ] svg:svg - An SVG graphic
+[x] symbol - A name that is replaced by a value before processing
+[ ] synopfragment - A portion of a CmdSynopsis broken out from the main body
+ of the synopsis
+[ ] synopfragmentref - A reference to a fragment of a command synopsis
+[ ] synopsis - A general-purpose element for representing the syntax of
+ commands or functions
+[ ] systemitem - A system-related item or term
+[ ] table - A formal table in a document
+[ ] task - A task to be completed
+[ ] taskprerequisites - The prerequisites for a task
+[ ] taskrelated - Information related to a task
+[ ] tasksummary - A summary of a task
+[x] tbody - A wrapper for the rows of a table or informal table
+[x] td - A table entry in an HTML table
+[x] term - The word or phrase being defined or described in a variable list
+[ ] termdef - An inline term definition
+[ ] tertiary - A tertiary word or phrase in an index term
+[ ] tertiaryie - A tertiary term in an index entry, rather than in the text
+[ ] textdata - Pointer to external text data
+[ ] textobject - A wrapper for a text description of an object and its
+ associated meta-information
+[ ] tfoot - A table footer consisting of one or more rows
+[x] tgroup - A wrapper for the main content of a table, or part of a table
+[x] th - A table header entry in an HTML table
+[x] thead - A table header consisting of one or more rows
+[x] tip - A suggestion to the user, set off from the text
+[x] title - The text of the title of a section of a document or of a formal
+ block-level element
+[x] titleabbrev - The abbreviation of a Title
+[x] toc - A table of contents
+[x] tocback - An entry in a table of contents for a back matter component
+[x] tocchap - An entry in a table of contents for a component in the body of
+ a document
+[x] tocentry - A component title in a table of contents
+[x] tocfront - An entry in a table of contents for a front matter component
+[x] toclevel1 - A top-level entry within a table of contents entry for a
+ chapter-like component
+[x] toclevel2 - A second-level entry within a table of contents entry for a
+ chapter-like component
+[x] toclevel3 - A third-level entry within a table of contents entry for a
+ chapter-like component
+[x] toclevel4 - A fourth-level entry within a table of contents entry for a
+ chapter-like component
+[x] toclevel5 - A fifth-level entry within a table of contents entry for a
+ chapter-like component
+[x] tocpart - An entry in a table of contents for a part of a book
+[ ] token - A unit of information
+[x] tr - A row in an HTML table
+[ ] trademark - A trademark
+[x] type - The classification of a value
+[x] ulink - A link that addresses its target by means of a URL
+ (Uniform Resource Locator)
+[x] uri - A Uniform Resource Identifier
+[x] userinput - Data entered by the user
+[x] varargs - An empty element in a function synopsis indicating a variable
+ number of arguments
+[x] variablelist - A list in which each entry is composed of a set of one or
+ more terms and an associated description
+[x] varlistentry - A wrapper for a set of terms and the associated description
+ in a variable list
+[x] varname - The name of a variable
+[ ] videodata - Pointer to external video data
+[ ] videoobject - A wrapper for video data and its associated meta-information
+[ ] void - An empty element in a function synopsis indicating that the
+ function in question takes no arguments
+[ ] volumenum - The volume number of a document in a set (as of books in a set
+ or articles in a journal)
+[x] warning - An admonition set off from the text
+[x] wordasword - A word meant specifically as a word and not representing
+ anything else
+[x] xref - A cross reference to another part of the document
+[ ] year - The year of publication of a document
+[x] ?asciidoc-br? - line break from asciidoc docbook output
+-}
+
+type DB m = StateT DBState m
+
+data DBState = DBState{ dbSectionLevel :: Int
+ , dbQuoteType :: QuoteType
+ , dbMeta :: Meta
+ , dbAcceptsMeta :: Bool
+ , dbBook :: Bool
+ , dbFigureTitle :: Inlines
+ , dbContent :: [Content]
+ } deriving Show
+
+instance Default DBState where
+ def = DBState{ dbSectionLevel = 0
+ , dbQuoteType = DoubleQuote
+ , dbMeta = mempty
+ , dbAcceptsMeta = False
+ , dbBook = False
+ , dbFigureTitle = mempty
+ , dbContent = [] }
+
+
+readDocBook :: PandocMonad m => ReaderOptions -> String -> m Pandoc
+readDocBook _ inp = do
+ let tree = normalizeTree . parseXML . handleInstructions $ inp
+ (bs, st') <- flip runStateT (def{ dbContent = tree }) $ mapM parseBlock $ tree
+ return $ Pandoc (dbMeta st') (toList . mconcat $ bs)
+
+-- We treat <?asciidoc-br?> specially (issue #1236), converting it
+-- to <br/>, since xml-light doesn't parse the instruction correctly.
+-- Other xml instructions are simply removed from the input stream.
+handleInstructions :: String -> String
+handleInstructions ('<':'?':'a':'s':'c':'i':'i':'d':'o':'c':'-':'b':'r':'?':'>':xs) = '<':'b':'r':'/':'>': handleInstructions xs
+handleInstructions xs = case break (=='<') xs of
+ (ys, []) -> ys
+ ([], '<':zs) -> '<' : handleInstructions zs
+ (ys, zs) -> ys ++ handleInstructions zs
+
+getFigure :: PandocMonad m => Element -> DB m Blocks
+getFigure e = do
+ tit <- case filterChild (named "title") e of
+ Just t -> getInlines t
+ Nothing -> return mempty
+ modify $ \st -> st{ dbFigureTitle = tit }
+ res <- getBlocks e
+ modify $ \st -> st{ dbFigureTitle = mempty }
+ return res
+
+-- normalize input, consolidating adjacent Text and CRef elements
+normalizeTree :: [Content] -> [Content]
+normalizeTree = everywhere (mkT go)
+ where go :: [Content] -> [Content]
+ go (Text (CData CDataRaw _ _):xs) = xs
+ go (Text (CData CDataText s1 z):Text (CData CDataText s2 _):xs) =
+ Text (CData CDataText (s1 ++ s2) z):xs
+ go (Text (CData CDataText s1 z):CRef r:xs) =
+ Text (CData CDataText (s1 ++ convertEntity r) z):xs
+ go (CRef r:Text (CData CDataText s1 z):xs) =
+ Text (CData CDataText (convertEntity r ++ s1) z):xs
+ go (CRef r1:CRef r2:xs) =
+ Text (CData CDataText (convertEntity r1 ++ convertEntity r2) Nothing):xs
+ go xs = xs
+
+convertEntity :: String -> String
+convertEntity e = maybe (map toUpper e) id (lookupEntity e)
+
+-- convenience function to get an attribute value, defaulting to ""
+attrValue :: String -> Element -> String
+attrValue attr elt =
+ case lookupAttrBy (\x -> qName x == attr) (elAttribs elt) of
+ Just z -> z
+ Nothing -> ""
+
+-- convenience function
+named :: String -> Element -> Bool
+named s e = qName (elName e) == s
+
+--
+
+acceptingMetadata :: PandocMonad m => DB m a -> DB m a
+acceptingMetadata p = do
+ modify (\s -> s { dbAcceptsMeta = True } )
+ res <- p
+ modify (\s -> s { dbAcceptsMeta = False })
+ return res
+
+checkInMeta :: (PandocMonad m, Monoid a) => DB m () -> DB m a
+checkInMeta p = do
+ accepts <- dbAcceptsMeta <$> get
+ when accepts p
+ return mempty
+
+addMeta :: PandocMonad m => ToMetaValue a => String -> a -> DB m ()
+addMeta field val = modify (setMeta field val)
+
+instance HasMeta DBState where
+ setMeta field v s = s {dbMeta = setMeta field v (dbMeta s)}
+ deleteMeta field s = s {dbMeta = deleteMeta field (dbMeta s)}
+
+isBlockElement :: Content -> Bool
+isBlockElement (Elem e) = qName (elName e) `elem` blocktags
+ where blocktags = ["toc","index","para","formalpara","simpara",
+ "ackno","epigraph","blockquote","bibliography","bibliodiv",
+ "biblioentry","glossee","glosseealso","glossary",
+ "glossdiv","glosslist","chapter","appendix","preface",
+ "bridgehead","sect1","sect2","sect3","sect4","sect5","section",
+ "refsect1","refsect2","refsect3","refsection",
+ "important","caution","note","tip","warning","qandadiv",
+ "question","answer","abstract","itemizedlist","orderedlist",
+ "variablelist","article","book","table","informaltable",
+ "informalexample", "linegroup",
+ "screen","programlisting","example","calloutlist"]
+isBlockElement _ = False
+
+-- Trim leading and trailing newline characters
+trimNl :: String -> String
+trimNl = reverse . go . reverse . go
+ where go ('\n':xs) = xs
+ go xs = xs
+
+-- meld text into beginning of first paragraph of Blocks.
+-- assumes Blocks start with a Para; if not, does nothing.
+addToStart :: Inlines -> Blocks -> Blocks
+addToStart toadd bs =
+ case toList bs of
+ (Para xs : rest) -> para (toadd <> fromList xs) <> fromList rest
+ _ -> bs
+
+-- function that is used by both mediaobject (in parseBlock)
+-- and inlinemediaobject (in parseInline)
+-- A DocBook mediaobject is a wrapper around a set of alternative presentations
+getMediaobject :: PandocMonad m => Element -> DB m Inlines
+getMediaobject e = do
+ (imageUrl, attr) <-
+ case filterChild (named "imageobject") e of
+ Nothing -> return (mempty, nullAttr)
+ Just z -> case filterChild (named "imagedata") z of
+ Nothing -> return (mempty, nullAttr)
+ Just i -> let atVal a = attrValue a i
+ w = case atVal "width" of
+ "" -> []
+ d -> [("width", d)]
+ h = case atVal "depth" of
+ "" -> []
+ d -> [("height", d)]
+ atr = (atVal "id", words $ atVal "role", w ++ h)
+ in return (atVal "fileref", atr)
+ let getCaption el = case filterChild (\x -> named "caption" x
+ || named "textobject" x
+ || named "alt" x) el of
+ Nothing -> return mempty
+ Just z -> mconcat <$> (mapM parseInline $ elContent z)
+ figTitle <- gets dbFigureTitle
+ let (caption, title) = if isNull figTitle
+ then (getCaption e, "")
+ else (return figTitle, "fig:")
+ liftM (imageWith attr imageUrl title) caption
+
+getBlocks :: PandocMonad m => Element -> DB m Blocks
+getBlocks e = mconcat <$> (mapM parseBlock $ elContent e)
+
+
+parseBlock :: PandocMonad m => Content -> DB m Blocks
+parseBlock (Text (CData CDataRaw _ _)) = return mempty -- DOCTYPE
+parseBlock (Text (CData _ s _)) = if all isSpace s
+ then return mempty
+ else return $ plain $ trimInlines $ text s
+parseBlock (CRef x) = return $ plain $ str $ map toUpper x
+parseBlock (Elem e) =
+ case qName (elName e) of
+ "toc" -> return mempty -- skip TOC, since in pandoc it's autogenerated
+ "index" -> return mempty -- skip index, since page numbers meaningless
+ "para" -> parseMixed para (elContent e)
+ "formalpara" -> do
+ tit <- case filterChild (named "title") e of
+ Just t -> (para . strong . (<> str ".")) <$>
+ getInlines t
+ Nothing -> return mempty
+ (tit <>) <$> parseMixed para (elContent e)
+ "simpara" -> parseMixed para (elContent e)
+ "ackno" -> parseMixed para (elContent e)
+ "epigraph" -> parseBlockquote
+ "blockquote" -> parseBlockquote
+ "attribution" -> return mempty
+ "titleabbrev" -> return mempty
+ "authorinitials" -> return mempty
+ "title" -> checkInMeta getTitle
+ "author" -> checkInMeta getAuthor
+ "authorgroup" -> checkInMeta getAuthorGroup
+ "releaseinfo" -> checkInMeta (getInlines e >>= addMeta "release")
+ "date" -> checkInMeta getDate
+ "bibliography" -> sect 0
+ "bibliodiv" -> sect 1
+ "biblioentry" -> parseMixed para (elContent e)
+ "bibliomixed" -> parseMixed para (elContent e)
+ "glosssee" -> para . (\ils -> text "See " <> ils <> str ".")
+ <$> getInlines e
+ "glossseealso" -> para . (\ils -> text "See also " <> ils <> str ".")
+ <$> getInlines e
+ "glossary" -> sect 0
+ "glossdiv" -> definitionList <$>
+ mapM parseGlossEntry (filterChildren (named "glossentry") e)
+ "glosslist" -> definitionList <$>
+ mapM parseGlossEntry (filterChildren (named "glossentry") e)
+ "chapter" -> sect 0
+ "appendix" -> sect 0
+ "preface" -> sect 0
+ "bridgehead" -> para . strong <$> getInlines e
+ "sect1" -> sect 1
+ "sect2" -> sect 2
+ "sect3" -> sect 3
+ "sect4" -> sect 4
+ "sect5" -> sect 5
+ "section" -> gets dbSectionLevel >>= sect . (+1)
+ "refsect1" -> sect 1
+ "refsect2" -> sect 2
+ "refsect3" -> sect 3
+ "refsection" -> gets dbSectionLevel >>= sect . (+1)
+ "important" -> blockQuote . (para (strong $ str "Important") <>)
+ <$> getBlocks e
+ "caution" -> blockQuote . (para (strong $ str "Caution") <>)
+ <$> getBlocks e
+ "note" -> blockQuote . (para (strong $ str "Note") <>)
+ <$> getBlocks e
+ "tip" -> blockQuote . (para (strong $ str "Tip") <>)
+ <$> getBlocks e
+ "warning" -> blockQuote . (para (strong $ str "Warning") <>)
+ <$> getBlocks e
+ "area" -> return mempty
+ "areaset" -> return mempty
+ "areaspec" -> return mempty
+ "qandadiv" -> gets dbSectionLevel >>= sect . (+1)
+ "question" -> addToStart (strong (str "Q:") <> str " ") <$> getBlocks e
+ "answer" -> addToStart (strong (str "A:") <> str " ") <$> getBlocks e
+ "abstract" -> blockQuote <$> getBlocks e
+ "calloutlist" -> bulletList <$> callouts
+ "itemizedlist" -> bulletList <$> listitems
+ "orderedlist" -> do
+ let listStyle = case attrValue "numeration" e of
+ "arabic" -> Decimal
+ "loweralpha" -> LowerAlpha
+ "upperalpha" -> UpperAlpha
+ "lowerroman" -> LowerRoman
+ "upperroman" -> UpperRoman
+ _ -> Decimal
+ let start = fromMaybe 1 $
+ (attrValue "override" <$> filterElement (named "listitem") e)
+ >>= safeRead
+ orderedListWith (start,listStyle,DefaultDelim)
+ <$> listitems
+ "variablelist" -> definitionList <$> deflistitems
+ "figure" -> getFigure e
+ "mediaobject" -> para <$> getMediaobject e
+ "caption" -> return mempty
+ "info" -> metaBlock
+ "articleinfo" -> metaBlock
+ "sectioninfo" -> return mempty -- keywords & other metadata
+ "refsectioninfo" -> return mempty -- keywords & other metadata
+ "refsect1info" -> return mempty -- keywords & other metadata
+ "refsect2info" -> return mempty -- keywords & other metadata
+ "refsect3info" -> return mempty -- keywords & other metadata
+ "sect1info" -> return mempty -- keywords & other metadata
+ "sect2info" -> return mempty -- keywords & other metadata
+ "sect3info" -> return mempty -- keywords & other metadata
+ "sect4info" -> return mempty -- keywords & other metadata
+ "sect5info" -> return mempty -- keywords & other metadata
+ "chapterinfo" -> return mempty -- keywords & other metadata
+ "glossaryinfo" -> return mempty -- keywords & other metadata
+ "appendixinfo" -> return mempty -- keywords & other metadata
+ "bookinfo" -> metaBlock
+ "article" -> modify (\st -> st{ dbBook = False }) >>
+ getBlocks e
+ "book" -> modify (\st -> st{ dbBook = True }) >> getBlocks e
+ "table" -> parseTable
+ "informaltable" -> parseTable
+ "informalexample" -> divWith ("", ["informalexample"], []) <$>
+ getBlocks e
+ "linegroup" -> lineBlock <$> lineItems
+ "literallayout" -> codeBlockWithLang
+ "screen" -> codeBlockWithLang
+ "programlisting" -> codeBlockWithLang
+ "?xml" -> return mempty
+ _ -> getBlocks e
+ where parseMixed container conts = do
+ let (ils,rest) = break isBlockElement conts
+ ils' <- (trimInlines . mconcat) <$> mapM parseInline ils
+ let p = if ils' == mempty then mempty else container ils'
+ case rest of
+ [] -> return p
+ (r:rs) -> do
+ b <- parseBlock r
+ x <- parseMixed container rs
+ return $ p <> b <> x
+ codeBlockWithLang = do
+ let classes' = case attrValue "language" e of
+ "" -> []
+ x -> [x]
+ return $ codeBlockWith (attrValue "id" e, classes', [])
+ $ trimNl $ strContentRecursive e
+ parseBlockquote = do
+ attrib <- case filterChild (named "attribution") e of
+ Nothing -> return mempty
+ Just z -> (para . (str "— " <>) . mconcat)
+ <$> (mapM parseInline $ elContent z)
+ contents <- getBlocks e
+ return $ blockQuote (contents <> attrib)
+ listitems = mapM getBlocks $ filterChildren (named "listitem") e
+ callouts = mapM getBlocks $ filterChildren (named "callout") e
+ deflistitems = mapM parseVarListEntry $ filterChildren
+ (named "varlistentry") e
+ parseVarListEntry e' = do
+ let terms = filterChildren (named "term") e'
+ let items = filterChildren (named "listitem") e'
+ terms' <- mapM getInlines terms
+ items' <- mapM getBlocks items
+ return (mconcat $ intersperse (str "; ") terms', items')
+ parseGlossEntry e' = do
+ let terms = filterChildren (named "glossterm") e'
+ let items = filterChildren (named "glossdef") e'
+ terms' <- mapM getInlines terms
+ items' <- mapM getBlocks items
+ return (mconcat $ intersperse (str "; ") terms', items')
+ getTitle = do
+ tit <- getInlines e
+ subtit <- case filterChild (named "subtitle") e of
+ Just s -> (text ": " <>) <$>
+ getInlines s
+ Nothing -> return mempty
+ addMeta "title" (tit <> subtit)
+
+ getAuthor = (:[]) <$> getInlines e >>= addMeta "author"
+ getAuthorGroup = do
+ let terms = filterChildren (named "author") e
+ mapM getInlines terms >>= addMeta "author"
+ getDate = getInlines e >>= addMeta "date"
+ parseTable = do
+ let isCaption x = named "title" x || named "caption" x
+ caption <- case filterChild isCaption e of
+ Just t -> getInlines t
+ Nothing -> return mempty
+ let e' = fromMaybe e $ filterChild (named "tgroup") e
+ let isColspec x = named "colspec" x || named "col" x
+ let colspecs = case filterChild (named "colgroup") e' of
+ Just c -> filterChildren isColspec c
+ _ -> filterChildren isColspec e'
+ let isRow x = named "row" x || named "tr" x
+ headrows <- case filterChild (named "thead") e' of
+ Just h -> case filterChild isRow h of
+ Just x -> parseRow x
+ Nothing -> return []
+ Nothing -> return []
+ bodyrows <- case filterChild (named "tbody") e' of
+ Just b -> mapM parseRow
+ $ filterChildren isRow b
+ Nothing -> mapM parseRow
+ $ filterChildren isRow e'
+ let toAlignment c = case findAttr (unqual "align") c of
+ Just "left" -> AlignLeft
+ Just "right" -> AlignRight
+ Just "center" -> AlignCenter
+ _ -> AlignDefault
+ let toWidth c = case findAttr (unqual "colwidth") c of
+ Just w -> fromMaybe 0
+ $ safeRead $ '0': filter (\x ->
+ (x >= '0' && x <= '9')
+ || x == '.') w
+ Nothing -> 0 :: Double
+ let numrows = case bodyrows of
+ [] -> 0
+ xs -> maximum $ map length xs
+ let aligns = case colspecs of
+ [] -> replicate numrows AlignDefault
+ cs -> map toAlignment cs
+ let widths = case colspecs of
+ [] -> replicate numrows 0
+ cs -> let ws = map toWidth cs
+ tot = sum ws
+ in if all (> 0) ws
+ then map (/ tot) ws
+ else replicate numrows 0
+ let headrows' = if null headrows
+ then replicate numrows mempty
+ else headrows
+ return $ table caption (zip aligns widths)
+ headrows' bodyrows
+ isEntry x = named "entry" x || named "td" x || named "th" x
+ parseRow = mapM (parseMixed plain . elContent) . filterChildren isEntry
+ sect n = do isbook <- gets dbBook
+ let n' = if isbook || n == 0 then n + 1 else n
+ headerText <- case filterChild (named "title") e `mplus`
+ (filterChild (named "info") e >>=
+ filterChild (named "title")) of
+ Just t -> getInlines t
+ Nothing -> return mempty
+ modify $ \st -> st{ dbSectionLevel = n }
+ b <- getBlocks e
+ let ident = attrValue "id" e
+ modify $ \st -> st{ dbSectionLevel = n - 1 }
+ return $ headerWith (ident,[],[]) n' headerText <> b
+ lineItems = mapM getInlines $ filterChildren (named "line") e
+ metaBlock = acceptingMetadata (getBlocks e) >> return mempty
+
+getInlines :: PandocMonad m => Element -> DB m Inlines
+getInlines e' = (trimInlines . mconcat) <$> (mapM parseInline $ elContent e')
+
+strContentRecursive :: Element -> String
+strContentRecursive = strContent .
+ (\e' -> e'{ elContent = map elementToStr $ elContent e' })
+
+elementToStr :: Content -> Content
+elementToStr (Elem e') = Text $ CData CDataText (strContentRecursive e') Nothing
+elementToStr x = x
+
+parseInline :: PandocMonad m => Content -> DB m Inlines
+parseInline (Text (CData _ s _)) = return $ text s
+parseInline (CRef ref) =
+ return $ maybe (text $ map toUpper ref) (text) $ lookupEntity ref
+parseInline (Elem e) =
+ case qName (elName e) of
+ "equation" -> equation displayMath
+ "informalequation" -> equation displayMath
+ "inlineequation" -> equation math
+ "subscript" -> subscript <$> innerInlines
+ "superscript" -> superscript <$> innerInlines
+ "inlinemediaobject" -> getMediaobject e
+ "quote" -> do
+ qt <- gets dbQuoteType
+ let qt' = if qt == SingleQuote then DoubleQuote else SingleQuote
+ modify $ \st -> st{ dbQuoteType = qt' }
+ contents <- innerInlines
+ modify $ \st -> st{ dbQuoteType = qt }
+ return $ if qt == SingleQuote
+ then singleQuoted contents
+ else doubleQuoted contents
+ "simplelist" -> simpleList
+ "segmentedlist" -> segmentedList
+ "classname" -> codeWithLang
+ "code" -> codeWithLang
+ "filename" -> codeWithLang
+ "literal" -> codeWithLang
+ "computeroutput" -> codeWithLang
+ "prompt" -> codeWithLang
+ "parameter" -> codeWithLang
+ "option" -> codeWithLang
+ "optional" -> do x <- getInlines e
+ return $ str "[" <> x <> str "]"
+ "markup" -> codeWithLang
+ "wordasword" -> emph <$> innerInlines
+ "command" -> codeWithLang
+ "varname" -> codeWithLang
+ "function" -> codeWithLang
+ "type" -> codeWithLang
+ "symbol" -> codeWithLang
+ "constant" -> codeWithLang
+ "userinput" -> codeWithLang
+ "varargs" -> return $ code "(...)"
+ "keycap" -> return (str $ strContent e)
+ "keycombo" -> keycombo <$> (mapM parseInline $ elContent e)
+ "menuchoice" -> menuchoice <$> (mapM parseInline $
+ filter isGuiMenu $ elContent e)
+ "xref" -> do
+ content <- dbContent <$> get
+ let linkend = attrValue "linkend" e
+ let title = case attrValue "endterm" e of
+ "" -> maybe "???" xrefTitleByElem
+ (findElementById linkend content)
+ endterm -> maybe "???" strContent
+ (findElementById endterm content)
+ return $ link ('#' : linkend) "" (text title)
+ "email" -> return $ link ("mailto:" ++ strContent e) ""
+ $ str $ strContent e
+ "uri" -> return $ link (strContent e) "" $ str $ strContent e
+ "ulink" -> link (attrValue "url" e) "" <$> innerInlines
+ "link" -> do
+ ils <- innerInlines
+ let href = case findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) e of
+ Just h -> h
+ _ -> ('#' : attrValue "linkend" e)
+ let ils' = if ils == mempty then str href else ils
+ let attr = (attrValue "id" e, words $ attrValue "role" e, [])
+ return $ linkWith attr href "" ils'
+ "foreignphrase" -> emph <$> innerInlines
+ "emphasis" -> case attrValue "role" e of
+ "bold" -> strong <$> innerInlines
+ "strong" -> strong <$> innerInlines
+ "strikethrough" -> strikeout <$> innerInlines
+ _ -> emph <$> innerInlines
+ "footnote" -> (note . mconcat) <$> (mapM parseBlock $ elContent e)
+ "title" -> return mempty
+ "affiliation" -> return mempty
+ -- Note: this isn't a real docbook tag; it's what we convert
+ -- <?asciidor-br?> to in handleInstructions, above. A kludge to
+ -- work around xml-light's inability to parse an instruction.
+ "br" -> return linebreak
+ _ -> innerInlines
+ where innerInlines = (trimInlines . mconcat) <$>
+ (mapM parseInline $ elContent e)
+ equation constructor = return $ mconcat $
+ map (constructor . writeTeX)
+ $ rights
+ $ map (readMathML . showElement . everywhere (mkT removePrefix))
+ $ filterChildren (\x -> qName (elName x) == "math" &&
+ qPrefix (elName x) == Just "mml") e
+ removePrefix elname = elname { qPrefix = Nothing }
+ codeWithLang = do
+ let classes' = case attrValue "language" e of
+ "" -> []
+ l -> [l]
+ return $ codeWith (attrValue "id" e,classes',[]) $ strContentRecursive e
+ simpleList = (mconcat . intersperse (str "," <> space)) <$> mapM getInlines
+ (filterChildren (named "member") e)
+ segmentedList = do
+ tit <- maybe (return mempty) getInlines $ filterChild (named "title") e
+ segtits <- mapM getInlines $ filterChildren (named "segtitle") e
+ segitems <- mapM (mapM getInlines . filterChildren (named "seg"))
+ $ filterChildren (named "seglistitem") e
+ let toSeg = mconcat . zipWith (\x y -> strong (x <> str ":") <> space <>
+ y <> linebreak) segtits
+ let segs = mconcat $ map toSeg segitems
+ let tit' = if tit == mempty
+ then mempty
+ else strong tit <> linebreak
+ return $ linebreak <> tit' <> segs
+ keycombo = spanWith ("",["keycombo"],[]) .
+ mconcat . intersperse (str "+")
+ menuchoice = spanWith ("",["menuchoice"],[]) .
+ mconcat . intersperse (text " > ")
+ isGuiMenu (Elem x) = named "guimenu" x || named "guisubmenu" x ||
+ named "guimenuitem" x
+ isGuiMenu _ = False
+
+ findElementById idString content
+ = asum [filterElement (\x -> attrValue "id" x == idString) el | Elem el <- content]
+
+ -- Use the 'xreflabel' attribute for getting the title of a xref link;
+ -- if there's no such attribute, employ some heuristics based on what
+ -- docbook-xsl does.
+ xrefTitleByElem el
+ | not (null xrefLabel) = xrefLabel
+ | otherwise = case qName (elName el) of
+ "chapter" -> descendantContent "title" el
+ "sect1" -> descendantContent "title" el
+ "sect2" -> descendantContent "title" el
+ "sect3" -> descendantContent "title" el
+ "sect4" -> descendantContent "title" el
+ "sect5" -> descendantContent "title" el
+ "cmdsynopsis" -> descendantContent "command" el
+ "funcsynopsis" -> descendantContent "function" el
+ _ -> qName (elName el) ++ "_title"
+ where
+ xrefLabel = attrValue "xreflabel" el
+ descendantContent name = maybe "???" strContent
+ . filterElementName (\n -> qName n == name)
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
new file mode 100644
index 000000000..8936a0403
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -0,0 +1,626 @@
+{-# LANGUAGE PatternGuards, OverloadedStrings, CPP #-}
+
+{-
+Copyright (C) 2014-2016 Jesse Rosenthal <jrosenthal@jhu.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.Docx
+ Copyright : Copyright (C) 2014-2016 Jesse Rosenthal
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of Docx type (defined in Text.Pandoc.Readers.Docx.Parse)
+to 'Pandoc' document. -}
+
+{-
+Current state of implementation of Docx entities ([x] means
+implemented, [-] means partially implemented):
+
+* Blocks
+
+ - [X] Para
+ - [X] CodeBlock (styled with `SourceCode`)
+ - [X] BlockQuote (styled with `Quote`, `BlockQuote`, or, optionally,
+ indented)
+ - [X] OrderedList
+ - [X] BulletList
+ - [X] DefinitionList (styled with adjacent `DefinitionTerm` and `Definition`)
+ - [X] Header (styled with `Heading#`)
+ - [ ] HorizontalRule
+ - [-] Table (column widths and alignments not yet implemented)
+
+* Inlines
+
+ - [X] Str
+ - [X] Emph (italics and underline both read as Emph)
+ - [X] Strong
+ - [X] Strikeout
+ - [X] Superscript
+ - [X] Subscript
+ - [X] SmallCaps
+ - [ ] Quoted
+ - [ ] Cite
+ - [X] Code (styled with `VerbatimChar`)
+ - [X] Space
+ - [X] LineBreak (these are invisible in Word: entered with Shift-Return)
+ - [X] Math
+ - [X] Link (links to an arbitrary bookmark create a span with the target as
+ id and "anchor" class)
+ - [X] Image
+ - [X] Note (Footnotes and Endnotes are silently combined.)
+-}
+
+module Text.Pandoc.Readers.Docx
+ ( readDocxWithWarnings
+ , readDocx
+ ) where
+
+import Codec.Archive.Zip
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Text.Pandoc.Builder
+import Text.Pandoc.Walk
+import Text.Pandoc.Readers.Docx.Parse
+import Text.Pandoc.Readers.Docx.Lists
+import Text.Pandoc.Readers.Docx.Combine
+import Text.Pandoc.Shared
+import Text.Pandoc.MediaBag (MediaBag)
+import Data.List (delete, intersect)
+import Text.TeXMath (writeTeX)
+import Data.Default (Default)
+import qualified Data.ByteString.Lazy as B
+import qualified Data.Map as M
+import qualified Data.Set as Set
+import Control.Monad.Reader
+import Control.Monad.State
+import Data.Sequence (ViewL(..), viewl)
+import qualified Data.Sequence as Seq (null)
+#if !(MIN_VERSION_base(4,8,0))
+import Data.Traversable (traverse)
+#endif
+import Text.Pandoc.Error
+import Control.Monad.Except (throwError)
+import Text.Pandoc.Class (PandocMonad)
+import qualified Text.Pandoc.Class as P
+import Text.Pandoc.Logging
+
+readDocx :: PandocMonad m
+ => ReaderOptions
+ -> B.ByteString
+ -> m Pandoc
+readDocx opts bytes
+ | Right archive <- toArchiveOrFail bytes
+ , Right (docx, parserWarnings) <- archiveToDocxWithWarnings archive = do
+ mapM_ (P.report . DocxParserWarning) parserWarnings
+ (meta, blks) <- docxToOutput opts docx
+ return $ Pandoc meta blks
+readDocx _ _ =
+ throwError $ PandocSomeError "couldn't parse docx file"
+
+-- TODO remove this for 2.0:
+readDocxWithWarnings :: PandocMonad m
+ => ReaderOptions
+ -> B.ByteString
+ -> m Pandoc
+readDocxWithWarnings = readDocx
+
+data DState = DState { docxAnchorMap :: M.Map String String
+ , docxMediaBag :: MediaBag
+ , docxDropCap :: Inlines
+ , docxWarnings :: [String]
+ }
+
+instance Default DState where
+ def = DState { docxAnchorMap = M.empty
+ , docxMediaBag = mempty
+ , docxDropCap = mempty
+ , docxWarnings = []
+ }
+
+data DEnv = DEnv { docxOptions :: ReaderOptions
+ , docxInHeaderBlock :: Bool }
+
+instance Default DEnv where
+ def = DEnv def False
+
+type DocxContext m = ReaderT DEnv (StateT DState m)
+
+evalDocxContext :: PandocMonad m => DocxContext m a -> DEnv -> DState -> m a
+evalDocxContext ctx env st = flip evalStateT st $ flip runReaderT env $ ctx
+
+-- This is empty, but we put it in for future-proofing.
+spansToKeep :: [String]
+spansToKeep = []
+
+divsToKeep :: [String]
+divsToKeep = ["list-item", "Definition", "DefinitionTerm"]
+
+metaStyles :: M.Map String String
+metaStyles = M.fromList [ ("Title", "title")
+ , ("Subtitle", "subtitle")
+ , ("Author", "author")
+ , ("Date", "date")
+ , ("Abstract", "abstract")]
+
+sepBodyParts :: [BodyPart] -> ([BodyPart], [BodyPart])
+sepBodyParts = span (\bp -> (isMetaPar bp || isEmptyPar bp))
+
+isMetaPar :: BodyPart -> Bool
+isMetaPar (Paragraph pPr _) =
+ not $ null $ intersect (pStyle pPr) (M.keys metaStyles)
+isMetaPar _ = False
+
+isEmptyPar :: BodyPart -> Bool
+isEmptyPar (Paragraph _ parParts) =
+ all isEmptyParPart parParts
+ where
+ isEmptyParPart (PlainRun (Run _ runElems)) = all isEmptyElem runElems
+ isEmptyParPart _ = False
+ isEmptyElem (TextRun s) = trim s == ""
+ isEmptyElem _ = True
+isEmptyPar _ = False
+
+bodyPartsToMeta' :: PandocMonad m => [BodyPart] -> DocxContext m (M.Map String MetaValue)
+bodyPartsToMeta' [] = return M.empty
+bodyPartsToMeta' (bp : bps)
+ | (Paragraph pPr parParts) <- bp
+ , (c : _)<- intersect (pStyle pPr) (M.keys metaStyles)
+ , (Just metaField) <- M.lookup c metaStyles = do
+ inlines <- smushInlines <$> mapM parPartToInlines parParts
+ remaining <- bodyPartsToMeta' bps
+ let
+ f (MetaInlines ils) (MetaInlines ils') = MetaBlocks [Para ils, Para ils']
+ f (MetaInlines ils) (MetaBlocks blks) = MetaBlocks ((Para ils) : blks)
+ f m (MetaList mv) = MetaList (m : mv)
+ f m n = MetaList [m, n]
+ return $ M.insertWith f metaField (MetaInlines (toList inlines)) remaining
+bodyPartsToMeta' (_ : bps) = bodyPartsToMeta' bps
+
+bodyPartsToMeta :: PandocMonad m => [BodyPart] -> DocxContext m Meta
+bodyPartsToMeta bps = do
+ mp <- bodyPartsToMeta' bps
+ let mp' =
+ case M.lookup "author" mp of
+ Just mv -> M.insert "author" (fixAuthors mv) mp
+ Nothing -> mp
+ return $ Meta mp'
+
+fixAuthors :: MetaValue -> MetaValue
+fixAuthors (MetaBlocks blks) =
+ MetaList $ map g $ filter f blks
+ where f (Para _) = True
+ f _ = False
+ g (Para ils) = MetaInlines ils
+ g _ = MetaInlines []
+fixAuthors mv = mv
+
+codeStyles :: [String]
+codeStyles = ["VerbatimChar"]
+
+codeDivs :: [String]
+codeDivs = ["SourceCode"]
+
+runElemToInlines :: RunElem -> Inlines
+runElemToInlines (TextRun s) = text s
+runElemToInlines (LnBrk) = linebreak
+runElemToInlines (Tab) = space
+runElemToInlines (SoftHyphen) = text "\xad"
+runElemToInlines (NoBreakHyphen) = text "\x2011"
+
+runElemToString :: RunElem -> String
+runElemToString (TextRun s) = s
+runElemToString (LnBrk) = ['\n']
+runElemToString (Tab) = ['\t']
+runElemToString (SoftHyphen) = ['\xad']
+runElemToString (NoBreakHyphen) = ['\x2011']
+
+runToString :: Run -> String
+runToString (Run _ runElems) = concatMap runElemToString runElems
+runToString _ = ""
+
+parPartToString :: ParPart -> String
+parPartToString (PlainRun run) = runToString run
+parPartToString (InternalHyperLink _ runs) = concatMap runToString runs
+parPartToString (ExternalHyperLink _ runs) = concatMap runToString runs
+parPartToString _ = ""
+
+blacklistedCharStyles :: [String]
+blacklistedCharStyles = ["Hyperlink"]
+
+resolveDependentRunStyle :: RunStyle -> RunStyle
+resolveDependentRunStyle rPr
+ | Just (s, _) <- rStyle rPr, s `elem` blacklistedCharStyles =
+ rPr
+ | Just (_, cs) <- rStyle rPr =
+ let rPr' = resolveDependentRunStyle cs
+ in
+ RunStyle { isBold = case isBold rPr of
+ Just bool -> Just bool
+ Nothing -> isBold rPr'
+ , isItalic = case isItalic rPr of
+ Just bool -> Just bool
+ Nothing -> isItalic rPr'
+ , isSmallCaps = case isSmallCaps rPr of
+ Just bool -> Just bool
+ Nothing -> isSmallCaps rPr'
+ , isStrike = case isStrike rPr of
+ Just bool -> Just bool
+ Nothing -> isStrike rPr'
+ , rVertAlign = case rVertAlign rPr of
+ Just valign -> Just valign
+ Nothing -> rVertAlign rPr'
+ , rUnderline = case rUnderline rPr of
+ Just ulstyle -> Just ulstyle
+ Nothing -> rUnderline rPr'
+ , rStyle = rStyle rPr }
+ | otherwise = rPr
+
+runStyleToTransform :: RunStyle -> (Inlines -> Inlines)
+runStyleToTransform rPr
+ | Just (s, _) <- rStyle rPr
+ , s `elem` spansToKeep =
+ let rPr' = rPr{rStyle = Nothing}
+ in
+ (spanWith ("", [s], [])) . (runStyleToTransform rPr')
+ | Just True <- isItalic rPr =
+ emph . (runStyleToTransform rPr {isItalic = Nothing})
+ | Just True <- isBold rPr =
+ strong . (runStyleToTransform rPr {isBold = Nothing})
+ | Just True <- isSmallCaps rPr =
+ smallcaps . (runStyleToTransform rPr {isSmallCaps = Nothing})
+ | Just True <- isStrike rPr =
+ strikeout . (runStyleToTransform rPr {isStrike = Nothing})
+ | Just SupScrpt <- rVertAlign rPr =
+ superscript . (runStyleToTransform rPr {rVertAlign = Nothing})
+ | Just SubScrpt <- rVertAlign rPr =
+ subscript . (runStyleToTransform rPr {rVertAlign = Nothing})
+ | Just "single" <- rUnderline rPr =
+ emph . (runStyleToTransform rPr {rUnderline = Nothing})
+ | otherwise = id
+
+runToInlines :: PandocMonad m => Run -> DocxContext m Inlines
+runToInlines (Run rs runElems)
+ | Just (s, _) <- rStyle rs
+ , s `elem` codeStyles =
+ let rPr = resolveDependentRunStyle rs
+ codeString = code $ concatMap runElemToString runElems
+ in
+ return $ case rVertAlign rPr of
+ Just SupScrpt -> superscript codeString
+ Just SubScrpt -> subscript codeString
+ _ -> codeString
+ | otherwise = do
+ let ils = smushInlines (map runElemToInlines runElems)
+ return $ (runStyleToTransform $ resolveDependentRunStyle rs) ils
+runToInlines (Footnote bps) = do
+ blksList <- smushBlocks <$> (mapM bodyPartToBlocks bps)
+ return $ note blksList
+runToInlines (Endnote bps) = do
+ blksList <- smushBlocks <$> (mapM bodyPartToBlocks bps)
+ return $ note blksList
+runToInlines (InlineDrawing fp title alt bs ext) = do
+ (lift . lift) $ P.insertMedia fp Nothing bs
+ return $ imageWith (extentToAttr ext) fp title $ text alt
+runToInlines InlineChart = return $ spanWith ("", ["chart"], []) $ text "[CHART]"
+
+extentToAttr :: Extent -> Attr
+extentToAttr (Just (w, h)) =
+ ("", [], [("width", showDim w), ("height", showDim h)] )
+ where
+ showDim d = show (d / 914400) ++ "in"
+extentToAttr _ = nullAttr
+
+blocksToInlinesWarn :: PandocMonad m => String -> Blocks -> DocxContext m Inlines
+blocksToInlinesWarn cmtId blks = do
+ let blkList = toList blks
+ notParaOrPlain :: Block -> Bool
+ notParaOrPlain (Para _) = False
+ notParaOrPlain (Plain _) = False
+ notParaOrPlain _ = True
+ when (not $ null $ filter notParaOrPlain blkList) $
+ lift $ P.report $ DocxParserWarning $
+ "Docx comment " ++ cmtId ++ " will not retain formatting"
+ return $ fromList $ blocksToInlines blkList
+
+parPartToInlines :: PandocMonad m => ParPart -> DocxContext m Inlines
+parPartToInlines (PlainRun r) = runToInlines r
+parPartToInlines (Insertion _ author date runs) = do
+ opts <- asks docxOptions
+ case readerTrackChanges opts of
+ AcceptChanges -> smushInlines <$> mapM runToInlines runs
+ RejectChanges -> return mempty
+ AllChanges -> do
+ ils <- smushInlines <$> mapM runToInlines runs
+ let attr = ("", ["insertion"], [("author", author), ("date", date)])
+ return $ spanWith attr ils
+parPartToInlines (Deletion _ author date runs) = do
+ opts <- asks docxOptions
+ case readerTrackChanges opts of
+ AcceptChanges -> return mempty
+ RejectChanges -> smushInlines <$> mapM runToInlines runs
+ AllChanges -> do
+ ils <- smushInlines <$> mapM runToInlines runs
+ let attr = ("", ["deletion"], [("author", author), ("date", date)])
+ return $ spanWith attr ils
+parPartToInlines (CommentStart cmtId author date bodyParts) = do
+ opts <- asks docxOptions
+ case readerTrackChanges opts of
+ AllChanges -> do
+ blks <- smushBlocks <$> mapM bodyPartToBlocks bodyParts
+ ils <- blocksToInlinesWarn cmtId blks
+ let attr = ("", ["comment-start"], [("id", cmtId), ("author", author), ("date", date)])
+ return $ spanWith attr ils
+ _ -> return mempty
+parPartToInlines (CommentEnd cmtId) = do
+ opts <- asks docxOptions
+ case readerTrackChanges opts of
+ AllChanges -> do
+ let attr = ("", ["comment-end"], [("id", cmtId)])
+ return $ spanWith attr mempty
+ _ -> return mempty
+parPartToInlines (BookMark _ anchor) | anchor `elem` dummyAnchors =
+ return mempty
+parPartToInlines (BookMark _ anchor) =
+ -- We record these, so we can make sure not to overwrite
+ -- user-defined anchor links with header auto ids.
+ do
+ -- get whether we're in a header.
+ inHdrBool <- asks docxInHeaderBlock
+ -- Get the anchor map.
+ anchorMap <- gets docxAnchorMap
+ -- We don't want to rewrite if we're in a header, since we'll take
+ -- care of that later, when we make the header anchor. If the
+ -- bookmark were already in uniqueIdent form, this would lead to a
+ -- duplication. Otherwise, we check to see if the id is already in
+ -- there. Rewrite if necessary. This will have the possible effect
+ -- of rewriting user-defined anchor links. However, since these
+ -- are not defined in pandoc, it seems like a necessary evil to
+ -- avoid an extra pass.
+ let newAnchor =
+ if not inHdrBool && anchor `elem` (M.elems anchorMap)
+ then uniqueIdent [Str anchor] (Set.fromList $ M.elems anchorMap)
+ else anchor
+ unless inHdrBool
+ (modify $ \s -> s { docxAnchorMap = M.insert anchor newAnchor anchorMap})
+ return $ spanWith (newAnchor, ["anchor"], []) mempty
+parPartToInlines (Drawing fp title alt bs ext) = do
+ (lift . lift) $ P.insertMedia fp Nothing bs
+ return $ imageWith (extentToAttr ext) fp title $ text alt
+parPartToInlines Chart = do
+ return $ spanWith ("", ["chart"], []) $ text "[CHART]"
+parPartToInlines (InternalHyperLink anchor runs) = do
+ ils <- smushInlines <$> mapM runToInlines runs
+ return $ link ('#' : anchor) "" ils
+parPartToInlines (ExternalHyperLink target runs) = do
+ ils <- smushInlines <$> mapM runToInlines runs
+ return $ link target "" ils
+parPartToInlines (PlainOMath exps) = do
+ return $ math $ writeTeX exps
+parPartToInlines (SmartTag runs) = do
+ ils <- smushInlines <$> mapM runToInlines runs
+ return ils
+
+isAnchorSpan :: Inline -> Bool
+isAnchorSpan (Span (_, classes, kvs) _) =
+ classes == ["anchor"] &&
+ null kvs
+isAnchorSpan _ = False
+
+dummyAnchors :: [String]
+dummyAnchors = ["_GoBack"]
+
+makeHeaderAnchor :: PandocMonad m => Blocks -> DocxContext m Blocks
+makeHeaderAnchor bs = traverse makeHeaderAnchor' bs
+
+makeHeaderAnchor' :: PandocMonad m => Block -> DocxContext m Block
+-- If there is an anchor already there (an anchor span in the header,
+-- to be exact), we rename and associate the new id with the old one.
+makeHeaderAnchor' (Header n (ident, classes, kvs) ils)
+ | (c:_) <- filter isAnchorSpan ils
+ , (Span (anchIdent, ["anchor"], _) cIls) <- c = do
+ hdrIDMap <- gets docxAnchorMap
+ let newIdent = if null ident
+ then uniqueIdent ils (Set.fromList $ M.elems hdrIDMap)
+ else ident
+ newIls = concatMap f ils where f il | il == c = cIls
+ | otherwise = [il]
+ modify $ \s -> s {docxAnchorMap = M.insert anchIdent newIdent hdrIDMap}
+ makeHeaderAnchor' $ Header n (newIdent, classes, kvs) newIls
+-- Otherwise we just give it a name, and register that name (associate
+-- it with itself.)
+makeHeaderAnchor' (Header n (ident, classes, kvs) ils) =
+ do
+ hdrIDMap <- gets docxAnchorMap
+ let newIdent = if null ident
+ then uniqueIdent ils (Set.fromList $ M.elems hdrIDMap)
+ else ident
+ modify $ \s -> s {docxAnchorMap = M.insert newIdent newIdent hdrIDMap}
+ return $ Header n (newIdent, classes, kvs) ils
+makeHeaderAnchor' blk = return blk
+
+-- Rewrite a standalone paragraph block as a plain
+singleParaToPlain :: Blocks -> Blocks
+singleParaToPlain blks
+ | (Para (ils) :< seeq) <- viewl $ unMany blks
+ , Seq.null seeq =
+ singleton $ Plain ils
+singleParaToPlain blks = blks
+
+cellToBlocks :: PandocMonad m => Cell -> DocxContext m Blocks
+cellToBlocks (Cell bps) = do
+ blks <- smushBlocks <$> mapM bodyPartToBlocks bps
+ return $ fromList $ blocksToDefinitions $ blocksToBullets $ toList blks
+
+rowToBlocksList :: PandocMonad m => Row -> DocxContext m [Blocks]
+rowToBlocksList (Row cells) = do
+ blksList <- mapM cellToBlocks cells
+ return $ map singleParaToPlain blksList
+
+trimLineBreaks :: [Inline] -> [Inline]
+trimLineBreaks [] = []
+trimLineBreaks (LineBreak : ils) = trimLineBreaks ils
+trimLineBreaks ils
+ | (LineBreak : ils') <- reverse ils = trimLineBreaks (reverse ils')
+trimLineBreaks ils = ils
+
+parStyleToTransform :: ParagraphStyle -> (Blocks -> Blocks)
+parStyleToTransform pPr
+ | (c:cs) <- pStyle pPr
+ , c `elem` divsToKeep =
+ let pPr' = pPr { pStyle = cs }
+ in
+ (divWith ("", [c], [])) . (parStyleToTransform pPr')
+ | (c:cs) <- pStyle pPr,
+ c `elem` listParagraphDivs =
+ let pPr' = pPr { pStyle = cs, indentation = Nothing}
+ in
+ (divWith ("", [c], [])) . (parStyleToTransform pPr')
+ | (_:cs) <- pStyle pPr
+ , Just True <- pBlockQuote pPr =
+ let pPr' = pPr { pStyle = cs }
+ in
+ blockQuote . (parStyleToTransform pPr')
+ | (_:cs) <- pStyle pPr =
+ let pPr' = pPr { pStyle = cs}
+ in
+ parStyleToTransform pPr'
+ | null (pStyle pPr)
+ , Just left <- indentation pPr >>= leftParIndent
+ , Just hang <- indentation pPr >>= hangingParIndent =
+ let pPr' = pPr { indentation = Nothing }
+ in
+ case (left - hang) > 0 of
+ True -> blockQuote . (parStyleToTransform pPr')
+ False -> parStyleToTransform pPr'
+ | null (pStyle pPr),
+ Just left <- indentation pPr >>= leftParIndent =
+ let pPr' = pPr { indentation = Nothing }
+ in
+ case left > 0 of
+ True -> blockQuote . (parStyleToTransform pPr')
+ False -> parStyleToTransform pPr'
+parStyleToTransform _ = id
+
+bodyPartToBlocks :: PandocMonad m => BodyPart -> DocxContext m Blocks
+bodyPartToBlocks (Paragraph pPr parparts)
+ | not $ null $ codeDivs `intersect` (pStyle pPr) =
+ return
+ $ parStyleToTransform pPr
+ $ codeBlock
+ $ concatMap parPartToString parparts
+ | Just (style, n) <- pHeading pPr = do
+ ils <- local (\s-> s{docxInHeaderBlock=True}) $
+ (smushInlines <$> mapM parPartToInlines parparts)
+ makeHeaderAnchor $
+ headerWith ("", delete style (pStyle pPr), []) n ils
+ | otherwise = do
+ ils <- smushInlines <$> mapM parPartToInlines parparts >>=
+ (return . fromList . trimLineBreaks . normalizeSpaces . toList)
+ dropIls <- gets docxDropCap
+ let ils' = dropIls <> ils
+ if dropCap pPr
+ then do modify $ \s -> s { docxDropCap = ils' }
+ return mempty
+ else do modify $ \s -> s { docxDropCap = mempty }
+ return $ case isNull ils' of
+ True -> mempty
+ _ -> parStyleToTransform pPr $ para ils'
+bodyPartToBlocks (ListItem pPr numId lvl (Just levelInfo) parparts) = do
+ let
+ kvs = case levelInfo of
+ (_, fmt, txt, Just start) -> [ ("level", lvl)
+ , ("num-id", numId)
+ , ("format", fmt)
+ , ("text", txt)
+ , ("start", (show start))
+ ]
+
+ (_, fmt, txt, Nothing) -> [ ("level", lvl)
+ , ("num-id", numId)
+ , ("format", fmt)
+ , ("text", txt)
+ ]
+ blks <- bodyPartToBlocks (Paragraph pPr parparts)
+ return $ divWith ("", ["list-item"], kvs) blks
+bodyPartToBlocks (ListItem pPr _ _ _ parparts) =
+ let pPr' = pPr {pStyle = "ListParagraph": (pStyle pPr)}
+ in
+ bodyPartToBlocks $ Paragraph pPr' parparts
+bodyPartToBlocks (Tbl _ _ _ []) =
+ return $ para mempty
+bodyPartToBlocks (Tbl cap _ look (r:rs)) = do
+ let caption = text cap
+ (hdr, rows) = case firstRowFormatting look of
+ True | null rs -> (Nothing, [r])
+ | otherwise -> (Just r, rs)
+ False -> (Nothing, r:rs)
+
+ cells <- mapM rowToBlocksList rows
+
+ let width = case cells of
+ r':_ -> length r'
+ -- shouldn't happen
+ [] -> 0
+
+ hdrCells <- case hdr of
+ Just r' -> rowToBlocksList r'
+ Nothing -> return $ replicate width mempty
+
+ -- The two following variables (horizontal column alignment and
+ -- relative column widths) go to the default at the
+ -- moment. Width information is in the TblGrid field of the Tbl,
+ -- so should be possible. Alignment might be more difficult,
+ -- since there doesn't seem to be a column entity in docx.
+ let alignments = replicate width AlignDefault
+ widths = replicate width 0 :: [Double]
+
+ return $ table caption (zip alignments widths) hdrCells cells
+bodyPartToBlocks (OMathPara e) = do
+ return $ para $ displayMath (writeTeX e)
+
+
+-- replace targets with generated anchors.
+rewriteLink' :: PandocMonad m => Inline -> DocxContext m Inline
+rewriteLink' l@(Link attr ils ('#':target, title)) = do
+ anchorMap <- gets docxAnchorMap
+ return $ case M.lookup target anchorMap of
+ Just newTarget -> (Link attr ils ('#':newTarget, title))
+ Nothing -> l
+rewriteLink' il = return il
+
+rewriteLinks :: PandocMonad m => [Block] -> DocxContext m [Block]
+rewriteLinks = mapM (walkM rewriteLink')
+
+bodyToOutput :: PandocMonad m => Body -> DocxContext m (Meta, [Block])
+bodyToOutput (Body bps) = do
+ let (metabps, blkbps) = sepBodyParts bps
+ meta <- bodyPartsToMeta metabps
+ blks <- smushBlocks <$> mapM bodyPartToBlocks blkbps
+ blks' <- rewriteLinks $ blocksToDefinitions $ blocksToBullets $ toList blks
+ return $ (meta, blks')
+
+docxToOutput :: PandocMonad m
+ => ReaderOptions
+ -> Docx
+ -> m (Meta, [Block])
+docxToOutput opts (Docx (Document _ body)) =
+ let dEnv = def { docxOptions = opts} in
+ evalDocxContext (bodyToOutput body) dEnv def
diff --git a/src/Text/Pandoc/Readers/Docx/Combine.hs b/src/Text/Pandoc/Readers/Docx/Combine.hs
new file mode 100644
index 000000000..39e0df825
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Docx/Combine.hs
@@ -0,0 +1,154 @@
+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances,
+ PatternGuards #-}
+
+module Text.Pandoc.Readers.Docx.Combine ( smushInlines
+ , smushBlocks
+ )
+ where
+
+import Text.Pandoc.Builder
+import Data.List
+import Data.Sequence (ViewR(..), ViewL(..), viewl, viewr, (><), (|>))
+import qualified Data.Sequence as Seq (null)
+
+data Modifier a = Modifier (a -> a)
+ | AttrModifier (Attr -> a -> a) Attr
+ | NullModifier
+
+spaceOutInlinesL :: Inlines -> (Inlines, Inlines)
+spaceOutInlinesL ms = (l, stackInlines fs (m' <> r))
+ where (l, m, r) = spaceOutInlines ms
+ (fs, m') = unstackInlines m
+
+spaceOutInlinesR :: Inlines -> (Inlines, Inlines)
+spaceOutInlinesR ms = (stackInlines fs (l <> m'), r)
+ where (l, m, r) = spaceOutInlines ms
+ (fs, m') = unstackInlines m
+
+spaceOutInlines :: Inlines -> (Inlines, Inlines, Inlines)
+spaceOutInlines ils =
+ let (fs, ils') = unstackInlines ils
+ contents = unMany ils'
+ left = case viewl contents of
+ (Space :< _) -> space
+ _ -> mempty
+ right = case viewr contents of
+ (_ :> Space) -> space
+ _ -> mempty in
+ (left, (stackInlines fs $ trimInlines . Many $ contents), right)
+
+stackInlines :: [Modifier Inlines] -> Inlines -> Inlines
+stackInlines [] ms = ms
+stackInlines (NullModifier : fs) ms = stackInlines fs ms
+stackInlines ((Modifier f) : fs) ms =
+ if isEmpty ms
+ then stackInlines fs ms
+ else f $ stackInlines fs ms
+stackInlines ((AttrModifier f attr) : fs) ms = f attr $ stackInlines fs ms
+
+unstackInlines :: Inlines -> ([Modifier Inlines], Inlines)
+unstackInlines ms = case ilModifier ms of
+ NullModifier -> ([], ms)
+ _ -> (f : fs, ms') where
+ f = ilModifier ms
+ (fs, ms') = unstackInlines $ ilInnards ms
+
+ilModifier :: Inlines -> Modifier Inlines
+ilModifier ils = case viewl (unMany ils) of
+ (x :< xs) | Seq.null xs -> case x of
+ (Emph _) -> Modifier emph
+ (Strong _) -> Modifier strong
+ (SmallCaps _) -> Modifier smallcaps
+ (Strikeout _) -> Modifier strikeout
+ (Superscript _) -> Modifier superscript
+ (Subscript _) -> Modifier subscript
+ (Link attr _ tgt) -> Modifier $ linkWith attr (fst tgt) (snd tgt)
+ (Span attr _) -> AttrModifier spanWith attr
+ _ -> NullModifier
+ _ -> NullModifier
+
+ilInnards :: Inlines -> Inlines
+ilInnards ils = case viewl (unMany ils) of
+ (x :< xs) | Seq.null xs -> case x of
+ (Emph lst) -> fromList lst
+ (Strong lst) -> fromList lst
+ (SmallCaps lst) -> fromList lst
+ (Strikeout lst) -> fromList lst
+ (Superscript lst) -> fromList lst
+ (Subscript lst) -> fromList lst
+ (Link _ lst _) -> fromList lst
+ (Span _ lst) -> fromList lst
+ _ -> ils
+ _ -> ils
+
+inlinesL :: Inlines -> (Inlines, Inlines)
+inlinesL ils = case viewl $ unMany ils of
+ (s :< sq) -> (singleton s, Many sq)
+ _ -> (mempty, ils)
+
+inlinesR :: Inlines -> (Inlines, Inlines)
+inlinesR ils = case viewr $ unMany ils of
+ (sq :> s) -> (Many sq, singleton s)
+ _ -> (ils, mempty)
+
+combineInlines :: Inlines -> Inlines -> Inlines
+combineInlines x y =
+ let (xs', x') = inlinesR x
+ (y', ys') = inlinesL y
+ in
+ xs' <> (combineSingletonInlines x' y') <> ys'
+
+combineSingletonInlines :: Inlines -> Inlines -> Inlines
+combineSingletonInlines x y =
+ let (xfs, xs) = unstackInlines x
+ (yfs, ys) = unstackInlines y
+ shared = xfs `intersect` yfs
+ x_remaining = xfs \\ shared
+ y_remaining = yfs \\ shared
+ x_rem_attr = filter isAttrModifier x_remaining
+ y_rem_attr = filter isAttrModifier y_remaining
+ in
+ case null shared of
+ True | isEmpty xs && isEmpty ys ->
+ stackInlines (x_rem_attr ++ y_rem_attr) mempty
+ | isEmpty xs ->
+ let (sp, y') = spaceOutInlinesL y in
+ (stackInlines x_rem_attr mempty) <> sp <> y'
+ | isEmpty ys ->
+ let (x', sp) = spaceOutInlinesR x in
+ x' <> sp <> (stackInlines y_rem_attr mempty)
+ | otherwise ->
+ let (x', xsp) = spaceOutInlinesR x
+ (ysp, y') = spaceOutInlinesL y
+ in
+ x' <> xsp <> ysp <> y'
+ False -> stackInlines shared $
+ combineInlines
+ (stackInlines x_remaining xs)
+ (stackInlines y_remaining ys)
+
+combineBlocks :: Blocks -> Blocks -> Blocks
+combineBlocks bs cs
+ | bs' :> (BlockQuote bs'') <- viewr (unMany bs)
+ , (BlockQuote cs'') :< cs' <- viewl (unMany cs) =
+ Many $ (bs' |> (BlockQuote (bs'' <> cs''))) >< cs'
+combineBlocks bs cs = bs <> cs
+
+instance (Monoid a, Eq a) => Eq (Modifier a) where
+ (Modifier f) == (Modifier g) = (f mempty == g mempty)
+ (AttrModifier f attr) == (AttrModifier g attr') = (f attr mempty == g attr' mempty)
+ (NullModifier) == (NullModifier) = True
+ _ == _ = False
+
+isEmpty :: (Monoid a, Eq a) => a -> Bool
+isEmpty x = x == mempty
+
+isAttrModifier :: Modifier a -> Bool
+isAttrModifier (AttrModifier _ _) = True
+isAttrModifier _ = False
+
+smushInlines :: [Inlines] -> Inlines
+smushInlines xs = foldl combineInlines mempty xs
+
+smushBlocks :: [Blocks] -> Blocks
+smushBlocks xs = foldl combineBlocks mempty xs
diff --git a/src/Text/Pandoc/Readers/Docx/Lists.hs b/src/Text/Pandoc/Readers/Docx/Lists.hs
new file mode 100644
index 000000000..395a53907
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Docx/Lists.hs
@@ -0,0 +1,229 @@
+{-
+Copyright (C) 2014-2016 Jesse Rosenthal <jrosenthal@jhu.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.Docx.Lists
+ Copyright : Copyright (C) 2014-2016 Jesse Rosenthal
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>
+ Stability : alpha
+ Portability : portable
+
+Functions for converting flat docx paragraphs into nested lists.
+-}
+
+module Text.Pandoc.Readers.Docx.Lists ( blocksToBullets
+ , blocksToDefinitions
+ , listParagraphDivs
+ ) where
+
+import Text.Pandoc.JSON
+import Text.Pandoc.Generic (bottomUp)
+import Text.Pandoc.Shared (trim)
+import Control.Monad
+import Data.List
+import Data.Maybe
+
+isListItem :: Block -> Bool
+isListItem (Div (_, classes, _) _) | "list-item" `elem` classes = True
+isListItem _ = False
+
+getLevel :: Block -> Maybe Integer
+getLevel (Div (_, _, kvs) _) = liftM read $ lookup "level" kvs
+getLevel _ = Nothing
+
+getLevelN :: Block -> Integer
+getLevelN b = case getLevel b of
+ Just n -> n
+ Nothing -> -1
+
+getNumId :: Block -> Maybe Integer
+getNumId (Div (_, _, kvs) _) = liftM read $ lookup "num-id" kvs
+getNumId _ = Nothing
+
+getNumIdN :: Block -> Integer
+getNumIdN b = case getNumId b of
+ Just n -> n
+ Nothing -> -1
+
+getText :: Block -> Maybe String
+getText (Div (_, _, kvs) _) = lookup "text" kvs
+getText _ = Nothing
+
+data ListType = Itemized | Enumerated ListAttributes
+
+listStyleMap :: [(String, ListNumberStyle)]
+listStyleMap = [("upperLetter", UpperAlpha),
+ ("lowerLetter", LowerAlpha),
+ ("upperRoman", UpperRoman),
+ ("lowerRoman", LowerRoman),
+ ("decimal", Decimal)]
+
+listDelimMap :: [(String, ListNumberDelim)]
+listDelimMap = [("%1)", OneParen),
+ ("(%1)", TwoParens),
+ ("%1.", Period)]
+
+getListType :: Block -> Maybe ListType
+getListType b@(Div (_, _, kvs) _) | isListItem b =
+ let
+ start = lookup "start" kvs
+ frmt = lookup "format" kvs
+ txt = lookup "text" kvs
+ in
+ case frmt of
+ Just "bullet" -> Just Itemized
+ Just f ->
+ case txt of
+ Just t -> Just $ Enumerated (
+ read (fromMaybe "1" start) :: Int,
+ fromMaybe DefaultStyle (lookup f listStyleMap),
+ fromMaybe DefaultDelim (lookup t listDelimMap))
+ Nothing -> Nothing
+ _ -> Nothing
+getListType _ = Nothing
+
+listParagraphDivs :: [String]
+listParagraphDivs = ["ListParagraph"]
+
+-- This is a first stab at going through and attaching meaning to list
+-- paragraphs, without an item marker, following a list item. We
+-- assume that these are paragraphs in the same item.
+
+handleListParagraphs :: [Block] -> [Block]
+handleListParagraphs [] = []
+handleListParagraphs (
+ (Div attr1@(_, classes1, _) blks1) :
+ (Div (ident2, classes2, kvs2) blks2) :
+ blks
+ ) | "list-item" `elem` classes1 &&
+ not ("list-item" `elem` classes2) &&
+ (not . null) (listParagraphDivs `intersect` classes2) =
+ -- We don't want to keep this indent.
+ let newDiv2 =
+ (Div (ident2, classes2, filter (\kv -> fst kv /= "indent") kvs2) blks2)
+ in
+ handleListParagraphs ((Div attr1 (blks1 ++ [newDiv2])) : blks)
+handleListParagraphs (blk:blks) = blk : (handleListParagraphs blks)
+
+separateBlocks' :: Block -> [[Block]] -> [[Block]]
+separateBlocks' blk ([] : []) = [[blk]]
+separateBlocks' b@(BulletList _) acc = (init acc) ++ [(last acc) ++ [b]]
+separateBlocks' b@(OrderedList _ _) acc = (init acc) ++ [(last acc) ++ [b]]
+-- The following is for the invisible bullet lists. This is how
+-- pandoc-generated ooxml does multiparagraph item lists.
+separateBlocks' b acc | liftM trim (getText b) == Just "" =
+ (init acc) ++ [(last acc) ++ [b]]
+separateBlocks' b acc = acc ++ [[b]]
+
+separateBlocks :: [Block] -> [[Block]]
+separateBlocks blks = foldr separateBlocks' [[]] (reverse blks)
+
+flatToBullets' :: Integer -> [Block] -> [Block]
+flatToBullets' _ [] = []
+flatToBullets' num xs@(b : elems)
+ | getLevelN b == num = b : (flatToBullets' num elems)
+ | otherwise =
+ let bNumId = getNumIdN b
+ bLevel = getLevelN b
+ (children, remaining) =
+ span
+ (\b' ->
+ ((getLevelN b') > bLevel ||
+ ((getLevelN b') == bLevel && (getNumIdN b') == bNumId)))
+ xs
+ in
+ case getListType b of
+ Just (Enumerated attr) ->
+ (OrderedList attr (separateBlocks $ flatToBullets' bLevel children)) :
+ (flatToBullets' num remaining)
+ _ ->
+ (BulletList (separateBlocks $ flatToBullets' bLevel children)) :
+ (flatToBullets' num remaining)
+
+flatToBullets :: [Block] -> [Block]
+flatToBullets elems = flatToBullets' (-1) elems
+
+singleItemHeaderToHeader :: Block -> Block
+singleItemHeaderToHeader (OrderedList _ [[h@(Header _ _ _)]]) = h
+singleItemHeaderToHeader blk = blk
+
+
+blocksToBullets :: [Block] -> [Block]
+blocksToBullets blks =
+ map singleItemHeaderToHeader $
+ bottomUp removeListDivs $
+ flatToBullets $ (handleListParagraphs blks)
+
+plainParaInlines :: Block -> [Inline]
+plainParaInlines (Plain ils) = ils
+plainParaInlines (Para ils) = ils
+plainParaInlines _ = []
+
+blocksToDefinitions' :: [([Inline], [[Block]])] -> [Block] -> [Block] -> [Block]
+blocksToDefinitions' [] acc [] = reverse acc
+blocksToDefinitions' defAcc acc [] =
+ reverse $ (DefinitionList (reverse defAcc)) : acc
+blocksToDefinitions' defAcc acc
+ ((Div (_, classes1, _) blks1) : (Div (ident2, classes2, kvs2) blks2) : blks)
+ | "DefinitionTerm" `elem` classes1 && "Definition" `elem` classes2 =
+ let remainingAttr2 = (ident2, delete "Definition" classes2, kvs2)
+ pair = case remainingAttr2 == ("", [], []) of
+ True -> (concatMap plainParaInlines blks1, [blks2])
+ False -> (concatMap plainParaInlines blks1, [[Div remainingAttr2 blks2]])
+ in
+ blocksToDefinitions' (pair : defAcc) acc blks
+blocksToDefinitions' defAcc acc
+ ((Div (ident2, classes2, kvs2) blks2) : blks)
+ | (not . null) defAcc && "Definition" `elem` classes2 =
+ let remainingAttr2 = (ident2, delete "Definition" classes2, kvs2)
+ defItems2 = case remainingAttr2 == ("", [], []) of
+ True -> blks2
+ False -> [Div remainingAttr2 blks2]
+ ((defTerm, defItems):defs) = defAcc
+ defAcc' = case null defItems of
+ True -> (defTerm, [defItems2]) : defs
+ False -> (defTerm, init defItems ++ [last defItems ++ defItems2]) : defs
+ in
+ blocksToDefinitions' defAcc' acc blks
+blocksToDefinitions' [] acc (b:blks) =
+ blocksToDefinitions' [] (b:acc) blks
+blocksToDefinitions' defAcc acc (b:blks) =
+ blocksToDefinitions' [] (b : (DefinitionList (reverse defAcc)) : acc) blks
+
+removeListDivs' :: Block -> [Block]
+removeListDivs' (Div (ident, classes, kvs) blks)
+ | "list-item" `elem` classes =
+ case delete "list-item" classes of
+ [] -> blks
+ classes' -> [Div (ident, classes', kvs) $ blks]
+removeListDivs' (Div (ident, classes, kvs) blks)
+ | not $ null $ listParagraphDivs `intersect` classes =
+ case classes \\ listParagraphDivs of
+ [] -> blks
+ classes' -> [Div (ident, classes', kvs) blks]
+removeListDivs' blk = [blk]
+
+removeListDivs :: [Block] -> [Block]
+removeListDivs = concatMap removeListDivs'
+
+
+
+blocksToDefinitions :: [Block] -> [Block]
+blocksToDefinitions = blocksToDefinitions' [] []
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
new file mode 100644
index 000000000..221a1d10a
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -0,0 +1,1044 @@
+{-# LANGUAGE PatternGuards, ViewPatterns, FlexibleInstances #-}
+
+{-
+Copyright (C) 2014-2016 Jesse Rosenthal <jrosenthal@jhu.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.Docx.Parse
+ Copyright : Copyright (C) 2014-2016 Jesse Rosenthal
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of docx archive into Docx haskell type
+-}
+
+module Text.Pandoc.Readers.Docx.Parse ( Docx(..)
+ , Document(..)
+ , Body(..)
+ , BodyPart(..)
+ , TblLook(..)
+ , Extent
+ , ParPart(..)
+ , Run(..)
+ , RunElem(..)
+ , Notes
+ , Numbering
+ , Relationship
+ , Media
+ , RunStyle(..)
+ , VertAlign(..)
+ , ParIndentation(..)
+ , ParagraphStyle(..)
+ , Row(..)
+ , Cell(..)
+ , archiveToDocx
+ , archiveToDocxWithWarnings
+ ) where
+import Codec.Archive.Zip
+import Text.XML.Light
+import Data.Maybe
+import Data.List
+import System.FilePath
+import Data.Bits ((.|.))
+import qualified Data.ByteString.Lazy as B
+import qualified Text.Pandoc.UTF8 as UTF8
+import Control.Monad.Reader
+import Control.Monad.State
+import Control.Applicative ((<|>))
+import qualified Data.Map as M
+import Control.Monad.Except
+import Text.Pandoc.Shared (safeRead, filteredFilesFromArchive)
+import Text.TeXMath.Readers.OMML (readOMML)
+import Text.TeXMath.Unicode.Fonts (getUnicode, stringToFont, Font(..))
+import Text.TeXMath (Exp)
+import Text.Pandoc.Readers.Docx.Util
+import Data.Char (readLitChar, ord, chr, isDigit)
+
+data ReaderEnv = ReaderEnv { envNotes :: Notes
+ , envComments :: Comments
+ , envNumbering :: Numbering
+ , envRelationships :: [Relationship]
+ , envMedia :: Media
+ , envFont :: Maybe Font
+ , envCharStyles :: CharStyleMap
+ , envParStyles :: ParStyleMap
+ , envLocation :: DocumentLocation
+ }
+ deriving Show
+
+data ReaderState = ReaderState { stateWarnings :: [String] }
+ deriving Show
+
+data DocxError = DocxError | WrongElem
+ deriving Show
+
+type D = ExceptT DocxError (ReaderT ReaderEnv (State ReaderState))
+
+runD :: D a -> ReaderEnv -> ReaderState -> (Either DocxError a, ReaderState)
+runD dx re rs = runState (runReaderT (runExceptT dx) re) rs
+
+maybeToD :: Maybe a -> D a
+maybeToD (Just a) = return a
+maybeToD Nothing = throwError DocxError
+
+eitherToD :: Either a b -> D b
+eitherToD (Right b) = return b
+eitherToD (Left _) = throwError DocxError
+
+concatMapM :: (Monad m) => (a -> m [b]) -> [a] -> m [b]
+concatMapM f xs = liftM concat (mapM f xs)
+
+
+-- This is similar to `mapMaybe`: it maps a function returning the D
+-- monad over a list, and only keeps the non-erroring return values.
+mapD :: (a -> D b) -> [a] -> D [b]
+mapD f xs =
+ let handler x = (f x >>= (\y-> return [y])) `catchError` (\_ -> return [])
+ in
+ concatMapM handler xs
+
+data Docx = Docx Document
+ deriving Show
+
+data Document = Document NameSpaces Body
+ deriving Show
+
+data Body = Body [BodyPart]
+ deriving Show
+
+type Media = [(FilePath, B.ByteString)]
+
+type CharStyle = (String, RunStyle)
+
+type ParStyle = (String, ParStyleData)
+
+type CharStyleMap = M.Map String RunStyle
+
+type ParStyleMap = M.Map String ParStyleData
+
+data Numbering = Numbering NameSpaces [Numb] [AbstractNumb]
+ deriving Show
+
+data Numb = Numb String String -- right now, only a key to an abstract num
+ deriving Show
+
+data AbstractNumb = AbstractNumb String [Level]
+ deriving Show
+
+-- (ilvl, format, string, start)
+type Level = (String, String, String, Maybe Integer)
+
+data DocumentLocation = InDocument | InFootnote | InEndnote
+ deriving (Eq,Show)
+
+data Relationship = Relationship DocumentLocation RelId Target
+ deriving Show
+
+data Notes = Notes NameSpaces
+ (Maybe (M.Map String Element))
+ (Maybe (M.Map String Element))
+ deriving Show
+
+data Comments = Comments NameSpaces (M.Map String Element)
+ deriving Show
+
+data ParIndentation = ParIndentation { leftParIndent :: Maybe Integer
+ , rightParIndent :: Maybe Integer
+ , hangingParIndent :: Maybe Integer}
+ deriving Show
+
+data ParagraphStyle = ParagraphStyle { pStyle :: [String]
+ , indentation :: Maybe ParIndentation
+ , dropCap :: Bool
+ , pHeading :: Maybe (String, Int)
+ , pNumInfo :: Maybe (String, String)
+ , pBlockQuote :: Maybe Bool
+ }
+ deriving Show
+
+defaultParagraphStyle :: ParagraphStyle
+defaultParagraphStyle = ParagraphStyle { pStyle = []
+ , indentation = Nothing
+ , dropCap = False
+ , pHeading = Nothing
+ , pNumInfo = Nothing
+ , pBlockQuote = Nothing
+ }
+
+
+data BodyPart = Paragraph ParagraphStyle [ParPart]
+ | ListItem ParagraphStyle String String (Maybe Level) [ParPart]
+ | Tbl String TblGrid TblLook [Row]
+ | OMathPara [Exp]
+ deriving Show
+
+type TblGrid = [Integer]
+
+data TblLook = TblLook {firstRowFormatting::Bool}
+ deriving Show
+
+defaultTblLook :: TblLook
+defaultTblLook = TblLook{firstRowFormatting = False}
+
+data Row = Row [Cell]
+ deriving Show
+
+data Cell = Cell [BodyPart]
+ deriving Show
+
+-- (width, height) in EMUs
+type Extent = Maybe (Double, Double)
+
+data ParPart = PlainRun Run
+ | Insertion ChangeId Author ChangeDate [Run]
+ | Deletion ChangeId Author ChangeDate [Run]
+ | CommentStart CommentId Author CommentDate [BodyPart]
+ | CommentEnd CommentId
+ | BookMark BookMarkId Anchor
+ | InternalHyperLink Anchor [Run]
+ | ExternalHyperLink URL [Run]
+ | Drawing FilePath String String B.ByteString Extent -- title, alt
+ | Chart -- placeholder for now
+ | PlainOMath [Exp]
+ | SmartTag [Run]
+ deriving Show
+
+data Run = Run RunStyle [RunElem]
+ | Footnote [BodyPart]
+ | Endnote [BodyPart]
+ | InlineDrawing FilePath String String B.ByteString Extent -- title, alt
+ | InlineChart -- placeholder
+ deriving Show
+
+data RunElem = TextRun String | LnBrk | Tab | SoftHyphen | NoBreakHyphen
+ deriving Show
+
+data VertAlign = BaseLn | SupScrpt | SubScrpt
+ deriving Show
+
+data RunStyle = RunStyle { isBold :: Maybe Bool
+ , isItalic :: Maybe Bool
+ , isSmallCaps :: Maybe Bool
+ , isStrike :: Maybe Bool
+ , rVertAlign :: Maybe VertAlign
+ , rUnderline :: Maybe String
+ , rStyle :: Maybe CharStyle}
+ deriving Show
+
+data ParStyleData = ParStyleData { headingLev :: Maybe (String, Int)
+ , isBlockQuote :: Maybe Bool
+ , numInfo :: Maybe (String, String)
+ , psStyle :: Maybe ParStyle}
+ deriving Show
+
+defaultRunStyle :: RunStyle
+defaultRunStyle = RunStyle { isBold = Nothing
+ , isItalic = Nothing
+ , isSmallCaps = Nothing
+ , isStrike = Nothing
+ , rVertAlign = Nothing
+ , rUnderline = Nothing
+ , rStyle = Nothing}
+
+type Target = String
+type Anchor = String
+type URL = String
+type BookMarkId = String
+type RelId = String
+type ChangeId = String
+type CommentId = String
+type Author = String
+type ChangeDate = String
+type CommentDate = String
+
+archiveToDocx :: Archive -> Either DocxError Docx
+archiveToDocx archive = fst <$> archiveToDocxWithWarnings archive
+
+archiveToDocxWithWarnings :: Archive -> Either DocxError (Docx, [String])
+archiveToDocxWithWarnings archive = do
+ let notes = archiveToNotes archive
+ comments = archiveToComments archive
+ numbering = archiveToNumbering archive
+ rels = archiveToRelationships archive
+ media = filteredFilesFromArchive archive filePathIsMedia
+ (styles, parstyles) = archiveToStyles archive
+ rEnv =
+ ReaderEnv notes comments numbering rels media Nothing styles parstyles InDocument
+ rState = ReaderState { stateWarnings = [] }
+ (eitherDoc, st) = runD (archiveToDocument archive) rEnv rState
+ case eitherDoc of
+ Right doc -> Right (Docx doc, stateWarnings st)
+ Left e -> Left e
+
+
+
+archiveToDocument :: Archive -> D Document
+archiveToDocument zf = do
+ entry <- maybeToD $ findEntryByPath "word/document.xml" zf
+ docElem <- maybeToD $ (parseXMLDoc . UTF8.toStringLazy . fromEntry) entry
+ let namespaces = elemToNameSpaces docElem
+ bodyElem <- maybeToD $ findChildByName namespaces "w" "body" docElem
+ body <- elemToBody namespaces bodyElem
+ return $ Document namespaces body
+
+elemToBody :: NameSpaces -> Element -> D Body
+elemToBody ns element | isElem ns "w" "body" element =
+ mapD (elemToBodyPart ns) (elChildren element) >>=
+ (\bps -> return $ Body bps)
+elemToBody _ _ = throwError WrongElem
+
+archiveToStyles :: Archive -> (CharStyleMap, ParStyleMap)
+archiveToStyles zf =
+ let stylesElem = findEntryByPath "word/styles.xml" zf >>=
+ (parseXMLDoc . UTF8.toStringLazy . fromEntry)
+ in
+ case stylesElem of
+ Nothing -> (M.empty, M.empty)
+ Just styElem ->
+ let namespaces = elemToNameSpaces styElem
+ in
+ ( M.fromList $ buildBasedOnList namespaces styElem
+ (Nothing :: Maybe CharStyle),
+ M.fromList $ buildBasedOnList namespaces styElem
+ (Nothing :: Maybe ParStyle) )
+
+isBasedOnStyle :: (ElemToStyle a) => NameSpaces -> Element -> Maybe a -> Bool
+isBasedOnStyle ns element parentStyle
+ | isElem ns "w" "style" element
+ , Just styleType <- findAttrByName ns "w" "type" element
+ , styleType == cStyleType parentStyle
+ , Just basedOnVal <- findChildByName ns "w" "basedOn" element >>=
+ findAttrByName ns "w" "val"
+ , Just ps <- parentStyle = (basedOnVal == getStyleId ps)
+ | isElem ns "w" "style" element
+ , Just styleType <- findAttrByName ns "w" "type" element
+ , styleType == cStyleType parentStyle
+ , Nothing <- findChildByName ns "w" "basedOn" element
+ , Nothing <- parentStyle = True
+ | otherwise = False
+
+class ElemToStyle a where
+ cStyleType :: Maybe a -> String
+ elemToStyle :: NameSpaces -> Element -> Maybe a -> Maybe a
+ getStyleId :: a -> String
+
+instance ElemToStyle CharStyle where
+ cStyleType _ = "character"
+ elemToStyle ns element parentStyle
+ | isElem ns "w" "style" element
+ , Just "character" <- findAttrByName ns "w" "type" element
+ , Just styleId <- findAttrByName ns "w" "styleId" element =
+ Just (styleId, elemToRunStyle ns element parentStyle)
+ | otherwise = Nothing
+ getStyleId s = fst s
+
+instance ElemToStyle ParStyle where
+ cStyleType _ = "paragraph"
+ elemToStyle ns element parentStyle
+ | isElem ns "w" "style" element
+ , Just "paragraph" <- findAttrByName ns "w" "type" element
+ , Just styleId <- findAttrByName ns "w" "styleId" element =
+ Just (styleId, elemToParStyleData ns element parentStyle)
+ | otherwise = Nothing
+ getStyleId s = fst s
+
+getStyleChildren :: (ElemToStyle a) => NameSpaces -> Element -> Maybe a -> [a]
+getStyleChildren ns element parentStyle
+ | isElem ns "w" "styles" element =
+ mapMaybe (\e -> elemToStyle ns e parentStyle) $
+ filterChildren (\e' -> isBasedOnStyle ns e' parentStyle) element
+ | otherwise = []
+
+buildBasedOnList :: (ElemToStyle a) => NameSpaces -> Element -> Maybe a -> [a]
+buildBasedOnList ns element rootStyle =
+ case (getStyleChildren ns element rootStyle) of
+ [] -> []
+ stys -> stys ++
+ (concatMap (\s -> buildBasedOnList ns element (Just s)) stys)
+
+archiveToNotes :: Archive -> Notes
+archiveToNotes zf =
+ let fnElem = findEntryByPath "word/footnotes.xml" zf
+ >>= (parseXMLDoc . UTF8.toStringLazy . fromEntry)
+ enElem = findEntryByPath "word/endnotes.xml" zf
+ >>= (parseXMLDoc . UTF8.toStringLazy . fromEntry)
+ fn_namespaces = case fnElem of
+ Just e -> elemToNameSpaces e
+ Nothing -> []
+ en_namespaces = case enElem of
+ Just e -> elemToNameSpaces e
+ Nothing -> []
+ ns = unionBy (\x y -> fst x == fst y) fn_namespaces en_namespaces
+ fn = fnElem >>= (elemToNotes ns "footnote")
+ en = enElem >>= (elemToNotes ns "endnote")
+ in
+ Notes ns fn en
+
+archiveToComments :: Archive -> Comments
+archiveToComments zf =
+ let cmtsElem = findEntryByPath "word/comments.xml" zf
+ >>= (parseXMLDoc . UTF8.toStringLazy . fromEntry)
+ cmts_namespaces = case cmtsElem of
+ Just e -> elemToNameSpaces e
+ Nothing -> []
+ cmts = (elemToComments cmts_namespaces) <$> cmtsElem
+ in
+ case cmts of
+ Just c -> Comments cmts_namespaces c
+ Nothing -> Comments cmts_namespaces M.empty
+
+filePathToRelType :: FilePath -> Maybe DocumentLocation
+filePathToRelType "word/_rels/document.xml.rels" = Just InDocument
+filePathToRelType "word/_rels/footnotes.xml.rels" = Just InFootnote
+filePathToRelType "word/_rels/endnotes.xml.rels" = Just InEndnote
+filePathToRelType _ = Nothing
+
+relElemToRelationship :: DocumentLocation -> Element -> Maybe Relationship
+relElemToRelationship relType element | qName (elName element) == "Relationship" =
+ do
+ relId <- findAttr (QName "Id" Nothing Nothing) element
+ target <- findAttr (QName "Target" Nothing Nothing) element
+ return $ Relationship relType relId target
+relElemToRelationship _ _ = Nothing
+
+filePathToRelationships :: Archive -> FilePath -> [Relationship]
+filePathToRelationships ar fp | Just relType <- filePathToRelType fp
+ , Just entry <- findEntryByPath fp ar
+ , Just relElems <- (parseXMLDoc . UTF8.toStringLazy . fromEntry) entry =
+ mapMaybe (relElemToRelationship relType) $ elChildren relElems
+filePathToRelationships _ _ = []
+
+archiveToRelationships :: Archive -> [Relationship]
+archiveToRelationships archive =
+ concatMap (filePathToRelationships archive) $ filesInArchive archive
+
+filePathIsMedia :: FilePath -> Bool
+filePathIsMedia fp =
+ let (dir, _) = splitFileName fp
+ in
+ (dir == "word/media/")
+
+lookupLevel :: String -> String -> Numbering -> Maybe Level
+lookupLevel numId ilvl (Numbering _ numbs absNumbs) = do
+ absNumId <- lookup numId $ map (\(Numb nid absnumid) -> (nid, absnumid)) numbs
+ lvls <- lookup absNumId $ map (\(AbstractNumb aid ls) -> (aid, ls)) absNumbs
+ lvl <- lookup ilvl $ map (\l@(i, _, _, _) -> (i, l)) lvls
+ return lvl
+
+
+numElemToNum :: NameSpaces -> Element -> Maybe Numb
+numElemToNum ns element
+ | isElem ns "w" "num" element = do
+ numId <- findAttrByName ns "w" "numId" element
+ absNumId <- findChildByName ns "w" "abstractNumId" element
+ >>= findAttrByName ns "w" "val"
+ return $ Numb numId absNumId
+numElemToNum _ _ = Nothing
+
+absNumElemToAbsNum :: NameSpaces -> Element -> Maybe AbstractNumb
+absNumElemToAbsNum ns element
+ | isElem ns "w" "abstractNum" element = do
+ absNumId <- findAttrByName ns "w" "abstractNumId" element
+ let levelElems = findChildrenByName ns "w" "lvl" element
+ levels = mapMaybe (levelElemToLevel ns) levelElems
+ return $ AbstractNumb absNumId levels
+absNumElemToAbsNum _ _ = Nothing
+
+levelElemToLevel :: NameSpaces -> Element -> Maybe Level
+levelElemToLevel ns element
+ | isElem ns "w" "lvl" element = do
+ ilvl <- findAttrByName ns "w" "ilvl" element
+ fmt <- findChildByName ns "w" "numFmt" element
+ >>= findAttrByName ns "w" "val"
+ txt <- findChildByName ns "w" "lvlText" element
+ >>= findAttrByName ns "w" "val"
+ let start = findChildByName ns "w" "start" element
+ >>= findAttrByName ns "w" "val"
+ >>= (\s -> listToMaybe (map fst (reads s :: [(Integer, String)])))
+ return (ilvl, fmt, txt, start)
+levelElemToLevel _ _ = Nothing
+
+archiveToNumbering' :: Archive -> Maybe Numbering
+archiveToNumbering' zf = do
+ case findEntryByPath "word/numbering.xml" zf of
+ Nothing -> Just $ Numbering [] [] []
+ Just entry -> do
+ numberingElem <- (parseXMLDoc . UTF8.toStringLazy . fromEntry) entry
+ let namespaces = elemToNameSpaces numberingElem
+ numElems = findChildrenByName namespaces "w" "num" numberingElem
+ absNumElems = findChildrenByName namespaces "w" "abstractNum" numberingElem
+ nums = mapMaybe (numElemToNum namespaces) numElems
+ absNums = mapMaybe (absNumElemToAbsNum namespaces) absNumElems
+ return $ Numbering namespaces nums absNums
+
+archiveToNumbering :: Archive -> Numbering
+archiveToNumbering archive =
+ fromMaybe (Numbering [] [] []) (archiveToNumbering' archive)
+
+elemToNotes :: NameSpaces -> String -> Element -> Maybe (M.Map String Element)
+elemToNotes ns notetype element
+ | isElem ns "w" (notetype ++ "s") element =
+ let pairs = mapMaybe
+ (\e -> findAttrByName ns "w" "id" e >>=
+ (\a -> Just (a, e)))
+ (findChildrenByName ns "w" notetype element)
+ in
+ Just $ M.fromList $ pairs
+elemToNotes _ _ _ = Nothing
+
+elemToComments :: NameSpaces -> Element -> M.Map String Element
+elemToComments ns element
+ | isElem ns "w" "comments" element =
+ let pairs = mapMaybe
+ (\e -> findAttrByName ns "w" "id" e >>=
+ (\a -> Just (a, e)))
+ (findChildrenByName ns "w" "comment" element)
+ in
+ M.fromList $ pairs
+elemToComments _ _ = M.empty
+
+
+---------------------------------------------
+---------------------------------------------
+
+elemToTblGrid :: NameSpaces -> Element -> D TblGrid
+elemToTblGrid ns element | isElem ns "w" "tblGrid" element =
+ let cols = findChildrenByName ns "w" "gridCol" element
+ in
+ mapD (\e -> maybeToD (findAttrByName ns "w" "val" e >>= stringToInteger))
+ cols
+elemToTblGrid _ _ = throwError WrongElem
+
+elemToTblLook :: NameSpaces -> Element -> D TblLook
+elemToTblLook ns element | isElem ns "w" "tblLook" element =
+ let firstRow = findAttrByName ns "w" "firstRow" element
+ val = findAttrByName ns "w" "val" element
+ firstRowFmt =
+ case firstRow of
+ Just "1" -> True
+ Just _ -> False
+ Nothing -> case val of
+ Just bitMask -> testBitMask bitMask 0x020
+ Nothing -> False
+ in
+ return $ TblLook{firstRowFormatting = firstRowFmt}
+elemToTblLook _ _ = throwError WrongElem
+
+elemToRow :: NameSpaces -> Element -> D Row
+elemToRow ns element | isElem ns "w" "tr" element =
+ do
+ let cellElems = findChildrenByName ns "w" "tc" element
+ cells <- mapD (elemToCell ns) cellElems
+ return $ Row cells
+elemToRow _ _ = throwError WrongElem
+
+elemToCell :: NameSpaces -> Element -> D Cell
+elemToCell ns element | isElem ns "w" "tc" element =
+ do
+ cellContents <- mapD (elemToBodyPart ns) (elChildren element)
+ return $ Cell cellContents
+elemToCell _ _ = throwError WrongElem
+
+elemToParIndentation :: NameSpaces -> Element -> Maybe ParIndentation
+elemToParIndentation ns element | isElem ns "w" "ind" element =
+ Just $ ParIndentation {
+ leftParIndent =
+ findAttrByName ns "w" "left" element >>=
+ stringToInteger
+ , rightParIndent =
+ findAttrByName ns "w" "right" element >>=
+ stringToInteger
+ , hangingParIndent =
+ findAttrByName ns "w" "hanging" element >>=
+ stringToInteger}
+elemToParIndentation _ _ = Nothing
+
+testBitMask :: String -> Int -> Bool
+testBitMask bitMaskS n =
+ case (reads ("0x" ++ bitMaskS) :: [(Int, String)]) of
+ [] -> False
+ ((n', _) : _) -> ((n' .|. n) /= 0)
+
+stringToInteger :: String -> Maybe Integer
+stringToInteger s = listToMaybe $ map fst (reads s :: [(Integer, String)])
+
+elemToBodyPart :: NameSpaces -> Element -> D BodyPart
+elemToBodyPart ns element
+ | isElem ns "w" "p" element
+ , (c:_) <- findChildrenByName ns "m" "oMathPara" element =
+ do
+ expsLst <- eitherToD $ readOMML $ showElement c
+ return $ OMathPara expsLst
+elemToBodyPart ns element
+ | isElem ns "w" "p" element
+ , Just (numId, lvl) <- getNumInfo ns element = do
+ sty <- asks envParStyles
+ let parstyle = elemToParagraphStyle ns element sty
+ parparts <- mapD (elemToParPart ns) (elChildren element)
+ num <- asks envNumbering
+ let levelInfo = lookupLevel numId lvl num
+ return $ ListItem parstyle numId lvl levelInfo parparts
+elemToBodyPart ns element
+ | isElem ns "w" "p" element = do
+ sty <- asks envParStyles
+ let parstyle = elemToParagraphStyle ns element sty
+ parparts <- mapD (elemToParPart ns) (elChildren element)
+ -- Word uses list enumeration for numbered headings, so we only
+ -- want to infer a list from the styles if it is NOT a heading.
+ case pHeading parstyle of
+ Nothing | Just (numId, lvl) <- pNumInfo parstyle -> do
+ num <- asks envNumbering
+ let levelInfo = lookupLevel numId lvl num
+ return $ ListItem parstyle numId lvl levelInfo parparts
+ _ -> return $ Paragraph parstyle parparts
+elemToBodyPart ns element
+ | isElem ns "w" "tbl" element = do
+ let caption' = findChildByName ns "w" "tblPr" element
+ >>= findChildByName ns "w" "tblCaption"
+ >>= findAttrByName ns "w" "val"
+ caption = (fromMaybe "" caption')
+ grid' = case findChildByName ns "w" "tblGrid" element of
+ Just g -> elemToTblGrid ns g
+ Nothing -> return []
+ tblLook' = case findChildByName ns "w" "tblPr" element >>=
+ findChildByName ns "w" "tblLook"
+ of
+ Just l -> elemToTblLook ns l
+ Nothing -> return defaultTblLook
+
+ grid <- grid'
+ tblLook <- tblLook'
+ rows <- mapD (elemToRow ns) (elChildren element)
+ return $ Tbl caption grid tblLook rows
+elemToBodyPart _ _ = throwError WrongElem
+
+lookupRelationship :: DocumentLocation -> RelId -> [Relationship] -> Maybe Target
+lookupRelationship docLocation relid rels =
+ lookup (docLocation, relid) pairs
+ where
+ pairs = map (\(Relationship loc relid' target) -> ((loc, relid'), target)) rels
+
+expandDrawingId :: String -> D (FilePath, B.ByteString)
+expandDrawingId s = do
+ location <- asks envLocation
+ target <- asks (lookupRelationship location s . envRelationships)
+ case target of
+ Just filepath -> do
+ bytes <- asks (lookup ("word/" ++ filepath) . envMedia)
+ case bytes of
+ Just bs -> return (filepath, bs)
+ Nothing -> throwError DocxError
+ Nothing -> throwError DocxError
+
+getTitleAndAlt :: NameSpaces -> Element -> (String, String)
+getTitleAndAlt ns element =
+ let mbDocPr = findChildByName ns "wp" "inline" element >>=
+ findChildByName ns "wp" "docPr"
+ title = case mbDocPr >>= findAttrByName ns "" "title" of
+ Just title' -> title'
+ Nothing -> ""
+ alt = case mbDocPr >>= findAttrByName ns "" "descr" of
+ Just alt' -> alt'
+ Nothing -> ""
+ in (title, alt)
+
+elemToParPart :: NameSpaces -> Element -> D ParPart
+elemToParPart ns element
+ | isElem ns "w" "r" element
+ , Just drawingElem <- findChildByName ns "w" "drawing" element
+ , pic_ns <- "http://schemas.openxmlformats.org/drawingml/2006/picture"
+ , Just picElem <- findElement (QName "pic" (Just pic_ns) (Just "pic")) drawingElem
+ = let (title, alt) = getTitleAndAlt ns drawingElem
+ a_ns = "http://schemas.openxmlformats.org/drawingml/2006/main"
+ drawing = findElement (QName "blip" (Just a_ns) (Just "a")) picElem
+ >>= findAttrByName ns "r" "embed"
+ in
+ case drawing of
+ Just s -> expandDrawingId s >>= (\(fp, bs) -> return $ Drawing fp title alt bs $ elemToExtent drawingElem)
+ Nothing -> throwError WrongElem
+-- The below is an attempt to deal with images in deprecated vml format.
+elemToParPart ns element
+ | isElem ns "w" "r" element
+ , Just _ <- findChildByName ns "w" "pict" element =
+ let drawing = findElement (elemName ns "v" "imagedata") element
+ >>= findAttrByName ns "r" "id"
+ in
+ case drawing of
+ -- Todo: check out title and attr for deprecated format.
+ Just s -> expandDrawingId s >>= (\(fp, bs) -> return $ Drawing fp "" "" bs Nothing)
+ Nothing -> throwError WrongElem
+-- Chart
+elemToParPart ns element
+ | isElem ns "w" "r" element
+ , Just drawingElem <- findChildByName ns "w" "drawing" element
+ , c_ns <- "http://schemas.openxmlformats.org/drawingml/2006/chart"
+ , Just _ <- findElement (QName "chart" (Just c_ns) (Just "c")) drawingElem
+ = return Chart
+elemToParPart ns element
+ | isElem ns "w" "r" element =
+ elemToRun ns element >>= (\r -> return $ PlainRun r)
+elemToParPart ns element
+ | isElem ns "w" "ins" element || isElem ns "w" "moveTo" element
+ , Just cId <- findAttrByName ns "w" "id" element
+ , Just cAuthor <- findAttrByName ns "w" "author" element
+ , Just cDate <- findAttrByName ns "w" "date" element = do
+ runs <- mapD (elemToRun ns) (elChildren element)
+ return $ Insertion cId cAuthor cDate runs
+elemToParPart ns element
+ | isElem ns "w" "del" element || isElem ns "w" "moveFrom" element
+ , Just cId <- findAttrByName ns "w" "id" element
+ , Just cAuthor <- findAttrByName ns "w" "author" element
+ , Just cDate <- findAttrByName ns "w" "date" element = do
+ runs <- mapD (elemToRun ns) (elChildren element)
+ return $ Deletion cId cAuthor cDate runs
+elemToParPart ns element
+ | isElem ns "w" "smartTag" element = do
+ runs <- mapD (elemToRun ns) (elChildren element)
+ return $ SmartTag runs
+elemToParPart ns element
+ | isElem ns "w" "bookmarkStart" element
+ , Just bmId <- findAttrByName ns "w" "id" element
+ , Just bmName <- findAttrByName ns "w" "name" element =
+ return $ BookMark bmId bmName
+elemToParPart ns element
+ | isElem ns "w" "hyperlink" element
+ , Just relId <- findAttrByName ns "r" "id" element = do
+ location <- asks envLocation
+ runs <- mapD (elemToRun ns) (elChildren element)
+ rels <- asks envRelationships
+ case lookupRelationship location relId rels of
+ Just target -> do
+ case findAttrByName ns "w" "anchor" element of
+ Just anchor -> return $ ExternalHyperLink (target ++ '#':anchor) runs
+ Nothing -> return $ ExternalHyperLink target runs
+ Nothing -> return $ ExternalHyperLink "" runs
+elemToParPart ns element
+ | isElem ns "w" "hyperlink" element
+ , Just anchor <- findAttrByName ns "w" "anchor" element = do
+ runs <- mapD (elemToRun ns) (elChildren element)
+ return $ InternalHyperLink anchor runs
+elemToParPart ns element
+ | isElem ns "w" "commentRangeStart" element
+ , Just cmtId <- findAttrByName ns "w" "id" element = do
+ (Comments _ commentMap) <- asks envComments
+ case M.lookup cmtId commentMap of
+ Just cmtElem -> elemToCommentStart ns cmtElem
+ Nothing -> throwError WrongElem
+elemToParPart ns element
+ | isElem ns "w" "commentRangeEnd" element
+ , Just cmtId <- findAttrByName ns "w" "id" element =
+ return $ CommentEnd cmtId
+elemToParPart ns element
+ | isElem ns "m" "oMath" element =
+ (eitherToD $ readOMML $ showElement element) >>= (return . PlainOMath)
+elemToParPart _ _ = throwError WrongElem
+
+elemToCommentStart :: NameSpaces -> Element -> D ParPart
+elemToCommentStart ns element
+ | isElem ns "w" "comment" element
+ , Just cmtId <- findAttrByName ns "w" "id" element
+ , Just cmtAuthor <- findAttrByName ns "w" "author" element
+ , Just cmtDate <- findAttrByName ns "w" "date" element = do
+ bps <- mapD (elemToBodyPart ns) (elChildren element)
+ return $ CommentStart cmtId cmtAuthor cmtDate bps
+elemToCommentStart _ _ = throwError WrongElem
+
+lookupFootnote :: String -> Notes -> Maybe Element
+lookupFootnote s (Notes _ fns _) = fns >>= (M.lookup s)
+
+lookupEndnote :: String -> Notes -> Maybe Element
+lookupEndnote s (Notes _ _ ens) = ens >>= (M.lookup s)
+
+elemToExtent :: Element -> Extent
+elemToExtent drawingElem =
+ case (getDim "cx", getDim "cy") of
+ (Just w, Just h) -> Just (w, h)
+ _ -> Nothing
+ where
+ wp_ns = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
+ getDim at = findElement (QName "extent" (Just wp_ns) (Just "wp")) drawingElem
+ >>= findAttr (QName at Nothing Nothing) >>= safeRead
+
+
+childElemToRun :: NameSpaces -> Element -> D Run
+childElemToRun ns element
+ | isElem ns "w" "drawing" element
+ , pic_ns <- "http://schemas.openxmlformats.org/drawingml/2006/picture"
+ , Just picElem <- findElement (QName "pic" (Just pic_ns) (Just "pic")) element
+ = let (title, alt) = getTitleAndAlt ns element
+ a_ns = "http://schemas.openxmlformats.org/drawingml/2006/main"
+ drawing = findElement (QName "blip" (Just a_ns) (Just "a")) picElem
+ >>= findAttr (QName "embed" (lookup "r" ns) (Just "r"))
+ in
+ case drawing of
+ Just s -> expandDrawingId s >>=
+ (\(fp, bs) -> return $ InlineDrawing fp title alt bs $ elemToExtent element)
+ Nothing -> throwError WrongElem
+childElemToRun ns element
+ | isElem ns "w" "drawing" element
+ , c_ns <- "http://schemas.openxmlformats.org/drawingml/2006/chart"
+ , Just _ <- findElement (QName "chart" (Just c_ns) (Just "c")) element
+ = return InlineChart
+childElemToRun ns element
+ | isElem ns "w" "footnoteReference" element
+ , Just fnId <- findAttrByName ns "w" "id" element = do
+ notes <- asks envNotes
+ case lookupFootnote fnId notes of
+ Just e -> do bps <- local (\r -> r {envLocation=InFootnote}) $ mapD (elemToBodyPart ns) (elChildren e)
+ return $ Footnote bps
+ Nothing -> return $ Footnote []
+childElemToRun ns element
+ | isElem ns "w" "endnoteReference" element
+ , Just enId <- findAttrByName ns "w" "id" element = do
+ notes <- asks envNotes
+ case lookupEndnote enId notes of
+ Just e -> do bps <- local (\r -> r {envLocation=InEndnote}) $ mapD (elemToBodyPart ns) (elChildren e)
+ return $ Endnote bps
+ Nothing -> return $ Endnote []
+childElemToRun _ _ = throwError WrongElem
+
+elemToRun :: NameSpaces -> Element -> D Run
+elemToRun ns element
+ | isElem ns "w" "r" element
+ , Just altCont <- findChildByName ns "mc" "AlternateContent" element =
+ do let choices = findChildrenByName ns "mc" "Choice" altCont
+ choiceChildren = map head $ filter (not . null) $ map elChildren choices
+ outputs <- mapD (childElemToRun ns) choiceChildren
+ case outputs of
+ r : _ -> return r
+ [] -> throwError WrongElem
+elemToRun ns element
+ | isElem ns "w" "r" element
+ , Just drawingElem <- findChildByName ns "w" "drawing" element =
+ childElemToRun ns drawingElem
+elemToRun ns element
+ | isElem ns "w" "r" element
+ , Just ref <- findChildByName ns "w" "footnoteReference" element =
+ childElemToRun ns ref
+elemToRun ns element
+ | isElem ns "w" "r" element
+ , Just ref <- findChildByName ns "w" "endnoteReference" element =
+ childElemToRun ns ref
+elemToRun ns element
+ | isElem ns "w" "r" element = do
+ runElems <- elemToRunElems ns element
+ runStyle <- elemToRunStyleD ns element
+ return $ Run runStyle runElems
+elemToRun _ _ = throwError WrongElem
+
+getParentStyleValue :: (ParStyleData -> Maybe a) -> ParStyleData -> Maybe a
+getParentStyleValue field style
+ | Just value <- field style = Just value
+ | Just parentStyle <- psStyle style
+ = getParentStyleValue field (snd parentStyle)
+getParentStyleValue _ _ = Nothing
+
+getParStyleField :: (ParStyleData -> Maybe a) -> ParStyleMap -> [String] ->
+ Maybe a
+getParStyleField field stylemap styles
+ | x <- mapMaybe (\x -> M.lookup x stylemap) styles
+ , (y:_) <- mapMaybe (getParentStyleValue field) x
+ = Just y
+getParStyleField _ _ _ = Nothing
+
+elemToParagraphStyle :: NameSpaces -> Element -> ParStyleMap -> ParagraphStyle
+elemToParagraphStyle ns element sty
+ | Just pPr <- findChildByName ns "w" "pPr" element =
+ let style =
+ mapMaybe
+ (findAttrByName ns "w" "val")
+ (findChildrenByName ns "w" "pStyle" pPr)
+ in ParagraphStyle
+ {pStyle = style
+ , indentation =
+ findChildByName ns "w" "ind" pPr >>=
+ elemToParIndentation ns
+ , dropCap =
+ case
+ findChildByName ns "w" "framePr" pPr >>=
+ findAttrByName ns "w" "dropCap"
+ of
+ Just "none" -> False
+ Just _ -> True
+ Nothing -> False
+ , pHeading = getParStyleField headingLev sty style
+ , pNumInfo = getParStyleField numInfo sty style
+ , pBlockQuote = getParStyleField isBlockQuote sty style
+ }
+elemToParagraphStyle _ _ _ = defaultParagraphStyle
+
+checkOnOff :: NameSpaces -> Element -> QName -> Maybe Bool
+checkOnOff ns rPr tag
+ | Just t <- findChild tag rPr
+ , Just val <- findAttrByName ns "w" "val" t =
+ Just $ case val of
+ "true" -> True
+ "false" -> False
+ "on" -> True
+ "off" -> False
+ "1" -> True
+ "0" -> False
+ _ -> False
+ | Just _ <- findChild tag rPr = Just True
+checkOnOff _ _ _ = Nothing
+
+elemToRunStyleD :: NameSpaces -> Element -> D RunStyle
+elemToRunStyleD ns element
+ | Just rPr <- findChildByName ns "w" "rPr" element = do
+ charStyles <- asks envCharStyles
+ let parentSty = case
+ findChildByName ns "w" "rStyle" rPr >>=
+ findAttrByName ns "w" "val"
+ of
+ Just styName | Just style <- M.lookup styName charStyles ->
+ Just (styName, style)
+ _ -> Nothing
+ return $ elemToRunStyle ns element parentSty
+elemToRunStyleD _ _ = return defaultRunStyle
+
+elemToRunStyle :: NameSpaces -> Element -> Maybe CharStyle -> RunStyle
+elemToRunStyle ns element parentStyle
+ | Just rPr <- findChildByName ns "w" "rPr" element =
+ RunStyle
+ {
+ isBold = checkOnOff ns rPr (elemName ns "w" "b")
+ , isItalic = checkOnOff ns rPr (elemName ns "w" "i")
+ , isSmallCaps = checkOnOff ns rPr (elemName ns "w" "smallCaps")
+ , isStrike = checkOnOff ns rPr (elemName ns "w" "strike")
+ , rVertAlign =
+ findChildByName ns "w" "vertAlign" rPr >>=
+ findAttrByName ns "w" "val" >>=
+ \v -> Just $ case v of
+ "superscript" -> SupScrpt
+ "subscript" -> SubScrpt
+ _ -> BaseLn
+ , rUnderline =
+ findChildByName ns "w" "u" rPr >>=
+ findAttrByName ns "w" "val"
+ , rStyle = parentStyle
+ }
+elemToRunStyle _ _ _ = defaultRunStyle
+
+isNumericNotNull :: String -> Bool
+isNumericNotNull str = (str /= []) && (all isDigit str)
+
+getHeaderLevel :: NameSpaces -> Element -> Maybe (String,Int)
+getHeaderLevel ns element
+ | Just styleId <- findAttrByName ns "w" "styleId" element
+ , Just index <- stripPrefix "Heading" styleId
+ , isNumericNotNull index = Just (styleId, read index)
+ | Just styleId <- findAttrByName ns "w" "styleId" element
+ , Just index <- findChildByName ns "w" "name" element >>=
+ findAttrByName ns "w" "val" >>=
+ stripPrefix "heading "
+ , isNumericNotNull index = Just (styleId, read index)
+getHeaderLevel _ _ = Nothing
+
+blockQuoteStyleIds :: [String]
+blockQuoteStyleIds = ["Quote", "BlockQuote", "BlockQuotation"]
+
+blockQuoteStyleNames :: [String]
+blockQuoteStyleNames = ["Quote", "Block Text"]
+
+getBlockQuote :: NameSpaces -> Element -> Maybe Bool
+getBlockQuote ns element
+ | Just styleId <- findAttrByName ns "w" "styleId" element
+ , styleId `elem` blockQuoteStyleIds = Just True
+ | Just styleName <- findChildByName ns "w" "name" element >>=
+ findAttrByName ns "w" "val"
+ , styleName `elem` blockQuoteStyleNames = Just True
+getBlockQuote _ _ = Nothing
+
+getNumInfo :: NameSpaces -> Element -> Maybe (String, String)
+getNumInfo ns element = do
+ let numPr = findChildByName ns "w" "pPr" element >>=
+ findChildByName ns "w" "numPr"
+ lvl = fromMaybe "0" (numPr >>=
+ findChildByName ns "w" "ilvl" >>=
+ findAttrByName ns "w" "val")
+ numId <- numPr >>=
+ findChildByName ns "w" "numId" >>=
+ findAttrByName ns "w" "val"
+ return (numId, lvl)
+
+
+elemToParStyleData :: NameSpaces -> Element -> Maybe ParStyle -> ParStyleData
+elemToParStyleData ns element parentStyle =
+ ParStyleData
+ {
+ headingLev = getHeaderLevel ns element
+ , isBlockQuote = getBlockQuote ns element
+ , numInfo = getNumInfo ns element
+ , psStyle = parentStyle
+ }
+
+elemToRunElem :: NameSpaces -> Element -> D RunElem
+elemToRunElem ns element
+ | isElem ns "w" "t" element
+ || isElem ns "w" "delText" element
+ || isElem ns "m" "t" element = do
+ let str = strContent element
+ font <- asks envFont
+ case font of
+ Nothing -> return $ TextRun str
+ Just f -> return . TextRun $
+ map (\x -> fromMaybe x . getUnicode f . lowerFromPrivate $ x) str
+ | isElem ns "w" "br" element = return LnBrk
+ | isElem ns "w" "tab" element = return Tab
+ | isElem ns "w" "softHyphen" element = return SoftHyphen
+ | isElem ns "w" "noBreakHyphen" element = return NoBreakHyphen
+ | isElem ns "w" "sym" element = return (getSymChar ns element)
+ | otherwise = throwError WrongElem
+ where
+ lowerFromPrivate (ord -> c)
+ | c >= ord '\xF000' = chr $ c - ord '\xF000'
+ | otherwise = chr c
+
+-- The char attribute is a hex string
+getSymChar :: NameSpaces -> Element -> RunElem
+getSymChar ns element
+ | Just s <- lowerFromPrivate <$> getCodepoint
+ , Just font <- getFont =
+ let [(char, _)] = readLitChar ("\\x" ++ s) in
+ TextRun . maybe "" (:[]) $ getUnicode font char
+ where
+ getCodepoint = findAttrByName ns "w" "char" element
+ getFont = stringToFont =<< findAttrByName ns "w" "font" element
+ lowerFromPrivate ('F':xs) = '0':xs
+ lowerFromPrivate xs = xs
+getSymChar _ _ = TextRun ""
+
+elemToRunElems :: NameSpaces -> Element -> D [RunElem]
+elemToRunElems ns element
+ | isElem ns "w" "r" element
+ || isElem ns "m" "r" element = do
+ let qualName = elemName ns "w"
+ let font = do
+ fontElem <- findElement (qualName "rFonts") element
+ stringToFont =<<
+ (foldr (<|>) Nothing $
+ map (flip findAttr fontElem . qualName) ["ascii", "hAnsi"])
+ local (setFont font) (mapD (elemToRunElem ns) (elChildren element))
+elemToRunElems _ _ = throwError WrongElem
+
+setFont :: Maybe Font -> ReaderEnv -> ReaderEnv
+setFont f s = s{envFont = f}
+
diff --git a/src/Text/Pandoc/Readers/Docx/StyleMap.hs b/src/Text/Pandoc/Readers/Docx/StyleMap.hs
new file mode 100644
index 000000000..00906cf07
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Docx/StyleMap.hs
@@ -0,0 +1,108 @@
+module Text.Pandoc.Readers.Docx.StyleMap ( StyleMaps(..)
+ , alterMap
+ , getMap
+ , defaultStyleMaps
+ , getStyleMaps
+ , getStyleId
+ , hasStyleName
+ ) where
+
+import Text.XML.Light
+import Text.Pandoc.Readers.Docx.Util
+import Control.Monad.State
+import Data.Char (toLower)
+import qualified Data.Map as M
+
+newtype ParaStyleMap = ParaStyleMap ( M.Map String String )
+newtype CharStyleMap = CharStyleMap ( M.Map String String )
+
+class StyleMap a where
+ alterMap :: (M.Map String String -> M.Map String String) -> a -> a
+ getMap :: a -> M.Map String String
+
+instance StyleMap ParaStyleMap where
+ alterMap f (ParaStyleMap m) = ParaStyleMap $ f m
+ getMap (ParaStyleMap m) = m
+
+instance StyleMap CharStyleMap where
+ alterMap f (CharStyleMap m) = CharStyleMap $ f m
+ getMap (CharStyleMap m) = m
+
+insert :: (StyleMap a) => Maybe String -> Maybe String -> a -> a
+insert (Just k) (Just v) m = alterMap (M.insert k v) m
+insert _ _ m = m
+
+getStyleId :: (StyleMap a) => String -> a -> String
+getStyleId s = M.findWithDefault (filter (/=' ') s) (map toLower s) . getMap
+
+hasStyleName :: (StyleMap a) => String -> a -> Bool
+hasStyleName styleName = M.member (map toLower styleName) . getMap
+
+data StyleMaps = StyleMaps { sNameSpaces :: NameSpaces
+ , sParaStyleMap :: ParaStyleMap
+ , sCharStyleMap :: CharStyleMap
+ }
+
+data StyleType = ParaStyle | CharStyle
+
+defaultStyleMaps :: StyleMaps
+defaultStyleMaps = StyleMaps { sNameSpaces = []
+ , sParaStyleMap = ParaStyleMap M.empty
+ , sCharStyleMap = CharStyleMap M.empty
+ }
+
+type StateM a = State StyleMaps a
+
+getStyleMaps :: Element -> StyleMaps
+getStyleMaps docElem = execState genStyleMap state'
+ where
+ state' = defaultStyleMaps {sNameSpaces = elemToNameSpaces docElem}
+ genStyleItem e = do
+ styleType <- getStyleType e
+ styleId <- getAttrStyleId e
+ nameValLowercase <- fmap (map toLower) `fmap` getNameVal e
+ case styleType of
+ Just ParaStyle -> modParaStyleMap $ insert nameValLowercase styleId
+ Just CharStyle -> modCharStyleMap $ insert nameValLowercase styleId
+ _ -> return ()
+ genStyleMap = do
+ style <- elemName' "style"
+ let styles = findChildren style docElem
+ forM_ styles genStyleItem
+
+modParaStyleMap :: (ParaStyleMap -> ParaStyleMap) -> StateM ()
+modParaStyleMap f = modify $ \s ->
+ s {sParaStyleMap = f $ sParaStyleMap s}
+
+modCharStyleMap :: (CharStyleMap -> CharStyleMap) -> StateM ()
+modCharStyleMap f = modify $ \s ->
+ s {sCharStyleMap = f $ sCharStyleMap s}
+
+getStyleType :: Element -> StateM (Maybe StyleType)
+getStyleType e = do
+ styleTypeStr <- getAttrType e
+ case styleTypeStr of
+ Just "paragraph" -> return $ Just ParaStyle
+ Just "character" -> return $ Just CharStyle
+ _ -> return Nothing
+
+getAttrType :: Element -> StateM (Maybe String)
+getAttrType el = do
+ name <- elemName' "type"
+ return $ findAttr name el
+
+getAttrStyleId :: Element -> StateM (Maybe String)
+getAttrStyleId el = do
+ name <- elemName' "styleId"
+ return $ findAttr name el
+
+getNameVal :: Element -> StateM (Maybe String)
+getNameVal el = do
+ name <- elemName' "name"
+ val <- elemName' "val"
+ return $ findChild name el >>= findAttr val
+
+elemName' :: String -> StateM QName
+elemName' name = do
+ namespaces <- gets sNameSpaces
+ return $ elemName namespaces "w" name
diff --git a/src/Text/Pandoc/Readers/Docx/Util.hs b/src/Text/Pandoc/Readers/Docx/Util.hs
new file mode 100644
index 000000000..6646e5b7f
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Docx/Util.hs
@@ -0,0 +1,47 @@
+module Text.Pandoc.Readers.Docx.Util (
+ NameSpaces
+ , elemName
+ , isElem
+ , elemToNameSpaces
+ , findChildByName
+ , findChildrenByName
+ , findAttrByName
+ ) where
+
+import Text.XML.Light
+import Data.Maybe (mapMaybe)
+
+type NameSpaces = [(String, String)]
+
+elemToNameSpaces :: Element -> NameSpaces
+elemToNameSpaces = mapMaybe attrToNSPair . elAttribs
+
+attrToNSPair :: Attr -> Maybe (String, String)
+attrToNSPair (Attr (QName s _ (Just "xmlns")) val) = Just (s, val)
+attrToNSPair _ = Nothing
+
+elemName :: NameSpaces -> String -> String -> QName
+elemName ns prefix name =
+ QName name (lookup prefix ns) (if null prefix then Nothing else Just prefix)
+
+isElem :: NameSpaces -> String -> String -> Element -> Bool
+isElem ns prefix name element =
+ let ns' = ns ++ elemToNameSpaces element
+ in qName (elName element) == name &&
+ qURI (elName element) == lookup prefix ns'
+
+findChildByName :: NameSpaces -> String -> String -> Element -> Maybe Element
+findChildByName ns pref name el =
+ let ns' = ns ++ elemToNameSpaces el
+ in findChild (elemName ns' pref name) el
+
+findChildrenByName :: NameSpaces -> String -> String -> Element -> [Element]
+findChildrenByName ns pref name el =
+ let ns' = ns ++ elemToNameSpaces el
+ in findChildren (elemName ns' pref name) el
+
+findAttrByName :: NameSpaces -> String -> String -> Element -> Maybe String
+findAttrByName ns pref name el =
+ let ns' = ns ++ elemToNameSpaces el
+ in findAttr (elemName ns' pref name) el
+
diff --git a/src/Text/Pandoc/Readers/EPUB.hs b/src/Text/Pandoc/Readers/EPUB.hs
new file mode 100644
index 000000000..2eaa842b6
--- /dev/null
+++ b/src/Text/Pandoc/Readers/EPUB.hs
@@ -0,0 +1,279 @@
+{-# LANGUAGE
+ ViewPatterns
+ , StandaloneDeriving
+ , TupleSections
+ , FlexibleContexts #-}
+
+module Text.Pandoc.Readers.EPUB
+ (readEPUB)
+ where
+
+import Text.XML.Light
+import Text.Pandoc.Definition hiding (Attr)
+import Text.Pandoc.Readers.HTML (readHtml)
+import Text.Pandoc.Walk (walk, query)
+import Text.Pandoc.Options ( ReaderOptions(..))
+import Text.Pandoc.Extensions (enableExtension, Extension(Ext_raw_html))
+import Text.Pandoc.Shared (escapeURI, collapseFilePath, addMetaField)
+import Network.URI (unEscapeString)
+import Text.Pandoc.MediaBag (MediaBag, insertMedia)
+import Control.Monad.Except (throwError)
+import Text.Pandoc.MIME (MimeType)
+import qualified Text.Pandoc.Builder as B
+import Codec.Archive.Zip ( Archive (..), toArchiveOrFail, fromEntry
+ , findEntryByPath, Entry)
+import qualified Data.ByteString.Lazy as BL (ByteString)
+import System.FilePath ( takeFileName, (</>), dropFileName, normalise
+ , dropFileName
+ , splitFileName )
+import qualified Text.Pandoc.UTF8 as UTF8 (toStringLazy)
+import Control.Monad (guard, liftM)
+import Data.List (isPrefixOf, isInfixOf)
+import Data.Maybe (mapMaybe, fromMaybe)
+import qualified Data.Map as M (Map, lookup, fromList, elems)
+import Data.Monoid ((<>))
+import Control.DeepSeq (deepseq, NFData)
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad)
+import qualified Text.Pandoc.Class as P
+
+type Items = M.Map String (FilePath, MimeType)
+
+readEPUB :: PandocMonad m => ReaderOptions -> BL.ByteString -> m Pandoc
+readEPUB opts bytes = case toArchiveOrFail bytes of
+ Right archive -> archiveToEPUB opts $ archive
+ Left _ -> throwError $ PandocParseError "Couldn't extract ePub file"
+
+-- runEPUB :: Except PandocError a -> Either PandocError a
+-- runEPUB = runExcept
+
+-- Note that internal reference are aggresively normalised so that all ids
+-- are of the form "filename#id"
+--
+archiveToEPUB :: (PandocMonad m) => ReaderOptions -> Archive -> m Pandoc
+archiveToEPUB os archive = do
+ -- root is path to folder with manifest file in
+ (root, content) <- getManifest archive
+ meta <- parseMeta content
+ (cover, items) <- parseManifest content
+ -- No need to collapse here as the image path is from the manifest file
+ let coverDoc = fromMaybe mempty (imageToPandoc <$> cover)
+ spine <- parseSpine items content
+ let escapedSpine = map (escapeURI . takeFileName . fst) spine
+ Pandoc _ bs <-
+ foldM' (\a b -> ((a <>) . walk (prependHash escapedSpine))
+ `liftM` parseSpineElem root b) mempty spine
+ let ast = coverDoc <> (Pandoc meta bs)
+ P.setMediaBag $ fetchImages (M.elems items) root archive ast
+ return ast
+ where
+ os' = os {readerExtensions = enableExtension Ext_raw_html (readerExtensions os)}
+ parseSpineElem :: PandocMonad m => FilePath -> (FilePath, MimeType) -> m Pandoc
+ parseSpineElem (normalise -> r) (normalise -> path, mime) = do
+ doc <- mimeToReader mime r path
+ let docSpan = B.doc $ B.para $ B.spanWith (takeFileName path, [], []) mempty
+ return $ docSpan <> doc
+ mimeToReader :: PandocMonad m => MimeType -> FilePath -> FilePath -> m Pandoc
+ mimeToReader "application/xhtml+xml" (unEscapeString -> root)
+ (unEscapeString -> path) = do
+ fname <- findEntryByPathE (root </> path) archive
+ html <- readHtml os' . UTF8.toStringLazy $ fromEntry fname
+ return $ fixInternalReferences path html
+ mimeToReader s _ (unEscapeString -> path)
+ | s `elem` imageMimes = return $ imageToPandoc path
+ | otherwise = return $ mempty
+
+-- paths should be absolute when this function is called
+-- renameImages should do this
+fetchImages :: [(FilePath, MimeType)]
+ -> FilePath -- ^ Root
+ -> Archive
+ -> Pandoc
+ -> MediaBag
+fetchImages mimes root arc (query iq -> links) =
+ foldr (uncurry3 insertMedia) mempty
+ (mapMaybe getEntry links)
+ where
+ getEntry link =
+ let abslink = normalise (root </> link) in
+ (link , lookup link mimes, ) . fromEntry
+ <$> findEntryByPath abslink arc
+
+iq :: Inline -> [FilePath]
+iq (Image _ _ (url, _)) = [url]
+iq _ = []
+
+-- Remove relative paths
+renameImages :: FilePath -> Inline -> Inline
+renameImages root img@(Image attr a (url, b))
+ | "data:" `isPrefixOf` url = img
+ | otherwise = Image attr a (collapseFilePath (root </> url), b)
+renameImages _ x = x
+
+imageToPandoc :: FilePath -> Pandoc
+imageToPandoc s = B.doc . B.para $ B.image s "" mempty
+
+imageMimes :: [MimeType]
+imageMimes = ["image/gif", "image/jpeg", "image/png"]
+
+type CoverImage = FilePath
+
+parseManifest :: (PandocMonad m) => Element -> m (Maybe CoverImage, Items)
+parseManifest content = do
+ manifest <- findElementE (dfName "manifest") content
+ let items = findChildren (dfName "item") manifest
+ r <- mapM parseItem items
+ let cover = findAttr (emptyName "href") =<< filterChild findCover manifest
+ return (cover, (M.fromList r))
+ where
+ findCover e = maybe False (isInfixOf "cover-image")
+ (findAttr (emptyName "properties") e)
+ parseItem e = do
+ uid <- findAttrE (emptyName "id") e
+ href <- findAttrE (emptyName "href") e
+ mime <- findAttrE (emptyName "media-type") e
+ return (uid, (href, mime))
+
+parseSpine :: PandocMonad m => Items -> Element -> m [(FilePath, MimeType)]
+parseSpine is e = do
+ spine <- findElementE (dfName "spine") e
+ let itemRefs = findChildren (dfName "itemref") spine
+ mapM (mkE "parseSpine" . (flip M.lookup is)) $ mapMaybe parseItemRef itemRefs
+ where
+ parseItemRef ref = do
+ let linear = maybe True (== "yes") (findAttr (emptyName "linear") ref)
+ guard linear
+ findAttr (emptyName "idref") ref
+
+parseMeta :: PandocMonad m => Element -> m Meta
+parseMeta content = do
+ meta <- findElementE (dfName "metadata") content
+ let dcspace (QName _ (Just "http://purl.org/dc/elements/1.1/") (Just "dc")) = True
+ dcspace _ = False
+ let dcs = filterChildrenName dcspace meta
+ let r = foldr parseMetaItem nullMeta dcs
+ return r
+
+-- http://www.idpf.org/epub/30/spec/epub30-publications.html#sec-metadata-elem
+parseMetaItem :: Element -> Meta -> Meta
+parseMetaItem e@(stripNamespace . elName -> field) meta =
+ addMetaField (renameMeta field) (B.str $ strContent e) meta
+
+renameMeta :: String -> String
+renameMeta "creator" = "author"
+renameMeta s = s
+
+getManifest :: PandocMonad m => Archive -> m (String, Element)
+getManifest archive = do
+ metaEntry <- findEntryByPathE ("META-INF" </> "container.xml") archive
+ docElem <- (parseXMLDocE . UTF8.toStringLazy . fromEntry) metaEntry
+ let namespaces = mapMaybe attrToNSPair (elAttribs docElem)
+ ns <- mkE "xmlns not in namespaces" (lookup "xmlns" namespaces)
+ as <- liftM ((map attrToPair) . elAttribs)
+ (findElementE (QName "rootfile" (Just ns) Nothing) docElem)
+ manifestFile <- mkE "Root not found" (lookup "full-path" as)
+ let rootdir = dropFileName manifestFile
+ --mime <- lookup "media-type" as
+ manifest <- findEntryByPathE manifestFile archive
+ liftM ((,) rootdir) (parseXMLDocE . UTF8.toStringLazy . fromEntry $ manifest)
+
+-- Fixup
+
+fixInternalReferences :: FilePath -> Pandoc -> Pandoc
+fixInternalReferences pathToFile =
+ (walk $ renameImages root)
+ . (walk $ fixBlockIRs filename)
+ . (walk $ fixInlineIRs filename)
+ where
+ (root, escapeURI -> filename) = splitFileName pathToFile
+
+fixInlineIRs :: String -> Inline -> Inline
+fixInlineIRs s (Span as v) =
+ Span (fixAttrs s as) v
+fixInlineIRs s (Code as code) =
+ Code (fixAttrs s as) code
+fixInlineIRs s (Link as is ('#':url, tit)) =
+ Link (fixAttrs s as) is (addHash s url, tit)
+fixInlineIRs s (Link as is t) =
+ Link (fixAttrs s as) is t
+fixInlineIRs _ v = v
+
+prependHash :: [String] -> Inline -> Inline
+prependHash ps l@(Link attr is (url, tit))
+ | or [s `isPrefixOf` url | s <- ps] =
+ Link attr is ('#':url, tit)
+ | otherwise = l
+prependHash _ i = i
+
+fixBlockIRs :: String -> Block -> Block
+fixBlockIRs s (Div as b) =
+ Div (fixAttrs s as) b
+fixBlockIRs s (Header i as b) =
+ Header i (fixAttrs s as) b
+fixBlockIRs s (CodeBlock as code) =
+ CodeBlock (fixAttrs s as) code
+fixBlockIRs _ b = b
+
+fixAttrs :: FilePath -> B.Attr -> B.Attr
+fixAttrs s (ident, cs, kvs) = (addHash s ident, filter (not . null) cs, removeEPUBAttrs kvs)
+
+addHash :: String -> String -> String
+addHash _ "" = ""
+addHash s ident = takeFileName s ++ "#" ++ ident
+
+removeEPUBAttrs :: [(String, String)] -> [(String, String)]
+removeEPUBAttrs kvs = filter (not . isEPUBAttr) kvs
+
+isEPUBAttr :: (String, String) -> Bool
+isEPUBAttr (k, _) = "epub:" `isPrefixOf` k
+
+-- Library
+
+-- Strict version of foldM
+foldM' :: (Monad m, NFData a) => (a -> b -> m a) -> a -> [b] -> m a
+foldM' _ z [] = return z
+foldM' f z (x:xs) = do
+ z' <- f z x
+ z' `deepseq` foldM' f z' xs
+
+uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d
+uncurry3 f (a, b, c) = f a b c
+
+-- Utility
+
+stripNamespace :: QName -> String
+stripNamespace (QName v _ _) = v
+
+attrToNSPair :: Attr -> Maybe (String, String)
+attrToNSPair (Attr (QName "xmlns" _ _) val) = Just ("xmlns", val)
+attrToNSPair _ = Nothing
+
+attrToPair :: Attr -> (String, String)
+attrToPair (Attr (QName name _ _) val) = (name, val)
+
+defaultNameSpace :: Maybe String
+defaultNameSpace = Just "http://www.idpf.org/2007/opf"
+
+dfName :: String -> QName
+dfName s = QName s defaultNameSpace Nothing
+
+emptyName :: String -> QName
+emptyName s = QName s Nothing Nothing
+
+-- Convert Maybe interface to Either
+
+findAttrE :: PandocMonad m => QName -> Element -> m String
+findAttrE q e = mkE "findAttr" $ findAttr q e
+
+findEntryByPathE :: PandocMonad m => FilePath -> Archive -> m Entry
+findEntryByPathE (normalise -> path) a =
+ mkE ("No entry on path: " ++ path) $ findEntryByPath path a
+
+parseXMLDocE :: PandocMonad m => String -> m Element
+parseXMLDocE doc = mkE "Unable to parse XML doc" $ parseXMLDoc doc
+
+findElementE :: PandocMonad m => QName -> Element -> m Element
+findElementE e x = mkE ("Unable to find element: " ++ show e) $ findElement e x
+
+mkE :: PandocMonad m => String -> Maybe a -> m a
+mkE s = maybe (throwError . PandocParseError $ s) return
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
new file mode 100644
index 000000000..f02f1a1d4
--- /dev/null
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -0,0 +1,1136 @@
+{-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses,
+ViewPatterns#-}
+{-
+Copyright (C) 2006-2015 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.HTML
+ Copyright : Copyright (C) 2006-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of HTML to 'Pandoc' document.
+-}
+module Text.Pandoc.Readers.HTML ( readHtml
+ , htmlTag
+ , htmlInBalanced
+ , isInlineTag
+ , isBlockTag
+ , isTextTag
+ , isCommentTag
+ ) where
+
+import Text.HTML.TagSoup
+import Text.HTML.TagSoup.Match
+import Text.Pandoc.Definition
+import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.Builder (Blocks, Inlines, trimInlines, HasMeta(..))
+import Text.Pandoc.Shared ( extractSpaces, renderTags', addMetaField
+ , escapeURI, safeRead )
+import Text.Pandoc.Options (ReaderOptions(readerExtensions), extensionEnabled,
+ Extension (Ext_epub_html_exts,
+ Ext_raw_html, Ext_native_divs, Ext_native_spans))
+import Text.Pandoc.Logging
+import Text.Pandoc.Parsing hiding ((<|>))
+import Text.Pandoc.Walk
+import qualified Data.Map as M
+import Data.Maybe ( fromMaybe, isJust)
+import Data.List ( intercalate, isInfixOf, isPrefixOf )
+import Data.Char ( isDigit )
+import Control.Monad ( guard, mzero, void, unless )
+import Control.Arrow ((***))
+import Control.Applicative ( (<|>) )
+import Data.Monoid (First (..))
+import Text.TeXMath (readMathML, writeTeX)
+import Data.Default (Default (..), def)
+import Control.Monad.Reader (ask, asks, local, ReaderT, runReaderT, lift)
+import Network.URI (URI, parseURIReference, nonStrictRelativeTo)
+import Text.Pandoc.CSS (foldOrElse, pickStyleAttrProps)
+import Data.Monoid ((<>))
+import Text.Parsec.Error
+import qualified Data.Set as Set
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad, report)
+import Control.Monad.Except (throwError)
+
+-- | Convert HTML-formatted string to 'Pandoc' document.
+readHtml :: PandocMonad m
+ => ReaderOptions -- ^ Reader options
+ -> String -- ^ String to parse (assumes @'\n'@ line endings)
+ -> m Pandoc
+readHtml opts inp = do
+ let tags = stripPrefixes . canonicalizeTags $
+ parseTagsOptions parseOptions{ optTagPosition = True } inp
+ parseDoc = do
+ blocks <- (fixPlains False) . mconcat <$> manyTill block eof
+ meta <- stateMeta . parserState <$> getState
+ bs' <- replaceNotes (B.toList blocks)
+ return $ Pandoc meta bs'
+ getError (errorMessages -> ms) = case ms of
+ [] -> ""
+ (m:_) -> messageString m
+ result <- flip runReaderT def $
+ runParserT parseDoc
+ (HTMLState def{ stateOptions = opts } [] Nothing Set.empty M.empty)
+ "source" tags
+ case result of
+ Right doc -> return doc
+ Left err -> throwError $ PandocParseError $ getError err
+
+replaceNotes :: PandocMonad m => [Block] -> TagParser m [Block]
+replaceNotes = walkM replaceNotes'
+
+replaceNotes' :: PandocMonad m => Inline -> TagParser m Inline
+replaceNotes' (RawInline (Format "noteref") ref) = maybe (Str "") (Note . B.toList) . lookup ref <$> getNotes
+ where
+ getNotes = noteTable <$> getState
+replaceNotes' x = return x
+
+data HTMLState =
+ HTMLState
+ { parserState :: ParserState,
+ noteTable :: [(String, Blocks)],
+ baseHref :: Maybe URI,
+ identifiers :: Set.Set String,
+ headerMap :: M.Map Inlines String
+ }
+
+data HTMLLocal = HTMLLocal { quoteContext :: QuoteContext
+ , inChapter :: Bool -- ^ Set if in chapter section
+ , inPlain :: Bool -- ^ Set if in pPlain
+ }
+
+setInChapter :: PandocMonad m => HTMLParser m s a -> HTMLParser m s a
+setInChapter = local (\s -> s {inChapter = True})
+
+setInPlain :: PandocMonad m => HTMLParser m s a -> HTMLParser m s a
+setInPlain = local (\s -> s {inPlain = True})
+
+type HTMLParser m s = ParserT s HTMLState (ReaderT HTMLLocal m)
+
+type TagParser m = HTMLParser m [Tag String]
+
+pBody :: PandocMonad m => TagParser m Blocks
+pBody = pInTags "body" block
+
+pHead :: PandocMonad m => TagParser m Blocks
+pHead = pInTags "head" $ pTitle <|> pMetaTag <|> pBaseTag <|> (mempty <$ pAnyTag)
+ where pTitle = pInTags "title" inline >>= setTitle . trimInlines
+ setTitle t = mempty <$ (updateState $ B.setMeta "title" t)
+ pMetaTag = do
+ mt <- pSatisfy (~== TagOpen "meta" [])
+ let name = fromAttrib "name" mt
+ if null name
+ then return mempty
+ else do
+ let content = fromAttrib "content" mt
+ updateState $ \s ->
+ let ps = parserState s in
+ s{ parserState = ps{
+ stateMeta = addMetaField name (B.text content)
+ (stateMeta ps) } }
+ return mempty
+ pBaseTag = do
+ bt <- pSatisfy (~== TagOpen "base" [])
+ updateState $ \st -> st{ baseHref =
+ parseURIReference $ fromAttrib "href" bt }
+ return mempty
+
+block :: PandocMonad m => TagParser m Blocks
+block = do
+ pos <- getPosition
+ res <- choice
+ [ eSection
+ , eSwitch B.para block
+ , mempty <$ eFootnote
+ , mempty <$ eTOC
+ , mempty <$ eTitlePage
+ , pPara
+ , pHeader
+ , pBlockQuote
+ , pCodeBlock
+ , pList
+ , pHrule
+ , pTable
+ , pHead
+ , pBody
+ , pDiv
+ , pPlain
+ , pRawHtmlBlock
+ ]
+ report $ ParsingTrace (take 60 $ show $ B.toList res) pos
+ return res
+
+namespaces :: PandocMonad m => [(String, TagParser m Inlines)]
+namespaces = [(mathMLNamespace, pMath True)]
+
+mathMLNamespace :: String
+mathMLNamespace = "http://www.w3.org/1998/Math/MathML"
+
+eSwitch :: (PandocMonad m, Monoid a)
+ => (Inlines -> a)
+ -> TagParser m a
+ -> TagParser m a
+eSwitch constructor parser = try $ do
+ guardEnabled Ext_epub_html_exts
+ pSatisfy (~== TagOpen "switch" [])
+ cases <- getFirst . mconcat <$>
+ manyTill (First <$> (eCase <* skipMany pBlank) )
+ (lookAhead $ try $ pSatisfy (~== TagOpen "default" []))
+ skipMany pBlank
+ fallback <- pInTags "default" (skipMany pBlank *> parser <* skipMany pBlank)
+ skipMany pBlank
+ pSatisfy (~== TagClose "switch")
+ return $ maybe fallback constructor cases
+
+eCase :: PandocMonad m => TagParser m (Maybe Inlines)
+eCase = do
+ skipMany pBlank
+ TagOpen _ attr <- lookAhead $ pSatisfy $ (~== TagOpen "case" [])
+ case (flip lookup namespaces) =<< lookup "required-namespace" attr of
+ Just p -> Just <$> (pInTags "case" (skipMany pBlank *> p <* skipMany pBlank))
+ Nothing -> Nothing <$ manyTill pAnyTag (pSatisfy (~== TagClose "case"))
+
+eFootnote :: PandocMonad m => TagParser m ()
+eFootnote = try $ do
+ let notes = ["footnote", "rearnote"]
+ guardEnabled Ext_epub_html_exts
+ (TagOpen tag attr) <- lookAhead $ pAnyTag
+ guard (maybe False (flip elem notes) (lookup "type" attr))
+ let ident = fromMaybe "" (lookup "id" attr)
+ content <- pInTags tag block
+ addNote ident content
+
+addNote :: PandocMonad m => String -> Blocks -> TagParser m ()
+addNote uid cont = updateState (\s -> s {noteTable = (uid, cont) : (noteTable s)})
+
+eNoteref :: PandocMonad m => TagParser m Inlines
+eNoteref = try $ do
+ guardEnabled Ext_epub_html_exts
+ TagOpen tag attr <- lookAhead $ pAnyTag
+ guard (maybe False (== "noteref") (lookup "type" attr))
+ let ident = maybe "" (dropWhile (== '#')) (lookup "href" attr)
+ guard (not (null ident))
+ pInTags tag block
+ return $ B.rawInline "noteref" ident
+
+-- Strip TOC if there is one, better to generate again
+eTOC :: PandocMonad m => TagParser m ()
+eTOC = try $ do
+ guardEnabled Ext_epub_html_exts
+ (TagOpen tag attr) <- lookAhead $ pAnyTag
+ guard (maybe False (== "toc") (lookup "type" attr))
+ void (pInTags tag block)
+
+pList :: PandocMonad m => TagParser m Blocks
+pList = pBulletList <|> pOrderedList <|> pDefinitionList
+
+pBulletList :: PandocMonad m => TagParser m Blocks
+pBulletList = try $ do
+ pSatisfy (~== TagOpen "ul" [])
+ let nonItem = pSatisfy (\t ->
+ not (tagOpen (`elem` ["li","ol","ul","dl"]) (const True) t) &&
+ not (t ~== TagClose "ul"))
+ -- note: if they have an <ol> or <ul> not in scope of a <li>,
+ -- treat it as a list item, though it's not valid xhtml...
+ skipMany nonItem
+ items <- manyTill (pListItem nonItem) (pCloses "ul")
+ return $ B.bulletList $ map (fixPlains True) items
+
+pListItem :: PandocMonad m => TagParser m a -> TagParser m Blocks
+pListItem nonItem = do
+ TagOpen _ attr <- lookAhead $ pSatisfy (~== TagOpen "li" [])
+ let liDiv = maybe mempty (\x -> B.divWith (x, [], []) mempty) (lookup "id" attr)
+ (liDiv <>) <$> pInTags "li" block <* skipMany nonItem
+
+parseListStyleType :: String -> ListNumberStyle
+parseListStyleType "lower-roman" = LowerRoman
+parseListStyleType "upper-roman" = UpperRoman
+parseListStyleType "lower-alpha" = LowerAlpha
+parseListStyleType "upper-alpha" = UpperAlpha
+parseListStyleType "decimal" = Decimal
+parseListStyleType _ = DefaultStyle
+
+parseTypeAttr :: String -> ListNumberStyle
+parseTypeAttr "i" = LowerRoman
+parseTypeAttr "I" = UpperRoman
+parseTypeAttr "a" = LowerAlpha
+parseTypeAttr "A" = UpperAlpha
+parseTypeAttr "1" = Decimal
+parseTypeAttr _ = DefaultStyle
+
+pOrderedList :: PandocMonad m => TagParser m Blocks
+pOrderedList = try $ do
+ TagOpen _ attribs <- pSatisfy (~== TagOpen "ol" [])
+ let (start, style) = (sta', sty')
+ where sta = fromMaybe "1" $
+ lookup "start" attribs
+ sta' = if all isDigit sta
+ then read sta
+ else 1
+
+ pickListStyle = pickStyleAttrProps ["list-style-type", "list-style"]
+
+ typeAttr = fromMaybe "" $ lookup "type" attribs
+ classAttr = fromMaybe "" $ lookup "class" attribs
+ styleAttr = fromMaybe "" $ lookup "style" attribs
+ listStyle = fromMaybe "" $ pickListStyle styleAttr
+
+ sty' = foldOrElse DefaultStyle
+ [ parseTypeAttr typeAttr
+ , parseListStyleType classAttr
+ , parseListStyleType listStyle
+ ]
+ let nonItem = pSatisfy (\t ->
+ not (tagOpen (`elem` ["li","ol","ul","dl"]) (const True) t) &&
+ not (t ~== TagClose "ol"))
+ -- note: if they have an <ol> or <ul> not in scope of a <li>,
+ -- treat it as a list item, though it's not valid xhtml...
+ skipMany nonItem
+ items <- manyTill (pListItem nonItem) (pCloses "ol")
+ return $ B.orderedListWith (start, style, DefaultDelim) $ map (fixPlains True) items
+
+pDefinitionList :: PandocMonad m => TagParser m Blocks
+pDefinitionList = try $ do
+ pSatisfy (~== TagOpen "dl" [])
+ items <- manyTill pDefListItem (pCloses "dl")
+ return $ B.definitionList items
+
+pDefListItem :: PandocMonad m => TagParser m (Inlines, [Blocks])
+pDefListItem = try $ do
+ let nonItem = pSatisfy (\t -> not (t ~== TagOpen "dt" []) &&
+ not (t ~== TagOpen "dd" []) && not (t ~== TagClose "dl"))
+ terms <- many1 (try $ skipMany nonItem >> pInTags "dt" inline)
+ defs <- many1 (try $ skipMany nonItem >> pInTags "dd" block)
+ skipMany nonItem
+ let term = foldl1 (\x y -> x <> B.linebreak <> y) terms
+ return (term, map (fixPlains True) defs)
+
+fixPlains :: Bool -> Blocks -> Blocks
+fixPlains inList bs = if any isParaish bs'
+ then B.fromList $ map plainToPara bs'
+ else bs
+ where isParaish (Para _) = True
+ isParaish (CodeBlock _ _) = True
+ isParaish (Header _ _ _) = True
+ isParaish (BlockQuote _) = True
+ isParaish (BulletList _) = not inList
+ isParaish (OrderedList _ _) = not inList
+ isParaish (DefinitionList _) = not inList
+ isParaish _ = False
+ plainToPara (Plain xs) = Para xs
+ plainToPara x = x
+ bs' = B.toList bs
+
+pRawTag :: PandocMonad m => TagParser m String
+pRawTag = do
+ tag <- pAnyTag
+ let ignorable x = x `elem` ["html","head","body","!DOCTYPE","?xml"]
+ if tagOpen ignorable (const True) tag || tagClose ignorable tag
+ then return []
+ else return $ renderTags' [tag]
+
+pDiv :: PandocMonad m => TagParser m Blocks
+pDiv = try $ do
+ guardEnabled Ext_native_divs
+ let isDivLike "div" = True
+ isDivLike "section" = True
+ isDivLike _ = False
+ TagOpen tag attr <- lookAhead $ pSatisfy $ tagOpen isDivLike (const True)
+ contents <- pInTags tag block
+ let (ident, classes, kvs) = mkAttr attr
+ let classes' = if tag == "section"
+ then "section":classes
+ else classes
+ return $ B.divWith (ident, classes', kvs) contents
+
+pRawHtmlBlock :: PandocMonad m => TagParser m Blocks
+pRawHtmlBlock = do
+ raw <- pHtmlBlock "script" <|> pHtmlBlock "style" <|> pRawTag
+ exts <- getOption readerExtensions
+ if extensionEnabled Ext_raw_html exts && not (null raw)
+ then return $ B.rawBlock "html" raw
+ else ignore raw
+
+ignore :: (Monoid a, PandocMonad m) => String -> TagParser m a
+ignore raw = do
+ pos <- getPosition
+ -- raw can be null for tags like <!DOCTYPE>; see paRawTag
+ -- in this case we don't want a warning:
+ unless (null raw) $
+ report $ SkippedContent raw pos
+ return mempty
+
+pHtmlBlock :: PandocMonad m => String -> TagParser m String
+pHtmlBlock t = try $ do
+ open <- pSatisfy (~== TagOpen t [])
+ contents <- manyTill pAnyTag (pSatisfy (~== TagClose t))
+ return $ renderTags' $ [open] ++ contents ++ [TagClose t]
+
+-- Sets chapter context
+eSection :: PandocMonad m => TagParser m Blocks
+eSection = try $ do
+ let matchChapter as = maybe False (isInfixOf "chapter") (lookup "type" as)
+ let sectTag = tagOpen (`elem` sectioningContent) matchChapter
+ TagOpen tag _ <- lookAhead $ pSatisfy sectTag
+ setInChapter (pInTags tag block)
+
+headerLevel :: PandocMonad m => String -> TagParser m Int
+headerLevel tagtype = do
+ let level = read (drop 1 tagtype)
+ (try $ do
+ guardEnabled Ext_epub_html_exts
+ asks inChapter >>= guard
+ return (level - 1))
+ <|>
+ return level
+
+eTitlePage :: PandocMonad m => TagParser m ()
+eTitlePage = try $ do
+ let isTitlePage as = maybe False (isInfixOf "titlepage") (lookup "type" as)
+ let groupTag = tagOpen (\x -> x `elem` groupingContent || x == "section")
+ isTitlePage
+ TagOpen tag _ <- lookAhead $ pSatisfy groupTag
+ () <$ pInTags tag block
+
+pHeader :: PandocMonad m => TagParser m Blocks
+pHeader = try $ do
+ TagOpen tagtype attr <- pSatisfy $
+ tagOpen (`elem` ["h1","h2","h3","h4","h5","h6"])
+ (const True)
+ let bodyTitle = TagOpen tagtype attr ~== TagOpen "h1" [("class","title")]
+ level <- headerLevel tagtype
+ contents <- trimInlines . mconcat <$> manyTill inline (pCloses tagtype <|> eof)
+ let ident = fromMaybe "" $ lookup "id" attr
+ let classes = maybe [] words $ lookup "class" attr
+ let keyvals = [(k,v) | (k,v) <- attr, k /= "class", k /= "id"]
+ attr' <- registerHeader (ident, classes, keyvals) contents
+ return $ if bodyTitle
+ then mempty -- skip a representation of the title in the body
+ else B.headerWith attr' level contents
+
+pHrule :: PandocMonad m => TagParser m Blocks
+pHrule = do
+ pSelfClosing (=="hr") (const True)
+ return B.horizontalRule
+
+pTable :: PandocMonad m => TagParser m Blocks
+pTable = try $ do
+ TagOpen _ _ <- pSatisfy (~== TagOpen "table" [])
+ skipMany pBlank
+ caption <- option mempty $ pInTags "caption" inline <* skipMany pBlank
+ widths' <- (mconcat <$> many1 pColgroup) <|> many pCol
+ let pTh = option [] $ pInTags "tr" (pCell "th")
+ pTr = try $ skipMany pBlank >> pInTags "tr" (pCell "td" <|> pCell "th")
+ pTBody = do pOptInTag "tbody" $ many1 pTr
+ head'' <- pOptInTag "thead" pTh
+ head' <- pOptInTag "tbody" $ do
+ if null head''
+ then pTh
+ else return head''
+ rowsLs <- many pTBody
+ rows' <- pOptInTag "tfoot" $ many pTr
+ TagClose _ <- pSatisfy (~== TagClose "table")
+ let rows'' = (concat rowsLs) ++ rows'
+ -- fail on empty table
+ guard $ not $ null head' && null rows''
+ let isSinglePlain x = case B.toList x of
+ [] -> True
+ [Plain _] -> True
+ _ -> False
+ let isSimple = all isSinglePlain $ concat (head':rows'')
+ let cols = length $ if null head' then head rows'' else head'
+ -- add empty cells to short rows
+ let addEmpties r = case cols - length r of
+ n | n > 0 -> r ++ replicate n mempty
+ | otherwise -> r
+ let rows = map addEmpties rows''
+ let aligns = replicate cols AlignDefault
+ let widths = if null widths'
+ then if isSimple
+ then replicate cols 0
+ else replicate cols (1.0 / fromIntegral cols)
+ else widths'
+ return $ B.table caption (zip aligns widths) head' rows
+
+pCol :: PandocMonad m => TagParser m Double
+pCol = try $ do
+ TagOpen _ attribs <- pSatisfy (~== TagOpen "col" [])
+ skipMany pBlank
+ optional $ pSatisfy (~== TagClose "col")
+ skipMany pBlank
+ return $ case lookup "width" attribs of
+ Nothing -> case lookup "style" attribs of
+ Just ('w':'i':'d':'t':'h':':':xs) | '%' `elem` xs ->
+ fromMaybe 0.0 $ safeRead ('0':'.':filter
+ (`notElem` " \t\r\n%'\";") xs)
+ _ -> 0.0
+ Just x | not (null x) && last x == '%' ->
+ fromMaybe 0.0 $ safeRead ('0':'.':init x)
+ _ -> 0.0
+
+pColgroup :: PandocMonad m => TagParser m [Double]
+pColgroup = try $ do
+ pSatisfy (~== TagOpen "colgroup" [])
+ skipMany pBlank
+ manyTill pCol (pCloses "colgroup" <|> eof) <* skipMany pBlank
+
+noColOrRowSpans :: Tag String -> Bool
+noColOrRowSpans t = isNullOrOne "colspan" && isNullOrOne "rowspan"
+ where isNullOrOne x = case fromAttrib x t of
+ "" -> True
+ "1" -> True
+ _ -> False
+
+pCell :: PandocMonad m => String -> TagParser m [Blocks]
+pCell celltype = try $ do
+ skipMany pBlank
+ res <- pInTags' celltype noColOrRowSpans block
+ skipMany pBlank
+ return [res]
+
+pBlockQuote :: PandocMonad m => TagParser m Blocks
+pBlockQuote = do
+ contents <- pInTags "blockquote" block
+ return $ B.blockQuote $ fixPlains False contents
+
+pPlain :: PandocMonad m => TagParser m Blocks
+pPlain = do
+ contents <- setInPlain $ trimInlines . mconcat <$> many1 inline
+ if B.isNull contents
+ then return mempty
+ else return $ B.plain contents
+
+pPara :: PandocMonad m => TagParser m Blocks
+pPara = do
+ contents <- trimInlines <$> pInTags "p" inline
+ return $ B.para contents
+
+pCodeBlock :: PandocMonad m => TagParser m Blocks
+pCodeBlock = try $ do
+ TagOpen _ attr <- pSatisfy (~== TagOpen "pre" [])
+ contents <- manyTill pAnyTag (pCloses "pre" <|> eof)
+ let rawText = concatMap tagToString contents
+ -- drop leading newline if any
+ let result' = case rawText of
+ '\n':xs -> xs
+ _ -> rawText
+ -- drop trailing newline if any
+ let result = case reverse result' of
+ '\n':_ -> init result'
+ _ -> result'
+ return $ B.codeBlockWith (mkAttr attr) result
+
+tagToString :: Tag String -> String
+tagToString (TagText s) = s
+tagToString (TagOpen "br" _) = "\n"
+tagToString _ = ""
+
+inline :: PandocMonad m => TagParser m Inlines
+inline = choice
+ [ eNoteref
+ , eSwitch id inline
+ , pTagText
+ , pQ
+ , pEmph
+ , pStrong
+ , pSuperscript
+ , pSubscript
+ , pStrikeout
+ , pLineBreak
+ , pLink
+ , pImage
+ , pCode
+ , pSpan
+ , pMath False
+ , pRawHtmlInline
+ ]
+
+pLocation :: PandocMonad m => TagParser m ()
+pLocation = do
+ (TagPosition r c) <- pSat isTagPosition
+ setPosition $ newPos "input" r c
+
+pSat :: PandocMonad m => (Tag String -> Bool) -> TagParser m (Tag String)
+pSat f = do
+ pos <- getPosition
+ token show (const pos) (\x -> if f x then Just x else Nothing)
+
+pSatisfy :: PandocMonad m => (Tag String -> Bool) -> TagParser m (Tag String)
+pSatisfy f = try $ optional pLocation >> pSat f
+
+pAnyTag :: PandocMonad m => TagParser m (Tag String)
+pAnyTag = pSatisfy (const True)
+
+pSelfClosing :: PandocMonad m
+ => (String -> Bool) -> ([Attribute String] -> Bool)
+ -> TagParser m (Tag String)
+pSelfClosing f g = do
+ open <- pSatisfy (tagOpen f g)
+ optional $ pSatisfy (tagClose f)
+ return open
+
+pQ :: PandocMonad m => TagParser m Inlines
+pQ = do
+ context <- asks quoteContext
+ let quoteType = case context of
+ InDoubleQuote -> SingleQuote
+ _ -> DoubleQuote
+ let innerQuoteContext = if quoteType == SingleQuote
+ then InSingleQuote
+ else InDoubleQuote
+ let constructor = case quoteType of
+ SingleQuote -> B.singleQuoted
+ DoubleQuote -> B.doubleQuoted
+ withQuoteContext innerQuoteContext $
+ pInlinesInTags "q" constructor
+
+pEmph :: PandocMonad m => TagParser m Inlines
+pEmph = pInlinesInTags "em" B.emph <|> pInlinesInTags "i" B.emph
+
+pStrong :: PandocMonad m => TagParser m Inlines
+pStrong = pInlinesInTags "strong" B.strong <|> pInlinesInTags "b" B.strong
+
+pSuperscript :: PandocMonad m => TagParser m Inlines
+pSuperscript = pInlinesInTags "sup" B.superscript
+
+pSubscript :: PandocMonad m => TagParser m Inlines
+pSubscript = pInlinesInTags "sub" B.subscript
+
+pStrikeout :: PandocMonad m => TagParser m Inlines
+pStrikeout = do
+ pInlinesInTags "s" B.strikeout <|>
+ pInlinesInTags "strike" B.strikeout <|>
+ pInlinesInTags "del" B.strikeout <|>
+ try (do pSatisfy (~== TagOpen "span" [("class","strikeout")])
+ contents <- mconcat <$> manyTill inline (pCloses "span")
+ return $ B.strikeout contents)
+
+pLineBreak :: PandocMonad m => TagParser m Inlines
+pLineBreak = do
+ pSelfClosing (=="br") (const True)
+ return B.linebreak
+
+-- Unlike fromAttrib from tagsoup, this distinguishes
+-- between a missing attribute and an attribute with empty content.
+maybeFromAttrib :: String -> Tag String -> Maybe String
+maybeFromAttrib name (TagOpen _ attrs) = lookup name attrs
+maybeFromAttrib _ _ = Nothing
+
+pLink :: PandocMonad m => TagParser m Inlines
+pLink = try $ do
+ tag <- pSatisfy $ tagOpenLit "a" (const True)
+ let title = fromAttrib "title" tag
+ -- take id from id attribute if present, otherwise name
+ let uid = maybe (fromAttrib "name" tag) id $ maybeFromAttrib "id" tag
+ let cls = words $ fromAttrib "class" tag
+ lab <- trimInlines . mconcat <$> manyTill inline (pCloses "a")
+ -- check for href; if href, then a link, otherwise a span
+ case maybeFromAttrib "href" tag of
+ Nothing ->
+ return $ B.spanWith (uid, cls, []) lab
+ Just url' -> do
+ mbBaseHref <- baseHref <$> getState
+ let url = case (parseURIReference url', mbBaseHref) of
+ (Just rel, Just bs) ->
+ show (rel `nonStrictRelativeTo` bs)
+ _ -> url'
+ return $ B.linkWith (uid, cls, []) (escapeURI url) title lab
+
+pImage :: PandocMonad m => TagParser m Inlines
+pImage = do
+ tag <- pSelfClosing (=="img") (isJust . lookup "src")
+ mbBaseHref <- baseHref <$> getState
+ let url' = fromAttrib "src" tag
+ let url = case (parseURIReference url', mbBaseHref) of
+ (Just rel, Just bs) -> show (rel `nonStrictRelativeTo` bs)
+ _ -> url'
+ let title = fromAttrib "title" tag
+ let alt = fromAttrib "alt" tag
+ let uid = fromAttrib "id" tag
+ let cls = words $ fromAttrib "class" tag
+ let getAtt k = case fromAttrib k tag of
+ "" -> []
+ v -> [(k, v)]
+ let kvs = concat $ map getAtt ["width", "height", "sizes", "srcset"]
+ return $ B.imageWith (uid, cls, kvs) (escapeURI url) title (B.text alt)
+
+pCode :: PandocMonad m => TagParser m Inlines
+pCode = try $ do
+ (TagOpen open attr) <- pSatisfy $ tagOpen (`elem` ["code","tt"]) (const True)
+ result <- manyTill pAnyTag (pCloses open)
+ return $ B.codeWith (mkAttr attr) $ intercalate " " $ lines $ innerText result
+
+pSpan :: PandocMonad m => TagParser m Inlines
+pSpan = try $ do
+ guardEnabled Ext_native_spans
+ TagOpen _ attr <- lookAhead $ pSatisfy $ tagOpen (=="span") (const True)
+ contents <- pInTags "span" inline
+ let isSmallCaps = fontVariant == "small-caps"
+ where styleAttr = fromMaybe "" $ lookup "style" attr
+ fontVariant = fromMaybe "" $ pickStyleAttrProps ["font-variant"] styleAttr
+ let tag = if isSmallCaps then B.smallcaps else B.spanWith (mkAttr attr)
+ return $ tag contents
+
+pRawHtmlInline :: PandocMonad m => TagParser m Inlines
+pRawHtmlInline = do
+ inplain <- asks inPlain
+ result <- pSatisfy (tagComment (const True))
+ <|> if inplain
+ then pSatisfy (not . isBlockTag)
+ else pSatisfy isInlineTag
+ exts <- getOption readerExtensions
+ let raw = renderTags' [result]
+ if extensionEnabled Ext_raw_html exts
+ then return $ B.rawInline "html" raw
+ else ignore raw
+
+mathMLToTeXMath :: String -> Either String String
+mathMLToTeXMath s = writeTeX <$> readMathML s
+
+pMath :: PandocMonad m => Bool -> TagParser m Inlines
+pMath inCase = try $ do
+ open@(TagOpen _ attr) <- pSatisfy $ tagOpen (=="math") (const True)
+ -- we'll assume math tags are MathML unless specially marked
+ -- otherwise...
+ unless inCase $
+ guard (maybe True (== mathMLNamespace) (lookup "xmlns" attr))
+ contents <- manyTill pAnyTag (pSatisfy (~== TagClose "math"))
+ case mathMLToTeXMath (renderTags $ [open] ++ contents ++ [TagClose "math"]) of
+ Left _ -> return $ B.spanWith ("",["math"],attr) $ B.text $
+ innerText contents
+ Right [] -> return mempty
+ Right x -> return $ case lookup "display" attr of
+ Just "block" -> B.displayMath x
+ _ -> B.math x
+
+pInlinesInTags :: PandocMonad m => String -> (Inlines -> Inlines)
+ -> TagParser m Inlines
+pInlinesInTags tagtype f = extractSpaces f <$> pInTags tagtype inline
+
+pInTags :: (PandocMonad m, Monoid a) => String -> TagParser m a -> TagParser m a
+pInTags tagtype parser = pInTags' tagtype (const True) parser
+
+pInTags' :: (PandocMonad m, Monoid a)
+ => String
+ -> (Tag String -> Bool)
+ -> TagParser m a
+ -> TagParser m a
+pInTags' tagtype tagtest parser = try $ do
+ pSatisfy (\t -> t ~== TagOpen tagtype [] && tagtest t)
+ mconcat <$> manyTill parser (pCloses tagtype <|> eof)
+
+-- parses p, preceeded by an optional opening tag
+-- and followed by an optional closing tags
+pOptInTag :: PandocMonad m => String -> TagParser m a -> TagParser m a
+pOptInTag tagtype p = try $ do
+ skipMany pBlank
+ optional $ pSatisfy (~== TagOpen tagtype [])
+ skipMany pBlank
+ x <- p
+ skipMany pBlank
+ optional $ pSatisfy (~== TagClose tagtype)
+ skipMany pBlank
+ return x
+
+pCloses :: PandocMonad m => String -> TagParser m ()
+pCloses tagtype = try $ do
+ t <- lookAhead $ pSatisfy $ \tag -> isTagClose tag || isTagOpen tag
+ case t of
+ (TagClose t') | t' == tagtype -> pAnyTag >> return ()
+ (TagOpen t' _) | t' `closes` tagtype -> return ()
+ (TagClose "ul") | tagtype == "li" -> return ()
+ (TagClose "ol") | tagtype == "li" -> return ()
+ (TagClose "dl") | tagtype == "dd" -> return ()
+ (TagClose "table") | tagtype == "td" -> return ()
+ (TagClose "table") | tagtype == "tr" -> return ()
+ _ -> mzero
+
+pTagText :: PandocMonad m => TagParser m Inlines
+pTagText = try $ do
+ (TagText str) <- pSatisfy isTagText
+ st <- getState
+ qu <- ask
+ parsed <- lift $ lift $
+ flip runReaderT qu $ runParserT (many pTagContents) st "text" str
+ case parsed of
+ Left _ -> throwError $ PandocParseError $ "Could not parse `" ++ str ++ "'"
+ Right result -> return $ mconcat result
+
+pBlank :: PandocMonad m => TagParser m ()
+pBlank = try $ do
+ (TagText str) <- pSatisfy isTagText
+ guard $ all isSpace str
+
+type InlinesParser m = HTMLParser m String
+
+pTagContents :: PandocMonad m => InlinesParser m Inlines
+pTagContents =
+ B.displayMath <$> mathDisplay
+ <|> B.math <$> mathInline
+ <|> pStr
+ <|> pSpace
+ <|> smartPunctuation pTagContents
+ <|> pSymbol
+ <|> pBad
+
+pStr :: PandocMonad m => InlinesParser m Inlines
+pStr = do
+ result <- many1 $ satisfy $ \c ->
+ not (isSpace c) && not (isSpecial c) && not (isBad c)
+ updateLastStrPos
+ return $ B.str result
+
+isSpecial :: Char -> Bool
+isSpecial '"' = True
+isSpecial '\'' = True
+isSpecial '.' = True
+isSpecial '-' = True
+isSpecial '$' = True
+isSpecial '\8216' = True
+isSpecial '\8217' = True
+isSpecial '\8220' = True
+isSpecial '\8221' = True
+isSpecial _ = False
+
+pSymbol :: PandocMonad m => InlinesParser m Inlines
+pSymbol = satisfy isSpecial >>= return . B.str . (:[])
+
+isBad :: Char -> Bool
+isBad c = c >= '\128' && c <= '\159' -- not allowed in HTML
+
+pBad :: PandocMonad m => InlinesParser m Inlines
+pBad = do
+ c <- satisfy isBad
+ let c' = case c of
+ '\128' -> '\8364'
+ '\130' -> '\8218'
+ '\131' -> '\402'
+ '\132' -> '\8222'
+ '\133' -> '\8230'
+ '\134' -> '\8224'
+ '\135' -> '\8225'
+ '\136' -> '\710'
+ '\137' -> '\8240'
+ '\138' -> '\352'
+ '\139' -> '\8249'
+ '\140' -> '\338'
+ '\142' -> '\381'
+ '\145' -> '\8216'
+ '\146' -> '\8217'
+ '\147' -> '\8220'
+ '\148' -> '\8221'
+ '\149' -> '\8226'
+ '\150' -> '\8211'
+ '\151' -> '\8212'
+ '\152' -> '\732'
+ '\153' -> '\8482'
+ '\154' -> '\353'
+ '\155' -> '\8250'
+ '\156' -> '\339'
+ '\158' -> '\382'
+ '\159' -> '\376'
+ _ -> '?'
+ return $ B.str [c']
+
+pSpace :: PandocMonad m => InlinesParser m Inlines
+pSpace = many1 (satisfy isSpace) >>= \xs ->
+ if '\n' `elem` xs
+ then return B.softbreak
+ else return B.space
+
+--
+-- Constants
+--
+
+eitherBlockOrInline :: [String]
+eitherBlockOrInline = ["audio", "applet", "button", "iframe", "embed",
+ "del", "ins",
+ "progress", "map", "area", "noscript", "script",
+ "object", "svg", "video", "source"]
+
+{-
+inlineHtmlTags :: [[Char]]
+inlineHtmlTags = ["a", "abbr", "acronym", "b", "basefont", "bdo", "big",
+ "br", "cite", "code", "dfn", "em", "font", "i", "img",
+ "input", "kbd", "label", "q", "s", "samp", "select",
+ "small", "span", "strike", "strong", "sub", "sup",
+ "textarea", "tt", "u", "var"]
+-}
+
+blockHtmlTags :: [String]
+blockHtmlTags = ["?xml", "!DOCTYPE", "address", "article", "aside",
+ "blockquote", "body", "button", "canvas",
+ "caption", "center", "col", "colgroup", "dd", "dir", "div",
+ "dl", "dt", "fieldset", "figcaption", "figure",
+ "footer", "form", "h1", "h2", "h3", "h4",
+ "h5", "h6", "head", "header", "hgroup", "hr", "html",
+ "isindex", "menu", "noframes", "ol", "output", "p", "pre",
+ "section", "table", "tbody", "textarea",
+ "thead", "tfoot", "ul", "dd",
+ "dt", "frameset", "li", "tbody", "td", "tfoot",
+ "th", "thead", "tr", "script", "style"]
+
+-- We want to allow raw docbook in markdown documents, so we
+-- include docbook block tags here too.
+blockDocBookTags :: [String]
+blockDocBookTags = ["calloutlist", "bibliolist", "glosslist", "itemizedlist",
+ "orderedlist", "segmentedlist", "simplelist",
+ "variablelist", "caution", "important", "note", "tip",
+ "warning", "address", "literallayout", "programlisting",
+ "programlistingco", "screen", "screenco", "screenshot",
+ "synopsis", "example", "informalexample", "figure",
+ "informalfigure", "table", "informaltable", "para",
+ "simpara", "formalpara", "equation", "informalequation",
+ "figure", "screenshot", "mediaobject", "qandaset",
+ "procedure", "task", "cmdsynopsis", "funcsynopsis",
+ "classsynopsis", "blockquote", "epigraph", "msgset",
+ "sidebar", "title"]
+
+epubTags :: [String]
+epubTags = ["case", "switch", "default"]
+
+blockTags :: [String]
+blockTags = blockHtmlTags ++ blockDocBookTags ++ epubTags
+
+isInlineTag :: Tag String -> Bool
+isInlineTag t = tagOpen isInlineTagName (const True) t ||
+ tagClose isInlineTagName t ||
+ tagComment (const True) t
+ where isInlineTagName x = x `notElem` blockTags
+
+isBlockTag :: Tag String -> Bool
+isBlockTag t = tagOpen isBlockTagName (const True) t ||
+ tagClose isBlockTagName t ||
+ tagComment (const True) t
+ where isBlockTagName ('?':_) = True
+ isBlockTagName ('!':_) = True
+ isBlockTagName x = x `elem` blockTags
+ || x `elem` eitherBlockOrInline
+
+isTextTag :: Tag String -> Bool
+isTextTag = tagText (const True)
+
+isCommentTag :: Tag String -> Bool
+isCommentTag = tagComment (const True)
+
+-- taken from HXT and extended
+-- See http://www.w3.org/TR/html5/syntax.html sec 8.1.2.4 optional tags
+closes :: String -> String -> Bool
+_ `closes` "body" = False
+_ `closes` "html" = False
+"body" `closes` "head" = True
+"a" `closes` "a" = True
+"li" `closes` "li" = True
+"th" `closes` t | t `elem` ["th","td"] = True
+"tr" `closes` t | t `elem` ["th","td","tr"] = True
+"dd" `closes` t | t `elem` ["dt", "dd"] = True
+"dt" `closes` t | t `elem` ["dt","dd"] = True
+"rt" `closes` t | t `elem` ["rb", "rt", "rtc"] = True
+"optgroup" `closes` "optgroup" = True
+"optgroup" `closes` "option" = True
+"option" `closes` "option" = True
+-- http://www.w3.org/TR/html-markup/p.html
+x `closes` "p" | x `elem` ["address", "article", "aside", "blockquote",
+ "dir", "div", "dl", "fieldset", "footer", "form", "h1", "h2", "h3", "h4",
+ "h5", "h6", "header", "hr", "menu", "nav", "ol", "p", "pre", "section",
+ "table", "ul"] = True
+"meta" `closes` "meta" = True
+"form" `closes` "form" = True
+"label" `closes` "label" = True
+"map" `closes` "map" = True
+"object" `closes` "object" = True
+_ `closes` t | t `elem` ["option","style","script","textarea","title"] = True
+t `closes` "select" | t /= "option" = True
+"thead" `closes` t | t `elem` ["colgroup"] = True
+"tfoot" `closes` t | t `elem` ["thead","colgroup"] = True
+"tbody" `closes` t | t `elem` ["tbody","tfoot","thead","colgroup"] = True
+t `closes` t2 |
+ t `elem` ["h1","h2","h3","h4","h5","h6","dl","ol","ul","table","div","p"] &&
+ t2 `elem` ["h1","h2","h3","h4","h5","h6","p" ] = True -- not "div"
+t1 `closes` t2 |
+ t1 `elem` blockTags &&
+ t2 `notElem` (blockTags ++ eitherBlockOrInline) = True
+_ `closes` _ = False
+
+--- parsers for use in markdown, textile readers
+
+-- | Matches a stretch of HTML in balanced tags.
+htmlInBalanced :: (Monad m)
+ => (Tag String -> Bool)
+ -> ParserT String st m String
+htmlInBalanced f = try $ do
+ lookAhead (char '<')
+ inp <- getInput
+ let ts = canonicalizeTags $
+ parseTagsOptions parseOptions{ optTagWarning = True,
+ optTagPosition = True } inp
+ case ts of
+ (TagPosition sr sc : t@(TagOpen tn _) : rest) -> do
+ guard $ f t
+ guard $ not $ hasTagWarning (t : take 1 rest)
+ case htmlInBalanced' tn (t:rest) of
+ [] -> mzero
+ xs -> case reverse xs of
+ (TagClose _ : TagPosition er ec : _) -> do
+ let ls = er - sr
+ let cs = ec - sc
+ lscontents <- unlines <$> count ls anyLine
+ cscontents <- count cs anyChar
+ (_,closetag) <- htmlTag (~== TagClose tn)
+ return (lscontents ++ cscontents ++ closetag)
+ _ -> mzero
+ _ -> mzero
+
+htmlInBalanced' :: String
+ -> [Tag String]
+ -> [Tag String]
+htmlInBalanced' tagname ts = fromMaybe [] $ go 0 ts
+ where go :: Int -> [Tag String] -> Maybe [Tag String]
+ go n (t@(TagOpen tn' _):rest) | tn' == tagname =
+ (t :) <$> go (n + 1) rest
+ go 1 (t@(TagClose tn'):_) | tn' == tagname =
+ return [t]
+ go n (t@(TagClose tn'):rest) | tn' == tagname =
+ (t :) <$> go (n - 1) rest
+ go n (t:ts') = (t :) <$> go n ts'
+ go _ [] = mzero
+
+hasTagWarning :: [Tag String] -> Bool
+hasTagWarning (TagWarning _:_) = True
+hasTagWarning _ = False
+
+-- | Matches a tag meeting a certain condition.
+htmlTag :: Monad m
+ => (Tag String -> Bool)
+ -> ParserT [Char] st m (Tag String, String)
+htmlTag f = try $ do
+ lookAhead (char '<')
+ inp <- getInput
+ let (next : _) = canonicalizeTags $ parseTagsOptions
+ parseOptions{ optTagWarning = False } inp
+ guard $ f next
+ let handleTag tagname = do
+ -- <www.boe.es/buscar/act.php?id=BOE-A-1996-8930#a66>
+ -- should NOT be parsed as an HTML tag, see #2277
+ guard $ not ('.' `elem` tagname)
+ -- <https://example.org> should NOT be a tag either.
+ -- tagsoup will parse it as TagOpen "https:" [("example.org","")]
+ guard $ not (null tagname)
+ guard $ last tagname /= ':'
+ rendered <- manyTill anyChar (char '>')
+ return (next, rendered ++ ">")
+ case next of
+ TagComment s
+ | "<!--" `isPrefixOf` inp -> do
+ count (length s + 4) anyChar
+ skipMany (satisfy (/='>'))
+ char '>'
+ return (next, "<!--" ++ s ++ "-->")
+ | otherwise -> fail "bogus comment mode, HTML5 parse error"
+ TagOpen tagname _attr -> handleTag tagname
+ TagClose tagname -> handleTag tagname
+ _ -> mzero
+
+mkAttr :: [(String, String)] -> Attr
+mkAttr attr = (attribsId, attribsClasses, attribsKV)
+ where attribsId = fromMaybe "" $ lookup "id" attr
+ attribsClasses = (words $ fromMaybe "" $ lookup "class" attr) ++ epubTypes
+ attribsKV = filter (\(k,_) -> k /= "class" && k /= "id") attr
+ epubTypes = words $ fromMaybe "" $ lookup "epub:type" attr
+
+-- Strip namespace prefixes
+stripPrefixes :: [Tag String] -> [Tag String]
+stripPrefixes = map stripPrefix
+
+stripPrefix :: Tag String -> Tag String
+stripPrefix (TagOpen s as) =
+ TagOpen (stripPrefix' s) (map (stripPrefix' *** id) as)
+stripPrefix (TagClose s) = TagClose (stripPrefix' s)
+stripPrefix x = x
+
+stripPrefix' :: String -> String
+stripPrefix' s =
+ case span (/= ':') s of
+ (_, "") -> s
+ (_, (_:ts)) -> ts
+
+isSpace :: Char -> Bool
+isSpace ' ' = True
+isSpace '\t' = True
+isSpace '\n' = True
+isSpace '\r' = True
+isSpace _ = False
+
+-- Instances
+
+instance HasIdentifierList HTMLState where
+ extractIdentifierList = identifiers
+ updateIdentifierList f s = s{ identifiers = f (identifiers s) }
+
+instance HasHeaderMap HTMLState where
+ extractHeaderMap = headerMap
+ updateHeaderMap f s = s{ headerMap = f (headerMap s) }
+
+-- This signature should be more general
+-- MonadReader HTMLLocal m => HasQuoteContext st m
+instance PandocMonad m => HasQuoteContext HTMLState (ReaderT HTMLLocal m) where
+ getQuoteContext = asks quoteContext
+ withQuoteContext q = local (\s -> s{quoteContext = q})
+
+instance HasReaderOptions HTMLState where
+ extractReaderOptions = extractReaderOptions . parserState
+
+instance HasMeta HTMLState where
+ setMeta s b st = st {parserState = setMeta s b $ parserState st}
+ deleteMeta s st = st {parserState = deleteMeta s $ parserState st}
+
+instance Default HTMLLocal where
+ def = HTMLLocal NoQuote False False
+
+instance HasLastStrPosition HTMLState where
+ setLastStrPos s st = st {parserState = setLastStrPos s (parserState st)}
+ getLastStrPos = getLastStrPos . parserState
+
+
+-- EPUB Specific
+--
+--
+sectioningContent :: [String]
+sectioningContent = ["article", "aside", "nav", "section"]
+
+
+groupingContent :: [String]
+groupingContent = ["p", "hr", "pre", "blockquote", "ol"
+ , "ul", "li", "dl", "dt", "dt", "dd"
+ , "figure", "figcaption", "div", "main"]
+
+
+{-
+
+types :: [(String, ([String], Int))]
+types = -- Document divisions
+ map (\s -> (s, (["section", "body"], 0)))
+ ["volume", "part", "chapter", "division"]
+ ++ -- Document section and components
+ [
+ ("abstract", ([], 0))]
+-}
diff --git a/src/Text/Pandoc/Readers/Haddock.hs b/src/Text/Pandoc/Readers/Haddock.hs
new file mode 100644
index 000000000..310a04574
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Haddock.hs
@@ -0,0 +1,160 @@
+{-# LANGUAGE CPP #-}
+{- |
+ Module : Text.Pandoc.Readers.Haddock
+ Copyright : Copyright (C) 2013 David Lazar
+ License : GNU GPL, version 2 or above
+
+ Maintainer : David Lazar <lazar6@illinois.edu>,
+ John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+
+Conversion of Haddock markup to 'Pandoc' document.
+-}
+module Text.Pandoc.Readers.Haddock
+ ( readHaddock
+ ) where
+
+import Text.Pandoc.Builder (Blocks, Inlines)
+import qualified Text.Pandoc.Builder as B
+import Data.Monoid ((<>))
+import Text.Pandoc.Shared (trim, splitBy)
+import Data.List (intersperse, stripPrefix)
+import Data.Maybe (fromMaybe)
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Documentation.Haddock.Parser
+import Documentation.Haddock.Types
+import Text.Pandoc.Error
+import Control.Monad.Except (throwError)
+import Text.Pandoc.Class (PandocMonad)
+
+
+-- | Parse Haddock markup and return a 'Pandoc' document.
+readHaddock :: PandocMonad m
+ => ReaderOptions
+ -> String
+ -> m Pandoc
+readHaddock opts s = case readHaddockEither opts s of
+ Right result -> return result
+ Left e -> throwError e
+
+readHaddockEither :: ReaderOptions -- ^ Reader options
+ -> String -- ^ String to parse
+ -> Either PandocError Pandoc
+readHaddockEither _opts =
+#if MIN_VERSION_haddock_library(1,2,0)
+ Right . B.doc . docHToBlocks . _doc . parseParas
+#else
+ Right . B.doc . docHToBlocks . parseParas
+#endif
+
+docHToBlocks :: DocH String Identifier -> Blocks
+docHToBlocks d' =
+ case d' of
+ DocEmpty -> mempty
+ DocAppend (DocParagraph (DocHeader h)) (DocParagraph (DocAName ident)) ->
+ B.headerWith (ident,[],[]) (headerLevel h)
+ (docHToInlines False $ headerTitle h)
+ DocAppend d1 d2 -> mappend (docHToBlocks d1) (docHToBlocks d2)
+ DocString _ -> inlineFallback
+ DocParagraph (DocAName h) -> B.plain $ docHToInlines False $ DocAName h
+ DocParagraph x -> B.para $ docHToInlines False x
+ DocIdentifier _ -> inlineFallback
+ DocIdentifierUnchecked _ -> inlineFallback
+ DocModule s -> B.plain $ docHToInlines False $ DocModule s
+ DocWarning _ -> mempty -- TODO
+ DocEmphasis _ -> inlineFallback
+ DocMonospaced _ -> inlineFallback
+ DocBold _ -> inlineFallback
+#if MIN_VERSION_haddock_library(1,4,0)
+ DocMathInline _ -> inlineFallback
+ DocMathDisplay _ -> inlineFallback
+#endif
+ DocHeader h -> B.header (headerLevel h)
+ (docHToInlines False $ headerTitle h)
+ DocUnorderedList items -> B.bulletList (map docHToBlocks items)
+ DocOrderedList items -> B.orderedList (map docHToBlocks items)
+ DocDefList items -> B.definitionList (map (\(d,t) ->
+ (docHToInlines False d,
+ [consolidatePlains $ docHToBlocks t])) items)
+ DocCodeBlock (DocString s) -> B.codeBlockWith ("",[],[]) s
+ DocCodeBlock d -> B.para $ docHToInlines True d
+ DocHyperlink _ -> inlineFallback
+ DocPic _ -> inlineFallback
+ DocAName _ -> inlineFallback
+ DocProperty s -> B.codeBlockWith ("",["property","haskell"],[]) (trim s)
+ DocExamples es -> mconcat $ map (\e ->
+ makeExample ">>>" (exampleExpression e) (exampleResult e)) es
+
+ where inlineFallback = B.plain $ docHToInlines False d'
+ consolidatePlains = B.fromList . consolidatePlains' . B.toList
+ consolidatePlains' zs@(Plain _ : _) =
+ let (xs, ys) = span isPlain zs in
+ Para (concatMap extractContents xs) : consolidatePlains' ys
+ consolidatePlains' (x : xs) = x : consolidatePlains' xs
+ consolidatePlains' [] = []
+ isPlain (Plain _) = True
+ isPlain _ = False
+ extractContents (Plain xs) = xs
+ extractContents _ = []
+
+docHToInlines :: Bool -> DocH String Identifier -> Inlines
+docHToInlines isCode d' =
+ case d' of
+ DocEmpty -> mempty
+ DocAppend d1 d2 -> mappend (docHToInlines isCode d1)
+ (docHToInlines isCode d2)
+ DocString s
+ | isCode -> mconcat $ intersperse B.linebreak
+ $ map B.code $ splitBy (=='\n') s
+ | otherwise -> B.text s
+ DocParagraph _ -> mempty
+ DocIdentifier (_,s,_) -> B.codeWith ("",["haskell","identifier"],[]) s
+ DocIdentifierUnchecked s -> B.codeWith ("",["haskell","identifier"],[]) s
+ DocModule s -> B.codeWith ("",["haskell","module"],[]) s
+ DocWarning _ -> mempty -- TODO
+ DocEmphasis d -> B.emph (docHToInlines isCode d)
+ DocMonospaced (DocString s) -> B.code s
+ DocMonospaced d -> docHToInlines True d
+ DocBold d -> B.strong (docHToInlines isCode d)
+#if MIN_VERSION_haddock_library(1,4,0)
+ DocMathInline s -> B.math s
+ DocMathDisplay s -> B.displayMath s
+#endif
+ DocHeader _ -> mempty
+ DocUnorderedList _ -> mempty
+ DocOrderedList _ -> mempty
+ DocDefList _ -> mempty
+ DocCodeBlock _ -> mempty
+ DocHyperlink h -> B.link (hyperlinkUrl h) (hyperlinkUrl h)
+ (maybe (B.text $ hyperlinkUrl h) B.text $ hyperlinkLabel h)
+ DocPic p -> B.image (pictureUri p) (fromMaybe (pictureUri p) $ pictureTitle p)
+ (maybe mempty B.text $ pictureTitle p)
+ DocAName s -> B.spanWith (s,["anchor"],[]) mempty
+ DocProperty _ -> mempty
+ DocExamples _ -> mempty
+
+-- | Create an 'Example', stripping superfluous characters as appropriate
+makeExample :: String -> String -> [String] -> Blocks
+makeExample prompt expression result =
+ B.para $ B.codeWith ("",["prompt"],[]) prompt
+ <> B.space
+ <> B.codeWith ([], ["haskell","expr"], []) (trim expression)
+ <> B.linebreak
+ <> (mconcat $ intersperse B.linebreak $ map coder result')
+ where
+ -- 1. drop trailing whitespace from the prompt, remember the prefix
+ prefix = takeWhile (`elem` " \t") prompt
+
+ -- 2. drop, if possible, the exact same sequence of whitespace
+ -- characters from each result line
+ --
+ -- 3. interpret lines that only contain the string "<BLANKLINE>" as an
+ -- empty line
+ result' = map (substituteBlankLine . tryStripPrefix prefix) result
+ where
+ tryStripPrefix xs ys = fromMaybe ys $ stripPrefix xs ys
+
+ substituteBlankLine "<BLANKLINE>" = ""
+ substituteBlankLine line = line
+ coder = B.codeWith ([], ["result"], [])
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
new file mode 100644
index 000000000..9f9a79535
--- /dev/null
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -0,0 +1,1437 @@
+{-# LANGUAGE ScopedTypeVariables, OverloadedStrings #-}
+{-
+Copyright (C) 2006-2015 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
+ Copyright : Copyright (C) 2006-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of LaTeX to 'Pandoc' document.
+-}
+module Text.Pandoc.Readers.LaTeX ( readLaTeX,
+ rawLaTeXInline,
+ rawLaTeXBlock,
+ inlineCommand,
+ ) where
+
+import Text.Pandoc.Definition
+import Text.Pandoc.Walk
+import Text.Pandoc.Shared
+import Text.Pandoc.Options
+import Text.Pandoc.Logging
+import Text.Pandoc.Parsing hiding ((<|>), many, optional, space,
+ mathDisplay, mathInline)
+import Data.Char ( chr, ord, isLetter, isAlphaNum )
+import Control.Monad
+import Text.Pandoc.Builder
+import Control.Applicative ((<|>), many, optional)
+import Data.Maybe (fromMaybe, maybeToList)
+import System.FilePath (replaceExtension, takeExtension, addExtension)
+import Data.List (intercalate)
+import qualified Data.Map as M
+import Text.Pandoc.Highlighting (fromListingsLanguage, languagesByExtension)
+import Text.Pandoc.ImageSize (numUnit, showFl)
+import Control.Monad.Except (throwError)
+import Text.Pandoc.Class (PandocMonad, PandocPure, lookupEnv, report,
+ readFileFromDirs)
+
+-- | Parse LaTeX from string and return 'Pandoc' document.
+readLaTeX :: PandocMonad m
+ => ReaderOptions -- ^ Reader options
+ -> String -- ^ String to parse (assumes @'\n'@ line endings)
+ -> m Pandoc
+readLaTeX opts ltx = do
+ parsed <- readWithM parseLaTeX def{ stateOptions = opts } ltx
+ case parsed of
+ Right result -> return result
+ Left e -> throwError e
+
+parseLaTeX :: PandocMonad m => LP m Pandoc
+parseLaTeX = do
+ bs <- blocks
+ eof
+ st <- getState
+ let meta = stateMeta st
+ let (Pandoc _ bs') = doc bs
+ return $ Pandoc meta bs'
+
+type LP m = ParserT String ParserState m
+
+anyControlSeq :: PandocMonad m => LP m String
+anyControlSeq = do
+ char '\\'
+ next <- option '\n' anyChar
+ case next of
+ '\n' -> return ""
+ c | isLetter c -> (c:) <$> (many letter <* optional sp)
+ | otherwise -> return [c]
+
+controlSeq :: PandocMonad m => String -> LP m String
+controlSeq name = try $ do
+ char '\\'
+ case name of
+ "" -> mzero
+ [c] | not (isLetter c) -> string [c]
+ cs -> string cs <* notFollowedBy letter <* optional sp
+ return name
+
+dimenarg :: PandocMonad m => LP m String
+dimenarg = try $ do
+ ch <- option "" $ string "="
+ num <- many1 digit
+ dim <- oneOfStrings ["pt","pc","in","bp","cm","mm","dd","cc","sp"]
+ return $ ch ++ num ++ dim
+
+sp :: PandocMonad m => LP m ()
+sp = whitespace <|> endline
+
+whitespace :: PandocMonad m => LP m ()
+whitespace = skipMany1 $ satisfy (\c -> c == ' ' || c == '\t')
+
+endline :: PandocMonad m => LP m ()
+endline = try (newline >> lookAhead anyChar >> notFollowedBy blankline)
+
+isLowerHex :: Char -> Bool
+isLowerHex x = x >= '0' && x <= '9' || x >= 'a' && x <= 'f'
+
+tildeEscape :: PandocMonad m => LP m Char
+tildeEscape = try $ do
+ string "^^"
+ c <- satisfy (\x -> x >= '\0' && x <= '\128')
+ d <- if isLowerHex c
+ then option "" $ count 1 (satisfy isLowerHex)
+ else return ""
+ if null d
+ then case ord c of
+ x | x >= 64 && x <= 127 -> return $ chr (x - 64)
+ | otherwise -> return $ chr (x + 64)
+ else return $ chr $ read ('0':'x':c:d)
+
+comment :: PandocMonad m => LP m ()
+comment = do
+ char '%'
+ skipMany (satisfy (/='\n'))
+ optional newline
+ return ()
+
+bgroup :: PandocMonad m => LP m ()
+bgroup = try $ do
+ skipMany (spaceChar <|> try (newline <* notFollowedBy blankline))
+ () <$ char '{'
+ <|> () <$ controlSeq "bgroup"
+ <|> () <$ controlSeq "begingroup"
+
+egroup :: PandocMonad m => LP m ()
+egroup = () <$ char '}'
+ <|> () <$ controlSeq "egroup"
+ <|> () <$ controlSeq "endgroup"
+
+grouped :: PandocMonad m => Monoid a => LP m a -> LP m a
+grouped parser = try $ bgroup *> (mconcat <$> manyTill parser egroup)
+
+braced :: PandocMonad m => LP m String
+braced = bgroup *> (concat <$> manyTill
+ ( many1 (satisfy (\c -> c /= '\\' && c /= '}' && c /= '{'))
+ <|> try (string "\\}")
+ <|> try (string "\\{")
+ <|> try (string "\\\\")
+ <|> ((\x -> "{" ++ x ++ "}") <$> braced)
+ <|> count 1 anyChar
+ ) egroup)
+
+bracketed :: PandocMonad m => Monoid a => LP m a -> LP m a
+bracketed parser = try $ char '[' *> (mconcat <$> manyTill parser (char ']'))
+
+mathDisplay :: PandocMonad m => LP m String -> LP m Inlines
+mathDisplay p = displayMath <$> (try p >>= applyMacros' . trim)
+
+mathInline :: PandocMonad m => LP m String -> LP m Inlines
+mathInline p = math <$> (try p >>= applyMacros')
+
+mathChars :: PandocMonad m => LP m String
+mathChars =
+ concat <$> many (escapedChar
+ <|> (snd <$> withRaw braced)
+ <|> many1 (satisfy isOrdChar))
+ where escapedChar = try $ do char '\\'
+ c <- anyChar
+ return ['\\',c]
+ isOrdChar '$' = False
+ isOrdChar '{' = False
+ isOrdChar '}' = False
+ isOrdChar '\\' = False
+ isOrdChar _ = True
+
+quoted' :: PandocMonad m => (Inlines -> Inlines) -> LP m String -> LP m () -> LP m Inlines
+quoted' f starter ender = do
+ startchs <- starter
+ smart <- extensionEnabled Ext_smart <$> getOption readerExtensions
+ if smart
+ then do
+ ils <- many (notFollowedBy ender >> inline)
+ (ender >> return (f (mconcat ils))) <|>
+ (<> mconcat ils) <$>
+ lit (case startchs of
+ "``" -> "“"
+ "`" -> "‘"
+ _ -> startchs)
+ else lit startchs
+
+doubleQuote :: PandocMonad m => LP m Inlines
+doubleQuote = do
+ quoted' doubleQuoted (try $ string "``") (void $ try $ string "''")
+ <|> quoted' doubleQuoted (string "“") (void $ char '”')
+ -- the following is used by babel for localized quotes:
+ <|> quoted' doubleQuoted (try $ string "\"`") (void $ try $ string "\"'")
+ <|> quoted' doubleQuoted (string "\"") (void $ char '"')
+
+singleQuote :: PandocMonad m => LP m Inlines
+singleQuote = do
+ smart <- extensionEnabled Ext_smart <$> getOption readerExtensions
+ if smart
+ then quoted' singleQuoted (string "`") (try $ char '\'' >> notFollowedBy letter)
+ <|> quoted' singleQuoted (string "‘") (try $ char '’' >> notFollowedBy letter)
+ else str <$> many1 (oneOf "`\'‘’")
+
+inline :: PandocMonad m => LP m Inlines
+inline = (mempty <$ comment)
+ <|> (space <$ whitespace)
+ <|> (softbreak <$ endline)
+ <|> inlineText
+ <|> inlineCommand
+ <|> inlineEnvironment
+ <|> inlineGroup
+ <|> (char '-' *> option (str "-")
+ (char '-' *> option (str "–") (str "—" <$ char '-')))
+ <|> doubleQuote
+ <|> singleQuote
+ <|> (str "”" <$ try (string "''"))
+ <|> (str "”" <$ char '”')
+ <|> (str "’" <$ char '\'')
+ <|> (str "’" <$ char '’')
+ <|> (str "\160" <$ char '~')
+ <|> mathDisplay (string "$$" *> mathChars <* string "$$")
+ <|> mathInline (char '$' *> mathChars <* char '$')
+ <|> (guardEnabled Ext_literate_haskell *> char '|' *> doLHSverb)
+ <|> (str . (:[]) <$> tildeEscape)
+ <|> (do res <- oneOf "#&~^'`\"[]"
+ pos <- getPosition
+ report $ ParsingUnescaped [res] pos
+ return $ str [res])
+
+inlines :: PandocMonad m => LP m Inlines
+inlines = mconcat <$> many (notFollowedBy (char '}') *> inline)
+
+inlineGroup :: PandocMonad m => LP m Inlines
+inlineGroup = do
+ ils <- grouped inline
+ if isNull ils
+ then return mempty
+ else return $ spanWith nullAttr ils
+ -- we need the span so we can detitlecase bibtex entries;
+ -- we need to know when something is {C}apitalized
+
+block :: PandocMonad m => LP m Blocks
+block = (mempty <$ comment)
+ <|> (mempty <$ ((spaceChar <|> newline) *> spaces))
+ <|> environment
+ <|> include
+ <|> macro
+ <|> blockCommand
+ <|> paragraph
+ <|> grouped block
+ <|> (mempty <$ char '&') -- loose & in table environment
+
+
+blocks :: PandocMonad m => LP m Blocks
+blocks = mconcat <$> many block
+
+getRawCommand :: PandocMonad m => String -> LP m String
+getRawCommand name' = do
+ rawargs <- withRaw (many (try (optional sp *> opt)) *>
+ option "" (try (optional sp *> dimenarg)) *>
+ many braced)
+ return $ '\\' : name' ++ snd rawargs
+
+lookupListDefault :: (Ord k) => v -> [k] -> M.Map k v -> v
+lookupListDefault d = (fromMaybe d .) . lookupList
+ where
+ lookupList l m = msum $ map (`M.lookup` m) l
+
+blockCommand :: PandocMonad m => LP m Blocks
+blockCommand = try $ do
+ name <- anyControlSeq
+ guard $ name /= "begin" && name /= "end"
+ star <- option "" (string "*" <* optional sp)
+ let name' = name ++ star
+ let raw = do
+ rawcommand <- getRawCommand name'
+ transformed <- applyMacros' rawcommand
+ guard $ transformed /= rawcommand
+ notFollowedBy $ parseFromString inlines transformed
+ parseFromString blocks transformed
+ lookupListDefault raw [name',name] blockCommands
+
+inBrackets :: Inlines -> Inlines
+inBrackets x = str "[" <> x <> str "]"
+
+-- eat an optional argument and one or more arguments in braces
+ignoreInlines :: PandocMonad m => String -> (String, LP m Inlines)
+ignoreInlines name = (name, p)
+ where
+ p = do oa <- optargs
+ let rawCommand = '\\':name ++ oa
+ let doraw = guardRaw >> return (rawInline "latex" rawCommand)
+ doraw <|> ignore rawCommand
+
+guardRaw :: PandocMonad m => LP m ()
+guardRaw = getOption readerExtensions >>= guard . extensionEnabled Ext_raw_tex
+
+optargs :: PandocMonad m => LP m String
+optargs = snd <$> withRaw (skipopts *> skipMany (try $ optional sp *> braced))
+
+ignore :: (Monoid a, PandocMonad m) => String -> ParserT s u m a
+ignore raw = do
+ pos <- getPosition
+ report $ SkippedContent raw pos
+ return mempty
+
+ignoreBlocks :: PandocMonad m => String -> (String, LP m Blocks)
+ignoreBlocks name = (name, p)
+ where
+ p = do oa <- optargs
+ let rawCommand = '\\':name ++ oa
+ let doraw = guardRaw >> return (rawBlock "latex" rawCommand)
+ doraw <|> ignore rawCommand
+
+blockCommands :: PandocMonad m => M.Map String (LP m Blocks)
+blockCommands = M.fromList $
+ [ ("par", mempty <$ skipopts)
+ , ("parbox", braced >> grouped blocks)
+ , ("title", mempty <$ (skipopts *>
+ (grouped inline >>= addMeta "title")
+ <|> (grouped block >>= addMeta "title")))
+ , ("subtitle", mempty <$ (skipopts *> tok >>= addMeta "subtitle"))
+ , ("author", mempty <$ (skipopts *> authors))
+ -- -- in letter class, temp. store address & sig as title, author
+ , ("address", mempty <$ (skipopts *> tok >>= addMeta "address"))
+ , ("signature", mempty <$ (skipopts *> authors))
+ , ("date", mempty <$ (skipopts *> tok >>= addMeta "date"))
+ -- sectioning
+ , ("chapter", updateState (\s -> s{ stateHasChapters = True })
+ *> section nullAttr 0)
+ , ("chapter*", updateState (\s -> s{ stateHasChapters = True })
+ *> section ("",["unnumbered"],[]) 0)
+ , ("section", section nullAttr 1)
+ , ("section*", section ("",["unnumbered"],[]) 1)
+ , ("subsection", section nullAttr 2)
+ , ("subsection*", section ("",["unnumbered"],[]) 2)
+ , ("subsubsection", section nullAttr 3)
+ , ("subsubsection*", section ("",["unnumbered"],[]) 3)
+ , ("paragraph", section nullAttr 4)
+ , ("paragraph*", section ("",["unnumbered"],[]) 4)
+ , ("subparagraph", section nullAttr 5)
+ , ("subparagraph*", section ("",["unnumbered"],[]) 5)
+ -- beamer slides
+ , ("frametitle", section nullAttr 3)
+ , ("framesubtitle", section nullAttr 4)
+ -- letters
+ , ("opening", (para . trimInlines) <$> (skipopts *> tok))
+ , ("closing", skipopts *> closing)
+ --
+ , ("hrule", pure horizontalRule)
+ , ("strut", pure mempty)
+ , ("rule", skipopts *> tok *> tok *> pure horizontalRule)
+ , ("item", skipopts *> looseItem)
+ , ("documentclass", skipopts *> braced *> preamble)
+ , ("centerline", (para . trimInlines) <$> (skipopts *> tok))
+ , ("caption", skipopts *> setCaption)
+ , ("bibliography", mempty <$ (skipopts *> braced >>=
+ addMeta "bibliography" . splitBibs))
+ , ("addbibresource", mempty <$ (skipopts *> braced >>=
+ addMeta "bibliography" . splitBibs))
+ -- includes
+ , ("lstinputlisting", inputListing)
+ ] ++ map ignoreBlocks
+ -- these commands will be ignored unless --parse-raw is specified,
+ -- in which case they will appear as raw latex blocks
+ [ "newcommand", "renewcommand", "newenvironment", "renewenvironment"
+ -- newcommand, etc. should be parsed by macro, but we need this
+ -- here so these aren't parsed as inline commands to ignore
+ , "special", "pdfannot", "pdfstringdef"
+ , "bibliographystyle"
+ , "maketitle", "makeindex", "makeglossary"
+ , "addcontentsline", "addtocontents", "addtocounter"
+ -- \ignore{} is used conventionally in literate haskell for definitions
+ -- that are to be processed by the compiler but not printed.
+ , "ignore"
+ , "hyperdef"
+ , "markboth", "markright", "markleft"
+ , "newpage"
+ ]
+
+addMeta :: PandocMonad m => ToMetaValue a => String -> a -> LP m ()
+addMeta field val = updateState $ \st ->
+ st{ stateMeta = addMetaField field val $ stateMeta st }
+
+splitBibs :: String -> [Inlines]
+splitBibs = map (str . flip replaceExtension "bib" . trim) . splitBy (==',')
+
+setCaption :: PandocMonad m => LP m Blocks
+setCaption = do
+ ils <- tok
+ mblabel <- option Nothing $
+ try $ spaces' >> controlSeq "label" >> (Just <$> tok)
+ let ils' = case mblabel of
+ Just lab -> ils <> spanWith
+ ("",[],[("data-label", stringify lab)]) mempty
+ Nothing -> ils
+ updateState $ \st -> st{ stateCaption = Just ils' }
+ return mempty
+
+resetCaption :: PandocMonad m => LP m ()
+resetCaption = updateState $ \st -> st{ stateCaption = Nothing }
+
+authors :: PandocMonad m => LP m ()
+authors = try $ do
+ char '{'
+ let oneAuthor = mconcat <$>
+ many1 (notFollowedBy' (controlSeq "and") >>
+ (inline <|> mempty <$ blockCommand))
+ -- skip e.g. \vspace{10pt}
+ auths <- sepBy oneAuthor (controlSeq "and")
+ char '}'
+ addMeta "author" (map trimInlines auths)
+
+section :: PandocMonad m => Attr -> Int -> LP m Blocks
+section (ident, classes, kvs) lvl = do
+ hasChapters <- stateHasChapters `fmap` getState
+ let lvl' = if hasChapters then lvl + 1 else lvl
+ skipopts
+ contents <- grouped inline
+ lab <- option ident $ try (spaces' >> controlSeq "label" >> spaces' >> braced)
+ attr' <- registerHeader (lab, classes, kvs) contents
+ return $ headerWith attr' lvl' contents
+
+inlineCommand :: PandocMonad m => LP m Inlines
+inlineCommand = try $ do
+ name <- anyControlSeq
+ guard $ name /= "begin" && name /= "end"
+ guard $ not $ isBlockCommand name
+ exts <- getOption readerExtensions
+ star <- option "" (string "*")
+ let name' = name ++ star
+ let raw = do
+ rawargs <- withRaw
+ (skipangles *> skipopts *> option "" dimenarg *> many braced)
+ let rawcommand = '\\' : name ++ star ++ snd rawargs
+ transformed <- applyMacros' rawcommand
+ if transformed /= rawcommand
+ then parseFromString inlines transformed
+ else if extensionEnabled Ext_raw_tex exts
+ then return $ rawInline "latex" rawcommand
+ else ignore rawcommand
+ (lookupListDefault mzero [name',name] inlineCommands <*
+ optional (try (string "{}")))
+ <|> raw
+
+unlessParseRaw :: PandocMonad m => LP m ()
+unlessParseRaw = getOption readerExtensions >>=
+ guard . not . extensionEnabled Ext_raw_tex
+
+isBlockCommand :: String -> Bool
+isBlockCommand s = s `M.member` (blockCommands :: M.Map String (LP PandocPure Blocks))
+
+
+inlineEnvironments :: PandocMonad m => M.Map String (LP m Inlines)
+inlineEnvironments = M.fromList
+ [ ("displaymath", mathEnv id Nothing "displaymath")
+ , ("math", math <$> verbEnv "math")
+ , ("equation", mathEnv id Nothing "equation")
+ , ("equation*", mathEnv id Nothing "equation*")
+ , ("gather", mathEnv id (Just "gathered") "gather")
+ , ("gather*", mathEnv id (Just "gathered") "gather*")
+ , ("multline", mathEnv id (Just "gathered") "multline")
+ , ("multline*", mathEnv id (Just "gathered") "multline*")
+ , ("eqnarray", mathEnv id (Just "aligned") "eqnarray")
+ , ("eqnarray*", mathEnv id (Just "aligned") "eqnarray*")
+ , ("align", mathEnv id (Just "aligned") "align")
+ , ("align*", mathEnv id (Just "aligned") "align*")
+ , ("alignat", mathEnv id (Just "aligned") "alignat")
+ , ("alignat*", mathEnv id (Just "aligned") "alignat*")
+ ]
+
+inlineCommands :: PandocMonad m => M.Map String (LP m Inlines)
+inlineCommands = M.fromList $
+ [ ("emph", extractSpaces emph <$> tok)
+ , ("textit", extractSpaces emph <$> tok)
+ , ("textsl", extractSpaces emph <$> tok)
+ , ("textsc", extractSpaces smallcaps <$> tok)
+ , ("sout", extractSpaces strikeout <$> tok)
+ , ("textsuperscript", extractSpaces superscript <$> tok)
+ , ("textsubscript", extractSpaces subscript <$> tok)
+ , ("textbackslash", lit "\\")
+ , ("backslash", lit "\\")
+ , ("slash", lit "/")
+ , ("textbf", extractSpaces strong <$> tok)
+ , ("textnormal", extractSpaces (spanWith ("",["nodecor"],[])) <$> tok)
+ , ("ldots", lit "…")
+ , ("dots", lit "…")
+ , ("mdots", lit "…")
+ , ("sim", lit "~")
+ , ("label", unlessParseRaw >> (inBrackets <$> tok))
+ , ("ref", unlessParseRaw >> (inBrackets <$> tok))
+ , ("noindent", unlessParseRaw >> ignore "noindent")
+ , ("textgreek", tok)
+ , ("sep", lit ",")
+ , ("cref", unlessParseRaw >> (inBrackets <$> tok)) -- from cleveref.sty
+ , ("(", mathInline $ manyTill anyChar (try $ string "\\)"))
+ , ("[", mathDisplay $ manyTill anyChar (try $ string "\\]"))
+ , ("ensuremath", mathInline braced)
+ , ("texorpdfstring", (\_ x -> x) <$> tok <*> tok)
+ , ("P", lit "¶")
+ , ("S", lit "§")
+ , ("$", lit "$")
+ , ("%", lit "%")
+ , ("&", lit "&")
+ , ("#", lit "#")
+ , ("_", lit "_")
+ , ("{", lit "{")
+ , ("}", lit "}")
+ -- old TeX commands
+ , ("em", extractSpaces emph <$> inlines)
+ , ("it", extractSpaces emph <$> inlines)
+ , ("sl", extractSpaces emph <$> inlines)
+ , ("bf", extractSpaces strong <$> inlines)
+ , ("rm", inlines)
+ , ("itshape", extractSpaces emph <$> inlines)
+ , ("slshape", extractSpaces emph <$> inlines)
+ , ("scshape", extractSpaces smallcaps <$> inlines)
+ , ("bfseries", extractSpaces strong <$> inlines)
+ , ("/", pure mempty) -- italic correction
+ , ("aa", lit "å")
+ , ("AA", lit "Å")
+ , ("ss", lit "ß")
+ , ("o", lit "ø")
+ , ("O", lit "Ø")
+ , ("L", lit "Ł")
+ , ("l", lit "ł")
+ , ("ae", lit "æ")
+ , ("AE", lit "Æ")
+ , ("oe", lit "œ")
+ , ("OE", lit "Œ")
+ , ("pounds", lit "£")
+ , ("euro", lit "€")
+ , ("copyright", lit "©")
+ , ("textasciicircum", lit "^")
+ , ("textasciitilde", lit "~")
+ , ("H", try $ tok >>= accent hungarumlaut)
+ , ("`", option (str "`") $ try $ tok >>= accent grave)
+ , ("'", option (str "'") $ try $ tok >>= accent acute)
+ , ("^", option (str "^") $ try $ tok >>= accent circ)
+ , ("~", option (str "~") $ try $ tok >>= accent tilde)
+ , ("\"", option (str "\"") $ try $ tok >>= accent umlaut)
+ , (".", option (str ".") $ try $ tok >>= accent dot)
+ , ("=", option (str "=") $ try $ tok >>= accent macron)
+ , ("c", option (str "c") $ try $ tok >>= accent cedilla)
+ , ("v", option (str "v") $ try $ tok >>= accent hacek)
+ , ("u", option (str "u") $ try $ tok >>= accent breve)
+ , ("i", lit "i")
+ , ("\\", linebreak <$ (optional (bracketed inline) *> spaces'))
+ , (",", pure mempty)
+ , ("@", pure mempty)
+ , (" ", lit "\160")
+ , ("ps", pure $ str "PS." <> space)
+ , ("TeX", lit "TeX")
+ , ("LaTeX", lit "LaTeX")
+ , ("bar", lit "|")
+ , ("textless", lit "<")
+ , ("textgreater", lit ">")
+ , ("thanks", (note . mconcat) <$> (char '{' *> manyTill block (char '}')))
+ , ("footnote", (note . mconcat) <$> (char '{' *> manyTill block (char '}')))
+ , ("verb", doverb)
+ , ("lstinline", skipopts *> doverb)
+ , ("Verb", doverb)
+ , ("texttt", (code . stringify . toList) <$> tok)
+ , ("url", (unescapeURL <$> braced) >>= \url ->
+ pure (link url "" (str url)))
+ , ("href", (unescapeURL <$> braced <* optional sp) >>= \url ->
+ tok >>= \lab ->
+ pure (link url "" lab))
+ , ("includegraphics", do options <- option [] keyvals
+ src <- unescapeURL . removeDoubleQuotes <$> braced
+ mkImage options src)
+ , ("enquote", enquote)
+ , ("cite", citation "cite" NormalCitation False)
+ , ("Cite", citation "Cite" NormalCitation False)
+ , ("citep", citation "citep" NormalCitation False)
+ , ("citep*", citation "citep*" NormalCitation False)
+ , ("citeal", citation "citeal" NormalCitation False)
+ , ("citealp", citation "citealp" NormalCitation False)
+ , ("citealp*", citation "citealp*" NormalCitation False)
+ , ("autocite", citation "autocite" NormalCitation False)
+ , ("smartcite", citation "smartcite" NormalCitation False)
+ , ("footcite", inNote <$> citation "footcite" NormalCitation False)
+ , ("parencite", citation "parencite" NormalCitation False)
+ , ("supercite", citation "supercite" NormalCitation False)
+ , ("footcitetext", inNote <$> citation "footcitetext" NormalCitation False)
+ , ("citeyearpar", citation "citeyearpar" SuppressAuthor False)
+ , ("citeyear", citation "citeyear" SuppressAuthor False)
+ , ("autocite*", citation "autocite*" SuppressAuthor False)
+ , ("cite*", citation "cite*" SuppressAuthor False)
+ , ("parencite*", citation "parencite*" SuppressAuthor False)
+ , ("textcite", citation "textcite" AuthorInText False)
+ , ("citet", citation "citet" AuthorInText False)
+ , ("citet*", citation "citet*" AuthorInText False)
+ , ("citealt", citation "citealt" AuthorInText False)
+ , ("citealt*", citation "citealt*" AuthorInText False)
+ , ("textcites", citation "textcites" AuthorInText True)
+ , ("cites", citation "cites" NormalCitation True)
+ , ("autocites", citation "autocites" NormalCitation True)
+ , ("footcites", inNote <$> citation "footcites" NormalCitation True)
+ , ("parencites", citation "parencites" NormalCitation True)
+ , ("supercites", citation "supercites" NormalCitation True)
+ , ("footcitetexts", inNote <$> citation "footcitetexts" NormalCitation True)
+ , ("Autocite", citation "Autocite" NormalCitation False)
+ , ("Smartcite", citation "Smartcite" NormalCitation False)
+ , ("Footcite", citation "Footcite" NormalCitation False)
+ , ("Parencite", citation "Parencite" NormalCitation False)
+ , ("Supercite", citation "Supercite" NormalCitation False)
+ , ("Footcitetext", inNote <$> citation "Footcitetext" NormalCitation False)
+ , ("Citeyearpar", citation "Citeyearpar" SuppressAuthor False)
+ , ("Citeyear", citation "Citeyear" SuppressAuthor False)
+ , ("Autocite*", citation "Autocite*" SuppressAuthor False)
+ , ("Cite*", citation "Cite*" SuppressAuthor False)
+ , ("Parencite*", citation "Parencite*" SuppressAuthor False)
+ , ("Textcite", citation "Textcite" AuthorInText False)
+ , ("Textcites", citation "Textcites" AuthorInText True)
+ , ("Cites", citation "Cites" NormalCitation True)
+ , ("Autocites", citation "Autocites" NormalCitation True)
+ , ("Footcites", citation "Footcites" NormalCitation True)
+ , ("Parencites", citation "Parencites" NormalCitation True)
+ , ("Supercites", citation "Supercites" NormalCitation True)
+ , ("Footcitetexts", inNote <$> citation "Footcitetexts" NormalCitation True)
+ , ("citetext", complexNatbibCitation NormalCitation)
+ , ("citeauthor", (try (tok *> optional sp *> controlSeq "citetext") *>
+ complexNatbibCitation AuthorInText)
+ <|> citation "citeauthor" AuthorInText False)
+ , ("nocite", mempty <$ (citation "nocite" NormalCitation False >>=
+ addMeta "nocite"))
+ ] ++ map ignoreInlines
+ -- these commands will be ignored unless --parse-raw is specified,
+ -- in which case they will appear as raw latex blocks:
+ [ "index" ]
+
+mkImage :: PandocMonad m => [(String, String)] -> String -> LP m Inlines
+mkImage options src = do
+ let replaceTextwidth (k,v) = case numUnit v of
+ Just (num, "\\textwidth") -> (k, showFl (num * 100) ++ "%")
+ _ -> (k, v)
+ let kvs = map replaceTextwidth $ filter (\(k,_) -> k `elem` ["width", "height"]) options
+ let attr = ("",[], kvs)
+ let alt = str "image"
+ case takeExtension src of
+ "" -> do
+ defaultExt <- getOption readerDefaultImageExtension
+ return $ imageWith attr (addExtension src defaultExt) "" alt
+ _ -> return $ imageWith attr src "" alt
+
+inNote :: Inlines -> Inlines
+inNote ils =
+ note $ para $ ils <> str "."
+
+unescapeURL :: String -> String
+unescapeURL ('\\':x:xs) | isEscapable x = x:unescapeURL xs
+ where isEscapable c = c `elem` ("#$%&~_^\\{}" :: String)
+unescapeURL (x:xs) = x:unescapeURL xs
+unescapeURL [] = ""
+
+enquote :: PandocMonad m => LP m Inlines
+enquote = do
+ skipopts
+ context <- stateQuoteContext <$> getState
+ if context == InDoubleQuote
+ then singleQuoted <$> withQuoteContext InSingleQuote tok
+ else doubleQuoted <$> withQuoteContext InDoubleQuote tok
+
+doverb :: PandocMonad m => LP m Inlines
+doverb = do
+ marker <- anyChar
+ code <$> manyTill (satisfy (/='\n')) (char marker)
+
+doLHSverb :: PandocMonad m => LP m Inlines
+doLHSverb = codeWith ("",["haskell"],[]) <$> manyTill (satisfy (/='\n')) (char '|')
+
+lit :: String -> LP m Inlines
+lit = pure . str
+
+accent :: (Char -> String) -> Inlines -> LP m Inlines
+accent f ils =
+ case toList ils of
+ (Str (x:xs) : ys) -> return $ fromList (Str (f x ++ xs) : ys)
+ [] -> mzero
+ _ -> 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]
+
+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]
+
+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]
+
+tok :: PandocMonad m => LP m Inlines
+tok = try $ grouped inline <|> inlineCommand <|> str <$> count 1 inlineChar
+
+opt :: PandocMonad m => LP m Inlines
+opt = bracketed inline
+
+rawopt :: PandocMonad m => LP m String
+rawopt = do
+ contents <- bracketed (many1 (noneOf "[]") <|> try (string "\\]") <|>
+ try (string "\\[") <|> rawopt)
+ optional sp
+ return $ "[" ++ contents ++ "]"
+
+skipopts :: PandocMonad m => LP m ()
+skipopts = skipMany rawopt
+
+-- opts in angle brackets are used in beamer
+rawangle :: PandocMonad m => LP m ()
+rawangle = try $ do
+ char '<'
+ skipMany (noneOf ">")
+ char '>'
+ return ()
+
+skipangles :: PandocMonad m => LP m ()
+skipangles = skipMany rawangle
+
+inlineText :: PandocMonad m => LP m Inlines
+inlineText = str <$> many1 inlineChar
+
+inlineChar :: PandocMonad m => LP m Char
+inlineChar = noneOf "\\$%&~#{}^'`\"‘’“”-[] \t\n"
+
+environment :: PandocMonad m => LP m Blocks
+environment = do
+ controlSeq "begin"
+ name <- braced
+ M.findWithDefault mzero name environments
+ <|> rawEnv name
+
+inlineEnvironment :: PandocMonad m => LP m Inlines
+inlineEnvironment = try $ do
+ controlSeq "begin"
+ name <- braced
+ M.findWithDefault mzero name inlineEnvironments
+
+rawEnv :: PandocMonad m => String -> LP m Blocks
+rawEnv name = do
+ exts <- getOption readerExtensions
+ let parseRaw = extensionEnabled Ext_raw_tex exts
+ rawOptions <- mconcat <$> many rawopt
+ let beginCommand = "\\begin{" ++ name ++ "}" ++ rawOptions
+ unless parseRaw $ do
+ pos1 <- getPosition
+ report $ SkippedContent beginCommand pos1
+ (bs, raw) <- withRaw $ env name blocks
+ raw' <- applyMacros' raw
+ if parseRaw
+ then return $ rawBlock "latex" $ beginCommand ++ raw'
+ else do
+ pos2 <- getPosition
+ report $ SkippedContent ("\\end{" ++ name ++ "}") pos2
+ return bs
+
+----
+
+braced' :: PandocMonad m => LP m String
+braced' = try $ char '{' *> manyTill (satisfy (/='}')) (char '}')
+
+maybeAddExtension :: String -> FilePath -> FilePath
+maybeAddExtension ext fp =
+ if null (takeExtension fp)
+ then addExtension fp ext
+ else fp
+
+include :: PandocMonad m => LP m Blocks
+include = do
+ fs' <- try $ do
+ char '\\'
+ name <- try (string "include")
+ <|> try (string "input")
+ <|> string "usepackage"
+ -- skip options
+ skipMany $ try $ char '[' *> manyTill anyChar (char ']')
+ fs <- (map trim . splitBy (==',')) <$> braced'
+ return $ if name == "usepackage"
+ then map (maybeAddExtension ".sty") fs
+ else map (maybeAddExtension ".tex") fs
+ dirs <- (splitBy (==':') . fromMaybe ".") <$> lookupEnv "TEXINPUTS"
+ mconcat <$> mapM (insertIncludedFile blocks dirs) fs'
+
+inputListing :: PandocMonad m => LP m Blocks
+inputListing = do
+ pos <- getPosition
+ options <- option [] keyvals
+ f <- filter (/='"') <$> braced
+ dirs <- (splitBy (==':') . fromMaybe ".") <$> lookupEnv "TEXINPUTS"
+ mbCode <- readFileFromDirs dirs f
+ codeLines <- case mbCode of
+ Just s -> return $ lines s
+ Nothing -> do
+ report $ CouldNotLoadIncludeFile f pos
+ return []
+ let (ident,classes,kvs) = parseListingsOptions options
+ let language = case lookup "language" options >>= fromListingsLanguage of
+ Just l -> [l]
+ Nothing -> take 1 $ languagesByExtension (takeExtension f)
+ let firstline = fromMaybe 1 $ lookup "firstline" options >>= safeRead
+ let lastline = fromMaybe (length codeLines) $
+ lookup "lastline" options >>= safeRead
+ let codeContents = intercalate "\n" $ take (1 + lastline - firstline) $
+ drop (firstline - 1) codeLines
+ return $ codeBlockWith (ident,ordNub (classes ++ language),kvs) codeContents
+
+parseListingsOptions :: [(String, String)] -> Attr
+parseListingsOptions options =
+ let kvs = [ (if k == "firstnumber"
+ then "startFrom"
+ else k, v) | (k,v) <- options ]
+ classes = [ "numberLines" |
+ lookup "numbers" options == Just "left" ]
+ ++ maybeToList (lookup "language" options
+ >>= fromListingsLanguage)
+ in (fromMaybe "" (lookup "label" options), classes, kvs)
+
+----
+
+keyval :: PandocMonad m => LP m (String, String)
+keyval = try $ do
+ key <- many1 alphaNum
+ val <- option "" $ char '=' >> many1 (alphaNum <|> char '.' <|> char '\\')
+ skipMany spaceChar
+ optional (char ',')
+ skipMany spaceChar
+ return (key, val)
+
+
+keyvals :: PandocMonad m => LP m [(String, String)]
+keyvals = try $ char '[' *> manyTill keyval (char ']')
+
+alltt :: PandocMonad m => String -> LP m Blocks
+alltt t = walk strToCode <$> parseFromString blocks
+ (substitute " " "\\ " $ substitute "%" "\\%" $
+ intercalate "\\\\\n" $ lines t)
+ where strToCode (Str s) = Code nullAttr s
+ strToCode x = x
+
+rawLaTeXBlock :: PandocMonad m => LP m String
+rawLaTeXBlock = snd <$> try (withRaw (environment <|> blockCommand))
+
+rawLaTeXInline :: PandocMonad m => LP m Inline
+rawLaTeXInline = do
+ raw <- (snd <$> withRaw inlineCommand) <|> (snd <$> withRaw blockCommand)
+ RawInline "latex" <$> applyMacros' raw
+
+addImageCaption :: PandocMonad m => Blocks -> LP m Blocks
+addImageCaption = walkM go
+ where go (Image attr alt (src,tit)) = do
+ mbcapt <- stateCaption <$> getState
+ return $ case mbcapt of
+ Just ils -> Image attr (toList ils) (src, "fig:")
+ Nothing -> Image attr alt (src,tit)
+ go x = return x
+
+addTableCaption :: PandocMonad m => Blocks -> LP m Blocks
+addTableCaption = walkM go
+ where go (Table c als ws hs rs) = do
+ mbcapt <- stateCaption <$> getState
+ return $ case mbcapt of
+ Just ils -> Table (toList ils) als ws hs rs
+ Nothing -> Table c als ws hs rs
+ go x = return x
+
+environments :: PandocMonad m => M.Map String (LP m Blocks)
+environments = M.fromList
+ [ ("document", env "document" blocks <* skipMany anyChar)
+ , ("abstract", mempty <$ (env "abstract" blocks >>= addMeta "abstract"))
+ , ("letter", env "letter" letterContents)
+ , ("minipage", env "minipage" $
+ skipopts *> spaces' *> optional braced *> spaces' *> blocks)
+ , ("figure", env "figure" $
+ resetCaption *> skipopts *> blocks >>= addImageCaption)
+ , ("center", env "center" blocks)
+ , ("longtable", env "longtable" $
+ resetCaption *> simpTable False >>= addTableCaption)
+ , ("table", env "table" $
+ resetCaption *> skipopts *> blocks >>= addTableCaption)
+ , ("tabular*", env "tabular" $ simpTable True)
+ , ("tabular", env "tabular" $ simpTable False)
+ , ("quote", blockQuote <$> env "quote" blocks)
+ , ("quotation", blockQuote <$> env "quotation" blocks)
+ , ("verse", blockQuote <$> env "verse" blocks)
+ , ("itemize", bulletList <$> listenv "itemize" (many item))
+ , ("description", definitionList <$> listenv "description" (many descItem))
+ , ("enumerate", orderedList')
+ , ("alltt", alltt =<< verbEnv "alltt")
+ , ("code", guardEnabled Ext_literate_haskell *>
+ (codeBlockWith ("",["sourceCode","literate","haskell"],[]) <$>
+ verbEnv "code"))
+ , ("comment", mempty <$ verbEnv "comment")
+ , ("verbatim", codeBlock <$> verbEnv "verbatim")
+ , ("Verbatim", fancyverbEnv "Verbatim")
+ , ("BVerbatim", fancyverbEnv "BVerbatim")
+ , ("lstlisting", do attr <- parseListingsOptions <$> option [] keyvals
+ codeBlockWith attr <$> verbEnv "lstlisting")
+ , ("minted", do options <- option [] keyvals
+ lang <- grouped (many1 $ satisfy (/='}'))
+ let kvs = [ (if k == "firstnumber"
+ then "startFrom"
+ else k, v) | (k,v) <- options ]
+ let classes = [ lang | not (null lang) ] ++
+ [ "numberLines" |
+ lookup "linenos" options == Just "true" ]
+ let attr = ("",classes,kvs)
+ codeBlockWith attr <$> verbEnv "minted")
+ , ("obeylines", parseFromString
+ (para . trimInlines . mconcat <$> many inline) =<<
+ intercalate "\\\\\n" . lines <$> verbEnv "obeylines")
+ , ("displaymath", mathEnv para Nothing "displaymath")
+ , ("equation", mathEnv para Nothing "equation")
+ , ("equation*", mathEnv para Nothing "equation*")
+ , ("gather", mathEnv para (Just "gathered") "gather")
+ , ("gather*", mathEnv para (Just "gathered") "gather*")
+ , ("multline", mathEnv para (Just "gathered") "multline")
+ , ("multline*", mathEnv para (Just "gathered") "multline*")
+ , ("eqnarray", mathEnv para (Just "aligned") "eqnarray")
+ , ("eqnarray*", mathEnv para (Just "aligned") "eqnarray*")
+ , ("align", mathEnv para (Just "aligned") "align")
+ , ("align*", mathEnv para (Just "aligned") "align*")
+ , ("alignat", mathEnv para (Just "aligned") "alignat")
+ , ("alignat*", mathEnv para (Just "aligned") "alignat*")
+ ]
+
+letterContents :: PandocMonad m => LP m Blocks
+letterContents = do
+ bs <- blocks
+ st <- getState
+ -- add signature (author) and address (title)
+ let addr = case lookupMeta "address" (stateMeta st) of
+ Just (MetaBlocks [Plain xs]) ->
+ para $ trimInlines $ fromList xs
+ _ -> mempty
+ return $ addr <> bs -- sig added by \closing
+
+closing :: PandocMonad m => LP m Blocks
+closing = do
+ contents <- tok
+ st <- getState
+ let extractInlines (MetaBlocks [Plain ys]) = ys
+ extractInlines (MetaBlocks [Para ys ]) = ys
+ extractInlines _ = []
+ let sigs = case lookupMeta "author" (stateMeta st) of
+ Just (MetaList xs) ->
+ para $ trimInlines $ fromList $
+ intercalate [LineBreak] $ map extractInlines xs
+ _ -> mempty
+ return $ para (trimInlines contents) <> sigs
+
+item :: PandocMonad m => LP m Blocks
+item = blocks *> controlSeq "item" *> skipopts *> blocks
+
+looseItem :: PandocMonad m => LP m Blocks
+looseItem = do
+ ctx <- stateParserContext `fmap` getState
+ if ctx == ListItemState
+ then mzero
+ else return mempty
+
+descItem :: PandocMonad m => LP m (Inlines, [Blocks])
+descItem = do
+ blocks -- skip blocks before item
+ controlSeq "item"
+ optional sp
+ ils <- opt
+ bs <- blocks
+ return (ils, [bs])
+
+env :: PandocMonad m => String -> LP m a -> LP m a
+env name p = p <*
+ (try (controlSeq "end" *> braced >>= guard . (== name))
+ <?> ("\\end{" ++ name ++ "}"))
+
+listenv :: PandocMonad m => String -> LP m a -> LP m a
+listenv name p = try $ do
+ oldCtx <- stateParserContext `fmap` getState
+ updateState $ \st -> st{ stateParserContext = ListItemState }
+ res <- env name p
+ updateState $ \st -> st{ stateParserContext = oldCtx }
+ return res
+
+mathEnv :: PandocMonad m => (Inlines -> a) -> Maybe String -> String -> LP m a
+mathEnv f innerEnv name = f <$> mathDisplay (inner <$> verbEnv name)
+ where inner x = case innerEnv of
+ Nothing -> x
+ Just y -> "\\begin{" ++ y ++ "}\n" ++ x ++
+ "\\end{" ++ y ++ "}"
+
+verbEnv :: PandocMonad m => String -> LP m String
+verbEnv name = do
+ skipopts
+ optional blankline
+ let endEnv = try $ controlSeq "end" *> braced >>= guard . (== name)
+ res <- manyTill anyChar endEnv
+ return $ stripTrailingNewlines res
+
+fancyverbEnv :: PandocMonad m => String -> LP m Blocks
+fancyverbEnv name = do
+ options <- option [] keyvals
+ let kvs = [ (if k == "firstnumber"
+ then "startFrom"
+ else k, v) | (k,v) <- options ]
+ let classes = [ "numberLines" |
+ lookup "numbers" options == Just "left" ]
+ let attr = ("",classes,kvs)
+ codeBlockWith attr <$> verbEnv name
+
+orderedList' :: PandocMonad m => LP m Blocks
+orderedList' = do
+ optional sp
+ (_, style, delim) <- option (1, DefaultStyle, DefaultDelim) $
+ try $ char '[' *> anyOrderedListMarker <* char ']'
+ spaces
+ optional $ try $ controlSeq "setlength" *> grouped (controlSeq "itemindent") *> braced
+ spaces
+ start <- option 1 $ try $ do controlSeq "setcounter"
+ grouped (string "enum" *> many1 (oneOf "iv"))
+ optional sp
+ num <- grouped (many1 digit)
+ spaces
+ return (read num + 1 :: Int)
+ bs <- listenv "enumerate" (many item)
+ return $ orderedListWith (start, style, delim) bs
+
+paragraph :: PandocMonad m => LP m Blocks
+paragraph = do
+ x <- trimInlines . mconcat <$> many1 inline
+ if x == mempty
+ then return mempty
+ else return $ para x
+
+preamble :: PandocMonad m => LP m Blocks
+preamble = mempty <$> manyTill preambleBlock beginDoc
+ where beginDoc = lookAhead $ try $ controlSeq "begin" *> string "{document}"
+ preambleBlock = void comment
+ <|> void sp
+ <|> void blanklines
+ <|> void include
+ <|> void macro
+ <|> void blockCommand
+ <|> void anyControlSeq
+ <|> void braced
+ <|> void anyChar
+
+-------
+
+-- citations
+
+addPrefix :: [Inline] -> [Citation] -> [Citation]
+addPrefix p (k:ks) = k {citationPrefix = p ++ citationPrefix k} : ks
+addPrefix _ _ = []
+
+addSuffix :: [Inline] -> [Citation] -> [Citation]
+addSuffix s ks@(_:_) =
+ let k = last ks
+ in init ks ++ [k {citationSuffix = citationSuffix k ++ s}]
+addSuffix _ _ = []
+
+simpleCiteArgs :: PandocMonad m => LP m [Citation]
+simpleCiteArgs = try $ do
+ first <- optionMaybe $ toList <$> opt
+ second <- optionMaybe $ toList <$> opt
+ char '{'
+ optional sp
+ keys <- manyTill citationLabel (char '}')
+ let (pre, suf) = case (first , second ) of
+ (Just s , Nothing) -> (mempty, s )
+ (Just s , Just t ) -> (s , t )
+ _ -> (mempty, mempty)
+ conv k = Citation { citationId = k
+ , citationPrefix = []
+ , citationSuffix = []
+ , citationMode = NormalCitation
+ , citationHash = 0
+ , citationNoteNum = 0
+ }
+ return $ addPrefix pre $ addSuffix suf $ map conv keys
+
+citationLabel :: PandocMonad m => LP m String
+citationLabel = optional sp *>
+ (many1 (satisfy isBibtexKeyChar)
+ <* optional sp
+ <* optional (char ',')
+ <* optional sp)
+ where isBibtexKeyChar c = isAlphaNum c || c `elem` (".:;?!`'()/*@_+=-[]" :: String)
+
+cites :: PandocMonad m => CitationMode -> Bool -> LP m [Citation]
+cites mode multi = try $ do
+ cits <- if multi
+ then many1 simpleCiteArgs
+ else count 1 simpleCiteArgs
+ let cs = concat cits
+ return $ case mode of
+ AuthorInText -> case cs of
+ (c:rest) -> c {citationMode = mode} : rest
+ [] -> []
+ _ -> map (\a -> a {citationMode = mode}) cs
+
+citation :: PandocMonad m => String -> CitationMode -> Bool -> LP m Inlines
+citation name mode multi = do
+ (c,raw) <- withRaw $ cites mode multi
+ return $ cite c (rawInline "latex" $ "\\" ++ name ++ raw)
+
+complexNatbibCitation :: PandocMonad m => CitationMode -> LP m Inlines
+complexNatbibCitation mode = try $ do
+ let ils = (toList . trimInlines . mconcat) <$>
+ many (notFollowedBy (oneOf "\\};") >> inline)
+ let parseOne = try $ do
+ skipSpaces
+ pref <- ils
+ cit' <- inline -- expect a citation
+ let citlist = toList cit'
+ cits' <- case citlist of
+ [Cite cs _] -> return cs
+ _ -> mzero
+ suff <- ils
+ skipSpaces
+ optional $ char ';'
+ return $ addPrefix pref $ addSuffix suff cits'
+ (c:cits, raw) <- withRaw $ grouped parseOne
+ return $ cite (c{ citationMode = mode }:cits)
+ (rawInline "latex" $ "\\citetext" ++ raw)
+
+-- tables
+
+parseAligns :: PandocMonad m => LP m [(String, Alignment, String)]
+parseAligns = try $ do
+ char '{'
+ let maybeBar = skipMany $ sp <|> () <$ char '|' <|> () <$ (char '@' >> braced)
+ maybeBar
+ let cAlign = AlignCenter <$ char 'c'
+ let lAlign = AlignLeft <$ char 'l'
+ let rAlign = AlignRight <$ char 'r'
+ let parAlign = AlignLeft <$ (char 'p' >> braced)
+ let alignChar = cAlign <|> lAlign <|> rAlign <|> parAlign
+ let alignPrefix = char '>' >> braced
+ let alignSuffix = char '<' >> braced
+ let alignSpec = do
+ spaces
+ pref <- option "" alignPrefix
+ spaces
+ ch <- alignChar
+ spaces
+ suff <- option "" alignSuffix
+ return (pref, ch, suff)
+ aligns' <- sepEndBy alignSpec maybeBar
+ spaces
+ char '}'
+ spaces
+ return $ aligns'
+
+hline :: PandocMonad m => LP m ()
+hline = try $ do
+ spaces'
+ controlSeq "hline" <|>
+ -- booktabs rules:
+ controlSeq "toprule" <|>
+ controlSeq "bottomrule" <|>
+ controlSeq "midrule" <|>
+ controlSeq "endhead" <|>
+ controlSeq "endfirsthead"
+ spaces'
+ optional $ bracketed (many1 (satisfy (/=']')))
+ return ()
+
+lbreak :: PandocMonad m => LP m ()
+lbreak = () <$ try (spaces' *>
+ (controlSeq "\\" <|> controlSeq "tabularnewline") <*
+ spaces')
+
+amp :: PandocMonad m => LP m ()
+amp = () <$ try (spaces' *> char '&' <* spaces')
+
+parseTableRow :: PandocMonad m
+ => Int -- ^ number of columns
+ -> [String] -- ^ prefixes
+ -> [String] -- ^ suffixes
+ -> LP m [Blocks]
+parseTableRow cols prefixes suffixes = try $ do
+ let tableCellRaw = many (notFollowedBy
+ (amp <|> lbreak <|>
+ (() <$ try (string "\\end"))) >> anyChar)
+ let minipage = try $ controlSeq "begin" *> string "{minipage}" *>
+ env "minipage"
+ (skipopts *> spaces' *> optional braced *> spaces' *> blocks)
+ let tableCell = minipage <|>
+ ((plain . trimInlines . mconcat) <$> many inline)
+ rawcells <- sepBy1 tableCellRaw amp
+ guard $ length rawcells == cols
+ let rawcells' = zipWith3 (\c p s -> p ++ trim c ++ s)
+ rawcells prefixes suffixes
+ cells' <- mapM (parseFromString tableCell) rawcells'
+ let numcells = length cells'
+ guard $ numcells <= cols && numcells >= 1
+ guard $ cells' /= [mempty]
+ -- note: a & b in a three-column table leaves an empty 3rd cell:
+ let cells'' = cells' ++ replicate (cols - numcells) mempty
+ spaces'
+ return cells''
+
+spaces' :: PandocMonad m => LP m ()
+spaces' = spaces *> skipMany (comment *> spaces)
+
+simpTable :: PandocMonad m => Bool -> LP m Blocks
+simpTable hasWidthParameter = try $ do
+ when hasWidthParameter $ () <$ (spaces' >> tok)
+ skipopts
+ (prefixes, aligns, suffixes) <- unzip3 <$> parseAligns
+ let cols = length aligns
+ optional $ controlSeq "caption" *> skipopts *> setCaption
+ optional lbreak
+ spaces'
+ skipMany hline
+ spaces'
+ header' <- option [] $ try (parseTableRow cols prefixes suffixes <*
+ lbreak <* many1 hline)
+ spaces'
+ rows <- sepEndBy (parseTableRow cols prefixes suffixes)
+ (lbreak <* optional (skipMany hline))
+ spaces'
+ optional $ controlSeq "caption" *> skipopts *> setCaption
+ optional lbreak
+ spaces'
+ let header'' = if null header'
+ then replicate cols mempty
+ else header'
+ lookAhead $ controlSeq "end" -- make sure we're at end
+ return $ table mempty (zip aligns (repeat 0)) header'' rows
+
+removeDoubleQuotes :: String -> String
+removeDoubleQuotes ('"':xs) =
+ case reverse xs of
+ '"':ys -> reverse ys
+ _ -> '"':xs
+removeDoubleQuotes xs = xs
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
new file mode 100644
index 000000000..80a1cd7a2
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -0,0 +1,2119 @@
+{-# LANGUAGE RelaxedPolyRec #-} -- needed for inlinesBetween on GHC < 7
+{-# LANGUAGE ScopedTypeVariables #-}
+
+{-
+Copyright (C) 2006-2015 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.Markdown
+ Copyright : Copyright (C) 2006-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of markdown-formatted plain text to 'Pandoc' document.
+-}
+module Text.Pandoc.Readers.Markdown ( readMarkdown ) where
+
+import Data.List ( transpose, sortBy, findIndex, intercalate )
+import qualified Data.Map as M
+import Data.Scientific (coefficient, base10Exponent)
+import Data.Ord ( comparing )
+import Data.Char ( isSpace, isAlphaNum, toLower, isPunctuation )
+import Data.Maybe
+import Text.Pandoc.Definition
+import Text.Pandoc.Emoji (emojis)
+import Text.Pandoc.Generic (bottomUp)
+import qualified Data.Text as T
+import Data.Text (Text)
+import qualified Data.Yaml as Yaml
+import Data.Yaml (ParseException(..), YamlException(..), YamlMark(..))
+import qualified Data.HashMap.Strict as H
+import qualified Text.Pandoc.Builder as B
+import qualified Text.Pandoc.UTF8 as UTF8
+import qualified Data.Vector as V
+import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
+import Text.Pandoc.Options
+import Text.Pandoc.Logging
+import Text.Pandoc.Shared
+import Text.Pandoc.Pretty (charWidth)
+import Text.Pandoc.XML (fromEntities)
+import Text.Pandoc.Parsing hiding (tableWith)
+import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )
+import Text.Pandoc.Readers.HTML ( htmlTag, htmlInBalanced, isInlineTag, isBlockTag,
+ isTextTag, isCommentTag )
+import Control.Monad
+import System.FilePath (takeExtension, addExtension)
+import Text.HTML.TagSoup
+import Data.Monoid ((<>))
+import Control.Monad.Trans (lift)
+import Control.Monad.Except (throwError, catchError)
+import Text.Pandoc.Class (PandocMonad, report)
+
+type MarkdownParser m = ParserT [Char] ParserState m
+
+-- | Read markdown from an input string and return a Pandoc document.
+readMarkdown :: PandocMonad m
+ => ReaderOptions -- ^ Reader options
+ -> String -- ^ String to parse (assuming @'\n'@ line endings)
+ -> m Pandoc
+readMarkdown opts s = do
+ parsed <- (readWithM parseMarkdown) def{ stateOptions = opts } (s ++ "\n\n")
+ case parsed of
+ Right result -> return result
+ Left e -> throwError e
+
+trimInlinesF :: F Inlines -> F Inlines
+trimInlinesF = liftM trimInlines
+
+--
+-- Constants and data structure definitions
+--
+
+isBulletListMarker :: Char -> Bool
+isBulletListMarker '*' = True
+isBulletListMarker '+' = True
+isBulletListMarker '-' = True
+isBulletListMarker _ = False
+
+isHruleChar :: Char -> Bool
+isHruleChar '*' = True
+isHruleChar '-' = True
+isHruleChar '_' = True
+isHruleChar _ = False
+
+setextHChars :: String
+setextHChars = "=-"
+
+isBlank :: Char -> Bool
+isBlank ' ' = True
+isBlank '\t' = True
+isBlank '\n' = True
+isBlank _ = False
+
+--
+-- auxiliary functions
+--
+
+-- | Succeeds when we're in list context.
+inList :: PandocMonad m => MarkdownParser m ()
+inList = do
+ ctx <- stateParserContext <$> getState
+ guard (ctx == ListItemState)
+
+spnl :: PandocMonad m => ParserT [Char] st m ()
+spnl = try $ do
+ skipSpaces
+ optional newline
+ skipSpaces
+ notFollowedBy (char '\n')
+
+indentSpaces :: PandocMonad m => MarkdownParser m String
+indentSpaces = try $ do
+ tabStop <- getOption readerTabStop
+ count tabStop (char ' ') <|>
+ string "\t" <?> "indentation"
+
+nonindentSpaces :: PandocMonad m => MarkdownParser m String
+nonindentSpaces = do
+ tabStop <- getOption readerTabStop
+ sps <- many (char ' ')
+ if length sps < tabStop
+ then return sps
+ else unexpected "indented line"
+
+-- returns number of spaces parsed
+skipNonindentSpaces :: PandocMonad m => MarkdownParser m Int
+skipNonindentSpaces = do
+ tabStop <- getOption readerTabStop
+ atMostSpaces (tabStop - 1) <* notFollowedBy (char ' ')
+
+atMostSpaces :: PandocMonad m => Int -> MarkdownParser m Int
+atMostSpaces n
+ | n > 0 = (char ' ' >> (+1) <$> atMostSpaces (n-1)) <|> return 0
+ | otherwise = return 0
+
+litChar :: PandocMonad m => MarkdownParser m Char
+litChar = escapedChar'
+ <|> characterReference
+ <|> noneOf "\n"
+ <|> try (newline >> notFollowedBy blankline >> return ' ')
+
+-- | Parse a sequence of inline elements between square brackets,
+-- including inlines between balanced pairs of square brackets.
+inlinesInBalancedBrackets :: PandocMonad m => MarkdownParser m (F Inlines)
+inlinesInBalancedBrackets = do
+ char '['
+ (_, raw) <- withRaw $ charsInBalancedBrackets 1
+ guard $ not $ null raw
+ parseFromString (trimInlinesF . mconcat <$> many inline) (init raw)
+
+charsInBalancedBrackets :: PandocMonad m => Int -> MarkdownParser m ()
+charsInBalancedBrackets 0 = return ()
+charsInBalancedBrackets openBrackets =
+ (char '[' >> charsInBalancedBrackets (openBrackets + 1))
+ <|> (char ']' >> charsInBalancedBrackets (openBrackets - 1))
+ <|> (( (() <$ code)
+ <|> (() <$ (escapedChar'))
+ <|> (newline >> notFollowedBy blankline)
+ <|> skipMany1 (noneOf "[]`\n\\")
+ <|> (() <$ count 1 (oneOf "`\\"))
+ ) >> charsInBalancedBrackets openBrackets)
+
+--
+-- document structure
+--
+
+rawTitleBlockLine :: PandocMonad m => MarkdownParser m String
+rawTitleBlockLine = do
+ char '%'
+ skipSpaces
+ first <- anyLine
+ rest <- many $ try $ do spaceChar
+ notFollowedBy blankline
+ skipSpaces
+ anyLine
+ return $ trim $ unlines (first:rest)
+
+titleLine :: PandocMonad m => MarkdownParser m (F Inlines)
+titleLine = try $ do
+ raw <- rawTitleBlockLine
+ res <- parseFromString (many inline) raw
+ return $ trimInlinesF $ mconcat res
+
+authorsLine :: PandocMonad m => MarkdownParser m (F [Inlines])
+authorsLine = try $ do
+ raw <- rawTitleBlockLine
+ let sep = (char ';' <* spaces) <|> newline
+ let pAuthors = sepEndBy
+ (trimInlinesF . mconcat <$> many
+ (try $ notFollowedBy sep >> inline))
+ sep
+ sequence <$> parseFromString pAuthors raw
+
+dateLine :: PandocMonad m => MarkdownParser m (F Inlines)
+dateLine = try $ do
+ raw <- rawTitleBlockLine
+ res <- parseFromString (many inline) raw
+ return $ trimInlinesF $ mconcat res
+
+titleBlock :: PandocMonad m => MarkdownParser m ()
+titleBlock = pandocTitleBlock <|> mmdTitleBlock
+
+pandocTitleBlock :: PandocMonad m => MarkdownParser m ()
+pandocTitleBlock = try $ do
+ guardEnabled Ext_pandoc_title_block
+ lookAhead (char '%')
+ title <- option mempty titleLine
+ author <- option (return []) authorsLine
+ date <- option mempty dateLine
+ optional blanklines
+ let meta' = do title' <- title
+ author' <- author
+ date' <- date
+ return $
+ (if B.isNull title' then id else B.setMeta "title" title')
+ . (if null author' then id else B.setMeta "author" author')
+ . (if B.isNull date' then id else B.setMeta "date" date')
+ $ nullMeta
+ updateState $ \st -> st{ stateMeta' = stateMeta' st <> meta' }
+
+
+-- Adapted from solution at
+-- http://stackoverflow.com/a/29448764/1901888
+foldrWithKeyM :: Monad m => (k -> b -> a -> m a) -> a -> H.HashMap k b -> m a
+foldrWithKeyM f acc = H.foldrWithKey f' (return acc)
+ where
+ f' k b ma = ma >>= \a -> f k b a
+
+yamlMetaBlock :: PandocMonad m => MarkdownParser m (F Blocks)
+yamlMetaBlock = try $ do
+ guardEnabled Ext_yaml_metadata_block
+ pos <- getPosition
+ string "---"
+ blankline
+ notFollowedBy blankline -- if --- is followed by a blank it's an HRULE
+ rawYamlLines <- manyTill anyLine stopLine
+ -- by including --- and ..., we allow yaml blocks with just comments:
+ let rawYaml = unlines ("---" : (rawYamlLines ++ ["..."]))
+ optional blanklines
+ opts <- stateOptions <$> getState
+ meta' <- case Yaml.decodeEither' $ UTF8.fromString rawYaml of
+ Right (Yaml.Object hashmap) ->
+ foldrWithKeyM
+ (\k v m -> do
+ if ignorable k
+ then return m
+ else (do v' <- lift $ yamlToMeta opts v
+ return $ B.setMeta (T.unpack k) v' m)
+ `catchError`
+ (\_ -> return m)
+ ) nullMeta hashmap
+ Right Yaml.Null -> return nullMeta
+ Right _ -> do
+ logMessage $
+ CouldNotParseYamlMetadata "not an object"
+ pos
+ return nullMeta
+ Left err' -> do
+ case err' of
+ InvalidYaml (Just YamlParseException{
+ yamlProblem = problem
+ , yamlContext = _ctxt
+ , yamlProblemMark = Yaml.YamlMark {
+ yamlLine = yline
+ , yamlColumn = ycol
+ }}) ->
+ logMessage $ CouldNotParseYamlMetadata
+ problem (setSourceLine
+ (setSourceColumn pos
+ (sourceColumn pos + ycol))
+ (sourceLine pos + 1 + yline))
+ _ -> logMessage $ CouldNotParseYamlMetadata
+ (show err') pos
+ return nullMeta
+ updateState $ \st -> st{ stateMeta' = stateMeta' st <> (return meta') }
+ return mempty
+
+-- ignore fields ending with _
+ignorable :: Text -> Bool
+ignorable t = (T.pack "_") `T.isSuffixOf` t
+
+toMetaValue :: PandocMonad m => ReaderOptions -> Text -> m MetaValue
+toMetaValue opts x = toMeta <$> readMarkdown opts' (T.unpack x)
+ where
+ toMeta p =
+ case p of
+ Pandoc _ [Plain xs] -> MetaInlines xs
+ Pandoc _ [Para xs]
+ | endsWithNewline x -> MetaBlocks [Para xs]
+ | otherwise -> MetaInlines xs
+ Pandoc _ bs -> MetaBlocks bs
+ endsWithNewline t = T.pack "\n" `T.isSuffixOf` t
+ opts' = opts{readerExtensions =
+ disableExtension Ext_pandoc_title_block $
+ disableExtension Ext_mmd_title_block $
+ disableExtension Ext_yaml_metadata_block $
+ readerExtensions opts }
+
+yamlToMeta :: PandocMonad m => ReaderOptions -> Yaml.Value -> m MetaValue
+yamlToMeta opts (Yaml.String t) = toMetaValue opts t
+yamlToMeta _ (Yaml.Number n)
+ -- avoid decimal points for numbers that don't need them:
+ | base10Exponent n >= 0 = return $ MetaString $ show
+ $ coefficient n * (10 ^ base10Exponent n)
+ | otherwise = return $ MetaString $ show n
+yamlToMeta _ (Yaml.Bool b) = return $ MetaBool b
+yamlToMeta opts (Yaml.Array xs) = B.toMetaValue <$> mapM (yamlToMeta opts)
+ (V.toList xs)
+yamlToMeta opts (Yaml.Object o) = MetaMap <$> H.foldrWithKey (\k v m ->
+ if ignorable k
+ then m
+ else (do
+ v' <- yamlToMeta opts v
+ m' <- m
+ return (M.insert (T.unpack k) v' m')))
+ (return M.empty) o
+yamlToMeta _ _ = return $ MetaString ""
+
+stopLine :: PandocMonad m => MarkdownParser m ()
+stopLine = try $ (string "---" <|> string "...") >> blankline >> return ()
+
+mmdTitleBlock :: PandocMonad m => MarkdownParser m ()
+mmdTitleBlock = try $ do
+ guardEnabled Ext_mmd_title_block
+ firstPair <- kvPair False
+ restPairs <- many (kvPair True)
+ let kvPairs = firstPair : restPairs
+ blanklines
+ updateState $ \st -> st{ stateMeta' = stateMeta' st <>
+ return (Meta $ M.fromList kvPairs) }
+
+kvPair :: PandocMonad m => Bool -> MarkdownParser m (String, MetaValue)
+kvPair allowEmpty = try $ do
+ key <- many1Till (alphaNum <|> oneOf "_- ") (char ':')
+ val <- trim <$> manyTill anyChar
+ (try $ newline >> lookAhead (blankline <|> nonspaceChar))
+ guard $ allowEmpty || not (null val)
+ let key' = concat $ words $ map toLower key
+ let val' = MetaBlocks $ B.toList $ B.plain $ B.text $ val
+ return (key',val')
+
+parseMarkdown :: PandocMonad m => MarkdownParser m Pandoc
+parseMarkdown = do
+ optional titleBlock
+ blocks <- parseBlocks
+ st <- getState
+ let meta = runF (stateMeta' st) st
+ let Pandoc _ bs = B.doc $ runF blocks st
+ eastAsianLineBreaks <- option False $
+ True <$ guardEnabled Ext_east_asian_line_breaks
+ reportLogMessages
+ return $ (if eastAsianLineBreaks
+ then bottomUp softBreakFilter
+ else id) $ Pandoc meta bs
+
+softBreakFilter :: [Inline] -> [Inline]
+softBreakFilter (x:SoftBreak:y:zs) =
+ case (stringify x, stringify y) of
+ (xs@(_:_), (c:_))
+ | charWidth (last xs) == 2 && charWidth c == 2 -> x:y:zs
+ _ -> x:SoftBreak:y:zs
+softBreakFilter xs = xs
+
+referenceKey :: PandocMonad m => MarkdownParser m (F Blocks)
+referenceKey = try $ do
+ pos <- getPosition
+ skipNonindentSpaces
+ (_,raw) <- reference
+ char ':'
+ skipSpaces >> optional newline >> skipSpaces >> notFollowedBy (char '[')
+ let sourceURL = liftM unwords $ many $ try $ do
+ skipMany spaceChar
+ notFollowedBy' referenceTitle
+ notFollowedBy' $ guardEnabled Ext_link_attributes >> attributes
+ notFollowedBy' (() <$ reference)
+ many1 $ notFollowedBy space >> litChar
+ let betweenAngles = try $ char '<' >> manyTill litChar (char '>')
+ src <- try betweenAngles <|> sourceURL
+ tit <- option "" referenceTitle
+ attr <- option nullAttr $ try $
+ guardEnabled Ext_link_attributes >> skipSpaces >> attributes
+ addKvs <- option [] $ guardEnabled Ext_mmd_link_attributes
+ >> many (try $ spnl >> keyValAttr)
+ blanklines
+ let attr' = extractIdClass $ foldl (\x f -> f x) attr addKvs
+ target = (escapeURI $ trimr src, tit)
+ st <- getState
+ let oldkeys = stateKeys st
+ let key = toKey raw
+ case M.lookup key oldkeys of
+ Just _ -> logMessage $ DuplicateLinkReference raw pos
+ Nothing -> return ()
+ updateState $ \s -> s { stateKeys = M.insert key (target, attr') oldkeys }
+ return $ return mempty
+
+referenceTitle :: PandocMonad m => MarkdownParser m String
+referenceTitle = try $ do
+ skipSpaces >> optional newline >> skipSpaces
+ quotedTitle '"' <|> quotedTitle '\'' <|> charsInBalanced '(' ')' litChar
+
+-- A link title in quotes
+quotedTitle :: PandocMonad m => Char -> MarkdownParser m String
+quotedTitle c = try $ do
+ char c
+ notFollowedBy spaces
+ let pEnder = try $ char c >> notFollowedBy (satisfy isAlphaNum)
+ let regChunk = many1 (noneOf ['\\','\n','&',c]) <|> count 1 litChar
+ let nestedChunk = (\x -> [c] ++ x ++ [c]) <$> quotedTitle c
+ unwords . words . concat <$> manyTill (nestedChunk <|> regChunk) pEnder
+
+-- | PHP Markdown Extra style abbreviation key. Currently
+-- we just skip them, since Pandoc doesn't have an element for
+-- an abbreviation.
+abbrevKey :: PandocMonad m => MarkdownParser m (F Blocks)
+abbrevKey = do
+ guardEnabled Ext_abbreviations
+ try $ do
+ char '*'
+ reference
+ char ':'
+ skipMany (satisfy (/= '\n'))
+ blanklines
+ return $ return mempty
+
+noteMarker :: PandocMonad m => MarkdownParser m String
+noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']')
+
+rawLine :: PandocMonad m => MarkdownParser m String
+rawLine = try $ do
+ notFollowedBy blankline
+ notFollowedBy' $ try $ skipNonindentSpaces >> noteMarker
+ optional indentSpaces
+ anyLine
+
+rawLines :: PandocMonad m => MarkdownParser m String
+rawLines = do
+ first <- anyLine
+ rest <- many rawLine
+ return $ unlines (first:rest)
+
+noteBlock :: PandocMonad m => MarkdownParser m (F Blocks)
+noteBlock = try $ do
+ pos <- getPosition
+ skipNonindentSpaces
+ ref <- noteMarker
+ char ':'
+ optional blankline
+ optional indentSpaces
+ first <- rawLines
+ rest <- many $ try $ blanklines >> indentSpaces >> rawLines
+ let raw = unlines (first:rest) ++ "\n"
+ optional blanklines
+ parsed <- parseFromString parseBlocks raw
+ let newnote = (ref, parsed)
+ oldnotes <- stateNotes' <$> getState
+ case lookup ref oldnotes of
+ Just _ -> logMessage $ DuplicateNoteReference ref pos
+ Nothing -> return ()
+ updateState $ \s -> s { stateNotes' = newnote : oldnotes }
+ return mempty
+
+--
+-- parsing blocks
+--
+
+parseBlocks :: PandocMonad m => MarkdownParser m (F Blocks)
+parseBlocks = mconcat <$> manyTill block eof
+
+block :: PandocMonad m => MarkdownParser m (F Blocks)
+block = do
+ pos <- getPosition
+ res <- choice [ mempty <$ blanklines
+ , codeBlockFenced
+ , yamlMetaBlock
+ -- note: bulletList needs to be before header because of
+ -- the possibility of empty list items: -
+ , bulletList
+ , header
+ , lhsCodeBlock
+ , divHtml
+ , htmlBlock
+ , table
+ , codeBlockIndented
+ , guardEnabled Ext_latex_macros *> (macro >>= return . return)
+ , rawTeXBlock
+ , lineBlock
+ , blockQuote
+ , hrule
+ , orderedList
+ , definitionList
+ , noteBlock
+ , referenceKey
+ , abbrevKey
+ , para
+ , plain
+ ] <?> "block"
+ report $ ParsingTrace
+ (take 60 $ show $ B.toList $ runF res defaultParserState) pos
+ return res
+
+--
+-- header blocks
+--
+
+header :: PandocMonad m => MarkdownParser m (F Blocks)
+header = setextHeader <|> atxHeader <?> "header"
+
+atxChar :: PandocMonad m => MarkdownParser m Char
+atxChar = do
+ exts <- getOption readerExtensions
+ return $ if extensionEnabled Ext_literate_haskell exts
+ then '='
+ else '#'
+
+atxHeader :: PandocMonad m => MarkdownParser m (F Blocks)
+atxHeader = try $ do
+ level <- atxChar >>= many1 . char >>= return . length
+ notFollowedBy $ guardEnabled Ext_fancy_lists >>
+ (char '.' <|> char ')') -- this would be a list
+ skipSpaces
+ (text, raw) <- withRaw $
+ trimInlinesF . mconcat <$> many (notFollowedBy atxClosing >> inline)
+ attr <- atxClosing
+ attr' <- registerHeader attr (runF text defaultParserState)
+ guardDisabled Ext_implicit_header_references
+ <|> registerImplicitHeader raw attr'
+ return $ B.headerWith attr' level <$> text
+
+atxClosing :: PandocMonad m => MarkdownParser m Attr
+atxClosing = try $ do
+ attr' <- option nullAttr
+ (guardEnabled Ext_mmd_header_identifiers >> mmdHeaderIdentifier)
+ skipMany . char =<< atxChar
+ skipSpaces
+ attr <- option attr'
+ (guardEnabled Ext_header_attributes >> attributes)
+ blanklines
+ return attr
+
+setextHeaderEnd :: PandocMonad m => MarkdownParser m Attr
+setextHeaderEnd = try $ do
+ attr <- option nullAttr
+ $ (guardEnabled Ext_mmd_header_identifiers >> mmdHeaderIdentifier)
+ <|> (guardEnabled Ext_header_attributes >> attributes)
+ blanklines
+ return attr
+
+mmdHeaderIdentifier :: PandocMonad m => MarkdownParser m Attr
+mmdHeaderIdentifier = do
+ ident <- stripFirstAndLast . snd <$> reference
+ skipSpaces
+ return (ident,[],[])
+
+setextHeader :: PandocMonad m => MarkdownParser m (F Blocks)
+setextHeader = try $ do
+ -- This lookahead prevents us from wasting time parsing Inlines
+ -- unless necessary -- it gives a significant performance boost.
+ lookAhead $ anyLine >> many1 (oneOf setextHChars) >> blankline
+ skipSpaces
+ (text, raw) <- withRaw $
+ trimInlinesF . mconcat <$> many1 (notFollowedBy setextHeaderEnd >> inline)
+ attr <- setextHeaderEnd
+ underlineChar <- oneOf setextHChars
+ many (char underlineChar)
+ blanklines
+ let level = (fromMaybe 0 $ findIndex (== underlineChar) setextHChars) + 1
+ attr' <- registerHeader attr (runF text defaultParserState)
+ guardDisabled Ext_implicit_header_references
+ <|> registerImplicitHeader raw attr'
+ return $ B.headerWith attr' level <$> text
+
+registerImplicitHeader :: PandocMonad m => String -> Attr -> MarkdownParser m ()
+registerImplicitHeader raw attr@(ident, _, _) = do
+ let key = toKey $ "[" ++ raw ++ "]"
+ updateState (\s -> s { stateHeaderKeys =
+ M.insert key (('#':ident,""), attr) (stateHeaderKeys s) })
+
+--
+-- hrule block
+--
+
+hrule :: PandocMonad m => ParserT [Char] st m (F Blocks)
+hrule = try $ do
+ skipSpaces
+ start <- satisfy isHruleChar
+ count 2 (skipSpaces >> char start)
+ skipMany (spaceChar <|> char start)
+ newline
+ optional blanklines
+ return $ return B.horizontalRule
+
+--
+-- code blocks
+--
+
+indentedLine :: PandocMonad m => MarkdownParser m String
+indentedLine = indentSpaces >> anyLine >>= return . (++ "\n")
+
+blockDelimiter :: PandocMonad m
+ => (Char -> Bool)
+ -> Maybe Int
+ -> ParserT [Char] st m Int
+blockDelimiter f len = try $ do
+ c <- lookAhead (satisfy f)
+ case len of
+ Just l -> count l (char c) >> many (char c) >> return l
+ Nothing -> count 3 (char c) >> many (char c) >>=
+ return . (+ 3) . length
+
+attributes :: PandocMonad m => MarkdownParser m Attr
+attributes = try $ do
+ char '{'
+ spnl
+ attrs <- many (attribute <* spnl)
+ char '}'
+ return $ foldl (\x f -> f x) nullAttr attrs
+
+attribute :: PandocMonad m => MarkdownParser m (Attr -> Attr)
+attribute = identifierAttr <|> classAttr <|> keyValAttr <|> specialAttr
+
+identifier :: PandocMonad m => MarkdownParser m String
+identifier = do
+ first <- letter
+ rest <- many $ alphaNum <|> oneOf "-_:."
+ return (first:rest)
+
+identifierAttr :: PandocMonad m => MarkdownParser m (Attr -> Attr)
+identifierAttr = try $ do
+ char '#'
+ result <- identifier
+ return $ \(_,cs,kvs) -> (result,cs,kvs)
+
+classAttr :: PandocMonad m => MarkdownParser m (Attr -> Attr)
+classAttr = try $ do
+ char '.'
+ result <- identifier
+ return $ \(id',cs,kvs) -> (id',cs ++ [result],kvs)
+
+keyValAttr :: PandocMonad m => MarkdownParser m (Attr -> Attr)
+keyValAttr = try $ do
+ key <- identifier
+ char '='
+ val <- enclosed (char '"') (char '"') litChar
+ <|> enclosed (char '\'') (char '\'') litChar
+ <|> many (escapedChar' <|> noneOf " \t\n\r}")
+ return $ \(id',cs,kvs) ->
+ case key of
+ "id" -> (val,cs,kvs)
+ "class" -> (id',cs ++ words val,kvs)
+ _ -> (id',cs,kvs ++ [(key,val)])
+
+specialAttr :: PandocMonad m => MarkdownParser m (Attr -> Attr)
+specialAttr = do
+ char '-'
+ return $ \(id',cs,kvs) -> (id',cs ++ ["unnumbered"],kvs)
+
+codeBlockFenced :: PandocMonad m => MarkdownParser m (F Blocks)
+codeBlockFenced = try $ do
+ c <- try (guardEnabled Ext_fenced_code_blocks >> lookAhead (char '~'))
+ <|> (guardEnabled Ext_backtick_code_blocks >> lookAhead (char '`'))
+ size <- blockDelimiter (== c) Nothing
+ skipMany spaceChar
+ attr <- option ([],[],[]) $
+ try (guardEnabled Ext_fenced_code_attributes >> attributes)
+ <|> ((\x -> ("",[toLanguageId x],[])) <$> many1 nonspaceChar)
+ blankline
+ contents <- manyTill anyLine (blockDelimiter (== c) (Just size))
+ blanklines
+ return $ return $ B.codeBlockWith attr $ intercalate "\n" contents
+
+-- correctly handle github language identifiers
+toLanguageId :: String -> String
+toLanguageId = map toLower . go
+ where go "c++" = "cpp"
+ go "objective-c" = "objectivec"
+ go x = x
+
+codeBlockIndented :: PandocMonad m => MarkdownParser m (F Blocks)
+codeBlockIndented = do
+ contents <- many1 (indentedLine <|>
+ try (do b <- blanklines
+ l <- indentedLine
+ return $ b ++ l))
+ optional blanklines
+ classes <- getOption readerIndentedCodeClasses
+ return $ return $ B.codeBlockWith ("", classes, []) $
+ stripTrailingNewlines $ concat contents
+
+lhsCodeBlock :: PandocMonad m => MarkdownParser m (F Blocks)
+lhsCodeBlock = do
+ guardEnabled Ext_literate_haskell
+ (return . B.codeBlockWith ("",["sourceCode","literate","haskell"],[]) <$>
+ (lhsCodeBlockBird <|> lhsCodeBlockLaTeX))
+ <|> (return . B.codeBlockWith ("",["sourceCode","haskell"],[]) <$>
+ lhsCodeBlockInverseBird)
+
+lhsCodeBlockLaTeX :: PandocMonad m => MarkdownParser m String
+lhsCodeBlockLaTeX = try $ do
+ string "\\begin{code}"
+ manyTill spaceChar newline
+ contents <- many1Till anyChar (try $ string "\\end{code}")
+ blanklines
+ return $ stripTrailingNewlines contents
+
+lhsCodeBlockBird :: PandocMonad m => MarkdownParser m String
+lhsCodeBlockBird = lhsCodeBlockBirdWith '>'
+
+lhsCodeBlockInverseBird :: PandocMonad m => MarkdownParser m String
+lhsCodeBlockInverseBird = lhsCodeBlockBirdWith '<'
+
+lhsCodeBlockBirdWith :: PandocMonad m => Char -> MarkdownParser m String
+lhsCodeBlockBirdWith c = try $ do
+ pos <- getPosition
+ when (sourceColumn pos /= 1) $ fail "Not in first column"
+ lns <- many1 $ birdTrackLine c
+ -- if (as is normal) there is always a space after >, drop it
+ let lns' = if all (\ln -> null ln || take 1 ln == " ") lns
+ then map (drop 1) lns
+ else lns
+ blanklines
+ return $ intercalate "\n" lns'
+
+birdTrackLine :: PandocMonad m => Char -> ParserT [Char] st m String
+birdTrackLine c = try $ do
+ char c
+ -- allow html tags on left margin:
+ when (c == '<') $ notFollowedBy letter
+ anyLine
+
+--
+-- block quotes
+--
+
+emailBlockQuoteStart :: PandocMonad m => MarkdownParser m Char
+emailBlockQuoteStart = try $ skipNonindentSpaces >> char '>' <* optional (char ' ')
+
+emailBlockQuote :: PandocMonad m => MarkdownParser m [String]
+emailBlockQuote = try $ do
+ emailBlockQuoteStart
+ let emailLine = many $ nonEndline <|> try
+ (endline >> notFollowedBy emailBlockQuoteStart >>
+ return '\n')
+ let emailSep = try (newline >> emailBlockQuoteStart)
+ first <- emailLine
+ rest <- many $ try $ emailSep >> emailLine
+ let raw = first:rest
+ newline <|> (eof >> return '\n')
+ optional blanklines
+ return raw
+
+blockQuote :: PandocMonad m => MarkdownParser m (F Blocks)
+blockQuote = do
+ raw <- emailBlockQuote
+ -- parse the extracted block, which may contain various block elements:
+ contents <- parseFromString parseBlocks $ (intercalate "\n" raw) ++ "\n\n"
+ return $ B.blockQuote <$> contents
+
+--
+-- list blocks
+--
+
+bulletListStart :: PandocMonad m => MarkdownParser m ()
+bulletListStart = try $ do
+ optional newline -- if preceded by a Plain block in a list context
+ startpos <- sourceColumn <$> getPosition
+ skipNonindentSpaces
+ notFollowedBy' (() <$ hrule) -- because hrules start out just like lists
+ satisfy isBulletListMarker
+ endpos <- sourceColumn <$> getPosition
+ tabStop <- getOption readerTabStop
+ lookAhead (newline <|> spaceChar)
+ () <$ atMostSpaces (tabStop - (endpos - startpos))
+
+anyOrderedListStart :: PandocMonad m => MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
+anyOrderedListStart = try $ do
+ optional newline -- if preceded by a Plain block in a list context
+ startpos <- sourceColumn <$> getPosition
+ skipNonindentSpaces
+ notFollowedBy $ string "p." >> spaceChar >> digit -- page number
+ res <- do guardDisabled Ext_fancy_lists
+ start <- many1 digit >>= safeRead
+ char '.'
+ return (start, DefaultStyle, DefaultDelim)
+ <|> do (num, style, delim) <- anyOrderedListMarker
+ -- if it could be an abbreviated first name,
+ -- insist on more than one space
+ when (delim == Period && (style == UpperAlpha ||
+ (style == UpperRoman &&
+ num `elem` [1, 5, 10, 50, 100, 500, 1000]))) $
+ () <$ spaceChar
+ return (num, style, delim)
+ endpos <- sourceColumn <$> getPosition
+ tabStop <- getOption readerTabStop
+ lookAhead (newline <|> spaceChar)
+ atMostSpaces (tabStop - (endpos - startpos))
+ return res
+
+listStart :: PandocMonad m => MarkdownParser m ()
+listStart = bulletListStart <|> (anyOrderedListStart >> return ())
+
+listLine :: PandocMonad m => MarkdownParser m String
+listLine = try $ do
+ notFollowedBy' (do indentSpaces
+ many spaceChar
+ listStart)
+ notFollowedByHtmlCloser
+ optional (() <$ indentSpaces)
+ listLineCommon
+
+listLineCommon :: PandocMonad m => MarkdownParser m String
+listLineCommon = concat <$> manyTill
+ ( many1 (satisfy $ \c -> c /= '\n' && c /= '<')
+ <|> liftM snd (htmlTag isCommentTag)
+ <|> count 1 anyChar
+ ) newline
+
+-- parse raw text for one list item, excluding start marker and continuations
+rawListItem :: PandocMonad m
+ => MarkdownParser m a
+ -> MarkdownParser m String
+rawListItem start = try $ do
+ start
+ first <- listLineCommon
+ rest <- many (notFollowedBy listStart >> notFollowedBy blankline >> listLine)
+ blanks <- many blankline
+ return $ unlines (first:rest) ++ blanks
+
+-- continuation of a list item - indented and separated by blankline
+-- or (in compact lists) endline.
+-- note: nested lists are parsed as continuations
+listContinuation :: PandocMonad m => MarkdownParser m String
+listContinuation = try $ do
+ lookAhead indentSpaces
+ result <- many1 listContinuationLine
+ blanks <- many blankline
+ return $ concat result ++ blanks
+
+notFollowedByHtmlCloser :: PandocMonad m => MarkdownParser m ()
+notFollowedByHtmlCloser = do
+ inHtmlBlock <- stateInHtmlBlock <$> getState
+ case inHtmlBlock of
+ Just t -> notFollowedBy' $ htmlTag (~== TagClose t)
+ Nothing -> return ()
+
+listContinuationLine :: PandocMonad m => MarkdownParser m String
+listContinuationLine = try $ do
+ notFollowedBy blankline
+ notFollowedBy' listStart
+ notFollowedByHtmlCloser
+ optional indentSpaces
+ result <- anyLine
+ return $ result ++ "\n"
+
+listItem :: PandocMonad m
+ => MarkdownParser m a
+ -> MarkdownParser m (F Blocks)
+listItem start = try $ do
+ first <- rawListItem start
+ continuations <- many listContinuation
+ -- parsing with ListItemState forces markers at beginning of lines to
+ -- count as list item markers, even if not separated by blank space.
+ -- see definition of "endline"
+ state <- getState
+ let oldContext = stateParserContext state
+ setState $ state {stateParserContext = ListItemState}
+ -- parse the extracted block, which may contain various block elements:
+ let raw = concat (first:continuations)
+ contents <- parseFromString parseBlocks raw
+ updateState (\st -> st {stateParserContext = oldContext})
+ return contents
+
+orderedList :: PandocMonad m => MarkdownParser m (F Blocks)
+orderedList = try $ do
+ (start, style, delim) <- lookAhead anyOrderedListStart
+ unless (style `elem` [DefaultStyle, Decimal, Example] &&
+ delim `elem` [DefaultDelim, Period]) $
+ guardEnabled Ext_fancy_lists
+ when (style == Example) $ guardEnabled Ext_example_lists
+ items <- fmap sequence $ many1 $ listItem
+ ( try $ do
+ optional newline -- if preceded by Plain block in a list
+ startpos <- sourceColumn <$> getPosition
+ skipNonindentSpaces
+ res <- orderedListMarker style delim
+ endpos <- sourceColumn <$> getPosition
+ tabStop <- getOption readerTabStop
+ lookAhead (newline <|> spaceChar)
+ atMostSpaces (tabStop - (endpos - startpos))
+ return res )
+ start' <- option 1 $ guardEnabled Ext_startnum >> return start
+ return $ B.orderedListWith (start', style, delim) <$> fmap compactify items
+
+bulletList :: PandocMonad m => MarkdownParser m (F Blocks)
+bulletList = do
+ items <- fmap sequence $ many1 $ listItem bulletListStart
+ return $ B.bulletList <$> fmap compactify items
+
+-- definition lists
+
+defListMarker :: PandocMonad m => MarkdownParser m ()
+defListMarker = do
+ sps <- nonindentSpaces
+ char ':' <|> char '~'
+ tabStop <- getOption readerTabStop
+ let remaining = tabStop - (length sps + 1)
+ if remaining > 0
+ then try (count remaining (char ' ')) <|> string "\t" <|> many1 spaceChar
+ else mzero
+ return ()
+
+definitionListItem :: PandocMonad m => Bool -> MarkdownParser m (F (Inlines, [Blocks]))
+definitionListItem compact = try $ do
+ rawLine' <- anyLine
+ raw <- many1 $ defRawBlock compact
+ term <- parseFromString (trimInlinesF . mconcat <$> many inline) rawLine'
+ contents <- mapM (parseFromString parseBlocks . (++"\n")) raw
+ optional blanklines
+ return $ liftM2 (,) term (sequence contents)
+
+defRawBlock :: PandocMonad m => Bool -> MarkdownParser m String
+defRawBlock compact = try $ do
+ hasBlank <- option False $ blankline >> return True
+ defListMarker
+ firstline <- anyLine
+ let dline = try
+ ( do notFollowedBy blankline
+ notFollowedByHtmlCloser
+ if compact -- laziness not compatible with compact
+ then () <$ indentSpaces
+ else (() <$ indentSpaces)
+ <|> notFollowedBy defListMarker
+ anyLine )
+ rawlines <- many dline
+ cont <- liftM concat $ many $ try $ do
+ trailing <- option "" blanklines
+ ln <- indentSpaces >> notFollowedBy blankline >> anyLine
+ lns <- many dline
+ return $ trailing ++ unlines (ln:lns)
+ return $ trimr (firstline ++ "\n" ++ unlines rawlines ++ cont) ++
+ if hasBlank || not (null cont) then "\n\n" else ""
+
+definitionList :: PandocMonad m => MarkdownParser m (F Blocks)
+definitionList = try $ do
+ lookAhead (anyLine >>
+ optional (blankline >> notFollowedBy (table >> return ())) >>
+ -- don't capture table caption as def list!
+ defListMarker)
+ compactDefinitionList <|> normalDefinitionList
+
+compactDefinitionList :: PandocMonad m => MarkdownParser m (F Blocks)
+compactDefinitionList = do
+ guardEnabled Ext_compact_definition_lists
+ items <- fmap sequence $ many1 $ definitionListItem True
+ return $ B.definitionList <$> fmap compactifyDL items
+
+normalDefinitionList :: PandocMonad m => MarkdownParser m (F Blocks)
+normalDefinitionList = do
+ guardEnabled Ext_definition_lists
+ items <- fmap sequence $ many1 $ definitionListItem False
+ return $ B.definitionList <$> items
+
+--
+-- paragraph block
+--
+
+para :: PandocMonad m => MarkdownParser m (F Blocks)
+para = try $ do
+ exts <- getOption readerExtensions
+ result <- trimInlinesF . mconcat <$> many1 inline
+ option (B.plain <$> result)
+ $ try $ do
+ newline
+ (blanklines >> return mempty)
+ <|> (guardDisabled Ext_blank_before_blockquote >> () <$ lookAhead blockQuote)
+ <|> (guardEnabled Ext_backtick_code_blocks >> () <$ lookAhead codeBlockFenced)
+ <|> (guardDisabled Ext_blank_before_header >> () <$ lookAhead header)
+ <|> (guardEnabled Ext_lists_without_preceding_blankline >>
+ -- Avoid creating a paragraph in a nested list.
+ notFollowedBy' inList >>
+ () <$ lookAhead listStart)
+ <|> do guardEnabled Ext_native_divs
+ inHtmlBlock <- stateInHtmlBlock <$> getState
+ case inHtmlBlock of
+ Just "div" -> () <$
+ lookAhead (htmlTag (~== TagClose "div"))
+ _ -> mzero
+ return $ do
+ result' <- result
+ case B.toList result' of
+ [Image attr alt (src,tit)]
+ | Ext_implicit_figures `extensionEnabled` exts ->
+ -- the fig: at beginning of title indicates a figure
+ return $ B.para $ B.singleton
+ $ Image attr alt (src,'f':'i':'g':':':tit)
+ _ -> return $ B.para result'
+
+plain :: PandocMonad m => MarkdownParser m (F Blocks)
+plain = fmap B.plain . trimInlinesF . mconcat <$> many1 inline
+
+--
+-- raw html
+--
+
+htmlElement :: PandocMonad m => MarkdownParser m String
+htmlElement = rawVerbatimBlock
+ <|> strictHtmlBlock
+ <|> liftM snd (htmlTag isBlockTag)
+
+htmlBlock :: PandocMonad m => MarkdownParser m (F Blocks)
+htmlBlock = do
+ guardEnabled Ext_raw_html
+ try (do
+ (TagOpen t attrs) <- lookAhead $ fst <$> htmlTag isBlockTag
+ (guard (t `elem` ["pre","style","script"]) >>
+ (return . B.rawBlock "html") <$> rawVerbatimBlock)
+ <|> (do guardEnabled Ext_markdown_attribute
+ oldMarkdownAttribute <- stateMarkdownAttribute <$> getState
+ markdownAttribute <-
+ case lookup "markdown" attrs of
+ Just "0" -> False <$ updateState (\st -> st{
+ stateMarkdownAttribute = False })
+ Just _ -> True <$ updateState (\st -> st{
+ stateMarkdownAttribute = True })
+ Nothing -> return oldMarkdownAttribute
+ res <- if markdownAttribute
+ then rawHtmlBlocks
+ else htmlBlock'
+ updateState $ \st -> st{ stateMarkdownAttribute =
+ oldMarkdownAttribute }
+ return res)
+ <|> (guardEnabled Ext_markdown_in_html_blocks >> rawHtmlBlocks))
+ <|> htmlBlock'
+
+htmlBlock' :: PandocMonad m => MarkdownParser m (F Blocks)
+htmlBlock' = try $ do
+ first <- htmlElement
+ skipMany spaceChar
+ optional blanklines
+ return $ return $ B.rawBlock "html" first
+
+strictHtmlBlock :: PandocMonad m => MarkdownParser m String
+strictHtmlBlock = htmlInBalanced (not . isInlineTag)
+
+rawVerbatimBlock :: PandocMonad m => MarkdownParser m String
+rawVerbatimBlock = htmlInBalanced isVerbTag
+ where isVerbTag (TagOpen "pre" _) = True
+ isVerbTag (TagOpen "style" _) = True
+ isVerbTag (TagOpen "script" _) = True
+ isVerbTag _ = False
+
+rawTeXBlock :: PandocMonad m => MarkdownParser m (F Blocks)
+rawTeXBlock = do
+ guardEnabled Ext_raw_tex
+ result <- (B.rawBlock "latex" . concat <$>
+ rawLaTeXBlock `sepEndBy1` blankline)
+ <|> (B.rawBlock "context" . concat <$>
+ rawConTeXtEnvironment `sepEndBy1` blankline)
+ spaces
+ return $ return result
+
+rawHtmlBlocks :: PandocMonad m => MarkdownParser m (F Blocks)
+rawHtmlBlocks = do
+ (TagOpen tagtype _, raw) <- htmlTag isBlockTag
+ -- try to find closing tag
+ -- we set stateInHtmlBlock so that closing tags that can be either block or
+ -- inline will not be parsed as inline tags
+ oldInHtmlBlock <- stateInHtmlBlock <$> getState
+ updateState $ \st -> st{ stateInHtmlBlock = Just tagtype }
+ let closer = htmlTag (\x -> x ~== TagClose tagtype)
+ contents <- mconcat <$> many (notFollowedBy' closer >> block)
+ result <-
+ (closer >>= \(_, rawcloser) -> return (
+ return (B.rawBlock "html" $ stripMarkdownAttribute raw) <>
+ contents <>
+ return (B.rawBlock "html" rawcloser)))
+ <|> return (return (B.rawBlock "html" raw) <> contents)
+ updateState $ \st -> st{ stateInHtmlBlock = oldInHtmlBlock }
+ return result
+
+-- remove markdown="1" attribute
+stripMarkdownAttribute :: String -> String
+stripMarkdownAttribute s = renderTags' $ map filterAttrib $ parseTags s
+ where filterAttrib (TagOpen t as) = TagOpen t
+ [(k,v) | (k,v) <- as, k /= "markdown"]
+ filterAttrib x = x
+
+--
+-- line block
+--
+
+lineBlock :: PandocMonad m => MarkdownParser m (F Blocks)
+lineBlock = try $ do
+ guardEnabled Ext_line_blocks
+ lines' <- lineBlockLines >>=
+ mapM (parseFromString (trimInlinesF . mconcat <$> many inline))
+ return $ B.lineBlock <$> sequence lines'
+
+--
+-- Tables
+--
+
+-- Parse a dashed line with optional trailing spaces; return its length
+-- and the length including trailing space.
+dashedLine :: PandocMonad m
+ => Char
+ -> ParserT [Char] st m (Int, Int)
+dashedLine ch = do
+ dashes <- many1 (char ch)
+ sp <- many spaceChar
+ let lengthDashes = length dashes
+ lengthSp = length sp
+ return (lengthDashes, lengthDashes + lengthSp)
+
+-- Parse a table header with dashed lines of '-' preceded by
+-- one (or zero) line of text.
+simpleTableHeader :: PandocMonad m
+ => Bool -- ^ Headerless table
+ -> MarkdownParser m (F [Blocks], [Alignment], [Int])
+simpleTableHeader headless = try $ do
+ rawContent <- if headless
+ then return ""
+ else anyLine
+ initSp <- nonindentSpaces
+ dashes <- many1 (dashedLine '-')
+ newline
+ let (lengths, lines') = unzip dashes
+ let indices = scanl (+) (length initSp) lines'
+ -- If no header, calculate alignment on basis of first row of text
+ rawHeads <- liftM (tail . splitStringByIndices (init indices)) $
+ if headless
+ then lookAhead anyLine
+ else return rawContent
+ let aligns = zipWith alignType (map (\a -> [a]) rawHeads) lengths
+ let rawHeads' = if headless
+ then replicate (length dashes) ""
+ else rawHeads
+ heads <- fmap sequence
+ $ mapM (parseFromString (mconcat <$> many plain))
+ $ map trim rawHeads'
+ return (heads, aligns, indices)
+
+-- Returns an alignment type for a table, based on a list of strings
+-- (the rows of the column header) and a number (the length of the
+-- dashed line under the rows.
+alignType :: [String]
+ -> Int
+ -> Alignment
+alignType [] _ = AlignDefault
+alignType strLst len =
+ let nonempties = filter (not . null) $ map trimr strLst
+ (leftSpace, rightSpace) =
+ case sortBy (comparing length) nonempties of
+ (x:_) -> (head x `elem` " \t", length x < len)
+ [] -> (False, False)
+ in case (leftSpace, rightSpace) of
+ (True, False) -> AlignRight
+ (False, True) -> AlignLeft
+ (True, True) -> AlignCenter
+ (False, False) -> AlignDefault
+
+-- Parse a table footer - dashed lines followed by blank line.
+tableFooter :: PandocMonad m => MarkdownParser m String
+tableFooter = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> blanklines
+
+-- Parse a table separator - dashed line.
+tableSep :: PandocMonad m => MarkdownParser m Char
+tableSep = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> char '\n'
+
+-- Parse a raw line and split it into chunks by indices.
+rawTableLine :: PandocMonad m
+ => [Int]
+ -> MarkdownParser m [String]
+rawTableLine indices = do
+ notFollowedBy' (blanklines <|> tableFooter)
+ line <- many1Till anyChar newline
+ return $ map trim $ tail $
+ splitStringByIndices (init indices) line
+
+-- Parse a table line and return a list of lists of blocks (columns).
+tableLine :: PandocMonad m
+ => [Int]
+ -> MarkdownParser m (F [Blocks])
+tableLine indices = rawTableLine indices >>=
+ fmap sequence . mapM (parseFromString (mconcat <$> many plain))
+
+-- Parse a multiline table row and return a list of blocks (columns).
+multilineRow :: PandocMonad m
+ => [Int]
+ -> MarkdownParser m (F [Blocks])
+multilineRow indices = do
+ colLines <- many1 (rawTableLine indices)
+ let cols = map unlines $ transpose colLines
+ fmap sequence $ mapM (parseFromString (mconcat <$> many plain)) cols
+
+-- Parses a table caption: inlines beginning with 'Table:'
+-- and followed by blank lines.
+tableCaption :: PandocMonad m => MarkdownParser m (F Inlines)
+tableCaption = try $ do
+ guardEnabled Ext_table_captions
+ skipNonindentSpaces
+ string ":" <|> string "Table:"
+ trimInlinesF . mconcat <$> many1 inline <* blanklines
+
+-- Parse a simple table with '---' header and one line per row.
+simpleTable :: PandocMonad m
+ => Bool -- ^ Headerless table
+ -> MarkdownParser m ([Alignment], [Double], F [Blocks], F [[Blocks]])
+simpleTable headless = do
+ (aligns, _widths, heads', lines') <-
+ tableWith (simpleTableHeader headless) tableLine
+ (return ())
+ (if headless then tableFooter else tableFooter <|> blanklines)
+ -- Simple tables get 0s for relative column widths (i.e., use default)
+ return (aligns, replicate (length aligns) 0, heads', lines')
+
+-- Parse a multiline table: starts with row of '-' on top, then header
+-- (which may be multiline), then the rows,
+-- which may be multiline, separated by blank lines, and
+-- ending with a footer (dashed line followed by blank line).
+multilineTable :: PandocMonad m
+ => Bool -- ^ Headerless table
+ -> MarkdownParser m ([Alignment], [Double], F [Blocks], F [[Blocks]])
+multilineTable headless =
+ tableWith (multilineTableHeader headless) multilineRow blanklines tableFooter
+
+multilineTableHeader :: PandocMonad m
+ => Bool -- ^ Headerless table
+ -> MarkdownParser m (F [Blocks], [Alignment], [Int])
+multilineTableHeader headless = try $ do
+ unless headless $
+ tableSep >> notFollowedBy blankline
+ rawContent <- if headless
+ then return $ repeat ""
+ else many1 $ notFollowedBy tableSep >> anyLine
+ initSp <- nonindentSpaces
+ dashes <- many1 (dashedLine '-')
+ newline
+ let (lengths, lines') = unzip dashes
+ let indices = scanl (+) (length initSp) lines'
+ rawHeadsList <- if headless
+ then liftM (map (:[]) . tail .
+ splitStringByIndices (init indices)) $ lookAhead anyLine
+ else return $ transpose $ map
+ (tail . splitStringByIndices (init indices))
+ rawContent
+ let aligns = zipWith alignType rawHeadsList lengths
+ let rawHeads = if headless
+ then replicate (length dashes) ""
+ else map (unlines . map trim) rawHeadsList
+ heads <- fmap sequence $
+ mapM (parseFromString (mconcat <$> many plain)) $
+ map trim rawHeads
+ return (heads, aligns, indices)
+
+-- Parse a grid table: starts with row of '-' on top, then header
+-- (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).
+gridTable :: PandocMonad m => Bool -- ^ Headerless table
+ -> MarkdownParser m ([Alignment], [Double], F [Blocks], F [[Blocks]])
+gridTable headless =
+ tableWith (gridTableHeader headless) gridTableRow
+ (gridTableSep '-') gridTableFooter
+
+gridTableSplitLine :: [Int] -> String -> [String]
+gridTableSplitLine indices line = map removeFinalBar $ tail $
+ splitStringByIndices (init indices) $ trimr line
+
+gridPart :: PandocMonad m => Char -> ParserT [Char] st m ((Int, Int), Alignment)
+gridPart ch = do
+ leftColon <- option False (True <$ char ':')
+ dashes <- many1 (char ch)
+ rightColon <- option False (True <$ char ':')
+ char '+'
+ let lengthDashes = length dashes + (if leftColon then 1 else 0) +
+ (if rightColon then 1 else 0)
+ let alignment = case (leftColon, rightColon) of
+ (True, True) -> AlignCenter
+ (True, False) -> AlignLeft
+ (False, True) -> AlignRight
+ (False, False) -> AlignDefault
+ return ((lengthDashes, lengthDashes + 1), alignment)
+
+gridDashedLines :: PandocMonad m => Char -> ParserT [Char] st m [((Int, Int), Alignment)]
+gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) <* blankline
+
+removeFinalBar :: String -> String
+removeFinalBar =
+ reverse . dropWhile (`elem` " \t") . dropWhile (=='|') . reverse
+
+-- | Separator between rows of grid table.
+gridTableSep :: PandocMonad m => Char -> MarkdownParser m Char
+gridTableSep ch = try $ gridDashedLines ch >> return '\n'
+
+-- | Parse header for a grid table.
+gridTableHeader :: PandocMonad m => Bool -- ^ Headerless table
+ -> MarkdownParser m (F [Blocks], [Alignment], [Int])
+gridTableHeader headless = try $ do
+ optional blanklines
+ dashes <- gridDashedLines '-'
+ rawContent <- if headless
+ then return []
+ else many1 (try (char '|' >> anyLine))
+ underDashes <- if headless
+ then return dashes
+ else gridDashedLines '='
+ guard $ length dashes == length underDashes
+ let lines' = map (snd . fst) underDashes
+ let indices = scanl (+) 0 lines'
+ let aligns = map snd underDashes
+ let rawHeads = if headless
+ then replicate (length underDashes) ""
+ else map (unlines . map trim) $ transpose
+ $ map (gridTableSplitLine indices) rawContent
+ heads <- fmap sequence $ mapM (parseFromString parseBlocks . trim) rawHeads
+ return (heads, aligns, indices)
+
+gridTableRawLine :: PandocMonad m => [Int] -> MarkdownParser m [String]
+gridTableRawLine indices = do
+ char '|'
+ line <- anyLine
+ return (gridTableSplitLine indices line)
+
+-- | Parse row of grid table.
+gridTableRow :: PandocMonad m => [Int]
+ -> MarkdownParser m (F [Blocks])
+gridTableRow indices = do
+ colLines <- many1 (gridTableRawLine indices)
+ let cols = map ((++ "\n") . unlines . removeOneLeadingSpace) $
+ transpose colLines
+ fmap compactify <$> fmap sequence (mapM (parseFromString parseBlocks) cols)
+
+removeOneLeadingSpace :: [String] -> [String]
+removeOneLeadingSpace xs =
+ if all startsWithSpace xs
+ then map (drop 1) xs
+ else xs
+ where startsWithSpace "" = True
+ startsWithSpace (y:_) = y == ' '
+
+-- | Parse footer for a grid table.
+gridTableFooter :: PandocMonad m => MarkdownParser m [Char]
+gridTableFooter = blanklines
+
+pipeBreak :: PandocMonad m => MarkdownParser m ([Alignment], [Int])
+pipeBreak = try $ do
+ nonindentSpaces
+ openPipe <- (True <$ char '|') <|> return False
+ first <- pipeTableHeaderPart
+ rest <- many $ sepPipe *> pipeTableHeaderPart
+ -- surrounding pipes needed for a one-column table:
+ guard $ not (null rest && not openPipe)
+ optional (char '|')
+ blankline
+ return $ unzip (first:rest)
+
+pipeTable :: PandocMonad m => MarkdownParser m ([Alignment], [Double], F [Blocks], F [[Blocks]])
+pipeTable = try $ do
+ nonindentSpaces
+ lookAhead nonspaceChar
+ (heads,(aligns, seplengths)) <- (,) <$> pipeTableRow <*> pipeBreak
+ let heads' = take (length aligns) <$> heads
+ lines' <- many pipeTableRow
+ let lines'' = map (take (length aligns) <$>) lines'
+ let maxlength = maximum $
+ map (\x -> length . stringify $ runF x def) (heads' : lines'')
+ numColumns <- getOption readerColumns
+ let widths = if maxlength > numColumns
+ then map (\len ->
+ fromIntegral (len + 1) / fromIntegral numColumns)
+ seplengths
+ else replicate (length aligns) 0.0
+ return $ (aligns, widths, heads', sequence lines'')
+
+sepPipe :: PandocMonad m => MarkdownParser m ()
+sepPipe = try $ do
+ char '|' <|> char '+'
+ notFollowedBy blankline
+
+-- parse a row, also returning probable alignments for org-table cells
+pipeTableRow :: PandocMonad m => MarkdownParser m (F [Blocks])
+pipeTableRow = try $ do
+ scanForPipe
+ skipMany spaceChar
+ openPipe <- (True <$ char '|') <|> return False
+ -- split into cells
+ let chunk = void (code <|> rawHtmlInline <|> escapedChar <|> rawLaTeXInline')
+ <|> void (noneOf "|\n\r")
+ let cellContents = ((trim . snd) <$> withRaw (many chunk)) >>=
+ parseFromString pipeTableCell
+ cells <- cellContents `sepEndBy1` (char '|')
+ -- surrounding pipes needed for a one-column table:
+ guard $ not (length cells == 1 && not openPipe)
+ blankline
+ return $ sequence cells
+
+pipeTableCell :: PandocMonad m => MarkdownParser m (F Blocks)
+pipeTableCell = do
+ result <- many inline
+ if null result
+ then return mempty
+ else return $ B.plain . mconcat <$> sequence result
+
+pipeTableHeaderPart :: PandocMonad m => ParserT [Char] st m (Alignment, Int)
+pipeTableHeaderPart = try $ do
+ skipMany spaceChar
+ left <- optionMaybe (char ':')
+ pipe <- many1 (char '-')
+ right <- optionMaybe (char ':')
+ skipMany spaceChar
+ let len = length pipe + maybe 0 (const 1) left + maybe 0 (const 1) right
+ return $
+ ((case (left,right) of
+ (Nothing,Nothing) -> AlignDefault
+ (Just _,Nothing) -> AlignLeft
+ (Nothing,Just _) -> AlignRight
+ (Just _,Just _) -> AlignCenter), len)
+
+-- Succeed only if current line contains a pipe.
+scanForPipe :: PandocMonad m => ParserT [Char] st m ()
+scanForPipe = do
+ inp <- getInput
+ case break (\c -> c == '\n' || c == '|') inp of
+ (_,'|':_) -> return ()
+ _ -> mzero
+
+-- | Parse a table using 'headerParser', 'rowParser',
+-- 'lineParser', and 'footerParser'. Variant of the version in
+-- Text.Pandoc.Parsing.
+tableWith :: PandocMonad m
+ => MarkdownParser m (F [Blocks], [Alignment], [Int])
+ -> ([Int] -> MarkdownParser m (F [Blocks]))
+ -> MarkdownParser m sep
+ -> MarkdownParser m end
+ -> MarkdownParser m ([Alignment], [Double], F [Blocks], F [[Blocks]])
+tableWith headerParser rowParser lineParser footerParser = try $ do
+ (heads, aligns, indices) <- headerParser
+ lines' <- fmap sequence $ rowParser indices `sepEndBy1` lineParser
+ footerParser
+ numColumns <- getOption readerColumns
+ let widths = if (indices == [])
+ then replicate (length aligns) 0.0
+ else widthsFromIndices numColumns indices
+ return $ (aligns, widths, heads, lines')
+
+table :: PandocMonad m => MarkdownParser m (F Blocks)
+table = try $ do
+ frontCaption <- option Nothing (Just <$> tableCaption)
+ (aligns, widths, heads, lns) <-
+ try (guardEnabled Ext_pipe_tables >> scanForPipe >> pipeTable) <|>
+ try (guardEnabled Ext_multiline_tables >>
+ multilineTable False) <|>
+ try (guardEnabled Ext_simple_tables >>
+ (simpleTable True <|> simpleTable False)) <|>
+ try (guardEnabled Ext_multiline_tables >>
+ multilineTable True) <|>
+ try (guardEnabled Ext_grid_tables >>
+ (gridTable False <|> gridTable True)) <?> "table"
+ optional blanklines
+ caption <- case frontCaption of
+ Nothing -> option (return mempty) tableCaption
+ Just c -> return c
+ -- renormalize widths if greater than 100%:
+ let totalWidth = sum widths
+ let widths' = if totalWidth < 1
+ then widths
+ else map (/ totalWidth) widths
+ return $ do
+ caption' <- caption
+ heads' <- heads
+ lns' <- lns
+ return $ B.table caption' (zip aligns widths') heads' lns'
+
+--
+-- inline
+--
+
+inline :: PandocMonad m => MarkdownParser m (F Inlines)
+inline = choice [ whitespace
+ , bareURL
+ , str
+ , endline
+ , code
+ , strongOrEmph
+ , note
+ , cite
+ , bracketedSpan
+ , link
+ , image
+ , math
+ , strikeout
+ , subscript
+ , superscript
+ , inlineNote -- after superscript because of ^[link](/foo)^
+ , autoLink
+ , spanHtml
+ , rawHtmlInline
+ , escapedChar
+ , rawLaTeXInline'
+ , exampleRef
+ , smart
+ , return . B.singleton <$> charRef
+ , emoji
+ , symbol
+ , ltSign
+ ] <?> "inline"
+
+escapedChar' :: PandocMonad m => MarkdownParser m Char
+escapedChar' = try $ do
+ char '\\'
+ (guardEnabled Ext_all_symbols_escapable >> satisfy (not . isAlphaNum))
+ <|> (guardEnabled Ext_angle_brackets_escapable >>
+ oneOf "\\`*_{}[]()>#+-.!~\"<>")
+ <|> (guardEnabled Ext_escaped_line_breaks >> char '\n')
+ <|> oneOf "\\`*_{}[]()>#+-.!~\""
+
+escapedChar :: PandocMonad m => MarkdownParser m (F Inlines)
+escapedChar = do
+ result <- escapedChar'
+ case result of
+ ' ' -> return $ return $ B.str "\160" -- "\ " is a nonbreaking space
+ '\n' -> guardEnabled Ext_escaped_line_breaks >>
+ return (return B.linebreak) -- "\[newline]" is a linebreak
+ _ -> return $ return $ B.str [result]
+
+ltSign :: PandocMonad m => MarkdownParser m (F Inlines)
+ltSign = do
+ guardDisabled Ext_raw_html
+ <|> (notFollowedByHtmlCloser >> notFollowedBy' (htmlTag isBlockTag))
+ char '<'
+ return $ return $ B.str "<"
+
+exampleRef :: PandocMonad m => MarkdownParser m (F Inlines)
+exampleRef = try $ do
+ guardEnabled Ext_example_lists
+ char '@'
+ lab <- many1 (alphaNum <|> oneOf "-_")
+ return $ do
+ st <- askF
+ return $ case M.lookup lab (stateExamples st) of
+ Just n -> B.str (show n)
+ Nothing -> B.str ('@':lab)
+
+symbol :: PandocMonad m => MarkdownParser m (F Inlines)
+symbol = do
+ result <- noneOf "<\\\n\t "
+ <|> try (do lookAhead $ char '\\'
+ notFollowedBy' (() <$ rawTeXBlock)
+ char '\\')
+ return $ return $ B.str [result]
+
+-- parses inline code, between n `s and n `s
+code :: PandocMonad m => MarkdownParser m (F Inlines)
+code = try $ do
+ starts <- many1 (char '`')
+ skipSpaces
+ result <- many1Till (many1 (noneOf "`\n") <|> many1 (char '`') <|>
+ (char '\n' >> notFollowedBy' blankline >> return " "))
+ (try (skipSpaces >> count (length starts) (char '`') >>
+ notFollowedBy (char '`')))
+ attr <- option ([],[],[]) (try $ guardEnabled Ext_inline_code_attributes
+ >> attributes)
+ return $ return $ B.codeWith attr $ trim $ concat result
+
+math :: PandocMonad m => MarkdownParser m (F Inlines)
+math = (return . B.displayMath <$> (mathDisplay >>= applyMacros'))
+ <|> (return . B.math <$> (mathInline >>= applyMacros')) <+?>
+ (guardEnabled Ext_smart *> (return <$> apostrophe)
+ <* notFollowedBy (space <|> satisfy isPunctuation))
+
+-- Parses material enclosed in *s, **s, _s, or __s.
+-- Designed to avoid backtracking.
+enclosure :: PandocMonad m
+ => Char
+ -> MarkdownParser m (F Inlines)
+enclosure c = do
+ -- we can't start an enclosure with _ if after a string and
+ -- the intraword_underscores extension is enabled:
+ guardDisabled Ext_intraword_underscores
+ <|> guard (c == '*')
+ <|> (guard =<< notAfterString)
+ cs <- many1 (char c)
+ (return (B.str cs) <>) <$> whitespace
+ <|> do
+ case length cs of
+ 3 -> three c
+ 2 -> two c mempty
+ 1 -> one c mempty
+ _ -> return (return $ B.str cs)
+
+ender :: PandocMonad m => Char -> Int -> MarkdownParser m ()
+ender c n = try $ do
+ count n (char c)
+ guard (c == '*')
+ <|> guardDisabled Ext_intraword_underscores
+ <|> notFollowedBy alphaNum
+
+-- Parse inlines til you hit one c or a sequence of two cs.
+-- If one c, emit emph and then parse two.
+-- If two cs, emit strong and then parse one.
+-- Otherwise, emit ccc then the results.
+three :: PandocMonad m => Char -> MarkdownParser m (F Inlines)
+three c = do
+ contents <- mconcat <$> many (notFollowedBy (ender c 1) >> inline)
+ (ender c 3 >> return ((B.strong . B.emph) <$> contents))
+ <|> (ender c 2 >> one c (B.strong <$> contents))
+ <|> (ender c 1 >> two c (B.emph <$> contents))
+ <|> return (return (B.str [c,c,c]) <> contents)
+
+-- Parse inlines til you hit two c's, and emit strong.
+-- If you never do hit two cs, emit ** plus inlines parsed.
+two :: PandocMonad m => Char -> F Inlines -> MarkdownParser m (F Inlines)
+two c prefix' = do
+ contents <- mconcat <$> many (try $ notFollowedBy (ender c 2) >> inline)
+ (ender c 2 >> return (B.strong <$> (prefix' <> contents)))
+ <|> return (return (B.str [c,c]) <> (prefix' <> contents))
+
+-- Parse inlines til you hit a c, and emit emph.
+-- If you never hit a c, emit * plus inlines parsed.
+one :: PandocMonad m => Char -> F Inlines -> MarkdownParser m (F Inlines)
+one c prefix' = do
+ contents <- mconcat <$> many ( (notFollowedBy (ender c 1) >> inline)
+ <|> try (string [c,c] >>
+ notFollowedBy (ender c 1) >>
+ two c mempty) )
+ (ender c 1 >> return (B.emph <$> (prefix' <> contents)))
+ <|> return (return (B.str [c]) <> (prefix' <> contents))
+
+strongOrEmph :: PandocMonad m => MarkdownParser m (F Inlines)
+strongOrEmph = enclosure '*' <|> enclosure '_'
+
+-- | Parses a list of inlines between start and end delimiters.
+inlinesBetween :: PandocMonad m
+ => (Show b)
+ => MarkdownParser m a
+ -> MarkdownParser m b
+ -> MarkdownParser m (F Inlines)
+inlinesBetween start end =
+ (trimInlinesF . mconcat) <$> try (start >> many1Till inner end)
+ where inner = innerSpace <|> (notFollowedBy' (() <$ whitespace) >> inline)
+ innerSpace = try $ whitespace <* notFollowedBy' end
+
+strikeout :: PandocMonad m => MarkdownParser m (F Inlines)
+strikeout = fmap B.strikeout <$>
+ (guardEnabled Ext_strikeout >> inlinesBetween strikeStart strikeEnd)
+ where strikeStart = string "~~" >> lookAhead nonspaceChar
+ >> notFollowedBy (char '~')
+ strikeEnd = try $ string "~~"
+
+superscript :: PandocMonad m => MarkdownParser m (F Inlines)
+superscript = fmap B.superscript <$> try (do
+ guardEnabled Ext_superscript
+ char '^'
+ mconcat <$> many1Till (notFollowedBy spaceChar >> inline) (char '^'))
+
+subscript :: PandocMonad m => MarkdownParser m (F Inlines)
+subscript = fmap B.subscript <$> try (do
+ guardEnabled Ext_subscript
+ char '~'
+ mconcat <$> many1Till (notFollowedBy spaceChar >> inline) (char '~'))
+
+whitespace :: PandocMonad m => MarkdownParser m (F Inlines)
+whitespace = spaceChar >> return <$> (lb <|> regsp) <?> "whitespace"
+ where lb = spaceChar >> skipMany spaceChar >> option B.space (endline >> return B.linebreak)
+ regsp = skipMany spaceChar >> return B.space
+
+nonEndline :: PandocMonad m => ParserT [Char] st m Char
+nonEndline = satisfy (/='\n')
+
+str :: PandocMonad m => MarkdownParser m (F Inlines)
+str = do
+ result <- many1 alphaNum
+ updateLastStrPos
+ let spacesToNbr = map (\c -> if c == ' ' then '\160' else c)
+ isSmart <- extensionEnabled Ext_smart <$> getOption readerExtensions
+ if isSmart
+ then case likelyAbbrev result of
+ [] -> return $ return $ B.str result
+ xs -> choice (map (\x ->
+ try (string x >> oneOf " \n" >>
+ lookAhead alphaNum >>
+ return (return $ B.str
+ $ result ++ spacesToNbr x ++ "\160"))) xs)
+ <|> (return $ return $ B.str result)
+ else return $ return $ B.str result
+
+-- | if the string matches the beginning of an abbreviation (before
+-- the first period, return strings that would finish the abbreviation.
+likelyAbbrev :: String -> [String]
+likelyAbbrev x =
+ let abbrevs = [ "Mr.", "Mrs.", "Ms.", "Capt.", "Dr.", "Prof.",
+ "Gen.", "Gov.", "e.g.", "i.e.", "Sgt.", "St.",
+ "vol.", "vs.", "Sen.", "Rep.", "Pres.", "Hon.",
+ "Rev.", "Ph.D.", "M.D.", "M.A.", "p.", "pp.",
+ "ch.", "sec.", "cf.", "cp."]
+ abbrPairs = map (break (=='.')) abbrevs
+ in map snd $ filter (\(y,_) -> y == x) abbrPairs
+
+-- an endline character that can be treated as a space, not a structural break
+endline :: PandocMonad m => MarkdownParser m (F Inlines)
+endline = try $ do
+ newline
+ notFollowedBy blankline
+ -- parse potential list-starts differently if in a list:
+ notFollowedBy (inList >> listStart)
+ guardDisabled Ext_lists_without_preceding_blankline <|> notFollowedBy listStart
+ guardEnabled Ext_blank_before_blockquote <|> notFollowedBy emailBlockQuoteStart
+ guardEnabled Ext_blank_before_header <|> (notFollowedBy . char =<< atxChar) -- atx header
+ guardDisabled Ext_backtick_code_blocks <|>
+ notFollowedBy (() <$ (lookAhead (char '`') >> codeBlockFenced))
+ notFollowedByHtmlCloser
+ (eof >> return mempty)
+ <|> (guardEnabled Ext_hard_line_breaks >> return (return B.linebreak))
+ <|> (guardEnabled Ext_ignore_line_breaks >> return mempty)
+ <|> (skipMany spaceChar >> return (return B.softbreak))
+
+--
+-- links
+--
+
+-- a reference label for a link
+reference :: PandocMonad m => MarkdownParser m (F Inlines, String)
+reference = do notFollowedBy' (string "[^") -- footnote reference
+ withRaw $ trimInlinesF <$> inlinesInBalancedBrackets
+
+parenthesizedChars :: PandocMonad m => MarkdownParser m [Char]
+parenthesizedChars = do
+ result <- charsInBalanced '(' ')' litChar
+ return $ '(' : result ++ ")"
+
+-- source for a link, with optional title
+source :: PandocMonad m => MarkdownParser m (String, String)
+source = do
+ char '('
+ skipSpaces
+ let urlChunk =
+ try parenthesizedChars
+ <|> (notFollowedBy (oneOf " )") >> (count 1 litChar))
+ <|> try (many1 spaceChar <* notFollowedBy (oneOf "\"')"))
+ let sourceURL = (unwords . words . concat) <$> many urlChunk
+ let betweenAngles = try $
+ char '<' >> manyTill litChar (char '>')
+ src <- try betweenAngles <|> sourceURL
+ tit <- option "" $ try $ spnl >> linkTitle
+ skipSpaces
+ char ')'
+ return (escapeURI $ trimr src, tit)
+
+linkTitle :: PandocMonad m => MarkdownParser m String
+linkTitle = quotedTitle '"' <|> quotedTitle '\''
+
+link :: PandocMonad m => MarkdownParser m (F Inlines)
+link = try $ do
+ st <- getState
+ guard $ stateAllowLinks st
+ setState $ st{ stateAllowLinks = False }
+ (lab,raw) <- reference
+ setState $ st{ stateAllowLinks = True }
+ regLink B.linkWith lab <|> referenceLink B.linkWith (lab,raw)
+
+bracketedSpan :: PandocMonad m => MarkdownParser m (F Inlines)
+bracketedSpan = try $ do
+ guardEnabled Ext_bracketed_spans
+ (lab,_) <- reference
+ attr <- attributes
+ let (ident,classes,keyvals) = attr
+ case lookup "style" keyvals of
+ Just s | null ident && null classes &&
+ map toLower (filter (`notElem` " \t;") s) ==
+ "font-variant:small-caps"
+ -> return $ B.smallcaps <$> lab
+ _ -> return $ B.spanWith attr <$> lab
+
+regLink :: PandocMonad m
+ => (Attr -> String -> String -> Inlines -> Inlines)
+ -> F Inlines
+ -> MarkdownParser m (F Inlines)
+regLink constructor lab = try $ do
+ (src, tit) <- source
+ attr <- option nullAttr $
+ guardEnabled Ext_link_attributes >> attributes
+ return $ constructor attr src tit <$> lab
+
+-- a link like [this][ref] or [this][] or [this]
+referenceLink :: PandocMonad m
+ => (Attr -> String -> String -> Inlines -> Inlines)
+ -> (F Inlines, String)
+ -> MarkdownParser m (F Inlines)
+referenceLink constructor (lab, raw) = do
+ sp <- (True <$ lookAhead (char ' ')) <|> return False
+ (_,raw') <- option (mempty, "") $
+ lookAhead (try (guardEnabled Ext_citations >>
+ spnl >> normalCite >> return (mempty, "")))
+ <|>
+ try (spnl >> reference)
+ when (raw' == "") $ guardEnabled Ext_shortcut_reference_links
+ let labIsRef = raw' == "" || raw' == "[]"
+ let key = toKey $ if labIsRef then raw else raw'
+ parsedRaw <- parseFromString (mconcat <$> many inline) raw'
+ fallback <- parseFromString (mconcat <$> many inline) $ dropBrackets raw
+ implicitHeaderRefs <- option False $
+ True <$ guardEnabled Ext_implicit_header_references
+ let makeFallback = do
+ parsedRaw' <- parsedRaw
+ fallback' <- fallback
+ return $ B.str "[" <> fallback' <> B.str "]" <>
+ (if sp && not (null raw) then B.space else mempty) <>
+ parsedRaw'
+ return $ do
+ keys <- asksF stateKeys
+ case M.lookup key keys of
+ Nothing ->
+ if implicitHeaderRefs
+ then do
+ headerKeys <- asksF stateHeaderKeys
+ case M.lookup key headerKeys of
+ Just ((src, tit), _) -> constructor nullAttr src tit <$> lab
+ Nothing -> makeFallback
+ else makeFallback
+ Just ((src,tit), attr) -> constructor attr src tit <$> lab
+
+dropBrackets :: String -> String
+dropBrackets = reverse . dropRB . reverse . dropLB
+ where dropRB (']':xs) = xs
+ dropRB xs = xs
+ dropLB ('[':xs) = xs
+ dropLB xs = xs
+
+bareURL :: PandocMonad m => MarkdownParser m (F Inlines)
+bareURL = try $ do
+ guardEnabled Ext_autolink_bare_uris
+ getState >>= guard . stateAllowLinks
+ (orig, src) <- uri <|> emailAddress
+ notFollowedBy $ try $ spaces >> htmlTag (~== TagClose "a")
+ return $ return $ B.link src "" (B.str orig)
+
+autoLink :: PandocMonad m => MarkdownParser m (F Inlines)
+autoLink = try $ do
+ getState >>= guard . stateAllowLinks
+ char '<'
+ (orig, src) <- uri <|> emailAddress
+ -- in rare cases, something may remain after the uri parser
+ -- is finished, because the uri parser tries to avoid parsing
+ -- final punctuation. for example: in `<http://hi---there>`,
+ -- the URI parser will stop before the dashes.
+ extra <- fromEntities <$> manyTill nonspaceChar (char '>')
+ attr <- option nullAttr $ try $
+ guardEnabled Ext_link_attributes >> attributes
+ return $ return $ B.linkWith attr (src ++ escapeURI extra) "" (B.str $ orig ++ extra)
+
+image :: PandocMonad m => MarkdownParser m (F Inlines)
+image = try $ do
+ char '!'
+ (lab,raw) <- reference
+ defaultExt <- getOption readerDefaultImageExtension
+ let constructor attr' src = case takeExtension src of
+ "" -> B.imageWith attr' (addExtension src defaultExt)
+ _ -> B.imageWith attr' src
+ regLink constructor lab <|> referenceLink constructor (lab,raw)
+
+note :: PandocMonad m => MarkdownParser m (F Inlines)
+note = try $ do
+ guardEnabled Ext_footnotes
+ ref <- noteMarker
+ return $ do
+ notes <- asksF stateNotes'
+ case lookup ref notes of
+ Nothing -> return $ B.str $ "[^" ++ ref ++ "]"
+ Just contents -> do
+ st <- askF
+ -- process the note in a context that doesn't resolve
+ -- notes, to avoid infinite looping with notes inside
+ -- notes:
+ let contents' = runF contents st{ stateNotes' = [] }
+ return $ B.note contents'
+
+inlineNote :: PandocMonad m => MarkdownParser m (F Inlines)
+inlineNote = try $ do
+ guardEnabled Ext_inline_notes
+ char '^'
+ contents <- inlinesInBalancedBrackets
+ return $ B.note . B.para <$> contents
+
+rawLaTeXInline' :: PandocMonad m => MarkdownParser m (F Inlines)
+rawLaTeXInline' = try $ do
+ guardEnabled Ext_raw_tex
+ lookAhead $ char '\\' >> notFollowedBy' (string "start") -- context env
+ RawInline _ s <- rawLaTeXInline
+ return $ return $ B.rawInline "tex" s
+ -- "tex" because it might be context or latex
+
+rawConTeXtEnvironment :: PandocMonad m => ParserT [Char] st m String
+rawConTeXtEnvironment = try $ do
+ string "\\start"
+ completion <- inBrackets (letter <|> digit <|> spaceChar)
+ <|> (many1 letter)
+ contents <- manyTill (rawConTeXtEnvironment <|> (count 1 anyChar))
+ (try $ string "\\stop" >> string completion)
+ return $ "\\start" ++ completion ++ concat contents ++ "\\stop" ++ completion
+
+inBrackets :: PandocMonad m => (ParserT [Char] st m Char) -> ParserT [Char] st m String
+inBrackets parser = do
+ char '['
+ contents <- many parser
+ char ']'
+ return $ "[" ++ contents ++ "]"
+
+spanHtml :: PandocMonad m => MarkdownParser m (F Inlines)
+spanHtml = try $ do
+ guardEnabled Ext_native_spans
+ (TagOpen _ attrs, _) <- htmlTag (~== TagOpen "span" [])
+ contents <- mconcat <$> manyTill inline (htmlTag (~== TagClose "span"))
+ let ident = fromMaybe "" $ lookup "id" attrs
+ let classes = maybe [] words $ lookup "class" attrs
+ let keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"]
+ case lookup "style" keyvals of
+ Just s | null ident && null classes &&
+ map toLower (filter (`notElem` " \t;") s) ==
+ "font-variant:small-caps"
+ -> return $ B.smallcaps <$> contents
+ _ -> return $ B.spanWith (ident, classes, keyvals) <$> contents
+
+divHtml :: PandocMonad m => MarkdownParser m (F Blocks)
+divHtml = try $ do
+ guardEnabled Ext_native_divs
+ (TagOpen _ attrs, rawtag) <- htmlTag (~== TagOpen "div" [])
+ -- we set stateInHtmlBlock so that closing tags that can be either block or
+ -- inline will not be parsed as inline tags
+ oldInHtmlBlock <- stateInHtmlBlock <$> getState
+ updateState $ \st -> st{ stateInHtmlBlock = Just "div" }
+ bls <- option "" (blankline >> option "" blanklines)
+ contents <- mconcat <$>
+ many (notFollowedBy' (htmlTag (~== TagClose "div")) >> block)
+ closed <- option False (True <$ htmlTag (~== TagClose "div"))
+ if closed
+ then do
+ updateState $ \st -> st{ stateInHtmlBlock = oldInHtmlBlock }
+ let ident = fromMaybe "" $ lookup "id" attrs
+ let classes = maybe [] words $ lookup "class" attrs
+ let keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"]
+ return $ B.divWith (ident, classes, keyvals) <$> contents
+ else -- avoid backtracing
+ return $ return (B.rawBlock "html" (rawtag <> bls)) <> contents
+
+rawHtmlInline :: PandocMonad m => MarkdownParser m (F Inlines)
+rawHtmlInline = do
+ guardEnabled Ext_raw_html
+ inHtmlBlock <- stateInHtmlBlock <$> getState
+ let isCloseBlockTag t = case inHtmlBlock of
+ Just t' -> t ~== TagClose t'
+ Nothing -> False
+ mdInHtml <- option False $
+ ( guardEnabled Ext_markdown_in_html_blocks
+ <|> guardEnabled Ext_markdown_attribute
+ ) >> return True
+ (_,result) <- htmlTag $ if mdInHtml
+ then (\x -> isInlineTag x &&
+ not (isCloseBlockTag x))
+ else not . isTextTag
+ return $ return $ B.rawInline "html" result
+
+-- Emoji
+
+emojiChars :: [Char]
+emojiChars = ['a'..'z'] ++ ['0'..'9'] ++ ['_','+','-']
+
+emoji :: PandocMonad m => MarkdownParser m (F Inlines)
+emoji = try $ do
+ guardEnabled Ext_emoji
+ char ':'
+ emojikey <- many1 (oneOf emojiChars)
+ char ':'
+ case M.lookup emojikey emojis of
+ Just s -> return (return (B.str s))
+ Nothing -> mzero
+
+-- Citations
+
+cite :: PandocMonad m => MarkdownParser m (F Inlines)
+cite = do
+ guardEnabled Ext_citations
+ citations <- textualCite
+ <|> do (cs, raw) <- withRaw normalCite
+ return $ (flip B.cite (B.text raw)) <$> cs
+ return citations
+
+textualCite :: PandocMonad m => MarkdownParser m (F Inlines)
+textualCite = try $ do
+ (_, key) <- citeKey
+ let first = Citation{ citationId = key
+ , citationPrefix = []
+ , citationSuffix = []
+ , citationMode = AuthorInText
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+ mbrest <- option Nothing $ try $ spnl >> Just <$> withRaw normalCite
+ case mbrest of
+ Just (rest, raw) ->
+ return $ (flip B.cite (B.text $ '@':key ++ " " ++ raw) . (first:))
+ <$> rest
+ Nothing ->
+ (do
+ (cs, raw) <- withRaw $ bareloc first
+ let (spaces',raw') = span isSpace raw
+ spc | null spaces' = mempty
+ | otherwise = B.space
+ lab <- parseFromString (mconcat <$> many inline) $ dropBrackets raw'
+ fallback <- referenceLink B.linkWith (lab,raw')
+ return $ do
+ fallback' <- fallback
+ cs' <- cs
+ return $
+ case B.toList fallback' of
+ Link{}:_ -> B.cite [first] (B.str $ '@':key) <> spc <> fallback'
+ _ -> B.cite cs' (B.text $ '@':key ++ " " ++ raw))
+ <|> return (do st <- askF
+ return $ case M.lookup key (stateExamples st) of
+ Just n -> B.str (show n)
+ _ -> B.cite [first] $ B.str $ '@':key)
+
+bareloc :: PandocMonad m => Citation -> MarkdownParser m (F [Citation])
+bareloc c = try $ do
+ spnl
+ char '['
+ notFollowedBy $ char '^'
+ suff <- suffix
+ rest <- option (return []) $ try $ char ';' >> citeList
+ spnl
+ char ']'
+ notFollowedBy $ oneOf "[("
+ return $ do
+ suff' <- suff
+ rest' <- rest
+ return $ c{ citationSuffix = B.toList suff' } : rest'
+
+normalCite :: PandocMonad m => MarkdownParser m (F [Citation])
+normalCite = try $ do
+ char '['
+ spnl
+ citations <- citeList
+ spnl
+ char ']'
+ return citations
+
+suffix :: PandocMonad m => MarkdownParser m (F Inlines)
+suffix = try $ do
+ hasSpace <- option False (notFollowedBy nonspaceChar >> return True)
+ spnl
+ rest <- trimInlinesF . mconcat <$> many (notFollowedBy (oneOf ";]") >> inline)
+ return $ if hasSpace
+ then (B.space <>) <$> rest
+ else rest
+
+prefix :: PandocMonad m => MarkdownParser m (F Inlines)
+prefix = trimInlinesF . mconcat <$>
+ manyTill inline (char ']' <|> liftM (const ']') (lookAhead citeKey))
+
+citeList :: PandocMonad m => MarkdownParser m (F [Citation])
+citeList = fmap sequence $ sepBy1 citation (try $ char ';' >> spnl)
+
+citation :: PandocMonad m => MarkdownParser m (F Citation)
+citation = try $ do
+ pref <- prefix
+ (suppress_author, key) <- citeKey
+ suff <- suffix
+ return $ do
+ x <- pref
+ y <- suff
+ return $ Citation{ citationId = key
+ , citationPrefix = B.toList x
+ , citationSuffix = B.toList y
+ , citationMode = if suppress_author
+ then SuppressAuthor
+ else NormalCitation
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+
+smart :: PandocMonad m => MarkdownParser m (F Inlines)
+smart = do
+ guardEnabled Ext_smart
+ doubleQuoted <|> singleQuoted <|>
+ choice (map (return <$>) [apostrophe, dash, ellipses])
+
+singleQuoted :: PandocMonad m => MarkdownParser m (F Inlines)
+singleQuoted = try $ do
+ singleQuoteStart
+ withQuoteContext InSingleQuote $
+ fmap B.singleQuoted . trimInlinesF . mconcat <$>
+ many1Till inline singleQuoteEnd
+
+-- doubleQuoted will handle regular double-quoted sections, as well
+-- as dialogues with an open double-quote without a close double-quote
+-- in the same paragraph.
+doubleQuoted :: PandocMonad m => MarkdownParser m (F Inlines)
+doubleQuoted = try $ do
+ doubleQuoteStart
+ contents <- mconcat <$> many (try $ notFollowedBy doubleQuoteEnd >> inline)
+ (withQuoteContext InDoubleQuote $ doubleQuoteEnd >> return
+ (fmap B.doubleQuoted . trimInlinesF $ contents))
+ <|> (return $ return (B.str "\8220") <> contents)
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs
new file mode 100644
index 000000000..14f9da9b6
--- /dev/null
+++ b/src/Text/Pandoc/Readers/MediaWiki.hs
@@ -0,0 +1,677 @@
+{-# LANGUAGE RelaxedPolyRec, FlexibleInstances, TypeSynonymInstances #-}
+-- RelaxedPolyRec needed for inlinesBetween on GHC < 7
+{-
+ Copyright (C) 2012-2015 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.MediaWiki
+ Copyright : Copyright (C) 2012-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of mediawiki text to 'Pandoc' document.
+-}
+{-
+TODO:
+_ correctly handle tables within tables
+_ parse templates?
+-}
+module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where
+
+import Text.Pandoc.Definition
+import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
+import Data.Monoid ((<>))
+import Text.Pandoc.Options
+import Text.Pandoc.Logging
+import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag, isCommentTag )
+import Text.Pandoc.XML ( fromEntities )
+import Text.Pandoc.Parsing hiding ( nested )
+import Text.Pandoc.Walk ( walk )
+import Text.Pandoc.Shared ( stripTrailingNewlines, safeRead, stringify, trim )
+import Control.Monad
+import Data.List (intersperse, intercalate, isPrefixOf )
+import Text.HTML.TagSoup
+import Data.Sequence (viewl, ViewL(..), (<|))
+import qualified Data.Foldable as F
+import qualified Data.Map as M
+import qualified Data.Set as Set
+import Data.Char (isDigit, isSpace)
+import Data.Maybe (fromMaybe)
+import Control.Monad.Except (throwError)
+import Text.Pandoc.Class (PandocMonad, report)
+
+-- | Read mediawiki from an input string and return a Pandoc document.
+readMediaWiki :: PandocMonad m
+ => ReaderOptions -- ^ Reader options
+ -> String -- ^ String to parse (assuming @'\n'@ line endings)
+ -> m Pandoc
+readMediaWiki opts s = do
+ parsed <- readWithM parseMediaWiki MWState{ mwOptions = opts
+ , mwMaxNestingLevel = 4
+ , mwNextLinkNumber = 1
+ , mwCategoryLinks = []
+ , mwHeaderMap = M.empty
+ , mwIdentifierList = Set.empty
+ }
+ (s ++ "\n")
+ case parsed of
+ Right result -> return result
+ Left e -> throwError e
+
+data MWState = MWState { mwOptions :: ReaderOptions
+ , mwMaxNestingLevel :: Int
+ , mwNextLinkNumber :: Int
+ , mwCategoryLinks :: [Inlines]
+ , mwHeaderMap :: M.Map Inlines String
+ , mwIdentifierList :: Set.Set String
+ }
+
+type MWParser m = ParserT [Char] MWState m
+
+instance HasReaderOptions MWState where
+ extractReaderOptions = mwOptions
+
+instance HasHeaderMap MWState where
+ extractHeaderMap = mwHeaderMap
+ updateHeaderMap f st = st{ mwHeaderMap = f $ mwHeaderMap st }
+
+instance HasIdentifierList MWState where
+ extractIdentifierList = mwIdentifierList
+ updateIdentifierList f st = st{ mwIdentifierList = f $ mwIdentifierList st }
+
+--
+-- auxiliary functions
+--
+
+-- This is used to prevent exponential blowups for things like:
+-- ''a'''a''a'''a''a'''a''a'''a
+nested :: PandocMonad m => MWParser m a -> MWParser m a
+nested p = do
+ nestlevel <- mwMaxNestingLevel `fmap` getState
+ guard $ nestlevel > 0
+ updateState $ \st -> st{ mwMaxNestingLevel = mwMaxNestingLevel st - 1 }
+ res <- p
+ updateState $ \st -> st{ mwMaxNestingLevel = nestlevel }
+ return res
+
+specialChars :: [Char]
+specialChars = "'[]<=&*{}|\":\\"
+
+spaceChars :: [Char]
+spaceChars = " \n\t"
+
+sym :: PandocMonad m => String -> MWParser m ()
+sym s = () <$ try (string s)
+
+newBlockTags :: [String]
+newBlockTags = ["haskell","syntaxhighlight","source","gallery","references"]
+
+isBlockTag' :: Tag String -> Bool
+isBlockTag' tag@(TagOpen t _) = (isBlockTag tag || t `elem` newBlockTags) &&
+ t `notElem` eitherBlockOrInline
+isBlockTag' tag@(TagClose t) = (isBlockTag tag || t `elem` newBlockTags) &&
+ t `notElem` eitherBlockOrInline
+isBlockTag' tag = isBlockTag tag
+
+isInlineTag' :: Tag String -> Bool
+isInlineTag' (TagComment _) = True
+isInlineTag' t = not (isBlockTag' t)
+
+eitherBlockOrInline :: [String]
+eitherBlockOrInline = ["applet", "button", "del", "iframe", "ins",
+ "map", "area", "object"]
+
+htmlComment :: PandocMonad m => MWParser m ()
+htmlComment = () <$ htmlTag isCommentTag
+
+inlinesInTags :: PandocMonad m => String -> MWParser m Inlines
+inlinesInTags tag = try $ do
+ (_,raw) <- htmlTag (~== TagOpen tag [])
+ if '/' `elem` raw -- self-closing tag
+ then return mempty
+ else trimInlines . mconcat <$>
+ manyTill inline (htmlTag (~== TagClose tag))
+
+blocksInTags :: PandocMonad m => String -> MWParser m Blocks
+blocksInTags tag = try $ do
+ (_,raw) <- htmlTag (~== TagOpen tag [])
+ let closer = if tag == "li"
+ then htmlTag (~== TagClose "li")
+ <|> lookAhead (
+ htmlTag (~== TagOpen "li" [])
+ <|> htmlTag (~== TagClose "ol")
+ <|> htmlTag (~== TagClose "ul"))
+ else htmlTag (~== TagClose tag)
+ if '/' `elem` raw -- self-closing tag
+ then return mempty
+ else mconcat <$> manyTill block closer
+
+charsInTags :: PandocMonad m => String -> MWParser m [Char]
+charsInTags tag = try $ do
+ (_,raw) <- htmlTag (~== TagOpen tag [])
+ if '/' `elem` raw -- self-closing tag
+ then return ""
+ else manyTill anyChar (htmlTag (~== TagClose tag))
+
+--
+-- main parser
+--
+
+parseMediaWiki :: PandocMonad m => MWParser m Pandoc
+parseMediaWiki = do
+ bs <- mconcat <$> many block
+ spaces
+ eof
+ categoryLinks <- reverse . mwCategoryLinks <$> getState
+ let categories = if null categoryLinks
+ then mempty
+ else B.para $ mconcat $ intersperse B.space categoryLinks
+ return $ B.doc $ bs <> categories
+
+--
+-- block parsers
+--
+
+block :: PandocMonad m => MWParser m Blocks
+block = do
+ pos <- getPosition
+ res <- mempty <$ skipMany1 blankline
+ <|> table
+ <|> header
+ <|> hrule
+ <|> orderedList
+ <|> bulletList
+ <|> definitionList
+ <|> mempty <$ try (spaces *> htmlComment)
+ <|> preformatted
+ <|> blockTag
+ <|> (B.rawBlock "mediawiki" <$> template)
+ <|> para
+ report $ ParsingTrace (take 60 $ show $ B.toList res) pos
+ return res
+
+para :: PandocMonad m => MWParser m Blocks
+para = do
+ contents <- trimInlines . mconcat <$> many1 inline
+ if F.all (==Space) contents
+ then return mempty
+ else return $ B.para contents
+
+table :: PandocMonad m => MWParser m Blocks
+table = do
+ tableStart
+ styles <- option [] parseAttrs <* blankline
+ let tableWidth = case lookup "width" styles of
+ Just w -> fromMaybe 1.0 $ parseWidth w
+ Nothing -> 1.0
+ caption <- option mempty tableCaption
+ optional rowsep
+ hasheader <- option False $ True <$ (lookAhead (skipSpaces *> char '!'))
+ (cellspecs',hdr) <- unzip <$> tableRow
+ let widths = map ((tableWidth *) . snd) cellspecs'
+ let restwidth = tableWidth - sum widths
+ let zerocols = length $ filter (==0.0) widths
+ let defaultwidth = if zerocols == 0 || zerocols == length widths
+ then 0.0
+ else restwidth / fromIntegral zerocols
+ let widths' = map (\w -> if w == 0 then defaultwidth else w) widths
+ let cellspecs = zip (map fst cellspecs') widths'
+ rows' <- many $ try $ rowsep *> (map snd <$> tableRow)
+ optional blanklines
+ tableEnd
+ let cols = length hdr
+ let (headers,rows) = if hasheader
+ then (hdr, rows')
+ else (replicate cols mempty, hdr:rows')
+ return $ B.table caption cellspecs headers rows
+
+parseAttrs :: PandocMonad m => MWParser m [(String,String)]
+parseAttrs = many1 parseAttr
+
+parseAttr :: PandocMonad m => MWParser m (String, String)
+parseAttr = try $ do
+ skipMany spaceChar
+ k <- many1 letter
+ char '='
+ v <- (char '"' >> many1Till (satisfy (/='\n')) (char '"'))
+ <|> many1 (satisfy $ \c -> not (isSpace c) && c /= '|')
+ return (k,v)
+
+tableStart :: PandocMonad m => MWParser m ()
+tableStart = try $ guardColumnOne *> skipSpaces *> sym "{|"
+
+tableEnd :: PandocMonad m => MWParser m ()
+tableEnd = try $ guardColumnOne *> skipSpaces *> sym "|}"
+
+rowsep :: PandocMonad m => MWParser m ()
+rowsep = try $ guardColumnOne *> skipSpaces *> sym "|-" <*
+ optional parseAttr <* blanklines
+
+cellsep :: PandocMonad m => MWParser m ()
+cellsep = try $
+ (guardColumnOne *> skipSpaces <*
+ ( (char '|' <* notFollowedBy (oneOf "-}+"))
+ <|> (char '!')
+ )
+ )
+ <|> (() <$ try (string "||"))
+ <|> (() <$ try (string "!!"))
+
+tableCaption :: PandocMonad m => MWParser m Inlines
+tableCaption = try $ do
+ guardColumnOne
+ skipSpaces
+ sym "|+"
+ optional (try $ parseAttr *> skipSpaces *> char '|' *> skipSpaces)
+ (trimInlines . mconcat) <$> many (notFollowedBy (cellsep <|> rowsep) *> inline)
+
+tableRow :: PandocMonad m => MWParser m [((Alignment, Double), Blocks)]
+tableRow = try $ skipMany htmlComment *> many tableCell
+
+tableCell :: PandocMonad m => MWParser m ((Alignment, Double), Blocks)
+tableCell = try $ do
+ cellsep
+ skipMany spaceChar
+ attrs <- option [] $ try $ parseAttrs <* skipSpaces <* char '|' <*
+ notFollowedBy (char '|')
+ skipMany spaceChar
+ ls <- concat <$> many (notFollowedBy (cellsep <|> rowsep <|> tableEnd) *>
+ ((snd <$> withRaw table) <|> count 1 anyChar))
+ bs <- parseFromString (mconcat <$> many block) ls
+ let align = case lookup "align" attrs of
+ Just "left" -> AlignLeft
+ Just "right" -> AlignRight
+ Just "center" -> AlignCenter
+ _ -> AlignDefault
+ let width = case lookup "width" attrs of
+ Just xs -> fromMaybe 0.0 $ parseWidth xs
+ Nothing -> 0.0
+ return ((align, width), bs)
+
+parseWidth :: String -> Maybe Double
+parseWidth s =
+ case reverse s of
+ ('%':ds) | all isDigit ds -> safeRead ('0':'.':reverse ds)
+ _ -> Nothing
+
+template :: PandocMonad m => MWParser m String
+template = try $ do
+ string "{{"
+ notFollowedBy (char '{')
+ lookAhead $ letter <|> digit <|> char ':'
+ let chunk = template <|> variable <|> many1 (noneOf "{}") <|> count 1 anyChar
+ contents <- manyTill chunk (try $ string "}}")
+ return $ "{{" ++ concat contents ++ "}}"
+
+blockTag :: PandocMonad m => MWParser m Blocks
+blockTag = do
+ (tag, _) <- lookAhead $ htmlTag isBlockTag'
+ case tag of
+ TagOpen "blockquote" _ -> B.blockQuote <$> blocksInTags "blockquote"
+ TagOpen "pre" _ -> B.codeBlock . trimCode <$> charsInTags "pre"
+ TagOpen "syntaxhighlight" attrs -> syntaxhighlight "syntaxhighlight" attrs
+ TagOpen "source" attrs -> syntaxhighlight "source" attrs
+ TagOpen "haskell" _ -> B.codeBlockWith ("",["haskell"],[]) . trimCode <$>
+ charsInTags "haskell"
+ TagOpen "gallery" _ -> blocksInTags "gallery"
+ TagOpen "p" _ -> mempty <$ htmlTag (~== tag)
+ TagClose "p" -> mempty <$ htmlTag (~== tag)
+ _ -> B.rawBlock "html" . snd <$> htmlTag (~== tag)
+
+trimCode :: String -> String
+trimCode ('\n':xs) = stripTrailingNewlines xs
+trimCode xs = stripTrailingNewlines xs
+
+syntaxhighlight :: PandocMonad m => String -> [Attribute String] -> MWParser m Blocks
+syntaxhighlight tag attrs = try $ do
+ let mblang = lookup "lang" attrs
+ let mbstart = lookup "start" attrs
+ let mbline = lookup "line" attrs
+ let classes = maybe [] (:[]) mblang ++ maybe [] (const ["numberLines"]) mbline
+ let kvs = maybe [] (\x -> [("startFrom",x)]) mbstart
+ contents <- charsInTags tag
+ return $ B.codeBlockWith ("",classes,kvs) $ trimCode contents
+
+hrule :: PandocMonad m => MWParser m Blocks
+hrule = B.horizontalRule <$ try (string "----" *> many (char '-') *> newline)
+
+guardColumnOne :: PandocMonad m => MWParser m ()
+guardColumnOne = getPosition >>= \pos -> guard (sourceColumn pos == 1)
+
+preformatted :: PandocMonad m => MWParser m Blocks
+preformatted = try $ do
+ guardColumnOne
+ char ' '
+ let endline' = B.linebreak <$ (try $ newline <* char ' ')
+ let whitespace' = B.str <$> many1 ('\160' <$ spaceChar)
+ let spToNbsp ' ' = '\160'
+ spToNbsp x = x
+ let nowiki' = mconcat . intersperse B.linebreak . map B.str .
+ lines . fromEntities . map spToNbsp <$> try
+ (htmlTag (~== TagOpen "nowiki" []) *>
+ manyTill anyChar (htmlTag (~== TagClose "nowiki")))
+ let inline' = whitespace' <|> endline' <|> nowiki'
+ <|> (try $ notFollowedBy newline *> inline)
+ contents <- mconcat <$> many1 inline'
+ let spacesStr (Str xs) = all isSpace xs
+ spacesStr _ = False
+ if F.all spacesStr contents
+ then return mempty
+ else return $ B.para $ encode contents
+
+encode :: Inlines -> Inlines
+encode = B.fromList . normalizeCode . B.toList . walk strToCode
+ where strToCode (Str s) = Code ("",[],[]) s
+ strToCode Space = Code ("",[],[]) " "
+ strToCode x = x
+ normalizeCode [] = []
+ normalizeCode (Code a1 x : Code a2 y : zs) | a1 == a2 =
+ normalizeCode $ (Code a1 (x ++ y)) : zs
+ normalizeCode (x:xs) = x : normalizeCode xs
+
+header :: PandocMonad m => MWParser m Blocks
+header = try $ do
+ guardColumnOne
+ eqs <- many1 (char '=')
+ let lev = length eqs
+ guard $ lev <= 6
+ contents <- trimInlines . mconcat <$> manyTill inline (count lev $ char '=')
+ attr <- registerHeader nullAttr contents
+ return $ B.headerWith attr lev contents
+
+bulletList :: PandocMonad m => MWParser m Blocks
+bulletList = B.bulletList <$>
+ ( many1 (listItem '*')
+ <|> (htmlTag (~== TagOpen "ul" []) *> spaces *> many (listItem '*' <|> li) <*
+ optional (htmlTag (~== TagClose "ul"))) )
+
+orderedList :: PandocMonad m => MWParser m Blocks
+orderedList =
+ (B.orderedList <$> many1 (listItem '#'))
+ <|> try
+ (do (tag,_) <- htmlTag (~== TagOpen "ol" [])
+ spaces
+ items <- many (listItem '#' <|> li)
+ optional (htmlTag (~== TagClose "ol"))
+ let start = fromMaybe 1 $ safeRead $ fromAttrib "start" tag
+ return $ B.orderedListWith (start, DefaultStyle, DefaultDelim) items)
+
+definitionList :: PandocMonad m => MWParser m Blocks
+definitionList = B.definitionList <$> many1 defListItem
+
+defListItem :: PandocMonad m => MWParser m (Inlines, [Blocks])
+defListItem = try $ do
+ terms <- mconcat . intersperse B.linebreak <$> many defListTerm
+ -- we allow dd with no dt, or dt with no dd
+ defs <- if B.isNull terms
+ then notFollowedBy
+ (try $ skipMany1 (char ':') >> string "<math>") *>
+ many1 (listItem ':')
+ else many (listItem ':')
+ return (terms, defs)
+
+defListTerm :: PandocMonad m => MWParser m Inlines
+defListTerm = char ';' >> skipMany spaceChar >> anyLine >>=
+ parseFromString (trimInlines . mconcat <$> many inline)
+
+listStart :: PandocMonad m => Char -> MWParser m ()
+listStart c = char c *> notFollowedBy listStartChar
+
+listStartChar :: PandocMonad m => MWParser m Char
+listStartChar = oneOf "*#;:"
+
+anyListStart :: PandocMonad m => MWParser m Char
+anyListStart = char '*'
+ <|> char '#'
+ <|> char ':'
+ <|> char ';'
+
+li :: PandocMonad m => MWParser m Blocks
+li = lookAhead (htmlTag (~== TagOpen "li" [])) *>
+ (firstParaToPlain <$> blocksInTags "li") <* spaces
+
+listItem :: PandocMonad m => Char -> MWParser m Blocks
+listItem c = try $ do
+ extras <- many (try $ char c <* lookAhead listStartChar)
+ if null extras
+ then listItem' c
+ else do
+ skipMany spaceChar
+ first <- concat <$> manyTill listChunk newline
+ rest <- many
+ (try $ string extras *> lookAhead listStartChar *>
+ (concat <$> manyTill listChunk newline))
+ contents <- parseFromString (many1 $ listItem' c)
+ (unlines (first : rest))
+ case c of
+ '*' -> return $ B.bulletList contents
+ '#' -> return $ B.orderedList contents
+ ':' -> return $ B.definitionList [(mempty, contents)]
+ _ -> mzero
+
+-- The point of this is to handle stuff like
+-- * {{cite book
+-- | blah
+-- | blah
+-- }}
+-- * next list item
+-- which seems to be valid mediawiki.
+listChunk :: PandocMonad m => MWParser m String
+listChunk = template <|> count 1 anyChar
+
+listItem' :: PandocMonad m => Char -> MWParser m Blocks
+listItem' c = try $ do
+ listStart c
+ skipMany spaceChar
+ first <- concat <$> manyTill listChunk newline
+ rest <- many (try $ char c *> lookAhead listStartChar *>
+ (concat <$> manyTill listChunk newline))
+ parseFromString (firstParaToPlain . mconcat <$> many1 block)
+ $ unlines $ first : rest
+
+firstParaToPlain :: Blocks -> Blocks
+firstParaToPlain contents =
+ case viewl (B.unMany contents) of
+ (Para xs) :< ys -> B.Many $ (Plain xs) <| ys
+ _ -> contents
+
+--
+-- inline parsers
+--
+
+inline :: PandocMonad m => MWParser m Inlines
+inline = whitespace
+ <|> url
+ <|> str
+ <|> doubleQuotes
+ <|> strong
+ <|> emph
+ <|> image
+ <|> internalLink
+ <|> externalLink
+ <|> math
+ <|> inlineTag
+ <|> B.singleton <$> charRef
+ <|> inlineHtml
+ <|> (B.rawInline "mediawiki" <$> variable)
+ <|> (B.rawInline "mediawiki" <$> template)
+ <|> special
+
+str :: PandocMonad m => MWParser m Inlines
+str = B.str <$> many1 (noneOf $ specialChars ++ spaceChars)
+
+math :: PandocMonad m => MWParser m Inlines
+math = (B.displayMath . trim <$> try (many1 (char ':') >> charsInTags "math"))
+ <|> (B.math . trim <$> charsInTags "math")
+ <|> (B.displayMath . trim <$> try (dmStart *> manyTill anyChar dmEnd))
+ <|> (B.math . trim <$> try (mStart *> manyTill (satisfy (/='\n')) mEnd))
+ where dmStart = string "\\["
+ dmEnd = try (string "\\]")
+ mStart = string "\\("
+ mEnd = try (string "\\)")
+
+variable :: PandocMonad m => MWParser m String
+variable = try $ do
+ string "{{{"
+ contents <- manyTill anyChar (try $ string "}}}")
+ return $ "{{{" ++ contents ++ "}}}"
+
+inlineTag :: PandocMonad m => MWParser m Inlines
+inlineTag = do
+ (tag, _) <- lookAhead $ htmlTag isInlineTag'
+ case tag of
+ TagOpen "ref" _ -> B.note . B.plain <$> inlinesInTags "ref"
+ TagOpen "nowiki" _ -> try $ do
+ (_,raw) <- htmlTag (~== tag)
+ if '/' `elem` raw
+ then return mempty
+ else B.text . fromEntities <$>
+ manyTill anyChar (htmlTag (~== TagClose "nowiki"))
+ TagOpen "br" _ -> B.linebreak <$ (htmlTag (~== TagOpen "br" []) -- will get /> too
+ *> optional blankline)
+ TagOpen "strike" _ -> B.strikeout <$> inlinesInTags "strike"
+ TagOpen "del" _ -> B.strikeout <$> inlinesInTags "del"
+ TagOpen "sub" _ -> B.subscript <$> inlinesInTags "sub"
+ TagOpen "sup" _ -> B.superscript <$> inlinesInTags "sup"
+ TagOpen "code" _ -> encode <$> inlinesInTags "code"
+ TagOpen "tt" _ -> encode <$> inlinesInTags "tt"
+ TagOpen "hask" _ -> B.codeWith ("",["haskell"],[]) <$> charsInTags "hask"
+ _ -> B.rawInline "html" . snd <$> htmlTag (~== tag)
+
+special :: PandocMonad m => MWParser m Inlines
+special = B.str <$> count 1 (notFollowedBy' (htmlTag isBlockTag') *>
+ oneOf specialChars)
+
+inlineHtml :: PandocMonad m => MWParser m Inlines
+inlineHtml = B.rawInline "html" . snd <$> htmlTag isInlineTag'
+
+whitespace :: PandocMonad m => MWParser m Inlines
+whitespace = B.space <$ (skipMany1 spaceChar <|> htmlComment)
+ <|> B.softbreak <$ endline
+
+endline :: PandocMonad m => MWParser m ()
+endline = () <$ try (newline <*
+ notFollowedBy spaceChar <*
+ notFollowedBy newline <*
+ notFollowedBy' hrule <*
+ notFollowedBy tableStart <*
+ notFollowedBy' header <*
+ notFollowedBy anyListStart)
+
+imageIdentifiers :: PandocMonad m => [MWParser m ()]
+imageIdentifiers = [sym (identifier ++ ":") | identifier <- identifiers]
+ where identifiers = ["File", "Image", "Archivo", "Datei", "Fichier",
+ "Bild"]
+
+image :: PandocMonad m => MWParser m Inlines
+image = try $ do
+ sym "[["
+ choice imageIdentifiers
+ fname <- addUnderscores <$> many1 (noneOf "|]")
+ _ <- many imageOption
+ dims <- try (char '|' *> (sepBy (many digit) (char 'x')) <* string "px")
+ <|> return []
+ _ <- many imageOption
+ let kvs = case dims of
+ w:[] -> [("width", w)]
+ w:(h:[]) -> [("width", w), ("height", h)]
+ _ -> []
+ let attr = ("", [], kvs)
+ caption <- (B.str fname <$ sym "]]")
+ <|> try (char '|' *> (mconcat <$> manyTill inline (sym "]]")))
+ return $ B.imageWith attr fname ("fig:" ++ stringify caption) caption
+
+imageOption :: PandocMonad m => MWParser m String
+imageOption = try $ char '|' *> opt
+ where
+ opt = try (oneOfStrings [ "border", "thumbnail", "frameless"
+ , "thumb", "upright", "left", "right"
+ , "center", "none", "baseline", "sub"
+ , "super", "top", "text-top", "middle"
+ , "bottom", "text-bottom" ])
+ <|> try (string "frame")
+ <|> try (oneOfStrings ["link=","alt=","page=","class="] <* many (noneOf "|]"))
+
+collapseUnderscores :: String -> String
+collapseUnderscores [] = []
+collapseUnderscores ('_':'_':xs) = collapseUnderscores ('_':xs)
+collapseUnderscores (x:xs) = x : collapseUnderscores xs
+
+addUnderscores :: String -> String
+addUnderscores = collapseUnderscores . intercalate "_" . words
+
+internalLink :: PandocMonad m => MWParser m Inlines
+internalLink = try $ do
+ sym "[["
+ pagename <- unwords . words <$> many (noneOf "|]")
+ label <- option (B.text pagename) $ char '|' *>
+ ( (mconcat <$> many1 (notFollowedBy (char ']') *> inline))
+ -- the "pipe trick"
+ -- [[Help:Contents|] -> "Contents"
+ <|> (return $ B.text $ drop 1 $ dropWhile (/=':') pagename) )
+ sym "]]"
+ linktrail <- B.text <$> many letter
+ let link = B.link (addUnderscores pagename) "wikilink" (label <> linktrail)
+ if "Category:" `isPrefixOf` pagename
+ then do
+ updateState $ \st -> st{ mwCategoryLinks = link : mwCategoryLinks st }
+ return mempty
+ else return link
+
+externalLink :: PandocMonad m => MWParser m Inlines
+externalLink = try $ do
+ char '['
+ (_, src) <- uri
+ lab <- try (trimInlines . mconcat <$>
+ (skipMany1 spaceChar *> manyTill inline (char ']')))
+ <|> do char ']'
+ num <- mwNextLinkNumber <$> getState
+ updateState $ \st -> st{ mwNextLinkNumber = num + 1 }
+ return $ B.str $ show num
+ return $ B.link src "" lab
+
+url :: PandocMonad m => MWParser m Inlines
+url = do
+ (orig, src) <- uri
+ return $ B.link src "" (B.str orig)
+
+-- | Parses a list of inlines between start and end delimiters.
+inlinesBetween :: (PandocMonad m, Show b) => MWParser m a -> MWParser m b -> MWParser m Inlines
+inlinesBetween start end =
+ (trimInlines . mconcat) <$> try (start >> many1Till inner end)
+ where inner = innerSpace <|> (notFollowedBy' (() <$ whitespace) >> inline)
+ innerSpace = try $ whitespace <* notFollowedBy' end
+
+emph :: PandocMonad m => MWParser m Inlines
+emph = B.emph <$> nested (inlinesBetween start end)
+ where start = sym "''" >> lookAhead nonspaceChar
+ end = try $ notFollowedBy' (() <$ strong) >> sym "''"
+
+strong :: PandocMonad m => MWParser m Inlines
+strong = B.strong <$> nested (inlinesBetween start end)
+ where start = sym "'''" >> lookAhead nonspaceChar
+ end = try $ sym "'''"
+
+doubleQuotes :: PandocMonad m => MWParser m Inlines
+doubleQuotes = B.doubleQuoted <$> nested (inlinesBetween openDoubleQuote closeDoubleQuote)
+ where openDoubleQuote = sym "\"" >> lookAhead nonspaceChar
+ closeDoubleQuote = try $ sym "\""
diff --git a/src/Text/Pandoc/Readers/Native.hs b/src/Text/Pandoc/Readers/Native.hs
new file mode 100644
index 000000000..1953c0c83
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Native.hs
@@ -0,0 +1,71 @@
+{-
+Copyright (C) 2011-2015 John MacFarlane <jgm@berkeley.edu>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; Either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Readers.Native
+ Copyright : Copyright (C) 2011-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of a string representation of a pandoc type (@Pandoc@,
+@[Block]@, @Block@, @[Inline]@, or @Inline@) to a @Pandoc@ document.
+-}
+module Text.Pandoc.Readers.Native ( readNative ) where
+
+import Text.Pandoc.Definition
+import Text.Pandoc.Shared (safeRead)
+import Text.Pandoc.Options (ReaderOptions)
+
+import Control.Monad.Except (throwError)
+import Text.Pandoc.Error
+import Text.Pandoc.Class
+
+-- | Read native formatted text and return a Pandoc document.
+-- The input may be a full pandoc document, a block list, a block,
+-- an inline list, or an inline. Thus, for example,
+--
+-- > Str "hi"
+--
+-- will be treated as if it were
+--
+-- > Pandoc nullMeta [Plain [Str "hi"]]
+--
+readNative :: PandocMonad m
+ => ReaderOptions
+ -> String -- ^ String to parse (assuming @'\n'@ line endings)
+ -> m Pandoc
+readNative _ s =
+ case maybe (Pandoc nullMeta <$> readBlocks s) Right (safeRead s) of
+ Right doc -> return doc
+ Left _ -> throwError $ PandocParseError "couldn't read native"
+
+readBlocks :: String -> Either PandocError [Block]
+readBlocks s = maybe ((:[]) <$> readBlock s) Right (safeRead s)
+
+readBlock :: String -> Either PandocError Block
+readBlock s = maybe (Plain <$> readInlines s) Right (safeRead s)
+
+readInlines :: String -> Either PandocError [Inline]
+readInlines s = maybe ((:[]) <$> readInline s) Right (safeRead s)
+
+readInline :: String -> Either PandocError Inline
+readInline s = maybe (Left . PandocParseError $ "Could not read: " ++ s) Right (safeRead s)
+
diff --git a/src/Text/Pandoc/Readers/OPML.hs b/src/Text/Pandoc/Readers/OPML.hs
new file mode 100644
index 000000000..cec64895c
--- /dev/null
+++ b/src/Text/Pandoc/Readers/OPML.hs
@@ -0,0 +1,103 @@
+{-# LANGUAGE FlexibleContexts #-}
+module Text.Pandoc.Readers.OPML ( readOPML ) where
+import Data.Char (toUpper)
+import Text.Pandoc.Options
+import Text.Pandoc.Definition
+import Text.Pandoc.Builder
+import Text.Pandoc.Readers.HTML (readHtml)
+import Text.Pandoc.Readers.Markdown (readMarkdown)
+import Text.XML.Light
+import Text.HTML.TagSoup.Entity (lookupEntity)
+import Data.Generics
+import Control.Monad.State
+import Data.Default
+import Text.Pandoc.Class (PandocMonad)
+
+type OPML m = StateT OPMLState m
+
+data OPMLState = OPMLState{
+ opmlSectionLevel :: Int
+ , opmlDocTitle :: Inlines
+ , opmlDocAuthors :: [Inlines]
+ , opmlDocDate :: Inlines
+ } deriving Show
+
+instance Default OPMLState where
+ def = OPMLState{ opmlSectionLevel = 0
+ , opmlDocTitle = mempty
+ , opmlDocAuthors = []
+ , opmlDocDate = mempty
+ }
+
+readOPML :: PandocMonad m => ReaderOptions -> String -> m Pandoc
+readOPML _ inp = do
+ (bs, st') <- flip runStateT def (mapM parseBlock $ normalizeTree $ parseXML inp)
+ return $
+ setTitle (opmlDocTitle st') $
+ setAuthors (opmlDocAuthors st') $
+ setDate (opmlDocDate st') $
+ doc $ mconcat bs
+
+-- normalize input, consolidating adjacent Text and CRef elements
+normalizeTree :: [Content] -> [Content]
+normalizeTree = everywhere (mkT go)
+ where go :: [Content] -> [Content]
+ go (Text (CData CDataRaw _ _):xs) = xs
+ go (Text (CData CDataText s1 z):Text (CData CDataText s2 _):xs) =
+ Text (CData CDataText (s1 ++ s2) z):xs
+ go (Text (CData CDataText s1 z):CRef r:xs) =
+ Text (CData CDataText (s1 ++ convertEntity r) z):xs
+ go (CRef r:Text (CData CDataText s1 z):xs) =
+ Text (CData CDataText (convertEntity r ++ s1) z):xs
+ go (CRef r1:CRef r2:xs) =
+ Text (CData CDataText (convertEntity r1 ++ convertEntity r2) Nothing):xs
+ go xs = xs
+
+convertEntity :: String -> String
+convertEntity e = maybe (map toUpper e) id (lookupEntity e)
+
+-- convenience function to get an attribute value, defaulting to ""
+attrValue :: String -> Element -> String
+attrValue attr elt =
+ case lookupAttrBy (\x -> qName x == attr) (elAttribs elt) of
+ Just z -> z
+ Nothing -> ""
+
+-- exceptT :: PandocMonad m => Either PandocError a -> OPML m a
+-- exceptT = either throwError return
+
+asHtml :: PandocMonad m => String -> OPML m Inlines
+asHtml s =
+ (\(Pandoc _ bs) -> case bs of
+ [Plain ils] -> fromList ils
+ _ -> mempty) <$> (lift $ readHtml def s)
+
+asMarkdown :: PandocMonad m => String -> OPML m Blocks
+asMarkdown s = (\(Pandoc _ bs) -> fromList bs) <$> (lift $ readMarkdown def s)
+
+getBlocks :: PandocMonad m => Element -> OPML m Blocks
+getBlocks e = mconcat <$> (mapM parseBlock $ elContent e)
+
+parseBlock :: PandocMonad m => Content -> OPML m Blocks
+parseBlock (Elem e) =
+ case qName (elName e) of
+ "ownerName" -> mempty <$ modify (\st ->
+ st{opmlDocAuthors = [text $ strContent e]})
+ "dateModified" -> mempty <$ modify (\st ->
+ st{opmlDocDate = text $ strContent e})
+ "title" -> mempty <$ modify (\st ->
+ st{opmlDocTitle = text $ strContent e})
+ "outline" -> gets opmlSectionLevel >>= sect . (+1)
+ "?xml" -> return mempty
+ _ -> getBlocks e
+ where sect n = do headerText <- asHtml $ attrValue "text" e
+ noteBlocks <- asMarkdown $ attrValue "_note" e
+ modify $ \st -> st{ opmlSectionLevel = n }
+ bs <- getBlocks e
+ modify $ \st -> st{ opmlSectionLevel = n - 1 }
+ let headerText' = case map toUpper (attrValue "type" e) of
+ "LINK" -> link
+ (attrValue "url" e) "" headerText
+ _ -> headerText
+ return $ header n headerText' <> noteBlocks <> bs
+parseBlock _ = return mempty
diff --git a/src/Text/Pandoc/Readers/Odt.hs b/src/Text/Pandoc/Readers/Odt.hs
new file mode 100644
index 000000000..ac22f2c09
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Odt.hs
@@ -0,0 +1,113 @@
+{-# LANGUAGE PatternGuards #-}
+
+{-
+Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Reader.Odt
+ Copyright : Copyright (C) 2015 Martin Linnemann
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Martin Linnemann <theCodingMarlin@googlemail.com>
+ Stability : alpha
+ Portability : portable
+
+Entry point to the odt reader.
+-}
+
+module Text.Pandoc.Readers.Odt ( readOdt ) where
+
+import Codec.Archive.Zip
+import qualified Text.XML.Light as XML
+
+import qualified Data.ByteString.Lazy as B
+
+import System.FilePath
+
+import Control.Monad.Except (throwError)
+
+import Text.Pandoc.Class (PandocMonad)
+import qualified Text.Pandoc.Class as P
+import Text.Pandoc.Definition
+import Text.Pandoc.Error
+import Text.Pandoc.Options
+import Text.Pandoc.MediaBag
+import qualified Text.Pandoc.UTF8 as UTF8
+
+import Text.Pandoc.Readers.Odt.ContentReader
+import Text.Pandoc.Readers.Odt.StyleReader
+
+import Text.Pandoc.Readers.Odt.Generic.XMLConverter
+import Text.Pandoc.Readers.Odt.Generic.Fallible
+import Text.Pandoc.Shared (filteredFilesFromArchive)
+
+readOdt :: PandocMonad m
+ => ReaderOptions
+ -> B.ByteString
+ -> m Pandoc
+readOdt opts bytes = case readOdt' opts bytes of
+ Right (doc, mb) -> do
+ P.setMediaBag mb
+ return doc
+ Left e -> throwError e
+
+--
+readOdt' :: ReaderOptions
+ -> B.ByteString
+ -> Either PandocError (Pandoc, MediaBag)
+readOdt' _ bytes = bytesToOdt bytes-- of
+-- Right (pandoc, mediaBag) -> Right (pandoc , mediaBag)
+-- Left err -> Left err
+
+--
+bytesToOdt :: B.ByteString -> Either PandocError (Pandoc, MediaBag)
+bytesToOdt bytes = case toArchiveOrFail bytes of
+ Right archive -> archiveToOdt archive
+ Left _ -> Left $ PandocParseError "Couldn't parse odt file."
+
+--
+archiveToOdt :: Archive -> Either PandocError (Pandoc, MediaBag)
+archiveToOdt archive
+ | Just contentEntry <- findEntryByPath "content.xml" archive
+ , Just stylesEntry <- findEntryByPath "styles.xml" archive
+ , Just contentElem <- entryToXmlElem contentEntry
+ , Just stylesElem <- entryToXmlElem stylesEntry
+ , Right styles <- chooseMax (readStylesAt stylesElem )
+ (readStylesAt contentElem)
+ , media <- filteredFilesFromArchive archive filePathIsOdtMedia
+ , startState <- readerState styles media
+ , Right pandocWithMedia <- runConverter' read_body
+ startState
+ contentElem
+
+ = Right pandocWithMedia
+
+ | otherwise
+ -- Not very detailed, but I don't think more information would be helpful
+ = Left $ PandocParseError "Couldn't parse odt file."
+ where
+ filePathIsOdtMedia :: FilePath -> Bool
+ filePathIsOdtMedia fp =
+ let (dir, _) = splitFileName fp
+ in
+ (dir == "Pictures/")
+
+
+--
+entryToXmlElem :: Entry -> Maybe XML.Element
+entryToXmlElem = XML.parseXMLDoc . UTF8.toStringLazy . fromEntry
diff --git a/src/Text/Pandoc/Readers/Odt/Arrows/State.hs b/src/Text/Pandoc/Readers/Odt/Arrows/State.hs
new file mode 100644
index 000000000..b056f1ecc
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Odt/Arrows/State.hs
@@ -0,0 +1,253 @@
+{-# LANGUAGE Arrows #-}
+{-# LANGUAGE TupleSections #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-
+Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Readers.Odt.Arrows.State
+ Copyright : Copyright (C) 2015 Martin Linnemann
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Martin Linnemann <theCodingMarlin@googlemail.com>
+ Stability : alpha
+ Portability : portable
+
+An arrow that transports a state. It is in essence a more powerful version of
+the standard state monad. As it is such a simple extension, there are
+other version out there that do exactly the same.
+The implementation is duplicated, though, to add some useful features.
+Most of these might be implemented without access to innards, but it's much
+faster and easier to implement this way.
+-}
+
+module Text.Pandoc.Readers.Odt.Arrows.State where
+
+import Prelude hiding ( foldr, foldl )
+
+import qualified Control.Category as Cat
+import Control.Arrow
+import Control.Monad
+
+import Data.Foldable
+import Data.Monoid
+
+import Text.Pandoc.Readers.Odt.Arrows.Utils
+import Text.Pandoc.Readers.Odt.Generic.Fallible
+
+
+newtype ArrowState state a b = ArrowState
+ { runArrowState :: (state, a) -> (state, b) }
+
+-- | Constructor
+withState :: (state -> a -> (state, b)) -> ArrowState state a b
+withState = ArrowState . uncurry
+
+-- | Constructor
+withState' :: ((state, a) -> (state, b)) -> ArrowState state a b
+withState' = ArrowState
+
+-- | Constructor
+modifyState :: (state -> state ) -> ArrowState state a a
+modifyState = ArrowState . first
+
+-- | Constructor
+ignoringState :: ( a -> b ) -> ArrowState state a b
+ignoringState = ArrowState . second
+
+-- | Constructor
+fromState :: (state -> (state, b)) -> ArrowState state a b
+fromState = ArrowState . (.fst)
+
+-- | Constructor
+extractFromState :: (state -> b ) -> ArrowState state x b
+extractFromState f = ArrowState $ \(state,_) -> (state, f state)
+
+-- | Constructor
+withUnchangedState :: (state -> a -> b ) -> ArrowState state a b
+withUnchangedState f = ArrowState $ \(state,a) -> (state, f state a)
+
+-- | Constructor
+tryModifyState :: (state -> Either f state)
+ -> ArrowState state a (Either f a)
+tryModifyState f = ArrowState $ \(state,a)
+ -> (state,).Left ||| (,Right a) $ f state
+
+instance Cat.Category (ArrowState s) where
+ id = ArrowState id
+ arrow2 . arrow1 = ArrowState $ (runArrowState arrow2).(runArrowState arrow1)
+
+instance Arrow (ArrowState state) where
+ arr = ignoringState
+ first a = ArrowState $ \(s,(aF,aS))
+ -> second (,aS) $ runArrowState a (s,aF)
+ second a = ArrowState $ \(s,(aF,aS))
+ -> second (aF,) $ runArrowState a (s,aS)
+
+instance ArrowChoice (ArrowState state) where
+ left a = ArrowState $ \(s,e) -> case e of
+ Left l -> second Left $ runArrowState a (s,l)
+ Right r -> (s, Right r)
+ right a = ArrowState $ \(s,e) -> case e of
+ Left l -> (s, Left l)
+ Right r -> second Right $ runArrowState a (s,r)
+
+instance ArrowLoop (ArrowState state) where
+ loop a = ArrowState $ \(s, x)
+ -> let (s', (x', _d)) = runArrowState a (s, (x, _d))
+ in (s', x')
+
+instance ArrowApply (ArrowState state) where
+ app = ArrowState $ \(s, (f,b)) -> runArrowState f (s,b)
+
+
+-- | Embedding of a state arrow in a state arrow with a different state type.
+switchState :: (s -> s') -> (s' -> s) -> ArrowState s' x y -> ArrowState s x y
+switchState there back a = ArrowState $ first there
+ >>> runArrowState a
+ >>> first back
+
+-- | Lift a state arrow to modify the state of an arrow
+-- with a different state type.
+liftToState :: (s -> s') -> ArrowState s' s s -> ArrowState s x x
+liftToState unlift a = modifyState $ unlift &&& id
+ >>> runArrowState a
+ >>> snd
+
+-- | Switches the type of the state temporarily.
+-- Drops the intermediate result state, behaving like the identity arrow,
+-- save for side effects in the state.
+withSubState :: ArrowState s x s2 -> ArrowState s2 s s -> ArrowState s x x
+withSubState unlift a = keepingTheValue (withSubState unlift a) >>^ fst
+
+-- | Switches the type of the state temporarily.
+-- Returns the resulting sub-state.
+withSubState' :: ArrowState s x s' -> ArrowState s' s s -> ArrowState s x s'
+withSubState' unlift a = ArrowState $ runArrowState unlift
+ >>> switch
+ >>> runArrowState a
+ >>> switch
+ where switch (x,y) = (y,x)
+
+-- | Switches the type of the state temporarily.
+-- Drops the intermediate result state, behaving like a fallible
+-- identity arrow, save for side effects in the state.
+withSubStateF :: ArrowState s x (Either f s')
+ -> ArrowState s' s (Either f s )
+ -> ArrowState s x (Either f x )
+withSubStateF unlift a = keepingTheValue (withSubStateF' unlift a)
+ >>^ spreadChoice
+ >>^ fmap fst
+
+-- | Switches the type of the state temporarily.
+-- Returns the resulting sub-state.
+withSubStateF' :: ArrowState s x (Either f s')
+ -> ArrowState s' s (Either f s )
+ -> ArrowState s x (Either f s')
+withSubStateF' unlift a = ArrowState go
+ where go p@(s,_) = tryRunning unlift
+ ( tryRunning a (second Right) )
+ p
+ where tryRunning a' b v = case runArrowState a' v of
+ (_ , Left f) -> (s, Left f)
+ (x , Right y) -> b (y,x)
+
+-- | Fold a state arrow through something 'Foldable'. Collect the results
+-- in a 'Monoid'.
+-- Intermediate form of a fold between one with "only" a 'Monoid'
+-- and one with any function.
+foldS :: (Foldable f, Monoid m) => ArrowState s x m -> ArrowState s (f x) m
+foldS a = ArrowState $ \(s,f) -> foldr a' (s,mempty) f
+ where a' x (s',m) = second (m <>) $ runArrowState a (s',x)
+
+-- | Fold a state arrow through something 'Foldable'. Collect the results
+-- in a 'Monoid'.
+-- Intermediate form of a fold between one with "only" a 'Monoid'
+-- and one with any function.
+foldSL :: (Foldable f, Monoid m) => ArrowState s x m -> ArrowState s (f x) m
+foldSL a = ArrowState $ \(s,f) -> foldl a' (s,mempty) f
+ where a' (s',m) x = second (m <>) $ runArrowState a (s',x)
+
+-- | Fold a fallible state arrow through something 'Foldable'. Collect the
+-- results in a 'Monoid'.
+-- Intermediate form of a fold between one with "only" a 'Monoid'
+-- and one with any function.
+-- If the iteration fails, the state will be reset to the initial one.
+foldS' :: (Foldable f, Monoid m)
+ => ArrowState s x (Either e m)
+ -> ArrowState s (f x) (Either e m)
+foldS' a = ArrowState $ \(s,f) -> foldr (a' s) (s,Right mempty) f
+ where a' s x (s',Right m) = case runArrowState a (s',x) of
+ (s'',Right m') -> (s'', Right (m <> m'))
+ (_ ,Left e ) -> (s , Left e)
+ a' _ _ e = e
+
+-- | Fold a fallible state arrow through something 'Foldable'. Collect the
+-- results in a 'Monoid'.
+-- Intermediate form of a fold between one with "only" a 'Monoid'
+-- and one with any function.
+-- If the iteration fails, the state will be reset to the initial one.
+foldSL' :: (Foldable f, Monoid m)
+ => ArrowState s x (Either e m)
+ -> ArrowState s (f x) (Either e m)
+foldSL' a = ArrowState $ \(s,f) -> foldl (a' s) (s,Right mempty) f
+ where a' s (s',Right m) x = case runArrowState a (s',x) of
+ (s'',Right m') -> (s'', Right (m <> m'))
+ (_ ,Left e ) -> (s , Left e)
+ a' _ e _ = e
+
+-- | Fold a state arrow through something 'Foldable'. Collect the results in a
+-- 'MonadPlus'.
+iterateS :: (Foldable f, MonadPlus m)
+ => ArrowState s x y
+ -> ArrowState s (f x) (m y)
+iterateS a = ArrowState $ \(s,f) -> foldr a' (s,mzero) f
+ where a' x (s',m) = second ((mplus m).return) $ runArrowState a (s',x)
+
+-- | Fold a state arrow through something 'Foldable'. Collect the results in a
+-- 'MonadPlus'.
+iterateSL :: (Foldable f, MonadPlus m)
+ => ArrowState s x y
+ -> ArrowState s (f x) (m y)
+iterateSL a = ArrowState $ \(s,f) -> foldl a' (s,mzero) f
+ where a' (s',m) x = second ((mplus m).return) $ runArrowState a (s',x)
+
+
+-- | Fold a fallible state arrow through something 'Foldable'.
+-- Collect the results in a 'MonadPlus'.
+-- If the iteration fails, the state will be reset to the initial one.
+iterateS' :: (Foldable f, MonadPlus m)
+ => ArrowState s x (Either e y )
+ -> ArrowState s (f x) (Either e (m y))
+iterateS' a = ArrowState $ \(s,f) -> foldr (a' s) (s,Right mzero) f
+ where a' s x (s',Right m) = case runArrowState a (s',x) of
+ (s'',Right m') -> (s'',Right $ mplus m $ return m')
+ (_ ,Left e ) -> (s ,Left e )
+ a' _ _ e = e
+
+-- | Fold a fallible state arrow through something 'Foldable'.
+-- Collect the results in a 'MonadPlus'.
+-- If the iteration fails, the state will be reset to the initial one.
+iterateSL' :: (Foldable f, MonadPlus m)
+ => ArrowState s x (Either e y )
+ -> ArrowState s (f x) (Either e (m y))
+iterateSL' a = ArrowState $ \(s,f) -> foldl (a' s) (s,Right mzero) f
+ where a' s (s',Right m) x = case runArrowState a (s',x) of
+ (s'',Right m') -> (s'',Right $ mplus m $ return m')
+ (_ ,Left e ) -> (s ,Left e )
+ a' _ e _ = e
diff --git a/src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs b/src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs
new file mode 100644
index 000000000..218a85661
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs
@@ -0,0 +1,495 @@
+{-
+Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Readers.Odt.Arrows.Utils
+ Copyright : Copyright (C) 2015 Martin Linnemann
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Martin Linnemann <theCodingMarlin@googlemail.com>
+ Stability : alpha
+ Portability : portable
+
+Utility functions for Arrows (Kleisli monads).
+
+Some general notes on notation:
+
+* "^" is meant to stand for a pure function that is lifted into an arrow
+based on its usage for that purpose in "Control.Arrow".
+* "?" is meant to stand for the usage of a 'FallibleArrow' or a pure function
+with an equivalent return value.
+* "_" stands for the dropping of a value.
+-}
+
+-- We export everything
+module Text.Pandoc.Readers.Odt.Arrows.Utils where
+
+import Control.Arrow
+import Control.Monad ( join, MonadPlus(..) )
+
+import qualified Data.Foldable as F
+import Data.Monoid
+
+import Text.Pandoc.Readers.Odt.Generic.Fallible
+import Text.Pandoc.Readers.Odt.Generic.Utils
+
+and2 :: (Arrow a) => a b c -> a b c' -> a b (c,c')
+and2 = (&&&)
+
+and3 :: (Arrow a)
+ => a b c0->a b c1->a b c2
+ -> a b (c0,c1,c2 )
+and4 :: (Arrow a)
+ => a b c0->a b c1->a b c2->a b c3
+ -> a b (c0,c1,c2,c3 )
+and5 :: (Arrow a)
+ => a b c0->a b c1->a b c2->a b c3->a b c4
+ -> a b (c0,c1,c2,c3,c4 )
+and6 :: (Arrow a)
+ => a b c0->a b c1->a b c2->a b c3->a b c4->a b c5
+ -> a b (c0,c1,c2,c3,c4,c5 )
+and7 :: (Arrow a)
+ => a b c0->a b c1->a b c2->a b c3->a b c4->a b c5->a b c6
+ -> a b (c0,c1,c2,c3,c4,c5,c6 )
+and8 :: (Arrow a)
+ => a b c0->a b c1->a b c2->a b c3->a b c4->a b c5->a b c6->a b c7
+ -> a b (c0,c1,c2,c3,c4,c5,c6,c7)
+
+and3 a b c = (and2 a b ) &&& c
+ >>^ \((z,y ) , x) -> (z,y,x )
+and4 a b c d = (and3 a b c ) &&& d
+ >>^ \((z,y,x ) , w) -> (z,y,x,w )
+and5 a b c d e = (and4 a b c d ) &&& e
+ >>^ \((z,y,x,w ) , v) -> (z,y,x,w,v )
+and6 a b c d e f = (and5 a b c d e ) &&& f
+ >>^ \((z,y,x,w,v ) , u) -> (z,y,x,w,v,u )
+and7 a b c d e f g = (and6 a b c d e f ) &&& g
+ >>^ \((z,y,x,w,v,u ) , t) -> (z,y,x,w,v,u,t )
+and8 a b c d e f g h = (and7 a b c d e f g) &&& h
+ >>^ \((z,y,x,w,v,u,t) , s) -> (z,y,x,w,v,u,t,s)
+
+liftA2 :: (Arrow a) => (x -> y -> z) -> a b x -> a b y -> a b z
+liftA2 f a b = a &&& b >>^ uncurry f
+
+liftA3 :: (Arrow a) => (z->y->x -> r)
+ -> a b z->a b y->a b x
+ -> a b r
+liftA4 :: (Arrow a) => (z->y->x->w -> r)
+ -> a b z->a b y->a b x->a b w
+ -> a b r
+liftA5 :: (Arrow a) => (z->y->x->w->v -> r)
+ -> a b z->a b y->a b x->a b w->a b v
+ -> a b r
+liftA6 :: (Arrow a) => (z->y->x->w->v->u -> r)
+ -> a b z->a b y->a b x->a b w->a b v->a b u
+ -> a b r
+liftA7 :: (Arrow a) => (z->y->x->w->v->u->t -> r)
+ -> a b z->a b y->a b x->a b w->a b v->a b u->a b t
+ -> a b r
+liftA8 :: (Arrow a) => (z->y->x->w->v->u->t->s -> r)
+ -> a b z->a b y->a b x->a b w->a b v->a b u->a b t->a b s
+ -> a b r
+
+liftA3 fun a b c = and3 a b c >>^ uncurry3 fun
+liftA4 fun a b c d = and4 a b c d >>^ uncurry4 fun
+liftA5 fun a b c d e = and5 a b c d e >>^ uncurry5 fun
+liftA6 fun a b c d e f = and6 a b c d e f >>^ uncurry6 fun
+liftA7 fun a b c d e f g = and7 a b c d e f g >>^ uncurry7 fun
+liftA8 fun a b c d e f g h = and8 a b c d e f g h >>^ uncurry8 fun
+
+liftA :: (Arrow a) => (y -> z) -> a b y -> a b z
+liftA fun a = a >>^ fun
+
+
+-- | Duplicate a value to subsequently feed it into different arrows.
+-- Can almost always be replaced with '(&&&)', 'keepingTheValue',
+-- or even '(|||)'.
+-- Aequivalent to
+-- > returnA &&& returnA
+duplicate :: (Arrow a) => a b (b,b)
+duplicate = arr $ join (,)
+
+-- | Lifts the combination of two values into an arrow.
+joinOn :: (Arrow a) => (x -> y -> z) -> a (x,y) z
+joinOn = arr.uncurry
+
+-- | Applies a function to the uncurried result-pair of an arrow-application.
+-- (The %-symbol was chosen to evoke an association with pairs.)
+(>>%) :: (Arrow a) => a x (b,c) -> (b -> c -> d) -> a x d
+a >>% f = a >>^ uncurry f
+
+-- | '(>>%)' with its arguments flipped
+(%<<) :: (Arrow a) => (b -> c -> d) -> a x (b,c) -> a x d
+(%<<) = flip (>>%)
+
+-- | Precomposition with an uncurried function
+(%>>) :: (Arrow a) => (b -> c -> d) -> a d r -> a (b,c) r
+f %>> a = uncurry f ^>> a
+
+-- | Precomposition with an uncurried function (right to left variant)
+(<<%) :: (Arrow a) => a d r -> (b -> c -> d) -> a (b,c) r
+(<<%) = flip (%>>)
+
+infixr 2 >>%, %<<, %>>, <<%
+
+
+-- | Duplicate a value and apply an arrow to the second instance.
+-- Aequivalent to
+-- > \a -> duplicate >>> second a
+-- or
+-- > \a -> returnA &&& a
+keepingTheValue :: (Arrow a) => a b c -> a b (b,c)
+keepingTheValue a = returnA &&& a
+
+-- | Duplicate a value and apply an arrow to the first instance.
+-- Aequivalent to
+-- > \a -> duplicate >>> first a
+-- or
+-- > \a -> a &&& returnA
+keepingTheValue' :: (Arrow a) => a b c -> a b (c,b)
+keepingTheValue' a = a &&& returnA
+
+-- | 'bind' from the "Maybe"-Monad lifted into an 'ArrowChoice'.
+-- Actually, it's the more complex '(>=>)', because 'bind' alone does not
+-- combine as nicely in arrow form.
+-- The current implementation is not the most efficient one, because it can
+-- not return directly if a 'Nothing' is encountered. That in turn follows
+-- from the type system, as 'Nothing' has an "invisible" type parameter that
+-- can not be dropped early.
+--
+-- Also, there probably is a way to generalize this to other monads
+-- or applicatives, but I'm leaving that as an exercise to the reader.
+-- I have a feeling there is a new Arrow-typeclass to be found that is less
+-- restrictive than 'ArrowApply'. If it is already out there,
+-- I have not seen it yet. ('ArrowPlus' for example is not general enough.)
+(>>>=) :: (ArrowChoice a) => a x (Maybe b) -> a b (Maybe c) -> a x (Maybe c)
+a1 >>>= a2 = a1 >>> maybeToChoice >>> right a2 >>> choiceToMaybe >>^ join
+
+infixr 2 >>>=
+
+-- | 'mplus' Lifted into an arrow. No 'ArrowPlus' required.
+-- (But still different from a true bind)
+(>++<) :: (Arrow a, MonadPlus m) => a x (m b) -> a x (m b) -> a x (m b)
+(>++<) = liftA2 mplus
+
+-- | Left-compose with a pure function
+leftLift :: (ArrowChoice a) => (l -> l') -> a (Either l r) (Either l' r)
+leftLift = left.arr
+
+-- | Right-compose with a pure function
+rightLift :: (ArrowChoice a) => (r -> r') -> a (Either l r) (Either l r')
+rightLift = right.arr
+
+
+( ^+++ ) :: (ArrowChoice a) => (b -> c) -> a b' c' -> a (Either b b') (Either c c')
+( +++^ ) :: (ArrowChoice a) => a b c -> (b' -> c') -> a (Either b b') (Either c c')
+( ^+++^ ) :: (ArrowChoice a) => (b -> c) -> (b' -> c') -> a (Either b b') (Either c c')
+
+l ^+++ r = leftLift l >>> right r
+l +++^ r = left l >>> rightLift r
+l ^+++^ r = leftLift l >>> rightLift r
+
+infixr 2 ^+++, +++^, ^+++^
+
+( ^||| ) :: (ArrowChoice a) => (b -> d) -> a c d -> a (Either b c) d
+( |||^ ) :: (ArrowChoice a) => a b d -> (c -> d) -> a (Either b c) d
+( ^|||^ ) :: (ArrowChoice a) => (b -> d) -> (c -> d) -> a (Either b c) d
+
+l ^||| r = arr l ||| r
+l |||^ r = l ||| arr r
+l ^|||^ r = arr l ||| arr r
+
+infixr 2 ^||| , |||^, ^|||^
+
+( ^&&& ) :: (Arrow a) => (b -> c) -> a b c' -> a b (c,c')
+( &&&^ ) :: (Arrow a) => a b c -> (b -> c') -> a b (c,c')
+( ^&&&^ ) :: (Arrow a) => (b -> c) -> (b -> c') -> a b (c,c')
+
+l ^&&& r = arr l &&& r
+l &&&^ r = l &&& arr r
+l ^&&&^ r = arr l &&& arr r
+
+infixr 3 ^&&&, &&&^, ^&&&^
+
+( ^*** ) :: (Arrow a) => (b -> c) -> a b' c' -> a (b,b') (c,c')
+( ***^ ) :: (Arrow a) => a b c -> (b' -> c') -> a (b,b') (c,c')
+( ^***^ ) :: (Arrow a) => (b -> c) -> (b' -> c') -> a (b,b') (c,c')
+
+l ^*** r = arr l *** r
+l ***^ r = l *** arr r
+l ^***^ r = arr l *** arr r
+
+infixr 3 ^***, ***^, ^***^
+
+-- | A version of
+--
+-- >>> \p -> arr (\x -> if p x the Right x else Left x)
+--
+-- but with p being an arrow
+choose :: (ArrowChoice a) => a b Bool -> a b (Either b b)
+choose checkValue = keepingTheValue checkValue >>^ select
+ where select (x,True ) = Right x
+ select (x,False ) = Left x
+
+-- | Converts @Right a@ into @Just a@ and @Left _@ into @Nothing@.
+choiceToMaybe :: (ArrowChoice a) => a (Either l r) (Maybe r)
+choiceToMaybe = arr eitherToMaybe
+
+-- | Converts @Nothing@ into @Left ()@ and @Just a@ into @Right a@.
+maybeToChoice :: (ArrowChoice a) => a (Maybe b) (Fallible b)
+maybeToChoice = arr maybeToEither
+
+-- | Lifts a constant value into an arrow
+returnV :: (Arrow a) => c -> a x c
+returnV = arr.const
+
+-- | 'returnA' dropping everything
+returnA_ :: (Arrow a) => a _b ()
+returnA_ = returnV ()
+
+-- | Wrapper for an arrow that can be evaluated im parallel. All
+-- Arrows can be evaluated in parallel, as long as they return a
+-- monoid.
+newtype ParallelArrow a b c = CoEval { evalParallelArrow :: a b c }
+ deriving (Eq, Ord, Show)
+
+instance (Arrow a, Monoid m) => Monoid (ParallelArrow a b m) where
+ mempty = CoEval $ returnV mempty
+ (CoEval a) `mappend` (CoEval ~b) = CoEval $ a &&& b >>% mappend
+
+-- | Evaluates a collection of arrows in a parallel fashion.
+--
+-- This is in essence a fold of '(&&&)' over the collection,
+-- so the actual execution order and parallelity depends on the
+-- implementation of '(&&&)' in the arrow in question.
+-- The default implementation of '(&&&)' for example keeps the
+-- order as given in the collection.
+--
+-- This function can be seen as a generalization of
+-- 'Control.Applicative.sequenceA' to arrows or as an alternative to
+-- a fold with 'Control.Applicative.WrappedArrow', which
+-- substitutes the monoid with function application.
+--
+coEval :: (Arrow a, F.Foldable f, Monoid m) => f (a b m) -> a b m
+coEval = evalParallelArrow . (F.foldMap CoEval)
+
+-- | Defines Left as failure, Right as success
+type FallibleArrow a input failure success = a input (Either failure success)
+
+type ReFallibleArrow a failure success success'
+ = FallibleArrow a (Either failure success) failure success'
+
+-- | Wrapper for fallible arrows. Fallible arrows are all arrows that return
+-- an Either value where left is a faliure and right is a success value.
+newtype AlternativeArrow a input failure success
+ = TryArrow { evalAlternativeArrow :: FallibleArrow a input failure success }
+
+
+instance (ArrowChoice a, Monoid failure)
+ => Monoid (AlternativeArrow a input failure success) where
+ mempty = TryArrow $ returnV $ Left mempty
+ (TryArrow a) `mappend` (TryArrow b)
+ = TryArrow $ a &&& b
+ >>^ \(a',~b')
+ -> ( (\a'' -> left (mappend a'') b') ||| Right )
+ a'
+
+-- | Evaluates a collection of fallible arrows, trying each one in succession.
+-- Left values are interpreted as failures, right values as successes.
+--
+-- The evaluation is stopped once an arrow succeeds.
+-- Up to that point, all failures are collected in the failure-monoid.
+-- Note that '()' is a monoid, and thus can serve as a failure-collector if
+-- you are uninterested in the exact failures.
+--
+-- This is in essence a fold of '(&&&)' over the collection, enhanced with a
+-- little bit of repackaging, so the actual execution order depends on the
+-- implementation of '(&&&)' in the arrow in question.
+-- The default implementation of '(&&&)' for example keeps the
+-- order as given in the collection.
+--
+tryArrows :: (ArrowChoice a, F.Foldable f, Monoid failure)
+ => f (FallibleArrow a b failure success)
+ -> FallibleArrow a b failure success
+tryArrows = evalAlternativeArrow . (F.foldMap TryArrow)
+
+--
+liftSuccess :: (ArrowChoice a)
+ => (success -> success')
+ -> ReFallibleArrow a failure success success'
+liftSuccess = rightLift
+
+--
+liftAsSuccess :: (ArrowChoice a)
+ => a x success
+ -> FallibleArrow a x failure success
+liftAsSuccess a = a >>^ Right
+
+--
+asFallibleArrow :: (ArrowChoice a)
+ => a x success
+ -> FallibleArrow a x failure success
+asFallibleArrow a = a >>^ Right
+
+-- | Raises an error into a 'ReFallibleArrow' if the arrow is already in
+-- "error mode"
+liftError :: (ArrowChoice a, Monoid failure)
+ => failure
+ -> ReFallibleArrow a failure success success
+liftError e = leftLift (e <>)
+
+-- | Raises an error into a 'FallibleArrow', droping both the arrow input
+-- and any previously stored error value.
+_raiseA :: (ArrowChoice a)
+ => failure
+ -> FallibleArrow a x failure success
+_raiseA e = returnV (Left e)
+
+-- | Raises an empty error into a 'FallibleArrow', droping both the arrow input
+-- and any previously stored error value.
+_raiseAEmpty :: (ArrowChoice a, Monoid failure)
+ => FallibleArrow a x failure success
+_raiseAEmpty = _raiseA mempty
+
+-- | Raises an error into a 'ReFallibleArrow', possibly appending the new error
+-- to an existing one
+raiseA :: (ArrowChoice a, Monoid failure)
+ => failure
+ -> ReFallibleArrow a failure success success
+raiseA e = arr $ Left.(either (<> e) (const e))
+
+-- | Raises an empty error into a 'ReFallibleArrow'. If there already is an
+-- error, nothing changes.
+-- (Note that this function is only aequivalent to @raiseA mempty@ iff the
+-- failure monoid follows the monoid laws.)
+raiseAEmpty :: (ArrowChoice a, Monoid failure)
+ => ReFallibleArrow a failure success success
+raiseAEmpty = arr (fromRight (const mempty) >>> Left)
+
+
+-- | Execute the second arrow if the first succeeds
+(>>?) :: (ArrowChoice a)
+ => FallibleArrow a x failure success
+ -> FallibleArrow a success failure success'
+ -> FallibleArrow a x failure success'
+a >>? b = a >>> Left ^||| b
+
+-- | Execute the lifted second arrow if the first succeeds
+(>>?^) :: (ArrowChoice a)
+ => FallibleArrow a x failure success
+ -> (success -> success')
+ -> FallibleArrow a x failure success'
+a >>?^ f = a >>^ Left ^|||^ Right . f
+
+-- | Execute the lifted second arrow if the first succeeds
+(>>?^?) :: (ArrowChoice a)
+ => FallibleArrow a x failure success
+ -> (success -> Either failure success')
+ -> FallibleArrow a x failure success'
+a >>?^? b = a >>> Left ^|||^ b
+
+-- | Execute the second arrow if the lifted first arrow succeeds
+(^>>?) :: (ArrowChoice a)
+ => (x -> Either failure success)
+ -> FallibleArrow a success failure success'
+ -> FallibleArrow a x failure success'
+a ^>>? b = a ^>> Left ^||| b
+
+-- | Execute the lifted second arrow if the lifted first arrow succeeds
+(^>>?^) :: (ArrowChoice a)
+ => (x -> Either failure success)
+ -> (success -> success')
+ -> FallibleArrow a x failure success'
+a ^>>?^ f = arr $ a >>> right f
+
+-- | Execute the lifted second arrow if the lifted first arrow succeeds
+(^>>?^?) :: (ArrowChoice a)
+ => (x -> Either failure success)
+ -> (success -> Either failure success')
+ -> FallibleArrow a x failure success'
+a ^>>?^? f = a ^>> Left ^|||^ f
+
+-- | Execute the second, non-fallible arrow if the first arrow succeeds
+(>>?!) :: (ArrowChoice a)
+ => FallibleArrow a x failure success
+ -> a success success'
+ -> FallibleArrow a x failure success'
+a >>?! f = a >>> right f
+
+---
+(>>?%) :: (ArrowChoice a)
+ => FallibleArrow a x f (b,b')
+ -> (b -> b' -> c)
+ -> FallibleArrow a x f c
+a >>?% f = a >>?^ (uncurry f)
+
+---
+(^>>?%) :: (ArrowChoice a)
+ => (x -> Either f (b,b'))
+ -> (b -> b' -> c)
+ -> FallibleArrow a x f c
+a ^>>?% f = arr a >>?^ (uncurry f)
+
+---
+(>>?%?) :: (ArrowChoice a)
+ => FallibleArrow a x f (b,b')
+ -> (b -> b' -> (Either f c))
+ -> FallibleArrow a x f c
+a >>?%? f = a >>?^? (uncurry f)
+
+infixr 1 >>?, >>?^, >>?^?
+infixr 1 ^>>?, ^>>?^, ^>>?^?, >>?!
+infixr 1 >>?%, ^>>?%, >>?%?
+
+-- | Keep values that are Right, replace Left values by a constant.
+ifFailedUse :: (ArrowChoice a) => v -> a (Either f v) v
+ifFailedUse v = arr $ either (const v) id
+
+-- | '(&&)' lifted into an arrow
+(<&&>) :: (Arrow a) => a x Bool -> a x Bool -> a x Bool
+(<&&>) = liftA2 (&&)
+
+-- | '(||)' lifted into an arrow
+(<||>) :: (Arrow a) => a x Bool -> a x Bool -> a x Bool
+(<||>) = liftA2 (||)
+
+-- | An equivalent of '(&&)' in a fallible arrow
+(>&&<) :: (ArrowChoice a, Monoid f) => FallibleArrow a x f s
+ -> FallibleArrow a x f s'
+ -> FallibleArrow a x f (s,s')
+(>&&<) = liftA2 chooseMin
+
+-- | An equivalent of '(||)' in some forms of fallible arrows
+(>||<) :: (ArrowChoice a, Monoid f, Monoid s) => FallibleArrow a x f s
+ -> FallibleArrow a x f s
+ -> FallibleArrow a x f s
+(>||<) = liftA2 chooseMax
+
+-- | An arrow version of a short-circuit (<|>)
+ifFailedDo :: (ArrowChoice a)
+ => FallibleArrow a x f y
+ -> FallibleArrow a x f y
+ -> FallibleArrow a x f y
+ifFailedDo a b = keepingTheValue a >>> repackage ^>> (b |||^ Right)
+ where repackage (x , Left _) = Left x
+ repackage (_ , Right y) = Right y
+
+infixr 4 <&&>, <||>, >&&<, >||<
+infixr 1 `ifFailedDo`
+
+
diff --git a/src/Text/Pandoc/Readers/Odt/Base.hs b/src/Text/Pandoc/Readers/Odt/Base.hs
new file mode 100644
index 000000000..1f095bade
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Odt/Base.hs
@@ -0,0 +1,43 @@
+{-# LANGUAGE PatternGuards #-}
+
+{-
+Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Readers.Odt.Base
+ Copyright : Copyright (C) 2015 Martin Linnemann
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Martin Linnemann <theCodingMarlin@googlemail.com>
+ Stability : alpha
+ Portability : portable
+
+Core types of the odt reader.
+-}
+
+module Text.Pandoc.Readers.Odt.Base where
+
+import Text.Pandoc.Readers.Odt.Generic.XMLConverter
+import Text.Pandoc.Readers.Odt.Namespaces
+
+type OdtConverterState s = XMLConverterState Namespace s
+
+type XMLReader s a b = FallibleXMLConverter Namespace s a b
+
+type XMLReaderSafe s a b = XMLConverter Namespace s a b
+
diff --git a/src/Text/Pandoc/Readers/Odt/ContentReader.hs b/src/Text/Pandoc/Readers/Odt/ContentReader.hs
new file mode 100644
index 000000000..a1bd8cb59
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Odt/ContentReader.hs
@@ -0,0 +1,929 @@
+{-# LANGUAGE Arrows #-}
+{-# LANGUAGE TupleSections #-}
+{-# LANGUAGE PatternGuards #-}
+{-# LANGUAGE ViewPatterns #-}
+{-# LANGUAGE RecordWildCards #-}
+
+{-
+Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Readers.Odt.ContentReader
+ Copyright : Copyright (C) 2015 Martin Linnemann
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Martin Linnemann <theCodingMarlin@googlemail.com>
+ Stability : alpha
+ Portability : portable
+
+The core of the odt reader that converts odt features into Pandoc types.
+-}
+
+module Text.Pandoc.Readers.Odt.ContentReader
+( readerState
+, read_body
+) where
+
+import Control.Arrow
+import Control.Applicative hiding ( liftA, liftA2, liftA3 )
+
+import qualified Data.ByteString.Lazy as B
+import qualified Data.Map as M
+import Data.List ( find, intercalate )
+import Data.Maybe
+
+import qualified Text.XML.Light as XML
+
+import Text.Pandoc.Definition
+import Text.Pandoc.Builder
+import Text.Pandoc.MediaBag (insertMedia, MediaBag)
+import Text.Pandoc.Shared
+
+import Text.Pandoc.Readers.Odt.Base
+import Text.Pandoc.Readers.Odt.Namespaces
+import Text.Pandoc.Readers.Odt.StyleReader
+
+import Text.Pandoc.Readers.Odt.Arrows.Utils
+import Text.Pandoc.Readers.Odt.Generic.XMLConverter
+import Text.Pandoc.Readers.Odt.Generic.Fallible
+import Text.Pandoc.Readers.Odt.Generic.Utils
+
+import qualified Data.Set as Set
+
+--------------------------------------------------------------------------------
+-- State
+--------------------------------------------------------------------------------
+
+type Anchor = String
+type Media = [(FilePath, B.ByteString)]
+
+data ReaderState
+ = ReaderState { -- | A collection of styles read somewhere else.
+ -- It is only queried here, not modified.
+ styleSet :: Styles
+ -- | A stack of the styles of parent elements.
+ -- Used to look up inherited style properties.
+ , styleTrace :: [Style]
+ -- | Keeps track of the current depth in nested lists
+ , currentListLevel :: ListLevel
+ -- | Lists may provide their own style, but they don't have
+ -- to. If they do not, the style of a parent list may be used
+ -- or even a default list style from the paragraph style.
+ -- This value keeps track of the closest list style there
+ -- currently is.
+ , currentListStyle :: Maybe ListStyle
+ -- | A map from internal anchor names to "pretty" ones.
+ -- The mapping is a purely cosmetic one.
+ , bookmarkAnchors :: M.Map Anchor Anchor
+ -- | A map of files / binary data from the archive
+ , envMedia :: Media
+ -- | Hold binary resources used in the document
+ , odtMediaBag :: MediaBag
+-- , sequences
+-- , trackedChangeIDs
+ }
+ deriving ( Show )
+
+readerState :: Styles -> Media -> ReaderState
+readerState styles media = ReaderState styles [] 0 Nothing M.empty media mempty
+
+--
+pushStyle' :: Style -> ReaderState -> ReaderState
+pushStyle' style state = state { styleTrace = style : styleTrace state }
+
+--
+popStyle' :: ReaderState -> ReaderState
+popStyle' state = case styleTrace state of
+ _:trace -> state { styleTrace = trace }
+ _ -> state
+
+--
+modifyListLevel :: (ListLevel -> ListLevel) -> (ReaderState -> ReaderState)
+modifyListLevel f state = state { currentListLevel = f (currentListLevel state) }
+
+--
+shiftListLevel :: ListLevel -> (ReaderState -> ReaderState)
+shiftListLevel diff = modifyListLevel (+ diff)
+
+--
+swapCurrentListStyle :: Maybe ListStyle -> ReaderState
+ -> (ReaderState, Maybe ListStyle)
+swapCurrentListStyle mListStyle state = ( state { currentListStyle = mListStyle }
+ , currentListStyle state
+ )
+
+--
+lookupPrettyAnchor :: Anchor -> ReaderState -> Maybe Anchor
+lookupPrettyAnchor anchor ReaderState{..} = M.lookup anchor bookmarkAnchors
+
+--
+putPrettyAnchor :: Anchor -> Anchor -> ReaderState -> ReaderState
+putPrettyAnchor ugly pretty state@ReaderState{..}
+ = state { bookmarkAnchors = M.insert ugly pretty bookmarkAnchors }
+
+--
+usedAnchors :: ReaderState -> [Anchor]
+usedAnchors ReaderState{..} = M.elems bookmarkAnchors
+
+getMediaBag :: ReaderState -> MediaBag
+getMediaBag ReaderState{..} = odtMediaBag
+
+getMediaEnv :: ReaderState -> Media
+getMediaEnv ReaderState{..} = envMedia
+
+insertMedia' :: (FilePath, B.ByteString) -> ReaderState -> ReaderState
+insertMedia' (fp, bs) state@ReaderState{..}
+ = state { odtMediaBag = insertMedia fp Nothing bs odtMediaBag }
+
+--------------------------------------------------------------------------------
+-- Reader type and associated tools
+--------------------------------------------------------------------------------
+
+type OdtReader a b = XMLReader ReaderState a b
+
+type OdtReaderSafe a b = XMLReaderSafe ReaderState a b
+
+-- | Extract something from the styles
+fromStyles :: (a -> Styles -> b) -> OdtReaderSafe a b
+fromStyles f = keepingTheValue
+ (getExtraState >>^ styleSet)
+ >>% f
+
+--
+getStyleByName :: OdtReader StyleName Style
+getStyleByName = fromStyles lookupStyle >>^ maybeToChoice
+
+--
+findStyleFamily :: OdtReader Style StyleFamily
+findStyleFamily = fromStyles getStyleFamily >>^ maybeToChoice
+
+--
+lookupListStyle :: OdtReader StyleName ListStyle
+lookupListStyle = fromStyles lookupListStyleByName >>^ maybeToChoice
+
+--
+switchCurrentListStyle :: OdtReaderSafe (Maybe ListStyle) (Maybe ListStyle)
+switchCurrentListStyle = keepingTheValue getExtraState
+ >>% swapCurrentListStyle
+ >>> first setExtraState
+ >>^ snd
+
+--
+pushStyle :: OdtReaderSafe Style Style
+pushStyle = keepingTheValue (
+ ( keepingTheValue getExtraState
+ >>% pushStyle'
+ )
+ >>> setExtraState
+ )
+ >>^ fst
+
+--
+popStyle :: OdtReaderSafe x x
+popStyle = keepingTheValue (
+ getExtraState
+ >>> arr popStyle'
+ >>> setExtraState
+ )
+ >>^ fst
+
+--
+getCurrentListLevel :: OdtReaderSafe _x ListLevel
+getCurrentListLevel = getExtraState >>^ currentListLevel
+
+--
+updateMediaWithResource :: OdtReaderSafe (FilePath, B.ByteString) (FilePath, B.ByteString)
+updateMediaWithResource = keepingTheValue (
+ (keepingTheValue getExtraState
+ >>% insertMedia'
+ )
+ >>> setExtraState
+ )
+ >>^ fst
+
+lookupResource :: OdtReaderSafe String (FilePath, B.ByteString)
+lookupResource = proc target -> do
+ state <- getExtraState -< ()
+ case lookup target (getMediaEnv state) of
+ Just bs -> returnV (target, bs) -<< ()
+ Nothing -> returnV ("", B.empty) -< ()
+
+type AnchorPrefix = String
+
+-- | An adaptation of 'uniqueIdent' from "Text.Pandoc.Shared" that generates a
+-- unique identifier but without assuming that the id should be for a header.
+-- Second argument is a list of already used identifiers.
+uniqueIdentFrom :: AnchorPrefix -> [Anchor] -> Anchor
+uniqueIdentFrom baseIdent usedIdents =
+ let numIdent n = baseIdent ++ "-" ++ show n
+ in if baseIdent `elem` usedIdents
+ then case find (\x -> numIdent x `notElem` usedIdents) ([1..60000] :: [Int]) of
+ Just x -> numIdent x
+ Nothing -> baseIdent -- if we have more than 60,000, allow repeats
+ else baseIdent
+
+-- | First argument: basis for a new "pretty" anchor if none exists yet
+-- Second argument: a key ("ugly" anchor)
+-- Returns: saved "pretty" anchor or created new one
+getPrettyAnchor :: OdtReaderSafe (AnchorPrefix, Anchor) Anchor
+getPrettyAnchor = proc (baseIdent, uglyAnchor) -> do
+ state <- getExtraState -< ()
+ case lookupPrettyAnchor uglyAnchor state of
+ Just prettyAnchor -> returnA -< prettyAnchor
+ Nothing -> do
+ let newPretty = uniqueIdentFrom baseIdent (usedAnchors state)
+ modifyExtraState (putPrettyAnchor uglyAnchor newPretty) -<< newPretty
+
+-- | Input: basis for a new header anchor
+-- Ouput: saved new anchor
+getHeaderAnchor :: OdtReaderSafe Inlines Anchor
+getHeaderAnchor = proc title -> do
+ state <- getExtraState -< ()
+ let anchor = uniqueIdent (toList title) (Set.fromList $ usedAnchors state)
+ modifyExtraState (putPrettyAnchor anchor anchor) -<< anchor
+
+
+--------------------------------------------------------------------------------
+-- Working with styles
+--------------------------------------------------------------------------------
+
+--
+readStyleByName :: OdtReader _x (StyleName, Style)
+readStyleByName =
+ findAttr NsText "style-name" >>? keepingTheValue getStyleByName >>^ liftE
+ where
+ liftE :: (StyleName, Fallible Style) -> Fallible (StyleName, Style)
+ liftE (name, Right v) = Right (name, v)
+ liftE (_, Left v) = Left v
+
+--
+isStyleToTrace :: OdtReader Style Bool
+isStyleToTrace = findStyleFamily >>?^ (==FaText)
+
+--
+withNewStyle :: OdtReaderSafe x Inlines -> OdtReaderSafe x Inlines
+withNewStyle a = proc x -> do
+ fStyle <- readStyleByName -< ()
+ case fStyle of
+ Right (styleName, _) | isCodeStyle styleName -> do
+ inlines <- a -< x
+ arr inlineCode -<< inlines
+ Right (_, style) -> do
+ mFamily <- arr styleFamily -< style
+ fTextProps <- arr ( maybeToChoice
+ . textProperties
+ . styleProperties
+ ) -< style
+ case fTextProps of
+ Right textProps -> do
+ state <- getExtraState -< ()
+ let triple = (state, textProps, mFamily)
+ modifier <- arr modifierFromStyleDiff -< triple
+ fShouldTrace <- isStyleToTrace -< style
+ case fShouldTrace of
+ Right shouldTrace -> do
+ if shouldTrace
+ then do
+ pushStyle -< style
+ inlines <- a -< x
+ popStyle -< ()
+ arr modifier -<< inlines
+ else
+ -- In case anything goes wrong
+ a -< x
+ Left _ -> a -< x
+ Left _ -> a -< x
+ Left _ -> a -< x
+ where
+ isCodeStyle :: StyleName -> Bool
+ isCodeStyle "Source_Text" = True
+ isCodeStyle _ = False
+
+ inlineCode :: Inlines -> Inlines
+ inlineCode = code . intercalate "" . map stringify . toList
+
+type PropertyTriple = (ReaderState, TextProperties, Maybe StyleFamily)
+type InlineModifier = Inlines -> Inlines
+
+-- | Given data about the local style changes, calculates how to modify
+-- an instance of 'Inlines'
+modifierFromStyleDiff :: PropertyTriple -> InlineModifier
+modifierFromStyleDiff propertyTriple =
+ composition $
+ (getVPosModifier propertyTriple)
+ : map (first ($ propertyTriple) >>> ifThen_else ignore)
+ [ (hasEmphChanged , emph )
+ , (hasChanged isStrong , strong )
+ , (hasChanged strikethrough , strikeout )
+ ]
+ where
+ ifThen_else else' (if',then') = if if' then then' else else'
+
+ ignore = id :: InlineModifier
+
+ getVPosModifier :: PropertyTriple -> InlineModifier
+ getVPosModifier triple@(_,textProps,_) =
+ let getVPos = Just . verticalPosition
+ in case lookupPreviousValueM getVPos triple of
+ Nothing -> ignore
+ Just oldVPos -> getVPosModifier' (oldVPos, verticalPosition textProps)
+
+ getVPosModifier' (oldVPos , newVPos ) | oldVPos == newVPos = ignore
+ getVPosModifier' ( _ , VPosSub ) = subscript
+ getVPosModifier' ( _ , VPosSuper ) = superscript
+ getVPosModifier' ( _ , _ ) = ignore
+
+ hasEmphChanged :: PropertyTriple -> Bool
+ hasEmphChanged = swing any [ hasChanged isEmphasised
+ , hasChangedM pitch
+ , hasChanged underline
+ ]
+
+ hasChanged property triple@(_, property -> newProperty, _) =
+ maybe True (/=newProperty) (lookupPreviousValue property triple)
+
+ hasChangedM property triple@(_, textProps,_) =
+ fromMaybe False $ (/=) <$> property textProps <*> lookupPreviousValueM property triple
+
+ lookupPreviousValue f = lookupPreviousStyleValue ((fmap f).textProperties)
+
+ lookupPreviousValueM f = lookupPreviousStyleValue ((f =<<).textProperties)
+
+ lookupPreviousStyleValue f (ReaderState{..},_,mFamily)
+ = ( findBy f $ extendedStylePropertyChain styleTrace styleSet )
+ <|> ( f =<< fmap (lookupDefaultStyle' styleSet) mFamily )
+
+
+type ParaModifier = Blocks -> Blocks
+
+_MINIMUM_INDENTATION_FOR_BLOCKQUOTES_IN_MM_ :: Int
+_MINIMUM_INDENTATION_FOR_BLOCKQUOTES_IN_PERCENT_ :: Int
+_MINIMUM_INDENTATION_FOR_BLOCKQUOTES_IN_MM_ = 5
+_MINIMUM_INDENTATION_FOR_BLOCKQUOTES_IN_PERCENT_ = 5
+
+-- | Returns either 'id' or 'blockQuote' depending on the current indentation
+getParaModifier :: Style -> ParaModifier
+getParaModifier Style{..} | Just props <- paraProperties styleProperties
+ , isBlockQuote (indentation props)
+ (margin_left props)
+ = blockQuote
+ | otherwise
+ = id
+ where
+ isBlockQuote mIndent mMargin
+ | LengthValueMM indent <- mIndent
+ , indent > _MINIMUM_INDENTATION_FOR_BLOCKQUOTES_IN_MM_
+ = True
+ | LengthValueMM margin <- mMargin
+ , margin > _MINIMUM_INDENTATION_FOR_BLOCKQUOTES_IN_MM_
+ = True
+ | LengthValueMM indent <- mIndent
+ , LengthValueMM margin <- mMargin
+ = indent + margin > _MINIMUM_INDENTATION_FOR_BLOCKQUOTES_IN_MM_
+
+ | PercentValue indent <- mIndent
+ , indent > _MINIMUM_INDENTATION_FOR_BLOCKQUOTES_IN_PERCENT_
+ = True
+ | PercentValue margin <- mMargin
+ , margin > _MINIMUM_INDENTATION_FOR_BLOCKQUOTES_IN_PERCENT_
+ = True
+ | PercentValue indent <- mIndent
+ , PercentValue margin <- mMargin
+ = indent + margin > _MINIMUM_INDENTATION_FOR_BLOCKQUOTES_IN_PERCENT_
+
+ | otherwise
+ = False
+
+--
+constructPara :: OdtReaderSafe Blocks Blocks -> OdtReaderSafe Blocks Blocks
+constructPara reader = proc blocks -> do
+ fStyle <- readStyleByName -< blocks
+ case fStyle of
+ Left _ -> reader -< blocks
+ Right (styleName, _) | isTableCaptionStyle styleName -> do
+ blocks' <- reader -< blocks
+ arr tableCaptionP -< blocks'
+ Right (_, style) -> do
+ let modifier = getParaModifier style
+ blocks' <- reader -< blocks
+ arr modifier -<< blocks'
+ where
+ isTableCaptionStyle :: StyleName -> Bool
+ isTableCaptionStyle "Table" = True
+ isTableCaptionStyle _ = False
+ tableCaptionP b = divWith ("", ["caption"], []) b
+
+type ListConstructor = [Blocks] -> Blocks
+
+getListConstructor :: ListLevelStyle -> ListConstructor
+getListConstructor ListLevelStyle{..} =
+ case listLevelType of
+ LltBullet -> bulletList
+ LltImage -> bulletList
+ LltNumbered -> let listNumberStyle = toListNumberStyle listItemFormat
+ listNumberDelim = toListNumberDelim listItemPrefix
+ listItemSuffix
+ in orderedListWith (listItemStart, listNumberStyle, listNumberDelim)
+ where
+ toListNumberStyle LinfNone = DefaultStyle
+ toListNumberStyle LinfNumber = Decimal
+ toListNumberStyle LinfRomanLC = LowerRoman
+ toListNumberStyle LinfRomanUC = UpperRoman
+ toListNumberStyle LinfAlphaLC = LowerAlpha
+ toListNumberStyle LinfAlphaUC = UpperAlpha
+ toListNumberStyle (LinfString _) = Example
+
+ toListNumberDelim Nothing (Just ".") = Period
+ toListNumberDelim (Just "" ) (Just ".") = Period
+ toListNumberDelim Nothing (Just ")") = OneParen
+ toListNumberDelim (Just "" ) (Just ")") = OneParen
+ toListNumberDelim (Just "(") (Just ")") = TwoParens
+ toListNumberDelim _ _ = DefaultDelim
+
+
+-- | Determines which style to use for a list, which level to use of that
+-- style, and which type of list to create as a result of this information.
+-- Then prepares the state for eventual child lists and constructs the list from
+-- the results.
+-- Two main cases are handled: The list may provide its own style or it may
+-- rely on a parent list's style. I the former case the current style in the
+-- state must be switched before and after the call to the child converter
+-- while in the latter the child converter can be called directly.
+-- If anything goes wrong, a default ordered-list-constructor is used.
+constructList :: OdtReaderSafe x [Blocks] -> OdtReaderSafe x Blocks
+constructList reader = proc x -> do
+ modifyExtraState (shiftListLevel 1) -< ()
+ listLevel <- getCurrentListLevel -< ()
+ fStyleName <- findAttr NsText "style-name" -< ()
+ case fStyleName of
+ Right styleName -> do
+ fListStyle <- lookupListStyle -< styleName
+ case fListStyle of
+ Right listStyle -> do
+ fLLS <- arr (uncurry getListLevelStyle) -< (listLevel,listStyle)
+ case fLLS of
+ Just listLevelStyle -> do
+ oldListStyle <- switchCurrentListStyle -< Just listStyle
+ blocks <- constructListWith listLevelStyle -<< x
+ switchCurrentListStyle -< oldListStyle
+ returnA -< blocks
+ Nothing -> constructOrderedList -< x
+ Left _ -> constructOrderedList -< x
+ Left _ -> do
+ state <- getExtraState -< ()
+ mListStyle <- arr currentListStyle -< state
+ case mListStyle of
+ Just listStyle -> do
+ fLLS <- arr (uncurry getListLevelStyle) -< (listLevel,listStyle)
+ case fLLS of
+ Just listLevelStyle -> constructListWith listLevelStyle -<< x
+ Nothing -> constructOrderedList -< x
+ Nothing -> constructOrderedList -< x
+ where
+ constructOrderedList =
+ reader
+ >>> modifyExtraState (shiftListLevel (-1))
+ >>^ orderedList
+ constructListWith listLevelStyle =
+ reader
+ >>> getListConstructor listLevelStyle
+ ^>> modifyExtraState (shiftListLevel (-1))
+
+--------------------------------------------------------------------------------
+-- Readers
+--------------------------------------------------------------------------------
+
+type ElementMatcher result = (Namespace, ElementName, OdtReader result result)
+
+type InlineMatcher = ElementMatcher Inlines
+
+type BlockMatcher = ElementMatcher Blocks
+
+
+--
+matchingElement :: (Monoid e)
+ => Namespace -> ElementName
+ -> OdtReaderSafe e e
+ -> ElementMatcher e
+matchingElement ns name reader = (ns, name, asResultAccumulator reader)
+ where
+ asResultAccumulator :: (ArrowChoice a, Monoid m) => a m m -> a m (Fallible m)
+ asResultAccumulator a = liftAsSuccess $ keepingTheValue a >>% (<>)
+
+--
+matchChildContent' :: (Monoid result)
+ => [ElementMatcher result]
+ -> OdtReaderSafe _x result
+matchChildContent' ls = returnV mempty >>> matchContent' ls
+
+--
+matchChildContent :: (Monoid result)
+ => [ElementMatcher result]
+ -> OdtReaderSafe (result, XML.Content) result
+ -> OdtReaderSafe _x result
+matchChildContent ls fallback = returnV mempty >>> matchContent ls fallback
+
+
+--------------------------------------------
+-- Matchers
+--------------------------------------------
+
+----------------------
+-- Basics
+----------------------
+
+--
+-- | Open Document allows several consecutive spaces if they are marked up
+read_plain_text :: OdtReaderSafe (Inlines, XML.Content) Inlines
+read_plain_text = fst ^&&& read_plain_text' >>% recover
+ where
+ -- fallible version
+ read_plain_text' :: OdtReader (Inlines, XML.Content) Inlines
+ read_plain_text' = ( second ( arr extractText )
+ >>^ spreadChoice >>?! second text
+ )
+ >>?% (<>)
+ --
+ extractText :: XML.Content -> Fallible String
+ extractText (XML.Text cData) = succeedWith (XML.cdData cData)
+ extractText _ = failEmpty
+
+read_text_seq :: InlineMatcher
+read_text_seq = matchingElement NsText "sequence"
+ $ matchChildContent [] read_plain_text
+
+
+-- specifically. I honor that, although the current implementation of '(<>)'
+-- for 'Inlines' in "Text.Pandoc.Builder" will collaps them agein.
+-- The rational is to be prepared for future modifications.
+read_spaces :: InlineMatcher
+read_spaces = matchingElement NsText "s" (
+ readAttrWithDefault NsText "c" 1 -- how many spaces?
+ >>^ fromList.(`replicate` Space)
+ )
+--
+read_line_break :: InlineMatcher
+read_line_break = matchingElement NsText "line-break"
+ $ returnV linebreak
+
+--
+read_span :: InlineMatcher
+read_span = matchingElement NsText "span"
+ $ withNewStyle
+ $ matchChildContent [ read_span
+ , read_spaces
+ , read_line_break
+ , read_link
+ , read_note
+ , read_citation
+ , read_bookmark
+ , read_bookmark_start
+ , read_reference_start
+ , read_bookmark_ref
+ , read_reference_ref
+ ] read_plain_text
+
+--
+read_paragraph :: BlockMatcher
+read_paragraph = matchingElement NsText "p"
+ $ constructPara
+ $ liftA para
+ $ withNewStyle
+ $ matchChildContent [ read_span
+ , read_spaces
+ , read_line_break
+ , read_link
+ , read_note
+ , read_citation
+ , read_bookmark
+ , read_bookmark_start
+ , read_reference_start
+ , read_bookmark_ref
+ , read_reference_ref
+ , read_maybe_nested_img_frame
+ , read_text_seq
+ ] read_plain_text
+
+
+----------------------
+-- Headers
+----------------------
+
+--
+read_header :: BlockMatcher
+read_header = matchingElement NsText "h"
+ $ proc blocks -> do
+ level <- ( readAttrWithDefault NsText "outline-level" 1
+ ) -< blocks
+ children <- ( matchChildContent [ read_span
+ , read_spaces
+ , read_line_break
+ , read_link
+ , read_note
+ , read_citation
+ , read_bookmark
+ , read_bookmark_start
+ , read_reference_start
+ , read_bookmark_ref
+ , read_reference_ref
+ , read_maybe_nested_img_frame
+ ] read_plain_text
+ ) -< blocks
+ anchor <- getHeaderAnchor -< children
+ let idAttr = (anchor, [], []) -- no classes, no key-value pairs
+ arr (uncurry3 headerWith) -< (idAttr, level, children)
+
+----------------------
+-- Lists
+----------------------
+
+--
+read_list :: BlockMatcher
+read_list = matchingElement NsText "list"
+-- $ withIncreasedListLevel
+ $ constructList
+-- $ liftA bulletList
+ $ matchChildContent' [ read_list_item
+ ]
+--
+read_list_item :: ElementMatcher [Blocks]
+read_list_item = matchingElement NsText "list-item"
+ $ liftA (compactify.(:[]))
+ ( matchChildContent' [ read_paragraph
+ , read_header
+ , read_list
+ ]
+ )
+
+
+----------------------
+-- Links
+----------------------
+
+read_link :: InlineMatcher
+read_link = matchingElement NsText "a"
+ $ liftA3 link
+ ( findAttrWithDefault NsXLink "href" "" )
+ ( findAttrWithDefault NsOffice "title" "" )
+ ( matchChildContent [ read_span
+ , read_note
+ , read_citation
+ , read_bookmark
+ , read_bookmark_start
+ , read_reference_start
+ , read_bookmark_ref
+ , read_reference_ref
+ ] read_plain_text )
+
+
+-------------------------
+-- Footnotes
+-------------------------
+
+read_note :: InlineMatcher
+read_note = matchingElement NsText "note"
+ $ liftA note
+ $ matchChildContent' [ read_note_body ]
+
+read_note_body :: BlockMatcher
+read_note_body = matchingElement NsText "note-body"
+ $ matchChildContent' [ read_paragraph ]
+
+-------------------------
+-- Citations
+-------------------------
+
+read_citation :: InlineMatcher
+read_citation = matchingElement NsText "bibliography-mark"
+ $ liftA2 cite
+ ( liftA2 makeCitation
+ ( findAttrWithDefault NsText "identifier" "" )
+ ( readAttrWithDefault NsText "number" 0 )
+ )
+ ( matchChildContent [] read_plain_text )
+ where
+ makeCitation :: String -> Int -> [Citation]
+ makeCitation citeId num = [Citation citeId [] [] NormalCitation num 0]
+
+
+----------------------
+-- Tables
+----------------------
+
+--
+read_table :: BlockMatcher
+read_table = matchingElement NsTable "table"
+ $ liftA simpleTable'
+ $ matchChildContent' [ read_table_row
+ ]
+
+-- | A simple table without a caption or headers
+-- | Infers the number of headers from rows
+simpleTable' :: [[Blocks]] -> Blocks
+simpleTable' [] = simpleTable [] []
+simpleTable' (x : rest) = simpleTable (fmap (const defaults) x) (x : rest)
+ where defaults = fromList []
+
+--
+read_table_row :: ElementMatcher [[Blocks]]
+read_table_row = matchingElement NsTable "table-row"
+ $ liftA (:[])
+ $ matchChildContent' [ read_table_cell
+ ]
+
+--
+read_table_cell :: ElementMatcher [Blocks]
+read_table_cell = matchingElement NsTable "table-cell"
+ $ liftA (compactify.(:[]))
+ $ matchChildContent' [ read_paragraph
+ ]
+
+----------------------
+-- Images
+----------------------
+
+--
+read_maybe_nested_img_frame :: InlineMatcher
+read_maybe_nested_img_frame = matchingElement NsDraw "frame"
+ $ proc blocks -> do
+ img <- (findChild' NsDraw "image") -< ()
+ case img of
+ Just _ -> read_frame -< blocks
+ Nothing -> matchChildContent' [ read_frame_text_box ] -< blocks
+
+read_frame :: OdtReaderSafe Inlines Inlines
+read_frame =
+ proc blocks -> do
+ w <- ( findAttr' NsSVG "width" ) -< ()
+ h <- ( findAttr' NsSVG "height" ) -< ()
+ titleNodes <- ( matchChildContent' [ read_frame_title ] ) -< blocks
+ src <- matchChildContent' [ read_image_src ] -< blocks
+ resource <- lookupResource -< src
+ _ <- updateMediaWithResource -< resource
+ alt <- (matchChildContent [] read_plain_text) -< blocks
+ arr (uncurry4 imageWith ) -<
+ (image_attributes w h, src, inlineListToIdentifier (toList titleNodes), alt)
+
+image_attributes :: Maybe String -> Maybe String -> Attr
+image_attributes x y =
+ ( "", [], (dim "width" x) ++ (dim "height" y))
+ where
+ dim _ (Just "") = []
+ dim name (Just v) = [(name, v)]
+ dim _ Nothing = []
+
+read_image_src :: (Namespace, ElementName, OdtReader Anchor Anchor)
+read_image_src = matchingElement NsDraw "image"
+ $ proc _ -> do
+ imgSrc <- findAttr NsXLink "href" -< ()
+ case imgSrc of
+ Right src -> returnV src -<< ()
+ Left _ -> returnV "" -< ()
+
+read_frame_title :: InlineMatcher
+read_frame_title = matchingElement NsSVG "title"
+ $ (matchChildContent [] read_plain_text)
+
+read_frame_text_box :: InlineMatcher
+read_frame_text_box = matchingElement NsDraw "text-box"
+ $ proc blocks -> do
+ paragraphs <- (matchChildContent' [ read_paragraph ]) -< blocks
+ arr read_img_with_caption -< toList paragraphs
+
+read_img_with_caption :: [Block] -> Inlines
+read_img_with_caption ((Para ((Image attr alt (src,title)) : [])) : _) =
+ singleton (Image attr alt (src, 'f':'i':'g':':':title)) -- no text, default caption
+read_img_with_caption ((Para ((Image attr _ (src,title)) : txt)) : _) =
+ singleton (Image attr txt (src, 'f':'i':'g':':':title) ) -- override caption with the text that follows
+read_img_with_caption ( (Para (_ : xs)) : ys) =
+ read_img_with_caption ((Para xs) : ys)
+read_img_with_caption _ =
+ mempty
+
+----------------------
+-- Internal links
+----------------------
+
+_ANCHOR_PREFIX_ :: String
+_ANCHOR_PREFIX_ = "anchor"
+
+--
+readAnchorAttr :: OdtReader _x Anchor
+readAnchorAttr = findAttr NsText "name"
+
+-- | Beware: may fail
+findAnchorName :: OdtReader AnchorPrefix Anchor
+findAnchorName = ( keepingTheValue readAnchorAttr
+ >>^ spreadChoice
+ ) >>?! getPrettyAnchor
+
+
+--
+maybeAddAnchorFrom :: OdtReader Inlines AnchorPrefix
+ -> OdtReaderSafe Inlines Inlines
+maybeAddAnchorFrom anchorReader =
+ keepingTheValue (anchorReader >>? findAnchorName >>?^ toAnchorElem)
+ >>>
+ proc (inlines, fAnchorElem) -> do
+ case fAnchorElem of
+ Right anchorElem -> returnA -< anchorElem
+ Left _ -> returnA -< inlines
+ where
+ toAnchorElem :: Anchor -> Inlines
+ toAnchorElem anchorID = spanWith (anchorID, [], []) mempty
+ -- no classes, no key-value pairs
+
+--
+read_bookmark :: InlineMatcher
+read_bookmark = matchingElement NsText "bookmark"
+ $ maybeAddAnchorFrom (liftAsSuccess $ returnV _ANCHOR_PREFIX_)
+
+--
+read_bookmark_start :: InlineMatcher
+read_bookmark_start = matchingElement NsText "bookmark-start"
+ $ maybeAddAnchorFrom (liftAsSuccess $ returnV _ANCHOR_PREFIX_)
+
+--
+read_reference_start :: InlineMatcher
+read_reference_start = matchingElement NsText "reference-mark-start"
+ $ maybeAddAnchorFrom readAnchorAttr
+
+-- | Beware: may fail
+findAnchorRef :: OdtReader _x Anchor
+findAnchorRef = ( findAttr NsText "ref-name"
+ >>?^ (_ANCHOR_PREFIX_,)
+ ) >>?! getPrettyAnchor
+
+
+--
+maybeInAnchorRef :: OdtReaderSafe Inlines Inlines
+maybeInAnchorRef = proc inlines -> do
+ fRef <- findAnchorRef -< ()
+ case fRef of
+ Right anchor ->
+ arr (toAnchorRef anchor) -<< inlines
+ Left _ -> returnA -< inlines
+ where
+ toAnchorRef :: Anchor -> Inlines -> Inlines
+ toAnchorRef anchor = link ('#':anchor) "" -- no title
+
+--
+read_bookmark_ref :: InlineMatcher
+read_bookmark_ref = matchingElement NsText "bookmark-ref"
+ $ maybeInAnchorRef
+ <<< matchChildContent [] read_plain_text
+
+--
+read_reference_ref :: InlineMatcher
+read_reference_ref = matchingElement NsText "reference-ref"
+ $ maybeInAnchorRef
+ <<< matchChildContent [] read_plain_text
+
+
+----------------------
+-- Entry point
+----------------------
+
+--read_plain_content :: OdtReaderSafe _x Inlines
+--read_plain_content = strContent >>^ text
+
+read_text :: OdtReaderSafe _x Pandoc
+read_text = matchChildContent' [ read_header
+ , read_paragraph
+ , read_list
+ , read_table
+ ]
+ >>^ doc
+
+post_process :: Pandoc -> Pandoc
+post_process (Pandoc m blocks) =
+ Pandoc m (post_process' blocks)
+
+post_process' :: [Block] -> [Block]
+post_process' ((Table _ a w h r) : (Div ("", ["caption"], _) [Para inlines] ) : xs) =
+ (Table inlines a w h r) : ( post_process' xs )
+post_process' bs = bs
+
+read_body :: OdtReader _x (Pandoc, MediaBag)
+read_body = executeIn NsOffice "body"
+ $ executeIn NsOffice "text"
+ $ liftAsSuccess
+ $ proc inlines -> do
+ txt <- read_text -< inlines
+ state <- getExtraState -< ()
+ returnA -< (post_process txt, getMediaBag state)
diff --git a/src/Text/Pandoc/Readers/Odt/Generic/Fallible.hs b/src/Text/Pandoc/Readers/Odt/Generic/Fallible.hs
new file mode 100644
index 000000000..877443543
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Odt/Generic/Fallible.hs
@@ -0,0 +1,260 @@
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+
+{-
+Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Readers.Odt.Generic.Fallible
+ Copyright : Copyright (C) 2015 Martin Linnemann
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Martin Linnemann <theCodingMarlin@googlemail.com>
+ Stability : alpha
+ Portability : portable
+
+Data types and utilities representing failure. Most of it is based on the
+"Either" type in its usual configuration (left represents failure).
+
+In most cases, the failure type is implied or required to be a "Monoid".
+
+The choice of "Either" instead of a custom type makes it easier to write
+compatible instances of "ArrowChoice".
+-}
+
+-- We export everything
+module Text.Pandoc.Readers.Odt.Generic.Fallible where
+
+import Control.Applicative
+import Control.Monad
+
+import qualified Data.Foldable as F
+import Data.Monoid ((<>))
+
+-- | Default for now. Will probably become a class at some point.
+type Failure = ()
+
+type Fallible a = Either Failure a
+
+
+-- | False -> Left (), True -> Right ()
+boolToEither :: Bool -> Fallible ()
+boolToEither False = Left ()
+boolToEither True = Right ()
+
+-- | False -> Left (), True -> Right ()
+boolToChoice :: Bool -> Fallible ()
+boolToChoice False = Left ()
+boolToChoice True = Right ()
+
+--
+maybeToEither :: Maybe a -> Fallible a
+maybeToEither (Just a) = Right a
+maybeToEither Nothing = Left ()
+
+--
+eitherToMaybe :: Either _l a -> Maybe a
+eitherToMaybe (Left _) = Nothing
+eitherToMaybe (Right a) = Just a
+
+-- | > untagEither === either id id
+untagEither :: Either a a -> a
+untagEither (Left a) = a
+untagEither (Right a) = a
+
+-- | > fromLeft f === either f id
+fromLeft :: (a -> b) -> Either a b -> b
+fromLeft f (Left a) = f a
+fromLeft _ (Right b) = b
+
+-- | > fromRight f === either id f
+fromRight :: (a -> b) -> Either b a -> b
+fromRight _ (Left b) = b
+fromRight f (Right a) = f a
+
+-- | > recover a === fromLeft (const a) === either (const a) id
+recover :: a -> Either _f a -> a
+recover a (Left _) = a
+recover _ (Right a) = a
+
+-- | I would love to use 'fail'. Alas, 'Monad.fail'...
+failWith :: failure -> Either failure _x
+failWith f = Left f
+
+--
+failEmpty :: (Monoid failure) => Either failure _x
+failEmpty = failWith mempty
+
+--
+succeedWith :: a -> Either _x a
+succeedWith = Right
+
+--
+collapseEither :: Either failure (Either failure x)
+ -> Either failure x
+collapseEither (Left f ) = Left f
+collapseEither (Right (Left f)) = Left f
+collapseEither (Right (Right x)) = Right x
+
+-- | If either of the values represents an error, the result is a
+-- (possibly combined) error. If both values represent a success,
+-- both are returned.
+chooseMin :: (Monoid a) => Either a b -> Either a b' -> Either a (b,b')
+chooseMin = chooseMinWith (,)
+
+-- | If either of the values represents an error, the result is a
+-- (possibly combined) error. If both values represent a success,
+-- a combination is returned.
+chooseMinWith :: (Monoid a) => (b -> b' -> c)
+ -> Either a b
+ -> Either a b'
+ -> Either a c
+chooseMinWith (><) (Right a) (Right b) = Right $ a >< b
+chooseMinWith _ (Left a) (Left b) = Left $ a <> b
+chooseMinWith _ (Left a) _ = Left a
+chooseMinWith _ _ (Left b) = Left b
+
+-- | If either of the values represents a non-error, the result is a
+-- (possibly combined) non-error. If both values represent an error, an error
+-- is returned.
+chooseMax :: (Monoid a, Monoid b) => Either a b -> Either a b -> Either a b
+chooseMax = chooseMaxWith (<>)
+
+-- | If either of the values represents a non-error, the result is a
+-- (possibly combined) non-error. If both values represent an error, an error
+-- is returned.
+chooseMaxWith :: (Monoid a) => (b -> b -> b)
+ -> Either a b
+ -> Either a b
+ -> Either a b
+chooseMaxWith (><) (Right a) (Right b) = Right $ a >< b
+chooseMaxWith _ (Left a) (Left b) = Left $ a <> b
+chooseMaxWith _ (Right a) _ = Right a
+chooseMaxWith _ _ (Right b) = Right b
+
+
+-- | Class of containers that can escalate contained 'Either's.
+-- The word "Vector" is meant in the sense of a disease transmitter.
+class ChoiceVector v where
+ spreadChoice :: v (Either f a) -> Either f (v a)
+
+-- Let's do a few examples first
+
+instance ChoiceVector Maybe where
+ spreadChoice (Just (Left f)) = Left f
+ spreadChoice (Just (Right x)) = Right (Just x)
+ spreadChoice Nothing = Right Nothing
+
+instance ChoiceVector (Either l) where
+ spreadChoice (Right (Left f)) = Left f
+ spreadChoice (Right (Right x)) = Right (Right x)
+ spreadChoice (Left x ) = Right (Left x)
+
+instance ChoiceVector ((,) a) where
+ spreadChoice (_, Left f) = Left f
+ spreadChoice (x, Right y) = Right (x,y)
+ -- Wasn't there a newtype somewhere with the elements flipped?
+
+--
+-- More instances later, first some discussion.
+--
+-- I'll have to freshen up on type system details to see how (or if) to do
+-- something like
+--
+-- > instance (ChoiceVector a, ChoiceVector b) => ChoiceVector (a b) where
+-- > :
+--
+-- But maybe it would be even better to use something like
+--
+-- > class ChoiceVector v v' f | v -> v' f where
+-- > spreadChoice :: v -> Either f v'
+--
+-- That way, more places in @v@ could spread the cheer, e.g.:
+--
+-- As before:
+-- -- ( a , Either f b) (a , b) f
+-- > instance ChoiceVector ((,) a (Either f b)) ((,) a b) f where
+-- > spreadChoice (_, Left f) = Left f
+-- > spreadChoice (a, Right b) = Right (a,b)
+--
+-- But also:
+-- -- ( Either f a , b) (a , b) f
+-- > instance ChoiceVector ((,) (Either f a) b) ((,) a b) f where
+-- > spreadChoice (Right a,b) = Right (a,b)
+-- > spreadChoice (Left f,_) = Left f
+--
+-- And maybe even:
+-- -- ( Either f a , Either f b) (a , b) f
+-- > instance ChoiceVector ((,) (Either f a) (Either f b)) ((,) a b) f where
+-- > spreadChoice (Right a , Right b) = Right (a,b)
+-- > spreadChoice (Left f , _ ) = Left f
+-- > spreadChoice ( _ , Left f) = Left f
+--
+-- Of course that would lead to a lot of overlapping instances...
+-- But I can't think of a different way. A selector function might help,
+-- but not even a "Data.Traversable" is powerful enough for that.
+-- But maybe someone has already solved all this with a lens library.
+--
+-- Well, it's an interesting academic question. But for practical purposes,
+-- I have more than enough right now.
+
+instance ChoiceVector ((,,) a b) where
+ spreadChoice (_,_, Left f) = Left f
+ spreadChoice (a,b, Right x) = Right (a,b,x)
+
+instance ChoiceVector ((,,,) a b c) where
+ spreadChoice (_,_,_, Left f) = Left f
+ spreadChoice (a,b,c, Right x) = Right (a,b,c,x)
+
+instance ChoiceVector ((,,,,) a b c d) where
+ spreadChoice (_,_,_,_, Left f) = Left f
+ spreadChoice (a,b,c,d, Right x) = Right (a,b,c,d,x)
+
+instance ChoiceVector (Const a) where
+ spreadChoice (Const c) = Right (Const c) -- need to repackage because of implicit types
+
+-- | Fails on the first error
+instance ChoiceVector [] where
+ spreadChoice = sequence -- using the monad instance of Either.
+ -- Could be generalized to "Data.Traversable" - but why play
+ -- with UndecidableInstances unless this is really needed.
+
+-- | Wrapper for a list. While the normal list instance of 'ChoiceVector'
+-- fails whenever it can, this type will never fail.
+newtype SuccessList a = SuccessList { collectNonFailing :: [a] }
+ deriving ( Eq, Ord, Show )
+
+instance ChoiceVector SuccessList where
+ spreadChoice = Right . SuccessList . (foldr unTagRight []) . collectNonFailing
+ where unTagRight (Right x) = (x:)
+ unTagRight _ = id
+
+-- | Like 'catMaybes', but for 'Either'.
+collectRights :: [Either _l r] -> [r]
+collectRights = collectNonFailing . untag . spreadChoice . SuccessList
+ where untag = fromLeft (error "Unexpected Left")
+
+-- | A version of 'collectRights' generalized to other containers. The
+-- container must be both "reducible" and "buildable". Most general containers
+-- should fullfill these requirements, but there is no single typeclass
+-- (that I know of) for that.
+-- Therefore, they are split between 'Foldable' and 'MonadPlus'.
+-- (Note that 'Data.Traversable.Traversable' alone would not be enough, either.)
+collectRightsF :: (F.Foldable c, MonadPlus c) => c (Either _l r) -> c r
+collectRightsF = F.foldr unTagRight mzero
+ where unTagRight (Right x) = mplus $ return x
+ unTagRight _ = id
diff --git a/src/Text/Pandoc/Readers/Odt/Generic/Namespaces.hs b/src/Text/Pandoc/Readers/Odt/Generic/Namespaces.hs
new file mode 100644
index 000000000..82ae3e20e
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Odt/Generic/Namespaces.hs
@@ -0,0 +1,62 @@
+{-
+Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Readers.Odt.Generic.Namespaces
+ Copyright : Copyright (C) 2015 Martin Linnemann
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Martin Linnemann <theCodingMarlin@googlemail.com>
+ Stability : alpha
+ Portability : portable
+
+A class containing a set of namespace identifiers. Used to convert between
+typesafe Haskell namespace identifiers and unsafe "real world" namespaces.
+-}
+
+module Text.Pandoc.Readers.Odt.Generic.Namespaces where
+
+import qualified Data.Map as M
+
+--
+type NameSpaceIRI = String
+
+--
+type NameSpaceIRIs nsID = M.Map nsID NameSpaceIRI
+
+--
+class (Eq nsID, Ord nsID) => NameSpaceID nsID where
+
+ -- | Given a IRI, possibly update the map and return the id of the namespace.
+ -- May fail if the namespace is unknown and the application does not
+ -- allow unknown namespaces.
+ getNamespaceID :: NameSpaceIRI
+ -> NameSpaceIRIs nsID
+ -> Maybe (NameSpaceIRIs nsID, nsID)
+ -- | Given a namespace id, lookup its IRI. May be overriden for performance.
+ getIRI :: nsID
+ -> NameSpaceIRIs nsID
+ -> Maybe NameSpaceIRI
+ -- | The root element of an XML document has a namespace, too, and the
+ -- "XML.Light-parser" is eager to remove the corresponding namespace
+ -- attribute.
+ -- As a result, at least this root namespace must be provided.
+ getInitialIRImap :: NameSpaceIRIs nsID
+
+ getIRI = M.lookup
+ getInitialIRImap = M.empty
diff --git a/src/Text/Pandoc/Readers/Odt/Generic/SetMap.hs b/src/Text/Pandoc/Readers/Odt/Generic/SetMap.hs
new file mode 100644
index 000000000..afd7d616c
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Odt/Generic/SetMap.hs
@@ -0,0 +1,48 @@
+{-
+Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Readers.Odt.Generic.SetMap
+ Copyright : Copyright (C) 2015 Martin Linnemann
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Martin Linnemann <theCodingMarlin@googlemail.com>
+ Stability : alpha
+ Portability : portable
+
+A map of values to sets of values.
+-}
+
+module Text.Pandoc.Readers.Odt.Generic.SetMap where
+
+import qualified Data.Map as M
+import qualified Data.Set as S
+
+type SetMap k v = M.Map k (S.Set v)
+
+empty :: SetMap k v
+empty = M.empty
+
+fromList :: (Ord k, Ord v) => [(k,v)] -> SetMap k v
+fromList = foldr (uncurry insert) empty
+
+insert :: (Ord k, Ord v) => k -> v -> SetMap k v -> SetMap k v
+insert key value setMap = M.insertWith S.union key (S.singleton value) setMap
+
+union3 :: (Ord k) => SetMap k v -> SetMap k v -> SetMap k v -> SetMap k v
+union3 sm1 sm2 sm3 = sm1 `M.union` sm2 `M.union` sm3
diff --git a/src/Text/Pandoc/Readers/Odt/Generic/Utils.hs b/src/Text/Pandoc/Readers/Odt/Generic/Utils.hs
new file mode 100644
index 000000000..6c10ed61d
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Odt/Generic/Utils.hs
@@ -0,0 +1,171 @@
+{-# LANGUAGE TypeOperators #-}
+{-# LANGUAGE TupleSections #-}
+{-# LANGUAGE PatternGuards #-}
+{-# LANGUAGE ViewPatterns #-}
+
+{-
+Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Reader.Odt.Generic.Utils
+ Copyright : Copyright (C) 2015 Martin Linnemann
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Martin Linnemann <theCodingMarlin@googlemail.com>
+ Stability : alpha
+ Portability : portable
+
+General utility functions for the odt reader.
+-}
+
+module Text.Pandoc.Readers.Odt.Generic.Utils
+( uncurry3
+, uncurry4
+, uncurry5
+, uncurry6
+, uncurry7
+, uncurry8
+, swap
+, reverseComposition
+, bool
+, tryToRead
+, Lookupable(..)
+, readLookupables
+, readLookupable
+, readPercent
+, findBy
+, swing
+, composition
+) where
+
+import Control.Category ( Category, (>>>), (<<<) )
+import qualified Control.Category as Cat ( id )
+import Control.Monad ( msum )
+
+import qualified Data.Foldable as F ( Foldable, foldr )
+import Data.Maybe
+
+
+-- | Aequivalent to
+-- > foldr (.) id
+-- where '(.)' are 'id' are the ones from "Control.Category"
+-- and 'foldr' is the one from "Data.Foldable".
+-- The noun-form was chosen to be consistend with 'sum', 'product' etc
+-- based on the discussion at
+-- <https://groups.google.com/forum/#!topic/haskell-cafe/VkOZM1zaHOI>
+-- (that I was not part of)
+composition :: (Category cat, F.Foldable f) => f (cat a a) -> cat a a
+composition = F.foldr (<<<) Cat.id
+
+-- | Aequivalent to
+-- > foldr (flip (.)) id
+-- where '(.)' are 'id' are the ones from "Control.Category"
+-- and 'foldr' is the one from "Data.Foldable".
+-- A reversed version of 'composition'.
+reverseComposition :: (Category cat, F.Foldable f) => f (cat a a) -> cat a a
+reverseComposition = F.foldr (>>>) Cat.id
+
+-- | 'Either' has 'either', 'Maybe' has 'maybe'. 'Bool' should have 'bool'.
+-- Note that the first value is selected if the boolean value is 'False'.
+-- That makes 'bool' consistent with the other two. Also, 'bool' now takes its
+-- arguments in the exact opposite order compared to the normal if construct.
+bool :: a -> a -> Bool -> a
+bool x _ False = x
+bool _ x True = x
+
+-- | This function often makes it possible to switch values with the functions
+-- that are applied to them.
+--
+-- Examples:
+-- > swing map :: [a -> b] -> a -> [b]
+-- > swing any :: [a -> Bool] -> a -> Bool
+-- > swing foldr :: b -> a -> [a -> b -> b] -> b
+-- > swing scanr :: c -> a -> [a -> c -> c] -> c
+-- > swing zipWith :: [a -> b -> c] -> a -> [b] -> [c]
+-- > swing find :: [a -> Bool] -> a -> Maybe (a -> Bool)
+--
+-- Stolen from <https://wiki.haskell.org/Pointfree>
+swing :: (((a -> b) -> b) -> c -> d) -> c -> a -> d
+swing = flip.(.flip id)
+-- swing f c a = f ($ a) c
+
+
+-- | Alternative to 'read'/'reads'. The former of these throws errors
+-- (nobody wants that) while the latter returns "to much" for simple purposes.
+-- This function instead applies 'reads' and returns the first match (if any)
+-- in a 'Maybe'.
+tryToRead :: (Read r) => String -> Maybe r
+tryToRead = reads >>> listToMaybe >>> fmap fst
+
+-- | A version of 'reads' that requires a '%' sign after the number
+readPercent :: ReadS Int
+readPercent s = [ (i,s') | (i , r ) <- reads s
+ , ("%" , s') <- lex r
+ ]
+
+-- | Data that can be looked up.
+-- This is mostly a utility to read data with kind *.
+class Lookupable a where
+ lookupTable :: [(String, a)]
+
+-- | The idea is to use this function as if there was a declaration like
+--
+-- > instance (Lookupable a) => (Read a) where
+-- > readsPrec _ = readLookupables
+-- .
+-- But including this code in this form would need UndecideableInstances.
+-- That is a bad idea. Luckily 'readLookupable' (without the s at the end)
+-- can be used directly in almost any case.
+readLookupables :: (Lookupable a) => String -> [(a,String)]
+readLookupables s = [ (a,rest) | (word,rest) <- lex s,
+ let result = lookup word lookupTable,
+ isJust result,
+ let Just a = result
+ ]
+
+-- | Very similar to a simple 'lookup' in the 'lookupTable', but with a lexer.
+readLookupable :: (Lookupable a) => String -> Maybe a
+readLookupable s = msum
+ $ map ((`lookup` lookupTable).fst)
+ $ lex s
+
+uncurry3 :: (a->b->c -> z) -> (a,b,c ) -> z
+uncurry4 :: (a->b->c->d -> z) -> (a,b,c,d ) -> z
+uncurry5 :: (a->b->c->d->e -> z) -> (a,b,c,d,e ) -> z
+uncurry6 :: (a->b->c->d->e->f -> z) -> (a,b,c,d,e,f ) -> z
+uncurry7 :: (a->b->c->d->e->f->g -> z) -> (a,b,c,d,e,f,g ) -> z
+uncurry8 :: (a->b->c->d->e->f->g->h -> z) -> (a,b,c,d,e,f,g,h) -> z
+
+uncurry3 fun (a,b,c ) = fun a b c
+uncurry4 fun (a,b,c,d ) = fun a b c d
+uncurry5 fun (a,b,c,d,e ) = fun a b c d e
+uncurry6 fun (a,b,c,d,e,f ) = fun a b c d e f
+uncurry7 fun (a,b,c,d,e,f,g ) = fun a b c d e f g
+uncurry8 fun (a,b,c,d,e,f,g,h) = fun a b c d e f g h
+
+swap :: (a,b) -> (b,a)
+swap (a,b) = (b,a)
+
+-- | A version of "Data.List.find" that uses a converter to a Maybe instance.
+-- The returned value is the first which the converter returns in a 'Just'
+-- wrapper.
+findBy :: (a -> Maybe b) -> [a] -> Maybe b
+findBy _ [] = Nothing
+findBy f ((f -> Just x):_ ) = Just x
+findBy f ( _:xs) = findBy f xs
+
diff --git a/src/Text/Pandoc/Readers/Odt/Generic/XMLConverter.hs b/src/Text/Pandoc/Readers/Odt/Generic/XMLConverter.hs
new file mode 100644
index 000000000..8c03d1a09
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Odt/Generic/XMLConverter.hs
@@ -0,0 +1,1063 @@
+{-# LANGUAGE Arrows #-}
+{-# LANGUAGE TupleSections #-}
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE PatternGuards #-}
+{-# LANGUAGE RecordWildCards #-}
+
+{-
+Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Readers.Odt.Generic.XMLConverter
+ Copyright : Copyright (C) 2015 Martin Linnemann
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Martin Linnemann <theCodingMarlin@googlemail.com>
+ Stability : alpha
+ Portability : portable
+
+A generalized XML parser based on stateful arrows.
+It might be sufficient to define this reader as a comonad, but there is
+not a lot of use in trying.
+-}
+
+module Text.Pandoc.Readers.Odt.Generic.XMLConverter
+( ElementName
+, XMLConverterState
+, XMLConverter
+, FallibleXMLConverter
+, swapPosition
+, runConverter
+, runConverter''
+, runConverter'
+, runConverterF'
+, runConverterF
+, getCurrentElement
+, getExtraState
+, setExtraState
+, modifyExtraState
+, convertingExtraState
+, producingExtraState
+, lookupNSiri
+, lookupNSprefix
+, readNSattributes
+, elemName
+, elemNameIs
+, strContent
+, elContent
+, currentElem
+, currentElemIs
+, expectElement
+, elChildren
+, findChildren
+, filterChildren
+, filterChildrenName
+, findChild'
+, findChild
+, filterChild'
+, filterChild
+, filterChildName'
+, filterChildName
+, isSet
+, isSet'
+, isSetWithDefault
+, hasAttrValueOf'
+, failIfNotAttrValueOf
+, isThatTheAttrValue
+, searchAttrIn
+, searchAttrWith
+, searchAttr
+, lookupAttr
+, lookupAttr'
+, lookupAttrWithDefault
+, lookupDefaultingAttr
+, findAttr'
+, findAttr
+, findAttrWithDefault
+, readAttr
+, readAttr'
+, readAttrWithDefault
+, getAttr
+-- , (>/<)
+-- , (?>/<)
+, executeIn
+, collectEvery
+, withEveryL
+, withEvery
+, tryAll
+, tryAll'
+, IdXMLConverter
+, MaybeEConverter
+, ElementMatchConverter
+, MaybeCConverter
+, ContentMatchConverter
+, makeMatcherE
+, makeMatcherC
+, prepareMatchersE
+, prepareMatchersC
+, matchChildren
+, matchContent''
+, matchContent'
+, matchContent
+) where
+
+import Control.Applicative hiding ( liftA, liftA2 )
+import Control.Monad ( MonadPlus )
+import Control.Arrow
+
+import qualified Data.Map as M
+import qualified Data.Foldable as F
+import Data.Default
+import Data.Maybe
+
+import qualified Text.XML.Light as XML
+
+import Text.Pandoc.Readers.Odt.Arrows.State
+import Text.Pandoc.Readers.Odt.Arrows.Utils
+
+import Text.Pandoc.Readers.Odt.Generic.Namespaces
+import Text.Pandoc.Readers.Odt.Generic.Utils
+import Text.Pandoc.Readers.Odt.Generic.Fallible
+
+--------------------------------------------------------------------------------
+-- Basis types for readability
+--------------------------------------------------------------------------------
+
+--
+type ElementName = String
+type AttributeName = String
+type AttributeValue = String
+
+--
+type NameSpacePrefix = String
+
+--
+type NameSpacePrefixes nsID = M.Map nsID NameSpacePrefix
+
+--------------------------------------------------------------------------------
+-- Main converter state
+--------------------------------------------------------------------------------
+
+-- GADT so some of the NameSpaceID restrictions can be deduced
+data XMLConverterState nsID extraState where
+ XMLConverterState :: NameSpaceID nsID
+ => { -- | A stack of parent elements. The top element is the current one.
+ -- Arguably, a real Zipper would be better. But that is an
+ -- optimization that can be made at a later time, e.g. when
+ -- replacing Text.XML.Light.
+ parentElements :: [XML.Element]
+ -- | A map from internal namespace IDs to the namespace prefixes
+ -- used in XML elements
+ , namespacePrefixes :: NameSpacePrefixes nsID
+ -- | A map from internal namespace IDs to namespace IRIs
+ -- (Only necessary for matching namespace IDs and prefixes)
+ , namespaceIRIs :: NameSpaceIRIs nsID
+ -- | A place to put "something else". This feature is used heavily
+ -- to keep the main code cleaner. More specifically, the main reader
+ -- is divided into different stages. Each stage lifts something up
+ -- here, which the next stage can then use. This could of course be
+ -- generalized to a state-tree or used for the namespace IRIs. The
+ -- border between states and values is an imaginary one, after all.
+ -- But the separation as it is seems to be enough for now.
+ , moreState :: extraState
+ }
+ -> XMLConverterState nsID extraState
+
+--
+createStartState :: (NameSpaceID nsID)
+ => XML.Element
+ -> extraState
+ -> XMLConverterState nsID extraState
+createStartState element extraState =
+ XMLConverterState
+ { parentElements = [element]
+ , namespacePrefixes = M.empty
+ , namespaceIRIs = getInitialIRImap
+ , moreState = extraState
+ }
+
+-- | Functor over extra state
+instance Functor (XMLConverterState nsID) where
+ fmap f ( XMLConverterState parents prefixes iRIs extraState )
+ = XMLConverterState parents prefixes iRIs (f extraState)
+
+--
+replaceExtraState :: extraState
+ -> XMLConverterState nsID _x
+ -> XMLConverterState nsID extraState
+replaceExtraState x s
+ = fmap (const x) s
+
+--
+currentElement :: XMLConverterState nsID extraState
+ -> XML.Element
+currentElement state = head (parentElements state)
+
+-- | Replace the current position by another, modifying the extra state
+-- in the process
+swapPosition :: (extraState -> extraState')
+ -> [XML.Element]
+ -> XMLConverterState nsID extraState
+ -> XMLConverterState nsID extraState'
+swapPosition f stack state
+ = state { parentElements = stack
+ , moreState = f (moreState state)
+ }
+
+-- | Replace the current position by another, modifying the extra state
+-- in the process
+swapStack' :: XMLConverterState nsID extraState
+ -> [XML.Element]
+ -> ( XMLConverterState nsID extraState , [XML.Element] )
+swapStack' state stack
+ = ( state { parentElements = stack }
+ , parentElements state
+ )
+
+--
+pushElement :: XML.Element
+ -> XMLConverterState nsID extraState
+ -> XMLConverterState nsID extraState
+pushElement e state = state { parentElements = e:(parentElements state) }
+
+-- | Pop the top element from the call stack, unless it is the last one.
+popElement :: XMLConverterState nsID extraState
+ -> Maybe (XMLConverterState nsID extraState)
+popElement state
+ | _:es@(_:_) <- parentElements state = Just $ state { parentElements = es }
+ | otherwise = Nothing
+
+--------------------------------------------------------------------------------
+-- Main type
+--------------------------------------------------------------------------------
+
+-- It might be a good idea to pack the converters in a GADT
+-- Downside: data instead of type
+-- Upside: 'Failure' could be made a parameter as well.
+
+--
+type XMLConverter nsID extraState input output
+ = ArrowState (XMLConverterState nsID extraState ) input output
+
+type FallibleXMLConverter nsID extraState input output
+ = XMLConverter nsID extraState input (Fallible output)
+
+--
+runConverter :: XMLConverter nsID extraState input output
+ -> XMLConverterState nsID extraState
+ -> input
+ -> output
+runConverter converter state input = snd $ runArrowState converter (state,input)
+
+--
+runConverter'' :: (NameSpaceID nsID)
+ => XMLConverter nsID extraState (Fallible ()) output
+ -> extraState
+ -> XML.Element
+ -> output
+runConverter'' converter extraState element = runConverter (readNSattributes >>> converter) (createStartState element extraState) ()
+
+runConverter' :: (NameSpaceID nsID)
+ => FallibleXMLConverter nsID extraState () success
+ -> extraState
+ -> XML.Element
+ -> Fallible success
+runConverter' converter extraState element = runConverter (readNSattributes >>? converter) (createStartState element extraState) ()
+
+--
+runConverterF' :: FallibleXMLConverter nsID extraState x y
+ -> XMLConverterState nsID extraState
+ -> Fallible x -> Fallible y
+runConverterF' a s e = runConverter (returnV e >>? a) s e
+
+--
+runConverterF :: (NameSpaceID nsID)
+ => FallibleXMLConverter nsID extraState XML.Element x
+ -> extraState
+ -> Fallible XML.Element -> Fallible x
+runConverterF a s = either failWith
+ (\e -> runConverter a (createStartState e s) e)
+
+--
+getCurrentElement :: XMLConverter nsID extraState x XML.Element
+getCurrentElement = extractFromState currentElement
+
+--
+getExtraState :: XMLConverter nsID extraState x extraState
+getExtraState = extractFromState moreState
+
+--
+setExtraState :: XMLConverter nsID extraState extraState extraState
+setExtraState = withState $ \state extra
+ -> (replaceExtraState extra state , extra)
+
+
+-- | Lifts a function to the extra state.
+modifyExtraState :: (extraState -> extraState)
+ -> XMLConverter nsID extraState x x
+modifyExtraState = modifyState.fmap
+
+
+-- | First sets the extra state to the new value. Then modifies the original
+-- extra state with a converter that uses the new state. Finally, the
+-- intermediate state is dropped and the extra state is lifted into the
+-- state as it was at the beginning of the function.
+-- As a result, exactly the extra state and nothing else is changed.
+-- The resulting converter even behaves like an identity converter on the
+-- value level.
+--
+-- (The -ing form is meant to be mnemonic in a sequence of arrows as in
+-- convertingExtraState () converter >>> doOtherStuff)
+--
+convertingExtraState :: extraState'
+ -> FallibleXMLConverter nsID extraState' extraState extraState
+ -> FallibleXMLConverter nsID extraState x x
+convertingExtraState v a = withSubStateF setVAsExtraState modifyWithA
+ where
+ setVAsExtraState = liftAsSuccess $ extractFromState id >>^ replaceExtraState v
+ modifyWithA = keepingTheValue (moreState ^>> a)
+ >>^ spreadChoice >>?% flip replaceExtraState
+
+-- | First sets the extra state to the new value. Then produces a new
+-- extra state with a converter that uses the new state. Finally, the
+-- intermediate state is dropped and the extra state is lifted into the
+-- state as it was at the beginning of the function.
+-- As a result, exactly the extra state and nothing else is changed.
+-- The resulting converter even behaves like an identity converter on the
+-- value level.
+--
+-- Aequivalent to
+--
+-- > \v x a -> convertingExtraState v (returnV x >>> a)
+--
+-- (The -ing form is meant to be mnemonic in a sequence of arrows as in
+-- producingExtraState () () producer >>> doOtherStuff)
+--
+producingExtraState :: extraState'
+ -> a
+ -> FallibleXMLConverter nsID extraState' a extraState
+ -> FallibleXMLConverter nsID extraState x x
+producingExtraState v x a = convertingExtraState v (returnV x >>> a)
+
+
+--------------------------------------------------------------------------------
+-- Work in namespaces
+--------------------------------------------------------------------------------
+
+-- | Arrow version of 'getIRI'
+lookupNSiri :: (NameSpaceID nsID)
+ => nsID
+ -> XMLConverter nsID extraState x (Maybe NameSpaceIRI)
+lookupNSiri nsID = extractFromState
+ $ \state -> getIRI nsID $ namespaceIRIs state
+
+--
+lookupNSprefix :: (NameSpaceID nsID)
+ => nsID
+ -> XMLConverter nsID extraState x (Maybe NameSpacePrefix)
+lookupNSprefix nsID = extractFromState
+ $ \state -> M.lookup nsID $ namespacePrefixes state
+
+-- | Extracts namespace attributes from the current element and tries to
+-- update the current mapping accordingly
+readNSattributes :: (NameSpaceID nsID)
+ => FallibleXMLConverter nsID extraState x ()
+readNSattributes = fromState $ \state -> maybe (state, failEmpty )
+ ( , succeedWith ())
+ (extractNSAttrs state )
+ where
+ extractNSAttrs :: (NameSpaceID nsID)
+ => XMLConverterState nsID extraState
+ -> Maybe (XMLConverterState nsID extraState)
+ extractNSAttrs startState
+ = foldl (\state d -> state >>= addNS d)
+ (Just startState)
+ nsAttribs
+ where nsAttribs = mapMaybe readNSattr (XML.elAttribs element)
+ element = currentElement startState
+ readNSattr (XML.Attr (XML.QName name _ (Just "xmlns")) iri)
+ = Just (name, iri)
+ readNSattr _ = Nothing
+ addNS (prefix, iri) state = fmap updateState
+ $ getNamespaceID iri
+ $ namespaceIRIs state
+ where updateState (iris,nsID)
+ = state { namespaceIRIs = iris
+ , namespacePrefixes = M.insert nsID prefix
+ $ namespacePrefixes state
+ }
+
+--------------------------------------------------------------------------------
+-- Common namespace accessors
+--------------------------------------------------------------------------------
+
+-- | Given a namespace id and an element name, creates a 'XML.QName' for
+-- internal use
+elemName :: (NameSpaceID nsID)
+ => nsID -> ElementName
+ -> XMLConverter nsID extraState x XML.QName
+elemName nsID name = lookupNSiri nsID
+ &&& lookupNSprefix nsID
+ >>% XML.QName name
+
+-- | Checks if a given element matches both a specified namespace id
+-- and a specified element name
+elemNameIs :: (NameSpaceID nsID)
+ => nsID -> ElementName
+ -> XMLConverter nsID extraState XML.Element Bool
+elemNameIs nsID name = keepingTheValue (lookupNSiri nsID) >>% hasThatName
+ where hasThatName e iri = let elName = XML.elName e
+ in XML.qName elName == name
+ && XML.qURI elName == iri
+
+--------------------------------------------------------------------------------
+-- General content
+--------------------------------------------------------------------------------
+
+--
+strContent :: XMLConverter nsID extraState x String
+strContent = getCurrentElement
+ >>^ XML.strContent
+
+--
+elContent :: XMLConverter nsID extraState x [XML.Content]
+elContent = getCurrentElement
+ >>^ XML.elContent
+
+--------------------------------------------------------------------------------
+-- Current element
+--------------------------------------------------------------------------------
+
+--
+currentElem :: XMLConverter nsID extraState x (XML.QName)
+currentElem = getCurrentElement
+ >>^ XML.elName
+
+currentElemIs :: (NameSpaceID nsID)
+ => nsID -> ElementName
+ -> XMLConverter nsID extraState x Bool
+currentElemIs nsID name = getCurrentElement
+ >>> elemNameIs nsID name
+
+
+
+{-
+currentElemIs'' nsID name = ( (getCurrentElement >>^ XML.elName >>>
+ (XML.qName >>^ (&&).(== name) )
+ ^&&&^
+ (XML.qIRI >>^ (==) )
+ ) >>% (.)
+ ) &&& lookupNSiri nsID >>% ($)
+-}
+
+--
+expectElement :: (NameSpaceID nsID)
+ => nsID -> ElementName
+ -> FallibleXMLConverter nsID extraState x ()
+expectElement nsID name = currentElemIs nsID name
+ >>^ boolToChoice
+
+--------------------------------------------------------------------------------
+-- Chilren
+--------------------------------------------------------------------------------
+
+--
+elChildren :: XMLConverter nsID extraState x [XML.Element]
+elChildren = getCurrentElement
+ >>^ XML.elChildren
+
+--
+findChildren :: (NameSpaceID nsID)
+ => nsID -> ElementName
+ -> XMLConverter nsID extraState x [XML.Element]
+findChildren nsID name = elemName nsID name
+ &&& getCurrentElement
+ >>% XML.findChildren
+
+--
+filterChildren :: (XML.Element -> Bool)
+ -> XMLConverter nsID extraState x [XML.Element]
+filterChildren p = getCurrentElement
+ >>^ XML.filterChildren p
+
+--
+filterChildrenName :: (XML.QName -> Bool)
+ -> XMLConverter nsID extraState x [XML.Element]
+filterChildrenName p = getCurrentElement
+ >>^ XML.filterChildrenName p
+
+--
+findChild' :: (NameSpaceID nsID)
+ => nsID
+ -> ElementName
+ -> XMLConverter nsID extraState x (Maybe XML.Element)
+findChild' nsID name = elemName nsID name
+ &&& getCurrentElement
+ >>% XML.findChild
+
+--
+findChild :: (NameSpaceID nsID)
+ => nsID -> ElementName
+ -> FallibleXMLConverter nsID extraState x XML.Element
+findChild nsID name = findChild' nsID name
+ >>> maybeToChoice
+
+--
+filterChild' :: (XML.Element -> Bool)
+ -> XMLConverter nsID extraState x (Maybe XML.Element)
+filterChild' p = getCurrentElement
+ >>^ XML.filterChild p
+
+--
+filterChild :: (XML.Element -> Bool)
+ -> FallibleXMLConverter nsID extraState x XML.Element
+filterChild p = filterChild' p
+ >>> maybeToChoice
+
+--
+filterChildName' :: (XML.QName -> Bool)
+ -> XMLConverter nsID extraState x (Maybe XML.Element)
+filterChildName' p = getCurrentElement
+ >>^ XML.filterChildName p
+
+--
+filterChildName :: (XML.QName -> Bool)
+ -> FallibleXMLConverter nsID extraState x XML.Element
+filterChildName p = filterChildName' p
+ >>> maybeToChoice
+
+
+--------------------------------------------------------------------------------
+-- Attributes
+--------------------------------------------------------------------------------
+
+--
+isSet :: (NameSpaceID nsID)
+ => nsID -> AttributeName
+ -> (Either Failure Bool)
+ -> FallibleXMLConverter nsID extraState x Bool
+isSet nsID attrName deflt
+ = findAttr' nsID attrName
+ >>^ maybe deflt stringToBool
+
+--
+isSet' :: (NameSpaceID nsID)
+ => nsID -> AttributeName
+ -> XMLConverter nsID extraState x (Maybe Bool)
+isSet' nsID attrName = findAttr' nsID attrName
+ >>^ (>>= stringToBool')
+
+isSetWithDefault :: (NameSpaceID nsID)
+ => nsID -> AttributeName
+ -> Bool
+ -> XMLConverter nsID extraState x Bool
+isSetWithDefault nsID attrName def'
+ = isSet' nsID attrName
+ >>^ fromMaybe def'
+
+--
+hasAttrValueOf' :: (NameSpaceID nsID)
+ => nsID -> AttributeName
+ -> AttributeValue
+ -> XMLConverter nsID extraState x Bool
+hasAttrValueOf' nsID attrName attrValue
+ = findAttr nsID attrName
+ >>> ( const False ^|||^ (==attrValue))
+
+--
+failIfNotAttrValueOf :: (NameSpaceID nsID)
+ => nsID -> AttributeName
+ -> AttributeValue
+ -> FallibleXMLConverter nsID extraState x ()
+failIfNotAttrValueOf nsID attrName attrValue
+ = hasAttrValueOf' nsID attrName attrValue
+ >>^ boolToChoice
+
+-- | Is the value that is currently transported in the arrow the value of
+-- the specified attribute?
+isThatTheAttrValue :: (NameSpaceID nsID)
+ => nsID -> AttributeName
+ -> FallibleXMLConverter nsID extraState AttributeValue Bool
+isThatTheAttrValue nsID attrName
+ = keepingTheValue
+ (findAttr nsID attrName)
+ >>% right.(==)
+
+-- | Lookup value in a dictionary, fail if no attribute found or value
+-- not in dictionary
+searchAttrIn :: (NameSpaceID nsID)
+ => nsID -> AttributeName
+ -> [(AttributeValue,a)]
+ -> FallibleXMLConverter nsID extraState x a
+searchAttrIn nsID attrName dict
+ = findAttr nsID attrName
+ >>?^? maybeToChoice.(`lookup` dict )
+
+
+-- | Lookup value in a dictionary. Fail if no attribute found. If value not in
+-- dictionary, return default value
+searchAttrWith :: (NameSpaceID nsID)
+ => nsID -> AttributeName
+ -> a
+ -> [(AttributeValue,a)]
+ -> FallibleXMLConverter nsID extraState x a
+searchAttrWith nsID attrName defV dict
+ = findAttr nsID attrName
+ >>?^ (fromMaybe defV).(`lookup` dict )
+
+-- | Lookup value in a dictionary. If attribute or value not found,
+-- return default value
+searchAttr :: (NameSpaceID nsID)
+ => nsID -> AttributeName
+ -> a
+ -> [(AttributeValue,a)]
+ -> XMLConverter nsID extraState x a
+searchAttr nsID attrName defV dict
+ = searchAttrIn nsID attrName dict
+ >>> const defV ^|||^ id
+
+-- | Read a 'Lookupable' attribute. Fail if no match.
+lookupAttr :: (NameSpaceID nsID, Lookupable a)
+ => nsID -> AttributeName
+ -> FallibleXMLConverter nsID extraState x a
+lookupAttr nsID attrName = lookupAttr' nsID attrName
+ >>^ maybeToChoice
+
+
+-- | Read a 'Lookupable' attribute. Return the result as a 'Maybe'.
+lookupAttr' :: (NameSpaceID nsID, Lookupable a)
+ => nsID -> AttributeName
+ -> XMLConverter nsID extraState x (Maybe a)
+lookupAttr' nsID attrName
+ = findAttr' nsID attrName
+ >>^ (>>= readLookupable)
+
+-- | Read a 'Lookupable' attribute with explicit default
+lookupAttrWithDefault :: (NameSpaceID nsID, Lookupable a)
+ => nsID -> AttributeName
+ -> a
+ -> XMLConverter nsID extraState x a
+lookupAttrWithDefault nsID attrName deflt
+ = lookupAttr' nsID attrName
+ >>^ fromMaybe deflt
+
+-- | Read a 'Lookupable' attribute with implicit default
+lookupDefaultingAttr :: (NameSpaceID nsID, Lookupable a, Default a)
+ => nsID -> AttributeName
+ -> XMLConverter nsID extraState x a
+lookupDefaultingAttr nsID attrName
+ = lookupAttrWithDefault nsID attrName def
+
+-- | Return value as a (Maybe String)
+findAttr' :: (NameSpaceID nsID)
+ => nsID -> AttributeName
+ -> XMLConverter nsID extraState x (Maybe AttributeValue)
+findAttr' nsID attrName = elemName nsID attrName
+ &&& getCurrentElement
+ >>% XML.findAttr
+
+-- | Return value as string or fail
+findAttr :: (NameSpaceID nsID)
+ => nsID -> AttributeName
+ -> FallibleXMLConverter nsID extraState x AttributeValue
+findAttr nsID attrName = findAttr' nsID attrName
+ >>> maybeToChoice
+
+-- | Return value as string or return provided default value
+findAttrWithDefault :: (NameSpaceID nsID)
+ => nsID -> AttributeName
+ -> AttributeValue
+ -> XMLConverter nsID extraState x AttributeValue
+findAttrWithDefault nsID attrName deflt
+ = findAttr' nsID attrName
+ >>^ fromMaybe deflt
+
+-- | Read and return value or fail
+readAttr :: (NameSpaceID nsID, Read attrValue)
+ => nsID -> AttributeName
+ -> FallibleXMLConverter nsID extraState x attrValue
+readAttr nsID attrName = readAttr' nsID attrName
+ >>> maybeToChoice
+
+-- | Read and return value or return Nothing
+readAttr' :: (NameSpaceID nsID, Read attrValue)
+ => nsID -> AttributeName
+ -> XMLConverter nsID extraState x (Maybe attrValue)
+readAttr' nsID attrName = findAttr' nsID attrName
+ >>^ (>>= tryToRead)
+
+-- | Read and return value or return provided default value
+readAttrWithDefault :: (NameSpaceID nsID, Read attrValue)
+ => nsID -> AttributeName
+ -> attrValue
+ -> XMLConverter nsID extraState x attrValue
+readAttrWithDefault nsID attrName deflt
+ = findAttr' nsID attrName
+ >>^ (>>= tryToRead)
+ >>^ fromMaybe deflt
+
+-- | Read and return value or return default value from 'Default' instance
+getAttr :: (NameSpaceID nsID, Read attrValue, Default attrValue)
+ => nsID -> AttributeName
+ -> XMLConverter nsID extraState x attrValue
+getAttr nsID attrName = readAttrWithDefault nsID attrName def
+
+--------------------------------------------------------------------------------
+-- Movements
+--------------------------------------------------------------------------------
+
+--
+jumpThere :: XMLConverter nsID extraState XML.Element XML.Element
+jumpThere = withState (\state element
+ -> ( pushElement element state , element )
+ )
+
+--
+swapStack :: XMLConverter nsID extraState [XML.Element] [XML.Element]
+swapStack = withState swapStack'
+
+--
+jumpBack :: FallibleXMLConverter nsID extraState _x _x
+jumpBack = tryModifyState (popElement >>> maybeToChoice)
+
+-- | Support function for "procedural" converters: jump to an element, execute
+-- a converter, jump back.
+-- This version is safer than 'executeThere', because it does not rely on the
+-- internal stack. As a result, the converter can not move around in arbitrary
+-- ways. The downside is of course that some of the environment is not
+-- accessible to the converter.
+switchingTheStack :: XMLConverter nsID moreState a b
+ -> XMLConverter nsID moreState (a, XML.Element) b
+switchingTheStack a = second ( (:[]) ^>> swapStack )
+ >>> first a
+ >>> second swapStack
+ >>^ fst
+
+-- | Support function for "procedural" converters: jumps to an element, executes
+-- a converter, jumps back.
+-- Make sure that the converter is well-behaved; that is it should
+-- return to the exact position it started from in /every possible path/ of
+-- execution, even if it "fails". If it does not, you may encounter
+-- strange bugs. If you are not sure about the behaviour or want to use
+-- shortcuts, you can often use 'switchingTheStack' instead.
+executeThere :: FallibleXMLConverter nsID moreState a b
+ -> FallibleXMLConverter nsID moreState (a, XML.Element) b
+executeThere a = second jumpThere
+ >>> fst
+ ^>> a
+ >>> jumpBack -- >>? jumpBack would not ensure the jump.
+ >>^ collapseEither
+
+-- | Do something in a sub-element, tnen come back
+executeIn :: (NameSpaceID nsID)
+ => nsID -> ElementName
+ -> FallibleXMLConverter nsID extraState f s
+ -> FallibleXMLConverter nsID extraState f s
+executeIn nsID name a = keepingTheValue
+ (findChild nsID name)
+ >>> ignoringState liftFailure
+ >>? switchingTheStack a
+ where liftFailure (_, (Left f)) = Left f
+ liftFailure (x, (Right e)) = Right (x, e)
+
+--------------------------------------------------------------------------------
+-- Iterating over children
+--------------------------------------------------------------------------------
+
+-- Helper converter to prepare different types of iterations.
+-- It lifts the children (of a certain type) of the current element
+-- into the value level and pairs each one with the current input value.
+prepareIteration :: (NameSpaceID nsID)
+ => nsID -> ElementName
+ -> XMLConverter nsID extraState b [(b, XML.Element)]
+prepareIteration nsID name = keepingTheValue
+ (findChildren nsID name)
+ >>% distributeValue
+
+-- | Applies a converter to every child element of a specific type.
+-- Collects results in a 'Monoid'.
+-- Fails completely if any conversion fails.
+collectEvery :: (NameSpaceID nsID, Monoid m)
+ => nsID -> ElementName
+ -> FallibleXMLConverter nsID extraState a m
+ -> FallibleXMLConverter nsID extraState a m
+collectEvery nsID name a = prepareIteration nsID name
+ >>> foldS' (switchingTheStack a)
+
+--
+withEveryL :: (NameSpaceID nsID)
+ => nsID -> ElementName
+ -> FallibleXMLConverter nsID extraState a b
+ -> FallibleXMLConverter nsID extraState a [b]
+withEveryL = withEvery
+
+-- | Applies a converter to every child element of a specific type.
+-- Collects results in a 'MonadPlus'.
+-- Fails completely if any conversion fails.
+withEvery :: (NameSpaceID nsID, MonadPlus m)
+ => nsID -> ElementName
+ -> FallibleXMLConverter nsID extraState a b
+ -> FallibleXMLConverter nsID extraState a (m b)
+withEvery nsID name a = prepareIteration nsID name
+ >>> iterateS' (switchingTheStack a)
+
+-- | Applies a converter to every child element of a specific type.
+-- Collects all successful results in a list.
+tryAll :: (NameSpaceID nsID)
+ => nsID -> ElementName
+ -> FallibleXMLConverter nsID extraState b a
+ -> XMLConverter nsID extraState b [a]
+tryAll nsID name a = prepareIteration nsID name
+ >>> iterateS (switchingTheStack a)
+ >>^ collectRights
+
+-- | Applies a converter to every child element of a specific type.
+-- Collects all successful results.
+tryAll' :: (NameSpaceID nsID, F.Foldable c, MonadPlus c)
+ => nsID -> ElementName
+ -> FallibleXMLConverter nsID extraState b a
+ -> XMLConverter nsID extraState b (c a)
+tryAll' nsID name a = prepareIteration nsID name
+ >>> iterateS (switchingTheStack a)
+ >>^ collectRightsF
+
+--------------------------------------------------------------------------------
+-- Matching children
+--------------------------------------------------------------------------------
+
+type IdXMLConverter nsID moreState x
+ = XMLConverter nsID moreState x x
+
+type MaybeEConverter nsID moreState x
+ = Maybe (IdXMLConverter nsID moreState (x, XML.Element))
+
+-- Chainable converter that helps deciding which converter to actually use.
+type ElementMatchConverter nsID extraState x
+ = IdXMLConverter nsID
+ extraState
+ (MaybeEConverter nsID extraState x, XML.Element)
+
+type MaybeCConverter nsID moreState x
+ = Maybe (IdXMLConverter nsID moreState (x, XML.Content))
+
+-- Chainable converter that helps deciding which converter to actually use.
+type ContentMatchConverter nsID extraState x
+ = IdXMLConverter nsID
+ extraState
+ (MaybeCConverter nsID extraState x, XML.Content)
+
+-- Helper function: The @c@ is actually a converter that is to be selected by
+-- matching XML elements to the first two parameters.
+-- The fold used to match elements however is very simple, so to use it,
+-- this function wraps the converter in another converter that unifies
+-- the accumulator. Think of a lot of converters with the resulting type
+-- chained together. The accumulator not only transports the element
+-- unchanged to the next matcher, it also does the actual selecting by
+-- combining the intermediate results with '(<|>)'.
+makeMatcherE :: (NameSpaceID nsID)
+ => nsID -> ElementName
+ -> FallibleXMLConverter nsID extraState a a
+ -> ElementMatchConverter nsID extraState a
+makeMatcherE nsID name c = ( second (
+ elemNameIs nsID name
+ >>^ bool Nothing (Just tryC)
+ )
+ >>% (<|>)
+ ) &&&^ snd
+ where tryC = (fst ^&&& executeThere c >>% recover) &&&^ snd
+
+-- Helper function: The @c@ is actually a converter that is to be selected by
+-- matching XML content to the first two parameters.
+-- The fold used to match elements however is very simple, so to use it,
+-- this function wraps the converter in another converter that unifies
+-- the accumulator. Think of a lot of converters with the resulting type
+-- chained together. The accumulator not only transports the element
+-- unchanged to the next matcher, it also does the actual selecting by
+-- combining the intermediate results with '(<|>)'.
+makeMatcherC :: (NameSpaceID nsID)
+ => nsID -> ElementName
+ -> FallibleXMLConverter nsID extraState a a
+ -> ContentMatchConverter nsID extraState a
+makeMatcherC nsID name c = ( second ( contentToElem
+ >>> returnV Nothing
+ ||| ( elemNameIs nsID name
+ >>^ bool Nothing (Just cWithJump)
+ )
+ )
+ >>% (<|>)
+ ) &&&^ snd
+ where cWithJump = ( fst
+ ^&&& ( second contentToElem
+ >>> spreadChoice
+ ^>>? executeThere c
+ )
+ >>% recover)
+ &&&^ snd
+ contentToElem :: FallibleXMLConverter nsID extraState XML.Content XML.Element
+ contentToElem = arr $ \e -> case e of
+ XML.Elem e' -> succeedWith e'
+ _ -> failEmpty
+
+-- Creates and chains a bunch of matchers
+prepareMatchersE :: (NameSpaceID nsID)
+ => [(nsID, ElementName, FallibleXMLConverter nsID extraState x x)]
+ -> ElementMatchConverter nsID extraState x
+--prepareMatchersE = foldSs . (map $ uncurry3 makeMatcherE)
+prepareMatchersE = reverseComposition . (map $ uncurry3 makeMatcherE)
+
+-- Creates and chains a bunch of matchers
+prepareMatchersC :: (NameSpaceID nsID)
+ => [(nsID, ElementName, FallibleXMLConverter nsID extraState x x)]
+ -> ContentMatchConverter nsID extraState x
+--prepareMatchersC = foldSs . (map $ uncurry3 makeMatcherC)
+prepareMatchersC = reverseComposition . (map $ uncurry3 makeMatcherC)
+
+-- | Takes a list of element-data - converter groups and
+-- * Finds all children of the current element
+-- * Matches each group to each child in order (at most one group per child)
+-- * Filters non-matched children
+-- * Chains all found converters in child-order
+-- * Applies the chain to the input element
+matchChildren :: (NameSpaceID nsID)
+ => [(nsID, ElementName, FallibleXMLConverter nsID extraState a a)]
+ -> XMLConverter nsID extraState a a
+matchChildren lookups = let matcher = prepareMatchersE lookups
+ in keepingTheValue (
+ elChildren
+ >>> map (Nothing,)
+ ^>> iterateSL matcher
+ >>^ catMaybes.map (\(m,e) -> fmap (swallowElem e) m)
+ -- >>> foldSs
+ >>> reverseComposition
+ )
+ >>> swap
+ ^>> app
+ where
+ -- let the converter swallow the element and drop the element
+ -- in the return value
+ swallowElem element converter = (,element) ^>> converter >>^ fst
+
+--
+matchContent'' :: (NameSpaceID nsID)
+ => [(nsID, ElementName, FallibleXMLConverter nsID extraState a a)]
+ -> XMLConverter nsID extraState a a
+matchContent'' lookups = let matcher = prepareMatchersC lookups
+ in keepingTheValue (
+ elContent
+ >>> map (Nothing,)
+ ^>> iterateSL matcher
+ >>^ catMaybes.map (\(m,c) -> fmap (swallowContent c) m)
+ -- >>> foldSs
+ >>> reverseComposition
+ )
+ >>> swap
+ ^>> app
+ where
+ -- let the converter swallow the content and drop the content
+ -- in the return value
+ swallowContent content converter = (,content) ^>> converter >>^ fst
+
+
+-- | Takes a list of element-data - converter groups and
+-- * Finds all content of the current element
+-- * Matches each group to each piece of content in order
+-- (at most one group per piece of content)
+-- * Filters non-matched content
+-- * Chains all found converters in content-order
+-- * Applies the chain to the input element
+matchContent' :: (NameSpaceID nsID)
+ => [(nsID, ElementName, FallibleXMLConverter nsID extraState a a)]
+ -> XMLConverter nsID extraState a a
+matchContent' lookups = matchContent lookups (arr fst)
+
+-- | Takes a list of element-data - converter groups and
+-- * Finds all content of the current element
+-- * Matches each group to each piece of content in order
+-- (at most one group per piece of content)
+-- * Adds a default converter for all non-matched content
+-- * Chains all found converters in content-order
+-- * Applies the chain to the input element
+matchContent :: (NameSpaceID nsID)
+ => [(nsID, ElementName, FallibleXMLConverter nsID extraState a a)]
+ -> XMLConverter nsID extraState (a,XML.Content) a
+ -> XMLConverter nsID extraState a a
+matchContent lookups fallback
+ = let matcher = prepareMatchersC lookups
+ in keepingTheValue (
+ elContent
+ >>> map (Nothing,)
+ ^>> iterateSL matcher
+ >>^ map swallowOrFallback
+ -- >>> foldSs
+ >>> reverseComposition
+ )
+ >>> swap
+ ^>> app
+ where
+ -- let the converter swallow the content and drop the content
+ -- in the return value
+ swallowOrFallback (Just converter,content) = (,content) ^>> converter >>^ fst
+ swallowOrFallback (Nothing ,content) = (,content) ^>> fallback
+
+--------------------------------------------------------------------------------
+-- Internals
+--------------------------------------------------------------------------------
+
+stringToBool :: (Monoid failure) => String -> Either failure Bool
+stringToBool val -- stringToBool' val >>> maybeToChoice
+ | val `elem` trueValues = succeedWith True
+ | val `elem` falseValues = succeedWith False
+ | otherwise = failEmpty
+ where trueValues = ["true" ,"on" ,"1"]
+ falseValues = ["false","off","0"]
+
+stringToBool' :: String -> Maybe Bool
+stringToBool' val | val `elem` trueValues = Just True
+ | val `elem` falseValues = Just False
+ | otherwise = Nothing
+ where trueValues = ["true" ,"on" ,"1"]
+ falseValues = ["false","off","0"]
+
+
+distributeValue :: a -> [b] -> [(a,b)]
+distributeValue = map.(,)
+
+--------------------------------------------------------------------------------
+
+{-
+NOTES
+It might be a good idea to refactor the namespace stuff.
+E.g.: if a namespace constructor took a string as a parameter, things like
+> a ?>/< (NsText,"body")
+would be nicer.
+Together with a rename and some trickery, something like
+> |< NsText "body" >< NsText "p" ?> a </> </>|
+might even be possible.
+
+Some day, XML.Light should be replaced by something better.
+While doing that, it might be useful to replace String as the type of element
+names with something else, too. (Of course with OverloadedStrings).
+While doing that, maybe the types can be created in a way that something like
+> NsText:"body"
+could be used. Overloading (:) does not sounds like the best idea, but if the
+element name type was a list, this might be possible.
+Of course that would be a bit hackish, so the "right" way would probably be
+something like
+> InNS NsText "body"
+but isn't that a bit boring? ;)
+-}
diff --git a/src/Text/Pandoc/Readers/Odt/Namespaces.hs b/src/Text/Pandoc/Readers/Odt/Namespaces.hs
new file mode 100644
index 000000000..deb009998
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Odt/Namespaces.hs
@@ -0,0 +1,110 @@
+{-
+Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Reader.Odt.Namespaces
+ Copyright : Copyright (C) 2015 Martin Linnemann
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Martin Linnemann <theCodingMarlin@googlemail.com>
+ Stability : alpha
+ Portability : portable
+
+Namespaces used in odt files.
+-}
+
+module Text.Pandoc.Readers.Odt.Namespaces ( Namespace (..)
+ ) where
+
+import Data.List ( isPrefixOf )
+import Data.Maybe ( fromMaybe, listToMaybe )
+import qualified Data.Map as M ( empty, insert )
+
+import Text.Pandoc.Readers.Odt.Generic.Namespaces
+
+
+instance NameSpaceID Namespace where
+
+ getInitialIRImap = nsIDmap
+
+ getNamespaceID "" m = Just(m, NsXML)
+ getNamespaceID iri m = asPair $ fromMaybe (NsOther iri) (findID iri)
+ where asPair nsID = Just (M.insert nsID iri m, nsID)
+
+
+findID :: NameSpaceIRI -> Maybe Namespace
+findID iri = listToMaybe [nsID | (iri',~nsID) <- nsIDs, iri' `isPrefixOf` iri]
+
+nsIDmap :: NameSpaceIRIs Namespace
+nsIDmap = foldr (uncurry $ flip M.insert) M.empty nsIDs
+
+data Namespace = -- Open Document core
+ NsOffice | NsStyle | NsText | NsTable | NsForm
+ | NsDraw | Ns3D | NsAnim | NsChart | NsConfig
+ | NsDB | NsMeta | NsNumber | NsScript | NsManifest
+ | NsPresentation
+ -- Metadata
+ | NsODF
+ -- Compatible elements
+ | NsXSL_FO | NsSVG | NsSmil
+ -- External standards
+ | NsMathML | NsXForms | NsXLink | NsXHtml | NsGRDDL
+ | NsDublinCore
+ -- Metadata manifest
+ | NsPKG
+ -- Others
+ | NsOpenFormula
+ -- Core XML (basically only for the 'id'-attribute)
+ | NsXML
+ -- Fallback
+ | NsOther String
+ deriving ( Eq, Ord, Show )
+
+-- | Not the actual iri's, but large prefixes of them - this way there are
+-- less versioning problems and the like.
+nsIDs :: [(String,Namespace)]
+nsIDs = [
+ ("urn:oasis:names:tc:opendocument:xmlns:animation" , NsAnim ),
+ ("urn:oasis:names:tc:opendocument:xmlns:chart" , NsChart ),
+ ("urn:oasis:names:tc:opendocument:xmlns:config" , NsConfig ),
+ ("urn:oasis:names:tc:opendocument:xmlns:database" , NsDB ),
+ ("urn:oasis:names:tc:opendocument:xmlns:dr3d" , Ns3D ),
+ ("urn:oasis:names:tc:opendocument:xmlns:drawing" , NsDraw ),
+ ("urn:oasis:names:tc:opendocument:xmlns:form" , NsForm ),
+ ("urn:oasis:names:tc:opendocument:xmlns:manifest" , NsManifest ),
+ ("urn:oasis:names:tc:opendocument:xmlns:meta" , NsMeta ),
+ ("urn:oasis:names:tc:opendocument:xmlns:datastyle" , NsNumber ),
+ ("urn:oasis:names:tc:opendocument:xmlns:of" , NsOpenFormula ),
+ ("urn:oasis:names:tc:opendocument:xmlns:office:1.0" , NsOffice ),
+ ("urn:oasis:names:tc:opendocument:xmlns:presentation" , NsPresentation ),
+ ("urn:oasis:names:tc:opendocument:xmlns:script" , NsScript ),
+ ("urn:oasis:names:tc:opendocument:xmlns:style" , NsStyle ),
+ ("urn:oasis:names:tc:opendocument:xmlns:table" , NsTable ),
+ ("urn:oasis:names:tc:opendocument:xmlns:text" , NsText ),
+ ("urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible", NsXSL_FO ),
+ ("urn:oasis:names:tc:opendocument:xmlns:smil-compatible" , NsSmil ),
+ ("urn:oasis:names:tc:opendocument:xmlns:svg-compatible" , NsSVG ),
+ ("http://docs.oasis-open.org/ns/office/1.2/meta/odf" , NsODF ),
+ ("http://docs.oasis-open.org/ns/office/1.2/meta/pkg" , NsPKG ),
+ ("http://purl.org/dc/elements" , NsDublinCore ),
+ ("http://www.w3.org/2003/g/data-view" , NsGRDDL ),
+ ("http://www.w3.org/1998/Math/MathML" , NsMathML ),
+ ("http://www.w3.org/1999/xhtml" , NsXHtml ),
+ ("http://www.w3.org/2002/xforms" , NsXForms ),
+ ("http://www.w3.org/1999/xlink" , NsXLink )
+ ]
diff --git a/src/Text/Pandoc/Readers/Odt/StyleReader.hs b/src/Text/Pandoc/Readers/Odt/StyleReader.hs
new file mode 100644
index 000000000..26ba6df82
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Odt/StyleReader.hs
@@ -0,0 +1,744 @@
+{-# LANGUAGE TupleSections #-}
+{-# LANGUAGE PatternGuards #-}
+{-# LANGUAGE ViewPatterns #-}
+{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE Arrows #-}
+
+{-
+Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Readers.Odt.StyleReader
+ Copyright : Copyright (C) 2015 Martin Linnemann
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Martin Linnemann <theCodingMarlin@googlemail.com>
+ Stability : alpha
+ Portability : portable
+
+Reader for the style information in an odt document.
+-}
+
+module Text.Pandoc.Readers.Odt.StyleReader
+( Style (..)
+, StyleName
+, StyleFamily (..)
+, Styles (..)
+, StyleProperties (..)
+, TextProperties (..)
+, ParaProperties (..)
+, VerticalTextPosition (..)
+, ListItemNumberFormat (..)
+, ListLevel
+, ListStyle (..)
+, ListLevelStyle (..)
+, ListLevelType (..)
+, LengthOrPercent (..)
+, lookupStyle
+, getTextProperty
+, getTextProperty'
+, getParaProperty
+, getListStyle
+, getListLevelStyle
+, getStyleFamily
+, lookupDefaultStyle
+, lookupDefaultStyle'
+, lookupListStyleByName
+, getPropertyChain
+, textPropertyChain
+, stylePropertyChain
+, stylePropertyChain'
+, getStylePropertyChain
+, extendedStylePropertyChain
+, extendedStylePropertyChain'
+, liftStyles
+, readStylesAt
+) where
+
+import Control.Arrow
+import Control.Applicative hiding ( liftA, liftA2, liftA3 )
+
+import qualified Data.Foldable as F
+import qualified Data.Map as M
+import qualified Data.Set as S
+import Data.Char ( isDigit )
+import Data.Default
+import Data.List ( unfoldr )
+import Data.Maybe
+
+import qualified Text.XML.Light as XML
+
+import Text.Pandoc.Readers.Odt.Arrows.State
+import Text.Pandoc.Readers.Odt.Arrows.Utils
+
+import Text.Pandoc.Readers.Odt.Generic.Utils
+import qualified Text.Pandoc.Readers.Odt.Generic.SetMap as SM
+import Text.Pandoc.Readers.Odt.Generic.Fallible
+import Text.Pandoc.Readers.Odt.Generic.XMLConverter
+
+import Text.Pandoc.Readers.Odt.Namespaces
+import Text.Pandoc.Readers.Odt.Base
+
+
+readStylesAt :: XML.Element -> Fallible Styles
+readStylesAt e = runConverter' readAllStyles mempty e
+
+--------------------------------------------------------------------------------
+-- Reader for font declarations and font pitches
+--------------------------------------------------------------------------------
+
+-- Pandoc has no support for different font pitches. Yet knowing them can be
+-- very helpful in cases where Pandoc has more semantics than OpenDocument.
+-- In these cases, the pitch can help deciding as what to define a block of
+-- text. So let's start with a type for font pitches:
+
+data FontPitch = PitchVariable | PitchFixed
+ deriving ( Eq, Show )
+
+instance Lookupable FontPitch where
+ lookupTable = [ ("variable" , PitchVariable)
+ , ("fixed" , PitchFixed )
+ ]
+
+instance Default FontPitch where
+ def = PitchVariable
+
+-- The font pitch can be specifed in a style directly. Normally, however,
+-- it is defined in the font. That is also the specs' recommendation.
+--
+-- Thus, we want
+
+type FontFaceName = String
+
+type FontPitches = M.Map FontFaceName FontPitch
+
+-- To get there, the fonts have to be read and the pitches extracted.
+-- But the resulting map are only needed at one later place, so it should not be
+-- transported on the value level, especially as we already use a state arrow.
+-- So instead, the resulting map is lifted into the state of the reader.
+-- (An alternative might be ImplicitParams, but again, we already have a state.)
+--
+-- So the main style readers will have the types
+type StyleReader a b = XMLReader FontPitches a b
+-- and
+type StyleReaderSafe a b = XMLReaderSafe FontPitches a b
+-- respectively.
+--
+-- But before we can work with these, we need to define the reader that reads
+-- the fonts:
+
+-- | A reader for font pitches
+fontPitchReader :: XMLReader _s _x FontPitches
+fontPitchReader = executeIn NsOffice "font-face-decls" (
+ ( withEveryL NsStyle "font-face" $ liftAsSuccess (
+ findAttr' NsStyle "name"
+ &&&
+ lookupDefaultingAttr NsStyle "font-pitch"
+ )
+ )
+ >>?^ ( M.fromList . (foldl accumLegalPitches []) )
+ )
+ where accumLegalPitches ls (Nothing,_) = ls
+ accumLegalPitches ls (Just n,p) = (n,p):ls
+
+
+-- | A wrapper around the font pitch reader that lifts the result into the
+-- state.
+readFontPitches :: StyleReader x x
+readFontPitches = producingExtraState () () fontPitchReader
+
+
+-- | Looking up a pitch in the state of the arrow.
+--
+-- The function does the following:
+-- * Look for the font pitch in an attribute.
+-- * If that fails, look for the font name, look up the font in the state
+-- and use the pitch from there.
+-- * Return the result in a Maybe
+--
+findPitch :: XMLReaderSafe FontPitches _x (Maybe FontPitch)
+findPitch = ( lookupAttr NsStyle "font-pitch"
+ `ifFailedDo` findAttr NsStyle "font-name"
+ >>? ( keepingTheValue getExtraState
+ >>% M.lookup
+ >>^ maybeToChoice
+ )
+ )
+ >>> choiceToMaybe
+
+--------------------------------------------------------------------------------
+-- Definitions of main data
+--------------------------------------------------------------------------------
+
+type StyleName = String
+
+-- | There are two types of styles: named styles with a style family and an
+-- optional style parent, and default styles for each style family,
+-- defining default style properties
+data Styles = Styles
+ { stylesByName :: M.Map StyleName Style
+ , listStylesByName :: M.Map StyleName ListStyle
+ , defaultStyleMap :: M.Map StyleFamily StyleProperties
+ }
+ deriving ( Show )
+
+-- Styles from a monoid under union
+instance Monoid Styles where
+ mempty = Styles M.empty M.empty M.empty
+ mappend (Styles sBn1 dSm1 lsBn1)
+ (Styles sBn2 dSm2 lsBn2)
+ = Styles (M.union sBn1 sBn2)
+ (M.union dSm1 dSm2)
+ (M.union lsBn1 lsBn2)
+
+-- Not all families from the specifications are implemented, only those we need.
+-- But there are none that are not mentioned here.
+data StyleFamily = FaText | FaParagraph
+-- | FaTable | FaTableCell | FaTableColumn | FaTableRow
+-- | FaGraphic | FaDrawing | FaChart
+-- | FaPresentation
+-- | FaRuby
+ deriving ( Eq, Ord, Show )
+
+instance Lookupable StyleFamily where
+ lookupTable = [ ( "text" , FaText )
+ , ( "paragraph" , FaParagraph )
+-- , ( "table" , FaTable )
+-- , ( "table-cell" , FaTableCell )
+-- , ( "table-column" , FaTableColumn )
+-- , ( "table-row" , FaTableRow )
+-- , ( "graphic" , FaGraphic )
+-- , ( "drawing-page" , FaDrawing )
+-- , ( "chart" , FaChart )
+-- , ( "presentation" , FaPresentation )
+-- , ( "ruby" , FaRuby )
+ ]
+
+-- | A named style
+data Style = Style { styleFamily :: Maybe StyleFamily
+ , styleParentName :: Maybe StyleName
+ , listStyle :: Maybe StyleName
+ , styleProperties :: StyleProperties
+ }
+ deriving ( Eq, Show )
+
+data StyleProperties = SProps { textProperties :: Maybe TextProperties
+ , paraProperties :: Maybe ParaProperties
+-- , tableColProperties :: Maybe TColProperties
+-- , tableRowProperties :: Maybe TRowProperties
+-- , tableCellProperties :: Maybe TCellProperties
+-- , tableProperties :: Maybe TableProperties
+-- , graphicProperties :: Maybe GraphProperties
+ }
+ deriving ( Eq, Show )
+
+instance Default StyleProperties where
+ def = SProps { textProperties = Just def
+ , paraProperties = Just def
+ }
+
+data TextProperties = PropT { isEmphasised :: Bool
+ , isStrong :: Bool
+ , pitch :: Maybe FontPitch
+ , verticalPosition :: VerticalTextPosition
+ , underline :: Maybe UnderlineMode
+ , strikethrough :: Maybe UnderlineMode
+ }
+ deriving ( Eq, Show )
+
+instance Default TextProperties where
+ def = PropT { isEmphasised = False
+ , isStrong = False
+ , pitch = Just def
+ , verticalPosition = def
+ , underline = Nothing
+ , strikethrough = Nothing
+ }
+
+data ParaProperties = PropP { paraNumbering :: ParaNumbering
+ , indentation :: LengthOrPercent
+ , margin_left :: LengthOrPercent
+ }
+ deriving ( Eq, Show )
+
+instance Default ParaProperties where
+ def = PropP { paraNumbering = NumberingNone
+ , indentation = def
+ , margin_left = def
+ }
+
+----
+-- All the little data types that make up the properties
+----
+
+data VerticalTextPosition = VPosNormal | VPosSuper | VPosSub
+ deriving ( Eq, Show )
+
+instance Default VerticalTextPosition where
+ def = VPosNormal
+
+instance Read VerticalTextPosition where
+ readsPrec _ s = [ (VPosSub , s') | ("sub" , s') <- lexS ]
+ ++ [ (VPosSuper , s') | ("super" , s') <- lexS ]
+ ++ [ (signumToVPos n , s') | ( n , s') <- readPercent s ]
+ where
+ lexS = lex s
+ signumToVPos n | n < 0 = VPosSub
+ | n > 0 = VPosSuper
+ | otherwise = VPosNormal
+
+data UnderlineMode = UnderlineModeNormal | UnderlineModeSkipWhitespace
+ deriving ( Eq, Show )
+
+instance Lookupable UnderlineMode where
+ lookupTable = [ ( "continuous" , UnderlineModeNormal )
+ , ( "skip-white-space" , UnderlineModeSkipWhitespace )
+ ]
+
+
+data ParaNumbering = NumberingNone | NumberingKeep | NumberingRestart Int
+ deriving ( Eq, Show )
+
+data LengthOrPercent = LengthValueMM Int | PercentValue Int
+ deriving ( Eq, Show )
+
+instance Default LengthOrPercent where
+ def = LengthValueMM 0
+
+instance Read LengthOrPercent where
+ readsPrec _ s =
+ [ (PercentValue percent , s' ) | (percent , s' ) <- readPercent s]
+ ++ [ (LengthValueMM lengthMM , s'') | (length' , s' ) <- reads s
+ , (unit , s'') <- reads s'
+ , let lengthMM = estimateInMillimeter
+ length' unit
+ ]
+
+data XslUnit = XslUnitMM | XslUnitCM
+ | XslUnitInch
+ | XslUnitPoints | XslUnitPica
+ | XslUnitPixel
+ | XslUnitEM
+
+instance Show XslUnit where
+ show XslUnitMM = "mm"
+ show XslUnitCM = "cm"
+ show XslUnitInch = "in"
+ show XslUnitPoints = "pt"
+ show XslUnitPica = "pc"
+ show XslUnitPixel = "px"
+ show XslUnitEM = "em"
+
+instance Read XslUnit where
+ readsPrec _ "mm" = [(XslUnitMM , "")]
+ readsPrec _ "cm" = [(XslUnitCM , "")]
+ readsPrec _ "in" = [(XslUnitInch , "")]
+ readsPrec _ "pt" = [(XslUnitPoints , "")]
+ readsPrec _ "pc" = [(XslUnitPica , "")]
+ readsPrec _ "px" = [(XslUnitPixel , "")]
+ readsPrec _ "em" = [(XslUnitEM , "")]
+ readsPrec _ _ = []
+
+-- | Rough conversion of measures into millimeters.
+-- Pixels and em's are actually implemetation dependant/relative measures,
+-- so I could not really easily calculate anything exact here even if I wanted.
+-- But I do not care about exactness right now, as I only use measures
+-- to determine if a paragraph is "indented" or not.
+estimateInMillimeter :: Int -> XslUnit -> Int
+estimateInMillimeter n XslUnitMM = n
+estimateInMillimeter n XslUnitCM = n * 10
+estimateInMillimeter n XslUnitInch = n * 25 -- \* 25.4
+estimateInMillimeter n XslUnitPoints = n `div` 3 -- \* 1/72 * 25.4
+estimateInMillimeter n XslUnitPica = n * 4 -- \* 12 * 1/72 * 25.4
+estimateInMillimeter n XslUnitPixel = n `div`3 -- \* 1/72 * 25.4
+estimateInMillimeter n XslUnitEM = n * 7 -- \* 16 * 1/72 * 25.4
+
+
+----
+-- List styles
+----
+
+type ListLevel = Int
+
+newtype ListStyle = ListStyle { levelStyles :: M.Map ListLevel ListLevelStyle
+ }
+ deriving ( Eq, Show )
+
+--
+getListLevelStyle :: ListLevel -> ListStyle -> Maybe ListLevelStyle
+getListLevelStyle level ListStyle{..} =
+ let (lower , exactHit , _) = M.splitLookup level levelStyles
+ in exactHit <|> fmap fst (M.maxView lower)
+ -- findBy (`M.lookup` levelStyles) [level, (level-1) .. 1]
+ -- \^ simpler, but in general less efficient
+
+data ListLevelStyle = ListLevelStyle { listLevelType :: ListLevelType
+ , listItemPrefix :: Maybe String
+ , listItemSuffix :: Maybe String
+ , listItemFormat :: ListItemNumberFormat
+ , listItemStart :: Int
+ }
+ deriving ( Eq, Ord )
+
+instance Show ListLevelStyle where
+ show ListLevelStyle{..} = "<LLS|"
+ ++ (show listLevelType)
+ ++ "|"
+ ++ (maybeToString listItemPrefix)
+ ++ (show listItemFormat)
+ ++ (maybeToString listItemSuffix)
+ ++ ">"
+ where maybeToString = fromMaybe ""
+
+data ListLevelType = LltBullet | LltImage | LltNumbered
+ deriving ( Eq, Ord, Show )
+
+data ListItemNumberFormat = LinfNone
+ | LinfNumber
+ | LinfRomanLC | LinfRomanUC
+ | LinfAlphaLC | LinfAlphaUC
+ | LinfString String
+ deriving ( Eq, Ord )
+
+instance Show ListItemNumberFormat where
+ show LinfNone = ""
+ show LinfNumber = "1"
+ show LinfRomanLC = "i"
+ show LinfRomanUC = "I"
+ show LinfAlphaLC = "a"
+ show LinfAlphaUC = "A"
+ show (LinfString s) = s
+
+instance Default ListItemNumberFormat where
+ def = LinfNone
+
+instance Read ListItemNumberFormat where
+ readsPrec _ "" = [(LinfNone , "")]
+ readsPrec _ "1" = [(LinfNumber , "")]
+ readsPrec _ "i" = [(LinfRomanLC , "")]
+ readsPrec _ "I" = [(LinfRomanUC , "")]
+ readsPrec _ "a" = [(LinfAlphaLC , "")]
+ readsPrec _ "A" = [(LinfAlphaUC , "")]
+ readsPrec _ s = [(LinfString s , "")]
+
+--------------------------------------------------------------------------------
+-- Readers
+--
+-- ...it seems like a whole lot of this should be automatically deriveable
+-- or at least moveable into a class. Most of this is data concealed in
+-- code.
+--------------------------------------------------------------------------------
+
+--
+readAllStyles :: StyleReader _x Styles
+readAllStyles = ( readFontPitches
+ >>?! ( readAutomaticStyles
+ &&& readStyles ))
+ >>?%? chooseMax
+ -- all top elements are always on the same hierarchy level
+
+--
+readStyles :: StyleReader _x Styles
+readStyles = executeIn NsOffice "styles" $ liftAsSuccess
+ $ liftA3 Styles
+ ( tryAll NsStyle "style" readStyle >>^ M.fromList )
+ ( tryAll NsText "list-style" readListStyle >>^ M.fromList )
+ ( tryAll NsStyle "default-style" readDefaultStyle >>^ M.fromList )
+
+--
+readAutomaticStyles :: StyleReader _x Styles
+readAutomaticStyles = executeIn NsOffice "automatic-styles" $ liftAsSuccess
+ $ liftA3 Styles
+ ( tryAll NsStyle "style" readStyle >>^ M.fromList )
+ ( tryAll NsText "list-style" readListStyle >>^ M.fromList )
+ ( returnV M.empty )
+
+--
+readDefaultStyle :: StyleReader _x (StyleFamily, StyleProperties)
+readDefaultStyle = lookupAttr NsStyle "family"
+ >>?! keepingTheValue readStyleProperties
+
+--
+readStyle :: StyleReader _x (StyleName,Style)
+readStyle = findAttr NsStyle "name"
+ >>?! keepingTheValue
+ ( liftA4 Style
+ ( lookupAttr' NsStyle "family" )
+ ( findAttr' NsStyle "parent-style-name" )
+ ( findAttr' NsStyle "list-style-name" )
+ readStyleProperties
+ )
+
+--
+readStyleProperties :: StyleReaderSafe _x StyleProperties
+readStyleProperties = liftA2 SProps
+ ( readTextProperties >>> choiceToMaybe )
+ ( readParaProperties >>> choiceToMaybe )
+
+--
+readTextProperties :: StyleReader _x TextProperties
+readTextProperties =
+ executeIn NsStyle "text-properties" $ liftAsSuccess
+ ( liftA6 PropT
+ ( searchAttr NsXSL_FO "font-style" False isFontEmphasised )
+ ( searchAttr NsXSL_FO "font-weight" False isFontBold )
+ ( findPitch )
+ ( getAttr NsStyle "text-position" )
+ ( readUnderlineMode )
+ ( readStrikeThroughMode )
+ )
+ where isFontEmphasised = [("normal",False),("italic",True),("oblique",True)]
+ isFontBold = ("normal",False):("bold",True)
+ :(map ((,True).show) ([100,200..900]::[Int]))
+
+readUnderlineMode :: StyleReaderSafe _x (Maybe UnderlineMode)
+readUnderlineMode = readLineMode "text-underline-mode"
+ "text-underline-style"
+
+readStrikeThroughMode :: StyleReaderSafe _x (Maybe UnderlineMode)
+readStrikeThroughMode = readLineMode "text-line-through-mode"
+ "text-line-through-style"
+
+readLineMode :: String -> String -> StyleReaderSafe _x (Maybe UnderlineMode)
+readLineMode modeAttr styleAttr = proc x -> do
+ isUL <- searchAttr NsStyle styleAttr False isLinePresent -< x
+ mode <- lookupAttr' NsStyle modeAttr -< x
+ if isUL
+ then case mode of
+ Just m -> returnA -< Just m
+ Nothing -> returnA -< Just UnderlineModeNormal
+ else returnA -< Nothing
+ where
+ isLinePresent = [("none",False)] ++ map (,True)
+ [ "dash" , "dot-dash" , "dot-dot-dash" , "dotted"
+ , "long-dash" , "solid" , "wave"
+ ]
+
+--
+readParaProperties :: StyleReader _x ParaProperties
+readParaProperties =
+ executeIn NsStyle "paragraph-properties" $ liftAsSuccess
+ ( liftA3 PropP
+ ( liftA2 readNumbering
+ ( isSet' NsText "number-lines" )
+ ( readAttr' NsText "line-number" )
+ )
+ ( liftA2 readIndentation
+ ( isSetWithDefault NsStyle "auto-text-indent" False )
+ ( getAttr NsXSL_FO "text-indent" )
+ )
+ ( getAttr NsXSL_FO "margin-left" )
+ )
+ where readNumbering (Just True) (Just n) = NumberingRestart n
+ readNumbering (Just True) _ = NumberingKeep
+ readNumbering _ _ = NumberingNone
+
+ readIndentation False indent = indent
+ readIndentation True _ = def
+
+----
+-- List styles
+----
+
+--
+readListStyle :: StyleReader _x (StyleName, ListStyle)
+readListStyle =
+ findAttr NsStyle "name"
+ >>?! keepingTheValue
+ ( liftA ListStyle
+ $ ( liftA3 SM.union3
+ ( readListLevelStyles NsText "list-level-style-number" LltNumbered )
+ ( readListLevelStyles NsText "list-level-style-bullet" LltBullet )
+ ( readListLevelStyles NsText "list-level-style-image" LltImage )
+ ) >>^ M.mapMaybe chooseMostSpecificListLevelStyle
+ )
+--
+readListLevelStyles :: Namespace -> ElementName
+ -> ListLevelType
+ -> StyleReaderSafe _x (SM.SetMap Int ListLevelStyle)
+readListLevelStyles namespace elementName levelType =
+ ( tryAll namespace elementName (readListLevelStyle levelType)
+ >>^ SM.fromList
+ )
+
+--
+readListLevelStyle :: ListLevelType -> StyleReader _x (Int, ListLevelStyle)
+readListLevelStyle levelType = readAttr NsText "level"
+ >>?! keepingTheValue
+ ( liftA5 toListLevelStyle
+ ( returnV levelType )
+ ( findAttr' NsStyle "num-prefix" )
+ ( findAttr' NsStyle "num-suffix" )
+ ( getAttr NsStyle "num-format" )
+ ( findAttr' NsText "start-value" )
+ )
+ where
+ toListLevelStyle _ p s LinfNone b = ListLevelStyle LltBullet p s LinfNone (startValue b)
+ toListLevelStyle _ p s f@(LinfString _) b = ListLevelStyle LltBullet p s f (startValue b)
+ toListLevelStyle t p s f b = ListLevelStyle t p s f (startValue b)
+ startValue (Just "") = 1
+ startValue (Just v) = if all isDigit v
+ then read v
+ else 1
+ startValue Nothing = 1
+
+--
+chooseMostSpecificListLevelStyle :: S.Set ListLevelStyle -> Maybe ListLevelStyle
+chooseMostSpecificListLevelStyle ls | ls == mempty = Nothing
+ | otherwise = Just ( F.foldr1 select ls )
+ where
+ select ( ListLevelStyle t1 p1 s1 f1 b1 )
+ ( ListLevelStyle t2 p2 s2 f2 _ )
+ = ListLevelStyle (select' t1 t2) (p1 <|> p2) (s1 <|> s2) (selectLinf f1 f2) b1
+ select' LltNumbered _ = LltNumbered
+ select' _ LltNumbered = LltNumbered
+ select' _ _ = LltBullet
+ selectLinf LinfNone f2 = f2
+ selectLinf f1 LinfNone = f1
+ selectLinf (LinfString _) f2 = f2
+ selectLinf f1 (LinfString _) = f1
+ selectLinf f1 _ = f1
+
+
+--------------------------------------------------------------------------------
+-- Tools to access style data
+--------------------------------------------------------------------------------
+
+--
+lookupStyle :: StyleName -> Styles -> Maybe Style
+lookupStyle name Styles{..} = M.lookup name stylesByName
+
+--
+lookupDefaultStyle :: StyleFamily -> Styles -> StyleProperties
+lookupDefaultStyle family Styles{..} = fromMaybe def
+ (M.lookup family defaultStyleMap)
+
+--
+lookupDefaultStyle' :: Styles -> StyleFamily -> StyleProperties
+lookupDefaultStyle' Styles{..} family = fromMaybe def
+ (M.lookup family defaultStyleMap)
+
+--
+getListStyle :: Style -> Styles -> Maybe ListStyle
+getListStyle Style{..} styles = listStyle >>= (`lookupListStyleByName` styles)
+
+--
+lookupListStyleByName :: StyleName -> Styles -> Maybe ListStyle
+lookupListStyleByName name Styles{..} = M.lookup name listStylesByName
+
+
+-- | Returns a chain of parent of the current style. The direct parent will
+-- be the first element of the list, followed by its parent and so on.
+-- The current style is not in the list.
+parents :: Style -> Styles -> [Style]
+parents style styles = unfoldr findNextParent style -- Ha!
+ where findNextParent Style{..}
+ = fmap duplicate $ (`lookupStyle` styles) =<< styleParentName
+
+-- | Looks up the style family of the current style. Normally, every style
+-- should have one. But if not, all parents are searched.
+getStyleFamily :: Style -> Styles -> Maybe StyleFamily
+getStyleFamily style@Style{..} styles
+ = styleFamily
+ <|> (F.asum $ map (`getStyleFamily` styles) $ parents style styles)
+
+-- | Each 'Style' has certain 'StyleProperties'. But sometimes not all property
+-- values are specified. Instead, a value might be inherited from a
+-- parent style. This function makes this chain of inheritance
+-- concrete and easily accessible by encapsulating the necessary lookups.
+-- The resulting list contains the direct properties of the style as the first
+-- element, the ones of the direct parent element as the next one, and so on.
+--
+-- Note: There should also be default properties for each style family. These
+-- are @not@ contained in this list because properties inherited from
+-- parent elements take precedence over default styles.
+--
+-- This function is primarily meant to be used through convenience wrappers.
+--
+stylePropertyChain :: Style -> Styles -> [StyleProperties]
+stylePropertyChain style styles
+ = map styleProperties (style : parents style styles)
+
+--
+extendedStylePropertyChain :: [Style] -> Styles -> [StyleProperties]
+extendedStylePropertyChain [] _ = []
+extendedStylePropertyChain [style] styles = (stylePropertyChain style styles)
+ ++ (maybeToList (fmap (lookupDefaultStyle' styles) (getStyleFamily style styles)))
+extendedStylePropertyChain (style:trace) styles = (stylePropertyChain style styles)
+ ++ (extendedStylePropertyChain trace styles)
+-- Optimizable with Data.Sequence
+
+--
+extendedStylePropertyChain' :: [Style] -> Styles -> Maybe [StyleProperties]
+extendedStylePropertyChain' [] _ = Nothing
+extendedStylePropertyChain' [style] styles = Just (
+ (stylePropertyChain style styles)
+ ++ (maybeToList (fmap (lookupDefaultStyle' styles) (getStyleFamily style styles)))
+ )
+extendedStylePropertyChain' (style:trace) styles = fmap ((stylePropertyChain style styles) ++)
+ (extendedStylePropertyChain' trace styles)
+
+--
+stylePropertyChain' :: Styles -> Style -> [StyleProperties]
+stylePropertyChain' = flip stylePropertyChain
+
+--
+getStylePropertyChain :: StyleName -> Styles -> [StyleProperties]
+getStylePropertyChain name styles = maybe []
+ (`stylePropertyChain` styles)
+ (lookupStyle name styles)
+
+--
+getPropertyChain :: (StyleProperties -> Maybe a) -> Style -> Styles -> [a]
+getPropertyChain extract style styles = catMaybes
+ $ map extract
+ $ stylePropertyChain style styles
+
+--
+textPropertyChain :: Style -> Styles -> [TextProperties]
+textPropertyChain = getPropertyChain textProperties
+
+--
+paraPropertyChain :: Style -> Styles -> [ParaProperties]
+paraPropertyChain = getPropertyChain paraProperties
+
+--
+getTextProperty :: (TextProperties -> a) -> Style -> Styles -> Maybe a
+getTextProperty extract style styles = fmap extract
+ $ listToMaybe
+ $ textPropertyChain style styles
+
+--
+getTextProperty' :: (TextProperties -> Maybe a) -> Style -> Styles -> Maybe a
+getTextProperty' extract style styles = F.asum
+ $ map extract
+ $ textPropertyChain style styles
+
+--
+getParaProperty :: (ParaProperties -> a) -> Style -> Styles -> Maybe a
+getParaProperty extract style styles = fmap extract
+ $ listToMaybe
+ $ paraPropertyChain style styles
+
+-- | Lifts the reader into another readers' state.
+liftStyles :: (OdtConverterState s -> OdtConverterState Styles)
+ -> (OdtConverterState Styles -> OdtConverterState s )
+ -> XMLReader s x x
+liftStyles extract inject = switchState extract inject
+ $ convertingExtraState M.empty readAllStyles
+
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
new file mode 100644
index 000000000..c8dbbf45a
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -0,0 +1,62 @@
+{-
+Copyright (C) 2014-2016 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.Readers.Org
+ Copyright : Copyright (C) 2014-2016 Albert Krewinkel
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
+
+Conversion of org-mode formatted plain text to 'Pandoc' document.
+-}
+module Text.Pandoc.Readers.Org ( readOrg ) where
+
+import Text.Pandoc.Readers.Org.Blocks ( blockList, meta )
+import Text.Pandoc.Readers.Org.Parsing ( OrgParser, readWithM )
+import Text.Pandoc.Readers.Org.ParserState ( optionsToParserState )
+
+import Text.Pandoc.Class (PandocMonad)
+import Text.Pandoc.Definition
+import Text.Pandoc.Error
+import Text.Pandoc.Options
+
+import Control.Monad.Except ( throwError )
+import Control.Monad.Reader ( runReaderT )
+
+
+-- | Parse org-mode string and return a Pandoc document.
+readOrg :: PandocMonad m
+ => ReaderOptions -- ^ Reader options
+ -> String -- ^ String to parse (assuming @'\n'@ line endings)
+ -> m Pandoc
+readOrg opts s = do
+ parsed <- flip runReaderT def $
+ readWithM parseOrg (optionsToParserState opts) (s ++ "\n\n")
+ case parsed of
+ Right result -> return result
+ Left _ -> throwError $ PandocParseError "problem parsing org"
+
+--
+-- Parser
+--
+parseOrg :: PandocMonad m => OrgParser m Pandoc
+parseOrg = do
+ blocks' <- blockList
+ meta' <- meta
+ return $ Pandoc meta' blocks'
diff --git a/src/Text/Pandoc/Readers/Org/BlockStarts.hs b/src/Text/Pandoc/Readers/Org/BlockStarts.hs
new file mode 100644
index 000000000..5588c4552
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Org/BlockStarts.hs
@@ -0,0 +1,137 @@
+{-
+Copyright (C) 2014-2016 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.Readers.Org.Options
+ Copyright : Copyright (C) 2014-2016 Albert Krewinkel
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
+
+Parsers for Org-mode inline elements.
+-}
+module Text.Pandoc.Readers.Org.BlockStarts
+ ( exampleLineStart
+ , hline
+ , noteMarker
+ , tableStart
+ , drawerStart
+ , headerStart
+ , metaLineStart
+ , latexEnvStart
+ , commentLineStart
+ , bulletListStart
+ , orderedListStart
+ , endOfBlock
+ ) where
+
+import Control.Monad ( void )
+import Text.Pandoc.Readers.Org.Parsing
+
+-- | Horizontal Line (five -- dashes or more)
+hline :: Monad m => OrgParser m ()
+hline = try $ do
+ skipSpaces
+ string "-----"
+ many (char '-')
+ skipSpaces
+ newline
+ return ()
+
+-- | Read the start of a header line, return the header level
+headerStart :: Monad m => OrgParser m Int
+headerStart = try $
+ (length <$> many1 (char '*')) <* many1 (char ' ') <* updateLastPreCharPos
+
+tableStart :: Monad m => OrgParser m Char
+tableStart = try $ skipSpaces *> char '|'
+
+latexEnvStart :: Monad m => OrgParser m String
+latexEnvStart = try $ do
+ skipSpaces *> string "\\begin{"
+ *> latexEnvName
+ <* string "}"
+ <* blankline
+ where
+ latexEnvName :: Monad m => OrgParser m String
+ latexEnvName = try $ mappend <$> many1 alphaNum <*> option "" (string "*")
+
+
+-- | Parses bullet list marker.
+bulletListStart :: Monad m => OrgParser m ()
+bulletListStart = try $
+ choice
+ [ () <$ skipSpaces <* oneOf "+-" <* skipSpaces1
+ , () <$ skipSpaces1 <* char '*' <* skipSpaces1
+ ]
+
+genericListStart :: Monad m
+ => OrgParser m String
+ -> OrgParser m Int
+genericListStart listMarker = try $
+ (+) <$> (length <$> many spaceChar)
+ <*> (length <$> listMarker <* many1 spaceChar)
+
+orderedListStart :: Monad m => OrgParser m Int
+orderedListStart = genericListStart orderedListMarker
+ -- Ordered list markers allowed in org-mode
+ where orderedListMarker = mappend <$> many1 digit <*> (pure <$> oneOf ".)")
+
+drawerStart :: Monad m => OrgParser m String
+drawerStart = try $
+ skipSpaces *> drawerName <* skipSpaces <* newline
+ where drawerName = char ':' *> manyTill nonspaceChar (char ':')
+
+metaLineStart :: Monad m => OrgParser m ()
+metaLineStart = try $ skipSpaces <* string "#+"
+
+commentLineStart :: Monad m => OrgParser m ()
+commentLineStart = try $ skipSpaces <* string "# "
+
+exampleLineStart :: Monad m => OrgParser m ()
+exampleLineStart = () <$ try (skipSpaces *> string ": ")
+
+noteMarker :: Monad m => OrgParser m String
+noteMarker = try $ do
+ char '['
+ choice [ many1Till digit (char ']')
+ , (++) <$> string "fn:"
+ <*> many1Till (noneOf "\n\r\t ") (char ']')
+ ]
+
+-- | Succeeds if the parser is at the end of a block.
+endOfBlock :: Monad m => OrgParser m ()
+endOfBlock = lookAhead . try $ do
+ void blankline <|> anyBlockStart
+ where
+ -- Succeeds if there is a new block starting at this position.
+ anyBlockStart :: Monad m => OrgParser m ()
+ anyBlockStart = try . choice $
+ [ exampleLineStart
+ , hline
+ , metaLineStart
+ , commentLineStart
+ , void noteMarker
+ , void tableStart
+ , void drawerStart
+ , void headerStart
+ , void latexEnvStart
+ , void bulletListStart
+ , void orderedListStart
+ ]
+
diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs
new file mode 100644
index 000000000..78ac8d0d1
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Org/Blocks.hs
@@ -0,0 +1,979 @@
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE ViewPatterns #-}
+{-
+Copyright (C) 2014-2017 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.Readers.Org.Options
+ Copyright : Copyright (C) 2014-2017 Albert Krewinkel
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
+
+Parsers for Org-mode block elements.
+-}
+module Text.Pandoc.Readers.Org.Blocks
+ ( blockList
+ , meta
+ ) where
+
+import Text.Pandoc.Readers.Org.BlockStarts
+import Text.Pandoc.Readers.Org.Inlines
+import Text.Pandoc.Readers.Org.Meta ( metaExport, metaKey, metaLine )
+import Text.Pandoc.Readers.Org.ParserState
+import Text.Pandoc.Readers.Org.Parsing
+import Text.Pandoc.Readers.Org.Shared
+ ( cleanLinkString, isImageFilename, rundocBlockClass
+ , toRundocAttrib, translateLang )
+
+import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.Builder ( Inlines, Blocks )
+import Text.Pandoc.Class (PandocMonad)
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Text.Pandoc.Shared ( compactify, compactifyDL, safeRead )
+
+import Control.Monad ( foldM, guard, mzero, void )
+import Data.Char ( isSpace, toLower, toUpper)
+import Data.Default ( Default )
+import Data.List ( foldl', isPrefixOf )
+import Data.Maybe ( fromMaybe, isNothing )
+import Data.Monoid ((<>))
+
+--
+-- Org headers
+--
+newtype Tag = Tag { fromTag :: String }
+ deriving (Show, Eq)
+
+-- | Create a tag containing the given string.
+toTag :: String -> Tag
+toTag = Tag
+
+-- | The key (also called name or type) of a property.
+newtype PropertyKey = PropertyKey { fromKey :: String }
+ deriving (Show, Eq, Ord)
+
+-- | Create a property key containing the given string. Org mode keys are
+-- case insensitive and are hence converted to lower case.
+toPropertyKey :: String -> PropertyKey
+toPropertyKey = PropertyKey . map toLower
+
+-- | The value assigned to a property.
+newtype PropertyValue = PropertyValue { fromValue :: String }
+
+-- | Create a property value containing the given string.
+toPropertyValue :: String -> PropertyValue
+toPropertyValue = PropertyValue
+
+-- | Check whether the property value is non-nil (i.e. truish).
+isNonNil :: PropertyValue -> Bool
+isNonNil p = map toLower (fromValue p) `notElem` ["()", "{}", "nil"]
+
+-- | Key/value pairs from a PROPERTIES drawer
+type Properties = [(PropertyKey, PropertyValue)]
+
+-- | Org mode headline (i.e. a document subtree).
+data Headline = Headline
+ { headlineLevel :: Int
+ , headlineTodoMarker :: Maybe TodoMarker
+ , headlineText :: Inlines
+ , headlineTags :: [Tag]
+ , headlineProperties :: Properties
+ , headlineContents :: Blocks
+ , headlineChildren :: [Headline]
+ }
+
+--
+-- Parsing headlines and subtrees
+--
+
+-- | Read an Org mode headline and its contents (i.e. a document subtree).
+-- @lvl@ gives the minimum acceptable level of the tree.
+headline :: PandocMonad m => Int -> OrgParser m (F Headline)
+headline lvl = try $ do
+ level <- headerStart
+ guard (lvl <= level)
+ todoKw <- optionMaybe todoKeyword
+ title <- trimInlinesF . mconcat <$> manyTill inline endOfTitle
+ tags <- option [] headerTags
+ newline
+ properties <- option mempty propertiesDrawer
+ contents <- blocks
+ children <- many (headline (level + 1))
+ return $ do
+ title' <- title
+ contents' <- contents
+ children' <- sequence children
+ return $ Headline
+ { headlineLevel = level
+ , headlineTodoMarker = todoKw
+ , headlineText = title'
+ , headlineTags = tags
+ , headlineProperties = properties
+ , headlineContents = contents'
+ , headlineChildren = children'
+ }
+ where
+ endOfTitle :: Monad m => OrgParser m ()
+ endOfTitle = void . lookAhead $ optional headerTags *> newline
+
+ headerTags :: Monad m => OrgParser m [Tag]
+ headerTags = try $
+ let tag = many1 (alphaNum <|> oneOf "@%#_") <* char ':'
+ in map toTag <$> (skipSpaces *> char ':' *> many1 tag <* skipSpaces)
+
+-- | Convert an Org mode headline (i.e. a document tree) into pandoc's Blocks
+headlineToBlocks :: Monad m => Headline -> OrgParser m Blocks
+headlineToBlocks hdln@(Headline {..}) = do
+ maxHeadlineLevels <- getExportSetting exportHeadlineLevels
+ case () of
+ _ | any isNoExportTag headlineTags -> return mempty
+ _ | any isArchiveTag headlineTags -> archivedHeadlineToBlocks hdln
+ _ | isCommentTitle headlineText -> return mempty
+ _ | headlineLevel >= maxHeadlineLevels -> headlineToHeaderWithList hdln
+ _ | otherwise -> headlineToHeaderWithContents hdln
+
+isNoExportTag :: Tag -> Bool
+isNoExportTag = (== toTag "noexport")
+
+isArchiveTag :: Tag -> Bool
+isArchiveTag = (== toTag "ARCHIVE")
+
+-- | Check if the title starts with COMMENT.
+-- FIXME: This accesses builder internals not intended for use in situations
+-- like these. Replace once keyword parsing is supported.
+isCommentTitle :: Inlines -> Bool
+isCommentTitle (B.toList -> (Str "COMMENT":_)) = True
+isCommentTitle _ = False
+
+archivedHeadlineToBlocks :: Monad m => Headline -> OrgParser m Blocks
+archivedHeadlineToBlocks hdln = do
+ archivedTreesOption <- getExportSetting exportArchivedTrees
+ case archivedTreesOption of
+ ArchivedTreesNoExport -> return mempty
+ ArchivedTreesExport -> headlineToHeaderWithContents hdln
+ ArchivedTreesHeadlineOnly -> headlineToHeader hdln
+
+headlineToHeaderWithList :: Monad m => Headline -> OrgParser m Blocks
+headlineToHeaderWithList hdln@(Headline {..}) = do
+ maxHeadlineLevels <- getExportSetting exportHeadlineLevels
+ header <- headlineToHeader hdln
+ listElements <- sequence (map headlineToBlocks headlineChildren)
+ let listBlock = if null listElements
+ then mempty
+ else B.orderedList listElements
+ let headerText = if maxHeadlineLevels == headlineLevel
+ then header
+ else flattenHeader header
+ return $ headerText <> headlineContents <> listBlock
+ where
+ flattenHeader :: Blocks -> Blocks
+ flattenHeader blks =
+ case B.toList blks of
+ (Header _ _ inlns:_) -> B.para (B.fromList inlns)
+ _ -> mempty
+
+headlineToHeaderWithContents :: Monad m => Headline -> OrgParser m Blocks
+headlineToHeaderWithContents hdln@(Headline {..}) = do
+ header <- headlineToHeader hdln
+ childrenBlocks <- mconcat <$> sequence (map headlineToBlocks headlineChildren)
+ return $ header <> headlineContents <> childrenBlocks
+
+headlineToHeader :: Monad m => Headline -> OrgParser m Blocks
+headlineToHeader (Headline {..}) = do
+ exportTodoKeyword <- getExportSetting exportWithTodoKeywords
+ let todoText = if exportTodoKeyword
+ then case headlineTodoMarker of
+ Just kw -> todoKeywordToInlines kw <> B.space
+ Nothing -> mempty
+ else mempty
+ let text = tagTitle (todoText <> headlineText) headlineTags
+ let propAttr = propertiesToAttr headlineProperties
+ attr <- registerHeader propAttr headlineText
+ return $ B.headerWith attr headlineLevel text
+
+todoKeyword :: Monad m => OrgParser m TodoMarker
+todoKeyword = try $ do
+ taskStates <- activeTodoMarkers <$> getState
+ let kwParser tdm = try $ (tdm <$ string (todoMarkerName tdm) <* spaceChar)
+ choice (map kwParser taskStates)
+
+todoKeywordToInlines :: TodoMarker -> Inlines
+todoKeywordToInlines tdm =
+ let todoText = todoMarkerName tdm
+ todoState = map toLower . show $ todoMarkerState tdm
+ classes = [todoState, todoText]
+ in B.spanWith (mempty, classes, mempty) (B.str todoText)
+
+propertiesToAttr :: Properties -> Attr
+propertiesToAttr properties =
+ let
+ toStringPair prop = (fromKey (fst prop), fromValue (snd prop))
+ customIdKey = toPropertyKey "custom_id"
+ classKey = toPropertyKey "class"
+ unnumberedKey = toPropertyKey "unnumbered"
+ specialProperties = [customIdKey, classKey, unnumberedKey]
+ id' = fromMaybe mempty . fmap fromValue . lookup customIdKey $ properties
+ cls = fromMaybe mempty . fmap fromValue . lookup classKey $ properties
+ kvs' = map toStringPair . filter ((`notElem` specialProperties) . fst)
+ $ properties
+ isUnnumbered =
+ fromMaybe False . fmap isNonNil . lookup unnumberedKey $ properties
+ in
+ (id', words cls ++ (if isUnnumbered then ["unnumbered"] else []), kvs')
+
+tagTitle :: Inlines -> [Tag] -> Inlines
+tagTitle title tags = title <> (mconcat $ map tagToInline tags)
+
+tagToInline :: Tag -> Inlines
+tagToInline t = B.spanWith ("", ["tag"], [("data-tag-name", fromTag t)]) mempty
+
+
+--
+-- parsing blocks
+--
+
+-- | Get a list of blocks.
+blockList :: PandocMonad m => OrgParser m [Block]
+blockList = do
+ initialBlocks <- blocks
+ headlines <- sequence <$> manyTill (headline 1) eof
+ st <- getState
+ headlineBlocks <- fmap mconcat . sequence . map headlineToBlocks $ runF headlines st
+ return . B.toList $ (runF initialBlocks st) <> headlineBlocks
+
+-- | Get the meta information safed in the state.
+meta :: Monad m => OrgParser m Meta
+meta = do
+ meta' <- metaExport
+ runF meta' <$> getState
+
+blocks :: PandocMonad m => OrgParser m (F Blocks)
+blocks = mconcat <$> manyTill block (void (lookAhead headerStart) <|> eof)
+
+block :: PandocMonad m => OrgParser m (F Blocks)
+block = choice [ mempty <$ blanklines
+ , table
+ , orgBlock
+ , figure
+ , example
+ , genericDrawer
+ , specialLine
+ , horizontalRule
+ , list
+ , latexFragment
+ , noteBlock
+ , paraOrPlain
+ ] <?> "block"
+
+
+--
+-- Block Attributes
+--
+
+-- | Attributes that may be added to figures (like a name or caption).
+data BlockAttributes = BlockAttributes
+ { blockAttrName :: Maybe String
+ , blockAttrLabel :: Maybe String
+ , blockAttrCaption :: Maybe (F Inlines)
+ , blockAttrKeyValues :: [(String, String)]
+ }
+
+-- | Convert BlockAttributes into pandoc Attr
+attrFromBlockAttributes :: BlockAttributes -> Attr
+attrFromBlockAttributes (BlockAttributes{..}) =
+ let
+ ident = fromMaybe mempty $ lookup "id" blockAttrKeyValues
+ classes = case lookup "class" blockAttrKeyValues of
+ Nothing -> []
+ Just clsStr -> words clsStr
+ kv = filter ((`notElem` ["id", "class"]) . fst) blockAttrKeyValues
+ in (ident, classes, kv)
+
+stringyMetaAttribute :: Monad m => (String -> Bool) -> OrgParser m (String, String)
+stringyMetaAttribute attrCheck = try $ do
+ metaLineStart
+ attrName <- map toUpper <$> many1Till nonspaceChar (char ':')
+ guard $ attrCheck attrName
+ skipSpaces
+ attrValue <- anyLine
+ return (attrName, attrValue)
+
+blockAttributes :: PandocMonad m => OrgParser m BlockAttributes
+blockAttributes = try $ do
+ kv <- many (stringyMetaAttribute attrCheck)
+ let caption = foldl' (appendValues "CAPTION") Nothing kv
+ let kvAttrs = foldl' (appendValues "ATTR_HTML") Nothing kv
+ let name = lookup "NAME" kv
+ let label = lookup "LABEL" kv
+ caption' <- case caption of
+ Nothing -> return Nothing
+ Just s -> Just <$> parseFromString inlines (s ++ "\n")
+ kvAttrs' <- parseFromString keyValues . (++ "\n") $ fromMaybe mempty kvAttrs
+ return $ BlockAttributes
+ { blockAttrName = name
+ , blockAttrLabel = label
+ , blockAttrCaption = caption'
+ , blockAttrKeyValues = kvAttrs'
+ }
+ where
+ attrCheck :: String -> Bool
+ attrCheck attr =
+ case attr of
+ "NAME" -> True
+ "LABEL" -> True
+ "CAPTION" -> True
+ "ATTR_HTML" -> True
+ _ -> False
+
+ appendValues :: String -> Maybe String -> (String, String) -> Maybe String
+ appendValues attrName accValue (key, value) =
+ if key /= attrName
+ then accValue
+ else case accValue of
+ Just acc -> Just $ acc ++ ' ':value
+ Nothing -> Just value
+
+keyValues :: Monad m => OrgParser m [(String, String)]
+keyValues = try $
+ manyTill ((,) <$> key <*> value) newline
+ where
+ key :: Monad m => OrgParser m String
+ key = try $ skipSpaces *> char ':' *> many1 nonspaceChar
+
+ value :: Monad m => OrgParser m String
+ value = skipSpaces *> manyTill anyChar endOfValue
+
+ endOfValue :: Monad m => OrgParser m ()
+ endOfValue =
+ lookAhead $ (() <$ try (many1 spaceChar <* key))
+ <|> () <$ newline
+
+
+--
+-- Org Blocks (#+BEGIN_... / #+END_...)
+--
+
+-- | Read an org-mode block delimited by #+BEGIN_TYPE and #+END_TYPE.
+orgBlock :: PandocMonad m => OrgParser m (F Blocks)
+orgBlock = try $ do
+ blockAttrs <- blockAttributes
+ blkType <- blockHeaderStart
+ ($ blkType) $
+ case (map toLower blkType) of
+ "export" -> exportBlock
+ "comment" -> rawBlockLines (const mempty)
+ "html" -> rawBlockLines (return . B.rawBlock (lowercase blkType))
+ "latex" -> rawBlockLines (return . B.rawBlock (lowercase blkType))
+ "ascii" -> rawBlockLines (return . B.rawBlock (lowercase blkType))
+ "example" -> rawBlockLines (return . exampleCode)
+ "quote" -> parseBlockLines (fmap B.blockQuote)
+ "verse" -> verseBlock
+ "src" -> codeBlock blockAttrs
+ _ -> parseBlockLines $
+ let (ident, classes, kv) = attrFromBlockAttributes blockAttrs
+ in fmap $ B.divWith (ident, classes ++ [blkType], kv)
+ where
+ blockHeaderStart :: Monad m => OrgParser m String
+ blockHeaderStart = try $ skipSpaces *> stringAnyCase "#+begin_" *> orgArgWord
+
+ lowercase :: String -> String
+ lowercase = map toLower
+
+rawBlockLines :: Monad m => (String -> F Blocks) -> String -> OrgParser m (F Blocks)
+rawBlockLines f blockType = (ignHeaders *> (f <$> rawBlockContent blockType))
+
+parseBlockLines :: PandocMonad m => (F Blocks -> F Blocks) -> String -> OrgParser m (F Blocks)
+parseBlockLines f blockType = (ignHeaders *> (f <$> parsedBlockContent))
+ where
+ parsedBlockContent :: PandocMonad m => OrgParser m (F Blocks)
+ parsedBlockContent = try $ do
+ raw <- rawBlockContent blockType
+ parseFromString blocks (raw ++ "\n")
+
+-- | Read the raw string content of a block
+rawBlockContent :: Monad m => String -> OrgParser m String
+rawBlockContent blockType = try $ do
+ blkLines <- manyTill rawLine blockEnder
+ tabLen <- getOption readerTabStop
+ return
+ . unlines
+ . stripIndent
+ . map (tabsToSpaces tabLen . commaEscaped)
+ $ blkLines
+ where
+ rawLine :: Monad m => OrgParser m String
+ rawLine = try $ ("" <$ blankline) <|> anyLine
+
+ blockEnder :: Monad m => OrgParser m ()
+ blockEnder = try $ skipSpaces <* stringAnyCase ("#+end_" <> blockType)
+
+ stripIndent :: [String] -> [String]
+ stripIndent strs = map (drop (shortestIndent strs)) strs
+
+ shortestIndent :: [String] -> Int
+ shortestIndent = foldr min maxBound
+ . map (length . takeWhile isSpace)
+ . filter (not . null)
+
+ tabsToSpaces :: Int -> String -> String
+ tabsToSpaces _ [] = []
+ tabsToSpaces tabLen cs'@(c:cs) =
+ case c of
+ ' ' -> ' ':tabsToSpaces tabLen cs
+ '\t' -> (take tabLen $ repeat ' ') ++ tabsToSpaces tabLen cs
+ _ -> cs'
+
+ commaEscaped :: String -> String
+ commaEscaped (',':cs@('*':_)) = cs
+ commaEscaped (',':cs@('#':'+':_)) = cs
+ commaEscaped (' ':cs) = ' ':commaEscaped cs
+ commaEscaped ('\t':cs) = '\t':commaEscaped cs
+ commaEscaped cs = cs
+
+-- | Read but ignore all remaining block headers.
+ignHeaders :: Monad m => OrgParser m ()
+ignHeaders = (() <$ newline) <|> (() <$ anyLine)
+
+-- | Read a block containing code intended for export in specific backends
+-- only.
+exportBlock :: Monad m => String -> OrgParser m (F Blocks)
+exportBlock blockType = try $ do
+ exportType <- skipSpaces *> orgArgWord <* ignHeaders
+ contents <- rawBlockContent blockType
+ returnF (B.rawBlock (map toLower exportType) contents)
+
+verseBlock :: PandocMonad m => String -> OrgParser m (F Blocks)
+verseBlock blockType = try $ do
+ ignHeaders
+ content <- rawBlockContent blockType
+ fmap B.lineBlock . sequence
+ <$> mapM parseVerseLine (lines content)
+ where
+ -- replace initial spaces with nonbreaking spaces to preserve
+ -- indentation, parse the rest as normal inline
+ parseVerseLine :: PandocMonad m => String -> OrgParser m (F Inlines)
+ parseVerseLine cs = do
+ let (initialSpaces, indentedLine) = span isSpace cs
+ let nbspIndent = if null initialSpaces
+ then mempty
+ else B.str $ map (const '\160') initialSpaces
+ line <- parseFromString inlines (indentedLine ++ "\n")
+ return (trimInlinesF $ pure nbspIndent <> line)
+
+-- | Read a code block and the associated results block if present. Which of
+-- boths blocks is included in the output is determined using the "exports"
+-- argument in the block header.
+codeBlock :: PandocMonad m => BlockAttributes -> String -> OrgParser m (F Blocks)
+codeBlock blockAttrs blockType = do
+ skipSpaces
+ (classes, kv) <- codeHeaderArgs <|> (mempty <$ ignHeaders)
+ content <- rawBlockContent blockType
+ resultsContent <- trailingResultsBlock
+ let id' = fromMaybe mempty $ blockAttrName blockAttrs
+ let includeCode = exportsCode kv
+ let includeResults = exportsResults kv
+ let codeBlck = B.codeBlockWith ( id', classes, kv ) content
+ let labelledBlck = maybe (pure codeBlck)
+ (labelDiv codeBlck)
+ (blockAttrCaption blockAttrs)
+ let resultBlck = fromMaybe mempty resultsContent
+ return $
+ (if includeCode then labelledBlck else mempty) <>
+ (if includeResults then resultBlck else mempty)
+ where
+ labelDiv :: Blocks -> F Inlines -> F Blocks
+ labelDiv blk value =
+ B.divWith nullAttr <$> (mappend <$> labelledBlock value <*> pure blk)
+
+ labelledBlock :: F Inlines -> F Blocks
+ labelledBlock = fmap (B.plain . B.spanWith ("", ["label"], []))
+
+exportsCode :: [(String, String)] -> Bool
+exportsCode attrs = not (("rundoc-exports", "none") `elem` attrs
+ || ("rundoc-exports", "results") `elem` attrs)
+
+exportsResults :: [(String, String)] -> Bool
+exportsResults attrs = ("rundoc-exports", "results") `elem` attrs
+ || ("rundoc-exports", "both") `elem` attrs
+
+trailingResultsBlock :: PandocMonad m => OrgParser m (Maybe (F Blocks))
+trailingResultsBlock = optionMaybe . try $ do
+ blanklines
+ stringAnyCase "#+RESULTS:"
+ blankline
+ block
+
+-- | Parse code block arguments
+-- TODO: We currently don't handle switches.
+codeHeaderArgs :: Monad m => OrgParser m ([String], [(String, String)])
+codeHeaderArgs = try $ do
+ language <- skipSpaces *> orgArgWord
+ _ <- skipSpaces *> (try $ switch `sepBy` (many1 spaceChar))
+ parameters <- manyTill blockOption newline
+ let pandocLang = translateLang language
+ return $
+ if hasRundocParameters parameters
+ then ( [ pandocLang, rundocBlockClass ]
+ , map toRundocAttrib (("language", language) : parameters)
+ )
+ else ([ pandocLang ], parameters)
+ where
+ hasRundocParameters = not . null
+
+switch :: Monad m => OrgParser m (Char, Maybe String)
+switch = try $ simpleSwitch <|> lineNumbersSwitch
+ where
+ simpleSwitch = (\c -> (c, Nothing)) <$> (oneOf "-+" *> letter)
+ lineNumbersSwitch = (\ls -> ('l', Just ls)) <$>
+ (string "-l \"" *> many1Till nonspaceChar (char '"'))
+
+blockOption :: Monad m => OrgParser m (String, String)
+blockOption = try $ do
+ argKey <- orgArgKey
+ paramValue <- option "yes" orgParamValue
+ return (argKey, paramValue)
+
+orgParamValue :: Monad m => OrgParser m String
+orgParamValue = try $
+ skipSpaces
+ *> notFollowedBy (char ':' )
+ *> many1 nonspaceChar
+ <* skipSpaces
+
+horizontalRule :: Monad m => OrgParser m (F Blocks)
+horizontalRule = return B.horizontalRule <$ try hline
+
+
+--
+-- Drawers
+--
+
+-- | A generic drawer which has no special meaning for org-mode.
+-- Whether or not this drawer is included in the output depends on the drawers
+-- export setting.
+genericDrawer :: PandocMonad m => OrgParser m (F Blocks)
+genericDrawer = try $ do
+ name <- map toUpper <$> drawerStart
+ content <- manyTill drawerLine (try drawerEnd)
+ state <- getState
+ -- Include drawer if it is explicitly included in or not explicitly excluded
+ -- from the list of drawers that should be exported. PROPERTIES drawers are
+ -- never exported.
+ case (exportDrawers . orgStateExportSettings $ state) of
+ _ | name == "PROPERTIES" -> return mempty
+ Left names | name `elem` names -> return mempty
+ Right names | name `notElem` names -> return mempty
+ _ -> drawerDiv name <$> parseLines content
+ where
+ parseLines :: PandocMonad m => [String] -> OrgParser m (F Blocks)
+ parseLines = parseFromString blocks . (++ "\n") . unlines
+
+ drawerDiv :: String -> F Blocks -> F Blocks
+ drawerDiv drawerName = fmap $ B.divWith (mempty, [drawerName, "drawer"], mempty)
+
+drawerLine :: Monad m => OrgParser m String
+drawerLine = anyLine
+
+drawerEnd :: Monad m => OrgParser m String
+drawerEnd = try $
+ skipSpaces *> stringAnyCase ":END:" <* skipSpaces <* newline
+
+-- | Read a :PROPERTIES: drawer and return the key/value pairs contained
+-- within.
+propertiesDrawer :: Monad m => OrgParser m Properties
+propertiesDrawer = try $ do
+ drawerType <- drawerStart
+ guard $ map toUpper drawerType == "PROPERTIES"
+ manyTill property (try drawerEnd)
+ where
+ property :: Monad m => OrgParser m (PropertyKey, PropertyValue)
+ property = try $ (,) <$> key <*> value
+
+ key :: Monad m => OrgParser m PropertyKey
+ key = fmap toPropertyKey . try $
+ skipSpaces *> char ':' *> many1Till nonspaceChar (char ':')
+
+ value :: Monad m => OrgParser m PropertyValue
+ value = fmap toPropertyValue . try $
+ skipSpaces *> manyTill anyChar (try $ skipSpaces *> newline)
+
+
+--
+-- Figures
+--
+
+-- | Figures or an image paragraph (i.e. an image on a line by itself). Only
+-- images with a caption attribute are interpreted as figures.
+figure :: PandocMonad m => OrgParser m (F Blocks)
+figure = try $ do
+ figAttrs <- blockAttributes
+ src <- skipSpaces *> selfTarget <* skipSpaces <* endOfParagraph
+ case cleanLinkString src of
+ Nothing -> mzero
+ Just imgSrc -> do
+ guard (isImageFilename imgSrc)
+ let isFigure = not . isNothing $ blockAttrCaption figAttrs
+ return $ imageBlock isFigure figAttrs imgSrc
+ where
+ selfTarget :: PandocMonad m => OrgParser m String
+ selfTarget = try $ char '[' *> linkTarget <* char ']'
+
+ imageBlock :: Bool -> BlockAttributes -> String -> F Blocks
+ imageBlock isFigure figAttrs imgSrc =
+ let
+ figName = fromMaybe mempty $ blockAttrName figAttrs
+ figLabel = fromMaybe mempty $ blockAttrLabel figAttrs
+ figCaption = fromMaybe mempty $ blockAttrCaption figAttrs
+ figKeyVals = blockAttrKeyValues figAttrs
+ attr = (figLabel, mempty, figKeyVals)
+ figTitle = (if isFigure then withFigPrefix else id) figName
+ in
+ B.para . B.imageWith attr imgSrc figTitle <$> figCaption
+
+ withFigPrefix :: String -> String
+ withFigPrefix cs =
+ if "fig:" `isPrefixOf` cs
+ then cs
+ else "fig:" ++ cs
+
+-- | Succeeds if looking at the end of the current paragraph
+endOfParagraph :: Monad m => OrgParser m ()
+endOfParagraph = try $ skipSpaces *> newline *> endOfBlock
+
+
+--
+-- Examples
+--
+
+-- | Example code marked up by a leading colon.
+example :: Monad m => OrgParser m (F Blocks)
+example = try $ do
+ return . return . exampleCode =<< unlines <$> many1 exampleLine
+ where
+ exampleLine :: Monad m => OrgParser m String
+ exampleLine = try $ exampleLineStart *> anyLine
+
+exampleCode :: String -> Blocks
+exampleCode = B.codeBlockWith ("", ["example"], [])
+
+
+--
+-- Comments, Options and Metadata
+--
+
+specialLine :: PandocMonad m => OrgParser m (F Blocks)
+specialLine = fmap return . try $ rawExportLine <|> metaLine <|> commentLine
+
+rawExportLine :: PandocMonad m => OrgParser m Blocks
+rawExportLine = try $ do
+ metaLineStart
+ key <- metaKey
+ if key `elem` ["latex", "html", "texinfo", "beamer"]
+ then B.rawBlock key <$> anyLine
+ else mzero
+
+commentLine :: Monad m => OrgParser m Blocks
+commentLine = commentLineStart *> anyLine *> pure mempty
+
+
+--
+-- Tables
+--
+data ColumnProperty = ColumnProperty
+ { columnAlignment :: Maybe Alignment
+ , columnRelWidth :: Maybe Int
+ } deriving (Show, Eq)
+
+instance Default ColumnProperty where
+ def = ColumnProperty Nothing Nothing
+
+data OrgTableRow = OrgContentRow (F [Blocks])
+ | OrgAlignRow [ColumnProperty]
+ | OrgHlineRow
+
+-- OrgTable is strongly related to the pandoc table ADT. Using the same
+-- (i.e. pandoc-global) ADT would mean that the reader would break if the
+-- global structure was to be changed, which would be bad. The final table
+-- should be generated using a builder function.
+data OrgTable = OrgTable
+ { orgTableColumnProperties :: [ColumnProperty]
+ , orgTableHeader :: [Blocks]
+ , orgTableRows :: [[Blocks]]
+ }
+
+table :: PandocMonad m => OrgParser m (F Blocks)
+table = try $ do
+ blockAttrs <- blockAttributes
+ lookAhead tableStart
+ do
+ rows <- tableRows
+ let caption = fromMaybe (return mempty) $ blockAttrCaption blockAttrs
+ return $ (<$> caption) . orgToPandocTable . normalizeTable =<< rowsToTable rows
+
+orgToPandocTable :: OrgTable
+ -> Inlines
+ -> Blocks
+orgToPandocTable (OrgTable colProps heads lns) caption =
+ let totalWidth = if any (not . isNothing) (map columnRelWidth colProps)
+ then Just . sum $ map (fromMaybe 1 . columnRelWidth) colProps
+ else Nothing
+ in B.table caption (map (convertColProp totalWidth) colProps) heads lns
+ where
+ convertColProp :: Maybe Int -> ColumnProperty -> (Alignment, Double)
+ convertColProp totalWidth colProp =
+ let
+ align' = fromMaybe AlignDefault $ columnAlignment colProp
+ width' = fromMaybe 0 $ (\w t -> (fromIntegral w / fromIntegral t))
+ <$> (columnRelWidth colProp)
+ <*> totalWidth
+ in (align', width')
+
+tableRows :: PandocMonad m => OrgParser m [OrgTableRow]
+tableRows = try $ many (tableAlignRow <|> tableHline <|> tableContentRow)
+
+tableContentRow :: PandocMonad m => OrgParser m OrgTableRow
+tableContentRow = try $
+ OrgContentRow . sequence <$> (tableStart *> many1Till tableContentCell newline)
+
+tableContentCell :: PandocMonad m => OrgParser m (F Blocks)
+tableContentCell = try $
+ fmap B.plain . trimInlinesF . mconcat <$> manyTill inline endOfCell
+
+tableAlignRow :: Monad m => OrgParser m OrgTableRow
+tableAlignRow = try $ do
+ tableStart
+ colProps <- many1Till columnPropertyCell newline
+ -- Empty rows are regular (i.e. content) rows, not alignment rows.
+ guard $ any (/= def) colProps
+ return $ OrgAlignRow colProps
+
+columnPropertyCell :: Monad m => OrgParser m ColumnProperty
+columnPropertyCell = emptyCell <|> propCell <?> "alignment info"
+ where
+ emptyCell = ColumnProperty Nothing Nothing <$ (try $ skipSpaces *> endOfCell)
+ propCell = try $ ColumnProperty
+ <$> (skipSpaces
+ *> char '<'
+ *> optionMaybe tableAlignFromChar)
+ <*> (optionMaybe (many1 digit >>= safeRead)
+ <* char '>'
+ <* emptyCell)
+
+tableAlignFromChar :: Monad m => OrgParser m Alignment
+tableAlignFromChar = try $
+ choice [ char 'l' *> return AlignLeft
+ , char 'c' *> return AlignCenter
+ , char 'r' *> return AlignRight
+ ]
+
+tableHline :: Monad m => OrgParser m OrgTableRow
+tableHline = try $
+ OrgHlineRow <$ (tableStart *> char '-' *> anyLine)
+
+endOfCell :: Monad m => OrgParser m Char
+endOfCell = try $ char '|' <|> lookAhead newline
+
+rowsToTable :: [OrgTableRow]
+ -> F OrgTable
+rowsToTable = foldM rowToContent emptyTable
+ where emptyTable = OrgTable mempty mempty mempty
+
+normalizeTable :: OrgTable -> OrgTable
+normalizeTable (OrgTable colProps heads rows) =
+ OrgTable colProps' heads rows
+ where
+ refRow = if heads /= mempty
+ then heads
+ else case rows of
+ (r:_) -> r
+ _ -> mempty
+ cols = length refRow
+ fillColumns base padding = take cols $ base ++ repeat padding
+ colProps' = fillColumns colProps def
+
+-- One or more horizontal rules after the first content line mark the previous
+-- line as a header. All other horizontal lines are discarded.
+rowToContent :: OrgTable
+ -> OrgTableRow
+ -> F OrgTable
+rowToContent orgTable row =
+ case row of
+ OrgHlineRow -> return singleRowPromotedToHeader
+ OrgAlignRow props -> return . setProperties $ props
+ OrgContentRow cs -> appendToBody cs
+ where
+ singleRowPromotedToHeader :: OrgTable
+ singleRowPromotedToHeader = case orgTable of
+ OrgTable{ orgTableHeader = [], orgTableRows = b:[] } ->
+ orgTable{ orgTableHeader = b , orgTableRows = [] }
+ _ -> orgTable
+
+ setProperties :: [ColumnProperty] -> OrgTable
+ setProperties ps = orgTable{ orgTableColumnProperties = ps }
+
+ appendToBody :: F [Blocks] -> F OrgTable
+ appendToBody frow = do
+ newRow <- frow
+ let oldRows = orgTableRows orgTable
+ -- NOTE: This is an inefficient O(n) operation. This should be changed
+ -- if performance ever becomes a problem.
+ return orgTable{ orgTableRows = oldRows ++ [newRow] }
+
+
+--
+-- LaTeX fragments
+--
+latexFragment :: Monad m => OrgParser m (F Blocks)
+latexFragment = try $ do
+ envName <- latexEnvStart
+ content <- mconcat <$> manyTill anyLineNewline (latexEnd envName)
+ return . return $ B.rawBlock "latex" (content `inLatexEnv` envName)
+ where
+ c `inLatexEnv` e = mconcat [ "\\begin{", e, "}\n"
+ , c
+ , "\\end{", e, "}\n"
+ ]
+
+latexEnd :: Monad m => String -> OrgParser m ()
+latexEnd envName = try $
+ () <$ skipSpaces
+ <* string ("\\end{" ++ envName ++ "}")
+ <* blankline
+
+
+--
+-- Footnote defintions
+--
+noteBlock :: PandocMonad m => OrgParser m (F Blocks)
+noteBlock = try $ do
+ ref <- noteMarker <* skipSpaces
+ content <- mconcat <$> blocksTillHeaderOrNote
+ addToNotesTable (ref, content)
+ return mempty
+ where
+ blocksTillHeaderOrNote =
+ many1Till block (eof <|> () <$ lookAhead noteMarker
+ <|> () <$ lookAhead headerStart)
+
+-- Paragraphs or Plain text
+paraOrPlain :: PandocMonad m => OrgParser m (F Blocks)
+paraOrPlain = try $ do
+ -- Make sure we are not looking at a headline
+ notFollowedBy' (char '*' *> (oneOf " *"))
+ ils <- inlines
+ nl <- option False (newline *> return True)
+ -- Read block as paragraph, except if we are in a list context and the block
+ -- is directly followed by a list item, in which case the block is read as
+ -- plain text.
+ try (guard nl
+ *> notFollowedBy (inList *> (() <$ orderedListStart <|> bulletListStart))
+ *> return (B.para <$> ils))
+ <|> (return (B.plain <$> ils))
+
+
+--
+-- list blocks
+--
+
+list :: PandocMonad m => OrgParser m (F Blocks)
+list = choice [ definitionList, bulletList, orderedList ] <?> "list"
+
+definitionList :: PandocMonad m => OrgParser m (F Blocks)
+definitionList = try $ do n <- lookAhead (bulletListStart' Nothing)
+ fmap B.definitionList . fmap compactifyDL . sequence
+ <$> many1 (definitionListItem $ bulletListStart' (Just n))
+
+bulletList :: PandocMonad m => OrgParser m (F Blocks)
+bulletList = try $ do n <- lookAhead (bulletListStart' Nothing)
+ fmap B.bulletList . fmap compactify . sequence
+ <$> many1 (listItem (bulletListStart' $ Just n))
+
+orderedList :: PandocMonad m => OrgParser m (F Blocks)
+orderedList = fmap B.orderedList . fmap compactify . sequence
+ <$> many1 (listItem orderedListStart)
+
+bulletListStart' :: Monad m => Maybe Int -> OrgParser m Int
+-- returns length of bulletList prefix, inclusive of marker
+bulletListStart' Nothing = do ind <- length <$> many spaceChar
+ oneOf (bullets $ ind == 0)
+ skipSpaces1
+ return (ind + 1)
+bulletListStart' (Just n) = do count (n-1) spaceChar
+ oneOf (bullets $ n == 1)
+ many1 spaceChar
+ return n
+
+-- Unindented lists are legal, but they can't use '*' bullets.
+-- We return n to maintain compatibility with the generic listItem.
+bullets :: Bool -> String
+bullets unindented = if unindented then "+-" else "*+-"
+
+definitionListItem :: PandocMonad m
+ => OrgParser m Int
+ -> OrgParser m (F (Inlines, [Blocks]))
+definitionListItem parseMarkerGetLength = try $ do
+ markerLength <- parseMarkerGetLength
+ term <- manyTill (noneOf "\n\r") (try definitionMarker)
+ line1 <- anyLineNewline
+ blank <- option "" ("\n" <$ blankline)
+ cont <- concat <$> many (listContinuation markerLength)
+ term' <- parseFromString inlines term
+ contents' <- parseFromString blocks $ line1 ++ blank ++ cont
+ return $ (,) <$> term' <*> fmap (:[]) contents'
+ where
+ definitionMarker =
+ spaceChar *> string "::" <* (spaceChar <|> lookAhead newline)
+
+
+-- parse raw text for one list item, excluding start marker and continuations
+listItem :: PandocMonad m
+ => OrgParser m Int
+ -> OrgParser m (F Blocks)
+listItem start = try . withContext ListItemState $ do
+ markerLength <- try start
+ firstLine <- anyLineNewline
+ blank <- option "" ("\n" <$ blankline)
+ rest <- concat <$> many (listContinuation markerLength)
+ parseFromString blocks $ firstLine ++ blank ++ rest
+
+-- continuation of a list item - indented and separated by blankline or endline.
+-- Note: nested lists are parsed as continuations.
+listContinuation :: Monad m => Int
+ -> OrgParser m String
+listContinuation markerLength = try $
+ notFollowedBy' blankline
+ *> (mappend <$> (concat <$> many1 listLine)
+ <*> many blankline)
+ where
+ listLine = try $ indentWith markerLength *> anyLineNewline
+
+ -- indent by specified number of spaces (or equiv. tabs)
+ indentWith :: Monad m => Int -> OrgParser m String
+ indentWith num = do
+ tabStop <- getOption readerTabStop
+ if num < tabStop
+ then count num (char ' ')
+ else choice [ try (count num (char ' '))
+ , try (char '\t' >> count (num - tabStop) (char ' ')) ]
+
+-- | Parse any line, include the final newline in the output.
+anyLineNewline :: Monad m => OrgParser m String
+anyLineNewline = (++ "\n") <$> anyLine
diff --git a/src/Text/Pandoc/Readers/Org/ExportSettings.hs b/src/Text/Pandoc/Readers/Org/ExportSettings.hs
new file mode 100644
index 000000000..391877c03
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Org/ExportSettings.hs
@@ -0,0 +1,172 @@
+{-
+Copyright (C) 2014-2016 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.Readers.Org.Options
+ Copyright : Copyright (C) 2016 Albert Krewinkel
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
+
+Parsers for Org-mode export options.
+-}
+module Text.Pandoc.Readers.Org.ExportSettings
+ ( exportSettings
+ ) where
+
+import Text.Pandoc.Readers.Org.ParserState
+import Text.Pandoc.Readers.Org.Parsing
+
+import Control.Monad ( mzero, void )
+import Data.Char ( toLower )
+import Data.Maybe ( listToMaybe )
+
+-- | Read and handle space separated org-mode export settings.
+exportSettings :: Monad m => OrgParser m ()
+exportSettings = void $ sepBy spaces exportSetting
+
+-- | Setter function for export settings.
+type ExportSettingSetter a = a -> ExportSettings -> ExportSettings
+
+-- | Read and process a single org-mode export option.
+exportSetting :: Monad m => OrgParser m ()
+exportSetting = choice
+ [ booleanSetting "^" (\val es -> es { exportSubSuperscripts = val })
+ , booleanSetting "'" (\val es -> es { exportSmartQuotes = val })
+ , booleanSetting "*" (\val es -> es { exportEmphasizedText = val })
+ , booleanSetting "-" (\val es -> es { exportSpecialStrings = val })
+ , ignoredSetting ":"
+ , ignoredSetting "<"
+ , ignoredSetting "\\n"
+ , archivedTreeSetting "arch" (\val es -> es { exportArchivedTrees = val })
+ , booleanSetting "author" (\val es -> es { exportWithAuthor = val })
+ , ignoredSetting "c"
+ -- org-mode allows the special value `comment` for creator, which we'll
+ -- interpret as true as it doesn't make sense in the context of Pandoc.
+ , booleanSetting "creator" (\val es -> es { exportWithCreator = val })
+ , complementableListSetting "d" (\val es -> es { exportDrawers = val })
+ , ignoredSetting "date"
+ , ignoredSetting "e"
+ , booleanSetting "email" (\val es -> es { exportWithEmail = val })
+ , ignoredSetting "f"
+ , integerSetting "H" (\val es -> es { exportHeadlineLevels = val })
+ , ignoredSetting "inline"
+ , ignoredSetting "num"
+ , ignoredSetting "p"
+ , ignoredSetting "pri"
+ , ignoredSetting "prop"
+ , ignoredSetting "stat"
+ , ignoredSetting "tags"
+ , ignoredSetting "tasks"
+ , ignoredSetting "tex"
+ , ignoredSetting "timestamp"
+ , ignoredSetting "title"
+ , ignoredSetting "toc"
+ , booleanSetting "todo" (\val es -> es { exportWithTodoKeywords = val })
+ , ignoredSetting "|"
+ ] <?> "export setting"
+
+genericExportSetting :: Monad m
+ => OrgParser m a
+ -> String
+ -> ExportSettingSetter a
+ -> OrgParser m ()
+genericExportSetting optionParser settingIdentifier setter = try $ do
+ _ <- string settingIdentifier *> char ':'
+ value <- optionParser
+ updateState $ modifyExportSettings value
+ where
+ modifyExportSettings val st =
+ st { orgStateExportSettings = setter val . orgStateExportSettings $ st }
+
+-- | A boolean option, either nil (False) or non-nil (True).
+booleanSetting :: Monad m => String -> ExportSettingSetter Bool -> OrgParser m ()
+booleanSetting = genericExportSetting elispBoolean
+
+-- | An integer-valued option.
+integerSetting :: Monad m => String -> ExportSettingSetter Int -> OrgParser m ()
+integerSetting = genericExportSetting parseInt
+ where
+ parseInt = try $
+ many1 digit >>= maybe mzero (return . fst) . listToMaybe . reads
+
+-- | Either the string "headline" or an elisp boolean and treated as an
+-- @ArchivedTreesOption@.
+archivedTreeSetting :: Monad m
+ => String
+ -> ExportSettingSetter ArchivedTreesOption
+ -> OrgParser m ()
+archivedTreeSetting =
+ genericExportSetting $ archivedTreesHeadlineSetting <|> archivedTreesBoolean
+ where
+ archivedTreesHeadlineSetting = try $ do
+ _ <- string "headline"
+ lookAhead (newline <|> spaceChar)
+ return ArchivedTreesHeadlineOnly
+
+ archivedTreesBoolean = try $ do
+ exportBool <- elispBoolean
+ return $
+ if exportBool
+ then ArchivedTreesExport
+ else ArchivedTreesNoExport
+
+-- | A list or a complement list (i.e. a list starting with `not`).
+complementableListSetting :: Monad m
+ => String
+ -> ExportSettingSetter (Either [String] [String])
+ -> OrgParser m ()
+complementableListSetting = genericExportSetting $ choice
+ [ Left <$> complementStringList
+ , Right <$> stringList
+ , (\b -> if b then Left [] else Right []) <$> elispBoolean
+ ]
+ where
+ -- Read a plain list of strings.
+ stringList :: Monad m => OrgParser m [String]
+ stringList = try $
+ char '('
+ *> sepBy elispString spaces
+ <* char ')'
+
+ -- Read an emacs lisp list specifying a complement set.
+ complementStringList :: Monad m => OrgParser m [String]
+ complementStringList = try $
+ string "(not "
+ *> sepBy elispString spaces
+ <* char ')'
+
+ elispString :: Monad m => OrgParser m String
+ elispString = try $
+ char '"'
+ *> manyTill alphaNum (char '"')
+
+-- | Read but ignore the export setting.
+ignoredSetting :: Monad m => String -> OrgParser m ()
+ignoredSetting s = try (() <$ string s <* char ':' <* many1 nonspaceChar)
+
+-- | Read an elisp boolean. Only NIL is treated as false, non-NIL values are
+-- interpreted as true.
+elispBoolean :: Monad m => OrgParser m Bool
+elispBoolean = try $ do
+ value <- many1 nonspaceChar
+ return $ case map toLower value of
+ "nil" -> False
+ "{}" -> False
+ "()" -> False
+ _ -> True
diff --git a/src/Text/Pandoc/Readers/Org/Inlines.hs b/src/Text/Pandoc/Readers/Org/Inlines.hs
new file mode 100644
index 000000000..f3671641a
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Org/Inlines.hs
@@ -0,0 +1,880 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-
+Copyright (C) 2014-2016 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.Readers.Org.Options
+ Copyright : Copyright (C) 2014-2016 Albert Krewinkel
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
+
+Parsers for Org-mode inline elements.
+-}
+module Text.Pandoc.Readers.Org.Inlines
+ ( inline
+ , inlines
+ , addToNotesTable
+ , linkTarget
+ ) where
+
+import Text.Pandoc.Readers.Org.BlockStarts ( endOfBlock, noteMarker )
+import Text.Pandoc.Readers.Org.ParserState
+import Text.Pandoc.Readers.Org.Parsing
+import Text.Pandoc.Readers.Org.Shared
+ ( cleanLinkString, isImageFilename, rundocBlockClass
+ , toRundocAttrib, translateLang )
+
+import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.Builder ( Inlines )
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Text.Pandoc.Readers.LaTeX ( inlineCommand, rawLaTeXInline )
+import Text.TeXMath ( readTeX, writePandoc, DisplayType(..) )
+import qualified Text.TeXMath.Readers.MathML.EntityMap as MathMLEntityMap
+import Text.Pandoc.Class (PandocMonad)
+
+import Prelude hiding (sequence)
+import Control.Monad ( guard, mplus, mzero, when, void )
+import Control.Monad.Trans ( lift )
+import Data.Char ( isAlphaNum, isSpace )
+import Data.List ( intersperse )
+import Data.Maybe ( fromMaybe )
+import qualified Data.Map as M
+import Data.Monoid ( (<>) )
+import Data.Traversable (sequence)
+
+--
+-- Functions acting on the parser state
+--
+recordAnchorId :: PandocMonad m => String -> OrgParser m ()
+recordAnchorId i = updateState $ \s ->
+ s{ orgStateAnchorIds = i : (orgStateAnchorIds s) }
+
+pushToInlineCharStack :: PandocMonad m => Char -> OrgParser m ()
+pushToInlineCharStack c = updateState $ \s ->
+ s{ orgStateEmphasisCharStack = c:orgStateEmphasisCharStack s }
+
+popInlineCharStack :: PandocMonad m => OrgParser m ()
+popInlineCharStack = updateState $ \s ->
+ s{ orgStateEmphasisCharStack = drop 1 . orgStateEmphasisCharStack $ s }
+
+surroundingEmphasisChar :: PandocMonad m => OrgParser m [Char]
+surroundingEmphasisChar =
+ take 1 . drop 1 . orgStateEmphasisCharStack <$> getState
+
+startEmphasisNewlinesCounting :: PandocMonad m => Int -> OrgParser m ()
+startEmphasisNewlinesCounting maxNewlines = updateState $ \s ->
+ s{ orgStateEmphasisNewlines = Just maxNewlines }
+
+decEmphasisNewlinesCount :: PandocMonad m => OrgParser m ()
+decEmphasisNewlinesCount = updateState $ \s ->
+ s{ orgStateEmphasisNewlines = (\n -> n - 1) <$> orgStateEmphasisNewlines s }
+
+newlinesCountWithinLimits :: PandocMonad m => OrgParser m Bool
+newlinesCountWithinLimits = do
+ st <- getState
+ return $ ((< 0) <$> orgStateEmphasisNewlines st) /= Just True
+
+resetEmphasisNewlines :: PandocMonad m => OrgParser m ()
+resetEmphasisNewlines = updateState $ \s ->
+ s{ orgStateEmphasisNewlines = Nothing }
+
+addToNotesTable :: PandocMonad m => OrgNoteRecord -> OrgParser m ()
+addToNotesTable note = do
+ oldnotes <- orgStateNotes' <$> getState
+ updateState $ \s -> s{ orgStateNotes' = note:oldnotes }
+
+-- | Parse a single Org-mode inline element
+inline :: PandocMonad m => OrgParser m (F Inlines)
+inline =
+ choice [ whitespace
+ , linebreak
+ , cite
+ , footnote
+ , linkOrImage
+ , anchor
+ , inlineCodeBlock
+ , str
+ , endline
+ , emphasizedText
+ , code
+ , math
+ , displayMath
+ , verbatim
+ , subscript
+ , superscript
+ , inlineLaTeX
+ , exportSnippet
+ , smart
+ , symbol
+ ] <* (guard =<< newlinesCountWithinLimits)
+ <?> "inline"
+
+-- | Read the rest of the input as inlines.
+inlines :: PandocMonad m => OrgParser m (F Inlines)
+inlines = trimInlinesF . mconcat <$> many1 inline
+
+-- treat these as potentially non-text when parsing inline:
+specialChars :: [Char]
+specialChars = "\"$'()*+-,./:;<=>@[\\]^_{|}~"
+
+
+whitespace :: PandocMonad m => OrgParser m (F Inlines)
+whitespace = pure B.space <$ skipMany1 spaceChar
+ <* updateLastPreCharPos
+ <* updateLastForbiddenCharPos
+ <?> "whitespace"
+
+linebreak :: PandocMonad m => OrgParser m (F Inlines)
+linebreak = try $ pure B.linebreak <$ string "\\\\" <* skipSpaces <* newline
+
+str :: PandocMonad m => OrgParser m (F Inlines)
+str = return . B.str <$> many1 (noneOf $ specialChars ++ "\n\r ")
+ <* updateLastStrPos
+
+-- | An endline character that can be treated as a space, not a structural
+-- break. This should reflect the values of the Emacs variable
+-- @org-element-pagaraph-separate@.
+endline :: PandocMonad m => OrgParser m (F Inlines)
+endline = try $ do
+ newline
+ notFollowedBy' endOfBlock
+ decEmphasisNewlinesCount
+ guard =<< newlinesCountWithinLimits
+ updateLastPreCharPos
+ return . return $ B.softbreak
+
+
+--
+-- Citations
+--
+
+-- The state of citations is a bit confusing due to the lack of an official
+-- syntax and multiple syntaxes coexisting. The pandocOrgCite syntax was the
+-- first to be implemented here and is almost identical to Markdown's citation
+-- syntax. The org-ref package is in wide use to handle citations, but the
+-- syntax is a bit limiting and not quite as simple to write. The
+-- semi-offical Org-mode citation syntax is based on John MacFarlane's Pandoc
+-- sytax and Org-oriented enhancements contributed by Richard Lawrence and
+-- others. It's dubbed Berkeley syntax due the place of activity of its main
+-- contributors. All this should be consolidated once an official Org-mode
+-- citation syntax has emerged.
+
+cite :: PandocMonad m => OrgParser m (F Inlines)
+cite = try $ berkeleyCite <|> do
+ guardEnabled Ext_citations
+ (cs, raw) <- withRaw $ choice
+ [ pandocOrgCite
+ , orgRefCite
+ , berkeleyTextualCite
+ ]
+ return $ (flip B.cite (B.text raw)) <$> cs
+
+-- | A citation in Pandoc Org-mode style (@[prefix \@citekey suffix]@).
+pandocOrgCite :: PandocMonad m => OrgParser m (F [Citation])
+pandocOrgCite = try $
+ char '[' *> skipSpaces *> citeList <* skipSpaces <* char ']'
+
+orgRefCite :: PandocMonad m => OrgParser m (F [Citation])
+orgRefCite = try $ choice
+ [ normalOrgRefCite
+ , fmap (:[]) <$> linkLikeOrgRefCite
+ ]
+
+normalOrgRefCite :: PandocMonad m => OrgParser m (F [Citation])
+normalOrgRefCite = try $ do
+ mode <- orgRefCiteMode
+ firstCitation <- orgRefCiteList mode
+ moreCitations <- many (try $ char ',' *> orgRefCiteList mode)
+ return . sequence $ firstCitation : moreCitations
+ where
+ -- | A list of org-ref style citation keys, parsed as citation of the given
+ -- citation mode.
+ orgRefCiteList :: PandocMonad m => CitationMode -> OrgParser m (F Citation)
+ orgRefCiteList citeMode = try $ do
+ key <- orgRefCiteKey
+ returnF $ Citation
+ { citationId = key
+ , citationPrefix = mempty
+ , citationSuffix = mempty
+ , citationMode = citeMode
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+
+-- | Read an Berkeley-style Org-mode citation. Berkeley citation style was
+-- develop and adjusted to Org-mode style by John MacFarlane and Richard
+-- Lawrence, respectively, both philosophers at UC Berkeley.
+berkeleyCite :: PandocMonad m => OrgParser m (F Inlines)
+berkeleyCite = try $ do
+ bcl <- berkeleyCitationList
+ return $ do
+ parens <- berkeleyCiteParens <$> bcl
+ prefix <- berkeleyCiteCommonPrefix <$> bcl
+ suffix <- berkeleyCiteCommonSuffix <$> bcl
+ citationList <- berkeleyCiteCitations <$> bcl
+ return $
+ if parens
+ then toCite
+ . maybe id (\p -> alterFirst (prependPrefix p)) prefix
+ . maybe id (\s -> alterLast (appendSuffix s)) suffix
+ $ citationList
+ else maybe mempty (<> " ") prefix
+ <> (toListOfCites $ map toInTextMode citationList)
+ <> maybe mempty (", " <>) suffix
+ where
+ toCite :: [Citation] -> Inlines
+ toCite cs = B.cite cs mempty
+
+ toListOfCites :: [Citation] -> Inlines
+ toListOfCites = mconcat . intersperse ", " . map (\c -> B.cite [c] mempty)
+
+ toInTextMode :: Citation -> Citation
+ toInTextMode c = c { citationMode = AuthorInText }
+
+ alterFirst, alterLast :: (a -> a) -> [a] -> [a]
+ alterFirst _ [] = []
+ alterFirst f (c:cs) = (f c):cs
+ alterLast f = reverse . alterFirst f . reverse
+
+ prependPrefix, appendSuffix :: Inlines -> Citation -> Citation
+ prependPrefix pre c = c { citationPrefix = B.toList pre <> citationPrefix c }
+ appendSuffix suf c = c { citationSuffix = citationSuffix c <> B.toList suf }
+
+data BerkeleyCitationList = BerkeleyCitationList
+ { berkeleyCiteParens :: Bool
+ , berkeleyCiteCommonPrefix :: Maybe Inlines
+ , berkeleyCiteCommonSuffix :: Maybe Inlines
+ , berkeleyCiteCitations :: [Citation]
+ }
+berkeleyCitationList :: PandocMonad m => OrgParser m (F BerkeleyCitationList)
+berkeleyCitationList = try $ do
+ char '['
+ parens <- choice [ False <$ berkeleyBareTag, True <$ berkeleyParensTag ]
+ char ':'
+ skipSpaces
+ commonPrefix <- optionMaybe (try $ citationListPart <* char ';')
+ citations <- citeList
+ commonSuffix <- optionMaybe (try $ citationListPart)
+ char ']'
+ return (BerkeleyCitationList parens
+ <$> sequence commonPrefix
+ <*> sequence commonSuffix
+ <*> citations)
+ where
+ citationListPart :: PandocMonad m => OrgParser m (F Inlines)
+ citationListPart = fmap (trimInlinesF . mconcat) . try . many1 $ do
+ notFollowedBy' citeKey
+ notFollowedBy (oneOf ";]")
+ inline
+
+berkeleyBareTag :: PandocMonad m => OrgParser m ()
+berkeleyBareTag = try $ void berkeleyBareTag'
+
+berkeleyParensTag :: PandocMonad m => OrgParser m ()
+berkeleyParensTag = try . void $ enclosedByPair '(' ')' berkeleyBareTag'
+
+berkeleyBareTag' :: PandocMonad m => OrgParser m ()
+berkeleyBareTag' = try $ void (string "cite")
+
+berkeleyTextualCite :: PandocMonad m => OrgParser m (F [Citation])
+berkeleyTextualCite = try $ do
+ (suppressAuthor, key) <- citeKey
+ returnF . return $ Citation
+ { citationId = key
+ , citationPrefix = mempty
+ , citationSuffix = mempty
+ , citationMode = if suppressAuthor then SuppressAuthor else AuthorInText
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+
+-- The following is what a Berkeley-style bracketed textual citation parser
+-- would look like. However, as these citations are a subset of Pandoc's Org
+-- citation style, this isn't used.
+-- berkeleyBracketedTextualCite :: PandocMonad m => OrgParser m (F [Citation])
+-- berkeleyBracketedTextualCite = try . (fmap head) $
+-- enclosedByPair '[' ']' 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
+-- in the syntax.
+linkLikeOrgRefCite :: PandocMonad m => OrgParser m (F Citation)
+linkLikeOrgRefCite = try $ do
+ _ <- string "[["
+ mode <- orgRefCiteMode
+ key <- orgRefCiteKey
+ _ <- string "]["
+ pre <- trimInlinesF . mconcat <$> manyTill inline (try $ string "::")
+ spc <- option False (True <$ spaceChar)
+ suf <- trimInlinesF . mconcat <$> manyTill inline (try $ string "]]")
+ return $ do
+ pre' <- pre
+ suf' <- suf
+ return Citation
+ { citationId = key
+ , citationPrefix = B.toList pre'
+ , citationSuffix = B.toList (if spc then B.space <> suf' else suf')
+ , citationMode = mode
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+
+-- | Read a citation key. The characters allowed in citation keys are taken
+-- from the `org-ref-cite-re` variable in `org-ref.el`.
+orgRefCiteKey :: PandocMonad m => OrgParser m String
+orgRefCiteKey = try . many1 . satisfy $ \c ->
+ isAlphaNum c || c `elem` ("-_:\\./"::String)
+
+-- | Supported citation types. Only a small subset of org-ref types is
+-- supported for now. TODO: rewrite this, use LaTeX reader as template.
+orgRefCiteMode :: PandocMonad m => OrgParser m CitationMode
+orgRefCiteMode =
+ choice $ map (\(s, mode) -> mode <$ try (string s <* char ':'))
+ [ ("cite", AuthorInText)
+ , ("citep", NormalCitation)
+ , ("citep*", NormalCitation)
+ , ("citet", AuthorInText)
+ , ("citet*", AuthorInText)
+ , ("citeyear", SuppressAuthor)
+ ]
+
+citeList :: PandocMonad m => OrgParser m (F [Citation])
+citeList = sequence <$> sepEndBy1 citation (try $ char ';' *> skipSpaces)
+
+citation :: PandocMonad m => OrgParser m (F Citation)
+citation = try $ do
+ pref <- prefix
+ (suppress_author, key) <- citeKey
+ suff <- suffix
+ return $ do
+ x <- pref
+ y <- suff
+ return $ Citation{ citationId = key
+ , citationPrefix = B.toList x
+ , citationSuffix = B.toList y
+ , citationMode = if suppress_author
+ then SuppressAuthor
+ else NormalCitation
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+ where
+ prefix = trimInlinesF . mconcat <$>
+ manyTill inline (char ']' <|> (']' <$ lookAhead citeKey))
+ suffix = try $ do
+ hasSpace <- option False (notFollowedBy nonspaceChar >> return True)
+ skipSpaces
+ rest <- trimInlinesF . mconcat <$>
+ many (notFollowedBy (oneOf ";]") *> inline)
+ return $ if hasSpace
+ then (B.space <>) <$> rest
+ else rest
+
+footnote :: PandocMonad m => OrgParser m (F Inlines)
+footnote = try $ inlineNote <|> referencedNote
+
+inlineNote :: PandocMonad m => OrgParser m (F Inlines)
+inlineNote = try $ do
+ string "[fn:"
+ ref <- many alphaNum
+ char ':'
+ note <- fmap B.para . trimInlinesF . mconcat <$> many1Till inline (char ']')
+ when (not $ null ref) $
+ addToNotesTable ("fn:" ++ ref, note)
+ return $ B.note <$> note
+
+referencedNote :: PandocMonad m => OrgParser m (F Inlines)
+referencedNote = try $ do
+ ref <- noteMarker
+ return $ do
+ notes <- asksF orgStateNotes'
+ case lookup ref notes of
+ Nothing -> return $ B.str $ "[" ++ ref ++ "]"
+ Just contents -> do
+ st <- askF
+ let contents' = runF contents st{ orgStateNotes' = [] }
+ return $ B.note contents'
+
+linkOrImage :: PandocMonad m => OrgParser m (F Inlines)
+linkOrImage = explicitOrImageLink
+ <|> selflinkOrImage
+ <|> angleLink
+ <|> plainLink
+ <?> "link or image"
+
+explicitOrImageLink :: PandocMonad m => OrgParser m (F Inlines)
+explicitOrImageLink = try $ do
+ char '['
+ srcF <- applyCustomLinkFormat =<< possiblyEmptyLinkTarget
+ title <- enclosedRaw (char '[') (char ']')
+ title' <- parseFromString (mconcat <$> many inline) title
+ char ']'
+ return $ do
+ src <- srcF
+ case cleanLinkString title of
+ Just imgSrc | isImageFilename imgSrc ->
+ pure $ B.link src "" $ B.image imgSrc mempty mempty
+ _ ->
+ linkToInlinesF src =<< title'
+
+selflinkOrImage :: PandocMonad m => OrgParser m (F Inlines)
+selflinkOrImage = try $ do
+ src <- char '[' *> linkTarget <* char ']'
+ return $ linkToInlinesF src (B.str src)
+
+plainLink :: PandocMonad m => OrgParser m (F Inlines)
+plainLink = try $ do
+ (orig, src) <- uri
+ returnF $ B.link src "" (B.str orig)
+
+angleLink :: PandocMonad m => OrgParser m (F Inlines)
+angleLink = try $ do
+ char '<'
+ link <- plainLink
+ char '>'
+ return link
+
+linkTarget :: PandocMonad m => OrgParser m String
+linkTarget = enclosedByPair '[' ']' (noneOf "\n\r[]")
+
+possiblyEmptyLinkTarget :: PandocMonad m => OrgParser m String
+possiblyEmptyLinkTarget = try linkTarget <|> ("" <$ string "[]")
+
+applyCustomLinkFormat :: String -> OrgParser m (F String)
+applyCustomLinkFormat link = do
+ let (linkType, rest) = break (== ':') link
+ return $ do
+ formatter <- M.lookup linkType <$> asksF orgStateLinkFormatters
+ return $ maybe link ($ drop 1 rest) formatter
+
+-- | Take a link and return a function which produces new inlines when given
+-- description inlines.
+linkToInlinesF :: String -> Inlines -> F Inlines
+linkToInlinesF linkStr =
+ case linkStr of
+ "" -> pure . B.link mempty "" -- wiki link (empty by convention)
+ ('#':_) -> pure . B.link linkStr "" -- document-local fraction
+ _ -> case cleanLinkString linkStr of
+ (Just cleanedLink) -> if isImageFilename cleanedLink
+ then const . pure $ B.image cleanedLink "" ""
+ else pure . B.link cleanedLink ""
+ Nothing -> internalLink linkStr -- other internal link
+
+internalLink :: String -> Inlines -> F Inlines
+internalLink link title = do
+ anchorB <- (link `elem`) <$> asksF orgStateAnchorIds
+ if anchorB
+ then return $ B.link ('#':link) "" title
+ else return $ B.emph title
+
+-- | Parse an anchor like @<<anchor-id>>@ and return an empty span with
+-- @anchor-id@ set as id. Legal anchors in org-mode are defined through
+-- @org-target-regexp@, which is fairly liberal. Since no link is created if
+-- @anchor-id@ contains spaces, we are more restrictive in what is accepted as
+-- an anchor.
+
+anchor :: PandocMonad m => OrgParser m (F Inlines)
+anchor = try $ do
+ anchorId <- parseAnchor
+ recordAnchorId anchorId
+ returnF $ B.spanWith (solidify anchorId, [], []) mempty
+ where
+ parseAnchor = string "<<"
+ *> many1 (noneOf "\t\n\r<>\"' ")
+ <* string ">>"
+ <* skipSpaces
+
+-- | Replace every char but [a-zA-Z0-9_.-:] with a hypen '-'. This mirrors
+-- the org function @org-export-solidify-link-text@.
+
+solidify :: String -> String
+solidify = map replaceSpecialChar
+ where replaceSpecialChar c
+ | isAlphaNum c = c
+ | c `elem` ("_.-:" :: String) = c
+ | otherwise = '-'
+
+-- | Parses an inline code block and marks it as an babel block.
+inlineCodeBlock :: PandocMonad m => OrgParser m (F Inlines)
+inlineCodeBlock = try $ do
+ string "src_"
+ lang <- many1 orgArgWordChar
+ opts <- option [] $ enclosedByPair '[' ']' inlineBlockOption
+ inlineCode <- enclosedByPair '{' '}' (noneOf "\n\r")
+ let attrClasses = [translateLang lang, rundocBlockClass]
+ let attrKeyVal = map toRundocAttrib (("language", lang) : opts)
+ returnF $ B.codeWith ("", attrClasses, attrKeyVal) inlineCode
+ where
+ inlineBlockOption :: PandocMonad m => OrgParser m (String, String)
+ inlineBlockOption = try $ do
+ argKey <- orgArgKey
+ paramValue <- option "yes" orgInlineParamValue
+ return (argKey, paramValue)
+
+ orgInlineParamValue :: PandocMonad m => OrgParser m String
+ orgInlineParamValue = try $
+ skipSpaces
+ *> notFollowedBy (char ':')
+ *> many1 (noneOf "\t\n\r ]")
+ <* skipSpaces
+
+
+emphasizedText :: PandocMonad m => OrgParser m (F Inlines)
+emphasizedText = do
+ state <- getState
+ guard . exportEmphasizedText . orgStateExportSettings $ state
+ try $ choice
+ [ emph
+ , strong
+ , strikeout
+ , underline
+ ]
+
+enclosedByPair :: PandocMonad m
+ => Char -- ^ opening char
+ -> Char -- ^ closing char
+ -> OrgParser m a -- ^ parser
+ -> OrgParser m [a]
+enclosedByPair s e p = char s *> many1Till p (char e)
+
+emph :: PandocMonad m => OrgParser m (F Inlines)
+emph = fmap B.emph <$> emphasisBetween '/'
+
+strong :: PandocMonad m => OrgParser m (F Inlines)
+strong = fmap B.strong <$> emphasisBetween '*'
+
+strikeout :: PandocMonad m => OrgParser m (F Inlines)
+strikeout = fmap B.strikeout <$> emphasisBetween '+'
+
+-- There is no underline, so we use strong instead.
+underline :: PandocMonad m => OrgParser m (F Inlines)
+underline = fmap B.strong <$> emphasisBetween '_'
+
+verbatim :: PandocMonad m => OrgParser m (F Inlines)
+verbatim = return . B.code <$> verbatimBetween '='
+
+code :: PandocMonad m => OrgParser m (F Inlines)
+code = return . B.code <$> verbatimBetween '~'
+
+subscript :: PandocMonad m => OrgParser m (F Inlines)
+subscript = fmap B.subscript <$> try (char '_' *> subOrSuperExpr)
+
+superscript :: PandocMonad m => OrgParser m (F Inlines)
+superscript = fmap B.superscript <$> try (char '^' *> subOrSuperExpr)
+
+math :: PandocMonad m => OrgParser m (F Inlines)
+math = return . B.math <$> choice [ math1CharBetween '$'
+ , mathStringBetween '$'
+ , rawMathBetween "\\(" "\\)"
+ ]
+
+displayMath :: PandocMonad m => OrgParser m (F Inlines)
+displayMath = return . B.displayMath <$> choice [ rawMathBetween "\\[" "\\]"
+ , rawMathBetween "$$" "$$"
+ ]
+
+updatePositions :: PandocMonad m
+ => Char
+ -> OrgParser m Char
+updatePositions c = do
+ when (c `elem` emphasisPreChars) updateLastPreCharPos
+ when (c `elem` emphasisForbiddenBorderChars) updateLastForbiddenCharPos
+ return c
+
+symbol :: PandocMonad m => OrgParser m (F Inlines)
+symbol = return . B.str . (: "") <$> (oneOf specialChars >>= updatePositions)
+
+emphasisBetween :: PandocMonad m
+ => Char
+ -> OrgParser m (F Inlines)
+emphasisBetween c = try $ do
+ startEmphasisNewlinesCounting emphasisAllowedNewlines
+ res <- enclosedInlines (emphasisStart c) (emphasisEnd c)
+ isTopLevelEmphasis <- null . orgStateEmphasisCharStack <$> getState
+ when isTopLevelEmphasis
+ resetEmphasisNewlines
+ return res
+
+verbatimBetween :: PandocMonad m
+ => Char
+ -> OrgParser m String
+verbatimBetween c = try $
+ emphasisStart c *>
+ many1TillNOrLessNewlines 1 verbatimChar (emphasisEnd c)
+ where
+ verbatimChar = noneOf "\n\r" >>= updatePositions
+
+-- | Parses a raw string delimited by @c@ using Org's math rules
+mathStringBetween :: PandocMonad m
+ => Char
+ -> OrgParser m String
+mathStringBetween c = try $ do
+ mathStart c
+ body <- many1TillNOrLessNewlines mathAllowedNewlines
+ (noneOf (c:"\n\r"))
+ (lookAhead $ mathEnd c)
+ final <- mathEnd c
+ return $ body ++ [final]
+
+-- | Parse a single character between @c@ using math rules
+math1CharBetween :: PandocMonad m
+ => Char
+ -> OrgParser m String
+math1CharBetween c = try $ do
+ char c
+ res <- noneOf $ c:mathForbiddenBorderChars
+ char c
+ eof <|> () <$ lookAhead (oneOf mathPostChars)
+ return [res]
+
+rawMathBetween :: PandocMonad m
+ => String
+ -> String
+ -> OrgParser m String
+rawMathBetween s e = try $ string s *> manyTill anyChar (try $ string e)
+
+-- | Parses the start (opening character) of emphasis
+emphasisStart :: PandocMonad m => Char -> OrgParser m Char
+emphasisStart c = try $ do
+ guard =<< afterEmphasisPreChar
+ guard =<< notAfterString
+ char c
+ lookAhead (noneOf emphasisForbiddenBorderChars)
+ pushToInlineCharStack c
+ -- nested inlines are allowed, so mark this position as one which might be
+ -- followed by another inline.
+ updateLastPreCharPos
+ return c
+
+-- | Parses the closing character of emphasis
+emphasisEnd :: PandocMonad m => Char -> OrgParser m Char
+emphasisEnd c = try $ do
+ guard =<< notAfterForbiddenBorderChar
+ char c
+ eof <|> () <$ lookAhead acceptablePostChars
+ updateLastStrPos
+ popInlineCharStack
+ return c
+ where acceptablePostChars =
+ surroundingEmphasisChar >>= \x -> oneOf (x ++ emphasisPostChars)
+
+mathStart :: PandocMonad m => Char -> OrgParser m Char
+mathStart c = try $
+ char c <* notFollowedBy' (oneOf (c:mathForbiddenBorderChars))
+
+mathEnd :: PandocMonad m => Char -> OrgParser m Char
+mathEnd c = try $ do
+ res <- noneOf (c:mathForbiddenBorderChars)
+ char c
+ eof <|> () <$ lookAhead (oneOf mathPostChars)
+ return res
+
+
+enclosedInlines :: PandocMonad m => OrgParser m a
+ -> OrgParser m b
+ -> OrgParser m (F Inlines)
+enclosedInlines start end = try $
+ trimInlinesF . mconcat <$> enclosed start end inline
+
+enclosedRaw :: PandocMonad m => OrgParser m a
+ -> OrgParser m b
+ -> OrgParser m String
+enclosedRaw start end = try $
+ start *> (onSingleLine <|> spanningTwoLines)
+ where onSingleLine = try $ many1Till (noneOf "\n\r") end
+ spanningTwoLines = try $
+ anyLine >>= \f -> mappend (f <> " ") <$> onSingleLine
+
+-- | Like many1Till, but parses at most @n+1@ lines. @p@ must not consume
+-- newlines.
+many1TillNOrLessNewlines :: PandocMonad m => Int
+ -> OrgParser m Char
+ -> OrgParser m a
+ -> OrgParser m String
+many1TillNOrLessNewlines n p end = try $
+ nMoreLines (Just n) mempty >>= oneOrMore
+ where
+ nMoreLines Nothing cs = return cs
+ nMoreLines (Just 0) cs = try $ (cs ++) <$> finalLine
+ nMoreLines k cs = try $ (final k cs <|> rest k cs)
+ >>= uncurry nMoreLines
+ final _ cs = (\x -> (Nothing, cs ++ x)) <$> try finalLine
+ rest m cs = (\x -> (minus1 <$> m, cs ++ x ++ "\n")) <$> try (manyTill p newline)
+ finalLine = try $ manyTill p end
+ minus1 k = k - 1
+ oneOrMore cs = guard (not $ null cs) *> return cs
+
+-- Org allows customization of the way it reads emphasis. We use the defaults
+-- here (see, e.g., the Emacs Lisp variable `org-emphasis-regexp-components`
+-- for details).
+
+-- | Chars allowed to occur before emphasis (spaces and newlines are ok, too)
+emphasisPreChars :: [Char]
+emphasisPreChars = "\t \"'({"
+
+-- | Chars allowed at after emphasis
+emphasisPostChars :: [Char]
+emphasisPostChars = "\t\n !\"'),-.:;?\\}"
+
+-- | Chars not allowed at the (inner) border of emphasis
+emphasisForbiddenBorderChars :: [Char]
+emphasisForbiddenBorderChars = "\t\n\r \"',"
+
+-- | The maximum number of newlines within
+emphasisAllowedNewlines :: Int
+emphasisAllowedNewlines = 1
+
+-- LaTeX-style math: see `org-latex-regexps` for details
+
+-- | Chars allowed after an inline ($...$) math statement
+mathPostChars :: [Char]
+mathPostChars = "\t\n \"'),-.:;?"
+
+-- | Chars not allowed at the (inner) border of math
+mathForbiddenBorderChars :: [Char]
+mathForbiddenBorderChars = "\t\n\r ,;.$"
+
+-- | Maximum number of newlines in an inline math statement
+mathAllowedNewlines :: Int
+mathAllowedNewlines = 2
+
+-- | Whether we are right behind a char allowed before emphasis
+afterEmphasisPreChar :: PandocMonad m => OrgParser m Bool
+afterEmphasisPreChar = do
+ pos <- getPosition
+ lastPrePos <- orgStateLastPreCharPos <$> getState
+ return . fromMaybe True $ (== pos) <$> lastPrePos
+
+-- | Whether the parser is right after a forbidden border char
+notAfterForbiddenBorderChar :: PandocMonad m => OrgParser m Bool
+notAfterForbiddenBorderChar = do
+ pos <- getPosition
+ lastFBCPos <- orgStateLastForbiddenCharPos <$> getState
+ return $ lastFBCPos /= Just pos
+
+-- | Read a sub- or superscript expression
+subOrSuperExpr :: PandocMonad m => OrgParser m (F Inlines)
+subOrSuperExpr = try $
+ choice [ id <$> charsInBalanced '{' '}' (noneOf "\n\r")
+ , enclosing ('(', ')') <$> charsInBalanced '(' ')' (noneOf "\n\r")
+ , simpleSubOrSuperString
+ ] >>= parseFromString (mconcat <$> many inline)
+ where enclosing (left, right) s = left : s ++ [right]
+
+simpleSubOrSuperString :: PandocMonad m => OrgParser m String
+simpleSubOrSuperString = try $ do
+ state <- getState
+ guard . exportSubSuperscripts . orgStateExportSettings $ state
+ choice [ string "*"
+ , mappend <$> option [] ((:[]) <$> oneOf "+-")
+ <*> many1 alphaNum
+ ]
+
+inlineLaTeX :: PandocMonad m => OrgParser m (F Inlines)
+inlineLaTeX = try $ do
+ cmd <- inlineLaTeXCommand
+ ils <- (lift . lift) $ parseAsInlineLaTeX cmd
+ maybe mzero returnF $
+ parseAsMath cmd `mplus` parseAsMathMLSym cmd `mplus` ils
+ where
+ parseAsMath :: String -> Maybe Inlines
+ parseAsMath cs = B.fromList <$> texMathToPandoc cs
+
+ parseAsInlineLaTeX :: PandocMonad m => String -> m (Maybe Inlines)
+ parseAsInlineLaTeX cs = maybeRight <$> runParserT inlineCommand state "" cs
+
+ parseAsMathMLSym :: String -> Maybe Inlines
+ parseAsMathMLSym cs = B.str <$> MathMLEntityMap.getUnicode (clean cs)
+ -- drop initial backslash and any trailing "{}"
+ where clean = dropWhileEnd (`elem` ("{}" :: String)) . drop 1
+
+ state :: ParserState
+ state = def{ stateOptions = def{ readerExtensions =
+ enableExtension Ext_raw_tex (readerExtensions def) } }
+
+ texMathToPandoc :: String -> Maybe [Inline]
+ texMathToPandoc cs = (maybeRight $ readTeX cs) >>= writePandoc DisplayInline
+
+maybeRight :: Either a b -> Maybe b
+maybeRight = either (const Nothing) Just
+
+inlineLaTeXCommand :: PandocMonad m => OrgParser m String
+inlineLaTeXCommand = try $ do
+ rest <- getInput
+ parsed <- (lift . lift) $ runParserT rawLaTeXInline def "source" rest
+ case parsed of
+ Right (RawInline _ cs) -> do
+ -- drop any trailing whitespace, those are not be part of the command as
+ -- far as org mode is concerned.
+ let cmdNoSpc = dropWhileEnd isSpace cs
+ let len = length cmdNoSpc
+ count len anyChar
+ return cmdNoSpc
+ _ -> mzero
+
+-- Taken from Data.OldList.
+dropWhileEnd :: (a -> Bool) -> [a] -> [a]
+dropWhileEnd p = foldr (\x xs -> if p x && null xs then [] else x : xs) []
+
+exportSnippet :: PandocMonad m => OrgParser m (F Inlines)
+exportSnippet = try $ do
+ string "@@"
+ format <- many1Till (alphaNum <|> char '-') (char ':')
+ snippet <- manyTill anyChar (try $ string "@@")
+ returnF $ B.rawInline format snippet
+
+smart :: PandocMonad m => OrgParser m (F Inlines)
+smart = do
+ guardEnabled Ext_smart
+ doubleQuoted <|> singleQuoted <|>
+ choice (map (return <$>) [orgApostrophe, orgDash, orgEllipses])
+ where
+ orgDash = do
+ guard =<< getExportSetting exportSpecialStrings
+ dash <* updatePositions '-'
+ orgEllipses = do
+ guard =<< getExportSetting exportSpecialStrings
+ ellipses <* updatePositions '.'
+ orgApostrophe =
+ (char '\'' <|> char '\8217') <* updateLastPreCharPos
+ <* updateLastForbiddenCharPos
+ *> return (B.str "\x2019")
+
+singleQuoted :: PandocMonad m => OrgParser m (F Inlines)
+singleQuoted = try $ do
+ guard =<< getExportSetting exportSmartQuotes
+ singleQuoteStart
+ updatePositions '\''
+ withQuoteContext InSingleQuote $
+ fmap B.singleQuoted . trimInlinesF . mconcat <$>
+ many1Till inline (singleQuoteEnd <* updatePositions '\'')
+
+-- doubleQuoted will handle regular double-quoted sections, as well
+-- as dialogues with an open double-quote without a close double-quote
+-- in the same paragraph.
+doubleQuoted :: PandocMonad m => OrgParser m (F Inlines)
+doubleQuoted = try $ do
+ guard =<< getExportSetting exportSmartQuotes
+ doubleQuoteStart
+ updatePositions '"'
+ contents <- mconcat <$> many (try $ notFollowedBy doubleQuoteEnd >> inline)
+ (withQuoteContext InDoubleQuote $ (doubleQuoteEnd <* updateLastForbiddenCharPos) >> return
+ (fmap B.doubleQuoted . trimInlinesF $ contents))
+ <|> (return $ return (B.str "\8220") <> contents)
diff --git a/src/Text/Pandoc/Readers/Org/Meta.hs b/src/Text/Pandoc/Readers/Org/Meta.hs
new file mode 100644
index 000000000..2f4e21248
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Org/Meta.hs
@@ -0,0 +1,218 @@
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE TupleSections #-}
+{-
+Copyright (C) 2014-2017 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.Readers.Org.Meta
+ Copyright : Copyright (C) 2014-2017 Albert Krewinkel
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
+
+Parsers for Org-mode meta declarations.
+-}
+module Text.Pandoc.Readers.Org.Meta
+ ( metaExport
+ , metaKey
+ , metaLine
+ ) where
+
+import Text.Pandoc.Readers.Org.BlockStarts
+import Text.Pandoc.Readers.Org.ExportSettings ( exportSettings )
+import Text.Pandoc.Readers.Org.Inlines
+import Text.Pandoc.Readers.Org.ParserState
+import Text.Pandoc.Readers.Org.Parsing
+
+import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.Builder ( Blocks, Inlines )
+import Text.Pandoc.Class ( PandocMonad )
+import Text.Pandoc.Definition
+
+import Control.Monad ( mzero, void )
+import Data.Char ( toLower )
+import Data.List ( intersperse )
+import qualified Data.Map as M
+import Data.Monoid ( (<>) )
+import Network.HTTP ( urlEncode )
+
+-- | Returns the current meta, respecting export options.
+metaExport :: Monad m => OrgParser m (F Meta)
+metaExport = do
+ st <- getState
+ let settings = orgStateExportSettings st
+ return $ (if exportWithAuthor settings then id else removeMeta "author")
+ . (if exportWithCreator settings then id else removeMeta "creator")
+ . (if exportWithEmail settings then id else removeMeta "email")
+ <$> orgStateMeta st
+
+removeMeta :: String -> Meta -> Meta
+removeMeta key meta' =
+ let metaMap = unMeta meta'
+ in Meta $ M.delete key metaMap
+
+-- | Parse and handle a single line containing meta information
+-- The order, in which blocks are tried, makes sure that we're not looking at
+-- the beginning of a block, so we don't need to check for it
+metaLine :: PandocMonad m => OrgParser m Blocks
+metaLine = mempty <$ metaLineStart <* (optionLine <|> declarationLine)
+
+declarationLine :: PandocMonad m => OrgParser m ()
+declarationLine = try $ do
+ key <- map toLower <$> metaKey
+ (key', value) <- metaValue key
+ updateState $ \st ->
+ let meta' = B.setMeta key' <$> value <*> pure nullMeta
+ in st { orgStateMeta = meta' <> orgStateMeta st }
+
+metaKey :: Monad m => OrgParser m String
+metaKey = map toLower <$> many1 (noneOf ": \n\r")
+ <* char ':'
+ <* skipSpaces
+
+metaValue :: PandocMonad m => String -> OrgParser m (String, (F MetaValue))
+metaValue key =
+ let inclKey = "header-includes"
+ in case key of
+ "author" -> (key,) <$> metaInlinesCommaSeparated
+ "title" -> (key,) <$> metaInlines
+ "date" -> (key,) <$> metaInlines
+ "header-includes" -> (key,) <$> accumulatingList key metaInlines
+ "latex_header" -> (inclKey,) <$>
+ accumulatingList inclKey (metaExportSnippet "latex")
+ "latex_class" -> ("documentclass",) <$> metaString
+ -- Org-mode expects class options to contain the surrounding brackets,
+ -- pandoc does not.
+ "latex_class_options" -> ("classoption",) <$>
+ metaModifiedString (filter (`notElem` "[]"))
+ "html_head" -> (inclKey,) <$>
+ accumulatingList inclKey (metaExportSnippet "html")
+ _ -> (key,) <$> metaString
+
+metaInlines :: PandocMonad m => OrgParser m (F MetaValue)
+metaInlines = fmap (MetaInlines . B.toList) <$> inlinesTillNewline
+
+metaInlinesCommaSeparated :: PandocMonad m => OrgParser m (F MetaValue)
+metaInlinesCommaSeparated = do
+ authStrs <- (many1 (noneOf ",\n")) `sepBy1` (char ',')
+ newline
+ authors <- mapM (parseFromString inlinesTillNewline . (++ "\n")) authStrs
+ let toMetaInlines = MetaInlines . B.toList
+ return $ MetaList . map toMetaInlines <$> sequence authors
+
+metaString :: Monad m => OrgParser m (F MetaValue)
+metaString = metaModifiedString id
+
+metaModifiedString :: Monad m => (String -> String) -> OrgParser m (F MetaValue)
+metaModifiedString f = return . MetaString . f <$> anyLine
+
+-- | Read an format specific meta definition
+metaExportSnippet :: Monad m => String -> OrgParser m (F MetaValue)
+metaExportSnippet format =
+ return . MetaInlines . B.toList . B.rawInline format <$> anyLine
+
+-- | Accumulate the result of the @parser@ in a list under @key@.
+accumulatingList :: Monad m => String
+ -> OrgParser m (F MetaValue)
+ -> OrgParser m (F MetaValue)
+accumulatingList key p = do
+ value <- p
+ meta' <- orgStateMeta <$> getState
+ return $ (\m v -> MetaList (curList m ++ [v])) <$> meta' <*> value
+ where curList m = case lookupMeta key m of
+ Just (MetaList ms) -> ms
+ Just x -> [x]
+ _ -> []
+
+--
+-- export options
+--
+optionLine :: Monad m => OrgParser m ()
+optionLine = try $ do
+ key <- metaKey
+ case key of
+ "link" -> parseLinkFormat >>= uncurry addLinkFormat
+ "options" -> exportSettings
+ "todo" -> todoSequence >>= updateState . registerTodoSequence
+ "seq_todo" -> todoSequence >>= updateState . registerTodoSequence
+ "typ_todo" -> todoSequence >>= updateState . registerTodoSequence
+ _ -> mzero
+
+addLinkFormat :: Monad m => String
+ -> (String -> String)
+ -> OrgParser m ()
+addLinkFormat key formatter = updateState $ \s ->
+ let fs = orgStateLinkFormatters s
+ in s{ orgStateLinkFormatters = M.insert key formatter fs }
+
+parseLinkFormat :: Monad m => OrgParser m ((String, String -> String))
+parseLinkFormat = try $ do
+ linkType <- (:) <$> letter <*> many (alphaNum <|> oneOf "-_") <* skipSpaces
+ linkSubst <- parseFormat
+ return (linkType, linkSubst)
+
+-- | An ad-hoc, single-argument-only implementation of a printf-style format
+-- parser.
+parseFormat :: Monad m => OrgParser m (String -> String)
+parseFormat = try $ do
+ replacePlain <|> replaceUrl <|> justAppend
+ where
+ -- inefficient, but who cares
+ replacePlain = try $ (\x -> concat . flip intersperse x)
+ <$> sequence [tillSpecifier 's', rest]
+ replaceUrl = try $ (\x -> concat . flip intersperse x . urlEncode)
+ <$> sequence [tillSpecifier 'h', rest]
+ justAppend = try $ (++) <$> rest
+
+ rest = manyTill anyChar (eof <|> () <$ oneOf "\n\r")
+ tillSpecifier c = manyTill (noneOf "\n\r") (try $ string ('%':c:""))
+
+inlinesTillNewline :: PandocMonad m => OrgParser m (F Inlines)
+inlinesTillNewline = trimInlinesF . mconcat <$> manyTill inline newline
+
+--
+-- ToDo Sequences and Keywords
+--
+todoSequence :: Monad m => OrgParser m TodoSequence
+todoSequence = try $ do
+ todoKws <- todoKeywords
+ doneKws <- optionMaybe $ todoDoneSep *> todoKeywords
+ newline
+ -- There must be at least one DONE keyword. The last TODO keyword is taken if
+ -- necessary.
+ case doneKws of
+ Just done -> return $ keywordsToSequence todoKws done
+ Nothing -> case reverse todoKws of
+ [] -> mzero -- no keywords present
+ (x:xs) -> return $ keywordsToSequence (reverse xs) [x]
+
+ where
+ todoKeywords :: Monad m => OrgParser m [String]
+ todoKeywords = try $
+ let keyword = many1 nonspaceChar <* skipSpaces
+ endOfKeywords = todoDoneSep <|> void newline
+ in manyTill keyword (lookAhead endOfKeywords)
+
+ todoDoneSep :: Monad m => OrgParser m ()
+ todoDoneSep = void . try $ skipSpaces *> char '|' <* skipSpaces1
+
+ keywordsToSequence :: [String] -> [String] -> TodoSequence
+ keywordsToSequence todo done =
+ let todoMarkers = map (TodoMarker Todo) todo
+ doneMarkers = map (TodoMarker Done) done
+ in todoMarkers ++ doneMarkers
diff --git a/src/Text/Pandoc/Readers/Org/ParserState.hs b/src/Text/Pandoc/Readers/Org/ParserState.hs
new file mode 100644
index 000000000..181dd1d5c
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Org/ParserState.hs
@@ -0,0 +1,259 @@
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-
+Copyright (C) 2014-2016 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.Readers.Org.Options
+ Copyright : Copyright (C) 2014-2016 Albert Krewinkel
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
+
+Define the Org-mode parser state.
+-}
+module Text.Pandoc.Readers.Org.ParserState
+ ( OrgParserState (..)
+ , OrgParserLocal (..)
+ , OrgNoteRecord
+ , HasReaderOptions (..)
+ , HasQuoteContext (..)
+ , TodoMarker (..)
+ , TodoSequence
+ , TodoState (..)
+ , activeTodoMarkers
+ , registerTodoSequence
+ , F(..)
+ , askF
+ , asksF
+ , trimInlinesF
+ , runF
+ , returnF
+ , ExportSettings (..)
+ , ArchivedTreesOption (..)
+ , optionsToParserState
+ ) where
+
+import Control.Monad (liftM, liftM2)
+import Control.Monad.Reader (Reader, runReader, ReaderT, ask, asks, local)
+
+import Data.Default (Default(..))
+import qualified Data.Map as M
+import qualified Data.Set as Set
+
+import Text.Pandoc.Builder ( Inlines, Blocks, trimInlines )
+import Text.Pandoc.Definition ( Meta(..), nullMeta )
+import Text.Pandoc.Options ( ReaderOptions(..) )
+import Text.Pandoc.Parsing ( HasHeaderMap(..)
+ , HasIdentifierList(..)
+ , HasLastStrPosition(..)
+ , HasQuoteContext(..)
+ , HasReaderOptions(..)
+ , ParserContext(..)
+ , QuoteContext(..)
+ , SourcePos )
+
+-- | An inline note / footnote containing the note key and its (inline) value.
+type OrgNoteRecord = (String, F Blocks)
+-- | Table of footnotes
+type OrgNoteTable = [OrgNoteRecord]
+-- | Map of functions for link transformations. The map key is refers to the
+-- link-type, the corresponding function transforms the given link string.
+type OrgLinkFormatters = M.Map String (String -> String)
+
+-- | The states in which a todo item can be
+data TodoState = Todo | Done
+ deriving (Eq, Ord, Show)
+
+-- | A ToDo keyword like @TODO@ or @DONE@.
+data TodoMarker = TodoMarker
+ { todoMarkerState :: TodoState
+ , todoMarkerName :: String
+ }
+ deriving (Show, Eq)
+
+-- | Collection of todo markers in the order in which items should progress
+type TodoSequence = [TodoMarker]
+
+-- | Org-mode parser state
+data OrgParserState = OrgParserState
+ { orgStateAnchorIds :: [String]
+ , orgStateEmphasisCharStack :: [Char]
+ , orgStateEmphasisNewlines :: Maybe Int
+ , orgStateExportSettings :: ExportSettings
+ , orgStateHeaderMap :: M.Map Inlines String
+ , orgStateIdentifiers :: Set.Set String
+ , orgStateLastForbiddenCharPos :: Maybe SourcePos
+ , orgStateLastPreCharPos :: Maybe SourcePos
+ , orgStateLastStrPos :: Maybe SourcePos
+ , orgStateLinkFormatters :: OrgLinkFormatters
+ , orgStateMeta :: F Meta
+ , orgStateNotes' :: OrgNoteTable
+ , orgStateOptions :: ReaderOptions
+ , orgStateParserContext :: ParserContext
+ , orgStateTodoSequences :: [TodoSequence]
+ }
+
+data OrgParserLocal = OrgParserLocal { orgLocalQuoteContext :: QuoteContext }
+
+instance Default OrgParserLocal where
+ def = OrgParserLocal NoQuote
+
+instance HasReaderOptions OrgParserState where
+ extractReaderOptions = orgStateOptions
+
+instance HasLastStrPosition OrgParserState where
+ getLastStrPos = orgStateLastStrPos
+ setLastStrPos pos st = st{ orgStateLastStrPos = Just pos }
+
+instance Monad m => HasQuoteContext st (ReaderT OrgParserLocal m) where
+ getQuoteContext = asks orgLocalQuoteContext
+ withQuoteContext q = local (\s -> s{orgLocalQuoteContext = q})
+
+instance HasIdentifierList OrgParserState where
+ extractIdentifierList = orgStateIdentifiers
+ updateIdentifierList f s = s{ orgStateIdentifiers = f (orgStateIdentifiers s) }
+
+instance HasHeaderMap OrgParserState where
+ extractHeaderMap = orgStateHeaderMap
+ updateHeaderMap f s = s{ orgStateHeaderMap = f (orgStateHeaderMap s) }
+
+instance Default OrgParserState where
+ def = defaultOrgParserState
+
+defaultOrgParserState :: OrgParserState
+defaultOrgParserState = OrgParserState
+ { orgStateAnchorIds = []
+ , orgStateEmphasisCharStack = []
+ , orgStateEmphasisNewlines = Nothing
+ , orgStateExportSettings = def
+ , orgStateHeaderMap = M.empty
+ , orgStateIdentifiers = Set.empty
+ , orgStateLastForbiddenCharPos = Nothing
+ , orgStateLastPreCharPos = Nothing
+ , orgStateLastStrPos = Nothing
+ , orgStateLinkFormatters = M.empty
+ , orgStateMeta = return nullMeta
+ , orgStateNotes' = []
+ , orgStateOptions = def
+ , orgStateParserContext = NullState
+ , orgStateTodoSequences = []
+ }
+
+optionsToParserState :: ReaderOptions -> OrgParserState
+optionsToParserState opts =
+ def { orgStateOptions = opts }
+
+registerTodoSequence :: TodoSequence -> OrgParserState -> OrgParserState
+registerTodoSequence todoSeq st =
+ let curSeqs = orgStateTodoSequences st
+ in st{ orgStateTodoSequences = todoSeq : curSeqs }
+
+-- | Get the current todo/done sequences. If no custom todo sequences have been
+-- defined, return a list containing just the default todo/done sequence.
+activeTodoSequences :: OrgParserState -> [TodoSequence]
+activeTodoSequences st =
+ let curSeqs = orgStateTodoSequences st
+ in if null curSeqs
+ then [[ TodoMarker Todo "TODO" , TodoMarker Done "DONE" ]]
+ else curSeqs
+
+activeTodoMarkers :: OrgParserState -> TodoSequence
+activeTodoMarkers = concat . activeTodoSequences
+
+
+--
+-- Export Settings
+--
+
+-- | Options for the way archived trees are handled.
+data ArchivedTreesOption =
+ ArchivedTreesExport -- ^ Export the complete tree
+ | ArchivedTreesNoExport -- ^ Exclude archived trees from exporting
+ | ArchivedTreesHeadlineOnly -- ^ Export only the headline, discard the contents
+
+-- | Export settings <http://orgmode.org/manual/Export-settings.html>
+-- These settings can be changed via OPTIONS statements.
+data ExportSettings = ExportSettings
+ { exportArchivedTrees :: ArchivedTreesOption -- ^ How to treat archived trees
+ , exportDrawers :: Either [String] [String]
+ -- ^ Specify drawer names which should be exported. @Left@ names are
+ -- explicitly excluded from the resulting output while @Right@ means that
+ -- only the listed drawer names should be included.
+ , exportEmphasizedText :: Bool -- ^ Parse emphasized text
+ , exportHeadlineLevels :: Int
+ -- ^ Maximum depth of headlines, deeper headlines are convert to list
+ , exportSmartQuotes :: Bool -- ^ Parse quotes smartly
+ , exportSpecialStrings :: Bool -- ^ Parse ellipses and dashes smartly
+ , exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts
+ , exportWithAuthor :: Bool -- ^ Include author in final meta-data
+ , exportWithCreator :: Bool -- ^ Include creator in final meta-data
+ , exportWithEmail :: Bool -- ^ Include email in final meta-data
+ , exportWithTodoKeywords :: Bool -- ^ Keep TODO keywords in headers
+ }
+
+instance Default ExportSettings where
+ def = defaultExportSettings
+
+defaultExportSettings :: ExportSettings
+defaultExportSettings = ExportSettings
+ { exportArchivedTrees = ArchivedTreesHeadlineOnly
+ , exportDrawers = Left ["LOGBOOK"]
+ , exportEmphasizedText = True
+ , exportHeadlineLevels = 3
+ , exportSmartQuotes = True
+ , exportSpecialStrings = True
+ , exportSubSuperscripts = True
+ , exportWithAuthor = True
+ , exportWithCreator = True
+ , exportWithEmail = True
+ , exportWithTodoKeywords = True
+ }
+
+
+--
+-- Parser state reader
+--
+
+-- | Reader monad wrapping the parser state. This is used to delay evaluation
+-- until all relevant information has been parsed and made available in the
+-- parser state. See also the newtype of the same name in
+-- Text.Pandoc.Parsing.
+newtype F a = F { unF :: Reader OrgParserState a
+ } deriving (Functor, Applicative, Monad)
+
+instance Monoid a => Monoid (F a) where
+ mempty = return mempty
+ mappend = liftM2 mappend
+ mconcat = fmap mconcat . sequence
+
+runF :: F a -> OrgParserState -> a
+runF = runReader . unF
+
+askF :: F OrgParserState
+askF = F ask
+
+asksF :: (OrgParserState -> a) -> F a
+asksF f = F $ asks f
+
+trimInlinesF :: F Inlines -> F Inlines
+trimInlinesF = liftM trimInlines
+
+returnF :: Monad m => a -> m (F a)
+returnF = return . return
diff --git a/src/Text/Pandoc/Readers/Org/Parsing.hs b/src/Text/Pandoc/Readers/Org/Parsing.hs
new file mode 100644
index 000000000..1eb8a3b00
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Org/Parsing.hs
@@ -0,0 +1,217 @@
+{-
+Copyright (C) 2014-2016 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.Readers.Org.Options
+ Copyright : Copyright (C) 2014-2016 Albert Krewinkel
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
+
+Org-mode parsing utilities.
+
+Most functions are simply re-exports from @Text.Pandoc.Parsing@, some
+functions are adapted to Org-mode specific functionality.
+-}
+module Text.Pandoc.Readers.Org.Parsing
+ ( OrgParser
+ , anyLine
+ , blanklines
+ , newline
+ , parseFromString
+ , skipSpaces1
+ , inList
+ , withContext
+ , getExportSetting
+ , updateLastForbiddenCharPos
+ , updateLastPreCharPos
+ , orgArgKey
+ , orgArgWord
+ , orgArgWordChar
+ -- * Re-exports from Text.Pandoc.Parser
+ , ParserContext (..)
+ , many1Till
+ , notFollowedBy'
+ , spaceChar
+ , nonspaceChar
+ , skipSpaces
+ , blankline
+ , enclosed
+ , stringAnyCase
+ , charsInBalanced
+ , uri
+ , withRaw
+ , readWithM
+ , guardEnabled
+ , updateLastStrPos
+ , notAfterString
+ , ParserState (..)
+ , registerHeader
+ , QuoteContext (..)
+ , singleQuoteStart
+ , singleQuoteEnd
+ , doubleQuoteStart
+ , doubleQuoteEnd
+ , dash
+ , ellipses
+ , citeKey
+ -- * Re-exports from Text.Pandoc.Parsec
+ , runParser
+ , runParserT
+ , getInput
+ , char
+ , letter
+ , digit
+ , alphaNum
+ , skipMany1
+ , spaces
+ , anyChar
+ , satisfy
+ , string
+ , count
+ , eof
+ , noneOf
+ , oneOf
+ , lookAhead
+ , notFollowedBy
+ , many
+ , many1
+ , manyTill
+ , (<|>)
+ , (<?>)
+ , choice
+ , try
+ , sepBy
+ , sepBy1
+ , sepEndBy1
+ , option
+ , optional
+ , optionMaybe
+ , getState
+ , updateState
+ , SourcePos
+ , getPosition
+ ) where
+
+import Text.Pandoc.Readers.Org.ParserState
+
+import qualified Text.Pandoc.Parsing as P
+import Text.Pandoc.Parsing hiding ( anyLine, blanklines, newline
+ , parseFromString )
+
+import Control.Monad ( guard )
+import Control.Monad.Reader ( ReaderT )
+
+-- | The parser used to read org files.
+type OrgParser m = ParserT [Char] OrgParserState (ReaderT OrgParserLocal m)
+
+--
+-- Adaptions and specializations of parsing utilities
+--
+
+-- | Parse any line of text
+anyLine :: Monad m => OrgParser m String
+anyLine =
+ P.anyLine
+ <* updateLastPreCharPos
+ <* updateLastForbiddenCharPos
+
+-- The version Text.Pandoc.Parsing cannot be used, as we need additional parts
+-- of the state saved and restored.
+parseFromString :: Monad m => OrgParser m a -> String -> OrgParser m a
+parseFromString parser str' = do
+ oldLastPreCharPos <- orgStateLastPreCharPos <$> getState
+ updateState $ \s -> s{ orgStateLastPreCharPos = Nothing }
+ result <- P.parseFromString parser str'
+ updateState $ \s -> s{ orgStateLastPreCharPos = oldLastPreCharPos }
+ return result
+
+-- | Skip one or more tab or space characters.
+skipSpaces1 :: Monad m => OrgParser m ()
+skipSpaces1 = skipMany1 spaceChar
+
+-- | Like @Text.Parsec.Char.newline@, but causes additional state changes.
+newline :: Monad m => OrgParser m Char
+newline =
+ P.newline
+ <* updateLastPreCharPos
+ <* updateLastForbiddenCharPos
+
+-- | Like @Text.Parsec.Char.blanklines@, but causes additional state changes.
+blanklines :: Monad m => OrgParser m [Char]
+blanklines =
+ P.blanklines
+ <* updateLastPreCharPos
+ <* updateLastForbiddenCharPos
+
+-- | Succeeds when we're in list context.
+inList :: Monad m => OrgParser m ()
+inList = do
+ ctx <- orgStateParserContext <$> getState
+ guard (ctx == ListItemState)
+
+-- | Parse in different context
+withContext :: Monad m
+ => ParserContext -- ^ New parser context
+ -> OrgParser m a -- ^ Parser to run in that context
+ -> OrgParser m a
+withContext context parser = do
+ oldContext <- orgStateParserContext <$> getState
+ updateState $ \s -> s{ orgStateParserContext = context }
+ result <- parser
+ updateState $ \s -> s{ orgStateParserContext = oldContext }
+ return result
+
+--
+-- Parser state functions
+--
+
+-- | Get an export setting.
+getExportSetting :: Monad m => (ExportSettings -> a) -> OrgParser m a
+getExportSetting s = s . orgStateExportSettings <$> getState
+
+-- | Set the current position as the last position at which a forbidden char
+-- was found (i.e. a character which is not allowed at the inner border of
+-- markup).
+updateLastForbiddenCharPos :: Monad m => OrgParser m ()
+updateLastForbiddenCharPos = getPosition >>= \p ->
+ updateState $ \s -> s{ orgStateLastForbiddenCharPos = Just p}
+
+-- | Set the current parser position as the position at which a character was
+-- seen which allows inline markup to follow.
+updateLastPreCharPos :: Monad m => OrgParser m ()
+updateLastPreCharPos = getPosition >>= \p ->
+ updateState $ \s -> s{ orgStateLastPreCharPos = Just p}
+
+--
+-- Org key-value parsing
+--
+
+-- | Read the key of a plist style key-value list.
+orgArgKey :: Monad m => OrgParser m String
+orgArgKey = try $
+ skipSpaces *> char ':'
+ *> many1 orgArgWordChar
+
+-- | Read the value of a plist style key-value list.
+orgArgWord :: Monad m => OrgParser m String
+orgArgWord = many1 orgArgWordChar
+
+-- | Chars treated as part of a word in plists.
+orgArgWordChar :: Monad m => OrgParser m Char
+orgArgWordChar = alphaNum <|> oneOf "-_"
diff --git a/src/Text/Pandoc/Readers/Org/Shared.hs b/src/Text/Pandoc/Readers/Org/Shared.hs
new file mode 100644
index 000000000..8c87cfa25
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Org/Shared.hs
@@ -0,0 +1,97 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-
+Copyright (C) 2014-2016 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.Readers.Org.Options
+ Copyright : Copyright (C) 2014-2016 Albert Krewinkel
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
+
+Utility functions used in other Pandoc Org modules.
+-}
+module Text.Pandoc.Readers.Org.Shared
+ ( cleanLinkString
+ , isImageFilename
+ , rundocBlockClass
+ , toRundocAttrib
+ , translateLang
+ ) where
+
+import Control.Arrow ( first )
+import Data.Char ( isAlphaNum )
+import Data.List ( isPrefixOf, isSuffixOf )
+
+
+-- | Check whether the given string looks like the path to of URL of an image.
+isImageFilename :: String -> Bool
+isImageFilename filename =
+ any (\x -> ('.':x) `isSuffixOf` filename) imageExtensions &&
+ (any (\x -> (x ++ "://") `isPrefixOf` filename) protocols ||
+ ':' `notElem` filename)
+ where
+ imageExtensions = [ "jpeg" , "jpg" , "png" , "gif" , "svg" ]
+ protocols = [ "file", "http", "https" ]
+
+-- | Cleanup and canonicalize a string describing a link. Return @Nothing@ if
+-- the string does not appear to be a link.
+cleanLinkString :: String -> Maybe String
+cleanLinkString s =
+ case s of
+ '/':_ -> Just $ "file://" ++ s -- absolute path
+ '.':'/':_ -> Just s -- relative path
+ '.':'.':'/':_ -> Just s -- relative path
+ -- Relative path or URL (file schema)
+ 'f':'i':'l':'e':':':s' -> Just $ if ("//" `isPrefixOf` s') then s else s'
+ _ | isUrl s -> Just s -- URL
+ _ -> Nothing
+ where
+ isUrl :: String -> Bool
+ isUrl cs =
+ let (scheme, path) = break (== ':') cs
+ in all (\c -> isAlphaNum c || c `elem` (".-"::String)) scheme
+ && not (null path)
+
+-- | Prefix used for Rundoc classes and arguments.
+rundocPrefix :: String
+rundocPrefix = "rundoc-"
+
+-- | The class-name used to mark rundoc blocks.
+rundocBlockClass :: String
+rundocBlockClass = rundocPrefix ++ "block"
+
+-- | Prefix the name of a attribute, marking it as a code execution parameter.
+toRundocAttrib :: (String, String) -> (String, String)
+toRundocAttrib = first (rundocPrefix ++)
+
+-- | Translate from Org-mode's programming language identifiers to those used
+-- by Pandoc. This is useful to allow for proper syntax highlighting in
+-- Pandoc output.
+translateLang :: String -> String
+translateLang cs =
+ case cs of
+ "C" -> "c"
+ "C++" -> "cpp"
+ "emacs-lisp" -> "commonlisp" -- emacs lisp is not supported
+ "js" -> "javascript"
+ "lisp" -> "commonlisp"
+ "R" -> "r"
+ "sh" -> "bash"
+ "sqlite" -> "sql"
+ _ -> cs
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
new file mode 100644
index 000000000..441c573d9
--- /dev/null
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -0,0 +1,1354 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-
+Copyright (C) 2006-2015 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.RST
+ Copyright : Copyright (C) 2006-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion from reStructuredText to 'Pandoc' document.
+-}
+module Text.Pandoc.Readers.RST ( readRST ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Builder (setMeta, fromList)
+import Text.Pandoc.Shared
+import Text.Pandoc.Parsing
+import Text.Pandoc.Options
+import Text.Pandoc.Logging
+import Text.Pandoc.Error
+import Control.Monad ( when, liftM, guard, mzero )
+import Data.List ( findIndex, intercalate, isInfixOf,
+ transpose, sort, deleteFirstsBy, isSuffixOf , nub, union)
+import Data.Maybe (fromMaybe, isJust)
+import qualified Data.Map as M
+import Text.Printf ( printf )
+import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
+import qualified Text.Pandoc.Builder as B
+import Data.Sequence (viewr, ViewR(..))
+import Data.Char (toLower, isHexDigit, isSpace, toUpper)
+import Data.Monoid ((<>))
+import Control.Monad.Except (throwError)
+import Text.Pandoc.Class (PandocMonad, readFileFromDirs)
+
+-- TODO:
+-- [ ] .. parsed-literal
+-- [ ] :widths: attribute in .. table
+-- [ ] .. csv-table
+-- [ ] .. list-table
+
+-- | Parse reStructuredText string and return Pandoc document.
+readRST :: PandocMonad m
+ => ReaderOptions -- ^ Reader options
+ -> String -- ^ String to parse (assuming @'\n'@ line endings)
+ -> m Pandoc
+readRST opts s = do
+ parsed <- (readWithM parseRST) def{ stateOptions = opts } (s ++ "\n\n")
+ case parsed of
+ Right result -> return result
+ Left e -> throwError e
+
+type RSTParser m = ParserT [Char] ParserState m
+
+--
+-- Constants and data structure definitions
+---
+
+bulletListMarkers :: [Char]
+bulletListMarkers = "*+-"
+
+underlineChars :: [Char]
+underlineChars = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
+
+-- treat these as potentially non-text when parsing inline:
+specialChars :: [Char]
+specialChars = "\\`|*_<>$:/[]{}()-.\"'\8216\8217\8220\8221"
+
+--
+-- parsing documents
+--
+
+isHeader :: Int -> Block -> Bool
+isHeader n (Header x _ _) = x == n
+isHeader _ _ = False
+
+-- | Promote all headers in a list of blocks. (Part of
+-- title transformation for RST.)
+promoteHeaders :: Int -> [Block] -> [Block]
+promoteHeaders num ((Header level attr text):rest) =
+ (Header (level - num) attr text):(promoteHeaders num rest)
+promoteHeaders num (other:rest) = other:(promoteHeaders num rest)
+promoteHeaders _ [] = []
+
+-- | If list of blocks starts with a header (or a header and subheader)
+-- of level that are not found elsewhere, return it as a title and
+-- promote all the other headers. Also process a definition list right
+-- after the title block as metadata.
+titleTransform :: ([Block], Meta) -- ^ list of blocks, metadata
+ -> ([Block], Meta) -- ^ modified list of blocks, metadata
+titleTransform (bs, meta) =
+ let (bs', meta') =
+ case bs of
+ ((Header 1 _ head1):(Header 2 _ head2):rest)
+ | not (any (isHeader 1) rest || any (isHeader 2) rest) -> -- tit/sub
+ (promoteHeaders 2 rest, setMeta "title" (fromList head1) $
+ setMeta "subtitle" (fromList head2) meta)
+ ((Header 1 _ head1):rest)
+ | not (any (isHeader 1) rest) -> -- title only
+ (promoteHeaders 1 rest,
+ setMeta "title" (fromList head1) meta)
+ _ -> (bs, meta)
+ in case bs' of
+ (DefinitionList ds : rest) ->
+ (rest, metaFromDefList ds meta')
+ _ -> (bs', meta')
+
+metaFromDefList :: [([Inline], [[Block]])] -> Meta -> Meta
+metaFromDefList ds meta = adjustAuthors $ foldr f meta ds
+ where f (k,v) = setMeta (map toLower $ stringify k) (mconcat $ map fromList v)
+ adjustAuthors (Meta metamap) = Meta $ M.adjust splitAuthors "author"
+ $ M.adjust toPlain "date"
+ $ M.adjust toPlain "title"
+ $ M.mapKeys (\k -> if k == "authors" then "author" else k)
+ $ metamap
+ toPlain (MetaBlocks [Para xs]) = MetaInlines xs
+ toPlain x = x
+ splitAuthors (MetaBlocks [Para xs])
+ = MetaList $ map MetaInlines
+ $ splitAuthors' xs
+ splitAuthors x = x
+ splitAuthors' = map normalizeSpaces .
+ splitOnSemi . concatMap factorSemi
+ splitOnSemi = splitBy (==Str ";")
+ factorSemi (Str []) = []
+ factorSemi (Str s) = case break (==';') s of
+ (xs,[]) -> [Str xs]
+ (xs,';':ys) -> Str xs : Str ";" :
+ factorSemi (Str ys)
+ (xs,ys) -> Str xs :
+ factorSemi (Str ys)
+ factorSemi x = [x]
+
+parseRST :: PandocMonad m => RSTParser m Pandoc
+parseRST = do
+ optional blanklines -- skip blank lines at beginning of file
+ startPos <- getPosition
+ -- go through once just to get list of reference keys and notes
+ -- docMinusKeys is the raw document with blanks where the keys were...
+ docMinusKeys <- concat <$>
+ manyTill (referenceKey <|> noteBlock <|> lineClump) eof
+ setInput docMinusKeys
+ setPosition startPos
+ st' <- getState
+ let reversedNotes = stateNotes st'
+ updateState $ \s -> s { stateNotes = reverse reversedNotes }
+ -- now parse it for real...
+ blocks <- B.toList <$> parseBlocks
+ standalone <- getOption readerStandalone
+ state <- getState
+ let meta = stateMeta state
+ let (blocks', meta') = if standalone
+ then titleTransform (blocks, meta)
+ else (blocks, meta)
+ reportLogMessages
+ return $ Pandoc meta' blocks'
+
+--
+-- parsing blocks
+--
+
+parseBlocks :: PandocMonad m => RSTParser m Blocks
+parseBlocks = mconcat <$> manyTill block eof
+
+block :: PandocMonad m => RSTParser m Blocks
+block = choice [ codeBlock
+ , blockQuote
+ , fieldList
+ , include
+ , directive
+ , comment
+ , header
+ , hrule
+ , lineBlock -- must go before definitionList
+ , table
+ , list
+ , lhsCodeBlock
+ , para
+ , mempty <$ blanklines
+ ] <?> "block"
+
+--
+-- field list
+--
+
+rawFieldListItem :: Monad m => Int -> RSTParser m (String, String)
+rawFieldListItem minIndent = try $ do
+ indent <- length <$> many (char ' ')
+ guard $ indent >= minIndent
+ char ':'
+ name <- many1Till (noneOf "\n") (char ':')
+ (() <$ lookAhead newline) <|> skipMany1 spaceChar
+ first <- anyLine
+ rest <- option "" $ try $ do lookAhead (count indent (char ' ') >> spaceChar)
+ indentedBlock
+ let raw = (if null first then "" else (first ++ "\n")) ++ rest ++ "\n"
+ return (name, raw)
+
+fieldListItem :: PandocMonad m => Int -> RSTParser m (Inlines, [Blocks])
+fieldListItem minIndent = try $ do
+ (name, raw) <- rawFieldListItem minIndent
+ term <- parseInlineFromString name
+ contents <- parseFromString parseBlocks raw
+ optional blanklines
+ return (term, [contents])
+
+fieldList :: PandocMonad m => RSTParser m Blocks
+fieldList = try $ do
+ indent <- length <$> lookAhead (many spaceChar)
+ items <- many1 $ fieldListItem indent
+ case items of
+ [] -> return mempty
+ items' -> return $ B.definitionList items'
+
+--
+-- line block
+--
+
+lineBlock :: PandocMonad m => RSTParser m Blocks
+lineBlock = try $ do
+ lines' <- lineBlockLines
+ lines'' <- mapM parseInlineFromString lines'
+ return $ B.lineBlock lines''
+
+lineBlockDirective :: PandocMonad m => String -> RSTParser m Blocks
+lineBlockDirective body = do
+ lines' <- mapM parseInlineFromString $ lines $ stripTrailingNewlines body
+ return $ B.lineBlock lines'
+
+--
+-- paragraph block
+--
+
+-- note: paragraph can end in a :: starting a code block
+para :: PandocMonad m => RSTParser m Blocks
+para = try $ do
+ result <- trimInlines . mconcat <$> many1 inline
+ option (B.plain result) $ try $ do
+ newline
+ blanklines
+ case viewr (B.unMany result) of
+ ys :> (Str xs) | "::" `isSuffixOf` xs -> do
+ raw <- option mempty codeBlockBody
+ return $ B.para (B.Many ys <> B.str (take (length xs - 1) xs))
+ <> raw
+ _ -> return (B.para result)
+
+plain :: PandocMonad m => RSTParser m Blocks
+plain = B.plain . trimInlines . mconcat <$> many1 inline
+
+--
+-- header blocks
+--
+
+header :: PandocMonad m => RSTParser m Blocks
+header = doubleHeader <|> singleHeader <?> "header"
+
+-- a header with lines on top and bottom
+doubleHeader :: PandocMonad m => RSTParser m Blocks
+doubleHeader = try $ do
+ c <- oneOf underlineChars
+ rest <- many (char c) -- the top line
+ let lenTop = length (c:rest)
+ skipSpaces
+ newline
+ txt <- trimInlines . mconcat <$> many1 (notFollowedBy blankline >> inline)
+ pos <- getPosition
+ let len = (sourceColumn pos) - 1
+ if (len > lenTop) then fail "title longer than border" else return ()
+ blankline -- spaces and newline
+ count lenTop (char c) -- the bottom line
+ blanklines
+ -- check to see if we've had this kind of header before.
+ -- if so, get appropriate level. if not, add to list.
+ state <- getState
+ let headerTable = stateHeaderTable state
+ let (headerTable',level) = case findIndex (== DoubleHeader c) headerTable of
+ Just ind -> (headerTable, ind + 1)
+ Nothing -> (headerTable ++ [DoubleHeader c], (length headerTable) + 1)
+ setState (state { stateHeaderTable = headerTable' })
+ attr <- registerHeader nullAttr txt
+ return $ B.headerWith attr level txt
+
+-- a header with line on the bottom only
+singleHeader :: PandocMonad m => RSTParser m Blocks
+singleHeader = try $ do
+ notFollowedBy' whitespace
+ txt <- trimInlines . mconcat <$> many1 (do {notFollowedBy blankline; inline})
+ pos <- getPosition
+ let len = (sourceColumn pos) - 1
+ blankline
+ c <- oneOf underlineChars
+ count (len - 1) (char c)
+ many (char c)
+ blanklines
+ state <- getState
+ let headerTable = stateHeaderTable state
+ let (headerTable',level) = case findIndex (== SingleHeader c) headerTable of
+ Just ind -> (headerTable, ind + 1)
+ Nothing -> (headerTable ++ [SingleHeader c], (length headerTable) + 1)
+ setState (state { stateHeaderTable = headerTable' })
+ attr <- registerHeader nullAttr txt
+ return $ B.headerWith attr level txt
+
+--
+-- hrule block
+--
+
+hrule :: Monad m => ParserT [Char] st m Blocks
+hrule = try $ do
+ chr <- oneOf underlineChars
+ count 3 (char chr)
+ skipMany (char chr)
+ blankline
+ blanklines
+ return B.horizontalRule
+
+--
+-- code blocks
+--
+
+-- read a line indented by a given string
+indentedLine :: Monad m => String -> ParserT [Char] st m [Char]
+indentedLine indents = try $ do
+ string indents
+ anyLine
+
+-- one or more indented lines, possibly separated by blank lines.
+-- any amount of indentation will work.
+indentedBlock :: Monad m => ParserT [Char] st m [Char]
+indentedBlock = try $ do
+ indents <- lookAhead $ many1 spaceChar
+ lns <- many1 $ try $ do b <- option "" blanklines
+ l <- indentedLine indents
+ return (b ++ l)
+ optional blanklines
+ return $ unlines lns
+
+quotedBlock :: Monad m => ParserT [Char] st m [Char]
+quotedBlock = try $ do
+ quote <- lookAhead $ oneOf "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
+ lns <- many1 $ lookAhead (char quote) >> anyLine
+ optional blanklines
+ return $ unlines lns
+
+codeBlockStart :: Monad m => ParserT [Char] st m Char
+codeBlockStart = string "::" >> blankline >> blankline
+
+codeBlock :: Monad m => ParserT [Char] st m Blocks
+codeBlock = try $ codeBlockStart >> codeBlockBody
+
+codeBlockBody :: Monad m => ParserT [Char] st m Blocks
+codeBlockBody = try $ B.codeBlock . stripTrailingNewlines <$>
+ (indentedBlock <|> quotedBlock)
+
+lhsCodeBlock :: Monad m => RSTParser m Blocks
+lhsCodeBlock = try $ do
+ getPosition >>= guard . (==1) . sourceColumn
+ guardEnabled Ext_literate_haskell
+ optional codeBlockStart
+ lns <- latexCodeBlock <|> birdCodeBlock
+ blanklines
+ return $ B.codeBlockWith ("", ["sourceCode", "literate", "haskell"], [])
+ $ intercalate "\n" lns
+
+latexCodeBlock :: Monad m => ParserT [Char] st m [[Char]]
+latexCodeBlock = try $ do
+ try (latexBlockLine "\\begin{code}")
+ many1Till anyLine (try $ latexBlockLine "\\end{code}")
+ where
+ latexBlockLine s = skipMany spaceChar >> string s >> blankline
+
+birdCodeBlock :: Monad m => ParserT [Char] st m [[Char]]
+birdCodeBlock = filterSpace <$> many1 birdTrackLine
+ where filterSpace lns =
+ -- if (as is normal) there is always a space after >, drop it
+ if all (\ln -> null ln || take 1 ln == " ") lns
+ then map (drop 1) lns
+ else lns
+
+birdTrackLine :: Monad m => ParserT [Char] st m [Char]
+birdTrackLine = char '>' >> anyLine
+
+--
+-- block quotes
+--
+
+blockQuote :: PandocMonad m => RSTParser m Blocks
+blockQuote = do
+ raw <- indentedBlock
+ -- parse the extracted block, which may contain various block elements:
+ contents <- parseFromString parseBlocks $ raw ++ "\n\n"
+ return $ B.blockQuote contents
+
+{-
+Unsupported options for include:
+tab-width
+encoding
+-}
+
+include :: PandocMonad m => RSTParser m Blocks
+include = try $ do
+ string ".. include::"
+ skipMany spaceChar
+ f <- trim <$> anyLine
+ fields <- many $ rawFieldListItem 3
+ -- options
+ let (startLine :: Maybe Int) = lookup "start-line" fields >>= safeRead
+ let (endLine :: Maybe Int) = lookup "end-line" fields >>= safeRead
+ guard $ not (null f)
+ oldPos <- getPosition
+ oldInput <- getInput
+ containers <- stateContainers <$> getState
+ when (f `elem` containers) $
+ throwError $ PandocParseError $ "Include file loop at " ++ show oldPos
+ updateState $ \s -> s{ stateContainers = f : stateContainers s }
+ mbContents <- readFileFromDirs ["."] f
+ contentLines <- case mbContents of
+ Just s -> return $ lines s
+ Nothing -> do
+ logMessage $ CouldNotLoadIncludeFile f oldPos
+ return []
+ let numLines = length contentLines
+ let startLine' = case startLine of
+ Nothing -> 1
+ Just x | x >= 0 -> x
+ | otherwise -> numLines + x -- negative from end
+ let endLine' = case endLine of
+ Nothing -> numLines + 1
+ Just x | x >= 0 -> x
+ | otherwise -> numLines + x -- negative from end
+ let contentLines' = drop (startLine' - 1)
+ $ take (endLine' - 1)
+ $ contentLines
+ let contentLines'' = (case trim <$> lookup "end-before" fields of
+ Just patt -> takeWhile (not . (patt `isInfixOf`))
+ Nothing -> id) .
+ (case trim <$> lookup "start-after" fields of
+ Just patt -> drop 1 .
+ dropWhile (not . (patt `isInfixOf`))
+ Nothing -> id) $ contentLines'
+ let contents' = unlines contentLines''
+ case lookup "code" fields of
+ Just lang -> do
+ let numberLines = lookup "number-lines" fields
+ let classes = trimr lang : ["numberLines" | isJust numberLines] ++
+ maybe [] words (lookup "class" fields)
+ let kvs = maybe [] (\n -> [("startFrom", trimr n)]) numberLines
+ let ident = maybe "" trimr $ lookup "name" fields
+ let attribs = (ident, classes, kvs)
+ return $ B.codeBlockWith attribs contents'
+ Nothing -> case lookup "literal" fields of
+ Just _ -> return $ B.rawBlock "rst" contents'
+ Nothing -> do
+ setPosition $ newPos f 1 1
+ setInput contents'
+ bs <- optional blanklines >>
+ (mconcat <$> many block)
+ setInput oldInput
+ setPosition oldPos
+ updateState $ \s -> s{ stateContainers =
+ tail $ stateContainers s }
+ return bs
+
+
+--
+-- list blocks
+--
+
+list :: PandocMonad m => RSTParser m Blocks
+list = choice [ bulletList, orderedList, definitionList ] <?> "list"
+
+definitionListItem :: PandocMonad m => RSTParser m (Inlines, [Blocks])
+definitionListItem = try $ do
+ -- avoid capturing a directive or comment
+ notFollowedBy (try $ char '.' >> char '.')
+ term <- trimInlines . mconcat <$> many1Till inline endline
+ raw <- indentedBlock
+ -- parse the extracted block, which may contain various block elements:
+ contents <- parseFromString parseBlocks $ raw ++ "\n"
+ return (term, [contents])
+
+definitionList :: PandocMonad m => RSTParser m Blocks
+definitionList = B.definitionList <$> many1 definitionListItem
+
+-- parses bullet list start and returns its length (inc. following whitespace)
+bulletListStart :: Monad m => ParserT [Char] st m Int
+bulletListStart = try $ do
+ notFollowedBy' hrule -- because hrules start out just like lists
+ marker <- oneOf bulletListMarkers
+ white <- many1 spaceChar
+ return $ length (marker:white)
+
+-- parses ordered list start and returns its length (inc following whitespace)
+orderedListStart :: Monad m => ListNumberStyle
+ -> ListNumberDelim
+ -> RSTParser m Int
+orderedListStart style delim = try $ do
+ (_, markerLen) <- withHorizDisplacement (orderedListMarker style delim)
+ white <- many1 spaceChar
+ return $ markerLen + length white
+
+-- parse a line of a list item
+listLine :: Monad m => Int -> RSTParser m [Char]
+listLine markerLength = try $ do
+ notFollowedBy blankline
+ indentWith markerLength
+ line <- anyLine
+ return $ line ++ "\n"
+
+-- indent by specified number of spaces (or equiv. tabs)
+indentWith :: Monad m => Int -> RSTParser m [Char]
+indentWith num = do
+ tabStop <- getOption readerTabStop
+ if (num < tabStop)
+ then count num (char ' ')
+ else choice [ try (count num (char ' ')),
+ (try (char '\t' >> count (num - tabStop) (char ' '))) ]
+
+-- parse raw text for one list item, excluding start marker and continuations
+rawListItem :: Monad m => RSTParser m Int
+ -> RSTParser m (Int, [Char])
+rawListItem start = try $ do
+ markerLength <- start
+ firstLine <- anyLine
+ restLines <- many (listLine markerLength)
+ return (markerLength, (firstLine ++ "\n" ++ (concat restLines)))
+
+-- continuation of a list item - indented and separated by blankline or
+-- (in compact lists) endline.
+-- Note: nested lists are parsed as continuations.
+listContinuation :: Monad m => Int -> RSTParser m [Char]
+listContinuation markerLength = try $ do
+ blanks <- many1 blankline
+ result <- many1 (listLine markerLength)
+ return $ blanks ++ concat result
+
+listItem :: PandocMonad m
+ => RSTParser m Int
+ -> RSTParser m Blocks
+listItem start = try $ do
+ (markerLength, first) <- rawListItem start
+ rest <- many (listContinuation markerLength)
+ skipMany1 blankline <|> () <$ lookAhead start
+ -- parsing with ListItemState forces markers at beginning of lines to
+ -- count as list item markers, even if not separated by blank space.
+ -- see definition of "endline"
+ state <- getState
+ let oldContext = stateParserContext state
+ setState $ state {stateParserContext = ListItemState}
+ -- parse the extracted block, which may itself contain block elements
+ parsed <- parseFromString parseBlocks $ concat (first:rest) ++ "\n"
+ updateState (\st -> st {stateParserContext = oldContext})
+ return $ case B.toList parsed of
+ [Para xs] -> B.singleton $ Plain xs
+ [Para xs, BulletList ys] -> B.fromList [Plain xs, BulletList ys]
+ [Para xs, OrderedList s ys] -> B.fromList [Plain xs, OrderedList s ys]
+ [Para xs, DefinitionList ys] -> B.fromList [Plain xs, DefinitionList ys]
+ _ -> parsed
+
+orderedList :: PandocMonad m => RSTParser m Blocks
+orderedList = try $ do
+ (start, style, delim) <- lookAhead (anyOrderedListMarker <* spaceChar)
+ items <- many1 (listItem (orderedListStart style delim))
+ let items' = compactify items
+ return $ B.orderedListWith (start, style, delim) items'
+
+bulletList :: PandocMonad m => RSTParser m Blocks
+bulletList = B.bulletList . compactify <$> many1 (listItem bulletListStart)
+
+--
+-- directive (e.g. comment, container, compound-paragraph)
+--
+
+comment :: Monad m => RSTParser m Blocks
+comment = try $ do
+ string ".."
+ skipMany1 spaceChar <|> (() <$ lookAhead newline)
+ notFollowedBy' directiveLabel
+ manyTill anyChar blanklines
+ optional indentedBlock
+ return mempty
+
+directiveLabel :: Monad m => RSTParser m String
+directiveLabel = map toLower
+ <$> many1Till (letter <|> char '-') (try $ string "::")
+
+directive :: PandocMonad m => RSTParser m Blocks
+directive = try $ do
+ string ".."
+ directive'
+
+directive' :: PandocMonad m => RSTParser m Blocks
+directive' = do
+ skipMany1 spaceChar
+ label <- directiveLabel
+ skipMany spaceChar
+ top <- many $ satisfy (/='\n')
+ <|> try (char '\n' <*
+ notFollowedBy' (rawFieldListItem 3) <*
+ count 3 (char ' ') <*
+ notFollowedBy blankline)
+ newline
+ fields <- many $ rawFieldListItem 3
+ body <- option "" $ try $ blanklines >> indentedBlock
+ optional blanklines
+ let body' = body ++ "\n\n"
+ imgAttr cl = ("", classes, getAtt "width" ++ getAtt "height")
+ where
+ classes = words $ maybe "" trim $ lookup cl fields
+ getAtt k = case lookup k fields of
+ Just v -> [(k, filter (not . isSpace) v)]
+ Nothing -> []
+ case label of
+ "table" -> tableDirective top fields body'
+ "line-block" -> lineBlockDirective body'
+ "raw" -> return $ B.rawBlock (trim top) (stripTrailingNewlines body)
+ "role" -> addNewRole top $ map (\(k,v) -> (k, trim v)) fields
+ "container" -> parseFromString parseBlocks body'
+ "replace" -> B.para <$> -- consumed by substKey
+ parseInlineFromString (trim top)
+ "unicode" -> B.para <$> -- consumed by substKey
+ parseInlineFromString (trim $ unicodeTransform top)
+ "compound" -> parseFromString parseBlocks body'
+ "pull-quote" -> B.blockQuote <$> parseFromString parseBlocks body'
+ "epigraph" -> B.blockQuote <$> parseFromString parseBlocks body'
+ "highlights" -> B.blockQuote <$> parseFromString parseBlocks body'
+ "rubric" -> B.para . B.strong <$> parseInlineFromString top
+ _ | label `elem` ["attention","caution","danger","error","hint",
+ "important","note","tip","warning","admonition"] ->
+ do bod <- parseFromString parseBlocks $ top ++ "\n\n" ++ body'
+ let lab = case label of
+ "admonition" -> mempty
+ (l:ls) -> B.divWith ("",["admonition-title"],[])
+ (B.para (B.str (toUpper l : ls)))
+ [] -> mempty
+ return $ B.divWith ("",[label],[]) (lab <> bod)
+ "sidebar" ->
+ do let subtit = maybe "" trim $ lookup "subtitle" fields
+ tit <- B.para . B.strong <$> parseInlineFromString
+ (trim top ++ if null subtit
+ then ""
+ else (": " ++ subtit))
+ bod <- parseFromString parseBlocks body'
+ return $ B.divWith ("",["sidebar"],[]) $ tit <> bod
+ "topic" ->
+ do tit <- B.para . B.strong <$> parseInlineFromString top
+ bod <- parseFromString parseBlocks body'
+ return $ B.divWith ("",["topic"],[]) $ 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)
+ (lookup "number-lines" fields) (trim top) body
+ "aafig" -> do
+ let attribs = ("", ["aafig"], map (\(k,v) -> (k, trimr v)) fields)
+ return $ B.codeBlockWith attribs $ stripTrailingNewlines body
+ "math" -> return $ B.para $ mconcat $ map B.displayMath
+ $ toChunks $ top ++ "\n\n" ++ body
+ "figure" -> do
+ (caption, legend) <- parseFromString extractCaption body'
+ let src = escapeURI $ trim top
+ return $ B.para (B.imageWith (imgAttr "figclass") src "fig:" caption) <> legend
+ "image" -> do
+ let src = escapeURI $ trim top
+ let alt = B.str $ maybe "image" trim $ lookup "alt" fields
+ let attr = imgAttr "class"
+ return $ B.para
+ $ case lookup "target" fields of
+ Just t -> B.link (escapeURI $ trim t) ""
+ $ B.imageWith attr src "" alt
+ Nothing -> B.imageWith attr src "" alt
+ "class" -> do
+ let attrs = ("", (splitBy isSpace $ trim top), map (\(k,v) -> (k, trimr v)) fields)
+ -- directive content or the first immediately following element
+ children <- case body of
+ "" -> block
+ _ -> parseFromString parseBlocks body'
+ return $ B.divWith attrs children
+ other -> do
+ pos <- getPosition
+ logMessage $ SkippedContent (".. " ++ other) pos
+ return mempty
+
+tableDirective :: PandocMonad m
+ => String -> [(String, String)] -> String -> RSTParser m Blocks
+tableDirective top _fields body = do
+ bs <- parseFromString parseBlocks body
+ case B.toList bs of
+ [Table _ aligns' widths' header' rows'] -> do
+ title <- parseFromString (trimInlines . mconcat <$> many inline) top
+ -- TODO widths
+ -- align is not applicable since we can't represent whole table align
+ return $ B.singleton $ Table (B.toList title)
+ aligns' widths' header' rows'
+ _ -> return mempty
+
+-- TODO:
+-- - Only supports :format: fields with a single format for :raw: roles,
+-- change Text.Pandoc.Definition.Format to fix
+addNewRole :: PandocMonad m => String -> [(String, String)] -> RSTParser m Blocks
+addNewRole roleString fields = do
+ pos <- getPosition
+ (role, parentRole) <- parseFromString inheritedRole roleString
+ customRoles <- stateRstCustomRoles <$> getState
+ let getBaseRole (r, f, a) roles =
+ case M.lookup r roles of
+ Just (r', f', a') -> getBaseRole (r', f', a') roles
+ Nothing -> (r, f, a)
+ (baseRole, baseFmt, baseAttr) =
+ getBaseRole (parentRole, Nothing, nullAttr) customRoles
+ fmt = if parentRole == "raw" then lookup "format" fields else baseFmt
+ annotate :: [String] -> [String]
+ annotate = maybe id (:) $
+ if baseRole == "code"
+ then lookup "language" fields
+ else Nothing
+ attr = let (ident, classes, keyValues) = baseAttr
+ -- nub in case role name & language class are the same
+ in (ident, nub . (role :) . annotate $ classes, keyValues)
+
+ -- warn about syntax we ignore
+ flip mapM_ fields $ \(key, _) -> case key of
+ "language" -> when (baseRole /= "code") $ logMessage $
+ SkippedContent ":language: [because parent of role is not :code:]"
+ pos
+ "format" -> when (baseRole /= "raw") $ logMessage $
+ SkippedContent ":format: [because parent of role is not :raw:]" pos
+ _ -> logMessage $ SkippedContent (":" ++ key ++ ":") pos
+ when (parentRole == "raw" && countKeys "format" > 1) $
+ logMessage $ SkippedContent ":format: [after first in definition of role]"
+ pos
+ when (parentRole == "code" && countKeys "language" > 1) $
+ logMessage $ SkippedContent
+ ":language: [after first in definition of role]" pos
+
+ updateState $ \s -> s {
+ stateRstCustomRoles =
+ M.insert role (baseRole, fmt, attr) customRoles
+ }
+
+ return mempty
+ where
+ countKeys k = length . filter (== k) . map fst $ fields
+ inheritedRole =
+ (,) <$> roleName <*> ((char '(' *> roleName <* char ')') <|> pure "span")
+
+
+-- Can contain character codes as decimal numbers or
+-- hexadecimal numbers, prefixed by 0x, x, \x, U+, u, or \u
+-- or as XML-style hexadecimal character entities, e.g. &#x1a2b;
+-- or text, which is used as-is. Comments start with ..
+unicodeTransform :: String -> String
+unicodeTransform t =
+ case t of
+ ('.':'.':xs) -> unicodeTransform $ dropWhile (/='\n') xs -- comment
+ ('0':'x':xs) -> go "0x" xs
+ ('x':xs) -> go "x" xs
+ ('\\':'x':xs) -> go "\\x" xs
+ ('U':'+':xs) -> go "U+" xs
+ ('u':xs) -> go "u" xs
+ ('\\':'u':xs) -> go "\\u" xs
+ ('&':'#':'x':xs) -> maybe ("&#x" ++ unicodeTransform xs)
+ -- drop semicolon
+ (\(c,s) -> c : unicodeTransform (drop 1 s))
+ $ extractUnicodeChar xs
+ (x:xs) -> x : unicodeTransform xs
+ [] -> []
+ where go pref zs = maybe (pref ++ unicodeTransform zs)
+ (\(c,s) -> c : unicodeTransform s)
+ $ extractUnicodeChar zs
+
+extractUnicodeChar :: String -> Maybe (Char, String)
+extractUnicodeChar s = maybe Nothing (\c -> Just (c,rest)) mbc
+ where (ds,rest) = span isHexDigit s
+ mbc = safeRead ('\'':'\\':'x':ds ++ "'")
+
+extractCaption :: PandocMonad m => RSTParser m (Inlines, Blocks)
+extractCaption = do
+ capt <- trimInlines . mconcat <$> many inline
+ legend <- optional blanklines >> (mconcat <$> many block)
+ return (capt,legend)
+
+-- divide string by blanklines
+toChunks :: String -> [String]
+toChunks = dropWhile null
+ . map (trim . unlines)
+ . splitBy (all (`elem` (" \t" :: String))) . lines
+
+codeblock :: [String] -> Maybe String -> String -> String -> RSTParser m Blocks
+codeblock classes numberLines lang body =
+ return $ B.codeBlockWith attribs $ stripTrailingNewlines body
+ where attribs = ("", classes', kvs)
+ classes' = "sourceCode" : lang
+ : maybe [] (\_ -> ["numberLines"]) numberLines
+ ++ classes
+ kvs = case numberLines of
+ Just "" -> []
+ Nothing -> []
+ Just n -> [("startFrom",trim n)]
+
+---
+--- note block
+---
+
+noteBlock :: Monad m => RSTParser m [Char]
+noteBlock = try $ do
+ startPos <- getPosition
+ string ".."
+ spaceChar >> skipMany spaceChar
+ ref <- noteMarker
+ first <- (spaceChar >> skipMany spaceChar >> anyLine)
+ <|> (newline >> return "")
+ blanks <- option "" blanklines
+ rest <- option "" indentedBlock
+ endPos <- getPosition
+ let raw = first ++ "\n" ++ blanks ++ rest ++ "\n"
+ let newnote = (ref, raw)
+ st <- getState
+ let oldnotes = stateNotes st
+ updateState $ \s -> s { stateNotes = newnote : oldnotes }
+ -- return blanks so line count isn't affected
+ return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
+
+noteMarker :: Monad m => RSTParser m [Char]
+noteMarker = do
+ char '['
+ res <- many1 digit
+ <|> (try $ char '#' >> liftM ('#':) simpleReferenceName')
+ <|> count 1 (oneOf "#*")
+ char ']'
+ return res
+
+--
+-- reference key
+--
+
+quotedReferenceName :: PandocMonad m => RSTParser m Inlines
+quotedReferenceName = try $ do
+ char '`' >> notFollowedBy (char '`') -- `` means inline code!
+ label' <- trimInlines . mconcat <$> many1Till inline (char '`')
+ return label'
+
+unquotedReferenceName :: PandocMonad m => RSTParser m Inlines
+unquotedReferenceName = try $ do
+ label' <- trimInlines . mconcat <$> many1Till inline (lookAhead $ char ':')
+ return label'
+
+-- Simple reference names are single words consisting of alphanumerics
+-- plus isolated (no two adjacent) internal hyphens, underscores,
+-- periods, colons and plus signs; no whitespace or other characters
+-- are allowed.
+simpleReferenceName' :: Monad m => ParserT [Char] st m String
+simpleReferenceName' = do
+ x <- alphaNum
+ xs <- many $ alphaNum
+ <|> (try $ oneOf "-_:+." <* lookAhead alphaNum)
+ return (x:xs)
+
+simpleReferenceName :: Monad m => ParserT [Char] st m Inlines
+simpleReferenceName = do
+ raw <- simpleReferenceName'
+ return $ B.str raw
+
+referenceName :: PandocMonad m => RSTParser m Inlines
+referenceName = quotedReferenceName <|>
+ (try $ simpleReferenceName <* lookAhead (char ':')) <|>
+ unquotedReferenceName
+
+referenceKey :: PandocMonad m => RSTParser m [Char]
+referenceKey = do
+ startPos <- getPosition
+ choice [substKey, anonymousKey, regularKey]
+ optional blanklines
+ endPos <- getPosition
+ -- return enough blanks to replace key
+ return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
+
+targetURI :: Monad m => ParserT [Char] st m [Char]
+targetURI = do
+ skipSpaces
+ optional newline
+ contents <- many1 (try (many spaceChar >> newline >>
+ many1 spaceChar >> noneOf " \t\n") <|> noneOf "\n")
+ blanklines
+ return $ escapeURI $ trim $ contents
+
+substKey :: PandocMonad m => RSTParser m ()
+substKey = try $ do
+ string ".."
+ skipMany1 spaceChar
+ (alt,ref) <- withRaw $ trimInlines . mconcat
+ <$> enclosed (char '|') (char '|') inline
+ res <- B.toList <$> directive'
+ il <- case res of
+ -- use alt unless :alt: attribute on image:
+ [Para [Image attr [Str "image"] (src,tit)]] ->
+ return $ B.imageWith attr src tit alt
+ [Para [Link _ [Image attr [Str "image"] (src,tit)] (src',tit')]] ->
+ return $ B.link src' tit' (B.imageWith attr src tit alt)
+ [Para ils] -> return $ B.fromList ils
+ _ -> mzero
+ let key = toKey $ stripFirstAndLast ref
+ updateState $ \s -> s{ stateSubstitutions = M.insert key il $ stateSubstitutions s }
+
+anonymousKey :: Monad m => RSTParser m ()
+anonymousKey = try $ do
+ oneOfStrings [".. __:", "__"]
+ src <- targetURI
+ pos <- getPosition
+ let key = toKey $ "_" ++ printf "%09d" (sourceLine pos)
+ --TODO: parse width, height, class and name attributes
+ updateState $ \s -> s { stateKeys = M.insert key ((src,""), nullAttr) $ stateKeys s }
+
+stripTicks :: String -> String
+stripTicks = reverse . stripTick . reverse . stripTick
+ where stripTick ('`':xs) = xs
+ stripTick xs = xs
+
+regularKey :: PandocMonad m => RSTParser m ()
+regularKey = try $ do
+ string ".. _"
+ (_,ref) <- withRaw referenceName
+ char ':'
+ src <- targetURI
+ let key = toKey $ stripTicks ref
+ --TODO: parse width, height, class and name attributes
+ updateState $ \s -> s { stateKeys = M.insert key ((src,""), nullAttr) $ stateKeys s }
+
+--
+-- tables
+--
+
+-- General tables TODO:
+-- - figure out if leading spaces are acceptable and if so, add
+-- support for them
+--
+-- Simple tables TODO:
+-- - column spans
+-- - multiline support
+-- - ensure that rightmost column span does not need to reach end
+-- - require at least 2 columns
+--
+-- Grid tables TODO:
+-- - column spans
+
+dashedLine :: Monad m => Char -> ParserT [Char] st m (Int, Int)
+dashedLine ch = do
+ dashes <- many1 (char ch)
+ sp <- many (char ' ')
+ return (length dashes, length $ dashes ++ sp)
+
+simpleDashedLines :: Monad m => Char -> ParserT [Char] st m [(Int,Int)]
+simpleDashedLines ch = try $ many1 (dashedLine ch)
+
+-- Parse a table row separator
+simpleTableSep :: Monad m => Char -> RSTParser m Char
+simpleTableSep ch = try $ simpleDashedLines ch >> newline
+
+-- Parse a table footer
+simpleTableFooter :: Monad m => RSTParser m [Char]
+simpleTableFooter = try $ simpleTableSep '=' >> blanklines
+
+-- Parse a raw line and split it into chunks by indices.
+simpleTableRawLine :: Monad m => [Int] -> RSTParser m [String]
+simpleTableRawLine indices = do
+ line <- many1Till anyChar newline
+ return (simpleTableSplitLine indices line)
+
+-- Parse a table row and return a list of blocks (columns).
+simpleTableRow :: PandocMonad m => [Int] -> RSTParser m [Blocks]
+simpleTableRow indices = do
+ notFollowedBy' simpleTableFooter
+ firstLine <- simpleTableRawLine indices
+ colLines <- return [] -- TODO
+ let cols = map unlines . transpose $ firstLine : colLines
+ mapM (parseFromString (mconcat <$> many plain)) cols
+
+simpleTableSplitLine :: [Int] -> String -> [String]
+simpleTableSplitLine indices line =
+ map trim
+ $ tail $ splitByIndices (init indices) line
+
+simpleTableHeader :: PandocMonad m
+ => Bool -- ^ Headerless table
+ -> RSTParser m ([Blocks], [Alignment], [Int])
+simpleTableHeader headless = try $ do
+ optional blanklines
+ rawContent <- if headless
+ then return ""
+ else simpleTableSep '=' >> anyLine
+ dashes <- simpleDashedLines '=' <|> simpleDashedLines '-'
+ newline
+ let lines' = map snd dashes
+ let indices = scanl (+) 0 lines'
+ let aligns = replicate (length lines') AlignDefault
+ let rawHeads = if headless
+ then replicate (length dashes) ""
+ else simpleTableSplitLine indices rawContent
+ heads <- mapM (parseFromString (mconcat <$> many plain)) $
+ map trim rawHeads
+ return (heads, aligns, indices)
+
+-- Parse a simple table.
+simpleTable :: PandocMonad m
+ => Bool -- ^ Headerless table
+ -> RSTParser m Blocks
+simpleTable headless = do
+ tbl <- tableWith (simpleTableHeader headless) simpleTableRow
+ sep simpleTableFooter
+ -- Simple tables get 0s for relative column widths (i.e., use default)
+ case B.toList tbl of
+ [Table c a _w h l] -> return $ B.singleton $
+ Table c a (replicate (length a) 0) h l
+ _ ->
+ throwError $ PandocShouldNeverHappenError
+ "tableWith returned something unexpected"
+ where
+ sep = return () -- optional (simpleTableSep '-')
+
+gridTable :: PandocMonad m
+ => Bool -- ^ Headerless table
+ -> RSTParser m Blocks
+gridTable headerless = gridTableWith parseBlocks headerless
+
+table :: PandocMonad m => RSTParser m Blocks
+table = gridTable False <|> simpleTable False <|>
+ gridTable True <|> simpleTable True <?> "table"
+
+--
+-- inline
+--
+
+inline :: PandocMonad m => RSTParser m Inlines
+inline = choice [ note -- can start with whitespace, so try before ws
+ , whitespace
+ , link
+ , str
+ , endline
+ , strong
+ , emph
+ , code
+ , subst
+ , interpretedRole
+ , smart
+ , hyphens
+ , escapedChar
+ , symbol ] <?> "inline"
+
+parseInlineFromString :: PandocMonad m => String -> RSTParser m Inlines
+parseInlineFromString = parseFromString (trimInlines . mconcat <$> many inline)
+
+hyphens :: Monad m => RSTParser m Inlines
+hyphens = do
+ result <- many1 (char '-')
+ optional endline
+ -- don't want to treat endline after hyphen or dash as a space
+ return $ B.str result
+
+escapedChar :: Monad m => ParserT [Char] st m Inlines
+escapedChar = do c <- escaped anyChar
+ return $ if c == ' ' -- '\ ' is null in RST
+ then mempty
+ else B.str [c]
+
+symbol :: Monad m => RSTParser m Inlines
+symbol = do
+ result <- oneOf specialChars
+ return $ B.str [result]
+
+-- parses inline code, between codeStart and codeEnd
+code :: Monad m => RSTParser m Inlines
+code = try $ do
+ string "``"
+ result <- manyTill anyChar (try (string "``"))
+ return $ B.code
+ $ trim $ unwords $ lines result
+
+-- succeeds only if we're not right after a str (ie. in middle of word)
+atStart :: Monad m => RSTParser m a -> RSTParser m a
+atStart p = do
+ pos <- getPosition
+ st <- getState
+ -- single quote start can't be right after str
+ guard $ stateLastStrPos st /= Just pos
+ p
+
+emph :: PandocMonad m => RSTParser m Inlines
+emph = B.emph . trimInlines . mconcat <$>
+ enclosed (atStart $ char '*') (char '*') inline
+
+strong :: PandocMonad m => RSTParser m Inlines
+strong = B.strong . trimInlines . mconcat <$>
+ enclosed (atStart $ string "**") (try $ string "**") inline
+
+-- Note, this doesn't precisely implement the complex rule in
+-- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules
+-- but it should be good enough for most purposes
+--
+-- TODO:
+-- - Classes are silently discarded in addNewRole
+-- - Lacks sensible implementation for title-reference (which is the default)
+-- - Allows direct use of the :raw: role, rST only allows inherited use.
+interpretedRole :: PandocMonad m => RSTParser m Inlines
+interpretedRole = try $ do
+ (role, contents) <- roleBefore <|> roleAfter
+ renderRole contents Nothing role nullAttr
+
+renderRole :: PandocMonad m => String -> Maybe String -> String -> Attr -> RSTParser m Inlines
+renderRole contents fmt role attr = case role of
+ "sup" -> return $ B.superscript $ B.str contents
+ "superscript" -> return $ B.superscript $ B.str contents
+ "sub" -> return $ B.subscript $ B.str contents
+ "subscript" -> return $ B.subscript $ B.str contents
+ "emphasis" -> return $ B.emph $ B.str contents
+ "strong" -> return $ B.strong $ B.str contents
+ "rfc-reference" -> return $ rfcLink contents
+ "RFC" -> return $ rfcLink contents
+ "pep-reference" -> return $ pepLink contents
+ "PEP" -> return $ pepLink contents
+ "literal" -> return $ B.codeWith attr contents
+ "math" -> return $ B.math contents
+ "title-reference" -> titleRef contents
+ "title" -> titleRef contents
+ "t" -> titleRef contents
+ "code" -> return $ B.codeWith (addClass "sourceCode" attr) contents
+ "span" -> return $ B.spanWith attr $ B.str contents
+ "raw" -> return $ B.rawInline (fromMaybe "" fmt) contents
+ custom -> do
+ customRoles <- stateRstCustomRoles <$> getState
+ case M.lookup custom customRoles of
+ Just (newRole, newFmt, newAttr) ->
+ renderRole contents newFmt newRole newAttr
+ Nothing -> do
+ pos <- getPosition
+ logMessage $ SkippedContent (":" ++ custom ++ ":") pos
+ return $ B.str contents -- Undefined role
+ where
+ titleRef ref = return $ B.str ref -- FIXME: Not a sensible behaviour
+ rfcLink rfcNo = B.link rfcUrl ("RFC " ++ rfcNo) $ B.str ("RFC " ++ rfcNo)
+ where rfcUrl = "http://www.faqs.org/rfcs/rfc" ++ rfcNo ++ ".html"
+ pepLink pepNo = B.link pepUrl ("PEP " ++ pepNo) $ B.str ("PEP " ++ pepNo)
+ where padNo = replicate (4 - length pepNo) '0' ++ pepNo
+ pepUrl = "http://www.python.org/dev/peps/pep-" ++ padNo ++ "/"
+
+addClass :: String -> Attr -> Attr
+addClass c (ident, classes, keyValues) = (ident, union classes [c], keyValues)
+
+roleName :: PandocMonad m => RSTParser m String
+roleName = many1 (letter <|> char '-')
+
+roleMarker :: PandocMonad m => RSTParser m String
+roleMarker = char ':' *> roleName <* char ':'
+
+roleBefore :: PandocMonad m => RSTParser m (String,String)
+roleBefore = try $ do
+ role <- roleMarker
+ contents <- unmarkedInterpretedText
+ return (role,contents)
+
+roleAfter :: PandocMonad m => RSTParser m (String,String)
+roleAfter = try $ do
+ contents <- unmarkedInterpretedText
+ role <- roleMarker <|> (stateRstDefaultRole <$> getState)
+ return (role,contents)
+
+unmarkedInterpretedText :: PandocMonad m => RSTParser m [Char]
+unmarkedInterpretedText = enclosed (atStart $ char '`') (char '`') anyChar
+
+whitespace :: PandocMonad m => RSTParser m Inlines
+whitespace = B.space <$ skipMany1 spaceChar <?> "whitespace"
+
+str :: Monad m => RSTParser m Inlines
+str = do
+ let strChar = noneOf ("\t\n " ++ specialChars)
+ result <- many1 strChar
+ updateLastStrPos
+ return $ B.str result
+
+-- an endline character that can be treated as a space, not a structural break
+endline :: Monad m => RSTParser m Inlines
+endline = try $ do
+ newline
+ notFollowedBy blankline
+ -- parse potential list-starts at beginning of line differently in a list:
+ st <- getState
+ if (stateParserContext st) == ListItemState
+ then notFollowedBy (anyOrderedListMarker >> spaceChar) >>
+ notFollowedBy' bulletListStart
+ else return ()
+ return B.softbreak
+
+--
+-- links
+--
+
+link :: PandocMonad m => RSTParser m Inlines
+link = choice [explicitLink, referenceLink, autoLink] <?> "link"
+
+explicitLink :: PandocMonad m => RSTParser m Inlines
+explicitLink = try $ do
+ char '`'
+ notFollowedBy (char '`') -- `` marks start of inline code
+ label' <- trimInlines . mconcat <$>
+ manyTill (notFollowedBy (char '`') >> inline) (char '<')
+ src <- trim <$> manyTill (noneOf ">\n") (char '>')
+ skipSpaces
+ string "`_"
+ optional $ char '_' -- anonymous form
+ let label'' = if label' == mempty
+ then B.str src
+ else label'
+ -- `link <google_>` is a reference link to _google!
+ ((src',tit),attr) <- case reverse src of
+ '_':xs -> lookupKey [] (toKey (reverse xs))
+ _ -> return ((src, ""), nullAttr)
+ return $ B.linkWith attr (escapeURI src') tit label''
+
+referenceLink :: PandocMonad m => RSTParser m Inlines
+referenceLink = try $ do
+ (label',ref) <- withRaw (quotedReferenceName <|> simpleReferenceName) <*
+ char '_'
+ let isAnonKey (Key ('_':_)) = True
+ isAnonKey _ = False
+ state <- getState
+ let keyTable = stateKeys state
+ key <- option (toKey $ stripTicks ref) $
+ do char '_'
+ let anonKeys = sort $ filter isAnonKey $ M.keys keyTable
+ case anonKeys of
+ [] -> mzero
+ (k:_) -> return k
+ ((src,tit), attr) <- lookupKey [] key
+ -- if anonymous link, remove key so it won't be used again
+ when (isAnonKey key) $ updateState $ \s -> s{ stateKeys = M.delete key keyTable }
+ return $ B.linkWith attr src tit label'
+
+-- We keep a list of oldkeys so we can detect lookup loops.
+lookupKey :: PandocMonad m
+ => [Key] -> Key -> RSTParser m ((String, String), Attr)
+lookupKey oldkeys key = do
+ pos <- getPosition
+ state <- getState
+ let keyTable = stateKeys state
+ case M.lookup key keyTable of
+ Nothing -> do
+ let Key key' = key
+ logMessage $ ReferenceNotFound key' pos
+ return (("",""),nullAttr)
+ -- check for keys of the form link_, which need to be resolved:
+ Just ((u@(_:_),""),_) | last u == '_' -> do
+ let rawkey = init u
+ let newkey = toKey rawkey
+ if newkey `elem` oldkeys
+ then do
+ logMessage $ CircularReference rawkey pos
+ return (("",""),nullAttr)
+ else lookupKey (key:oldkeys) newkey
+ Just val -> return val
+
+autoURI :: Monad m => RSTParser m Inlines
+autoURI = do
+ (orig, src) <- uri
+ return $ B.link src "" $ B.str orig
+
+autoEmail :: Monad m => RSTParser m Inlines
+autoEmail = do
+ (orig, src) <- emailAddress
+ return $ B.link src "" $ B.str orig
+
+autoLink :: PandocMonad m => RSTParser m Inlines
+autoLink = autoURI <|> autoEmail
+
+subst :: PandocMonad m => RSTParser m Inlines
+subst = try $ do
+ (_,ref) <- withRaw $ enclosed (char '|') (char '|') inline
+ state <- getState
+ let substTable = stateSubstitutions state
+ let key = toKey $ stripFirstAndLast ref
+ case M.lookup key substTable of
+ Nothing -> do
+ pos <- getPosition
+ logMessage $ ReferenceNotFound (show key) pos
+ return mempty
+ Just target -> return target
+
+note :: PandocMonad m => RSTParser m Inlines
+note = try $ do
+ optional whitespace
+ ref <- noteMarker
+ char '_'
+ state <- getState
+ let notes = stateNotes state
+ case lookup ref notes of
+ Nothing -> do
+ pos <- getPosition
+ logMessage $ ReferenceNotFound ref pos
+ return mempty
+ Just raw -> do
+ -- We temporarily empty the note list while parsing the note,
+ -- so that we don't get infinite loops with notes inside notes...
+ -- Note references inside other notes are allowed in reST, but
+ -- not yet in this implementation.
+ updateState $ \st -> st{ stateNotes = [] }
+ contents <- parseFromString parseBlocks raw
+ let newnotes = if (ref == "*" || ref == "#") -- auto-numbered
+ -- delete the note so the next auto-numbered note
+ -- doesn't get the same contents:
+ then deleteFirstsBy (==) notes [(ref,raw)]
+ else notes
+ updateState $ \st -> st{ stateNotes = newnotes }
+ return $ B.note contents
+
+smart :: PandocMonad m => RSTParser m Inlines
+smart = do
+ guardEnabled Ext_smart
+ doubleQuoted <|> singleQuoted <|>
+ choice [apostrophe, dash, ellipses]
+
+singleQuoted :: PandocMonad m => RSTParser m Inlines
+singleQuoted = try $ do
+ singleQuoteStart
+ withQuoteContext InSingleQuote $
+ B.singleQuoted . trimInlines . mconcat <$>
+ many1Till inline singleQuoteEnd
+
+doubleQuoted :: PandocMonad m => RSTParser m Inlines
+doubleQuoted = try $ do
+ doubleQuoteStart
+ withQuoteContext InDoubleQuote $
+ B.doubleQuoted . trimInlines . mconcat <$>
+ many1Till inline doubleQuoteEnd
diff --git a/src/Text/Pandoc/Readers/TWiki.hs b/src/Text/Pandoc/Readers/TWiki.hs
new file mode 100644
index 000000000..3b89f2ee9
--- /dev/null
+++ b/src/Text/Pandoc/Readers/TWiki.hs
@@ -0,0 +1,525 @@
+{-# LANGUAGE RelaxedPolyRec, FlexibleInstances, TypeSynonymInstances, FlexibleContexts #-}
+-- RelaxedPolyRec needed for inlinesBetween on GHC < 7
+{-
+ Copyright (C) 2014 Alexander Sulfrian <alexander.sulfrian@fu-berlin.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.Readers.TWiki
+ Copyright : Copyright (C) 2014 Alexander Sulfrian
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Alexander Sulfrian <alexander.sulfrian@fu-berlin.de>
+ Stability : alpha
+ Portability : portable
+
+Conversion of twiki text to 'Pandoc' document.
+-}
+module Text.Pandoc.Readers.TWiki ( readTWiki
+ ) where
+
+import Text.Pandoc.Definition
+import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.Options
+import Text.Pandoc.Logging
+import Text.Pandoc.Parsing hiding (enclosed, macro, nested)
+import Text.Pandoc.Readers.HTML (htmlTag, isCommentTag)
+import Control.Monad
+import Text.Pandoc.XML (fromEntities)
+import Data.Maybe (fromMaybe)
+import Text.HTML.TagSoup
+import Data.Char (isAlphaNum)
+import qualified Data.Foldable as F
+import Control.Monad.Except (throwError)
+import Text.Pandoc.Class (PandocMonad, report)
+
+-- | Read twiki from an input string and return a Pandoc document.
+readTWiki :: PandocMonad m
+ => ReaderOptions
+ -> String
+ -> m Pandoc
+readTWiki opts s = do
+ res <- readWithM parseTWiki def{ stateOptions = opts } (s ++ "\n\n")
+ case res of
+ Left e -> throwError e
+ Right d -> return d
+
+type TWParser = ParserT [Char] ParserState
+
+--
+-- utility functions
+--
+
+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
+ guard $ nestlevel > 0
+ updateState $ \st -> st{ stateMaxNestingLevel = stateMaxNestingLevel st - 1 }
+ res <- p
+ updateState $ \st -> st{ stateMaxNestingLevel = nestlevel }
+ return res
+
+htmlElement :: PandocMonad m => String -> TWParser m (Attr, String)
+htmlElement tag = tryMsg tag $ do
+ (TagOpen _ attr, _) <- htmlTag (~== TagOpen tag [])
+ content <- manyTill anyChar (endtag <|> endofinput)
+ return (htmlAttrToPandoc attr, trim content)
+ where
+ endtag = skip $ htmlTag (~== TagClose tag)
+ endofinput = lookAhead $ try $ skipMany blankline >> skipSpaces >> eof
+ trim = dropWhile (=='\n') . reverse . dropWhile (=='\n') . reverse
+
+htmlAttrToPandoc :: [Attribute 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"]
+
+parseHtmlContentWithAttrs :: PandocMonad m
+ => String -> TWParser m a -> TWParser m (Attr, [a])
+parseHtmlContentWithAttrs tag parser = do
+ (attr, content) <- htmlElement tag
+ parsedContent <- try $ parseContent content
+ return (attr, parsedContent)
+ where
+ parseContent = parseFromString $ nested $ manyTill parser endOfContent
+ endOfContent = try $ skipMany blankline >> skipSpaces >> eof
+
+parseHtmlContent :: PandocMonad m => String -> TWParser m a -> TWParser m [a]
+parseHtmlContent tag p = parseHtmlContentWithAttrs tag p >>= return . snd
+
+--
+-- main parser
+--
+
+parseTWiki :: PandocMonad m => TWParser m Pandoc
+parseTWiki = do
+ bs <- mconcat <$> many block
+ spaces
+ eof
+ return $ B.doc bs
+
+
+--
+-- block parsers
+--
+
+block :: PandocMonad m => TWParser m B.Blocks
+block = do
+ pos <- getPosition
+ res <- mempty <$ skipMany1 blankline
+ <|> blockElements
+ <|> para
+ skipMany blankline
+ report $ ParsingTrace (take 60 $ show $ B.toList res) pos
+ return res
+
+blockElements :: PandocMonad m => TWParser m B.Blocks
+blockElements = choice [ separator
+ , header
+ , verbatim
+ , literal
+ , list ""
+ , table
+ , blockQuote
+ , noautolink
+ ]
+
+separator :: PandocMonad m => TWParser m B.Blocks
+separator = tryMsg "separator" $ string "---" >> newline >> return B.horizontalRule
+
+header :: PandocMonad m => TWParser m B.Blocks
+header = tryMsg "header" $ do
+ string "---"
+ level <- many1 (char '+') >>= return . length
+ guard $ level <= 6
+ classes <- option [] $ string "!!" >> return ["unnumbered"]
+ skipSpaces
+ content <- B.trimInlines . mconcat <$> manyTill inline newline
+ attr <- registerHeader ("", classes, []) content
+ return $ B.headerWith attr level $ content
+
+verbatim :: PandocMonad m => TWParser m B.Blocks
+verbatim = (htmlElement "verbatim" <|> htmlElement "pre")
+ >>= return . (uncurry B.codeBlockWith)
+
+literal :: PandocMonad m => TWParser m B.Blocks
+literal = htmlElement "literal" >>= return . rawBlock
+ where
+ format (_, _, kvs) = fromMaybe "html" $ lookup "format" kvs
+ rawBlock (attrs, content) = B.rawBlock (format attrs) content
+
+list :: PandocMonad m => String -> TWParser m B.Blocks
+list prefix = choice [ bulletList prefix
+ , orderedList prefix
+ , definitionList prefix]
+
+definitionList :: PandocMonad m => String -> TWParser m B.Blocks
+definitionList prefix = tryMsg "definitionList" $ do
+ indent <- lookAhead $ string prefix *> (many1 $ string " ") <* string "$ "
+ elements <- many $ parseDefinitionListItem (prefix ++ concat indent)
+ return $ B.definitionList elements
+ where
+ parseDefinitionListItem :: PandocMonad m
+ => String -> TWParser m (B.Inlines, [B.Blocks])
+ parseDefinitionListItem indent = do
+ string (indent ++ "$ ") >> skipSpaces
+ term <- many1Till inline $ string ": "
+ line <- listItemLine indent $ string "$ "
+ return $ (mconcat term, [line])
+
+bulletList :: PandocMonad m => String -> TWParser m B.Blocks
+bulletList prefix = tryMsg "bulletList" $
+ parseList prefix (char '*') (char ' ')
+
+orderedList :: PandocMonad m => String -> TWParser m B.Blocks
+orderedList prefix = tryMsg "orderedList" $
+ parseList prefix (oneOf "1iIaA") (string ". ")
+
+parseList :: PandocMonad m
+ => String -> TWParser m Char -> TWParser m a -> TWParser m B.Blocks
+parseList prefix marker delim = do
+ (indent, style) <- lookAhead $ string prefix *> listStyle <* delim
+ blocks <- many $ parseListItem (prefix ++ indent) (char style <* delim)
+ return $ case style of
+ '1' -> B.orderedListWith (1, DefaultStyle, DefaultDelim) blocks
+ 'i' -> B.orderedListWith (1, LowerRoman, DefaultDelim) blocks
+ 'I' -> B.orderedListWith (1, UpperRoman, DefaultDelim) blocks
+ 'a' -> B.orderedListWith (1, LowerAlpha, DefaultDelim) blocks
+ 'A' -> B.orderedListWith (1, UpperAlpha, DefaultDelim) blocks
+ _ -> B.bulletList blocks
+ where
+ listStyle = do
+ indent <- many1 $ string " "
+ style <- marker
+ return (concat indent, style)
+
+parseListItem :: (PandocMonad m, Show a)
+ => String -> TWParser m a -> TWParser m B.Blocks
+parseListItem prefix marker = string prefix >> marker >> listItemLine prefix marker
+
+listItemLine :: (PandocMonad m, Show a)
+ => String -> TWParser m a -> TWParser m B.Blocks
+listItemLine prefix marker = lineContent >>= parseContent >>= return . mconcat
+ where
+ lineContent = do
+ content <- anyLine
+ continuation <- optionMaybe listContinuation
+ 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
+ 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
+ rows <- many1 tableParseRow
+ return $ buildTable mempty rows $ fromMaybe (align rows, columns rows) tableHead
+ where
+ buildTable caption rows (aligns, heads)
+ = B.table caption aligns heads rows
+ align rows = replicate (columCount rows) (AlignDefault, 0)
+ columns rows = replicate (columCount rows) mempty
+ columCount rows = length $ head rows
+
+tableParseHeader :: PandocMonad m => TWParser m ((Alignment, Double), B.Blocks)
+tableParseHeader = try $ do
+ char '|'
+ leftSpaces <- many spaceChar >>= return . length
+ char '*'
+ content <- tableColumnContent (char '*' >> skipSpaces >> char '|')
+ char '*'
+ rightSpaces <- many spaceChar >>= return . length
+ optional tableEndOfRow
+ return (tableAlign leftSpaces rightSpaces, content)
+ where
+ tableAlign left right
+ | left >= 2 && left == right = (AlignCenter, 0)
+ | left > right = (AlignRight, 0)
+ | otherwise = (AlignLeft, 0)
+
+tableParseRow :: PandocMonad m => TWParser m [B.Blocks]
+tableParseRow = many1Till tableParseColumn newline
+
+tableParseColumn :: PandocMonad m => TWParser m B.Blocks
+tableParseColumn = char '|' *> skipSpaces *>
+ tableColumnContent (skipSpaces >> char '|')
+ <* skipSpaces <* optional tableEndOfRow
+
+tableEndOfRow :: PandocMonad m => TWParser m Char
+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
+ 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
+
+noautolink :: PandocMonad m => TWParser m B.Blocks
+noautolink = do
+ (_, content) <- htmlElement "noautolink"
+ st <- getState
+ setState $ st{ stateAllowLinks = False }
+ blocks <- try $ parseContent content
+ setState $ st{ stateAllowLinks = True }
+ return $ mconcat blocks
+ where
+ parseContent = parseFromString $ many $ block
+
+para :: PandocMonad m => TWParser m B.Blocks
+para = many1Till inline endOfParaElement >>= return . result . mconcat
+ where
+ endOfParaElement = lookAhead $ endOfInput <|> endOfPara <|> newBlockElement
+ endOfInput = try $ skipMany blankline >> skipSpaces >> eof
+ endOfPara = try $ blankline >> skipMany1 blankline
+ newBlockElement = try $ blankline >> skip blockElements
+ result content = if F.all (==Space) content
+ then mempty
+ else B.para $ B.trimInlines content
+
+
+--
+-- inline parsers
+--
+
+inline :: PandocMonad m => TWParser m B.Inlines
+inline = choice [ whitespace
+ , br
+ , macro
+ , strong
+ , strongHtml
+ , strongAndEmph
+ , emph
+ , emphHtml
+ , boldCode
+ , smart
+ , link
+ , htmlComment
+ , code
+ , codeHtml
+ , nop
+ , autoLink
+ , str
+ , symbol
+ ] <?> "inline"
+
+whitespace :: PandocMonad m => TWParser m B.Inlines
+whitespace = (lb <|> regsp) >>= return
+ where lb = try $ skipMany spaceChar >> linebreak >> return B.space
+ regsp = try $ skipMany1 spaceChar >> return B.space
+
+br :: PandocMonad m => TWParser m B.Inlines
+br = try $ string "%BR%" >> return B.linebreak
+
+linebreak :: PandocMonad m => TWParser m B.Inlines
+linebreak = newline >> notFollowedBy newline >> (lastNewline <|> innerNewline)
+ where lastNewline = eof >> return mempty
+ innerNewline = return B.space
+
+between :: (Monoid c, PandocMonad m)
+ => TWParser m a -> TWParser m b -> (TWParser m b -> TWParser m c)
+ -> TWParser m c
+between start end p =
+ mconcat <$> try (start >> notFollowedBy whitespace >> many1Till (p end) end)
+
+enclosed :: (Monoid b, PandocMonad m)
+ => 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
+ endSpace = (spaceChar <|> newline) >> return B.space
+
+macro :: PandocMonad m => TWParser m B.Inlines
+macro = macroWithParameters <|> withoutParameters
+ where
+ withoutParameters = enclosed (char '%') (\_ -> macroName) >>= return . emptySpan
+ emptySpan name = buildSpan name [] mempty
+
+macroWithParameters :: PandocMonad m => TWParser m B.Inlines
+macroWithParameters = try $ do
+ char '%'
+ name <- macroName
+ (content, kvs) <- attributes
+ char '%'
+ return $ buildSpan name kvs $ B.str content
+
+buildSpan :: String -> [(String, String)] -> B.Inlines -> B.Inlines
+buildSpan className kvs = B.spanWith attrs
+ where
+ attrs = ("", ["twiki-macro", className] ++ additionalClasses, kvsWithoutClasses)
+ additionalClasses = maybe [] words $ lookup "class" kvs
+ kvsWithoutClasses = [(k,v) | (k,v) <- kvs, k /= "class"]
+
+macroName :: PandocMonad m => TWParser m String
+macroName = do
+ first <- letter
+ rest <- many $ alphaNum <|> char '_'
+ return (first:rest)
+
+attributes :: PandocMonad m => TWParser m (String, [(String, String)])
+attributes = char '{' *> spnl *> many (attribute <* spnl) <* char '}' >>=
+ return . foldr (either mkContent mkKvs) ([], [])
+ where
+ spnl = skipMany (spaceChar <|> newline)
+ mkContent c ([], kvs) = (c, kvs)
+ mkContent c (rest, kvs) = (c ++ " " ++ rest, kvs)
+ mkKvs kv (cont, rest) = (cont, (kv : rest))
+
+attribute :: PandocMonad m => TWParser m (Either String (String, String))
+attribute = withKey <|> withoutKey
+ where
+ 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
+ withQuotes = between (char '"') (char '"') (\_ -> count 1 $ noneOf ['"'])
+ withoutQuotes allowSpaces
+ | allowSpaces == True = 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)
+ nestedInline = notFollowedBy whitespace >> nested inline
+
+strong :: PandocMonad m => TWParser m B.Inlines
+strong = try $ enclosed (char '*') nestedInlines >>= return . B.strong
+
+strongHtml :: PandocMonad m => TWParser m B.Inlines
+strongHtml = (parseHtmlContent "strong" inline <|> parseHtmlContent "b" inline)
+ >>= return . B.strong . mconcat
+
+strongAndEmph :: PandocMonad m => TWParser m B.Inlines
+strongAndEmph = try $ enclosed (string "__") nestedInlines >>= return . B.emph . B.strong
+
+emph :: PandocMonad m => TWParser m B.Inlines
+emph = try $ enclosed (char '_') nestedInlines >>= return . B.emph
+
+emphHtml :: PandocMonad m => TWParser m B.Inlines
+emphHtml = (parseHtmlContent "em" inline <|> parseHtmlContent "i" inline)
+ >>= return . B.emph . mconcat
+
+nestedString :: (Show a, PandocMonad m)
+ => TWParser m a -> TWParser m String
+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
+
+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
+
+codeHtml :: PandocMonad m => TWParser m B.Inlines
+codeHtml = do
+ (attrs, content) <- parseHtmlContentWithAttrs "code" anyChar
+ return $ B.codeWith attrs $ fromEntities content
+
+autoLink :: PandocMonad m => TWParser m B.Inlines
+autoLink = try $ do
+ state <- getState
+ guard $ stateAllowLinks state
+ (text, url) <- parseLink
+ guard $ checkLink (head $ reverse url)
+ return $ makeLink (text, url)
+ where
+ parseLink = notFollowedBy nop >> (uri <|> emailAddress)
+ makeLink (text, url) = B.link url "" $ B.str text
+ checkLink c
+ | c == '/' = True
+ | otherwise = isAlphaNum c
+
+str :: PandocMonad m => TWParser m B.Inlines
+str = (many1 alphaNum <|> count 1 characterReference) >>= return . B.str
+
+nop :: PandocMonad m => TWParser m B.Inlines
+nop = try $ (skip exclamation <|> skip nopTag) >> followContent
+ where
+ exclamation = char '!'
+ nopTag = stringAnyCase "<nop>"
+ followContent = many1 nonspaceChar >>= return . B.str . fromEntities
+
+symbol :: PandocMonad m => TWParser m B.Inlines
+symbol = count 1 nonspaceChar >>= return . B.str
+
+smart :: PandocMonad m => TWParser m B.Inlines
+smart = do
+ guardEnabled Ext_smart
+ doubleQuoted <|> singleQuoted <|>
+ choice [ apostrophe
+ , dash
+ , ellipses
+ ]
+
+singleQuoted :: PandocMonad m => TWParser m B.Inlines
+singleQuoted = try $ do
+ singleQuoteStart
+ withQuoteContext InSingleQuote $
+ many1Till inline singleQuoteEnd >>=
+ (return . B.singleQuoted . B.trimInlines . mconcat)
+
+doubleQuoted :: PandocMonad m => TWParser m B.Inlines
+doubleQuoted = try $ do
+ doubleQuoteStart
+ contents <- mconcat <$> many (try $ notFollowedBy doubleQuoteEnd >> inline)
+ (withQuoteContext InDoubleQuote $ doubleQuoteEnd >>
+ return (B.doubleQuoted $ B.trimInlines contents))
+ <|> (return $ (B.str "\8220") B.<> contents)
+
+link :: PandocMonad m => TWParser m B.Inlines
+link = try $ do
+ st <- getState
+ guard $ stateAllowLinks st
+ setState $ st{ stateAllowLinks = False }
+ (url, title, content) <- linkText
+ setState $ st{ stateAllowLinks = True }
+ return $ B.link url title content
+
+linkText :: PandocMonad m => TWParser m (String, String, B.Inlines)
+linkText = do
+ string "[["
+ url <- many1Till anyChar (char ']')
+ content <- option [B.str url] linkContent
+ char ']'
+ return (url, "", mconcat content)
+ where
+ linkContent = (char '[') >> many1Till anyChar (char ']') >>= parseLinkContent
+ parseLinkContent = parseFromString $ many1 inline
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs
new file mode 100644
index 000000000..6594b9ab8
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Textile.hs
@@ -0,0 +1,729 @@
+{-
+Copyright (C) 2010-2015 Paul Rivier <paul*rivier#demotera*com> | tr '*#' '.@'
+ 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.Textile
+ Copyright : Copyright (C) 2010-2015 Paul Rivier and John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Paul Rivier <paul*rivier#demotera*com>
+ Stability : alpha
+ Portability : portable
+
+Conversion from Textile to 'Pandoc' document, based on the spec
+available at http://redcloth.org/textile.
+
+Implemented and parsed:
+ - Paragraphs
+ - Code blocks
+ - Lists
+ - blockquote
+ - Inlines : strong, emph, cite, code, deleted, superscript,
+ subscript, links
+ - footnotes
+ - HTML-specific and CSS-specific attributes on headers
+
+Left to be implemented:
+ - dimension sign
+ - all caps
+ - continued blocks (ex bq..)
+
+TODO : refactor common patterns across readers :
+ - more ...
+
+-}
+
+
+module Text.Pandoc.Readers.Textile ( readTextile) where
+import Text.Pandoc.CSS
+import Text.Pandoc.Definition
+import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)
+import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.Options
+import Text.Pandoc.Parsing
+import Text.Pandoc.Logging
+import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag, isInlineTag )
+import Text.Pandoc.Shared (trim)
+import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )
+import Text.HTML.TagSoup (fromAttrib, Tag(..))
+import Text.HTML.TagSoup.Match
+import Data.List ( intercalate, transpose, intersperse )
+import Data.Char ( digitToInt, isUpper )
+import Control.Monad ( guard, liftM )
+import Data.Monoid ((<>))
+import Text.Pandoc.Class (PandocMonad, report)
+import Control.Monad.Except (throwError)
+
+-- | Parse a Textile text and return a Pandoc document.
+readTextile :: PandocMonad m
+ => ReaderOptions -- ^ Reader options
+ -> String -- ^ String to parse (assuming @'\n'@ line endings)
+ -> m Pandoc
+readTextile opts s = do
+ parsed <- readWithM parseTextile def{ stateOptions = opts } (s ++ "\n\n")
+ case parsed of
+ Right result -> return result
+ Left e -> throwError e
+
+
+-- | Generate a Pandoc ADT from a textile document
+parseTextile :: PandocMonad m => ParserT [Char] ParserState m Pandoc
+parseTextile = do
+ many blankline
+ startPos <- getPosition
+ -- go through once just to get list of reference keys and notes
+ -- docMinusKeys is the raw document with blanks where the keys/notes were...
+ let firstPassParser = noteBlock <|> lineClump
+ manyTill firstPassParser eof >>= setInput . concat
+ setPosition startPos
+ st' <- getState
+ let reversedNotes = stateNotes st'
+ updateState $ \s -> s { stateNotes = reverse reversedNotes }
+ -- now parse it for real...
+ blocks <- parseBlocks
+ return $ Pandoc nullMeta (B.toList blocks) -- FIXME
+
+noteMarker :: PandocMonad m => ParserT [Char] ParserState m [Char]
+noteMarker = skipMany spaceChar >> string "fn" >> manyTill digit (char '.')
+
+noteBlock :: PandocMonad m => ParserT [Char] ParserState m [Char]
+noteBlock = try $ do
+ startPos <- getPosition
+ ref <- noteMarker
+ optional blankline
+ contents <- liftM unlines $ many1Till anyLine (blanklines <|> noteBlock)
+ endPos <- getPosition
+ let newnote = (ref, contents ++ "\n")
+ st <- getState
+ let oldnotes = stateNotes st
+ updateState $ \s -> s { stateNotes = newnote : oldnotes }
+ -- return blanks so line count isn't affected
+ return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
+
+-- | Parse document blocks
+parseBlocks :: PandocMonad m => ParserT [Char] ParserState m Blocks
+parseBlocks = mconcat <$> manyTill block eof
+
+-- | Block parsers list tried in definition order
+blockParsers :: PandocMonad m => [ParserT [Char] ParserState m Blocks]
+blockParsers = [ codeBlock
+ , header
+ , blockQuote
+ , hrule
+ , commentBlock
+ , anyList
+ , rawHtmlBlock
+ , rawLaTeXBlock'
+ , table
+ , maybeExplicitBlock "p" para
+ , mempty <$ blanklines
+ ]
+
+-- | Any block in the order of definition of blockParsers
+block :: PandocMonad m => ParserT [Char] ParserState m Blocks
+block = do
+ res <- choice blockParsers <?> "block"
+ pos <- getPosition
+ report $ ParsingTrace (take 60 $ show $ B.toList res) pos
+ return res
+
+commentBlock :: PandocMonad m => ParserT [Char] ParserState m Blocks
+commentBlock = try $ do
+ string "###."
+ manyTill anyLine blanklines
+ return mempty
+
+codeBlock :: PandocMonad m => ParserT [Char] ParserState m Blocks
+codeBlock = codeBlockBc <|> codeBlockPre
+
+codeBlockBc :: PandocMonad m => ParserT [Char] ParserState m Blocks
+codeBlockBc = try $ do
+ string "bc."
+ extended <- option False (True <$ char '.')
+ char ' '
+ let starts = ["p", "table", "bq", "bc", "h1", "h2", "h3",
+ "h4", "h5", "h6", "pre", "###", "notextile"]
+ let ender = choice $ map explicitBlockStart starts
+ contents <- if extended
+ then do
+ f <- anyLine
+ rest <- many (notFollowedBy ender *> anyLine)
+ return (f:rest)
+ else manyTill anyLine blanklines
+ return $ B.codeBlock (trimTrailingNewlines (unlines contents))
+
+trimTrailingNewlines :: String -> String
+trimTrailingNewlines = reverse . dropWhile (=='\n') . reverse
+
+-- | Code Blocks in Textile are between <pre> and </pre>
+codeBlockPre :: PandocMonad m => ParserT [Char] ParserState m Blocks
+codeBlockPre = try $ do
+ (t@(TagOpen _ attrs),_) <- htmlTag (tagOpen (=="pre") (const True))
+ result' <- manyTill anyChar (htmlTag (tagClose (=="pre")))
+ optional blanklines
+ -- drop leading newline if any
+ let result'' = case result' of
+ '\n':xs -> xs
+ _ -> result'
+ -- drop trailing newline if any
+ let result''' = case reverse result'' of
+ '\n':_ -> init result''
+ _ -> result''
+ let classes = words $ fromAttrib "class" t
+ let ident = fromAttrib "id" t
+ let kvs = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"]
+ return $ B.codeBlockWith (ident,classes,kvs) result'''
+
+-- | Header of the form "hN. content" with N in 1..6
+header :: PandocMonad m => ParserT [Char] ParserState m Blocks
+header = try $ do
+ char 'h'
+ level <- digitToInt <$> oneOf "123456"
+ attr <- attributes
+ char '.'
+ lookAhead whitespace
+ name <- trimInlines . mconcat <$> many inline
+ attr' <- registerHeader attr name
+ return $ B.headerWith attr' level name
+
+-- | Blockquote of the form "bq. content"
+blockQuote :: PandocMonad m => ParserT [Char] ParserState m Blocks
+blockQuote = try $ do
+ string "bq" >> attributes >> char '.' >> whitespace
+ B.blockQuote <$> para
+
+-- Horizontal rule
+
+hrule :: PandocMonad m => ParserT [Char] st m Blocks
+hrule = try $ do
+ skipSpaces
+ start <- oneOf "-*"
+ count 2 (skipSpaces >> char start)
+ skipMany (spaceChar <|> char start)
+ newline
+ optional blanklines
+ return B.horizontalRule
+
+-- Lists handling
+
+-- | Can be a bullet list or an ordered list. This implementation is
+-- strict in the nesting, sublist must start at exactly "parent depth
+-- plus one"
+anyList :: PandocMonad m => ParserT [Char] ParserState m Blocks
+anyList = try $ anyListAtDepth 1 <* blanklines
+
+-- | This allow one type of list to be nested into an other type,
+-- provided correct nesting
+anyListAtDepth :: PandocMonad m => Int -> ParserT [Char] ParserState m Blocks
+anyListAtDepth depth = choice [ bulletListAtDepth depth,
+ orderedListAtDepth depth,
+ definitionList ]
+
+-- | Bullet List of given depth, depth being the number of leading '*'
+bulletListAtDepth :: PandocMonad m => Int -> ParserT [Char] ParserState m Blocks
+bulletListAtDepth depth = try $ B.bulletList <$> many1 (bulletListItemAtDepth depth)
+
+-- | Bullet List Item of given depth, depth being the number of
+-- leading '*'
+bulletListItemAtDepth :: PandocMonad m => Int -> ParserT [Char] ParserState m Blocks
+bulletListItemAtDepth = genericListItemAtDepth '*'
+
+-- | Ordered List of given depth, depth being the number of
+-- leading '#'
+orderedListAtDepth :: PandocMonad m => Int -> ParserT [Char] ParserState m Blocks
+orderedListAtDepth depth = try $ do
+ items <- many1 (orderedListItemAtDepth depth)
+ return $ B.orderedList items
+
+-- | Ordered List Item of given depth, depth being the number of
+-- leading '#'
+orderedListItemAtDepth :: PandocMonad m => Int -> ParserT [Char] ParserState m Blocks
+orderedListItemAtDepth = genericListItemAtDepth '#'
+
+-- | Common implementation of list items
+genericListItemAtDepth :: PandocMonad m => Char -> Int -> ParserT [Char] ParserState m Blocks
+genericListItemAtDepth c depth = try $ do
+ count depth (char c) >> attributes >> whitespace
+ p <- mconcat <$> many listInline
+ newline
+ sublist <- option mempty (anyListAtDepth (depth + 1))
+ return $ (B.plain p) <> sublist
+
+-- | A definition list is a set of consecutive definition items
+definitionList :: PandocMonad m => ParserT [Char] ParserState m Blocks
+definitionList = try $ B.definitionList <$> many1 definitionListItem
+
+-- | List start character.
+listStart :: PandocMonad m => ParserT [Char] ParserState m ()
+listStart = genericListStart '*'
+ <|> () <$ genericListStart '#'
+ <|> () <$ definitionListStart
+
+genericListStart :: PandocMonad m => Char -> ParserT [Char] st m ()
+genericListStart c = () <$ try (many1 (char c) >> whitespace)
+
+basicDLStart :: PandocMonad m => ParserT [Char] ParserState m ()
+basicDLStart = do
+ char '-'
+ whitespace
+ notFollowedBy newline
+
+definitionListStart :: PandocMonad m => ParserT [Char] ParserState m Inlines
+definitionListStart = try $ do
+ basicDLStart
+ trimInlines . mconcat <$>
+ many1Till inline
+ ( try (newline *> lookAhead basicDLStart)
+ <|> try (lookAhead (() <$ string ":="))
+ )
+
+listInline :: PandocMonad m => ParserT [Char] ParserState m Inlines
+listInline = try (notFollowedBy newline >> inline)
+ <|> try (endline <* notFollowedBy listStart)
+
+-- | A definition list item in textile begins with '- ', followed by
+-- the term defined, then spaces and ":=". The definition follows, on
+-- the same single line, or spaned on multiple line, after a line
+-- break.
+definitionListItem :: PandocMonad m => ParserT [Char] ParserState m (Inlines, [Blocks])
+definitionListItem = try $ do
+ term <- (mconcat . intersperse B.linebreak) <$> many1 definitionListStart
+ def' <- string ":=" *> optional whitespace *> (multilineDef <|> inlineDef)
+ return (term, def')
+ where inlineDef :: PandocMonad m => ParserT [Char] ParserState m [Blocks]
+ inlineDef = liftM (\d -> [B.plain d])
+ $ optional whitespace >> (trimInlines . mconcat <$> many listInline) <* newline
+ multilineDef :: PandocMonad m => ParserT [Char] ParserState m [Blocks]
+ multilineDef = try $ do
+ optional whitespace >> newline
+ s <- many1Till anyChar (try (string "=:" >> newline))
+ -- this ++ "\n\n" does not look very good
+ ds <- parseFromString parseBlocks (s ++ "\n\n")
+ return [ds]
+
+-- raw content
+
+-- | A raw Html Block, optionally followed by blanklines
+rawHtmlBlock :: PandocMonad m => ParserT [Char] ParserState m Blocks
+rawHtmlBlock = try $ do
+ skipMany spaceChar
+ (_,b) <- htmlTag isBlockTag
+ optional blanklines
+ return $ B.rawBlock "html" b
+
+-- | Raw block of LaTeX content
+rawLaTeXBlock' :: PandocMonad m => ParserT [Char] ParserState m Blocks
+rawLaTeXBlock' = do
+ guardEnabled Ext_raw_tex
+ B.rawBlock "latex" <$> (rawLaTeXBlock <* spaces)
+
+
+-- | In textile, paragraphs are separated by blank lines.
+para :: PandocMonad m => ParserT [Char] ParserState m Blocks
+para = B.para . trimInlines . mconcat <$> many1 inline
+
+-- Tables
+
+toAlignment :: Char -> Alignment
+toAlignment '<' = AlignLeft
+toAlignment '>' = AlignRight
+toAlignment '=' = AlignCenter
+toAlignment _ = AlignDefault
+
+cellAttributes :: PandocMonad m => ParserT [Char] ParserState m (Bool, Alignment)
+cellAttributes = try $ do
+ isHeader <- option False (True <$ char '_')
+ -- we just ignore colspan and rowspan markers:
+ optional $ try $ oneOf "/\\" >> many1 digit
+ -- we pay attention to alignments:
+ alignment <- option AlignDefault $ toAlignment <$> oneOf "<>="
+ -- ignore other attributes for now:
+ _ <- attributes
+ char '.'
+ return (isHeader, alignment)
+
+-- | A table cell spans until a pipe |
+tableCell :: PandocMonad m => ParserT [Char] ParserState m ((Bool, Alignment), Blocks)
+tableCell = try $ do
+ char '|'
+ (isHeader, alignment) <- option (False, AlignDefault) $ cellAttributes
+ notFollowedBy blankline
+ raw <- trim <$>
+ many (noneOf "|\n" <|> try (char '\n' <* notFollowedBy blankline))
+ content <- mconcat <$> parseFromString (many inline) raw
+ return ((isHeader, alignment), B.plain content)
+
+-- | A table row is made of many table cells
+tableRow :: PandocMonad m => ParserT [Char] ParserState m [((Bool, Alignment), Blocks)]
+tableRow = try $ do
+ -- skip optional row attributes
+ optional $ try $ do
+ _ <- attributes
+ char '.'
+ many1 spaceChar
+ many1 tableCell <* char '|' <* blankline
+
+-- | A table with an optional header.
+table :: PandocMonad m => ParserT [Char] ParserState m Blocks
+table = try $ do
+ -- ignore table attributes
+ caption <- option mempty $ try $ do
+ string "table"
+ _ <- attributes
+ char '.'
+ rawcapt <- trim <$> anyLine
+ parseFromString (mconcat <$> many inline) rawcapt
+ rawrows <- many1 $ (skipMany ignorableRow) >> tableRow
+ skipMany ignorableRow
+ blanklines
+ let (headers, rows) = case rawrows of
+ (toprow:rest) | any (fst . fst) toprow ->
+ (toprow, rest)
+ _ -> (mempty, rawrows)
+ let nbOfCols = max (length headers) (length $ head rows)
+ let aligns = map minimum $ transpose $ map (map (snd . fst)) (headers:rows)
+ return $ B.table caption
+ (zip aligns (replicate nbOfCols 0.0))
+ (map snd headers)
+ (map (map snd) rows)
+
+-- | Ignore markers for cols, thead, tfoot.
+ignorableRow :: PandocMonad m => ParserT [Char] ParserState m ()
+ignorableRow = try $ do
+ char '|'
+ oneOf ":^-~"
+ _ <- attributes
+ char '.'
+ _ <- anyLine
+ return ()
+
+explicitBlockStart :: PandocMonad m => String -> ParserT [Char] ParserState m ()
+explicitBlockStart name = try $ do
+ string name
+ attributes
+ char '.'
+ optional whitespace
+ optional endline
+
+-- | Blocks like 'p' and 'table' do not need explicit block tag.
+-- However, they can be used to set HTML/CSS attributes when needed.
+maybeExplicitBlock :: PandocMonad m
+ => String -- ^ block tag name
+ -> ParserT [Char] ParserState m Blocks -- ^ implicit block
+ -> ParserT [Char] ParserState m Blocks
+maybeExplicitBlock name blk = try $ do
+ optional $ explicitBlockStart name
+ blk
+
+
+
+----------
+-- Inlines
+----------
+
+
+-- | Any inline element
+inline :: PandocMonad m => ParserT [Char] ParserState m Inlines
+inline = do
+ choice inlineParsers <?> "inline"
+
+-- | Inline parsers tried in order
+inlineParsers :: PandocMonad m => [ParserT [Char] ParserState m Inlines]
+inlineParsers = [ str
+ , whitespace
+ , endline
+ , code
+ , escapedInline
+ , inlineMarkup
+ , groupedInlineMarkup
+ , rawHtmlInline
+ , rawLaTeXInline'
+ , note
+ , link
+ , image
+ , mark
+ , (B.str . (:[])) <$> characterReference
+ , smartPunctuation inline
+ , symbol
+ ]
+
+-- | Inline markups
+inlineMarkup :: PandocMonad m => ParserT [Char] ParserState m Inlines
+inlineMarkup = choice [ simpleInline (string "??") (B.cite [])
+ , simpleInline (string "**") B.strong
+ , simpleInline (string "__") B.emph
+ , simpleInline (char '*') B.strong
+ , simpleInline (char '_') B.emph
+ , simpleInline (char '+') B.emph -- approximates underline
+ , simpleInline (char '-' <* notFollowedBy (char '-')) B.strikeout
+ , simpleInline (char '^') B.superscript
+ , simpleInline (char '~') B.subscript
+ , simpleInline (char '%') id
+ ]
+
+-- | Trademark, registered, copyright
+mark :: PandocMonad m => ParserT [Char] st m Inlines
+mark = try $ char '(' >> (try tm <|> try reg <|> copy)
+
+reg :: PandocMonad m => ParserT [Char] st m Inlines
+reg = do
+ oneOf "Rr"
+ char ')'
+ return $ B.str "\174"
+
+tm :: PandocMonad m => ParserT [Char] st m Inlines
+tm = do
+ oneOf "Tt"
+ oneOf "Mm"
+ char ')'
+ return $ B.str "\8482"
+
+copy :: PandocMonad m => ParserT [Char] st m Inlines
+copy = do
+ oneOf "Cc"
+ char ')'
+ return $ B.str "\169"
+
+note :: PandocMonad m => ParserT [Char] ParserState m Inlines
+note = try $ do
+ ref <- (char '[' *> many1 digit <* char ']')
+ notes <- stateNotes <$> getState
+ case lookup ref notes of
+ Nothing -> fail "note not found"
+ Just raw -> B.note <$> parseFromString parseBlocks raw
+
+-- | Special chars
+markupChars :: [Char]
+markupChars = "\\*#_@~-+^|%=[]&"
+
+-- | Break strings on following chars. Space tab and newline break for
+-- inlines breaking. Open paren breaks for mark. Quote, dash and dot
+-- break for smart punctuation. Punctuation breaks for regular
+-- punctuation. Double quote breaks for named links. > and < break
+-- for inline html.
+stringBreakers :: [Char]
+stringBreakers = " \t\n\r.,\"'?!;:<>«»„“”‚‘’()[]"
+
+wordBoundaries :: [Char]
+wordBoundaries = markupChars ++ stringBreakers
+
+-- | Parse a hyphened sequence of words
+hyphenedWords :: PandocMonad m => ParserT [Char] ParserState m String
+hyphenedWords = do
+ x <- wordChunk
+ xs <- many (try $ char '-' >> wordChunk)
+ return $ intercalate "-" (x:xs)
+
+wordChunk :: PandocMonad m => ParserT [Char] ParserState m String
+wordChunk = try $ do
+ hd <- noneOf wordBoundaries
+ tl <- many ( (noneOf wordBoundaries) <|>
+ try (notFollowedBy' note *> oneOf markupChars
+ <* lookAhead (noneOf wordBoundaries) ) )
+ return $ hd:tl
+
+-- | Any string
+str :: PandocMonad m => ParserT [Char] ParserState m Inlines
+str = do
+ baseStr <- hyphenedWords
+ -- RedCloth compliance : if parsed word is uppercase and immediatly
+ -- followed by parens, parens content is unconditionally word acronym
+ fullStr <- option baseStr $ try $ do
+ guard $ all isUpper baseStr
+ acro <- enclosed (char '(') (char ')') anyChar'
+ return $ concat [baseStr, " (", acro, ")"]
+ updateLastStrPos
+ return $ B.str fullStr
+
+-- | Some number of space chars
+whitespace :: PandocMonad m => ParserT [Char] st m Inlines
+whitespace = many1 spaceChar >> return B.space <?> "whitespace"
+
+-- | In Textile, an isolated endline character is a line break
+endline :: PandocMonad m => ParserT [Char] ParserState m Inlines
+endline = try $ do
+ newline
+ notFollowedBy blankline
+ notFollowedBy listStart
+ notFollowedBy rawHtmlBlock
+ return B.linebreak
+
+rawHtmlInline :: PandocMonad m => ParserT [Char] ParserState m Inlines
+rawHtmlInline = B.rawInline "html" . snd <$> htmlTag isInlineTag
+
+-- | Raw LaTeX Inline
+rawLaTeXInline' :: PandocMonad m => ParserT [Char] ParserState m Inlines
+rawLaTeXInline' = try $ do
+ guardEnabled Ext_raw_tex
+ B.singleton <$> rawLaTeXInline
+
+-- | Textile standard link syntax is "label":target. But we
+-- can also have ["label":target].
+link :: PandocMonad m => ParserT [Char] ParserState m Inlines
+link = try $ do
+ bracketed <- (True <$ char '[') <|> return False
+ char '"' *> notFollowedBy (oneOf " \t\n\r")
+ attr <- attributes
+ name <- trimInlines . mconcat <$>
+ withQuoteContext InDoubleQuote (many1Till inline (char '"'))
+ char ':'
+ let stop = if bracketed
+ then char ']'
+ else lookAhead $ space <|>
+ try (oneOf "!.,;:" *> (space <|> newline))
+ url <- many1Till nonspaceChar stop
+ let name' = if B.toList name == [Str "$"] then B.str url else name
+ return $ if attr == nullAttr
+ then B.link url "" name'
+ else B.spanWith attr $ B.link url "" name'
+
+-- | image embedding
+image :: PandocMonad m => ParserT [Char] ParserState m Inlines
+image = try $ do
+ char '!' >> notFollowedBy space
+ (ident, cls, kvs) <- attributes
+ let attr = case lookup "style" kvs of
+ Just stls -> (ident, cls, pickStylesToKVs ["width", "height"] stls)
+ Nothing -> (ident, cls, kvs)
+ src <- many1 (noneOf " \t\n\r!(")
+ alt <- option "" $ try $ char '(' *> manyTill anyChar (char ')')
+ char '!'
+ return $ B.imageWith attr src alt (B.str alt)
+
+escapedInline :: PandocMonad m => ParserT [Char] ParserState m Inlines
+escapedInline = escapedEqs <|> escapedTag
+
+escapedEqs :: PandocMonad m => ParserT [Char] ParserState m Inlines
+escapedEqs = B.str <$>
+ (try $ string "==" *> manyTill anyChar' (try $ string "=="))
+
+-- | literal text escaped btw <notextile> tags
+escapedTag :: PandocMonad m => ParserT [Char] ParserState m Inlines
+escapedTag = B.str <$>
+ (try $ string "<notextile>" *>
+ manyTill anyChar' (try $ string "</notextile>"))
+
+-- | Any special symbol defined in wordBoundaries
+symbol :: PandocMonad m => ParserT [Char] ParserState m Inlines
+symbol = B.str . singleton <$> (notFollowedBy newline *>
+ notFollowedBy rawHtmlBlock *>
+ oneOf wordBoundaries)
+
+-- | Inline code
+code :: PandocMonad m => ParserT [Char] ParserState m Inlines
+code = code1 <|> code2
+
+-- any character except a newline before a blank line
+anyChar' :: PandocMonad m => ParserT [Char] ParserState m Char
+anyChar' =
+ satisfy (/='\n') <|> (try $ char '\n' <* notFollowedBy blankline)
+
+code1 :: PandocMonad m => ParserT [Char] ParserState m Inlines
+code1 = B.code <$> surrounded (char '@') anyChar'
+
+code2 :: PandocMonad m => ParserT [Char] ParserState m Inlines
+code2 = do
+ htmlTag (tagOpen (=="tt") null)
+ B.code <$> manyTill anyChar' (try $ htmlTag $ tagClose (=="tt"))
+
+-- | Html / CSS attributes
+attributes :: PandocMonad m => ParserT [Char] ParserState m Attr
+attributes = (foldl (flip ($)) ("",[],[])) <$>
+ try (do special <- option id specialAttribute
+ attrs <- many attribute
+ return (special : attrs))
+
+specialAttribute :: PandocMonad m => ParserT [Char] ParserState m (Attr -> Attr)
+specialAttribute = do
+ alignStr <- ("center" <$ char '=') <|>
+ ("justify" <$ try (string "<>")) <|>
+ ("right" <$ char '>') <|>
+ ("left" <$ char '<')
+ notFollowedBy spaceChar
+ return $ addStyle ("text-align:" ++ alignStr)
+
+attribute :: PandocMonad m => ParserT [Char] ParserState m (Attr -> Attr)
+attribute = try $
+ (classIdAttr <|> styleAttr <|> langAttr) <* notFollowedBy spaceChar
+
+classIdAttr :: PandocMonad m => ParserT [Char] ParserState m (Attr -> Attr)
+classIdAttr = try $ do -- (class class #id)
+ char '('
+ ws <- words `fmap` manyTill anyChar' (char ')')
+ case reverse ws of
+ [] -> return $ \(_,_,keyvals) -> ("",[],keyvals)
+ (('#':ident'):classes') -> return $ \(_,_,keyvals) ->
+ (ident',classes',keyvals)
+ classes' -> return $ \(_,_,keyvals) ->
+ ("",classes',keyvals)
+
+styleAttr :: PandocMonad m => ParserT [Char] ParserState m (Attr -> Attr)
+styleAttr = do
+ style <- try $ enclosed (char '{') (char '}') anyChar'
+ return $ addStyle style
+
+addStyle :: String -> Attr -> Attr
+addStyle style (id',classes,keyvals) =
+ (id',classes,keyvals')
+ where keyvals' = ("style", style') : [(k,v) | (k,v) <- keyvals, k /= "style"]
+ style' = style ++ ";" ++ concat [v | ("style",v) <- keyvals]
+
+langAttr :: PandocMonad m => ParserT [Char] ParserState m (Attr -> Attr)
+langAttr = do
+ lang <- try $ enclosed (char '[') (char ']') alphaNum
+ return $ \(id',classes,keyvals) -> (id',classes,("lang",lang):keyvals)
+
+-- | Parses material surrounded by a parser.
+surrounded :: PandocMonad m
+ => ParserT [Char] st m t -- ^ surrounding parser
+ -> ParserT [Char] st m a -- ^ content parser (to be used repeatedly)
+ -> ParserT [Char] st m [a]
+surrounded border =
+ enclosed (border *> notFollowedBy (oneOf " \t\n\r")) (try border)
+
+simpleInline :: PandocMonad m
+ => ParserT [Char] ParserState m t -- ^ surrounding parser
+ -> (Inlines -> Inlines) -- ^ Inline constructor
+ -> ParserT [Char] ParserState m Inlines -- ^ content parser (to be used repeatedly)
+simpleInline border construct = try $ do
+ notAfterString
+ border *> notFollowedBy (oneOf " \t\n\r")
+ attr <- attributes
+ body <- trimInlines . mconcat <$>
+ withQuoteContext InSingleQuote
+ (manyTill (notFollowedBy newline >> inline)
+ (try border <* notFollowedBy alphaNum))
+ return $ construct $
+ if attr == nullAttr
+ then body
+ else B.spanWith attr body
+
+groupedInlineMarkup :: PandocMonad m => ParserT [Char] ParserState m Inlines
+groupedInlineMarkup = try $ do
+ char '['
+ sp1 <- option mempty $ B.space <$ whitespace
+ result <- withQuoteContext InSingleQuote inlineMarkup
+ sp2 <- option mempty $ B.space <$ whitespace
+ char ']'
+ return $ sp1 <> result <> sp2
+
+-- | Create a singleton list
+singleton :: a -> [a]
+singleton x = [x]
+
diff --git a/src/Text/Pandoc/Readers/Txt2Tags.hs b/src/Text/Pandoc/Readers/Txt2Tags.hs
new file mode 100644
index 000000000..9e2b6963d
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Txt2Tags.hs
@@ -0,0 +1,596 @@
+{-# LANGUAGE ViewPatterns #-}
+{-
+Copyright (C) 2014 Matthew Pickering <matthewtpickering@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Readers.Txt2Tags
+ Copyright : Copyright (C) 2014 Matthew Pickering
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Matthew Pickering <matthewtpickering@gmail.com>
+
+Conversion of txt2tags formatted plain text to 'Pandoc' document.
+-}
+module Text.Pandoc.Readers.Txt2Tags ( readTxt2Tags
+ , getT2TMeta
+ , T2TMeta (..)
+ )
+ where
+
+import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.Builder ( Inlines, Blocks, trimInlines )
+import Data.Monoid ((<>))
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Text.Pandoc.Shared (escapeURI,compactify, compactifyDL)
+import Text.Pandoc.Parsing hiding (space, spaces, uri, macro)
+import Data.Char (toLower)
+import Data.List (transpose, intersperse, intercalate)
+import Data.Maybe (fromMaybe)
+--import Network.URI (isURI) -- Not sure whether to use this function
+import Control.Monad (void, guard, when)
+import Data.Default
+import Control.Monad.Reader (Reader, runReader, asks)
+
+import Data.Time.Format (formatTime)
+import Text.Pandoc.Compat.Time (defaultTimeLocale)
+import Control.Monad.Except (throwError, catchError)
+import Text.Pandoc.Class (PandocMonad)
+import qualified Text.Pandoc.Class as P
+
+type T2T = ParserT String ParserState (Reader T2TMeta)
+
+-- | An object for the T2T macros meta information
+-- the contents of each field is simply substituted verbatim into the file
+data T2TMeta = T2TMeta {
+ date :: String -- ^ Current date
+ , mtime :: String -- ^ Last modification time of infile
+ , infile :: FilePath -- ^ Input file
+ , outfile :: FilePath -- ^ Output file
+ } deriving Show
+
+instance Default T2TMeta where
+ def = T2TMeta "" "" "" ""
+
+-- | Get the meta information required by Txt2Tags macros
+getT2TMeta :: PandocMonad m => m T2TMeta
+getT2TMeta = do
+ mbInps <- P.getInputFiles
+ let inps = case mbInps of
+ Just x -> x
+ Nothing -> []
+ mbOutp <- P.getOutputFile
+ let outp = case mbOutp of
+ Just x -> x
+ Nothing -> ""
+ curDate <- formatTime defaultTimeLocale "%F" <$> P.getZonedTime
+ let getModTime = fmap (formatTime defaultTimeLocale "%T") .
+ P.getModificationTime
+ curMtime <- case inps of
+ [] -> formatTime defaultTimeLocale "%T" <$> P.getZonedTime
+ _ -> catchError
+ (maximum <$> mapM getModTime inps)
+ (const (return ""))
+ return $ T2TMeta curDate curMtime (intercalate ", " inps) outp
+
+-- | Read Txt2Tags from an input string returning a Pandoc document
+readTxt2Tags :: PandocMonad m
+ => ReaderOptions
+ -> String
+ -> m Pandoc
+readTxt2Tags opts s = do
+ meta <- getT2TMeta
+ let parsed = flip runReader meta $ readWithM parseT2T (def {stateOptions = opts}) (s ++ "\n\n")
+ case parsed of
+ Right result -> return $ result
+ Left e -> throwError e
+
+-- | Read Txt2Tags (ignoring all macros) from an input string returning
+-- a Pandoc document
+-- readTxt2TagsNoMacros :: PandocMonad m => ReaderOptions -> String -> m Pandoc
+-- readTxt2TagsNoMacros = readTxt2Tags
+
+parseT2T :: T2T Pandoc
+parseT2T = do
+ -- Parse header if standalone flag is set
+ standalone <- getOption readerStandalone
+ when standalone parseHeader
+ body <- mconcat <$> manyTill block eof
+ meta' <- stateMeta <$> getState
+ return $ Pandoc meta' (B.toList body)
+
+parseHeader :: T2T ()
+parseHeader = do
+ () <$ try blankline <|> header
+ meta <- stateMeta <$> getState
+ optional blanklines
+ config <- manyTill setting (notFollowedBy setting)
+ -- TODO: Handle settings better
+ let settings = foldr (\(k,v) -> B.setMeta k (MetaString v)) meta config
+ updateState (\s -> s {stateMeta = settings}) <* optional blanklines
+
+header :: T2T ()
+header = titleline >> authorline >> dateline
+
+headerline :: B.ToMetaValue a => String -> T2T a -> T2T ()
+headerline field p = (() <$ try blankline)
+ <|> (p >>= updateState . B.setMeta field)
+
+titleline :: T2T ()
+titleline =
+ headerline "title" (trimInlines . mconcat <$> manyTill inline newline)
+
+authorline :: T2T ()
+authorline =
+ headerline "author" (sepBy author (char ';') <* newline)
+ where
+ author = trimInlines . mconcat <$> many (notFollowedBy (char ';' <|> newline) >> inline)
+
+dateline :: T2T ()
+dateline = headerline "date" (trimInlines . mconcat <$> manyTill inline newline)
+
+type Keyword = String
+type Value = String
+
+setting :: T2T (Keyword, Value)
+setting = do
+ string "%!"
+ keyword <- ignoreSpacesCap (many1 alphaNum)
+ char ':'
+ value <- ignoreSpacesCap (manyTill anyChar (newline))
+ return (keyword, value)
+
+-- Blocks
+
+parseBlocks :: T2T Blocks
+parseBlocks = mconcat <$> manyTill block eof
+
+block :: T2T Blocks
+block = do
+ choice
+ [ mempty <$ blanklines
+ , quote
+ , hrule -- hrule must go above title
+ , title
+ , commentBlock
+ , verbatim
+ , rawBlock
+ , taggedBlock
+ , list
+ , table
+ , para
+ ]
+
+title :: T2T Blocks
+title = try $ balancedTitle '+' <|> balancedTitle '='
+
+balancedTitle :: Char -> T2T Blocks
+balancedTitle c = try $ do
+ spaces
+ level <- length <$> many1 (char c)
+ guard (level <= 5) -- Max header level 5
+ heading <- manyTill (noneOf "\n\r") (count level (char c))
+ label <- optionMaybe (enclosed (char '[') (char ']') (alphaNum <|> oneOf "_-"))
+ many spaceChar *> newline
+ let attr = maybe nullAttr (\x -> (x, [], [])) label
+ return $ B.headerWith attr level (trimInlines $ B.text heading)
+
+para :: T2T Blocks
+para = try $ do
+ ils <- parseInlines
+ nl <- option False (True <$ newline)
+ option (B.plain ils) (guard nl >> notFollowedBy listStart >> return (B.para ils))
+ where
+ listStart = try bulletListStart <|> orderedListStart
+
+commentBlock :: T2T Blocks
+commentBlock = try (blockMarkupArea (anyLine) (const mempty) "%%%") <|> comment
+
+-- Seperator and Strong line treated the same
+hrule :: T2T Blocks
+hrule = try $ do
+ spaces
+ line <- many1 (oneOf "=-_")
+ guard (length line >= 20)
+ B.horizontalRule <$ blankline
+
+quote :: T2T Blocks
+quote = try $ do
+ lookAhead tab
+ rawQuote <- many1 (tab *> optional spaces *> anyLine)
+ contents <- parseFromString parseBlocks (intercalate "\n" rawQuote ++ "\n\n")
+ return $ B.blockQuote contents
+
+commentLine :: T2T Inlines
+commentLine = comment
+
+-- List Parsing code from Org Reader
+
+list :: T2T Blocks
+list = choice [bulletList, orderedList, definitionList]
+
+bulletList :: T2T Blocks
+bulletList = B.bulletList . compactify
+ <$> many1 (listItem bulletListStart parseBlocks)
+
+orderedList :: T2T Blocks
+orderedList = B.orderedList . compactify
+ <$> many1 (listItem orderedListStart parseBlocks)
+
+definitionList :: T2T Blocks
+definitionList = try $ do
+ B.definitionList . compactifyDL <$>
+ many1 (listItem definitionListStart definitionListEnd)
+
+definitionListEnd :: T2T (Inlines, [Blocks])
+definitionListEnd = (,) <$> (mconcat <$> manyTill inline newline) <*> ((:[]) <$> parseBlocks)
+
+genericListStart :: T2T Char
+ -> T2T Int
+genericListStart listMarker = try $
+ (2+) <$> (length <$> many spaceChar
+ <* listMarker <* space <* notFollowedBy space)
+
+-- parses bullet list \start and returns its length (excl. following whitespace)
+bulletListStart :: T2T Int
+bulletListStart = genericListStart (char '-')
+
+orderedListStart :: T2T Int
+orderedListStart = genericListStart (char '+' )
+
+definitionListStart :: T2T Int
+definitionListStart = genericListStart (char ':')
+
+-- parse raw text for one list item, excluding start marker and continuations
+listItem :: T2T Int
+ -> T2T a
+ -> T2T a
+listItem start end = try $ do
+ markerLength <- try start
+ firstLine <- anyLineNewline
+ blank <- option "" ("\n" <$ blankline)
+ rest <- concat <$> many (listContinuation markerLength)
+ parseFromString end $ firstLine ++ blank ++ rest
+
+-- continuation of a list item - indented and separated by blankline or endline.
+-- Note: nested lists are parsed as continuations.
+listContinuation :: Int
+ -> T2T String
+listContinuation markerLength = try $
+ notFollowedBy' (blankline >> blankline)
+ *> (mappend <$> (concat <$> many1 listLine)
+ <*> many blankline)
+ where listLine = try $ indentWith markerLength *> anyLineNewline
+
+anyLineNewline :: T2T String
+anyLineNewline = (++ "\n") <$> anyLine
+
+indentWith :: Int -> T2T String
+indentWith n = count n space
+
+-- Table
+
+table :: T2T Blocks
+table = try $ do
+ tableHeader <- fmap snd <$> option mempty (try headerRow)
+ rows <- many1 (many commentLine *> tableRow)
+ let columns = transpose rows
+ let ncolumns = length columns
+ let aligns = map (foldr1 findAlign) (map (map fst) columns)
+ let rows' = map (map snd) rows
+ let size = maximum (map length rows')
+ let rowsPadded = map (pad size) rows'
+ let headerPadded = if (not (null tableHeader)) then pad size tableHeader else mempty
+ return $ B.table mempty
+ (zip aligns (replicate ncolumns 0.0))
+ headerPadded rowsPadded
+
+pad :: (Monoid a) => Int -> [a] -> [a]
+pad n xs = xs ++ (replicate (n - length xs) mempty)
+
+
+findAlign :: Alignment -> Alignment -> Alignment
+findAlign x y
+ | x == y = x
+ | otherwise = AlignDefault
+
+headerRow :: T2T [(Alignment, Blocks)]
+headerRow = genericRow (string "||")
+
+tableRow :: T2T [(Alignment, Blocks)]
+tableRow = genericRow (char '|')
+
+genericRow :: T2T a -> T2T [(Alignment, Blocks)]
+genericRow start = try $ do
+ spaces *> start
+ manyTill tableCell newline <?> "genericRow"
+
+
+tableCell :: T2T (Alignment, Blocks)
+tableCell = try $ do
+ leftSpaces <- length <$> lookAhead (many1 space) -- Case of empty cell means we must lookAhead
+ content <- (manyTill inline (try $ lookAhead (cellEnd)))
+ rightSpaces <- length <$> many space
+ let align =
+ case compare leftSpaces rightSpaces of
+ LT -> AlignLeft
+ EQ -> AlignCenter
+ GT -> AlignRight
+ endOfCell
+ return $ (align, B.plain (B.trimInlines $ mconcat content))
+ where
+ cellEnd = (void newline <|> (many1 space *> endOfCell))
+
+endOfCell :: T2T ()
+endOfCell = try (skipMany1 $ char '|') <|> ( () <$ lookAhead newline)
+
+-- Raw area
+
+verbatim :: T2T Blocks
+verbatim = genericBlock anyLineNewline B.codeBlock "```"
+
+rawBlock :: T2T Blocks
+rawBlock = genericBlock anyLineNewline (B.para . B.str) "\"\"\""
+
+taggedBlock :: T2T Blocks
+taggedBlock = do
+ target <- getTarget
+ genericBlock anyLineNewline (B.rawBlock target) "'''"
+
+-- Generic
+
+genericBlock :: Monoid a => T2T a -> (a -> Blocks) -> String -> T2T Blocks
+genericBlock p f s = blockMarkupArea p f s <|> blockMarkupLine p f s
+
+blockMarkupArea :: Monoid a => (T2T a) -> (a -> Blocks) -> String -> T2T Blocks
+blockMarkupArea p f s = try $ (do
+ string s *> blankline
+ f . mconcat <$> (manyTill p (eof <|> void (string s *> blankline))))
+
+blockMarkupLine :: T2T a -> (a -> Blocks) -> String -> T2T Blocks
+blockMarkupLine p f s = try (f <$> (string s *> space *> p))
+
+-- Can be in either block or inline position
+comment :: Monoid a => T2T a
+comment = try $ do
+ atStart
+ notFollowedBy macro
+ mempty <$ (char '%' *> anyLine)
+
+-- Inline
+
+parseInlines :: T2T Inlines
+parseInlines = trimInlines . mconcat <$> many1 inline
+
+inline :: T2T Inlines
+inline = do
+ choice
+ [ endline
+ , macro
+ , commentLine
+ , whitespace
+ , url
+ , link
+ , image
+ , bold
+ , underline
+ , code
+ , raw
+ , tagged
+ , strike
+ , italic
+ , code
+ , str
+ , symbol
+ ]
+
+bold :: T2T Inlines
+bold = inlineMarkup inline B.strong '*' (B.str)
+
+underline :: T2T Inlines
+underline = inlineMarkup inline B.emph '_' (B.str)
+
+strike :: T2T Inlines
+strike = inlineMarkup inline B.strikeout '-' (B.str)
+
+italic :: T2T Inlines
+italic = inlineMarkup inline B.emph '/' (B.str)
+
+code :: T2T Inlines
+code = inlineMarkup ((:[]) <$> anyChar) B.code '`' id
+
+raw :: T2T Inlines
+raw = inlineMarkup ((:[]) <$> anyChar) B.text '"' id
+
+tagged :: T2T Inlines
+tagged = do
+ target <- getTarget
+ inlineMarkup ((:[]) <$> anyChar) (B.rawInline target) '\'' id
+
+-- Parser for markup indicated by a double character.
+-- Inline markup is greedy and glued
+-- Greedy meaning ***a*** = Bold [Str "*a*"]
+-- Glued meaning that markup must be tight to content
+-- Markup can't pass newlines
+inlineMarkup :: Monoid a
+ => (T2T a) -- Content parser
+ -> (a -> Inlines) -- Constructor
+ -> Char -- Fence
+ -> (String -> a) -- Special Case to handle ******
+ -> T2T Inlines
+inlineMarkup p f c special = try $ do
+ start <- many1 (char c)
+ let l = length start
+ guard (l >= 2)
+ when (l == 2) (void $ notFollowedBy space)
+ -- We must make sure that there is no space before the start of the
+ -- closing tags
+ body <- optionMaybe (try $ manyTill (noneOf "\n\r") $
+ (try $ lookAhead (noneOf " " >> string [c,c] )))
+ case body of
+ Just middle -> do
+ lastChar <- anyChar
+ end <- many1 (char c)
+ let parser inp = parseFromString (mconcat <$> many p) inp
+ let start' = case drop 2 start of
+ "" -> mempty
+ xs -> special xs
+ body' <- parser (middle ++ [lastChar])
+ let end' = case drop 2 end of
+ "" -> mempty
+ xs -> special xs
+ return $ f (start' <> body' <> end')
+ Nothing -> do -- Either bad or case such as *****
+ guard (l >= 5)
+ let body' = (replicate (l - 4) c)
+ return $ f (special body')
+
+link :: T2T Inlines
+link = try imageLink <|> titleLink
+
+-- Link with title
+titleLink :: T2T Inlines
+titleLink = try $ do
+ char '['
+ notFollowedBy space
+ tokens <- sepBy1 (many $ noneOf " ]") space
+ guard (length tokens >= 2)
+ char ']'
+ let link' = last tokens
+ guard (length link' > 0)
+ let tit = concat (intersperse " " (init tokens))
+ return $ B.link link' "" (B.text tit)
+
+-- Link with image
+imageLink :: T2T Inlines
+imageLink = try $ do
+ char '['
+ body <- image
+ many1 space
+ l <- manyTill (noneOf "\n\r ") (char ']')
+ return (B.link l "" body)
+
+macro :: T2T Inlines
+macro = try $ do
+ name <- string "%%" *> oneOfStringsCI (map fst commands)
+ optional (try $ enclosed (char '(') (char ')') anyChar)
+ lookAhead (spaceChar <|> oneOf specialChars <|> newline)
+ maybe (return mempty) (\f -> B.str <$> asks f) (lookup name commands)
+ where
+ commands = [ ("date", date), ("mtime", mtime)
+ , ("infile", infile), ("outfile", outfile)]
+
+-- raw URLs in text are automatically linked
+url :: T2T Inlines
+url = try $ do
+ (rawUrl, escapedUrl) <- (try uri <|> emailAddress)
+ return $ B.link rawUrl "" (B.str escapedUrl)
+
+uri :: T2T (String, String)
+uri = try $ do
+ address <- t2tURI
+ return (address, escapeURI address)
+
+-- The definition of a URI in the T2T source differs from the
+-- actual definition. This is a transcription of the definition in
+-- the source of v2.6
+--isT2TURI :: String -> Bool
+--isT2TURI (parse t2tURI "" -> Right _) = True
+--isT2TURI _ = False
+
+t2tURI :: T2T String
+t2tURI = do
+ start <- try ((++) <$> proto <*> urlLogin) <|> guess
+ domain <- many1 chars
+ sep <- many (char '/')
+ form' <- option mempty ((:) <$> char '?' <*> many1 form)
+ anchor' <- option mempty ((:) <$> char '#' <*> many anchor)
+ return (start ++ domain ++ sep ++ form' ++ anchor')
+ where
+ protos = ["http", "https", "ftp", "telnet", "gopher", "wais"]
+ proto = (++) <$> oneOfStrings protos <*> string "://"
+ guess = (++) <$> (((++) <$> stringAnyCase "www" <*> option mempty ((:[]) <$> oneOf "23"))
+ <|> stringAnyCase "ftp") <*> ((:[]) <$> char '.')
+ login = alphaNum <|> oneOf "_.-"
+ pass = many (noneOf " @")
+ chars = alphaNum <|> oneOf "%._/~:,=$@&+-"
+ anchor = alphaNum <|> oneOf "%._0"
+ form = chars <|> oneOf ";*"
+ urlLogin = option mempty $ try ((\x y z -> x ++ y ++ [z]) <$> many1 login <*> option mempty ((:) <$> char ':' <*> pass) <*> char '@')
+
+
+image :: T2T Inlines
+image = try $ do
+ -- List taken from txt2tags source
+ let extensions = [".jpg", ".jpeg", ".gif", ".png", ".eps", ".bmp"]
+ char '['
+ path <- manyTill (noneOf "\n\t\r ") (try $ lookAhead (oneOfStrings extensions))
+ ext <- oneOfStrings extensions
+ char ']'
+ return $ B.image (path ++ ext) "" mempty
+
+-- Characters used in markup
+specialChars :: String
+specialChars = "%*-_/|:+;"
+
+tab :: T2T Char
+tab = char '\t'
+
+space :: T2T Char
+space = char ' '
+
+spaces :: T2T String
+spaces = many space
+
+endline :: T2T Inlines
+endline = try $ do
+ newline
+ notFollowedBy blankline
+ notFollowedBy hrule
+ notFollowedBy title
+ notFollowedBy verbatim
+ notFollowedBy rawBlock
+ notFollowedBy taggedBlock
+ notFollowedBy quote
+ notFollowedBy list
+ notFollowedBy table
+ return $ B.softbreak
+
+str :: T2T Inlines
+str = try $ do
+ B.str <$> many1 (noneOf $ specialChars ++ "\n\r ")
+
+whitespace :: T2T Inlines
+whitespace = try $ B.space <$ spaceChar
+
+symbol :: T2T Inlines
+symbol = B.str . (:[]) <$> oneOf specialChars
+
+-- Utility
+
+getTarget :: T2T String
+getTarget = do
+ mv <- lookupMeta "target" . stateMeta <$> getState
+ let MetaString target = fromMaybe (MetaString "html") mv
+ return target
+
+atStart :: T2T ()
+atStart = (sourceColumn <$> getPosition) >>= guard . (== 1)
+
+ignoreSpacesCap :: T2T String -> T2T String
+ignoreSpacesCap p = map toLower <$> (spaces *> p <* spaces)
diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs
new file mode 100644
index 000000000..85b298a85
--- /dev/null
+++ b/src/Text/Pandoc/SelfContained.hs
@@ -0,0 +1,181 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-
+Copyright (C) 2011-2016 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.SelfContained
+ Copyright : Copyright (C) 2011-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Functions for converting an HTML file into one that can be viewed
+offline, by incorporating linked images, CSS, and scripts into
+the HTML using data URIs.
+-}
+module Text.Pandoc.SelfContained ( makeSelfContained ) where
+import Text.HTML.TagSoup
+import Network.URI (isURI, escapeURIString, URI(..), parseURI)
+import Data.ByteString.Base64
+import qualified Data.ByteString.Char8 as B
+import Data.ByteString (ByteString)
+import System.FilePath (takeExtension, takeDirectory, (</>))
+import Data.Char (toLower, isAscii, isAlphaNum)
+import Codec.Compression.GZip as Gzip
+import qualified Data.ByteString.Lazy as L
+import Control.Monad.Trans (MonadIO(..))
+import Text.Pandoc.Shared (renderTags', err, warn, trim)
+import Text.Pandoc.MediaBag (MediaBag)
+import Text.Pandoc.MIME (MimeType)
+import Text.Pandoc.UTF8 (toString)
+import Text.Pandoc.Options (WriterOptions(..))
+import Data.List (isPrefixOf)
+import Control.Applicative ((<|>))
+import Text.Parsec (runParserT, ParsecT)
+import qualified Text.Parsec as P
+import Control.Monad.Trans (lift)
+import Text.Pandoc.Class (fetchItem, runIO, setMediaBag)
+
+isOk :: Char -> Bool
+isOk c = isAscii c && isAlphaNum c
+
+makeDataURI :: String -> ByteString -> String
+makeDataURI mime raw =
+ if textual
+ then "data:" ++ mime' ++ "," ++ escapeURIString isOk (toString raw)
+ else "data:" ++ mime' ++ ";base64," ++ toString (encode raw)
+ where textual = "text/" `Data.List.isPrefixOf` mime
+ mime' = if textual && ';' `notElem` mime
+ then mime ++ ";charset=utf-8"
+ else mime -- mime type already has charset
+
+convertTag :: MediaBag -> Maybe String -> Tag String -> IO (Tag String)
+convertTag media sourceURL t@(TagOpen tagname as)
+ | tagname `elem`
+ ["img", "embed", "video", "input", "audio", "source", "track"] = do
+ as' <- mapM processAttribute as
+ return $ TagOpen tagname as'
+ where processAttribute (x,y) =
+ if x == "src" || x == "href" || x == "poster"
+ then do
+ enc <- getDataURI media sourceURL (fromAttrib "type" t) y
+ return (x, enc)
+ else return (x,y)
+convertTag media sourceURL t@(TagOpen "script" as) =
+ case fromAttrib "src" t of
+ [] -> return t
+ src -> do
+ enc <- getDataURI media sourceURL (fromAttrib "type" t) src
+ return $ TagOpen "script" (("src",enc) : [(x,y) | (x,y) <- as, x /= "src"])
+convertTag media sourceURL t@(TagOpen "link" as) =
+ case fromAttrib "href" t of
+ [] -> return t
+ src -> do
+ enc <- getDataURI media sourceURL (fromAttrib "type" t) src
+ return $ TagOpen "link" (("href",enc) : [(x,y) | (x,y) <- as, x /= "href"])
+convertTag _ _ t = return t
+
+cssURLs :: MediaBag -> Maybe String -> FilePath -> ByteString
+ -> IO ByteString
+cssURLs media sourceURL d orig = do
+ res <- runParserT (parseCSSUrls media sourceURL d) () "css" orig
+ case res of
+ Left e -> warn ("Could not parse CSS: " ++ show e) >> return orig
+ Right bs -> return bs
+
+parseCSSUrls :: MediaBag -> Maybe String -> FilePath
+ -> ParsecT ByteString () IO ByteString
+parseCSSUrls media sourceURL d = B.concat <$> P.many
+ (pCSSWhite <|> pCSSComment <|> pCSSUrl media sourceURL d <|> pCSSOther)
+
+-- Note: some whitespace in CSS is significant, so we can't collapse it!
+pCSSWhite :: ParsecT ByteString () IO ByteString
+pCSSWhite = B.singleton <$> P.space <* P.spaces
+
+pCSSComment :: ParsecT ByteString () IO ByteString
+pCSSComment = P.try $ do
+ P.string "/*"
+ P.manyTill P.anyChar (P.try (P.string "*/"))
+ return B.empty
+
+pCSSOther :: ParsecT ByteString () IO ByteString
+pCSSOther = do
+ (B.pack <$> P.many1 (P.noneOf "u/ \n\r\t")) <|>
+ (B.singleton <$> P.char 'u') <|>
+ (B.singleton <$> P.char '/')
+
+pCSSUrl :: MediaBag -> Maybe String -> FilePath
+ -> ParsecT ByteString () IO ByteString
+pCSSUrl media sourceURL d = P.try $ do
+ P.string "url("
+ P.spaces
+ quote <- P.option Nothing (Just <$> P.oneOf "\"'")
+ url <- P.manyTill P.anyChar (maybe (P.lookAhead (P.char ')')) P.char quote)
+ P.spaces
+ P.char ')'
+ let fallback = B.pack ("url(" ++ maybe "" (:[]) quote ++ trim url ++
+ maybe "" (:[]) quote ++ ")")
+ case trim url of
+ '#':_ -> return fallback
+ 'd':'a':'t':'a':':':_ -> return fallback
+ u -> do let url' = if isURI u then u else d </> u
+ enc <- lift $ getDataURI media sourceURL "" url'
+ return (B.pack $ "url(" ++ enc ++ ")")
+
+
+getDataURI :: MediaBag -> Maybe String -> MimeType -> String
+ -> IO String
+getDataURI _ _ _ src@('d':'a':'t':'a':':':_) = return src -- already data: uri
+getDataURI media sourceURL mimetype src = do
+ let ext = map toLower $ takeExtension src
+ fetchResult <- runIO $ do setMediaBag media
+ fetchItem sourceURL src
+ (raw, respMime) <- case fetchResult of
+ Left msg -> err 67 $ "Could not fetch " ++ src ++
+ "\n" ++ show msg
+ Right x -> return x
+ let raw' = if ext == ".gz"
+ then B.concat $ L.toChunks $ Gzip.decompress $ L.fromChunks
+ $ [raw]
+ else raw
+ let mime = case (mimetype, respMime) of
+ ("",Nothing) -> error
+ $ "Could not determine mime type for `" ++ src ++ "'"
+ (x, Nothing) -> x
+ (_, Just x ) -> x
+ let cssSourceURL = case parseURI src of
+ Just u
+ | uriScheme u `elem` ["http:","https:"] ->
+ Just $ show u{ uriPath = "",
+ uriQuery = "",
+ uriFragment = "" }
+ _ -> Nothing
+ result <- if mime == "text/css"
+ then cssURLs media cssSourceURL (takeDirectory src) raw'
+ else return raw'
+ return $ makeDataURI mime result
+
+-- | Convert HTML into self-contained HTML, incorporating images,
+-- scripts, and CSS using data: URIs.
+makeSelfContained :: MonadIO m => WriterOptions -> MediaBag -> String -> m String
+makeSelfContained opts mediabag inp = liftIO $ do
+ let tags = parseTags inp
+ out' <- mapM (convertTag mediabag (writerSourceURL opts)) tags
+ return $ renderTags' out'
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
new file mode 100644
index 000000000..268a5052e
--- /dev/null
+++ b/src/Text/Pandoc/Shared.hs
@@ -0,0 +1,883 @@
+{-# LANGUAGE DeriveDataTypeable, CPP, MultiParamTypeClasses,
+ FlexibleContexts, ScopedTypeVariables, PatternGuards,
+ ViewPatterns #-}
+{-
+Copyright (C) 2006-2016 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.Shared
+ Copyright : Copyright (C) 2006-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Utility functions and definitions used by the various Pandoc modules.
+-}
+module Text.Pandoc.Shared (
+ -- * List processing
+ splitBy,
+ splitByIndices,
+ splitStringByIndices,
+ substitute,
+ ordNub,
+ -- * Text processing
+ backslashEscapes,
+ escapeStringUsing,
+ stripTrailingNewlines,
+ trim,
+ triml,
+ trimr,
+ stripFirstAndLast,
+ camelCaseToHyphenated,
+ toRomanNumeral,
+ escapeURI,
+ tabFilter,
+ -- * Date/time
+ normalizeDate,
+ -- * Pandoc block and inline list processing
+ orderedListMarkers,
+ normalizeSpaces,
+ extractSpaces,
+ removeFormatting,
+ deNote,
+ stringify,
+ capitalize,
+ compactify,
+ compactifyDL,
+ linesToPara,
+ Element (..),
+ hierarchicalize,
+ uniqueIdent,
+ inlineListToIdentifier,
+ isHeaderBlock,
+ headerShift,
+ isTightList,
+ addMetaField,
+ makeMeta,
+ -- * TagSoup HTML handling
+ renderTags',
+ -- * File handling
+ inDirectory,
+ getDefaultReferenceDocx,
+ getDefaultReferenceODT,
+ readDataFile,
+ readDataFileUTF8,
+ openURL,
+ collapseFilePath,
+ filteredFilesFromArchive,
+ -- * Error handling
+ err,
+ warn,
+ mapLeft,
+ -- * for squashing blocks
+ blocksToInlines,
+ -- * Safe read
+ safeRead,
+ -- * Temp directory
+ withTempDir,
+ -- * Version
+ pandocVersion
+ ) where
+
+import Text.Pandoc.Definition
+import Text.Pandoc.Walk
+import Text.Pandoc.Builder (Inlines, Blocks, ToMetaValue(..))
+import qualified Text.Pandoc.Builder as B
+import qualified Text.Pandoc.UTF8 as UTF8
+import System.Exit (exitWith, ExitCode(..))
+import Data.Char ( toLower, isLower, isUpper, isAlpha,
+ isLetter, isDigit, isSpace )
+import Data.List ( find, stripPrefix, intercalate )
+import Data.Maybe (mapMaybe)
+import Data.Version ( showVersion )
+import qualified Data.Map as M
+import Network.URI ( escapeURIString, unEscapeString )
+import qualified Data.Set as Set
+import System.Directory
+import System.FilePath (splitDirectories, isPathSeparator)
+import qualified System.FilePath.Posix as Posix
+import Text.Pandoc.MIME (MimeType)
+import System.FilePath ( (</>) )
+import Data.Generics (Typeable, Data)
+import qualified Control.Monad.State as S
+import Control.Monad.Trans (MonadIO (..))
+import qualified Control.Exception as E
+import Control.Monad (msum, unless, MonadPlus(..))
+import Text.Pandoc.Pretty (charWidth)
+import Text.Pandoc.Compat.Time
+import Data.Time.Clock.POSIX
+import System.IO (stderr)
+import System.IO.Temp
+import Text.HTML.TagSoup (renderTagsOptions, RenderOptions(..), Tag(..),
+ renderOptions)
+import Data.Monoid ((<>))
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Char8 as B8
+import Data.ByteString.Base64 (decodeLenient)
+import Data.Sequence (ViewR(..), ViewL(..), viewl, viewr)
+import qualified Data.Text as T (toUpper, pack, unpack)
+import Data.ByteString.Lazy (toChunks, fromChunks)
+import qualified Data.ByteString.Lazy as BL
+import Paths_pandoc (version)
+
+import Codec.Archive.Zip
+
+#ifdef EMBED_DATA_FILES
+import Text.Pandoc.Data (dataFiles)
+#else
+import Paths_pandoc (getDataFileName)
+#endif
+#ifdef HTTP_CLIENT
+import Network.HTTP.Client (httpLbs, responseBody, responseHeaders,
+ Request(port,host,requestHeaders))
+import Network.HTTP.Client (parseRequest)
+import Network.HTTP.Client (newManager)
+import Network.HTTP.Client.Internal (addProxy)
+import Network.HTTP.Client.TLS (tlsManagerSettings)
+import System.Environment (getEnv)
+import Network.HTTP.Types.Header ( hContentType, hUserAgent)
+import Network (withSocketsDo)
+#else
+import Network.URI (parseURI)
+import Network.HTTP (findHeader, rspBody,
+ RequestMethod(..), HeaderName(..), mkRequest)
+import Network.Browser (browse, setAllowRedirects, setOutHandler, request)
+#endif
+
+-- | Version number of pandoc library.
+pandocVersion :: String
+pandocVersion = showVersion version
+
+--
+-- List processing
+--
+
+-- | Split list by groups of one or more sep.
+splitBy :: (a -> Bool) -> [a] -> [[a]]
+splitBy _ [] = []
+splitBy isSep lst =
+ let (first, rest) = break isSep lst
+ rest' = dropWhile isSep rest
+ in first:(splitBy isSep rest')
+
+splitByIndices :: [Int] -> [a] -> [[a]]
+splitByIndices [] lst = [lst]
+splitByIndices (x:xs) lst = first:(splitByIndices (map (\y -> y - x) xs) rest)
+ where (first, rest) = splitAt x lst
+
+-- | Split string into chunks divided at specified indices.
+splitStringByIndices :: [Int] -> [Char] -> [[Char]]
+splitStringByIndices [] lst = [lst]
+splitStringByIndices (x:xs) lst =
+ let (first, rest) = splitAt' x lst in
+ first : (splitStringByIndices (map (\y -> y - x) xs) rest)
+
+splitAt' :: Int -> [Char] -> ([Char],[Char])
+splitAt' _ [] = ([],[])
+splitAt' n xs | n <= 0 = ([],xs)
+splitAt' n (x:xs) = (x:ys,zs)
+ where (ys,zs) = splitAt' (n - charWidth x) xs
+
+-- | Replace each occurrence of one sublist in a list with another.
+substitute :: (Eq a) => [a] -> [a] -> [a] -> [a]
+substitute _ _ [] = []
+substitute [] _ xs = xs
+substitute target replacement lst@(x:xs) =
+ case stripPrefix target lst of
+ Just lst' -> replacement ++ substitute target replacement lst'
+ Nothing -> x : substitute target replacement xs
+
+ordNub :: (Ord a) => [a] -> [a]
+ordNub l = go Set.empty l
+ where
+ go _ [] = []
+ go s (x:xs) = if x `Set.member` s then go s xs
+ else x : go (Set.insert x s) xs
+
+--
+-- Text processing
+--
+
+-- | Returns an association list of backslash escapes for the
+-- designated characters.
+backslashEscapes :: [Char] -- ^ list of special characters to escape
+ -> [(Char, String)]
+backslashEscapes = map (\ch -> (ch, ['\\',ch]))
+
+-- | Escape a string of characters, using an association list of
+-- characters and strings.
+escapeStringUsing :: [(Char, String)] -> String -> String
+escapeStringUsing _ [] = ""
+escapeStringUsing escapeTable (x:xs) =
+ case (lookup x escapeTable) of
+ Just str -> str ++ rest
+ Nothing -> x:rest
+ where rest = escapeStringUsing escapeTable xs
+
+-- | Strip trailing newlines from string.
+stripTrailingNewlines :: String -> String
+stripTrailingNewlines = reverse . dropWhile (== '\n') . reverse
+
+-- | Remove leading and trailing space (including newlines) from string.
+trim :: String -> String
+trim = triml . trimr
+
+-- | Remove leading space (including newlines) from string.
+triml :: String -> String
+triml = dropWhile (`elem` " \r\n\t")
+
+-- | Remove trailing space (including newlines) from string.
+trimr :: String -> String
+trimr = reverse . triml . reverse
+
+-- | Strip leading and trailing characters from string
+stripFirstAndLast :: String -> String
+stripFirstAndLast str =
+ drop 1 $ take ((length str) - 1) str
+
+-- | Change CamelCase word to hyphenated lowercase (e.g., camel-case).
+camelCaseToHyphenated :: String -> String
+camelCaseToHyphenated [] = ""
+camelCaseToHyphenated (a:b:rest) | isLower a && isUpper b =
+ a:'-':(toLower b):(camelCaseToHyphenated rest)
+camelCaseToHyphenated (a:rest) = (toLower a):(camelCaseToHyphenated rest)
+
+-- | Convert number < 4000 to uppercase roman numeral.
+toRomanNumeral :: Int -> String
+toRomanNumeral x
+ | x >= 4000 || x < 0 = "?"
+ | x >= 1000 = "M" ++ toRomanNumeral (x - 1000)
+ | x >= 900 = "CM" ++ toRomanNumeral (x - 900)
+ | x >= 500 = "D" ++ toRomanNumeral (x - 500)
+ | x >= 400 = "CD" ++ toRomanNumeral (x - 400)
+ | x >= 100 = "C" ++ toRomanNumeral (x - 100)
+ | x >= 90 = "XC" ++ toRomanNumeral (x - 90)
+ | x >= 50 = "L" ++ toRomanNumeral (x - 50)
+ | x >= 40 = "XL" ++ toRomanNumeral (x - 40)
+ | x >= 10 = "X" ++ toRomanNumeral (x - 10)
+ | x == 9 = "IX"
+ | x >= 5 = "V" ++ toRomanNumeral (x - 5)
+ | x == 4 = "IV"
+ | x >= 1 = "I" ++ toRomanNumeral (x - 1)
+ | otherwise = ""
+
+-- | Escape whitespace and some punctuation characters in URI.
+escapeURI :: String -> String
+escapeURI = escapeURIString (not . needsEscaping)
+ where needsEscaping c = isSpace c || c `elem`
+ ['<','>','|','"','{','}','[',']','^', '`']
+
+
+-- | Convert tabs to spaces and filter out DOS line endings.
+-- Tabs will be preserved if tab stop is set to 0.
+tabFilter :: Int -- ^ Tab stop
+ -> String -- ^ Input
+ -> String
+tabFilter tabStop =
+ let go _ [] = ""
+ go _ ('\n':xs) = '\n' : go tabStop xs
+ go _ ('\r':'\n':xs) = '\n' : go tabStop xs
+ go _ ('\r':xs) = '\n' : go tabStop xs
+ go spsToNextStop ('\t':xs) =
+ if tabStop == 0
+ then '\t' : go tabStop xs
+ else replicate spsToNextStop ' ' ++ go tabStop xs
+ go 1 (x:xs) =
+ x : go tabStop xs
+ go spsToNextStop (x:xs) =
+ x : go (spsToNextStop - 1) xs
+ in go tabStop
+
+--
+-- Date/time
+--
+
+-- | Parse a date and convert (if possible) to "YYYY-MM-DD" format. We
+-- limit years to the range 1601-9999 (ISO 8601 accepts greater than
+-- or equal to 1583, but MS Word only accepts dates starting 1601).
+normalizeDate :: String -> Maybe String
+normalizeDate s = fmap (formatTime defaultTimeLocale "%F")
+ (msum $ map (\fs -> parsetimeWith fs s >>= rejectBadYear) formats :: Maybe Day)
+ where rejectBadYear day = case toGregorian day of
+ (y, _, _) | y >= 1601 && y <= 9999 -> Just day
+ _ -> Nothing
+ parsetimeWith =
+#if MIN_VERSION_time(1,5,0)
+ parseTimeM True defaultTimeLocale
+#else
+ parseTime defaultTimeLocale
+#endif
+ formats = ["%x","%m/%d/%Y", "%D","%F", "%d %b %Y",
+ "%d %B %Y", "%b. %d, %Y", "%B %d, %Y",
+ "%Y%m%d", "%Y%m", "%Y"]
+
+--
+-- Pandoc block and inline list processing
+--
+
+-- | Generate infinite lazy list of markers for an ordered list,
+-- depending on list attributes.
+orderedListMarkers :: (Int, ListNumberStyle, ListNumberDelim) -> [String]
+orderedListMarkers (start, numstyle, numdelim) =
+ let singleton c = [c]
+ nums = case numstyle of
+ DefaultStyle -> map show [start..]
+ Example -> map show [start..]
+ Decimal -> map show [start..]
+ UpperAlpha -> drop (start - 1) $ cycle $
+ map singleton ['A'..'Z']
+ LowerAlpha -> drop (start - 1) $ cycle $
+ map singleton ['a'..'z']
+ UpperRoman -> map toRomanNumeral [start..]
+ LowerRoman -> map (map toLower . toRomanNumeral) [start..]
+ inDelim str = case numdelim of
+ DefaultDelim -> str ++ "."
+ Period -> str ++ "."
+ OneParen -> str ++ ")"
+ TwoParens -> "(" ++ str ++ ")"
+ in map inDelim nums
+
+-- | Normalize a list of inline elements: remove leading and trailing
+-- @Space@ elements, collapse double @Space@s into singles, and
+-- remove empty Str elements.
+normalizeSpaces :: [Inline] -> [Inline]
+normalizeSpaces = cleanup . dropWhile isSpaceOrEmpty
+ where cleanup [] = []
+ cleanup (Space:rest) = case dropWhile isSpaceOrEmpty rest of
+ [] -> []
+ (x:xs) -> Space : x : cleanup xs
+ cleanup ((Str ""):rest) = cleanup rest
+ cleanup (x:rest) = x : cleanup rest
+
+isSpaceOrEmpty :: Inline -> Bool
+isSpaceOrEmpty Space = True
+isSpaceOrEmpty (Str "") = True
+isSpaceOrEmpty _ = False
+
+-- | Extract the leading and trailing spaces from inside an inline element
+-- and place them outside the element. SoftBreaks count as Spaces for
+-- these purposes.
+extractSpaces :: (Inlines -> Inlines) -> Inlines -> Inlines
+extractSpaces f is =
+ let contents = B.unMany is
+ left = case viewl contents of
+ (Space :< _) -> B.space
+ (SoftBreak :< _) -> B.softbreak
+ _ -> mempty
+ right = case viewr contents of
+ (_ :> Space) -> B.space
+ (_ :> SoftBreak) -> B.softbreak
+ _ -> mempty in
+ (left <> f (B.trimInlines . B.Many $ contents) <> right)
+
+-- | Extract inlines, removing formatting.
+removeFormatting :: Walkable Inline a => a -> [Inline]
+removeFormatting = query go . walk deNote
+ where go :: Inline -> [Inline]
+ go (Str xs) = [Str xs]
+ go Space = [Space]
+ go SoftBreak = [SoftBreak]
+ go (Code _ x) = [Str x]
+ go (Math _ x) = [Str x]
+ go LineBreak = [Space]
+ go _ = []
+
+deNote :: Inline -> Inline
+deNote (Note _) = Str ""
+deNote x = x
+
+-- | Convert pandoc structure to a string with formatting removed.
+-- Footnotes are skipped (since we don't want their contents in link
+-- labels).
+stringify :: Walkable Inline a => a -> String
+stringify = query go . walk deNote
+ where go :: Inline -> [Char]
+ go Space = " "
+ go SoftBreak = " "
+ go (Str x) = x
+ go (Code _ x) = x
+ go (Math _ x) = x
+ go (RawInline (Format "html") ('<':'b':'r':_)) = " " -- see #2105
+ go LineBreak = " "
+ go _ = ""
+
+-- | Bring all regular text in a pandoc structure to uppercase.
+--
+-- This function correctly handles cases where a lowercase character doesn't
+-- match to a single uppercase character – e.g. “Straße” would be converted
+-- to “STRASSE”, not “STRAßE”.
+capitalize :: Walkable Inline a => a -> a
+capitalize = walk go
+ where go :: Inline -> Inline
+ go (Str s) = Str (T.unpack $ T.toUpper $ T.pack s)
+ go x = x
+
+-- | Change final list item from @Para@ to @Plain@ if the list contains
+-- no other @Para@ blocks. Like compactify, but operates on @Blocks@ rather
+-- than @[Block]@.
+compactify :: [Blocks] -- ^ List of list items (each a list of blocks)
+ -> [Blocks]
+compactify [] = []
+compactify items =
+ let (others, final) = (init items, last items)
+ in case reverse (B.toList final) of
+ (Para a:xs) -> case [Para x | Para x <- concatMap B.toList items] of
+ -- if this is only Para, change to Plain
+ [_] -> others ++ [B.fromList (reverse $ Plain a : xs)]
+ _ -> items
+ _ -> items
+
+-- | Like @compactify@, but acts on items of definition lists.
+compactifyDL :: [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]
+compactifyDL items =
+ let defs = concatMap snd items
+ in case reverse (concatMap B.toList defs) of
+ (Para x:xs)
+ | not (any isPara xs) ->
+ let (t,ds) = last items
+ lastDef = B.toList $ last ds
+ ds' = init ds ++
+ if null lastDef
+ then [B.fromList lastDef]
+ else [B.fromList $ init lastDef ++ [Plain x]]
+ in init items ++ [(t, ds')]
+ | otherwise -> items
+ _ -> items
+
+-- | Combine a list of lines by adding hard linebreaks.
+combineLines :: [[Inline]] -> [Inline]
+combineLines = intercalate [LineBreak]
+
+-- | Convert a list of lines into a paragraph with hard line breaks. This is
+-- useful e.g. for rudimentary support of LineBlock elements in writers.
+linesToPara :: [[Inline]] -> Block
+linesToPara = Para . combineLines
+
+isPara :: Block -> Bool
+isPara (Para _) = True
+isPara _ = False
+
+-- | Data structure for defining hierarchical Pandoc documents
+data Element = Blk Block
+ | Sec Int [Int] Attr [Inline] [Element]
+ -- lvl num attributes label contents
+ deriving (Eq, Read, Show, Typeable, Data)
+
+instance Walkable Inline Element where
+ walk f (Blk x) = Blk (walk f x)
+ walk f (Sec lev nums attr ils elts) = Sec lev nums attr (walk f ils) (walk f elts)
+ walkM f (Blk x) = Blk `fmap` walkM f x
+ walkM f (Sec lev nums attr ils elts) = do
+ ils' <- walkM f ils
+ elts' <- walkM f elts
+ return $ Sec lev nums attr ils' elts'
+ query f (Blk x) = query f x
+ query f (Sec _ _ _ ils elts) = query f ils <> query f elts
+
+instance Walkable Block Element where
+ walk f (Blk x) = Blk (walk f x)
+ walk f (Sec lev nums attr ils elts) = Sec lev nums attr (walk f ils) (walk f elts)
+ walkM f (Blk x) = Blk `fmap` walkM f x
+ walkM f (Sec lev nums attr ils elts) = do
+ ils' <- walkM f ils
+ elts' <- walkM f elts
+ return $ Sec lev nums attr ils' elts'
+ query f (Blk x) = query f x
+ query f (Sec _ _ _ ils elts) = query f ils <> query f elts
+
+
+-- | Convert Pandoc inline list to plain text identifier. HTML
+-- identifiers must start with a letter, and may contain only
+-- letters, digits, and the characters _-.
+inlineListToIdentifier :: [Inline] -> String
+inlineListToIdentifier =
+ dropWhile (not . isAlpha) . intercalate "-" . words .
+ map (nbspToSp . toLower) .
+ filter (\c -> isLetter c || isDigit c || c `elem` "_-. ") .
+ stringify
+ where nbspToSp '\160' = ' '
+ nbspToSp x = x
+
+-- | Convert list of Pandoc blocks into (hierarchical) list of Elements
+hierarchicalize :: [Block] -> [Element]
+hierarchicalize blocks = S.evalState (hierarchicalizeWithIds blocks) []
+
+hierarchicalizeWithIds :: [Block] -> S.State [Int] [Element]
+hierarchicalizeWithIds [] = return []
+hierarchicalizeWithIds ((Header level attr@(_,classes,_) title'):xs) = do
+ lastnum <- S.get
+ let lastnum' = take level lastnum
+ let newnum = case length lastnum' of
+ x | "unnumbered" `elem` classes -> []
+ | x >= level -> init lastnum' ++ [last lastnum' + 1]
+ | otherwise -> lastnum ++
+ replicate (level - length lastnum - 1) 0 ++ [1]
+ unless (null newnum) $ S.put newnum
+ let (sectionContents, rest) = break (headerLtEq level) xs
+ sectionContents' <- hierarchicalizeWithIds sectionContents
+ rest' <- hierarchicalizeWithIds rest
+ return $ Sec level newnum attr title' sectionContents' : rest'
+hierarchicalizeWithIds ((Div ("",["references"],[])
+ (Header level (ident,classes,kvs) title' : xs)):ys) =
+ hierarchicalizeWithIds ((Header level (ident,("references":classes),kvs)
+ title') : (xs ++ ys))
+hierarchicalizeWithIds (x:rest) = do
+ rest' <- hierarchicalizeWithIds rest
+ return $ (Blk x) : rest'
+
+headerLtEq :: Int -> Block -> Bool
+headerLtEq level (Header l _ _) = l <= level
+headerLtEq level (Div ("",["references"],[]) (Header l _ _ : _)) = l <= level
+headerLtEq _ _ = False
+
+-- | Generate a unique identifier from a list of inlines.
+-- Second argument is a list of already used identifiers.
+uniqueIdent :: [Inline] -> Set.Set String -> String
+uniqueIdent title' usedIdents
+ = let baseIdent = case inlineListToIdentifier title' of
+ "" -> "section"
+ x -> x
+ numIdent n = baseIdent ++ "-" ++ show n
+ in if baseIdent `Set.member` usedIdents
+ then case find (\x -> not $ numIdent x `Set.member` usedIdents) ([1..60000] :: [Int]) of
+ Just x -> numIdent x
+ Nothing -> baseIdent -- if we have more than 60,000, allow repeats
+ else baseIdent
+
+-- | True if block is a Header block.
+isHeaderBlock :: Block -> Bool
+isHeaderBlock (Header _ _ _) = True
+isHeaderBlock _ = False
+
+-- | Shift header levels up or down.
+headerShift :: Int -> Pandoc -> Pandoc
+headerShift n = walk shift
+ where shift :: Block -> Block
+ shift (Header level attr inner) = Header (level + n) attr inner
+ shift x = x
+
+-- | Detect if a list is tight.
+isTightList :: [[Block]] -> Bool
+isTightList = all firstIsPlain
+ where firstIsPlain (Plain _ : _) = True
+ firstIsPlain _ = False
+
+-- | Set a field of a 'Meta' object. If the field already has a value,
+-- convert it into a list with the new value appended to the old value(s).
+addMetaField :: ToMetaValue a
+ => String
+ -> a
+ -> Meta
+ -> Meta
+addMetaField key val (Meta meta) =
+ Meta $ M.insertWith combine key (toMetaValue val) meta
+ where combine newval (MetaList xs) = MetaList (xs ++ tolist newval)
+ combine newval x = MetaList [x, newval]
+ tolist (MetaList ys) = ys
+ tolist y = [y]
+
+-- | Create 'Meta' from old-style title, authors, date. This is
+-- provided to ease the transition from the old API.
+makeMeta :: [Inline] -> [[Inline]] -> [Inline] -> Meta
+makeMeta title authors date =
+ addMetaField "title" (B.fromList title)
+ $ addMetaField "author" (map B.fromList authors)
+ $ addMetaField "date" (B.fromList date)
+ $ nullMeta
+
+--
+-- TagSoup HTML handling
+--
+
+-- | Render HTML tags.
+renderTags' :: [Tag String] -> String
+renderTags' = renderTagsOptions
+ renderOptions{ optMinimize = matchTags ["hr", "br", "img",
+ "meta", "link"]
+ , optRawTag = matchTags ["script", "style"] }
+ where matchTags = \tags -> flip elem tags . map toLower
+
+--
+-- File handling
+--
+
+-- | Perform an IO action in a directory, returning to starting directory.
+inDirectory :: FilePath -> IO a -> IO a
+inDirectory path action = E.bracket
+ getCurrentDirectory
+ setCurrentDirectory
+ (const $ setCurrentDirectory path >> action)
+
+getDefaultReferenceDocx :: Maybe FilePath -> IO Archive
+getDefaultReferenceDocx datadir = do
+ let paths = ["[Content_Types].xml",
+ "_rels/.rels",
+ "docProps/app.xml",
+ "docProps/core.xml",
+ "word/document.xml",
+ "word/fontTable.xml",
+ "word/footnotes.xml",
+ "word/numbering.xml",
+ "word/settings.xml",
+ "word/webSettings.xml",
+ "word/styles.xml",
+ "word/_rels/document.xml.rels",
+ "word/_rels/footnotes.xml.rels",
+ "word/theme/theme1.xml"]
+ let toLazy = fromChunks . (:[])
+ let pathToEntry path = do epochtime <- (floor . utcTimeToPOSIXSeconds) <$>
+ getCurrentTime
+ contents <- toLazy <$> readDataFile datadir
+ ("docx/" ++ path)
+ return $ toEntry path epochtime contents
+ mbArchive <- case datadir of
+ Nothing -> return Nothing
+ Just d -> do
+ exists <- doesFileExist (d </> "reference.docx")
+ if exists
+ then return (Just (d </> "reference.docx"))
+ else return Nothing
+ case mbArchive of
+ Just arch -> toArchive <$> BL.readFile arch
+ Nothing -> foldr addEntryToArchive emptyArchive <$>
+ mapM pathToEntry paths
+
+getDefaultReferenceODT :: Maybe FilePath -> IO Archive
+getDefaultReferenceODT datadir = do
+ let paths = ["mimetype",
+ "manifest.rdf",
+ "styles.xml",
+ "content.xml",
+ "meta.xml",
+ "settings.xml",
+ "Configurations2/accelerator/current.xml",
+ "Thumbnails/thumbnail.png",
+ "META-INF/manifest.xml"]
+ let pathToEntry path = do epochtime <- floor `fmap` getPOSIXTime
+ contents <- (fromChunks . (:[])) `fmap`
+ readDataFile datadir ("odt/" ++ path)
+ return $ toEntry path epochtime contents
+ mbArchive <- case datadir of
+ Nothing -> return Nothing
+ Just d -> do
+ exists <- doesFileExist (d </> "reference.odt")
+ if exists
+ then return (Just (d </> "reference.odt"))
+ else return Nothing
+ case mbArchive of
+ Just arch -> toArchive <$> BL.readFile arch
+ Nothing -> foldr addEntryToArchive emptyArchive <$>
+ mapM pathToEntry paths
+
+
+readDefaultDataFile :: FilePath -> IO BS.ByteString
+readDefaultDataFile "reference.docx" =
+ (BS.concat . toChunks . fromArchive) <$> getDefaultReferenceDocx Nothing
+readDefaultDataFile "reference.odt" =
+ (BS.concat . toChunks . fromArchive) <$> getDefaultReferenceODT Nothing
+readDefaultDataFile fname =
+#ifdef EMBED_DATA_FILES
+ case lookup (makeCanonical fname) dataFiles of
+ Nothing -> err 97 $ "Could not find data file " ++ fname
+ Just contents -> return contents
+ where makeCanonical = Posix.joinPath . transformPathParts . splitDirectories
+ transformPathParts = reverse . foldl go []
+ go as "." = as
+ go (_:as) ".." = as
+ go as x = x : as
+#else
+ getDataFileName fname' >>= checkExistence >>= BS.readFile
+ where fname' = if fname == "MANUAL.txt" then fname else "data" </> fname
+
+checkExistence :: FilePath -> IO FilePath
+checkExistence fn = do
+ exists <- doesFileExist fn
+ if exists
+ then return fn
+ else err 97 ("Could not find data file " ++ fn)
+#endif
+
+-- | Read file from specified user data directory or, if not found there, from
+-- Cabal data directory.
+readDataFile :: Maybe FilePath -> FilePath -> IO BS.ByteString
+readDataFile Nothing fname = readDefaultDataFile fname
+readDataFile (Just userDir) fname = do
+ exists <- doesFileExist (userDir </> fname)
+ if exists
+ then BS.readFile (userDir </> fname)
+ else readDefaultDataFile fname
+
+-- | Same as 'readDataFile' but returns a String instead of a ByteString.
+readDataFileUTF8 :: Maybe FilePath -> FilePath -> IO String
+readDataFileUTF8 userDir fname =
+ UTF8.toString `fmap` readDataFile userDir fname
+
+-- | Read from a URL and return raw data and maybe mime type.
+openURL :: String -> IO (Either E.SomeException (BS.ByteString, Maybe MimeType))
+openURL u
+ | Just u'' <- stripPrefix "data:" u =
+ let mime = takeWhile (/=',') u''
+ contents = B8.pack $ unEscapeString $ drop 1 $ dropWhile (/=',') u''
+ in return $ Right (decodeLenient contents, Just mime)
+#ifdef HTTP_CLIENT
+ | otherwise = withSocketsDo $ E.try $ do
+ let parseReq = parseRequest
+ (proxy :: Either E.SomeException String) <- E.try $ getEnv "http_proxy"
+ (useragent :: Either E.SomeException String) <- E.try $ getEnv "USER_AGENT"
+ req <- parseReq u
+ req' <- case proxy of
+ Left _ -> return req
+ Right pr -> (parseReq pr >>= \r ->
+ return $ addProxy (host r) (port r) req)
+ `mplus` return req
+ req'' <- case useragent of
+ Left _ -> return req'
+ Right ua -> do
+ let headers = requestHeaders req'
+ let useragentheader = (hUserAgent, B8.pack ua)
+ let headers' = useragentheader:headers
+ return $ req' {requestHeaders = headers'}
+ resp <- newManager tlsManagerSettings >>= httpLbs req''
+ return (BS.concat $ toChunks $ responseBody resp,
+ UTF8.toString `fmap` lookup hContentType (responseHeaders resp))
+#else
+ | otherwise = E.try $ getBodyAndMimeType `fmap` browse
+ (do liftIO $ UTF8.hPutStrLn stderr $ "Fetching " ++ u ++ "..."
+ setOutHandler $ const (return ())
+ setAllowRedirects True
+ request (getRequest' u'))
+ where getBodyAndMimeType (_, r) = (rspBody r, findHeader HdrContentType r)
+ getRequest' uriString = case parseURI uriString of
+ Nothing -> error ("Not a valid URL: " ++
+ uriString)
+ Just v -> mkRequest GET v
+ u' = escapeURIString (/= '|') u -- pipes are rejected by Network.URI
+#endif
+
+--
+-- Error reporting
+--
+
+err :: MonadIO m => Int -> String -> m a
+err exitCode msg = liftIO $ do
+ UTF8.hPutStrLn stderr msg
+ exitWith $ ExitFailure exitCode
+ return undefined
+
+warn :: MonadIO m => String -> m ()
+warn msg = liftIO $ do
+ UTF8.hPutStrLn stderr $ "[warning] " ++ msg
+
+mapLeft :: (a -> b) -> Either a c -> Either b c
+mapLeft f (Left x) = Left (f x)
+mapLeft _ (Right x) = Right x
+
+-- | Remove intermediate "." and ".." directories from a path.
+--
+-- > collapseFilePath "./foo" == "foo"
+-- > collapseFilePath "/bar/../baz" == "/baz"
+-- > collapseFilePath "/../baz" == "/../baz"
+-- > collapseFilePath "parent/foo/baz/../bar" == "parent/foo/bar"
+-- > collapseFilePath "parent/foo/baz/../../bar" == "parent/bar"
+-- > collapseFilePath "parent/foo/.." == "parent"
+-- > collapseFilePath "/parent/foo/../../bar" == "/bar"
+collapseFilePath :: FilePath -> FilePath
+collapseFilePath = Posix.joinPath . reverse . foldl go [] . splitDirectories
+ where
+ go rs "." = rs
+ go r@(p:rs) ".." = case p of
+ ".." -> ("..":r)
+ (checkPathSeperator -> Just True) -> ("..":r)
+ _ -> rs
+ go _ (checkPathSeperator -> Just True) = [[Posix.pathSeparator]]
+ go rs x = x:rs
+ isSingleton [] = Nothing
+ isSingleton [x] = Just x
+ isSingleton _ = Nothing
+ checkPathSeperator = fmap isPathSeparator . isSingleton
+
+--
+-- File selection from the archive
+--
+filteredFilesFromArchive :: Archive -> (FilePath -> Bool) -> [(FilePath, BL.ByteString)]
+filteredFilesFromArchive zf f =
+ mapMaybe (fileAndBinary zf) (filter f (filesInArchive zf))
+ where
+ fileAndBinary :: Archive -> FilePath -> Maybe (FilePath, BL.ByteString)
+ fileAndBinary a fp = findEntryByPath fp a >>= \e -> Just (fp, fromEntry e)
+
+---
+--- Squash blocks into inlines
+---
+
+blockToInlines :: Block -> [Inline]
+blockToInlines (Plain ils) = ils
+blockToInlines (Para ils) = ils
+blockToInlines (LineBlock lns) = combineLines lns
+blockToInlines (CodeBlock attr str) = [Code attr str]
+blockToInlines (RawBlock fmt str) = [RawInline fmt str]
+blockToInlines (BlockQuote blks) = blocksToInlines blks
+blockToInlines (OrderedList _ blkslst) =
+ concatMap blocksToInlines blkslst
+blockToInlines (BulletList blkslst) =
+ concatMap blocksToInlines blkslst
+blockToInlines (DefinitionList pairslst) =
+ concatMap f pairslst
+ where
+ f (ils, blkslst) = ils ++
+ [Str ":", Space] ++
+ (concatMap blocksToInlines blkslst)
+blockToInlines (Header _ _ ils) = ils
+blockToInlines (HorizontalRule) = []
+blockToInlines (Table _ _ _ headers rows) =
+ intercalate [LineBreak] $ map (concatMap blocksToInlines) tbl
+ where
+ tbl = headers : rows
+blockToInlines (Div _ blks) = blocksToInlines blks
+blockToInlines Null = []
+
+blocksToInlinesWithSep :: [Inline] -> [Block] -> [Inline]
+blocksToInlinesWithSep sep blks = intercalate sep $ map blockToInlines blks
+
+blocksToInlines :: [Block] -> [Inline]
+blocksToInlines = blocksToInlinesWithSep [Space, Str "¶", Space]
+
+
+--
+-- Safe read
+--
+
+safeRead :: (MonadPlus m, Read a) => String -> m a
+safeRead s = case reads s of
+ (d,x):_
+ | all isSpace x -> return d
+ _ -> mzero
+
+--
+-- Temp directory
+--
+
+withTempDir :: String -> (FilePath -> IO a) -> IO a
+withTempDir =
+#ifdef _WINDOWS
+ withTempDirectory "."
+#else
+ withSystemTempDirectory
+#endif
diff --git a/src/Text/Pandoc/Slides.hs b/src/Text/Pandoc/Slides.hs
new file mode 100644
index 000000000..e19dba3e2
--- /dev/null
+++ b/src/Text/Pandoc/Slides.hs
@@ -0,0 +1,63 @@
+{-
+Copyright (C) 2012-2016 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.Slides
+ Copyright : Copyright (C) 2012-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Utility functions for splitting documents into slides for slide
+show formats (dzslides, revealjs, s5, slidy, slideous, beamer).
+-}
+module Text.Pandoc.Slides ( getSlideLevel, prepSlides ) where
+import Text.Pandoc.Definition
+
+-- | Find level of header that starts slides (defined as the least header
+-- level that occurs before a non-header/non-hrule in the blocks).
+getSlideLevel :: [Block] -> Int
+getSlideLevel = go 6
+ where go least (Header n _ _ : x : xs)
+ | n < least && nonHOrHR x = go n xs
+ | otherwise = go least (x:xs)
+ go least (_ : xs) = go least xs
+ go least [] = least
+ nonHOrHR (Header{}) = False
+ nonHOrHR (HorizontalRule) = False
+ nonHOrHR _ = True
+
+-- | Prepare a block list to be passed to hierarchicalize.
+prepSlides :: Int -> [Block] -> [Block]
+prepSlides slideLevel = ensureStartWithH . splitHrule . extractRefsHeader
+ where splitHrule (HorizontalRule : Header n attr xs : ys)
+ | n == slideLevel = Header slideLevel attr xs : splitHrule ys
+ splitHrule (HorizontalRule : xs) = Header slideLevel nullAttr [Str "\0"] :
+ splitHrule xs
+ splitHrule (x : xs) = x : splitHrule xs
+ splitHrule [] = []
+ extractRefsHeader bs =
+ case reverse bs of
+ (Div ("",["references"],[]) (Header n attrs xs : ys) : zs)
+ -> reverse zs ++ (Header n attrs xs : [Div ("",["references"],[]) ys])
+ _ -> bs
+ ensureStartWithH bs@(Header n _ _:_)
+ | n <= slideLevel = bs
+ ensureStartWithH bs = Header slideLevel nullAttr [Str "\0"] : bs
diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs
new file mode 100644
index 000000000..705ac54c9
--- /dev/null
+++ b/src/Text/Pandoc/Templates.hs
@@ -0,0 +1,77 @@
+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances,
+ OverloadedStrings, GeneralizedNewtypeDeriving #-}
+{-
+Copyright (C) 2009-2016 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.Templates
+ Copyright : Copyright (C) 2009-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+A simple templating system with variable substitution and conditionals.
+
+-}
+
+module Text.Pandoc.Templates ( renderTemplate
+ , renderTemplate'
+ , TemplateTarget
+ , varListToJSON
+ , compileTemplate
+ , Template
+ , getDefaultTemplate ) where
+
+import Text.DocTemplates (Template, TemplateTarget, compileTemplate,
+ renderTemplate, applyTemplate,
+ varListToJSON)
+import Data.Aeson (ToJSON(..))
+import qualified Data.Text as T
+import System.FilePath ((</>), (<.>))
+import qualified Control.Exception.Extensible as E (try, IOException)
+import Text.Pandoc.Shared (readDataFileUTF8)
+
+-- | Get default template for the specified writer.
+getDefaultTemplate :: (Maybe FilePath) -- ^ User data directory to search first
+ -> String -- ^ Name of writer
+ -> IO (Either E.IOException String)
+getDefaultTemplate user writer = do
+ let format = takeWhile (`notElem` ("+-" :: String)) writer -- strip off extensions
+ case format of
+ "native" -> return $ Right ""
+ "json" -> return $ Right ""
+ "docx" -> return $ Right ""
+ "fb2" -> return $ Right ""
+ "odt" -> getDefaultTemplate user "opendocument"
+ "html" -> getDefaultTemplate user "html5"
+ "docbook" -> getDefaultTemplate user "docbook5"
+ "epub" -> getDefaultTemplate user "epub3"
+ "markdown_strict" -> getDefaultTemplate user "markdown"
+ "multimarkdown" -> getDefaultTemplate user "markdown"
+ "markdown_github" -> getDefaultTemplate user "markdown"
+ "markdown_mmd" -> getDefaultTemplate user "markdown"
+ "markdown_phpextra" -> getDefaultTemplate user "markdown"
+ _ -> let fname = "templates" </> "default" <.> format
+ in E.try $ readDataFileUTF8 user fname
+
+-- | Like 'applyTemplate', but raising an error if compilation fails.
+renderTemplate' :: (ToJSON a, TemplateTarget b) => String -> a -> b
+renderTemplate' template = either error id . applyTemplate (T.pack template)
+
diff --git a/src/Text/Pandoc/UTF8.hs b/src/Text/Pandoc/UTF8.hs
new file mode 100644
index 000000000..62a662029
--- /dev/null
+++ b/src/Text/Pandoc/UTF8.hs
@@ -0,0 +1,121 @@
+{-
+Copyright (C) 2010-2016 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.UTF8
+ Copyright : Copyright (C) 2010-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+UTF-8 aware string IO functions that will work with GHC 6.10, 6.12, or 7.
+-}
+module Text.Pandoc.UTF8 ( readFile
+ , writeFile
+ , getContents
+ , putStr
+ , putStrLn
+ , hPutStr
+ , hPutStrLn
+ , hGetContents
+ , toString
+ , fromString
+ , toStringLazy
+ , fromStringLazy
+ , encodePath
+ , decodeArg
+ )
+
+where
+
+import System.IO hiding (readFile, writeFile, getContents,
+ putStr, putStrLn, hPutStr, hPutStrLn, hGetContents)
+import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn)
+import qualified System.IO as IO
+import qualified Data.ByteString.Char8 as B
+import qualified Data.ByteString.Lazy as BL
+import qualified Data.Text.Encoding as T
+import qualified Data.Text as T
+import qualified Data.Text.Lazy as TL
+import qualified Data.Text.Lazy.Encoding as TL
+
+readFile :: FilePath -> IO String
+readFile f = do
+ h <- openFile (encodePath f) ReadMode
+ hGetContents h
+
+writeFile :: FilePath -> String -> IO ()
+writeFile f s = withFile (encodePath f) WriteMode $ \h -> hPutStr h s
+
+getContents :: IO String
+getContents = hGetContents stdin
+
+putStr :: String -> IO ()
+putStr s = hPutStr stdout s
+
+putStrLn :: String -> IO ()
+putStrLn s = hPutStrLn stdout s
+
+hPutStr :: Handle -> String -> IO ()
+hPutStr h s = hSetEncoding h utf8 >> IO.hPutStr h s
+
+hPutStrLn :: Handle -> String -> IO ()
+hPutStrLn h s = hSetEncoding h utf8 >> IO.hPutStrLn h s
+
+hGetContents :: Handle -> IO String
+hGetContents = fmap toString . B.hGetContents
+-- hGetContents h = hSetEncoding h utf8_bom
+-- >> hSetNewlineMode h universalNewlineMode
+-- >> IO.hGetContents h
+
+-- | Drop BOM (byte order marker) if present at beginning of string.
+-- Note that Data.Text converts the BOM to code point FEFF, zero-width
+-- no-break space, so if the string begins with this we strip it off.
+dropBOM :: String -> String
+dropBOM ('\xFEFF':xs) = xs
+dropBOM xs = xs
+
+filterCRs :: String -> String
+filterCRs ('\r':'\n':xs) = '\n': filterCRs xs
+filterCRs ('\r':xs) = '\n' : filterCRs xs
+filterCRs (x:xs) = x : filterCRs xs
+filterCRs [] = []
+
+-- | Convert UTF8-encoded ByteString to String, also
+-- removing '\r' characters.
+toString :: B.ByteString -> String
+toString = filterCRs . dropBOM . T.unpack . T.decodeUtf8
+
+fromString :: String -> B.ByteString
+fromString = T.encodeUtf8 . T.pack
+
+-- | Convert UTF8-encoded ByteString to String, also
+-- removing '\r' characters.
+toStringLazy :: BL.ByteString -> String
+toStringLazy = filterCRs . dropBOM . TL.unpack . TL.decodeUtf8
+
+fromStringLazy :: String -> BL.ByteString
+fromStringLazy = TL.encodeUtf8 . TL.pack
+
+encodePath :: FilePath -> FilePath
+encodePath = id
+
+decodeArg :: String -> String
+decodeArg = id
diff --git a/src/Text/Pandoc/UUID.hs b/src/Text/Pandoc/UUID.hs
new file mode 100644
index 000000000..8de102742
--- /dev/null
+++ b/src/Text/Pandoc/UUID.hs
@@ -0,0 +1,78 @@
+{-
+Copyright (C) 2010-2016 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.UUID
+ Copyright : Copyright (C) 2010-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+UUID generation using Version 4 (random method) described
+in RFC4122. See http://tools.ietf.org/html/rfc4122
+-}
+
+module Text.Pandoc.UUID ( UUID(..), getRandomUUID, getUUID ) where
+
+import Text.Printf ( printf )
+import System.Random ( RandomGen, randoms, getStdGen )
+import Data.Word
+import Data.Bits ( setBit, clearBit )
+
+data UUID = UUID Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8
+ Word8 Word8 Word8 Word8 Word8 Word8 Word8 Word8
+
+instance Show UUID where
+ show (UUID a b c d e f g h i j k l m n o p) =
+ "urn:uuid:" ++
+ printf "%02x" a ++
+ printf "%02x" b ++
+ printf "%02x" c ++
+ printf "%02x" d ++
+ "-" ++
+ printf "%02x" e ++
+ printf "%02x" f ++
+ "-" ++
+ printf "%02x" g ++
+ printf "%02x" h ++
+ "-" ++
+ printf "%02x" i ++
+ printf "%02x" j ++
+ "-" ++
+ printf "%02x" k ++
+ printf "%02x" l ++
+ printf "%02x" m ++
+ printf "%02x" n ++
+ printf "%02x" o ++
+ printf "%02x" p
+
+getUUID :: RandomGen g => g -> UUID
+getUUID gen =
+ let [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p] = take 16 $ randoms gen :: [Word8]
+ -- set variant
+ i' = i `setBit` 7 `clearBit` 6
+ -- set version (0100 for random)
+ g' = g `clearBit` 7 `setBit` 6 `clearBit` 5 `clearBit` 4
+ in
+ UUID a b c d e f g' h i' j k l m n o p
+
+getRandomUUID :: IO UUID
+getRandomUUID = getUUID <$> getStdGen
+
diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs
new file mode 100644
index 000000000..356b29504
--- /dev/null
+++ b/src/Text/Pandoc/Writers/AsciiDoc.hs
@@ -0,0 +1,470 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-
+Copyright (C) 2006-2015 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.AsciiDoc
+ Copyright : Copyright (C) 2006-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to asciidoc.
+
+Note that some information may be lost in conversion, due to
+expressive limitations of asciidoc. Footnotes and table cells with
+paragraphs (or other block items) are not possible in asciidoc.
+If pandoc encounters one of these, it will insert a message indicating
+that it has omitted the construct.
+
+AsciiDoc: <http://www.methods.co.nz/asciidoc/>
+-}
+module Text.Pandoc.Writers.AsciiDoc (writeAsciiDoc) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Templates (renderTemplate')
+import Text.Pandoc.Shared
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Options
+import Text.Pandoc.Parsing hiding (blankline, space)
+import Data.Maybe (fromMaybe)
+import Data.List ( stripPrefix, intersperse, intercalate )
+import Text.Pandoc.Pretty
+import Text.Pandoc.ImageSize
+import Control.Monad.State
+import qualified Data.Map as M
+import Data.Aeson (Value(String), fromJSON, toJSON, Result(..))
+import qualified Data.Text as T
+import Data.Char (isSpace, isPunctuation)
+import Text.Pandoc.Class (PandocMonad)
+
+data WriterState = WriterState { defListMarker :: String
+ , orderedListLevel :: Int
+ , bulletListLevel :: Int
+ , intraword :: Bool
+ }
+
+-- | Convert Pandoc to AsciiDoc.
+writeAsciiDoc :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeAsciiDoc opts document = return $
+ evalState (pandocToAsciiDoc opts document) WriterState{
+ defListMarker = "::"
+ , orderedListLevel = 1
+ , bulletListLevel = 1
+ , intraword = False
+ }
+
+-- | Return asciidoc representation of document.
+pandocToAsciiDoc :: WriterOptions -> Pandoc -> State WriterState String
+pandocToAsciiDoc opts (Pandoc meta blocks) = do
+ let titleblock = not $ null (docTitle meta) && null (docAuthors meta) &&
+ null (docDate meta)
+ let colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ metadata <- metaToJSON opts
+ (fmap (render colwidth) . blockListToAsciiDoc opts)
+ (fmap (render colwidth) . 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
+ let main = render colwidth body
+ let context = defField "body" main
+ $ defField "toc"
+ (writerTableOfContents opts &&
+ writerTemplate opts /= Nothing)
+ $ defField "titleblock" titleblock
+ $ metadata'
+ case writerTemplate opts of
+ Nothing -> return main
+ Just tpl -> return $ renderTemplate' tpl context
+
+-- | Escape special characters for AsciiDoc.
+escapeString :: String -> String
+escapeString = escapeStringUsing escs
+ where escs = backslashEscapes "{"
+
+-- | Ordered list start parser for use in Para below.
+olMarker :: Parser [Char] ParserState Char
+olMarker = do (start, style', delim) <- anyOrderedListMarker
+ if delim == Period &&
+ (style' == UpperAlpha || (style' == UpperRoman &&
+ start `elem` [1, 5, 10, 50, 100, 500, 1000]))
+ then spaceChar >> spaceChar
+ else spaceChar
+
+-- | True if string begins with an ordered list marker
+beginsWithOrderedListMarker :: String -> Bool
+beginsWithOrderedListMarker str =
+ case runParser olMarker defaultParserState "para start" (take 10 str) of
+ Left _ -> False
+ Right _ -> True
+
+-- | Convert Pandoc block element to asciidoc.
+blockToAsciiDoc :: WriterOptions -- ^ Options
+ -> Block -- ^ Block element
+ -> State WriterState Doc
+blockToAsciiDoc _ Null = return empty
+blockToAsciiDoc opts (Plain inlines) = do
+ contents <- inlineListToAsciiDoc opts inlines
+ return $ contents <> blankline
+blockToAsciiDoc opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) = do
+ blockToAsciiDoc opts (Para [Image attr alt (src,tit)])
+blockToAsciiDoc opts (Para inlines) = do
+ contents <- inlineListToAsciiDoc opts inlines
+ -- escape if para starts with ordered list marker
+ let esc = if beginsWithOrderedListMarker (render Nothing contents)
+ then text "\\"
+ else empty
+ return $ esc <> contents <> blankline
+blockToAsciiDoc opts (LineBlock lns) = do
+ let docify line = if null line
+ then return blankline
+ else inlineListToAsciiDoc opts line
+ let joinWithLinefeeds = nowrap . mconcat . intersperse cr
+ contents <- joinWithLinefeeds <$> mapM docify lns
+ return $ "[verse]" $$ text "--" $$ contents $$ text "--" $$ blankline
+blockToAsciiDoc _ (RawBlock f s)
+ | f == "asciidoc" = return $ text s
+ | otherwise = return empty
+blockToAsciiDoc _ HorizontalRule =
+ 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
+ let identifier = if (null ident) 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)
+blockToAsciiDoc _ (CodeBlock (_,classes,_) str) = return $ (flush $
+ if null classes
+ then "...." $$ text str $$ "...."
+ else attrs $$ "----" $$ text str $$ "----")
+ <> blankline
+ where attrs = "[" <> text (intercalate "," ("source" : classes)) <> "]"
+blockToAsciiDoc opts (BlockQuote blocks) = do
+ contents <- blockListToAsciiDoc opts blocks
+ let isBlock (BlockQuote _) = True
+ isBlock _ = False
+ -- if there are nested block quotes, put in an open block
+ let contents' = if any isBlock blocks
+ then "--" $$ contents $$ "--"
+ else contents
+ let cols = offset contents'
+ let bar = text $ replicate cols '_'
+ return $ bar $$ chomp contents' $$ bar <> blankline
+blockToAsciiDoc opts (Table caption aligns widths headers rows) = do
+ caption' <- inlineListToAsciiDoc opts caption
+ let caption'' = if null caption
+ then empty
+ else "." <> caption' <> cr
+ let isSimple = all (== 0) widths
+ let relativePercentWidths = if isSimple
+ then widths
+ else map (/ (sum widths)) widths
+ let widths'' :: [Integer]
+ widths'' = map (floor . (* 100)) relativePercentWidths
+ -- ensure that the widths sum to 100
+ let widths' = case widths'' of
+ _ | isSimple -> widths''
+ (w:ws) | sum (w:ws) < 100
+ -> (100 - sum ws) : ws
+ ws -> ws
+ let totalwidth :: Integer
+ totalwidth = floor $ sum widths * 100
+ let colspec al wi = (case al of
+ AlignLeft -> "<"
+ AlignCenter -> "^"
+ AlignRight -> ">"
+ AlignDefault -> "") ++
+ if wi == 0 then "" else (show wi ++ "%")
+ let headerspec = if all null headers
+ then empty
+ else text "options=\"header\","
+ let widthspec = if totalwidth == 0
+ then empty
+ else text "width="
+ <> doubleQuotes (text $ show totalwidth ++ "%")
+ <> text ","
+ let tablespec = text "["
+ <> widthspec
+ <> text "cols="
+ <> doubleQuotes (text $ intercalate ","
+ $ zipWith colspec aligns widths')
+ <> text ","
+ <> headerspec <> text "]"
+ let makeCell [Plain x] = do d <- blockListToAsciiDoc opts [Plain x]
+ return $ text "|" <> chomp d
+ makeCell [Para x] = makeCell [Plain x]
+ makeCell [] = return $ text "|"
+ makeCell bs = do d <- blockListToAsciiDoc opts bs
+ return $ text "a|" $$ d
+ let makeRow cells = hsep `fmap` mapM makeCell cells
+ rows' <- mapM makeRow rows
+ head' <- makeRow headers
+ let head'' = if all null headers then empty else head'
+ let colwidth = if writerWrapText opts == WrapAuto
+ then writerColumns opts
+ else 100000
+ let maxwidth = maximum $ map offset (head':rows')
+ let body = if maxwidth > colwidth then vsep rows' else vcat rows'
+ let border = text $ "|" ++ replicate (max 5 (min maxwidth colwidth) - 1) '='
+ return $
+ caption'' $$ tablespec $$ border $$ head'' $$ body $$ border $$ blankline
+blockToAsciiDoc opts (BulletList items) = do
+ contents <- mapM (bulletListItemToAsciiDoc opts) items
+ return $ cat contents <> blankline
+blockToAsciiDoc opts (OrderedList (_start, sty, _delim) items) = do
+ let sty' = case sty of
+ UpperRoman -> UpperAlpha
+ LowerRoman -> LowerAlpha
+ x -> x
+ let markers = orderedListMarkers (1, sty', Period) -- start num not used
+ let markers' = map (\m -> if length m < 3
+ then m ++ replicate (3 - length m) ' '
+ else m) markers
+ contents <- mapM (\(item, num) -> orderedListItemToAsciiDoc opts item num) $
+ zip markers' items
+ return $ cat contents <> blankline
+blockToAsciiDoc opts (DefinitionList items) = do
+ contents <- mapM (definitionListItemToAsciiDoc opts) items
+ return $ cat contents <> blankline
+blockToAsciiDoc opts (Div (ident,_,_) bs) = do
+ let identifier = if (null ident) then empty else ("[[" <> text ident <> "]]")
+ contents <- blockListToAsciiDoc opts bs
+ return $ identifier $$ contents
+
+-- | Convert bullet list item (list of blocks) to asciidoc.
+bulletListItemToAsciiDoc :: WriterOptions -> [Block] -> State WriterState Doc
+bulletListItemToAsciiDoc opts blocks = do
+ let addBlock :: Doc -> Block -> State WriterState Doc
+ addBlock d b | isEmpty d = chomp `fmap` blockToAsciiDoc opts b
+ addBlock d b@(BulletList _) = do x <- blockToAsciiDoc opts b
+ return $ d <> cr <> chomp x
+ addBlock d b@(OrderedList _ _) = do x <- blockToAsciiDoc opts b
+ return $ d <> cr <> chomp x
+ addBlock d b = do x <- blockToAsciiDoc opts b
+ return $ d <> cr <> text "+" <> cr <> chomp x
+ lev <- bulletListLevel `fmap` get
+ modify $ \s -> s{ bulletListLevel = lev + 1 }
+ contents <- foldM addBlock empty blocks
+ modify $ \s -> s{ bulletListLevel = lev }
+ let marker = text (replicate lev '*')
+ return $ marker <> text " " <> contents <> cr
+
+-- | Convert ordered list item (a list of blocks) to asciidoc.
+orderedListItemToAsciiDoc :: WriterOptions -- ^ options
+ -> String -- ^ list item marker
+ -> [Block] -- ^ list item (list of blocks)
+ -> State WriterState Doc
+orderedListItemToAsciiDoc opts marker blocks = do
+ let addBlock :: Doc -> Block -> State WriterState Doc
+ addBlock d b | isEmpty d = chomp `fmap` blockToAsciiDoc opts b
+ addBlock d b@(BulletList _) = do x <- blockToAsciiDoc opts b
+ return $ d <> cr <> chomp x
+ addBlock d b@(OrderedList _ _) = do x <- blockToAsciiDoc opts b
+ return $ d <> cr <> chomp x
+ addBlock d b = do x <- blockToAsciiDoc opts b
+ return $ d <> cr <> text "+" <> cr <> chomp x
+ lev <- orderedListLevel `fmap` get
+ modify $ \s -> s{ orderedListLevel = lev + 1 }
+ contents <- foldM addBlock empty blocks
+ modify $ \s -> s{ orderedListLevel = lev }
+ return $ text marker <> text " " <> contents <> cr
+
+-- | Convert definition list item (label, list of blocks) to asciidoc.
+definitionListItemToAsciiDoc :: WriterOptions
+ -> ([Inline],[[Block]])
+ -> State WriterState Doc
+definitionListItemToAsciiDoc opts (label, defs) = do
+ labelText <- inlineListToAsciiDoc opts label
+ marker <- defListMarker `fmap` get
+ if marker == "::"
+ then modify (\st -> st{ defListMarker = ";;"})
+ else modify (\st -> st{ defListMarker = "::"})
+ let divider = cr <> text "+" <> cr
+ let defsToAsciiDoc :: [Block] -> State WriterState Doc
+ defsToAsciiDoc ds = (vcat . intersperse divider . map chomp)
+ `fmap` mapM (blockToAsciiDoc opts) ds
+ defs' <- mapM defsToAsciiDoc defs
+ modify (\st -> st{ defListMarker = marker })
+ let contents = nest 2 $ vcat $ intersperse divider $ map chomp defs'
+ return $ labelText <> text marker <> cr <> contents <> cr
+
+-- | Convert list of Pandoc block elements to asciidoc.
+blockListToAsciiDoc :: WriterOptions -- ^ Options
+ -> [Block] -- ^ List of block elements
+ -> State WriterState Doc
+blockListToAsciiDoc opts blocks = cat `fmap` mapM (blockToAsciiDoc opts) blocks
+
+data SpacyLocation = End | Start
+
+-- | Convert list of Pandoc inline elements to asciidoc.
+inlineListToAsciiDoc :: WriterOptions -> [Inline] -> State WriterState Doc
+inlineListToAsciiDoc opts lst = do
+ oldIntraword <- gets intraword
+ setIntraword False
+ result <- go lst
+ setIntraword oldIntraword
+ return result
+ where go [] = return empty
+ go (y:x:xs)
+ | not (isSpacy End y) = do
+ y' <- if isSpacy Start x
+ then inlineToAsciiDoc opts y
+ else withIntraword $ inlineToAsciiDoc opts y
+ x' <- withIntraword $ inlineToAsciiDoc opts x
+ xs' <- go xs
+ return (y' <> x' <> xs')
+ | not (isSpacy Start x) = do
+ y' <- withIntraword $ inlineToAsciiDoc opts y
+ xs' <- go (x:xs)
+ return (y' <> xs')
+ go (x:xs) = do
+ x' <- inlineToAsciiDoc opts x
+ xs' <- go xs
+ return (x' <> xs')
+ isSpacy :: SpacyLocation -> Inline -> Bool
+ isSpacy _ Space = True
+ isSpacy _ LineBreak = True
+ isSpacy _ SoftBreak = True
+ -- Note that \W characters count as spacy in AsciiDoc
+ -- for purposes of determining interword:
+ isSpacy End (Str xs) = case reverse xs of
+ c:_ -> isPunctuation c || isSpace c
+ _ -> False
+ isSpacy Start (Str (c:_)) = isPunctuation c || isSpace c
+ isSpacy _ _ = False
+
+setIntraword :: Bool -> State WriterState ()
+setIntraword b = modify $ \st -> st{ intraword = b }
+
+withIntraword :: State WriterState a -> State WriterState a
+withIntraword p = setIntraword True *> p <* setIntraword False
+
+-- | Convert Pandoc inline element to asciidoc.
+inlineToAsciiDoc :: WriterOptions -> Inline -> State WriterState Doc
+inlineToAsciiDoc opts (Emph lst) = do
+ contents <- inlineListToAsciiDoc opts lst
+ isIntraword <- gets intraword
+ let marker = if isIntraword then "__" else "_"
+ return $ marker <> contents <> marker
+inlineToAsciiDoc opts (Strong lst) = do
+ contents <- inlineListToAsciiDoc opts lst
+ isIntraword <- gets intraword
+ let marker = if isIntraword then "**" else "*"
+ return $ marker <> contents <> marker
+inlineToAsciiDoc opts (Strikeout lst) = do
+ contents <- inlineListToAsciiDoc opts lst
+ return $ "[line-through]*" <> contents <> "*"
+inlineToAsciiDoc opts (Superscript lst) = do
+ contents <- inlineListToAsciiDoc opts lst
+ return $ "^" <> contents <> "^"
+inlineToAsciiDoc opts (Subscript lst) = do
+ contents <- inlineListToAsciiDoc opts lst
+ return $ "~" <> contents <> "~"
+inlineToAsciiDoc opts (SmallCaps lst) = inlineListToAsciiDoc opts lst
+inlineToAsciiDoc opts (Quoted SingleQuote lst) =
+ inlineListToAsciiDoc opts (Str "`" : lst ++ [Str "'"])
+inlineToAsciiDoc opts (Quoted DoubleQuote lst) =
+ inlineListToAsciiDoc opts (Str "``" : lst ++ [Str "''"])
+inlineToAsciiDoc _ (Code _ str) = return $
+ text "`" <> text (escapeStringUsing (backslashEscapes "`") str) <> "`"
+inlineToAsciiDoc _ (Str str) = return $ text $ escapeString str
+inlineToAsciiDoc _ (Math InlineMath str) =
+ return $ "latexmath:[$" <> text str <> "$]"
+inlineToAsciiDoc _ (Math DisplayMath str) =
+ return $ "latexmath:[\\[" <> text str <> "\\]]"
+inlineToAsciiDoc _ (RawInline f s)
+ | f == "asciidoc" = return $ text s
+ | otherwise = return empty
+inlineToAsciiDoc _ LineBreak = return $ " +" <> cr
+inlineToAsciiDoc _ Space = return space
+inlineToAsciiDoc opts SoftBreak =
+ case writerWrapText opts of
+ WrapAuto -> return space
+ WrapPreserve -> return cr
+ WrapNone -> return space
+inlineToAsciiDoc opts (Cite _ lst) = inlineListToAsciiDoc opts lst
+inlineToAsciiDoc opts (Link _ txt (src, _tit)) = do
+-- relative: link:downloads/foo.zip[download foo.zip]
+-- abs: http://google.cod[Google]
+-- or my@email.com[email john]
+ linktext <- inlineListToAsciiDoc opts txt
+ let isRelative = ':' `notElem` src
+ let prefix = if isRelative
+ then text "link:"
+ else empty
+ let srcSuffix = fromMaybe src (stripPrefix "mailto:" src)
+ let useAuto = case txt of
+ [Str s] | escapeURI s == srcSuffix -> True
+ _ -> False
+ return $ if useAuto
+ then text srcSuffix
+ else prefix <> text src <> "[" <> linktext <> "]"
+inlineToAsciiDoc opts (Image attr alternate (src, tit)) = do
+-- image:images/logo.png[Company logo, title="blah"]
+ let txt = if (null alternate) || (alternate == [Str ""])
+ then [Str "image"]
+ else alternate
+ linktext <- inlineListToAsciiDoc opts txt
+ let linktitle = if null tit
+ then empty
+ else ",title=\"" <> text tit <> "\""
+ showDim dir = case (dimension dir attr) of
+ Just (Percent a) ->
+ ["scaledwidth=" <> text (show (Percent a))]
+ Just dim ->
+ [text (show dir) <> "=" <> text (showInPixel opts dim)]
+ Nothing ->
+ []
+ dimList = showDim Width ++ showDim Height
+ dims = if null dimList
+ then empty
+ else "," <> cat (intersperse "," dimList)
+ return $ "image:" <> text src <> "[" <> linktext <> linktitle <> dims <> "]"
+inlineToAsciiDoc opts (Note [Para inlines]) =
+ inlineToAsciiDoc opts (Note [Plain inlines])
+inlineToAsciiDoc opts (Note [Plain inlines]) = do
+ contents <- inlineListToAsciiDoc opts inlines
+ return $ text "footnote:[" <> contents <> "]"
+-- asciidoc can't handle blank lines in notes
+inlineToAsciiDoc _ (Note _) = return "[multiblock footnote omitted]"
+inlineToAsciiDoc opts (Span (ident,_,_) ils) = do
+ let identifier = if (null ident) then empty else ("[[" <> text ident <> "]]")
+ contents <- inlineListToAsciiDoc opts ils
+ return $ identifier <> contents
diff --git a/src/Text/Pandoc/Writers/CommonMark.hs b/src/Text/Pandoc/Writers/CommonMark.hs
new file mode 100644
index 000000000..b83f6785d
--- /dev/null
+++ b/src/Text/Pandoc/Writers/CommonMark.hs
@@ -0,0 +1,190 @@
+{-
+Copyright (C) 2015 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.CommonMark
+ Copyright : Copyright (C) 2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to CommonMark.
+
+CommonMark: <http://commonmark.org>
+-}
+module Text.Pandoc.Writers.CommonMark (writeCommonMark) where
+
+import Text.Pandoc.Writers.HTML (writeHtml5String)
+import Text.Pandoc.Definition
+import Text.Pandoc.Shared (isTightList, linesToPara)
+import Text.Pandoc.Templates (renderTemplate')
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Options
+import CMark
+import qualified Data.Text as T
+import Control.Monad.State (runState, State, modify, get)
+import Text.Pandoc.Walk (walkM)
+import Text.Pandoc.Class (PandocMonad)
+import Data.Foldable (foldrM)
+
+-- | Convert Pandoc to CommonMark.
+writeCommonMark :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeCommonMark opts (Pandoc meta blocks) = do
+ let (blocks', notes) = runState (walkM processNotes blocks) []
+ notes' = if null notes
+ then []
+ else [OrderedList (1, Decimal, Period) $ reverse notes]
+ main <- blocksToCommonMark opts (blocks' ++ notes')
+ metadata <- metaToJSON opts
+ (blocksToCommonMark opts)
+ (inlinesToCommonMark opts)
+ meta
+ let context = defField "body" main $ metadata
+ return $ case writerTemplate opts of
+ Nothing -> main
+ Just tpl -> renderTemplate' tpl context
+
+processNotes :: Inline -> State [[Block]] Inline
+processNotes (Note bs) = do
+ modify (bs :)
+ notes <- get
+ return $ Str $ "[" ++ show (length notes) ++ "]"
+processNotes x = return x
+
+node :: NodeType -> [Node] -> Node
+node = Node Nothing
+
+blocksToCommonMark :: PandocMonad m => WriterOptions -> [Block] -> m String
+blocksToCommonMark opts bs = do
+ let cmarkOpts = [optHardBreaks | isEnabled Ext_hard_line_breaks opts]
+ colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ nodes <- blocksToNodes bs
+ return $
+ T.unpack $
+ nodeToCommonmark cmarkOpts colwidth $
+ node DOCUMENT nodes
+
+inlinesToCommonMark :: PandocMonad m => WriterOptions -> [Inline] -> m String
+inlinesToCommonMark opts ils = return $
+ T.unpack $ nodeToCommonmark cmarkOpts colwidth
+ $ node PARAGRAPH (inlinesToNodes ils)
+ where cmarkOpts = [optHardBreaks | isEnabled Ext_hard_line_breaks opts]
+ colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+
+blocksToNodes :: PandocMonad m => [Block] -> m [Node]
+blocksToNodes = foldrM blockToNodes []
+
+blockToNodes :: PandocMonad m => Block -> [Node] -> m [Node]
+blockToNodes (Plain xs) ns = return (node PARAGRAPH (inlinesToNodes xs) : ns)
+blockToNodes (Para xs) ns = return (node PARAGRAPH (inlinesToNodes xs) : ns)
+blockToNodes (LineBlock lns) ns = blockToNodes (linesToPara lns) ns
+blockToNodes (CodeBlock (_,classes,_) xs) ns = return $
+ (node (CODE_BLOCK (T.pack (unwords classes)) (T.pack xs)) [] : ns)
+blockToNodes (RawBlock fmt xs) ns
+ | fmt == Format "html" = return (node (HTML_BLOCK (T.pack xs)) [] : ns)
+ | otherwise = return (node (CUSTOM_BLOCK (T.pack xs) (T.empty)) [] : ns)
+blockToNodes (BlockQuote bs) ns = do
+ nodes <- blocksToNodes bs
+ return (node BLOCK_QUOTE nodes : ns)
+blockToNodes (BulletList items) ns = do
+ nodes <- mapM blocksToNodes items
+ return (node (LIST ListAttributes{
+ listType = BULLET_LIST,
+ listDelim = PERIOD_DELIM,
+ listTight = isTightList items,
+ listStart = 1 }) (map (node ITEM) nodes) : ns)
+blockToNodes (OrderedList (start, _sty, delim) items) ns = do
+ nodes <- mapM blocksToNodes items
+ return (node (LIST ListAttributes{
+ listType = ORDERED_LIST,
+ listDelim = case delim of
+ OneParen -> PAREN_DELIM
+ TwoParens -> PAREN_DELIM
+ _ -> PERIOD_DELIM,
+ listTight = isTightList items,
+ listStart = start }) (map (node ITEM) nodes) : ns)
+blockToNodes HorizontalRule ns = return (node THEMATIC_BREAK [] : ns)
+blockToNodes (Header lev _ ils) ns = return (node (HEADING lev) (inlinesToNodes ils) : ns)
+blockToNodes (Div _ bs) ns = do
+ nodes <- blocksToNodes bs
+ return (nodes ++ ns)
+blockToNodes (DefinitionList items) ns = blockToNodes (BulletList items') ns
+ where items' = map dlToBullet items
+ dlToBullet (term, ((Para xs : ys) : zs)) =
+ Para (term ++ [LineBreak] ++ xs) : ys ++ concat zs
+ dlToBullet (term, ((Plain xs : ys) : zs)) =
+ Plain (term ++ [LineBreak] ++ xs) : ys ++ concat zs
+ dlToBullet (term, xs) =
+ Para term : concat xs
+blockToNodes t@(Table _ _ _ _ _) ns = do
+ s <- writeHtml5String def $! Pandoc nullMeta [t]
+ return (node (HTML_BLOCK (T.pack $! s)) [] : ns)
+blockToNodes Null ns = return ns
+
+inlinesToNodes :: [Inline] -> [Node]
+inlinesToNodes = foldr inlineToNodes []
+
+inlineToNodes :: Inline -> [Node] -> [Node]
+inlineToNodes (Str s) = (node (TEXT (T.pack s)) [] :)
+inlineToNodes Space = (node (TEXT (T.pack " ")) [] :)
+inlineToNodes LineBreak = (node LINEBREAK [] :)
+inlineToNodes SoftBreak = (node SOFTBREAK [] :)
+inlineToNodes (Emph xs) = (node EMPH (inlinesToNodes xs) :)
+inlineToNodes (Strong xs) = (node STRONG (inlinesToNodes xs) :)
+inlineToNodes (Strikeout xs) =
+ ((node (HTML_INLINE (T.pack "<s>")) [] : inlinesToNodes xs ++
+ [node (HTML_INLINE (T.pack "</s>")) []]) ++ )
+inlineToNodes (Superscript xs) =
+ ((node (HTML_INLINE (T.pack "<sup>")) [] : inlinesToNodes xs ++
+ [node (HTML_INLINE (T.pack "</sup>")) []]) ++ )
+inlineToNodes (Subscript xs) =
+ ((node (HTML_INLINE (T.pack "<sub>")) [] : inlinesToNodes xs ++
+ [node (HTML_INLINE (T.pack "</sub>")) []]) ++ )
+inlineToNodes (SmallCaps xs) =
+ ((node (HTML_INLINE (T.pack "<span style=\"font-variant:small-caps;\">")) []
+ : inlinesToNodes xs ++
+ [node (HTML_INLINE (T.pack "</span>")) []]) ++ )
+inlineToNodes (Link _ ils (url,tit)) =
+ (node (LINK (T.pack url) (T.pack tit)) (inlinesToNodes ils) :)
+inlineToNodes (Image _ ils (url,tit)) =
+ (node (IMAGE (T.pack url) (T.pack tit)) (inlinesToNodes ils) :)
+inlineToNodes (RawInline fmt xs)
+ | fmt == Format "html" = (node (HTML_INLINE (T.pack xs)) [] :)
+ | otherwise = (node (CUSTOM_INLINE (T.pack xs) (T.empty)) [] :)
+inlineToNodes (Quoted qt ils) =
+ ((node (TEXT start) [] : inlinesToNodes ils ++ [node (TEXT end) []]) ++)
+ where (start, end) = case qt of
+ SingleQuote -> (T.pack "‘", T.pack "’")
+ DoubleQuote -> (T.pack "“", T.pack "”")
+inlineToNodes (Code _ str) = (node (CODE (T.pack str)) [] :)
+inlineToNodes (Math mt str) =
+ case mt of
+ InlineMath ->
+ (node (HTML_INLINE (T.pack ("\\(" ++ str ++ "\\)"))) [] :)
+ DisplayMath ->
+ (node (HTML_INLINE (T.pack ("\\[" ++ str ++ "\\]"))) [] :)
+inlineToNodes (Span _ ils) = (inlinesToNodes ils ++)
+inlineToNodes (Cite _ ils) = (inlinesToNodes ils ++)
+inlineToNodes (Note _) = id -- should not occur
+-- we remove Note elements in preprocessing
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs
new file mode 100644
index 000000000..ea8b90db3
--- /dev/null
+++ b/src/Text/Pandoc/Writers/ConTeXt.hs
@@ -0,0 +1,481 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-
+Copyright (C) 2007-2015 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.ConTeXt
+ Copyright : Copyright (C) 2007-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' format into ConTeXt.
+-}
+module Text.Pandoc.Writers.ConTeXt ( writeConTeXt ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Shared
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Options
+import Text.Pandoc.Walk (query)
+import Text.Printf ( printf )
+import Data.List ( intercalate, intersperse )
+import Data.Char ( ord )
+import Data.Maybe ( catMaybes )
+import Control.Monad.State
+import Text.Pandoc.Pretty
+import Text.Pandoc.ImageSize
+import Text.Pandoc.Templates ( renderTemplate' )
+import Network.URI ( isURI, unEscapeString )
+import Text.Pandoc.Class (PandocMonad)
+
+data WriterState =
+ WriterState { stNextRef :: Int -- number of next URL reference
+ , stOrderedListLevel :: Int -- level of ordered list
+ , stOptions :: WriterOptions -- writer options
+ }
+
+orderedListStyles :: [Char]
+orderedListStyles = cycle "narg"
+
+-- | Convert Pandoc to ConTeXt.
+writeConTeXt :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeConTeXt options document = return $
+ let defaultWriterState = WriterState { stNextRef = 1
+ , stOrderedListLevel = 0
+ , stOptions = options
+ }
+ in evalState (pandocToConTeXt options document) defaultWriterState
+
+pandocToConTeXt :: WriterOptions -> Pandoc -> State WriterState String
+pandocToConTeXt options (Pandoc meta blocks) = do
+ let colwidth = if writerWrapText options == WrapAuto
+ then Just $ writerColumns options
+ else Nothing
+ metadata <- metaToJSON options
+ (fmap (render colwidth) . blockListToConTeXt)
+ (fmap (render colwidth) . inlineListToConTeXt)
+ meta
+ body <- mapM (elementToConTeXt options) $ hierarchicalize blocks
+ let main = (render colwidth . vcat) body
+ let layoutFromMargins = intercalate [','] $ catMaybes $
+ map (\(x,y) ->
+ ((x ++ "=") ++) <$> getField y metadata)
+ [("leftmargin","margin-left")
+ ,("rightmargin","margin-right")
+ ,("top","margin-top")
+ ,("bottom","margin-bottom")
+ ]
+ let context = defField "toc" (writerTableOfContents options)
+ $ defField "placelist" (intercalate ("," :: String) $
+ take (writerTOCDepth options +
+ case writerTopLevelDivision options of
+ TopLevelPart -> 0
+ TopLevelChapter -> 0
+ _ -> 1)
+ ["chapter","section","subsection","subsubsection",
+ "subsubsubsection","subsubsubsubsection"])
+ $ defField "body" main
+ $ defField "layout" layoutFromMargins
+ $ defField "number-sections" (writerNumberSections options)
+ $ metadata
+ let context' = defField "context-lang" (maybe "" (fromBcp47 . splitBy (=='-')) $
+ getField "lang" context)
+ $ defField "context-dir" (toContextDir $ getField "dir" context)
+ $ context
+ return $ case writerTemplate options of
+ Nothing -> main
+ Just tpl -> renderTemplate' tpl context'
+
+toContextDir :: Maybe String -> String
+toContextDir (Just "rtl") = "r2l"
+toContextDir (Just "ltr") = "l2r"
+toContextDir _ = ""
+
+-- | escape things as needed for ConTeXt
+escapeCharForConTeXt :: WriterOptions -> Char -> String
+escapeCharForConTeXt opts ch =
+ let ligatures = isEnabled Ext_smart opts in
+ case ch of
+ '{' -> "\\{"
+ '}' -> "\\}"
+ '\\' -> "\\letterbackslash{}"
+ '$' -> "\\$"
+ '|' -> "\\letterbar{}"
+ '%' -> "\\letterpercent{}"
+ '~' -> "\\lettertilde{}"
+ '#' -> "\\#"
+ '[' -> "{[}"
+ ']' -> "{]}"
+ '\160' -> "~"
+ '\x2014' | ligatures -> "---"
+ '\x2013' | ligatures -> "--"
+ '\x2019' | ligatures -> "'"
+ '\x2026' -> "\\ldots{}"
+ x -> [x]
+
+-- | Escape string for ConTeXt
+stringToConTeXt :: WriterOptions -> String -> String
+stringToConTeXt opts = concatMap (escapeCharForConTeXt opts)
+
+-- | Sanitize labels
+toLabel :: String -> String
+toLabel z = concatMap go z
+ where go x
+ | elem x ("\\#[]\",{}%()|=" :: String) = "ux" ++ printf "%x" (ord x)
+ | otherwise = [x]
+
+-- | Convert Elements to ConTeXt
+elementToConTeXt :: WriterOptions -> Element -> State WriterState Doc
+elementToConTeXt _ (Blk block) = blockToConTeXt block
+elementToConTeXt opts (Sec level _ attr title' elements) = do
+ header' <- sectionHeader attr level title'
+ innerContents <- mapM (elementToConTeXt opts) elements
+ return $ vcat (header' : innerContents)
+
+-- | Convert Pandoc block element to ConTeXt.
+blockToConTeXt :: Block
+ -> State WriterState Doc
+blockToConTeXt Null = return empty
+blockToConTeXt (Plain lst) = inlineListToConTeXt lst
+-- title beginning with fig: indicates that the image is a figure
+blockToConTeXt (Para [Image attr txt (src,'f':'i':'g':':':_)]) = do
+ capt <- inlineListToConTeXt txt
+ img <- inlineToConTeXt (Image attr txt (src, ""))
+ let (ident, _, _) = attr
+ label = if null ident
+ then empty
+ else "[]" <> brackets (text $ toLabel ident)
+ return $ blankline $$ "\\placefigure" <> label <> braces capt <> img <> blankline
+blockToConTeXt (Para lst) = do
+ contents <- inlineListToConTeXt lst
+ return $ contents <> blankline
+blockToConTeXt (LineBlock lns) = do
+ doclines <- nowrap . vcat <$> mapM inlineListToConTeXt lns
+ return $ "\\startlines" $$ doclines $$ "\\stoplines" <> blankline
+blockToConTeXt (BlockQuote lst) = do
+ contents <- blockListToConTeXt lst
+ return $ "\\startblockquote" $$ nest 0 contents $$ "\\stopblockquote" <> blankline
+blockToConTeXt (CodeBlock _ str) =
+ return $ flush ("\\starttyping" <> cr <> text str <> cr <> "\\stoptyping") $$ blankline
+ -- blankline because \stoptyping can't have anything after it, inc. '}'
+blockToConTeXt (RawBlock "context" str) = return $ text str <> blankline
+blockToConTeXt (RawBlock _ _ ) = return empty
+blockToConTeXt (Div (ident,_,kvs) bs) = do
+ let align dir txt = "\\startalignment[" <> dir <> "]" $$ txt $$ "\\stopalignment"
+ let wrapRef txt = if null ident
+ then txt
+ else ("\\reference" <> brackets (text $ toLabel ident) <>
+ braces empty <> "%") $$ txt
+ wrapDir = case lookup "dir" kvs of
+ Just "rtl" -> align "righttoleft"
+ Just "ltr" -> align "lefttoright"
+ _ -> id
+ wrapLang txt = case lookup "lang" kvs of
+ Just lng -> "\\start\\language["
+ <> text (fromBcp47' lng) <> "]" $$ txt $$ "\\stop"
+ Nothing -> txt
+ wrapBlank txt = blankline <> txt <> blankline
+ fmap (wrapBlank . wrapLang . wrapDir . wrapRef) $ blockListToConTeXt bs
+blockToConTeXt (BulletList lst) = do
+ contents <- mapM listItemToConTeXt lst
+ return $ ("\\startitemize" <> if isTightList lst
+ then brackets "packed"
+ else empty) $$
+ vcat contents $$ text "\\stopitemize" <> blankline
+blockToConTeXt (OrderedList (start, style', delim) lst) = do
+ st <- get
+ let level = stOrderedListLevel st
+ put $ st {stOrderedListLevel = level + 1}
+ contents <- mapM listItemToConTeXt lst
+ put $ st {stOrderedListLevel = level}
+ let start' = if start == 1 then "" else "start=" ++ show start
+ let delim' = case delim of
+ DefaultDelim -> ""
+ Period -> "stopper=."
+ OneParen -> "stopper=)"
+ TwoParens -> "left=(,stopper=)"
+ let width = maximum $ map length $ take (length contents)
+ (orderedListMarkers (start, style', delim))
+ let width' = (toEnum width + 1) / 2
+ let width'' = if width' > (1.5 :: Double)
+ then "width=" ++ show width' ++ "em"
+ else ""
+ let specs2Items = filter (not . null) [start', delim', width'']
+ let specs2 = if null specs2Items
+ then ""
+ else "[" ++ intercalate "," specs2Items ++ "]"
+ let style'' = '[': (case style' of
+ DefaultStyle -> orderedListStyles !! level
+ Decimal -> 'n'
+ Example -> 'n'
+ LowerRoman -> 'r'
+ UpperRoman -> 'R'
+ LowerAlpha -> 'a'
+ UpperAlpha -> 'A') :
+ if isTightList lst then ",packed]" else "]"
+ let specs = style'' ++ specs2
+ return $ "\\startitemize" <> text specs $$ vcat contents $$
+ "\\stopitemize" <> blankline
+blockToConTeXt (DefinitionList lst) =
+ liftM vcat $ mapM defListItemToConTeXt lst
+blockToConTeXt HorizontalRule = return $ "\\thinrule" <> blankline
+-- If this is ever executed, provide a default for the reference identifier.
+blockToConTeXt (Header level attr lst) = sectionHeader attr level lst
+blockToConTeXt (Table caption aligns widths heads rows) = do
+ let colDescriptor colWidth alignment = (case alignment of
+ AlignLeft -> 'l'
+ AlignRight -> 'r'
+ AlignCenter -> 'c'
+ AlignDefault -> 'l'):
+ if colWidth == 0
+ then "|"
+ else ("p(" ++ printf "%.2f" colWidth ++ "\\textwidth)|")
+ let colDescriptors = "|" ++ (concat $
+ zipWith colDescriptor widths aligns)
+ headers <- if all null heads
+ then return empty
+ else liftM ($$ "\\HL") $ tableRowToConTeXt heads
+ captionText <- inlineListToConTeXt caption
+ rows' <- mapM tableRowToConTeXt rows
+ return $ "\\placetable" <> (if null caption
+ then brackets "none"
+ else empty)
+ <> braces captionText $$
+ "\\starttable" <> brackets (text colDescriptors) $$
+ "\\HL" $$ headers $$
+ vcat rows' $$ "\\HL" $$ "\\stoptable" <> blankline
+
+tableRowToConTeXt :: [[Block]] -> State WriterState Doc
+tableRowToConTeXt cols = do
+ cols' <- mapM blockListToConTeXt cols
+ return $ (vcat (map ("\\NC " <>) cols')) $$ "\\NC\\AR"
+
+listItemToConTeXt :: [Block] -> State WriterState Doc
+listItemToConTeXt list = blockListToConTeXt list >>=
+ return . ("\\item" $$) . (nest 2)
+
+defListItemToConTeXt :: ([Inline], [[Block]]) -> State WriterState Doc
+defListItemToConTeXt (term, defs) = do
+ term' <- inlineListToConTeXt term
+ def' <- liftM vsep $ mapM blockListToConTeXt defs
+ return $ "\\startdescription" <> braces term' $$ nest 2 def' $$
+ "\\stopdescription" <> blankline
+
+-- | Convert list of block elements to ConTeXt.
+blockListToConTeXt :: [Block] -> State WriterState Doc
+blockListToConTeXt lst = liftM vcat $ mapM blockToConTeXt lst
+
+-- | Convert list of inline elements to ConTeXt.
+inlineListToConTeXt :: [Inline] -- ^ Inlines to convert
+ -> State WriterState Doc
+inlineListToConTeXt lst = liftM hcat $ mapM inlineToConTeXt $ addStruts lst
+ -- We add a \strut after a line break that precedes a space,
+ -- or the space gets swallowed
+ where addStruts (LineBreak : s : xs) | isSpacey s =
+ LineBreak : RawInline (Format "context") "\\strut " : s :
+ addStruts xs
+ addStruts (x:xs) = x : addStruts xs
+ addStruts [] = []
+ isSpacey Space = True
+ isSpacey (Str ('\160':_)) = True
+ isSpacey _ = False
+
+-- | Convert inline element to ConTeXt
+inlineToConTeXt :: Inline -- ^ Inline to convert
+ -> State WriterState Doc
+inlineToConTeXt (Emph lst) = do
+ contents <- inlineListToConTeXt lst
+ return $ braces $ "\\em " <> contents
+inlineToConTeXt (Strong lst) = do
+ contents <- inlineListToConTeXt lst
+ return $ braces $ "\\bf " <> contents
+inlineToConTeXt (Strikeout lst) = do
+ contents <- inlineListToConTeXt lst
+ return $ "\\overstrikes" <> braces contents
+inlineToConTeXt (Superscript lst) = do
+ contents <- inlineListToConTeXt lst
+ return $ "\\high" <> braces contents
+inlineToConTeXt (Subscript lst) = do
+ contents <- inlineListToConTeXt lst
+ return $ "\\low" <> braces contents
+inlineToConTeXt (SmallCaps lst) = do
+ contents <- inlineListToConTeXt lst
+ return $ braces $ "\\sc " <> contents
+inlineToConTeXt (Code _ str) | not ('{' `elem` str || '}' `elem` str) =
+ return $ "\\type" <> braces (text str)
+inlineToConTeXt (Code _ str) = do
+ opts <- gets stOptions
+ return $ "\\mono" <> braces (text $ stringToConTeXt opts str)
+inlineToConTeXt (Quoted SingleQuote lst) = do
+ contents <- inlineListToConTeXt lst
+ return $ "\\quote" <> braces contents
+inlineToConTeXt (Quoted DoubleQuote lst) = do
+ contents <- inlineListToConTeXt lst
+ return $ "\\quotation" <> braces contents
+inlineToConTeXt (Cite _ lst) = inlineListToConTeXt lst
+inlineToConTeXt (Str str) = do
+ opts <- gets stOptions
+ return $ text $ stringToConTeXt opts str
+inlineToConTeXt (Math InlineMath str) =
+ return $ char '$' <> text str <> char '$'
+inlineToConTeXt (Math DisplayMath str) =
+ return $ text "\\startformula " <> text str <> text " \\stopformula" <> space
+inlineToConTeXt (RawInline "context" str) = return $ text str
+inlineToConTeXt (RawInline "tex" str) = return $ text str
+inlineToConTeXt (RawInline _ _) = return empty
+inlineToConTeXt (LineBreak) = return $ text "\\crlf" <> cr
+inlineToConTeXt SoftBreak = do
+ wrapText <- gets (writerWrapText . stOptions)
+ return $ case wrapText of
+ WrapAuto -> space
+ WrapNone -> space
+ WrapPreserve -> cr
+inlineToConTeXt Space = return space
+-- Handle HTML-like internal document references to sections
+inlineToConTeXt (Link _ txt (('#' : ref), _)) = do
+ opts <- gets stOptions
+ contents <- inlineListToConTeXt txt
+ let ref' = toLabel $ stringToConTeXt opts ref
+ return $ text "\\goto"
+ <> braces contents
+ <> brackets (text ref')
+
+inlineToConTeXt (Link _ txt (src, _)) = do
+ let isAutolink = txt == [Str (unEscapeString src)]
+ st <- get
+ let next = stNextRef st
+ put $ st {stNextRef = next + 1}
+ let ref = "url" ++ show next
+ contents <- inlineListToConTeXt txt
+ return $ "\\useURL"
+ <> brackets (text ref)
+ <> brackets (text $ escapeStringUsing [('#',"\\#"),('%',"\\%")] src)
+ <> (if isAutolink
+ then empty
+ else brackets empty <> brackets contents)
+ <> "\\from"
+ <> brackets (text ref)
+inlineToConTeXt (Image attr@(_,cls,_) _ (src, _)) = do
+ opts <- gets stOptions
+ let showDim dir = let d = text (show dir) <> "="
+ in case (dimension dir attr) of
+ Just (Pixel a) ->
+ [d <> text (showInInch opts (Pixel a)) <> "in"]
+ Just (Percent a) ->
+ [d <> text (showFl (a / 100)) <> "\\textwidth"]
+ Just dim ->
+ [d <> text (show dim)]
+ Nothing ->
+ []
+ dimList = showDim Width ++ showDim Height
+ dims = if null dimList
+ then empty
+ else brackets $ cat (intersperse "," dimList)
+ clas = if null cls
+ then empty
+ else brackets $ text $ toLabel $ head cls
+ src' = if isURI src
+ then src
+ else unEscapeString src
+ return $ braces $ "\\externalfigure" <> brackets (text src') <> dims <> clas
+inlineToConTeXt (Note contents) = do
+ contents' <- blockListToConTeXt contents
+ let codeBlock x@(CodeBlock _ _) = [x]
+ codeBlock _ = []
+ let codeBlocks = query codeBlock contents
+ return $ if null codeBlocks
+ then text "\\footnote{" <> nest 2 contents' <> char '}'
+ else text "\\startbuffer " <> nest 2 contents' <>
+ text "\\stopbuffer\\footnote{\\getbuffer}"
+inlineToConTeXt (Span (_,_,kvs) ils) = do
+ let wrapDir txt = case lookup "dir" kvs of
+ Just "rtl" -> braces $ "\\righttoleft " <> txt
+ Just "ltr" -> braces $ "\\lefttoright " <> txt
+ _ -> txt
+ wrapLang txt = case lookup "lang" kvs of
+ Just lng -> "\\start\\language[" <> text (fromBcp47' lng)
+ <> "]" <> txt <> "\\stop "
+ Nothing -> txt
+ fmap (wrapLang . wrapDir) $ inlineListToConTeXt ils
+
+-- | Craft the section header, inserting the section reference, if supplied.
+sectionHeader :: Attr
+ -> Int
+ -> [Inline]
+ -> State WriterState Doc
+sectionHeader (ident,classes,_) hdrLevel lst = do
+ contents <- inlineListToConTeXt lst
+ st <- get
+ let opts = stOptions st
+ let level' = case writerTopLevelDivision opts of
+ TopLevelPart -> hdrLevel - 2
+ TopLevelChapter -> hdrLevel - 1
+ TopLevelSection -> hdrLevel
+ TopLevelDefault -> hdrLevel
+ let ident' = toLabel ident
+ let (section, chapter) = if "unnumbered" `elem` classes
+ then (text "subject", text "title")
+ else (text "section", text "chapter")
+ return $ case level' of
+ -1 -> text "\\part" <> braces contents
+ 0 -> char '\\' <> chapter <> braces contents
+ n | n >= 1 && n <= 5 -> char '\\'
+ <> text (concat (replicate (n - 1) "sub"))
+ <> section
+ <> (if (not . null) ident'
+ then brackets (text ident')
+ else empty)
+ <> braces contents
+ <> blankline
+ _ -> contents <> blankline
+
+fromBcp47' :: String -> String
+fromBcp47' = fromBcp47 . splitBy (=='-')
+
+-- Takes a list of the constituents of a BCP 47 language code
+-- and irons out ConTeXt's exceptions
+-- https://tools.ietf.org/html/bcp47#section-2.1
+-- http://wiki.contextgarden.net/Language_Codes
+fromBcp47 :: [String] -> String
+fromBcp47 [] = ""
+fromBcp47 ("ar":"SY":_) = "ar-sy"
+fromBcp47 ("ar":"IQ":_) = "ar-iq"
+fromBcp47 ("ar":"JO":_) = "ar-jo"
+fromBcp47 ("ar":"LB":_) = "ar-lb"
+fromBcp47 ("ar":"DZ":_) = "ar-dz"
+fromBcp47 ("ar":"MA":_) = "ar-ma"
+fromBcp47 ("de":"1901":_) = "deo"
+fromBcp47 ("de":"DE":_) = "de-de"
+fromBcp47 ("de":"AT":_) = "de-at"
+fromBcp47 ("de":"CH":_) = "de-ch"
+fromBcp47 ("el":"poly":_) = "agr"
+fromBcp47 ("en":"US":_) = "en-us"
+fromBcp47 ("en":"GB":_) = "en-gb"
+fromBcp47 ("grc":_) = "agr"
+fromBcp47 x = fromIso $ head x
+ where
+ fromIso "el" = "gr"
+ fromIso "eu" = "ba"
+ fromIso "he" = "il"
+ fromIso "jp" = "ja"
+ fromIso "uk" = "ua"
+ fromIso "vi" = "vn"
+ fromIso "zh" = "cn"
+ fromIso l = l
diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs
new file mode 100644
index 000000000..cf641dcd6
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Custom.hs
@@ -0,0 +1,322 @@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# LANGUAGE FlexibleInstances, OverloadedStrings,
+ ScopedTypeVariables, DeriveDataTypeable, CPP #-}
+#if MIN_VERSION_base(4,8,0)
+#else
+{-# LANGUAGE OverlappingInstances #-}
+#endif
+{- Copyright (C) 2012-2015 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.Custom
+ Copyright : Copyright (C) 2012-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to custom markup using
+a lua writer.
+-}
+module Text.Pandoc.Writers.Custom ( writeCustom ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Data.List ( intersperse )
+import Data.Char ( toLower )
+import Data.Typeable
+import Scripting.Lua (LuaState, StackValue, callfunc)
+import Text.Pandoc.Writers.Shared
+import qualified Scripting.Lua as Lua
+import qualified Text.Pandoc.UTF8 as UTF8
+import Control.Monad (when)
+import Control.Exception
+import qualified Data.Map as M
+import Text.Pandoc.Templates
+import GHC.IO.Encoding (getForeignEncoding,setForeignEncoding, utf8)
+
+attrToMap :: Attr -> M.Map String String
+attrToMap (id',classes,keyvals) = M.fromList
+ $ ("id", id')
+ : ("class", unwords classes)
+ : keyvals
+
+#if MIN_VERSION_hslua(0,4,0)
+#if MIN_VERSION_base(4,8,0)
+instance {-# OVERLAPS #-} StackValue [Char] where
+#else
+instance StackValue [Char] where
+#endif
+ push lua cs = Lua.push lua (UTF8.fromString cs)
+ peek lua i = do
+ res <- Lua.peek lua i
+ return $ UTF8.toString `fmap` res
+ valuetype _ = Lua.TSTRING
+#else
+#if MIN_VERSION_base(4,8,0)
+instance {-# OVERLAPS #-} StackValue a => StackValue [a] where
+#else
+instance StackValue a => StackValue [a] where
+#endif
+ push lua xs = do
+ Lua.createtable lua (length xs + 1) 0
+ let addValue (i, x) = Lua.push lua x >> Lua.rawseti lua (-2) i
+ mapM_ addValue $ zip [1..] xs
+ peek lua i = do
+ top <- Lua.gettop lua
+ let i' = if i < 0 then top + i + 1 else i
+ Lua.pushnil lua
+ lst <- getList lua i'
+ Lua.pop lua 1
+ return (Just lst)
+ valuetype _ = Lua.TTABLE
+
+getList :: StackValue a => LuaState -> Int -> IO [a]
+getList lua i' = do
+ continue <- Lua.next lua i'
+ if continue
+ then do
+ next <- Lua.peek lua (-1)
+ Lua.pop lua 1
+ x <- maybe (fail "peek returned Nothing") return next
+ rest <- getList lua i'
+ return (x : rest)
+ else return []
+#endif
+
+instance StackValue Format where
+ push lua (Format f) = Lua.push lua (map toLower f)
+ peek l n = fmap Format `fmap` Lua.peek l n
+ valuetype _ = Lua.TSTRING
+
+instance (StackValue a, StackValue b) => StackValue (M.Map a b) where
+ push lua m = do
+ let xs = M.toList m
+ Lua.createtable lua (length xs + 1) 0
+ let addValue (k, v) = Lua.push lua k >> Lua.push lua v >>
+ Lua.rawset lua (-3)
+ mapM_ addValue xs
+ peek _ _ = undefined -- not needed for our purposes
+ valuetype _ = Lua.TTABLE
+
+instance (StackValue a, StackValue b) => StackValue (a,b) where
+ push lua (k,v) = do
+ Lua.createtable lua 2 0
+ Lua.push lua k
+ Lua.push lua v
+ Lua.rawset lua (-3)
+ peek _ _ = undefined -- not needed for our purposes
+ valuetype _ = Lua.TTABLE
+
+#if MIN_VERSION_base(4,8,0)
+instance {-# OVERLAPS #-} StackValue [Inline] where
+#else
+instance StackValue [Inline] where
+#endif
+ push l ils = Lua.push l =<< inlineListToCustom l ils
+ peek _ _ = undefined
+ valuetype _ = Lua.TSTRING
+
+#if MIN_VERSION_base(4,8,0)
+instance {-# OVERLAPS #-} StackValue [Block] where
+#else
+instance StackValue [Block] where
+#endif
+ push l ils = Lua.push l =<< blockListToCustom l ils
+ peek _ _ = undefined
+ valuetype _ = Lua.TSTRING
+
+instance StackValue MetaValue where
+ push l (MetaMap m) = Lua.push l m
+ push l (MetaList xs) = Lua.push l xs
+ push l (MetaBool x) = Lua.push l x
+ push l (MetaString s) = Lua.push l s
+ push l (MetaInlines ils) = Lua.push l ils
+ push l (MetaBlocks bs) = Lua.push l bs
+ peek _ _ = undefined
+ valuetype (MetaMap _) = Lua.TTABLE
+ valuetype (MetaList _) = Lua.TTABLE
+ valuetype (MetaBool _) = Lua.TBOOLEAN
+ valuetype (MetaString _) = Lua.TSTRING
+ valuetype (MetaInlines _) = Lua.TSTRING
+ valuetype (MetaBlocks _) = Lua.TSTRING
+
+instance StackValue Citation where
+ push lua cit = do
+ Lua.createtable lua 6 0
+ let addValue (k :: String, v) = Lua.push lua k >> Lua.push lua v >>
+ Lua.rawset lua (-3)
+ addValue ("citationId", citationId cit)
+ addValue ("citationPrefix", citationPrefix cit)
+ addValue ("citationSuffix", citationSuffix cit)
+ addValue ("citationMode", show (citationMode cit))
+ addValue ("citationNoteNum", citationNoteNum cit)
+ addValue ("citationHash", citationHash cit)
+ peek = undefined
+ valuetype _ = Lua.TTABLE
+
+data PandocLuaException = PandocLuaException String
+ deriving (Show, Typeable)
+
+instance Exception PandocLuaException
+
+-- | Convert Pandoc to custom markup.
+writeCustom :: FilePath -> WriterOptions -> Pandoc -> IO String
+writeCustom luaFile opts doc@(Pandoc meta _) = do
+ luaScript <- UTF8.readFile luaFile
+ enc <- getForeignEncoding
+ setForeignEncoding utf8
+ lua <- Lua.newstate
+ Lua.openlibs lua
+ status <- Lua.loadstring lua luaScript luaFile
+ -- check for error in lua script (later we'll change the return type
+ -- to handle this more gracefully):
+ when (status /= 0) $
+#if MIN_VERSION_hslua(0,4,0)
+ Lua.tostring lua 1 >>= throw . PandocLuaException . UTF8.toString
+#else
+ Lua.tostring lua 1 >>= throw . PandocLuaException
+#endif
+ Lua.call lua 0 0
+ -- TODO - call hierarchicalize, so we have that info
+ rendered <- docToCustom lua opts doc
+ context <- metaToJSON opts
+ (blockListToCustom lua)
+ (inlineListToCustom lua)
+ meta
+ Lua.close lua
+ setForeignEncoding enc
+ let body = rendered
+ case writerTemplate opts of
+ Nothing -> return body
+ Just tpl -> return $ renderTemplate' tpl $ setField "body" body context
+
+docToCustom :: LuaState -> WriterOptions -> Pandoc -> IO String
+docToCustom lua opts (Pandoc (Meta metamap) blocks) = do
+ body <- blockListToCustom lua blocks
+ callfunc lua "Doc" body metamap (writerVariables opts)
+
+-- | Convert Pandoc block element to Custom.
+blockToCustom :: LuaState -- ^ Lua state
+ -> Block -- ^ Block element
+ -> IO String
+
+blockToCustom _ Null = return ""
+
+blockToCustom lua (Plain inlines) = callfunc lua "Plain" inlines
+
+blockToCustom lua (Para [Image attr txt (src,tit)]) =
+ callfunc lua "CaptionedImage" src tit txt (attrToMap attr)
+
+blockToCustom lua (Para inlines) = callfunc lua "Para" inlines
+
+blockToCustom lua (LineBlock linesList) = callfunc lua "LineBlock" linesList
+
+blockToCustom lua (RawBlock format str) =
+ callfunc lua "RawBlock" format str
+
+blockToCustom lua HorizontalRule = callfunc lua "HorizontalRule"
+
+blockToCustom lua (Header level attr inlines) =
+ callfunc lua "Header" level inlines (attrToMap attr)
+
+blockToCustom lua (CodeBlock attr str) =
+ callfunc lua "CodeBlock" str (attrToMap attr)
+
+blockToCustom lua (BlockQuote blocks) = callfunc lua "BlockQuote" blocks
+
+blockToCustom lua (Table capt aligns widths headers rows') =
+ callfunc lua "Table" capt (map show aligns) widths headers rows'
+
+blockToCustom lua (BulletList items) = callfunc lua "BulletList" items
+
+blockToCustom lua (OrderedList (num,sty,delim) items) =
+ callfunc lua "OrderedList" items num (show sty) (show delim)
+
+blockToCustom lua (DefinitionList items) =
+ callfunc lua "DefinitionList" items
+
+blockToCustom lua (Div attr items) =
+ callfunc lua "Div" items (attrToMap attr)
+
+-- | Convert list of Pandoc block elements to Custom.
+blockListToCustom :: LuaState -- ^ Options
+ -> [Block] -- ^ List of block elements
+ -> IO String
+blockListToCustom lua xs = do
+ blocksep <- callfunc lua "Blocksep"
+ bs <- mapM (blockToCustom lua) xs
+ return $ mconcat $ intersperse blocksep bs
+
+-- | Convert list of Pandoc inline elements to Custom.
+inlineListToCustom :: LuaState -> [Inline] -> IO String
+inlineListToCustom lua lst = do
+ xs <- mapM (inlineToCustom lua) lst
+ return $ concat xs
+
+-- | Convert Pandoc inline element to Custom.
+inlineToCustom :: LuaState -> Inline -> IO String
+
+inlineToCustom lua (Str str) = callfunc lua "Str" str
+
+inlineToCustom lua Space = callfunc lua "Space"
+
+inlineToCustom lua SoftBreak = callfunc lua "SoftBreak"
+
+inlineToCustom lua (Emph lst) = callfunc lua "Emph" lst
+
+inlineToCustom lua (Strong lst) = callfunc lua "Strong" lst
+
+inlineToCustom lua (Strikeout lst) = callfunc lua "Strikeout" lst
+
+inlineToCustom lua (Superscript lst) = callfunc lua "Superscript" lst
+
+inlineToCustom lua (Subscript lst) = callfunc lua "Subscript" lst
+
+inlineToCustom lua (SmallCaps lst) = callfunc lua "SmallCaps" lst
+
+inlineToCustom lua (Quoted SingleQuote lst) = callfunc lua "SingleQuoted" lst
+
+inlineToCustom lua (Quoted DoubleQuote lst) = callfunc lua "DoubleQuoted" lst
+
+inlineToCustom lua (Cite cs lst) = callfunc lua "Cite" lst cs
+
+inlineToCustom lua (Code attr str) =
+ callfunc lua "Code" str (attrToMap attr)
+
+inlineToCustom lua (Math DisplayMath str) =
+ callfunc lua "DisplayMath" str
+
+inlineToCustom lua (Math InlineMath str) =
+ callfunc lua "InlineMath" str
+
+inlineToCustom lua (RawInline format str) =
+ callfunc lua "RawInline" format str
+
+inlineToCustom lua (LineBreak) = callfunc lua "LineBreak"
+
+inlineToCustom lua (Link attr txt (src,tit)) =
+ callfunc lua "Link" txt src tit (attrToMap attr)
+
+inlineToCustom lua (Image attr alt (src,tit)) =
+ callfunc lua "Image" alt src tit (attrToMap attr)
+
+inlineToCustom lua (Note contents) = callfunc lua "Note" contents
+
+inlineToCustom lua (Span attr items) =
+ callfunc lua "Span" items (attrToMap attr)
diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs
new file mode 100644
index 000000000..597851f65
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Docbook.hs
@@ -0,0 +1,440 @@
+{-# LANGUAGE OverloadedStrings, PatternGuards #-}
+{-
+Copyright (C) 2006-2015 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.Docbook
+ Copyright : Copyright (C) 2006-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to Docbook XML.
+-}
+module Text.Pandoc.Writers.Docbook ( writeDocbook4, writeDocbook5 ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.XML
+import Text.Pandoc.Shared
+import Text.Pandoc.Walk
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Options
+import Text.Pandoc.Templates (renderTemplate')
+import Text.Pandoc.Writers.Math
+import Data.List ( stripPrefix, isPrefixOf, intercalate, isSuffixOf )
+import Data.Char ( toLower )
+import Data.Monoid ( Any(..) )
+import Text.Pandoc.Highlighting ( languages, languagesByExtension )
+import Text.Pandoc.Pretty
+import Text.Pandoc.ImageSize
+import qualified Text.Pandoc.Builder as B
+import Text.TeXMath
+import qualified Text.XML.Light as Xml
+import Data.Generics (everywhere, mkT)
+import Text.Pandoc.Class (PandocMonad, report)
+import Text.Pandoc.Logging
+import Control.Monad.Reader
+
+data DocBookVersion = DocBook4 | DocBook5
+ deriving (Eq, Show)
+
+type DB = ReaderT DocBookVersion
+
+-- | Convert list of authors to a docbook <author> section
+authorToDocbook :: PandocMonad m => WriterOptions -> [Inline] -> DB m B.Inlines
+authorToDocbook opts name' = do
+ name <- render Nothing <$> inlinesToDocbook opts name'
+ let colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ return $ B.rawInline "docbook" $ render colwidth $
+ if ',' `elem` name
+ then -- last name first
+ let (lastname, rest) = break (==',') name
+ firstname = triml rest in
+ inTagsSimple "firstname" (text $ escapeStringForXML firstname) <>
+ inTagsSimple "surname" (text $ escapeStringForXML lastname)
+ else -- last name last
+ let namewords = words name
+ lengthname = length namewords
+ (firstname, lastname) = case lengthname of
+ 0 -> ("","")
+ 1 -> ("", name)
+ n -> (intercalate " " (take (n-1) namewords), last namewords)
+ in inTagsSimple "firstname" (text $ escapeStringForXML firstname) $$
+ inTagsSimple "surname" (text $ escapeStringForXML lastname)
+
+writeDocbook4 :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeDocbook4 opts d =
+ runReaderT (writeDocbook opts d) DocBook4
+
+writeDocbook5 :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeDocbook5 opts d =
+ runReaderT (writeDocbook opts d) DocBook5
+
+-- | Convert Pandoc document to string in Docbook format.
+writeDocbook :: PandocMonad m => WriterOptions -> Pandoc -> DB m String
+writeDocbook opts (Pandoc meta blocks) = do
+ let elements = hierarchicalize blocks
+ let colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ let render' = render colwidth
+ let opts' = if (maybe False (("/book>" `isSuffixOf`) . trimr)
+ (writerTemplate opts) &&
+ TopLevelDefault == writerTopLevelDivision opts)
+ then opts{ writerTopLevelDivision = TopLevelChapter }
+ else opts
+ -- The numbering here follows LaTeX's internal numbering
+ let startLvl = case writerTopLevelDivision opts' of
+ TopLevelPart -> -1
+ TopLevelChapter -> 0
+ TopLevelSection -> 1
+ TopLevelDefault -> 1
+ auths' <- mapM (authorToDocbook opts) $ docAuthors meta
+ let meta' = B.setMeta "author" auths' meta
+ metadata <- metaToJSON opts
+ (fmap (render colwidth . vcat) .
+ (mapM (elementToDocbook opts' startLvl) .
+ hierarchicalize))
+ (fmap (render colwidth) . inlinesToDocbook opts')
+ meta'
+ main <- (render' . vcat) <$> (mapM (elementToDocbook opts' startLvl) elements)
+ let context = defField "body" main
+ $ defField "mathml" (case writerHTMLMathMethod opts of
+ MathML -> True
+ _ -> False)
+ $ metadata
+ return $ case writerTemplate opts of
+ Nothing -> main
+ Just tpl -> renderTemplate' tpl context
+
+-- | Convert an Element to Docbook.
+elementToDocbook :: PandocMonad m => WriterOptions -> Int -> Element -> DB m Doc
+elementToDocbook opts _ (Blk block) = blockToDocbook opts block
+elementToDocbook opts lvl (Sec _ _num (id',_,_) title elements) = do
+ version <- ask
+ -- Docbook doesn't allow sections with no content, so insert some if needed
+ let elements' = if null elements
+ then [Blk (Para [])]
+ else elements
+ tag = case lvl of
+ -1 -> "part"
+ 0 -> "chapter"
+ n | n >= 1 && n <= 5 -> if version == DocBook5
+ then "section"
+ else "sect" ++ show n
+ _ -> "simplesect"
+ idName = if version == DocBook5
+ then "xml:id"
+ else "id"
+ idAttr = [(idName, writerIdentifierPrefix opts ++ id') | not (null id')]
+ nsAttr = if version == DocBook5 && lvl == 0 then [("xmlns", "http://docbook.org/ns/docbook"),("xmlns:xlink", "http://www.w3.org/1999/xlink")]
+ else []
+ attribs = nsAttr ++ idAttr
+ contents <- mapM (elementToDocbook opts (lvl + 1)) elements'
+ title' <- inlinesToDocbook opts title
+ return $ inTags True tag attribs $
+ inTagsSimple "title" title' $$ vcat contents
+
+-- | Convert a list of Pandoc blocks to Docbook.
+blocksToDocbook :: PandocMonad m => WriterOptions -> [Block] -> DB m Doc
+blocksToDocbook opts = fmap vcat . mapM (blockToDocbook opts)
+
+-- | Auxiliary function to convert Plain block to Para.
+plainToPara :: Block -> Block
+plainToPara (Plain x) = Para x
+plainToPara x = x
+
+-- | Convert a list of pairs of terms and definitions into a list of
+-- Docbook varlistentrys.
+deflistItemsToDocbook :: PandocMonad m
+ => WriterOptions -> [([Inline],[[Block]])] -> DB m Doc
+deflistItemsToDocbook opts items =
+ vcat <$> mapM (\(term, defs) -> deflistItemToDocbook opts term defs) items
+
+-- | Convert a term and a list of blocks into a Docbook varlistentry.
+deflistItemToDocbook :: PandocMonad m
+ => WriterOptions -> [Inline] -> [[Block]] -> DB m Doc
+deflistItemToDocbook opts term defs = do
+ term' <- inlinesToDocbook opts term
+ def' <- blocksToDocbook opts $ concatMap (map plainToPara) defs
+ return $ inTagsIndented "varlistentry" $
+ inTagsIndented "term" term' $$
+ inTagsIndented "listitem" def'
+
+-- | Convert a list of lists of blocks to a list of Docbook list items.
+listItemsToDocbook :: PandocMonad m => WriterOptions -> [[Block]] -> DB m Doc
+listItemsToDocbook opts items = vcat <$> mapM (listItemToDocbook opts) items
+
+-- | Convert a list of blocks into a Docbook list item.
+listItemToDocbook :: PandocMonad m => WriterOptions -> [Block] -> DB m Doc
+listItemToDocbook opts item =
+ inTagsIndented "listitem" <$> blocksToDocbook opts (map plainToPara item)
+
+imageToDocbook :: WriterOptions -> Attr -> String -> Doc
+imageToDocbook _ attr src = selfClosingTag "imagedata" $
+ ("fileref", src) : idAndRole attr ++ dims
+ where
+ dims = go Width "width" ++ go Height "depth"
+ go dir dstr = case (dimension dir attr) of
+ Just a -> [(dstr, show a)]
+ Nothing -> []
+
+-- | Convert a Pandoc block element to Docbook.
+blockToDocbook :: PandocMonad m => WriterOptions -> Block -> DB m Doc
+blockToDocbook _ Null = return empty
+-- Add ids to paragraphs in divs with ids - this is needed for
+-- pandoc-citeproc to get link anchors in bibliographies:
+blockToDocbook opts (Div (ident,_,_) [Para lst]) =
+ let attribs = [("id", ident) | not (null ident)] in
+ if hasLineBreaks lst
+ then (flush . nowrap . inTags False "literallayout" attribs)
+ <$> inlinesToDocbook opts lst
+ else inTags True "para" attribs <$> inlinesToDocbook opts lst
+blockToDocbook opts (Div (ident,_,_) bs) = do
+ contents <- blocksToDocbook opts (map plainToPara bs)
+ return $
+ (if null ident
+ then mempty
+ else selfClosingTag "anchor" [("id", ident)]) $$ contents
+blockToDocbook _ (Header _ _ _) =
+ return empty -- should not occur after hierarchicalize
+blockToDocbook opts (Plain lst) = inlinesToDocbook opts lst
+-- title beginning with fig: indicates that the image is a figure
+blockToDocbook opts (Para [Image attr txt (src,'f':'i':'g':':':_)]) = do
+ alt <- inlinesToDocbook opts txt
+ let capt = if null txt
+ then empty
+ else inTagsSimple "title" alt
+ return $ inTagsIndented "figure" $
+ capt $$
+ (inTagsIndented "mediaobject" $
+ (inTagsIndented "imageobject"
+ (imageToDocbook opts attr src)) $$
+ inTagsSimple "textobject" (inTagsSimple "phrase" alt))
+blockToDocbook opts (Para lst)
+ | hasLineBreaks lst = (flush . nowrap . inTagsSimple "literallayout")
+ <$> inlinesToDocbook opts lst
+ | otherwise = inTagsIndented "para" <$> inlinesToDocbook opts lst
+blockToDocbook opts (LineBlock lns) =
+ blockToDocbook opts $ linesToPara lns
+blockToDocbook opts (BlockQuote blocks) =
+ inTagsIndented "blockquote" <$> blocksToDocbook opts blocks
+blockToDocbook _ (CodeBlock (_,classes,_) str) = return $
+ text ("<programlisting" ++ lang ++ ">") <> cr <>
+ flush (text (escapeStringForXML str) <> cr <> text "</programlisting>")
+ where lang = if null langs
+ then ""
+ else " language=\"" ++ escapeStringForXML (head langs) ++
+ "\""
+ isLang l = map toLower l `elem` map (map toLower) languages
+ langsFrom s = if isLang s
+ then [s]
+ else languagesByExtension . map toLower $ s
+ langs = concatMap langsFrom classes
+blockToDocbook opts (BulletList lst) = do
+ let attribs = [("spacing", "compact") | isTightList lst]
+ inTags True "itemizedlist" attribs <$> listItemsToDocbook opts lst
+blockToDocbook _ (OrderedList _ []) = return empty
+blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) = do
+ let numeration = case numstyle of
+ DefaultStyle -> []
+ Decimal -> [("numeration", "arabic")]
+ Example -> [("numeration", "arabic")]
+ UpperAlpha -> [("numeration", "upperalpha")]
+ LowerAlpha -> [("numeration", "loweralpha")]
+ UpperRoman -> [("numeration", "upperroman")]
+ LowerRoman -> [("numeration", "lowerroman")]
+ spacing = [("spacing", "compact") | isTightList (first:rest)]
+ attribs = numeration ++ spacing
+ items <- if start == 1
+ then listItemsToDocbook opts (first:rest)
+ else do
+ first' <- blocksToDocbook opts (map plainToPara first)
+ rest' <- listItemsToDocbook opts rest
+ return $
+ (inTags True "listitem" [("override",show start)] first') $$
+ rest'
+ return $ inTags True "orderedlist" attribs items
+blockToDocbook opts (DefinitionList lst) = do
+ let attribs = [("spacing", "compact") | isTightList $ concatMap snd lst]
+ inTags True "variablelist" attribs <$> deflistItemsToDocbook opts lst
+blockToDocbook _ b@(RawBlock f str)
+ | f == "docbook" = return $ text str -- raw XML block
+ | f == "html" = do
+ version <- ask
+ if version == DocBook5
+ then return empty -- No html in Docbook5
+ else return $ text str -- allow html for backwards compatibility
+ | otherwise = do
+ report $ BlockNotRendered b
+ return empty
+blockToDocbook _ HorizontalRule = return empty -- not semantic
+blockToDocbook opts (Table caption aligns widths headers rows) = do
+ captionDoc <- if null caption
+ then return empty
+ else inTagsIndented "title" <$>
+ inlinesToDocbook opts caption
+ let tableType = if isEmpty captionDoc then "informaltable" else "table"
+ percent w = show (truncate (100*w) :: Integer) ++ "*"
+ coltags = vcat $ zipWith (\w al -> selfClosingTag "colspec"
+ ([("colwidth", percent w) | w > 0] ++
+ [("align", alignmentToString al)])) widths aligns
+ head' <- if all null headers
+ then return empty
+ else inTagsIndented "thead" <$> tableRowToDocbook opts headers
+ body' <- (inTagsIndented "tbody" . vcat) <$>
+ mapM (tableRowToDocbook opts) rows
+ return $ inTagsIndented tableType $ captionDoc $$
+ (inTags True "tgroup" [("cols", show (length headers))] $
+ coltags $$ head' $$ body')
+
+hasLineBreaks :: [Inline] -> Bool
+hasLineBreaks = getAny . query isLineBreak . walk removeNote
+ where
+ removeNote :: Inline -> Inline
+ removeNote (Note _) = Str ""
+ removeNote x = x
+ isLineBreak :: Inline -> Any
+ isLineBreak LineBreak = Any True
+ isLineBreak _ = Any False
+
+alignmentToString :: Alignment -> [Char]
+alignmentToString alignment = case alignment of
+ AlignLeft -> "left"
+ AlignRight -> "right"
+ AlignCenter -> "center"
+ AlignDefault -> "left"
+
+tableRowToDocbook :: PandocMonad m
+ => WriterOptions
+ -> [[Block]]
+ -> DB m Doc
+tableRowToDocbook opts cols =
+ (inTagsIndented "row" . vcat) <$> mapM (tableItemToDocbook opts) cols
+
+tableItemToDocbook :: PandocMonad m
+ => WriterOptions
+ -> [Block]
+ -> DB m Doc
+tableItemToDocbook opts item =
+ (inTags True "entry" [] . vcat) <$> mapM (blockToDocbook opts) item
+
+-- | Convert a list of inline elements to Docbook.
+inlinesToDocbook :: PandocMonad m => WriterOptions -> [Inline] -> DB m Doc
+inlinesToDocbook opts lst = hcat <$> mapM (inlineToDocbook opts) lst
+
+-- | Convert an inline element to Docbook.
+inlineToDocbook :: PandocMonad m => WriterOptions -> Inline -> DB m Doc
+inlineToDocbook _ (Str str) = return $ text $ escapeStringForXML str
+inlineToDocbook opts (Emph lst) =
+ inTagsSimple "emphasis" <$> inlinesToDocbook opts lst
+inlineToDocbook opts (Strong lst) =
+ inTags False "emphasis" [("role", "strong")] <$> inlinesToDocbook opts lst
+inlineToDocbook opts (Strikeout lst) =
+ inTags False "emphasis" [("role", "strikethrough")] <$>
+ inlinesToDocbook opts lst
+inlineToDocbook opts (Superscript lst) =
+ inTagsSimple "superscript" <$> inlinesToDocbook opts lst
+inlineToDocbook opts (Subscript lst) =
+ inTagsSimple "subscript" <$> inlinesToDocbook opts lst
+inlineToDocbook opts (SmallCaps lst) =
+ inTags False "emphasis" [("role", "smallcaps")] <$>
+ inlinesToDocbook opts lst
+inlineToDocbook opts (Quoted _ lst) =
+ inTagsSimple "quote" <$> inlinesToDocbook opts lst
+inlineToDocbook opts (Cite _ lst) =
+ inlinesToDocbook opts lst
+inlineToDocbook opts (Span (ident,_,_) ils) =
+ ((if null ident
+ then mempty
+ else selfClosingTag "anchor" [("id", ident)]) <>) <$>
+ inlinesToDocbook opts ils
+inlineToDocbook _ (Code _ str) =
+ return $ inTagsSimple "literal" $ text (escapeStringForXML str)
+inlineToDocbook opts (Math t str)
+ | isMathML (writerHTMLMathMethod opts) = do
+ res <- convertMath writeMathML t str
+ case res of
+ Right r -> return $ inTagsSimple tagtype
+ $ text $ Xml.ppcElement conf
+ $ fixNS
+ $ removeAttr r
+ Left il -> inlineToDocbook opts il
+ | otherwise =
+ texMathToInlines t str >>= inlinesToDocbook opts
+ where tagtype = case t of
+ InlineMath -> "inlineequation"
+ DisplayMath -> "informalequation"
+ conf = Xml.useShortEmptyTags (const False) Xml.defaultConfigPP
+ removeAttr e = e{ Xml.elAttribs = [] }
+ fixNS' qname = qname{ Xml.qPrefix = Just "mml" }
+ fixNS = everywhere (mkT fixNS')
+inlineToDocbook _ il@(RawInline f x)
+ | f == "html" || f == "docbook" = return $ text x
+ | otherwise = do
+ report $ InlineNotRendered il
+ return empty
+inlineToDocbook _ LineBreak = return $ text "\n"
+-- currently ignore, would require the option to add custom
+-- styles to the document
+inlineToDocbook _ Space = return space
+-- because we use \n for LineBreak, we can't do soft breaks:
+inlineToDocbook _ SoftBreak = return space
+inlineToDocbook opts (Link attr txt (src, _))
+ | Just email <- stripPrefix "mailto:" src =
+ let emailLink = inTagsSimple "email" $ text $
+ escapeStringForXML $ email
+ in case txt of
+ [Str s] | escapeURI s == email -> return emailLink
+ _ -> do contents <- inlinesToDocbook opts txt
+ return $ contents <+>
+ char '(' <> emailLink <> char ')'
+ | otherwise = do
+ version <- ask
+ (if isPrefixOf "#" src
+ then inTags False "link" $ ("linkend", writerIdentifierPrefix opts ++ drop 1 src) : idAndRole attr
+ else if version == DocBook5
+ then inTags False "link" $ ("xlink:href", src) : idAndRole attr
+ else inTags False "ulink" $ ("url", src) : idAndRole attr )
+ <$> inlinesToDocbook opts txt
+inlineToDocbook opts (Image attr _ (src, tit)) = return $
+ let titleDoc = if null tit
+ then empty
+ else inTagsIndented "objectinfo" $
+ inTagsIndented "title" (text $ escapeStringForXML tit)
+ in inTagsIndented "inlinemediaobject" $ inTagsIndented "imageobject" $
+ titleDoc $$ imageToDocbook opts attr src
+inlineToDocbook opts (Note contents) =
+ inTagsIndented "footnote" <$> blocksToDocbook opts contents
+
+isMathML :: HTMLMathMethod -> Bool
+isMathML MathML = True
+isMathML _ = False
+
+idAndRole :: Attr -> [(String, String)]
+idAndRole (id',cls,_) = ident ++ role
+ where
+ ident = if null id'
+ then []
+ else [("id", id')]
+ role = if null cls
+ then []
+ else [("role", unwords cls)]
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
new file mode 100644
index 000000000..56aa29211
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -0,0 +1,1302 @@
+{-# LANGUAGE ScopedTypeVariables, PatternGuards, ViewPatterns, DeriveFunctor #-}
+{-
+Copyright (C) 2012-2015 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.Docx
+ Copyright : Copyright (C) 2012-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to docx.
+-}
+module Text.Pandoc.Writers.Docx ( writeDocx ) where
+import Data.List ( intercalate, isPrefixOf, isSuffixOf )
+import qualified Data.ByteString as B
+import qualified Data.ByteString.Lazy as BL
+import qualified Data.ByteString.Lazy.Char8 as BL8
+import qualified Data.Map as M
+import qualified Data.Set as Set
+import qualified Text.Pandoc.UTF8 as UTF8
+import Codec.Archive.Zip
+import Data.Time.Clock.POSIX
+import Text.Pandoc.Compat.Time
+import Text.Pandoc.Definition
+import Text.Pandoc.Generic
+import Text.Pandoc.ImageSize
+import Text.Pandoc.Shared hiding (Element)
+import Text.Pandoc.Writers.Shared (fixDisplayMath)
+import Text.Pandoc.Options
+import Text.Pandoc.Writers.Math
+import Text.Pandoc.Highlighting ( highlight )
+import Text.Pandoc.Walk
+import Text.Pandoc.Error (PandocError)
+import Text.XML.Light as XML
+import Text.TeXMath
+import Text.Pandoc.Readers.Docx.StyleMap
+import Control.Monad.Reader
+import Control.Monad.State
+import Skylighting
+import Control.Monad.Except (runExceptT)
+import System.Random (randomR)
+import Text.Printf (printf)
+import Data.Monoid ((<>))
+import qualified Data.Text as T
+import Text.Pandoc.MIME (MimeType, getMimeType, getMimeTypeDef,
+ extensionFromMimeType)
+import Control.Applicative ((<|>))
+import Data.Maybe (fromMaybe, mapMaybe, maybeToList, isNothing)
+import Data.Char (ord, isSpace, toLower)
+import Text.Pandoc.Class (PandocMonad, report)
+import qualified Text.Pandoc.Class as P
+import Text.Pandoc.Logging
+
+data ListMarker = NoMarker
+ | BulletMarker
+ | NumberMarker ListNumberStyle ListNumberDelim Int
+ deriving (Show, Read, Eq, Ord)
+
+listMarkerToId :: ListMarker -> String
+listMarkerToId NoMarker = "990"
+listMarkerToId BulletMarker = "991"
+listMarkerToId (NumberMarker sty delim n) =
+ '9' : '9' : styNum : delimNum : show n
+ where styNum = case sty of
+ DefaultStyle -> '2'
+ Example -> '3'
+ Decimal -> '4'
+ LowerRoman -> '5'
+ UpperRoman -> '6'
+ LowerAlpha -> '7'
+ UpperAlpha -> '8'
+ delimNum = case delim of
+ DefaultDelim -> '0'
+ Period -> '1'
+ OneParen -> '2'
+ TwoParens -> '3'
+
+data WriterEnv = WriterEnv{ envTextProperties :: [Element]
+ , envParaProperties :: [Element]
+ , envRTL :: Bool
+ , envListLevel :: Int
+ , envListNumId :: Int
+ , envInDel :: Bool
+ , envChangesAuthor :: String
+ , envChangesDate :: String
+ , envPrintWidth :: Integer
+ }
+
+defaultWriterEnv :: WriterEnv
+defaultWriterEnv = WriterEnv{ envTextProperties = []
+ , envParaProperties = []
+ , envRTL = False
+ , envListLevel = -1
+ , envListNumId = 1
+ , envInDel = False
+ , envChangesAuthor = "unknown"
+ , envChangesDate = "1969-12-31T19:00:00Z"
+ , envPrintWidth = 1
+ }
+
+data WriterState = WriterState{
+ stFootnotes :: [Element]
+ , stSectionIds :: Set.Set String
+ , stExternalLinks :: M.Map String String
+ , stImages :: M.Map FilePath (String, String, Maybe MimeType, Element, B.ByteString)
+ , stLists :: [ListMarker]
+ , stInsId :: Int
+ , stDelId :: Int
+ , stStyleMaps :: StyleMaps
+ , stFirstPara :: Bool
+ , stTocTitle :: [Inline]
+ , stDynamicParaProps :: [String]
+ , stDynamicTextProps :: [String]
+ }
+
+defaultWriterState :: WriterState
+defaultWriterState = WriterState{
+ stFootnotes = defaultFootnotes
+ , stSectionIds = Set.empty
+ , stExternalLinks = M.empty
+ , stImages = M.empty
+ , stLists = [NoMarker]
+ , stInsId = 1
+ , stDelId = 1
+ , stStyleMaps = defaultStyleMaps
+ , stFirstPara = False
+ , stTocTitle = [Str "Table of Contents"]
+ , stDynamicParaProps = []
+ , stDynamicTextProps = []
+ }
+
+type WS m = ReaderT WriterEnv (StateT WriterState m)
+
+mknode :: Node t => String -> [(String,String)] -> t -> Element
+mknode s attrs =
+ add_attrs (map (\(k,v) -> Attr (nodename k) v) attrs) . node (nodename s)
+
+nodename :: String -> QName
+nodename s = QName{ qName = name, qURI = Nothing, qPrefix = prefix }
+ where (name, prefix) = case break (==':') s of
+ (xs,[]) -> (xs, Nothing)
+ (ys, _:zs) -> (zs, Just ys)
+
+toLazy :: B.ByteString -> BL.ByteString
+toLazy = BL.fromChunks . (:[])
+
+renderXml :: Element -> BL.ByteString
+renderXml elt = BL8.pack "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" <>
+ UTF8.fromStringLazy (showElement elt)
+
+renumIdMap :: Int -> [Element] -> M.Map String String
+renumIdMap _ [] = M.empty
+renumIdMap n (e:es)
+ | Just oldId <- findAttr (QName "Id" Nothing Nothing) e =
+ M.insert oldId ("rId" ++ (show n)) (renumIdMap (n+1) es)
+ | otherwise = renumIdMap n es
+
+replaceAttr :: (QName -> Bool) -> String -> [XML.Attr] -> [XML.Attr]
+replaceAttr _ _ [] = []
+replaceAttr f val (a:as) | f (attrKey a) =
+ (XML.Attr (attrKey a) val) : (replaceAttr f val as)
+ | otherwise = a : (replaceAttr f val as)
+
+renumId :: (QName -> Bool) -> (M.Map String String) -> Element -> Element
+renumId f renumMap e
+ | Just oldId <- findAttrBy f e
+ , Just newId <- M.lookup oldId renumMap =
+ let attrs' = replaceAttr f newId (elAttribs e)
+ in
+ e { elAttribs = attrs' }
+ | otherwise = e
+
+renumIds :: (QName -> Bool) -> (M.Map String String) -> [Element] -> [Element]
+renumIds f renumMap = map (renumId f renumMap)
+
+-- | Certain characters are invalid in XML even if escaped.
+-- See #1992
+stripInvalidChars :: String -> String
+stripInvalidChars = filter isValidChar
+
+-- | See XML reference
+isValidChar :: Char -> Bool
+isValidChar (ord -> c)
+ | c == 0x9 = True
+ | c == 0xA = True
+ | c == 0xD = True
+ | 0x20 <= c && c <= 0xD7FF = True
+ | 0xE000 <= c && c <= 0xFFFD = True
+ | 0x10000 <= c && c <= 0x10FFFF = True
+ | otherwise = False
+
+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 _ = []
+
+
+
+writeDocx :: (PandocMonad m)
+ => WriterOptions -- ^ Writer options
+ -> Pandoc -- ^ Document to convert
+ -> m BL.ByteString
+writeDocx opts doc@(Pandoc meta _) = do
+ let datadir = writerUserDataDir opts
+ let doc' = walk fixDisplayMath $ doc
+ username <- P.lookupEnv "USERNAME"
+ utctime <- P.getCurrentTime
+ distArchive <- (toArchive . BL.fromStrict) <$>
+ P.readDataFile datadir "reference.docx"
+ refArchive <- case writerReferenceDoc opts of
+ Just f -> toArchive <$> P.readFileLazy f
+ Nothing -> return distArchive
+
+ parsedDoc <- parseXml refArchive distArchive "word/document.xml"
+ let wname f qn = qPrefix qn == Just "w" && f (qName qn)
+ let mbsectpr = filterElementName (wname (=="sectPr")) parsedDoc
+
+ -- Gets the template size
+ let mbpgsz = mbsectpr >>= (filterElementName (wname (=="pgSz")))
+ let mbAttrSzWidth = (elAttribs <$> mbpgsz) >>= (lookupAttrBy ((=="w") . qName))
+
+ let mbpgmar = mbsectpr >>= (filterElementName (wname (=="pgMar")))
+ let mbAttrMarLeft = (elAttribs <$> mbpgmar) >>= (lookupAttrBy ((=="left") . qName))
+ let mbAttrMarRight = (elAttribs <$> mbpgmar) >>= (lookupAttrBy ((=="right") . qName))
+
+ -- Get the avaible area (converting the size and the margins to int and
+ -- doing the difference
+ let pgContentWidth = (-) <$> (read <$> mbAttrSzWidth ::Maybe Integer)
+ <*> (
+ (+) <$> (read <$> mbAttrMarRight ::Maybe Integer)
+ <*> (read <$> mbAttrMarLeft ::Maybe Integer)
+ )
+
+ -- styles
+ let stylepath = "word/styles.xml"
+ styledoc <- parseXml refArchive distArchive stylepath
+
+ -- parse styledoc for heading styles
+ let styleMaps = getStyleMaps styledoc
+
+ let tocTitle = fromMaybe (stTocTitle defaultWriterState) $
+ metaValueToInlines <$> lookupMeta "toc-title" meta
+
+ let initialSt = defaultWriterState {
+ stStyleMaps = styleMaps
+ , stTocTitle = tocTitle
+ }
+
+ let isRTLmeta = case lookupMeta "dir" meta of
+ Just (MetaString "rtl") -> True
+ Just (MetaInlines [Str "rtl"]) -> True
+ _ -> False
+
+ let env = defaultWriterEnv {
+ envRTL = isRTLmeta
+ , envChangesAuthor = fromMaybe "unknown" username
+ , envChangesDate = formatTime defaultTimeLocale "%FT%XZ" utctime
+ , envPrintWidth = (maybe 420 (\x -> quot x 20) pgContentWidth)
+ }
+
+
+ ((contents, footnotes), st) <- runStateT
+ (runReaderT
+ (writeOpenXML opts{writerWrapText = WrapNone} doc')
+ env)
+ initialSt
+ let epochtime = floor $ utcTimeToPOSIXSeconds utctime
+ let imgs = M.elems $ stImages st
+
+ -- create entries for images in word/media/...
+ let toImageEntry (_,path,_,_,img) = toEntry ("word/" ++ path) epochtime $ toLazy img
+ let imageEntries = map toImageEntry imgs
+
+ let stdAttributes =
+ [("xmlns:w","http://schemas.openxmlformats.org/wordprocessingml/2006/main")
+ ,("xmlns:m","http://schemas.openxmlformats.org/officeDocument/2006/math")
+ ,("xmlns:r","http://schemas.openxmlformats.org/officeDocument/2006/relationships")
+ ,("xmlns:o","urn:schemas-microsoft-com:office:office")
+ ,("xmlns:v","urn:schemas-microsoft-com:vml")
+ ,("xmlns:w10","urn:schemas-microsoft-com:office:word")
+ ,("xmlns:a","http://schemas.openxmlformats.org/drawingml/2006/main")
+ ,("xmlns:pic","http://schemas.openxmlformats.org/drawingml/2006/picture")
+ ,("xmlns:wp","http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing")]
+
+
+ parsedRels <- parseXml refArchive distArchive "word/_rels/document.xml.rels"
+ let isHeaderNode e = findAttr (QName "Type" Nothing Nothing) e == Just "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"
+ let isFooterNode e = findAttr (QName "Type" Nothing Nothing) e == Just "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
+ let headers = filterElements isHeaderNode parsedRels
+ let footers = filterElements isFooterNode parsedRels
+
+ let extractTarget = findAttr (QName "Target" Nothing Nothing)
+
+ -- we create [Content_Types].xml and word/_rels/document.xml.rels
+ -- from scratch rather than reading from reference.docx,
+ -- because Word sometimes changes these files when a reference.docx is modified,
+ -- e.g. deleting the reference to footnotes.xml or removing default entries
+ -- for image content types.
+
+ -- [Content_Types].xml
+ let mkOverrideNode (part', contentType') = mknode "Override"
+ [("PartName",part'),("ContentType",contentType')] ()
+ let mkImageOverride (_, imgpath, mbMimeType, _, _) =
+ mkOverrideNode ("/word/" ++ imgpath,
+ fromMaybe "application/octet-stream" mbMimeType)
+ let mkMediaOverride imgpath =
+ mkOverrideNode ('/':imgpath, getMimeTypeDef imgpath)
+ let overrides = map mkOverrideNode (
+ [("/word/webSettings.xml",
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml")
+ ,("/word/numbering.xml",
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml")
+ ,("/word/settings.xml",
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml")
+ ,("/word/theme/theme1.xml",
+ "application/vnd.openxmlformats-officedocument.theme+xml")
+ ,("/word/fontTable.xml",
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml")
+ ,("/docProps/app.xml",
+ "application/vnd.openxmlformats-officedocument.extended-properties+xml")
+ ,("/docProps/core.xml",
+ "application/vnd.openxmlformats-package.core-properties+xml")
+ ,("/word/styles.xml",
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml")
+ ,("/word/document.xml",
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml")
+ ,("/word/footnotes.xml",
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml")
+ ] ++
+ map (\x -> (maybe "" ("/word/" ++) $ extractTarget x,
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml")) headers ++
+ map (\x -> (maybe "" ("/word/" ++) $ extractTarget x,
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml")) footers) ++
+ map mkImageOverride imgs ++
+ map mkMediaOverride [ eRelativePath e | e <- zEntries refArchive
+ , "word/media/" `isPrefixOf` eRelativePath e ]
+
+ let defaultnodes = [mknode "Default"
+ [("Extension","xml"),("ContentType","application/xml")] (),
+ mknode "Default"
+ [("Extension","rels"),("ContentType","application/vnd.openxmlformats-package.relationships+xml")] ()]
+ let contentTypesDoc = mknode "Types" [("xmlns","http://schemas.openxmlformats.org/package/2006/content-types")] $ defaultnodes ++ overrides
+ let contentTypesEntry = toEntry "[Content_Types].xml" epochtime
+ $ renderXml contentTypesDoc
+
+ -- word/_rels/document.xml.rels
+ let toBaseRel (url', id', target') = mknode "Relationship"
+ [("Type",url')
+ ,("Id",id')
+ ,("Target",target')] ()
+ let baserels' = map toBaseRel
+ [("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",
+ "rId1",
+ "numbering.xml")
+ ,("http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",
+ "rId2",
+ "styles.xml")
+ ,("http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",
+ "rId3",
+ "settings.xml")
+ ,("http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",
+ "rId4",
+ "webSettings.xml")
+ ,("http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",
+ "rId5",
+ "fontTable.xml")
+ ,("http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
+ "rId6",
+ "theme/theme1.xml")
+ ,("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",
+ "rId7",
+ "footnotes.xml")
+ ]
+
+ let idMap = renumIdMap (length baserels' + 1) (headers ++ footers)
+ let renumHeaders = renumIds (\q -> qName q == "Id") idMap headers
+ let renumFooters = renumIds (\q -> qName q == "Id") idMap footers
+ let baserels = baserels' ++ renumHeaders ++ renumFooters
+ let toImgRel (ident,path,_,_,_) = mknode "Relationship" [("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"),("Id",ident),("Target",path)] ()
+ let imgrels = map toImgRel imgs
+ let toLinkRel (src,ident) = mknode "Relationship" [("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"),("Id",ident),("Target",src),("TargetMode","External") ] ()
+ let linkrels = map toLinkRel $ M.toList $ stExternalLinks st
+ let reldoc = mknode "Relationships" [("xmlns","http://schemas.openxmlformats.org/package/2006/relationships")] $ baserels ++ imgrels ++ linkrels
+ let relEntry = toEntry "word/_rels/document.xml.rels" epochtime
+ $ renderXml reldoc
+
+
+ -- adjust contents to add sectPr from reference.docx
+ let sectpr = case mbsectpr of
+ Just sectpr' -> let cs = renumIds
+ (\q -> qName q == "id" && qPrefix q == Just "r")
+ idMap
+ (elChildren sectpr')
+ in
+ add_attrs (elAttribs sectpr') $ mknode "w:sectPr" [] cs
+ Nothing -> (mknode "w:sectPr" [] ())
+
+ -- let sectpr = fromMaybe (mknode "w:sectPr" [] ()) mbsectpr'
+ let contents' = contents ++ [sectpr]
+ let docContents = mknode "w:document" stdAttributes
+ $ mknode "w:body" [] contents'
+
+
+
+ -- word/document.xml
+ let contentEntry = toEntry "word/document.xml" epochtime
+ $ renderXml docContents
+
+ -- footnotes
+ let notes = mknode "w:footnotes" stdAttributes footnotes
+ let footnotesEntry = toEntry "word/footnotes.xml" epochtime $ renderXml notes
+
+ -- footnote rels
+ let footnoteRelEntry = toEntry "word/_rels/footnotes.xml.rels" epochtime
+ $ renderXml $ mknode "Relationships" [("xmlns","http://schemas.openxmlformats.org/package/2006/relationships")]
+ linkrels
+
+ -- styles
+
+ -- We only want to inject paragraph and text properties that
+ -- are not already in the style map. Note that keys in the stylemap
+ -- are normalized as lowercase.
+ let newDynamicParaProps = filter
+ (\sty -> isNothing $ M.lookup (toLower <$> sty) $ getMap $ sParaStyleMap styleMaps)
+ (stDynamicParaProps st)
+
+ newDynamicTextProps = filter
+ (\sty -> isNothing $ M.lookup (toLower <$> sty) $ getMap $ sCharStyleMap styleMaps)
+ (stDynamicTextProps st)
+
+ let newstyles = map newParaPropToOpenXml newDynamicParaProps ++
+ map newTextPropToOpenXml newDynamicTextProps ++
+ (case writerHighlightStyle opts of
+ Nothing -> []
+ Just sty -> (styleToOpenXml styleMaps sty))
+ let styledoc' = styledoc{ elContent = elContent styledoc ++
+ map Elem newstyles }
+ let styleEntry = toEntry stylepath epochtime $ renderXml styledoc'
+
+ -- construct word/numbering.xml
+ let numpath = "word/numbering.xml"
+ numbering <- parseXml refArchive distArchive numpath
+ newNumElts <- mkNumbering (stLists st)
+ let allElts = onlyElems (elContent numbering) ++ newNumElts
+ let numEntry = toEntry numpath epochtime $ renderXml numbering{ elContent =
+ -- we want all the abstractNums first, then the nums,
+ -- otherwise things break:
+ [Elem e | e <- allElts
+ , qName (elName e) == "abstractNum" ] ++
+ [Elem e | e <- allElts
+ , qName (elName e) == "num" ] }
+ let docPropsPath = "docProps/core.xml"
+ let docProps = mknode "cp:coreProperties"
+ [("xmlns:cp","http://schemas.openxmlformats.org/package/2006/metadata/core-properties")
+ ,("xmlns:dc","http://purl.org/dc/elements/1.1/")
+ ,("xmlns:dcterms","http://purl.org/dc/terms/")
+ ,("xmlns:dcmitype","http://purl.org/dc/dcmitype/")
+ ,("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance")]
+ $ mknode "dc:title" [] (stringify $ docTitle meta)
+ : mknode "dc:creator" [] (intercalate "; " (map stringify $ docAuthors meta))
+ : (\x -> [ mknode "dcterms:created" [("xsi:type","dcterms:W3CDTF")] x
+ , mknode "dcterms:modified" [("xsi:type","dcterms:W3CDTF")] x
+ ]) (formatTime defaultTimeLocale "%FT%XZ" utctime)
+ let docPropsEntry = toEntry docPropsPath epochtime $ renderXml docProps
+
+ let relsPath = "_rels/.rels"
+ let rels = mknode "Relationships" [("xmlns", "http://schemas.openxmlformats.org/package/2006/relationships")]
+ $ map (\attrs -> mknode "Relationship" attrs ())
+ [ [("Id","rId1")
+ ,("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument")
+ ,("Target","word/document.xml")]
+ , [("Id","rId4")
+ ,("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties")
+ ,("Target","docProps/app.xml")]
+ , [("Id","rId3")
+ ,("Type","http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties")
+ ,("Target","docProps/core.xml")]
+ ]
+ let relsEntry = toEntry relsPath epochtime $ renderXml rels
+
+ -- we use dist archive for settings.xml, because Word sometimes
+ -- adds references to footnotes or endnotes we don't have...
+ -- we do, however, copy some settings over from reference
+ let settingsPath = "word/settings.xml"
+ settingsList = [ "w:autoHyphenation"
+ , "w:consecutiveHyphenLimit"
+ , "w:hyphenationZone"
+ , "w:doNotHyphenateCap"
+ ]
+ settingsEntry <- copyChildren refArchive distArchive settingsPath epochtime settingsList
+
+ let entryFromArchive arch path =
+ maybe (fail $ path ++ " missing in reference docx")
+ return
+ (findEntryByPath path arch `mplus` findEntryByPath path distArchive)
+ docPropsAppEntry <- entryFromArchive refArchive "docProps/app.xml"
+ themeEntry <- entryFromArchive refArchive "word/theme/theme1.xml"
+ fontTableEntry <- entryFromArchive refArchive "word/fontTable.xml"
+ webSettingsEntry <- entryFromArchive refArchive "word/webSettings.xml"
+ headerFooterEntries <- mapM (entryFromArchive refArchive) $
+ mapMaybe (fmap ("word/" ++) . extractTarget)
+ (headers ++ footers)
+ let miscRelEntries = [ e | e <- zEntries refArchive
+ , "word/_rels/" `isPrefixOf` (eRelativePath e)
+ , ".xml.rels" `isSuffixOf` (eRelativePath e)
+ , eRelativePath e /= "word/_rels/document.xml.rels"
+ , eRelativePath e /= "word/_rels/footnotes.xml.rels" ]
+ let otherMediaEntries = [ e | e <- zEntries refArchive
+ , "word/media/" `isPrefixOf` eRelativePath e ]
+
+ -- Create archive
+ let archive = foldr addEntryToArchive emptyArchive $
+ contentTypesEntry : relsEntry : contentEntry : relEntry :
+ footnoteRelEntry : numEntry : styleEntry : footnotesEntry :
+ docPropsEntry : docPropsAppEntry : themeEntry :
+ fontTableEntry : settingsEntry : webSettingsEntry :
+ imageEntries ++ headerFooterEntries ++
+ miscRelEntries ++ otherMediaEntries
+ return $ fromArchive archive
+
+
+newParaPropToOpenXml :: String -> Element
+newParaPropToOpenXml s =
+ let styleId = filter (not . isSpace) s
+ in mknode "w:style" [ ("w:type", "paragraph")
+ , ("w:customStyle", "1")
+ , ("w:styleId", styleId)]
+ [ mknode "w:name" [("w:val", s)] ()
+ , mknode "w:basedOn" [("w:val","BodyText")] ()
+ , mknode "w:qFormat" [] ()
+ ]
+
+newTextPropToOpenXml :: String -> Element
+newTextPropToOpenXml s =
+ let styleId = filter (not . isSpace) s
+ in mknode "w:style" [ ("w:type", "character")
+ , ("w:customStyle", "1")
+ , ("w:styleId", styleId)]
+ [ mknode "w:name" [("w:val", s)] ()
+ , mknode "w:basedOn" [("w:val","BodyTextChar")] ()
+ ]
+
+styleToOpenXml :: StyleMaps -> Style -> [Element]
+styleToOpenXml sm style =
+ maybeToList parStyle ++ mapMaybe toStyle alltoktypes
+ where alltoktypes = enumFromTo KeywordTok NormalTok
+ toStyle toktype | hasStyleName (show toktype) (sCharStyleMap sm) = Nothing
+ | otherwise = Just $
+ mknode "w:style" [("w:type","character"),
+ ("w:customStyle","1"),("w:styleId",show toktype)]
+ [ mknode "w:name" [("w:val",show toktype)] ()
+ , mknode "w:basedOn" [("w:val","VerbatimChar")] ()
+ , mknode "w:rPr" [] $
+ [ mknode "w:color" [("w:val",tokCol toktype)] ()
+ | tokCol toktype /= "auto" ] ++
+ [ mknode "w:shd" [("w:val","clear"),("w:fill",tokBg toktype)] ()
+ | tokBg toktype /= "auto" ] ++
+ [ mknode "w:b" [] () | tokFeature tokenBold toktype ] ++
+ [ mknode "w:i" [] () | tokFeature tokenItalic toktype ] ++
+ [ mknode "w:u" [] () | tokFeature tokenUnderline toktype ]
+ ]
+ tokStyles = tokenStyles style
+ tokFeature f toktype = maybe False f $ lookup toktype tokStyles
+ tokCol toktype = maybe "auto" (drop 1 . fromColor)
+ $ (tokenColor =<< lookup toktype tokStyles)
+ `mplus` defaultColor style
+ tokBg toktype = maybe "auto" (drop 1 . fromColor)
+ $ (tokenBackground =<< lookup toktype tokStyles)
+ `mplus` backgroundColor style
+ parStyle | hasStyleName "Source Code" (sParaStyleMap sm) = Nothing
+ | otherwise = Just $
+ mknode "w:style" [("w:type","paragraph"),
+ ("w:customStyle","1"),("w:styleId","SourceCode")]
+ [ mknode "w:name" [("w:val","Source Code")] ()
+ , mknode "w:basedOn" [("w:val","Normal")] ()
+ , mknode "w:link" [("w:val","VerbatimChar")] ()
+ , mknode "w:pPr" []
+ $ mknode "w:wordWrap" [("w:val","off")] ()
+ : ( maybe [] (\col -> [mknode "w:shd" [("w:val","clear"),("w:fill",drop 1 $ fromColor col)] ()])
+ $ backgroundColor style )
+ ]
+
+copyChildren :: (PandocMonad m) => Archive -> Archive -> String -> Integer -> [String] -> m Entry
+copyChildren refArchive distArchive path timestamp elNames = do
+ ref <- parseXml refArchive distArchive path
+ dist <- parseXml distArchive distArchive path
+ return $ toEntry path timestamp $ renderXml dist{
+ elContent = elContent dist ++ copyContent ref
+ }
+ where
+ strName QName{qName=name, qPrefix=prefix}
+ | Just p <- prefix = p++":"++name
+ | otherwise = name
+ shouldCopy = (`elem` elNames) . strName
+ cleanElem el@Element{elName=name} = Elem el{elName=name{qURI=Nothing}}
+ copyContent = map cleanElem . filterChildrenName shouldCopy
+
+-- this is the lowest number used for a list numId
+baseListId :: Int
+baseListId = 1000
+
+mkNumbering :: (PandocMonad m) => [ListMarker] -> m [Element]
+mkNumbering lists = do
+ elts <- mapM mkAbstractNum (ordNub lists)
+ return $ elts ++ zipWith mkNum lists [baseListId..(baseListId + length lists - 1)]
+
+mkNum :: ListMarker -> Int -> Element
+mkNum marker numid =
+ mknode "w:num" [("w:numId",show numid)]
+ $ mknode "w:abstractNumId" [("w:val",listMarkerToId marker)] ()
+ : case marker of
+ NoMarker -> []
+ BulletMarker -> []
+ NumberMarker _ _ start ->
+ map (\lvl -> mknode "w:lvlOverride" [("w:ilvl",show (lvl :: Int))]
+ $ mknode "w:startOverride" [("w:val",show start)] ()) [0..6]
+
+mkAbstractNum :: (PandocMonad m) => ListMarker -> m Element
+mkAbstractNum marker = do
+ gen <- P.newStdGen
+ let (nsid, _) = randomR (0x10000000 :: Integer, 0xFFFFFFFF :: Integer) gen
+ return $ mknode "w:abstractNum" [("w:abstractNumId",listMarkerToId marker)]
+ $ mknode "w:nsid" [("w:val", printf "%8x" nsid)] ()
+ : mknode "w:multiLevelType" [("w:val","multilevel")] ()
+ : map (mkLvl marker) [0..6]
+
+mkLvl :: ListMarker -> Int -> Element
+mkLvl marker lvl =
+ mknode "w:lvl" [("w:ilvl",show lvl)] $
+ [ mknode "w:start" [("w:val",start)] ()
+ | marker /= NoMarker && marker /= BulletMarker ] ++
+ [ mknode "w:numFmt" [("w:val",fmt)] ()
+ , mknode "w:lvlText" [("w:val",lvltxt)] ()
+ , mknode "w:lvlJc" [("w:val","left")] ()
+ , mknode "w:pPr" []
+ [ mknode "w:tabs" []
+ $ mknode "w:tab" [("w:val","num"),("w:pos",show $ lvl * step)] ()
+ , mknode "w:ind" [("w:left",show $ lvl * step + hang),("w:hanging",show hang)] ()
+ ]
+ ]
+ where (fmt, lvltxt, start) =
+ case marker of
+ NoMarker -> ("bullet"," ","1")
+ BulletMarker -> ("bullet",bulletFor lvl,"1")
+ NumberMarker st de n -> (styleFor st lvl
+ ,patternFor de ("%" ++ show (lvl + 1))
+ ,show n)
+ step = 720
+ hang = 480
+ bulletFor 0 = "\x2022" -- filled circle
+ bulletFor 1 = "\x2013" -- en dash
+ bulletFor 2 = "\x2022" -- hyphen bullet
+ bulletFor 3 = "\x2013"
+ bulletFor 4 = "\x2022"
+ bulletFor 5 = "\x2013"
+ bulletFor _ = "\x2022"
+ styleFor UpperAlpha _ = "upperLetter"
+ styleFor LowerAlpha _ = "lowerLetter"
+ styleFor UpperRoman _ = "upperRoman"
+ styleFor LowerRoman _ = "lowerRoman"
+ styleFor Decimal _ = "decimal"
+ styleFor DefaultStyle 1 = "decimal"
+ styleFor DefaultStyle 2 = "lowerLetter"
+ styleFor DefaultStyle 3 = "lowerRoman"
+ styleFor DefaultStyle 4 = "decimal"
+ styleFor DefaultStyle 5 = "lowerLetter"
+ styleFor DefaultStyle 6 = "lowerRoman"
+ styleFor _ _ = "decimal"
+ patternFor OneParen s = s ++ ")"
+ patternFor TwoParens s = "(" ++ s ++ ")"
+ patternFor _ s = s ++ "."
+
+getNumId :: (PandocMonad m) => WS m Int
+getNumId = (((baseListId - 1) +) . length) `fmap` gets stLists
+
+
+makeTOC :: (PandocMonad m) => WriterOptions -> WS m [Element]
+makeTOC opts | writerTableOfContents opts = do
+ let depth = "1-"++(show (writerTOCDepth opts))
+ let tocCmd = "TOC \\o \""++depth++"\" \\h \\z \\u"
+ tocTitle <- gets stTocTitle
+ title <- withParaPropM (pStyleM "TOC Heading") (blocksToOpenXML opts [Para tocTitle])
+ return $
+ [mknode "w:sdt" [] ([
+ mknode "w:sdtPr" [] (
+ mknode "w:docPartObj" [] (
+ [mknode "w:docPartGallery" [("w:val","Table of Contents")] (),
+ mknode "w:docPartUnique" [] ()]
+ ) -- w:docPartObj
+ ), -- w:sdtPr
+ mknode "w:sdtContent" [] (title++[
+ mknode "w:p" [] (
+ mknode "w:r" [] ([
+ mknode "w:fldChar" [("w:fldCharType","begin"),("w:dirty","true")] (),
+ mknode "w:instrText" [("xml:space","preserve")] tocCmd,
+ mknode "w:fldChar" [("w:fldCharType","separate")] (),
+ mknode "w:fldChar" [("w:fldCharType","end")] ()
+ ]) -- w:r
+ ) -- w:p
+ ])
+ ])] -- w:sdt
+makeTOC _ = return []
+
+
+-- | Convert Pandoc document to two lists of
+-- OpenXML elements (the main document and footnotes).
+writeOpenXML :: (PandocMonad m) => WriterOptions -> Pandoc -> WS m ([Element], [Element])
+writeOpenXML opts (Pandoc meta blocks) = do
+ let tit = docTitle meta ++ case lookupMeta "subtitle" meta of
+ Just (MetaBlocks [Plain xs]) -> LineBreak : xs
+ _ -> []
+ let auths = docAuthors meta
+ let dat = docDate meta
+ let abstract' = case lookupMeta "abstract" meta of
+ Just (MetaBlocks bs) -> bs
+ Just (MetaInlines ils) -> [Plain ils]
+ _ -> []
+ let subtitle' = case lookupMeta "subtitle" meta of
+ Just (MetaBlocks [Plain xs]) -> xs
+ Just (MetaBlocks [Para xs]) -> xs
+ Just (MetaInlines xs) -> xs
+ _ -> []
+ 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 $
+ map Para auths
+ date <- withParaPropM (pStyleM "Date") $ blocksToOpenXML opts [Para dat | not (null dat)]
+ abstract <- if null abstract'
+ then return []
+ else withParaProp (pCustomStyle "Abstract") $ blocksToOpenXML opts abstract'
+ let convertSpace (Str x : Space : Str y : xs) = Str (x ++ " " ++ y) : xs
+ convertSpace (Str x : Str y : xs) = Str (x ++ y) : xs
+ convertSpace xs = xs
+ let blocks' = bottomUp convertSpace blocks
+ doc' <- (setFirstPara >> blocksToOpenXML opts blocks')
+ notes' <- reverse `fmap` gets stFootnotes
+ toc <- makeTOC opts
+ let meta' = title ++ subtitle ++ authors ++ date ++ abstract ++ toc
+ return (meta' ++ doc', notes')
+
+-- | Convert a list of Pandoc blocks to OpenXML.
+blocksToOpenXML :: (PandocMonad m) => WriterOptions -> [Block] -> WS m [Element]
+blocksToOpenXML opts bls = concat `fmap` mapM (blockToOpenXML opts) bls
+
+pCustomStyle :: String -> Element
+pCustomStyle sty = mknode "w:pStyle" [("w:val",sty)] ()
+
+pStyleM :: (PandocMonad m) => String -> WS m XML.Element
+pStyleM styleName = do
+ styleMaps <- gets stStyleMaps
+ let sty' = getStyleId styleName $ sParaStyleMap styleMaps
+ return $ mknode "w:pStyle" [("w:val",sty')] ()
+
+rCustomStyle :: String -> Element
+rCustomStyle sty = mknode "w:rStyle" [("w:val",sty)] ()
+
+rStyleM :: (PandocMonad m) => String -> WS m XML.Element
+rStyleM styleName = do
+ styleMaps <- gets stStyleMaps
+ let sty' = getStyleId styleName $ sCharStyleMap styleMaps
+ return $ mknode "w:rStyle" [("w:val",sty')] ()
+
+getUniqueId :: (PandocMonad m) => m String
+-- the + 20 is to ensure that there are no clashes with the rIds
+-- already in word/document.xml.rel
+getUniqueId = (show . (+ 20)) <$> P.newUniqueHash
+
+-- | Key for specifying user-defined docx styles.
+dynamicStyleKey :: String
+dynamicStyleKey = "custom-style"
+
+-- | Convert a Pandoc block element to OpenXML.
+blockToOpenXML :: (PandocMonad m) => WriterOptions -> Block -> WS m [Element]
+blockToOpenXML opts blk = withDirection $ blockToOpenXML' opts blk
+
+blockToOpenXML' :: (PandocMonad m) => WriterOptions -> Block -> WS m [Element]
+blockToOpenXML' _ Null = return []
+blockToOpenXML' opts (Div (ident,classes,kvs) bs)
+ | Just sty <- lookup dynamicStyleKey kvs = do
+ modify $ \s -> s{stDynamicParaProps = sty : (stDynamicParaProps s)}
+ withParaPropM (pStyleM sty) $ blocksToOpenXML opts bs
+ | Just "rtl" <- lookup "dir" kvs = do
+ let kvs' = filter (("dir", "rtl")/=) kvs
+ local (\env -> env { envRTL = True }) $
+ blockToOpenXML opts (Div (ident,classes,kvs') bs)
+ | Just "ltr" <- lookup "dir" kvs = do
+ let kvs' = filter (("dir", "ltr")/=) kvs
+ local (\env -> env { envRTL = False }) $
+ blockToOpenXML opts (Div (ident,classes,kvs') bs)
+blockToOpenXML' opts (Div (_,["references"],_) bs) = do
+ let (hs, bs') = span isHeaderBlock bs
+ header <- blocksToOpenXML opts hs
+ -- We put the Bibliography style on paragraphs after the header
+ rest <- withParaPropM (pStyleM "Bibliography") $ blocksToOpenXML opts bs'
+ return (header ++ rest)
+blockToOpenXML' opts (Div _ bs) = blocksToOpenXML opts bs
+blockToOpenXML' opts (Header lev (ident,_,_) lst) = do
+ setFirstPara
+ paraProps <- withParaPropM (pStyleM ("Heading "++show lev)) $
+ getParaProps False
+ contents <- inlinesToOpenXML opts lst
+ usedIdents <- gets stSectionIds
+ let bookmarkName = if null ident
+ then uniqueIdent lst usedIdents
+ else ident
+ modify $ \s -> s{ stSectionIds = Set.insert bookmarkName $ stSectionIds s }
+ id' <- (lift . lift) getUniqueId
+ let bookmarkStart = mknode "w:bookmarkStart" [("w:id", id')
+ ,("w:name",bookmarkName)] ()
+ let bookmarkEnd = mknode "w:bookmarkEnd" [("w:id", id')] ()
+ return [mknode "w:p" [] (paraProps ++ [bookmarkStart, bookmarkEnd] ++ contents)]
+blockToOpenXML' opts (Plain lst) = withParaProp (pCustomStyle "Compact")
+ $ blockToOpenXML opts (Para lst)
+-- title beginning with fig: indicates that the image is a figure
+blockToOpenXML' opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) = do
+ setFirstPara
+ let prop = pCustomStyle $
+ if null alt
+ then "Figure"
+ else "FigureWithCaption"
+ paraProps <- local (\env -> env { envParaProperties = prop : envParaProperties env }) (getParaProps False)
+ contents <- inlinesToOpenXML opts [Image attr alt (src,tit)]
+ captionNode <- withParaProp (pCustomStyle "ImageCaption")
+ $ blockToOpenXML opts (Para alt)
+ return $ mknode "w:p" [] (paraProps ++ contents) : captionNode
+-- fixDisplayMath sometimes produces a Para [] as artifact
+blockToOpenXML' _ (Para []) = return []
+blockToOpenXML' opts (Para lst) = do
+ isFirstPara <- gets stFirstPara
+ paraProps <- getParaProps $ case lst of
+ [Math DisplayMath _] -> True
+ _ -> False
+ bodyTextStyle <- pStyleM "Body Text"
+ let paraProps' = case paraProps of
+ [] | isFirstPara -> [mknode "w:pPr" [] [pCustomStyle "FirstParagraph"]]
+ [] -> [mknode "w:pPr" [] [bodyTextStyle]]
+ ps -> ps
+ modify $ \s -> s { stFirstPara = False }
+ contents <- inlinesToOpenXML opts lst
+ return [mknode "w:p" [] (paraProps' ++ contents)]
+blockToOpenXML' opts (LineBlock lns) = blockToOpenXML opts $ linesToPara lns
+blockToOpenXML' _ b@(RawBlock format str)
+ | format == Format "openxml" = return [ x | Elem x <- parseXML str ]
+ | otherwise = do
+ report $ BlockNotRendered b
+ return []
+blockToOpenXML' opts (BlockQuote blocks) = do
+ p <- withParaPropM (pStyleM "Block Text") $ blocksToOpenXML opts blocks
+ setFirstPara
+ return p
+blockToOpenXML' opts (CodeBlock attrs str) = do
+ p <- withParaProp (pCustomStyle "SourceCode") (blockToOpenXML opts $ Para [Code attrs str])
+ setFirstPara
+ return p
+blockToOpenXML' _ HorizontalRule = do
+ setFirstPara
+ return [
+ mknode "w:p" [] $ mknode "w:r" [] $ mknode "w:pict" []
+ $ mknode "v:rect" [("style","width:0;height:1.5pt"),
+ ("o:hralign","center"),
+ ("o:hrstd","t"),("o:hr","t")] () ]
+blockToOpenXML' opts (Table caption aligns widths headers rows) = do
+ setFirstPara
+ let captionStr = stringify caption
+ caption' <- if null caption
+ then return []
+ 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
+ headers' <- mapM cellToOpenXML $ zip aligns headers
+ rows' <- mapM (mapM cellToOpenXML . zip aligns) rows
+ let borderProps = mknode "w:tcPr" []
+ [ mknode "w:tcBorders" []
+ $ mknode "w:bottom" [("w:val","single")] ()
+ , mknode "w:vAlign" [("w:val","bottom")] () ]
+ let emptyCell = [mknode "w:p" [] [mknode "w:pPr" [] [pCustomStyle "Compact"]]]
+ let mkcell border contents = mknode "w:tc" []
+ $ [ borderProps | border ] ++
+ if null contents
+ then emptyCell
+ else contents
+ let mkrow border cells = mknode "w:tr" [] $
+ [mknode "w:trPr" [] [
+ mknode "w:cnfStyle" [("w:firstRow","1")] ()] | border]
+ ++ map (mkcell border) cells
+ let textwidth = 7920 -- 5.5 in in twips, 1/20 pt
+ let fullrow = 5000 -- 100% specified in pct
+ let rowwidth = fullrow * sum widths
+ let mkgridcol w = mknode "w:gridCol"
+ [("w:w", show (floor (textwidth * w) :: Integer))] ()
+ let hasHeader = not (all null headers)
+ return $
+ caption' ++
+ [mknode "w:tbl" []
+ ( mknode "w:tblPr" []
+ ( mknode "w:tblStyle" [("w:val","TableNormal")] () :
+ mknode "w:tblW" [("w:type", "pct"), ("w:w", show rowwidth)] () :
+ mknode "w:tblLook" [("w:firstRow","1") | hasHeader ] () :
+ [ mknode "w:tblCaption" [("w:val", captionStr)] ()
+ | not (null caption) ] )
+ : mknode "w:tblGrid" []
+ (if all (==0) widths
+ then []
+ else map mkgridcol widths)
+ : [ mkrow True headers' | hasHeader ] ++
+ map (mkrow False) rows'
+ )]
+blockToOpenXML' opts (BulletList lst) = do
+ let marker = BulletMarker
+ addList marker
+ numid <- getNumId
+ l <- asList $ concat `fmap` mapM (listItemToOpenXML opts numid) lst
+ setFirstPara
+ return l
+blockToOpenXML' opts (OrderedList (start, numstyle, numdelim) lst) = do
+ let marker = NumberMarker numstyle numdelim start
+ addList marker
+ numid <- getNumId
+ l <- asList $ concat `fmap` mapM (listItemToOpenXML opts numid) lst
+ setFirstPara
+ return l
+blockToOpenXML' opts (DefinitionList items) = do
+ l <- concat `fmap` mapM (definitionListItemToOpenXML opts) items
+ setFirstPara
+ return l
+
+definitionListItemToOpenXML :: (PandocMonad m) => WriterOptions -> ([Inline],[[Block]]) -> WS m [Element]
+definitionListItemToOpenXML opts (term,defs) = do
+ term' <- withParaProp (pCustomStyle "DefinitionTerm")
+ $ blockToOpenXML opts (Para term)
+ defs' <- withParaProp (pCustomStyle "Definition")
+ $ concat `fmap` mapM (blocksToOpenXML opts) defs
+ return $ term' ++ defs'
+
+addList :: (PandocMonad m) => ListMarker -> WS m ()
+addList marker = do
+ lists <- gets stLists
+ modify $ \st -> st{ stLists = lists ++ [marker] }
+
+listItemToOpenXML :: (PandocMonad m) => WriterOptions -> Int -> [Block] -> WS m [Element]
+listItemToOpenXML _ _ [] = return []
+listItemToOpenXML opts numid (first:rest) = do
+ first' <- withNumId numid $ blockToOpenXML opts first
+ -- baseListId is the code for no list marker:
+ rest' <- withNumId baseListId $ blocksToOpenXML opts rest
+ return $ first' ++ rest'
+
+alignmentToString :: Alignment -> [Char]
+alignmentToString alignment = case alignment of
+ AlignLeft -> "left"
+ AlignRight -> "right"
+ AlignCenter -> "center"
+ AlignDefault -> "left"
+
+-- | Convert a list of inline elements to OpenXML.
+inlinesToOpenXML :: (PandocMonad m) => WriterOptions -> [Inline] -> WS m [Element]
+inlinesToOpenXML opts lst = concat `fmap` mapM (inlineToOpenXML opts) lst
+
+withNumId :: (PandocMonad m) => Int -> WS m a -> WS m a
+withNumId numid = local $ \env -> env{ envListNumId = numid }
+
+asList :: (PandocMonad m) => WS m a -> WS m a
+asList = local $ \env -> env{ envListLevel = envListLevel env + 1 }
+
+getTextProps :: (PandocMonad m) => WS m [Element]
+getTextProps = do
+ props <- asks envTextProperties
+ return $ if null props
+ then []
+ else [mknode "w:rPr" [] props]
+
+withTextProp :: PandocMonad m => Element -> WS m a -> WS m a
+withTextProp d p =
+ local (\env -> env {envTextProperties = d : envTextProperties env}) p
+
+withTextPropM :: PandocMonad m => WS m Element -> WS m a -> WS m a
+withTextPropM = (. flip withTextProp) . (>>=)
+
+getParaProps :: PandocMonad m => Bool -> WS m [Element]
+getParaProps displayMathPara = do
+ props <- asks envParaProperties
+ listLevel <- asks envListLevel
+ numid <- asks envListNumId
+ let listPr = if listLevel >= 0 && not displayMathPara
+ then [ mknode "w:numPr" []
+ [ mknode "w:numId" [("w:val",show numid)] ()
+ , mknode "w:ilvl" [("w:val",show listLevel)] () ]
+ ]
+ else []
+ return $ case props ++ listPr of
+ [] -> []
+ ps -> [mknode "w:pPr" [] ps]
+
+withParaProp :: PandocMonad m => Element -> WS m a -> WS m a
+withParaProp d p =
+ local (\env -> env {envParaProperties = d : envParaProperties env}) p
+
+withParaPropM :: PandocMonad m => WS m Element -> WS m a -> WS m a
+withParaPropM = (. flip withParaProp) . (>>=)
+
+formattedString :: PandocMonad m => String -> WS m [Element]
+formattedString str = do
+ props <- getTextProps
+ inDel <- asks envInDel
+ return [ mknode "w:r" [] $
+ props ++
+ [ mknode (if inDel then "w:delText" else "w:t")
+ [("xml:space","preserve")] (stripInvalidChars str) ] ]
+
+setFirstPara :: PandocMonad m => WS m ()
+setFirstPara = modify $ \s -> s { stFirstPara = True }
+
+-- | Convert an inline element to OpenXML.
+inlineToOpenXML :: PandocMonad m => WriterOptions -> Inline -> WS m [Element]
+inlineToOpenXML opts il = withDirection $ inlineToOpenXML' opts il
+
+inlineToOpenXML' :: PandocMonad m => WriterOptions -> Inline -> WS m [Element]
+inlineToOpenXML' _ (Str str) = formattedString str
+inlineToOpenXML' opts Space = inlineToOpenXML opts (Str " ")
+inlineToOpenXML' opts SoftBreak = inlineToOpenXML opts (Str " ")
+inlineToOpenXML' opts (Span (ident,classes,kvs) ils)
+ | Just sty <- lookup dynamicStyleKey kvs = do
+ let kvs' = filter ((dynamicStyleKey, sty)/=) kvs
+ modify $ \s -> s{stDynamicTextProps = sty : (stDynamicTextProps s)}
+ withTextProp (rCustomStyle sty) $
+ inlineToOpenXML opts (Span (ident,classes,kvs') ils)
+ | Just "rtl" <- lookup "dir" kvs = do
+ let kvs' = filter (("dir", "rtl")/=) kvs
+ local (\env -> env { envRTL = True }) $
+ inlineToOpenXML opts (Span (ident,classes,kvs') ils)
+ | Just "ltr" <- lookup "dir" kvs = do
+ let kvs' = filter (("dir", "ltr")/=) kvs
+ local (\env -> env { envRTL = False }) $
+ inlineToOpenXML opts (Span (ident,classes,kvs') ils)
+ | "insertion" `elem` classes = do
+ defaultAuthor <- asks envChangesAuthor
+ defaultDate <- asks envChangesDate
+ let author = fromMaybe defaultAuthor (lookup "author" kvs)
+ date = fromMaybe defaultDate (lookup "date" kvs)
+ insId <- gets stInsId
+ modify $ \s -> s{stInsId = (insId + 1)}
+ x <- inlinesToOpenXML opts ils
+ return [ mknode "w:ins" [("w:id", (show insId)),
+ ("w:author", author),
+ ("w:date", date)]
+ x ]
+ | "deletion" `elem` classes = do
+ defaultAuthor <- asks envChangesAuthor
+ defaultDate <- asks envChangesDate
+ let author = fromMaybe defaultAuthor (lookup "author" kvs)
+ date = fromMaybe defaultDate (lookup "date" kvs)
+ delId <- gets stDelId
+ modify $ \s -> s{stDelId = (delId + 1)}
+ x <- local (\env -> env {envInDel = True}) (inlinesToOpenXML opts ils)
+ return [ mknode "w:del" [("w:id", (show delId)),
+ ("w:author", author),
+ ("w:date", date)]
+ x ]
+ | otherwise = do
+ let off x = withTextProp (mknode x [("w:val","0")] ())
+ ((if "csl-no-emph" `elem` classes then off "w:i" else id) .
+ (if "csl-no-strong" `elem` classes then off "w:b" else id) .
+ (if "csl-no-smallcaps" `elem` classes then off "w:smallCaps" else id))
+ $ inlinesToOpenXML opts ils
+inlineToOpenXML' opts (Strong lst) =
+ withTextProp (mknode "w:b" [] ()) $ inlinesToOpenXML opts lst
+inlineToOpenXML' opts (Emph lst) =
+ withTextProp (mknode "w:i" [] ()) $ inlinesToOpenXML opts lst
+inlineToOpenXML' opts (Subscript lst) =
+ withTextProp (mknode "w:vertAlign" [("w:val","subscript")] ())
+ $ inlinesToOpenXML opts lst
+inlineToOpenXML' opts (Superscript lst) =
+ withTextProp (mknode "w:vertAlign" [("w:val","superscript")] ())
+ $ inlinesToOpenXML opts lst
+inlineToOpenXML' opts (SmallCaps lst) =
+ withTextProp (mknode "w:smallCaps" [] ())
+ $ inlinesToOpenXML opts lst
+inlineToOpenXML' opts (Strikeout lst) =
+ withTextProp (mknode "w:strike" [] ())
+ $ inlinesToOpenXML opts lst
+inlineToOpenXML' _ LineBreak = return [br]
+inlineToOpenXML' _ il@(RawInline f str)
+ | f == Format "openxml" = return [ x | Elem x <- parseXML str ]
+ | otherwise = do
+ report $ InlineNotRendered il
+ return []
+inlineToOpenXML' opts (Quoted quoteType lst) =
+ inlinesToOpenXML opts $ [Str open] ++ lst ++ [Str close]
+ where (open, close) = case quoteType of
+ SingleQuote -> ("\x2018", "\x2019")
+ DoubleQuote -> ("\x201C", "\x201D")
+inlineToOpenXML' opts (Math mathType str) = do
+ when (mathType == DisplayMath) setFirstPara
+ res <- (lift . lift) (convertMath writeOMML mathType str)
+ case res of
+ Right r -> return [r]
+ Left il -> inlineToOpenXML' opts il
+inlineToOpenXML' opts (Cite _ lst) = inlinesToOpenXML opts lst
+inlineToOpenXML' opts (Code attrs str) = do
+ let unhighlighted = intercalate [br] `fmap`
+ (mapM formattedString $ lines str)
+ formatOpenXML _fmtOpts = intercalate [br] . map (map toHlTok)
+ toHlTok (toktype,tok) = mknode "w:r" []
+ [ mknode "w:rPr" []
+ [ rCustomStyle (show toktype) ]
+ , mknode "w:t" [("xml:space","preserve")] (T.unpack tok) ]
+ withTextProp (rCustomStyle "VerbatimChar")
+ $ case writerHighlightStyle opts >> highlight formatOpenXML attrs str of
+ Just h -> return h
+ Nothing -> unhighlighted
+inlineToOpenXML' opts (Note bs) = do
+ notes <- gets stFootnotes
+ notenum <- (lift . lift) getUniqueId
+ footnoteStyle <- rStyleM "Footnote Reference"
+ let notemarker = mknode "w:r" []
+ [ mknode "w:rPr" [] footnoteStyle
+ , mknode "w:footnoteRef" [] () ]
+ let notemarkerXml = RawInline (Format "openxml") $ ppElement notemarker
+ let insertNoteRef (Plain ils : xs) = Plain (notemarkerXml : Space : ils) : xs
+ insertNoteRef (Para ils : xs) = Para (notemarkerXml : Space : ils) : xs
+ insertNoteRef xs = Para [notemarkerXml] : xs
+
+ contents <- local (\env -> env{ envListLevel = -1
+ , envParaProperties = []
+ , envTextProperties = [] })
+ (withParaPropM (pStyleM "Footnote Text") $ blocksToOpenXML opts
+ $ insertNoteRef bs)
+ let newnote = mknode "w:footnote" [("w:id", notenum)] $ contents
+ modify $ \s -> s{ stFootnotes = newnote : notes }
+ return [ mknode "w:r" []
+ [ mknode "w:rPr" [] footnoteStyle
+ , mknode "w:footnoteReference" [("w:id", notenum)] () ] ]
+-- internal link:
+inlineToOpenXML' opts (Link _ txt ('#':xs,_)) = do
+ contents <- withTextPropM (rStyleM "Hyperlink") $ inlinesToOpenXML opts txt
+ return [ mknode "w:hyperlink" [("w:anchor",xs)] contents ]
+-- external link:
+inlineToOpenXML' opts (Link _ txt (src,_)) = do
+ contents <- withTextPropM (rStyleM "Hyperlink") $ inlinesToOpenXML opts txt
+ extlinks <- gets stExternalLinks
+ id' <- case M.lookup src extlinks of
+ Just i -> return i
+ Nothing -> do
+ i <- ("rId"++) `fmap` ((lift . lift) getUniqueId)
+ modify $ \st -> st{ stExternalLinks =
+ M.insert src i extlinks }
+ return i
+ return [ mknode "w:hyperlink" [("r:id",id')] contents ]
+inlineToOpenXML' opts (Image attr alt (src, title)) = do
+ -- first, check to see if we've already done this image
+ pageWidth <- asks envPrintWidth
+ imgs <- gets stImages
+ case M.lookup src imgs of
+ Just (_,_,_,elt,_) -> return [elt]
+ Nothing -> do
+ res <- runExceptT $ lift (P.fetchItem (writerSourceURL opts) src)
+ case res of
+ Left (_ :: PandocError) -> do
+ report $ CouldNotFetchResource src ""
+ -- emit alt text
+ inlinesToOpenXML opts alt
+ Right (img, mt) -> do
+ ident <- ("rId"++) `fmap` ((lift . lift) getUniqueId)
+ let (xpt,ypt) = desiredSizeInPoints opts attr
+ (either (const def) id (imageSize img))
+ -- 12700 emu = 1 pt
+ let (xemu,yemu) = fitToPage (xpt * 12700, ypt * 12700) (pageWidth * 12700)
+ let cNvPicPr = mknode "pic:cNvPicPr" [] $
+ mknode "a:picLocks" [("noChangeArrowheads","1"),("noChangeAspect","1")] ()
+ let nvPicPr = mknode "pic:nvPicPr" []
+ [ mknode "pic:cNvPr"
+ [("descr",src),("id","0"),("name","Picture")] ()
+ , cNvPicPr ]
+ let blipFill = mknode "pic:blipFill" []
+ [ mknode "a:blip" [("r:embed",ident)] ()
+ , mknode "a:stretch" [] $ mknode "a:fillRect" [] () ]
+ let xfrm = mknode "a:xfrm" []
+ [ mknode "a:off" [("x","0"),("y","0")] ()
+ , mknode "a:ext" [("cx",show xemu),("cy",show yemu)] () ]
+ let prstGeom = mknode "a:prstGeom" [("prst","rect")] $
+ mknode "a:avLst" [] ()
+ let ln = mknode "a:ln" [("w","9525")]
+ [ mknode "a:noFill" [] ()
+ , mknode "a:headEnd" [] ()
+ , mknode "a:tailEnd" [] () ]
+ let spPr = mknode "pic:spPr" [("bwMode","auto")]
+ [xfrm, prstGeom, mknode "a:noFill" [] (), ln]
+ let graphic = mknode "a:graphic" [] $
+ mknode "a:graphicData" [("uri","http://schemas.openxmlformats.org/drawingml/2006/picture")]
+ [ mknode "pic:pic" []
+ [ nvPicPr
+ , blipFill
+ , spPr ] ]
+ let imgElt = mknode "w:r" [] $
+ mknode "w:drawing" [] $
+ mknode "wp:inline" []
+ [ mknode "wp:extent" [("cx",show xemu),("cy",show yemu)] ()
+ , mknode "wp:effectExtent" [("b","0"),("l","0"),("r","0"),("t","0")] ()
+ , mknode "wp:docPr" [("descr",stringify alt), ("title", title), ("id","1"),("name","Picture")] ()
+ , graphic ]
+ let imgext = case mt >>= extensionFromMimeType of
+ Just x -> '.':x
+ Nothing -> case imageType img of
+ Just Png -> ".png"
+ Just Jpeg -> ".jpeg"
+ Just Gif -> ".gif"
+ Just Pdf -> ".pdf"
+ Just Eps -> ".eps"
+ Nothing -> ""
+ if null imgext
+ then -- without an extension there is no rule for content type
+ inlinesToOpenXML opts alt -- return alt to avoid corrupted docx
+ else do
+ let imgpath = "media/" ++ ident ++ imgext
+ let mbMimeType = mt <|> getMimeType imgpath
+ -- insert mime type to use in constructing [Content_Types].xml
+ modify $ \st -> st{ stImages =
+ M.insert src (ident, imgpath, mbMimeType, imgElt, img)
+ $ stImages st }
+ return [imgElt]
+
+br :: Element
+br = breakElement "textWrapping"
+
+breakElement :: String -> Element
+breakElement kind = mknode "w:r" [] [mknode "w:br" [("w:type",kind)] () ]
+
+-- Word will insert these footnotes into the settings.xml file
+-- (whether or not they're visible in the document). If they're in the
+-- file, but not in the footnotes.xml file, it will produce
+-- problems. So we want to make sure we insert them into our document.
+defaultFootnotes :: [Element]
+defaultFootnotes = [ mknode "w:footnote"
+ [("w:type", "separator"), ("w:id", "-1")] $
+ [ mknode "w:p" [] $
+ [mknode "w:r" [] $
+ [ mknode "w:separator" [] ()]]]
+ , mknode "w:footnote"
+ [("w:type", "continuationSeparator"), ("w:id", "0")] $
+ [ mknode "w:p" [] $
+ [ mknode "w:r" [] $
+ [ mknode "w:continuationSeparator" [] ()]]]]
+
+parseXml :: (PandocMonad m) => Archive -> Archive -> String -> m Element
+parseXml refArchive distArchive relpath =
+ case findEntryByPath relpath refArchive `mplus`
+ findEntryByPath relpath distArchive of
+ Nothing -> fail $ relpath ++ " missing in reference docx"
+ Just e -> case parseXMLDoc . UTF8.toStringLazy . fromEntry $ e of
+ Nothing -> fail $ relpath ++ " corrupt in reference docx"
+ Just d -> return d
+
+-- | Scales the image to fit the page
+-- sizes are passed in emu
+fitToPage :: (Double, Double) -> Integer -> (Integer, Integer)
+fitToPage (x, y) pageWidth
+ -- Fixes width to the page width and scales the height
+ | x > fromIntegral pageWidth =
+ (pageWidth, floor $ ((fromIntegral pageWidth) / x) * y)
+ | otherwise = (floor x, floor y)
+
+withDirection :: PandocMonad m => WS m a -> WS m a
+withDirection x = do
+ isRTL <- asks envRTL
+ paraProps <- asks envParaProperties
+ textProps <- asks envTextProperties
+ -- We want to clean all bidirection (bidi) and right-to-left (rtl)
+ -- properties from the props first. This is because we don't want
+ -- them to stack up.
+ let paraProps' = filter (\e -> (qName . elName) e /= "bidi") paraProps
+ textProps' = filter (\e -> (qName . elName) e /= "rtl") textProps
+ if isRTL
+ -- if we are going right-to-left, we (re?)add the properties.
+ then flip local x $
+ \env -> env { envParaProperties = (mknode "w:bidi" [] ()) : paraProps'
+ , envTextProperties = (mknode "w:rtl" [] ()) : textProps'
+ }
+ else flip local x $ \env -> env { envParaProperties = paraProps'
+ , envTextProperties = textProps'
+ }
diff --git a/src/Text/Pandoc/Writers/DokuWiki.hs b/src/Text/Pandoc/Writers/DokuWiki.hs
new file mode 100644
index 000000000..79a371d4d
--- /dev/null
+++ b/src/Text/Pandoc/Writers/DokuWiki.hs
@@ -0,0 +1,522 @@
+{-
+Copyright (C) 2008-2015 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.DokuWiki
+ Copyright : Copyright (C) 2008-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Clare Macrae <clare.macrae@googlemail.com>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to DokuWiki markup.
+
+DokuWiki: <https://www.dokuwiki.org/dokuwiki>
+-}
+
+{-
+ [ ] Implement nested blockquotes (currently only ever does one level)
+ [x] Implement alignment of text in tables
+ [ ] Implement comments
+ [ ] Work through the Dokuwiki spec, and check I've not missed anything out
+ [ ] Remove dud/duplicate code
+-}
+
+module Text.Pandoc.Writers.DokuWiki ( writeDokuWiki ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Options ( WriterOptions(
+ writerTableOfContents
+ , writerTemplate
+ , writerWrapText), WrapOption(..) )
+import Text.Pandoc.Shared ( escapeURI, linesToPara, removeFormatting
+ , camelCaseToHyphenated, trimr, substitute )
+import Text.Pandoc.Writers.Shared ( defField, metaToJSON )
+import Text.Pandoc.ImageSize
+import Text.Pandoc.Templates ( renderTemplate' )
+import Data.List ( intersect, intercalate, isPrefixOf, transpose )
+import Data.Default (Default(..))
+import Network.URI ( isURI )
+import Control.Monad ( zipWithM )
+import Control.Monad.State ( modify, State, get, evalState )
+import Control.Monad.Reader ( ReaderT, runReaderT, ask, local )
+import Text.Pandoc.Class (PandocMonad)
+
+data WriterState = WriterState {
+ stNotes :: Bool -- True if there are notes
+ }
+
+data WriterEnvironment = WriterEnvironment {
+ stIndent :: String -- Indent after the marker at the beginning of list items
+ , stUseTags :: Bool -- True if we should use HTML tags because we're in a complex list
+ , stBackSlashLB :: Bool -- True if we should produce formatted strings with newlines (as in a table cell)
+ }
+
+instance Default WriterState where
+ def = WriterState { stNotes = False }
+
+instance Default WriterEnvironment where
+ def = WriterEnvironment { stIndent = ""
+ , stUseTags = False
+ , stBackSlashLB = False }
+
+type DokuWiki = ReaderT WriterEnvironment (State WriterState)
+
+-- | Convert Pandoc to DokuWiki.
+writeDokuWiki :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeDokuWiki opts document = return $
+ runDokuWiki (pandocToDokuWiki opts document)
+
+runDokuWiki :: DokuWiki a -> a
+runDokuWiki = flip evalState def . flip runReaderT def
+
+-- | Return DokuWiki representation of document.
+pandocToDokuWiki :: WriterOptions -> Pandoc -> DokuWiki String
+pandocToDokuWiki opts (Pandoc meta blocks) = do
+ metadata <- metaToJSON opts
+ (fmap trimr . blockListToDokuWiki opts)
+ (inlineListToDokuWiki opts)
+ meta
+ body <- blockListToDokuWiki opts blocks
+ notesExist <- stNotes <$> get
+ let notes = if notesExist
+ then "" -- TODO Was "\n<references />" Check whether I can really remove this:
+ -- if it is definitely to do with footnotes, can remove this whole bit
+ else ""
+ let main = body ++ notes
+ let context = defField "body" main
+ $ defField "toc" (writerTableOfContents opts)
+ $ metadata
+ case writerTemplate opts of
+ Nothing -> return main
+ Just tpl -> return $ renderTemplate' tpl context
+
+-- | Escape special characters for DokuWiki.
+escapeString :: String -> String
+escapeString = substitute "__" "%%__%%" .
+ substitute "**" "%%**%%" .
+ substitute "//" "%%//%%"
+
+-- | Convert Pandoc block element to DokuWiki.
+blockToDokuWiki :: WriterOptions -- ^ Options
+ -> Block -- ^ Block element
+ -> DokuWiki String
+
+blockToDokuWiki _ Null = return ""
+
+blockToDokuWiki opts (Div _attrs bs) = do
+ contents <- blockListToDokuWiki opts bs
+ return $ contents ++ "\n"
+
+blockToDokuWiki opts (Plain inlines) =
+ inlineListToDokuWiki opts inlines
+
+-- title beginning with fig: indicates that the image is a figure
+-- dokuwiki doesn't support captions - so combine together alt and caption into alt
+blockToDokuWiki opts (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
+ capt <- if null txt
+ then return ""
+ else (" " ++) `fmap` inlineListToDokuWiki opts txt
+ let opt = if null txt
+ then ""
+ else "|" ++ if null tit then capt else tit ++ capt
+ -- Relative links fail isURI and receive a colon
+ prefix = if isURI src then "" else ":"
+ return $ "{{" ++ prefix ++ src ++ imageDims opts attr ++ opt ++ "}}\n"
+
+blockToDokuWiki opts (Para inlines) = do
+ indent <- stIndent <$> ask
+ useTags <- stUseTags <$> ask
+ contents <- inlineListToDokuWiki opts inlines
+ return $ if useTags
+ then "<HTML><p></HTML>" ++ contents ++ "<HTML></p></HTML>"
+ else contents ++ if null indent then "\n" else ""
+
+blockToDokuWiki opts (LineBlock lns) =
+ blockToDokuWiki opts $ linesToPara lns
+
+blockToDokuWiki _ (RawBlock f str)
+ | f == Format "dokuwiki" = return str
+ -- See https://www.dokuwiki.org/wiki:syntax
+ -- use uppercase HTML tag for block-level content:
+ | f == Format "html" = return $ "<HTML>\n" ++ str ++ "\n</HTML>"
+ | otherwise = return ""
+
+blockToDokuWiki _ HorizontalRule = return "\n----\n"
+
+blockToDokuWiki opts (Header level _ inlines) = do
+ -- emphasis, links etc. not allowed in headers, apparently,
+ -- so we remove formatting:
+ contents <- inlineListToDokuWiki opts $ removeFormatting inlines
+ let eqs = replicate ( 7 - level ) '='
+ return $ eqs ++ " " ++ contents ++ " " ++ eqs ++ "\n"
+
+blockToDokuWiki _ (CodeBlock (_,classes,_) str) = do
+ let at = classes `intersect` ["actionscript", "ada", "apache", "applescript", "asm", "asp",
+ "autoit", "bash", "blitzbasic", "bnf", "c", "c_mac", "caddcl", "cadlisp", "cfdg", "cfm",
+ "cpp", "cpp-qt", "csharp", "css", "d", "delphi", "diff", "div", "dos", "eiffel", "fortran",
+ "freebasic", "gml", "groovy", "html4strict", "idl", "ini", "inno", "io", "java", "java5",
+ "javascript", "latex", "lisp", "lua", "matlab", "mirc", "mpasm", "mysql", "nsis", "objc",
+ "ocaml", "ocaml-brief", "oobas", "oracle8", "pascal", "perl", "php", "php-brief", "plsql",
+ "python", "qbasic", "rails", "reg", "robots", "ruby", "sas", "scheme", "sdlbasic",
+ "smalltalk", "smarty", "sql", "tcl", "", "thinbasic", "tsql", "vb", "vbnet", "vhdl",
+ "visualfoxpro", "winbatch", "xml", "xpp", "z80"]
+ return $ "<code" ++
+ (case at of
+ [] -> ">\n"
+ (x:_) -> " " ++ x ++ ">\n") ++ str ++ "\n</code>"
+
+blockToDokuWiki opts (BlockQuote blocks) = do
+ contents <- blockListToDokuWiki opts blocks
+ if isSimpleBlockQuote blocks
+ then return $ unlines $ map ("> " ++) $ lines contents
+ else return $ "<HTML><blockquote>\n" ++ contents ++ "</blockquote></HTML>"
+
+blockToDokuWiki opts (Table capt aligns _ headers rows) = do
+ captionDoc <- if null capt
+ then return ""
+ else do
+ c <- inlineListToDokuWiki opts capt
+ return $ "" ++ c ++ "\n"
+ headers' <- if all null headers
+ then return []
+ else zipWithM (tableItemToDokuWiki opts) aligns headers
+ rows' <- mapM (zipWithM (tableItemToDokuWiki opts) aligns) rows
+ let widths = map (maximum . map length) $ transpose (headers':rows')
+ let padTo (width, al) s =
+ case (width - length s) of
+ x | x > 0 ->
+ if al == AlignLeft || al == AlignDefault
+ then s ++ replicate x ' '
+ else if al == AlignRight
+ then replicate x ' ' ++ s
+ else replicate (x `div` 2) ' ' ++
+ s ++ replicate (x - x `div` 2) ' '
+ | otherwise -> s
+ let renderRow sep cells = sep ++
+ intercalate sep (zipWith padTo (zip widths aligns) cells) ++ sep
+ return $ captionDoc ++
+ (if null headers' then "" else renderRow "^" headers' ++ "\n") ++
+ unlines (map (renderRow "|") rows')
+
+blockToDokuWiki opts x@(BulletList items) = do
+ oldUseTags <- stUseTags <$> ask
+ indent <- stIndent <$> ask
+ backSlash <- stBackSlashLB <$> ask
+ let useTags = oldUseTags || not (isSimpleList x)
+ if useTags
+ then do
+ contents <- local (\s -> s { stUseTags = True })
+ (mapM (listItemToDokuWiki opts) items)
+ return $ "<HTML><ul></HTML>\n" ++ vcat contents ++ "<HTML></ul></HTML>\n"
+ else do
+ contents <- local (\s -> s { stIndent = stIndent s ++ " "
+ , stBackSlashLB = backSlash})
+ (mapM (listItemToDokuWiki opts) items)
+ return $ vcat contents ++ if null indent then "\n" else ""
+
+blockToDokuWiki opts x@(OrderedList attribs items) = do
+ oldUseTags <- stUseTags <$> ask
+ indent <- stIndent <$> ask
+ backSlash <- stBackSlashLB <$> ask
+ let useTags = oldUseTags || not (isSimpleList x)
+ if useTags
+ then do
+ contents <- local (\s -> s { stUseTags = True })
+ (mapM (orderedListItemToDokuWiki opts) items)
+ return $ "<HTML><ol" ++ listAttribsToString attribs ++ "></HTML>\n" ++ vcat contents ++ "<HTML></ol></HTML>\n"
+ else do
+ contents <- local (\s -> s { stIndent = stIndent s ++ " "
+ , stBackSlashLB = backSlash})
+ (mapM (orderedListItemToDokuWiki opts) items)
+ return $ vcat contents ++ if null indent then "\n" else ""
+
+-- TODO Need to decide how to make definition lists work on dokuwiki - I don't think there
+-- is a specific representation of them.
+-- TODO This creates double '; ; ' if there is a bullet or ordered list inside a definition list
+blockToDokuWiki opts x@(DefinitionList items) = do
+ oldUseTags <- stUseTags <$> ask
+ indent <- stIndent <$> ask
+ backSlash <- stBackSlashLB <$> ask
+ let useTags = oldUseTags || not (isSimpleList x)
+ if useTags
+ then do
+ contents <- local (\s -> s { stUseTags = True })
+ (mapM (definitionListItemToDokuWiki opts) items)
+ return $ "<HTML><dl></HTML>\n" ++ vcat contents ++ "<HTML></dl></HTML>\n"
+ else do
+ contents <- local (\s -> s { stIndent = stIndent s ++ " "
+ , stBackSlashLB = backSlash})
+ (mapM (definitionListItemToDokuWiki opts) items)
+ return $ vcat contents ++ if null indent then "\n" else ""
+
+-- Auxiliary functions for lists:
+
+-- | Convert ordered list attributes to HTML attribute string
+listAttribsToString :: ListAttributes -> String
+listAttribsToString (startnum, numstyle, _) =
+ let numstyle' = camelCaseToHyphenated $ show numstyle
+ in (if startnum /= 1
+ then " start=\"" ++ show startnum ++ "\""
+ else "") ++
+ (if numstyle /= DefaultStyle
+ then " style=\"list-style-type: " ++ numstyle' ++ ";\""
+ else "")
+
+-- | Convert bullet list item (list of blocks) to DokuWiki.
+listItemToDokuWiki :: WriterOptions -> [Block] -> DokuWiki String
+listItemToDokuWiki opts items = do
+ contents <- blockListToDokuWiki opts items
+ useTags <- stUseTags <$> ask
+ if useTags
+ then return $ "<HTML><li></HTML>" ++ contents ++ "<HTML></li></HTML>"
+ else do
+ indent <- stIndent <$> ask
+ backSlash <- stBackSlashLB <$> ask
+ let indent' = if backSlash then (drop 2 indent) else indent
+ return $ indent' ++ "* " ++ contents
+
+-- | Convert ordered list item (list of blocks) to DokuWiki.
+-- | TODO Emiminate dreadful duplication of text from listItemToDokuWiki
+orderedListItemToDokuWiki :: WriterOptions -> [Block] -> DokuWiki String
+orderedListItemToDokuWiki opts items = do
+ contents <- blockListToDokuWiki opts items
+ useTags <- stUseTags <$> ask
+ if useTags
+ then return $ "<HTML><li></HTML>" ++ contents ++ "<HTML></li></HTML>"
+ else do
+ indent <- stIndent <$> ask
+ backSlash <- stBackSlashLB <$> ask
+ let indent' = if backSlash then (drop 2 indent) else indent
+ return $ indent' ++ "- " ++ contents
+
+-- | Convert definition list item (label, list of blocks) to DokuWiki.
+definitionListItemToDokuWiki :: WriterOptions
+ -> ([Inline],[[Block]])
+ -> DokuWiki String
+definitionListItemToDokuWiki opts (label, items) = do
+ labelText <- inlineListToDokuWiki opts label
+ contents <- mapM (blockListToDokuWiki opts) items
+ useTags <- stUseTags <$> ask
+ if useTags
+ then return $ "<HTML><dt></HTML>" ++ labelText ++ "<HTML></dt></HTML>\n" ++
+ (intercalate "\n" $ map (\d -> "<HTML><dd></HTML>" ++ d ++ "<HTML></dd></HTML>") contents)
+ else do
+ indent <- stIndent <$> ask
+ backSlash <- stBackSlashLB <$> ask
+ let indent' = if backSlash then (drop 2 indent) else indent
+ return $ indent' ++ "* **" ++ labelText ++ "** " ++ concat contents
+
+-- | True if the list can be handled by simple wiki markup, False if HTML tags will be needed.
+isSimpleList :: Block -> Bool
+isSimpleList x =
+ case x of
+ BulletList items -> all isSimpleListItem items
+ OrderedList (num, sty, _) items -> all isSimpleListItem items &&
+ num == 1 && sty `elem` [DefaultStyle, Decimal]
+ DefinitionList items -> all isSimpleListItem $ concatMap snd items
+ _ -> False
+
+-- | True if list item can be handled with the simple wiki syntax. False if
+-- HTML tags will be needed.
+isSimpleListItem :: [Block] -> Bool
+isSimpleListItem [] = True
+isSimpleListItem [x] =
+ case x of
+ Plain _ -> True
+ Para _ -> True
+ BulletList _ -> isSimpleList x
+ OrderedList _ _ -> isSimpleList x
+ DefinitionList _ -> isSimpleList x
+ _ -> False
+isSimpleListItem [x, y] | isPlainOrPara x =
+ case y of
+ BulletList _ -> isSimpleList y
+ OrderedList _ _ -> isSimpleList y
+ DefinitionList _ -> isSimpleList y
+ _ -> False
+isSimpleListItem _ = False
+
+isPlainOrPara :: Block -> Bool
+isPlainOrPara (Plain _) = True
+isPlainOrPara (Para _) = True
+isPlainOrPara _ = False
+
+isSimpleBlockQuote :: [Block] -> Bool
+isSimpleBlockQuote bs = all isPlainOrPara bs
+
+-- | Concatenates strings with line breaks between them.
+vcat :: [String] -> String
+vcat = intercalate "\n"
+
+backSlashLineBreaks :: String -> String
+backSlashLineBreaks cs = reverse $ g $ reverse $ concatMap f cs
+ where f '\n' = "\\\\ "
+ f c = [c]
+ g (' ' : '\\':'\\': xs) = xs
+ g s = s
+
+-- Auxiliary functions for tables:
+
+tableItemToDokuWiki :: WriterOptions
+ -> Alignment
+ -> [Block]
+ -> DokuWiki String
+tableItemToDokuWiki opts align' item = do
+ let mkcell x = (if align' == AlignRight || align' == AlignCenter
+ then " "
+ else "") ++ x ++
+ (if align' == AlignLeft || align' == AlignCenter
+ then " "
+ else "")
+ contents <- local (\s -> s { stBackSlashLB = True }) $
+ blockListToDokuWiki opts item
+ return $ mkcell contents
+
+-- | Convert list of Pandoc block elements to DokuWiki.
+blockListToDokuWiki :: WriterOptions -- ^ Options
+ -> [Block] -- ^ List of block elements
+ -> DokuWiki String
+blockListToDokuWiki opts blocks = do
+ backSlash <- stBackSlashLB <$> ask
+ let blocks' = consolidateRawBlocks blocks
+ if backSlash
+ then (backSlashLineBreaks . vcat) <$> mapM (blockToDokuWiki opts) blocks'
+ else vcat <$> mapM (blockToDokuWiki opts) blocks'
+
+consolidateRawBlocks :: [Block] -> [Block]
+consolidateRawBlocks [] = []
+consolidateRawBlocks (RawBlock f1 b1 : RawBlock f2 b2 : xs)
+ | f1 == f2 = consolidateRawBlocks (RawBlock f1 (b1 ++ "\n" ++ b2) : xs)
+consolidateRawBlocks (x:xs) = x : consolidateRawBlocks xs
+
+-- | Convert list of Pandoc inline elements to DokuWiki.
+inlineListToDokuWiki :: WriterOptions -> [Inline] -> DokuWiki String
+inlineListToDokuWiki opts lst =
+ concat <$> (mapM (inlineToDokuWiki opts) lst)
+
+-- | Convert Pandoc inline element to DokuWiki.
+inlineToDokuWiki :: WriterOptions -> Inline -> DokuWiki String
+
+inlineToDokuWiki opts (Span _attrs ils) =
+ inlineListToDokuWiki opts ils
+
+inlineToDokuWiki opts (Emph lst) = do
+ contents <- inlineListToDokuWiki opts lst
+ return $ "//" ++ contents ++ "//"
+
+inlineToDokuWiki opts (Strong lst) = do
+ contents <- inlineListToDokuWiki opts lst
+ return $ "**" ++ contents ++ "**"
+
+inlineToDokuWiki opts (Strikeout lst) = do
+ contents <- inlineListToDokuWiki opts lst
+ return $ "<del>" ++ contents ++ "</del>"
+
+inlineToDokuWiki opts (Superscript lst) = do
+ contents <- inlineListToDokuWiki opts lst
+ return $ "<sup>" ++ contents ++ "</sup>"
+
+inlineToDokuWiki opts (Subscript lst) = do
+ contents <- inlineListToDokuWiki opts lst
+ return $ "<sub>" ++ contents ++ "</sub>"
+
+inlineToDokuWiki opts (SmallCaps lst) = inlineListToDokuWiki opts lst
+
+inlineToDokuWiki opts (Quoted SingleQuote lst) = do
+ contents <- inlineListToDokuWiki opts lst
+ return $ "\8216" ++ contents ++ "\8217"
+
+inlineToDokuWiki opts (Quoted DoubleQuote lst) = do
+ contents <- inlineListToDokuWiki opts lst
+ return $ "\8220" ++ contents ++ "\8221"
+
+inlineToDokuWiki opts (Cite _ lst) = inlineListToDokuWiki opts lst
+
+inlineToDokuWiki _ (Code _ str) =
+ -- In dokuwiki, text surrounded by '' is really just a font statement, i.e. <tt>,
+ -- and so other formatting can be present inside.
+ -- However, in pandoc, and markdown, inlined code doesn't contain formatting.
+ -- So I have opted for using %% to disable all formatting inside inline code blocks.
+ -- This gives the best results when converting from other formats to dokuwiki, even if
+ -- the resultand code is a little ugly, for short strings that don't contain formatting
+ -- characters.
+ -- It does mean that if pandoc could ever read dokuwiki, and so round-trip the format,
+ -- any formatting inside inlined code blocks would be lost, or presented incorrectly.
+ return $ "''%%" ++ str ++ "%%''"
+
+inlineToDokuWiki _ (Str str) = return $ escapeString str
+
+inlineToDokuWiki _ (Math mathType str) = return $ delim ++ str ++ delim
+ -- note: str should NOT be escaped
+ where delim = case mathType of
+ DisplayMath -> "$$"
+ InlineMath -> "$"
+
+inlineToDokuWiki _ (RawInline f str)
+ | f == Format "dokuwiki" = return str
+ | f == Format "html" = return $ "<html>" ++ str ++ "</html>"
+ | otherwise = return ""
+
+inlineToDokuWiki _ LineBreak = return "\\\\\n"
+
+inlineToDokuWiki opts SoftBreak =
+ case writerWrapText opts of
+ WrapNone -> return " "
+ WrapAuto -> return " "
+ WrapPreserve -> return "\n"
+
+inlineToDokuWiki _ Space = return " "
+
+inlineToDokuWiki opts (Link _ txt (src, _)) = do
+ label <- inlineListToDokuWiki opts txt
+ case txt of
+ [Str s] | "mailto:" `isPrefixOf` src -> return $ "<" ++ s ++ ">"
+ | escapeURI s == src -> return src
+ _ -> if isURI src
+ then return $ "[[" ++ src ++ "|" ++ label ++ "]]"
+ else return $ "[[" ++ src' ++ "|" ++ label ++ "]]"
+ where src' = case src of
+ '/':xs -> xs -- with leading / it's a
+ _ -> src -- link to a help page
+inlineToDokuWiki opts (Image attr alt (source, tit)) = do
+ alt' <- inlineListToDokuWiki opts alt
+ let txt = case (tit, alt) of
+ ("", []) -> ""
+ ("", _ ) -> "|" ++ alt'
+ (_ , _ ) -> "|" ++ tit
+ -- Relative links fail isURI and receive a colon
+ prefix = if isURI source then "" else ":"
+ return $ "{{" ++ prefix ++ source ++ imageDims opts attr ++ txt ++ "}}"
+
+inlineToDokuWiki opts (Note contents) = do
+ contents' <- blockListToDokuWiki opts contents
+ modify (\s -> s { stNotes = True })
+ return $ "((" ++ contents' ++ "))"
+ -- note - may not work for notes with multiple blocks
+
+imageDims :: WriterOptions -> Attr -> String
+imageDims opts attr = go (toPx $ dimension Width attr) (toPx $ dimension Height attr)
+ where
+ toPx = fmap (showInPixel opts) . checkPct
+ checkPct (Just (Percent _)) = Nothing
+ checkPct maybeDim = maybeDim
+ go (Just w) Nothing = "?" ++ w
+ go (Just w) (Just h) = "?" ++ w ++ "x" ++ h
+ go Nothing (Just h) = "?0x" ++ h
+ go Nothing Nothing = ""
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
new file mode 100644
index 000000000..247014c20
--- /dev/null
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -0,0 +1,1257 @@
+{-# LANGUAGE PatternGuards, CPP, ScopedTypeVariables, ViewPatterns, FlexibleContexts #-}
+{-
+Copyright (C) 2010-2015 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.EPUB
+ Copyright : Copyright (C) 2010-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to EPUB.
+-}
+module Text.Pandoc.Writers.EPUB ( writeEPUB2, writeEPUB3 ) where
+import Text.Pandoc.Logging
+import qualified Data.Map as M
+import qualified Data.Set as Set
+import Data.Maybe ( fromMaybe, catMaybes )
+import Data.List ( isPrefixOf, isInfixOf, intercalate )
+import Text.Printf (printf)
+import System.FilePath ( takeExtension, takeFileName )
+import Network.HTTP ( urlEncode )
+import qualified Data.ByteString.Lazy as B
+import qualified Data.ByteString.Lazy.Char8 as B8
+import qualified Text.Pandoc.UTF8 as UTF8
+import Codec.Archive.Zip ( emptyArchive, addEntryToArchive, eRelativePath, fromEntry , Entry, toEntry, fromArchive)
+import Text.Pandoc.Compat.Time
+import Text.Pandoc.Shared ( renderTags', safeRead, uniqueIdent, trim
+ , normalizeDate, stringify
+ , hierarchicalize )
+import qualified Text.Pandoc.Shared as S (Element(..))
+import Text.Pandoc.Builder (fromList, setMeta)
+import Text.Pandoc.Options ( WriterOptions(..)
+ , WrapOption(..)
+ , HTMLMathMethod(..)
+ , EPUBVersion(..)
+ , ObfuscationMethod(NoObfuscation) )
+import Text.Pandoc.Definition
+import Text.Pandoc.Walk (walk, walkM, query)
+import Text.Pandoc.UUID (getUUID)
+import Control.Monad.State (modify, get, gets, State, StateT, put, evalState, evalStateT, lift)
+import Control.Monad (mplus, when, zipWithM)
+import Text.XML.Light ( unode, Element(..), unqual, Attr(..), add_attrs
+ , strContent, lookupAttr, Node(..), QName(..), parseXML
+ , onlyElems, node, ppElement)
+import Text.Pandoc.Writers.HTML ( writeHtmlStringForEPUB )
+import Data.Char ( toLower, isDigit, isAlphaNum )
+import Text.Pandoc.MIME (MimeType, getMimeType, extensionFromMimeType)
+import Text.HTML.TagSoup (Tag(TagOpen), fromAttrib, parseTags)
+import Control.Monad.Except (throwError, catchError)
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad, report)
+import qualified Text.Pandoc.Class as P
+
+-- A Chapter includes a list of blocks and maybe a section
+-- number offset. Note, some chapters are unnumbered. The section
+-- number is different from the index number, which will be used
+-- in filenames, chapter0003.xhtml.
+data Chapter = Chapter (Maybe [Int]) [Block]
+
+data EPUBState = EPUBState {
+ stMediaPaths :: [(FilePath, (FilePath, Maybe Entry))]
+ }
+
+type E m = StateT EPUBState m
+
+data EPUBMetadata = EPUBMetadata{
+ epubIdentifier :: [Identifier]
+ , epubTitle :: [Title]
+ , epubDate :: [Date]
+ , epubLanguage :: String
+ , epubCreator :: [Creator]
+ , epubContributor :: [Creator]
+ , epubSubject :: [String]
+ , epubDescription :: Maybe String
+ , epubType :: Maybe String
+ , epubFormat :: Maybe String
+ , epubPublisher :: Maybe String
+ , epubSource :: Maybe String
+ , epubRelation :: Maybe String
+ , epubCoverage :: Maybe String
+ , epubRights :: Maybe String
+ , epubCoverImage :: Maybe String
+ , epubStylesheet :: Maybe Stylesheet
+ , epubPageDirection :: Maybe ProgressionDirection
+ } deriving Show
+
+data Stylesheet = StylesheetPath FilePath
+ | StylesheetContents String
+ deriving Show
+
+data Date = Date{
+ dateText :: String
+ , dateEvent :: Maybe String
+ } deriving Show
+
+data Creator = Creator{
+ creatorText :: String
+ , creatorRole :: Maybe String
+ , creatorFileAs :: Maybe String
+ } deriving Show
+
+data Identifier = Identifier{
+ identifierText :: String
+ , identifierScheme :: Maybe String
+ } deriving Show
+
+data Title = Title{
+ titleText :: String
+ , titleFileAs :: Maybe String
+ , titleType :: Maybe String
+ } deriving Show
+
+data ProgressionDirection = LTR | RTL deriving Show
+
+dcName :: String -> QName
+dcName n = QName n Nothing (Just "dc")
+
+dcNode :: Node t => String -> t -> Element
+dcNode = node . dcName
+
+opfName :: String -> QName
+opfName n = QName n Nothing (Just "opf")
+
+toId :: FilePath -> String
+toId = map (\x -> if isAlphaNum x || x == '-' || x == '_'
+ then x
+ else '_') . takeFileName
+
+removeNote :: Inline -> Inline
+removeNote (Note _) = Str ""
+removeNote x = x
+
+getEPUBMetadata :: PandocMonad m => WriterOptions -> Meta -> E m EPUBMetadata
+getEPUBMetadata opts meta = do
+ let md = metadataFromMeta opts meta
+ let elts = maybe [] (onlyElems . parseXML) $ writerEpubMetadata opts
+ let md' = foldr addMetadataFromXML md elts
+ let addIdentifier m =
+ if null (epubIdentifier m)
+ then do
+ randomId <- (show . getUUID) <$> lift P.newStdGen
+ return $ m{ epubIdentifier = [Identifier randomId Nothing] }
+ else return m
+ let addLanguage m =
+ if null (epubLanguage m)
+ then case lookup "lang" (writerVariables opts) of
+ Just x -> return m{ epubLanguage = x }
+ Nothing -> do
+ mLang <- lift $ P.lookupEnv "LANG"
+ let localeLang =
+ case mLang of
+ Just lang ->
+ map (\c -> if c == '_' then '-' else c) $
+ takeWhile (/='.') lang
+ Nothing -> "en-US"
+ return m{ epubLanguage = localeLang }
+ else return m
+ let fixDate m =
+ if null (epubDate m)
+ then do
+ currentTime <- lift P.getCurrentTime
+ return $ m{ epubDate = [ Date{
+ dateText = showDateTimeISO8601 currentTime
+ , dateEvent = Nothing } ] }
+ else return m
+ let addAuthor m =
+ if any (\c -> creatorRole c == Just "aut") $ epubCreator m
+ then return m
+ else do
+ let authors' = map stringify $ docAuthors meta
+ let toAuthor name = Creator{ creatorText = name
+ , creatorRole = Just "aut"
+ , creatorFileAs = Nothing }
+ return $ m{ epubCreator = map toAuthor authors' ++ epubCreator m }
+ addIdentifier md' >>= fixDate >>= addAuthor >>= addLanguage
+
+addMetadataFromXML :: Element -> EPUBMetadata -> EPUBMetadata
+addMetadataFromXML e@(Element (QName name _ (Just "dc")) attrs _ _) md
+ | name == "identifier" = md{ epubIdentifier =
+ Identifier{ identifierText = strContent e
+ , identifierScheme = lookupAttr (opfName "scheme") attrs
+ } : epubIdentifier md }
+ | name == "title" = md{ epubTitle =
+ Title{ titleText = strContent e
+ , titleFileAs = getAttr "file-as"
+ , titleType = getAttr "type"
+ } : epubTitle md }
+ | name == "date" = md{ epubDate =
+ Date{ dateText = fromMaybe "" $ normalizeDate' $ strContent e
+ , dateEvent = getAttr "event"
+ } : epubDate md }
+ | name == "language" = md{ epubLanguage = strContent e }
+ | name == "creator" = md{ epubCreator =
+ Creator{ creatorText = strContent e
+ , creatorRole = getAttr "role"
+ , creatorFileAs = getAttr "file-as"
+ } : epubCreator md }
+ | name == "contributor" = md{ epubContributor =
+ Creator { creatorText = strContent e
+ , creatorRole = getAttr "role"
+ , creatorFileAs = getAttr "file-as"
+ } : epubContributor md }
+ | name == "subject" = md{ epubSubject = strContent e : epubSubject md }
+ | name == "description" = md { epubDescription = Just $ strContent e }
+ | name == "type" = md { epubType = Just $ strContent e }
+ | name == "format" = md { epubFormat = Just $ strContent e }
+ | name == "type" = md { epubType = Just $ strContent e }
+ | name == "publisher" = md { epubPublisher = Just $ strContent e }
+ | name == "source" = md { epubSource = Just $ strContent e }
+ | name == "relation" = md { epubRelation = Just $ strContent e }
+ | name == "coverage" = md { epubCoverage = Just $ strContent e }
+ | name == "rights" = md { epubRights = Just $ strContent e }
+ | otherwise = md
+ where getAttr n = lookupAttr (opfName n) attrs
+addMetadataFromXML _ md = md
+
+metaValueToString :: MetaValue -> String
+metaValueToString (MetaString s) = s
+metaValueToString (MetaInlines ils) = stringify ils
+metaValueToString (MetaBlocks bs) = stringify bs
+metaValueToString (MetaBool True) = "true"
+metaValueToString (MetaBool False) = "false"
+metaValueToString _ = ""
+
+getList :: String -> Meta -> (MetaValue -> a) -> [a]
+getList s meta handleMetaValue =
+ case lookupMeta s meta of
+ Just (MetaList xs) -> map handleMetaValue xs
+ Just mv -> [handleMetaValue mv]
+ Nothing -> []
+
+getIdentifier :: Meta -> [Identifier]
+getIdentifier meta = getList "identifier" meta handleMetaValue
+ where handleMetaValue (MetaMap m) =
+ Identifier{ identifierText = maybe "" metaValueToString
+ $ M.lookup "text" m
+ , identifierScheme = metaValueToString <$>
+ M.lookup "scheme" m }
+ handleMetaValue mv = Identifier (metaValueToString mv) Nothing
+
+getTitle :: Meta -> [Title]
+getTitle meta = getList "title" meta handleMetaValue
+ where handleMetaValue (MetaMap m) =
+ Title{ titleText = maybe "" metaValueToString $ M.lookup "text" m
+ , titleFileAs = metaValueToString <$> M.lookup "file-as" m
+ , titleType = metaValueToString <$> M.lookup "type" m }
+ handleMetaValue mv = Title (metaValueToString mv) Nothing Nothing
+
+getCreator :: String -> Meta -> [Creator]
+getCreator s meta = getList s meta handleMetaValue
+ where handleMetaValue (MetaMap m) =
+ Creator{ creatorText = maybe "" metaValueToString $ M.lookup "text" m
+ , creatorFileAs = metaValueToString <$> M.lookup "file-as" m
+ , creatorRole = metaValueToString <$> M.lookup "role" m }
+ handleMetaValue mv = Creator (metaValueToString mv) Nothing Nothing
+
+getDate :: String -> Meta -> [Date]
+getDate s meta = getList s meta handleMetaValue
+ where handleMetaValue (MetaMap m) =
+ Date{ dateText = maybe "" id $
+ M.lookup "text" m >>= normalizeDate' . metaValueToString
+ , dateEvent = metaValueToString <$> M.lookup "event" m }
+ handleMetaValue mv = Date { dateText = maybe ""
+ id $ normalizeDate' $ metaValueToString mv
+ , dateEvent = Nothing }
+
+simpleList :: String -> Meta -> [String]
+simpleList s meta =
+ case lookupMeta s meta of
+ Just (MetaList xs) -> map metaValueToString xs
+ Just x -> [metaValueToString x]
+ Nothing -> []
+
+metadataFromMeta :: WriterOptions -> Meta -> EPUBMetadata
+metadataFromMeta opts meta = EPUBMetadata{
+ epubIdentifier = identifiers
+ , epubTitle = titles
+ , epubDate = date
+ , epubLanguage = language
+ , epubCreator = creators
+ , epubContributor = contributors
+ , epubSubject = subjects
+ , epubDescription = description
+ , epubType = epubtype
+ , epubFormat = format
+ , epubPublisher = publisher
+ , epubSource = source
+ , epubRelation = relation
+ , epubCoverage = coverage
+ , epubRights = rights
+ , epubCoverImage = coverImage
+ , epubStylesheet = stylesheet
+ , epubPageDirection = pageDirection
+ }
+ where identifiers = getIdentifier meta
+ titles = getTitle meta
+ date = getDate "date" meta
+ language = maybe "" metaValueToString $
+ lookupMeta "language" meta `mplus` lookupMeta "lang" meta
+ creators = getCreator "creator" meta
+ contributors = getCreator "contributor" meta
+ subjects = simpleList "subject" meta
+ description = metaValueToString <$> lookupMeta "description" meta
+ epubtype = metaValueToString <$> lookupMeta "type" meta
+ format = metaValueToString <$> lookupMeta "format" meta
+ publisher = metaValueToString <$> lookupMeta "publisher" meta
+ source = metaValueToString <$> lookupMeta "source" meta
+ relation = metaValueToString <$> lookupMeta "relation" meta
+ coverage = metaValueToString <$> lookupMeta "coverage" meta
+ rights = metaValueToString <$> lookupMeta "rights" meta
+ coverImage = lookup "epub-cover-image" (writerVariables opts) `mplus`
+ (metaValueToString <$> lookupMeta "cover-image" meta)
+ stylesheet = (StylesheetContents <$> writerEpubStylesheet opts) `mplus`
+ ((StylesheetPath . metaValueToString) <$>
+ lookupMeta "stylesheet" meta)
+ pageDirection = case map toLower . metaValueToString <$>
+ lookupMeta "page-progression-direction" meta of
+ Just "ltr" -> Just LTR
+ Just "rtl" -> Just RTL
+ _ -> Nothing
+
+-- | Produce an EPUB2 file from a Pandoc document.
+writeEPUB2 :: PandocMonad m
+ => WriterOptions -- ^ Writer options
+ -> Pandoc -- ^ Document to convert
+ -> m B.ByteString
+writeEPUB2 = writeEPUB EPUB2
+
+-- | Produce an EPUB3 file from a Pandoc document.
+writeEPUB3 :: PandocMonad m
+ => WriterOptions -- ^ Writer options
+ -> Pandoc -- ^ Document to convert
+ -> m B.ByteString
+writeEPUB3 = writeEPUB EPUB3
+
+-- | Produce an EPUB file from a Pandoc document.
+writeEPUB :: PandocMonad m
+ => EPUBVersion
+ -> WriterOptions -- ^ Writer options
+ -> Pandoc -- ^ Document to convert
+ -> m B.ByteString
+writeEPUB epubVersion opts doc =
+ let initState = EPUBState { stMediaPaths = []
+ }
+ in
+ evalStateT (pandocToEPUB epubVersion opts doc)
+ initState
+
+pandocToEPUB :: PandocMonad m
+ => EPUBVersion
+ -> WriterOptions
+ -> Pandoc
+ -> E m B.ByteString
+pandocToEPUB version opts doc@(Pandoc meta _) = do
+ let epub3 = version == EPUB3
+ let writeHtml o = fmap UTF8.fromStringLazy .
+ writeHtmlStringForEPUB version o
+ epochtime <- floor <$> lift P.getPOSIXTime
+ let mkEntry path content = toEntry path epochtime content
+ let vars = ("epub3", if epub3 then "true" else "false")
+ : ("css", "stylesheet.css")
+ : writerVariables opts
+ let opts' = opts{ writerEmailObfuscation = NoObfuscation
+ , writerSectionDivs = True
+ , writerVariables = vars
+ , writerHTMLMathMethod =
+ if epub3
+ then MathML
+ else writerHTMLMathMethod opts
+ , writerWrapText = WrapAuto }
+ metadata <- getEPUBMetadata opts' meta
+
+ -- cover page
+ (cpgEntry, cpicEntry) <-
+ case epubCoverImage metadata of
+ Nothing -> return ([],[])
+ Just img -> do
+ let coverImage = "media/" ++ takeFileName img
+ cpContent <- lift $ writeHtml
+ opts'{ writerVariables = ("coverpage","true"):vars }
+ (Pandoc meta [RawBlock (Format "html") $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ "\" alt=\"cover image\" />\n</div>"])
+ imgContent <- lift $ P.readFileLazy img
+ return ( [mkEntry "cover.xhtml" cpContent]
+ , [mkEntry coverImage imgContent] )
+
+ -- title page
+ tpContent <- lift $ writeHtml opts'{
+ writerVariables = ("titlepage","true"):vars }
+ (Pandoc meta [])
+ let tpEntry = mkEntry "title_page.xhtml" tpContent
+
+ -- handle pictures
+ -- mediaRef <- P.newIORef []
+ Pandoc _ blocks <- walkM (transformInline opts') doc >>=
+ walkM (transformBlock opts')
+ picEntries <- (catMaybes . map (snd . snd)) <$> (gets stMediaPaths)
+ -- handle fonts
+ let matchingGlob f = do
+ xs <- lift $ P.glob f
+ when (null xs) $
+ report $ CouldNotFetchResource f "glob did not match any font files"
+ return xs
+ let mkFontEntry f = mkEntry (takeFileName f) `fmap` (lift $ P.readFileLazy f)
+ fontFiles <- concat <$> mapM matchingGlob (writerEpubFonts opts')
+ fontEntries <- mapM mkFontEntry fontFiles
+
+ -- set page progression direction attribution
+ let progressionDirection = case epubPageDirection metadata of
+ Just LTR | epub3 ->
+ [("page-progression-direction", "ltr")]
+ Just RTL | epub3 ->
+ [("page-progression-direction", "rtl")]
+ _ -> []
+
+ -- body pages
+
+ -- add level 1 header to beginning if none there
+ let blocks' = addIdentifiers
+ $ case blocks of
+ (Header 1 _ _ : _) -> blocks
+ _ -> Header 1 ("",["unnumbered"],[])
+ (docTitle' meta) : blocks
+
+ let chapterHeaderLevel = writerEpubChapterLevel opts
+
+ let isChapterHeader (Header n _ _) = n <= chapterHeaderLevel
+ isChapterHeader (Div ("",["references"],[]) (Header n _ _:_)) =
+ n <= chapterHeaderLevel
+ isChapterHeader _ = False
+
+ let toChapters :: [Block] -> State [Int] [Chapter]
+ toChapters [] = return []
+ toChapters (Div ("",["references"],[]) bs@(Header 1 _ _:_) : rest) =
+ toChapters (bs ++ rest)
+ toChapters (Header n attr@(_,classes,_) ils : bs) = do
+ nums <- get
+ mbnum <- if "unnumbered" `elem` classes
+ then return Nothing
+ else case splitAt (n - 1) nums of
+ (ks, (m:_)) -> do
+ let nums' = ks ++ [m+1]
+ put nums'
+ return $ Just (ks ++ [m])
+ -- note, this is the offset not the sec number
+ (ks, []) -> do
+ let nums' = ks ++ [1]
+ put nums'
+ return $ Just ks
+ let (xs,ys) = break isChapterHeader bs
+ (Chapter mbnum (Header n attr ils : xs) :) `fmap` toChapters ys
+ toChapters (b:bs) = do
+ let (xs,ys) = break isChapterHeader bs
+ (Chapter Nothing (b:xs) :) `fmap` toChapters ys
+
+ let chapters' = evalState (toChapters blocks') []
+
+ let extractLinkURL' :: Int -> Inline -> [(String, String)]
+ extractLinkURL' num (Span (ident, _, _) _)
+ | not (null ident) = [(ident, showChapter num ++ ('#':ident))]
+ extractLinkURL' _ _ = []
+
+ let extractLinkURL :: Int -> Block -> [(String, String)]
+ extractLinkURL num (Div (ident, _, _) _)
+ | not (null ident) = [(ident, showChapter num ++ ('#':ident))]
+ extractLinkURL num (Header _ (ident, _, _) _)
+ | not (null ident) = [(ident, showChapter num ++ ('#':ident))]
+ extractLinkURL num b = query (extractLinkURL' num) b
+
+ let reftable = concat $ zipWith (\(Chapter _ bs) num ->
+ query (extractLinkURL num) bs)
+ chapters' [1..]
+
+ let fixInternalReferences :: Inline -> Inline
+ fixInternalReferences (Link attr lab ('#':xs, tit)) =
+ case lookup xs reftable of
+ Just ys -> Link attr lab (ys, tit)
+ Nothing -> Link attr lab ('#':xs, tit)
+ fixInternalReferences x = x
+
+ -- internal reference IDs change when we chunk the file,
+ -- so that '#my-header-1' might turn into 'chap004.xhtml#my-header'.
+ -- this fixes that:
+ let chapters = map (\(Chapter mbnum bs) ->
+ Chapter mbnum $ walk fixInternalReferences bs)
+ chapters'
+
+ let chapToEntry num (Chapter mbnum bs) =
+ mkEntry (showChapter num) <$>
+ (writeHtml opts'{ writerNumberOffset = fromMaybe [] mbnum }
+ $ case bs of
+ (Header _ _ xs : _) ->
+ -- remove notes or we get doubled footnotes
+ Pandoc (setMeta "title" (walk removeNote $ fromList xs)
+ nullMeta) bs
+ _ ->
+ Pandoc nullMeta bs)
+
+ chapterEntries <- lift $ zipWithM chapToEntry [1..] chapters
+
+ -- incredibly inefficient (TODO):
+ let containsMathML ent = epub3 &&
+ "<math" `isInfixOf` (B8.unpack $ fromEntry ent)
+ let containsSVG ent = epub3 &&
+ "<svg" `isInfixOf` (B8.unpack $ fromEntry ent)
+ let props ent = ["mathml" | containsMathML ent] ++ ["svg" | containsSVG ent]
+
+ -- contents.opf
+ let chapterNode ent = unode "item" !
+ ([("id", toId $ eRelativePath ent),
+ ("href", eRelativePath ent),
+ ("media-type", "application/xhtml+xml")]
+ ++ case props ent of
+ [] -> []
+ xs -> [("properties", unwords xs)])
+ $ ()
+ let chapterRefNode ent = unode "itemref" !
+ [("idref", toId $ eRelativePath ent)] $ ()
+ let pictureNode ent = unode "item" !
+ [("id", toId $ eRelativePath ent),
+ ("href", eRelativePath ent),
+ ("media-type", fromMaybe "application/octet-stream"
+ $ mediaTypeOf $ eRelativePath ent)] $ ()
+ let fontNode ent = unode "item" !
+ [("id", toId $ eRelativePath ent),
+ ("href", eRelativePath ent),
+ ("media-type", fromMaybe "" $ getMimeType $ eRelativePath ent)] $ ()
+ let plainTitle = case docTitle' meta of
+ [] -> case epubTitle metadata of
+ [] -> "UNTITLED"
+ (x:_) -> titleText x
+ x -> stringify x
+
+ let tocTitle = fromMaybe plainTitle $
+ metaValueToString <$> lookupMeta "toc-title" meta
+ uuid <- case epubIdentifier metadata of
+ (x:_) -> return $ identifierText x -- use first identifier as UUID
+ [] -> throwError $ PandocShouldNeverHappenError "epubIdentifier is null" -- shouldn't happen
+ currentTime <- lift $ P.getCurrentTime
+ let contentsData = UTF8.fromStringLazy $ ppTopElement $
+ unode "package" ! [("version", case version of
+ EPUB2 -> "2.0"
+ EPUB3 -> "3.0")
+ ,("xmlns","http://www.idpf.org/2007/opf")
+ ,("unique-identifier","epub-id-1")] $
+ [ metadataElement version metadata currentTime
+ , unode "manifest" $
+ [ unode "item" ! [("id","ncx"), ("href","toc.ncx")
+ ,("media-type","application/x-dtbncx+xml")] $ ()
+ , unode "item" ! [("id","style"), ("href","stylesheet.css")
+ ,("media-type","text/css")] $ ()
+ , unode "item" ! ([("id","nav")
+ ,("href","nav.xhtml")
+ ,("media-type","application/xhtml+xml")] ++
+ [("properties","nav") | epub3 ]) $ ()
+ ] ++
+ map chapterNode (cpgEntry ++ (tpEntry : chapterEntries)) ++
+ (case cpicEntry of
+ [] -> []
+ (x:_) -> [add_attrs
+ [Attr (unqual "properties") "cover-image" | epub3]
+ (pictureNode x)]) ++
+ map pictureNode picEntries ++
+ map fontNode fontEntries
+ , unode "spine" ! ([("toc","ncx")] ++ progressionDirection) $
+ case epubCoverImage metadata of
+ Nothing -> []
+ Just _ -> [ unode "itemref" !
+ [("idref", "cover_xhtml")] $ () ]
+ ++ ((unode "itemref" ! [("idref", "title_page_xhtml")
+ ,("linear",
+ case lookupMeta "title" meta of
+ Just _ -> "yes"
+ Nothing -> "no")] $ ()) :
+ [unode "itemref" ! [("idref", "nav")] $ ()
+ | writerTableOfContents opts ] ++
+ map chapterRefNode chapterEntries)
+ , unode "guide" $
+ [ unode "reference" !
+ [("type","toc"),("title", tocTitle),
+ ("href","nav.xhtml")] $ ()
+ ] ++
+ [ unode "reference" !
+ [("type","cover"),("title","Cover"),("href","cover.xhtml")] $ () | epubCoverImage metadata /= Nothing
+ ]
+ ]
+ let contentsEntry = mkEntry "content.opf" contentsData
+
+ -- toc.ncx
+ let secs = hierarchicalize blocks'
+
+ let tocLevel = writerTOCDepth opts
+
+ let navPointNode :: PandocMonad m
+ => (Int -> String -> String -> [Element] -> Element)
+ -> S.Element -> StateT Int m Element
+ navPointNode formatter (S.Sec _ nums (ident,_,_) ils children) = do
+ n <- get
+ modify (+1)
+ let showNums :: [Int] -> String
+ showNums = intercalate "." . map show
+ let tit' = stringify ils
+ let tit = if writerNumberSections opts && not (null nums)
+ then showNums nums ++ " " ++ tit'
+ else tit'
+ src <- case lookup ident reftable of
+ Just x -> return x
+ Nothing -> throwError $ PandocSomeError $ ident ++ " not found in reftable"
+ let isSec (S.Sec lev _ _ _ _) = lev <= tocLevel
+ isSec _ = False
+ let subsecs = filter isSec children
+ subs <- mapM (navPointNode formatter) subsecs
+ return $ formatter n tit src subs
+ navPointNode _ (S.Blk _) = throwError $ PandocSomeError "navPointNode encountered Blk"
+
+ let navMapFormatter :: Int -> String -> String -> [Element] -> Element
+ navMapFormatter n tit src subs = unode "navPoint" !
+ [("id", "navPoint-" ++ show n)] $
+ [ unode "navLabel" $ unode "text" tit
+ , unode "content" ! [("src", src)] $ ()
+ ] ++ subs
+
+ let tpNode = unode "navPoint" ! [("id", "navPoint-0")] $
+ [ unode "navLabel" $ unode "text" (stringify $ docTitle' meta)
+ , unode "content" ! [("src","title_page.xhtml")] $ () ]
+
+ navMap <- lift $ evalStateT (mapM (navPointNode navMapFormatter) secs) 1
+ let tocData = UTF8.fromStringLazy $ ppTopElement $
+ unode "ncx" ! [("version","2005-1")
+ ,("xmlns","http://www.daisy.org/z3986/2005/ncx/")] $
+ [ unode "head" $
+ [ unode "meta" ! [("name","dtb:uid")
+ ,("content", uuid)] $ ()
+ , unode "meta" ! [("name","dtb:depth")
+ ,("content", "1")] $ ()
+ , unode "meta" ! [("name","dtb:totalPageCount")
+ ,("content", "0")] $ ()
+ , unode "meta" ! [("name","dtb:maxPageNumber")
+ ,("content", "0")] $ ()
+ ] ++ case epubCoverImage metadata of
+ Nothing -> []
+ Just img -> [unode "meta" ! [("name","cover"),
+ ("content", toId img)] $ ()]
+ , unode "docTitle" $ unode "text" $ plainTitle
+ , unode "navMap" $
+ tpNode : navMap
+ ]
+ let tocEntry = mkEntry "toc.ncx" tocData
+
+ let navXhtmlFormatter :: Int -> String -> String -> [Element] -> Element
+ navXhtmlFormatter n tit src subs = unode "li" !
+ [("id", "toc-li-" ++ show n)] $
+ (unode "a" ! [("href",src)]
+ $ tit)
+ : case subs of
+ [] -> []
+ (_:_) -> [unode "ol" ! [("class","toc")] $ subs]
+
+ let navtag = if epub3 then "nav" else "div"
+ tocBlocks <- lift $ evalStateT (mapM (navPointNode navXhtmlFormatter) secs) 1
+ let navBlocks = [RawBlock (Format "html") $ ppElement $
+ unode navtag ! ([("epub:type","toc") | epub3] ++
+ [("id","toc")]) $
+ [ unode "h1" ! [("id","toc-title")] $ tocTitle
+ , unode "ol" ! [("class","toc")] $ tocBlocks ]]
+ let landmarks = if epub3
+ then [RawBlock (Format "html") $ ppElement $
+ unode "nav" ! [("epub:type","landmarks")
+ ,("hidden","hidden")] $
+ [ unode "ol" $
+ [ unode "li"
+ [ unode "a" ! [("href", "cover.xhtml")
+ ,("epub:type", "cover")] $
+ "Cover"] |
+ epubCoverImage metadata /= Nothing
+ ] ++
+ [ unode "li"
+ [ unode "a" ! [("href", "#toc")
+ ,("epub:type", "toc")] $
+ "Table of contents"
+ ] | writerTableOfContents opts
+ ]
+ ]
+ ]
+ else []
+ navData <- lift $ writeHtml opts'{ writerVariables = ("navpage","true"):vars }
+ (Pandoc (setMeta "title"
+ (walk removeNote $ fromList $ docTitle' meta) nullMeta)
+ (navBlocks ++ landmarks))
+ let navEntry = mkEntry "nav.xhtml" navData
+
+ -- mimetype
+ let mimetypeEntry = mkEntry "mimetype" $ UTF8.fromStringLazy "application/epub+zip"
+
+ -- container.xml
+ let containerData = UTF8.fromStringLazy $ ppTopElement $
+ unode "container" ! [("version","1.0")
+ ,("xmlns","urn:oasis:names:tc:opendocument:xmlns:container")] $
+ unode "rootfiles" $
+ unode "rootfile" ! [("full-path","content.opf")
+ ,("media-type","application/oebps-package+xml")] $ ()
+ let containerEntry = mkEntry "META-INF/container.xml" containerData
+
+ -- com.apple.ibooks.display-options.xml
+ let apple = UTF8.fromStringLazy $ ppTopElement $
+ unode "display_options" $
+ unode "platform" ! [("name","*")] $
+ unode "option" ! [("name","specified-fonts")] $ "true"
+ let appleEntry = mkEntry "META-INF/com.apple.ibooks.display-options.xml" apple
+
+ -- stylesheet
+ stylesheet <- case epubStylesheet metadata of
+ Just (StylesheetPath fp) -> UTF8.toStringLazy <$> (lift $ P.readFileLazy fp)
+ Just (StylesheetContents s) -> return s
+ Nothing -> UTF8.toString `fmap`
+ (lift $ P.readDataFile (writerUserDataDir opts) "epub.css")
+ let stylesheetEntry = mkEntry "stylesheet.css" $ UTF8.fromStringLazy stylesheet
+
+ -- construct archive
+ let archive = foldr addEntryToArchive emptyArchive
+ (mimetypeEntry : containerEntry : appleEntry : stylesheetEntry : tpEntry :
+ contentsEntry : tocEntry : navEntry :
+ (picEntries ++ cpicEntry ++ cpgEntry ++ chapterEntries ++ fontEntries))
+ return $ fromArchive archive
+
+metadataElement :: EPUBVersion -> EPUBMetadata -> UTCTime -> Element
+metadataElement version md currentTime =
+ unode "metadata" ! [("xmlns:dc","http://purl.org/dc/elements/1.1/")
+ ,("xmlns:opf","http://www.idpf.org/2007/opf")] $ mdNodes
+ where mdNodes = identifierNodes ++ titleNodes ++ dateNodes ++ languageNodes
+ ++ creatorNodes ++ contributorNodes ++ subjectNodes
+ ++ descriptionNodes ++ typeNodes ++ formatNodes
+ ++ publisherNodes ++ sourceNodes ++ relationNodes
+ ++ coverageNodes ++ rightsNodes ++ coverImageNodes
+ ++ modifiedNodes
+ withIds base f = concat . zipWith f (map (\x -> base ++ ('-' : show x))
+ ([1..] :: [Int]))
+ identifierNodes = withIds "epub-id" toIdentifierNode $
+ epubIdentifier md
+ titleNodes = withIds "epub-title" toTitleNode $ epubTitle md
+ dateNodes = if version == EPUB2
+ then withIds "epub-date" toDateNode $ epubDate md
+ else -- epub3 allows only one dc:date
+ -- http://www.idpf.org/epub/30/spec/epub30-publications.html#sec-opf-dcdate
+ case epubDate md of
+ [] -> []
+ (x:_) -> [dcNode "date" ! [("id","epub-date")]
+ $ dateText x]
+ languageNodes = [dcTag "language" $ epubLanguage md]
+ creatorNodes = withIds "epub-creator" (toCreatorNode "creator") $
+ epubCreator md
+ contributorNodes = withIds "epub-contributor"
+ (toCreatorNode "contributor") $ epubContributor md
+ subjectNodes = map (dcTag "subject") $ epubSubject md
+ descriptionNodes = maybe [] (dcTag' "description") $ epubDescription md
+ typeNodes = maybe [] (dcTag' "type") $ epubType md
+ formatNodes = maybe [] (dcTag' "format") $ epubFormat md
+ publisherNodes = maybe [] (dcTag' "publisher") $ epubPublisher md
+ sourceNodes = maybe [] (dcTag' "source") $ epubSource md
+ relationNodes = maybe [] (dcTag' "relation") $ epubRelation md
+ coverageNodes = maybe [] (dcTag' "coverage") $ epubCoverage md
+ rightsNodes = maybe [] (dcTag' "rights") $ epubRights md
+ coverImageNodes = maybe []
+ (\img -> [unode "meta" ! [("name","cover"),
+ ("content",toId img)] $ ()])
+ $ epubCoverImage md
+ modifiedNodes = [ unode "meta" ! [("property", "dcterms:modified")] $
+ (showDateTimeISO8601 currentTime) | version == EPUB3 ]
+ dcTag n s = unode ("dc:" ++ n) s
+ dcTag' n s = [dcTag n s]
+ toIdentifierNode id' (Identifier txt scheme)
+ | version == EPUB2 = [dcNode "identifier" !
+ ([("id",id')] ++ maybe [] (\x -> [("opf:scheme", x)]) scheme) $
+ txt]
+ | otherwise = [dcNode "identifier" ! [("id",id')] $ txt] ++
+ maybe [] (\x -> [unode "meta" !
+ [("refines",'#':id'),("property","identifier-type"),
+ ("scheme","onix:codelist5")] $ x])
+ (schemeToOnix `fmap` scheme)
+ toCreatorNode s id' creator
+ | version == EPUB2 = [dcNode s !
+ (("id",id') :
+ maybe [] (\x -> [("opf:file-as",x)]) (creatorFileAs creator) ++
+ maybe [] (\x -> [("opf:role",x)])
+ (creatorRole creator >>= toRelator)) $ creatorText creator]
+ | otherwise = [dcNode s ! [("id",id')] $ creatorText creator] ++
+ maybe [] (\x -> [unode "meta" !
+ [("refines",'#':id'),("property","file-as")] $ x])
+ (creatorFileAs creator) ++
+ maybe [] (\x -> [unode "meta" !
+ [("refines",'#':id'),("property","role"),
+ ("scheme","marc:relators")] $ x])
+ (creatorRole creator >>= toRelator)
+ toTitleNode id' title
+ | version == EPUB2 = [dcNode "title" !
+ (("id",id') :
+ -- note: EPUB2 doesn't accept opf:title-type
+ maybe [] (\x -> [("opf:file-as",x)]) (titleFileAs title)) $
+ titleText title]
+ | otherwise = [dcNode "title" ! [("id",id')] $ titleText title]
+ ++
+ maybe [] (\x -> [unode "meta" !
+ [("refines",'#':id'),("property","file-as")] $ x])
+ (titleFileAs title) ++
+ maybe [] (\x -> [unode "meta" !
+ [("refines",'#':id'),("property","title-type")] $ x])
+ (titleType title)
+ toDateNode id' date = [dcNode "date" !
+ (("id",id') :
+ maybe [] (\x -> [("opf:event",x)]) (dateEvent date)) $
+ dateText date]
+ schemeToOnix "ISBN-10" = "02"
+ schemeToOnix "GTIN-13" = "03"
+ schemeToOnix "UPC" = "04"
+ schemeToOnix "ISMN-10" = "05"
+ schemeToOnix "DOI" = "06"
+ schemeToOnix "LCCN" = "13"
+ schemeToOnix "GTIN-14" = "14"
+ schemeToOnix "ISBN-13" = "15"
+ schemeToOnix "Legal deposit number" = "17"
+ schemeToOnix "URN" = "22"
+ schemeToOnix "OCLC" = "23"
+ schemeToOnix "ISMN-13" = "25"
+ schemeToOnix "ISBN-A" = "26"
+ schemeToOnix "JP" = "27"
+ schemeToOnix "OLCC" = "28"
+ schemeToOnix _ = "01"
+
+showDateTimeISO8601 :: UTCTime -> String
+showDateTimeISO8601 = formatTime defaultTimeLocale "%FT%TZ"
+
+transformTag :: PandocMonad m
+ => WriterOptions
+ -- -> IORef [(FilePath, (FilePath, Maybe Entry))] -- ^ (oldpath, newpath, entry) media
+ -> Tag String
+ -> E m (Tag String)
+transformTag opts tag@(TagOpen name attr)
+ | name `elem` ["video", "source", "img", "audio"] &&
+ lookup "data-external" attr == Nothing = do
+ let src = fromAttrib "src" tag
+ let poster = fromAttrib "poster" tag
+ newsrc <- modifyMediaRef opts src
+ newposter <- modifyMediaRef opts poster
+ let attr' = filter (\(x,_) -> x /= "src" && x /= "poster") attr ++
+ [("src", newsrc) | not (null newsrc)] ++
+ [("poster", newposter) | not (null newposter)]
+ return $ TagOpen name attr'
+transformTag _ tag = return tag
+
+modifyMediaRef :: PandocMonad m
+ => WriterOptions
+ -> FilePath
+ -> E m FilePath
+modifyMediaRef _ "" = return ""
+modifyMediaRef opts oldsrc = do
+ media <- gets stMediaPaths
+ case lookup oldsrc media of
+ Just (n,_) -> return n
+ Nothing -> catchError
+ (do (img, mbMime) <- P.fetchItem (writerSourceURL opts) oldsrc
+ let new = "media/file" ++ show (length media) ++
+ fromMaybe (takeExtension (takeWhile (/='?') oldsrc))
+ (('.':) <$> (mbMime >>= extensionFromMimeType))
+ epochtime <- floor `fmap` lift P.getPOSIXTime
+ let entry = toEntry new epochtime $ B.fromChunks . (:[]) $ img
+ modify $ \st -> st{ stMediaPaths =
+ (oldsrc, (new, Just entry)):media}
+ return new)
+ (\e -> do
+ report $ CouldNotFetchResource oldsrc (show e)
+ return oldsrc)
+
+transformBlock :: PandocMonad m
+ => WriterOptions
+ -- -> IORef [(FilePath, (FilePath, Maybe Entry))] -- ^ (oldpath, newpath, entry) media
+ -> Block
+ -> E m Block
+transformBlock opts (RawBlock fmt raw)
+ | fmt == Format "html" = do
+ let tags = parseTags raw
+ tags' <- mapM (transformTag opts) tags
+ return $ RawBlock fmt (renderTags' tags')
+transformBlock _ b = return b
+
+transformInline :: PandocMonad m
+ => WriterOptions
+ -- -> IORef [(FilePath, (FilePath, Maybe Entry))] -- ^ (oldpath, newpath) media
+ -> Inline
+ -> E m Inline
+transformInline opts (Image attr lab (src,tit)) = do
+ newsrc <- modifyMediaRef opts src
+ return $ Image attr lab (newsrc, tit)
+transformInline opts (x@(Math t m))
+ | WebTeX url <- writerHTMLMathMethod opts = do
+ newsrc <- modifyMediaRef opts (url ++ urlEncode m)
+ let mathclass = if t == DisplayMath then "display" else "inline"
+ return $ Span ("",["math",mathclass],[]) [Image nullAttr [x] (newsrc, "")]
+transformInline opts (RawInline fmt raw)
+ | fmt == Format "html" = do
+ let tags = parseTags raw
+ tags' <- mapM (transformTag opts) tags
+ return $ RawInline fmt (renderTags' tags')
+transformInline _ x = return x
+
+(!) :: (t -> Element) -> [(String, String)] -> t -> Element
+(!) f attrs n = add_attrs (map (\(k,v) -> Attr (unqual k) v) attrs) (f n)
+
+-- | Version of 'ppTopElement' that specifies UTF-8 encoding.
+ppTopElement :: Element -> String
+ppTopElement = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ++) . unEntity . ppElement
+ -- unEntity removes numeric entities introduced by ppElement
+ -- (kindlegen seems to choke on these).
+ where unEntity [] = ""
+ unEntity ('&':'#':xs) =
+ let (ds,ys) = break (==';') xs
+ rest = drop 1 ys
+ in case safeRead ('\'':'\\':ds ++ "'") of
+ Just x -> x : unEntity rest
+ Nothing -> '&':'#':unEntity xs
+ unEntity (x:xs) = x : unEntity xs
+
+mediaTypeOf :: FilePath -> Maybe MimeType
+mediaTypeOf x =
+ let mediaPrefixes = ["image", "video", "audio"] in
+ case getMimeType x of
+ Just y | any (`isPrefixOf` y) mediaPrefixes -> Just y
+ _ -> Nothing
+
+-- Returns filename for chapter number.
+showChapter :: Int -> String
+showChapter = printf "ch%03d.xhtml"
+
+-- Add identifiers to any headers without them.
+addIdentifiers :: [Block] -> [Block]
+addIdentifiers bs = evalState (mapM go bs) Set.empty
+ where go (Header n (ident,classes,kvs) ils) = do
+ ids <- get
+ let ident' = if null ident
+ then uniqueIdent ils ids
+ else ident
+ modify $ Set.insert ident'
+ return $ Header n (ident',classes,kvs) ils
+ go x = return x
+
+-- Variant of normalizeDate that allows partial dates: YYYY, YYYY-MM
+normalizeDate' :: String -> Maybe String
+normalizeDate' xs =
+ let xs' = trim xs in
+ case xs' of
+ [y1,y2,y3,y4] | all isDigit [y1,y2,y3,y4] -> Just xs' -- YYYY
+ [y1,y2,y3,y4,'-',m1,m2] | all isDigit [y1,y2,y3,y4,m1,m2] -- YYYY-MM
+ -> Just xs'
+ _ -> normalizeDate xs'
+
+toRelator :: String -> Maybe String
+toRelator x
+ | x `elem` relators = Just x
+ | otherwise = lookup (map toLower x) relatorMap
+
+relators :: [String]
+relators = map snd relatorMap
+
+relatorMap :: [(String, String)]
+relatorMap =
+ [("abridger", "abr")
+ ,("actor", "act")
+ ,("adapter", "adp")
+ ,("addressee", "rcp")
+ ,("analyst", "anl")
+ ,("animator", "anm")
+ ,("annotator", "ann")
+ ,("appellant", "apl")
+ ,("appellee", "ape")
+ ,("applicant", "app")
+ ,("architect", "arc")
+ ,("arranger", "arr")
+ ,("art copyist", "acp")
+ ,("art director", "adi")
+ ,("artist", "art")
+ ,("artistic director", "ard")
+ ,("assignee", "asg")
+ ,("associated name", "asn")
+ ,("attributed name", "att")
+ ,("auctioneer", "auc")
+ ,("author", "aut")
+ ,("author in quotations or text abstracts", "aqt")
+ ,("author of afterword, colophon, etc.", "aft")
+ ,("author of dialog", "aud")
+ ,("author of introduction, etc.", "aui")
+ ,("autographer", "ato")
+ ,("bibliographic antecedent", "ant")
+ ,("binder", "bnd")
+ ,("binding designer", "bdd")
+ ,("blurb writer", "blw")
+ ,("book designer", "bkd")
+ ,("book producer", "bkp")
+ ,("bookjacket designer", "bjd")
+ ,("bookplate designer", "bpd")
+ ,("bookseller", "bsl")
+ ,("braille embosser", "brl")
+ ,("broadcaster", "brd")
+ ,("calligrapher", "cll")
+ ,("cartographer", "ctg")
+ ,("caster", "cas")
+ ,("censor", "cns")
+ ,("choreographer", "chr")
+ ,("cinematographer", "cng")
+ ,("client", "cli")
+ ,("collection registrar", "cor")
+ ,("collector", "col")
+ ,("collotyper", "clt")
+ ,("colorist", "clr")
+ ,("commentator", "cmm")
+ ,("commentator for written text", "cwt")
+ ,("compiler", "com")
+ ,("complainant", "cpl")
+ ,("complainant-appellant", "cpt")
+ ,("complainant-appellee", "cpe")
+ ,("composer", "cmp")
+ ,("compositor", "cmt")
+ ,("conceptor", "ccp")
+ ,("conductor", "cnd")
+ ,("conservator", "con")
+ ,("consultant", "csl")
+ ,("consultant to a project", "csp")
+ ,("contestant", "cos")
+ ,("contestant-appellant", "cot")
+ ,("contestant-appellee", "coe")
+ ,("contestee", "cts")
+ ,("contestee-appellant", "ctt")
+ ,("contestee-appellee", "cte")
+ ,("contractor", "ctr")
+ ,("contributor", "ctb")
+ ,("copyright claimant", "cpc")
+ ,("copyright holder", "cph")
+ ,("corrector", "crr")
+ ,("correspondent", "crp")
+ ,("costume designer", "cst")
+ ,("court governed", "cou")
+ ,("court reporter", "crt")
+ ,("cover designer", "cov")
+ ,("creator", "cre")
+ ,("curator", "cur")
+ ,("dancer", "dnc")
+ ,("data contributor", "dtc")
+ ,("data manager", "dtm")
+ ,("dedicatee", "dte")
+ ,("dedicator", "dto")
+ ,("defendant", "dfd")
+ ,("defendant-appellant", "dft")
+ ,("defendant-appellee", "dfe")
+ ,("degree granting institution", "dgg")
+ ,("delineator", "dln")
+ ,("depicted", "dpc")
+ ,("depositor", "dpt")
+ ,("designer", "dsr")
+ ,("director", "drt")
+ ,("dissertant", "dis")
+ ,("distribution place", "dbp")
+ ,("distributor", "dst")
+ ,("donor", "dnr")
+ ,("draftsman", "drm")
+ ,("dubious author", "dub")
+ ,("editor", "edt")
+ ,("editor of compilation", "edc")
+ ,("editor of moving image work", "edm")
+ ,("electrician", "elg")
+ ,("electrotyper", "elt")
+ ,("enacting jurisdiction", "enj")
+ ,("engineer", "eng")
+ ,("engraver", "egr")
+ ,("etcher", "etr")
+ ,("event place", "evp")
+ ,("expert", "exp")
+ ,("facsimilist", "fac")
+ ,("field director", "fld")
+ ,("film director", "fmd")
+ ,("film distributor", "fds")
+ ,("film editor", "flm")
+ ,("film producer", "fmp")
+ ,("filmmaker", "fmk")
+ ,("first party", "fpy")
+ ,("forger", "frg")
+ ,("former owner", "fmo")
+ ,("funder", "fnd")
+ ,("geographic information specialist", "gis")
+ ,("honoree", "hnr")
+ ,("host", "hst")
+ ,("host institution", "his")
+ ,("illuminator", "ilu")
+ ,("illustrator", "ill")
+ ,("inscriber", "ins")
+ ,("instrumentalist", "itr")
+ ,("interviewee", "ive")
+ ,("interviewer", "ivr")
+ ,("inventor", "inv")
+ ,("issuing body", "isb")
+ ,("judge", "jud")
+ ,("jurisdiction governed", "jug")
+ ,("laboratory", "lbr")
+ ,("laboratory director", "ldr")
+ ,("landscape architect", "lsa")
+ ,("lead", "led")
+ ,("lender", "len")
+ ,("libelant", "lil")
+ ,("libelant-appellant", "lit")
+ ,("libelant-appellee", "lie")
+ ,("libelee", "lel")
+ ,("libelee-appellant", "let")
+ ,("libelee-appellee", "lee")
+ ,("librettist", "lbt")
+ ,("licensee", "lse")
+ ,("licensor", "lso")
+ ,("lighting designer", "lgd")
+ ,("lithographer", "ltg")
+ ,("lyricist", "lyr")
+ ,("manufacture place", "mfp")
+ ,("manufacturer", "mfr")
+ ,("marbler", "mrb")
+ ,("markup editor", "mrk")
+ ,("metadata contact", "mdc")
+ ,("metal-engraver", "mte")
+ ,("moderator", "mod")
+ ,("monitor", "mon")
+ ,("music copyist", "mcp")
+ ,("musical director", "msd")
+ ,("musician", "mus")
+ ,("narrator", "nrt")
+ ,("onscreen presenter", "osp")
+ ,("opponent", "opn")
+ ,("organizer of meeting", "orm")
+ ,("originator", "org")
+ ,("other", "oth")
+ ,("owner", "own")
+ ,("panelist", "pan")
+ ,("papermaker", "ppm")
+ ,("patent applicant", "pta")
+ ,("patent holder", "pth")
+ ,("patron", "pat")
+ ,("performer", "prf")
+ ,("permitting agency", "pma")
+ ,("photographer", "pht")
+ ,("plaintiff", "ptf")
+ ,("plaintiff-appellant", "ptt")
+ ,("plaintiff-appellee", "pte")
+ ,("platemaker", "plt")
+ ,("praeses", "pra")
+ ,("presenter", "pre")
+ ,("printer", "prt")
+ ,("printer of plates", "pop")
+ ,("printmaker", "prm")
+ ,("process contact", "prc")
+ ,("producer", "pro")
+ ,("production company", "prn")
+ ,("production designer", "prs")
+ ,("production manager", "pmn")
+ ,("production personnel", "prd")
+ ,("production place", "prp")
+ ,("programmer", "prg")
+ ,("project director", "pdr")
+ ,("proofreader", "pfr")
+ ,("provider", "prv")
+ ,("publication place", "pup")
+ ,("publisher", "pbl")
+ ,("publishing director", "pbd")
+ ,("puppeteer", "ppt")
+ ,("radio director", "rdd")
+ ,("radio producer", "rpc")
+ ,("recording engineer", "rce")
+ ,("recordist", "rcd")
+ ,("redaktor", "red")
+ ,("renderer", "ren")
+ ,("reporter", "rpt")
+ ,("repository", "rps")
+ ,("research team head", "rth")
+ ,("research team member", "rtm")
+ ,("researcher", "res")
+ ,("respondent", "rsp")
+ ,("respondent-appellant", "rst")
+ ,("respondent-appellee", "rse")
+ ,("responsible party", "rpy")
+ ,("restager", "rsg")
+ ,("restorationist", "rsr")
+ ,("reviewer", "rev")
+ ,("rubricator", "rbr")
+ ,("scenarist", "sce")
+ ,("scientific advisor", "sad")
+ ,("screenwriter", "aus")
+ ,("scribe", "scr")
+ ,("sculptor", "scl")
+ ,("second party", "spy")
+ ,("secretary", "sec")
+ ,("seller", "sll")
+ ,("set designer", "std")
+ ,("setting", "stg")
+ ,("signer", "sgn")
+ ,("singer", "sng")
+ ,("sound designer", "sds")
+ ,("speaker", "spk")
+ ,("sponsor", "spn")
+ ,("stage director", "sgd")
+ ,("stage manager", "stm")
+ ,("standards body", "stn")
+ ,("stereotyper", "str")
+ ,("storyteller", "stl")
+ ,("supporting host", "sht")
+ ,("surveyor", "srv")
+ ,("teacher", "tch")
+ ,("technical director", "tcd")
+ ,("television director", "tld")
+ ,("television producer", "tlp")
+ ,("thesis advisor", "ths")
+ ,("transcriber", "trc")
+ ,("translator", "trl")
+ ,("type designer", "tyd")
+ ,("typographer", "tyg")
+ ,("university place", "uvp")
+ ,("videographer", "vdg")
+ ,("witness", "wit")
+ ,("wood engraver", "wde")
+ ,("woodcutter", "wdc")
+ ,("writer of accompanying material", "wam")
+ ,("writer of added commentary", "wac")
+ ,("writer of added lyrics", "wal")
+ ,("writer of added text", "wat")
+ ]
+
+docTitle' :: Meta -> [Inline]
+docTitle' meta = fromMaybe [] $ go <$> lookupMeta "title" meta
+ where go (MetaString s) = [Str s]
+ go (MetaInlines xs) = xs
+ go (MetaBlocks [Para xs]) = xs
+ go (MetaBlocks [Plain xs]) = xs
+ go (MetaMap m) =
+ case M.lookup "type" m of
+ Just x | stringify x == "main" ->
+ maybe [] go $ M.lookup "text" m
+ _ -> []
+ go (MetaList xs) = concatMap go xs
+ go _ = []
diff --git a/src/Text/Pandoc/Writers/FB2.hs b/src/Text/Pandoc/Writers/FB2.hs
new file mode 100644
index 000000000..967fe6a4c
--- /dev/null
+++ b/src/Text/Pandoc/Writers/FB2.hs
@@ -0,0 +1,617 @@
+{-# LANGUAGE PatternGuards #-}
+
+{-
+Copyright (c) 2011-2012, Sergey Astanin
+All rights reserved.
+
+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
+-}
+
+{- | Conversion of 'Pandoc' documents to FB2 (FictionBook2) format.
+
+FictionBook is an XML-based e-book format. For more information see:
+<http://www.fictionbook.org/index.php/Eng:XML_Schema_Fictionbook_2.1>
+
+-}
+module Text.Pandoc.Writers.FB2 (writeFB2) where
+
+import Control.Monad.State (StateT, evalStateT, get, modify, lift)
+import Control.Monad.State (liftM)
+import Data.ByteString.Base64 (encode)
+import Data.Char (toLower, isSpace, isAscii, isControl)
+import Data.List (intersperse, intercalate, isPrefixOf, stripPrefix)
+import Data.Either (lefts, rights)
+import Network.HTTP (urlEncode)
+import Network.URI (isURI)
+import Text.XML.Light
+import qualified Text.XML.Light as X
+import qualified Text.XML.Light.Cursor as XC
+import qualified Data.ByteString.Char8 as B8
+import Control.Monad.Except (throwError, catchError)
+
+import Text.Pandoc.Logging
+import Text.Pandoc.Definition
+import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..), def)
+import Text.Pandoc.Shared (orderedListMarkers, isHeaderBlock, capitalize,
+ linesToPara)
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad, report)
+import qualified Text.Pandoc.Class as P
+
+-- | Data to be written at the end of the document:
+-- (foot)notes, URLs, references, images.
+data FbRenderState = FbRenderState
+ { footnotes :: [ (Int, String, [Content]) ] -- ^ #, ID, text
+ , imagesToFetch :: [ (String, String) ] -- ^ filename, URL or path
+ , parentListMarker :: String -- ^ list marker of the parent ordered list
+ , parentBulletLevel :: Int -- ^ nesting level of the unordered list
+ , writerOptions :: WriterOptions
+ } deriving (Show)
+
+-- | FictionBook building monad.
+type FBM m = StateT FbRenderState m
+
+newFB :: FbRenderState
+newFB = FbRenderState { footnotes = [], imagesToFetch = []
+ , parentListMarker = "", parentBulletLevel = 0
+ , writerOptions = def }
+
+data ImageMode = NormalImage | InlineImage deriving (Eq)
+instance Show ImageMode where
+ show NormalImage = "imageType"
+ show InlineImage = "inlineImageType"
+
+-- | Produce an FB2 document from a 'Pandoc' document.
+writeFB2 :: PandocMonad m
+ => WriterOptions -- ^ conversion options
+ -> Pandoc -- ^ document to convert
+ -> m String -- ^ FictionBook2 document (not encoded yet)
+writeFB2 opts doc = flip evalStateT newFB $ pandocToFB2 opts doc
+
+pandocToFB2 :: PandocMonad m
+ => WriterOptions
+ -> Pandoc
+ -> FBM m String
+pandocToFB2 opts (Pandoc meta blocks) = do
+ modify (\s -> s { writerOptions = opts })
+ desc <- description meta
+ fp <- frontpage meta
+ secs <- renderSections 1 blocks
+ let body = el "body" $ fp ++ secs
+ notes <- renderFootnotes
+ (imgs,missing) <- liftM imagesToFetch get >>= \s -> lift (fetchImages s)
+ let body' = replaceImagesWithAlt missing body
+ let fb2_xml = el "FictionBook" (fb2_attrs, [desc, body'] ++ notes ++ imgs)
+ return $ xml_head ++ (showContent fb2_xml) ++ "\n"
+ where
+ xml_head = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ fb2_attrs =
+ let xmlns = "http://www.gribuser.ru/xml/fictionbook/2.0"
+ xlink = "http://www.w3.org/1999/xlink"
+ in [ uattr "xmlns" xmlns
+ , attr ("xmlns", "l") xlink ]
+
+frontpage :: PandocMonad m => Meta -> FBM m [Content]
+frontpage meta' = do
+ t <- cMapM toXml . docTitle $ meta'
+ return $
+ [ el "title" (el "p" t)
+ , el "annotation" (map (el "p" . cMap plain)
+ (docAuthors meta' ++ [docDate meta']))
+ ]
+
+description :: PandocMonad m => Meta -> FBM m Content
+description meta' = do
+ bt <- booktitle meta'
+ let as = authors meta'
+ dd <- docdate meta'
+ return $ el "description"
+ [ el "title-info" (bt ++ as ++ dd)
+ , el "document-info" [ el "program-used" "pandoc" ] -- FIXME: +version
+ ]
+
+booktitle :: PandocMonad m => Meta -> FBM m [Content]
+booktitle meta' = do
+ t <- cMapM toXml . docTitle $ meta'
+ return $ if null t
+ then []
+ else [ el "book-title" t ]
+
+authors :: Meta -> [Content]
+authors meta' = cMap author (docAuthors meta')
+
+author :: [Inline] -> [Content]
+author ss =
+ let ws = words . cMap plain $ ss
+ email = (el "email") `fmap` (take 1 $ filter ('@' `elem`) ws)
+ ws' = filter ('@' `notElem`) ws
+ names = case ws' of
+ (nickname:[]) -> [ el "nickname" nickname ]
+ (fname:lname:[]) -> [ el "first-name" fname
+ , el "last-name" lname ]
+ (fname:rest) -> [ el "first-name" fname
+ , el "middle-name" (concat . init $ rest)
+ , el "last-name" (last rest) ]
+ ([]) -> []
+ in list $ el "author" (names ++ email)
+
+docdate :: PandocMonad m => Meta -> FBM m [Content]
+docdate meta' = do
+ let ss = docDate meta'
+ d <- cMapM toXml ss
+ return $ if null d
+ then []
+ else [el "date" d]
+
+-- | Divide the stream of blocks into sections and convert to XML
+-- representation.
+renderSections :: PandocMonad m => Int -> [Block] -> FBM m [Content]
+renderSections level blocks = do
+ let secs = splitSections level blocks
+ mapM (renderSection level) secs
+
+renderSection :: PandocMonad m => Int -> ([Inline], [Block]) -> FBM m Content
+renderSection level (ttl, body) = do
+ title <- if null ttl
+ then return []
+ else return . list . el "title" . formatTitle $ ttl
+ content <- if (hasSubsections body)
+ then renderSections (level + 1) body
+ else cMapM blockToXml body
+ return $ el "section" (title ++ content)
+ where
+ hasSubsections = any isHeaderBlock
+
+-- | Only <p> and <empty-line> are allowed within <title> in FB2.
+formatTitle :: [Inline] -> [Content]
+formatTitle inlines =
+ let lns = split isLineBreak inlines
+ lns' = map (el "p" . cMap plain) lns
+ in intersperse (el "empty-line" ()) lns'
+
+split :: (a -> Bool) -> [a] -> [[a]]
+split _ [] = []
+split cond xs = let (b,a) = break cond xs
+ in (b:split cond (drop 1 a))
+
+isLineBreak :: Inline -> Bool
+isLineBreak LineBreak = True
+isLineBreak _ = False
+
+-- | Divide the stream of block elements into sections: [(title, blocks)].
+splitSections :: Int -> [Block] -> [([Inline], [Block])]
+splitSections level blocks = reverse $ revSplit (reverse blocks)
+ where
+ revSplit [] = []
+ revSplit rblocks =
+ let (lastsec, before) = break sameLevel rblocks
+ (header, prevblocks) =
+ case before of
+ ((Header n _ title):prevblocks') ->
+ if n == level
+ then (title, prevblocks')
+ else ([], before)
+ _ -> ([], before)
+ in (header, reverse lastsec) : revSplit prevblocks
+ sameLevel (Header n _ _) = n == level
+ sameLevel _ = False
+
+-- | Make another FictionBook body with footnotes.
+renderFootnotes :: PandocMonad m => FBM m [Content]
+renderFootnotes = do
+ fns <- footnotes `liftM` get
+ if null fns
+ then return [] -- no footnotes
+ else return . list $
+ el "body" ([uattr "name" "notes"], map renderFN (reverse fns))
+ where
+ renderFN (n, idstr, cs) =
+ let fn_texts = (el "title" (el "p" (show n))) : cs
+ in el "section" ([uattr "id" idstr], fn_texts)
+
+-- | Fetch images and encode them for the FictionBook XML.
+-- Return image data and a list of hrefs of the missing images.
+fetchImages :: PandocMonad m => [(String,String)] -> m ([Content],[String])
+fetchImages links = do
+ imgs <- mapM (uncurry fetchImage) links
+ return $ (rights imgs, lefts imgs)
+
+-- | Fetch image data from disk or from network and make a <binary> XML section.
+-- Return either (Left hrefOfMissingImage) or (Right xmlContent).
+fetchImage :: PandocMonad m => String -> String -> m (Either String Content)
+fetchImage href link = do
+ mbimg <-
+ case (isURI link, readDataURI link) of
+ (True, Just (mime,_,True,base64)) ->
+ let mime' = map toLower mime
+ in if mime' == "image/png" || mime' == "image/jpeg"
+ then return (Just (mime',base64))
+ else return Nothing
+ (True, Just _) -> return Nothing -- not base64-encoded
+ _ -> do
+ catchError (do (bs, mbmime) <- P.fetchItem Nothing link
+ case mbmime of
+ Nothing -> do
+ report $ CouldNotDetermineMimeType link
+ return Nothing
+ Just mime -> return $ Just (mime,
+ B8.unpack $ encode bs))
+ (\e ->
+ do report $ CouldNotFetchResource link (show e)
+ return Nothing)
+ case mbimg of
+ Just (imgtype, imgdata) -> do
+ return . Right $ el "binary"
+ ( [uattr "id" href
+ , uattr "content-type" imgtype]
+ , txt imgdata )
+ _ -> return (Left ('#':href))
+
+
+-- | Extract mime type and encoded data from the Data URI.
+readDataURI :: String -- ^ URI
+ -> Maybe (String,String,Bool,String)
+ -- ^ Maybe (mime,charset,isBase64,data)
+readDataURI uri =
+ case stripPrefix "data:" uri of
+ Nothing -> Nothing
+ Just rest ->
+ let meta = takeWhile (/= ',') rest -- without trailing ','
+ uridata = drop (length meta + 1) rest
+ parts = split (== ';') meta
+ (mime,cs,enc)=foldr upd ("text/plain","US-ASCII",False) parts
+ in Just (mime,cs,enc,uridata)
+
+ where
+ upd str m@(mime,cs,enc)
+ | isMimeType str = (str,cs,enc)
+ | Just str' <- stripPrefix "charset=" str = (mime,str',enc)
+ | str == "base64" = (mime,cs,True)
+ | otherwise = m
+
+-- Without parameters like ;charset=...; see RFC 2045, 5.1
+isMimeType :: String -> Bool
+isMimeType s =
+ case split (=='/') s of
+ [mtype,msubtype] ->
+ ((map toLower mtype) `elem` types
+ || "x-" `isPrefixOf` (map toLower mtype))
+ && all valid mtype
+ && all valid msubtype
+ _ -> False
+ where
+ types = ["text","image","audio","video","application","message","multipart"]
+ valid c = isAscii c && not (isControl c) && not (isSpace c) &&
+ c `notElem` "()<>@,;:\\\"/[]?="
+
+footnoteID :: Int -> String
+footnoteID i = "n" ++ (show i)
+
+linkID :: Int -> String
+linkID i = "l" ++ (show i)
+
+-- | Convert a block-level Pandoc's element to FictionBook XML representation.
+blockToXml :: PandocMonad m => Block -> FBM m [Content]
+blockToXml (Plain ss) = cMapM toXml ss -- FIXME: can lead to malformed FB2
+blockToXml (Para [Math DisplayMath formula]) = insertMath NormalImage formula
+-- title beginning with fig: indicates that the image is a figure
+blockToXml (Para [Image atr alt (src,'f':'i':'g':':':tit)]) =
+ insertImage NormalImage (Image atr alt (src,tit))
+blockToXml (Para ss) = liftM (list . el "p") $ cMapM toXml ss
+blockToXml (CodeBlock _ s) = return . spaceBeforeAfter .
+ map (el "p" . el "code") . lines $ s
+blockToXml b@(RawBlock _ _) = do
+ report $ BlockNotRendered b
+ return []
+blockToXml (Div _ bs) = cMapM blockToXml bs
+blockToXml (BlockQuote bs) = liftM (list . el "cite") $ cMapM blockToXml bs
+blockToXml (LineBlock lns) = blockToXml $ linesToPara lns
+blockToXml (OrderedList a bss) = do
+ state <- get
+ let pmrk = parentListMarker state
+ let markers = map ((pmrk ++ " ") ++) $ orderedListMarkers a
+ let mkitem mrk bs = do
+ modify (\s -> s { parentListMarker = mrk })
+ itemtext <- cMapM blockToXml . paraToPlain $ bs
+ modify (\s -> s { parentListMarker = pmrk }) -- old parent marker
+ return . el "p" $ [ txt mrk, txt " " ] ++ itemtext
+ mapM (uncurry mkitem) (zip markers bss)
+blockToXml (BulletList bss) = do
+ state <- get
+ let level = parentBulletLevel state
+ let pmrk = parentListMarker state
+ let prefix = replicate (length pmrk) ' '
+ let bullets = ["\x2022", "\x25e6", "*", "\x2043", "\x2023"]
+ let mrk = prefix ++ bullets !! (level `mod` (length bullets))
+ let mkitem bs = do
+ modify (\s -> s { parentBulletLevel = (level+1) })
+ itemtext <- cMapM blockToXml . paraToPlain $ bs
+ modify (\s -> s { parentBulletLevel = level }) -- restore bullet level
+ return $ el "p" $ [ txt (mrk ++ " ") ] ++ itemtext
+ mapM mkitem bss
+blockToXml (DefinitionList defs) =
+ cMapM mkdef defs
+ where
+ mkdef (term, bss) = do
+ def' <- cMapM (cMapM blockToXml . sep . paraToPlain . map indent) bss
+ t <- wrap "strong" term
+ return [ el "p" t, el "p" def' ]
+ sep blocks =
+ if all needsBreak blocks then
+ blocks ++ [Plain [LineBreak]]
+ else
+ blocks
+ needsBreak (Para _) = False
+ needsBreak (Plain ins) = LineBreak `notElem` ins
+ needsBreak _ = True
+blockToXml (Header _ _ _) = -- should never happen, see renderSections
+ throwError $ PandocShouldNeverHappenError "unexpected header in section text"
+blockToXml HorizontalRule = return
+ [ el "empty-line" ()
+ , el "p" (txt (replicate 10 '—'))
+ , el "empty-line" () ]
+blockToXml (Table caption aligns _ headers rows) = do
+ hd <- mkrow "th" headers aligns
+ bd <- mapM (\r -> mkrow "td" r aligns) rows
+ c <- return . el "emphasis" =<< cMapM toXml caption
+ return [el "table" (hd : bd), el "p" c]
+ where
+ mkrow :: PandocMonad m => String -> [TableCell] -> [Alignment] -> FBM m Content
+ mkrow tag cells aligns' =
+ (el "tr") `liftM` (mapM (mkcell tag) (zip cells aligns'))
+ --
+ mkcell :: PandocMonad m => String -> (TableCell, Alignment) -> FBM m Content
+ mkcell tag (cell, align) = do
+ cblocks <- cMapM blockToXml cell
+ return $ el tag ([align_attr align], cblocks)
+ --
+ align_attr a = Attr (QName "align" Nothing Nothing) (align_str a)
+ align_str AlignLeft = "left"
+ align_str AlignCenter = "center"
+ align_str AlignRight = "right"
+ align_str AlignDefault = "left"
+blockToXml Null = return []
+
+-- Replace paragraphs with plain text and line break.
+-- Necessary to simulate multi-paragraph lists in FB2.
+paraToPlain :: [Block] -> [Block]
+paraToPlain [] = []
+paraToPlain (Para inlines : rest) =
+ let p = (Plain (inlines ++ [LineBreak]))
+ in p : paraToPlain rest
+paraToPlain (p:rest) = p : paraToPlain rest
+
+-- Simulate increased indentation level. Will not really work
+-- for multi-line paragraphs.
+indent :: Block -> Block
+indent = indentBlock
+ where
+ -- indentation space
+ spacer :: String
+ spacer = replicate 4 ' '
+ --
+ indentBlock (Plain ins) = Plain ((Str spacer):ins)
+ indentBlock (Para ins) = Para ((Str spacer):ins)
+ indentBlock (CodeBlock a s) =
+ let s' = unlines . map (spacer++) . lines $ s
+ in CodeBlock a s'
+ indentBlock (BlockQuote bs) = BlockQuote (map indent bs)
+ indentBlock (Header l attr' ins) = Header l attr' (indentLines ins)
+ indentBlock everythingElse = everythingElse
+ -- indent every (explicit) line
+ indentLines :: [Inline] -> [Inline]
+ indentLines ins = let lns = split isLineBreak ins :: [[Inline]]
+ in intercalate [LineBreak] $ map ((Str spacer):) lns
+
+-- | Convert a Pandoc's Inline element to FictionBook XML representation.
+toXml :: PandocMonad m => Inline -> FBM m [Content]
+toXml (Str s) = return [txt s]
+toXml (Span _ ils) = cMapM toXml ils
+toXml (Emph ss) = list `liftM` wrap "emphasis" ss
+toXml (Strong ss) = list `liftM` wrap "strong" ss
+toXml (Strikeout ss) = list `liftM` wrap "strikethrough" ss
+toXml (Superscript ss) = list `liftM` wrap "sup" ss
+toXml (Subscript ss) = list `liftM` wrap "sub" ss
+toXml (SmallCaps ss) = cMapM toXml $ capitalize ss
+toXml (Quoted SingleQuote ss) = do -- FIXME: should be language-specific
+ inner <- cMapM toXml ss
+ return $ [txt "‘"] ++ inner ++ [txt "’"]
+toXml (Quoted DoubleQuote ss) = do
+ inner <- cMapM toXml ss
+ return $ [txt "“"] ++ inner ++ [txt "”"]
+toXml (Cite _ ss) = cMapM toXml ss -- FIXME: support citation styles
+toXml (Code _ s) = return [el "code" s]
+toXml Space = return [txt " "]
+toXml SoftBreak = return [txt " "]
+toXml LineBreak = return [el "empty-line" ()]
+toXml (Math _ formula) = insertMath InlineImage formula
+toXml il@(RawInline _ _) = do
+ report $ InlineNotRendered il
+ return [] -- raw TeX and raw HTML are suppressed
+toXml (Link _ text (url,ttl)) = do
+ fns <- footnotes `liftM` get
+ let n = 1 + length fns
+ let ln_id = linkID n
+ let ln_ref = list . el "sup" . txt $ "[" ++ show n ++ "]"
+ ln_text <- cMapM toXml text
+ let ln_desc =
+ let ttl' = dropWhile isSpace ttl
+ in if null ttl'
+ then list . el "p" $ el "code" url
+ else list . el "p" $ [ txt (ttl' ++ ": "), el "code" url ]
+ modify (\s -> s { footnotes = (n, ln_id, ln_desc) : fns })
+ return $ ln_text ++
+ [ el "a"
+ ( [ attr ("l","href") ('#':ln_id)
+ , uattr "type" "note" ]
+ , ln_ref) ]
+toXml img@(Image _ _ _) = insertImage InlineImage img
+toXml (Note bs) = do
+ fns <- footnotes `liftM` get
+ let n = 1 + length fns
+ let fn_id = footnoteID n
+ fn_desc <- cMapM blockToXml bs
+ modify (\s -> s { footnotes = (n, fn_id, fn_desc) : fns })
+ let fn_ref = el "sup" . txt $ "[" ++ show n ++ "]"
+ return . list $ el "a" ( [ attr ("l","href") ('#':fn_id)
+ , uattr "type" "note" ]
+ , fn_ref )
+
+insertMath :: PandocMonad m => ImageMode -> String -> FBM m [Content]
+insertMath immode formula = do
+ htmlMath <- return . writerHTMLMathMethod . writerOptions =<< get
+ case htmlMath of
+ WebTeX url -> do
+ let alt = [Code nullAttr formula]
+ let imgurl = url ++ urlEncode formula
+ let img = Image nullAttr alt (imgurl, "")
+ insertImage immode img
+ _ -> return [el "code" formula]
+
+insertImage :: PandocMonad m => ImageMode -> Inline -> FBM m [Content]
+insertImage immode (Image _ alt (url,ttl)) = do
+ images <- imagesToFetch `liftM` get
+ let n = 1 + length images
+ let fname = "image" ++ show n
+ modify (\s -> s { imagesToFetch = (fname, url) : images })
+ let ttlattr = case (immode, null ttl) of
+ (NormalImage, False) -> [ uattr "title" ttl ]
+ _ -> []
+ return . list $
+ el "image" $
+ [ attr ("l","href") ('#':fname)
+ , attr ("l","type") (show immode)
+ , uattr "alt" (cMap plain alt) ]
+ ++ ttlattr
+insertImage _ _ = error "unexpected inline instead of image"
+
+replaceImagesWithAlt :: [String] -> Content -> Content
+replaceImagesWithAlt missingHrefs body =
+ let cur = XC.fromContent body
+ cur' = replaceAll cur
+ in XC.toTree . XC.root $ cur'
+ where
+ --
+ replaceAll :: XC.Cursor -> XC.Cursor
+ replaceAll c =
+ let n = XC.current c
+ c' = if isImage n && isMissing n
+ then XC.modifyContent replaceNode c
+ else c
+ in case XC.nextDF c' of
+ (Just cnext) -> replaceAll cnext
+ Nothing -> c' -- end of document
+ --
+ isImage :: Content -> Bool
+ isImage (Elem e) = (elName e) == (uname "image")
+ isImage _ = False
+ --
+ isMissing (Elem img@(Element _ _ _ _)) =
+ let imgAttrs = elAttribs img
+ badAttrs = map (attr ("l","href")) missingHrefs
+ in any (`elem` imgAttrs) badAttrs
+ isMissing _ = False
+ --
+ replaceNode :: Content -> Content
+ replaceNode n@(Elem img@(Element _ _ _ _)) =
+ let attrs = elAttribs img
+ alt = getAttrVal attrs (uname "alt")
+ imtype = getAttrVal attrs (qname "l" "type")
+ in case (alt, imtype) of
+ (Just alt', Just imtype') ->
+ if imtype' == show NormalImage
+ then el "p" alt'
+ else txt alt'
+ (Just alt', Nothing) -> txt alt' -- no type attribute
+ _ -> n -- don't replace if alt text is not found
+ replaceNode n = n
+ --
+ getAttrVal :: [X.Attr] -> QName -> Maybe String
+ getAttrVal attrs name =
+ case filter ((name ==) . attrKey) attrs of
+ (a:_) -> Just (attrVal a)
+ _ -> Nothing
+
+
+-- | Wrap all inlines with an XML tag (given its unqualified name).
+wrap :: PandocMonad m => String -> [Inline] -> FBM m Content
+wrap tagname inlines = el tagname `liftM` cMapM toXml inlines
+
+-- " Create a singleton list.
+list :: a -> [a]
+list = (:[])
+
+-- | Convert an 'Inline' to plaintext.
+plain :: Inline -> String
+plain (Str s) = s
+plain (Emph ss) = concat (map plain ss)
+plain (Span _ ss) = concat (map plain ss)
+plain (Strong ss) = concat (map plain ss)
+plain (Strikeout ss) = concat (map plain ss)
+plain (Superscript ss) = concat (map plain ss)
+plain (Subscript ss) = concat (map plain ss)
+plain (SmallCaps ss) = concat (map plain ss)
+plain (Quoted _ ss) = concat (map plain ss)
+plain (Cite _ ss) = concat (map plain ss) -- FIXME
+plain (Code _ s) = s
+plain Space = " "
+plain SoftBreak = " "
+plain LineBreak = "\n"
+plain (Math _ s) = s
+plain (RawInline _ _) = ""
+plain (Link _ text (url,_)) = concat (map plain text ++ [" <", url, ">"])
+plain (Image _ alt _) = concat (map plain alt)
+plain (Note _) = "" -- FIXME
+
+-- | Create an XML element.
+el :: (Node t)
+ => String -- ^ unqualified element name
+ -> t -- ^ node contents
+ -> Content -- ^ XML content
+el name cs = Elem $ unode name cs
+
+-- | Put empty lines around content
+spaceBeforeAfter :: [Content] -> [Content]
+spaceBeforeAfter cs =
+ let emptyline = el "empty-line" ()
+ in [emptyline] ++ cs ++ [emptyline]
+
+-- | Create a plain-text XML content.
+txt :: String -> Content
+txt s = Text $ CData CDataText s Nothing
+
+-- | Create an XML attribute with an unqualified name.
+uattr :: String -> String -> Text.XML.Light.Attr
+uattr name val = Attr (uname name) val
+
+-- | Create an XML attribute with a qualified name from given namespace.
+attr :: (String, String) -> String -> Text.XML.Light.Attr
+attr (ns, name) val = Attr (qname ns name) val
+
+-- | Unqualified name
+uname :: String -> QName
+uname name = QName name Nothing Nothing
+
+-- | Qualified name
+qname :: String -> String -> QName
+qname ns name = QName name Nothing (Just ns)
+
+-- | Abbreviation for 'concatMap'.
+cMap :: (a -> [b]) -> [a] -> [b]
+cMap = concatMap
+
+-- | Monadic equivalent of 'concatMap'.
+cMapM :: (Monad m) => (a -> m [b]) -> [a] -> m [b]
+cMapM f xs = concat `liftM` mapM f xs
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
new file mode 100644
index 000000000..99f8c5b42
--- /dev/null
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -0,0 +1,1069 @@
+{-# LANGUAGE OverloadedStrings, CPP, ViewPatterns, ScopedTypeVariables #-}
+{-
+Copyright (C) 2006-2015 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.HTML
+ Copyright : Copyright (C) 2006-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to HTML.
+-}
+module Text.Pandoc.Writers.HTML (
+ writeHtml4,
+ writeHtml4String,
+ writeHtml5,
+ writeHtml5String,
+ writeHtmlStringForEPUB,
+ writeS5,
+ writeSlidy,
+ writeSlideous,
+ writeDZSlides,
+ writeRevealJs
+ ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Walk
+import Data.Monoid ((<>))
+import Text.Pandoc.Shared
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Options
+import Text.Pandoc.ImageSize
+import Text.Pandoc.Templates
+import Text.Pandoc.Writers.Math
+import Text.Pandoc.Slides
+import Text.Pandoc.Highlighting ( highlight, styleToCss,
+ formatHtmlInline, formatHtmlBlock )
+import Text.Pandoc.XML (fromEntities, escapeStringForXML)
+import Network.URI ( parseURIReference, URI(..), unEscapeString )
+import Network.HTTP ( urlEncode )
+import Numeric ( showHex )
+import Data.Char ( ord, toLower )
+import Data.List ( isPrefixOf, intersperse )
+import Data.String ( fromString )
+import Data.Maybe ( catMaybes, fromMaybe, isJust )
+import Control.Monad.State
+import Text.Blaze.Html hiding(contents)
+#if MIN_VERSION_blaze_markup(0,6,3)
+#else
+import Text.Blaze.Internal(preEscapedString)
+#endif
+#if MIN_VERSION_blaze_html(0,5,1)
+import qualified Text.Blaze.XHtml5 as H5
+#else
+import qualified Text.Blaze.Html5 as H5
+#endif
+import qualified Text.Blaze.XHtml1.Transitional as H
+import qualified Text.Blaze.XHtml1.Transitional.Attributes as A
+import Text.Blaze.Html.Renderer.String (renderHtml)
+import Text.TeXMath
+import Text.XML.Light.Output
+import Text.XML.Light (unode, elChildren, unqual)
+import qualified Text.XML.Light as XML
+import System.FilePath (takeExtension)
+import Data.Aeson (Value)
+import Control.Monad.Except (throwError)
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad, report)
+import Text.Pandoc.Logging
+
+data WriterState = WriterState
+ { stNotes :: [Html] -- ^ List of notes
+ , stMath :: Bool -- ^ Math is used in document
+ , stQuotes :: Bool -- ^ <q> tag is used
+ , stHighlighting :: Bool -- ^ Syntax highlighting is used
+ , stSecNum :: [Int] -- ^ Number of current section
+ , stElement :: Bool -- ^ Processing an Element
+ , stHtml5 :: Bool -- ^ Use HTML5
+ , stEPUBVersion :: Maybe EPUBVersion -- ^ EPUB version if for epub
+ , stSlideVariant :: HTMLSlideVariant
+ }
+
+defaultWriterState :: WriterState
+defaultWriterState = WriterState {stNotes= [], stMath = False, stQuotes = False,
+ stHighlighting = False, stSecNum = [],
+ stElement = False, stHtml5 = False,
+ stEPUBVersion = Nothing,
+ stSlideVariant = NoSlides}
+
+-- Helpers to render HTML with the appropriate function.
+
+strToHtml :: String -> Html
+strToHtml ('\'':xs) = preEscapedString "\'" `mappend` strToHtml xs
+strToHtml xs@(_:_) = case break (=='\'') xs of
+ (_ ,[]) -> toHtml xs
+ (ys,zs) -> toHtml ys `mappend` strToHtml zs
+strToHtml [] = ""
+
+-- | Hard linebreak.
+nl :: WriterOptions -> Html
+nl opts = if writerWrapText opts == WrapNone
+ then mempty
+ else preEscapedString "\n"
+
+-- | Convert Pandoc document to Html 5 string.
+writeHtml5String :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeHtml5String = writeHtmlString'
+ defaultWriterState{ stHtml5 = True }
+
+-- | Convert Pandoc document to Html 5 structure.
+writeHtml5 :: PandocMonad m => WriterOptions -> Pandoc -> m Html
+writeHtml5 = writeHtml' defaultWriterState{ stHtml5 = True }
+
+-- | Convert Pandoc document to Html 4 string.
+writeHtml4String :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeHtml4String = writeHtmlString'
+ defaultWriterState{ stHtml5 = False }
+
+-- | Convert Pandoc document to Html 4 structure.
+writeHtml4 :: PandocMonad m => WriterOptions -> Pandoc -> m Html
+writeHtml4 = writeHtml' defaultWriterState{ stHtml5 = False }
+
+-- | Convert Pandoc document to Html appropriate for an epub version.
+writeHtmlStringForEPUB :: PandocMonad m
+ => EPUBVersion -> WriterOptions -> Pandoc -> m String
+writeHtmlStringForEPUB version = writeHtmlString'
+ defaultWriterState{ stHtml5 = version == EPUB3,
+ stEPUBVersion = Just version }
+
+-- | Convert Pandoc document to Reveal JS HTML slide show.
+writeRevealJs :: PandocMonad m
+ => WriterOptions -> Pandoc -> m String
+writeRevealJs = writeHtmlSlideShow' RevealJsSlides
+
+-- | Convert Pandoc document to S5 HTML slide show.
+writeS5 :: PandocMonad m
+ => WriterOptions -> Pandoc -> m String
+writeS5 = writeHtmlSlideShow' S5Slides
+
+-- | Convert Pandoc document to Slidy HTML slide show.
+writeSlidy :: PandocMonad m
+ => WriterOptions -> Pandoc -> m String
+writeSlidy = writeHtmlSlideShow' SlidySlides
+
+-- | Convert Pandoc document to Slideous HTML slide show.
+writeSlideous :: PandocMonad m
+ => WriterOptions -> Pandoc -> m String
+writeSlideous = writeHtmlSlideShow' SlideousSlides
+
+-- | Convert Pandoc document to DZSlides HTML slide show.
+writeDZSlides :: PandocMonad m
+ => WriterOptions -> Pandoc -> m String
+writeDZSlides = writeHtmlSlideShow' DZSlides
+
+writeHtmlSlideShow' :: PandocMonad m
+ => HTMLSlideVariant -> WriterOptions -> Pandoc -> m String
+writeHtmlSlideShow' variant = writeHtmlString'
+ defaultWriterState{ stSlideVariant = variant
+ , stHtml5 = case variant of
+ RevealJsSlides -> True
+ S5Slides -> False
+ SlidySlides -> False
+ DZSlides -> True
+ SlideousSlides -> False
+ NoSlides -> False
+ }
+
+writeHtmlString' :: PandocMonad m
+ => WriterState -> WriterOptions -> Pandoc -> m String
+writeHtmlString' st opts d = do
+ (body, context) <- evalStateT (pandocToHtml opts d) st
+ return $ case writerTemplate opts of
+ Nothing -> renderHtml body
+ Just tpl -> renderTemplate' tpl $
+ defField "body" (renderHtml body) context
+
+writeHtml' :: PandocMonad m => WriterState -> WriterOptions -> Pandoc -> m Html
+writeHtml' st opts d = do
+ (body, context) <- evalStateT (pandocToHtml opts d) st
+ return $ case writerTemplate opts of
+ Nothing -> body
+ Just tpl -> renderTemplate' tpl $
+ defField "body" (renderHtml body) context
+
+-- result is (title, authors, date, toc, body, new variables)
+pandocToHtml :: PandocMonad m
+ => WriterOptions
+ -> Pandoc
+ -> StateT WriterState m (Html, Value)
+pandocToHtml opts (Pandoc meta blocks) = do
+ metadata <- metaToJSON opts
+ (fmap renderHtml . blockListToHtml opts)
+ (fmap renderHtml . inlineListToHtml opts)
+ meta
+ let stringifyHTML = escapeStringForXML . stringify
+ let authsMeta = map stringifyHTML $ docAuthors meta
+ let dateMeta = stringifyHTML $ docDate meta
+ let slideLevel = fromMaybe (getSlideLevel blocks) $ writerSlideLevel opts
+ slideVariant <- gets stSlideVariant
+ let sects = hierarchicalize $
+ if slideVariant == NoSlides
+ then blocks
+ else prepSlides slideLevel blocks
+ toc <- if writerTableOfContents opts && slideVariant /= S5Slides
+ then tableOfContents opts sects
+ else return Nothing
+ blocks' <- liftM (mconcat . intersperse (nl opts)) $
+ mapM (elementToHtml slideLevel opts) sects
+ st <- get
+ notes <- footnoteSection opts (reverse (stNotes st))
+ let thebody = blocks' >> notes
+ let math = case writerHTMLMathMethod opts of
+ LaTeXMathML (Just url) ->
+ H.script ! A.src (toValue url)
+ ! A.type_ "text/javascript"
+ $ mempty
+ MathJax url ->
+ H.script ! A.src (toValue url)
+ ! A.type_ "text/javascript"
+ $ case slideVariant of
+ SlideousSlides ->
+ preEscapedString
+ "MathJax.Hub.Queue([\"Typeset\",MathJax.Hub]);"
+ _ -> mempty
+ JsMath (Just url) ->
+ H.script ! A.src (toValue url)
+ ! A.type_ "text/javascript"
+ $ mempty
+ KaTeX js css ->
+ (H.script ! A.src (toValue js) $ mempty) <>
+ (H.link ! A.rel "stylesheet" ! A.href (toValue css)) <>
+ (H.script ! A.type_ "text/javascript" $ toHtml renderKaTeX)
+ _ -> case lookup "mathml-script" (writerVariables opts) of
+ Just s | not (stHtml5 st) ->
+ H.script ! A.type_ "text/javascript"
+ $ preEscapedString
+ ("/*<![CDATA[*/\n" ++ s ++ "/*]]>*/\n")
+ | otherwise -> mempty
+ Nothing -> mempty
+ let context = (if stHighlighting st
+ then case writerHighlightStyle opts of
+ Just sty -> defField "highlighting-css"
+ (styleToCss sty)
+ Nothing -> id
+ else id) $
+ (if stMath st
+ then defField "math" (renderHtml math)
+ else id) $
+ defField "quotes" (stQuotes st) $
+ maybe id (defField "toc" . renderHtml) toc $
+ defField "author-meta" authsMeta $
+ maybe id (defField "date-meta") (normalizeDate dateMeta) $
+ defField "pagetitle" (stringifyHTML $ docTitle meta) $
+ defField "idprefix" (writerIdentifierPrefix opts) $
+ -- these should maybe be set in pandoc.hs
+ defField "slidy-url"
+ ("http://www.w3.org/Talks/Tools/Slidy2" :: String) $
+ defField "slideous-url" ("slideous" :: String) $
+ defField "revealjs-url" ("reveal.js" :: String) $
+ defField "s5-url" ("s5/default" :: String) $
+ defField "html5" (stHtml5 st) $
+ metadata
+ return (thebody, context)
+
+-- | Like Text.XHtml's identifier, but adds the writerIdentifierPrefix
+prefixedId :: WriterOptions -> String -> Attribute
+prefixedId opts s =
+ case s of
+ "" -> mempty
+ _ -> A.id $ toValue $ writerIdentifierPrefix opts ++ s
+
+toList :: PandocMonad m
+ => (Html -> Html)
+ -> WriterOptions
+ -> [Html]
+ -> StateT WriterState m Html
+toList listop opts items = do
+ slideVariant <- gets stSlideVariant
+ return $
+ if (writerIncremental opts)
+ then if (slideVariant /= RevealJsSlides)
+ then (listop $ mconcat items) ! A.class_ "incremental"
+ else listop $ mconcat $ map (! A.class_ "fragment") items
+ else listop $ mconcat items
+
+unordList :: PandocMonad m
+ => WriterOptions -> [Html] -> StateT WriterState m Html
+unordList opts = toList H.ul opts . toListItems opts
+
+ordList :: PandocMonad m
+ => WriterOptions -> [Html] -> StateT WriterState m Html
+ordList opts = toList H.ol opts . toListItems opts
+
+defList :: PandocMonad m
+ => WriterOptions -> [Html] -> StateT WriterState m Html
+defList opts items = toList H.dl opts (items ++ [nl opts])
+
+-- | Construct table of contents from list of elements.
+tableOfContents :: PandocMonad m => WriterOptions -> [Element] -> StateT WriterState m (Maybe Html)
+tableOfContents _ [] = return Nothing
+tableOfContents opts sects = do
+ contents <- mapM (elementToListItem opts) sects
+ let tocList = catMaybes contents
+ if null tocList
+ then return Nothing
+ else Just <$> unordList opts tocList
+
+-- | Convert section number to string
+showSecNum :: [Int] -> String
+showSecNum = concat . intersperse "." . map show
+
+-- | Converts an Element to a list item for a table of contents,
+-- retrieving the appropriate identifier from state.
+elementToListItem :: PandocMonad m => WriterOptions -> Element -> StateT WriterState m (Maybe Html)
+-- Don't include the empty headers created in slide shows
+-- shows when an hrule is used to separate slides without a new title:
+elementToListItem _ (Sec _ _ _ [Str "\0"] _) = return Nothing
+elementToListItem opts (Sec lev num (id',classes,_) headerText subsecs)
+ | lev <= writerTOCDepth opts = do
+ let num' = zipWith (+) num (writerNumberOffset opts ++ repeat 0)
+ let sectnum = if writerNumberSections opts && not (null num) &&
+ "unnumbered" `notElem` classes
+ then (H.span ! A.class_ "toc-section-number"
+ $ toHtml $ showSecNum num') >> preEscapedString " "
+ else mempty
+ txt <- liftM (sectnum >>) $ inlineListToHtml opts $ walk deNote headerText
+ subHeads <- mapM (elementToListItem opts) subsecs >>= return . catMaybes
+ subList <- if null subHeads
+ then return mempty
+ else unordList opts subHeads
+ -- in reveal.js, we need #/apples, not #apples:
+ slideVariant <- gets stSlideVariant
+ let revealSlash = ['/' | slideVariant== RevealJsSlides]
+ return $ Just
+ $ if null id'
+ then (H.a $ toHtml txt) >> subList
+ else (H.a ! A.href (toValue $ "#" ++ revealSlash ++
+ writerIdentifierPrefix opts ++ id')
+ $ toHtml txt) >> subList
+elementToListItem _ _ = return Nothing
+
+-- | Convert an Element to Html.
+elementToHtml :: PandocMonad m => Int -> WriterOptions -> Element -> StateT WriterState m Html
+elementToHtml _slideLevel opts (Blk block) = blockToHtml opts block
+elementToHtml slideLevel opts (Sec level num (id',classes,keyvals) title' elements) = do
+ slideVariant <- gets stSlideVariant
+ let slide = slideVariant /= NoSlides && level <= slideLevel
+ let num' = zipWith (+) num (writerNumberOffset opts ++ repeat 0)
+ modify $ \st -> st{stSecNum = num'} -- update section number
+ html5 <- gets stHtml5
+ let titleSlide = slide && level < slideLevel
+ header' <- if title' == [Str "\0"] -- marker for hrule
+ then return mempty
+ else do
+ modify (\st -> st{ stElement = True})
+ res <- blockToHtml opts
+ (Header level (id',classes,keyvals) title')
+ modify (\st -> st{ stElement = False})
+ return res
+
+ let isSec (Sec _ _ _ _ _) = True
+ isSec (Blk _) = False
+ let isPause (Blk x) = x == Para [Str ".",Space,Str ".",Space,Str "."]
+ isPause _ = False
+ let fragmentClass = case slideVariant of
+ RevealJsSlides -> "fragment"
+ _ -> "incremental"
+ let inDiv xs = Blk (RawBlock (Format "html") ("<div class=\""
+ ++ fragmentClass ++ "\">")) :
+ (xs ++ [Blk (RawBlock (Format "html") "</div>")])
+ innerContents <- mapM (elementToHtml slideLevel opts)
+ $ if titleSlide
+ -- title slides have no content of their own
+ then filter isSec elements
+ else case splitBy isPause elements of
+ [] -> []
+ (x:xs) -> x ++ concatMap inDiv xs
+ let inNl x = mconcat $ nl opts : intersperse (nl opts) x ++ [nl opts]
+ let classes' = ["titleslide" | titleSlide] ++ ["slide" | slide] ++
+ ["section" | (slide || writerSectionDivs opts) &&
+ not html5 ] ++
+ ["level" ++ show level | slide || writerSectionDivs opts ]
+ ++ classes
+ let secttag = if html5
+ then H5.section
+ else H.div
+ let attr = (id',classes',keyvals)
+ return $ if titleSlide
+ then (if slideVariant == RevealJsSlides
+ then H5.section
+ else id) $ mconcat $
+ (addAttrs opts attr $ secttag $ header') : innerContents
+ else if writerSectionDivs opts || slide
+ then addAttrs opts attr
+ $ secttag $ inNl $ header' : innerContents
+ else mconcat $ intersperse (nl opts)
+ $ addAttrs opts attr header' : innerContents
+
+-- | Convert list of Note blocks to a footnote <div>.
+-- Assumes notes are sorted.
+footnoteSection :: PandocMonad m
+ => WriterOptions -> [Html] -> StateT WriterState m Html
+footnoteSection opts notes = do
+ html5 <- gets stHtml5
+ slideVariant <- gets stSlideVariant
+ let hrtag = if html5 then H5.hr else H.hr
+ let container x = if html5
+ then H5.section ! A.class_ "footnotes" $ x
+ else if slideVariant /= NoSlides
+ then H.div ! A.class_ "footnotes slide" $ x
+ else H.div ! A.class_ "footnotes" $ x
+ return $
+ if null notes
+ then mempty
+ else nl opts >> (container
+ $ nl opts >> hrtag >> nl opts >>
+ H.ol (mconcat notes >> nl opts) >> nl opts)
+
+-- | Parse a mailto link; return Just (name, domain) or Nothing.
+parseMailto :: String -> Maybe (String, String)
+parseMailto s = do
+ case break (==':') s of
+ (xs,':':addr) | map toLower xs == "mailto" -> do
+ let (name', rest) = span (/='@') addr
+ let domain = drop 1 rest
+ return (name', domain)
+ _ -> fail "not a mailto: URL"
+
+-- | Obfuscate a "mailto:" link.
+obfuscateLink :: PandocMonad m => WriterOptions -> Attr -> Html -> String -> m Html
+obfuscateLink opts attr txt s | writerEmailObfuscation opts == NoObfuscation =
+ return $ addAttrs opts attr $ H.a ! A.href (toValue s) $ txt
+obfuscateLink opts attr (renderHtml -> txt) s =
+ let meth = writerEmailObfuscation opts
+ s' = map toLower (take 7 s) ++ drop 7 s
+ in case parseMailto s' of
+ (Just (name', domain)) ->
+ let domain' = substitute "." " dot " domain
+ at' = obfuscateChar '@'
+ (linkText, altText) =
+ if txt == drop 7 s' -- autolink
+ then ("e", name' ++ " at " ++ domain')
+ else ("'" ++ obfuscateString txt ++ "'",
+ txt ++ " (" ++ name' ++ " at " ++ domain' ++ ")")
+ in case meth of
+ ReferenceObfuscation ->
+ -- need to use preEscapedString or &'s are escaped to &amp; in URL
+ return $
+ preEscapedString $ "<a href=\"" ++ (obfuscateString s')
+ ++ "\" class=\"email\">" ++ (obfuscateString txt) ++ "</a>"
+ JavascriptObfuscation ->
+ return $
+ (H.script ! A.type_ "text/javascript" $
+ preEscapedString ("\n<!--\nh='" ++
+ obfuscateString domain ++ "';a='" ++ at' ++ "';n='" ++
+ obfuscateString name' ++ "';e=n+a+h;\n" ++
+ "document.write('<a h'+'ref'+'=\"ma'+'ilto'+':'+e+'\" clas'+'s=\"em' + 'ail\">'+" ++
+ linkText ++ "+'<\\/'+'a'+'>');\n// -->\n")) >>
+ H.noscript (preEscapedString $ obfuscateString altText)
+ _ -> throwError $ PandocSomeError $ "Unknown obfuscation method: " ++ show meth
+ _ -> return $ addAttrs opts attr $ H.a ! A.href (toValue s) $ toHtml txt -- malformed email
+
+-- | Obfuscate character as entity.
+obfuscateChar :: Char -> String
+obfuscateChar char =
+ let num = ord char
+ numstr = if even num then show num else "x" ++ showHex num ""
+ in "&#" ++ numstr ++ ";"
+
+-- | Obfuscate string using entities.
+obfuscateString :: String -> String
+obfuscateString = concatMap obfuscateChar . fromEntities
+
+addAttrs :: WriterOptions -> Attr -> Html -> Html
+addAttrs opts attr h = foldl (!) h (attrsToHtml opts attr)
+
+toAttrs :: [(String, String)] -> [Attribute]
+toAttrs kvs = map (\(x,y) -> customAttribute (fromString x) (toValue y)) kvs
+
+attrsToHtml :: WriterOptions -> Attr -> [Attribute]
+attrsToHtml opts (id',classes',keyvals) =
+ [prefixedId opts id' | not (null id')] ++
+ [A.class_ (toValue $ unwords classes') | not (null classes')] ++ toAttrs keyvals
+
+imgAttrsToHtml :: WriterOptions -> Attr -> [Attribute]
+imgAttrsToHtml opts attr =
+ attrsToHtml opts (ident,cls,kvs') ++
+ toAttrs (dimensionsToAttrList opts attr)
+ where
+ (ident,cls,kvs) = attr
+ kvs' = filter isNotDim kvs
+ isNotDim ("width", _) = False
+ isNotDim ("height", _) = False
+ isNotDim _ = True
+
+dimensionsToAttrList :: WriterOptions -> Attr -> [(String, String)]
+dimensionsToAttrList opts attr = (go Width) ++ (go Height)
+ where
+ go dir = case (dimension dir attr) of
+ (Just (Percent a)) -> [("style", show dir ++ ":" ++ show (Percent a))]
+ (Just dim) -> [(show dir, showInPixel opts dim)]
+ _ -> []
+
+
+imageExts :: [String]
+imageExts = [ "art", "bmp", "cdr", "cdt", "cpt", "cr2", "crw", "djvu", "erf",
+ "gif", "ico", "ief", "jng", "jpg", "jpeg", "nef", "orf", "pat", "pbm",
+ "pcx", "pgm", "png", "pnm", "ppm", "psd", "ras", "rgb", "svg", "tiff",
+ "wbmp", "xbm", "xpm", "xwd" ]
+
+treatAsImage :: FilePath -> Bool
+treatAsImage fp =
+ let path = case uriPath `fmap` parseURIReference fp of
+ Nothing -> fp
+ Just up -> up
+ ext = map toLower $ drop 1 $ takeExtension path
+ in null ext || ext `elem` imageExts
+
+-- | Convert Pandoc block element to HTML.
+blockToHtml :: PandocMonad m => WriterOptions -> Block -> StateT WriterState m Html
+blockToHtml _ Null = return mempty
+blockToHtml opts (Plain lst) = inlineListToHtml opts lst
+-- title beginning with fig: indicates that the image is a figure
+blockToHtml opts (Para [Image attr txt (s,'f':'i':'g':':':tit)]) = do
+ img <- inlineToHtml opts (Image attr txt (s,tit))
+ html5 <- gets stHtml5
+ let tocapt = if html5
+ then H5.figcaption
+ else H.p ! A.class_ "caption"
+ capt <- if null txt
+ then return mempty
+ else tocapt `fmap` inlineListToHtml opts txt
+ return $ if html5
+ then H5.figure $ mconcat
+ [nl opts, img, capt, nl opts]
+ else H.div ! A.class_ "figure" $ mconcat
+ [nl opts, img, nl opts, capt, nl opts]
+blockToHtml opts (Para lst)
+ | isEmptyRaw lst = return mempty
+ | otherwise = do
+ contents <- inlineListToHtml opts lst
+ return $ H.p contents
+ where
+ isEmptyRaw [RawInline f _] = f /= (Format "html")
+ isEmptyRaw _ = False
+blockToHtml opts (LineBlock lns) =
+ if writerWrapText opts == WrapNone
+ then blockToHtml opts $ linesToPara lns
+ else do
+ let lf = preEscapedString "\n"
+ htmlLines <- mconcat . intersperse lf <$> mapM (inlineListToHtml opts) lns
+ return $ H.div ! A.style "white-space: pre-line;" $ htmlLines
+blockToHtml opts (Div attr@(ident, classes, kvs) bs) = do
+ html5 <- gets stHtml5
+ let speakerNotes = "notes" `elem` classes
+ -- we don't want incremental output inside speaker notes, see #1394
+ let opts' = if speakerNotes then opts{ writerIncremental = False } else opts
+ contents <- blockListToHtml opts' bs
+ let contents' = nl opts >> contents >> nl opts
+ let (divtag, classes') = if html5 && "section" `elem` classes
+ then (H5.section, filter (/= "section") classes)
+ else (H.div, classes)
+ slideVariant <- gets stSlideVariant
+ return $
+ if speakerNotes
+ then case slideVariant of
+ RevealJsSlides -> addAttrs opts' attr $ H5.aside $ contents'
+ DZSlides -> (addAttrs opts' attr $ H5.div $ contents')
+ ! (H5.customAttribute "role" "note")
+ NoSlides -> addAttrs opts' attr $ H.div $ contents'
+ _ -> mempty
+ else addAttrs opts (ident, classes', kvs) $ divtag $ contents'
+blockToHtml opts (RawBlock f str)
+ | f == Format "html" = return $ preEscapedString str
+ | (f == Format "latex" || f == Format "tex") &&
+ allowsMathEnvironments (writerHTMLMathMethod opts) &&
+ isMathEnvironment str = blockToHtml opts $ Plain [Math DisplayMath str]
+ | otherwise = do
+ report $ BlockNotRendered (RawBlock f str)
+ return mempty
+blockToHtml _ (HorizontalRule) = do
+ html5 <- gets stHtml5
+ return $ if html5 then H5.hr else H.hr
+blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do
+ let tolhs = isEnabled Ext_literate_haskell opts &&
+ any (\c -> map toLower c == "haskell") classes &&
+ any (\c -> map toLower c == "literate") classes
+ classes' = if tolhs
+ then map (\c -> if map toLower c == "haskell"
+ then "literatehaskell"
+ else c) classes
+ else classes
+ adjCode = if tolhs
+ then unlines . map ("> " ++) . lines $ rawCode
+ else rawCode
+ hlCode = if isJust (writerHighlightStyle opts)
+ then highlight formatHtmlBlock
+ (id',classes',keyvals) adjCode
+ else Nothing
+ case hlCode of
+ Nothing -> return $ addAttrs opts (id',classes,keyvals)
+ $ H.pre $ H.code $ toHtml adjCode
+ Just h -> modify (\st -> st{ stHighlighting = True }) >>
+ return (addAttrs opts (id',[],keyvals) h)
+blockToHtml opts (BlockQuote blocks) = do
+ -- in S5, treat list in blockquote specially
+ -- if default is incremental, make it nonincremental;
+ -- otherwise incremental
+ slideVariant <- gets stSlideVariant
+ if slideVariant /= NoSlides
+ then let inc = not (writerIncremental opts) in
+ case blocks of
+ [BulletList lst] -> blockToHtml (opts {writerIncremental = inc})
+ (BulletList lst)
+ [OrderedList attribs lst] ->
+ blockToHtml (opts {writerIncremental = inc})
+ (OrderedList attribs lst)
+ [DefinitionList lst] ->
+ blockToHtml (opts {writerIncremental = inc})
+ (DefinitionList lst)
+ _ -> do contents <- blockListToHtml opts blocks
+ return $ H.blockquote
+ $ nl opts >> contents >> nl opts
+ else do
+ contents <- blockListToHtml opts blocks
+ return $ H.blockquote $ nl opts >> contents >> nl opts
+blockToHtml opts (Header level attr@(_,classes,_) lst) = do
+ contents <- inlineListToHtml opts lst
+ secnum <- liftM stSecNum get
+ let contents' = if writerNumberSections opts && not (null secnum)
+ && "unnumbered" `notElem` classes
+ then (H.span ! A.class_ "header-section-number" $ toHtml
+ $ showSecNum secnum) >> strToHtml " " >> contents
+ else contents
+ inElement <- gets stElement
+ return $ (if inElement then id else addAttrs opts attr)
+ $ case level of
+ 1 -> H.h1 contents'
+ 2 -> H.h2 contents'
+ 3 -> H.h3 contents'
+ 4 -> H.h4 contents'
+ 5 -> H.h5 contents'
+ 6 -> H.h6 contents'
+ _ -> H.p contents'
+blockToHtml opts (BulletList lst) = do
+ contents <- mapM (blockListToHtml opts) lst
+ unordList opts contents
+blockToHtml opts (OrderedList (startnum, numstyle, _) lst) = do
+ contents <- mapM (blockListToHtml opts) lst
+ html5 <- gets stHtml5
+ let numstyle' = case numstyle of
+ Example -> "decimal"
+ _ -> camelCaseToHyphenated $ show numstyle
+ let attribs = (if startnum /= 1
+ then [A.start $ toValue startnum]
+ else []) ++
+ (if numstyle == Example
+ then [A.class_ "example"]
+ else []) ++
+ (if numstyle /= DefaultStyle
+ then if html5
+ then [A.type_ $
+ case numstyle of
+ Decimal -> "1"
+ LowerAlpha -> "a"
+ UpperAlpha -> "A"
+ LowerRoman -> "i"
+ UpperRoman -> "I"
+ _ -> "1"]
+ else [A.style $ toValue $ "list-style-type: " ++
+ numstyle']
+ else [])
+ l <- ordList opts contents
+ return $ foldl (!) l attribs
+blockToHtml opts (DefinitionList lst) = do
+ contents <- mapM (\(term, defs) ->
+ do term' <- if null term
+ then return mempty
+ else liftM H.dt $ inlineListToHtml opts term
+ defs' <- mapM ((liftM (\x -> H.dd $ (x >> nl opts))) .
+ blockListToHtml opts) defs
+ return $ mconcat $ nl opts : term' : nl opts :
+ intersperse (nl opts) defs') lst
+ defList opts contents
+blockToHtml opts (Table capt aligns widths headers rows') = do
+ captionDoc <- if null capt
+ then return mempty
+ else do
+ cs <- inlineListToHtml opts capt
+ return $ H.caption cs >> nl opts
+ html5 <- gets stHtml5
+ let percent w = show (truncate (100*w) :: Integer) ++ "%"
+ let coltags = if all (== 0.0) widths
+ then mempty
+ else do
+ H.colgroup $ do
+ nl opts
+ mapM_ (\w -> do
+ if html5
+ then H.col ! A.style (toValue $ "width: " ++
+ percent w)
+ else H.col ! A.width (toValue $ percent w)
+ nl opts) widths
+ nl opts
+ head' <- if all null headers
+ then return mempty
+ else do
+ contents <- tableRowToHtml opts aligns 0 headers
+ return $ H.thead (nl opts >> contents) >> nl opts
+ body' <- liftM (\x -> H.tbody (nl opts >> mconcat x)) $
+ zipWithM (tableRowToHtml opts aligns) [1..] rows'
+ let tbl = H.table $
+ nl opts >> captionDoc >> coltags >> head' >> body' >> nl opts
+ let totalWidth = sum widths
+ -- When widths of columns are < 100%, we need to set width for the whole
+ -- table, or some browsers give us skinny columns with lots of space between:
+ return $ if totalWidth == 0 || totalWidth == 1
+ then tbl
+ else tbl ! A.style (toValue $ "width:" ++
+ show (round (totalWidth * 100) :: Int) ++ "%;")
+
+tableRowToHtml :: PandocMonad m
+ => WriterOptions
+ -> [Alignment]
+ -> Int
+ -> [[Block]]
+ -> StateT WriterState m Html
+tableRowToHtml opts aligns rownum cols' = do
+ let mkcell = if rownum == 0 then H.th else H.td
+ let rowclass = case rownum of
+ 0 -> "header"
+ x | x `rem` 2 == 1 -> "odd"
+ _ -> "even"
+ cols'' <- sequence $ zipWith
+ (\alignment item -> tableItemToHtml opts mkcell alignment item)
+ aligns cols'
+ return $ (H.tr ! A.class_ rowclass $ nl opts >> mconcat cols'')
+ >> nl opts
+
+alignmentToString :: Alignment -> [Char]
+alignmentToString alignment = case alignment of
+ AlignLeft -> "left"
+ AlignRight -> "right"
+ AlignCenter -> "center"
+ AlignDefault -> ""
+
+tableItemToHtml :: PandocMonad m
+ => WriterOptions
+ -> (Html -> Html)
+ -> Alignment
+ -> [Block]
+ -> StateT WriterState m Html
+tableItemToHtml opts tag' align' item = do
+ contents <- blockListToHtml opts item
+ html5 <- gets stHtml5
+ let alignStr = alignmentToString align'
+ let attribs = if html5
+ then A.style (toValue $ "text-align: " ++ alignStr ++ ";")
+ else A.align (toValue alignStr)
+ let tag'' = if null alignStr
+ then tag'
+ else tag' ! attribs
+ return $ (tag'' $ contents) >> nl opts
+
+toListItems :: WriterOptions -> [Html] -> [Html]
+toListItems opts items = map (toListItem opts) items ++ [nl opts]
+
+toListItem :: WriterOptions -> Html -> Html
+toListItem opts item = nl opts >> H.li item
+
+blockListToHtml :: PandocMonad m => WriterOptions -> [Block] -> StateT WriterState m Html
+blockListToHtml opts lst =
+ fmap (mconcat . intersperse (nl opts)) $ mapM (blockToHtml opts) lst
+
+-- | Convert list of Pandoc inline elements to HTML.
+inlineListToHtml :: PandocMonad m => WriterOptions -> [Inline] -> StateT WriterState m Html
+inlineListToHtml opts lst =
+ mapM (inlineToHtml opts) lst >>= return . mconcat
+
+-- | Annotates a MathML expression with the tex source
+annotateMML :: XML.Element -> String -> XML.Element
+annotateMML e tex = math (unode "semantics" [cs, unode "annotation" (annotAttrs, tex)])
+ where
+ cs = case elChildren e of
+ [] -> unode "mrow" ()
+ [x] -> x
+ xs -> unode "mrow" xs
+ math childs = XML.Element q as [XML.Elem childs] l
+ where
+ (XML.Element q as _ l) = e
+ annotAttrs = [XML.Attr (unqual "encoding") "application/x-tex"]
+
+
+-- | Convert Pandoc inline element to HTML.
+inlineToHtml :: PandocMonad m
+ => WriterOptions -> Inline -> StateT WriterState m Html
+inlineToHtml opts inline = do
+ html5 <- gets stHtml5
+ case inline of
+ (Str str) -> return $ strToHtml str
+ (Space) -> return $ strToHtml " "
+ (SoftBreak) -> return $ case writerWrapText opts of
+ WrapNone -> preEscapedString " "
+ WrapAuto -> preEscapedString " "
+ WrapPreserve -> preEscapedString "\n"
+ (LineBreak) -> return $ (if html5 then H5.br else H.br)
+ <> strToHtml "\n"
+ (Span (id',classes,kvs) ils)
+ -> inlineListToHtml opts ils >>=
+ return . addAttrs opts attr' . H.span
+ where attr' = (id',classes',kvs')
+ classes' = filter (`notElem` ["csl-no-emph",
+ "csl-no-strong",
+ "csl-no-smallcaps"]) classes
+ kvs' = if null styles
+ then kvs
+ else (("style", concat styles) : kvs)
+ styles = ["font-style:normal;"
+ | "csl-no-emph" `elem` classes]
+ ++ ["font-weight:normal;"
+ | "csl-no-strong" `elem` classes]
+ ++ ["font-variant:normal;"
+ | "csl-no-smallcaps" `elem` classes]
+ (Emph lst) -> inlineListToHtml opts lst >>= return . H.em
+ (Strong lst) -> inlineListToHtml opts lst >>= return . H.strong
+ (Code attr str) -> case hlCode of
+ Nothing -> return
+ $ addAttrs opts attr
+ $ H.code $ strToHtml str
+ Just h -> do
+ modify $ \st -> st{ stHighlighting = True }
+ return $ addAttrs opts (id',[],keyvals) h
+ where (id',_,keyvals) = attr
+ hlCode = if isJust (writerHighlightStyle opts)
+ then highlight formatHtmlInline
+ attr str
+ else Nothing
+ (Strikeout lst) -> inlineListToHtml opts lst >>=
+ return . H.del
+ (SmallCaps lst) -> inlineListToHtml opts lst >>=
+ return . (H.span ! A.style "font-variant: small-caps;")
+ (Superscript lst) -> inlineListToHtml opts lst >>= return . H.sup
+ (Subscript lst) -> inlineListToHtml opts lst >>= return . H.sub
+ (Quoted quoteType lst) ->
+ let (leftQuote, rightQuote) = case quoteType of
+ SingleQuote -> (strToHtml "‘",
+ strToHtml "’")
+ DoubleQuote -> (strToHtml "“",
+ strToHtml "”")
+ in if writerHtmlQTags opts
+ then do
+ modify $ \st -> st{ stQuotes = True }
+ H.q `fmap` inlineListToHtml opts lst
+ else (\x -> leftQuote >> x >> rightQuote)
+ `fmap` inlineListToHtml opts lst
+ (Math t str) -> do
+ modify (\st -> st {stMath = True})
+ let mathClass = toValue $ ("math " :: String) ++
+ if t == InlineMath then "inline" else "display"
+ case writerHTMLMathMethod opts of
+ LaTeXMathML _ ->
+ -- putting LaTeXMathML in container with class "LaTeX" prevents
+ -- non-math elements on the page from being treated as math by
+ -- the javascript
+ return $ H.span ! A.class_ "LaTeX" $
+ case t of
+ InlineMath -> toHtml ("$" ++ str ++ "$")
+ DisplayMath -> toHtml ("$$" ++ str ++ "$$")
+ JsMath _ -> do
+ let m = preEscapedString str
+ return $ case t of
+ InlineMath -> H.span ! A.class_ mathClass $ m
+ DisplayMath -> H.div ! A.class_ mathClass $ m
+ WebTeX url -> do
+ let imtag = if html5 then H5.img else H.img
+ let m = imtag ! A.style "vertical-align:middle"
+ ! A.src (toValue $ url ++ urlEncode str)
+ ! A.alt (toValue str)
+ ! A.title (toValue str)
+ let brtag = if html5 then H5.br else H.br
+ return $ case t of
+ InlineMath -> m
+ DisplayMath -> brtag >> m >> brtag
+ GladTeX ->
+ return $ case t of
+ InlineMath -> preEscapedString $ "<EQ ENV=\"math\">" ++ str ++ "</EQ>"
+ DisplayMath -> preEscapedString $ "<EQ ENV=\"displaymath\">" ++ str ++ "</EQ>"
+ MathML -> do
+ let conf = useShortEmptyTags (const False)
+ defaultConfigPP
+ res <- lift $ convertMath writeMathML t str
+ case res of
+ Right r -> return $ preEscapedString $
+ ppcElement conf (annotateMML r str)
+ Left il -> (H.span ! A.class_ mathClass) <$>
+ inlineToHtml opts il
+ MathJax _ -> return $ H.span ! A.class_ mathClass $ toHtml $
+ case t of
+ InlineMath -> "\\(" ++ str ++ "\\)"
+ DisplayMath -> "\\[" ++ str ++ "\\]"
+ KaTeX _ _ -> return $ H.span ! A.class_ mathClass $
+ toHtml (case t of
+ InlineMath -> str
+ DisplayMath -> "\\displaystyle " ++ str)
+ PlainMath -> do
+ x <- lift (texMathToInlines t str) >>= inlineListToHtml opts
+ let m = H.span ! A.class_ mathClass $ x
+ let brtag = if html5 then H5.br else H.br
+ return $ case t of
+ InlineMath -> m
+ DisplayMath -> brtag >> m >> brtag
+ (RawInline f str)
+ | f == Format "html" -> return $ preEscapedString str
+ | otherwise -> do
+ report $ InlineNotRendered inline
+ return mempty
+ (Link attr txt (s,_)) | "mailto:" `isPrefixOf` s -> do
+ linkText <- inlineListToHtml opts txt
+ lift $ obfuscateLink opts attr linkText s
+ (Link attr txt (s,tit)) -> do
+ linkText <- inlineListToHtml opts txt
+ slideVariant <- gets stSlideVariant
+ let s' = case s of
+ '#':xs -> let prefix = if slideVariant == RevealJsSlides
+ then "/"
+ else writerIdentifierPrefix opts
+ in '#' : prefix ++ xs
+ _ -> s
+ let link = H.a ! A.href (toValue s') $ linkText
+ let link' = if txt == [Str (unEscapeString s)]
+ then link ! A.class_ "uri"
+ else link
+ let link'' = addAttrs opts attr link'
+ return $ if null tit
+ then link''
+ else link'' ! A.title (toValue tit)
+ (Image attr txt (s,tit)) | treatAsImage s -> do
+ let alternate' = stringify txt
+ let attributes = [A.src $ toValue s] ++
+ [A.title $ toValue tit | not (null tit)] ++
+ [A.alt $ toValue alternate' | not (null txt)] ++
+ imgAttrsToHtml opts attr
+ let tag = if html5 then H5.img else H.img
+ return $ foldl (!) tag attributes
+ -- note: null title included, as in Markdown.pl
+ (Image attr _ (s,tit)) -> do
+ let attributes = [A.src $ toValue s] ++
+ [A.title $ toValue tit | not (null tit)] ++
+ imgAttrsToHtml opts attr
+ return $ foldl (!) H5.embed attributes
+ -- note: null title included, as in Markdown.pl
+ (Note contents) -> do
+ notes <- gets stNotes
+ let number = (length notes) + 1
+ let ref = show number
+ htmlContents <- blockListToNote opts ref contents
+ epubVersion <- gets stEPUBVersion
+ -- push contents onto front of notes
+ modify $ \st -> st {stNotes = (htmlContents:notes)}
+ slideVariant <- gets stSlideVariant
+ let revealSlash = ['/' | slideVariant == RevealJsSlides]
+ let link = H.a ! A.href (toValue $ "#" ++
+ revealSlash ++
+ writerIdentifierPrefix opts ++ "fn" ++ ref)
+ ! A.class_ "footnoteRef"
+ ! prefixedId opts ("fnref" ++ ref)
+ $ (if isJust epubVersion
+ then id
+ else H.sup)
+ $ toHtml ref
+ return $ case epubVersion of
+ Just EPUB3 -> link ! customAttribute "epub:type" "noteref"
+ _ -> link
+ (Cite cits il)-> do contents <- inlineListToHtml opts il
+ let citationIds = unwords $ map citationId cits
+ let result = H.span ! A.class_ "citation" $ contents
+ return $ if html5
+ then result ! customAttribute "data-cites" (toValue citationIds)
+ else result
+
+blockListToNote :: PandocMonad m => WriterOptions -> String -> [Block] -> StateT WriterState m Html
+blockListToNote opts ref blocks =
+ -- If last block is Para or Plain, include the backlink at the end of
+ -- that block. Otherwise, insert a new Plain block with the backlink.
+ let backlink = [Link nullAttr [Str "↩"] ("#" ++ writerIdentifierPrefix opts ++ "fnref" ++ ref,[])]
+ blocks' = if null blocks
+ then []
+ else let lastBlock = last blocks
+ otherBlocks = init blocks
+ in case lastBlock of
+ (Para lst) -> otherBlocks ++
+ [Para (lst ++ backlink)]
+ (Plain lst) -> otherBlocks ++
+ [Plain (lst ++ backlink)]
+ _ -> otherBlocks ++ [lastBlock,
+ Plain backlink]
+ in do contents <- blockListToHtml opts blocks'
+ let noteItem = H.li ! (prefixedId opts ("fn" ++ ref)) $ contents
+ epubVersion <- gets stEPUBVersion
+ let noteItem' = case epubVersion of
+ Just EPUB3 -> noteItem ! customAttribute "epub:type" "footnote"
+ _ -> noteItem
+ return $ nl opts >> noteItem'
+
+-- Javascript snippet to render all KaTeX elements
+renderKaTeX :: String
+renderKaTeX = unlines [
+ "window.onload = function(){var mathElements = document.getElementsByClassName(\"math\");"
+ , "for (var i=0; i < mathElements.length; i++)"
+ , "{"
+ , " var texText = mathElements[i].firstChild"
+ , " katex.render(texText.data, mathElements[i])"
+ , "}}"
+ ]
+
+isMathEnvironment :: String -> Bool
+isMathEnvironment s = "\\begin{" `isPrefixOf` s &&
+ envName `elem` mathmlenvs
+ where envName = takeWhile (/= '}') (drop 7 s)
+ mathmlenvs = [ "align"
+ , "align*"
+ , "alignat"
+ , "alignat*"
+ , "aligned"
+ , "alignedat"
+ , "array"
+ , "Bmatrix"
+ , "bmatrix"
+ , "cases"
+ , "CD"
+ , "eqnarray"
+ , "eqnarray*"
+ , "equation"
+ , "equation*"
+ , "gather"
+ , "gather*"
+ , "gathered"
+ , "matrix"
+ , "multline"
+ , "multline*"
+ , "pmatrix"
+ , "smallmatrix"
+ , "split"
+ , "subarray"
+ , "Vmatrix"
+ , "vmatrix" ]
+
+allowsMathEnvironments :: HTMLMathMethod -> Bool
+allowsMathEnvironments (MathJax _) = True
+allowsMathEnvironments (MathML) = True
+allowsMathEnvironments (WebTeX _) = True
+allowsMathEnvironments _ = False
diff --git a/src/Text/Pandoc/Writers/Haddock.hs b/src/Text/Pandoc/Writers/Haddock.hs
new file mode 100644
index 000000000..945e4a0f1
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Haddock.hs
@@ -0,0 +1,370 @@
+{-# LANGUAGE OverloadedStrings, TupleSections, ScopedTypeVariables #-}
+{-
+Copyright (C) 2014 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.Haddock
+ Copyright : Copyright (C) 2014 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to haddock markup.
+
+Haddock: <http://www.haskell.org/haddock/doc/html/>
+-}
+module Text.Pandoc.Writers.Haddock (writeHaddock) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Templates (renderTemplate')
+import Text.Pandoc.Shared
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Options
+import Data.List ( intersperse, transpose )
+import Text.Pandoc.Pretty
+import Control.Monad.State
+import Text.Pandoc.Writers.Math (texMathToInlines)
+import Network.URI (isURI)
+import Data.Default
+import Text.Pandoc.Class (PandocMonad, report)
+import Text.Pandoc.Logging
+
+type Notes = [[Block]]
+data WriterState = WriterState { stNotes :: Notes }
+instance Default WriterState
+ where def = WriterState{ stNotes = [] }
+
+-- | Convert Pandoc to Haddock.
+writeHaddock :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeHaddock opts document =
+ evalStateT (pandocToHaddock opts{
+ writerWrapText = writerWrapText opts } document) def
+
+-- | Return haddock representation of document.
+pandocToHaddock :: PandocMonad m
+ => WriterOptions -> Pandoc -> StateT WriterState m String
+pandocToHaddock opts (Pandoc meta blocks) = do
+ let colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ body <- blockListToHaddock opts blocks
+ st <- get
+ notes' <- notesToHaddock opts (reverse $ stNotes st)
+ let render' :: Doc -> String
+ render' = render colwidth
+ let main = render' $ body <>
+ (if isEmpty notes' then empty else blankline <> notes')
+ metadata <- metaToJSON opts
+ (fmap (render colwidth) . blockListToHaddock opts)
+ (fmap (render colwidth) . inlineListToHaddock opts)
+ meta
+ let context = defField "body" main
+ $ metadata
+ case writerTemplate opts of
+ Nothing -> return main
+ Just tpl -> return $ renderTemplate' tpl context
+
+-- | Return haddock representation of notes.
+notesToHaddock :: PandocMonad m
+ => WriterOptions -> [[Block]] -> StateT WriterState m Doc
+notesToHaddock opts notes =
+ if null notes
+ then return empty
+ else do
+ contents <- blockToHaddock opts $ OrderedList (1,DefaultStyle,DefaultDelim) notes
+ return $ text "#notes#" <> blankline <> contents
+
+-- | Escape special characters for Haddock.
+escapeString :: String -> String
+escapeString = escapeStringUsing haddockEscapes
+ where haddockEscapes = backslashEscapes "\\/'`\"@<"
+
+-- | Convert Pandoc block element to haddock.
+blockToHaddock :: PandocMonad m
+ => WriterOptions -- ^ Options
+ -> Block -- ^ Block element
+ -> StateT WriterState m Doc
+blockToHaddock _ Null = return empty
+blockToHaddock opts (Div _ ils) = do
+ contents <- blockListToHaddock opts ils
+ return $ contents <> blankline
+blockToHaddock opts (Plain inlines) = do
+ contents <- inlineListToHaddock opts inlines
+ return $ contents <> cr
+-- title beginning with fig: indicates figure
+blockToHaddock opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) =
+ blockToHaddock opts (Para [Image attr alt (src,tit)])
+blockToHaddock opts (Para inlines) =
+ -- TODO: if it contains linebreaks, we need to use a @...@ block
+ (<> blankline) `fmap` blockToHaddock opts (Plain inlines)
+blockToHaddock opts (LineBlock lns) =
+ blockToHaddock opts $ linesToPara lns
+blockToHaddock _ b@(RawBlock f str)
+ | f == "haddock" = do
+ return $ text str <> text "\n"
+ | otherwise = do
+ report $ BlockNotRendered b
+ return empty
+blockToHaddock opts HorizontalRule =
+ return $ blankline <> text (replicate (writerColumns opts) '_') <> blankline
+blockToHaddock opts (Header level (ident,_,_) inlines) = do
+ contents <- inlineListToHaddock opts inlines
+ let attr' = if null ident
+ then empty
+ else cr <> text "#" <> text ident <> text "#"
+ return $ nowrap (text (replicate level '=') <> space <> contents)
+ <> attr' <> blankline
+blockToHaddock _ (CodeBlock (_,_,_) str) =
+ return $ prefixed "> " (text str) <> blankline
+-- Nothing in haddock corresponds to block quotes:
+blockToHaddock opts (BlockQuote blocks) =
+ blockListToHaddock opts blocks
+-- Haddock doesn't have tables. Use haddock tables in code.
+blockToHaddock opts (Table caption aligns widths headers rows) = do
+ caption' <- inlineListToHaddock opts caption
+ let caption'' = if null caption
+ then empty
+ else blankline <> caption' <> blankline
+ rawHeaders <- mapM (blockListToHaddock opts) headers
+ rawRows <- mapM (mapM (blockListToHaddock opts)) rows
+ let isSimple = all (==0) widths
+ let isPlainBlock (Plain _) = True
+ isPlainBlock _ = False
+ let hasBlocks = not (all isPlainBlock $ concat . concat $ headers:rows)
+ (nst,tbl) <- case True of
+ _ | isSimple -> fmap (nest 2,) $
+ pandocTable opts (all null headers) aligns widths
+ rawHeaders rawRows
+ | not hasBlocks -> fmap (nest 2,) $
+ pandocTable opts (all null headers) aligns widths
+ rawHeaders rawRows
+ | otherwise -> fmap (id,) $
+ gridTable opts (all null headers) aligns widths
+ rawHeaders rawRows
+ return $ (prefixed "> " $ nst $ tbl $$ blankline $$ caption'') $$ blankline
+blockToHaddock opts (BulletList items) = do
+ contents <- mapM (bulletListItemToHaddock opts) items
+ return $ cat contents <> blankline
+blockToHaddock opts (OrderedList (start,_,delim) items) = do
+ let attribs = (start, Decimal, delim)
+ let markers = orderedListMarkers attribs
+ let markers' = map (\m -> if length m < 3
+ then m ++ replicate (3 - length m) ' '
+ else m) markers
+ contents <- mapM (\(item, num) -> orderedListItemToHaddock opts item num) $
+ zip markers' items
+ return $ cat contents <> blankline
+blockToHaddock opts (DefinitionList items) = do
+ contents <- mapM (definitionListItemToHaddock opts) items
+ return $ cat contents <> blankline
+
+pandocTable :: PandocMonad m
+ => WriterOptions -> Bool -> [Alignment] -> [Double]
+ -> [Doc] -> [[Doc]] -> StateT WriterState m Doc
+pandocTable opts headless aligns widths rawHeaders rawRows = do
+ let isSimple = all (==0) widths
+ let alignHeader alignment = case alignment of
+ AlignLeft -> lblock
+ AlignCenter -> cblock
+ AlignRight -> rblock
+ AlignDefault -> lblock
+ let numChars = maximum . map offset
+ let widthsInChars = if isSimple
+ then map ((+2) . numChars)
+ $ transpose (rawHeaders : rawRows)
+ else map
+ (floor . (fromIntegral (writerColumns opts) *))
+ widths
+ let makeRow = hcat . intersperse (lblock 1 (text " ")) .
+ (zipWith3 alignHeader aligns widthsInChars)
+ let rows' = map makeRow rawRows
+ let head' = makeRow rawHeaders
+ let maxRowHeight = maximum $ map height (head':rows')
+ let underline = cat $ intersperse (text " ") $
+ map (\width -> text (replicate width '-')) widthsInChars
+ let border = if maxRowHeight > 1
+ then text (replicate (sum widthsInChars +
+ length widthsInChars - 1) '-')
+ else if headless
+ then underline
+ else empty
+ let head'' = if headless
+ then empty
+ else border <> cr <> head'
+ let body = if maxRowHeight > 1
+ then vsep rows'
+ else vcat rows'
+ let bottom = if headless
+ then underline
+ else border
+ return $ head'' $$ underline $$ body $$ bottom
+
+gridTable :: PandocMonad m
+ => WriterOptions -> Bool -> [Alignment] -> [Double]
+ -> [Doc] -> [[Doc]] -> StateT WriterState m Doc
+gridTable opts headless _aligns widths headers' rawRows = do
+ let numcols = length headers'
+ let widths' = if all (==0) widths
+ then replicate numcols (1.0 / fromIntegral numcols)
+ else widths
+ let widthsInChars = map (floor . (fromIntegral (writerColumns opts) *)) widths'
+ let hpipeBlocks blocks = hcat [beg, middle, end]
+ where h = maximum (map height blocks)
+ sep' = lblock 3 $ vcat (map text $ replicate h " | ")
+ beg = lblock 2 $ vcat (map text $ replicate h "| ")
+ end = lblock 2 $ vcat (map text $ replicate h " |")
+ middle = chomp $ hcat $ intersperse sep' blocks
+ let makeRow = hpipeBlocks . zipWith lblock widthsInChars
+ let head' = makeRow headers'
+ let rows' = map (makeRow . map chomp) rawRows
+ let border ch = char '+' <> char ch <>
+ (hcat $ intersperse (char ch <> char '+' <> char ch) $
+ map (\l -> text $ replicate l ch) widthsInChars) <>
+ char ch <> char '+'
+ let body = vcat $ intersperse (border '-') rows'
+ let head'' = if headless
+ then empty
+ else head' $$ border '='
+ return $ border '-' $$ head'' $$ body $$ border '-'
+
+-- | Convert bullet list item (list of blocks) to haddock
+bulletListItemToHaddock :: PandocMonad m
+ => WriterOptions -> [Block] -> StateT WriterState m Doc
+bulletListItemToHaddock opts items = do
+ contents <- blockListToHaddock opts items
+ let sps = replicate (writerTabStop opts - 2) ' '
+ let start = text ('-' : ' ' : sps)
+ -- remove trailing blank line if it is a tight list
+ let contents' = case reverse items of
+ (BulletList xs:_) | isTightList xs ->
+ chomp contents <> cr
+ (OrderedList _ xs:_) | isTightList xs ->
+ chomp contents <> cr
+ _ -> contents
+ return $ hang (writerTabStop opts) start $ contents' <> cr
+
+-- | Convert ordered list item (a list of blocks) to haddock
+orderedListItemToHaddock :: PandocMonad m
+ => WriterOptions -- ^ options
+ -> String -- ^ list item marker
+ -> [Block] -- ^ list item (list of blocks)
+ -> StateT WriterState m Doc
+orderedListItemToHaddock opts marker items = do
+ contents <- blockListToHaddock opts items
+ let sps = case length marker - writerTabStop opts of
+ n | n > 0 -> text $ replicate n ' '
+ _ -> text " "
+ let start = text marker <> sps
+ return $ hang (writerTabStop opts) start $ contents <> cr
+
+-- | Convert definition list item (label, list of blocks) to haddock
+definitionListItemToHaddock :: PandocMonad m
+ => WriterOptions
+ -> ([Inline],[[Block]])
+ -> StateT WriterState m Doc
+definitionListItemToHaddock opts (label, defs) = do
+ labelText <- inlineListToHaddock opts label
+ defs' <- mapM (mapM (blockToHaddock opts)) defs
+ let contents = vcat $ map (\d -> hang 4 empty $ vcat d <> cr) defs'
+ return $ nowrap (brackets labelText) <> cr <> contents <> cr
+
+-- | Convert list of Pandoc block elements to haddock
+blockListToHaddock :: PandocMonad m
+ => WriterOptions -- ^ Options
+ -> [Block] -- ^ List of block elements
+ -> StateT WriterState m Doc
+blockListToHaddock opts blocks =
+ mapM (blockToHaddock opts) blocks >>= return . cat
+
+-- | Convert list of Pandoc inline elements to haddock.
+inlineListToHaddock :: PandocMonad m
+ => WriterOptions -> [Inline] -> StateT WriterState m Doc
+inlineListToHaddock opts lst =
+ mapM (inlineToHaddock opts) lst >>= return . cat
+
+-- | Convert Pandoc inline element to haddock.
+inlineToHaddock :: PandocMonad m
+ => WriterOptions -> Inline -> StateT WriterState m Doc
+inlineToHaddock opts (Span (ident,_,_) ils) = do
+ contents <- inlineListToHaddock opts ils
+ if not (null ident) && null ils
+ then return $ "#" <> text ident <> "#"
+ else return contents
+inlineToHaddock opts (Emph lst) = do
+ contents <- inlineListToHaddock opts lst
+ return $ "/" <> contents <> "/"
+inlineToHaddock opts (Strong lst) = do
+ contents <- inlineListToHaddock opts lst
+ return $ "__" <> contents <> "__"
+inlineToHaddock opts (Strikeout lst) = do
+ contents <- inlineListToHaddock opts lst
+ -- not supported in haddock, but we fake it:
+ return $ "~~" <> contents <> "~~"
+-- not supported in haddock:
+inlineToHaddock opts (Superscript lst) = inlineListToHaddock opts lst
+-- not supported in haddock:
+inlineToHaddock opts (Subscript lst) = inlineListToHaddock opts lst
+-- not supported in haddock:
+inlineToHaddock opts (SmallCaps lst) = inlineListToHaddock opts lst
+inlineToHaddock opts (Quoted SingleQuote lst) = do
+ contents <- inlineListToHaddock opts lst
+ return $ "‘" <> contents <> "’"
+inlineToHaddock opts (Quoted DoubleQuote lst) = do
+ contents <- inlineListToHaddock opts lst
+ return $ "“" <> contents <> "”"
+inlineToHaddock _ (Code _ str) =
+ return $ "@" <> text (escapeString str) <> "@"
+inlineToHaddock _ (Str str) = do
+ return $ text $ escapeString str
+inlineToHaddock opts (Math mt str) = do
+ let adjust x = case mt of
+ DisplayMath -> cr <> x <> cr
+ InlineMath -> x
+ adjust <$> (lift (texMathToInlines mt str) >>= inlineListToHaddock opts)
+inlineToHaddock _ il@(RawInline f str)
+ | f == "haddock" = return $ text str
+ | otherwise = do
+ report $ InlineNotRendered il
+ return empty
+-- no line break in haddock (see above on CodeBlock)
+inlineToHaddock _ LineBreak = return cr
+inlineToHaddock opts SoftBreak =
+ case writerWrapText opts of
+ WrapAuto -> return space
+ WrapNone -> return space
+ WrapPreserve -> return cr
+inlineToHaddock _ Space = return space
+inlineToHaddock opts (Cite _ lst) = inlineListToHaddock opts lst
+inlineToHaddock _ (Link _ txt (src, _)) = do
+ let linktext = text $ escapeString $ stringify txt
+ let useAuto = isURI src &&
+ case txt of
+ [Str s] | escapeURI s == src -> True
+ _ -> False
+ return $ nowrap $ "<" <> text src <>
+ (if useAuto then empty else space <> linktext) <> ">"
+inlineToHaddock opts (Image attr alternate (source, tit)) = do
+ linkhaddock <- inlineToHaddock opts (Link attr alternate (source, tit))
+ return $ "<" <> linkhaddock <> ">"
+-- haddock doesn't have notes, but we can fake it:
+inlineToHaddock opts (Note contents) = do
+ modify (\st -> st{ stNotes = contents : stNotes st })
+ st <- get
+ let ref = text $ writerIdentifierPrefix opts ++ show (length $ stNotes st)
+ return $ "<#notes [" <> ref <> "]>"
diff --git a/src/Text/Pandoc/Writers/ICML.hs b/src/Text/Pandoc/Writers/ICML.hs
new file mode 100644
index 000000000..efec17d26
--- /dev/null
+++ b/src/Text/Pandoc/Writers/ICML.hs
@@ -0,0 +1,584 @@
+{-# LANGUAGE OverloadedStrings, FlexibleContexts, ScopedTypeVariables #-}
+
+{- |
+ Module : Text.Pandoc.Writers.ICML
+ Copyright : Copyright (C) 2013-2016 github.com/mb21
+ License : GNU GPL, version 2 or above
+
+ Stability : alpha
+
+Conversion of 'Pandoc' documents to Adobe InCopy ICML, a stand-alone XML format
+which is a subset of the zipped IDML format for which the documentation is
+available here: http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/indesign/sdk/cs6/idml/idml-specification.pdf
+InCopy is the companion word-processor to Adobe InDesign and ICML documents can be integrated
+into InDesign with File -> Place.
+-}
+module Text.Pandoc.Writers.ICML (writeICML) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Error (PandocError)
+import Text.Pandoc.XML
+import Text.Pandoc.Writers.Math (texMathToInlines)
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Shared (linesToPara, splitBy)
+import Text.Pandoc.Options
+import Text.Pandoc.Templates (renderTemplate')
+import Text.Pandoc.Pretty
+import Text.Pandoc.ImageSize
+import Data.List (isPrefixOf, isInfixOf, stripPrefix, intersperse)
+import Data.Text as Text (breakOnAll, pack)
+import Control.Monad.State
+import Control.Monad.Except (runExceptT)
+import Network.URI (isURI)
+import qualified Data.Set as Set
+import Text.Pandoc.Class (PandocMonad, report)
+import Text.Pandoc.Logging
+import qualified Text.Pandoc.Class as P
+
+type Style = [String]
+type Hyperlink = [(Int, String)]
+
+data WriterState = WriterState{
+ blockStyles :: Set.Set String
+ , inlineStyles :: Set.Set String
+ , links :: Hyperlink
+ , listDepth :: Int
+ , maxListDepth :: Int
+ }
+
+type WS m = StateT WriterState m
+
+defaultWriterState :: WriterState
+defaultWriterState = WriterState{
+ blockStyles = Set.empty
+ , inlineStyles = Set.empty
+ , links = []
+ , listDepth = 1
+ , maxListDepth = 0
+ }
+
+-- inline names (appear in InDesign's character styles pane)
+emphName :: String
+strongName :: String
+strikeoutName :: String
+superscriptName :: String
+subscriptName :: String
+smallCapsName :: String
+codeName :: String
+linkName :: String
+emphName = "Italic"
+strongName = "Bold"
+strikeoutName = "Strikeout"
+superscriptName = "Superscript"
+subscriptName = "Subscript"
+smallCapsName = "SmallCaps"
+codeName = "Code"
+linkName = "Link"
+
+-- block element names (appear in InDesign's paragraph styles pane)
+paragraphName :: String
+figureName :: String
+imgCaptionName :: String
+codeBlockName :: String
+blockQuoteName :: String
+orderedListName :: String
+bulletListName :: String
+defListTermName :: String
+defListDefName :: String
+headerName :: String
+tableName :: String
+tableHeaderName :: String
+tableCaptionName :: String
+alignLeftName :: String
+alignRightName :: String
+alignCenterName :: String
+firstListItemName :: String
+beginsWithName :: String
+lowerRomanName :: String
+upperRomanName :: String
+lowerAlphaName :: String
+upperAlphaName :: String
+subListParName :: String
+footnoteName :: String
+citeName :: String
+paragraphName = "Paragraph"
+figureName = "Figure"
+imgCaptionName = "Caption"
+codeBlockName = "CodeBlock"
+blockQuoteName = "Blockquote"
+orderedListName = "NumList"
+bulletListName = "BulList"
+defListTermName = "DefListTerm"
+defListDefName = "DefListDef"
+headerName = "Header"
+tableName = "TablePar"
+tableHeaderName = "TableHeader"
+tableCaptionName = "TableCaption"
+alignLeftName = "LeftAlign"
+alignRightName = "RightAlign"
+alignCenterName = "CenterAlign"
+firstListItemName = "first"
+beginsWithName = "beginsWith-"
+lowerRomanName = "lowerRoman"
+upperRomanName = "upperRoman"
+lowerAlphaName = "lowerAlpha"
+upperAlphaName = "upperAlpha"
+subListParName = "subParagraph"
+footnoteName = "Footnote"
+citeName = "Cite"
+
+-- | Convert Pandoc document to string in ICML format.
+writeICML :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeICML opts (Pandoc meta blocks) = do
+ let colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ render' = render colwidth
+ renderMeta f s = liftM (render' . fst) $ runStateT (f opts [] s) defaultWriterState
+ metadata <- metaToJSON opts
+ (renderMeta blocksToICML)
+ (renderMeta inlinesToICML)
+ meta
+ (doc, st) <- runStateT (blocksToICML opts [] blocks) defaultWriterState
+ let main = render' doc
+ context = defField "body" main
+ $ defField "charStyles" (render' $ charStylesToDoc st)
+ $ defField "parStyles" (render' $ parStylesToDoc st)
+ $ defField "hyperlinks" (render' $ hyperlinksToDoc $ links st)
+ $ metadata
+ return $ case writerTemplate opts of
+ Nothing -> main
+ Just tpl -> renderTemplate' tpl context
+
+-- | Auxilary functions for parStylesToDoc and charStylesToDoc.
+contains :: String -> (String, (String, String)) -> [(String, String)]
+contains s rule =
+ if isInfixOf (fst rule) s
+ then [snd rule]
+ else []
+
+-- | The monospaced font to use as default.
+monospacedFont :: Doc
+monospacedFont = inTags False "AppliedFont" [("type", "string")] $ text "Courier New"
+
+-- | How much to indent blockquotes etc.
+defaultIndent :: Int
+defaultIndent = 20
+
+-- | How much to indent numbered lists before the number.
+defaultListIndent :: Int
+defaultListIndent = 10
+
+-- other constants
+lineSeparator :: String
+lineSeparator = "&#x2028;"
+
+-- | Convert a WriterState with its block styles to the ICML listing of Paragraph Styles.
+parStylesToDoc :: WriterState -> Doc
+parStylesToDoc st = vcat $ map makeStyle $ Set.toAscList $ blockStyles st
+ where
+ makeStyle s =
+ let countSubStrs sub str = length $ Text.breakOnAll (Text.pack sub) (Text.pack str)
+ attrs = concat $ map (contains s) $ [
+ (defListTermName, ("BulletsAndNumberingListType", "BulletList"))
+ , (defListTermName, ("FontStyle", "Bold"))
+ , (tableHeaderName, ("FontStyle", "Bold"))
+ , (alignLeftName, ("Justification", "LeftAlign"))
+ , (alignRightName, ("Justification", "RightAlign"))
+ , (alignCenterName, ("Justification", "CenterAlign"))
+ , (headerName++"1", ("PointSize", "36"))
+ , (headerName++"2", ("PointSize", "30"))
+ , (headerName++"3", ("PointSize", "24"))
+ , (headerName++"4", ("PointSize", "18"))
+ , (headerName++"5", ("PointSize", "14"))
+ ]
+ -- what is the most nested list type, if any?
+ (isBulletList, isOrderedList) = findList $ reverse $ splitBy (==' ') s
+ where
+ findList [] = (False, False)
+ findList (x:xs) | x == bulletListName = (True, False)
+ | x == orderedListName = (False, True)
+ | otherwise = findList xs
+ nBuls = countSubStrs bulletListName s
+ nOrds = countSubStrs orderedListName s
+ attrs' = numbering ++ listType ++ indent ++ attrs
+ where
+ numbering | isOrderedList = [("NumberingExpression", "^#.^t"), ("NumberingLevel", show nOrds)]
+ | otherwise = []
+ listType | isOrderedList && (not $ isInfixOf subListParName s)
+ = [("BulletsAndNumberingListType", "NumberedList")]
+ | isBulletList && (not $ isInfixOf subListParName s)
+ = [("BulletsAndNumberingListType", "BulletList")]
+ | otherwise = []
+ indent = [("LeftIndent", show indt)]
+ where
+ nBlockQuotes = countSubStrs blockQuoteName s
+ nDefLists = countSubStrs defListDefName s
+ indt = max 0 $ defaultListIndent*(nBuls + nOrds - 1) + defaultIndent*(nBlockQuotes + nDefLists)
+ props = inTags True "Properties" [] $ (basedOn $$ tabList $$ numbForm)
+ where
+ font = if isInfixOf codeBlockName s
+ then monospacedFont
+ else empty
+ basedOn = inTags False "BasedOn" [("type", "object")] (text "$ID/NormalParagraphStyle") $$ font
+ tabList = if isBulletList
+ then inTags True "TabList" [("type","list")] $ inTags True "ListItem" [("type","record")]
+ $ vcat [
+ inTags False "Alignment" [("type","enumeration")] $ text "LeftAlign"
+ , inTags False "AlignmentCharacter" [("type","string")] $ text "."
+ , selfClosingTag "Leader" [("type","string")]
+ , inTags False "Position" [("type","unit")] $ text
+ $ show $ defaultListIndent * (nBuls + nOrds)
+ ]
+ else empty
+ makeNumb name = inTags False "NumberingFormat" [("type", "string")] (text name)
+ numbForm | isInfixOf lowerRomanName s = makeNumb "i, ii, iii, iv..."
+ | isInfixOf upperRomanName s = makeNumb "I, II, III, IV..."
+ | isInfixOf lowerAlphaName s = makeNumb "a, b, c, d..."
+ | isInfixOf upperAlphaName s = makeNumb "A, B, C, D..."
+ | otherwise = empty
+ in inTags True "ParagraphStyle" ([("Self", "ParagraphStyle/"++s), ("Name", s)] ++ attrs') props
+
+-- | Convert a WriterState with its inline styles to the ICML listing of Character Styles.
+charStylesToDoc :: WriterState -> Doc
+charStylesToDoc st = vcat $ map makeStyle $ Set.toAscList $ inlineStyles st
+ where
+ makeStyle s =
+ let attrs = concat $ map (contains s) [
+ (strikeoutName, ("StrikeThru", "true"))
+ , (superscriptName, ("Position", "Superscript"))
+ , (subscriptName, ("Position", "Subscript"))
+ , (smallCapsName, ("Capitalization", "SmallCaps"))
+ ]
+ attrs' | isInfixOf emphName s && isInfixOf strongName s = ("FontStyle", "Bold Italic") : attrs
+ | isInfixOf strongName s = ("FontStyle", "Bold") : attrs
+ | isInfixOf emphName s = ("FontStyle", "Italic") : attrs
+ | otherwise = attrs
+ props = inTags True "Properties" [] $
+ inTags False "BasedOn" [("type", "object")] (text "$ID/NormalCharacterStyle") $$ font
+ where
+ font =
+ if isInfixOf codeName s
+ then monospacedFont
+ else empty
+ in inTags True "CharacterStyle" ([("Self", "CharacterStyle/"++s), ("Name", s)] ++ attrs') props
+
+-- | Escape colon characters as %3a
+escapeColons :: String -> String
+escapeColons (x:xs)
+ | x == ':' = "%3a" ++ escapeColons xs
+ | otherwise = x : escapeColons xs
+escapeColons [] = []
+
+-- | Convert a list of (identifier, url) pairs to the ICML listing of hyperlinks.
+hyperlinksToDoc :: Hyperlink -> Doc
+hyperlinksToDoc [] = empty
+hyperlinksToDoc (x:xs) = hyp x $$ hyperlinksToDoc xs
+ where
+ hyp (ident, url) = hdest $$ hlink
+ where
+ hdest = selfClosingTag "HyperlinkURLDestination"
+ [("Self", "HyperlinkURLDestination/"++(escapeColons url)), ("Name","link"), ("DestinationURL",url), ("DestinationUniqueKey","1")] -- HyperlinkURLDestination with more than one colon crashes CS6
+ hlink = inTags True "Hyperlink" [("Self","uf-"++show ident), ("Name",url),
+ ("Source","htss-"++show ident), ("Visible","true"), ("DestinationUniqueKey","1")]
+ $ inTags True "Properties" []
+ $ inTags False "BorderColor" [("type","enumeration")] (text "Black")
+ $$ (inTags False "Destination" [("type","object")]
+ $ text $ "HyperlinkURLDestination/"++(escapeColons (escapeStringForXML url))) -- HyperlinkURLDestination with more than one colon crashes CS6
+
+
+-- | Convert a list of Pandoc blocks to ICML.
+blocksToICML :: PandocMonad m => WriterOptions -> Style -> [Block] -> WS m Doc
+blocksToICML opts style lst = do
+ docs <- mapM (blockToICML opts style) lst
+ return $ intersperseBrs docs
+
+-- | Convert a Pandoc block element to ICML.
+blockToICML :: PandocMonad m => WriterOptions -> Style -> Block -> WS m Doc
+blockToICML opts style (Plain lst) = parStyle opts style lst
+-- title beginning with fig: indicates that the image is a figure
+blockToICML opts style (Para img@[Image _ txt (_,'f':'i':'g':':':_)]) = do
+ figure <- parStyle opts (figureName:style) img
+ caption <- parStyle opts (imgCaptionName:style) txt
+ return $ intersperseBrs [figure, caption]
+blockToICML opts style (Para lst) = parStyle opts (paragraphName:style) lst
+blockToICML opts style (LineBlock lns) =
+ blockToICML opts style $ linesToPara lns
+blockToICML opts style (CodeBlock _ str) = parStyle opts (codeBlockName:style) $ [Str str]
+blockToICML _ _ b@(RawBlock f str)
+ | f == Format "icml" = return $ text str
+ | otherwise = do
+ report $ BlockNotRendered b
+ return empty
+blockToICML opts style (BlockQuote blocks) = blocksToICML opts (blockQuoteName:style) blocks
+blockToICML opts style (OrderedList attribs lst) = listItemsToICML opts orderedListName style (Just attribs) lst
+blockToICML opts style (BulletList lst) = listItemsToICML opts bulletListName style Nothing lst
+blockToICML opts style (DefinitionList lst) = intersperseBrs `fmap` mapM (definitionListItemToICML opts style) lst
+blockToICML opts style (Header lvl _ lst) =
+ let stl = (headerName ++ show lvl):style
+ in parStyle opts stl lst
+blockToICML _ _ HorizontalRule = return empty -- we could insert a page break instead
+blockToICML opts style (Table caption aligns widths headers rows) =
+ let style' = tableName : style
+ noHeader = all null headers
+ nrHeaders = if noHeader
+ then "0"
+ else "1"
+ nrRows = length rows
+ nrCols = if null rows
+ then 0
+ else length $ head rows
+ rowsToICML [] _ = return empty
+ rowsToICML (col:rest) rowNr =
+ liftM2 ($$) (colsToICML col aligns rowNr (0::Int)) $ rowsToICML rest (rowNr+1)
+ colsToICML [] _ _ _ = return empty
+ colsToICML _ [] _ _ = return empty
+ colsToICML (cell:rest) (alig:restAligns) rowNr colNr = do
+ let stl = if rowNr == 0 && not noHeader
+ then tableHeaderName:style'
+ else style'
+ stl' | alig == AlignLeft = alignLeftName : stl
+ | alig == AlignRight = alignRightName : stl
+ | alig == AlignCenter = alignCenterName : stl
+ | otherwise = stl
+ c <- blocksToICML opts stl' cell
+ let cl = return $ inTags True "Cell"
+ [("Name", show colNr ++":"++ show rowNr), ("AppliedCellStyle","CellStyle/Cell")] c
+ liftM2 ($$) cl $ colsToICML rest restAligns rowNr (colNr+1)
+ in do
+ let tabl = if noHeader
+ then rows
+ else headers:rows
+ cells <- rowsToICML tabl (0::Int)
+ let colWidths w = if w > 0
+ then [("SingleColumnWidth",show $ 500 * w)]
+ else []
+ let tupToDoc tup = selfClosingTag "Column" $ [("Name",show $ fst tup)] ++ (colWidths $ snd tup)
+ let colDescs = vcat $ map tupToDoc $ zip [0..nrCols-1] widths
+ let tableDoc = return $ inTags True "Table" [
+ ("AppliedTableStyle","TableStyle/Table")
+ , ("HeaderRowCount", nrHeaders)
+ , ("BodyRowCount", show nrRows)
+ , ("ColumnCount", show nrCols)
+ ] (colDescs $$ cells)
+ liftM2 ($$) tableDoc $ parStyle opts (tableCaptionName:style) caption
+blockToICML opts style (Div _ lst) = blocksToICML opts style lst
+blockToICML _ _ Null = return empty
+
+-- | Convert a list of lists of blocks to ICML list items.
+listItemsToICML :: PandocMonad m => WriterOptions -> String -> Style -> Maybe ListAttributes -> [[Block]] -> WS m Doc
+listItemsToICML _ _ _ _ [] = return empty
+listItemsToICML opts listType style attribs (first:rest) = do
+ st <- get
+ put st{ listDepth = 1 + listDepth st}
+ let stl = listType:style
+ let f = listItemToICML opts stl True attribs first
+ let r = map (listItemToICML opts stl False attribs) rest
+ docs <- sequence $ f:r
+ s <- get
+ let maxD = max (maxListDepth s) (listDepth s)
+ put s{ listDepth = 1, maxListDepth = maxD }
+ return $ intersperseBrs docs
+
+-- | Convert a list of blocks to ICML list items.
+listItemToICML :: PandocMonad m => WriterOptions -> Style -> Bool-> Maybe ListAttributes -> [Block] -> WS m Doc
+listItemToICML opts style isFirst attribs item =
+ let makeNumbStart (Just (beginsWith, numbStl, _)) =
+ let doN DefaultStyle = []
+ doN LowerRoman = [lowerRomanName]
+ doN UpperRoman = [upperRomanName]
+ doN LowerAlpha = [lowerAlphaName]
+ doN UpperAlpha = [upperAlphaName]
+ doN _ = []
+ bw = if beginsWith > 1
+ then [beginsWithName ++ show beginsWith]
+ else []
+ in doN numbStl ++ bw
+ makeNumbStart Nothing = []
+ stl = if isFirst
+ then firstListItemName:style
+ else style
+ stl' = makeNumbStart attribs ++ stl
+ in if length item > 1
+ then do
+ let insertTab (Para lst) = blockToICML opts (subListParName:style) $ Para $ (Str "\t"):lst
+ insertTab block = blockToICML opts style block
+ f <- blockToICML opts stl' $ head item
+ r <- mapM insertTab $ tail item
+ return $ intersperseBrs (f : r)
+ else blocksToICML opts stl' item
+
+definitionListItemToICML :: PandocMonad m => WriterOptions -> Style -> ([Inline],[[Block]]) -> WS m Doc
+definitionListItemToICML opts style (term,defs) = do
+ term' <- parStyle opts (defListTermName:style) term
+ defs' <- mapM (blocksToICML opts (defListDefName:style)) defs
+ return $ intersperseBrs $ (term' : defs')
+
+
+-- | Convert a list of inline elements to ICML.
+inlinesToICML :: PandocMonad m => WriterOptions -> Style -> [Inline] -> WS m Doc
+inlinesToICML opts style lst = vcat `fmap` mapM (inlineToICML opts style) (mergeSpaces lst)
+
+-- | Convert an inline element to ICML.
+inlineToICML :: PandocMonad m => WriterOptions -> Style -> Inline -> WS m Doc
+inlineToICML _ style (Str str) = charStyle style $ text $ escapeStringForXML str
+inlineToICML opts style (Emph lst) = inlinesToICML opts (emphName:style) lst
+inlineToICML opts style (Strong lst) = inlinesToICML opts (strongName:style) lst
+inlineToICML opts style (Strikeout lst) = inlinesToICML opts (strikeoutName:style) lst
+inlineToICML opts style (Superscript lst) = inlinesToICML opts (superscriptName:style) lst
+inlineToICML opts style (Subscript lst) = inlinesToICML opts (subscriptName:style) lst
+inlineToICML opts style (SmallCaps lst) = inlinesToICML opts (smallCapsName:style) lst
+inlineToICML opts style (Quoted SingleQuote lst) = inlinesToICML opts style $ [Str "‘"] ++ lst ++ [Str "’"]
+inlineToICML opts style (Quoted DoubleQuote lst) = inlinesToICML opts style $ [Str "“"] ++ lst ++ [Str "”"]
+inlineToICML opts style (Cite _ lst) = inlinesToICML opts (citeName:style) lst
+inlineToICML _ style (Code _ str) = charStyle (codeName:style) $ text $ escapeStringForXML str
+inlineToICML _ style Space = charStyle style space
+inlineToICML opts style SoftBreak =
+ case writerWrapText opts of
+ WrapAuto -> charStyle style space
+ WrapNone -> charStyle style space
+ WrapPreserve -> charStyle style cr
+inlineToICML _ style LineBreak = charStyle style $ text lineSeparator
+inlineToICML opts style (Math mt str) =
+ lift (texMathToInlines mt str) >>=
+ (fmap cat . mapM (inlineToICML opts style))
+inlineToICML _ _ il@(RawInline f str)
+ | f == Format "icml" = return $ text str
+ | otherwise = do
+ report $ InlineNotRendered il
+ return empty
+inlineToICML opts style (Link _ lst (url, title)) = do
+ content <- inlinesToICML opts (linkName:style) lst
+ state $ \st ->
+ let ident = if null $ links st
+ then 1::Int
+ else 1 + (fst $ head $ links st)
+ newst = st{ links = (ident, url):(links st) }
+ cont = inTags True "HyperlinkTextSource"
+ [("Self","htss-"++show ident), ("Name",title), ("Hidden","false")] content
+ in (cont, newst)
+inlineToICML opts style (Image attr _ target) = imageICML opts style attr target
+inlineToICML opts style (Note lst) = footnoteToICML opts style lst
+inlineToICML opts style (Span _ lst) = inlinesToICML opts style lst
+
+-- | Convert a list of block elements to an ICML footnote.
+footnoteToICML :: PandocMonad m => WriterOptions -> Style -> [Block] -> WS m Doc
+footnoteToICML opts style lst =
+ let insertTab (Para ls) = blockToICML opts (footnoteName:style) $ Para $ (Str "\t"):ls
+ insertTab block = blockToICML opts (footnoteName:style) block
+ in do
+ contents <- mapM insertTab lst
+ let number = inTags True "ParagraphStyleRange" [] $
+ inTags True "CharacterStyleRange" [] $ inTagsSimple "Content" "<?ACE 4?>"
+ return $ inTags True "CharacterStyleRange"
+ [("AppliedCharacterStyle","$ID/NormalCharacterStyle"), ("Position","Superscript")]
+ $ inTags True "Footnote" [] $ number $$ intersperseBrs contents
+
+-- | Auxiliary function to merge Space elements into the adjacent Strs.
+mergeSpaces :: [Inline] -> [Inline]
+mergeSpaces ((Str s):(x:((Str s'):xs))) | isSp x =
+ mergeSpaces $ Str(s++" "++s') : xs
+mergeSpaces (x:((Str s):xs)) | isSp x = mergeSpaces $ Str (" "++s) : xs
+mergeSpaces ((Str s):(x:xs)) | isSp x = mergeSpaces $ Str (s++" ") : xs
+mergeSpaces (x:xs) = x : (mergeSpaces xs)
+mergeSpaces [] = []
+
+isSp :: Inline -> Bool
+isSp Space = True
+isSp SoftBreak = True
+isSp _ = False
+
+-- | Intersperse line breaks
+intersperseBrs :: [Doc] -> Doc
+intersperseBrs = vcat . intersperse (selfClosingTag "Br" []) . filter (not . isEmpty)
+
+-- | Wrap a list of inline elements in an ICML Paragraph Style
+parStyle :: PandocMonad m => WriterOptions -> Style -> [Inline] -> WS m Doc
+parStyle opts style lst =
+ let slipIn x y = if null y
+ then x
+ else x ++ " > " ++ y
+ stlStr = foldr slipIn [] $ reverse style
+ stl = if null stlStr
+ then ""
+ else "ParagraphStyle/" ++ stlStr
+ attrs = ("AppliedParagraphStyle", stl)
+ attrs' = if firstListItemName `elem` style
+ then let ats = attrs : [("NumberingContinue", "false")]
+ begins = filter (isPrefixOf beginsWithName) style
+ in if null begins
+ then ats
+ else let i = maybe "" id $ stripPrefix beginsWithName $ head begins
+ in ("NumberingStartAt", i) : ats
+ else [attrs]
+ in do
+ content <- inlinesToICML opts [] lst
+ let cont = inTags True "ParagraphStyleRange" attrs' content
+ state $ \st -> (cont, st{ blockStyles = Set.insert stlStr $ blockStyles st })
+
+-- | Wrap a Doc in an ICML Character Style.
+charStyle :: PandocMonad m => Style -> Doc -> WS m Doc
+charStyle style content =
+ let (stlStr, attrs) = styleToStrAttr style
+ doc = inTags True "CharacterStyleRange" attrs $ inTagsSimple "Content" $ flush content
+ in do
+ state $ \st ->
+ let styles = if null stlStr
+ then st
+ else st{ inlineStyles = Set.insert stlStr $ inlineStyles st }
+ in (doc, styles)
+
+-- | Transform a Style to a tuple of String (eliminating duplicates and ordered) and corresponding attribute.
+styleToStrAttr :: Style -> (String, [(String, String)])
+styleToStrAttr style =
+ let stlStr = unwords $ Set.toAscList $ Set.fromList style
+ stl = if null style
+ then "$ID/NormalCharacterStyle"
+ else "CharacterStyle/" ++ stlStr
+ attrs = [("AppliedCharacterStyle", stl)]
+ in (stlStr, attrs)
+
+-- | Assemble an ICML Image.
+imageICML :: PandocMonad m => WriterOptions -> Style -> Attr -> Target -> WS m Doc
+imageICML opts style attr (src, _) = do
+ res <- runExceptT $ lift $ P.fetchItem (writerSourceURL opts) src
+ imgS <- case res of
+ Left (_ :: PandocError) -> do
+ report $ CouldNotFetchResource src ""
+ return def
+ Right (img, _) -> do
+ case imageSize img of
+ Right size -> return size
+ Left msg -> do
+ report $ CouldNotDetermineImageSize src msg
+ return def
+ let (ow, oh) = sizeInPoints imgS
+ (imgWidth, imgHeight) = desiredSizeInPoints opts attr imgS
+ hw = showFl $ ow / 2
+ hh = showFl $ oh / 2
+ scale = showFl (imgWidth / ow) ++ " 0 0 " ++ showFl (imgHeight / oh)
+ src' = if isURI src then src else "file:" ++ src
+ (stlStr, attrs) = styleToStrAttr style
+ props = inTags True "Properties" [] $ inTags True "PathGeometry" []
+ $ inTags True "GeometryPathType" [("PathOpen","false")]
+ $ inTags True "PathPointArray" []
+ $ vcat [
+ selfClosingTag "PathPointType" [("Anchor", "-"++hw++" -"++hh),
+ ("LeftDirection", "-"++hw++" -"++hh), ("RightDirection", "-"++hw++" -"++hh)]
+ , selfClosingTag "PathPointType" [("Anchor", "-"++hw++" "++hh),
+ ("LeftDirection", "-"++hw++" "++hh), ("RightDirection", "-"++hw++" "++hh)]
+ , selfClosingTag "PathPointType" [("Anchor", hw++" "++hh),
+ ("LeftDirection", hw++" "++hh), ("RightDirection", hw++" "++hh)]
+ , selfClosingTag "PathPointType" [("Anchor", hw++" -"++hh),
+ ("LeftDirection", hw++" -"++hh), ("RightDirection", hw++" -"++hh)]
+ ]
+ image = inTags True "Image"
+ [("Self","ue6"), ("ItemTransform", scale++" -"++hw++" -"++hh)]
+ $ vcat [
+ inTags True "Properties" [] $ inTags True "Profile" [("type","string")] $ text "$ID/Embedded"
+ , selfClosingTag "Link" [("Self", "ueb"), ("LinkResourceURI", src')]
+ ]
+ doc = inTags True "CharacterStyleRange" attrs
+ $ inTags True "Rectangle" [("Self","uec"), ("StrokeWeight", "0"),
+ ("ItemTransform", scale++" "++hw++" -"++hh)]
+ $ (props $$ image)
+ state $ \st -> (doc, st{ inlineStyles = Set.insert stlStr $ inlineStyles st } )
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
new file mode 100644
index 000000000..ac2b5d758
--- /dev/null
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -0,0 +1,1388 @@
+{-# LANGUAGE OverloadedStrings, ScopedTypeVariables,
+ PatternGuards #-}
+{-
+Copyright (C) 2006-2015 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.LaTeX
+ Copyright : Copyright (C) 2006-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' format into LaTeX.
+-}
+module Text.Pandoc.Writers.LaTeX (
+ writeLaTeX
+ , writeBeamer
+ ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Walk
+import Text.Pandoc.Shared
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Options
+import Text.Pandoc.Templates
+import Text.Pandoc.Logging
+import Text.Printf ( printf )
+import Network.URI ( isURI, unEscapeString )
+import Data.Aeson (object, (.=), FromJSON)
+import Data.List ( (\\), isInfixOf, stripPrefix, intercalate, intersperse,
+ nub, nubBy, foldl' )
+import Data.Char ( toLower, isPunctuation, isAscii, isLetter, isDigit,
+ ord, isAlphaNum )
+import Data.Maybe ( fromMaybe, isJust, catMaybes )
+import qualified Data.Text as T
+import Control.Applicative ((<|>))
+import Control.Monad.State
+import qualified Text.Parsec as P
+import Text.Pandoc.Pretty
+import Text.Pandoc.ImageSize
+import Text.Pandoc.Slides
+import Text.Pandoc.Highlighting (highlight, styleToLaTeX,
+ formatLaTeXInline, formatLaTeXBlock,
+ toListingsLanguage)
+import Text.Pandoc.Class (PandocMonad, report)
+
+data WriterState =
+ WriterState { stInNote :: Bool -- true if we're in a note
+ , stInQuote :: Bool -- true if in a blockquote
+ , stInMinipage :: Bool -- true if in minipage
+ , stInHeading :: Bool -- true if in a section heading
+ , stNotes :: [Doc] -- notes in a minipage
+ , stOLLevel :: Int -- level of ordered list nesting
+ , stOptions :: WriterOptions -- writer options, so they don't have to be parameter
+ , stVerbInNote :: Bool -- true if document has verbatim text in note
+ , stTable :: Bool -- true if document has a table
+ , stStrikeout :: Bool -- true if document has strikeout
+ , stUrl :: Bool -- true if document has visible URL link
+ , stGraphics :: Bool -- true if document contains images
+ , stLHS :: Bool -- true if document has literate haskell code
+ , stBook :: Bool -- true if document uses book or memoir class
+ , stCsquotes :: Bool -- true if document uses csquotes
+ , stHighlighting :: Bool -- true if document has highlighted code
+ , stIncremental :: Bool -- true if beamer lists should be displayed bit by bit
+ , stInternalLinks :: [String] -- list of internal link targets
+ , stUsesEuro :: Bool -- true if euro symbol used
+ , stBeamer :: Bool -- produce beamer
+ }
+
+startingState :: WriterOptions -> WriterState
+startingState options = WriterState {
+ stInNote = False
+ , stInQuote = False
+ , stInMinipage = False
+ , stInHeading = False
+ , stNotes = []
+ , stOLLevel = 1
+ , stOptions = options
+ , stVerbInNote = False
+ , stTable = False
+ , stStrikeout = False
+ , stUrl = False
+ , stGraphics = False
+ , stLHS = False
+ , stBook = (case writerTopLevelDivision options of
+ TopLevelPart -> True
+ TopLevelChapter -> True
+ _ -> False)
+ , stCsquotes = False
+ , stHighlighting = False
+ , stIncremental = writerIncremental options
+ , stInternalLinks = []
+ , stUsesEuro = False
+ , stBeamer = False }
+
+-- | Convert Pandoc to LaTeX.
+writeLaTeX :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeLaTeX options document =
+ evalStateT (pandocToLaTeX options document) $
+ startingState options
+
+-- | Convert Pandoc to LaTeX Beamer.
+writeBeamer :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeBeamer options document =
+ evalStateT (pandocToLaTeX options document) $
+ (startingState options){ stBeamer = True }
+
+type LW m = StateT WriterState m
+
+pandocToLaTeX :: PandocMonad m
+ => WriterOptions -> Pandoc -> LW m String
+pandocToLaTeX options (Pandoc meta blocks) = do
+ -- Strip off final 'references' header if --natbib or --biblatex
+ let method = writerCiteMethod options
+ let blocks' = if method == Biblatex || method == Natbib
+ then case reverse blocks of
+ (Div (_,["references"],_) _):xs -> reverse xs
+ _ -> blocks
+ else blocks
+ -- see if there are internal links
+ let isInternalLink (Link _ _ ('#':xs,_)) = [xs]
+ isInternalLink _ = []
+ modify $ \s -> s{ stInternalLinks = query isInternalLink blocks' }
+ let template = maybe "" id $ writerTemplate options
+ -- set stBook depending on documentclass
+ let colwidth = if writerWrapText options == WrapAuto
+ then Just $ writerColumns options
+ else Nothing
+ metadata <- metaToJSON options
+ (fmap (render colwidth) . blockListToLaTeX)
+ (fmap (render colwidth) . inlineListToLaTeX)
+ meta
+ let bookClasses = ["memoir","book","report","scrreprt","scrbook"]
+ let documentClass = case P.parse pDocumentClass "template" template of
+ Right r -> r
+ Left _ -> ""
+ case lookup "documentclass" (writerVariables options) `mplus`
+ fmap stringify (lookupMeta "documentclass" meta) of
+ Just x | x `elem` bookClasses -> modify $ \s -> s{stBook = True}
+ | otherwise -> return ()
+ Nothing | documentClass `elem` bookClasses
+ -> modify $ \s -> s{stBook = True}
+ | otherwise -> return ()
+ -- check for \usepackage...{csquotes}; if present, we'll use
+ -- \enquote{...} for smart quotes:
+ let headerIncludesField :: FromJSON a => Maybe a
+ headerIncludesField = getField "header-includes" metadata
+ let headerIncludes = fromMaybe [] $ mplus
+ (fmap return headerIncludesField)
+ headerIncludesField
+ when (any (isInfixOf "{csquotes}") (template : headerIncludes)) $
+ modify $ \s -> s{stCsquotes = True}
+ let (blocks'', lastHeader) = if writerCiteMethod options == Citeproc then
+ (blocks', [])
+ else case last blocks' of
+ Header 1 _ il -> (init blocks', il)
+ _ -> (blocks', [])
+ beamer <- gets stBeamer
+ blocks''' <- if beamer
+ then toSlides blocks''
+ else return blocks''
+ body <- mapM (elementToLaTeX options) $ hierarchicalize blocks'''
+ (biblioTitle :: String) <- liftM (render colwidth) $ inlineListToLaTeX lastHeader
+ let main = render colwidth $ vsep body
+ st <- get
+ titleMeta <- stringToLaTeX TextString $ stringify $ docTitle meta
+ authorsMeta <- mapM (stringToLaTeX TextString . stringify) $ docAuthors meta
+ let docLangs = nub $ query (extract "lang") blocks
+ let hasStringValue x = isJust (getField x metadata :: Maybe String)
+ let geometryFromMargins = intercalate [','] $ catMaybes $
+ map (\(x,y) ->
+ ((x ++ "=") ++) <$> getField y metadata)
+ [("lmargin","margin-left")
+ ,("rmargin","margin-right")
+ ,("tmargin","margin-top")
+ ,("bmargin","margin-bottom")
+ ]
+ let context = defField "toc" (writerTableOfContents options) $
+ defField "toc-depth" (show (writerTOCDepth options -
+ if stBook st
+ then 1
+ else 0)) $
+ defField "body" main $
+ defField "title-meta" titleMeta $
+ defField "author-meta" (intercalate "; " authorsMeta) $
+ defField "documentclass" (if beamer
+ then ("beamer" :: String)
+ else if stBook st
+ then "book"
+ else "article") $
+ defField "verbatim-in-note" (stVerbInNote st) $
+ defField "tables" (stTable st) $
+ defField "strikeout" (stStrikeout st) $
+ defField "url" (stUrl st) $
+ defField "numbersections" (writerNumberSections options) $
+ defField "lhs" (stLHS st) $
+ defField "graphics" (stGraphics st) $
+ defField "book-class" (stBook st) $
+ defField "euro" (stUsesEuro st) $
+ defField "listings" (writerListings options || stLHS st) $
+ defField "beamer" beamer $
+ (if stHighlighting st
+ then case writerHighlightStyle options of
+ Just sty ->
+ defField "highlighting-macros"
+ (styleToLaTeX sty)
+ Nothing -> id
+ else id) $
+ (case writerCiteMethod options of
+ Natbib -> defField "biblio-title" biblioTitle .
+ defField "natbib" True
+ Biblatex -> defField "biblio-title" biblioTitle .
+ defField "biblatex" True
+ _ -> id) $
+ -- set lang to something so polyglossia/babel is included
+ defField "lang" (if null docLangs then ""::String else "en") $
+ defField "otherlangs" docLangs $
+ defField "colorlinks" (any hasStringValue
+ ["citecolor", "urlcolor", "linkcolor", "toccolor"]) $
+ defField "dir" (if (null $ query (extract "dir") blocks)
+ then ""::String
+ else "ltr") $
+ defField "section-titles" True $
+ defField "geometry" geometryFromMargins $
+ metadata
+ let toPolyObj lang = object [ "name" .= T.pack name
+ , "options" .= T.pack opts ]
+ where
+ (name, opts) = toPolyglossia lang
+ let lang = maybe [] (splitBy (=='-')) $ getField "lang" context
+ otherlangs = maybe [] (map $ splitBy (=='-')) $ getField "otherlangs" context
+ let context' =
+ defField "babel-lang" (toBabel lang)
+ $ defField "babel-otherlangs" (map toBabel otherlangs)
+ $ defField "babel-newcommands" (concatMap (\(poly, babel) ->
+ -- \textspanish and \textgalician are already used by babel
+ -- save them as \oritext... and let babel use that
+ if poly `elem` ["spanish", "galician"]
+ then "\\let\\oritext" ++ poly ++ "\\text" ++ poly ++ "\n" ++
+ "\\AddBabelHook{" ++ poly ++ "}{beforeextras}" ++
+ "{\\renewcommand{\\text" ++ poly ++ "}{\\oritext"
+ ++ poly ++ "}}\n" ++
+ "\\AddBabelHook{" ++ poly ++ "}{afterextras}" ++
+ "{\\renewcommand{\\text" ++ poly ++ "}[2][]{\\foreignlanguage{"
+ ++ poly ++ "}{##2}}}\n"
+ else "\\newcommand{\\text" ++ poly ++ "}[2][]{\\foreignlanguage{"
+ ++ babel ++ "}{#2}}\n" ++
+ "\\newenvironment{" ++ poly ++ "}[2][]{\\begin{otherlanguage}{"
+ ++ babel ++ "}}{\\end{otherlanguage}}\n"
+ )
+ -- eliminate duplicates that have same polyglossia name
+ $ nubBy (\a b -> fst a == fst b)
+ -- find polyglossia and babel names of languages used in the document
+ $ map (\l ->
+ let lng = splitBy (=='-') l
+ in (fst $ toPolyglossia lng, toBabel lng)
+ )
+ docLangs )
+ $ defField "polyglossia-lang" (toPolyObj lang)
+ $ defField "polyglossia-otherlangs" (map toPolyObj otherlangs)
+ $ defField "latex-dir-rtl" (case (getField "dir" context)::Maybe String of
+ Just "rtl" -> True
+ _ -> False)
+ $ context
+ return $ case writerTemplate options of
+ Nothing -> main
+ Just tpl -> renderTemplate' tpl context'
+
+-- | Convert Elements to LaTeX
+elementToLaTeX :: PandocMonad m => WriterOptions -> Element -> LW m Doc
+elementToLaTeX _ (Blk block) = blockToLaTeX block
+elementToLaTeX opts (Sec level _ (id',classes,_) title' elements) = do
+ modify $ \s -> s{stInHeading = True}
+ header' <- sectionHeader ("unnumbered" `elem` classes) id' level title'
+ modify $ \s -> s{stInHeading = False}
+ innerContents <- mapM (elementToLaTeX opts) elements
+ return $ vsep (header' : innerContents)
+
+data StringContext = TextString
+ | URLString
+ | CodeString
+ deriving (Eq)
+
+-- escape things as needed for LaTeX
+stringToLaTeX :: PandocMonad m => StringContext -> String -> LW m String
+stringToLaTeX _ [] = return ""
+stringToLaTeX ctx (x:xs) = do
+ opts <- gets stOptions
+ rest <- stringToLaTeX ctx xs
+ let ligatures = isEnabled Ext_smart opts && ctx == TextString
+ let isUrl = ctx == URLString
+ when (x == '€') $
+ modify $ \st -> st{ stUsesEuro = True }
+ return $
+ case x of
+ '€' -> "\\euro{}" ++ rest
+ '{' -> "\\{" ++ 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
+
+toLabel :: PandocMonad m => String -> LW m String
+toLabel z = go `fmap` stringToLaTeX URLString z
+ where go [] = ""
+ go (x:xs)
+ | (isLetter x || isDigit x) && isAscii x = x:go xs
+ | elem x ("_-+=:;." :: String) = x:go xs
+ | otherwise = "ux" ++ printf "%x" (ord x) ++ go xs
+
+-- | Puts contents into LaTeX command.
+inCmd :: String -> Doc -> Doc
+inCmd cmd contents = char '\\' <> text cmd <> braces contents
+
+toSlides :: PandocMonad m => [Block] -> LW m [Block]
+toSlides bs = do
+ opts <- gets stOptions
+ let slideLevel = fromMaybe (getSlideLevel bs) $ writerSlideLevel opts
+ let bs' = prepSlides slideLevel bs
+ concat `fmap` (mapM (elementToBeamer slideLevel) $ hierarchicalize bs')
+
+elementToBeamer :: PandocMonad m => Int -> Element -> LW m [Block]
+elementToBeamer _slideLevel (Blk b) = return [b]
+elementToBeamer slideLevel (Sec lvl _num (ident,classes,kvs) tit elts)
+ | lvl > slideLevel = do
+ bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts
+ return $ Para ( RawInline "latex" "\\begin{block}{"
+ : tit ++ [RawInline "latex" "}"] )
+ : bs ++ [RawBlock "latex" "\\end{block}"]
+ | lvl < slideLevel = do
+ bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts
+ return $ (Header lvl (ident,classes,kvs) tit) : bs
+ | otherwise = do -- lvl == slideLevel
+ -- note: [fragile] is required or verbatim breaks
+ let hasCodeBlock (CodeBlock _ _) = [True]
+ hasCodeBlock _ = []
+ let hasCode (Code _ _) = [True]
+ hasCode _ = []
+ let fragile = "fragile" `elem` classes ||
+ not (null $ query hasCodeBlock elts ++ query hasCode elts)
+ let frameoptions = ["allowdisplaybreaks", "allowframebreaks",
+ "b", "c", "t", "environment",
+ "label", "plain", "shrink", "standout"]
+ let optionslist = ["fragile" | fragile] ++
+ [k | k <- classes, k `elem` frameoptions] ++
+ [k ++ "=" ++ v | (k,v) <- kvs, k `elem` frameoptions]
+ let options = if null optionslist
+ then ""
+ else "[" ++ intercalate "," optionslist ++ "]"
+ let slideStart = Para $ RawInline "latex" ("\\begin{frame}" ++ options) :
+ if tit == [Str "\0"] -- marker for hrule
+ then []
+ else (RawInline "latex" "{") : tit ++ [RawInline "latex" "}"]
+ let slideEnd = RawBlock "latex" "\\end{frame}"
+ -- now carve up slide into blocks if there are sections inside
+ bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts
+ return $ slideStart : bs ++ [slideEnd]
+
+isListBlock :: Block -> Bool
+isListBlock (BulletList _) = True
+isListBlock (OrderedList _ _) = True
+isListBlock (DefinitionList _) = True
+isListBlock _ = False
+
+isLineBreakOrSpace :: Inline -> Bool
+isLineBreakOrSpace LineBreak = True
+isLineBreakOrSpace SoftBreak = True
+isLineBreakOrSpace Space = True
+isLineBreakOrSpace _ = False
+
+-- | Convert Pandoc block element to LaTeX.
+blockToLaTeX :: PandocMonad m
+ => Block -- ^ Block to convert
+ -> LW m Doc
+blockToLaTeX Null = return empty
+blockToLaTeX (Div (identifier,classes,kvs) bs) = do
+ beamer <- gets stBeamer
+ ref <- toLabel identifier
+ let linkAnchor = if null identifier
+ then empty
+ else "\\hypertarget" <> braces (text ref) <>
+ braces empty
+ let align dir txt = inCmd "begin" dir $$ txt $$ inCmd "end" dir
+ let wrapDir = case lookup "dir" kvs of
+ Just "rtl" -> align "RTL"
+ Just "ltr" -> align "LTR"
+ _ -> id
+ wrapLang txt = case lookup "lang" kvs of
+ Just lng -> let (l, o) = toPolyglossiaEnv lng
+ ops = if null o
+ then ""
+ else brackets $ text o
+ in inCmd "begin" (text l) <> ops
+ $$ blankline <> txt <> blankline
+ $$ inCmd "end" (text l)
+ Nothing -> txt
+ wrapNotes txt = if beamer && "notes" `elem` classes
+ then "\\note" <> braces txt -- speaker notes
+ else linkAnchor $$ txt
+ fmap (wrapDir . wrapLang . wrapNotes) $ blockListToLaTeX bs
+blockToLaTeX (Plain lst) =
+ inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
+-- title beginning with fig: indicates that the image is a figure
+blockToLaTeX (Para [Image attr@(ident, _, _) txt (src,'f':'i':'g':':':tit)]) = do
+ inNote <- gets stInNote
+ modify $ \st -> st{ stInMinipage = True, stNotes = [] }
+ capt <- inlineListToLaTeX txt
+ notes <- gets stNotes
+ modify $ \st -> st{ stInMinipage = False, stNotes = [] }
+
+ -- We can't have footnotes in the list of figures, so remove them:
+ captForLof <- if null notes
+ then return empty
+ else brackets <$> inlineListToLaTeX (walk deNote txt)
+ img <- inlineToLaTeX (Image attr txt (src,tit))
+ let footnotes = notesToLaTeX notes
+ lab <- labelFor ident
+ let caption = "\\caption" <> captForLof <> braces capt <> lab
+ figure <- hypertarget ident (cr <>
+ "\\begin{figure}" $$ "\\centering" $$ img $$
+ caption $$ "\\end{figure}" <> cr)
+ return $ if inNote
+ -- can't have figures in notes
+ then "\\begin{center}" $$ img $+$ capt $$ "\\end{center}"
+ else figure $$ footnotes
+-- . . . indicates pause in beamer slides
+blockToLaTeX (Para [Str ".",Space,Str ".",Space,Str "."]) = do
+ beamer <- gets stBeamer
+ if beamer
+ then blockToLaTeX (RawBlock "latex" "\\pause")
+ else inlineListToLaTeX [Str ".",Space,Str ".",Space,Str "."]
+blockToLaTeX (Para lst) =
+ inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
+blockToLaTeX (LineBlock lns) = do
+ blockToLaTeX $ linesToPara lns
+blockToLaTeX (BlockQuote lst) = do
+ beamer <- gets stBeamer
+ case lst of
+ [b] | beamer && isListBlock b -> do
+ oldIncremental <- gets stIncremental
+ modify $ \s -> s{ stIncremental = not oldIncremental }
+ result <- blockToLaTeX b
+ modify $ \s -> s{ stIncremental = oldIncremental }
+ return result
+ _ -> do
+ oldInQuote <- gets stInQuote
+ modify (\s -> s{stInQuote = True})
+ contents <- blockListToLaTeX lst
+ modify (\s -> s{stInQuote = oldInQuote})
+ return $ "\\begin{quote}" $$ contents $$ "\\end{quote}"
+blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do
+ opts <- gets stOptions
+ ref <- toLabel identifier
+ let linkAnchor = if null identifier
+ then empty
+ else "\\hypertarget" <> braces (text ref) <>
+ braces ("\\label" <> braces (text ref))
+ let lhsCodeBlock = do
+ modify $ \s -> s{ stLHS = True }
+ return $ flush (linkAnchor $$ "\\begin{code}" $$ text str $$
+ "\\end{code}") $$ cr
+ let rawCodeBlock = do
+ st <- get
+ env <- if stInNote st
+ then modify (\s -> s{ stVerbInNote = True }) >>
+ return "Verbatim"
+ else return "verbatim"
+ return $ flush (linkAnchor $$ text ("\\begin{" ++ env ++ "}") $$
+ text str $$ text ("\\end{" ++ env ++ "}")) <> cr
+ let listingsCodeBlock = do
+ st <- get
+ let params = if writerListings (stOptions st)
+ then (case getListingsLanguage classes of
+ Just l -> [ "language=" ++ mbBraced l ]
+ Nothing -> []) ++
+ [ "numbers=left" | "numberLines" `elem` classes
+ || "number" `elem` classes
+ || "number-lines" `elem` classes ] ++
+ [ (if key == "startFrom"
+ then "firstnumber"
+ else key) ++ "=" ++ mbBraced attr |
+ (key,attr) <- keyvalAttr ] ++
+ (if identifier == ""
+ then []
+ else [ "label=" ++ ref ])
+
+ else []
+ printParams
+ | null params = empty
+ | otherwise = brackets $ hcat (intersperse ", "
+ (map text params))
+ return $ flush ("\\begin{lstlisting}" <> printParams $$ text str $$
+ "\\end{lstlisting}") $$ cr
+ let highlightedCodeBlock =
+ case highlight formatLaTeXBlock ("",classes,keyvalAttr) str of
+ Nothing -> rawCodeBlock
+ Just h -> modify (\st -> st{ stHighlighting = True }) >>
+ return (flush $ linkAnchor $$ text (T.unpack h))
+ case () of
+ _ | isEnabled Ext_literate_haskell opts && "haskell" `elem` classes &&
+ "literate" `elem` classes -> lhsCodeBlock
+ | writerListings opts -> listingsCodeBlock
+ | not (null classes) && isJust (writerHighlightStyle opts)
+ -> highlightedCodeBlock
+ | otherwise -> rawCodeBlock
+blockToLaTeX b@(RawBlock f x)
+ | f == Format "latex" || f == Format "tex"
+ = return $ text x
+ | otherwise = do
+ report $ BlockNotRendered b
+ return empty
+blockToLaTeX (BulletList []) = return empty -- otherwise latex error
+blockToLaTeX (BulletList lst) = do
+ incremental <- gets stIncremental
+ beamer <- gets stBeamer
+ let inc = if beamer && incremental then "[<+->]" else ""
+ items <- mapM listItemToLaTeX lst
+ let spacing = if isTightList lst
+ then text "\\tightlist"
+ else empty
+ return $ text ("\\begin{itemize}" ++ inc) $$ spacing $$ vcat items $$
+ "\\end{itemize}"
+blockToLaTeX (OrderedList _ []) = return empty -- otherwise latex error
+blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
+ st <- get
+ let inc = if stIncremental st then "[<+->]" else ""
+ let oldlevel = stOLLevel st
+ put $ st {stOLLevel = oldlevel + 1}
+ items <- mapM listItemToLaTeX lst
+ modify (\s -> s {stOLLevel = oldlevel})
+ let tostyle x = case numstyle of
+ Decimal -> "\\arabic" <> braces x
+ UpperRoman -> "\\Roman" <> braces x
+ LowerRoman -> "\\roman" <> braces x
+ UpperAlpha -> "\\Alph" <> braces x
+ LowerAlpha -> "\\alph" <> braces x
+ Example -> "\\arabic" <> braces x
+ DefaultStyle -> "\\arabic" <> braces x
+ let todelim x = case numdelim of
+ OneParen -> x <> ")"
+ TwoParens -> parens x
+ Period -> x <> "."
+ _ -> x <> "."
+ let enum = text $ "enum" ++ map toLower (toRomanNumeral oldlevel)
+ let stylecommand = if numstyle == DefaultStyle && numdelim == DefaultDelim
+ then empty
+ else "\\def" <> "\\label" <> enum <>
+ braces (todelim $ tostyle enum)
+ let resetcounter = if start == 1 || oldlevel > 4
+ then empty
+ else "\\setcounter" <> braces enum <>
+ braces (text $ show $ start - 1)
+ let spacing = if isTightList lst
+ then text "\\tightlist"
+ else empty
+ return $ text ("\\begin{enumerate}" ++ inc)
+ $$ stylecommand
+ $$ resetcounter
+ $$ spacing
+ $$ vcat items
+ $$ "\\end{enumerate}"
+blockToLaTeX (DefinitionList []) = return empty
+blockToLaTeX (DefinitionList lst) = do
+ incremental <- gets stIncremental
+ let inc = if incremental then "[<+->]" else ""
+ items <- mapM defListItemToLaTeX lst
+ let spacing = if all isTightList (map snd lst)
+ then text "\\tightlist"
+ else empty
+ return $ text ("\\begin{description}" ++ inc) $$ spacing $$ vcat items $$
+ "\\end{description}"
+blockToLaTeX HorizontalRule = return $
+ "\\begin{center}\\rule{0.5\\linewidth}{\\linethickness}\\end{center}"
+blockToLaTeX (Header level (id',classes,_) lst) = do
+ modify $ \s -> s{stInHeading = True}
+ hdr <- sectionHeader ("unnumbered" `elem` classes) id' level lst
+ modify $ \s -> s{stInHeading = False}
+ return hdr
+blockToLaTeX (Table caption aligns widths heads rows) = do
+ headers <- if all null heads
+ then return empty
+ else do
+ contents <- (tableRowToLaTeX True aligns widths) heads
+ return ("\\toprule" $$ contents $$ "\\midrule")
+ let endhead = if all null heads
+ then empty
+ else text "\\endhead"
+ let endfirsthead = if all null heads
+ then empty
+ else text "\\endfirsthead"
+ captionText <- inlineListToLaTeX caption
+ let capt = if isEmpty captionText
+ then empty
+ else text "\\caption" <> braces captionText <> "\\tabularnewline"
+ $$ headers
+ $$ endfirsthead
+ rows' <- mapM (tableRowToLaTeX False aligns widths) rows
+ let colDescriptors = text $ concat $ map toColDescriptor aligns
+ modify $ \s -> s{ stTable = True }
+ return $ "\\begin{longtable}[]" <>
+ braces ("@{}" <> colDescriptors <> "@{}")
+ -- the @{} removes extra space at beginning and end
+ $$ capt
+ $$ (if all null heads then "\\toprule" else empty)
+ $$ headers
+ $$ endhead
+ $$ vcat rows'
+ $$ "\\bottomrule"
+ $$ "\\end{longtable}"
+
+toColDescriptor :: Alignment -> String
+toColDescriptor align =
+ case align of
+ AlignLeft -> "l"
+ AlignRight -> "r"
+ AlignCenter -> "c"
+ AlignDefault -> "l"
+
+blockListToLaTeX :: PandocMonad m => [Block] -> LW m Doc
+blockListToLaTeX lst = vsep `fmap` mapM blockToLaTeX lst
+
+tableRowToLaTeX :: PandocMonad m
+ => Bool
+ -> [Alignment]
+ -> [Double]
+ -> [[Block]]
+ -> LW m Doc
+tableRowToLaTeX header aligns widths cols = do
+ -- scale factor compensates for extra space between columns
+ -- so the whole table isn't larger than columnwidth
+ let scaleFactor = 0.97 ** fromIntegral (length aligns)
+ let isSimple [Plain _] = True
+ isSimple [Para _] = True
+ isSimple [] = True
+ isSimple _ = False
+ -- simple tables have to have simple cells:
+ let widths' = if not (all isSimple cols)
+ then replicate (length aligns)
+ (0.97 / fromIntegral (length aligns))
+ else map (scaleFactor *) widths
+ cells <- mapM (tableCellToLaTeX header) $ zip3 widths' aligns cols
+ return $ hsep (intersperse "&" cells) <> "\\tabularnewline"
+
+-- For simple latex tables (without minipages or parboxes),
+-- we need to go to some lengths to get line breaks working:
+-- as LineBreak bs = \vtop{\hbox{\strut as}\hbox{\strut bs}}.
+fixLineBreaks :: Block -> Block
+fixLineBreaks (Para ils) = Para $ fixLineBreaks' ils
+fixLineBreaks (Plain ils) = Plain $ fixLineBreaks' ils
+fixLineBreaks x = x
+
+fixLineBreaks' :: [Inline] -> [Inline]
+fixLineBreaks' ils = case splitBy (== LineBreak) ils of
+ [] -> []
+ [xs] -> xs
+ chunks -> RawInline "tex" "\\vtop{" :
+ concatMap tohbox chunks ++
+ [RawInline "tex" "}"]
+ where tohbox ys = RawInline "tex" "\\hbox{\\strut " : ys ++
+ [RawInline "tex" "}"]
+
+-- We also change display math to inline math, since display
+-- math breaks in simple tables.
+displayMathToInline :: Inline -> Inline
+displayMathToInline (Math DisplayMath x) = Math InlineMath x
+displayMathToInline x = x
+
+tableCellToLaTeX :: PandocMonad m => Bool -> (Double, Alignment, [Block])
+ -> LW m Doc
+tableCellToLaTeX _ (0, _, blocks) =
+ blockListToLaTeX $ walk fixLineBreaks $ walk displayMathToInline blocks
+tableCellToLaTeX header (width, align, blocks) = do
+ modify $ \st -> st{ stInMinipage = True, stNotes = [] }
+ cellContents <- blockListToLaTeX blocks
+ notes <- gets stNotes
+ modify $ \st -> st{ stInMinipage = False, stNotes = [] }
+ let valign = text $ if header then "[b]" else "[t]"
+ let halign = case align of
+ AlignLeft -> "\\raggedright"
+ AlignRight -> "\\raggedleft"
+ AlignCenter -> "\\centering"
+ AlignDefault -> "\\raggedright"
+ return $ ("\\begin{minipage}" <> valign <>
+ braces (text (printf "%.2f\\columnwidth" width)) <>
+ (halign <> "\\strut" <> cr <> cellContents <> "\\strut" <> cr) <>
+ "\\end{minipage}") $$
+ notesToLaTeX notes
+
+notesToLaTeX :: [Doc] -> Doc
+notesToLaTeX [] = empty
+notesToLaTeX ns = (case length ns of
+ n | n > 1 -> "\\addtocounter" <>
+ braces "footnote" <>
+ braces (text $ show $ 1 - n)
+ | otherwise -> empty)
+ $$
+ vcat (intersperse
+ ("\\addtocounter" <> braces "footnote" <> braces "1")
+ $ map (\x -> "\\footnotetext" <> braces x)
+ $ reverse ns)
+
+listItemToLaTeX :: PandocMonad m => [Block] -> LW m Doc
+listItemToLaTeX lst
+ -- we need to put some text before a header if it's the first
+ -- element in an item. This will look ugly in LaTeX regardless, but
+ -- this will keep the typesetter from throwing an error.
+ | ((Header _ _ _) :_) <- lst =
+ blockListToLaTeX lst >>= return . (text "\\item ~" $$) . (nest 2)
+ | otherwise = blockListToLaTeX lst >>= return . (text "\\item" $$) .
+ (nest 2)
+
+defListItemToLaTeX :: PandocMonad m => ([Inline], [[Block]]) -> LW m Doc
+defListItemToLaTeX (term, defs) = do
+ term' <- inlineListToLaTeX term
+ -- put braces around term if it contains an internal link,
+ -- since otherwise we get bad bracket interactions: \item[\hyperref[..]
+ let isInternalLink (Link _ _ ('#':_,_)) = True
+ isInternalLink _ = False
+ let term'' = if any isInternalLink term
+ then braces term'
+ else term'
+ def' <- liftM vsep $ mapM blockListToLaTeX defs
+ return $ case defs of
+ (((Header _ _ _) : _) : _) ->
+ "\\item" <> brackets term'' <> " ~ " $$ def'
+ _ ->
+ "\\item" <> brackets term'' $$ def'
+
+-- | Craft the section header, inserting the secton reference, if supplied.
+sectionHeader :: PandocMonad m
+ => Bool -- True for unnumbered
+ -> [Char]
+ -> Int
+ -> [Inline]
+ -> LW m Doc
+sectionHeader unnumbered ident level lst = do
+ txt <- inlineListToLaTeX lst
+ plain <- stringToLaTeX TextString $ concatMap stringify lst
+ let removeInvalidInline (Note _) = []
+ removeInvalidInline (Span (id', _, _) _) | not (null id') = []
+ removeInvalidInline (Image _ _ _) = []
+ removeInvalidInline x = [x]
+ let lstNoNotes = foldr (mappend . (\x -> walkM removeInvalidInline x)) mempty lst
+ txtNoNotes <- inlineListToLaTeX lstNoNotes
+ -- footnotes in sections don't work (except for starred variants)
+ -- unless you specify an optional argument:
+ -- \section[mysec]{mysec\footnote{blah}}
+ optional <- if unnumbered || lstNoNotes == lst || lstNoNotes == []
+ then return empty
+ else do
+ return $ brackets txtNoNotes
+ let contents = if render Nothing txt == plain
+ then braces txt
+ else braces (text "\\texorpdfstring"
+ <> braces txt
+ <> braces (text plain))
+ book <- gets stBook
+ opts <- gets stOptions
+ let topLevelDivision = if book && writerTopLevelDivision opts == TopLevelDefault
+ then TopLevelChapter
+ else writerTopLevelDivision opts
+ beamer <- gets stBeamer
+ let level' = if beamer &&
+ topLevelDivision `elem` [TopLevelPart, TopLevelChapter]
+ -- beamer has parts but no chapters
+ then if level == 1 then -1 else level - 1
+ else case topLevelDivision of
+ TopLevelPart -> level - 2
+ TopLevelChapter -> level - 1
+ TopLevelSection -> level
+ TopLevelDefault -> level
+ let sectionType = case level' of
+ -1 -> "part"
+ 0 -> "chapter"
+ 1 -> "section"
+ 2 -> "subsection"
+ 3 -> "subsubsection"
+ 4 -> "paragraph"
+ 5 -> "subparagraph"
+ _ -> ""
+ inQuote <- gets stInQuote
+ let prefix = if inQuote && level' >= 4
+ then text "\\mbox{}%"
+ -- needed for \paragraph, \subparagraph in quote environment
+ -- see http://tex.stackexchange.com/questions/169830/
+ else empty
+ lab <- labelFor ident
+ let star = if unnumbered && level' < 4 then text "*" else empty
+ let stuffing = star <> optional <> contents
+ stuffing' <- hypertarget ident $ text ('\\':sectionType) <> stuffing <> lab
+ return $ if level' > 5
+ then txt
+ else prefix $$ stuffing'
+ $$ if unnumbered
+ then "\\addcontentsline{toc}" <>
+ braces (text sectionType) <>
+ braces txtNoNotes
+ else empty
+
+hypertarget :: PandocMonad m => String -> Doc -> LW m Doc
+hypertarget ident x = do
+ ref <- text `fmap` toLabel ident
+ internalLinks <- gets stInternalLinks
+ return $
+ if ident `elem` internalLinks
+ then text "\\hypertarget"
+ <> braces ref
+ <> braces x
+ else x
+
+labelFor :: PandocMonad m => String -> LW m Doc
+labelFor "" = return empty
+labelFor ident = do
+ ref <- text `fmap` toLabel ident
+ return $ text "\\label" <> braces ref
+
+-- | Convert list of inline elements to LaTeX.
+inlineListToLaTeX :: PandocMonad m
+ => [Inline] -- ^ Inlines to convert
+ -> LW m Doc
+inlineListToLaTeX lst =
+ mapM inlineToLaTeX (fixBreaks $ fixLineInitialSpaces lst)
+ >>= return . hcat
+ -- nonbreaking spaces (~) in LaTeX don't work after line breaks,
+ -- so we turn nbsps after hard breaks to \hspace commands.
+ -- this is mostly used in verse.
+ where fixLineInitialSpaces [] = []
+ fixLineInitialSpaces (LineBreak : Str s@('\160':_) : xs) =
+ LineBreak : fixNbsps s ++ fixLineInitialSpaces xs
+ fixLineInitialSpaces (x:xs) = x : fixLineInitialSpaces xs
+ fixNbsps s = let (ys,zs) = span (=='\160') s
+ in replicate (length ys) hspace ++ [Str zs]
+ hspace = RawInline "latex" "\\hspace*{0.333em}"
+ -- linebreaks after blank lines cause problems:
+ fixBreaks [] = []
+ fixBreaks ys@(LineBreak : LineBreak : _) =
+ case span (== LineBreak) ys of
+ (lbs, rest) -> RawInline "latex"
+ ("\\\\[" ++ show (length lbs) ++
+ "\\baselineskip]") : fixBreaks rest
+ fixBreaks (y:ys) = y : fixBreaks ys
+
+isQuoted :: Inline -> Bool
+isQuoted (Quoted _ _) = True
+isQuoted _ = False
+
+-- | Convert inline element to LaTeX
+inlineToLaTeX :: PandocMonad m
+ => Inline -- ^ Inline to convert
+ -> LW m Doc
+inlineToLaTeX (Span (id',classes,kvs) ils) = do
+ ref <- toLabel id'
+ let linkAnchor = if null id'
+ then empty
+ else "\\protect\\hypertarget" <> braces (text ref) <>
+ braces empty
+ let cmds = ["textup" | "csl-no-emph" `elem` classes] ++
+ ["textnormal" | "csl-no-strong" `elem` classes ||
+ "csl-no-smallcaps" `elem` classes] ++
+ ["RL" | ("dir", "rtl") `elem` kvs] ++
+ ["LR" | ("dir", "ltr") `elem` kvs] ++
+ (case lookup "lang" kvs of
+ Just lng -> let (l, o) = toPolyglossia $ splitBy (=='-') lng
+ ops = if null o then "" else ("[" ++ o ++ "]")
+ in ["text" ++ l ++ ops]
+ Nothing -> [])
+ contents <- inlineListToLaTeX ils
+ return $ linkAnchor <>
+ if null cmds
+ then braces contents
+ else foldr inCmd contents cmds
+inlineToLaTeX (Emph lst) =
+ inlineListToLaTeX lst >>= return . inCmd "emph"
+inlineToLaTeX (Strong lst) =
+ inlineListToLaTeX lst >>= return . inCmd "textbf"
+inlineToLaTeX (Strikeout lst) = do
+ -- we need to protect VERB in an mbox or we get an error
+ -- see #1294
+ contents <- inlineListToLaTeX $ protectCode lst
+ modify $ \s -> s{ stStrikeout = True }
+ return $ inCmd "sout" contents
+inlineToLaTeX (Superscript lst) =
+ inlineListToLaTeX lst >>= return . inCmd "textsuperscript"
+inlineToLaTeX (Subscript lst) = do
+ inlineListToLaTeX lst >>= return . inCmd "textsubscript"
+inlineToLaTeX (SmallCaps lst) =
+ inlineListToLaTeX lst >>= return . inCmd "textsc"
+inlineToLaTeX (Cite cits lst) = do
+ st <- get
+ let opts = stOptions st
+ case writerCiteMethod opts of
+ Natbib -> citationsToNatbib cits
+ Biblatex -> citationsToBiblatex cits
+ _ -> inlineListToLaTeX lst
+
+inlineToLaTeX (Code (_,classes,_) str) = do
+ opts <- gets stOptions
+ inHeading <- gets stInHeading
+ case () of
+ _ | writerListings opts && not inHeading -> listingsCode
+ | isJust (writerHighlightStyle opts) && not (null classes)
+ -> highlightCode
+ | otherwise -> rawCode
+ where listingsCode = do
+ let listingsopt = case getListingsLanguage classes of
+ Just l -> "[language=" ++ mbBraced l ++ "]"
+ Nothing -> ""
+ inNote <- gets stInNote
+ when inNote $ modify $ \s -> s{ stVerbInNote = True }
+ let chr = case "!\"&'()*,-./:;?@_" \\ str of
+ (c:_) -> c
+ [] -> '!'
+ return $ text $ "\\lstinline" ++ listingsopt ++ [chr] ++ str ++ [chr]
+ highlightCode = do
+ case highlight formatLaTeXInline ("",classes,[]) str of
+ Nothing -> rawCode
+ Just h -> modify (\st -> st{ stHighlighting = True }) >>
+ return (text (T.unpack h))
+ rawCode = liftM (text . (\s -> "\\texttt{" ++ escapeSpaces s ++ "}"))
+ $ stringToLaTeX CodeString str
+ where
+ escapeSpaces = concatMap (\c -> if c == ' ' then "\\ " else [c])
+inlineToLaTeX (Quoted qt lst) = do
+ contents <- inlineListToLaTeX lst
+ csquotes <- liftM stCsquotes get
+ opts <- gets stOptions
+ if csquotes
+ then return $ "\\enquote" <> braces contents
+ else do
+ let s1 = if (not (null lst)) && (isQuoted (head lst))
+ then "\\,"
+ else empty
+ let s2 = if (not (null lst)) && (isQuoted (last lst))
+ then "\\,"
+ else empty
+ let inner = s1 <> contents <> s2
+ return $ case qt of
+ DoubleQuote ->
+ if isEnabled Ext_smart opts
+ then text "``" <> inner <> text "''"
+ else char '\x201C' <> inner <> char '\x201D'
+ SingleQuote ->
+ if isEnabled Ext_smart opts
+ then char '`' <> inner <> char '\''
+ else char '\x2018' <> inner <> char '\x2019'
+inlineToLaTeX (Str str) = liftM text $ stringToLaTeX TextString str
+inlineToLaTeX (Math InlineMath str) =
+ return $ "\\(" <> text str <> "\\)"
+inlineToLaTeX (Math DisplayMath str) =
+ return $ "\\[" <> text str <> "\\]"
+inlineToLaTeX il@(RawInline f str)
+ | f == Format "latex" || f == Format "tex"
+ = return $ text str
+ | otherwise = do
+ report $ InlineNotRendered il
+ return empty
+inlineToLaTeX (LineBreak) = return $ "\\\\" <> cr
+inlineToLaTeX SoftBreak = do
+ wrapText <- gets (writerWrapText . stOptions)
+ case wrapText of
+ WrapAuto -> return space
+ WrapNone -> return space
+ WrapPreserve -> return cr
+inlineToLaTeX Space = return space
+inlineToLaTeX (Link _ txt ('#':ident, _)) = do
+ contents <- inlineListToLaTeX txt
+ lab <- toLabel ident
+ return $ text "\\protect\\hyperlink" <> braces (text lab) <> braces contents
+inlineToLaTeX (Link _ txt (src, _)) =
+ case txt of
+ [Str x] | escapeURI x == src -> -- autolink
+ do modify $ \s -> s{ stUrl = True }
+ src' <- stringToLaTeX URLString (escapeURI src)
+ return $ text $ "\\url{" ++ src' ++ "}"
+ [Str x] | Just rest <- stripPrefix "mailto:" src,
+ escapeURI x == rest -> -- email autolink
+ do modify $ \s -> s{ stUrl = True }
+ src' <- stringToLaTeX URLString (escapeURI src)
+ contents <- inlineListToLaTeX txt
+ return $ "\\href" <> braces (text src') <>
+ braces ("\\nolinkurl" <> braces contents)
+ _ -> do contents <- inlineListToLaTeX txt
+ src' <- stringToLaTeX URLString (escapeURI src)
+ return $ text ("\\href{" ++ src' ++ "}{") <>
+ contents <> char '}'
+inlineToLaTeX (Image attr _ (source, _)) = do
+ modify $ \s -> s{ stGraphics = True }
+ opts <- gets stOptions
+ let showDim dir = let d = text (show dir) <> "="
+ in case (dimension dir attr) of
+ Just (Pixel a) ->
+ [d <> text (showInInch opts (Pixel a)) <> "in"]
+ Just (Percent a) ->
+ [d <> text (showFl (a / 100)) <> "\\textwidth"]
+ Just dim ->
+ [d <> text (show dim)]
+ Nothing ->
+ []
+ dimList = showDim Width ++ showDim Height
+ dims = if null dimList
+ then empty
+ else brackets $ cat (intersperse "," dimList)
+ source' = if isURI source
+ then source
+ else unEscapeString source
+ source'' <- stringToLaTeX URLString source'
+ inHeading <- gets stInHeading
+ return $
+ (if inHeading then "\\protect\\includegraphics" else "\\includegraphics") <>
+ dims <> braces (text source'')
+inlineToLaTeX (Note contents) = do
+ inMinipage <- gets stInMinipage
+ modify (\s -> s{stInNote = True})
+ contents' <- blockListToLaTeX contents
+ modify (\s -> s {stInNote = False})
+ let optnl = case reverse contents of
+ (CodeBlock _ _ : _) -> cr
+ _ -> empty
+ let noteContents = nest 2 contents' <> optnl
+ beamer <- gets stBeamer
+ -- in beamer slides, display footnote from current overlay forward
+ let beamerMark = if beamer
+ then text "<.->"
+ else empty
+ modify $ \st -> st{ stNotes = noteContents : stNotes st }
+ return $
+ if inMinipage
+ then "\\footnotemark{}"
+ -- note: a \n before } needed when note ends with a Verbatim environment
+ else "\\footnote" <> beamerMark <> braces noteContents
+
+protectCode :: [Inline] -> [Inline]
+protectCode [] = []
+protectCode (x@(Code ("",[],[]) _) : xs) = x : protectCode xs
+protectCode (x@(Code _ _) : xs) = ltx "\\mbox{" : x : ltx "}" : xs
+ where ltx = RawInline (Format "latex")
+protectCode (x : xs) = x : protectCode xs
+
+citationsToNatbib :: PandocMonad m => [Citation] -> LW m Doc
+citationsToNatbib (one:[])
+ = citeCommand c p s k
+ where
+ Citation { citationId = k
+ , citationPrefix = p
+ , citationSuffix = s
+ , citationMode = m
+ }
+ = one
+ c = case m of
+ AuthorInText -> "citet"
+ SuppressAuthor -> "citeyearpar"
+ NormalCitation -> "citep"
+
+citationsToNatbib cits
+ | noPrefix (tail cits) && noSuffix (init cits) && ismode NormalCitation cits
+ = citeCommand "citep" p s ks
+ where
+ noPrefix = all (null . citationPrefix)
+ noSuffix = all (null . citationSuffix)
+ ismode m = all (((==) m) . citationMode)
+ p = citationPrefix $ head $ cits
+ s = citationSuffix $ last $ cits
+ ks = intercalate ", " $ map citationId cits
+
+citationsToNatbib (c:cs) | citationMode c == AuthorInText = do
+ author <- citeCommand "citeauthor" [] [] (citationId c)
+ cits <- citationsToNatbib (c { citationMode = SuppressAuthor } : cs)
+ return $ author <+> cits
+
+citationsToNatbib cits = do
+ cits' <- mapM convertOne cits
+ return $ text "\\citetext{" <> foldl' combineTwo empty cits' <> text "}"
+ where
+ combineTwo a b | isEmpty a = b
+ | otherwise = a <> text "; " <> b
+ convertOne Citation { citationId = k
+ , citationPrefix = p
+ , citationSuffix = s
+ , citationMode = m
+ }
+ = case m of
+ AuthorInText -> citeCommand "citealt" p s k
+ SuppressAuthor -> citeCommand "citeyear" p s k
+ NormalCitation -> citeCommand "citealp" p s k
+
+citeCommand :: PandocMonad m
+ => String -> [Inline] -> [Inline] -> String -> LW m Doc
+citeCommand c p s k = do
+ args <- citeArguments p s k
+ return $ text ("\\" ++ c) <> args
+
+citeArguments :: PandocMonad m
+ => [Inline] -> [Inline] -> String -> LW m Doc
+citeArguments p s k = do
+ let s' = case s of
+ (Str (x:[]) : r) | isPunctuation x -> dropWhile (== Space) r
+ (Str (x:xs) : r) | isPunctuation x -> Str xs : r
+ _ -> s
+ pdoc <- inlineListToLaTeX p
+ sdoc <- inlineListToLaTeX s'
+ let optargs = case (isEmpty pdoc, isEmpty sdoc) of
+ (True, True ) -> empty
+ (True, False) -> brackets sdoc
+ (_ , _ ) -> brackets pdoc <> brackets sdoc
+ return $ optargs <> braces (text k)
+
+citationsToBiblatex :: PandocMonad m => [Citation] -> LW m Doc
+citationsToBiblatex (one:[])
+ = citeCommand cmd p s k
+ where
+ Citation { citationId = k
+ , citationPrefix = p
+ , citationSuffix = s
+ , citationMode = m
+ } = one
+ cmd = case m of
+ SuppressAuthor -> "autocite*"
+ AuthorInText -> "textcite"
+ NormalCitation -> "autocite"
+
+citationsToBiblatex (c:cs) = do
+ args <- mapM convertOne (c:cs)
+ return $ text cmd <> foldl' (<>) empty args
+ where
+ cmd = case citationMode c of
+ SuppressAuthor -> "\\autocites*"
+ AuthorInText -> "\\textcites"
+ NormalCitation -> "\\autocites"
+ convertOne Citation { citationId = k
+ , citationPrefix = p
+ , citationSuffix = s
+ }
+ = citeArguments p s k
+
+citationsToBiblatex _ = return empty
+
+-- Determine listings language from list of class attributes.
+getListingsLanguage :: [String] -> Maybe String
+getListingsLanguage [] = Nothing
+getListingsLanguage (x:xs) = toListingsLanguage x <|> getListingsLanguage xs
+
+mbBraced :: String -> String
+mbBraced x = if not (all isAlphaNum x)
+ then "{" <> x <> "}"
+ else x
+
+-- Extract a key from divs and spans
+extract :: String -> Block -> [String]
+extract key (Div attr _) = lookKey key attr
+extract key (Plain ils) = concatMap (extractInline key) ils
+extract key (Para ils) = concatMap (extractInline key) ils
+extract key (Header _ _ ils) = concatMap (extractInline key) ils
+extract _ _ = []
+
+-- Extract a key from spans
+extractInline :: String -> Inline -> [String]
+extractInline key (Span attr _) = lookKey key attr
+extractInline _ _ = []
+
+-- Look up a key in an attribute and give a list of its values
+lookKey :: String -> Attr -> [String]
+lookKey key (_,_,kvs) = maybe [] words $ lookup key kvs
+
+-- In environments \Arabic instead of \arabic is used
+toPolyglossiaEnv :: String -> (String, String)
+toPolyglossiaEnv l =
+ case toPolyglossia $ (splitBy (=='-')) l of
+ ("arabic", o) -> ("Arabic", o)
+ x -> x
+
+-- Takes a list of the constituents of a BCP 47 language code and
+-- converts it to a Polyglossia (language, options) tuple
+-- http://mirrors.ctan.org/macros/latex/contrib/polyglossia/polyglossia.pdf
+toPolyglossia :: [String] -> (String, String)
+toPolyglossia ("ar":"DZ":_) = ("arabic", "locale=algeria")
+toPolyglossia ("ar":"IQ":_) = ("arabic", "locale=mashriq")
+toPolyglossia ("ar":"JO":_) = ("arabic", "locale=mashriq")
+toPolyglossia ("ar":"LB":_) = ("arabic", "locale=mashriq")
+toPolyglossia ("ar":"LY":_) = ("arabic", "locale=libya")
+toPolyglossia ("ar":"MA":_) = ("arabic", "locale=morocco")
+toPolyglossia ("ar":"MR":_) = ("arabic", "locale=mauritania")
+toPolyglossia ("ar":"PS":_) = ("arabic", "locale=mashriq")
+toPolyglossia ("ar":"SY":_) = ("arabic", "locale=mashriq")
+toPolyglossia ("ar":"TN":_) = ("arabic", "locale=tunisia")
+toPolyglossia ("de":"1901":_) = ("german", "spelling=old")
+toPolyglossia ("de":"AT":"1901":_) = ("german", "variant=austrian, spelling=old")
+toPolyglossia ("de":"AT":_) = ("german", "variant=austrian")
+toPolyglossia ("de":"CH":"1901":_) = ("german", "variant=swiss, spelling=old")
+toPolyglossia ("de":"CH":_) = ("german", "variant=swiss")
+toPolyglossia ("de":_) = ("german", "")
+toPolyglossia ("dsb":_) = ("lsorbian", "")
+toPolyglossia ("el":"polyton":_) = ("greek", "variant=poly")
+toPolyglossia ("en":"AU":_) = ("english", "variant=australian")
+toPolyglossia ("en":"CA":_) = ("english", "variant=canadian")
+toPolyglossia ("en":"GB":_) = ("english", "variant=british")
+toPolyglossia ("en":"NZ":_) = ("english", "variant=newzealand")
+toPolyglossia ("en":"UK":_) = ("english", "variant=british")
+toPolyglossia ("en":"US":_) = ("english", "variant=american")
+toPolyglossia ("grc":_) = ("greek", "variant=ancient")
+toPolyglossia ("hsb":_) = ("usorbian", "")
+toPolyglossia ("la":"x":"classic":_) = ("latin", "variant=classic")
+toPolyglossia ("sl":_) = ("slovenian", "")
+toPolyglossia x = (commonFromBcp47 x, "")
+
+-- Takes a list of the constituents of a BCP 47 language code and
+-- converts it to a Babel language string.
+-- http://mirrors.ctan.org/macros/latex/required/babel/base/babel.pdf
+-- List of supported languages (slightly outdated):
+-- http://tug.ctan.org/language/hyph-utf8/doc/generic/hyph-utf8/hyphenation.pdf
+toBabel :: [String] -> String
+toBabel ("de":"1901":_) = "german"
+toBabel ("de":"AT":"1901":_) = "austrian"
+toBabel ("de":"AT":_) = "naustrian"
+toBabel ("de":"CH":"1901":_) = "swissgerman"
+toBabel ("de":"CH":_) = "nswissgerman"
+toBabel ("de":_) = "ngerman"
+toBabel ("dsb":_) = "lowersorbian"
+toBabel ("el":"polyton":_) = "polutonikogreek"
+toBabel ("en":"AU":_) = "australian"
+toBabel ("en":"CA":_) = "canadian"
+toBabel ("en":"GB":_) = "british"
+toBabel ("en":"NZ":_) = "newzealand"
+toBabel ("en":"UK":_) = "british"
+toBabel ("en":"US":_) = "american"
+toBabel ("fr":"CA":_) = "canadien"
+toBabel ("fra":"aca":_) = "acadian"
+toBabel ("grc":_) = "polutonikogreek"
+toBabel ("hsb":_) = "uppersorbian"
+toBabel ("la":"x":"classic":_) = "classiclatin"
+toBabel ("sl":_) = "slovene"
+toBabel x = commonFromBcp47 x
+
+-- Takes a list of the constituents of a BCP 47 language code
+-- and converts it to a string shared by Babel and Polyglossia.
+-- https://tools.ietf.org/html/bcp47#section-2.1
+commonFromBcp47 :: [String] -> String
+commonFromBcp47 [] = ""
+commonFromBcp47 ("pt":"BR":_) = "brazil"
+-- Note: documentation says "brazilian" works too, but it doesn't seem to work
+-- on some systems. See #2953.
+commonFromBcp47 ("sr":"Cyrl":_) = "serbianc"
+commonFromBcp47 ("zh":"Latn":"pinyin":_) = "pinyin"
+commonFromBcp47 x = fromIso $ head x
+ where
+ fromIso "af" = "afrikaans"
+ fromIso "am" = "amharic"
+ fromIso "ar" = "arabic"
+ fromIso "as" = "assamese"
+ fromIso "ast" = "asturian"
+ fromIso "bg" = "bulgarian"
+ fromIso "bn" = "bengali"
+ fromIso "bo" = "tibetan"
+ fromIso "br" = "breton"
+ fromIso "ca" = "catalan"
+ fromIso "cy" = "welsh"
+ fromIso "cs" = "czech"
+ fromIso "cop" = "coptic"
+ fromIso "da" = "danish"
+ fromIso "dv" = "divehi"
+ fromIso "el" = "greek"
+ fromIso "en" = "english"
+ fromIso "eo" = "esperanto"
+ fromIso "es" = "spanish"
+ fromIso "et" = "estonian"
+ fromIso "eu" = "basque"
+ fromIso "fa" = "farsi"
+ fromIso "fi" = "finnish"
+ fromIso "fr" = "french"
+ fromIso "fur" = "friulan"
+ fromIso "ga" = "irish"
+ fromIso "gd" = "scottish"
+ fromIso "gez" = "ethiopic"
+ fromIso "gl" = "galician"
+ fromIso "he" = "hebrew"
+ fromIso "hi" = "hindi"
+ fromIso "hr" = "croatian"
+ fromIso "hu" = "magyar"
+ fromIso "hy" = "armenian"
+ fromIso "ia" = "interlingua"
+ fromIso "id" = "indonesian"
+ fromIso "ie" = "interlingua"
+ fromIso "is" = "icelandic"
+ fromIso "it" = "italian"
+ fromIso "jp" = "japanese"
+ fromIso "km" = "khmer"
+ fromIso "kmr" = "kurmanji"
+ fromIso "kn" = "kannada"
+ fromIso "ko" = "korean"
+ fromIso "la" = "latin"
+ fromIso "lo" = "lao"
+ fromIso "lt" = "lithuanian"
+ fromIso "lv" = "latvian"
+ fromIso "ml" = "malayalam"
+ fromIso "mn" = "mongolian"
+ fromIso "mr" = "marathi"
+ fromIso "nb" = "norsk"
+ fromIso "nl" = "dutch"
+ fromIso "nn" = "nynorsk"
+ fromIso "no" = "norsk"
+ fromIso "nqo" = "nko"
+ fromIso "oc" = "occitan"
+ fromIso "pa" = "panjabi"
+ fromIso "pl" = "polish"
+ fromIso "pms" = "piedmontese"
+ fromIso "pt" = "portuguese"
+ fromIso "rm" = "romansh"
+ fromIso "ro" = "romanian"
+ fromIso "ru" = "russian"
+ fromIso "sa" = "sanskrit"
+ fromIso "se" = "samin"
+ fromIso "sk" = "slovak"
+ fromIso "sq" = "albanian"
+ fromIso "sr" = "serbian"
+ fromIso "sv" = "swedish"
+ fromIso "syr" = "syriac"
+ fromIso "ta" = "tamil"
+ fromIso "te" = "telugu"
+ fromIso "th" = "thai"
+ fromIso "ti" = "ethiopic"
+ fromIso "tk" = "turkmen"
+ fromIso "tr" = "turkish"
+ fromIso "uk" = "ukrainian"
+ fromIso "ur" = "urdu"
+ fromIso "vi" = "vietnamese"
+ fromIso _ = ""
+
+pDocumentOptions :: P.Parsec String () [String]
+pDocumentOptions = do
+ P.char '['
+ opts <- P.sepBy
+ (P.many $ P.spaces *> P.noneOf (" ,]" :: String) <* P.spaces)
+ (P.char ',')
+ P.char ']'
+ return opts
+
+pDocumentClass :: P.Parsec String () String
+pDocumentClass =
+ do P.skipMany (P.satisfy (/='\\'))
+ P.string "\\documentclass"
+ classOptions <- pDocumentOptions <|> return []
+ if ("article" :: String) `elem` classOptions
+ then return "article"
+ else do P.skipMany (P.satisfy (/='{'))
+ P.char '{'
+ P.manyTill P.letter (P.char '}')
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs
new file mode 100644
index 000000000..f33acef32
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Man.hs
@@ -0,0 +1,381 @@
+{-
+Copyright (C) 2007-2015 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.Man
+ Copyright : Copyright (C) 2007-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to groff man page format.
+
+-}
+module Text.Pandoc.Writers.Man ( writeMan) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Templates
+import Text.Pandoc.Shared
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Options
+import Text.Pandoc.Writers.Math
+import Text.Printf ( printf )
+import Data.List ( stripPrefix, intersperse, intercalate )
+import Data.Maybe (fromMaybe)
+import Text.Pandoc.Pretty
+import Text.Pandoc.Builder (deleteMeta)
+import Control.Monad.State
+import Text.Pandoc.Error
+import Control.Monad.Except (throwError)
+import Text.Pandoc.Class (PandocMonad, report)
+import Text.Pandoc.Logging
+
+type Notes = [[Block]]
+data WriterState = WriterState { stNotes :: Notes
+ , stHasTables :: Bool }
+
+-- | Convert Pandoc to Man.
+writeMan :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeMan opts document = evalStateT (pandocToMan opts document) (WriterState [] False)
+
+-- | Return groff man representation of document.
+pandocToMan :: PandocMonad m => WriterOptions -> Pandoc -> StateT WriterState m String
+pandocToMan opts (Pandoc meta blocks) = do
+ let colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ let render' = render colwidth
+ titleText <- inlineListToMan opts $ docTitle meta
+ let title' = render' titleText
+ let setFieldsFromTitle =
+ case break (== ' ') title' of
+ (cmdName, rest) -> case break (=='(') cmdName of
+ (xs, '(':ys) | not (null ys) &&
+ last ys == ')' ->
+ defField "title" xs .
+ defField "section" (init ys) .
+ case splitBy (=='|') rest of
+ (ft:hds) ->
+ defField "footer" (trim ft) .
+ defField "header"
+ (trim $ concat hds)
+ [] -> id
+ _ -> defField "title" title'
+ metadata <- metaToJSON opts
+ (fmap (render colwidth) . blockListToMan opts)
+ (fmap (render colwidth) . inlineListToMan opts)
+ $ deleteMeta "title" meta
+ body <- blockListToMan opts blocks
+ notes <- liftM stNotes get
+ notes' <- notesToMan opts (reverse notes)
+ let main = render' $ body $$ notes' $$ text ""
+ hasTables <- liftM stHasTables get
+ let context = defField "body" main
+ $ setFieldsFromTitle
+ $ defField "has-tables" hasTables
+ $ defField "hyphenate" True
+ $ defField "pandoc-version" pandocVersion
+ $ metadata
+ case writerTemplate opts of
+ Nothing -> return main
+ Just tpl -> return $ renderTemplate' tpl context
+
+-- | Return man representation of notes.
+notesToMan :: PandocMonad m => WriterOptions -> [[Block]] -> StateT WriterState m Doc
+notesToMan opts notes =
+ if null notes
+ then return empty
+ else mapM (\(num, note) -> noteToMan opts num note) (zip [1..] notes) >>=
+ return . (text ".SH NOTES" $$) . vcat
+
+-- | Return man representation of a note.
+noteToMan :: PandocMonad m => WriterOptions -> Int -> [Block] -> StateT WriterState m Doc
+noteToMan opts num note = do
+ contents <- blockListToMan opts note
+ 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 = concat . intersperse "\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.
+-- 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
+ -> Block -- ^ Block element
+ -> StateT WriterState m Doc
+blockToMan _ Null = return empty
+blockToMan opts (Div _ bs) = blockListToMan opts bs
+blockToMan opts (Plain inlines) =
+ liftM vcat $ mapM (inlineListToMan opts) $ splitSentences inlines
+blockToMan opts (Para inlines) = do
+ contents <- liftM vcat $ mapM (inlineListToMan opts) $
+ splitSentences inlines
+ return $ text ".PP" $$ contents
+blockToMan opts (LineBlock lns) =
+ blockToMan opts $ linesToPara lns
+blockToMan _ b@(RawBlock f str)
+ | f == Format "man" = return $ text str
+ | otherwise = do
+ report $ BlockNotRendered b
+ return empty
+blockToMan _ HorizontalRule = return $ text ".PP" $$ text " * * * * *"
+blockToMan opts (Header level _ inlines) = do
+ contents <- inlineListToMan opts inlines
+ let heading = case level of
+ 1 -> ".SH "
+ _ -> ".SS "
+ return $ text heading <> contents
+blockToMan _ (CodeBlock _ str) = return $
+ text ".IP" $$
+ text ".nf" $$
+ text "\\f[C]" $$
+ text (escapeCode str) $$
+ text "\\f[]" $$
+ text ".fi"
+blockToMan opts (BlockQuote blocks) = do
+ contents <- blockListToMan opts blocks
+ return $ text ".RS" $$ contents $$ text ".RE"
+blockToMan opts (Table caption alignments widths headers rows) =
+ let aligncode AlignLeft = "l"
+ aligncode AlignRight = "r"
+ aligncode AlignCenter = "c"
+ aligncode AlignDefault = "l"
+ in do
+ caption' <- inlineListToMan opts caption
+ modify $ \st -> st{ stHasTables = True }
+ let iwidths = if all (== 0) widths
+ then repeat ""
+ else map (printf "w(%0.1fn)" . (70 *)) widths
+ -- 78n default width - 8n indent = 70n
+ let coldescriptions = text $ intercalate " "
+ (zipWith (\align width -> aligncode align ++ width)
+ alignments iwidths) ++ "."
+ colheadings <- mapM (blockListToMan opts) headers
+ let makeRow cols = text "T{" $$
+ (vcat $ intersperse (text "T}@T{") cols) $$
+ text "T}"
+ let colheadings' = if all null headers
+ then empty
+ else makeRow colheadings $$ char '_'
+ body <- mapM (\row -> do
+ cols <- mapM (blockListToMan opts) row
+ return $ makeRow cols) rows
+ return $ text ".PP" $$ caption' $$
+ text ".TS" $$ text "tab(@);" $$ coldescriptions $$
+ colheadings' $$ vcat body $$ text ".TE"
+
+blockToMan opts (BulletList items) = do
+ contents <- mapM (bulletListItemToMan opts) items
+ return (vcat contents)
+blockToMan opts (OrderedList attribs items) = do
+ let markers = take (length items) $ orderedListMarkers attribs
+ let indent = 1 + (maximum $ map length markers)
+ contents <- mapM (\(num, item) -> orderedListItemToMan opts num indent item) $
+ zip markers items
+ return (vcat contents)
+blockToMan opts (DefinitionList items) = do
+ contents <- mapM (definitionListItemToMan opts) items
+ return (vcat contents)
+
+-- | Convert bullet list item (list of blocks) to man.
+bulletListItemToMan :: PandocMonad m => WriterOptions -> [Block] -> StateT WriterState m Doc
+bulletListItemToMan _ [] = return empty
+bulletListItemToMan opts ((Para first):rest) =
+ bulletListItemToMan opts ((Plain first):rest)
+bulletListItemToMan opts ((Plain first):rest) = do
+ first' <- blockToMan opts (Plain first)
+ rest' <- blockListToMan opts rest
+ let first'' = text ".IP \\[bu] 2" $$ first'
+ let rest'' = if null rest
+ then empty
+ else text ".RS 2" $$ rest' $$ text ".RE"
+ return (first'' $$ rest'')
+bulletListItemToMan opts (first:rest) = do
+ first' <- blockToMan opts first
+ rest' <- blockListToMan opts rest
+ return $ text "\\[bu] .RS 2" $$ first' $$ rest' $$ text ".RE"
+
+-- | Convert ordered list item (a list of blocks) to man.
+orderedListItemToMan :: PandocMonad m
+ => WriterOptions -- ^ options
+ -> String -- ^ order marker for list item
+ -> Int -- ^ number of spaces to indent
+ -> [Block] -- ^ list item (list of blocks)
+ -> StateT WriterState m Doc
+orderedListItemToMan _ _ _ [] = return empty
+orderedListItemToMan opts num indent ((Para first):rest) =
+ orderedListItemToMan opts num indent ((Plain first):rest)
+orderedListItemToMan opts num indent (first:rest) = do
+ first' <- blockToMan opts first
+ rest' <- blockListToMan opts rest
+ let num' = printf ("%" ++ show (indent - 1) ++ "s") num
+ let first'' = text (".IP \"" ++ num' ++ "\" " ++ show indent) $$ first'
+ let rest'' = if null rest
+ then empty
+ else text ".RS 4" $$ rest' $$ text ".RE"
+ return $ first'' $$ rest''
+
+-- | Convert definition list item (label, list of blocks) to man.
+definitionListItemToMan :: PandocMonad m
+ => WriterOptions
+ -> ([Inline],[[Block]])
+ -> StateT WriterState m Doc
+definitionListItemToMan opts (label, defs) = do
+ labelText <- inlineListToMan opts label
+ contents <- if null defs
+ then return empty
+ else liftM vcat $ forM defs $ \blocks -> do
+ (first, rest) <- case blocks of
+ ((Para x):y) -> return (Plain x,y)
+ (x:y) -> return (x,y)
+ [] -> throwError $ PandocSomeError "blocks is null"
+ rest' <- liftM vcat $
+ mapM (\item -> blockToMan opts item) rest
+ first' <- blockToMan opts first
+ return $ first' $$ text ".RS" $$ rest' $$ text ".RE"
+ return $ text ".TP" $$ nowrap (text ".B " <> labelText) $$ contents
+
+-- | Convert list of Pandoc block elements to man.
+blockListToMan :: PandocMonad m
+ => WriterOptions -- ^ Options
+ -> [Block] -- ^ List of block elements
+ -> StateT WriterState m Doc
+blockListToMan opts blocks =
+ mapM (blockToMan opts) blocks >>= (return . vcat)
+
+-- | Convert list of Pandoc inline elements to man.
+inlineListToMan :: PandocMonad m => WriterOptions -> [Inline] -> StateT WriterState m Doc
+inlineListToMan opts lst = mapM (inlineToMan opts) lst >>= (return . hcat)
+
+-- | Convert Pandoc inline element to man.
+inlineToMan :: PandocMonad m => WriterOptions -> Inline -> StateT WriterState m Doc
+inlineToMan opts (Span _ ils) = inlineListToMan opts ils
+inlineToMan opts (Emph lst) = do
+ contents <- inlineListToMan opts lst
+ return $ text "\\f[I]" <> contents <> text "\\f[]"
+inlineToMan opts (Strong lst) = do
+ contents <- inlineListToMan opts lst
+ return $ text "\\f[B]" <> contents <> text "\\f[]"
+inlineToMan opts (Strikeout lst) = do
+ contents <- inlineListToMan opts lst
+ return $ text "[STRIKEOUT:" <> contents <> char ']'
+inlineToMan opts (Superscript lst) = do
+ contents <- inlineListToMan opts lst
+ return $ char '^' <> contents <> char '^'
+inlineToMan opts (Subscript lst) = do
+ contents <- inlineListToMan opts lst
+ return $ char '~' <> contents <> char '~'
+inlineToMan opts (SmallCaps lst) = inlineListToMan opts lst -- not supported
+inlineToMan opts (Quoted SingleQuote lst) = do
+ contents <- inlineListToMan opts lst
+ return $ char '`' <> contents <> char '\''
+inlineToMan opts (Quoted DoubleQuote lst) = do
+ contents <- inlineListToMan opts lst
+ return $ text "\\[lq]" <> contents <> text "\\[rq]"
+inlineToMan opts (Cite _ lst) =
+ inlineListToMan opts lst
+inlineToMan _ (Code _ str) =
+ return $ text $ "\\f[C]" ++ escapeCode str ++ "\\f[]"
+inlineToMan _ (Str str@('.':_)) =
+ return $ afterBreak "\\&" <> text (escapeString str)
+inlineToMan _ (Str str) = return $ text $ escapeString str
+inlineToMan opts (Math InlineMath str) =
+ lift (texMathToInlines InlineMath str) >>= inlineListToMan opts
+inlineToMan opts (Math DisplayMath str) = do
+ contents <- lift (texMathToInlines DisplayMath str) >>= inlineListToMan opts
+ return $ cr <> text ".RS" $$ contents $$ text ".RE"
+inlineToMan _ il@(RawInline f str)
+ | f == Format "man" = return $ text str
+ | otherwise = do
+ report $ InlineNotRendered il
+ return empty
+inlineToMan _ LineBreak = return $
+ cr <> text ".PD 0" $$ text ".P" $$ text ".PD" <> cr
+inlineToMan _ SoftBreak = return space
+inlineToMan _ Space = return space
+inlineToMan opts (Link _ txt (src, _)) = do
+ linktext <- inlineListToMan opts txt
+ let srcSuffix = fromMaybe src (stripPrefix "mailto:" src)
+ return $ case txt of
+ [Str s]
+ | escapeURI s == srcSuffix ->
+ char '<' <> text srcSuffix <> char '>'
+ _ -> linktext <> text " (" <> text src <> char ')'
+inlineToMan opts (Image attr alternate (source, tit)) = do
+ let txt = if (null alternate) || (alternate == [Str ""]) ||
+ (alternate == [Str source]) -- to prevent autolinks
+ then [Str "image"]
+ else alternate
+ linkPart <- inlineToMan opts (Link attr txt (source, tit))
+ return $ char '[' <> text "IMAGE: " <> linkPart <> char ']'
+inlineToMan _ (Note contents) = do
+ -- add to notes in state
+ modify $ \st -> st{ stNotes = contents : stNotes st }
+ notes <- liftM stNotes get
+ let ref = show $ (length notes)
+ return $ char '[' <> text ref <> char ']'
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
new file mode 100644
index 000000000..a97c32542
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -0,0 +1,1147 @@
+{-# LANGUAGE OverloadedStrings, TupleSections, ScopedTypeVariables, MultiWayIf #-}
+{-
+Copyright (C) 2006-2015 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.Markdown
+ Copyright : Copyright (C) 2006-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to markdown-formatted plain text.
+
+Markdown: <http://daringfireball.net/projects/markdown/>
+-}
+module Text.Pandoc.Writers.Markdown (writeMarkdown, writePlain) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Walk
+import Text.Pandoc.Templates (renderTemplate')
+import Text.Pandoc.Shared
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Options
+import Text.Pandoc.Parsing hiding (blankline, blanklines, char, space)
+import Data.Maybe (fromMaybe)
+import Data.Monoid (Any(..))
+import Data.List ( group, stripPrefix, find, intersperse, transpose, sortBy )
+import Data.Char ( isSpace, isPunctuation, ord, chr )
+import Data.Ord ( comparing )
+import Text.Pandoc.Pretty
+import Control.Monad.Reader
+import Control.Monad.State
+import Control.Monad.Except (throwError)
+import Text.Pandoc.Writers.HTML (writeHtml5String)
+import Text.Pandoc.Writers.Math (texMathToInlines)
+import Text.HTML.TagSoup (parseTags, isTagText, Tag(..))
+import Network.URI (isURI)
+import Data.Default
+import Data.Yaml (Value(Object,String,Array,Bool,Number))
+import qualified Data.HashMap.Strict as H
+import qualified Data.Vector as V
+import qualified Data.Text as T
+import qualified Data.Set as Set
+import Network.HTTP ( urlEncode )
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad, report)
+import Text.Pandoc.Logging
+
+type Notes = [[Block]]
+type Ref = ([Inline], Target, Attr)
+type Refs = [Ref]
+
+type MD m = ReaderT WriterEnv (StateT WriterState m)
+
+evalMD :: PandocMonad m => MD m a -> WriterEnv -> WriterState -> m a
+evalMD md env st = evalStateT (runReaderT md env) st
+
+data WriterEnv = WriterEnv { envInList :: Bool
+ , envPlain :: Bool
+ , envRefShortcutable :: Bool
+ , envBlockLevel :: Int
+ , envEscapeSpaces :: Bool
+ }
+
+instance Default WriterEnv
+ where def = WriterEnv { envInList = False
+ , envPlain = False
+ , envRefShortcutable = True
+ , envBlockLevel = 0
+ , envEscapeSpaces = False
+ }
+
+data WriterState = WriterState { stNotes :: Notes
+ , stRefs :: Refs
+ , stIds :: Set.Set String
+ , stNoteNum :: Int
+ }
+
+instance Default WriterState
+ where def = WriterState{ stNotes = []
+ , stRefs = []
+ , stIds = Set.empty
+ , stNoteNum = 1
+ }
+
+-- | Convert Pandoc to Markdown.
+writeMarkdown :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeMarkdown opts document =
+ evalMD (pandocToMarkdown opts{
+ writerWrapText = if isEnabled Ext_hard_line_breaks opts
+ then WrapNone
+ else writerWrapText opts }
+ document) def def
+
+-- | Convert Pandoc to plain text (like markdown, but without links,
+-- pictures, or inline formatting).
+writePlain :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writePlain opts document =
+ evalMD (pandocToMarkdown opts document) def{ envPlain = True } def
+
+pandocTitleBlock :: Doc -> [Doc] -> Doc -> Doc
+pandocTitleBlock tit auths dat =
+ hang 2 (text "% ") tit <> cr <>
+ hang 2 (text "% ") (vcat $ map nowrap auths) <> cr <>
+ hang 2 (text "% ") dat <> cr
+
+mmdTitleBlock :: Value -> Doc
+mmdTitleBlock (Object hashmap) =
+ vcat $ map go $ sortBy (comparing fst) $ H.toList hashmap
+ where go (k,v) =
+ case (text (T.unpack k), v) of
+ (k', Array vec)
+ | V.null vec -> empty
+ | otherwise -> k' <> ":" <> space <>
+ hcat (intersperse "; "
+ (map fromstr $ V.toList vec))
+ (_, String "") -> empty
+ (k', x) -> k' <> ":" <> space <> nest 2 (fromstr x)
+ fromstr (String s) = text (removeBlankLines $ T.unpack s)
+ fromstr (Bool b) = text (show b)
+ fromstr (Number n) = text (show n)
+ fromstr _ = empty
+ -- blank lines not allowed in MMD metadata - we replace with .
+ removeBlankLines = trimr . unlines . map (\x ->
+ if all isSpace x then "." else x) . lines
+mmdTitleBlock _ = empty
+
+plainTitleBlock :: Doc -> [Doc] -> Doc -> Doc
+plainTitleBlock tit auths dat =
+ tit <> cr <>
+ (hcat (intersperse (text "; ") auths)) <> cr <>
+ dat <> cr
+
+yamlMetadataBlock :: Value -> Doc
+yamlMetadataBlock v = "---" $$ (jsonToYaml v) $$ "---"
+
+jsonToYaml :: Value -> Doc
+jsonToYaml (Object hashmap) =
+ vcat $ map (\(k,v) ->
+ case (text (T.unpack k), v, jsonToYaml v) of
+ (k', Array vec, x)
+ | V.null vec -> empty
+ | otherwise -> (k' <> ":") $$ x
+ (k', Object _, x) -> (k' <> ":") $$ nest 2 x
+ (_, String "", _) -> empty
+ (k', _, x) | k == "meta-json" -> empty
+ | otherwise -> k' <> ":" <> space <> hang 2 "" x)
+ $ sortBy (comparing fst) $ H.toList hashmap
+jsonToYaml (Array vec) =
+ vcat $ map (\v -> hang 2 "- " (jsonToYaml v)) $ V.toList vec
+jsonToYaml (String "") = empty
+jsonToYaml (String s) =
+ case T.unpack s of
+ x | '\n' `elem` x -> hang 2 ("|" <> cr) $ text x
+ | not (any isPunctuation x) -> text x
+ | otherwise -> text $ "'" ++ substitute "'" "''" x ++ "'"
+jsonToYaml (Bool b) = text $ show b
+jsonToYaml (Number n) = text $ show n
+jsonToYaml _ = empty
+
+-- | Return markdown representation of document.
+pandocToMarkdown :: PandocMonad m => WriterOptions -> Pandoc -> MD m String
+pandocToMarkdown opts (Pandoc meta blocks) = do
+ let colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ isPlain <- asks envPlain
+ metadata <- metaToJSON opts
+ (fmap (render colwidth) . blockListToMarkdown opts)
+ (fmap (render colwidth) . inlineListToMarkdown opts)
+ meta
+ let title' = maybe empty text $ getField "title" metadata
+ let authors' = maybe [] (map text) $ getField "author" metadata
+ let date' = maybe empty text $ getField "date" metadata
+ let titleblock = case writerTemplate opts of
+ Just _ | isPlain ->
+ plainTitleBlock title' authors' date'
+ | isEnabled Ext_yaml_metadata_block opts ->
+ yamlMetadataBlock metadata
+ | isEnabled Ext_pandoc_title_block opts ->
+ pandocTitleBlock title' authors' date'
+ | isEnabled Ext_mmd_title_block opts ->
+ mmdTitleBlock metadata
+ | otherwise -> empty
+ Nothing -> empty
+ let headerBlocks = filter isHeaderBlock blocks
+ toc <- if writerTableOfContents opts
+ then tableOfContents opts headerBlocks
+ else return empty
+ -- Strip off final 'references' header if markdown citations enabled
+ let blocks' = if isEnabled Ext_citations opts
+ then case reverse blocks of
+ (Div (_,["references"],_) _):xs -> reverse xs
+ _ -> blocks
+ else blocks
+ body <- blockListToMarkdown opts blocks'
+ notesAndRefs' <- notesAndRefs opts
+ let render' :: Doc -> String
+ render' = render colwidth
+ let main = render' $ body <> notesAndRefs'
+ let context = defField "toc" (render' toc)
+ $ defField "body" main
+ $ (if isNullMeta meta
+ then id
+ else defField "titleblock" (render' titleblock))
+ $ metadata
+ case writerTemplate opts of
+ Nothing -> return main
+ Just tpl -> return $ renderTemplate' tpl context
+
+-- | Return markdown representation of reference key table.
+refsToMarkdown :: PandocMonad m => WriterOptions -> Refs -> MD m Doc
+refsToMarkdown opts refs = mapM (keyToMarkdown opts) refs >>= return . vcat
+
+-- | Return markdown representation of a reference key.
+keyToMarkdown :: PandocMonad m
+ => WriterOptions
+ -> Ref
+ -> MD m Doc
+keyToMarkdown opts (label, (src, tit), attr) = do
+ label' <- inlineListToMarkdown opts label
+ let tit' = if null tit
+ then empty
+ else space <> "\"" <> text tit <> "\""
+ return $ nest 2 $ hang 2
+ ("[" <> label' <> "]:" <> space) (text src <> tit')
+ <> linkAttributes opts attr
+
+-- | Return markdown representation of notes.
+notesToMarkdown :: PandocMonad m => WriterOptions -> [[Block]] -> MD m Doc
+notesToMarkdown opts notes = do
+ n <- gets stNoteNum
+ notes' <- mapM (\(num, note) -> noteToMarkdown opts num note) (zip [n..] notes)
+ modify $ \st -> st { stNoteNum = stNoteNum st + length notes }
+ return $ vsep notes'
+
+-- | Return markdown representation of a note.
+noteToMarkdown :: PandocMonad m => WriterOptions -> Int -> [Block] -> MD m Doc
+noteToMarkdown opts num blocks = do
+ contents <- blockListToMarkdown opts blocks
+ let num' = text $ writerIdentifierPrefix opts ++ show num
+ let marker = if isEnabled Ext_footnotes opts
+ then text "[^" <> num' <> text "]:"
+ else text "[" <> num' <> text "]"
+ let markerSize = 4 + offset num'
+ let spacer = case writerTabStop opts - markerSize of
+ n | n > 0 -> text $ replicate n ' '
+ _ -> text " "
+ return $ if isEnabled Ext_footnotes opts
+ then hang (writerTabStop opts) (marker <> spacer) contents
+ else marker <> spacer <> contents
+
+-- | Escape special characters for Markdown.
+escapeString :: WriterOptions -> String -> String
+escapeString _ [] = []
+escapeString opts (c:cs) =
+ case c of
+ '<' -> "&lt;" ++ escapeString opts cs
+ '>' -> "&gt;" ++ escapeString opts cs
+ _ | c `elem` ['\\','`','*','_','[',']','#'] ->
+ '\\':c:escapeString opts cs
+ '^' | isEnabled Ext_superscript opts -> '\\':'^':escapeString opts cs
+ '~' | isEnabled Ext_subscript 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_smart opts ->
+ case cs of
+ '-':_ -> '\\':'-':escapeString opts cs
+ _ -> '-':escapeString opts cs
+ '.' | isEnabled Ext_smart opts ->
+ case cs of
+ '.':'.':rest -> '\\':'.':'.':'.':escapeString opts rest
+ _ -> '.':escapeString opts cs
+ _ -> c : escapeString opts cs
+
+-- | Construct table of contents from list of header blocks.
+tableOfContents :: PandocMonad m => WriterOptions -> [Block] -> m Doc
+tableOfContents opts headers =
+ let contents = BulletList $ map (elementToListItem opts) $ hierarchicalize headers
+ in evalMD (blockToMarkdown opts contents) def def
+
+-- | Converts an Element to a list item for a table of contents,
+elementToListItem :: WriterOptions -> Element -> [Block]
+elementToListItem opts (Sec lev _nums (ident,_,_) headerText subsecs)
+ = Plain headerLink :
+ [ BulletList (map (elementToListItem opts) subsecs) |
+ not (null subsecs) && lev < writerTOCDepth opts ]
+ where headerLink = if null ident
+ then walk deNote headerText
+ else [Link nullAttr (walk deNote headerText)
+ ('#':ident, "")]
+elementToListItem _ (Blk _) = []
+
+attrsToMarkdown :: Attr -> Doc
+attrsToMarkdown attribs = braces $ hsep [attribId, attribClasses, attribKeys]
+ where attribId = case attribs of
+ ([],_,_) -> empty
+ (i,_,_) -> "#" <> text i
+ attribClasses = case attribs of
+ (_,[],_) -> empty
+ (_,cs,_) -> hsep $
+ map (text . ('.':))
+ cs
+ attribKeys = case attribs of
+ (_,_,[]) -> empty
+ (_,_,ks) -> hsep $
+ map (\(k,v) -> text k
+ <> "=\"" <> text v <> "\"") ks
+
+linkAttributes :: WriterOptions -> Attr -> Doc
+linkAttributes opts attr =
+ if isEnabled Ext_link_attributes opts && attr /= nullAttr
+ then attrsToMarkdown attr
+ else empty
+
+-- | Ordered list start parser for use in Para below.
+olMarker :: Parser [Char] ParserState Char
+olMarker = do (start, style', delim) <- anyOrderedListMarker
+ if delim == Period &&
+ (style' == UpperAlpha || (style' == UpperRoman &&
+ start `elem` [1, 5, 10, 50, 100, 500, 1000]))
+ then spaceChar >> spaceChar
+ else spaceChar
+
+-- | True if string begins with an ordered list marker
+beginsWithOrderedListMarker :: String -> Bool
+beginsWithOrderedListMarker str =
+ case runParser olMarker defaultParserState "para start" (take 10 str) of
+ Left _ -> False
+ Right _ -> True
+
+notesAndRefs :: PandocMonad m => WriterOptions -> MD m Doc
+notesAndRefs opts = do
+ notes' <- reverse <$> gets stNotes >>= notesToMarkdown opts
+ modify $ \s -> s { stNotes = [] }
+ refs' <- reverse <$> gets stRefs >>= refsToMarkdown opts
+ modify $ \s -> s { stRefs = [] }
+
+ let endSpacing =
+ if | writerReferenceLocation opts == EndOfDocument -> empty
+ | isEmpty notes' && isEmpty refs' -> empty
+ | otherwise -> blankline
+
+ return $
+ (if isEmpty notes' then empty else blankline <> notes') <>
+ (if isEmpty refs' then empty else blankline <> refs') <>
+ endSpacing
+
+-- | Convert Pandoc block element to markdown.
+blockToMarkdown :: PandocMonad m
+ => WriterOptions -- ^ Options
+ -> Block -- ^ Block element
+ -> MD m Doc
+blockToMarkdown opts blk =
+ local (\env -> env {envBlockLevel = envBlockLevel env + 1}) $
+ do doc <- blockToMarkdown' opts blk
+ blkLevel <- asks envBlockLevel
+ if writerReferenceLocation opts == EndOfBlock && blkLevel == 1
+ then notesAndRefs opts >>= (\d -> return $ doc <> d)
+ else return doc
+
+blockToMarkdown' :: PandocMonad m
+ => WriterOptions -- ^ Options
+ -> Block -- ^ Block element
+ -> MD m Doc
+blockToMarkdown' _ Null = return empty
+blockToMarkdown' opts (Div attrs ils) = do
+ contents <- blockListToMarkdown opts ils
+ return $ if isEnabled Ext_raw_html opts &&
+ isEnabled Ext_markdown_in_html_blocks opts
+ then tagWithAttrs "div" attrs <> blankline <>
+ contents <> blankline <> "</div>" <> blankline
+ else contents <> blankline
+blockToMarkdown' opts (Plain inlines) = do
+ contents <- inlineListToMarkdown opts inlines
+ -- escape if para starts with ordered list marker
+ isPlain <- asks envPlain
+ let colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ let rendered = render colwidth contents
+ let escapeDelimiter (x:xs) | x `elem` (".()" :: String) = '\\':x:xs
+ | otherwise = x : escapeDelimiter xs
+ escapeDelimiter [] = []
+ let contents' = if isEnabled Ext_all_symbols_escapable opts &&
+ not isPlain && beginsWithOrderedListMarker rendered
+ then text $ escapeDelimiter rendered
+ else contents
+ return $ contents' <> cr
+-- title beginning with fig: indicates figure
+blockToMarkdown' opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) =
+ blockToMarkdown opts (Para [Image attr alt (src,tit)])
+blockToMarkdown' opts (Para inlines) =
+ (<> blankline) `fmap` blockToMarkdown opts (Plain inlines)
+blockToMarkdown' opts (LineBlock lns) =
+ if isEnabled Ext_line_blocks opts
+ then do
+ mdLines <- mapM (inlineListToMarkdown opts) lns
+ return $ (vcat $ map (hang 2 (text "| ")) mdLines) <> blankline
+ else blockToMarkdown opts $ linesToPara lns
+blockToMarkdown' opts b@(RawBlock f str)
+ | f == "markdown" = return $ text str <> text "\n"
+ | f == "html" && isEnabled Ext_raw_html opts = do
+ plain <- asks envPlain
+ return $ if plain
+ then empty
+ else if isEnabled Ext_markdown_attribute opts
+ then text (addMarkdownAttribute str) <> text "\n"
+ else text str <> text "\n"
+ | f `elem` ["latex", "tex"] && isEnabled Ext_raw_tex opts = do
+ plain <- asks envPlain
+ return $ if plain
+ then empty
+ else text str <> text "\n"
+ | otherwise = do
+ report $ BlockNotRendered b
+ return empty
+blockToMarkdown' opts HorizontalRule = do
+ return $ blankline <> text (replicate (writerColumns opts) '-') <> blankline
+blockToMarkdown' opts (Header level attr inlines) = do
+ -- first, if we're putting references at the end of a section, we
+ -- put them here.
+ blkLevel <- asks envBlockLevel
+ refs <- if writerReferenceLocation opts == EndOfSection && blkLevel == 1
+ then notesAndRefs opts
+ else return empty
+
+ plain <- asks envPlain
+ -- we calculate the id that would be used by auto_identifiers
+ -- so we know whether to print an explicit identifier
+ ids <- gets stIds
+ let autoId = uniqueIdent inlines ids
+ modify $ \st -> st{ stIds = Set.insert autoId ids }
+ let attr' = case attr of
+ ("",[],[]) -> empty
+ (id',[],[]) | isEnabled Ext_auto_identifiers opts
+ && id' == autoId -> empty
+ (id',_,_) | isEnabled Ext_mmd_header_identifiers opts ->
+ space <> brackets (text id')
+ _ | isEnabled Ext_header_attributes opts ->
+ space <> attrsToMarkdown attr
+ | otherwise -> empty
+ contents <- inlineListToMarkdown opts $
+ if level == 1 && plain
+ then capitalize inlines
+ else inlines
+ let setext = writerSetextHeaders opts
+ hdr = nowrap $ case level of
+ 1 | plain -> blanklines 3 <> contents <> blanklines 2
+ | setext ->
+ contents <> attr' <> cr <> text (replicate (offset contents) '=') <>
+ blankline
+ 2 | plain -> blanklines 2 <> contents <> blankline
+ | setext ->
+ contents <> attr' <> cr <> text (replicate (offset contents) '-') <>
+ blankline
+ -- ghc interprets '#' characters in column 1 as linenum specifiers.
+ _ | plain || isEnabled Ext_literate_haskell opts ->
+ contents <> blankline
+ _ -> text (replicate level '#') <> space <> contents <> attr' <> blankline
+
+ return $ refs <> hdr
+blockToMarkdown' opts (CodeBlock (_,classes,_) str)
+ | "haskell" `elem` classes && "literate" `elem` classes &&
+ isEnabled Ext_literate_haskell opts =
+ return $ prefixed "> " (text str) <> blankline
+blockToMarkdown' opts (CodeBlock attribs str) = return $
+ case attribs == nullAttr of
+ False | isEnabled Ext_backtick_code_blocks opts ->
+ backticks <> attrs <> cr <> text str <> cr <> backticks <> blankline
+ | isEnabled Ext_fenced_code_blocks opts ->
+ tildes <> attrs <> cr <> text str <> cr <> tildes <> blankline
+ _ -> nest (writerTabStop opts) (text str) <> blankline
+ where tildes = text $ case [ln | ln <- lines str, all (=='~') ln] of
+ [] -> "~~~~"
+ xs -> case maximum $ map length xs of
+ n | n < 3 -> "~~~~"
+ | otherwise -> replicate (n+1) '~'
+ backticks = text $ case [ln | ln <- lines str, all (=='`') ln] of
+ [] -> "```"
+ xs -> case maximum $ map length xs of
+ n | n < 3 -> "```"
+ | otherwise -> replicate (n+1) '`'
+ attrs = if isEnabled Ext_fenced_code_attributes opts
+ then nowrap $ " " <> attrsToMarkdown attribs
+ else case attribs of
+ (_,(cls:_),_) -> " " <> text cls
+ _ -> empty
+blockToMarkdown' opts (BlockQuote blocks) = do
+ plain <- asks envPlain
+ -- if we're writing literate haskell, put a space before the bird tracks
+ -- so they won't be interpreted as lhs...
+ let leader = if isEnabled Ext_literate_haskell opts
+ then " > "
+ else if plain then " " else "> "
+ contents <- blockListToMarkdown opts blocks
+ return $ (prefixed leader contents) <> blankline
+blockToMarkdown' opts t@(Table caption aligns widths headers rows) = do
+ caption' <- inlineListToMarkdown opts caption
+ let caption'' = if null caption || not (isEnabled Ext_table_captions opts)
+ then empty
+ else blankline <> ": " <> caption' <> blankline
+ rawHeaders <- mapM (blockListToMarkdown opts) headers
+ rawRows <- mapM (mapM (blockListToMarkdown opts)) rows
+ let isLineBreak LineBreak = Any True
+ isLineBreak _ = Any False
+ let isSimple = all (==0) widths &&
+ not ( getAny (query isLineBreak (headers:rows)) )
+ let isPlainBlock (Plain _) = True
+ isPlainBlock _ = False
+ let hasBlocks = not (all isPlainBlock $ concat . concat $ headers:rows)
+ (nst,tbl) <- case True of
+ _ | isSimple &&
+ isEnabled Ext_simple_tables opts -> fmap (nest 2,) $
+ pandocTable opts (all null headers) aligns widths
+ rawHeaders rawRows
+ | isSimple &&
+ isEnabled Ext_pipe_tables opts -> fmap (id,) $
+ pipeTable (all null headers) aligns rawHeaders rawRows
+ | not hasBlocks &&
+ isEnabled Ext_multiline_tables opts -> fmap (nest 2,) $
+ pandocTable opts (all null headers) aligns widths
+ rawHeaders rawRows
+ | isEnabled Ext_grid_tables opts -> fmap (id,) $
+ gridTable opts (all null headers) aligns widths
+ rawHeaders rawRows
+ | isEnabled Ext_raw_html opts -> fmap (id,) $
+ text <$>
+ (writeHtml5String def $ Pandoc nullMeta [t])
+ | otherwise -> return $ (id, text "[TABLE]")
+ return $ nst $ tbl $$ blankline $$ caption'' $$ blankline
+blockToMarkdown' opts (BulletList items) = do
+ contents <- inList $ mapM (bulletListItemToMarkdown opts) items
+ return $ cat contents <> blankline
+blockToMarkdown' opts (OrderedList (start,sty,delim) items) = do
+ let start' = if isEnabled Ext_startnum opts then start else 1
+ let sty' = if isEnabled Ext_fancy_lists opts then sty else DefaultStyle
+ let delim' = if isEnabled Ext_fancy_lists opts then delim else DefaultDelim
+ let attribs = (start', sty', delim')
+ let markers = orderedListMarkers attribs
+ let markers' = map (\m -> if length m < 3
+ then m ++ replicate (3 - length m) ' '
+ else m) markers
+ contents <- inList $
+ mapM (\(item, num) -> orderedListItemToMarkdown opts item num) $
+ zip markers' items
+ return $ cat contents <> blankline
+blockToMarkdown' opts (DefinitionList items) = do
+ contents <- inList $ mapM (definitionListItemToMarkdown opts) items
+ return $ cat contents <> blankline
+
+inList :: Monad m => MD m a -> MD m a
+inList p = local (\env -> env {envInList = True}) p
+
+addMarkdownAttribute :: String -> String
+addMarkdownAttribute s =
+ case span isTagText $ reverse $ parseTags s of
+ (xs,(TagOpen t attrs:rest)) ->
+ renderTags' $ reverse rest ++ (TagOpen t attrs' : reverse xs)
+ where attrs' = ("markdown","1"):[(x,y) | (x,y) <- attrs,
+ x /= "markdown"]
+ _ -> s
+
+pipeTable :: PandocMonad m => Bool -> [Alignment] -> [Doc] -> [[Doc]] -> MD m Doc
+pipeTable headless aligns rawHeaders rawRows = do
+ let sp = text " "
+ let blockFor AlignLeft x y = lblock (x + 2) (sp <> y) <> lblock 0 empty
+ blockFor AlignCenter x y = cblock (x + 2) (sp <> y) <> lblock 0 empty
+ blockFor AlignRight x y = rblock (x + 2) (sp <> y) <> lblock 0 empty
+ blockFor _ x y = lblock (x + 2) (sp <> y) <> lblock 0 empty
+ let widths = map (max 3 . maximum . map offset) $ transpose (rawHeaders : rawRows)
+ let torow cs = nowrap $ text "|" <>
+ hcat (intersperse (text "|") $
+ zipWith3 blockFor aligns widths (map chomp cs))
+ <> text "|"
+ let toborder (a, w) = text $ case a of
+ AlignLeft -> ':':replicate (w + 1) '-'
+ AlignCenter -> ':':replicate w '-' ++ ":"
+ AlignRight -> replicate (w + 1) '-' ++ ":"
+ AlignDefault -> replicate (w + 2) '-'
+ -- note: pipe tables can't completely lack a
+ -- header; for a headerless table, we need a header of empty cells.
+ -- see jgm/pandoc#1996.
+ let header = if headless
+ then torow (replicate (length aligns) empty)
+ else torow rawHeaders
+ let border = nowrap $ text "|" <> hcat (intersperse (text "|") $
+ map toborder $ zip aligns widths) <> text "|"
+ let body = vcat $ map torow rawRows
+ return $ header $$ border $$ body
+
+pandocTable :: PandocMonad m => WriterOptions -> Bool -> [Alignment] -> [Double]
+ -> [Doc] -> [[Doc]] -> MD m Doc
+pandocTable opts headless aligns widths rawHeaders rawRows = do
+ let isSimple = all (==0) widths
+ let alignHeader alignment = case alignment of
+ AlignLeft -> lblock
+ AlignCenter -> cblock
+ AlignRight -> rblock
+ AlignDefault -> lblock
+ -- Number of characters per column necessary to output every cell
+ -- without requiring a line break.
+ -- The @+2@ is needed for specifying the alignment.
+ let numChars = (+ 2) . maximum . map offset
+ -- Number of characters per column necessary to output every cell
+ -- without requiring a line break *inside a word*.
+ -- The @+2@ is needed for specifying the alignment.
+ let minNumChars = (+ 2) . maximum . map minOffset
+ let columns = transpose (rawHeaders : rawRows)
+ -- minimal column width without wrapping a single word
+ let noWordWrapWidth
+ | writerWrapText opts == WrapAuto
+ = fromIntegral $ maximum (map minNumChars columns)
+ | otherwise = fromIntegral $ maximum (map numChars columns)
+ let relWidth w = floor $ max (fromIntegral (writerColumns opts) * w)
+ (noWordWrapWidth * w / minimum widths)
+ let widthsInChars
+ | isSimple = map numChars columns
+ | otherwise = map relWidth widths
+ let makeRow = hcat . intersperse (lblock 1 (text " ")) .
+ (zipWith3 alignHeader aligns widthsInChars)
+ let rows' = map makeRow rawRows
+ let head' = makeRow rawHeaders
+ let maxRowHeight = maximum $ map height (head':rows')
+ let underline = cat $ intersperse (text " ") $
+ map (\width -> text (replicate width '-')) widthsInChars
+ let border = if maxRowHeight > 1
+ then text (replicate (sum widthsInChars +
+ length widthsInChars - 1) '-')
+ else if headless
+ then underline
+ else empty
+ let head'' = if headless
+ then empty
+ else border <> cr <> head'
+ let body = if maxRowHeight > 1
+ then vsep rows'
+ else vcat rows'
+ let bottom = if headless
+ then underline
+ else border
+ return $ head'' $$ underline $$ body $$ bottom
+
+gridTable :: PandocMonad m => WriterOptions -> Bool -> [Alignment] -> [Double]
+ -> [Doc] -> [[Doc]] -> MD m Doc
+gridTable opts headless aligns widths headers' rawRows = do
+ let numcols = length headers'
+ let widths' = if all (==0) widths
+ then replicate numcols (1.0 / fromIntegral numcols)
+ else widths
+ let widthsInChars = map
+ ((\x -> x - 3) . floor . (fromIntegral (writerColumns opts) *)) widths'
+ let hpipeBlocks blocks = hcat [beg, middle, end]
+ where h = maximum (1 : map height blocks)
+ sep' = lblock 3 $ vcat (map text $ replicate h " | ")
+ beg = lblock 2 $ vcat (map text $ replicate h "| ")
+ end = lblock 2 $ vcat (map text $ replicate h " |")
+ middle = chomp $ hcat $ intersperse sep' blocks
+ let makeRow = hpipeBlocks . zipWith lblock widthsInChars
+ let head' = makeRow headers'
+ let rows' = map (makeRow . map chomp) rawRows
+ let borderpart ch align widthInChars =
+ let widthInChars' = if widthInChars < 1 then 1 else widthInChars
+ in (if (align == AlignLeft || align == AlignCenter)
+ then char ':'
+ else char ch) <>
+ text (replicate widthInChars' ch) <>
+ (if (align == AlignRight || align == AlignCenter)
+ then char ':'
+ else char ch)
+ let border ch aligns' widthsInChars' =
+ char '+' <>
+ hcat (intersperse (char '+') (zipWith (borderpart ch)
+ aligns' widthsInChars')) <> char '+'
+ let body = vcat $ intersperse (border '-' (repeat AlignDefault) widthsInChars)
+ rows'
+ let head'' = if headless
+ then empty
+ else head' $$ border '=' aligns widthsInChars
+ if headless
+ then return $
+ border '-' aligns widthsInChars $$
+ body $$
+ border '-' (repeat AlignDefault) widthsInChars
+ else return $
+ border '-' (repeat AlignDefault) widthsInChars $$
+ head'' $$
+ body $$
+ border '-' (repeat AlignDefault) widthsInChars
+
+itemEndsWithTightList :: [Block] -> Bool
+itemEndsWithTightList bs =
+ case bs of
+ [Plain _, BulletList xs] -> isTightList xs
+ [Plain _, OrderedList _ xs] -> isTightList xs
+ _ -> False
+
+-- | Convert bullet list item (list of blocks) to markdown.
+bulletListItemToMarkdown :: PandocMonad m => WriterOptions -> [Block] -> MD m Doc
+bulletListItemToMarkdown opts bs = do
+ contents <- blockListToMarkdown opts bs
+ let sps = replicate (writerTabStop opts - 2) ' '
+ let start = text ('-' : ' ' : sps)
+ -- remove trailing blank line if item ends with a tight list
+ let contents' = if itemEndsWithTightList bs
+ then chomp contents <> cr
+ else contents
+ return $ hang (writerTabStop opts) start $ contents' <> cr
+
+-- | Convert ordered list item (a list of blocks) to markdown.
+orderedListItemToMarkdown :: PandocMonad m
+ => WriterOptions -- ^ options
+ -> String -- ^ list item marker
+ -> [Block] -- ^ list item (list of blocks)
+ -> MD m Doc
+orderedListItemToMarkdown opts marker bs = do
+ contents <- blockListToMarkdown opts bs
+ let sps = case length marker - writerTabStop opts of
+ n | n > 0 -> text $ replicate n ' '
+ _ -> text " "
+ let start = text marker <> sps
+ -- remove trailing blank line if item ends with a tight list
+ let contents' = if itemEndsWithTightList bs
+ then chomp contents <> cr
+ else contents
+ return $ hang (writerTabStop opts) start $ contents' <> cr
+
+-- | Convert definition list item (label, list of blocks) to markdown.
+definitionListItemToMarkdown :: PandocMonad m
+ => WriterOptions
+ -> ([Inline],[[Block]])
+ -> MD m Doc
+definitionListItemToMarkdown opts (label, defs) = do
+ labelText <- inlineListToMarkdown opts label
+ defs' <- mapM (mapM (blockToMarkdown opts)) defs
+ if isEnabled Ext_definition_lists opts
+ then do
+ let tabStop = writerTabStop opts
+ isPlain <- asks envPlain
+ let leader = if isPlain then " " else ": "
+ let sps = case writerTabStop opts - 3 of
+ n | n > 0 -> text $ replicate n ' '
+ _ -> text " "
+ if isEnabled Ext_compact_definition_lists opts
+ then do
+ let contents = vcat $ map (\d -> hang tabStop (leader <> sps)
+ $ vcat d <> cr) defs'
+ return $ nowrap labelText <> cr <> contents <> cr
+ else do
+ let contents = vcat $ map (\d -> hang tabStop (leader <> sps)
+ $ vcat d <> cr) defs'
+ let isTight = case defs of
+ ((Plain _ : _): _) -> True
+ _ -> False
+ return $ blankline <> nowrap labelText <>
+ (if isTight then cr else blankline) <> contents <> blankline
+ else do
+ return $ nowrap labelText <> text " " <> cr <>
+ vsep (map vsep defs') <> blankline
+
+-- | Convert list of Pandoc block elements to markdown.
+blockListToMarkdown :: PandocMonad m
+ => WriterOptions -- ^ Options
+ -> [Block] -- ^ List of block elements
+ -> MD m Doc
+blockListToMarkdown opts blocks =
+ mapM (blockToMarkdown opts) (fixBlocks blocks) >>= return . cat
+ -- insert comment between list and indented code block, or the
+ -- code block will be treated as a list continuation paragraph
+ where fixBlocks (b : CodeBlock attr x : rest)
+ | (not (isEnabled Ext_fenced_code_blocks opts) || attr == nullAttr)
+ && isListBlock b = b : commentSep : CodeBlock attr x :
+ fixBlocks rest
+ fixBlocks (b1@(BulletList _) : b2@(BulletList _) : bs) =
+ b1 : commentSep : fixBlocks (b2:bs)
+ fixBlocks (b1@(OrderedList _ _) : b2@(OrderedList _ _) : bs) =
+ b1 : commentSep : fixBlocks (b2:bs)
+ fixBlocks (b1@(DefinitionList _) : b2@(DefinitionList _) : bs) =
+ b1 : commentSep : fixBlocks (b2:bs)
+ fixBlocks (x : xs) = x : fixBlocks xs
+ fixBlocks [] = []
+ isListBlock (BulletList _) = True
+ isListBlock (OrderedList _ _) = True
+ isListBlock (DefinitionList _) = True
+ isListBlock _ = False
+ commentSep = if isEnabled Ext_raw_html opts
+ then RawBlock "html" "<!-- -->\n"
+ else RawBlock "markdown" "&nbsp;"
+
+-- | Get reference for target; if none exists, create unique one and return.
+-- Prefer label if possible; otherwise, generate a unique key.
+getReference :: PandocMonad m => Attr -> [Inline] -> Target -> MD m [Inline]
+getReference attr label target = do
+ st <- get
+ case find (\(_,t,a) -> t == target && a == attr) (stRefs st) of
+ Just (ref, _, _) -> return ref
+ Nothing -> do
+ label' <- case find (\(l,_,_) -> l == label) (stRefs st) of
+ Just _ -> -- label is used; generate numerical label
+ case find (\n -> notElem [Str (show n)]
+ (map (\(l,_,_) -> l) (stRefs st)))
+ [1..(10000 :: Integer)] of
+ Just x -> return [Str (show x)]
+ Nothing -> throwError $ PandocSomeError "no unique label"
+ Nothing -> return label
+ modify (\s -> s{ stRefs = (label', target, attr) : stRefs st })
+ return label'
+
+-- | Convert list of Pandoc inline elements to markdown.
+inlineListToMarkdown :: PandocMonad m => WriterOptions -> [Inline] -> MD m Doc
+inlineListToMarkdown opts lst = do
+ inlist <- asks envInList
+ go (if inlist then avoidBadWrapsInList lst else lst)
+ where go [] = return empty
+ go (i:is) = case i of
+ (Link _ _ _) -> case is of
+ -- If a link is followed by another link or '[' we don't shortcut
+ (Link _ _ _):_ -> unshortcutable
+ Space:(Link _ _ _):_ -> unshortcutable
+ Space:(Str('[':_)):_ -> unshortcutable
+ Space:(RawInline _ ('[':_)):_ -> unshortcutable
+ Space:(Cite _ _):_ -> unshortcutable
+ SoftBreak:(Link _ _ _):_ -> unshortcutable
+ SoftBreak:(Str('[':_)):_ -> unshortcutable
+ SoftBreak:(RawInline _ ('[':_)):_ -> unshortcutable
+ SoftBreak:(Cite _ _):_ -> unshortcutable
+ (Cite _ _):_ -> unshortcutable
+ Str ('[':_):_ -> unshortcutable
+ (RawInline _ ('[':_)):_ -> unshortcutable
+ (RawInline _ (' ':'[':_)):_ -> unshortcutable
+ _ -> shortcutable
+ _ -> shortcutable
+ where shortcutable = liftM2 (<>) (inlineToMarkdown opts i) (go is)
+ unshortcutable = do
+ iMark <- local
+ (\env -> env { envRefShortcutable = False })
+ (inlineToMarkdown opts i)
+ fmap (iMark <>) (go is)
+
+isSp :: Inline -> Bool
+isSp Space = True
+isSp SoftBreak = True
+isSp _ = False
+
+avoidBadWrapsInList :: [Inline] -> [Inline]
+avoidBadWrapsInList [] = []
+avoidBadWrapsInList (s:Str ('>':cs):xs) | isSp s =
+ Str (' ':'>':cs) : avoidBadWrapsInList xs
+avoidBadWrapsInList (s:Str [c]:[])
+ | isSp s && c `elem` ['-','*','+'] = Str [' ', c] : []
+avoidBadWrapsInList (s:Str [c]:Space:xs)
+ | isSp s && c `elem` ['-','*','+'] =
+ Str [' ', c] : Space : avoidBadWrapsInList xs
+avoidBadWrapsInList (s:Str cs:Space:xs)
+ | isSp s && isOrderedListMarker cs =
+ Str (' ':cs) : Space : avoidBadWrapsInList xs
+avoidBadWrapsInList (s:Str cs:[])
+ | isSp s && isOrderedListMarker cs = Str (' ':cs) : []
+avoidBadWrapsInList (x:xs) = x : avoidBadWrapsInList xs
+
+isOrderedListMarker :: String -> Bool
+isOrderedListMarker xs = (last xs `elem` ['.',')']) &&
+ isRight (runParser (anyOrderedListMarker >> eof)
+ defaultParserState "" xs)
+
+isRight :: Either a b -> Bool
+isRight (Right _) = True
+isRight (Left _) = False
+
+-- | Convert Pandoc inline element to markdown.
+inlineToMarkdown :: PandocMonad m => WriterOptions -> Inline -> MD m Doc
+inlineToMarkdown opts (Span attrs ils) = do
+ plain <- asks envPlain
+ contents <- inlineListToMarkdown opts ils
+ return $ case plain of
+ True -> contents
+ False | isEnabled Ext_bracketed_spans opts ->
+ "[" <> contents <> "]" <>
+ if attrs == nullAttr
+ then "{}"
+ else linkAttributes opts attrs
+ | isEnabled Ext_raw_html opts ||
+ isEnabled Ext_native_spans opts ->
+ tagWithAttrs "span" attrs <> contents <> text "</span>"
+ | otherwise -> contents
+inlineToMarkdown opts (Emph lst) = do
+ plain <- asks envPlain
+ contents <- inlineListToMarkdown opts lst
+ return $ if plain
+ then "_" <> contents <> "_"
+ else "*" <> contents <> "*"
+inlineToMarkdown opts (Strong lst) = do
+ plain <- asks envPlain
+ if plain
+ then inlineListToMarkdown opts $ capitalize lst
+ else do
+ contents <- inlineListToMarkdown opts lst
+ return $ "**" <> contents <> "**"
+inlineToMarkdown opts (Strikeout lst) = do
+ contents <- inlineListToMarkdown opts lst
+ return $ if isEnabled Ext_strikeout opts
+ then "~~" <> contents <> "~~"
+ else if isEnabled Ext_raw_html opts
+ then "<s>" <> contents <> "</s>"
+ else contents
+inlineToMarkdown opts (Superscript lst) =
+ local (\env -> env {envEscapeSpaces = True}) $ do
+ contents <- inlineListToMarkdown opts lst
+ return $ if isEnabled Ext_superscript opts
+ then "^" <> contents <> "^"
+ else if isEnabled Ext_raw_html opts
+ then "<sup>" <> contents <> "</sup>"
+ else case (render Nothing contents) of
+ ds | all (\d -> d >= '0' && d <= '9') ds
+ -> text (map toSuperscript ds)
+ _ -> contents
+ where toSuperscript '1' = '\x00B9'
+ toSuperscript '2' = '\x00B2'
+ toSuperscript '3' = '\x00B3'
+ toSuperscript c = chr (0x2070 + (ord c - 48))
+inlineToMarkdown opts (Subscript lst) =
+ local (\env -> env {envEscapeSpaces = True}) $ do
+ contents <- inlineListToMarkdown opts lst
+ return $ if isEnabled Ext_subscript opts
+ then "~" <> contents <> "~"
+ else if isEnabled Ext_raw_html opts
+ then "<sub>" <> contents <> "</sub>"
+ else case (render Nothing contents) of
+ ds | all (\d -> d >= '0' && d <= '9') ds
+ -> text (map toSubscript ds)
+ _ -> contents
+ where toSubscript c = chr (0x2080 + (ord c - 48))
+inlineToMarkdown opts (SmallCaps lst) = do
+ plain <- asks envPlain
+ if not plain &&
+ (isEnabled Ext_raw_html opts || isEnabled Ext_native_spans opts)
+ then do
+ contents <- inlineListToMarkdown opts lst
+ return $ tagWithAttrs "span"
+ ("",[],[("style","font-variant:small-caps;")])
+ <> contents <> text "</span>"
+ else inlineListToMarkdown opts $ capitalize lst
+inlineToMarkdown opts (Quoted SingleQuote lst) = do
+ contents <- inlineListToMarkdown opts lst
+ return $ if isEnabled Ext_smart 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 <> "”"
+inlineToMarkdown opts (Code attr str) = do
+ let tickGroups = filter (\s -> '`' `elem` s) $ group str
+ let longest = if null tickGroups
+ then 0
+ else maximum $ map length tickGroups
+ let marker = replicate (longest + 1) '`'
+ let spacer = if (longest == 0) then "" else " "
+ let attrs = if isEnabled Ext_inline_code_attributes opts && attr /= nullAttr
+ then attrsToMarkdown attr
+ else empty
+ plain <- asks envPlain
+ if plain
+ then return $ text str
+ else return $ text (marker ++ spacer ++ str ++ spacer ++ marker) <> attrs
+inlineToMarkdown opts (Str str) = do
+ isPlain <- asks envPlain
+ let str' = (if isEnabled Ext_smart opts
+ then unsmartify opts
+ else id) $
+ if isPlain
+ then str
+ else escapeString opts str
+ return $ text str'
+inlineToMarkdown opts (Math InlineMath str) =
+ case writerHTMLMathMethod opts of
+ WebTeX url ->
+ inlineToMarkdown opts (Image nullAttr [Str str]
+ (url ++ urlEncode str, str))
+ _ | isEnabled Ext_tex_math_dollars opts ->
+ return $ "$" <> text str <> "$"
+ | isEnabled Ext_tex_math_single_backslash opts ->
+ return $ "\\(" <> text str <> "\\)"
+ | isEnabled Ext_tex_math_double_backslash opts ->
+ return $ "\\\\(" <> text str <> "\\\\)"
+ | otherwise -> do
+ plain <- asks envPlain
+ texMathToInlines InlineMath str >>=
+ inlineListToMarkdown opts .
+ (if plain then makeMathPlainer else id)
+inlineToMarkdown opts (Math DisplayMath str) =
+ case writerHTMLMathMethod opts of
+ WebTeX url -> (\x -> blankline <> x <> blankline) `fmap`
+ inlineToMarkdown opts (Image nullAttr [Str str]
+ (url ++ urlEncode str, str))
+ _ | isEnabled Ext_tex_math_dollars opts ->
+ return $ "$$" <> text str <> "$$"
+ | isEnabled Ext_tex_math_single_backslash opts ->
+ return $ "\\[" <> text str <> "\\]"
+ | isEnabled Ext_tex_math_double_backslash opts ->
+ return $ "\\\\[" <> text str <> "\\\\]"
+ | otherwise -> (\x -> cr <> x <> cr) `fmap`
+ (texMathToInlines DisplayMath str >>= inlineListToMarkdown opts)
+inlineToMarkdown opts il@(RawInline f str) = do
+ plain <- asks envPlain
+ if not plain &&
+ ( f == "markdown" ||
+ (isEnabled Ext_raw_tex opts && (f == "latex" || f == "tex")) ||
+ (isEnabled Ext_raw_html opts && f == "html") )
+ then return $ text str
+ else do
+ report $ InlineNotRendered il
+ return empty
+inlineToMarkdown opts (LineBreak) = do
+ plain <- asks envPlain
+ if plain || isEnabled Ext_hard_line_breaks opts
+ then return cr
+ else return $
+ if isEnabled Ext_escaped_line_breaks opts
+ then "\\" <> cr
+ else " " <> cr
+inlineToMarkdown _ Space = do
+ escapeSpaces <- asks envEscapeSpaces
+ return $ if escapeSpaces then "\\ " else space
+inlineToMarkdown opts SoftBreak = do
+ escapeSpaces <- asks envEscapeSpaces
+ let space' = if escapeSpaces then "\\ " else space
+ return $ case writerWrapText opts of
+ WrapNone -> space'
+ WrapAuto -> space'
+ WrapPreserve -> cr
+inlineToMarkdown opts (Cite [] lst) = inlineListToMarkdown opts lst
+inlineToMarkdown opts (Cite (c:cs) lst)
+ | not (isEnabled Ext_citations opts) = inlineListToMarkdown opts lst
+ | otherwise =
+ if citationMode c == AuthorInText
+ then do
+ suffs <- inlineListToMarkdown opts $ citationSuffix c
+ rest <- mapM convertOne cs
+ let inbr = suffs <+> joincits rest
+ br = if isEmpty inbr then empty else char '[' <> inbr <> char ']'
+ return $ text ("@" ++ citationId c) <+> br
+ else do
+ cits <- mapM convertOne (c:cs)
+ return $ text "[" <> joincits cits <> text "]"
+ where
+ joincits = hcat . intersperse (text "; ") . filter (not . isEmpty)
+ convertOne Citation { citationId = k
+ , citationPrefix = pinlines
+ , citationSuffix = sinlines
+ , citationMode = m }
+ = do
+ pdoc <- inlineListToMarkdown opts pinlines
+ sdoc <- inlineListToMarkdown opts sinlines
+ let k' = text (modekey m ++ "@" ++ k)
+ r = case sinlines of
+ Str (y:_):_ | y `elem` (",;]@" :: String) -> k' <> sdoc
+ _ -> k' <+> sdoc
+ return $ pdoc <+> r
+ modekey SuppressAuthor = "-"
+ modekey _ = ""
+inlineToMarkdown opts lnk@(Link attr txt (src, tit))
+ | isEnabled Ext_raw_html opts &&
+ not (isEnabled Ext_link_attributes opts) &&
+ attr /= nullAttr = -- use raw HTML
+ (text . trim) <$> writeHtml5String def (Pandoc nullMeta [Plain [lnk]])
+ | otherwise = do
+ plain <- asks envPlain
+ linktext <- inlineListToMarkdown opts txt
+ let linktitle = if null tit
+ then empty
+ else text $ " \"" ++ tit ++ "\""
+ let srcSuffix = fromMaybe src (stripPrefix "mailto:" src)
+ let useAuto = isURI src &&
+ case txt of
+ [Str s] | escapeURI s == srcSuffix -> True
+ _ -> False
+ let useRefLinks = writerReferenceLinks opts && not useAuto
+ shortcutable <- asks envRefShortcutable
+ let useShortcutRefLinks = shortcutable &&
+ isEnabled Ext_shortcut_reference_links opts
+ ref <- if useRefLinks then getReference attr txt (src, tit) else return []
+ reftext <- inlineListToMarkdown opts ref
+ return $ if useAuto
+ then if plain
+ then text srcSuffix
+ else "<" <> text srcSuffix <> ">"
+ else if useRefLinks
+ then let first = "[" <> linktext <> "]"
+ second = if txt == ref
+ then if useShortcutRefLinks
+ then ""
+ else "[]"
+ else "[" <> reftext <> "]"
+ in first <> second
+ else if plain
+ then linktext
+ else "[" <> linktext <> "](" <>
+ text src <> linktitle <> ")" <>
+ linkAttributes opts attr
+inlineToMarkdown opts img@(Image attr alternate (source, tit))
+ | isEnabled Ext_raw_html opts &&
+ not (isEnabled Ext_link_attributes opts) &&
+ attr /= nullAttr = -- use raw HTML
+ (text . trim) <$> writeHtml5String def (Pandoc nullMeta [Plain [img]])
+ | otherwise = do
+ plain <- asks envPlain
+ let txt = if null alternate || alternate == [Str source]
+ -- to prevent autolinks
+ then [Str ""]
+ else alternate
+ linkPart <- inlineToMarkdown opts (Link attr txt (source, tit))
+ return $ if plain
+ then "[" <> linkPart <> "]"
+ else "!" <> linkPart
+inlineToMarkdown opts (Note contents) = do
+ modify (\st -> st{ stNotes = contents : stNotes st })
+ st <- get
+ let ref = text $ writerIdentifierPrefix opts ++ show (stNoteNum st + (length $ stNotes st) - 1)
+ if isEnabled Ext_footnotes opts
+ then return $ "[^" <> ref <> "]"
+ else return $ "[" <> ref <> "]"
+
+makeMathPlainer :: [Inline] -> [Inline]
+makeMathPlainer = walk go
+ where
+ go (Emph xs) = Span nullAttr xs
+ go x = x
+
diff --git a/src/Text/Pandoc/Writers/Math.hs b/src/Text/Pandoc/Writers/Math.hs
new file mode 100644
index 000000000..b7419ddf9
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Math.hs
@@ -0,0 +1,49 @@
+module Text.Pandoc.Writers.Math
+ ( texMathToInlines
+ , convertMath
+ )
+where
+
+import Text.Pandoc.Class
+import Text.Pandoc.Definition
+import Text.Pandoc.Logging
+import Text.TeXMath (Exp, writePandoc, DisplayType(..), readTeX)
+
+-- | Converts a raw TeX math formula to a list of 'Pandoc' inlines.
+-- Defaults to raw formula between @$@ or @$$@ characters if entire formula
+-- can't be converted.
+texMathToInlines :: PandocMonad m
+ => MathType
+ -> String -- ^ String to parse (assumes @'\n'@ line endings)
+ -> m [Inline]
+texMathToInlines mt inp = do
+ res <- convertMath writePandoc mt inp
+ case res of
+ Right (Just ils) -> return ils
+ Right (Nothing) -> do
+ report $ CouldNotConvertTeXMath inp ""
+ return [mkFallback mt inp]
+ Left il -> return [il]
+
+mkFallback :: MathType -> String -> Inline
+mkFallback mt str = Str (delim ++ str ++ delim)
+ where delim = case mt of
+ DisplayMath -> "$$"
+ InlineMath -> "$"
+
+-- | Converts a raw TeX math formula using a writer function,
+-- issuing a warning and producing a fallback (a raw string)
+-- on failure.
+convertMath :: PandocMonad m
+ => (DisplayType -> [Exp] -> a) -> MathType -> String
+ -> m (Either Inline a)
+convertMath writer mt str = do
+ case writer dt <$> readTeX str of
+ Right r -> return (Right r)
+ Left e -> do
+ report $ CouldNotConvertTeXMath str e
+ return (Left $ mkFallback mt str)
+ where dt = case mt of
+ DisplayMath -> DisplayBlock
+ InlineMath -> DisplayInline
+
diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs
new file mode 100644
index 000000000..dc6206e6c
--- /dev/null
+++ b/src/Text/Pandoc/Writers/MediaWiki.hs
@@ -0,0 +1,442 @@
+{-
+Copyright (C) 2008-2015 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.MediaWiki
+ Copyright : Copyright (C) 2008-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to MediaWiki markup.
+
+MediaWiki: <http://www.mediawiki.org/wiki/MediaWiki>
+-}
+module Text.Pandoc.Writers.MediaWiki ( writeMediaWiki ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Text.Pandoc.Shared
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Pretty (render)
+import Text.Pandoc.ImageSize
+import Text.Pandoc.Templates (renderTemplate')
+import Text.Pandoc.XML ( escapeStringForXML )
+import Data.List ( intersect, intercalate )
+import Network.URI ( isURI )
+import Control.Monad.Reader
+import Control.Monad.State
+import Text.Pandoc.Class (PandocMonad)
+
+data WriterState = WriterState {
+ stNotes :: Bool -- True if there are notes
+ , stOptions :: WriterOptions -- writer options
+ }
+
+data WriterReader = WriterReader {
+ options :: WriterOptions -- Writer options
+ , listLevel :: String -- String at beginning of list items, e.g. "**"
+ , useTags :: Bool -- True if we should use HTML tags because we're in a complex list
+ }
+
+type MediaWikiWriter = ReaderT WriterReader (State WriterState)
+
+-- | Convert Pandoc to MediaWiki.
+writeMediaWiki :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeMediaWiki opts document = return $
+ let initialState = WriterState { stNotes = False, stOptions = opts }
+ env = WriterReader { options = opts, listLevel = [], useTags = False }
+ in evalState (runReaderT (pandocToMediaWiki document) env) initialState
+
+-- | Return MediaWiki representation of document.
+pandocToMediaWiki :: Pandoc -> MediaWikiWriter String
+pandocToMediaWiki (Pandoc meta blocks) = do
+ opts <- asks options
+ metadata <- metaToJSON opts
+ (fmap trimr . blockListToMediaWiki)
+ inlineListToMediaWiki
+ meta
+ body <- blockListToMediaWiki blocks
+ notesExist <- gets stNotes
+ let notes = if notesExist
+ then "\n<references />"
+ else ""
+ let main = body ++ notes
+ let context = defField "body" main
+ $ defField "toc" (writerTableOfContents opts) metadata
+ return $ case writerTemplate opts of
+ Nothing -> main
+ Just tpl -> renderTemplate' tpl context
+
+-- | Escape special characters for MediaWiki.
+escapeString :: String -> String
+escapeString = escapeStringForXML
+
+-- | Convert Pandoc block element to MediaWiki.
+blockToMediaWiki :: Block -- ^ Block element
+ -> MediaWikiWriter String
+
+blockToMediaWiki Null = return ""
+
+blockToMediaWiki (Div attrs bs) = do
+ contents <- blockListToMediaWiki bs
+ return $ render Nothing (tagWithAttrs "div" attrs) ++ "\n\n" ++
+ contents ++ "\n\n" ++ "</div>"
+
+blockToMediaWiki (Plain inlines) =
+ inlineListToMediaWiki inlines
+
+-- title beginning with fig: indicates that the image is a figure
+blockToMediaWiki (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
+ capt <- if null txt
+ then return ""
+ else ("|caption " ++) `fmap` inlineListToMediaWiki txt
+ img <- imageToMediaWiki attr
+ let opt = if null txt
+ then ""
+ else "|alt=" ++ if null tit then capt else tit ++ capt
+ return $ "[[File:" ++ src ++ "|frame|none" ++ img ++ opt ++ "]]\n"
+
+blockToMediaWiki (Para inlines) = do
+ tags <- asks useTags
+ lev <- asks listLevel
+ contents <- inlineListToMediaWiki inlines
+ return $ if tags
+ then "<p>" ++ contents ++ "</p>"
+ else contents ++ if null lev then "\n" else ""
+
+blockToMediaWiki (LineBlock lns) =
+ blockToMediaWiki $ linesToPara lns
+
+blockToMediaWiki (RawBlock f str)
+ | f == Format "mediawiki" = return str
+ | f == Format "html" = return str
+ | otherwise = return ""
+
+blockToMediaWiki HorizontalRule = return "\n-----\n"
+
+blockToMediaWiki (Header level _ inlines) = do
+ contents <- inlineListToMediaWiki inlines
+ let eqs = replicate level '='
+ return $ eqs ++ " " ++ contents ++ " " ++ eqs ++ "\n"
+
+blockToMediaWiki (CodeBlock (_,classes,_) str) = do
+ let at = classes `intersect` ["actionscript", "ada", "apache", "applescript", "asm", "asp",
+ "autoit", "bash", "blitzbasic", "bnf", "c", "c_mac", "caddcl", "cadlisp", "cfdg", "cfm",
+ "cpp", "cpp-qt", "csharp", "css", "d", "delphi", "diff", "div", "dos", "eiffel", "fortran",
+ "freebasic", "gml", "groovy", "html4strict", "idl", "ini", "inno", "io", "java", "java5",
+ "javascript", "latex", "lisp", "lua", "matlab", "mirc", "mpasm", "mysql", "nsis", "objc",
+ "ocaml", "ocaml-brief", "oobas", "oracle8", "pascal", "perl", "php", "php-brief", "plsql",
+ "python", "qbasic", "rails", "reg", "robots", "ruby", "sas", "scheme", "sdlbasic",
+ "smalltalk", "smarty", "sql", "tcl", "", "thinbasic", "tsql", "vb", "vbnet", "vhdl",
+ "visualfoxpro", "winbatch", "xml", "xpp", "z80"]
+ return $
+ if null at
+ then "<pre" ++ (if null classes
+ then ">"
+ else " class=\"" ++ unwords classes ++ "\">") ++
+ escapeString str ++ "</pre>"
+ else "<source lang=\"" ++ head at ++ "\">" ++ str ++ "</source>"
+ -- note: no escape!
+
+blockToMediaWiki (BlockQuote blocks) = do
+ contents <- blockListToMediaWiki blocks
+ return $ "<blockquote>" ++ contents ++ "</blockquote>"
+
+blockToMediaWiki (Table capt aligns widths headers rows') = do
+ caption <- if null capt
+ then return ""
+ else do
+ c <- inlineListToMediaWiki capt
+ return $ "|+ " ++ trimr c ++ "\n"
+ let headless = all null headers
+ let allrows = if headless then rows' else headers:rows'
+ tableBody <- intercalate "|-\n" `fmap`
+ mapM (tableRowToMediaWiki headless aligns widths)
+ (zip [1..] allrows)
+ return $ "{|\n" ++ caption ++ tableBody ++ "|}\n"
+
+blockToMediaWiki x@(BulletList items) = do
+ tags <- fmap (|| not (isSimpleList x)) $ asks useTags
+ if tags
+ then do
+ contents <- local (\ s -> s { useTags = True }) $ mapM listItemToMediaWiki items
+ return $ "<ul>\n" ++ vcat contents ++ "</ul>\n"
+ else do
+ lev <- asks listLevel
+ contents <- local (\s -> s { listLevel = listLevel s ++ "*" }) $ mapM listItemToMediaWiki items
+ return $ vcat contents ++ if null lev then "\n" else ""
+
+blockToMediaWiki x@(OrderedList attribs items) = do
+ tags <- fmap (|| not (isSimpleList x)) $ asks useTags
+ if tags
+ then do
+ contents <- local (\s -> s { useTags = True }) $ mapM listItemToMediaWiki items
+ return $ "<ol" ++ listAttribsToString attribs ++ ">\n" ++ vcat contents ++ "</ol>\n"
+ else do
+ lev <- asks listLevel
+ contents <- local (\s -> s { listLevel = listLevel s ++ "#" }) $ mapM listItemToMediaWiki items
+ return $ vcat contents ++ if null lev then "\n" else ""
+
+blockToMediaWiki x@(DefinitionList items) = do
+ tags <- fmap (|| not (isSimpleList x)) $ asks useTags
+ if tags
+ then do
+ contents <- local (\s -> s { useTags = True }) $ mapM definitionListItemToMediaWiki items
+ return $ "<dl>\n" ++ vcat contents ++ "</dl>\n"
+ else do
+ lev <- asks listLevel
+ contents <- local (\s -> s { listLevel = listLevel s ++ ";" }) $ mapM definitionListItemToMediaWiki items
+ return $ vcat contents ++ if null lev then "\n" else ""
+
+-- Auxiliary functions for lists:
+
+-- | Convert ordered list attributes to HTML attribute string
+listAttribsToString :: ListAttributes -> String
+listAttribsToString (startnum, numstyle, _) =
+ let numstyle' = camelCaseToHyphenated $ show numstyle
+ in (if startnum /= 1
+ then " start=\"" ++ show startnum ++ "\""
+ else "") ++
+ (if numstyle /= DefaultStyle
+ then " style=\"list-style-type: " ++ numstyle' ++ ";\""
+ else "")
+
+-- | Convert bullet or ordered list item (list of blocks) to MediaWiki.
+listItemToMediaWiki :: [Block] -> MediaWikiWriter String
+listItemToMediaWiki items = do
+ contents <- blockListToMediaWiki items
+ tags <- asks useTags
+ if tags
+ then return $ "<li>" ++ contents ++ "</li>"
+ else do
+ marker <- asks listLevel
+ return $ marker ++ " " ++ contents
+
+-- | Convert definition list item (label, list of blocks) to MediaWiki.
+definitionListItemToMediaWiki :: ([Inline],[[Block]])
+ -> MediaWikiWriter String
+definitionListItemToMediaWiki (label, items) = do
+ labelText <- inlineListToMediaWiki label
+ contents <- mapM blockListToMediaWiki items
+ tags <- asks useTags
+ if tags
+ then return $ "<dt>" ++ labelText ++ "</dt>\n" ++
+ intercalate "\n" (map (\d -> "<dd>" ++ d ++ "</dd>") contents)
+ else do
+ marker <- asks listLevel
+ return $ marker ++ " " ++ labelText ++ "\n" ++
+ intercalate "\n" (map (\d -> init marker ++ ": " ++ d) contents)
+
+-- | True if the list can be handled by simple wiki markup, False if HTML tags will be needed.
+isSimpleList :: Block -> Bool
+isSimpleList x =
+ case x of
+ BulletList items -> all isSimpleListItem items
+ OrderedList (num, sty, _) items -> all isSimpleListItem items &&
+ num == 1 && sty `elem` [DefaultStyle, Decimal]
+ DefinitionList items -> all isSimpleListItem $ concatMap snd items
+ _ -> False
+
+-- | True if list item can be handled with the simple wiki syntax. False if
+-- HTML tags will be needed.
+isSimpleListItem :: [Block] -> Bool
+isSimpleListItem [] = True
+isSimpleListItem [x] =
+ case x of
+ Plain _ -> True
+ Para _ -> True
+ BulletList _ -> isSimpleList x
+ OrderedList _ _ -> isSimpleList x
+ DefinitionList _ -> isSimpleList x
+ _ -> False
+isSimpleListItem [x, y] | isPlainOrPara x =
+ case y of
+ BulletList _ -> isSimpleList y
+ OrderedList _ _ -> isSimpleList y
+ DefinitionList _ -> isSimpleList y
+ _ -> False
+isSimpleListItem _ = False
+
+isPlainOrPara :: Block -> Bool
+isPlainOrPara (Plain _) = True
+isPlainOrPara (Para _) = True
+isPlainOrPara _ = False
+
+-- | Concatenates strings with line breaks between them.
+vcat :: [String] -> String
+vcat = intercalate "\n"
+
+-- Auxiliary functions for tables:
+
+tableRowToMediaWiki :: Bool
+ -> [Alignment]
+ -> [Double]
+ -> (Int, [[Block]])
+ -> MediaWikiWriter String
+tableRowToMediaWiki headless alignments widths (rownum, cells) = do
+ cells' <- mapM (tableCellToMediaWiki headless rownum)
+ $ zip3 alignments widths cells
+ return $ unlines cells'
+
+tableCellToMediaWiki :: Bool
+ -> Int
+ -> (Alignment, Double, [Block])
+ -> MediaWikiWriter String
+tableCellToMediaWiki headless rownum (alignment, width, bs) = do
+ contents <- blockListToMediaWiki bs
+ let marker = if rownum == 1 && not headless then "!" else "|"
+ let percent w = show (truncate (100*w) :: Integer) ++ "%"
+ let attrs = ["align=" ++ show (alignmentToString alignment) |
+ alignment /= AlignDefault && alignment /= AlignLeft] ++
+ ["width=\"" ++ percent width ++ "\"" |
+ width /= 0.0 && rownum == 1]
+ let attr = if null attrs
+ then ""
+ else unwords attrs ++ "|"
+ let sep = case bs of
+ [Plain _] -> " "
+ [Para _] -> " "
+ _ -> "\n"
+ return $ marker ++ attr ++ sep ++ trimr contents
+
+alignmentToString :: Alignment -> String
+alignmentToString alignment = case alignment of
+ AlignLeft -> "left"
+ AlignRight -> "right"
+ AlignCenter -> "center"
+ AlignDefault -> "left"
+
+imageToMediaWiki :: Attr -> MediaWikiWriter String
+imageToMediaWiki attr = do
+ opts <- gets stOptions
+ let (_, cls, _) = attr
+ toPx = fmap (showInPixel opts) . checkPct
+ checkPct (Just (Percent _)) = Nothing
+ checkPct maybeDim = maybeDim
+ go (Just w) Nothing = '|':w ++ "px"
+ go (Just w) (Just h) = '|':w ++ "x" ++ h ++ "px"
+ go Nothing (Just h) = "|x" ++ h ++ "px"
+ go Nothing Nothing = ""
+ dims = go (toPx $ dimension Width attr) (toPx $ dimension Height attr)
+ classes = if null cls
+ then ""
+ else "|class=" ++ unwords cls
+ return $ dims ++ classes
+
+-- | Convert list of Pandoc block elements to MediaWiki.
+blockListToMediaWiki :: [Block] -- ^ List of block elements
+ -> MediaWikiWriter String
+blockListToMediaWiki blocks =
+ fmap vcat $ mapM blockToMediaWiki blocks
+
+-- | Convert list of Pandoc inline elements to MediaWiki.
+inlineListToMediaWiki :: [Inline] -> MediaWikiWriter String
+inlineListToMediaWiki lst =
+ fmap concat $ mapM inlineToMediaWiki lst
+
+-- | Convert Pandoc inline element to MediaWiki.
+inlineToMediaWiki :: Inline -> MediaWikiWriter String
+
+inlineToMediaWiki (Span attrs ils) = do
+ contents <- inlineListToMediaWiki ils
+ return $ render Nothing (tagWithAttrs "span" attrs) ++ contents ++ "</span>"
+
+inlineToMediaWiki (Emph lst) = do
+ contents <- inlineListToMediaWiki lst
+ return $ "''" ++ contents ++ "''"
+
+inlineToMediaWiki (Strong lst) = do
+ contents <- inlineListToMediaWiki lst
+ return $ "'''" ++ contents ++ "'''"
+
+inlineToMediaWiki (Strikeout lst) = do
+ contents <- inlineListToMediaWiki lst
+ return $ "<s>" ++ contents ++ "</s>"
+
+inlineToMediaWiki (Superscript lst) = do
+ contents <- inlineListToMediaWiki lst
+ return $ "<sup>" ++ contents ++ "</sup>"
+
+inlineToMediaWiki (Subscript lst) = do
+ contents <- inlineListToMediaWiki lst
+ return $ "<sub>" ++ contents ++ "</sub>"
+
+inlineToMediaWiki (SmallCaps lst) = inlineListToMediaWiki lst
+
+inlineToMediaWiki (Quoted SingleQuote lst) = do
+ contents <- inlineListToMediaWiki lst
+ return $ "\8216" ++ contents ++ "\8217"
+
+inlineToMediaWiki (Quoted DoubleQuote lst) = do
+ contents <- inlineListToMediaWiki lst
+ return $ "\8220" ++ contents ++ "\8221"
+
+inlineToMediaWiki (Cite _ lst) = inlineListToMediaWiki lst
+
+inlineToMediaWiki (Code _ str) =
+ return $ "<code>" ++ escapeString str ++ "</code>"
+
+inlineToMediaWiki (Str str) = return $ escapeString str
+
+inlineToMediaWiki (Math _ str) = return $ "<math>" ++ str ++ "</math>"
+ -- note: str should NOT be escaped
+
+inlineToMediaWiki (RawInline f str)
+ | f == Format "mediawiki" = return str
+ | f == Format "html" = return str
+ | otherwise = return ""
+
+inlineToMediaWiki LineBreak = return "<br />\n"
+
+inlineToMediaWiki SoftBreak = do
+ wrapText <- gets (writerWrapText . stOptions)
+ case wrapText of
+ WrapAuto -> return " "
+ WrapNone -> return " "
+ WrapPreserve -> return "\n"
+
+inlineToMediaWiki Space = return " "
+
+inlineToMediaWiki (Link _ txt (src, _)) = do
+ label <- inlineListToMediaWiki txt
+ case txt of
+ [Str s] | isURI src && escapeURI s == src -> return src
+ _ -> return $ if isURI src
+ then "[" ++ src ++ " " ++ label ++ "]"
+ else "[[" ++ src' ++ "|" ++ label ++ "]]"
+ where src' = case src of
+ '/':xs -> xs -- with leading / it's a
+ _ -> src -- link to a help page
+
+inlineToMediaWiki (Image attr alt (source, tit)) = do
+ img <- imageToMediaWiki attr
+ alt' <- inlineListToMediaWiki alt
+ let txt = if null tit
+ then if null alt
+ then ""
+ else '|' : alt'
+ else '|' : tit
+ return $ "[[File:" ++ source ++ img ++ txt ++ "]]"
+
+inlineToMediaWiki (Note contents) = do
+ contents' <- blockListToMediaWiki contents
+ modify (\s -> s { stNotes = True })
+ return $ "<ref>" ++ contents' ++ "</ref>"
+ -- note - may not work for notes with multiple blocks
diff --git a/src/Text/Pandoc/Writers/Native.hs b/src/Text/Pandoc/Writers/Native.hs
new file mode 100644
index 000000000..2421fd94d
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Native.hs
@@ -0,0 +1,79 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-
+Copyright (C) 2006-2015 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.Native
+ Copyright : Copyright (C) 2006-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of a 'Pandoc' document to a string representation.
+-}
+module Text.Pandoc.Writers.Native ( writeNative )
+where
+import Text.Pandoc.Options ( WriterOptions(..), WrapOption(..) )
+import Data.List ( intersperse )
+import Text.Pandoc.Definition
+import Text.Pandoc.Pretty
+import Text.Pandoc.Class (PandocMonad)
+
+prettyList :: [Doc] -> Doc
+prettyList ds =
+ "[" <> (cat $ intersperse (cr <> ",") $ map (nest 1) ds) <> "]"
+
+-- | Prettyprint Pandoc block element.
+prettyBlock :: Block -> Doc
+prettyBlock (LineBlock lines') =
+ "LineBlock" $$ prettyList (map (text . show) lines')
+prettyBlock (BlockQuote blocks) =
+ "BlockQuote" $$ prettyList (map prettyBlock blocks)
+prettyBlock (OrderedList attribs blockLists) =
+ "OrderedList" <> space <> text (show attribs) $$
+ (prettyList $ map (prettyList . map prettyBlock) blockLists)
+prettyBlock (BulletList blockLists) =
+ "BulletList" $$
+ (prettyList $ map (prettyList . map prettyBlock) blockLists)
+prettyBlock (DefinitionList items) = "DefinitionList" $$
+ (prettyList $ map deflistitem items)
+ where deflistitem (term, defs) = "(" <> text (show term) <> "," <> cr <>
+ nest 1 (prettyList $ map (prettyList . map prettyBlock) defs) <> ")"
+prettyBlock (Table caption aligns widths header rows) =
+ "Table " <> text (show caption) <> " " <> text (show aligns) <> " " <>
+ text (show widths) $$
+ prettyRow header $$
+ prettyList (map prettyRow rows)
+ where prettyRow cols = prettyList (map (prettyList . map prettyBlock) cols)
+prettyBlock (Div attr blocks) =
+ text ("Div " <> show attr) $$ prettyList (map prettyBlock blocks)
+prettyBlock block = text $ show block
+
+-- | Prettyprint Pandoc document.
+writeNative :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeNative opts (Pandoc meta blocks) = return $
+ let colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ withHead = case writerTemplate opts of
+ Just _ -> \bs -> text ("Pandoc (" ++ show meta ++ ")") $$
+ bs $$ cr
+ Nothing -> id
+ in render colwidth $ withHead $ prettyList $ map prettyBlock blocks
diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs
new file mode 100644
index 000000000..ee5fa4c24
--- /dev/null
+++ b/src/Text/Pandoc/Writers/ODT.hs
@@ -0,0 +1,210 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+{-
+Copyright (C) 2008-2015 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.ODT
+ Copyright : Copyright (C) 2008-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to ODT.
+-}
+module Text.Pandoc.Writers.ODT ( writeODT ) where
+import Data.List ( isPrefixOf )
+import Data.Maybe ( fromMaybe )
+import Text.XML.Light.Output
+import Text.TeXMath
+import qualified Data.ByteString.Lazy as B
+import Text.Pandoc.UTF8 ( fromStringLazy )
+import Codec.Archive.Zip
+import Text.Pandoc.Options ( WriterOptions(..), WrapOption(..) )
+import Text.Pandoc.Shared ( stringify )
+import Text.Pandoc.ImageSize
+import Text.Pandoc.MIME ( getMimeType, extensionFromMimeType )
+import Text.Pandoc.Definition
+import Text.Pandoc.Walk
+import Text.Pandoc.Writers.Shared ( fixDisplayMath )
+import Text.Pandoc.Writers.OpenDocument ( writeOpenDocument )
+import Control.Monad.State
+import Control.Monad.Except (runExceptT)
+import Text.Pandoc.Error (PandocError)
+import Text.Pandoc.XML
+import Text.Pandoc.Pretty
+import System.FilePath ( takeExtension, takeDirectory, (<.>))
+import Text.Pandoc.Class ( PandocMonad, report )
+import qualified Text.Pandoc.Class as P
+import Text.Pandoc.Logging
+
+data ODTState = ODTState { stEntries :: [Entry]
+ }
+
+type O m = StateT ODTState m
+
+-- | Produce an ODT file from a Pandoc document.
+writeODT :: PandocMonad m
+ => WriterOptions -- ^ Writer options
+ -> Pandoc -- ^ Document to convert
+ -> m B.ByteString
+writeODT opts doc =
+ let initState = ODTState{ stEntries = []
+ }
+ in
+ evalStateT (pandocToODT opts doc) initState
+
+-- | Produce an ODT file from a Pandoc document.
+pandocToODT :: PandocMonad m
+ => WriterOptions -- ^ Writer options
+ -> Pandoc -- ^ Document to convert
+ -> O m B.ByteString
+pandocToODT opts doc@(Pandoc meta _) = do
+ let datadir = writerUserDataDir opts
+ let title = docTitle meta
+ refArchive <-
+ case writerReferenceDoc opts of
+ Just f -> liftM toArchive $ lift $ P.readFileLazy f
+ Nothing -> lift $ (toArchive . B.fromStrict) <$>
+ P.readDataFile datadir "reference.odt"
+ -- handle formulas and pictures
+ -- picEntriesRef <- P.newIORef ([] :: [Entry])
+ doc' <- walkM (transformPicMath opts) $ walk fixDisplayMath doc
+ newContents <- lift $ writeOpenDocument opts{writerWrapText = WrapNone} doc'
+ epochtime <- floor `fmap` (lift P.getPOSIXTime)
+ let contentEntry = toEntry "content.xml" epochtime
+ $ fromStringLazy newContents
+ picEntries <- gets stEntries
+ let archive = foldr addEntryToArchive refArchive
+ $ contentEntry : picEntries
+ -- construct META-INF/manifest.xml based on archive
+ let toFileEntry fp = case getMimeType fp of
+ Nothing -> empty
+ Just m -> selfClosingTag "manifest:file-entry"
+ [("manifest:media-type", m)
+ ,("manifest:full-path", fp)
+ ,("manifest:version", "1.2")
+ ]
+ let files = [ ent | ent <- filesInArchive archive,
+ not ("META-INF" `isPrefixOf` ent) ]
+ let formulas = [ takeDirectory ent ++ "/" | ent <- filesInArchive archive,
+ "Formula-" `isPrefixOf` ent, takeExtension ent == ".xml" ]
+ let manifestEntry = toEntry "META-INF/manifest.xml" epochtime
+ $ fromStringLazy $ render Nothing
+ $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ $$
+ ( inTags True "manifest:manifest"
+ [("xmlns:manifest","urn:oasis:names:tc:opendocument:xmlns:manifest:1.0")
+ ,("manifest:version","1.2")]
+ $ ( selfClosingTag "manifest:file-entry"
+ [("manifest:media-type","application/vnd.oasis.opendocument.text")
+ ,("manifest:full-path","/")]
+ $$ vcat ( map toFileEntry $ files )
+ $$ vcat ( map toFileEntry $ formulas )
+ )
+ )
+ let archive' = addEntryToArchive manifestEntry archive
+ let metaEntry = toEntry "meta.xml" epochtime
+ $ fromStringLazy $ render Nothing
+ $ text "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ $$
+ ( inTags True "office:document-meta"
+ [("xmlns:office","urn:oasis:names:tc:opendocument:xmlns:office:1.0")
+ ,("xmlns:xlink","http://www.w3.org/1999/xlink")
+ ,("xmlns:dc","http://purl.org/dc/elements/1.1/")
+ ,("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))
+ )
+ )
+ )
+ -- make sure mimetype is first
+ let mimetypeEntry = toEntry "mimetype" epochtime
+ $ fromStringLazy "application/vnd.oasis.opendocument.text"
+ let archive'' = addEntryToArchive mimetypeEntry
+ $ addEntryToArchive metaEntry archive'
+ return $ fromArchive archive''
+
+-- | transform both Image and Math elements
+transformPicMath :: PandocMonad m => WriterOptions ->Inline -> O m Inline
+transformPicMath opts (Image attr@(id', cls, _) lab (src,t)) = do
+ res <- runExceptT $ lift $ P.fetchItem (writerSourceURL opts) src
+ case res of
+ Left (_ :: PandocError) -> do
+ report $ CouldNotFetchResource src ""
+ return $ Emph lab
+ Right (img, mbMimeType) -> do
+ (ptX, ptY) <- case imageSize img of
+ Right s -> return $ sizeInPoints s
+ Left msg -> do
+ report $ CouldNotDetermineImageSize src msg
+ return (100, 100)
+ let dims =
+ case (getDim Width, getDim Height) of
+ (Just w, Just h) -> [("width", show w), ("height", show h)]
+ (Just w@(Percent _), Nothing) -> [("width", show w), ("style:rel-height", "scale")]
+ (Nothing, Just h@(Percent _)) -> [("style:rel-width", "scale"), ("height", show h)]
+ (Just w@(Inch i), Nothing) -> [("width", show w), ("height", show (i / ratio) ++ "in")]
+ (Nothing, Just h@(Inch i)) -> [("width", show (i * ratio) ++ "in"), ("height", show h)]
+ _ -> [("width", show ptX ++ "pt"), ("height", show ptY ++ "pt")]
+ where
+ ratio = ptX / ptY
+ getDim dir = case (dimension dir attr) of
+ Just (Percent i) -> Just $ Percent i
+ Just dim -> Just $ Inch $ inInch opts dim
+ Nothing -> Nothing
+ let newattr = (id', cls, dims)
+ entries <- gets stEntries
+ let extension = fromMaybe (takeExtension $ takeWhile (/='?') src)
+ (mbMimeType >>= extensionFromMimeType)
+ let newsrc = "Pictures/" ++ show (length entries) <.> extension
+ let toLazy = B.fromChunks . (:[])
+ epochtime <- floor `fmap` (lift P.getPOSIXTime)
+ let entry = toEntry newsrc epochtime $ toLazy img
+ modify $ \st -> st{ stEntries = entry : entries }
+ return $ Image newattr lab (newsrc, t)
+transformPicMath _ (Math t math) = do
+ entries <- gets stEntries
+ let dt = if t == InlineMath then DisplayInline else DisplayBlock
+ case writeMathML dt <$> readTeX math of
+ Left _ -> return $ Math t math
+ Right r -> do
+ let conf = useShortEmptyTags (const False) defaultConfigPP
+ let mathml = ppcTopElement conf r
+ epochtime <- floor `fmap` (lift $ P.getPOSIXTime)
+ let dirname = "Formula-" ++ show (length entries) ++ "/"
+ let fname = dirname ++ "content.xml"
+ let entry = toEntry fname epochtime (fromStringLazy mathml)
+ modify $ \st -> st{ stEntries = entry : entries }
+ return $ RawInline (Format "opendocument") $ render Nothing $
+ inTags False "draw:frame" [("text:anchor-type",
+ if t == DisplayMath
+ then "paragraph"
+ else "as-char")
+ ,("style:vertical-pos", "middle")
+ ,("style:vertical-rel", "text")] $
+ selfClosingTag "draw:object" [("xlink:href", dirname)
+ , ("xlink:type", "simple")
+ , ("xlink:show", "embed")
+ , ("xlink:actuate", "onLoad")]
+
+transformPicMath _ x = return x
diff --git a/src/Text/Pandoc/Writers/OPML.hs b/src/Text/Pandoc/Writers/OPML.hs
new file mode 100644
index 000000000..bc0cfc300
--- /dev/null
+++ b/src/Text/Pandoc/Writers/OPML.hs
@@ -0,0 +1,103 @@
+{-# LANGUAGE CPP #-}
+{-
+Copyright (C) 2013-2015 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.OPML
+ Copyright : Copyright (C) 2013-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to OPML XML.
+-}
+module Text.Pandoc.Writers.OPML ( writeOPML) where
+import Text.Pandoc.Definition
+import Text.Pandoc.XML
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Shared
+import Text.Pandoc.Options
+import Text.Pandoc.Templates (renderTemplate')
+import Text.Pandoc.Writers.HTML (writeHtml5String)
+import Text.Pandoc.Writers.Markdown (writeMarkdown)
+import Text.Pandoc.Pretty
+import Text.Pandoc.Compat.Time
+import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.Error
+import Control.Monad.Except (throwError)
+import Text.Pandoc.Class (PandocMonad)
+
+-- | Convert Pandoc document to string in OPML format.
+writeOPML :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeOPML opts (Pandoc meta blocks) = do
+ let elements = hierarchicalize blocks
+ colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ meta' = B.setMeta "date" (B.str $ convertDate $ docDate meta) meta
+ metadata <- metaToJSON opts
+ (writeMarkdown def . Pandoc nullMeta)
+ (\ils -> trimr <$> (writeMarkdown def $ Pandoc nullMeta [Plain ils]))
+ meta'
+ main <- (render colwidth . vcat) <$> (mapM (elementToOPML opts) elements)
+ let context = defField "body" main metadata
+ return $ case writerTemplate opts of
+ Nothing -> main
+ Just tpl -> renderTemplate' tpl context
+
+
+writeHtmlInlines :: PandocMonad m => [Inline] -> m String
+writeHtmlInlines ils =
+ trim <$> (writeHtml5String def $ Pandoc nullMeta [Plain ils])
+
+-- date format: RFC 822: Thu, 14 Jul 2005 23:41:05 GMT
+showDateTimeRFC822 :: UTCTime -> String
+showDateTimeRFC822 = formatTime defaultTimeLocale "%a, %d %b %Y %X %Z"
+
+convertDate :: [Inline] -> String
+convertDate ils = maybe "" showDateTimeRFC822 $
+#if MIN_VERSION_time(1,5,0)
+ parseTimeM True
+#else
+ parseTime
+#endif
+ defaultTimeLocale "%F" =<< (normalizeDate $ stringify ils)
+
+-- | Convert an Element to OPML.
+elementToOPML :: PandocMonad m => WriterOptions -> Element -> m Doc
+elementToOPML _ (Blk _) = return empty
+elementToOPML opts (Sec _ _num _ title elements) = do
+ let isBlk :: Element -> Bool
+ isBlk (Blk _) = True
+ isBlk _ = False
+
+ fromBlk :: PandocMonad m => Element -> m Block
+ fromBlk (Blk x) = return x
+ fromBlk _ = throwError $ PandocSomeError "fromBlk called on non-block"
+
+ (blocks, rest) = span isBlk elements
+ htmlIls <- writeHtmlInlines title
+ md <- if null blocks
+ then return []
+ else do blks <- mapM fromBlk blocks
+ writeMarkdown def $ Pandoc nullMeta blks
+ let attrs = [("text", htmlIls)] ++ [("_note", md) | not (null blocks)]
+ o <- mapM (elementToOPML opts) rest
+ return $ inTags True "outline" attrs $ vcat o
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
new file mode 100644
index 000000000..851e18b8e
--- /dev/null
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -0,0 +1,626 @@
+{-# LANGUAGE PatternGuards, OverloadedStrings, FlexibleContexts #-}
+{-
+Copyright (C) 2008-2015 Andrea Rossato <andrea.rossato@ing.unitn.it>
+ 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.Writers.OpenDocument
+ Copyright : Copyright (C) 2008-2015 Andrea Rossato and John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Andrea Rossato <andrea.rossato@ing.unitn.it>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to OpenDocument XML.
+-}
+module Text.Pandoc.Writers.OpenDocument ( writeOpenDocument ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Text.Pandoc.XML
+import Text.Pandoc.Shared (linesToPara)
+import Text.Pandoc.Templates (renderTemplate')
+import Text.Pandoc.Writers.Math
+import Text.Pandoc.Pretty
+import Text.Printf ( printf )
+import Control.Arrow ( (***), (>>>) )
+import Control.Monad.State hiding ( when )
+import Data.Char (chr)
+import qualified Data.Set as Set
+import qualified Data.Map as Map
+import Text.Pandoc.Writers.Shared
+import Data.List (sortBy)
+import Data.Ord (comparing)
+import Text.Pandoc.Class (PandocMonad, report)
+import Text.Pandoc.Logging
+
+-- | Auxiliary function to convert Plain block to Para.
+plainToPara :: Block -> Block
+plainToPara (Plain x) = Para x
+plainToPara x = x
+
+--
+-- OpenDocument writer
+--
+
+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
+ }
+
+defaultWriterState :: WriterState
+defaultWriterState =
+ WriterState { stNotes = []
+ , stTableStyles = []
+ , stParaStyles = []
+ , stListStyles = []
+ , stTextStyles = Map.empty
+ , stTextStyleAttr = Set.empty
+ , stIndentPara = 0
+ , stInDefinition = False
+ , stTight = False
+ , stFirstPara = False
+ , stImageId = 1
+ }
+
+when :: Bool -> Doc -> Doc
+when p a = if p then a else empty
+
+addTableStyle :: PandocMonad m => Doc -> OD m ()
+addTableStyle i = modify $ \s -> s { stTableStyles = i : stTableStyles s }
+
+addNote :: PandocMonad m => Doc -> OD m ()
+addNote i = modify $ \s -> s { stNotes = i : stNotes s }
+
+addParaStyle :: PandocMonad m => Doc -> OD m ()
+addParaStyle i = modify $ \s -> s { stParaStyles = i : stParaStyles s }
+
+addTextStyle :: PandocMonad m => Set.Set TextStyle -> (String, Doc) -> OD m ()
+addTextStyle attrs i = modify $ \s ->
+ s { stTextStyles = Map.insert attrs i (stTextStyles s) }
+
+addTextStyleAttr :: PandocMonad m => TextStyle -> OD m ()
+addTextStyleAttr t = modify $ \s ->
+ s { stTextStyleAttr = Set.insert t (stTextStyleAttr s) }
+
+increaseIndent :: PandocMonad m => OD m ()
+increaseIndent = modify $ \s -> s { stIndentPara = 1 + stIndentPara s }
+
+resetIndent :: PandocMonad m => OD m ()
+resetIndent = modify $ \s -> s { stIndentPara = (stIndentPara s) - 1 }
+
+inTightList :: PandocMonad m => OD m a -> OD m a
+inTightList f = modify (\s -> s { stTight = True }) >> f >>= \r ->
+ modify (\s -> s { stTight = False }) >> return r
+
+setInDefinitionList :: PandocMonad m => Bool -> OD m ()
+setInDefinitionList b = modify $ \s -> s { stInDefinition = b }
+
+setFirstPara :: PandocMonad m => OD m ()
+setFirstPara = modify $ \s -> s { stFirstPara = True }
+
+inParagraphTags :: PandocMonad m => Doc -> OD m Doc
+inParagraphTags d | isEmpty d = return empty
+inParagraphTags d = do
+ b <- gets stFirstPara
+ a <- if b
+ then do modify $ \st -> st { stFirstPara = False }
+ return $ [("text:style-name", "First_20_paragraph")]
+ else return [("text:style-name", "Text_20_body")]
+ return $ inTags False "text:p" a d
+
+inParagraphTagsWithStyle :: String -> Doc -> Doc
+inParagraphTagsWithStyle sty = inTags False "text:p" [("text:style-name", sty)]
+
+inSpanTags :: String -> Doc -> Doc
+inSpanTags s = inTags False "text:span" [("text:style-name",s)]
+
+withTextStyle :: PandocMonad m => TextStyle -> OD m a -> OD m a
+withTextStyle s f = do
+ oldTextStyleAttr <- gets stTextStyleAttr
+ addTextStyleAttr s
+ res <- f
+ modify $ \st -> st{ stTextStyleAttr = oldTextStyleAttr }
+ return res
+
+inTextStyle :: PandocMonad m => Doc -> OD m Doc
+inTextStyle d = do
+ at <- gets stTextStyleAttr
+ if Set.null at
+ then return d
+ else do
+ styles <- gets stTextStyles
+ case Map.lookup at styles of
+ Just (styleName, _) -> return $
+ inTags False "text:span" [("text:style-name",styleName)] d
+ Nothing -> do
+ let styleName = "T" ++ show (Map.size styles + 1)
+ addTextStyle at (styleName,
+ inTags False "style:style"
+ [("style:name", styleName)
+ ,("style:family", "text")]
+ $ selfClosingTag "style:text-properties"
+ (concatMap textStyleAttr (Set.toList at)))
+ return $ inTags False
+ "text:span" [("text:style-name",styleName)] d
+
+inHeaderTags :: PandocMonad m => Int -> Doc -> OD m Doc
+inHeaderTags i d =
+ return $ inTags False "text:h" [ ("text:style-name", "Heading_20_" ++ show i)
+ , ("text:outline-level", show i)] d
+
+inQuotes :: QuoteType -> Doc -> Doc
+inQuotes SingleQuote s = char '\8216' <> s <> char '\8217'
+inQuotes DoubleQuote s = char '\8220' <> s <> char '\8221'
+
+handleSpaces :: String -> Doc
+handleSpaces s
+ | ( ' ':_) <- s = genTag s
+ | ('\t':x) <- s = selfClosingTag "text:tab" [] <> rm x
+ | otherwise = rm s
+ where
+ genTag = span (==' ') >>> tag . length *** rm >>> uncurry (<>)
+ tag n = when (n /= 0) $ selfClosingTag "text:s" [("text:c", show n)]
+ rm ( ' ':xs) = char ' ' <> genTag xs
+ rm ('\t':xs) = selfClosingTag "text:tab" [] <> genTag xs
+ rm ( x:xs) = char x <> rm xs
+ rm [] = empty
+
+-- | Convert Pandoc document to string in OpenDocument format.
+writeOpenDocument :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeOpenDocument opts (Pandoc meta blocks) = do
+ let colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ let render' = render colwidth
+ ((body, metadata),s) <- flip runStateT
+ defaultWriterState $ do
+ m <- metaToJSON opts
+ (fmap (render colwidth) . blocksToOpenDocument opts)
+ (fmap (render colwidth) . inlinesToOpenDocument opts)
+ meta
+ b <- render' `fmap` blocksToOpenDocument opts blocks
+ return (b, m)
+ let styles = stTableStyles s ++ stParaStyles s ++
+ map snd (reverse $ sortBy (comparing fst) $
+ Map.elems (stTextStyles s))
+ listStyle (n,l) = inTags True "text:list-style"
+ [("style:name", "L" ++ show n)] (vcat l)
+ let listStyles = map listStyle (stListStyles s)
+ let automaticStyles = vcat $ reverse $ styles ++ listStyles
+ let context = defField "body" body
+ $ defField "automatic-styles" (render' automaticStyles)
+ $ metadata
+ return $ case writerTemplate opts of
+ Nothing -> body
+ Just tpl -> renderTemplate' tpl context
+
+withParagraphStyle :: PandocMonad m
+ => WriterOptions -> String -> [Block] -> OD m Doc
+withParagraphStyle o s (b:bs)
+ | Para l <- b = go =<< inParagraphTagsWithStyle s <$> inlinesToOpenDocument o l
+ | otherwise = go =<< blockToOpenDocument o b
+ where go i = (<>) i <$> withParagraphStyle o s bs
+withParagraphStyle _ _ [] = return empty
+
+inPreformattedTags :: PandocMonad m => String -> OD m Doc
+inPreformattedTags s = do
+ n <- paraStyle [("style:parent-style-name","Preformatted_20_Text")]
+ return . inParagraphTagsWithStyle ("P" ++ show n) . handleSpaces $ s
+
+orderedListToOpenDocument :: PandocMonad m
+ => WriterOptions -> Int -> [[Block]] -> OD m Doc
+orderedListToOpenDocument o pn bs =
+ vcat . map (inTagsIndented "text:list-item") <$>
+ mapM (orderedItemToOpenDocument o pn . map plainToPara) bs
+
+orderedItemToOpenDocument :: PandocMonad m
+ => WriterOptions -> Int -> [Block] -> OD m Doc
+orderedItemToOpenDocument o n (b:bs)
+ | OrderedList a l <- b = newLevel a l
+ | Para l <- b = go =<< inParagraphTagsWithStyle ("P" ++ show n) <$> inlinesToOpenDocument o l
+ | otherwise = go =<< blockToOpenDocument o b
+ where
+ go i = ($$) i <$> orderedItemToOpenDocument o n bs
+ newLevel a l = do
+ nn <- length <$> gets stParaStyles
+ ls <- head <$> gets stListStyles
+ modify $ \s -> s { stListStyles = orderedListLevelStyle a ls : tail (stListStyles s) }
+ inTagsIndented "text:list" <$> orderedListToOpenDocument o nn l
+orderedItemToOpenDocument _ _ [] = return empty
+
+isTightList :: [[Block]] -> Bool
+isTightList [] = False
+isTightList (b:_)
+ | Plain {} : _ <- b = True
+ | otherwise = False
+
+newOrderedListStyle :: PandocMonad m
+ => Bool -> ListAttributes -> OD m (Int,Int)
+newOrderedListStyle b a = do
+ ln <- (+) 1 . length <$> gets stListStyles
+ let nbs = orderedListLevelStyle a (ln, [])
+ pn <- if b then inTightList (paraListStyle ln) else paraListStyle ln
+ modify $ \s -> s { stListStyles = nbs : stListStyles s }
+ return (ln,pn)
+
+bulletListToOpenDocument :: PandocMonad m
+ => WriterOptions -> [[Block]] -> OD m Doc
+bulletListToOpenDocument o b = do
+ ln <- (+) 1 . length <$> gets stListStyles
+ (pn,ns) <- if isTightList b then inTightList (bulletListStyle ln) else bulletListStyle ln
+ modify $ \s -> s { stListStyles = ns : stListStyles s }
+ is <- listItemsToOpenDocument ("P" ++ show pn) o b
+ return $ inTags True "text:list" [("text:style-name", "L" ++ show ln)] is
+
+listItemsToOpenDocument :: PandocMonad m
+ => String -> WriterOptions -> [[Block]] -> OD m Doc
+listItemsToOpenDocument s o is =
+ vcat . map (inTagsIndented "text:list-item") <$> mapM (withParagraphStyle o s . map plainToPara) is
+
+deflistItemToOpenDocument :: PandocMonad m
+ => WriterOptions -> ([Inline],[[Block]]) -> OD m Doc
+deflistItemToOpenDocument o (t,d) = do
+ let ts = if isTightList d
+ then "Definition_20_Term_20_Tight" else "Definition_20_Term"
+ ds = if isTightList d
+ then "Definition_20_Definition_20_Tight" else "Definition_20_Definition"
+ t' <- withParagraphStyle o ts [Para t]
+ d' <- liftM vcat $ mapM (withParagraphStyle o ds . (map plainToPara)) d
+ return $ t' $$ d'
+
+inBlockQuote :: PandocMonad m
+ => WriterOptions -> Int -> [Block] -> OD m Doc
+inBlockQuote o i (b:bs)
+ | BlockQuote l <- b = do increaseIndent
+ ni <- paraStyle
+ [("style:parent-style-name","Quotations")]
+ go =<< inBlockQuote o ni (map plainToPara l)
+ | Para l <- b = do go =<< inParagraphTagsWithStyle ("P" ++ show i) <$> inlinesToOpenDocument o l
+ | otherwise = do go =<< blockToOpenDocument o b
+ where go block = ($$) block <$> inBlockQuote o i bs
+inBlockQuote _ _ [] = resetIndent >> return empty
+
+-- | Convert a list of Pandoc blocks to OpenDocument.
+blocksToOpenDocument :: PandocMonad m => WriterOptions -> [Block] -> OD m Doc
+blocksToOpenDocument o b = vcat <$> mapM (blockToOpenDocument o) b
+
+-- | Convert a Pandoc block element to OpenDocument.
+blockToOpenDocument :: PandocMonad m => WriterOptions -> Block -> OD m Doc
+blockToOpenDocument o bs
+ | Plain b <- bs = if null b
+ then return empty
+ else inParagraphTags =<< inlinesToOpenDocument o b
+ | Para [Image attr c (s,'f':'i':'g':':':t)] <- bs
+ = figure attr c s t
+ | Para b <- bs = if null b
+ then return empty
+ else inParagraphTags =<< inlinesToOpenDocument o b
+ | LineBlock b <- bs = blockToOpenDocument o $ linesToPara b
+ | Div _ xs <- bs = blocksToOpenDocument o xs
+ | Header i _ b <- bs = setFirstPara >>
+ (inHeaderTags i =<< inlinesToOpenDocument o b)
+ | BlockQuote b <- bs = setFirstPara >> mkBlockQuote b
+ | DefinitionList b <- bs = setFirstPara >> defList b
+ | BulletList b <- bs = setFirstPara >> bulletListToOpenDocument o b
+ | OrderedList a b <- bs = setFirstPara >> orderedList a b
+ | CodeBlock _ s <- bs = setFirstPara >> preformatted s
+ | Table c a w h r <- bs = setFirstPara >> table c a w h r
+ | HorizontalRule <- bs = setFirstPara >> return (selfClosingTag "text:p"
+ [ ("text:style-name", "Horizontal_20_Line") ])
+ | RawBlock f s <- bs = if f == Format "opendocument"
+ then return $ text s
+ else do
+ report $ BlockNotRendered bs
+ return empty
+ | Null <- bs = return empty
+ | otherwise = return empty
+ where
+ defList b = do setInDefinitionList True
+ r <- vcat <$> mapM (deflistItemToOpenDocument o) b
+ setInDefinitionList False
+ return r
+ preformatted s = (flush . vcat) <$> mapM (inPreformattedTags . escapeStringForXML) (lines s)
+ mkBlockQuote b = do increaseIndent
+ i <- paraStyle
+ [("style:parent-style-name","Quotations")]
+ inBlockQuote o i (map plainToPara b)
+ orderedList a b = do (ln,pn) <- newOrderedListStyle (isTightList b) a
+ inTags True "text:list" [ ("text:style-name", "L" ++ show ln)]
+ <$> orderedListToOpenDocument o pn b
+ table c a w h r = do
+ tn <- length <$> gets stTableStyles
+ pn <- length <$> gets stParaStyles
+ let genIds = map chr [65..]
+ name = "Table" ++ show (tn + 1)
+ columnIds = zip genIds w
+ mkColumn n = selfClosingTag "table:table-column" [("table:style-name", name ++ "." ++ [fst n])]
+ columns = map mkColumn columnIds
+ paraHStyles = paraTableStyles "Heading" pn a
+ paraStyles = paraTableStyles "Contents" (pn + length (newPara paraHStyles)) a
+ newPara = map snd . filter (not . isEmpty . snd)
+ addTableStyle $ tableStyle tn columnIds
+ mapM_ addParaStyle . newPara $ paraHStyles ++ paraStyles
+ captionDoc <- if null c
+ then return empty
+ else withParagraphStyle o "Table" [Para c]
+ th <- if all null h
+ then return empty
+ else colHeadsToOpenDocument o name (map fst paraHStyles) h
+ tr <- mapM (tableRowToOpenDocument o name (map fst paraStyles)) r
+ return $ inTags True "table:table" [ ("table:name" , name)
+ , ("table:style-name", name)
+ ] (vcat columns $$ th $$ vcat tr) $$ captionDoc
+ figure attr caption source title | null caption =
+ withParagraphStyle o "Figure" [Para [Image attr caption (source,title)]]
+ | otherwise = do
+ imageDoc <- withParagraphStyle o "FigureWithCaption" [Para [Image attr caption (source,title)]]
+ captionDoc <- withParagraphStyle o "FigureCaption" [Para caption]
+ return $ imageDoc $$ captionDoc
+
+colHeadsToOpenDocument :: PandocMonad m
+ => WriterOptions -> String -> [String] -> [[Block]]
+ -> OD m Doc
+colHeadsToOpenDocument o tn ns hs =
+ inTagsIndented "table:table-header-rows" . inTagsIndented "table:table-row" . vcat <$>
+ mapM (tableItemToOpenDocument o tn) (zip ns hs)
+
+tableRowToOpenDocument :: PandocMonad m
+ => WriterOptions -> String -> [String] -> [[Block]]
+ -> OD m Doc
+tableRowToOpenDocument o tn ns cs =
+ inTagsIndented "table:table-row" . vcat <$>
+ mapM (tableItemToOpenDocument o tn) (zip ns cs)
+
+tableItemToOpenDocument :: PandocMonad m
+ => WriterOptions -> String -> (String,[Block])
+ -> OD m Doc
+tableItemToOpenDocument o tn (n,i) =
+ let a = [ ("table:style-name" , tn ++ ".A1" )
+ , ("office:value-type", "string" )
+ ]
+ in inTags True "table:table-cell" a <$>
+ withParagraphStyle o n (map plainToPara i)
+
+-- | Convert a list of inline elements to OpenDocument.
+inlinesToOpenDocument :: PandocMonad m => WriterOptions -> [Inline] -> OD m Doc
+inlinesToOpenDocument o l = hcat <$> toChunks o l
+
+toChunks :: PandocMonad m => WriterOptions -> [Inline] -> OD m [Doc]
+toChunks _ [] = return []
+toChunks o (x : xs)
+ | isChunkable x = do
+ contents <- (inTextStyle . hcat) =<<
+ mapM (inlineToOpenDocument o) (x:ys)
+ rest <- toChunks o zs
+ return (contents : rest)
+ | otherwise = do
+ contents <- inlineToOpenDocument o x
+ rest <- toChunks o xs
+ return (contents : rest)
+ where (ys, zs) = span isChunkable xs
+
+isChunkable :: Inline -> Bool
+isChunkable (Str _) = True
+isChunkable Space = True
+isChunkable SoftBreak = True
+isChunkable _ = False
+
+-- | Convert an inline element to OpenDocument.
+inlineToOpenDocument :: PandocMonad m => WriterOptions -> Inline -> OD m Doc
+inlineToOpenDocument o ils
+ = case ils of
+ Space -> return space
+ SoftBreak
+ | writerWrapText o == WrapPreserve
+ -> return $ preformatted "\n"
+ | otherwise -> return $ space
+ Span _ xs -> inlinesToOpenDocument o xs
+ LineBreak -> return $ selfClosingTag "text:line-break" []
+ Str s -> return $ handleSpaces $ escapeStringForXML s
+ Emph l -> withTextStyle Italic $ inlinesToOpenDocument o l
+ Strong l -> withTextStyle Bold $ inlinesToOpenDocument o l
+ Strikeout l -> withTextStyle Strike $ inlinesToOpenDocument o l
+ Superscript l -> withTextStyle Sup $ inlinesToOpenDocument o l
+ Subscript l -> withTextStyle Sub $ inlinesToOpenDocument o l
+ SmallCaps l -> withTextStyle SmallC $ inlinesToOpenDocument o l
+ Quoted t l -> inQuotes t <$> inlinesToOpenDocument o l
+ Code _ s -> inlinedCode $ preformatted s
+ Math t s -> lift (texMathToInlines t s) >>=
+ inlinesToOpenDocument o
+ Cite _ l -> inlinesToOpenDocument o l
+ RawInline f s -> if f == Format "opendocument"
+ then return $ text s
+ else do
+ report $ InlineNotRendered ils
+ return empty
+ Link _ l (s,t) -> mkLink s t <$> inlinesToOpenDocument o l
+ Image attr _ (s,t) -> mkImg attr s t
+ Note l -> mkNote l
+ where
+ preformatted s = handleSpaces $ escapeStringForXML s
+ inlinedCode s = return $ inTags False "text:span" [("text:style-name", "Source_Text")] s
+ mkLink s t = inTags False "text:a" [ ("xlink:type" , "simple")
+ , ("xlink:href" , s )
+ , ("office:name", t )
+ ] . inSpanTags "Definition"
+ mkImg (_, _, kvs) s _ = do
+ id' <- gets stImageId
+ modify (\st -> st{ stImageId = id' + 1 })
+ let getDims [] = []
+ getDims (("width", w) :xs) = ("svg:width", w) : getDims xs
+ getDims (("height", h):xs) = ("svg:height", h) : getDims xs
+ getDims (x@("style:rel-width", _) :xs) = x : getDims xs
+ getDims (x@("style:rel-height", _):xs) = x : getDims xs
+ getDims (_:xs) = getDims xs
+ return $ inTags False "draw:frame"
+ (("draw:name", "img" ++ show id') : getDims kvs) $
+ selfClosingTag "draw:image" [ ("xlink:href" , s )
+ , ("xlink:type" , "simple")
+ , ("xlink:show" , "embed" )
+ , ("xlink:actuate", "onLoad")]
+ mkNote l = do
+ n <- length <$> gets stNotes
+ let footNote t = inTags False "text:note"
+ [ ("text:id" , "ftn" ++ show n)
+ , ("text:note-class", "footnote" )] $
+ inTagsSimple "text:note-citation" (text . show $ n + 1) <>
+ inTagsSimple "text:note-body" t
+ nn <- footNote <$> withParagraphStyle o "Footnote" l
+ addNote nn
+ return nn
+
+bulletListStyle :: PandocMonad m => Int -> OD m (Int,(Int,[Doc]))
+bulletListStyle l = do
+ let doStyles i = inTags True "text:list-level-style-bullet"
+ [ ("text:level" , show (i + 1) )
+ , ("text:style-name" , "Bullet_20_Symbols")
+ , ("style:num-suffix", "." )
+ , ("text:bullet-char", [bulletList !! i] )
+ ] (listLevelStyle (1 + i))
+ bulletList = map chr $ cycle [8226,8227,8259]
+ listElStyle = map doStyles [0..9]
+ pn <- paraListStyle l
+ return (pn, (l, listElStyle))
+
+orderedListLevelStyle :: ListAttributes -> (Int, [Doc]) -> (Int,[Doc])
+orderedListLevelStyle (s,n, d) (l,ls) =
+ let suffix = case d of
+ OneParen -> [("style:num-suffix", ")")]
+ TwoParens -> [("style:num-prefix", "(")
+ ,("style:num-suffix", ")")]
+ _ -> [("style:num-suffix", ".")]
+ format = case n of
+ UpperAlpha -> "A"
+ LowerAlpha -> "a"
+ UpperRoman -> "I"
+ LowerRoman -> "i"
+ _ -> "1"
+ listStyle = inTags True "text:list-level-style-number"
+ ([ ("text:level" , show $ 1 + length ls )
+ , ("text:style-name" , "Numbering_20_Symbols")
+ , ("style:num-format", format )
+ , ("text:start-value", show s )
+ ] ++ suffix) (listLevelStyle (1 + length ls))
+ in (l, ls ++ [listStyle])
+
+listLevelStyle :: Int -> Doc
+listLevelStyle i =
+ let indent = show (0.25 * fromIntegral i :: Double) in
+ selfClosingTag "style:list-level-properties"
+ [ ("text:space-before" , indent ++ "in")
+ , ("text:min-label-width", "0.25in")]
+
+tableStyle :: Int -> [(Char,Double)] -> Doc
+tableStyle num wcs =
+ let tableId = "Table" ++ show (num + 1)
+ table = inTags True "style:style"
+ [("style:name", tableId)
+ ,("style:family", "table")] $
+ selfClosingTag "style:table-properties"
+ [("table:align" , "center")]
+ colStyle (c,0) = selfClosingTag "style:style"
+ [ ("style:name" , tableId ++ "." ++ [c])
+ , ("style:family", "table-column" )]
+ colStyle (c,w) = inTags True "style:style"
+ [ ("style:name" , tableId ++ "." ++ [c])
+ , ("style:family", "table-column" )] $
+ selfClosingTag "style:table-column-properties"
+ [("style:rel-column-width", printf "%d*" $ (floor $ w * 65535 :: Integer))]
+ cellStyle = inTags True "style:style"
+ [ ("style:name" , tableId ++ ".A1")
+ , ("style:family", "table-cell" )] $
+ selfClosingTag "style:table-cell-properties"
+ [ ("fo:border", "none")]
+ columnStyles = map colStyle wcs
+ in table $$ vcat columnStyles $$ cellStyle
+
+paraStyle :: PandocMonad m => [(String,String)] -> OD m Int
+paraStyle attrs = do
+ pn <- (+) 1 . length <$> gets stParaStyles
+ i <- (*) (0.5 :: Double) . fromIntegral <$> gets stIndentPara
+ b <- gets stInDefinition
+ t <- gets stTight
+ let styleAttr = [ ("style:name" , "P" ++ show pn)
+ , ("style:family" , "paragraph" )]
+ indentVal = flip (++) "in" . show $ if b then (max 0.5 i) else i
+ tight = if t then [ ("fo:margin-top" , "0in" )
+ , ("fo:margin-bottom" , "0in" )]
+ else []
+ indent = if (i /= 0 || b)
+ then [ ("fo:margin-left" , indentVal)
+ , ("fo:margin-right" , "0in" )
+ , ("fo:text-indent" , "0in" )
+ , ("style:auto-text-indent" , "false" )]
+ else []
+ attributes = indent ++ tight
+ paraProps = when (not $ null attributes) $
+ selfClosingTag "style:paragraph-properties" attributes
+ addParaStyle $ inTags True "style:style" (styleAttr ++ attrs) paraProps
+ return pn
+
+paraListStyle :: PandocMonad m => Int -> OD m Int
+paraListStyle l = paraStyle
+ [("style:parent-style-name","Text_20_body")
+ ,("style:list-style-name", "L" ++ show l )]
+
+paraTableStyles :: String -> Int -> [Alignment] -> [(String, Doc)]
+paraTableStyles _ _ [] = []
+paraTableStyles t s (a:xs)
+ | AlignRight <- a = ( pName s, res s "end" ) : paraTableStyles t (s + 1) xs
+ | AlignCenter <- a = ( pName s, res s "center") : paraTableStyles t (s + 1) xs
+ | otherwise = ("Table_20_" ++ t, empty ) : paraTableStyles t s xs
+ where pName sn = "P" ++ show (sn + 1)
+ res sn x = inTags True "style:style"
+ [ ("style:name" , pName sn )
+ , ("style:family" , "paragraph" )
+ , ("style:parent-style-name", "Table_20_" ++ t)] $
+ selfClosingTag "style:paragraph-properties"
+ [ ("fo:text-align", x)
+ , ("style:justify-single-word", "false")]
+
+data TextStyle = Italic | Bold | Strike | Sub | Sup | SmallC | Pre
+ deriving ( Eq,Ord )
+
+textStyleAttr :: TextStyle -> [(String,String)]
+textStyleAttr s
+ | Italic <- s = [("fo:font-style" ,"italic" )
+ ,("style:font-style-asian" ,"italic" )
+ ,("style:font-style-complex" ,"italic" )]
+ | Bold <- s = [("fo:font-weight" ,"bold" )
+ ,("style:font-weight-asian" ,"bold" )
+ ,("style:font-weight-complex" ,"bold" )]
+ | Strike <- s = [("style:text-line-through-style", "solid" )]
+ | Sub <- s = [("style:text-position" ,"sub 58%" )]
+ | Sup <- s = [("style:text-position" ,"super 58%" )]
+ | SmallC <- s = [("fo:font-variant" ,"small-caps")]
+ | Pre <- s = [("style:font-name" ,"Courier New")
+ ,("style:font-name-asian" ,"Courier New")
+ ,("style:font-name-complex" ,"Courier New")]
+ | otherwise = []
diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs
new file mode 100644
index 000000000..55d3fe656
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Org.hs
@@ -0,0 +1,411 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-
+Copyright (C) 2010-2015 Puneeth Chaganti <punchagan@gmail.com>
+ Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>,
+ and 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.Org
+ Copyright : Copyright (C) 2010-2015 Puneeth Chaganti and John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Puneeth Chaganti <punchagan@gmail.com>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to Emacs Org-Mode.
+
+Org-Mode: <http://orgmode.org>
+-}
+module Text.Pandoc.Writers.Org ( writeOrg) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Text.Pandoc.Shared
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Pretty
+import Text.Pandoc.Templates (renderTemplate')
+import Data.Char ( isAlphaNum, toLower )
+import Data.List ( isPrefixOf, intersect, intersperse, partition, transpose )
+import Control.Monad.State
+import Text.Pandoc.Class (PandocMonad)
+
+data WriterState =
+ WriterState { stNotes :: [[Block]]
+ , stHasMath :: Bool
+ , stOptions :: WriterOptions
+ }
+
+-- | Convert Pandoc to Org.
+writeOrg :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeOrg opts document = return $
+ let st = WriterState { stNotes = [],
+ stHasMath = False,
+ stOptions = opts }
+ in evalState (pandocToOrg document) st
+
+-- | Return Org representation of document.
+pandocToOrg :: Pandoc -> State WriterState String
+pandocToOrg (Pandoc meta blocks) = do
+ opts <- liftM stOptions get
+ let colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ metadata <- metaToJSON opts
+ (fmap (render colwidth) . blockListToOrg)
+ (fmap (render colwidth) . inlineListToOrg)
+ meta
+ body <- blockListToOrg blocks
+ notes <- liftM (reverse . stNotes) get >>= notesToOrg
+ hasMath <- liftM stHasMath get
+ let main = render colwidth $ foldl ($+$) empty $ [body, notes]
+ let context = defField "body" main
+ $ defField "math" hasMath
+ $ metadata
+ case writerTemplate opts of
+ Nothing -> return main
+ Just tpl -> return $ renderTemplate' tpl context
+
+-- | Return Org representation of notes.
+notesToOrg :: [[Block]] -> State WriterState Doc
+notesToOrg notes =
+ mapM (\(num, note) -> noteToOrg num note) (zip [1..] notes) >>=
+ return . vsep
+
+-- | Return Org representation of a note.
+noteToOrg :: Int -> [Block] -> State WriterState Doc
+noteToOrg num note = do
+ contents <- blockListToOrg note
+ let marker = "[fn:" ++ show num ++ "] "
+ return $ hang (length marker) (text marker) contents
+
+-- | Escape special characters for Org.
+escapeString :: String -> String
+escapeString = escapeStringUsing $
+ [ ('\x2014',"---")
+ , ('\x2013',"--")
+ , ('\x2019',"'")
+ , ('\x2026',"...")
+ ] ++ backslashEscapes "^_"
+
+isRawFormat :: Format -> Bool
+isRawFormat f =
+ f == Format "latex" || f == Format "tex" || f == Format "org"
+
+-- | Convert Pandoc block element to Org.
+blockToOrg :: Block -- ^ Block element
+ -> State WriterState Doc
+blockToOrg Null = return empty
+blockToOrg (Div (_,classes@(cls:_),kvs) bs) | "drawer" `elem` classes = do
+ contents <- blockListToOrg bs
+ let drawerNameTag = ":" <> text cls <> ":"
+ let keys = vcat $ map (\(k,v) ->
+ ":" <> text k <> ":"
+ <> space <> text v) kvs
+ let drawerEndTag = text ":END:"
+ return $ drawerNameTag $$ cr $$ keys $$
+ blankline $$ contents $$
+ blankline $$ drawerEndTag $$
+ blankline
+blockToOrg (Div attrs bs) = do
+ contents <- blockListToOrg bs
+ let isGreaterBlockClass = (`elem` ["center", "quote"]) . map toLower
+ return $ case attrs of
+ ("", [], []) ->
+ -- nullAttr, treat contents as if it wasn't wrapped
+ blankline $$ contents $$ blankline
+ (ident, [], []) ->
+ -- only an id: add id as an anchor, unwrap the rest
+ blankline $$ "<<" <> text ident <> ">>" $$ contents $$ blankline
+ (ident, classes, kv) ->
+ -- if one class looks like the name of a greater block then output as
+ -- such: The ID, if present, is added via the #+NAME keyword; other
+ -- classes and key-value pairs are kept as #+ATTR_HTML attributes.
+ let
+ (blockTypeCand, classes') = partition isGreaterBlockClass classes
+ in case blockTypeCand of
+ (blockType:classes'') ->
+ blankline $$ attrHtml (ident, classes'' <> classes', kv) $$
+ "#+BEGIN_" <> text blockType $$ contents $$
+ "#+END_" <> text blockType $$ blankline
+ _ ->
+ -- fallback: wrap in div tags
+ let
+ startTag = tagWithAttrs "div" attrs
+ endTag = text "</div>"
+ in blankline $$ "#+BEGIN_HTML" $$
+ nest 2 startTag $$ "#+END_HTML" $$ blankline $$
+ contents $$ blankline $$ "#+BEGIN_HTML" $$
+ nest 2 endTag $$ "#+END_HTML" $$ blankline
+blockToOrg (Plain inlines) = inlineListToOrg inlines
+-- title beginning with fig: indicates that the image is a figure
+blockToOrg (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
+ capt <- if null txt
+ then return empty
+ else ("#+CAPTION: " <>) `fmap` inlineListToOrg txt
+ img <- inlineToOrg (Image attr txt (src,tit))
+ return $ capt $$ img $$ blankline
+blockToOrg (Para inlines) = do
+ contents <- inlineListToOrg inlines
+ return $ contents <> blankline
+blockToOrg (LineBlock lns) = do
+ let splitStanza [] = []
+ splitStanza xs = case break (== mempty) xs of
+ (l, []) -> l : []
+ (l, _:r) -> l : splitStanza r
+ let joinWithLinefeeds = nowrap . mconcat . intersperse cr
+ let joinWithBlankLines = mconcat . intersperse blankline
+ let prettyfyStanza ls = joinWithLinefeeds <$> mapM inlineListToOrg ls
+ contents <- joinWithBlankLines <$> mapM prettyfyStanza (splitStanza lns)
+ return $ blankline $$ "#+BEGIN_VERSE" $$
+ nest 2 contents $$ "#+END_VERSE" <> blankline
+blockToOrg (RawBlock "html" str) =
+ return $ blankline $$ "#+BEGIN_HTML" $$
+ nest 2 (text str) $$ "#+END_HTML" $$ blankline
+blockToOrg (RawBlock f str) | isRawFormat f =
+ return $ text str
+blockToOrg (RawBlock _ _) = return empty
+blockToOrg HorizontalRule = return $ blankline $$ "--------------" $$ blankline
+blockToOrg (Header level attr inlines) = do
+ contents <- inlineListToOrg inlines
+ let headerStr = text $ if level > 999 then " " else replicate level '*'
+ let drawerStr = if attr == nullAttr
+ then empty
+ else cr <> nest (level + 1) (propertiesDrawer attr)
+ return $ headerStr <> " " <> contents <> drawerStr <> blankline
+blockToOrg (CodeBlock (_,classes,_) str) = do
+ opts <- stOptions <$> get
+ let tabstop = writerTabStop opts
+ let at = map pandocLangToOrg classes `intersect` orgLangIdentifiers
+ let (beg, end) = case at of
+ [] -> ("#+BEGIN_EXAMPLE", "#+END_EXAMPLE")
+ (x:_) -> ("#+BEGIN_SRC " ++ x, "#+END_SRC")
+ return $ text beg $$ nest tabstop (text str) $$ text end $$ blankline
+blockToOrg (BlockQuote blocks) = do
+ contents <- blockListToOrg blocks
+ return $ blankline $$ "#+BEGIN_QUOTE" $$
+ nest 2 contents $$ "#+END_QUOTE" $$ blankline
+blockToOrg (Table caption' _ _ headers rows) = do
+ caption'' <- inlineListToOrg caption'
+ let caption = if null caption'
+ then empty
+ else ("#+CAPTION: " <> caption'')
+ headers' <- mapM blockListToOrg headers
+ rawRows <- mapM (mapM blockListToOrg) rows
+ let numChars = maximum . map offset
+ -- FIXME: width is not being used.
+ let widthsInChars =
+ map ((+2) . numChars) $ transpose (headers' : rawRows)
+ -- FIXME: Org doesn't allow blocks with height more than 1.
+ let hpipeBlocks blocks = hcat [beg, middle, end]
+ where h = maximum (1 : map height blocks)
+ sep' = lblock 3 $ vcat (map text $ replicate h " | ")
+ beg = lblock 2 $ vcat (map text $ replicate h "| ")
+ end = lblock 2 $ vcat (map text $ replicate h " |")
+ middle = hcat $ intersperse sep' blocks
+ let makeRow = hpipeBlocks . zipWith lblock widthsInChars
+ let head' = makeRow headers'
+ rows' <- mapM (\row -> do cols <- mapM blockListToOrg row
+ return $ makeRow cols) rows
+ let border ch = char '|' <> char ch <>
+ (hcat $ intersperse (char ch <> char '+' <> char ch) $
+ map (\l -> text $ replicate l ch) widthsInChars) <>
+ char ch <> char '|'
+ let body = vcat rows'
+ let head'' = if all null headers
+ then empty
+ else head' $$ border '-'
+ return $ head'' $$ body $$ caption $$ blankline
+blockToOrg (BulletList items) = do
+ contents <- mapM bulletListItemToOrg items
+ -- ensure that sublists have preceding blank line
+ return $ blankline $+$ vcat contents $$ blankline
+blockToOrg (OrderedList (start, _, delim) items) = do
+ let delim' = case delim of
+ TwoParens -> OneParen
+ x -> x
+ let markers = take (length items) $ orderedListMarkers
+ (start, Decimal, delim')
+ let maxMarkerLength = maximum $ map length markers
+ let markers' = map (\m -> let s = maxMarkerLength - length m
+ in m ++ replicate s ' ') markers
+ contents <- mapM (\(item, num) -> orderedListItemToOrg item num) $
+ zip markers' items
+ -- ensure that sublists have preceding blank line
+ return $ blankline $$ vcat contents $$ blankline
+blockToOrg (DefinitionList items) = do
+ contents <- mapM definitionListItemToOrg items
+ return $ vcat contents $$ blankline
+
+-- | Convert bullet list item (list of blocks) to Org.
+bulletListItemToOrg :: [Block] -> State WriterState Doc
+bulletListItemToOrg items = do
+ contents <- blockListToOrg items
+ return $ hang 2 "- " (contents <> cr)
+
+-- | Convert ordered list item (a list of blocks) to Org.
+orderedListItemToOrg :: String -- ^ marker for list item
+ -> [Block] -- ^ list item (list of blocks)
+ -> State WriterState Doc
+orderedListItemToOrg marker items = do
+ contents <- blockListToOrg items
+ return $ hang (length marker + 1) (text marker <> space) (contents <> cr)
+
+-- | Convert defintion list item (label, list of blocks) to Org.
+definitionListItemToOrg :: ([Inline], [[Block]]) -> State WriterState Doc
+definitionListItemToOrg (label, defs) = do
+ label' <- inlineListToOrg label
+ contents <- liftM vcat $ mapM blockListToOrg defs
+ return $ hang 2 "- " $ label' <> " :: " <> (contents <> cr)
+
+-- | Convert list of key/value pairs to Org :PROPERTIES: drawer.
+propertiesDrawer :: Attr -> Doc
+propertiesDrawer (ident, classes, kv) =
+ let
+ drawerStart = text ":PROPERTIES:"
+ drawerEnd = text ":END:"
+ kv' = if (classes == mempty) then kv else ("CLASS", unwords classes):kv
+ kv'' = if (ident == mempty) then kv' else ("CUSTOM_ID", ident):kv'
+ properties = vcat $ map kvToOrgProperty kv''
+ in
+ drawerStart <> cr <> properties <> cr <> drawerEnd
+ where
+ kvToOrgProperty :: (String, String) -> Doc
+ kvToOrgProperty (key, value) =
+ text ":" <> text key <> text ": " <> text value <> cr
+
+attrHtml :: Attr -> Doc
+attrHtml ("" , [] , []) = mempty
+attrHtml (ident, classes, kvs) =
+ let
+ name = if (null ident) then mempty else "#+NAME: " <> text ident <> cr
+ keyword = "#+ATTR_HTML"
+ classKv = ("class", unwords classes)
+ kvStrings = map (\(k,v) -> ":" <> k <> " " <> v) (classKv:kvs)
+ in name <> keyword <> ": " <> text (unwords kvStrings) <> cr
+
+-- | Convert list of Pandoc block elements to Org.
+blockListToOrg :: [Block] -- ^ List of block elements
+ -> State WriterState Doc
+blockListToOrg blocks = mapM blockToOrg blocks >>= return . vcat
+
+-- | Convert list of Pandoc inline elements to Org.
+inlineListToOrg :: [Inline] -> State WriterState Doc
+inlineListToOrg lst = mapM inlineToOrg lst >>= return . hcat
+
+-- | Convert Pandoc inline element to Org.
+inlineToOrg :: Inline -> State WriterState Doc
+inlineToOrg (Span (uid, [], []) []) =
+ return $ "<<" <> text uid <> ">>"
+inlineToOrg (Span _ lst) =
+ inlineListToOrg lst
+inlineToOrg (Emph lst) = do
+ contents <- inlineListToOrg lst
+ return $ "/" <> contents <> "/"
+inlineToOrg (Strong lst) = do
+ contents <- inlineListToOrg lst
+ return $ "*" <> contents <> "*"
+inlineToOrg (Strikeout lst) = do
+ contents <- inlineListToOrg lst
+ return $ "+" <> contents <> "+"
+inlineToOrg (Superscript lst) = do
+ contents <- inlineListToOrg lst
+ return $ "^{" <> contents <> "}"
+inlineToOrg (Subscript lst) = do
+ contents <- inlineListToOrg lst
+ return $ "_{" <> contents <> "}"
+inlineToOrg (SmallCaps lst) = inlineListToOrg lst
+inlineToOrg (Quoted SingleQuote lst) = do
+ contents <- inlineListToOrg lst
+ return $ "'" <> contents <> "'"
+inlineToOrg (Quoted DoubleQuote lst) = do
+ contents <- inlineListToOrg lst
+ return $ "\"" <> contents <> "\""
+inlineToOrg (Cite _ lst) = inlineListToOrg lst
+inlineToOrg (Code _ str) = return $ "=" <> text str <> "="
+inlineToOrg (Str str) = return $ text $ escapeString str
+inlineToOrg (Math t str) = do
+ modify $ \st -> st{ stHasMath = True }
+ return $ if t == InlineMath
+ then "$" <> text str <> "$"
+ else "$$" <> text str <> "$$"
+inlineToOrg (RawInline f@(Format f') str) =
+ return $ if isRawFormat f
+ then text str
+ else "@@" <> text f' <> ":" <> text str <> "@@"
+inlineToOrg LineBreak = return (text "\\\\" <> cr)
+inlineToOrg Space = return space
+inlineToOrg SoftBreak = do
+ wrapText <- gets (writerWrapText . stOptions)
+ case wrapText of
+ WrapPreserve -> return cr
+ WrapAuto -> return space
+ WrapNone -> return space
+inlineToOrg (Link _ txt (src, _)) = do
+ case txt of
+ [Str x] | escapeURI x == src -> -- autolink
+ do return $ "[[" <> text (orgPath x) <> "]]"
+ _ -> do contents <- inlineListToOrg txt
+ return $ "[[" <> text (orgPath src) <> "][" <> contents <> "]]"
+inlineToOrg (Image _ _ (source, _)) = do
+ return $ "[[" <> text (orgPath source) <> "]]"
+inlineToOrg (Note contents) = do
+ -- add to notes in state
+ notes <- get >>= (return . stNotes)
+ modify $ \st -> st { stNotes = contents:notes }
+ let ref = show $ (length notes) + 1
+ return $ "[fn:" <> text ref <> "]"
+
+orgPath :: String -> String
+orgPath src =
+ case src of
+ [] -> mempty -- wiki link
+ ('#':_) -> src -- internal link
+ _ | isUrl src -> src
+ _ | isFilePath src -> src
+ _ -> "file:" <> src
+ where
+ isFilePath :: String -> Bool
+ isFilePath cs = any (`isPrefixOf` cs) ["/", "./", "../", "file:"]
+
+ isUrl :: String -> Bool
+ isUrl cs =
+ let (scheme, path) = break (== ':') cs
+ in all (\c -> isAlphaNum c || c `elem` (".-"::String)) scheme
+ && not (null path)
+
+-- | Translate from pandoc's programming language identifiers to those used by
+-- org-mode.
+pandocLangToOrg :: String -> String
+pandocLangToOrg cs =
+ case cs of
+ "c" -> "C"
+ "cpp" -> "C++"
+ "commonlisp" -> "lisp"
+ "r" -> "R"
+ "bash" -> "sh"
+ _ -> cs
+
+-- | List of language identifiers recognized by org-mode.
+orgLangIdentifiers :: [String]
+orgLangIdentifiers =
+ [ "asymptote", "awk", "C", "C++", "clojure", "css", "d", "ditaa", "dot"
+ , "calc", "emacs-lisp", "fortran", "gnuplot", "haskell", "java", "js"
+ , "latex", "ledger", "lisp", "lilypond", "matlab", "mscgen", "ocaml"
+ , "octave", "org", "oz", "perl", "plantuml", "processing", "python", "R"
+ , "ruby", "sass", "scheme", "screen", "sed", "sh", "sql", "sqlite"
+ ]
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
new file mode 100644
index 000000000..5cce64d17
--- /dev/null
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -0,0 +1,556 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-
+Copyright (C) 2006-2015 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.RST
+ Copyright : Copyright (C) 2006-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to reStructuredText.
+
+reStructuredText: <http://docutils.sourceforge.net/rst.html>
+-}
+module Text.Pandoc.Writers.RST ( writeRST ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Text.Pandoc.Shared
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.ImageSize
+import Text.Pandoc.Templates (renderTemplate')
+import Text.Pandoc.Builder (deleteMeta)
+import Data.Maybe (fromMaybe)
+import Data.List ( isPrefixOf, stripPrefix, intersperse, transpose )
+import Network.URI (isURI)
+import Text.Pandoc.Pretty
+import Control.Monad.State
+import Data.Char (isSpace, toLower)
+import Text.Pandoc.Class (PandocMonad)
+
+type Refs = [([Inline], Target)]
+
+data WriterState =
+ WriterState { stNotes :: [[Block]]
+ , stLinks :: Refs
+ , stImages :: [([Inline], (Attr, String, String, Maybe String))]
+ , stHasMath :: Bool
+ , stHasRawTeX :: Bool
+ , stOptions :: WriterOptions
+ , stTopLevel :: Bool
+ }
+
+-- | Convert Pandoc to RST.
+writeRST :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeRST opts document = return $
+ let st = WriterState { stNotes = [], stLinks = [],
+ stImages = [], stHasMath = False,
+ stHasRawTeX = False, stOptions = opts,
+ stTopLevel = True}
+ in evalState (pandocToRST document) st
+
+-- | Return RST representation of document.
+pandocToRST :: Pandoc -> State WriterState String
+pandocToRST (Pandoc meta blocks) = do
+ opts <- liftM stOptions get
+ let colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ let subtit = case lookupMeta "subtitle" meta of
+ Just (MetaBlocks [Plain xs]) -> xs
+ _ -> []
+ title <- titleToRST (docTitle meta) subtit
+ metadata <- metaToJSON opts
+ (fmap (render colwidth) . blockListToRST)
+ (fmap (trimr . render colwidth) . inlineListToRST)
+ $ deleteMeta "title" $ deleteMeta "subtitle" meta
+ body <- blockListToRST' True $ case writerTemplate opts of
+ Just _ -> normalizeHeadings 1 blocks
+ Nothing -> blocks
+ notes <- liftM (reverse . stNotes) get >>= notesToRST
+ -- note that the notes may contain refs, so we do them first
+ refs <- liftM (reverse . stLinks) get >>= refsToRST
+ pics <- liftM (reverse . stImages) get >>= pictRefsToRST
+ hasMath <- liftM stHasMath get
+ rawTeX <- liftM stHasRawTeX get
+ let main = render colwidth $ foldl ($+$) empty $ [body, notes, refs, pics]
+ let context = defField "body" main
+ $ defField "toc" (writerTableOfContents opts)
+ $ defField "toc-depth" (show $ writerTOCDepth opts)
+ $ defField "math" hasMath
+ $ defField "title" (render Nothing title :: String)
+ $ defField "math" hasMath
+ $ defField "rawtex" rawTeX
+ $ metadata
+ case writerTemplate opts of
+ Nothing -> return main
+ Just tpl -> return $ renderTemplate' tpl context
+ where
+ normalizeHeadings lev (Header l a i:bs) =
+ Header lev a i:normalizeHeadings (lev+1) cont ++ normalizeHeadings lev bs'
+ where (cont,bs') = break (headerLtEq l) bs
+ headerLtEq level (Header l' _ _) = l' <= level
+ headerLtEq _ _ = False
+ normalizeHeadings lev (b:bs) = b:normalizeHeadings lev bs
+ normalizeHeadings _ [] = []
+
+-- | Return RST representation of reference key table.
+refsToRST :: Refs -> State WriterState Doc
+refsToRST refs = mapM keyToRST refs >>= return . vcat
+
+-- | Return RST representation of a reference key.
+keyToRST :: ([Inline], (String, String))
+ -> State WriterState Doc
+keyToRST (label, (src, _)) = do
+ label' <- inlineListToRST label
+ let label'' = if ':' `elem` ((render Nothing label') :: String)
+ then char '`' <> label' <> char '`'
+ else label'
+ return $ nowrap $ ".. _" <> label'' <> ": " <> text src
+
+-- | Return RST representation of notes.
+notesToRST :: [[Block]] -> State WriterState Doc
+notesToRST notes =
+ mapM (\(num, note) -> noteToRST num note) (zip [1..] notes) >>=
+ return . vsep
+
+-- | Return RST representation of a note.
+noteToRST :: Int -> [Block] -> State WriterState Doc
+noteToRST num note = do
+ contents <- blockListToRST note
+ let marker = ".. [" <> text (show num) <> "]"
+ return $ nowrap $ marker $$ nest 3 contents
+
+-- | Return RST representation of picture reference table.
+pictRefsToRST :: [([Inline], (Attr, String, String, Maybe String))]
+ -> State WriterState Doc
+pictRefsToRST refs = mapM pictToRST refs >>= return . vcat
+
+-- | Return RST representation of a picture substitution reference.
+pictToRST :: ([Inline], (Attr, String, String, Maybe String))
+ -> State WriterState Doc
+pictToRST (label, (attr, src, _, mbtarget)) = do
+ label' <- inlineListToRST label
+ dims <- imageDimsToRST attr
+ let (_, cls, _) = attr
+ classes = if null cls
+ then empty
+ else ":class: " <> text (unwords cls)
+ return $ nowrap
+ $ ".. |" <> label' <> "| image:: " <> text src $$ hang 3 empty (classes $$ dims)
+ $$ case mbtarget of
+ Nothing -> empty
+ Just t -> " :target: " <> text t
+
+-- | Escape special characters for RST.
+escapeString :: WriterOptions -> String -> String
+escapeString _ [] = []
+escapeString opts (c:cs) =
+ case c of
+ _ | c `elem` ['\\','`','*','_','|'] -> '\\':c:escapeString opts cs
+ '\'' | isEnabled Ext_smart opts -> '\\':'\'':escapeString opts cs
+ '"' | isEnabled Ext_smart opts -> '\\':'"':escapeString opts cs
+ '-' | isEnabled Ext_smart opts ->
+ case cs of
+ '-':_ -> '\\':'-':escapeString opts cs
+ _ -> '-':escapeString opts cs
+ '.' | isEnabled Ext_smart opts ->
+ case cs of
+ '.':'.':rest -> '\\':'.':'.':'.':escapeString opts rest
+ _ -> '.':escapeString opts cs
+ _ -> c : escapeString opts cs
+
+titleToRST :: [Inline] -> [Inline] -> State WriterState Doc
+titleToRST [] _ = return empty
+titleToRST tit subtit = do
+ title <- inlineListToRST tit
+ subtitle <- inlineListToRST subtit
+ return $ bordered title '=' $$ bordered subtitle '-'
+
+bordered :: Doc -> Char -> Doc
+bordered contents c =
+ if len > 0
+ then border $$ contents $$ border
+ else empty
+ where len = offset contents
+ border = text (replicate len c)
+
+-- | Convert Pandoc block element to RST.
+blockToRST :: Block -- ^ Block element
+ -> State WriterState Doc
+blockToRST Null = return empty
+blockToRST (Div attr bs) = do
+ contents <- blockListToRST bs
+ let startTag = ".. raw:: html" $+$ nest 3 (tagWithAttrs "div" attr)
+ let endTag = ".. raw:: html" $+$ nest 3 "</div>"
+ return $ blankline <> startTag $+$ contents $+$ endTag $$ blankline
+blockToRST (Plain inlines) = inlineListToRST inlines
+-- title beginning with fig: indicates that the image is a figure
+blockToRST (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
+ capt <- inlineListToRST txt
+ dims <- imageDimsToRST attr
+ let fig = "figure:: " <> text src
+ alt = ":alt: " <> if null tit then capt else text tit
+ (_,cls,_) = attr
+ classes = if null cls
+ then empty
+ else ":figclass: " <> text (unwords cls)
+ return $ hang 3 ".. " (fig $$ alt $$ classes $$ dims $+$ capt) $$ blankline
+blockToRST (Para inlines)
+ | LineBreak `elem` inlines = do -- use line block if LineBreaks
+ linesToLineBlock $ splitBy (==LineBreak) inlines
+ | otherwise = do
+ contents <- inlineListToRST inlines
+ return $ contents <> blankline
+blockToRST (LineBlock lns) =
+ linesToLineBlock lns
+blockToRST (RawBlock f@(Format f') str)
+ | f == "rst" = return $ text str
+ | otherwise = return $ blankline <> ".. raw:: " <>
+ text (map toLower f') $+$
+ (nest 3 $ text str) $$ blankline
+blockToRST HorizontalRule =
+ return $ blankline $$ "--------------" $$ blankline
+blockToRST (Header level (name,classes,_) inlines) = do
+ contents <- inlineListToRST inlines
+ isTopLevel <- gets stTopLevel
+ if isTopLevel
+ then do
+ let headerChar = if level > 5 then ' ' else "=-~^'" !! (level - 1)
+ let border = text $ replicate (offset contents) headerChar
+ return $ nowrap $ contents $$ border $$ blankline
+ else do
+ let rub = "rubric:: " <> contents
+ let name' | null name = empty
+ | otherwise = ":name: " <> text name
+ let cls | null classes = empty
+ | otherwise = ":class: " <> text (unwords classes)
+ return $ nowrap $ hang 3 ".. " (rub $$ name' $$ cls) $$ blankline
+blockToRST (CodeBlock (_,classes,kvs) str) = do
+ opts <- stOptions <$> get
+ let tabstop = writerTabStop opts
+ let startnum = maybe "" (\x -> " " <> text x) $ lookup "startFrom" kvs
+ let numberlines = if "numberLines" `elem` classes
+ then " :number-lines:" <> startnum
+ else empty
+ if "haskell" `elem` classes && "literate" `elem` classes &&
+ isEnabled Ext_literate_haskell opts
+ then return $ prefixed "> " (text str) $$ blankline
+ else return $
+ (case [c | c <- classes,
+ c `notElem` ["sourceCode","literate","numberLines"]] of
+ [] -> "::"
+ (lang:_) -> (".. code:: " <> text lang) $$ numberlines)
+ $+$ nest tabstop (text str) $$ blankline
+blockToRST (BlockQuote blocks) = do
+ tabstop <- get >>= (return . writerTabStop . stOptions)
+ contents <- blockListToRST blocks
+ return $ (nest tabstop contents) <> blankline
+blockToRST (Table caption _ widths headers rows) = do
+ caption' <- inlineListToRST caption
+ headers' <- mapM blockListToRST headers
+ rawRows <- mapM (mapM blockListToRST) rows
+ -- let isSimpleCell [Plain _] = True
+ -- isSimpleCell [Para _] = True
+ -- isSimpleCell [] = True
+ -- isSimpleCell _ = False
+ -- let isSimple = all (==0) widths && all (all isSimpleCell) rows
+ let numChars = maximum . map offset
+ opts <- get >>= return . stOptions
+ let widthsInChars =
+ if all (== 0) widths
+ then map ((+2) . numChars) $ transpose (headers' : rawRows)
+ else map (floor . (fromIntegral (writerColumns opts) *)) widths
+ let hpipeBlocks blocks = hcat [beg, middle, end]
+ where h = height (hcat blocks)
+ sep' = lblock 3 $ vcat (map text $ replicate h " | ")
+ beg = lblock 2 $ vcat (map text $ replicate h "| ")
+ end = lblock 2 $ vcat (map text $ replicate h " |")
+ middle = hcat $ intersperse sep' blocks
+ let makeRow = hpipeBlocks . zipWith lblock widthsInChars
+ let head' = makeRow headers'
+ let rows' = map makeRow rawRows
+ let border ch = char '+' <> char ch <>
+ (hcat $ intersperse (char ch <> char '+' <> char ch) $
+ map (\l -> text $ replicate l ch) widthsInChars) <>
+ char ch <> char '+'
+ let body = vcat $ intersperse (border '-') rows'
+ let head'' = if all null headers
+ then empty
+ else head' $$ border '='
+ let tbl = border '-' $$ head'' $$ body $$ border '-'
+ return $ if null caption
+ then tbl $$ blankline
+ else (".. table:: " <> caption') $$ blankline $$ nest 3 tbl $$
+ blankline
+blockToRST (BulletList items) = do
+ contents <- mapM bulletListItemToRST items
+ -- ensure that sublists have preceding blank line
+ return $ blankline $$ chomp (vcat contents) $$ blankline
+blockToRST (OrderedList (start, style', delim) items) = do
+ let markers = if start == 1 && style' == DefaultStyle && delim == DefaultDelim
+ then take (length items) $ repeat "#."
+ else take (length items) $ orderedListMarkers
+ (start, style', delim)
+ let maxMarkerLength = maximum $ map length markers
+ let markers' = map (\m -> let s = maxMarkerLength - length m
+ in m ++ replicate s ' ') markers
+ contents <- mapM (\(item, num) -> orderedListItemToRST item num) $
+ zip markers' items
+ -- ensure that sublists have preceding blank line
+ return $ blankline $$ chomp (vcat contents) $$ blankline
+blockToRST (DefinitionList items) = do
+ contents <- mapM definitionListItemToRST items
+ -- ensure that sublists have preceding blank line
+ return $ blankline $$ chomp (vcat contents) $$ blankline
+
+-- | Convert bullet list item (list of blocks) to RST.
+bulletListItemToRST :: [Block] -> State WriterState Doc
+bulletListItemToRST items = do
+ contents <- blockListToRST items
+ return $ hang 3 "- " $ contents <> cr
+
+-- | Convert ordered list item (a list of blocks) to RST.
+orderedListItemToRST :: String -- ^ marker for list item
+ -> [Block] -- ^ list item (list of blocks)
+ -> State WriterState Doc
+orderedListItemToRST marker items = do
+ contents <- blockListToRST items
+ let marker' = marker ++ " "
+ return $ hang (length marker') (text marker') $ contents <> cr
+
+-- | Convert defintion list item (label, list of blocks) to RST.
+definitionListItemToRST :: ([Inline], [[Block]]) -> State WriterState Doc
+definitionListItemToRST (label, defs) = do
+ label' <- inlineListToRST label
+ contents <- liftM vcat $ mapM blockListToRST defs
+ tabstop <- get >>= (return . writerTabStop . stOptions)
+ return $ label' $$ nest tabstop (nestle contents <> cr)
+
+-- | Format a list of lines as line block.
+linesToLineBlock :: [[Inline]] -> State WriterState Doc
+linesToLineBlock inlineLines = do
+ lns <- mapM inlineListToRST inlineLines
+ return $ (vcat $ map (hang 2 (text "| ")) lns) <> blankline
+
+-- | Convert list of Pandoc block elements to RST.
+blockListToRST' :: Bool
+ -> [Block] -- ^ List of block elements
+ -> State WriterState Doc
+blockListToRST' topLevel blocks = do
+ tl <- gets stTopLevel
+ modify (\s->s{stTopLevel=topLevel})
+ res <- vcat `fmap` mapM blockToRST blocks
+ modify (\s->s{stTopLevel=tl})
+ return res
+
+blockListToRST :: [Block] -- ^ List of block elements
+ -> State WriterState Doc
+blockListToRST = blockListToRST' False
+
+-- | Convert list of Pandoc inline elements to RST.
+inlineListToRST :: [Inline] -> State WriterState Doc
+inlineListToRST lst =
+ mapM inlineToRST (removeSpaceAfterDisplayMath $ insertBS lst) >>=
+ return . hcat
+ where -- remove spaces after displaymath, as they screw up indentation:
+ removeSpaceAfterDisplayMath (Math DisplayMath x : zs) =
+ Math DisplayMath x : dropWhile (==Space) zs
+ removeSpaceAfterDisplayMath (x:xs) = x : removeSpaceAfterDisplayMath xs
+ removeSpaceAfterDisplayMath [] = []
+ insertBS :: [Inline] -> [Inline] -- insert '\ ' where needed
+ insertBS (x:y:z:zs)
+ | isComplex y && (surroundComplex x z) =
+ x : y : insertBS (z : zs)
+ insertBS (x:y:zs)
+ | isComplex x && not (okAfterComplex y) =
+ x : RawInline "rst" "\\ " : insertBS (y : zs)
+ | isComplex y && not (okBeforeComplex x) =
+ x : RawInline "rst" "\\ " : insertBS (y : zs)
+ | otherwise =
+ x : insertBS (y : zs)
+ insertBS (x:ys) = x : insertBS ys
+ insertBS [] = []
+ surroundComplex :: Inline -> Inline -> Bool
+ surroundComplex (Str s@(_:_)) (Str s'@(_:_)) =
+ case (last s, head s') of
+ ('\'','\'') -> True
+ ('"','"') -> True
+ ('<','>') -> True
+ ('[',']') -> True
+ ('{','}') -> True
+ _ -> False
+ surroundComplex _ _ = False
+ okAfterComplex :: Inline -> Bool
+ okAfterComplex Space = True
+ okAfterComplex SoftBreak = True
+ okAfterComplex LineBreak = True
+ okAfterComplex (Str (c:_)) = isSpace c || c `elem` ("-.,:;!?\\/'\")]}>–—" :: String)
+ okAfterComplex _ = False
+ okBeforeComplex :: Inline -> Bool
+ okBeforeComplex Space = True
+ okBeforeComplex SoftBreak = True
+ okBeforeComplex LineBreak = True
+ okBeforeComplex (Str (c:_)) = isSpace c || c `elem` ("-:/'\"<([{–—" :: String)
+ okBeforeComplex _ = False
+ isComplex :: Inline -> Bool
+ isComplex (Emph _) = True
+ isComplex (Strong _) = True
+ isComplex (SmallCaps _) = True
+ isComplex (Strikeout _) = True
+ isComplex (Superscript _) = True
+ isComplex (Subscript _) = True
+ isComplex (Link _ _ _) = True
+ isComplex (Image _ _ _) = True
+ isComplex (Code _ _) = True
+ isComplex (Math _ _) = True
+ isComplex (Cite _ (x:_)) = isComplex x
+ isComplex (Span _ (x:_)) = isComplex x
+ isComplex _ = False
+
+-- | Convert Pandoc inline element to RST.
+inlineToRST :: Inline -> State WriterState Doc
+inlineToRST (Span _ ils) = inlineListToRST ils
+inlineToRST (Emph lst) = do
+ contents <- inlineListToRST lst
+ return $ "*" <> contents <> "*"
+inlineToRST (Strong lst) = do
+ contents <- inlineListToRST lst
+ return $ "**" <> contents <> "**"
+inlineToRST (Strikeout lst) = do
+ contents <- inlineListToRST lst
+ return $ "[STRIKEOUT:" <> contents <> "]"
+inlineToRST (Superscript lst) = do
+ contents <- inlineListToRST lst
+ return $ ":sup:`" <> contents <> "`"
+inlineToRST (Subscript lst) = do
+ contents <- inlineListToRST lst
+ return $ ":sub:`" <> contents <> "`"
+inlineToRST (SmallCaps lst) = inlineListToRST lst
+inlineToRST (Quoted SingleQuote lst) = do
+ contents <- inlineListToRST lst
+ opts <- gets stOptions
+ if isEnabled Ext_smart opts
+ then return $ "'" <> contents <> "'"
+ else return $ "‘" <> contents <> "’"
+inlineToRST (Quoted DoubleQuote lst) = do
+ contents <- inlineListToRST lst
+ opts <- gets stOptions
+ if isEnabled Ext_smart opts
+ then return $ "\"" <> contents <> "\""
+ else return $ "“" <> contents <> "”"
+inlineToRST (Cite _ lst) =
+ inlineListToRST lst
+inlineToRST (Code _ str) = return $ "``" <> text str <> "``"
+inlineToRST (Str str) = do
+ opts <- gets stOptions
+ return $ text $
+ (if isEnabled Ext_smart opts
+ then unsmartify opts
+ else id) $ escapeString opts str
+inlineToRST (Math t str) = do
+ modify $ \st -> st{ stHasMath = True }
+ return $ if t == InlineMath
+ then ":math:`" <> text str <> "`"
+ else if '\n' `elem` str
+ then blankline $$ ".. math::" $$
+ blankline $$ nest 3 (text str) $$ blankline
+ else blankline $$ (".. math:: " <> text str) $$ blankline
+inlineToRST (RawInline f x)
+ | f == "rst" = return $ text x
+ | f == "latex" || f == "tex" = do
+ modify $ \st -> st{ stHasRawTeX = True }
+ return $ ":raw-latex:`" <> text x <> "`"
+ | otherwise = return empty
+inlineToRST (LineBreak) = return cr -- there's no line break in RST (see Para)
+inlineToRST Space = return space
+inlineToRST SoftBreak = do
+ wrapText <- gets (writerWrapText . stOptions)
+ case wrapText of
+ WrapPreserve -> return cr
+ WrapAuto -> return space
+ WrapNone -> return space
+-- autolink
+inlineToRST (Link _ [Str str] (src, _))
+ | isURI src &&
+ if "mailto:" `isPrefixOf` src
+ then src == escapeURI ("mailto:" ++ str)
+ else src == escapeURI str = do
+ let srcSuffix = fromMaybe src (stripPrefix "mailto:" src)
+ return $ text srcSuffix
+inlineToRST (Link _ [Image attr alt (imgsrc,imgtit)] (src, _tit)) = do
+ label <- registerImage attr alt (imgsrc,imgtit) (Just src)
+ return $ "|" <> label <> "|"
+inlineToRST (Link _ txt (src, tit)) = do
+ useReferenceLinks <- get >>= return . writerReferenceLinks . stOptions
+ linktext <- inlineListToRST $ normalizeSpaces txt
+ if useReferenceLinks
+ then do refs <- get >>= return . stLinks
+ case lookup txt refs of
+ Just (src',tit') ->
+ if src == src' && tit == tit'
+ then return $ "`" <> linktext <> "`_"
+ else do -- duplicate label, use non-reference link
+ return $ "`" <> linktext <> " <" <> text src <> ">`__"
+ Nothing -> do
+ modify $ \st -> st { stLinks = (txt,(src,tit)):refs }
+ return $ "`" <> linktext <> "`_"
+ else return $ "`" <> linktext <> " <" <> text src <> ">`__"
+inlineToRST (Image attr alternate (source, tit)) = do
+ label <- registerImage attr alternate (source,tit) Nothing
+ return $ "|" <> label <> "|"
+inlineToRST (Note contents) = do
+ -- add to notes in state
+ notes <- gets stNotes
+ modify $ \st -> st { stNotes = contents:notes }
+ let ref = show $ (length notes) + 1
+ return $ " [" <> text ref <> "]_"
+
+registerImage :: Attr -> [Inline] -> Target -> Maybe String -> State WriterState Doc
+registerImage attr alt (src,tit) mbtarget = do
+ pics <- get >>= return . stImages
+ txt <- case lookup alt pics of
+ Just (a,s,t,mbt) | (a,s,t,mbt) == (attr,src,tit,mbtarget)
+ -> return alt
+ _ -> do
+ let alt' = if null alt || alt == [Str ""]
+ then [Str $ "image" ++ show (length pics)]
+ else alt
+ modify $ \st -> st { stImages =
+ (alt', (attr,src,tit, mbtarget)):stImages st }
+ return alt'
+ inlineListToRST txt
+
+imageDimsToRST :: Attr -> State WriterState Doc
+imageDimsToRST attr = do
+ let (ident, _, _) = attr
+ name = if null ident
+ then empty
+ else ":name: " <> text ident
+ showDim dir = let cols d = ":" <> text (show dir) <> ": " <> text (show d)
+ in case (dimension dir attr) of
+ Just (Percent a) ->
+ case dir of
+ Height -> empty
+ Width -> cols (Percent a)
+ Just dim -> cols dim
+ Nothing -> empty
+ return $ cr <> name $$ showDim Width $$ showDim Height
diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs
new file mode 100644
index 000000000..ef012e58e
--- /dev/null
+++ b/src/Text/Pandoc/Writers/RTF.hs
@@ -0,0 +1,412 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+{-
+Copyright (C) 2006-2015 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.RTF
+ Copyright : Copyright (C) 2006-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to RTF (rich text format).
+-}
+module Text.Pandoc.Writers.RTF ( writeRTF
+ ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Text.Pandoc.Shared
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Writers.Math
+import Text.Pandoc.Templates (renderTemplate')
+import Text.Pandoc.Walk
+import Text.Pandoc.Logging
+import Data.List ( isSuffixOf, intercalate )
+import Data.Char ( ord, chr, isDigit )
+import qualified Data.ByteString as B
+import qualified Data.Map as M
+import Text.Printf ( printf )
+import Text.Pandoc.ImageSize
+import Control.Monad.Except (throwError, runExceptT, lift)
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad, report)
+import qualified Text.Pandoc.Class as P
+
+-- | Convert Image inlines into a raw RTF embedded image, read from a file,
+-- or a MediaBag, or the internet.
+-- If file not found or filetype not jpeg or png, leave the inline unchanged.
+rtfEmbedImage :: PandocMonad m => WriterOptions -> Inline -> m Inline
+rtfEmbedImage opts x@(Image attr _ (src,_)) = do
+ result <- runExceptT $ lift $ P.fetchItem (writerSourceURL opts) src
+ case result of
+ Right (imgdata, Just mime)
+ | mime == "image/jpeg" || mime == "image/png" -> do
+ let bytes = map (printf "%02x") $ B.unpack imgdata
+ filetype <- case mime of
+ "image/jpeg" -> return "\\jpegblip"
+ "image/png" -> return "\\pngblip"
+ _ -> throwError $ PandocSomeError "Unknown file type"
+ sizeSpec <- case imageSize imgdata of
+ Left msg -> do
+ report $ CouldNotDetermineImageSize src msg
+ return ""
+ Right sz -> return $ "\\picw" ++ show xpx ++
+ "\\pich" ++ show ypx ++
+ "\\picwgoal" ++ show (floor (xpt * 20) :: Integer)
+ ++ "\\pichgoal" ++ show (floor (ypt * 20) :: Integer)
+ -- twip = 1/1440in = 1/20pt
+ where (xpx, ypx) = sizeInPixels sz
+ (xpt, ypt) = desiredSizeInPoints opts attr sz
+ let raw = "{\\pict" ++ filetype ++ sizeSpec ++ "\\bin " ++
+ concat bytes ++ "}"
+ if B.null imgdata
+ then do
+ report $ CouldNotFetchResource src "image contained no data"
+ return x
+ else return $ RawInline (Format "rtf") raw
+ | otherwise -> do
+ report $ CouldNotFetchResource src "image is not a jpeg or png"
+ return x
+ Right (_, Nothing) -> do
+ report $ CouldNotDetermineMimeType src
+ return x
+ Left ( e :: PandocError ) -> do
+ report $ CouldNotFetchResource src (show e)
+ return x
+rtfEmbedImage _ x = return x
+
+-- | Convert Pandoc to a string in rich text format.
+writeRTF :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeRTF options doc = do
+ -- handle images
+ Pandoc meta@(Meta metamap) blocks <- walkM (rtfEmbedImage options) doc
+ let spacer = not $ all null $ docTitle meta : docDate meta : docAuthors meta
+ let toPlain (MetaBlocks [Para ils]) = MetaInlines ils
+ toPlain x = x
+ -- adjust title, author, date so we don't get para inside para
+ let meta' = Meta $ M.adjust toPlain "title"
+ . M.adjust toPlain "author"
+ . M.adjust toPlain "date"
+ $ metamap
+ metadata <- metaToJSON options
+ (fmap concat . mapM (blockToRTF 0 AlignDefault))
+ (inlinesToRTF)
+ meta'
+ body <- blocksToRTF 0 AlignDefault blocks
+ let isTOCHeader (Header lev _ _) = lev <= writerTOCDepth options
+ isTOCHeader _ = False
+ toc <- tableOfContents $ filter isTOCHeader blocks
+ let context = defField "body" body
+ $ defField "spacer" spacer
+ $ (if writerTableOfContents options
+ then defField "toc" toc
+ else id)
+ $ metadata
+ return $ case writerTemplate options of
+ Just tpl -> renderTemplate' tpl context
+ Nothing -> case reverse body of
+ ('\n':_) -> body
+ _ -> body ++ "\n"
+
+-- | Construct table of contents from list of header blocks.
+tableOfContents :: PandocMonad m => [Block] -> m String
+tableOfContents headers = do
+ let contents = map elementToListItem $ hierarchicalize headers
+ blocksToRTF 0 AlignDefault $
+ [Header 1 nullAttr [Str "Contents"], BulletList contents]
+
+elementToListItem :: Element -> [Block]
+elementToListItem (Blk _) = []
+elementToListItem (Sec _ _ _ sectext subsecs) = [Plain sectext] ++
+ if null subsecs
+ then []
+ else [BulletList (map elementToListItem subsecs)]
+
+-- | Convert unicode characters (> 127) into rich text format representation.
+handleUnicode :: String -> String
+handleUnicode [] = []
+handleUnicode (c:cs) =
+ if ord c > 127
+ then if surrogate c
+ then let x = ord c - 0x10000
+ (q, r) = x `divMod` 0x400
+ upper = q + 0xd800
+ lower = r + 0xDC00
+ in enc (chr upper) ++ enc (chr lower) ++ handleUnicode cs
+ else enc c ++ handleUnicode cs
+ else c:(handleUnicode cs)
+ where
+ surrogate x = not ( (0x0000 <= ord x && ord x <= 0xd7ff)
+ || (0xe000 <= ord x && ord x <= 0xffff) )
+ enc x = '\\':'u':(show (ord x)) ++ "?"
+
+-- | Escape special characters.
+escapeSpecial :: String -> String
+escapeSpecial = escapeStringUsing $
+ [ ('\t',"\\tab ")
+ , ('\8216',"\\u8216'")
+ , ('\8217',"\\u8217'")
+ , ('\8220',"\\u8220\"")
+ , ('\8221',"\\u8221\"")
+ , ('\8211',"\\u8211-")
+ , ('\8212',"\\u8212-")
+ ] ++ backslashEscapes "{\\}"
+
+-- | Escape strings as needed for rich text format.
+stringToRTF :: String -> String
+stringToRTF = handleUnicode . escapeSpecial
+
+-- | Escape things as needed for code block in RTF.
+codeStringToRTF :: String -> String
+codeStringToRTF str = intercalate "\\line\n" $ lines (stringToRTF str)
+
+-- | Make a paragraph with first-line indent, block indent, and space after.
+rtfParSpaced :: Int -- ^ space after (in twips)
+ -> Int -- ^ block indent (in twips)
+ -> Int -- ^ first line indent (relative to block) (in twips)
+ -> Alignment -- ^ alignment
+ -> String -- ^ string with content
+ -> String
+rtfParSpaced spaceAfter indent firstLineIndent alignment content =
+ let alignString = case alignment of
+ AlignLeft -> "\\ql "
+ AlignRight -> "\\qr "
+ AlignCenter -> "\\qc "
+ AlignDefault -> "\\ql "
+ in "{\\pard " ++ alignString ++
+ "\\f0 \\sa" ++ (show spaceAfter) ++ " \\li" ++ (show indent) ++
+ " \\fi" ++ (show firstLineIndent) ++ " " ++ content ++ "\\par}\n"
+
+-- | Default paragraph.
+rtfPar :: Int -- ^ block indent (in twips)
+ -> Int -- ^ first line indent (relative to block) (in twips)
+ -> Alignment -- ^ alignment
+ -> String -- ^ string with content
+ -> String
+rtfPar = rtfParSpaced 180
+
+-- | Compact paragraph (e.g. for compact list items).
+rtfCompact :: Int -- ^ block indent (in twips)
+ -> Int -- ^ first line indent (relative to block) (in twips)
+ -> Alignment -- ^ alignment
+ -> String -- ^ string with content
+ -> String
+rtfCompact = rtfParSpaced 0
+
+-- number of twips to indent
+indentIncrement :: Int
+indentIncrement = 720
+
+listIncrement :: Int
+listIncrement = 360
+
+-- | Returns appropriate bullet list marker for indent level.
+bulletMarker :: Int -> String
+bulletMarker indent = case indent `mod` 720 of
+ 0 -> "\\bullet "
+ _ -> "\\endash "
+
+-- | Returns appropriate (list of) ordered list markers for indent level.
+orderedMarkers :: Int -> ListAttributes -> [String]
+orderedMarkers indent (start, style, delim) =
+ if style == DefaultStyle && delim == DefaultDelim
+ then case indent `mod` 720 of
+ 0 -> orderedListMarkers (start, Decimal, Period)
+ _ -> orderedListMarkers (start, LowerAlpha, Period)
+ else orderedListMarkers (start, style, delim)
+
+blocksToRTF :: PandocMonad m
+ => Int
+ -> Alignment
+ -> [Block]
+ -> m String
+blocksToRTF indent align = fmap concat . mapM (blockToRTF indent align)
+
+-- | Convert Pandoc block element to RTF.
+blockToRTF :: PandocMonad m
+ => Int -- ^ indent level
+ -> Alignment -- ^ alignment
+ -> Block -- ^ block to convert
+ -> m String
+blockToRTF _ _ Null = return ""
+blockToRTF indent alignment (Div _ bs) =
+ blocksToRTF indent alignment bs
+blockToRTF indent alignment (Plain lst) =
+ rtfCompact indent 0 alignment <$> inlinesToRTF lst
+blockToRTF indent alignment (Para lst) =
+ rtfPar indent 0 alignment <$> inlinesToRTF lst
+blockToRTF indent alignment (LineBlock lns) =
+ blockToRTF indent alignment $ linesToPara lns
+blockToRTF indent alignment (BlockQuote lst) =
+ blocksToRTF (indent + indentIncrement) alignment lst
+blockToRTF indent _ (CodeBlock _ str) =
+ return $ rtfPar indent 0 AlignLeft ("\\f1 " ++ (codeStringToRTF str))
+blockToRTF _ _ b@(RawBlock f str)
+ | f == Format "rtf" = return str
+ | otherwise = do
+ report $ BlockNotRendered b
+ return ""
+blockToRTF indent alignment (BulletList lst) = (spaceAtEnd . concat) <$>
+ mapM (listItemToRTF alignment indent (bulletMarker indent)) lst
+blockToRTF indent alignment (OrderedList attribs lst) =
+ (spaceAtEnd . concat) <$>
+ mapM (\(x,y) -> listItemToRTF alignment indent x y)
+ (zip (orderedMarkers indent attribs) lst)
+blockToRTF indent alignment (DefinitionList lst) = (spaceAtEnd . concat) <$>
+ mapM (definitionListItemToRTF alignment indent) lst
+blockToRTF indent _ HorizontalRule = return $
+ rtfPar indent 0 AlignCenter "\\emdash\\emdash\\emdash\\emdash\\emdash"
+blockToRTF indent alignment (Header level _ lst) = do
+ contents <- inlinesToRTF lst
+ return $ rtfPar indent 0 alignment $
+ "\\b \\fs" ++ (show (40 - (level * 4))) ++ " " ++ contents
+blockToRTF indent alignment (Table caption aligns sizes headers rows) = do
+ caption' <- inlinesToRTF caption
+ header' <- if all null headers
+ then return ""
+ else tableRowToRTF True indent aligns sizes headers
+ rows' <- concat <$> mapM (tableRowToRTF False indent aligns sizes) rows
+ return $ header' ++ rows' ++ rtfPar indent 0 alignment caption'
+
+tableRowToRTF :: PandocMonad m
+ => Bool -> Int -> [Alignment] -> [Double] -> [[Block]] -> m String
+tableRowToRTF header indent aligns sizes' cols = do
+ let totalTwips = 6 * 1440 -- 6 inches
+ let sizes = if all (== 0) sizes'
+ then take (length cols) $ repeat (1.0 / fromIntegral (length cols))
+ else sizes'
+ columns <- concat <$> mapM (\(x,y) -> tableItemToRTF indent x y)
+ (zip aligns cols)
+ let rightEdges = tail $ scanl (\sofar new -> sofar + floor (new * totalTwips))
+ (0 :: Integer) sizes
+ let cellDefs = map (\edge -> (if header
+ then "\\clbrdrb\\brdrs"
+ else "") ++ "\\cellx" ++ show edge)
+ rightEdges
+ let start = "{\n\\trowd \\trgaph120\n" ++ concat cellDefs ++ "\n" ++
+ "\\trkeep\\intbl\n{\n"
+ let end = "}\n\\intbl\\row}\n"
+ return $ start ++ columns ++ end
+
+tableItemToRTF :: PandocMonad m => Int -> Alignment -> [Block] -> m String
+tableItemToRTF indent alignment item = do
+ contents <- blocksToRTF indent alignment item
+ return $ "{" ++ substitute "\\pard" "\\pard\\intbl" contents ++ "\\cell}\n"
+
+-- | Ensure that there's the same amount of space after compact
+-- lists as after regular lists.
+spaceAtEnd :: String -> String
+spaceAtEnd str =
+ if isSuffixOf "\\par}\n" str
+ then (take ((length str) - 6) str) ++ "\\sa180\\par}\n"
+ else str
+
+-- | Convert list item (list of blocks) to RTF.
+listItemToRTF :: PandocMonad m
+ => Alignment -- ^ alignment
+ -> Int -- ^ indent level
+ -> String -- ^ list start marker
+ -> [Block] -- ^ list item (list of blocks)
+ -> m String
+listItemToRTF alignment indent marker [] = return $
+ rtfCompact (indent + listIncrement) (0 - listIncrement) alignment
+ (marker ++ "\\tx" ++ (show listIncrement) ++ "\\tab ")
+listItemToRTF alignment indent marker list = do
+ (first:rest) <- mapM (blockToRTF (indent + listIncrement) alignment) list
+ let listMarker = "\\fi" ++ show (0 - listIncrement) ++ " " ++ marker ++
+ "\\tx" ++ show listIncrement ++ "\\tab"
+ let insertListMarker ('\\':'f':'i':'-':d:xs) | isDigit d =
+ listMarker ++ dropWhile isDigit xs
+ insertListMarker ('\\':'f':'i':d:xs) | isDigit d =
+ listMarker ++ dropWhile isDigit xs
+ insertListMarker (x:xs) =
+ x : insertListMarker xs
+ insertListMarker [] = []
+ -- insert the list marker into the (processed) first block
+ return $ insertListMarker first ++ concat rest
+
+-- | Convert definition list item (label, list of blocks) to RTF.
+definitionListItemToRTF :: PandocMonad m
+ => Alignment -- ^ alignment
+ -> Int -- ^ indent level
+ -> ([Inline],[[Block]]) -- ^ list item (list of blocks)
+ -> m String
+definitionListItemToRTF alignment indent (label, defs) = do
+ labelText <- blockToRTF indent alignment (Plain label)
+ itemsText <- blocksToRTF (indent + listIncrement) alignment (concat defs)
+ return $ labelText ++ itemsText
+
+-- | Convert list of inline items to RTF.
+inlinesToRTF :: PandocMonad m
+ => [Inline] -- ^ list of inlines to convert
+ -> m String
+inlinesToRTF lst = concat <$> mapM inlineToRTF lst
+
+-- | Convert inline item to RTF.
+inlineToRTF :: PandocMonad m
+ => Inline -- ^ inline to convert
+ -> m String
+inlineToRTF (Span _ lst) = inlinesToRTF lst
+inlineToRTF (Emph lst) = do
+ contents <- inlinesToRTF lst
+ return $ "{\\i " ++ contents ++ "}"
+inlineToRTF (Strong lst) = do
+ contents <- inlinesToRTF lst
+ return $ "{\\b " ++ contents ++ "}"
+inlineToRTF (Strikeout lst) = do
+ contents <- inlinesToRTF lst
+ return $ "{\\strike " ++ contents ++ "}"
+inlineToRTF (Superscript lst) = do
+ contents <- inlinesToRTF lst
+ return $ "{\\super " ++ contents ++ "}"
+inlineToRTF (Subscript lst) = do
+ contents <- inlinesToRTF lst
+ return $ "{\\sub " ++ contents ++ "}"
+inlineToRTF (SmallCaps lst) = do
+ contents <- inlinesToRTF lst
+ return $ "{\\scaps " ++ contents ++ "}"
+inlineToRTF (Quoted SingleQuote lst) = do
+ contents <- inlinesToRTF lst
+ return $ "\\u8216'" ++ contents ++ "\\u8217'"
+inlineToRTF (Quoted DoubleQuote lst) = do
+ contents <- inlinesToRTF lst
+ return $ "\\u8220\"" ++ contents ++ "\\u8221\""
+inlineToRTF (Code _ str) = return $ "{\\f1 " ++ (codeStringToRTF str) ++ "}"
+inlineToRTF (Str str) = return $ stringToRTF str
+inlineToRTF (Math t str) = texMathToInlines t str >>= inlinesToRTF
+inlineToRTF (Cite _ lst) = inlinesToRTF lst
+inlineToRTF il@(RawInline f str)
+ | f == Format "rtf" = return str
+ | otherwise = do
+ return $ InlineNotRendered il
+ return ""
+inlineToRTF (LineBreak) = return "\\line "
+inlineToRTF SoftBreak = return " "
+inlineToRTF Space = return " "
+inlineToRTF (Link _ text (src, _)) = do
+ contents <- inlinesToRTF text
+ return $ "{\\field{\\*\\fldinst{HYPERLINK \"" ++ (codeStringToRTF src) ++
+ "\"}}{\\fldrslt{\\ul\n" ++ contents ++ "\n}}}\n"
+inlineToRTF (Image _ _ (source, _)) =
+ return $ "{\\cf1 [image: " ++ source ++ "]\\cf0}"
+inlineToRTF (Note contents) = do
+ body <- concat <$> mapM (blockToRTF 0 AlignDefault) contents
+ return $ "{\\super\\chftn}{\\*\\footnote\\chftn\\~\\plain\\pard " ++
+ body ++ "}"
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs
new file mode 100644
index 000000000..89a826269
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Shared.hs
@@ -0,0 +1,183 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-
+Copyright (C) 2013-2015 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.Shared
+ Copyright : Copyright (C) 2013-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Shared utility functions for pandoc writers.
+-}
+module Text.Pandoc.Writers.Shared (
+ metaToJSON
+ , getField
+ , setField
+ , defField
+ , tagWithAttrs
+ , fixDisplayMath
+ , unsmartify
+ )
+where
+import Text.Pandoc.Definition
+import Text.Pandoc.Pretty
+import Text.Pandoc.Options
+import Text.Pandoc.XML (escapeStringForXML)
+import Control.Monad (liftM)
+import qualified Data.HashMap.Strict as H
+import qualified Data.Map as M
+import qualified Data.Text as T
+import Data.Aeson (FromJSON(..), fromJSON, ToJSON (..), Value(Object), Result(..), encode)
+import Text.Pandoc.UTF8 (toStringLazy)
+import qualified Data.Traversable as Traversable
+import Data.List ( groupBy )
+import Data.Maybe ( isJust )
+
+-- | Create JSON value for template from a 'Meta' and an association list
+-- of variables, specified at the command line or in the writer.
+-- Variables overwrite metadata fields with the same names.
+-- If multiple variables are set with the same name, a list is
+-- assigned.
+metaToJSON :: Monad m
+ => WriterOptions
+ -> ([Block] -> m String)
+ -> ([Inline] -> m String)
+ -> Meta
+ -> m Value
+metaToJSON opts blockWriter inlineWriter (Meta metamap)
+ | isJust (writerTemplate opts) = do
+ let baseContext = foldl (\acc (x,y) -> setField x y acc) (Object H.empty)
+ $ writerVariables opts
+ renderedMap <- Traversable.mapM
+ (metaValueToJSON blockWriter inlineWriter)
+ metamap
+ let metadata = M.foldWithKey defField baseContext renderedMap
+ return $ defField "meta-json" (toStringLazy $ encode metadata) metadata
+ | otherwise = return (Object H.empty)
+
+metaValueToJSON :: Monad m
+ => ([Block] -> m String)
+ -> ([Inline] -> m String)
+ -> MetaValue
+ -> m Value
+metaValueToJSON blockWriter inlineWriter (MetaMap metamap) = liftM toJSON $
+ Traversable.mapM (metaValueToJSON blockWriter inlineWriter) metamap
+metaValueToJSON blockWriter inlineWriter (MetaList xs) = liftM toJSON $
+ Traversable.mapM (metaValueToJSON blockWriter inlineWriter) xs
+metaValueToJSON _ _ (MetaBool b) = return $ toJSON b
+metaValueToJSON _ _ (MetaString s) = return $ toJSON s
+metaValueToJSON blockWriter _ (MetaBlocks bs) = liftM toJSON $ blockWriter bs
+metaValueToJSON _ inlineWriter (MetaInlines bs) = liftM toJSON $ inlineWriter bs
+
+-- | Retrieve a field value from a JSON object.
+getField :: FromJSON a
+ => String
+ -> Value
+ -> Maybe a
+getField field (Object hashmap) = do
+ result <- H.lookup (T.pack field) hashmap
+ case fromJSON result of
+ Success x -> return x
+ _ -> fail "Could not convert from JSON"
+getField _ _ = fail "Not a JSON object"
+
+setField :: ToJSON a
+ => String
+ -> a
+ -> Value
+ -> Value
+-- | Set a field of a JSON object. If the field already has a value,
+-- convert it into a list with the new value appended to the old value(s).
+-- This is a utility function to be used in preparing template contexts.
+setField field val (Object hashmap) =
+ Object $ H.insertWith combine (T.pack field) (toJSON val) hashmap
+ where combine newval oldval =
+ case fromJSON oldval of
+ Success xs -> toJSON $ xs ++ [newval]
+ _ -> toJSON [oldval, newval]
+setField _ _ x = x
+
+defField :: ToJSON a
+ => String
+ -> a
+ -> Value
+ -> Value
+-- | Set a field of a JSON object if it currently has no value.
+-- If it has a value, do nothing.
+-- This is a utility function to be used in preparing template contexts.
+defField field val (Object hashmap) =
+ Object $ H.insertWith f (T.pack field) (toJSON val) hashmap
+ where f _newval oldval = oldval
+defField _ _ x = x
+
+-- Produce an HTML tag with the given pandoc attributes.
+tagWithAttrs :: String -> Attr -> Doc
+tagWithAttrs tag (ident,classes,kvs) = hsep
+ ["<" <> text tag
+ ,if null ident
+ then empty
+ else "id=" <> doubleQuotes (text ident)
+ ,if null classes
+ then empty
+ else "class=" <> doubleQuotes (text (unwords classes))
+ ,hsep (map (\(k,v) -> text k <> "=" <>
+ doubleQuotes (text (escapeStringForXML v))) kvs)
+ ] <> ">"
+
+isDisplayMath :: Inline -> Bool
+isDisplayMath (Math DisplayMath _) = True
+isDisplayMath _ = False
+
+stripLeadingTrailingSpace :: [Inline] -> [Inline]
+stripLeadingTrailingSpace = go . reverse . go . reverse
+ where go (Space:xs) = xs
+ go (SoftBreak:xs) = xs
+ go xs = xs
+
+-- Put display math in its own block (for ODT/DOCX).
+fixDisplayMath :: Block -> Block
+fixDisplayMath (Plain lst)
+ | any isDisplayMath lst && not (all isDisplayMath lst) =
+ -- chop into several paragraphs so each displaymath is its own
+ Div ("",["math"],[]) $ map (Plain . stripLeadingTrailingSpace) $
+ groupBy (\x y -> (isDisplayMath x && isDisplayMath y) ||
+ not (isDisplayMath x || isDisplayMath y)) lst
+fixDisplayMath (Para lst)
+ | any isDisplayMath lst && not (all isDisplayMath lst) =
+ -- chop into several paragraphs so each displaymath is its own
+ Div ("",["math"],[]) $ map (Para . stripLeadingTrailingSpace) $
+ groupBy (\x y -> (isDisplayMath x && isDisplayMath y) ||
+ not (isDisplayMath x || isDisplayMath y)) lst
+fixDisplayMath x = x
+
+unsmartify :: WriterOptions -> String -> String
+unsmartify opts ('\8217':xs) = '\'' : unsmartify opts xs
+unsmartify opts ('\8230':xs) = "..." ++ unsmartify opts xs
+unsmartify opts ('\8211':xs)
+ | isEnabled Ext_old_dashes opts = '-' : unsmartify opts xs
+ | otherwise = "--" ++ unsmartify opts xs
+unsmartify opts ('\8212':xs)
+ | isEnabled Ext_old_dashes opts = "--" ++ unsmartify opts xs
+ | otherwise = "---" ++ unsmartify opts xs
+unsmartify opts (x:xs) = x : unsmartify opts xs
+unsmartify _ [] = []
+
diff --git a/src/Text/Pandoc/Writers/TEI.hs b/src/Text/Pandoc/Writers/TEI.hs
new file mode 100644
index 000000000..a54d42c53
--- /dev/null
+++ b/src/Text/Pandoc/Writers/TEI.hs
@@ -0,0 +1,324 @@
+{-# LANGUAGE OverloadedStrings, PatternGuards #-}
+{-
+Copyright (C) 2006-2015 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.Docbook
+ Copyright : Copyright (C) 2006-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to Docbook XML.
+-}
+module Text.Pandoc.Writers.TEI (writeTEI) where
+import Text.Pandoc.Definition
+import Text.Pandoc.XML
+import Text.Pandoc.Shared
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Options
+import Text.Pandoc.Templates (renderTemplate')
+import Data.List ( stripPrefix, isPrefixOf )
+import Data.Char ( toLower )
+import Text.Pandoc.Highlighting ( languages, languagesByExtension )
+import Text.Pandoc.Pretty
+import Text.Pandoc.ImageSize
+import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.Class ( PandocMonad )
+
+-- | Convert list of authors to a docbook <author> section
+authorToTEI :: WriterOptions -> [Inline] -> B.Inlines
+authorToTEI opts name' =
+ let name = render Nothing $ inlinesToTEI opts name'
+ colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ in B.rawInline "tei" $ render colwidth $
+ inTagsSimple "author" (text $ escapeStringForXML name)
+
+-- | Convert Pandoc document to string in Docbook format.
+writeTEI :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeTEI opts (Pandoc meta blocks) = return $
+ let elements = hierarchicalize blocks
+ colwidth = if writerWrapText opts == WrapAuto
+ then Just $ writerColumns opts
+ else Nothing
+ render' = render colwidth
+ startLvl = case writerTopLevelDivision opts of
+ TopLevelPart -> -1
+ TopLevelChapter -> 0
+ TopLevelSection -> 1
+ TopLevelDefault -> 1
+ auths' = map (authorToTEI opts) $ docAuthors meta
+ meta' = B.setMeta "author" auths' meta
+ Just metadata = metaToJSON opts
+ (Just . render colwidth . (vcat .
+ (map (elementToTEI opts startLvl)) . hierarchicalize))
+ (Just . render colwidth . inlinesToTEI opts)
+ meta'
+ main = render' $ vcat (map (elementToTEI opts startLvl) elements)
+ context = defField "body" main
+ $ defField "mathml" (case writerHTMLMathMethod opts of
+ MathML -> True
+ _ -> False)
+ $ metadata
+ in case writerTemplate opts of
+ Nothing -> main
+ Just tpl -> renderTemplate' tpl context
+
+-- | Convert an Element to TEI.
+elementToTEI :: WriterOptions -> Int -> Element -> Doc
+elementToTEI opts _ (Blk block) = blockToTEI opts block
+elementToTEI opts lvl (Sec _ _num (id',_,_) title elements) =
+ -- TEI doesn't allow sections with no content, so insert some if needed
+ let elements' = if null elements
+ then [Blk (Para [])]
+ else elements
+ -- level numbering correspond to LaTeX internals
+ divType = case lvl of
+ n | n == -1 -> "part"
+ | n == 0 -> "chapter"
+ | n >= 1 && n <= 5 -> "level" ++ show n
+ | otherwise -> "section"
+ in inTags True "div" [("type", divType) | not (null id')] $
+-- ("id", writerIdentifierPrefix opts ++ id') | not (null id')] $
+ inTagsSimple "head" (inlinesToTEI opts title) $$
+ vcat (map (elementToTEI opts (lvl + 1)) elements')
+
+-- | Convert a list of Pandoc blocks to TEI.
+blocksToTEI :: WriterOptions -> [Block] -> Doc
+blocksToTEI opts = vcat . map (blockToTEI opts)
+
+-- | Auxiliary function to convert Plain block to Para.
+plainToPara :: Block -> Block
+plainToPara (Plain x) = Para x
+plainToPara x = x
+
+-- | Convert a list of pairs of terms and definitions into a TEI
+-- list with labels and items.
+deflistItemsToTEI :: WriterOptions -> [([Inline],[[Block]])] -> Doc
+deflistItemsToTEI opts items =
+ vcat $ map (\(term, defs) -> deflistItemToTEI opts term defs) items
+
+-- | Convert a term and a list of blocks into a TEI varlistentry.
+deflistItemToTEI :: WriterOptions -> [Inline] -> [[Block]] -> Doc
+deflistItemToTEI opts term defs =
+ let def' = concatMap (map plainToPara) defs
+ in inTagsIndented "label" (inlinesToTEI opts term) $$
+ inTagsIndented "item" (blocksToTEI opts def')
+
+-- | Convert a list of lists of blocks to a list of TEI list items.
+listItemsToTEI :: WriterOptions -> [[Block]] -> Doc
+listItemsToTEI opts items = vcat $ map (listItemToTEI opts) items
+
+-- | Convert a list of blocks into a TEI list item.
+listItemToTEI :: WriterOptions -> [Block] -> Doc
+listItemToTEI opts item =
+ inTagsIndented "item" $ blocksToTEI opts $ map plainToPara item
+
+imageToTEI :: WriterOptions -> Attr -> String -> Doc
+imageToTEI _ attr src = selfClosingTag "graphic" $
+ ("url", src) : idAndRole attr ++ dims
+ where
+ dims = go Width "width" ++ go Height "depth"
+ go dir dstr = case (dimension dir attr) of
+ Just a -> [(dstr, show a)]
+ Nothing -> []
+
+-- | Convert a Pandoc block element to TEI.
+blockToTEI :: WriterOptions -> Block -> Doc
+blockToTEI _ Null = empty
+-- Add ids to paragraphs in divs with ids - this is needed for
+-- pandoc-citeproc to get link anchors in bibliographies:
+blockToTEI opts (Div (ident,_,_) [Para lst]) =
+ let attribs = [("id", ident) | not (null ident)] in
+ inTags False "p" attribs $ inlinesToTEI opts lst
+blockToTEI opts (Div _ bs) = blocksToTEI opts $ map plainToPara bs
+blockToTEI _ (Header _ _ _) = empty -- should not occur after hierarchicalize
+-- For TEI simple, text must be within containing block element, so
+-- we use plainToPara to ensure that Plain text ends up contained by
+-- something.
+blockToTEI opts (Plain lst) = blockToTEI opts $ Para lst
+-- title beginning with fig: indicates that the image is a figure
+--blockToTEI opts (Para [Image attr txt (src,'f':'i':'g':':':_)]) =
+-- let alt = inlinesToTEI opts txt
+-- capt = if null txt
+-- then empty
+-- else inTagsSimple "title" alt
+-- in inTagsIndented "figure" $
+-- capt $$
+-- (inTagsIndented "mediaobject" $
+-- (inTagsIndented "imageobject"
+-- (imageToTEI opts attr src)) $$
+-- inTagsSimple "textobject" (inTagsSimple "phrase" alt))
+blockToTEI opts (Para lst) =
+ inTags False "p" [] $ inlinesToTEI opts lst
+blockToTEI opts (LineBlock lns) =
+ blockToTEI opts $ linesToPara lns
+blockToTEI opts (BlockQuote blocks) =
+ inTagsIndented "quote" $ blocksToTEI opts blocks
+blockToTEI _ (CodeBlock (_,classes,_) str) =
+ text ("<ab type='codeblock " ++ lang ++ "'>") <> cr <>
+ flush (text (escapeStringForXML str) <> cr <> text "</ab>")
+ where lang = if null langs
+ then ""
+ else escapeStringForXML (head langs)
+ isLang l = map toLower l `elem` map (map toLower) languages
+ langsFrom s = if isLang s
+ then [s]
+ else languagesByExtension . map toLower $ s
+ langs = concatMap langsFrom classes
+blockToTEI opts (BulletList lst) =
+ let attribs = [("type", "unordered")]
+ in inTags True "list" attribs $ listItemsToTEI opts lst
+blockToTEI _ (OrderedList _ []) = empty
+blockToTEI opts (OrderedList (start, numstyle, _) (first:rest)) =
+ let attribs = case numstyle of
+ DefaultStyle -> []
+ Decimal -> [("type", "ordered:arabic")]
+ Example -> [("type", "ordered:arabic")]
+ UpperAlpha -> [("type", "ordered:upperalpha")]
+ LowerAlpha -> [("type", "ordered:loweralpha")]
+ UpperRoman -> [("type", "ordered:upperroman")]
+ LowerRoman -> [("type", "ordered:lowerroman")]
+ items = if start == 1
+ then listItemsToTEI opts (first:rest)
+ else (inTags True "item" [("n",show start)]
+ (blocksToTEI opts $ map plainToPara first)) $$
+ listItemsToTEI opts rest
+ in inTags True "list" attribs items
+blockToTEI opts (DefinitionList lst) =
+ let attribs = [("type", "definition")]
+ in inTags True "list" attribs $ deflistItemsToTEI opts lst
+blockToTEI _ (RawBlock f str)
+ | f == "tei" = text str -- raw TEI block (should such a thing exist).
+-- | f == "html" = text str -- allow html for backwards compatibility
+ | otherwise = empty
+blockToTEI _ HorizontalRule =
+ selfClosingTag "milestone" [("unit","undefined"), ("type","separator"),("rendition","line")]
+
+-- | TEI Tables
+-- TEI Simple's tables are composed of cells and rows; other
+-- table info in the AST is here lossily discard.
+blockToTEI opts (Table _ _ _ headers rows) =
+ let
+ headers' = tableHeadersToTEI opts headers
+-- headers' = if all null headers
+-- then return empty
+-- else tableRowToTEI opts headers
+ in
+ inTags True "table" [] $
+ vcat $ [headers'] <> map (tableRowToTEI opts) rows
+
+tableRowToTEI :: WriterOptions
+ -> [[Block]]
+ -> Doc
+tableRowToTEI opts cols =
+ inTagsIndented "row" $ vcat $ map (tableItemToTEI opts) cols
+
+tableHeadersToTEI :: WriterOptions
+ -> [[Block]]
+ -> Doc
+tableHeadersToTEI opts cols =
+ inTags True "row" [("role","label")] $ vcat $ map (tableItemToTEI opts) cols
+
+tableItemToTEI :: WriterOptions
+ -> [Block]
+ -> Doc
+tableItemToTEI opts item =
+ inTags False "cell" [] $ vcat $ map (blockToTEI opts) item
+
+-- | Convert a list of inline elements to TEI.
+inlinesToTEI :: WriterOptions -> [Inline] -> Doc
+inlinesToTEI opts lst = hcat $ map (inlineToTEI opts) lst
+
+-- | Convert an inline element to TEI.
+inlineToTEI :: WriterOptions -> Inline -> Doc
+inlineToTEI _ (Str str) = text $ escapeStringForXML str
+inlineToTEI opts (Emph lst) =
+ inTags False "hi" [("rendition","simple:italic")] $ inlinesToTEI opts lst
+inlineToTEI opts (Strong lst) =
+ inTags False "hi" [("rendition", "simple:bold")] $ inlinesToTEI opts lst
+inlineToTEI opts (Strikeout lst) =
+ inTags False "hi" [("rendition", "simple:strikethrough")] $
+ inlinesToTEI opts lst
+inlineToTEI opts (Superscript lst) =
+ inTags False "hi" [("rendition", "simple:superscript")] $ inlinesToTEI opts lst
+inlineToTEI opts (Subscript lst) =
+ inTags False "hi" [("rendition", "simple:subscript")] $ inlinesToTEI opts lst
+inlineToTEI opts (SmallCaps lst) =
+ inTags False "hi" [("rendition", "simple:smallcaps")] $
+ inlinesToTEI opts lst
+inlineToTEI opts (Quoted _ lst) =
+ inTagsSimple "quote" $ inlinesToTEI opts lst
+inlineToTEI opts (Cite _ lst) =
+ inlinesToTEI opts lst
+inlineToTEI opts (Span _ ils) =
+ inlinesToTEI opts ils
+inlineToTEI _ (Code _ str) =
+ inTags False "seg" [("type","code")] $ text (escapeStringForXML str)
+-- Distinguish display from inline math by wrapping the former in a "figure."
+inlineToTEI _ (Math t str) =
+ case t of
+ InlineMath -> inTags False "formula" [("notation","TeX")] $
+ text (str)
+ DisplayMath -> inTags True "figure" [("type","math")] $
+ inTags False "formula" [("notation","TeX")] $ text (str)
+
+inlineToTEI _ (RawInline f x) | f == "tei" = text x
+ | otherwise = empty
+inlineToTEI _ LineBreak = selfClosingTag "lb" []
+inlineToTEI _ Space = space
+-- because we use \n for LineBreak, we can't do soft breaks:
+inlineToTEI _ SoftBreak = space
+inlineToTEI opts (Link attr txt (src, _))
+ | Just email <- stripPrefix "mailto:" src =
+ let emailLink = text $
+ escapeStringForXML $ email
+ in case txt of
+ [Str s] | escapeURI s == email -> emailLink
+ _ -> inlinesToTEI opts txt <+>
+ char '(' <> emailLink <> char ')'
+ | otherwise =
+ (if isPrefixOf "#" src
+ then inTags False "ref" $ ("target", drop 1 src) : idAndRole attr
+ else inTags False "ref" $ ("target", src) : idAndRole attr ) $
+ inlinesToTEI opts txt
+inlineToTEI opts (Image attr description (src, tit)) =
+ let titleDoc = if null tit
+ then empty
+ else inTags False "figDesc" [] (text $ escapeStringForXML tit)
+ imageDesc = if null description
+ then empty
+ else inTags False "head" [] (inlinesToTEI opts description)
+ in inTagsIndented "figure" $ imageDesc $$
+ imageToTEI opts attr src $$ titleDoc
+inlineToTEI opts (Note contents) =
+ inTagsIndented "note" $ blocksToTEI opts contents
+
+idAndRole :: Attr -> [(String, String)]
+idAndRole (id',cls,_) = ident ++ role
+ where
+ ident = if null id'
+ then []
+ else [("id", id')]
+ role = if null cls
+ then []
+ else [("role", unwords cls)]
diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs
new file mode 100644
index 000000000..fe6024351
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Texinfo.hs
@@ -0,0 +1,498 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-
+Copyright (C) 2008-2015 John MacFarlane and Peter Wang
+
+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.Texinfo
+ Copyright : Copyright (C) 2008-2015 John MacFarlane and Peter Wang
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' format into Texinfo.
+-}
+module Text.Pandoc.Writers.Texinfo ( writeTexinfo ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Text.Pandoc.Shared
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Templates (renderTemplate')
+import Text.Printf ( printf )
+import Data.List ( transpose, maximumBy )
+import Data.Ord ( comparing )
+import Data.Char ( chr, ord )
+import Control.Monad.State
+import Text.Pandoc.Pretty
+import Text.Pandoc.ImageSize
+import Network.URI ( isURI, unEscapeString )
+import System.FilePath
+import qualified Data.Set as Set
+import Control.Monad.Except (throwError)
+import Text.Pandoc.Error
+import Text.Pandoc.Class (PandocMonad, report)
+import Text.Pandoc.Logging
+
+data WriterState =
+ WriterState { stStrikeout :: Bool -- document contains strikeout
+ , stSuperscript :: Bool -- document contains superscript
+ , stSubscript :: Bool -- document contains subscript
+ , stEscapeComma :: Bool -- in a context where we need @comma
+ , stIdentifiers :: Set.Set String -- header ids used already
+ , stOptions :: WriterOptions -- writer options
+ }
+
+{- TODO:
+ - internal cross references a la HTML
+ - generated .texi files don't work when run through texi2dvi
+ -}
+
+type TI m = StateT WriterState m
+
+-- | Convert Pandoc to Texinfo.
+writeTexinfo :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeTexinfo options document =
+ evalStateT (pandocToTexinfo options $ wrapTop document) $
+ WriterState { stStrikeout = False, stSuperscript = False,
+ stEscapeComma = False, stSubscript = False,
+ stIdentifiers = Set.empty, stOptions = options}
+
+-- | Add a "Top" node around the document, needed by Texinfo.
+wrapTop :: Pandoc -> Pandoc
+wrapTop (Pandoc meta blocks) =
+ Pandoc meta (Header 0 nullAttr (docTitle meta) : blocks)
+
+pandocToTexinfo :: PandocMonad m => WriterOptions -> Pandoc -> TI m String
+pandocToTexinfo options (Pandoc meta blocks) = do
+ let titlePage = not $ all null
+ $ docTitle meta : docDate meta : docAuthors meta
+ let colwidth = if writerWrapText options == WrapAuto
+ then Just $ writerColumns options
+ else Nothing
+ metadata <- metaToJSON options
+ (fmap (render colwidth) . blockListToTexinfo)
+ (fmap (render colwidth) . inlineListToTexinfo)
+ meta
+ main <- blockListToTexinfo blocks
+ st <- get
+ let body = render colwidth main
+ let context = defField "body" body
+ $ defField "toc" (writerTableOfContents options)
+ $ defField "titlepage" titlePage
+ $ defField "subscript" (stSubscript st)
+ $ defField "superscript" (stSuperscript st)
+ $ defField "strikeout" (stStrikeout st)
+ $ metadata
+ case writerTemplate options of
+ Nothing -> return body
+ Just tpl -> return $ renderTemplate' tpl context
+
+-- | Escape things as needed for Texinfo.
+stringToTexinfo :: String -> String
+stringToTexinfo = escapeStringUsing texinfoEscapes
+ where texinfoEscapes = [ ('{', "@{")
+ , ('}', "@}")
+ , ('@', "@@")
+ , ('\160', "@ ")
+ , ('\x2014', "---")
+ , ('\x2013', "--")
+ , ('\x2026', "@dots{}")
+ , ('\x2019', "'")
+ ]
+
+escapeCommas :: PandocMonad m => TI m Doc -> TI m Doc
+escapeCommas parser = do
+ oldEscapeComma <- gets stEscapeComma
+ modify $ \st -> st{ stEscapeComma = True }
+ res <- parser
+ modify $ \st -> st{ stEscapeComma = oldEscapeComma }
+ return res
+
+-- | Puts contents into Texinfo command.
+inCmd :: String -> Doc -> Doc
+inCmd cmd contents = char '@' <> text cmd <> braces contents
+
+-- | Convert Pandoc block element to Texinfo.
+blockToTexinfo :: PandocMonad m
+ => Block -- ^ Block to convert
+ -> TI m Doc
+
+blockToTexinfo Null = return empty
+
+blockToTexinfo (Div _ bs) = blockListToTexinfo bs
+
+blockToTexinfo (Plain lst) =
+ inlineListToTexinfo lst
+
+-- title beginning with fig: indicates that the image is a figure
+blockToTexinfo (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
+ capt <- if null txt
+ then return empty
+ else (\c -> text "@caption" <> braces c) `fmap`
+ inlineListToTexinfo txt
+ img <- inlineToTexinfo (Image attr txt (src,tit))
+ return $ text "@float" $$ img $$ capt $$ text "@end float"
+
+blockToTexinfo (Para lst) =
+ inlineListToTexinfo lst -- this is handled differently from Plain in blockListToTexinfo
+
+blockToTexinfo (LineBlock lns) =
+ blockToTexinfo $ linesToPara lns
+
+blockToTexinfo (BlockQuote lst) = do
+ contents <- blockListToTexinfo lst
+ return $ text "@quotation" $$
+ contents $$
+ text "@end quotation"
+
+blockToTexinfo (CodeBlock _ str) = do
+ return $ blankline $$
+ text "@verbatim" $$
+ flush (text str) $$
+ text "@end verbatim" <> blankline
+
+blockToTexinfo b@(RawBlock f str)
+ | f == "texinfo" = return $ text str
+ | f == "latex" || f == "tex" =
+ return $ text "@tex" $$ text str $$ text "@end tex"
+ | otherwise = do
+ report $ BlockNotRendered b
+ return empty
+
+blockToTexinfo (BulletList lst) = do
+ items <- mapM listItemToTexinfo lst
+ return $ text "@itemize" $$
+ vcat items $$
+ text "@end itemize" <> blankline
+
+blockToTexinfo (OrderedList (start, numstyle, _) lst) = do
+ items <- mapM listItemToTexinfo lst
+ return $ text "@enumerate " <> exemplar $$
+ vcat items $$
+ text "@end enumerate" <> blankline
+ where
+ exemplar = case numstyle of
+ DefaultStyle -> decimal
+ Decimal -> decimal
+ Example -> decimal
+ UpperRoman -> decimal -- Roman numerals not supported
+ LowerRoman -> decimal
+ UpperAlpha -> upperAlpha
+ LowerAlpha -> lowerAlpha
+ decimal = if start == 1
+ then empty
+ else text (show start)
+ upperAlpha = text [chr $ ord 'A' + start - 1]
+ lowerAlpha = text [chr $ ord 'a' + start - 1]
+
+blockToTexinfo (DefinitionList lst) = do
+ items <- mapM defListItemToTexinfo lst
+ return $ text "@table @asis" $$
+ vcat items $$
+ text "@end table" <> blankline
+
+blockToTexinfo HorizontalRule =
+ -- XXX can't get the equivalent from LaTeX.hs to work
+ return $ text "@iftex" $$
+ text "@bigskip@hrule@bigskip" $$
+ text "@end iftex" $$
+ text "@ifnottex" $$
+ text (take 72 $ repeat '-') $$
+ text "@end ifnottex"
+
+blockToTexinfo (Header 0 _ lst) = do
+ txt <- if null lst
+ then return $ text "Top"
+ else inlineListToTexinfo lst
+ return $ text "@node Top" $$
+ text "@top " <> txt <> blankline
+
+blockToTexinfo (Header level _ lst)
+ | level < 1 || level > 4 = blockToTexinfo (Para lst)
+ | otherwise = do
+ node <- inlineListForNode lst
+ txt <- inlineListToTexinfo lst
+ idsUsed <- gets stIdentifiers
+ let id' = uniqueIdent lst idsUsed
+ modify $ \st -> st{ stIdentifiers = Set.insert id' idsUsed }
+ sec <- seccmd level
+ return $ if (level > 0) && (level <= 4)
+ then blankline <> text "@node " <> node $$
+ text sec <> txt $$
+ text "@anchor" <> braces (text $ '#':id')
+ else txt
+ where
+ seccmd :: PandocMonad m => Int -> TI m String
+ seccmd 1 = return "@chapter "
+ seccmd 2 = return "@section "
+ seccmd 3 = return "@subsection "
+ seccmd 4 = return "@subsubsection "
+ seccmd _ = throwError $ PandocSomeError "illegal seccmd level"
+
+blockToTexinfo (Table caption aligns widths heads rows) = do
+ headers <- if all null heads
+ then return empty
+ else tableHeadToTexinfo aligns heads
+ captionText <- inlineListToTexinfo caption
+ rowsText <- mapM (tableRowToTexinfo aligns) rows
+ colDescriptors <-
+ if all (== 0) widths
+ then do -- use longest entry instead of column widths
+ cols <- mapM (mapM (liftM (render Nothing . hcat) . mapM blockToTexinfo)) $
+ transpose $ heads : rows
+ return $ concatMap ((\x -> "{"++x++"} ") . maximumBy (comparing length)) cols
+ else return $ "@columnfractions " ++ concatMap (printf "%.2f ") widths
+ let tableBody = text ("@multitable " ++ colDescriptors) $$
+ headers $$
+ vcat rowsText $$
+ text "@end multitable"
+ return $ if isEmpty captionText
+ then tableBody <> blankline
+ else text "@float" $$
+ tableBody $$
+ inCmd "caption" captionText $$
+ text "@end float"
+
+tableHeadToTexinfo :: PandocMonad m
+ => [Alignment]
+ -> [[Block]]
+ -> TI m Doc
+tableHeadToTexinfo = tableAnyRowToTexinfo "@headitem "
+
+tableRowToTexinfo :: PandocMonad m
+ => [Alignment]
+ -> [[Block]]
+ -> TI m Doc
+tableRowToTexinfo = tableAnyRowToTexinfo "@item "
+
+tableAnyRowToTexinfo :: PandocMonad m
+ => String
+ -> [Alignment]
+ -> [[Block]]
+ -> TI m Doc
+tableAnyRowToTexinfo itemtype aligns cols =
+ zipWithM alignedBlock aligns cols >>=
+ return . (text itemtype $$) . foldl (\row item -> row $$
+ (if isEmpty row then empty else text " @tab ") <> item) empty
+
+alignedBlock :: PandocMonad m
+ => Alignment
+ -> [Block]
+ -> TI m Doc
+-- XXX @flushleft and @flushright text won't get word wrapped. Since word
+-- wrapping is more important than alignment, we ignore the alignment.
+alignedBlock _ = blockListToTexinfo
+{-
+alignedBlock AlignLeft col = do
+ b <- blockListToTexinfo col
+ return $ text "@flushleft" $$ b $$ text "@end flushleft"
+alignedBlock AlignRight col = do
+ b <- blockListToTexinfo col
+ return $ text "@flushright" $$ b $$ text "@end flushright"
+alignedBlock _ col = blockListToTexinfo col
+-}
+
+-- | Convert Pandoc block elements to Texinfo.
+blockListToTexinfo :: PandocMonad m
+ => [Block]
+ -> TI m Doc
+blockListToTexinfo [] = return empty
+blockListToTexinfo (x:xs) = do
+ x' <- blockToTexinfo x
+ case x of
+ Header level _ _ -> do
+ -- We need need to insert a menu for this node.
+ let (before, after) = break isHeaderBlock xs
+ before' <- blockListToTexinfo before
+ let menu = if level < 4
+ then collectNodes (level + 1) after
+ else []
+ lines' <- mapM makeMenuLine menu
+ let menu' = if null lines'
+ then empty
+ else text "@menu" $$
+ vcat lines' $$
+ text "@end menu"
+ after' <- blockListToTexinfo after
+ return $ x' $$ before' $$ menu' $$ after'
+ Para _ -> do
+ xs' <- blockListToTexinfo xs
+ case xs of
+ ((CodeBlock _ _):_) -> return $ x' $$ xs'
+ _ -> return $ x' $+$ xs'
+ _ -> do
+ xs' <- blockListToTexinfo xs
+ return $ x' $$ xs'
+
+collectNodes :: Int -> [Block] -> [Block]
+collectNodes _ [] = []
+collectNodes level (x:xs) =
+ case x of
+ (Header hl _ _) ->
+ if hl < level
+ then []
+ else if hl == level
+ then x : collectNodes level xs
+ else collectNodes level xs
+ _ ->
+ collectNodes level xs
+
+makeMenuLine :: PandocMonad m
+ => Block
+ -> TI m Doc
+makeMenuLine (Header _ _ lst) = do
+ txt <- inlineListForNode lst
+ return $ text "* " <> txt <> text "::"
+makeMenuLine _ = throwError $ PandocSomeError "makeMenuLine called with non-Header block"
+
+listItemToTexinfo :: PandocMonad m
+ => [Block]
+ -> TI m Doc
+listItemToTexinfo lst = do
+ contents <- blockListToTexinfo lst
+ let spacer = case reverse lst of
+ (Para{}:_) -> blankline
+ _ -> empty
+ return $ text "@item" $$ contents <> spacer
+
+defListItemToTexinfo :: PandocMonad m
+ => ([Inline], [[Block]])
+ -> TI m Doc
+defListItemToTexinfo (term, defs) = do
+ term' <- inlineListToTexinfo term
+ let defToTexinfo bs = do d <- blockListToTexinfo bs
+ case reverse bs of
+ (Para{}:_) -> return $ d <> blankline
+ _ -> return d
+ defs' <- mapM defToTexinfo defs
+ return $ text "@item " <> term' $+$ vcat defs'
+
+-- | Convert list of inline elements to Texinfo.
+inlineListToTexinfo :: PandocMonad m
+ => [Inline] -- ^ Inlines to convert
+ -> TI m Doc
+inlineListToTexinfo lst = mapM inlineToTexinfo lst >>= return . hcat
+
+-- | Convert list of inline elements to Texinfo acceptable for a node name.
+inlineListForNode :: PandocMonad m
+ => [Inline] -- ^ Inlines to convert
+ -> TI m Doc
+inlineListForNode = return . text . stringToTexinfo .
+ filter (not . disallowedInNode) . stringify
+
+-- periods, commas, colons, and parentheses are disallowed in node names
+disallowedInNode :: Char -> Bool
+disallowedInNode c = c `elem` (".,:()" :: String)
+
+-- | Convert inline element to Texinfo
+inlineToTexinfo :: PandocMonad m
+ => Inline -- ^ Inline to convert
+ -> TI m Doc
+
+inlineToTexinfo (Span _ lst) =
+ inlineListToTexinfo lst
+
+inlineToTexinfo (Emph lst) =
+ inlineListToTexinfo lst >>= return . inCmd "emph"
+
+inlineToTexinfo (Strong lst) =
+ inlineListToTexinfo lst >>= return . inCmd "strong"
+
+inlineToTexinfo (Strikeout lst) = do
+ modify $ \st -> st{ stStrikeout = True }
+ contents <- inlineListToTexinfo lst
+ return $ text "@textstrikeout{" <> contents <> text "}"
+
+inlineToTexinfo (Superscript lst) = do
+ modify $ \st -> st{ stSuperscript = True }
+ contents <- inlineListToTexinfo lst
+ return $ text "@textsuperscript{" <> contents <> char '}'
+
+inlineToTexinfo (Subscript lst) = do
+ modify $ \st -> st{ stSubscript = True }
+ contents <- inlineListToTexinfo lst
+ return $ text "@textsubscript{" <> contents <> char '}'
+
+inlineToTexinfo (SmallCaps lst) =
+ inlineListToTexinfo lst >>= return . inCmd "sc"
+
+inlineToTexinfo (Code _ str) = do
+ return $ text $ "@code{" ++ stringToTexinfo str ++ "}"
+
+inlineToTexinfo (Quoted SingleQuote lst) = do
+ contents <- inlineListToTexinfo lst
+ return $ char '`' <> contents <> char '\''
+
+inlineToTexinfo (Quoted DoubleQuote lst) = do
+ contents <- inlineListToTexinfo lst
+ return $ text "``" <> contents <> text "''"
+
+inlineToTexinfo (Cite _ lst) =
+ inlineListToTexinfo lst
+inlineToTexinfo (Str str) = return $ text (stringToTexinfo str)
+inlineToTexinfo (Math _ str) = return $ inCmd "math" $ text str
+inlineToTexinfo il@(RawInline f str)
+ | f == "latex" || f == "tex" =
+ return $ text "@tex" $$ text str $$ text "@end tex"
+ | f == "texinfo" = return $ text str
+ | otherwise = do
+ report $ InlineNotRendered il
+ return empty
+inlineToTexinfo (LineBreak) = return $ text "@*" <> cr
+inlineToTexinfo SoftBreak = do
+ wrapText <- gets (writerWrapText . stOptions)
+ case wrapText of
+ WrapAuto -> return space
+ WrapNone -> return space
+ WrapPreserve -> return cr
+inlineToTexinfo Space = return space
+
+inlineToTexinfo (Link _ txt (src@('#':_), _)) = do
+ contents <- escapeCommas $ inlineListToTexinfo txt
+ return $ text "@ref" <>
+ braces (text (stringToTexinfo src) <> text "," <> contents)
+inlineToTexinfo (Link _ txt (src, _)) = do
+ case txt of
+ [Str x] | escapeURI x == src -> -- autolink
+ do return $ text $ "@url{" ++ x ++ "}"
+ _ -> do contents <- escapeCommas $ inlineListToTexinfo txt
+ let src1 = stringToTexinfo src
+ return $ text ("@uref{" ++ src1 ++ ",") <> contents <>
+ char '}'
+
+inlineToTexinfo (Image attr alternate (source, _)) = do
+ content <- escapeCommas $ inlineListToTexinfo alternate
+ opts <- gets stOptions
+ let showDim dim = case (dimension dim attr) of
+ (Just (Pixel a)) -> showInInch opts (Pixel a) ++ "in"
+ (Just (Percent _)) -> ""
+ (Just d) -> show d
+ Nothing -> ""
+ return $ text ("@image{" ++ base ++ ',':(showDim Width) ++ ',':(showDim Height) ++ ",")
+ <> content <> text "," <> text (ext ++ "}")
+ where
+ ext = drop 1 $ takeExtension source'
+ base = dropExtension source'
+ source' = if isURI source
+ then source
+ else unEscapeString source
+
+inlineToTexinfo (Note contents) = do
+ contents' <- blockListToTexinfo contents
+ return $ text "@footnote" <> braces contents'
diff --git a/src/Text/Pandoc/Writers/Textile.hs b/src/Text/Pandoc/Writers/Textile.hs
new file mode 100644
index 000000000..45f1780cf
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Textile.hs
@@ -0,0 +1,486 @@
+{-
+Copyright (C) 2010-2015 John MacFarlane <jgm@berkeley.edu>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : Text.Pandoc.Writers.Textile
+ Copyright : Copyright (C) 2010-2015 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Conversion of 'Pandoc' documents to Textile markup.
+
+Textile: <http://thresholdstate.com/articles/4312/the-textile-reference-manual>
+-}
+module Text.Pandoc.Writers.Textile ( writeTextile ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Text.Pandoc.Shared
+import Text.Pandoc.Pretty (render)
+import Text.Pandoc.ImageSize
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Templates (renderTemplate')
+import Text.Pandoc.XML ( escapeStringForXML )
+import Data.List ( intercalate )
+import Control.Monad.State
+import Data.Char ( isSpace )
+import Text.Pandoc.Class ( PandocMonad )
+
+data WriterState = WriterState {
+ stNotes :: [String] -- Footnotes
+ , stListLevel :: [Char] -- String at beginning of list items, e.g. "**"
+ , stStartNum :: Maybe Int -- Start number if first list item
+ , stUseTags :: Bool -- True if we should use HTML tags because we're in a complex list
+ }
+
+-- | Convert Pandoc to Textile.
+writeTextile :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeTextile opts document = return $
+ evalState (pandocToTextile opts document)
+ WriterState { stNotes = [], stListLevel = [], stStartNum = Nothing,
+ stUseTags = False }
+
+-- | Return Textile representation of document.
+pandocToTextile :: WriterOptions -> Pandoc -> State WriterState String
+pandocToTextile opts (Pandoc meta blocks) = do
+ metadata <- metaToJSON opts (blockListToTextile opts)
+ (inlineListToTextile opts) meta
+ body <- blockListToTextile opts blocks
+ notes <- liftM (unlines . reverse . stNotes) get
+ let main = body ++ if null notes then "" else ("\n\n" ++ notes)
+ let context = defField "body" main metadata
+ case writerTemplate opts of
+ Nothing -> return main
+ Just tpl -> return $ renderTemplate' tpl context
+
+withUseTags :: State WriterState a -> State WriterState a
+withUseTags action = do
+ oldUseTags <- liftM stUseTags get
+ modify $ \s -> s { stUseTags = True }
+ result <- action
+ modify $ \s -> s { stUseTags = oldUseTags }
+ return result
+
+-- | Escape one character as needed for Textile.
+escapeCharForTextile :: Char -> String
+escapeCharForTextile x = case x of
+ '&' -> "&amp;"
+ '<' -> "&lt;"
+ '>' -> "&gt;"
+ '"' -> "&quot;"
+ '*' -> "&#42;"
+ '_' -> "&#95;"
+ '@' -> "&#64;"
+ '+' -> "&#43;"
+ '-' -> "&#45;"
+ '|' -> "&#124;"
+ '\x2014' -> " -- "
+ '\x2013' -> " - "
+ '\x2019' -> "'"
+ '\x2026' -> "..."
+ c -> [c]
+
+-- | Escape string as needed for Textile.
+escapeStringForTextile :: String -> String
+escapeStringForTextile = concatMap escapeCharForTextile
+
+-- | Convert Pandoc block element to Textile.
+blockToTextile :: WriterOptions -- ^ Options
+ -> Block -- ^ Block element
+ -> State WriterState String
+
+blockToTextile _ Null = return ""
+
+blockToTextile opts (Div attr bs) = do
+ let startTag = render Nothing $ tagWithAttrs "div" attr
+ let endTag = "</div>"
+ contents <- blockListToTextile opts bs
+ return $ startTag ++ "\n\n" ++ contents ++ "\n\n" ++ endTag ++ "\n"
+
+blockToTextile opts (Plain inlines) =
+ inlineListToTextile opts inlines
+
+-- title beginning with fig: indicates that the image is a figure
+blockToTextile opts (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
+ capt <- blockToTextile opts (Para txt)
+ im <- inlineToTextile opts (Image attr txt (src,tit))
+ return $ im ++ "\n" ++ capt
+
+blockToTextile opts (Para inlines) = do
+ useTags <- liftM stUseTags get
+ listLevel <- liftM stListLevel get
+ contents <- inlineListToTextile opts inlines
+ return $ if useTags
+ then "<p>" ++ contents ++ "</p>"
+ else contents ++ if null listLevel then "\n" else ""
+
+blockToTextile opts (LineBlock lns) =
+ blockToTextile opts $ linesToPara lns
+
+blockToTextile _ (RawBlock f str)
+ | f == Format "html" || f == Format "textile" = return str
+ | otherwise = return ""
+
+blockToTextile _ HorizontalRule = return "<hr />\n"
+
+blockToTextile opts (Header level (ident,classes,keyvals) inlines) = do
+ contents <- inlineListToTextile opts inlines
+ let identAttr = if null ident then "" else ('#':ident)
+ let attribs = if null identAttr && null classes
+ then ""
+ else "(" ++ unwords classes ++ identAttr ++ ")"
+ let lang = maybe "" (\x -> "[" ++ x ++ "]") $ lookup "lang" keyvals
+ let styles = maybe "" (\x -> "{" ++ x ++ "}") $ lookup "style" keyvals
+ let prefix = 'h' : show level ++ attribs ++ styles ++ lang ++ ". "
+ return $ prefix ++ contents ++ "\n"
+
+blockToTextile _ (CodeBlock (_,classes,_) str) | any (all isSpace) (lines str) =
+ return $ "<pre" ++ classes' ++ ">\n" ++ escapeStringForXML str ++
+ "\n</pre>\n"
+ where classes' = if null classes
+ then ""
+ else " class=\"" ++ unwords classes ++ "\""
+
+blockToTextile _ (CodeBlock (_,classes,_) str) =
+ return $ "bc" ++ classes' ++ ". " ++ str ++ "\n\n"
+ where classes' = if null classes
+ then ""
+ else "(" ++ unwords classes ++ ")"
+
+blockToTextile opts (BlockQuote bs@[Para _]) = do
+ contents <- blockListToTextile opts bs
+ return $ "bq. " ++ contents ++ "\n\n"
+
+blockToTextile opts (BlockQuote blocks) = do
+ contents <- blockListToTextile opts blocks
+ return $ "<blockquote>\n\n" ++ contents ++ "\n</blockquote>\n"
+
+blockToTextile opts (Table [] aligns widths headers rows') |
+ all (==0) widths = do
+ hs <- mapM (liftM (("_. " ++) . stripTrailingNewlines) . blockListToTextile opts) headers
+ let cellsToRow cells = "|" ++ intercalate "|" cells ++ "|"
+ let header = if all null headers then "" else cellsToRow hs ++ "\n"
+ let blocksToCell (align, bs) = do
+ contents <- stripTrailingNewlines <$> blockListToTextile opts bs
+ let alignMarker = case align of
+ AlignLeft -> "<. "
+ AlignRight -> ">. "
+ AlignCenter -> "=. "
+ AlignDefault -> ""
+ return $ alignMarker ++ contents
+ let rowToCells = mapM blocksToCell . zip aligns
+ bs <- mapM rowToCells rows'
+ let body = unlines $ map cellsToRow bs
+ return $ header ++ body
+
+blockToTextile opts (Table capt aligns widths headers rows') = do
+ let alignStrings = map alignmentToString aligns
+ captionDoc <- if null capt
+ then return ""
+ else do
+ c <- inlineListToTextile opts capt
+ return $ "<caption>" ++ c ++ "</caption>\n"
+ let percent w = show (truncate (100*w) :: Integer) ++ "%"
+ let coltags = if all (== 0.0) widths
+ then ""
+ else unlines $ map
+ (\w -> "<col width=\"" ++ percent w ++ "\" />") widths
+ head' <- if all null headers
+ then return ""
+ else do
+ hs <- tableRowToTextile opts alignStrings 0 headers
+ return $ "<thead>\n" ++ hs ++ "\n</thead>\n"
+ body' <- zipWithM (tableRowToTextile opts alignStrings) [1..] rows'
+ return $ "<table>\n" ++ captionDoc ++ coltags ++ head' ++
+ "<tbody>\n" ++ unlines body' ++ "</tbody>\n</table>\n"
+
+blockToTextile opts x@(BulletList items) = do
+ oldUseTags <- liftM stUseTags get
+ let useTags = oldUseTags || not (isSimpleList x)
+ if useTags
+ then do
+ contents <- withUseTags $ mapM (listItemToTextile opts) items
+ return $ "<ul>\n" ++ vcat contents ++ "\n</ul>\n"
+ else do
+ modify $ \s -> s { stListLevel = stListLevel s ++ "*" }
+ level <- get >>= return . length . stListLevel
+ contents <- mapM (listItemToTextile opts) items
+ modify $ \s -> s { stListLevel = init (stListLevel s) }
+ return $ vcat contents ++ (if level > 1 then "" else "\n")
+
+blockToTextile opts x@(OrderedList attribs@(start, _, _) items) = do
+ oldUseTags <- liftM stUseTags get
+ let useTags = oldUseTags || not (isSimpleList x)
+ if useTags
+ then do
+ contents <- withUseTags $ mapM (listItemToTextile opts) items
+ return $ "<ol" ++ listAttribsToString attribs ++ ">\n" ++ vcat contents ++
+ "\n</ol>\n"
+ else do
+ modify $ \s -> s { stListLevel = stListLevel s ++ "#"
+ , stStartNum = if start > 1
+ then Just start
+ else Nothing }
+ level <- get >>= return . length . stListLevel
+ contents <- mapM (listItemToTextile opts) items
+ modify $ \s -> s { stListLevel = init (stListLevel s),
+ stStartNum = Nothing }
+ return $ vcat contents ++ (if level > 1 then "" else "\n")
+
+blockToTextile opts (DefinitionList items) = do
+ contents <- withUseTags $ mapM (definitionListItemToTextile opts) items
+ return $ "<dl>\n" ++ vcat contents ++ "\n</dl>\n"
+
+-- Auxiliary functions for lists:
+
+-- | Convert ordered list attributes to HTML attribute string
+listAttribsToString :: ListAttributes -> String
+listAttribsToString (startnum, numstyle, _) =
+ let numstyle' = camelCaseToHyphenated $ show numstyle
+ in (if startnum /= 1
+ then " start=\"" ++ show startnum ++ "\""
+ else "") ++
+ (if numstyle /= DefaultStyle
+ then " style=\"list-style-type: " ++ numstyle' ++ ";\""
+ else "")
+
+-- | Convert bullet or ordered list item (list of blocks) to Textile.
+listItemToTextile :: WriterOptions -> [Block] -> State WriterState String
+listItemToTextile opts items = do
+ contents <- blockListToTextile opts items
+ useTags <- get >>= return . stUseTags
+ if useTags
+ then return $ "<li>" ++ contents ++ "</li>"
+ else do
+ marker <- gets stListLevel
+ mbstart <- gets stStartNum
+ case mbstart of
+ Just n -> do
+ modify $ \s -> s{ stStartNum = Nothing }
+ return $ marker ++ show n ++ " " ++ contents
+ Nothing -> return $ marker ++ " " ++ contents
+
+-- | Convert definition list item (label, list of blocks) to Textile.
+definitionListItemToTextile :: WriterOptions
+ -> ([Inline],[[Block]])
+ -> State WriterState String
+definitionListItemToTextile opts (label, items) = do
+ labelText <- inlineListToTextile opts label
+ contents <- mapM (blockListToTextile opts) items
+ return $ "<dt>" ++ labelText ++ "</dt>\n" ++
+ (intercalate "\n" $ map (\d -> "<dd>" ++ d ++ "</dd>") contents)
+
+-- | True if the list can be handled by simple wiki markup, False if HTML tags will be needed.
+isSimpleList :: Block -> Bool
+isSimpleList x =
+ case x of
+ BulletList items -> all isSimpleListItem items
+ OrderedList (_, sty, _) items -> all isSimpleListItem items &&
+ sty `elem` [DefaultStyle, Decimal]
+ _ -> False
+
+-- | True if list item can be handled with the simple wiki syntax. False if
+-- HTML tags will be needed.
+isSimpleListItem :: [Block] -> Bool
+isSimpleListItem [] = True
+isSimpleListItem [x] =
+ case x of
+ Plain _ -> True
+ Para _ -> True
+ BulletList _ -> isSimpleList x
+ OrderedList _ _ -> isSimpleList x
+ _ -> False
+isSimpleListItem [x, y] | isPlainOrPara x =
+ case y of
+ BulletList _ -> isSimpleList y
+ OrderedList _ _ -> isSimpleList y
+ _ -> False
+isSimpleListItem _ = False
+
+isPlainOrPara :: Block -> Bool
+isPlainOrPara (Plain _) = True
+isPlainOrPara (Para _) = True
+isPlainOrPara _ = False
+
+-- | Concatenates strings with line breaks between them.
+vcat :: [String] -> String
+vcat = intercalate "\n"
+
+-- Auxiliary functions for tables. (TODO: these are common to HTML, MediaWiki,
+-- and Textile writers, and should be abstracted out.)
+
+tableRowToTextile :: WriterOptions
+ -> [String]
+ -> Int
+ -> [[Block]]
+ -> State WriterState String
+tableRowToTextile opts alignStrings rownum cols' = do
+ let celltype = if rownum == 0 then "th" else "td"
+ let rowclass = case rownum of
+ 0 -> "header"
+ x | x `rem` 2 == 1 -> "odd"
+ _ -> "even"
+ cols'' <- sequence $ zipWith
+ (\alignment item -> tableItemToTextile opts celltype alignment item)
+ alignStrings cols'
+ return $ "<tr class=\"" ++ rowclass ++ "\">\n" ++ unlines cols'' ++ "</tr>"
+
+alignmentToString :: Alignment -> [Char]
+alignmentToString alignment = case alignment of
+ AlignLeft -> "left"
+ AlignRight -> "right"
+ AlignCenter -> "center"
+ AlignDefault -> "left"
+
+tableItemToTextile :: WriterOptions
+ -> String
+ -> String
+ -> [Block]
+ -> State WriterState String
+tableItemToTextile opts celltype align' item = do
+ let mkcell x = "<" ++ celltype ++ " align=\"" ++ align' ++ "\">" ++
+ x ++ "</" ++ celltype ++ ">"
+ contents <- blockListToTextile opts item
+ return $ mkcell contents
+
+-- | Convert list of Pandoc block elements to Textile.
+blockListToTextile :: WriterOptions -- ^ Options
+ -> [Block] -- ^ List of block elements
+ -> State WriterState String
+blockListToTextile opts blocks =
+ mapM (blockToTextile opts) blocks >>= return . vcat
+
+-- | Convert list of Pandoc inline elements to Textile.
+inlineListToTextile :: WriterOptions -> [Inline] -> State WriterState String
+inlineListToTextile opts lst =
+ mapM (inlineToTextile opts) lst >>= return . concat
+
+-- | Convert Pandoc inline element to Textile.
+inlineToTextile :: WriterOptions -> Inline -> State WriterState String
+
+inlineToTextile opts (Span _ lst) =
+ inlineListToTextile opts lst
+
+inlineToTextile opts (Emph lst) = do
+ contents <- inlineListToTextile opts lst
+ return $ if '_' `elem` contents
+ then "<em>" ++ contents ++ "</em>"
+ else "_" ++ contents ++ "_"
+
+inlineToTextile opts (Strong lst) = do
+ contents <- inlineListToTextile opts lst
+ return $ if '*' `elem` contents
+ then "<strong>" ++ contents ++ "</strong>"
+ else "*" ++ contents ++ "*"
+
+inlineToTextile opts (Strikeout lst) = do
+ contents <- inlineListToTextile opts lst
+ return $ if '-' `elem` contents
+ then "<del>" ++ contents ++ "</del>"
+ else "-" ++ contents ++ "-"
+
+inlineToTextile opts (Superscript lst) = do
+ contents <- inlineListToTextile opts lst
+ return $ if '^' `elem` contents
+ then "<sup>" ++ contents ++ "</sup>"
+ else "[^" ++ contents ++ "^]"
+
+inlineToTextile opts (Subscript lst) = do
+ contents <- inlineListToTextile opts lst
+ return $ if '~' `elem` contents
+ then "<sub>" ++ contents ++ "</sub>"
+ else "[~" ++ contents ++ "~]"
+
+inlineToTextile opts (SmallCaps lst) = inlineListToTextile opts lst
+
+inlineToTextile opts (Quoted SingleQuote lst) = do
+ contents <- inlineListToTextile opts lst
+ return $ "'" ++ contents ++ "'"
+
+inlineToTextile opts (Quoted DoubleQuote lst) = do
+ contents <- inlineListToTextile opts lst
+ return $ "\"" ++ contents ++ "\""
+
+inlineToTextile opts (Cite _ lst) = inlineListToTextile opts lst
+
+inlineToTextile _ (Code _ str) =
+ return $ if '@' `elem` str
+ then "<tt>" ++ escapeStringForXML str ++ "</tt>"
+ else "@" ++ str ++ "@"
+
+inlineToTextile _ (Str str) = return $ escapeStringForTextile str
+
+inlineToTextile _ (Math _ str) =
+ return $ "<span class=\"math\">" ++ escapeStringForXML str ++ "</math>"
+
+inlineToTextile opts (RawInline f str)
+ | f == Format "html" || f == Format "textile" = return str
+ | (f == Format "latex" || f == Format "tex") &&
+ isEnabled Ext_raw_tex opts = return str
+ | otherwise = return ""
+
+inlineToTextile _ LineBreak = return "\n"
+
+inlineToTextile _ SoftBreak = return " "
+
+inlineToTextile _ Space = return " "
+
+inlineToTextile opts (Link (_, cls, _) txt (src, _)) = do
+ let classes = if null cls
+ then ""
+ else "(" ++ unwords cls ++ ")"
+ label <- case txt of
+ [Code _ s]
+ | s == src -> return "$"
+ [Str s]
+ | s == src -> return "$"
+ _ -> inlineListToTextile opts txt
+ return $ "\"" ++ classes ++ label ++ "\":" ++ src
+
+inlineToTextile opts (Image attr@(_, cls, _) alt (source, tit)) = do
+ alt' <- inlineListToTextile opts alt
+ let txt = if null tit
+ then if null alt'
+ then ""
+ else "(" ++ alt' ++ ")"
+ else "(" ++ tit ++ ")"
+ classes = if null cls
+ then ""
+ else "(" ++ unwords cls ++ ")"
+ showDim dir = let toCss str = Just $ show dir ++ ":" ++ str ++ ";"
+ in case (dimension dir attr) of
+ Just (Percent a) -> toCss $ show (Percent a)
+ Just dim -> toCss $ showInPixel opts dim ++ "px"
+ Nothing -> Nothing
+ styles = case (showDim Width, showDim Height) of
+ (Just w, Just h) -> "{" ++ w ++ h ++ "}"
+ (Just w, Nothing) -> "{" ++ w ++ "height:auto;}"
+ (Nothing, Just h) -> "{" ++ "width:auto;" ++ h ++ "}"
+ (Nothing, Nothing) -> ""
+ return $ "!" ++ classes ++ styles ++ source ++ txt ++ "!"
+
+inlineToTextile opts (Note contents) = do
+ curNotes <- liftM stNotes get
+ let newnum = length curNotes + 1
+ contents' <- blockListToTextile opts contents
+ let thisnote = "fn" ++ show newnum ++ ". " ++ contents' ++ "\n"
+ modify $ \s -> s { stNotes = thisnote : curNotes }
+ return $ "[" ++ show newnum ++ "]"
+ -- note - may not work for notes with multiple blocks
diff --git a/src/Text/Pandoc/Writers/ZimWiki.hs b/src/Text/Pandoc/Writers/ZimWiki.hs
new file mode 100644
index 000000000..d01ce0e8b
--- /dev/null
+++ b/src/Text/Pandoc/Writers/ZimWiki.hs
@@ -0,0 +1,396 @@
+{-
+Copyright (C) 2008-2015 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.ZimWiki
+ Copyright : Copyright (C) 2008-2015 John MacFarlane, 2017 Alex Ivkin
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Alex Ivkin <alex@ivkin.net>
+ Stability : beta
+ Portability : portable
+
+Conversion of 'Pandoc' documents to ZimWiki markup.
+
+http://zim-wiki.org/manual/Help/Wiki_Syntax.html
+-}
+
+module Text.Pandoc.Writers.ZimWiki ( writeZimWiki ) where
+import Text.Pandoc.Definition
+import Text.Pandoc.Options ( WriterOptions(writerTableOfContents, writerTemplate, writerWrapText), WrapOption(..) )
+import Text.Pandoc.Shared ( escapeURI, linesToPara, removeFormatting, trimr
+ , substitute )
+import Text.Pandoc.Writers.Shared ( defField, metaToJSON )
+import Text.Pandoc.ImageSize
+import Text.Pandoc.Templates ( renderTemplate' )
+import Data.List ( intercalate, isPrefixOf, transpose, isInfixOf )
+import Data.Text ( breakOnAll, pack )
+import Data.Default (Default(..))
+import Network.URI ( isURI )
+import Control.Monad ( zipWithM )
+import Control.Monad.State ( modify, State, get, evalState )
+import Text.Pandoc.Class ( PandocMonad )
+import qualified Data.Map as Map
+
+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 }
+
+-- | Convert Pandoc to ZimWiki.
+writeZimWiki :: PandocMonad m => WriterOptions -> Pandoc -> m String
+writeZimWiki opts document = return $ evalState (pandocToZimWiki opts document) def
+
+-- | Return ZimWiki representation of document.
+pandocToZimWiki :: WriterOptions -> Pandoc -> State WriterState String
+pandocToZimWiki opts (Pandoc meta blocks) = do
+ metadata <- metaToJSON opts
+ (fmap trimr . blockListToZimWiki opts)
+ (inlineListToZimWiki opts)
+ meta
+ body <- blockListToZimWiki opts blocks
+ --let header = "Content-Type: text/x-zim-wiki\nWiki-Format: zim 0.4\n"
+ let main = body
+ let context = defField "body" main
+ $ defField "toc" (writerTableOfContents opts)
+ $ metadata
+ case writerTemplate opts of
+ Just tpl -> return $ renderTemplate' tpl context
+ Nothing -> return main
+
+-- | Escape special characters for ZimWiki.
+escapeString :: String -> String
+escapeString = substitute "__" "''__''" .
+ substitute "**" "''**''" .
+ substitute "~~" "''~~''" .
+ substitute "//" "''//''"
+
+-- | Convert Pandoc block element to ZimWiki.
+blockToZimWiki :: WriterOptions -> Block -> State WriterState String
+
+blockToZimWiki _ Null = return ""
+
+blockToZimWiki opts (Div _attrs bs) = do
+ contents <- blockListToZimWiki opts bs
+ return $ contents ++ "\n"
+
+blockToZimWiki opts (Plain inlines) = inlineListToZimWiki opts inlines
+
+-- title beginning with fig: indicates that the image is a figure
+-- ZimWiki doesn't support captions - so combine together alt and caption into alt
+blockToZimWiki opts (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
+ capt <- if null txt
+ then return ""
+ else (" " ++) `fmap` inlineListToZimWiki opts txt
+ let opt = if null txt
+ then ""
+ else "|" ++ if null tit then capt else tit ++ capt
+ -- Relative links fail isURI and receive a colon
+ prefix = if isURI src then "" else ":"
+ return $ "{{" ++ prefix ++ src ++ imageDims opts attr ++ opt ++ "}}\n"
+
+blockToZimWiki opts (Para inlines) = do
+ indent <- stIndent <$> get
+ -- useTags <- stUseTags <$> get
+ contents <- inlineListToZimWiki opts inlines
+ return $ contents ++ if null indent then "\n" else ""
+
+blockToZimWiki opts (LineBlock lns) = do
+ blockToZimWiki opts $ linesToPara lns
+
+blockToZimWiki opts (RawBlock f str)
+ | f == Format "zimwiki" = return str
+ | f == Format "html" = do cont <- indentFromHTML opts str; return cont
+ | otherwise = return ""
+
+blockToZimWiki _ HorizontalRule = return "\n----\n"
+
+blockToZimWiki opts (Header level _ inlines) = do
+ contents <- inlineListToZimWiki opts $ removeFormatting inlines -- emphasis, links etc. not allowed in headers
+ let eqs = replicate ( 7 - level ) '='
+ return $ eqs ++ " " ++ contents ++ " " ++ eqs ++ "\n"
+
+blockToZimWiki _ (CodeBlock (_,classes,_) str) = do
+ -- Remap languages into the gtksourceview2 convention that ZimWiki source code plugin is using
+ let langal = [("javascript", "js"), ("bash", "sh"), ("winbatch", "dosbatch")]
+ let langmap = Map.fromList langal
+ return $ case classes of
+ [] -> "'''\n" ++ cleanupCode str ++ "\n'''\n" -- turn no lang block into a quote block
+ (x:_) -> "{{{code: lang=\"" ++
+ (case Map.lookup x langmap of
+ Nothing -> x
+ Just y -> y) ++ "\" linenumbers=\"True\"\n" ++ str ++ "\n}}}\n" -- for zim's code plugin, go verbatim on the lang spec
+
+blockToZimWiki opts (BlockQuote blocks) = do
+ contents <- blockListToZimWiki opts blocks
+ return $ unlines $ map ("> " ++) $ lines contents
+
+blockToZimWiki opts (Table capt aligns _ headers rows) = do
+ captionDoc <- if null capt
+ then return ""
+ else do
+ c <- inlineListToZimWiki opts capt
+ return $ "" ++ c ++ "\n"
+ headers' <- if all null headers
+ then zipWithM (tableItemToZimWiki opts) aligns (rows !! 0)
+ else mapM (inlineListToZimWiki opts) (map removeFormatting headers) -- emphasis, links etc. are not allowed in table headers
+ rows' <- mapM (zipWithM (tableItemToZimWiki opts) aligns) rows
+ let widths = map (maximum . map length) $ transpose (headers':rows')
+ let padTo (width, al) s =
+ case (width - length s) of
+ x | x > 0 ->
+ if al == AlignLeft || al == AlignDefault
+ then s ++ replicate x ' '
+ else if al == AlignRight
+ then replicate x ' ' ++ s
+ else replicate (x `div` 2) ' ' ++
+ s ++ replicate (x - x `div` 2) ' '
+ | otherwise -> s
+ let borderCell (width, al) _ =
+ if al == AlignLeft
+ then ":"++ replicate (width-1) '-'
+ else if al == AlignDefault
+ then replicate width '-'
+ else if al == AlignRight
+ then replicate (width-1) '-' ++ ":"
+ else ":" ++ replicate (width-2) '-' ++ ":"
+ let underheader = "|" ++ intercalate "|" (zipWith borderCell (zip widths aligns) headers') ++ "|"
+ let renderRow cells = "|" ++ intercalate "|" (zipWith padTo (zip widths aligns) cells) ++ "|"
+ return $ captionDoc ++
+ (if null headers' then "" else renderRow headers' ++ "\n") ++ underheader ++ "\n" ++
+ unlines (map renderRow rows')
+
+blockToZimWiki opts (BulletList items) = do
+ indent <- stIndent <$> get
+ modify $ \s -> s { stIndent = stIndent s ++ "\t" }
+ contents <- (mapM (listItemToZimWiki opts) items)
+ modify $ \s -> s{ stIndent = indent } -- drop 1 (stIndent s) }
+ return $ vcat contents ++ if null indent then "\n" else ""
+
+blockToZimWiki opts (OrderedList _ items) = do
+ indent <- stIndent <$> get
+ 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
+ contents <- (mapM (definitionListItemToZimWiki opts) items)
+ return $ vcat contents
+
+definitionListItemToZimWiki :: WriterOptions -> ([Inline],[[Block]]) -> State WriterState String
+definitionListItemToZimWiki opts (label, items) = do
+ labelText <- inlineListToZimWiki opts label
+ contents <- mapM (blockListToZimWiki opts) items
+ indent <- stIndent <$> get
+ return $ indent ++ "* **" ++ labelText ++ "** " ++ concat contents
+
+-- Auxiliary functions for lists:
+indentFromHTML :: WriterOptions -> String -> State WriterState String
+indentFromHTML _ str = do
+ indent <- stIndent <$> get
+ itemnum <- stItemNum <$> get
+ if isInfixOf "<li>" str then return $ indent ++ show itemnum ++ "."
+ else if isInfixOf "</li>" str then return "\n"
+ else if isInfixOf "<li value=" 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 isInfixOf "<ol>" str then do
+ let olcount=countSubStrs "<ol>" str
+ modify $ \s -> s { stIndent = stIndent s ++ replicate olcount '\t', stItemNum = 1 }
+ return ""
+ else if isInfixOf "</ol>" 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)
+
+cleanupCode :: String -> String
+cleanupCode = substitute "<nowiki>" "" . substitute "</nowiki>" ""
+
+vcat :: [String] -> String
+vcat = intercalate "\n"
+
+-- | Convert bullet list item (list of blocks) to ZimWiki.
+listItemToZimWiki :: WriterOptions -> [Block] -> State WriterState String
+listItemToZimWiki opts items = do
+ contents <- blockListToZimWiki opts items
+ indent <- stIndent <$> get
+ return $ indent ++ "* " ++ contents
+
+-- | Convert ordered list item (list of blocks) to ZimWiki.
+orderedListItemToZimWiki :: WriterOptions -> [Block] -> State WriterState String
+orderedListItemToZimWiki opts items = do
+ contents <- blockListToZimWiki opts items
+ indent <- stIndent <$> get
+ itemnum <- stItemNum <$> get
+ --modify $ \s -> s { stItemNum = itemnum + 1 } -- this is not strictly necessary for zim as zim does its own renumbering
+ return $ indent ++ show itemnum ++ ". " ++ contents
+
+-- Auxiliary functions for tables:
+tableItemToZimWiki :: WriterOptions -> Alignment -> [Block] -> State WriterState String
+tableItemToZimWiki opts align' item = do
+ let mkcell x = (if align' == AlignRight || align' == AlignCenter
+ then " "
+ else "") ++ x ++
+ (if align' == AlignLeft || align' == AlignCenter
+ then " "
+ else "")
+ modify $ \s -> s { stInTable = True }
+ contents <- blockListToZimWiki opts item
+ modify $ \s -> s { stInTable = False }
+ return $ mkcell contents
+
+-- | Convert list of Pandoc block elements to ZimWiki.
+blockListToZimWiki :: WriterOptions -> [Block] -> State WriterState String
+blockListToZimWiki opts blocks = vcat <$> mapM (blockToZimWiki opts) blocks
+
+-- | Convert list of Pandoc inline elements to ZimWiki.
+inlineListToZimWiki :: WriterOptions -> [Inline] -> State WriterState String
+inlineListToZimWiki opts lst = concat <$> (mapM (inlineToZimWiki opts) lst)
+
+-- | Convert Pandoc inline element to ZimWiki.
+inlineToZimWiki :: WriterOptions -> Inline -> State WriterState String
+
+inlineToZimWiki opts (Emph lst) = do
+ contents <- inlineListToZimWiki opts lst
+ return $ "//" ++ contents ++ "//"
+
+inlineToZimWiki opts (Strong lst) = do
+ contents <- inlineListToZimWiki opts lst
+ return $ "**" ++ contents ++ "**"
+
+inlineToZimWiki opts (Strikeout lst) = do
+ contents <- inlineListToZimWiki opts lst
+ return $ "~~" ++ contents ++ "~~"
+
+inlineToZimWiki opts (Superscript lst) = do
+ contents <- inlineListToZimWiki opts lst
+ return $ "^{" ++ contents ++ "}"
+
+inlineToZimWiki opts (Subscript lst) = do
+ contents <- inlineListToZimWiki opts lst
+ return $ "_{" ++ contents ++ "}"
+
+inlineToZimWiki opts (Quoted SingleQuote lst) = do
+ contents <- inlineListToZimWiki opts lst
+ return $ "\8216" ++ contents ++ "\8217"
+
+inlineToZimWiki opts (Quoted DoubleQuote lst) = do
+ contents <- inlineListToZimWiki opts lst
+ return $ "\8220" ++ contents ++ "\8221"
+
+inlineToZimWiki opts (Span _attrs ils) = inlineListToZimWiki opts ils
+
+inlineToZimWiki opts (SmallCaps lst) = inlineListToZimWiki opts lst
+
+inlineToZimWiki opts (Cite _ lst) = inlineListToZimWiki opts lst
+
+inlineToZimWiki _ (Code _ str) = return $ "''" ++ str ++ "''"
+
+inlineToZimWiki _ (Str str) = do
+ inTable <- stInTable <$> get
+ inLink <- stInLink <$> get
+ if inTable
+ then return $ substitute "|" "\\|" . escapeString $ str
+ else
+ if inLink
+ then return $ str
+ else return $ escapeString str
+
+inlineToZimWiki _ (Math mathType str) = return $ delim ++ str ++ delim -- note: str should NOT be escaped
+ where delim = case mathType of
+ DisplayMath -> "$$"
+ InlineMath -> "$"
+
+-- | f == Format "html" = return $ "<html>" ++ str ++ "</html>"
+inlineToZimWiki opts (RawInline f str)
+ | f == Format "zimwiki" = return str
+ | f == Format "html" = do cont <- indentFromHTML opts str; return cont
+ | otherwise = return ""
+
+inlineToZimWiki _ LineBreak = do
+ inTable <- stInTable <$> get
+ if inTable
+ then return "\\n"
+ else return "\n"
+
+inlineToZimWiki opts SoftBreak =
+ case writerWrapText opts of
+ WrapNone -> return " "
+ WrapAuto -> return " "
+ WrapPreserve -> return "\n"
+
+inlineToZimWiki _ Space = return " "
+
+inlineToZimWiki opts (Link _ txt (src, _)) = do
+ inTable <- stInTable <$> get
+ modify $ \s -> s { stInLink = True }
+ label <- inlineListToZimWiki opts $ removeFormatting txt -- zim does not allow formatting in link text, it takes the text verbatim, no need to escape it
+ modify $ \s -> s { stInLink = False }
+ let label'= if inTable
+ then "" -- no label is allowed in a table
+ else "|"++label
+ case txt of
+ [Str s] | "mailto:" `isPrefixOf` src -> return $ "<" ++ s ++ ">"
+ | escapeURI s == src -> return src
+ _ -> if isURI src
+ then return $ "[[" ++ src ++ label' ++ "]]"
+ else return $ "[[" ++ src' ++ label' ++ "]]"
+ where src' = case src of
+ '/':xs -> xs -- with leading / it's a
+ _ -> src -- link to a help page
+inlineToZimWiki opts (Image attr alt (source, tit)) = do
+ alt' <- inlineListToZimWiki opts alt
+ inTable <- stInTable <$> get
+ let txt = case (tit, alt, inTable) of
+ ("",[], _) -> ""
+ ("", _, False ) -> "|" ++ alt'
+ (_ , _, False ) -> "|" ++ tit
+ (_ , _, True ) -> ""
+ -- Relative links fail isURI and receive a colon
+ prefix = if isURI source then "" else ":"
+ return $ "{{" ++ prefix ++ source ++ imageDims opts attr ++ txt ++ "}}"
+
+inlineToZimWiki opts (Note contents) = do
+ -- no concept of notes in zim wiki, use a text block
+ contents' <- blockListToZimWiki opts contents
+ return $ " **{Note:** " ++ trimr contents' ++ "**}**"
+
+imageDims :: WriterOptions -> Attr -> String
+imageDims opts attr = go (toPx $ dimension Width attr) (toPx $ dimension Height attr)
+ where
+ toPx = fmap (showInPixel opts) . checkPct
+ checkPct (Just (Percent _)) = Nothing
+ checkPct maybeDim = maybeDim
+ go (Just w) Nothing = "?" ++ w
+ go (Just w) (Just h) = "?" ++ w ++ "x" ++ h
+ go Nothing (Just h) = "?0x" ++ h
+ go Nothing Nothing = ""
diff --git a/src/Text/Pandoc/XML.hs b/src/Text/Pandoc/XML.hs
new file mode 100644
index 000000000..e105aee91
--- /dev/null
+++ b/src/Text/Pandoc/XML.hs
@@ -0,0 +1,115 @@
+{-
+Copyright (C) 2006-2016 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.XML
+ Copyright : Copyright (C) 2006-2016 John MacFarlane
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John MacFarlane <jgm@berkeley.edu>
+ Stability : alpha
+ Portability : portable
+
+Functions for escaping and formatting XML.
+-}
+module Text.Pandoc.XML ( escapeCharForXML,
+ escapeStringForXML,
+ inTags,
+ selfClosingTag,
+ inTagsSimple,
+ inTagsIndented,
+ toEntities,
+ fromEntities ) where
+
+import Text.Pandoc.Pretty
+import Data.Char (ord, isAscii, isSpace)
+import Text.HTML.TagSoup.Entity (lookupEntity)
+
+-- | Escape one character as needed for XML.
+escapeCharForXML :: Char -> String
+escapeCharForXML x = case x of
+ '&' -> "&amp;"
+ '<' -> "&lt;"
+ '>' -> "&gt;"
+ '"' -> "&quot;"
+ c -> [c]
+
+-- | Escape string as needed for XML. Entity references are not preserved.
+escapeStringForXML :: String -> String
+escapeStringForXML = concatMap escapeCharForXML
+
+-- | Escape newline characters as &#10;
+escapeNls :: String -> String
+escapeNls (x:xs)
+ | x == '\n' = "&#10;" ++ escapeNls xs
+ | otherwise = x : escapeNls xs
+escapeNls [] = []
+
+-- | Return a text object with a string of formatted XML attributes.
+attributeList :: [(String, String)] -> Doc
+attributeList = hcat . map
+ (\(a, b) -> text (' ' : escapeStringForXML a ++ "=\"" ++
+ escapeNls (escapeStringForXML b) ++ "\""))
+
+-- | Put the supplied contents between start and end tags of tagType,
+-- with specified attributes and (if specified) indentation.
+inTags:: Bool -> String -> [(String, String)] -> Doc -> Doc
+inTags isIndented tagType attribs contents =
+ let openTag = char '<' <> text tagType <> attributeList attribs <>
+ char '>'
+ closeTag = text "</" <> text tagType <> char '>'
+ in if isIndented
+ then openTag $$ nest 2 contents $$ closeTag
+ else openTag <> contents <> closeTag
+
+-- | Return a self-closing tag of tagType with specified attributes
+selfClosingTag :: String -> [(String, String)] -> Doc
+selfClosingTag tagType attribs =
+ char '<' <> text tagType <> attributeList attribs <> text " />"
+
+-- | Put the supplied contents between start and end tags of tagType.
+inTagsSimple :: String -> Doc -> Doc
+inTagsSimple tagType = inTags False tagType []
+
+-- | Put the supplied contents in indented block btw start and end tags.
+inTagsIndented :: String -> Doc -> Doc
+inTagsIndented tagType = inTags True tagType []
+
+-- | Escape all non-ascii characters using numerical entities.
+toEntities :: String -> String
+toEntities [] = ""
+toEntities (c:cs)
+ | isAscii c = c : toEntities cs
+ | otherwise = "&#" ++ show (ord c) ++ ";" ++ toEntities cs
+
+-- Unescapes XML entities
+fromEntities :: String -> String
+fromEntities ('&':xs) =
+ case lookupEntity ent' of
+ Just c -> c ++ fromEntities rest
+ Nothing -> '&' : fromEntities xs
+ where (ent, rest) = case break (\c -> isSpace c || c == ';') xs of
+ (zs,';':ys) -> (zs,ys)
+ (zs, ys) -> (zs,ys)
+ ent' = case ent of
+ '#':'X':ys -> '#':'x':ys -- workaround tagsoup bug
+ '#':_ -> ent
+ _ -> ent ++ ";"
+
+fromEntities (x:xs) = x : fromEntities xs
+fromEntities [] = []
diff --git a/stack.full.yaml b/stack.full.yaml
new file mode 100644
index 000000000..e00623261
--- /dev/null
+++ b/stack.full.yaml
@@ -0,0 +1,25 @@
+# This version builds both pandoc and pandoc-citeproc, assuming
+# pandoc-citeproc is in the pandoc-citeproc subdirectory.
+flags:
+ pandoc:
+ trypandoc: false
+ https: true
+ embed_data_files: false
+ old-locale: false
+ network-uri: true
+ pandoc-citeproc:
+ bibutils: true
+ embed_data_files: true
+# if you are on OSX, stack install cpphs and
+# uncomment the following three lines:
+ghc-options:
+ pandoc-citeproc: '-pgmP cpphs -optP--cpp'
+ highlighting-kate: '-pgmP cpphs -optP--cpp'
+packages:
+- '.'
+- '../pandoc-citeproc'
+- '../pandoc-types'
+- '../texmath'
+extra-deps:
+- doctemplates-0.1.0.2
+resolver: lts-7.5
diff --git a/stack.pkg.yaml b/stack.pkg.yaml
new file mode 100644
index 000000000..e84aa09b3
--- /dev/null
+++ b/stack.pkg.yaml
@@ -0,0 +1,22 @@
+flags:
+ pandoc:
+ trypandoc: false
+ https: true
+ embed_data_files: true
+ old-locale: false
+ network-uri: true
+ pandoc-citeproc:
+ bibutils: true
+ embed_data_files: true
+ unicode_collation: false
+ test_citeproc: false
+ debug: false
+packages:
+- '.'
+- location:
+ git: https://github.com/jgm/pandoc-citeproc.git
+ commit: 9de619a02f79544bec933e4366a0d2f92ae2fe13
+ extra-dep: false
+extra-deps:
+- skylighting-0.3
+resolver: lts-8.2
diff --git a/stack.yaml b/stack.yaml
new file mode 100644
index 000000000..3c736c89d
--- /dev/null
+++ b/stack.yaml
@@ -0,0 +1,12 @@
+flags:
+ pandoc:
+ trypandoc: false
+ https: true
+ embed_data_files: false
+ old-locale: false
+ network-uri: true
+packages:
+- '.'
+extra-deps:
+- skylighting-0.3
+resolver: lts-8.2
diff --git a/test/Tests/Command.hs b/test/Tests/Command.hs
new file mode 100644
index 000000000..ab0402b4d
--- /dev/null
+++ b/test/Tests/Command.hs
@@ -0,0 +1,93 @@
+module Tests.Command (findPandoc, runTest, tests)
+where
+
+import Tests.Helpers
+import Test.Framework
+import Test.Framework.Providers.HUnit
+import Test.HUnit ( assertBool )
+import System.FilePath ( (</>), takeDirectory, splitDirectories,
+ joinPath )
+import System.Process
+import System.Directory
+import System.Exit
+import Text.Pandoc
+import Data.Algorithm.Diff
+import Prelude hiding ( readFile )
+import qualified Text.Pandoc.UTF8 as UTF8
+import Data.List (isSuffixOf)
+import Text.Pandoc.Shared (trimr)
+
+-- | Run a test with normalize function, return True if test passed.
+runTest :: String -- ^ Title of test
+ -> String -- ^ Shell command
+ -> String -- ^ Input text
+ -> String -- ^ Expected output
+ -> Test
+runTest testname cmd inp norm = testCase testname $ do
+ let cmd' = cmd ++ " --quiet --data-dir ../data"
+ let findDynlibDir [] = Nothing
+ findDynlibDir ("build":xs) = Just $ joinPath (reverse xs) </> "build"
+ findDynlibDir (_:xs) = findDynlibDir xs
+ let mbDynlibDir = findDynlibDir (reverse $ splitDirectories $
+ takeDirectory $ takeWhile (/=' ') cmd)
+ let dynlibEnv = case mbDynlibDir of
+ Nothing -> []
+ Just d -> [("DYLD_LIBRARY_PATH", d),
+ ("LD_LIBRARY_PATH", d)]
+ let env' = dynlibEnv ++ [("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./")]
+ let pr = (shell cmd'){ env = Just env' }
+ (ec, out', _err) <- readCreateProcessWithExitCode pr inp
+ -- filter \r so the tests will work on Windows machines
+ let out = filter (/= '\r') out'
+ result <- if ec == ExitSuccess
+ then do
+ if out == norm
+ then return TestPassed
+ else return
+ $ TestFailed cmd "expected"
+ $ getDiff (lines out) (lines norm)
+ else return $ TestError ec
+ assertBool (show result) (result == TestPassed)
+
+tests :: Test
+tests = buildTest $ do
+ files <- filter (".md" `isSuffixOf`) <$>
+ getDirectoryContents "command"
+ let cmds = map extractCommandTest files
+ return $ testGroup "Command:" cmds
+
+isCodeBlock :: Block -> Bool
+isCodeBlock (CodeBlock _ _) = True
+isCodeBlock _ = False
+
+extractCode :: Block -> String
+extractCode (CodeBlock _ code) = code
+extractCode _ = ""
+
+dropPercent :: String -> String
+dropPercent ('%':xs) = dropWhile (== ' ') xs
+dropPercent xs = xs
+
+runCommandTest :: FilePath -> (Int, String) -> IO Test
+runCommandTest pandocpath (num, code) = do
+ let codelines = lines code
+ let (continuations, r1) = span ("\\" `isSuffixOf`) codelines
+ let (cmd, r2) = (dropPercent (unwords (map init continuations ++ take 1 r1)),
+ drop 1 r1)
+ let (inplines, r3) = break (=="^D") r2
+ let normlines = takeWhile (/=".") (drop 1 r3)
+ let input = unlines inplines
+ let norm = unlines normlines
+ let shcmd = trimr $ takeDirectory pandocpath </> cmd
+ return $ runTest ("#" ++ show num) shcmd input norm
+
+extractCommandTest :: FilePath -> Test
+extractCommandTest fp = buildTest $ do
+ pandocpath <- findPandoc
+ contents <- UTF8.readFile ("command" </> fp)
+ Pandoc _ blocks <- runIOorExplode (readMarkdown
+ def{ readerExtensions = pandocExtensions } contents)
+ let codeblocks = map extractCode $ filter isCodeBlock $ blocks
+ cases <- mapM (runCommandTest pandocpath) $ zip [1..] codeblocks
+ return $ testGroup fp cases
+
diff --git a/test/Tests/Helpers.hs b/test/Tests/Helpers.hs
new file mode 100644
index 000000000..ad8b31364
--- /dev/null
+++ b/test/Tests/Helpers.hs
@@ -0,0 +1,136 @@
+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
+-- Utility functions for the test suite.
+
+module Tests.Helpers ( test
+ , TestResult(..)
+ , showDiff
+ , findPandoc
+ , (=?>)
+ , purely
+ , property
+ , ToString(..)
+ , ToPandoc(..)
+ )
+ where
+
+import Text.Pandoc.Definition
+import Text.Pandoc.Builder (Inlines, Blocks, doc, plain)
+import Text.Pandoc.Class
+import Test.Framework
+import Test.Framework.Providers.HUnit
+import Test.Framework.Providers.QuickCheck2
+import Test.HUnit (assertBool)
+import Text.Pandoc.Shared (trimr)
+import Text.Pandoc.Options
+import Text.Pandoc.Writers.Native (writeNative)
+import Text.Printf
+import System.Environment.Executable (getExecutablePath)
+import qualified Test.QuickCheck.Property as QP
+import Data.Algorithm.Diff
+import qualified Data.Map as M
+import System.Exit
+import System.Directory
+import System.FilePath
+
+test :: (ToString a, ToString b, ToString c)
+ => (a -> b) -- ^ function to test
+ -> String -- ^ name of test case
+ -> (a, c) -- ^ (input, expected value)
+ -> Test
+test fn name (input, expected) =
+ testCase name $ assertBool msg (actual' == expected')
+ where msg = nl ++ dashes "input" ++ nl ++ input' ++ nl ++
+ dashes "result" ++ nl ++
+ unlines (map vividize diff) ++
+ dashes ""
+ nl = "\n"
+ input' = toString input
+ actual' = lines $ toString $ fn input
+ expected' = lines $ toString expected
+ diff = getDiff expected' actual'
+ dashes "" = replicate 72 '-'
+ dashes x = replicate (72 - length x - 5) '-' ++ " " ++ x ++ " ---"
+
+data TestResult = TestPassed
+ | TestError ExitCode
+ | TestFailed String FilePath [Diff String]
+ deriving (Eq)
+
+instance Show TestResult where
+ show TestPassed = "PASSED"
+ show (TestError ec) = "ERROR " ++ show ec
+ show (TestFailed cmd file d) = '\n' : dash ++
+ "\n--- " ++ file ++
+ "\n+++ " ++ cmd ++ "\n" ++ showDiff (1,1) d ++
+ dash
+ where dash = replicate 72 '-'
+
+showDiff :: (Int,Int) -> [Diff String] -> String
+showDiff _ [] = ""
+showDiff (l,r) (First ln : ds) =
+ printf "+%4d " l ++ ln ++ "\n" ++ showDiff (l+1,r) ds
+showDiff (l,r) (Second ln : ds) =
+ printf "-%4d " r ++ ln ++ "\n" ++ showDiff (l,r+1) ds
+showDiff (l,r) (Both _ _ : ds) =
+ showDiff (l+1,r+1) ds
+
+-- | Find pandoc executable relative to test-pandoc
+-- First, try in same directory (e.g. if both in ~/.cabal/bin)
+-- Second, try ../pandoc (e.g. if in dist/XXX/build/test-pandoc)
+findPandoc :: IO FilePath
+findPandoc = do
+ testExePath <- getExecutablePath
+ let testExeDir = takeDirectory testExePath
+ found <- doesFileExist (testExeDir </> "pandoc")
+ return $ if found
+ then testExeDir </> "pandoc"
+ else case splitDirectories testExeDir of
+ [] -> error "test-pandoc: empty testExeDir"
+ xs -> joinPath (init xs) </> "pandoc" </> "pandoc"
+
+
+vividize :: Diff String -> String
+vividize (Both s _) = " " ++ s
+vividize (First s) = "- " ++ s
+vividize (Second s) = "+ " ++ s
+
+property :: QP.Testable a => TestName -> a -> Test
+property = testProperty
+
+purely :: (b -> PandocPure a) -> b -> a
+purely f = either (error . show) id . runPure . f
+
+infix 5 =?>
+(=?>) :: a -> b -> (a,b)
+x =?> y = (x, y)
+
+class ToString a where
+ toString :: a -> String
+
+instance ToString Pandoc where
+ toString d = purely (writeNative def{ writerTemplate = s }) $ toPandoc d
+ where s = case d of
+ (Pandoc (Meta m) _)
+ | M.null m -> Nothing
+ | otherwise -> Just "" -- need this to get meta output
+
+instance ToString Blocks where
+ toString = purely (writeNative def) . toPandoc
+
+instance ToString Inlines where
+ toString = trimr . purely (writeNative def) . toPandoc
+
+instance ToString String where
+ toString = id
+
+class ToPandoc a where
+ toPandoc :: a -> Pandoc
+
+instance ToPandoc Pandoc where
+ toPandoc = id
+
+instance ToPandoc Blocks where
+ toPandoc = doc
+
+instance ToPandoc Inlines where
+ toPandoc = doc . plain
diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs
new file mode 100644
index 000000000..d9877c8a0
--- /dev/null
+++ b/test/Tests/Old.hs
@@ -0,0 +1,248 @@
+module Tests.Old (tests) where
+
+import Tests.Helpers hiding (test)
+import Test.Framework (testGroup, Test )
+import Test.Framework.Providers.HUnit
+import Test.HUnit ( assertBool )
+import System.IO ( openTempFile, stderr )
+import System.Process ( runProcess, waitForProcess )
+import System.FilePath ( (</>), (<.>), splitDirectories, joinPath )
+import System.Directory
+import System.Exit
+import Data.Algorithm.Diff
+import Prelude hiding ( readFile )
+import qualified Text.Pandoc.UTF8 as UTF8
+
+tests :: [Test]
+tests = [ testGroup "markdown"
+ [ testGroup "writer"
+ $ writerTests "markdown" ++ lhsWriterTests "markdown"
+ , testGroup "reader"
+ [ test "basic" ["-r", "markdown", "-w", "native", "-s"]
+ "testsuite.txt" "testsuite.native"
+ , test "tables" ["-r", "markdown", "-w", "native", "--columns=80"]
+ "tables.txt" "tables.native"
+ , test "pipe tables" ["-r", "markdown", "-w", "native", "--columns=80"]
+ "pipe-tables.txt" "pipe-tables.native"
+ , test "more" ["-r", "markdown", "-w", "native", "-s"]
+ "markdown-reader-more.txt" "markdown-reader-more.native"
+ , lhsReaderTest "markdown+lhs"
+ ]
+ , testGroup "citations"
+ [ test "citations" ["-r", "markdown", "-w", "native"]
+ "markdown-citations.txt" "markdown-citations.native"
+ ]
+ ]
+ , testGroup "rst"
+ [ testGroup "writer" (writerTests "rst" ++ lhsWriterTests "rst")
+ , testGroup "reader"
+ [ test "basic" ["-r", "rst+smart", "-w", "native",
+ "-s", "--columns=80"] "rst-reader.rst" "rst-reader.native"
+ , test "tables" ["-r", "rst", "-w", "native", "--columns=80"]
+ "tables.rst" "tables-rstsubset.native"
+ , lhsReaderTest "rst+lhs"
+ ]
+ ]
+ , testGroup "latex"
+ [ testGroup "writer" (writerTests "latex" ++ lhsWriterTests "latex")
+ , testGroup "reader"
+ [ test "basic" ["-r", "latex+raw_tex", "-w", "native", "-s"]
+ "latex-reader.latex" "latex-reader.native"
+ , lhsReaderTest "latex+lhs"
+ ]
+ ]
+ , testGroup "html"
+ [ testGroup "writer" (writerTests "html4" ++ writerTests "html5" ++
+ lhsWriterTests "html")
+ , test "reader" ["-r", "html", "-w", "native", "-s"]
+ "html-reader.html" "html-reader.native"
+ ]
+ , testGroup "s5"
+ [ s5WriterTest "basic" ["-s"] "s5"
+ , s5WriterTest "fancy" ["-s","-m","-i"] "s5"
+ , s5WriterTest "fragment" [] "html4"
+ , s5WriterTest "inserts" ["-s", "-H", "insert",
+ "-B", "insert", "-A", "insert", "-c", "main.css"] "html4"
+ ]
+ , testGroup "textile"
+ [ testGroup "writer" $ writerTests "textile"
+ , test "reader" ["-r", "textile", "-w", "native", "-s"]
+ "textile-reader.textile" "textile-reader.native"
+ ]
+ , testGroup "docbook"
+ [ testGroup "writer" $ writerTests "docbook4"
+ , test "reader" ["-r", "docbook", "-w", "native", "-s"]
+ "docbook-reader.docbook" "docbook-reader.native"
+ , test "reader" ["-r", "docbook", "-w", "native", "-s"]
+ "docbook-xref.docbook" "docbook-xref.native"
+ ]
+ , testGroup "docbook5"
+ [ testGroup "writer" $ writerTests "docbook5"
+ ]
+ , testGroup "native"
+ [ testGroup "writer" $ writerTests "native"
+ , test "reader" ["-r", "native", "-w", "native", "-s"]
+ "testsuite.native" "testsuite.native"
+ ]
+ , testGroup "fb2"
+ [ fb2WriterTest "basic" [] "fb2/basic.markdown" "fb2/basic.fb2"
+ , fb2WriterTest "titles" [] "fb2/titles.markdown" "fb2/titles.fb2"
+ , fb2WriterTest "images" [] "fb2/images.markdown" "fb2/images.fb2"
+ , fb2WriterTest "images-embedded" [] "fb2/images-embedded.html" "fb2/images-embedded.fb2"
+ , fb2WriterTest "math" [] "fb2/math.markdown" "fb2/math.fb2"
+ , fb2WriterTest "tables" [] "tables.native" "tables.fb2"
+ , fb2WriterTest "testsuite" [] "testsuite.native" "writer.fb2"
+ ]
+ , testGroup "mediawiki"
+ [ testGroup "writer" $ writerTests "mediawiki"
+ , test "reader" ["-r", "mediawiki", "-w", "native", "-s"]
+ "mediawiki-reader.wiki" "mediawiki-reader.native"
+ ]
+ , testGroup "dokuwiki"
+ [ testGroup "writer" $ writerTests "dokuwiki"
+ , test "inline_formatting" ["-r", "native", "-w", "dokuwiki", "-s"]
+ "dokuwiki_inline_formatting.native" "dokuwiki_inline_formatting.dokuwiki"
+ , test "multiblock table" ["-r", "native", "-w", "dokuwiki", "-s"]
+ "dokuwiki_multiblock_table.native" "dokuwiki_multiblock_table.dokuwiki"
+ , test "external images" ["-r", "native", "-w", "dokuwiki", "-s"]
+ "dokuwiki_external_images.native" "dokuwiki_external_images.dokuwiki"
+ ]
+ , testGroup "opml"
+ [ test "basic" ["-r", "native", "-w", "opml", "--columns=78", "-s"]
+ "testsuite.native" "writer.opml"
+ , test "reader" ["-r", "opml", "-w", "native", "-s"]
+ "opml-reader.opml" "opml-reader.native"
+ ]
+ , testGroup "haddock"
+ [ testGroup "writer" $ writerTests "haddock"
+ , test "reader" ["-r", "haddock", "-w", "native", "-s"]
+ "haddock-reader.haddock" "haddock-reader.native"
+ ]
+ , testGroup "txt2tags"
+ [ test "reader" ["-r", "t2t", "-w", "native", "-s"]
+ "txt2tags.t2t" "txt2tags.native" ]
+ , testGroup "epub" [
+ test "features" ["-r", "epub", "-w", "native"]
+ "epub/features.epub" "epub/features.native"
+ , test "wasteland" ["-r", "epub", "-w", "native"]
+ "epub/wasteland.epub" "epub/wasteland.native"
+ , test "formatting" ["-r", "epub", "-w", "native"]
+ "epub/formatting.epub" "epub/formatting.native"
+ ]
+ , testGroup "twiki"
+ [ test "reader" ["-r", "twiki", "-w", "native", "-s"]
+ "twiki-reader.twiki" "twiki-reader.native" ]
+ , testGroup "other writers" $ map (\f -> testGroup f $ writerTests f)
+ [ "opendocument" , "context" , "texinfo", "icml", "tei"
+ , "man" , "plain" , "rtf", "org", "asciidoc", "zimwiki"
+ ]
+ , testGroup "writers-lang-and-dir"
+ [ test "latex" ["-f", "native", "-t", "latex", "-s"]
+ "writers-lang-and-dir.native" "writers-lang-and-dir.latex"
+ , test "context" ["-f", "native", "-t", "context", "-s"]
+ "writers-lang-and-dir.native" "writers-lang-and-dir.context"
+ ]
+ ]
+
+-- makes sure file is fully closed after reading
+readFile' :: FilePath -> IO String
+readFile' f = do s <- UTF8.readFile f
+ return $! (length s `seq` s)
+
+lhsWriterTests :: String -> [Test]
+lhsWriterTests format
+ = [ t "lhs to normal" format
+ , t "lhs to lhs" (format ++ "+lhs")
+ ]
+ where
+ t n f = test n ["--wrap=preserve", "-r", "native", "-s", "-w", f]
+ "lhs-test.native" ("lhs-test" <.> f)
+
+lhsReaderTest :: String -> Test
+lhsReaderTest format =
+ test "lhs" ["-r", format, "-w", "native"]
+ ("lhs-test" <.> format) norm
+ where norm = if format == "markdown+lhs"
+ then "lhs-test-markdown.native"
+ else "lhs-test.native"
+
+writerTests :: String -> [Test]
+writerTests format
+ = [ test "basic" (opts ++ ["-s"]) "testsuite.native" ("writer" <.> format)
+ , test "tables" opts "tables.native" ("tables" <.> format)
+ ]
+ where
+ opts = ["-r", "native", "-w", format, "--columns=78",
+ "--variable", "pandoc-version="]
+
+s5WriterTest :: String -> [String] -> String -> Test
+s5WriterTest modifier opts format
+ = test (format ++ " writer (" ++ modifier ++ ")")
+ (["-r", "native", "-w", format] ++ opts)
+ "s5.native" ("s5-" ++ modifier <.> "html")
+
+fb2WriterTest :: String -> [String] -> String -> String -> Test
+fb2WriterTest title opts inputfile normfile =
+ testWithNormalize (ignoreBinary . formatXML)
+ title (["-t", "fb2"]++opts) inputfile normfile
+ where
+ formatXML xml = splitTags $ zip xml (drop 1 xml)
+ splitTags [] = []
+ splitTags [end] = fst end : snd end : []
+ splitTags (('>','<'):rest) = ">\n" ++ splitTags rest
+ splitTags ((c,_):rest) = c : splitTags rest
+ ignoreBinary = unlines . filter (not . startsWith "<binary ") . lines
+ startsWith tag str = all (uncurry (==)) $ zip tag str
+
+-- | Run a test without normalize function, return True if test passed.
+test :: String -- ^ Title of test
+ -> [String] -- ^ Options to pass to pandoc
+ -> String -- ^ Input filepath
+ -> FilePath -- ^ Norm (for test results) filepath
+ -> Test
+test = testWithNormalize id
+
+-- | Run a test with normalize function, return True if test passed.
+testWithNormalize :: (String -> String) -- ^ Normalize function for output
+ -> String -- ^ Title of test
+ -> [String] -- ^ Options to pass to pandoc
+ -> String -- ^ Input filepath
+ -> FilePath -- ^ Norm (for test results) filepath
+ -> Test
+testWithNormalize normalizer testname opts inp norm = testCase testname $ do
+ -- find pandoc executable relative to test-pandoc
+ -- First, try in same directory (e.g. if both in ~/.cabal/bin)
+ -- Second, try ../pandoc (e.g. if in dist/XXX/build/test-pandoc)
+ pandocPath <- findPandoc
+ (outputPath, hOut) <- openTempFile "" "pandoc-test"
+ let inpPath = inp
+ let normPath = norm
+ let options = ["--quiet", "--data-dir", ".." </> "data"] ++ [inpPath] ++ opts
+ let cmd = pandocPath ++ " " ++ unwords options
+ let findDynlibDir [] = Nothing
+ findDynlibDir ("build":xs) = Just $ joinPath (reverse xs) </> "build"
+ findDynlibDir (_:xs) = findDynlibDir xs
+ let mbDynlibDir = findDynlibDir (reverse $ splitDirectories pandocPath)
+ let dynlibEnv = case mbDynlibDir of
+ Nothing -> []
+ Just d -> [("DYLD_LIBRARY_PATH", d),
+ ("LD_LIBRARY_PATH", d)]
+ let env = dynlibEnv ++ [("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./")]
+ ph <- runProcess pandocPath options Nothing
+ (Just env) Nothing (Just hOut) (Just stderr)
+ ec <- waitForProcess ph
+ result <- if ec == ExitSuccess
+ then do
+ -- filter \r so the tests will work on Windows machines
+ outputContents <- readFile' outputPath >>=
+ return . filter (/='\r') . normalizer
+ normContents <- readFile' normPath >>=
+ return . filter (/='\r') . normalizer
+ if outputContents == normContents
+ then return TestPassed
+ else return
+ $ TestFailed cmd normPath
+ $ getDiff (lines outputContents) (lines normContents)
+ else return $ TestError ec
+ removeFile outputPath
+ assertBool (show result) (result == TestPassed)
diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs
new file mode 100644
index 000000000..e73065012
--- /dev/null
+++ b/test/Tests/Readers/Docx.hs
@@ -0,0 +1,344 @@
+module Tests.Readers.Docx (tests) where
+
+import Text.Pandoc
+import Tests.Helpers
+import Test.Framework
+import Test.HUnit (assertBool)
+import Test.Framework.Providers.HUnit
+import qualified Data.ByteString.Lazy as B
+import qualified Data.Map as M
+import Text.Pandoc.MediaBag (MediaBag, lookupMedia, mediaDirectory)
+import Codec.Archive.Zip
+import qualified Text.Pandoc.Class as P
+
+-- We define a wrapper around pandoc that doesn't normalize in the
+-- tests. Since we do our own normalization, we want to make sure
+-- we're doing it right.
+
+data NoNormPandoc = NoNormPandoc {unNoNorm :: Pandoc}
+ deriving Show
+
+noNorm :: Pandoc -> NoNormPandoc
+noNorm = NoNormPandoc
+
+defopts :: ReaderOptions
+defopts = def{ readerExtensions = getDefaultExtensions "docx" }
+
+instance ToString NoNormPandoc where
+ toString d = purely (writeNative def{ writerTemplate = s }) $ toPandoc d
+ where s = case d of
+ NoNormPandoc (Pandoc (Meta m) _)
+ | M.null m -> Nothing
+ | otherwise -> Just "" -- need this to get meta output
+
+instance ToPandoc NoNormPandoc where
+ toPandoc = unNoNorm
+
+compareOutput :: ReaderOptions
+ -> FilePath
+ -> FilePath
+ -> IO (NoNormPandoc, NoNormPandoc)
+compareOutput opts docxFile nativeFile = do
+ df <- B.readFile docxFile
+ nf <- Prelude.readFile nativeFile
+ p <- runIOorExplode $ readDocx opts df
+ df' <- runIOorExplode $ readNative def nf
+ return $ (noNorm p, noNorm df')
+
+testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO Test
+testCompareWithOptsIO opts name docxFile nativeFile = do
+ (dp, np) <- compareOutput opts docxFile nativeFile
+ return $ test id name (dp, np)
+
+testCompareWithOpts :: ReaderOptions -> String -> FilePath -> FilePath -> Test
+testCompareWithOpts opts name docxFile nativeFile =
+ buildTest $ testCompareWithOptsIO opts name docxFile nativeFile
+
+testCompare :: String -> FilePath -> FilePath -> Test
+testCompare = testCompareWithOpts defopts
+
+testForWarningsWithOptsIO :: ReaderOptions -> String -> FilePath -> [String] -> IO Test
+testForWarningsWithOptsIO opts name docxFile expected = do
+ df <- B.readFile docxFile
+ logs <- runIOorExplode (readDocx opts df >> P.getLog)
+ let warns = [m | DocxParserWarning m <- logs]
+ return $ test id name (unlines warns, unlines expected)
+
+testForWarningsWithOpts :: ReaderOptions -> String -> FilePath -> [String] -> Test
+testForWarningsWithOpts opts name docxFile expected =
+ buildTest $ testForWarningsWithOptsIO opts name docxFile expected
+
+-- testForWarnings :: String -> FilePath -> [String] -> Test
+-- testForWarnings = testForWarningsWithOpts defopts
+
+getMedia :: FilePath -> FilePath -> IO (Maybe B.ByteString)
+getMedia archivePath mediaPath = do
+ zf <- B.readFile archivePath >>= return . toArchive
+ return $ findEntryByPath ("word/" ++ mediaPath) zf >>= (Just . fromEntry)
+
+compareMediaPathIO :: FilePath -> MediaBag -> FilePath -> IO Bool
+compareMediaPathIO mediaPath mediaBag docxPath = do
+ docxMedia <- getMedia docxPath mediaPath
+ let mbBS = case lookupMedia mediaPath mediaBag of
+ Just (_, bs) -> bs
+ Nothing -> error ("couldn't find " ++
+ mediaPath ++
+ " in media bag")
+ docxBS = case docxMedia of
+ Just bs -> bs
+ Nothing -> error ("couldn't find " ++
+ mediaPath ++
+ " in media bag")
+ return $ mbBS == docxBS
+
+compareMediaBagIO :: FilePath -> IO Bool
+compareMediaBagIO docxFile = do
+ df <- B.readFile docxFile
+ mb <- runIOorExplode (readDocx defopts df >> P.getMediaBag)
+ bools <- mapM
+ (\(fp, _, _) -> compareMediaPathIO fp mb docxFile)
+ (mediaDirectory mb)
+ return $ and bools
+
+testMediaBagIO :: String -> FilePath -> IO Test
+testMediaBagIO name docxFile = do
+ outcome <- compareMediaBagIO docxFile
+ return $ testCase name (assertBool
+ ("Media didn't match media bag in file " ++ docxFile)
+ outcome)
+
+testMediaBag :: String -> FilePath -> Test
+testMediaBag name docxFile = buildTest $ testMediaBagIO name docxFile
+
+tests :: [Test]
+tests = [ testGroup "inlines"
+ [ testCompare
+ "font formatting"
+ "docx/inline_formatting.docx"
+ "docx/inline_formatting.native"
+ , testCompare
+ "font formatting with character styles"
+ "docx/char_styles.docx"
+ "docx/char_styles.native"
+ , testCompare
+ "hyperlinks"
+ "docx/links.docx"
+ "docx/links.native"
+ , testCompare
+ "normalizing adjacent hyperlinks"
+ "docx/adjacent_links.docx"
+ "docx/adjacent_links.native"
+ , testCompare
+ "inline image"
+ "docx/image.docx"
+ "docx/image_no_embed.native"
+ , testCompare
+ "VML image"
+ "docx/image_vml.docx"
+ "docx/image_vml.native"
+ , testCompare
+ "inline image in links"
+ "docx/inline_images.docx"
+ "docx/inline_images.native"
+ , testCompare
+ "handling unicode input"
+ "docx/unicode.docx"
+ "docx/unicode.native"
+ , testCompare
+ "literal tabs"
+ "docx/tabs.docx"
+ "docx/tabs.native"
+ , testCompare
+ "special punctuation"
+ "docx/special_punctuation.docx"
+ "docx/special_punctuation.native"
+ , testCompare
+ "normalizing inlines"
+ "docx/normalize.docx"
+ "docx/normalize.native"
+ , testCompare
+ "normalizing inlines deep inside blocks"
+ "docx/deep_normalize.docx"
+ "docx/deep_normalize.native"
+ , testCompare
+ "move trailing spaces outside of formatting"
+ "docx/trailing_spaces_in_formatting.docx"
+ "docx/trailing_spaces_in_formatting.native"
+ , testCompare
+ "inline code (with VerbatimChar style)"
+ "docx/inline_code.docx"
+ "docx/inline_code.native"
+ , testCompare
+ "inline code in subscript and superscript"
+ "docx/verbatim_subsuper.docx"
+ "docx/verbatim_subsuper.native"
+ ]
+ , testGroup "blocks"
+ [ testCompare
+ "headers"
+ "docx/headers.docx"
+ "docx/headers.native"
+ , testCompare
+ "headers already having auto identifiers"
+ "docx/already_auto_ident.docx"
+ "docx/already_auto_ident.native"
+ , testCompare
+ "nested anchor spans in header"
+ "docx/nested_anchors_in_header.docx"
+ "docx/nested_anchors_in_header.native"
+ , testCompare
+ "single numbered item not made into list"
+ "docx/numbered_header.docx"
+ "docx/numbered_header.native"
+ , testCompare
+ "enumerated headers not made into numbered list"
+ "docx/enumerated_headings.docx"
+ "docx/enumerated_headings.native"
+ , testCompare
+ "i18n blocks (headers and blockquotes)"
+ "docx/i18n_blocks.docx"
+ "docx/i18n_blocks.native"
+ , testCompare
+ "lists"
+ "docx/lists.docx"
+ "docx/lists.native"
+ , testCompare
+ "definition lists"
+ "docx/definition_list.docx"
+ "docx/definition_list.native"
+ , testCompare
+ "custom defined lists in styles"
+ "docx/german_styled_lists.docx"
+ "docx/german_styled_lists.native"
+ , testCompare
+ "user deletes bullet after list item (=> part of item par)"
+ "docx/dummy_item_after_list_item.docx"
+ "docx/dummy_item_after_list_item.native"
+ , testCompare
+ "user deletes bullet after par (=> new par)"
+ "docx/dummy_item_after_paragraph.docx"
+ "docx/dummy_item_after_paragraph.native"
+ , testCompare
+ "footnotes and endnotes"
+ "docx/notes.docx"
+ "docx/notes.native"
+ , testCompare
+ "links in footnotes and endnotes"
+ "docx/link_in_notes.docx"
+ "docx/link_in_notes.native"
+ , testCompare
+ "blockquotes (parsing indent as blockquote)"
+ "docx/block_quotes.docx"
+ "docx/block_quotes_parse_indent.native"
+ , testCompare
+ "hanging indents"
+ "docx/hanging_indent.docx"
+ "docx/hanging_indent.native"
+ , testCompare
+ "tables"
+ "docx/tables.docx"
+ "docx/tables.native"
+ , testCompare
+ "tables with lists in cells"
+ "docx/table_with_list_cell.docx"
+ "docx/table_with_list_cell.native"
+ , testCompare
+ "tables with one row"
+ "docx/table_one_row.docx"
+ "docx/table_one_row.native"
+ , testCompare
+ "code block"
+ "docx/codeblock.docx"
+ "docx/codeblock.native"
+ , testCompare
+ "dropcap paragraphs"
+ "docx/drop_cap.docx"
+ "docx/drop_cap.native"
+ ]
+ , testGroup "track changes"
+ [ testCompare
+ "insertion (default)"
+ "docx/track_changes_insertion.docx"
+ "docx/track_changes_insertion_accept.native"
+ , testCompareWithOpts def{readerTrackChanges=AcceptChanges}
+ "insert insertion (accept)"
+ "docx/track_changes_insertion.docx"
+ "docx/track_changes_insertion_accept.native"
+ , testCompareWithOpts def{readerTrackChanges=RejectChanges}
+ "remove insertion (reject)"
+ "docx/track_changes_insertion.docx"
+ "docx/track_changes_insertion_reject.native"
+ , testCompare
+ "deletion (default)"
+ "docx/track_changes_deletion.docx"
+ "docx/track_changes_deletion_accept.native"
+ , testCompareWithOpts def{readerTrackChanges=AcceptChanges}
+ "remove deletion (accept)"
+ "docx/track_changes_deletion.docx"
+ "docx/track_changes_deletion_accept.native"
+ , testCompareWithOpts def{readerTrackChanges=RejectChanges}
+ "insert deletion (reject)"
+ "docx/track_changes_deletion.docx"
+ "docx/track_changes_deletion_reject.native"
+ , testCompareWithOpts def{readerTrackChanges=AllChanges}
+ "keep insertion (all)"
+ "docx/track_changes_deletion.docx"
+ "docx/track_changes_deletion_all.native"
+ , testCompareWithOpts def{readerTrackChanges=AllChanges}
+ "keep deletion (all)"
+ "docx/track_changes_deletion.docx"
+ "docx/track_changes_deletion_all.native"
+ , testCompareWithOpts def{readerTrackChanges=AcceptChanges}
+ "move text (accept)"
+ "docx/track_changes_move.docx"
+ "docx/track_changes_move_accept.native"
+ , testCompareWithOpts def{readerTrackChanges=RejectChanges}
+ "move text (reject)"
+ "docx/track_changes_move.docx"
+ "docx/track_changes_move_reject.native"
+ , testCompareWithOpts def{readerTrackChanges=AllChanges}
+ "move text (all)"
+ "docx/track_changes_move.docx"
+ "docx/track_changes_move_all.native"
+ , testCompareWithOpts def{readerTrackChanges=AcceptChanges}
+ "comments (accept -- no comments)"
+ "docx/comments.docx"
+ "docx/comments_no_comments.native"
+ , testCompareWithOpts def{readerTrackChanges=RejectChanges}
+ "comments (reject -- comments)"
+ "docx/comments.docx"
+ "docx/comments_no_comments.native"
+ , testCompareWithOpts def{readerTrackChanges=AllChanges}
+ "comments (all comments)"
+ "docx/comments.docx"
+ "docx/comments.native"
+ , testForWarningsWithOpts def{readerTrackChanges=AcceptChanges}
+ "comment warnings (accept -- no warnings)"
+ "docx/comments_warning.docx"
+ []
+ , testForWarningsWithOpts def{readerTrackChanges=RejectChanges}
+ "comment warnings (reject -- no warnings)"
+ "docx/comments_warning.docx"
+ []
+ , testForWarningsWithOpts def{readerTrackChanges=AllChanges}
+ "comment warnings (all)"
+ "docx/comments_warning.docx"
+ ["Docx comment 1 will not retain formatting"]
+ ]
+ , testGroup "media"
+ [ testMediaBag
+ "image extraction"
+ "docx/image.docx"
+ ]
+ , testGroup "metadata"
+ [ testCompareWithOpts def{readerStandalone=True}
+ "metadata fields"
+ "docx/metadata.docx"
+ "docx/metadata.native"
+ , testCompareWithOpts def{readerStandalone=True}
+ "stop recording metadata with normal text"
+ "docx/metadata_after_normal.docx"
+ "docx/metadata_after_normal.native"
+ ]
+
+ ]
diff --git a/test/Tests/Readers/EPUB.hs b/test/Tests/Readers/EPUB.hs
new file mode 100644
index 000000000..9190671c3
--- /dev/null
+++ b/test/Tests/Readers/EPUB.hs
@@ -0,0 +1,39 @@
+module Tests.Readers.EPUB (tests) where
+
+import Text.Pandoc.Options
+import Test.Framework
+import Test.HUnit (assertBool)
+import Test.Framework.Providers.HUnit
+import qualified Data.ByteString.Lazy as BL
+import Text.Pandoc.Readers.EPUB
+import Text.Pandoc.MediaBag (MediaBag, mediaDirectory)
+import qualified Text.Pandoc.Class as P
+
+getMediaBag :: FilePath -> IO MediaBag
+getMediaBag fp = do
+ bs <- BL.readFile fp
+ snd <$> (P.runIOorExplode $ P.withMediaBag $ readEPUB def bs)
+
+testMediaBag :: FilePath -> [(String, String, Int)] -> IO ()
+testMediaBag fp bag = do
+ actBag <- (mediaDirectory <$> getMediaBag fp)
+ assertBool (show "MediaBag did not match:\nExpected: "
+ ++ show bag
+ ++ "\nActual: "
+ ++ show actBag)
+ (actBag == bag)
+
+featuresBag :: [(String, String, Int)]
+featuresBag = [("img/check.gif","image/gif",1340)
+ ,("img/check.jpg","image/jpeg",2661)
+ ,("img/check.png","image/png",2815)
+ ,("img/multiscripts_and_greek_alphabet.png","image/png",10060)
+ ]
+
+tests :: [Test]
+tests =
+ [ testGroup "EPUB Mediabag"
+ [ testCase "features bag"
+ (testMediaBag "epub/img.epub" featuresBag)
+ ]
+ ]
diff --git a/test/Tests/Readers/HTML.hs b/test/Tests/Readers/HTML.hs
new file mode 100644
index 000000000..a1533e42a
--- /dev/null
+++ b/test/Tests/Readers/HTML.hs
@@ -0,0 +1,33 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Readers.HTML (tests) where
+
+import Text.Pandoc.Definition
+import Test.Framework
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+import Text.Pandoc.Builder
+import Text.Pandoc
+
+html :: String -> Pandoc
+html = purely $ readHtml def
+
+tests :: [Test]
+tests = [ testGroup "base tag"
+ [ test html "simple" $
+ "<head><base href=\"http://www.w3schools.com/images/foo\" ></head><body><img src=\"stickman.gif\" alt=\"Stickman\"></head>" =?>
+ plain (image "http://www.w3schools.com/images/stickman.gif" "" (text "Stickman"))
+ , test html "slash at end of base" $
+ "<head><base href=\"http://www.w3schools.com/images/\" ></head><body><img src=\"stickman.gif\" alt=\"Stickman\"></head>" =?>
+ plain (image "http://www.w3schools.com/images/stickman.gif" "" (text "Stickman"))
+ , test html "slash at beginning of href" $
+ "<head><base href=\"http://www.w3schools.com/images/\" ></head><body><img src=\"/stickman.gif\" alt=\"Stickman\"></head>" =?>
+ plain (image "http://www.w3schools.com/stickman.gif" "" (text "Stickman"))
+ , test html "absolute URL" $
+ "<head><base href=\"http://www.w3schools.com/images/\" ></head><body><img src=\"http://example.com/stickman.gif\" alt=\"Stickman\"></head>" =?>
+ plain (image "http://example.com/stickman.gif" "" (text "Stickman"))
+ ]
+ , testGroup "anchors"
+ [ test html "anchor without href" $ "<a name=\"anchor\"/>" =?>
+ plain (spanWith ("anchor",[],[]) mempty)
+ ]
+ ]
diff --git a/test/Tests/Readers/LaTeX.hs b/test/Tests/Readers/LaTeX.hs
new file mode 100644
index 000000000..d8572b15b
--- /dev/null
+++ b/test/Tests/Readers/LaTeX.hs
@@ -0,0 +1,226 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Readers.LaTeX (tests) where
+
+import Text.Pandoc.Definition
+import Test.Framework
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+import Text.Pandoc.Builder
+import Text.Pandoc
+
+latex :: String -> Pandoc
+latex = purely $ readLaTeX def{
+ readerExtensions = getDefaultExtensions "latex" }
+
+infix 4 =:
+(=:) :: ToString c
+ => String -> (String, c) -> Test
+(=:) = test latex
+
+simpleTable' :: [Alignment] -> [[Blocks]] -> Blocks
+simpleTable' aligns = table "" (zip aligns (repeat 0.0))
+ (map (const mempty) aligns)
+
+tests :: [Test]
+tests = [ testGroup "basic"
+ [ "simple" =:
+ "word" =?> para "word"
+ , "space" =:
+ "some text" =?> para "some text"
+ , "emphasized" =:
+ "\\emph{emphasized}" =?> para (emph "emphasized")
+ ]
+
+ , testGroup "headers"
+ [ "level 1" =:
+ "\\section{header}" =?> headerWith ("header",[],[]) 1 "header"
+ , "level 2" =:
+ "\\subsection{header}" =?> headerWith ("header",[],[]) 2 "header"
+ , "level 3" =:
+ "\\subsubsection{header}" =?> headerWith ("header",[],[]) 3 "header"
+ , "emph" =:
+ "\\section{text \\emph{emph}}" =?>
+ headerWith ("text-emph",[],[]) 1 ("text" <> space <> emph "emph")
+ , "link" =:
+ "\\section{text \\href{/url}{link}}" =?>
+ headerWith ("text-link",[],[]) 1 ("text" <> space <> link "/url" "" "link")
+ ]
+
+ , testGroup "math"
+ [ "escaped $" =:
+ "$x=\\$4$" =?> para (math "x=\\$4")
+ ]
+
+ , testGroup "space and comments"
+ [ "blank lines + space at beginning" =:
+ "\n \n hi" =?> para "hi"
+ , "blank lines + space + comments" =:
+ "% my comment\n\n \n % another\n\nhi" =?> para "hi"
+ , "comment in paragraph" =:
+ "hi % this is a comment\nthere\n" =?> para "hi there"
+ ]
+
+ , testGroup "code blocks"
+ [ "identifier" =:
+ "\\begin{lstlisting}[label=test]\\end{lstlisting}" =?> codeBlockWith ("test", [], [("label","test")]) ""
+ , "no identifier" =:
+ "\\begin{lstlisting}\\end{lstlisting}" =?> codeBlock ""
+ ]
+
+ , testGroup "tables"
+ [ "Single cell table" =:
+ "\\begin{tabular}{|l|}Test\\\\\\end{tabular}" =?>
+ simpleTable' [AlignLeft] [[plain "Test"]]
+ , "Multi cell table" =:
+ "\\begin{tabular}{|rl|}One & Two\\\\ \\end{tabular}" =?>
+ simpleTable' [AlignRight,AlignLeft] [[plain "One", plain "Two"]]
+ , "Multi line table" =:
+ unlines [ "\\begin{tabular}{|c|}"
+ , "One\\\\"
+ , "Two\\\\"
+ , "Three\\\\"
+ , "\\end{tabular}" ] =?>
+ simpleTable' [AlignCenter]
+ [[plain "One"], [plain "Two"], [plain "Three"]]
+ , "Empty table" =:
+ "\\begin{tabular}{}\\end{tabular}" =?>
+ simpleTable' [] []
+ , "Table with fixed column width" =:
+ "\\begin{tabular}{|p{5cm}r|}One & Two\\\\ \\end{tabular}" =?>
+ simpleTable' [AlignLeft,AlignRight] [[plain "One", plain "Two"]]
+ , "Table with empty column separators" =:
+ "\\begin{tabular}{@{}r@{}l}One & Two\\\\ \\end{tabular}" =?>
+ simpleTable' [AlignRight,AlignLeft] [[plain "One", plain "Two"]]
+ , "Table with custom column separators" =:
+ unlines [ "\\begin{tabular}{@{($\\to$)}r@{\\hspace{2cm}}l}"
+ , "One&Two\\\\"
+ , "\\end{tabular}" ] =?>
+ simpleTable' [AlignRight,AlignLeft] [[plain "One", plain "Two"]]
+ , "Table with vertical alignment argument" =:
+ "\\begin{tabular}[t]{r|r}One & Two\\\\ \\end{tabular}" =?>
+ simpleTable' [AlignRight,AlignRight] [[plain "One", plain "Two"]]
+ ]
+
+ , testGroup "citations"
+ [ natbibCitations
+ , biblatexCitations
+ ]
+
+ , let hex = ['0'..'9']++['a'..'f'] in
+ testGroup "Character Escapes"
+ [ "Two-character escapes" =:
+ concat ["^^"++[i,j] | i <- hex, j <- hex] =?>
+ para (str ['\0'..'\255'])
+ , "One-character escapes" =:
+ concat ["^^"++[i] | i <- hex] =?>
+ para (str $ ['p'..'y']++['!'..'&'])
+ ]
+ ]
+
+baseCitation :: Citation
+baseCitation = Citation{ citationId = "item1"
+ , citationPrefix = []
+ , citationSuffix = []
+ , citationMode = AuthorInText
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+
+rt :: String -> Inlines
+rt = rawInline "latex"
+
+natbibCitations :: Test
+natbibCitations = testGroup "natbib"
+ [ "citet" =: "\\citet{item1}"
+ =?> para (cite [baseCitation] (rt "\\citet{item1}"))
+ , "suffix" =: "\\citet[p.~30]{item1}"
+ =?> para
+ (cite [baseCitation{ citationSuffix = toList $ text "p.\160\&30" }] (rt "\\citet[p.~30]{item1}"))
+ , "suffix long" =: "\\citet[p.~30, with suffix]{item1}"
+ =?> para (cite [baseCitation{ citationSuffix =
+ toList $ text "p.\160\&30, with suffix" }] (rt "\\citet[p.~30, with suffix]{item1}"))
+ , "multiple" =: "\\citeauthor{item1} \\citetext{\\citeyear{item1}; \\citeyear[p.~30]{item2}; \\citealp[see also][]{item3}}"
+ =?> para (cite [baseCitation{ citationMode = AuthorInText }
+ ,baseCitation{ citationMode = SuppressAuthor
+ , citationSuffix = [Str "p.\160\&30"]
+ , citationId = "item2" }
+ ,baseCitation{ citationId = "item3"
+ , citationPrefix = [Str "see",Space,Str "also"]
+ , citationMode = NormalCitation }
+ ] (rt "\\citetext{\\citeyear{item1}; \\citeyear[p.~30]{item2}; \\citealp[see also][]{item3}}"))
+ , "group" =: "\\citetext{\\citealp[see][p.~34--35]{item1}; \\citealp[also][chap. 3]{item3}}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationPrefix = [Str "see"]
+ , citationSuffix = [Str "p.\160\&34\8211\&35"] }
+ ,baseCitation{ citationMode = NormalCitation
+ , citationId = "item3"
+ , citationPrefix = [Str "also"]
+ , citationSuffix = [Str "chap.",Space,Str "3"] }
+ ] (rt "\\citetext{\\citealp[see][p.~34--35]{item1}; \\citealp[also][chap. 3]{item3}}"))
+ , "suffix and locator" =: "\\citep[pp.~33, 35--37, and nowhere else]{item1}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationSuffix = [Str "pp.\160\&33,",Space,Str "35\8211\&37,",Space,Str "and",Space,Str "nowhere",Space, Str "else"] }] (rt "\\citep[pp.~33, 35--37, and nowhere else]{item1}"))
+ , "suffix only" =: "\\citep[and nowhere else]{item1}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationSuffix = toList $ text "and nowhere else" }] (rt "\\citep[and nowhere else]{item1}"))
+ , "no author" =: "\\citeyearpar{item1}, and now Doe with a locator \\citeyearpar[p.~44]{item2}"
+ =?> para (cite [baseCitation{ citationMode = SuppressAuthor }] (rt "\\citeyearpar{item1}") <>
+ text ", and now Doe with a locator " <>
+ cite [baseCitation{ citationMode = SuppressAuthor
+ , citationSuffix = [Str "p.\160\&44"]
+ , citationId = "item2" }] (rt "\\citeyearpar[p.~44]{item2}"))
+ , "markup" =: "\\citep[\\emph{see}][p. \\textbf{32}]{item1}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationPrefix = [Emph [Str "see"]]
+ , citationSuffix = [Str "p.",Space,
+ Strong [Str "32"]] }] (rt "\\citep[\\emph{see}][p. \\textbf{32}]{item1}"))
+ ]
+
+biblatexCitations :: Test
+biblatexCitations = testGroup "biblatex"
+ [ "textcite" =: "\\textcite{item1}"
+ =?> para (cite [baseCitation] (rt "\\textcite{item1}"))
+ , "suffix" =: "\\textcite[p.~30]{item1}"
+ =?> para
+ (cite [baseCitation{ citationSuffix = toList $ text "p.\160\&30" }] (rt "\\textcite[p.~30]{item1}"))
+ , "suffix long" =: "\\textcite[p.~30, with suffix]{item1}"
+ =?> para (cite [baseCitation{ citationSuffix =
+ toList $ text "p.\160\&30, with suffix" }] (rt "\\textcite[p.~30, with suffix]{item1}"))
+ , "multiple" =: "\\textcites{item1}[p.~30]{item2}[see also][]{item3}"
+ =?> para (cite [baseCitation{ citationMode = AuthorInText }
+ ,baseCitation{ citationMode = NormalCitation
+ , citationSuffix = [Str "p.\160\&30"]
+ , citationId = "item2" }
+ ,baseCitation{ citationId = "item3"
+ , citationPrefix = [Str "see",Space,Str "also"]
+ , citationMode = NormalCitation }
+ ] (rt "\\textcites{item1}[p.~30]{item2}[see also][]{item3}"))
+ , "group" =: "\\autocites[see][p.~34--35]{item1}[also][chap. 3]{item3}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationPrefix = [Str "see"]
+ , citationSuffix = [Str "p.\160\&34\8211\&35"] }
+ ,baseCitation{ citationMode = NormalCitation
+ , citationId = "item3"
+ , citationPrefix = [Str "also"]
+ , citationSuffix = [Str "chap.",Space,Str "3"] }
+ ] (rt "\\autocites[see][p.~34--35]{item1}[also][chap. 3]{item3}"))
+ , "suffix and locator" =: "\\autocite[pp.~33, 35--37, and nowhere else]{item1}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationSuffix = [Str "pp.\160\&33,",Space,Str "35\8211\&37,",Space,Str "and",Space,Str "nowhere",Space, Str "else"] }] (rt "\\autocite[pp.~33, 35--37, and nowhere else]{item1}"))
+ , "suffix only" =: "\\autocite[and nowhere else]{item1}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationSuffix = toList $ text "and nowhere else" }] (rt "\\autocite[and nowhere else]{item1}"))
+ , "no author" =: "\\autocite*{item1}, and now Doe with a locator \\autocite*[p.~44]{item2}"
+ =?> para (cite [baseCitation{ citationMode = SuppressAuthor }] (rt "\\autocite*{item1}") <>
+ text ", and now Doe with a locator " <>
+ cite [baseCitation{ citationMode = SuppressAuthor
+ , citationSuffix = [Str "p.\160\&44"]
+ , citationId = "item2" }] (rt "\\autocite*[p.~44]{item2}"))
+ , "markup" =: "\\autocite[\\emph{see}][p. \\textbf{32}]{item1}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation
+ , citationPrefix = [Emph [Str "see"]]
+ , citationSuffix = [Str "p.",Space,
+ Strong [Str "32"]] }] (rt "\\autocite[\\emph{see}][p. \\textbf{32}]{item1}"))
+ , "parencite" =: "\\parencite{item1}"
+ =?> para (cite [baseCitation{ citationMode = NormalCitation }] (rt "\\parencite{item1}"))
+ ]
diff --git a/test/Tests/Readers/Markdown.hs b/test/Tests/Readers/Markdown.hs
new file mode 100644
index 000000000..65edf7c38
--- /dev/null
+++ b/test/Tests/Readers/Markdown.hs
@@ -0,0 +1,461 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Readers.Markdown (tests) where
+
+import Text.Pandoc.Definition
+import Test.Framework
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+import Text.Pandoc.Builder
+import Text.Pandoc
+
+markdown :: String -> Pandoc
+markdown = purely $ readMarkdown def { readerExtensions =
+ disableExtension Ext_smart pandocExtensions }
+
+markdownSmart :: String -> Pandoc
+markdownSmart = purely $ readMarkdown def { readerExtensions =
+ enableExtension Ext_smart pandocExtensions }
+
+markdownCDL :: String -> Pandoc
+markdownCDL = purely $ readMarkdown def { readerExtensions = enableExtension
+ Ext_compact_definition_lists pandocExtensions }
+
+markdownGH :: String -> Pandoc
+markdownGH = purely $ readMarkdown def {
+ readerExtensions = githubMarkdownExtensions }
+
+infix 4 =:
+(=:) :: ToString c
+ => String -> (String, c) -> Test
+(=:) = test markdown
+
+testBareLink :: (String, Inlines) -> Test
+testBareLink (inp, ils) =
+ test (purely $ readMarkdown def{ readerExtensions =
+ extensionsFromList [Ext_autolink_bare_uris, Ext_raw_html] })
+ inp (inp, doc $ para ils)
+
+autolink :: String -> Inlines
+autolink = autolinkWith nullAttr
+
+autolinkWith :: Attr -> String -> Inlines
+autolinkWith attr s = linkWith attr s "" (str s)
+
+bareLinkTests :: [(String, Inlines)]
+bareLinkTests =
+ [ ("http://google.com is a search engine.",
+ autolink "http://google.com" <> " is a search engine.")
+ , ("<a href=\"http://foo.bar.baz\">http://foo.bar.baz</a>",
+ rawInline "html" "<a href=\"http://foo.bar.baz\">" <>
+ "http://foo.bar.baz" <> rawInline "html" "</a>")
+ , ("Try this query: http://google.com?search=fish&time=hour.",
+ "Try this query: " <> autolink "http://google.com?search=fish&time=hour" <> ".")
+ , ("HTTPS://GOOGLE.COM,",
+ autolink "HTTPS://GOOGLE.COM" <> ",")
+ , ("http://el.wikipedia.org/wiki/Τεχνολογία,",
+ autolink "http://el.wikipedia.org/wiki/Τεχνολογία" <> ",")
+ , ("doi:10.1000/182,",
+ autolink "doi:10.1000/182" <> ",")
+ , ("git://github.com/foo/bar.git,",
+ autolink "git://github.com/foo/bar.git" <> ",")
+ , ("file:///Users/joe/joe.txt, and",
+ autolink "file:///Users/joe/joe.txt" <> ", and")
+ , ("mailto:someone@somedomain.com.",
+ autolink "mailto:someone@somedomain.com" <> ".")
+ , ("Use http: this is not a link!",
+ "Use http: this is not a link!")
+ , ("(http://google.com).",
+ "(" <> autolink "http://google.com" <> ").")
+ , ("http://en.wikipedia.org/wiki/Sprite_(computer_graphics)",
+ autolink "http://en.wikipedia.org/wiki/Sprite_(computer_graphics)")
+ , ("http://en.wikipedia.org/wiki/Sprite_[computer_graphics]",
+ link "http://en.wikipedia.org/wiki/Sprite_%5Bcomputer_graphics%5D" ""
+ (str "http://en.wikipedia.org/wiki/Sprite_[computer_graphics]"))
+ , ("http://en.wikipedia.org/wiki/Sprite_{computer_graphics}",
+ link "http://en.wikipedia.org/wiki/Sprite_%7Bcomputer_graphics%7D" ""
+ (str "http://en.wikipedia.org/wiki/Sprite_{computer_graphics}"))
+ , ("http://example.com/Notification_Center-GitHub-20101108-140050.jpg",
+ autolink "http://example.com/Notification_Center-GitHub-20101108-140050.jpg")
+ , ("https://github.com/github/hubot/blob/master/scripts/cream.js#L20-20",
+ autolink "https://github.com/github/hubot/blob/master/scripts/cream.js#L20-20")
+ , ("http://www.rubyonrails.com",
+ autolink "http://www.rubyonrails.com")
+ , ("http://www.rubyonrails.com:80",
+ autolink "http://www.rubyonrails.com:80")
+ , ("http://www.rubyonrails.com/~minam",
+ autolink "http://www.rubyonrails.com/~minam")
+ , ("https://www.rubyonrails.com/~minam",
+ autolink "https://www.rubyonrails.com/~minam")
+ , ("http://www.rubyonrails.com/~minam/url%20with%20spaces",
+ autolink "http://www.rubyonrails.com/~minam/url%20with%20spaces")
+ , ("http://www.rubyonrails.com/foo.cgi?something=here",
+ autolink "http://www.rubyonrails.com/foo.cgi?something=here")
+ , ("http://www.rubyonrails.com/foo.cgi?something=here&and=here",
+ autolink "http://www.rubyonrails.com/foo.cgi?something=here&and=here")
+ , ("http://www.rubyonrails.com/contact;new",
+ autolink "http://www.rubyonrails.com/contact;new")
+ , ("http://www.rubyonrails.com/contact;new%20with%20spaces",
+ autolink "http://www.rubyonrails.com/contact;new%20with%20spaces")
+ , ("http://www.rubyonrails.com/contact;new?with=query&string=params",
+ autolink "http://www.rubyonrails.com/contact;new?with=query&string=params")
+ , ("http://www.rubyonrails.com/~minam/contact;new?with=query&string=params",
+ autolink "http://www.rubyonrails.com/~minam/contact;new?with=query&string=params")
+ , ("http://en.wikipedia.org/wiki/Wikipedia:Today%27s_featured_picture_%28animation%29/January_20%2C_2007",
+ autolink "http://en.wikipedia.org/wiki/Wikipedia:Today%27s_featured_picture_%28animation%29/January_20%2C_2007")
+ , ("http://www.mail-archive.com/rails@lists.rubyonrails.org/",
+ autolink "http://www.mail-archive.com/rails@lists.rubyonrails.org/")
+ , ("http://www.amazon.com/Testing-Equal-Sign-In-Path/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1198861734&sr=8-1",
+ autolink "http://www.amazon.com/Testing-Equal-Sign-In-Path/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1198861734&sr=8-1")
+ , ("http://en.wikipedia.org/wiki/Texas_hold%27em",
+ autolink "http://en.wikipedia.org/wiki/Texas_hold%27em")
+ , ("https://www.google.com/doku.php?id=gps:resource:scs:start",
+ autolink "https://www.google.com/doku.php?id=gps:resource:scs:start")
+ , ("http://www.rubyonrails.com",
+ autolink "http://www.rubyonrails.com")
+ , ("http://manuals.ruby-on-rails.com/read/chapter.need_a-period/103#page281",
+ autolink "http://manuals.ruby-on-rails.com/read/chapter.need_a-period/103#page281")
+ , ("http://foo.example.com/controller/action?parm=value&p2=v2#anchor123",
+ autolink "http://foo.example.com/controller/action?parm=value&p2=v2#anchor123")
+ , ("http://foo.example.com:3000/controller/action",
+ autolink "http://foo.example.com:3000/controller/action")
+ , ("http://foo.example.com:3000/controller/action+pack",
+ autolink "http://foo.example.com:3000/controller/action+pack")
+ , ("http://business.timesonline.co.uk/article/0,,9065-2473189,00.html",
+ autolink "http://business.timesonline.co.uk/article/0,,9065-2473189,00.html")
+ , ("http://www.mail-archive.com/ruby-talk@ruby-lang.org/",
+ autolink "http://www.mail-archive.com/ruby-talk@ruby-lang.org/")
+ , ("https://example.org/?anchor=lala-",
+ autolink "https://example.org/?anchor=lala-")
+ , ("https://example.org/?anchor=-lala",
+ autolink "https://example.org/?anchor=-lala")
+ ]
+
+{-
+p_markdown_round_trip :: Block -> Bool
+p_markdown_round_trip b = matches d' d''
+ where d' = normalize $ Pandoc (Meta [] [] []) [b]
+ d'' = normalize
+ $ readMarkdown def { readerSmart = True }
+ $ writeMarkdown def d'
+ matches (Pandoc _ [Plain []]) (Pandoc _ []) = True
+ matches (Pandoc _ [Para []]) (Pandoc _ []) = True
+ matches (Pandoc _ [Plain xs]) (Pandoc _ [Para xs']) = xs == xs'
+ matches x y = x == y
+-}
+
+tests :: [Test]
+tests = [ testGroup "inline code"
+ [ "with attribute" =:
+ "`document.write(\"Hello\");`{.javascript}"
+ =?> para
+ (codeWith ("",["javascript"],[]) "document.write(\"Hello\");")
+ , "with attribute space" =:
+ "`*` {.haskell .special x=\"7\"}"
+ =?> para (code "*" <> space <> str "{.haskell" <> space <>
+ str ".special" <> space <> str "x=\"7\"}")
+ ]
+ , testGroup "emph and strong"
+ [ "two strongs in emph" =:
+ "***a**b **c**d*" =?> para (emph (strong (str "a") <> str "b" <> space
+ <> strong (str "c") <> str "d"))
+ , "emph and strong emph alternating" =:
+ "*xxx* ***xxx*** xxx\n*xxx* ***xxx*** xxx"
+ =?> para (emph "xxx" <> space <> strong (emph "xxx") <>
+ space <> "xxx" <> softbreak <>
+ emph "xxx" <> space <> strong (emph "xxx") <>
+ space <> "xxx")
+ , "emph with spaced strong" =:
+ "*x **xx** x*"
+ =?> para (emph ("x" <> space <> strong "xx" <> space <> "x"))
+ , "intraword underscore with opening underscore (#1121)" =:
+ "_foot_ball_" =?> para (emph (text "foot_ball"))
+ ]
+ , testGroup "raw LaTeX"
+ [ "in URL" =:
+ "\\begin\n" =?> para (text "\\begin")
+ ]
+ , testGroup "raw HTML"
+ [ "nesting (issue #1330)" =:
+ "<del>test</del>" =?>
+ rawBlock "html" "<del>" <> plain (str "test") <>
+ rawBlock "html" "</del>"
+ , "invalid tag (issue #1820" =:
+ "</ div></.div>" =?>
+ para (text "</ div></.div>")
+ , "technically invalid comment" =:
+ "<!-- pandoc --help -->" =?>
+ rawBlock "html" "<!-- pandoc --help -->"
+ , test markdownGH "issue 2469" $
+ "<\n\na>" =?>
+ para (text "<") <> para (text "a>")
+ ]
+ , testGroup "raw email addresses"
+ [ test markdownGH "issue 2940" $
+ "**@user**" =?>
+ para (strong (text "@user"))
+ ]
+ , testGroup "emoji"
+ [ test markdownGH "emoji symbols" $
+ ":smile: and :+1:" =?> para (text "😄 and 👍")
+ ]
+ , "unbalanced brackets" =:
+ "[[[[[[[[[[[[[[[hi" =?> para (text "[[[[[[[[[[[[[[[hi")
+ , testGroup "backslash escapes"
+ [ "in URL" =:
+ "[hi](/there\\))"
+ =?> para (link "/there)" "" "hi")
+ , "in title" =:
+ "[hi](/there \"a\\\"a\")"
+ =?> para (link "/there" "a\"a" "hi")
+ , "in reference link title" =:
+ "[hi]\n\n[hi]: /there (a\\)a)"
+ =?> para (link "/there" "a)a" "hi")
+ , "in reference link URL" =:
+ "[hi]\n\n[hi]: /there\\.0"
+ =?> para (link "/there.0" "" "hi")
+ ]
+ , testGroup "bare URIs"
+ (map testBareLink bareLinkTests)
+ , testGroup "autolinks"
+ [ "with unicode dash following" =:
+ "<http://foo.bar>\8212" =?> para (autolink "http://foo.bar" <>
+ str "\8212")
+ , "a partial URL (#2277)" =:
+ "<www.boe.es/buscar/act.php?id=BOE-A-1996-8930#a66>" =?>
+ para (text "<www.boe.es/buscar/act.php?id=BOE-A-1996-8930#a66>")
+ , "with some attributes" =:
+ "<http://foo.bar>{#i .j .z k=v}" =?>
+ para (autolinkWith ("i", ["j", "z"], [("k", "v")]) "http://foo.bar")
+ , "with some attributes and spaces" =:
+ "<http://foo.bar> {#i .j .z k=v}" =?>
+ para (autolink "http://foo.bar" <> space <> text "{#i .j .z k=v}")
+ ]
+ , testGroup "links"
+ [ "no autolink inside link" =:
+ "[<https://example.org>](url)" =?>
+ para (link "url" "" (text "<https://example.org>"))
+ , "no inline link inside link" =:
+ "[[a](url2)](url)" =?>
+ para (link "url" "" (text "[a](url2)"))
+ , "no bare URI inside link" =:
+ "[https://example.org(](url)" =?>
+ para (link "url" "" (text "https://example.org("))
+ ]
+ , testGroup "Headers"
+ [ "blank line before header" =:
+ "\n# Header\n"
+ =?> headerWith ("header",[],[]) 1 "Header"
+ , "bracketed text (#2062)" =:
+ "# [hi]\n"
+ =?> headerWith ("hi",[],[]) 1 "[hi]"
+ , "ATX header without trailing #s" =:
+ "# Foo bar\n\n" =?>
+ headerWith ("foo-bar",[],[]) 1 "Foo bar"
+ , "ATX header without trailing #s" =:
+ "# Foo bar with # #" =?>
+ headerWith ("foo-bar-with",[],[]) 1 "Foo bar with #"
+ , "setext header" =:
+ "Foo bar\n=\n\n Foo bar 2 \n=" =?>
+ headerWith ("foo-bar",[],[]) 1 "Foo bar"
+ <> headerWith ("foo-bar-2",[],[]) 1 "Foo bar 2"
+ ]
+ , testGroup "Implicit header references"
+ [ "ATX header without trailing #s" =:
+ "# Header\n[header]\n\n[header ]\n\n[ header]" =?>
+ headerWith ("header",[],[]) 1 "Header"
+ <> para (link "#header" "" (text "header"))
+ <> para (link "#header" "" (text "header"))
+ <> para (link "#header" "" (text "header"))
+ , "ATX header with trailing #s" =:
+ "# Foo bar #\n[foo bar]\n\n[foo bar ]\n\n[ foo bar]" =?>
+ headerWith ("foo-bar",[],[]) 1 "Foo bar"
+ <> para (link "#foo-bar" "" (text "foo bar"))
+ <> para (link "#foo-bar" "" (text "foo bar"))
+ <> para (link "#foo-bar" "" (text "foo bar"))
+ , "setext header" =:
+ " Header \n=\n\n[header]\n\n[header ]\n\n[ header]" =?>
+ headerWith ("header",[],[]) 1 "Header"
+ <> para (link "#header" "" (text "header"))
+ <> para (link "#header" "" (text "header"))
+ <> para (link "#header" "" (text "header"))
+ ]
+ , testGroup "smart punctuation"
+ [ test markdownSmart "quote before ellipses"
+ ("'...hi'"
+ =?> para (singleQuoted "…hi"))
+ , test markdownSmart "apostrophe before emph"
+ ("D'oh! A l'*aide*!"
+ =?> para ("D’oh! A l’" <> emph "aide" <> "!"))
+ , test markdownSmart "apostrophe in French"
+ ("À l'arrivée de la guerre, le thème de l'«impossibilité du socialisme»"
+ =?> para "À l’arrivée de la guerre, le thème de l’«impossibilité du socialisme»")
+ , test markdownSmart "apostrophe after math" $ -- issue #1909
+ "The value of the $x$'s and the systems' condition." =?>
+ para (text "The value of the " <> math "x" <> text "\8217s and the systems\8217 condition.")
+ ]
+ , testGroup "footnotes"
+ [ "indent followed by newline and flush-left text" =:
+ "[^1]\n\n[^1]: my note\n\n \nnot in note\n"
+ =?> para (note (para "my note")) <> para "not in note"
+ , "indent followed by newline and indented text" =:
+ "[^1]\n\n[^1]: my note\n \n in note\n"
+ =?> para (note (para "my note" <> para "in note"))
+ , "recursive note" =:
+ "[^1]\n\n[^1]: See [^1]\n"
+ =?> para (note (para "See [^1]"))
+ ]
+ , testGroup "lhs"
+ [ test (purely $ readMarkdown def{ readerExtensions = enableExtension
+ Ext_literate_haskell pandocExtensions })
+ "inverse bird tracks and html" $
+ "> a\n\n< b\n\n<div>\n"
+ =?> codeBlockWith ("",["sourceCode","literate","haskell"],[]) "a"
+ <>
+ codeBlockWith ("",["sourceCode","haskell"],[]) "b"
+ <>
+ rawBlock "html" "<div>\n\n"
+ ]
+-- the round-trip properties frequently fail
+-- , testGroup "round trip"
+-- [ property "p_markdown_round_trip" p_markdown_round_trip
+-- ]
+ , testGroup "definition lists"
+ [ "no blank space" =:
+ "foo1\n : bar\n\nfoo2\n : bar2\n : bar3\n" =?>
+ definitionList [ (text "foo1", [plain (text "bar")])
+ , (text "foo2", [plain (text "bar2"),
+ plain (text "bar3")])
+ ]
+ , "blank space before first def" =:
+ "foo1\n\n : bar\n\nfoo2\n\n : bar2\n : bar3\n" =?>
+ definitionList [ (text "foo1", [para (text "bar")])
+ , (text "foo2", [para (text "bar2"),
+ plain (text "bar3")])
+ ]
+ , "blank space before second def" =:
+ "foo1\n : bar\n\nfoo2\n : bar2\n\n : bar3\n" =?>
+ definitionList [ (text "foo1", [plain (text "bar")])
+ , (text "foo2", [plain (text "bar2"),
+ para (text "bar3")])
+ ]
+ , "laziness" =:
+ "foo1\n : bar\nbaz\n : bar2\n" =?>
+ definitionList [ (text "foo1", [plain (text "bar" <>
+ softbreak <> text "baz"),
+ plain (text "bar2")])
+ ]
+ , "no blank space before first of two paragraphs" =:
+ "foo1\n : bar\n\n baz\n" =?>
+ definitionList [ (text "foo1", [para (text "bar") <>
+ para (text "baz")])
+ ]
+ , "first line not indented" =:
+ "foo\n: bar\n" =?>
+ definitionList [ (text "foo", [plain (text "bar")]) ]
+ , "list in definition" =:
+ "foo\n: - bar\n" =?>
+ definitionList [ (text "foo", [bulletList [plain (text "bar")]]) ]
+ , "in div" =:
+ "<div>foo\n: - bar\n</div>" =?>
+ divWith nullAttr (definitionList
+ [ (text "foo", [bulletList [plain (text "bar")]]) ])
+ ]
+ , testGroup "+compact_definition_lists"
+ [ test markdownCDL "basic compact list" $
+ "foo1\n: bar\n baz\nfoo2\n: bar2\n" =?>
+ definitionList [ (text "foo1", [plain (text "bar" <> softbreak <>
+ text "baz")])
+ , (text "foo2", [plain (text "bar2")])
+ ]
+ ]
+ , testGroup "lists"
+ [ "issue #1154" =:
+ " - <div>\n first div breaks\n </div>\n\n <button>if this button exists</button>\n\n <div>\n with this div too.\n </div>\n"
+ =?> bulletList [divWith nullAttr (para $ text "first div breaks") <>
+ rawBlock "html" "<button>" <>
+ plain (text "if this button exists") <>
+ rawBlock "html" "</button>" <>
+ divWith nullAttr (para $ text "with this div too.")]
+ , test markdownGH "issue #1636" $
+ unlines [ "* a"
+ , "* b"
+ , "* c"
+ , " * d" ]
+ =?>
+ bulletList [ plain "a"
+ , plain "b"
+ , plain "c" <> bulletList [plain "d"] ]
+ ]
+ , testGroup "entities"
+ [ "character references" =:
+ "&lang; &ouml;" =?> para (text "\10216 ö")
+ , "numeric" =:
+ "&#44;&#x44;&#X44;" =?> para (text ",DD")
+ , "in link title" =:
+ "[link](/url \"title &lang; &ouml; &#44;\")" =?>
+ para (link "/url" "title \10216 ö ," (text "link"))
+ ]
+ , testGroup "citations"
+ [ "simple" =:
+ "@item1" =?> para (cite [
+ Citation{ citationId = "item1"
+ , citationPrefix = []
+ , citationSuffix = []
+ , citationMode = AuthorInText
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+ ] "@item1")
+ , "key starts with digit" =:
+ "@1657:huyghens" =?> para (cite [
+ Citation{ citationId = "1657:huyghens"
+ , citationPrefix = []
+ , citationSuffix = []
+ , citationMode = AuthorInText
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+ ] "@1657:huyghens")
+ ]
+ , let citation = cite [Citation "cita" [] [] AuthorInText 0 0] (str "@cita")
+ in testGroup "footnote/link following citation" -- issue #2083
+ [ "footnote" =:
+ unlines [ "@cita[^note]"
+ , ""
+ , "[^note]: note" ] =?>
+ para (
+ citation <> note (para $ str "note")
+ )
+ , "normal link" =:
+ "@cita [link](http://www.com)" =?>
+ para (
+ citation <> space <> link "http://www.com" "" (str "link")
+ )
+ , "reference link" =:
+ unlines [ "@cita [link][link]"
+ , ""
+ , "[link]: http://www.com" ] =?>
+ para (
+ citation <> space <> link "http://www.com" "" (str "link")
+ )
+ , "short reference link" =:
+ unlines [ "@cita [link]"
+ , ""
+ , "[link]: http://www.com" ] =?>
+ para (
+ citation <> space <> link "http://www.com" "" (str "link")
+ )
+ , "implicit header link" =:
+ unlines [ "# Header"
+ , "@cita [Header]" ] =?>
+ headerWith ("header",[],[]) 1 (str "Header") <> para (
+ citation <> space <> link "#header" "" (str "Header")
+ )
+ , "regular citation" =:
+ "@cita [foo]" =?>
+ para (
+ cite [Citation "cita" [] [Str "foo"] AuthorInText 0 0]
+ (str "@cita" <> space <> str "[foo]")
+ )
+ ]
+ ]
diff --git a/test/Tests/Readers/Odt.hs b/test/Tests/Readers/Odt.hs
new file mode 100644
index 000000000..653252c5c
--- /dev/null
+++ b/test/Tests/Readers/Odt.hs
@@ -0,0 +1,165 @@
+module Tests.Readers.Odt (tests) where
+
+import Control.Monad ( liftM )
+import Text.Pandoc
+import Tests.Helpers
+import Test.Framework
+import qualified Data.ByteString.Lazy as B
+import qualified Data.Map as M
+
+defopts :: ReaderOptions
+defopts = def{ readerExtensions = getDefaultExtensions "odt" }
+
+tests :: [Test]
+tests = testsComparingToMarkdown ++ testsComparingToNative
+
+testsComparingToMarkdown :: [Test]
+testsComparingToMarkdown = map nameToTest namesOfTestsComparingToMarkdown
+ where nameToTest name = createTest
+ compareOdtToMarkdown
+ name
+ (toOdtPath name)
+ (toMarkdownPath name)
+ toOdtPath name = "odt/odt/" ++ name ++ ".odt"
+ toMarkdownPath name = "odt/markdown/" ++ name ++ ".md"
+
+testsComparingToNative :: [Test]
+testsComparingToNative = map nameToTest namesOfTestsComparingToNative
+ where nameToTest name = createTest
+ compareOdtToNative
+ name
+ (toOdtPath name)
+ (toNativePath name)
+ toOdtPath name = "odt/odt/" ++ name ++ ".odt"
+ toNativePath name = "odt/native/" ++ name ++ ".native"
+
+
+newtype NoNormPandoc = NoNormPandoc {unNoNorm :: Pandoc}
+ deriving ( Show )
+
+instance ToString NoNormPandoc where
+ toString d = purely (writeNative def{ writerTemplate = s }) $ toPandoc d
+ where s = case d of
+ NoNormPandoc (Pandoc (Meta m) _)
+ | M.null m -> Nothing
+ | otherwise -> Just "" -- need this for Meta output
+
+instance ToPandoc NoNormPandoc where
+ toPandoc = unNoNorm
+
+getNoNormVia :: (a -> Pandoc) -> String -> Either PandocError a -> NoNormPandoc
+getNoNormVia _ readerName (Left _) = error (readerName ++ " reader failed")
+getNoNormVia f _ (Right a) = NoNormPandoc (f a)
+
+type TestCreator = ReaderOptions
+ -> FilePath -> FilePath
+ -> IO (NoNormPandoc, NoNormPandoc)
+
+compareOdtToNative :: TestCreator
+compareOdtToNative opts odtPath nativePath = do
+ nativeFile <- Prelude.readFile nativePath
+ odtFile <- B.readFile odtPath
+ native <- getNoNormVia id "native" <$> runIO (readNative def nativeFile)
+ odt <- getNoNormVia id "odt" <$> runIO (readOdt opts odtFile)
+ return (odt,native)
+
+compareOdtToMarkdown :: TestCreator
+compareOdtToMarkdown opts odtPath markdownPath = do
+ markdownFile <- Prelude.readFile markdownPath
+ odtFile <- B.readFile odtPath
+ markdown <- getNoNormVia id "markdown" <$>
+ runIO (readMarkdown def{ readerExtensions = pandocExtensions }
+ markdownFile)
+ odt <- getNoNormVia id "odt" <$> runIO (readOdt opts odtFile)
+ return (odt,markdown)
+
+
+createTest :: TestCreator
+ -> TestName
+ -> FilePath -> FilePath
+ -> Test
+createTest creator name path1 path2 =
+ buildTest $ liftM (test id name) (creator defopts path1 path2)
+
+{-
+--
+
+getMedia :: FilePath -> FilePath -> IO (Maybe B.ByteString)
+getMedia archivePath mediaPath = do
+ zf <- B.readFile archivePath >>= return . toArchive
+ return $ findEntryByPath ("Pictures/" ++ mediaPath) zf >>= (Just . fromEntry)
+
+compareMediaPathIO :: FilePath -> MediaBag -> FilePath -> IO Bool
+compareMediaPathIO mediaPath mediaBag odtPath = do
+ odtMedia <- getMedia odtPath mediaPath
+ let mbBS = case lookupMedia mediaPath mediaBag of
+ Just (_, bs) -> bs
+ Nothing -> error ("couldn't find " ++
+ mediaPath ++
+ " in media bag")
+ odtBS = case odtMedia of
+ Just bs -> bs
+ Nothing -> error ("couldn't find " ++
+ mediaPath ++
+ " in media bag")
+ return $ mbBS == odtBS
+
+compareMediaBagIO :: FilePath -> IO Bool
+compareMediaBagIO odtFile = do
+ df <- B.readFile odtFile
+ let (_, mb) = readOdt def df
+ bools <- mapM
+ (\(fp, _, _) -> compareMediaPathIO fp mb odtFile)
+ (mediaDirectory mb)
+ return $ and bools
+
+testMediaBagIO :: String -> FilePath -> IO Test
+testMediaBagIO name odtFile = do
+ outcome <- compareMediaBagIO odtFile
+ return $ testCase name (assertBool
+ ("Media didn't match media bag in file " ++ odtFile)
+ outcome)
+
+testMediaBag :: String -> FilePath -> Test
+testMediaBag name odtFile = buildTest $ testMediaBagIO name odtFile
+-}
+--
+
+
+
+namesOfTestsComparingToMarkdown :: [ String ]
+namesOfTestsComparingToMarkdown = [ "bold"
+-- , "citation"
+ , "endnote"
+ , "externalLink"
+ , "footnote"
+ , "headers"
+-- , "horizontalRule"
+ , "italic"
+-- , "listBlocks"
+ , "paragraph"
+ , "strikeout"
+-- , "trackedChanges"
+ , "underlined"
+ ]
+
+namesOfTestsComparingToNative :: [ String ]
+namesOfTestsComparingToNative = [ "blockquote"
+ , "image"
+ , "imageIndex"
+ , "imageWithCaption"
+ , "inlinedCode"
+ , "orderedListMixed"
+ , "orderedListRoman"
+ , "orderedListSimple"
+ , "referenceToChapter"
+ , "referenceToListItem"
+ , "referenceToText"
+ , "simpleTable"
+ , "simpleTableWithCaption"
+-- , "table"
+ , "textMixedStyles"
+ , "tableWithContents"
+ , "unicode"
+ , "unorderedList"
+ ]
diff --git a/test/Tests/Readers/Org.hs b/test/Tests/Readers/Org.hs
new file mode 100644
index 000000000..ef0530b37
--- /dev/null
+++ b/test/Tests/Readers/Org.hs
@@ -0,0 +1,1724 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Readers.Org (tests) where
+
+import Text.Pandoc.Definition
+import Test.Framework
+import Tests.Helpers
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Data.List (intersperse)
+
+org :: String -> Pandoc
+org = purely $ readOrg def{ readerExtensions = getDefaultExtensions "org" }
+
+orgSmart :: String -> Pandoc
+orgSmart = purely $ readOrg def { readerExtensions =
+ enableExtension Ext_smart $ getDefaultExtensions "org" }
+
+infix 4 =:
+(=:) :: ToString c
+ => String -> (String, c) -> Test
+(=:) = test org
+
+spcSep :: [Inlines] -> Inlines
+spcSep = mconcat . intersperse space
+
+simpleTable' :: Int
+ -> [Blocks]
+ -> [[Blocks]]
+ -> Blocks
+simpleTable' n = table "" (take n $ repeat (AlignDefault, 0.0))
+
+tests :: [Test]
+tests =
+ [ testGroup "Inlines" $
+ [ "Plain String" =:
+ "Hello, World" =?>
+ para (spcSep [ "Hello,", "World" ])
+
+ , "Emphasis" =:
+ "/Planet Punk/" =?>
+ para (emph . spcSep $ ["Planet", "Punk"])
+
+ , "Strong" =:
+ "*Cider*" =?>
+ para (strong "Cider")
+
+ , "Strong Emphasis" =:
+ "/*strength*/" =?>
+ para (emph . strong $ "strength")
+
+ , "Emphasized Strong preceded by space" =:
+ " */super/*" =?>
+ para (strong . emph $ "super")
+
+ , "Strikeout" =:
+ "+Kill Bill+" =?>
+ para (strikeout . spcSep $ [ "Kill", "Bill" ])
+
+ , "Verbatim" =:
+ "=Robot.rock()=" =?>
+ para (code "Robot.rock()")
+
+ , "Code" =:
+ "~word for word~" =?>
+ para (code "word for word")
+
+ , "Math $..$" =:
+ "$E=mc^2$" =?>
+ para (math "E=mc^2")
+
+ , "Math $$..$$" =:
+ "$$E=mc^2$$" =?>
+ para (displayMath "E=mc^2")
+
+ , "Math \\[..\\]" =:
+ "\\[E=ℎν\\]" =?>
+ para (displayMath "E=ℎν")
+
+ , "Math \\(..\\)" =:
+ "\\(σ_x σ_p ≥ \\frac{ℏ}{2}\\)" =?>
+ para (math "σ_x σ_p ≥ \\frac{ℏ}{2}")
+
+ , "Symbol" =:
+ "A * symbol" =?>
+ para (str "A" <> space <> str "*" <> space <> "symbol")
+
+ , "Superscript simple expression" =:
+ "2^-λ" =?>
+ para (str "2" <> superscript "-λ")
+
+ , "Superscript multi char" =:
+ "2^{n-1}" =?>
+ para (str "2" <> superscript "n-1")
+
+ , "Subscript simple expression" =:
+ "a_n" =?>
+ para (str "a" <> subscript "n")
+
+ , "Subscript multi char" =:
+ "a_{n+1}" =?>
+ para (str "a" <> subscript "n+1")
+
+ , "Linebreak" =:
+ "line \\\\ \nbreak" =?>
+ para ("line" <> linebreak <> "break")
+
+ , "Inline note" =:
+ "[fn::Schreib mir eine E-Mail]" =?>
+ para (note $ para "Schreib mir eine E-Mail")
+
+ , "Markup-chars not occuring on word break are symbols" =:
+ unlines [ "this+that+ +so+on"
+ , "seven*eight* nine*"
+ , "+not+funny+"
+ ] =?>
+ para ("this+that+ +so+on" <> softbreak <>
+ "seven*eight* nine*" <> softbreak <>
+ strikeout "not+funny")
+
+ , "No empty markup" =:
+ "// ** __ ++ == ~~ $$" =?>
+ para (spcSep [ "//", "**", "__", "++", "==", "~~", "$$" ])
+
+ , "Adherence to Org's rules for markup borders" =:
+ "/t/& a/ / ./r/ (*l*) /e/! /b/." =?>
+ para (spcSep [ emph $ "t/&" <> space <> "a"
+ , "/"
+ , "./r/"
+ , "(" <> (strong "l") <> ")"
+ , (emph "e") <> "!"
+ , (emph "b") <> "."
+ ])
+
+ , "Quotes are forbidden border chars" =:
+ "/'nope/ *nope\"*" =?>
+ para ("/'nope/" <> space <> "*nope\"*")
+
+ , "Commata are forbidden border chars" =:
+ "/nada,/" =?>
+ para "/nada,/"
+
+ , "Markup should work properly after a blank line" =:
+ unlines ["foo", "", "/bar/"] =?>
+ (para $ text "foo") <> (para $ emph $ text "bar")
+
+ , "Inline math must stay within three lines" =:
+ unlines [ "$a", "b", "c$", "$d", "e", "f", "g$" ] =?>
+ para ((math "a\nb\nc") <> softbreak <>
+ "$d" <> softbreak <> "e" <> softbreak <>
+ "f" <> softbreak <> "g$")
+
+ , "Single-character math" =:
+ "$a$ $b$! $c$?" =?>
+ para (spcSep [ math "a"
+ , "$b$!"
+ , (math "c") <> "?"
+ ])
+
+ , "Markup may not span more than two lines" =:
+ "/this *is +totally\nnice+ not*\nemph/" =?>
+ para ("/this" <> space <>
+ strong ("is" <> space <>
+ strikeout ("totally" <>
+ softbreak <> "nice") <>
+ space <> "not") <>
+ softbreak <> "emph/")
+
+ , "Sub- and superscript expressions" =:
+ unlines [ "a_(a(b)(c)d)"
+ , "e^(f(g)h)"
+ , "i_(jk)l)"
+ , "m^()n"
+ , "o_{p{q{}r}}"
+ , "s^{t{u}v}"
+ , "w_{xy}z}"
+ , "1^{}2"
+ , "3_{{}}"
+ , "4^(a(*b(c*)d))"
+ ] =?>
+ para (mconcat $ intersperse softbreak
+ [ "a" <> subscript "(a(b)(c)d)"
+ , "e" <> superscript "(f(g)h)"
+ , "i" <> (subscript "(jk)") <> "l)"
+ , "m" <> (superscript "()") <> "n"
+ , "o" <> subscript "p{q{}r}"
+ , "s" <> superscript "t{u}v"
+ , "w" <> (subscript "xy") <> "z}"
+ , "1" <> (superscript "") <> "2"
+ , "3" <> subscript "{}"
+ , "4" <> superscript ("(a(" <> strong "b(c" <> ")d))")
+ ])
+ , "Verbatim text can contain equal signes (=)" =:
+ "=is_subst = True=" =?>
+ para (code "is_subst = True")
+
+ , testGroup "Images"
+ [ "Image" =:
+ "[[./sunset.jpg]]" =?>
+ (para $ image "./sunset.jpg" "" "")
+
+ , "Image with explicit file: prefix" =:
+ "[[file:sunrise.jpg]]" =?>
+ (para $ image "sunrise.jpg" "" "")
+
+ , "Multiple images within a paragraph" =:
+ unlines [ "[[file:sunrise.jpg]]"
+ , "[[file:sunset.jpg]]"
+ ] =?>
+ (para $ (image "sunrise.jpg" "" "")
+ <> softbreak
+ <> (image "sunset.jpg" "" ""))
+
+ , "Image with html attributes" =:
+ unlines [ "#+ATTR_HTML: :width 50%"
+ , "[[file:guinea-pig.gif]]"
+ ] =?>
+ (para $ imageWith ("", [], [("width", "50%")]) "guinea-pig.gif" "" "")
+ ]
+
+ , "Explicit link" =:
+ "[[http://zeitlens.com/][pseudo-random /nonsense/]]" =?>
+ (para $ link "http://zeitlens.com/" ""
+ ("pseudo-random" <> space <> emph "nonsense"))
+
+ , "Self-link" =:
+ "[[http://zeitlens.com/]]" =?>
+ (para $ link "http://zeitlens.com/" "" "http://zeitlens.com/")
+
+ , "Absolute file link" =:
+ "[[/url][hi]]" =?>
+ (para $ link "file:///url" "" "hi")
+
+ , "Link to file in parent directory" =:
+ "[[../file.txt][moin]]" =?>
+ (para $ link "../file.txt" "" "moin")
+
+ , "Empty link (for gitit interop)" =:
+ "[[][New Link]]" =?>
+ (para $ link "" "" "New Link")
+
+ , "Image link" =:
+ "[[sunset.png][file:dusk.svg]]" =?>
+ (para $ link "sunset.png" "" (image "dusk.svg" "" ""))
+
+ , "Image link with non-image target" =:
+ "[[http://example.com][./logo.png]]" =?>
+ (para $ link "http://example.com" "" (image "./logo.png" "" ""))
+
+ , "Plain link" =:
+ "Posts on http://zeitlens.com/ can be funny at times." =?>
+ (para $ spcSep [ "Posts", "on"
+ , link "http://zeitlens.com/" "" "http://zeitlens.com/"
+ , "can", "be", "funny", "at", "times."
+ ])
+
+ , "Angle link" =:
+ "Look at <http://moltkeplatz.de> for fnords." =?>
+ (para $ spcSep [ "Look", "at"
+ , link "http://moltkeplatz.de" "" "http://moltkeplatz.de"
+ , "for", "fnords."
+ ])
+
+ , "Absolute file link" =:
+ "[[file:///etc/passwd][passwd]]" =?>
+ (para $ link "file:///etc/passwd" "" "passwd")
+
+ , "File link" =:
+ "[[file:target][title]]" =?>
+ (para $ link "target" "" "title")
+
+ , "Anchor" =:
+ "<<anchor>> Link here later." =?>
+ (para $ spanWith ("anchor", [], []) mempty <>
+ "Link" <> space <> "here" <> space <> "later.")
+
+ , "Inline code block" =:
+ "src_emacs-lisp{(message \"Hello\")}" =?>
+ (para $ codeWith ( ""
+ , [ "commonlisp", "rundoc-block" ]
+ , [ ("rundoc-language", "emacs-lisp") ])
+ "(message \"Hello\")")
+
+ , "Inline code block with arguments" =:
+ "src_sh[:export both :results output]{echo 'Hello, World'}" =?>
+ (para $ codeWith ( ""
+ , [ "bash", "rundoc-block" ]
+ , [ ("rundoc-language", "sh")
+ , ("rundoc-export", "both")
+ , ("rundoc-results", "output")
+ ]
+ )
+ "echo 'Hello, World'")
+
+ , "Inline code block with toggle" =:
+ "src_sh[:toggle]{echo $HOME}" =?>
+ (para $ codeWith ( ""
+ , [ "bash", "rundoc-block" ]
+ , [ ("rundoc-language", "sh")
+ , ("rundoc-toggle", "yes")
+ ]
+ )
+ "echo $HOME")
+
+ , "Citation" =:
+ "[@nonexistent]" =?>
+ let citation = Citation
+ { citationId = "nonexistent"
+ , citationPrefix = []
+ , citationSuffix = []
+ , citationMode = NormalCitation
+ , citationNoteNum = 0
+ , citationHash = 0}
+ in (para $ cite [citation] "[@nonexistent]")
+
+ , "Citation containing text" =:
+ "[see @item1 p. 34-35]" =?>
+ let citation = Citation
+ { citationId = "item1"
+ , citationPrefix = [Str "see"]
+ , citationSuffix = [Space ,Str "p.",Space,Str "34-35"]
+ , citationMode = NormalCitation
+ , citationNoteNum = 0
+ , citationHash = 0}
+ in (para $ cite [citation] "[see @item1 p. 34-35]")
+
+ , "Org-ref simple citation" =:
+ "cite:pandoc" =?>
+ let citation = Citation
+ { citationId = "pandoc"
+ , citationPrefix = mempty
+ , citationSuffix = mempty
+ , citationMode = AuthorInText
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+ in (para $ cite [citation] "cite:pandoc")
+
+ , "Org-ref simple citation succeeded by comma" =:
+ "cite:pandoc," =?>
+ let citation = Citation
+ { citationId = "pandoc"
+ , citationPrefix = mempty
+ , citationSuffix = mempty
+ , citationMode = AuthorInText
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+ in (para $ cite [citation] "cite:pandoc" <> str ",")
+
+ , "Org-ref simple citep citation" =:
+ "citep:pandoc" =?>
+ let citation = Citation
+ { citationId = "pandoc"
+ , citationPrefix = mempty
+ , citationSuffix = mempty
+ , citationMode = NormalCitation
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+ in (para $ cite [citation] "citep:pandoc")
+
+ , "Org-ref extended citation" =:
+ "[[citep:Dominik201408][See page 20::, for example]]" =?>
+ let citation = Citation
+ { citationId = "Dominik201408"
+ , citationPrefix = toList "See page 20"
+ , citationSuffix = toList ", for example"
+ , citationMode = NormalCitation
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+ in (para $ cite [citation] "[[citep:Dominik201408][See page 20::, for example]]")
+
+ , testGroup "Berkeley-style citations" $
+ let pandocCite = Citation
+ { citationId = "Pandoc"
+ , citationPrefix = mempty
+ , citationSuffix = mempty
+ , citationMode = NormalCitation
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+ pandocInText = pandocCite { citationMode = AuthorInText }
+ dominikCite = Citation
+ { citationId = "Dominik201408"
+ , citationPrefix = mempty
+ , citationSuffix = mempty
+ , citationMode = NormalCitation
+ , citationNoteNum = 0
+ , citationHash = 0
+ }
+ dominikInText = dominikCite { citationMode = AuthorInText }
+ in [
+ "Berkeley-style in-text citation" =:
+ "See @Dominik201408." =?>
+ (para $ "See "
+ <> cite [dominikInText] "@Dominik201408"
+ <> ".")
+
+ , "Berkeley-style parenthetical citation list" =:
+ "[(cite): see; @Dominik201408;also @Pandoc; and others]" =?>
+ let pandocCite' = pandocCite {
+ citationPrefix = toList "also"
+ , citationSuffix = toList "and others"
+ }
+ dominikCite' = dominikCite {
+ citationPrefix = toList "see"
+ }
+ in (para $ cite [dominikCite', pandocCite'] "")
+
+ , "Berkeley-style plain citation list" =:
+ "[cite: See; @Dominik201408; and @Pandoc; and others]" =?>
+ let pandocCite' = pandocInText {
+ citationPrefix = toList "and"
+ }
+ in (para $ "See "
+ <> cite [dominikInText] ""
+ <> "," <> space
+ <> cite [pandocCite'] ""
+ <> "," <> space <> "and others")
+ ]
+
+ , "Inline LaTeX symbol" =:
+ "\\dots" =?>
+ para "…"
+
+ , "Inline LaTeX command" =:
+ "\\textit{Emphasised}" =?>
+ para (emph "Emphasised")
+
+ , "Inline LaTeX command with spaces" =:
+ "\\emph{Emphasis mine}" =?>
+ para (emph "Emphasis mine")
+
+ , "Inline LaTeX math symbol" =:
+ "\\tau" =?>
+ para (emph "τ")
+
+ , "Unknown inline LaTeX command" =:
+ "\\notacommand{foo}" =?>
+ para (rawInline "latex" "\\notacommand{foo}")
+
+ , "Export snippet" =:
+ "@@html:<kbd>M-x org-agenda</kbd>@@" =?>
+ para (rawInline "html" "<kbd>M-x org-agenda</kbd>")
+
+ , "MathML symbol in LaTeX-style" =:
+ "There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: '\\nbsp')." =?>
+ para ("There is a hackerspace in Lübeck, Germany, called nbsp (unicode symbol: ' ').")
+
+ , "MathML symbol in LaTeX-style, including braces" =:
+ "\\Aacute{}stor" =?>
+ para "Ástor"
+
+ , "MathML copy sign" =:
+ "\\copy" =?>
+ para "©"
+
+ , "MathML symbols, space separated" =:
+ "\\ForAll \\Auml" =?>
+ para "∀ Ä"
+
+ , "LaTeX citation" =:
+ "\\cite{Coffee}" =?>
+ let citation = Citation
+ { citationId = "Coffee"
+ , citationPrefix = []
+ , citationSuffix = []
+ , citationMode = NormalCitation
+ , citationNoteNum = 0
+ , citationHash = 0}
+ in (para . cite [citation] $ rawInline "latex" "\\cite{Coffee}")
+ ]
+
+ , testGroup "Meta Information" $
+ [ "Comment" =:
+ "# Nothing to see here" =?>
+ (mempty::Blocks)
+
+ , "Not a comment" =:
+ "#-tag" =?>
+ para "#-tag"
+
+ , "Comment surrounded by Text" =:
+ unlines [ "Before"
+ , "# Comment"
+ , "After"
+ ] =?>
+ mconcat [ para "Before"
+ , para "After"
+ ]
+
+ , "Title" =:
+ "#+TITLE: Hello, World" =?>
+ let titleInline = toList $ "Hello," <> space <> "World"
+ meta = setMeta "title" (MetaInlines titleInline) $ nullMeta
+ in Pandoc meta mempty
+
+ , "Author" =:
+ "#+author: Albert /Emacs-Fanboy/ Krewinkel" =?>
+ let author = toList . spcSep $ [ "Albert", emph "Emacs-Fanboy", "Krewinkel" ]
+ meta = setMeta "author" (MetaList [MetaInlines author]) $ nullMeta
+ in Pandoc meta mempty
+
+ , "Multiple authors" =:
+ "#+author: James Dewey Watson, Francis Harry Compton Crick " =?>
+ let watson = MetaInlines $ toList "James Dewey Watson"
+ crick = MetaInlines $ toList "Francis Harry Compton Crick"
+ meta = setMeta "author" (MetaList [watson, crick]) $ nullMeta
+ in Pandoc meta mempty
+
+ , "Date" =:
+ "#+Date: Feb. *28*, 2014" =?>
+ let date = toList . spcSep $ [ "Feb.", (strong "28") <> ",", "2014" ]
+ meta = setMeta "date" (MetaInlines date) $ nullMeta
+ in Pandoc meta mempty
+
+ , "Description" =:
+ "#+DESCRIPTION: Explanatory text" =?>
+ let description = "Explanatory text"
+ meta = setMeta "description" (MetaString description) $ nullMeta
+ in Pandoc meta mempty
+
+ , "Properties drawer" =:
+ unlines [ " :PROPERTIES:"
+ , " :setting: foo"
+ , " :END:"
+ ] =?>
+ (mempty::Blocks)
+
+ , "LaTeX_headers options are translated to header-includes" =:
+ "#+LaTeX_header: \\usepackage{tikz}" =?>
+ let latexInlines = rawInline "latex" "\\usepackage{tikz}"
+ inclList = MetaList [MetaInlines (toList latexInlines)]
+ meta = setMeta "header-includes" inclList nullMeta
+ in Pandoc meta mempty
+
+ , "LaTeX_class option is translated to documentclass" =:
+ "#+LATEX_CLASS: article" =?>
+ let meta = setMeta "documentclass" (MetaString "article") nullMeta
+ in Pandoc meta mempty
+
+ , "LaTeX_class_options is translated to classoption" =:
+ "#+LATEX_CLASS_OPTIONS: [a4paper]" =?>
+ let meta = setMeta "classoption" (MetaString "a4paper") nullMeta
+ in Pandoc meta mempty
+
+ , "LaTeX_class_options is translated to classoption" =:
+ "#+html_head: <meta/>" =?>
+ let html = rawInline "html" "<meta/>"
+ inclList = MetaList [MetaInlines (toList html)]
+ meta = setMeta "header-includes" inclList nullMeta
+ in Pandoc meta mempty
+
+ , "later meta definitions take precedence" =:
+ unlines [ "#+AUTHOR: this will not be used"
+ , "#+author: Max"
+ ] =?>
+ let author = MetaInlines [Str "Max"]
+ meta = setMeta "author" (MetaList [author]) $ nullMeta
+ in Pandoc meta mempty
+
+ , "Logbook drawer" =:
+ unlines [ " :LogBook:"
+ , " - State \"DONE\" from \"TODO\" [2014-03-03 Mon 11:00]"
+ , " :END:"
+ ] =?>
+ (mempty::Blocks)
+
+ , "Drawer surrounded by text" =:
+ unlines [ "Before"
+ , ":PROPERTIES:"
+ , ":END:"
+ , "After"
+ ] =?>
+ para "Before" <> para "After"
+
+ , "Drawer markers must be the only text in the line" =:
+ unlines [ " :LOGBOOK: foo"
+ , " :END: bar"
+ ] =?>
+ para (":LOGBOOK: foo" <> softbreak <> ":END: bar")
+
+ , "Drawers can be arbitrary" =:
+ unlines [ ":FOO:"
+ , "/bar/"
+ , ":END:"
+ ] =?>
+ divWith (mempty, ["FOO", "drawer"], mempty) (para $ emph "bar")
+
+ , "Anchor reference" =:
+ unlines [ "<<link-here>> Target."
+ , ""
+ , "[[link-here][See here!]]"
+ ] =?>
+ (para (spanWith ("link-here", [], []) mempty <> "Target.") <>
+ para (link "#link-here" "" ("See" <> space <> "here!")))
+
+ , "Search links are read as emph" =:
+ "[[Wally][Where's Wally?]]" =?>
+ (para (emph $ "Where's" <> space <> "Wally?"))
+
+ , "Link to nonexistent anchor" =:
+ unlines [ "<<link-here>> Target."
+ , ""
+ , "[[link$here][See here!]]"
+ ] =?>
+ (para (spanWith ("link-here", [], []) mempty <> "Target.") <>
+ para (emph ("See" <> space <> "here!")))
+
+ , "Link abbreviation" =:
+ unlines [ "#+LINK: wp https://en.wikipedia.org/wiki/%s"
+ , "[[wp:Org_mode][Wikipedia on Org-mode]]"
+ ] =?>
+ (para (link "https://en.wikipedia.org/wiki/Org_mode" ""
+ ("Wikipedia" <> space <> "on" <> space <> "Org-mode")))
+
+ , "Link abbreviation, defined after first use" =:
+ unlines [ "[[zl:non-sense][Non-sense articles]]"
+ , "#+LINK: zl http://zeitlens.com/tags/%s.html"
+ ] =?>
+ (para (link "http://zeitlens.com/tags/non-sense.html" ""
+ ("Non-sense" <> space <> "articles")))
+
+ , "Link abbreviation, URL encoded arguments" =:
+ unlines [ "#+link: expl http://example.com/%h/foo"
+ , "[[expl:Hello, World!][Moin!]]"
+ ] =?>
+ (para (link "http://example.com/Hello%2C%20World%21/foo" "" "Moin!"))
+
+ , "Link abbreviation, append arguments" =:
+ unlines [ "#+link: expl http://example.com/"
+ , "[[expl:foo][bar]]"
+ ] =?>
+ (para (link "http://example.com/foo" "" "bar"))
+
+
+ , testGroup "export options"
+
+ [ "disable simple sub/superscript syntax" =:
+ unlines [ "#+OPTIONS: ^:nil"
+ , "a^b"
+ ] =?>
+ para "a^b"
+
+ , "directly select drawers to be exported" =:
+ unlines [ "#+OPTIONS: d:(\"IMPORTANT\")"
+ , ":IMPORTANT:"
+ , "23"
+ , ":END:"
+ , ":BORING:"
+ , "very boring"
+ , ":END:"
+ ] =?>
+ divWith (mempty, ["IMPORTANT", "drawer"], mempty) (para "23")
+
+ , "exclude drawers from being exported" =:
+ unlines [ "#+OPTIONS: d:(not \"BORING\")"
+ , ":IMPORTANT:"
+ , "5"
+ , ":END:"
+ , ":BORING:"
+ , "very boring"
+ , ":END:"
+ ] =?>
+ divWith (mempty, ["IMPORTANT", "drawer"], mempty) (para "5")
+
+ , "don't include archive trees" =:
+ unlines [ "#+OPTIONS: arch:nil"
+ , "* old :ARCHIVE:"
+ ] =?>
+ (mempty ::Blocks)
+
+ , "include complete archive trees" =:
+ unlines [ "#+OPTIONS: arch:t"
+ , "* old :ARCHIVE:"
+ , " boring"
+ ] =?>
+ let tagSpan t = spanWith ("", ["tag"], [("data-tag-name", t)]) mempty
+ in mconcat [ headerWith ("old", [], mempty) 1 ("old" <> tagSpan "ARCHIVE")
+ , para "boring"
+ ]
+
+ , "include archive tree header only" =:
+ unlines [ "#+OPTIONS: arch:headline"
+ , "* old :ARCHIVE:"
+ , " boring"
+ ] =?>
+ let tagSpan t = spanWith ("", ["tag"], [("data-tag-name", t)]) mempty
+ in headerWith ("old", [], mempty) 1 ("old" <> tagSpan "ARCHIVE")
+
+ , "limit headline depth" =:
+ unlines [ "#+OPTIONS: H:2"
+ , "* section"
+ , "** subsection"
+ , "*** list item 1"
+ , "*** list item 2"
+ ] =?>
+ mconcat [ headerWith ("section", [], []) 1 "section"
+ , headerWith ("subsection", [], []) 2 "subsection"
+ , orderedList [ para "list item 1", para "list item 2" ]
+ ]
+
+ , "disable author export" =:
+ unlines [ "#+OPTIONS: author:nil"
+ , "#+AUTHOR: ShyGuy"
+ ] =?>
+ Pandoc nullMeta mempty
+
+ , "disable creator export" =:
+ unlines [ "#+OPTIONS: creator:nil"
+ , "#+creator: The Architect"
+ ] =?>
+ Pandoc nullMeta mempty
+
+ , "disable email export" =:
+ unlines [ "#+OPTIONS: email:nil"
+ , "#+email: no-mail-please@example.com"
+ ] =?>
+ Pandoc nullMeta mempty
+
+ , "disable inclusion of todo keywords" =:
+ unlines [ "#+OPTIONS: todo:nil"
+ , "** DONE todo export"
+ ] =?>
+ headerWith ("todo-export", [], []) 2 "todo export"
+ ]
+ ]
+
+ , testGroup "Basic Blocks" $
+ [ "Paragraph" =:
+ "Paragraph\n" =?>
+ para "Paragraph"
+
+ , testGroup "headers" $
+ [ "First Level Header" =:
+ "* Headline\n" =?>
+ headerWith ("headline", [], []) 1 "Headline"
+
+ , "Third Level Header" =:
+ "*** Third Level Headline\n" =?>
+ headerWith ("third-level-headline", [], [])
+ 3
+ ("Third" <> space <> "Level" <> space <> "Headline")
+
+ , "Compact Headers with Paragraph" =:
+ unlines [ "* First Level"
+ , "** Second Level"
+ , " Text"
+ ] =?>
+ mconcat [ headerWith ("first-level", [], [])
+ 1
+ ("First" <> space <> "Level")
+ , headerWith ("second-level", [], [])
+ 2
+ ("Second" <> space <> "Level")
+ , para "Text"
+ ]
+
+ , "Separated Headers with Paragraph" =:
+ unlines [ "* First Level"
+ , ""
+ , "** Second Level"
+ , ""
+ , " Text"
+ ] =?>
+ mconcat [ headerWith ("first-level", [], [])
+ 1
+ ("First" <> space <> "Level")
+ , headerWith ("second-level", [], [])
+ 2
+ ("Second" <> space <> "Level")
+ , para "Text"
+ ]
+
+ , "Headers not preceded by a blank line" =:
+ unlines [ "** eat dinner"
+ , "Spaghetti and meatballs tonight."
+ , "** walk dog"
+ ] =?>
+ mconcat [ headerWith ("eat-dinner", [], [])
+ 2
+ ("eat" <> space <> "dinner")
+ , para $ spcSep [ "Spaghetti", "and", "meatballs", "tonight." ]
+ , headerWith ("walk-dog", [], [])
+ 2
+ ("walk" <> space <> "dog")
+ ]
+
+ , testGroup "Todo keywords"
+ [ "Header with known todo keyword" =:
+ "* TODO header" =?>
+ let todoSpan = spanWith ("", ["todo", "TODO"], []) "TODO"
+ in headerWith ("header", [], []) 1 (todoSpan <> space <> "header")
+
+ , "Header marked as done" =:
+ "* DONE header" =?>
+ let todoSpan = spanWith ("", ["done", "DONE"], []) "DONE"
+ in headerWith ("header", [], []) 1 (todoSpan <> space <> "header")
+
+ , "Header with unknown todo keyword" =:
+ "* WAITING header" =?>
+ headerWith ("waiting-header", [], []) 1 "WAITING header"
+
+ , "Custom todo keywords" =:
+ unlines [ "#+TODO: WAITING CANCELLED"
+ , "* WAITING compile"
+ , "* CANCELLED lunch"
+ ] =?>
+ let todoSpan = spanWith ("", ["todo", "WAITING"], []) "WAITING"
+ doneSpan = spanWith ("", ["done", "CANCELLED"], []) "CANCELLED"
+ in headerWith ("compile", [], []) 1 (todoSpan <> space <> "compile")
+ <> headerWith ("lunch", [], []) 1 (doneSpan <> space <> "lunch")
+
+ , "Custom todo keywords with multiple done-states" =:
+ unlines [ "#+TODO: WAITING | DONE CANCELLED "
+ , "* WAITING compile"
+ , "* CANCELLED lunch"
+ , "* DONE todo-feature"
+ ] =?>
+ let waiting = spanWith ("", ["todo", "WAITING"], []) "WAITING"
+ cancelled = spanWith ("", ["done", "CANCELLED"], []) "CANCELLED"
+ done = spanWith ("", ["done", "DONE"], []) "DONE"
+ in headerWith ("compile", [], []) 1 (waiting <> space <> "compile")
+ <> headerWith ("lunch", [], []) 1 (cancelled <> space <> "lunch")
+ <> headerWith ("todo-feature", [], []) 1 (done <> space <> "todo-feature")
+ ]
+
+ , "Tagged headers" =:
+ unlines [ "* Personal :PERSONAL:"
+ , "** Call Mom :@PHONE:"
+ , "** Call John :@PHONE:JOHN: "
+ ] =?>
+ let tagSpan t = spanWith ("", ["tag"], [("data-tag-name", t)]) mempty
+ in mconcat [ headerWith ("personal", [], [])
+ 1
+ ("Personal" <> tagSpan "PERSONAL")
+ , headerWith ("call-mom", [], [])
+ 2
+ ("Call Mom" <> tagSpan "@PHONE")
+ , headerWith ("call-john", [], [])
+ 2
+ ("Call John" <> tagSpan "@PHONE" <> tagSpan "JOHN")
+ ]
+
+ , "Untagged header containing colons" =:
+ "* This: is not: tagged" =?>
+ headerWith ("this-is-not-tagged", [], []) 1 "This: is not: tagged"
+
+ , "Header starting with strokeout text" =:
+ unlines [ "foo"
+ , ""
+ , "* +thing+ other thing"
+ ] =?>
+ mconcat [ para "foo"
+ , headerWith ("thing-other-thing", [], [])
+ 1
+ ((strikeout "thing") <> " other thing")
+ ]
+
+ , "Comment Trees" =:
+ unlines [ "* COMMENT A comment tree"
+ , " Not much going on here"
+ , "** This will be dropped"
+ , "* Comment tree above"
+ ] =?>
+ headerWith ("comment-tree-above", [], []) 1 "Comment tree above"
+
+ , "Nothing but a COMMENT header" =:
+ "* COMMENT Test" =?>
+ (mempty::Blocks)
+
+ , "Tree with :noexport:" =:
+ unlines [ "* Should be ignored :archive:noexport:old:"
+ , "** Old stuff"
+ , " This is not going to be exported"
+ ] =?>
+ (mempty::Blocks)
+
+ , "Subtree with :noexport:" =:
+ unlines [ "* Exported"
+ , "** This isn't exported :noexport:"
+ , "*** This neither"
+ , "** But this is"
+ ] =?>
+ mconcat [ headerWith ("exported", [], []) 1 "Exported"
+ , headerWith ("but-this-is", [], []) 2 "But this is"
+ ]
+
+ , "Preferences are treated as header attributes" =:
+ unlines [ "* foo"
+ , " :PROPERTIES:"
+ , " :custom_id: fubar"
+ , " :bar: baz"
+ , " :END:"
+ ] =?>
+ headerWith ("fubar", [], [("bar", "baz")]) 1 "foo"
+
+
+ , "Headers marked with a unnumbered property get a class of the same name" =:
+ unlines [ "* Not numbered"
+ , " :PROPERTIES:"
+ , " :UNNUMBERED: t"
+ , " :END:"
+ ] =?>
+ headerWith ("not-numbered", ["unnumbered"], []) 1 "Not numbered"
+ ]
+ , "Paragraph starting with an asterisk" =:
+ "*five" =?>
+ para "*five"
+
+ , "Paragraph containing asterisk at beginning of line" =:
+ unlines [ "lucky"
+ , "*star"
+ ] =?>
+ para ("lucky" <> softbreak <> "*star")
+
+ , "Example block" =:
+ unlines [ ": echo hello"
+ , ": echo dear tester"
+ ] =?>
+ codeBlockWith ("", ["example"], []) "echo hello\necho dear tester\n"
+
+ , "Example block surrounded by text" =:
+ unlines [ "Greetings"
+ , ": echo hello"
+ , ": echo dear tester"
+ , "Bye"
+ ] =?>
+ mconcat [ para "Greetings"
+ , codeBlockWith ("", ["example"], [])
+ "echo hello\necho dear tester\n"
+ , para "Bye"
+ ]
+
+ , "Horizontal Rule" =:
+ unlines [ "before"
+ , "-----"
+ , "after"
+ ] =?>
+ mconcat [ para "before"
+ , horizontalRule
+ , para "after"
+ ]
+
+ , "Not a Horizontal Rule" =:
+ "----- five dashes" =?>
+ (para $ spcSep [ "-----", "five", "dashes" ])
+
+ , "Comment Block" =:
+ unlines [ "#+BEGIN_COMMENT"
+ , "stuff"
+ , "bla"
+ , "#+END_COMMENT"] =?>
+ (mempty::Blocks)
+
+ , testGroup "Figures" $
+ [ "Figure" =:
+ unlines [ "#+caption: A very courageous man."
+ , "#+name: goodguy"
+ , "[[file:edward.jpg]]"
+ ] =?>
+ para (image "edward.jpg" "fig:goodguy" "A very courageous man.")
+
+ , "Figure with no name" =:
+ unlines [ "#+caption: I've been through the desert on this"
+ , "[[file:horse.png]]"
+ ] =?>
+ para (image "horse.png" "fig:" "I've been through the desert on this")
+
+ , "Figure with `fig:` prefix in name" =:
+ unlines [ "#+caption: Used as a metapher in evolutionary biology."
+ , "#+name: fig:redqueen"
+ , "[[./the-red-queen.jpg]]"
+ ] =?>
+ para (image "./the-red-queen.jpg" "fig:redqueen"
+ "Used as a metapher in evolutionary biology.")
+
+ , "Figure with HTML attributes" =:
+ unlines [ "#+CAPTION: mah brain just explodid"
+ , "#+NAME: lambdacat"
+ , "#+ATTR_HTML: :style color: blue :role button"
+ , "[[file:lambdacat.jpg]]"
+ ] =?>
+ let kv = [("style", "color: blue"), ("role", "button")]
+ name = "fig:lambdacat"
+ caption = "mah brain just explodid"
+ in para (imageWith (mempty, mempty, kv) "lambdacat.jpg" name caption)
+
+ , "Labelled figure" =:
+ unlines [ "#+CAPTION: My figure"
+ , "#+LABEL: fig:myfig"
+ , "[[file:blub.png]]"
+ ] =?>
+ let attr = ("fig:myfig", mempty, mempty)
+ in para (imageWith attr "blub.png" "fig:" "My figure")
+
+ , "Figure with empty caption" =:
+ unlines [ "#+CAPTION:"
+ , "[[file:guess.jpg]]"
+ ] =?>
+ para (image "guess.jpg" "fig:" "")
+ ]
+
+ , "Footnote" =:
+ unlines [ "A footnote[1]"
+ , ""
+ , "[1] First paragraph"
+ , ""
+ , "second paragraph"
+ ] =?>
+ para (mconcat
+ [ "A", space, "footnote"
+ , note $ mconcat [ para ("First" <> space <> "paragraph")
+ , para ("second" <> space <> "paragraph")
+ ]
+ ])
+
+ , "Two footnotes" =:
+ unlines [ "Footnotes[fn:1][fn:2]"
+ , ""
+ , "[fn:1] First note."
+ , ""
+ , "[fn:2] Second note."
+ ] =?>
+ para (mconcat
+ [ "Footnotes"
+ , note $ para ("First" <> space <> "note.")
+ , note $ para ("Second" <> space <> "note.")
+ ])
+
+ , "Footnote followed by header" =:
+ unlines [ "Another note[fn:yay]"
+ , ""
+ , "[fn:yay] This is great!"
+ , ""
+ , "** Headline"
+ ] =?>
+ mconcat
+ [ para (mconcat
+ [ "Another", space, "note"
+ , note $ para ("This" <> space <> "is" <> space <> "great!")
+ ])
+ , headerWith ("headline", [], []) 2 "Headline"
+ ]
+ ]
+
+ , testGroup "Lists" $
+ [ "Simple Bullet Lists" =:
+ ("- Item1\n" ++
+ "- Item2\n") =?>
+ bulletList [ plain "Item1"
+ , plain "Item2"
+ ]
+
+ , "Indented Bullet Lists" =:
+ (" - Item1\n" ++
+ " - Item2\n") =?>
+ bulletList [ plain "Item1"
+ , plain "Item2"
+ ]
+
+ , "Unindented *" =:
+ ("- Item1\n" ++
+ "* Item2\n") =?>
+ bulletList [ plain "Item1"
+ ] <>
+ headerWith ("item2", [], []) 1 "Item2"
+
+ , "Multi-line Bullet Lists" =:
+ ("- *Fat\n" ++
+ " Tony*\n" ++
+ "- /Sideshow\n" ++
+ " Bob/") =?>
+ bulletList [ plain $ strong ("Fat" <> softbreak <> "Tony")
+ , plain $ emph ("Sideshow" <> softbreak <> "Bob")
+ ]
+
+ , "Nested Bullet Lists" =:
+ ("- Discovery\n" ++
+ " + One More Time\n" ++
+ " + Harder, Better, Faster, Stronger\n" ++
+ "- Homework\n" ++
+ " + Around the World\n"++
+ "- Human After All\n" ++
+ " + Technologic\n" ++
+ " + Robot Rock\n") =?>
+ bulletList [ mconcat
+ [ plain "Discovery"
+ , bulletList [ plain ("One" <> space <>
+ "More" <> space <>
+ "Time")
+ , plain ("Harder," <> space <>
+ "Better," <> space <>
+ "Faster," <> space <>
+ "Stronger")
+ ]
+ ]
+ , mconcat
+ [ plain "Homework"
+ , bulletList [ plain ("Around" <> space <>
+ "the" <> space <>
+ "World")
+ ]
+ ]
+ , mconcat
+ [ plain ("Human" <> space <> "After" <> space <> "All")
+ , bulletList [ plain "Technologic"
+ , plain ("Robot" <> space <> "Rock")
+ ]
+ ]
+ ]
+
+ , "Bullet List with Decreasing Indent" =:
+ (" - Discovery\n\
+ \ - Human After All\n") =?>
+ mconcat [ bulletList [ plain "Discovery" ]
+ , bulletList [ plain ("Human" <> space <> "After" <> space <> "All")]
+ ]
+
+ , "Header follows Bullet List" =:
+ (" - Discovery\n\
+ \ - Human After All\n\
+ \* Homework") =?>
+ mconcat [ bulletList [ plain "Discovery"
+ , plain ("Human" <> space <> "After" <> space <> "All")
+ ]
+ , headerWith ("homework", [], []) 1 "Homework"
+ ]
+
+ , "Bullet List Unindented with trailing Header" =:
+ ("- Discovery\n\
+ \- Homework\n\
+ \* NotValidListItem") =?>
+ mconcat [ bulletList [ plain "Discovery"
+ , plain "Homework"
+ ]
+ , headerWith ("notvalidlistitem", [], []) 1 "NotValidListItem"
+ ]
+
+ , "Simple Ordered List" =:
+ ("1. Item1\n" ++
+ "2. Item2\n") =?>
+ let listStyle = (1, DefaultStyle, DefaultDelim)
+ listStructure = [ plain "Item1"
+ , plain "Item2"
+ ]
+ in orderedListWith listStyle listStructure
+
+ , "Simple Ordered List with Parens" =:
+ ("1) Item1\n" ++
+ "2) Item2\n") =?>
+ let listStyle = (1, DefaultStyle, DefaultDelim)
+ listStructure = [ plain "Item1"
+ , plain "Item2"
+ ]
+ in orderedListWith listStyle listStructure
+
+ , "Indented Ordered List" =:
+ (" 1. Item1\n" ++
+ " 2. Item2\n") =?>
+ let listStyle = (1, DefaultStyle, DefaultDelim)
+ listStructure = [ plain "Item1"
+ , plain "Item2"
+ ]
+ in orderedListWith listStyle listStructure
+
+ , "Nested Ordered Lists" =:
+ ("1. One\n" ++
+ " 1. One-One\n" ++
+ " 2. One-Two\n" ++
+ "2. Two\n" ++
+ " 1. Two-One\n"++
+ " 2. Two-Two\n") =?>
+ let listStyle = (1, DefaultStyle, DefaultDelim)
+ listStructure = [ mconcat
+ [ plain "One"
+ , orderedList [ plain "One-One"
+ , plain "One-Two"
+ ]
+ ]
+ , mconcat
+ [ plain "Two"
+ , orderedList [ plain "Two-One"
+ , plain "Two-Two"
+ ]
+ ]
+ ]
+ in orderedListWith listStyle listStructure
+
+ , "Ordered List in Bullet List" =:
+ ("- Emacs\n" ++
+ " 1. Org\n") =?>
+ bulletList [ (plain "Emacs") <>
+ (orderedList [ plain "Org"])
+ ]
+
+ , "Bullet List in Ordered List" =:
+ ("1. GNU\n" ++
+ " - Freedom\n") =?>
+ orderedList [ (plain "GNU") <> bulletList [ (plain "Freedom") ] ]
+
+ , "Definition List" =:
+ unlines [ "- PLL :: phase-locked loop"
+ , "- TTL ::"
+ , " transistor-transistor logic"
+ , "- PSK :: phase-shift keying"
+ , ""
+ , " a digital modulation scheme"
+ ] =?>
+ definitionList [ ("PLL", [ plain $ "phase-locked" <> space <> "loop" ])
+ , ("TTL", [ plain $ "transistor-transistor" <> space <>
+ "logic" ])
+ , ("PSK", [ mconcat
+ [ para $ "phase-shift" <> space <> "keying"
+ , para $ spcSep [ "a", "digital"
+ , "modulation", "scheme" ]
+ ]
+ ])
+ ]
+ , "Definition list with multi-word term" =:
+ " - Elijah Wood :: He plays Frodo" =?>
+ definitionList [ ("Elijah" <> space <> "Wood", [plain $ "He" <> space <> "plays" <> space <> "Frodo"])]
+ , "Compact definition list" =:
+ unlines [ "- ATP :: adenosine 5' triphosphate"
+ , "- DNA :: deoxyribonucleic acid"
+ , "- PCR :: polymerase chain reaction"
+ , ""
+ ] =?>
+ definitionList
+ [ ("ATP", [ plain $ spcSep [ "adenosine", "5'", "triphosphate" ] ])
+ , ("DNA", [ plain $ spcSep [ "deoxyribonucleic", "acid" ] ])
+ , ("PCR", [ plain $ spcSep [ "polymerase", "chain", "reaction" ] ])
+ ]
+
+ , "Definition List With Trailing Header" =:
+ "- definition :: list\n\
+ \- cool :: defs\n\
+ \* header" =?>
+ mconcat [ definitionList [ ("definition", [plain "list"])
+ , ("cool", [plain "defs"])
+ ]
+ , headerWith ("header", [], []) 1 "header"
+ ]
+
+ , "Definition lists double-colon markers must be surrounded by whitespace" =:
+ "- std::cout" =?>
+ bulletList [ plain "std::cout" ]
+
+ , "Loose bullet list" =:
+ unlines [ "- apple"
+ , ""
+ , "- orange"
+ , ""
+ , "- peach"
+ ] =?>
+ bulletList [ para "apple"
+ , para "orange"
+ , para "peach"
+ ]
+
+ , "Recognize preceding paragraphs in non-list contexts" =:
+ unlines [ "CLOSED: [2015-10-19 Mon 15:03]"
+ , "- Note taken on [2015-10-19 Mon 13:24]"
+ ] =?>
+ mconcat [ para "CLOSED: [2015-10-19 Mon 15:03]"
+ , bulletList [ plain "Note taken on [2015-10-19 Mon 13:24]" ]
+ ]
+ ]
+
+ , testGroup "Tables"
+ [ "Single cell table" =:
+ "|Test|" =?>
+ simpleTable' 1 mempty [[plain "Test"]]
+
+ , "Multi cell table" =:
+ "| One | Two |" =?>
+ simpleTable' 2 mempty [ [ plain "One", plain "Two" ] ]
+
+ , "Multi line table" =:
+ unlines [ "| One |"
+ , "| Two |"
+ , "| Three |"
+ ] =?>
+ simpleTable' 1 mempty
+ [ [ plain "One" ]
+ , [ plain "Two" ]
+ , [ plain "Three" ]
+ ]
+
+ , "Empty table" =:
+ "||" =?>
+ simpleTable' 1 mempty [[mempty]]
+
+ , "Glider Table" =:
+ unlines [ "| 1 | 0 | 0 |"
+ , "| 0 | 1 | 1 |"
+ , "| 1 | 1 | 0 |"
+ ] =?>
+ simpleTable' 3 mempty
+ [ [ plain "1", plain "0", plain "0" ]
+ , [ plain "0", plain "1", plain "1" ]
+ , [ plain "1", plain "1", plain "0" ]
+ ]
+
+ , "Table between Paragraphs" =:
+ unlines [ "Before"
+ , "| One | Two |"
+ , "After"
+ ] =?>
+ mconcat [ para "Before"
+ , simpleTable' 2 mempty [ [ plain "One", plain "Two" ] ]
+ , para "After"
+ ]
+
+ , "Table with Header" =:
+ unlines [ "| Species | Status |"
+ , "|--------------+--------------|"
+ , "| cervisiae | domesticated |"
+ , "| paradoxus | wild |"
+ ] =?>
+ simpleTable [ plain "Species", plain "Status" ]
+ [ [ plain "cervisiae", plain "domesticated" ]
+ , [ plain "paradoxus", plain "wild" ]
+ ]
+
+ , "Table with final hline" =:
+ unlines [ "| cervisiae | domesticated |"
+ , "| paradoxus | wild |"
+ , "|--------------+--------------|"
+ ] =?>
+ simpleTable' 2 mempty
+ [ [ plain "cervisiae", plain "domesticated" ]
+ , [ plain "paradoxus", plain "wild" ]
+ ]
+
+ , "Table in a box" =:
+ unlines [ "|---------|---------|"
+ , "| static | Haskell |"
+ , "| dynamic | Lisp |"
+ , "|---------+---------|"
+ ] =?>
+ simpleTable' 2 mempty
+ [ [ plain "static", plain "Haskell" ]
+ , [ plain "dynamic", plain "Lisp" ]
+ ]
+
+ , "Table with empty cells" =:
+ "|||c|" =?>
+ simpleTable' 3 mempty [[mempty, mempty, plain "c"]]
+
+ , "Table with empty rows" =:
+ unlines [ "| first |"
+ , "| |"
+ , "| third |"
+ ] =?>
+ simpleTable' 1 mempty [[plain "first"], [mempty], [plain "third"]]
+
+ , "Table with alignment row" =:
+ unlines [ "| Numbers | Text | More |"
+ , "| <c> | <r> | |"
+ , "| 1 | One | foo |"
+ , "| 2 | Two | bar |"
+ ] =?>
+ table "" (zip [AlignCenter, AlignRight, AlignDefault] [0, 0, 0])
+ []
+ [ [ plain "Numbers", plain "Text", plain "More" ]
+ , [ plain "1" , plain "One" , plain "foo" ]
+ , [ plain "2" , plain "Two" , plain "bar" ]
+ ]
+
+ , "Pipe within text doesn't start a table" =:
+ "Ceci n'est pas une | pipe " =?>
+ para (spcSep [ "Ceci", "n'est", "pas", "une", "|", "pipe" ])
+
+ , "Missing pipe at end of row" =:
+ "|incomplete-but-valid" =?>
+ simpleTable' 1 mempty [ [ plain "incomplete-but-valid" ] ]
+
+ , "Table with differing row lengths" =:
+ unlines [ "| Numbers | Text "
+ , "|-"
+ , "| <c> | <r> |"
+ , "| 1 | One | foo |"
+ , "| 2"
+ ] =?>
+ table "" (zip [AlignCenter, AlignRight] [0, 0])
+ [ plain "Numbers", plain "Text" ]
+ [ [ plain "1" , plain "One" , plain "foo" ]
+ , [ plain "2" ]
+ ]
+
+ , "Table with caption" =:
+ unlines [ "#+CAPTION: Hitchhiker's Multiplication Table"
+ , "| x | 6 |"
+ , "| 9 | 42 |"
+ ] =?>
+ table "Hitchhiker's Multiplication Table"
+ [(AlignDefault, 0), (AlignDefault, 0)]
+ []
+ [ [ plain "x", plain "6" ]
+ , [ plain "9", plain "42" ]
+ ]
+ ]
+
+ , testGroup "Blocks and fragments"
+ [ "Source block" =:
+ unlines [ " #+BEGIN_SRC haskell"
+ , " main = putStrLn greeting"
+ , " where greeting = \"moin\""
+ , " #+END_SRC" ] =?>
+ let attr' = ("", ["haskell"], [])
+ code' = "main = putStrLn greeting\n" ++
+ " where greeting = \"moin\"\n"
+ in codeBlockWith attr' code'
+
+ , "Source block with indented code" =:
+ unlines [ " #+BEGIN_SRC haskell"
+ , " main = putStrLn greeting"
+ , " where greeting = \"moin\""
+ , " #+END_SRC" ] =?>
+ let attr' = ("", ["haskell"], [])
+ code' = "main = putStrLn greeting\n" ++
+ " where greeting = \"moin\"\n"
+ in codeBlockWith attr' code'
+
+ , "Source block with tab-indented code" =:
+ unlines [ "\t#+BEGIN_SRC haskell"
+ , "\tmain = putStrLn greeting"
+ , "\t where greeting = \"moin\""
+ , "\t#+END_SRC" ] =?>
+ let attr' = ("", ["haskell"], [])
+ code' = "main = putStrLn greeting\n" ++
+ " where greeting = \"moin\"\n"
+ in codeBlockWith attr' code'
+
+ , "Empty source block" =:
+ unlines [ " #+BEGIN_SRC haskell"
+ , " #+END_SRC" ] =?>
+ let attr' = ("", ["haskell"], [])
+ code' = ""
+ in codeBlockWith attr' code'
+
+ , "Source block between paragraphs" =:
+ unlines [ "Low German greeting"
+ , " #+BEGIN_SRC haskell"
+ , " main = putStrLn greeting"
+ , " where greeting = \"Moin!\""
+ , " #+END_SRC" ] =?>
+ let attr' = ("", ["haskell"], [])
+ code' = "main = putStrLn greeting\n" ++
+ " where greeting = \"Moin!\"\n"
+ in mconcat [ para $ spcSep [ "Low", "German", "greeting" ]
+ , codeBlockWith attr' code'
+ ]
+ , "Source block with rundoc/babel arguments" =:
+ unlines [ "#+BEGIN_SRC emacs-lisp :exports both"
+ , "(progn (message \"Hello, World!\")"
+ , " (+ 23 42))"
+ , "#+END_SRC" ] =?>
+ let classes = [ "commonlisp" -- as kate doesn't know emacs-lisp syntax
+ , "rundoc-block"
+ ]
+ params = [ ("rundoc-language", "emacs-lisp")
+ , ("rundoc-exports", "both")
+ ]
+ code' = unlines [ "(progn (message \"Hello, World!\")"
+ , " (+ 23 42))" ]
+ in codeBlockWith ("", classes, params) code'
+
+ , "Source block with results and :exports both" =:
+ unlines [ "#+BEGIN_SRC emacs-lisp :exports both"
+ , "(progn (message \"Hello, World!\")"
+ , " (+ 23 42))"
+ , "#+END_SRC"
+ , ""
+ , "#+RESULTS:"
+ , ": 65"] =?>
+ let classes = [ "commonlisp" -- as kate doesn't know emacs-lisp syntax
+ , "rundoc-block"
+ ]
+ params = [ ("rundoc-language", "emacs-lisp")
+ , ("rundoc-exports", "both")
+ ]
+ code' = unlines [ "(progn (message \"Hello, World!\")"
+ , " (+ 23 42))" ]
+ results' = "65\n"
+ in codeBlockWith ("", classes, params) code'
+ <>
+ codeBlockWith ("", ["example"], []) results'
+
+ , "Source block with results and :exports code" =:
+ unlines [ "#+BEGIN_SRC emacs-lisp :exports code"
+ , "(progn (message \"Hello, World!\")"
+ , " (+ 23 42))"
+ , "#+END_SRC"
+ , ""
+ , "#+RESULTS:"
+ , ": 65" ] =?>
+ let classes = [ "commonlisp" -- as kate doesn't know emacs-lisp syntax
+ , "rundoc-block"
+ ]
+ params = [ ("rundoc-language", "emacs-lisp")
+ , ("rundoc-exports", "code")
+ ]
+ code' = unlines [ "(progn (message \"Hello, World!\")"
+ , " (+ 23 42))" ]
+ in codeBlockWith ("", classes, params) code'
+
+ , "Source block with results and :exports results" =:
+ unlines [ "#+BEGIN_SRC emacs-lisp :exports results"
+ , "(progn (message \"Hello, World!\")"
+ , " (+ 23 42))"
+ , "#+END_SRC"
+ , ""
+ , "#+RESULTS:"
+ , ": 65" ] =?>
+ let results' = "65\n"
+ in codeBlockWith ("", ["example"], []) results'
+
+ , "Source block with results and :exports none" =:
+ unlines [ "#+BEGIN_SRC emacs-lisp :exports none"
+ , "(progn (message \"Hello, World!\")"
+ , " (+ 23 42))"
+ , "#+END_SRC"
+ , ""
+ , "#+RESULTS:"
+ , ": 65" ] =?>
+ (mempty :: Blocks)
+
+ , "Source block with toggling header arguments" =:
+ unlines [ "#+BEGIN_SRC sh :noeval"
+ , "echo $HOME"
+ , "#+END_SRC"
+ ] =?>
+ let classes = [ "bash", "rundoc-block" ]
+ params = [ ("rundoc-language", "sh"), ("rundoc-noeval", "yes") ]
+ in codeBlockWith ("", classes, params) "echo $HOME\n"
+
+ , "Example block" =:
+ unlines [ "#+begin_example"
+ , "A chosen representation of"
+ , "a rule."
+ , "#+eND_exAMPle"
+ ] =?>
+ codeBlockWith ("", ["example"], [])
+ "A chosen representation of\na rule.\n"
+
+ , "HTML block" =:
+ unlines [ "#+BEGIN_HTML"
+ , "<aside>HTML5 is pretty nice.</aside>"
+ , "#+END_HTML"
+ ] =?>
+ rawBlock "html" "<aside>HTML5 is pretty nice.</aside>\n"
+
+ , "Quote block" =:
+ unlines [ "#+BEGIN_QUOTE"
+ , "/Niemand/ hat die Absicht, eine Mauer zu errichten!"
+ , "#+END_QUOTE"
+ ] =?>
+ blockQuote (para (spcSep [ emph "Niemand", "hat", "die", "Absicht,"
+ , "eine", "Mauer", "zu", "errichten!"
+ ]))
+
+ , "Verse block" =:
+ unlines [ "The first lines of Goethe's /Faust/:"
+ , "#+begin_verse"
+ , "Habe nun, ach! Philosophie,"
+ , "Juristerei und Medizin,"
+ , "Und leider auch Theologie!"
+ , "Durchaus studiert, mit heißem Bemühn."
+ , "#+end_verse"
+ ] =?>
+ mconcat
+ [ para $ spcSep [ "The", "first", "lines", "of"
+ , "Goethe's", emph "Faust" <> ":"]
+ , lineBlock
+ [ "Habe nun, ach! Philosophie,"
+ , "Juristerei und Medizin,"
+ , "Und leider auch Theologie!"
+ , "Durchaus studiert, mit heißem Bemühn."
+ ]
+ ]
+
+ , "Verse block with blank lines" =:
+ unlines [ "#+BEGIN_VERSE"
+ , "foo"
+ , ""
+ , "bar"
+ , "#+END_VERSE"
+ ] =?>
+ lineBlock [ "foo", mempty, "bar" ]
+
+ , "Verse block with varying indentation" =:
+ unlines [ "#+BEGIN_VERSE"
+ , " hello darkness"
+ , "my old friend"
+ , "#+END_VERSE"
+ ] =?>
+ lineBlock [ "\160\160hello darkness", "my old friend" ]
+
+ , "Raw block LaTeX" =:
+ unlines [ "#+BEGIN_LaTeX"
+ , "The category $\\cat{Set}$ is adhesive."
+ , "#+END_LaTeX"
+ ] =?>
+ rawBlock "latex" "The category $\\cat{Set}$ is adhesive.\n"
+
+ , "Raw LaTeX line" =:
+ "#+LATEX: \\let\\foo\\bar" =?>
+ rawBlock "latex" "\\let\\foo\\bar"
+
+ , "Raw Beamer line" =:
+ "#+beamer: \\pause" =?>
+ rawBlock "beamer" "\\pause"
+
+ , "Raw HTML line" =:
+ "#+HTML: <aside>not important</aside>" =?>
+ rawBlock "html" "<aside>not important</aside>"
+
+ , "Export block HTML" =:
+ unlines [ "#+BEGIN_export html"
+ , "<samp>Hello, World!</samp>"
+ , "#+END_export"
+ ] =?>
+ rawBlock "html" "<samp>Hello, World!</samp>\n"
+
+ , "LaTeX fragment" =:
+ unlines [ "\\begin{equation}"
+ , "X_i = \\begin{cases}"
+ , " G_{\\alpha(i)} & \\text{if }\\alpha(i-1) = \\alpha(i)\\\\"
+ , " C_{\\alpha(i)} & \\text{otherwise}"
+ , " \\end{cases}"
+ , "\\end{equation}"
+ ] =?>
+ rawBlock "latex"
+ (unlines [ "\\begin{equation}"
+ , "X_i = \\begin{cases}"
+ , " G_{\\alpha(i)} & \\text{if }\\alpha(i-1) =" ++
+ " \\alpha(i)\\\\"
+ , " C_{\\alpha(i)} & \\text{otherwise}"
+ , " \\end{cases}"
+ , "\\end{equation}"
+ ])
+
+ , "Code block with caption" =:
+ unlines [ "#+CAPTION: Functor laws in Haskell"
+ , "#+NAME: functor-laws"
+ , "#+BEGIN_SRC haskell"
+ , "fmap id = id"
+ , "fmap (p . q) = (fmap p) . (fmap q)"
+ , "#+END_SRC"
+ ] =?>
+ divWith
+ nullAttr
+ (mappend
+ (plain $ spanWith ("", ["label"], [])
+ (spcSep [ "Functor", "laws", "in", "Haskell" ]))
+ (codeBlockWith ("functor-laws", ["haskell"], [])
+ (unlines [ "fmap id = id"
+ , "fmap (p . q) = (fmap p) . (fmap q)"
+ ])))
+
+ , "Convert blank lines in blocks to single newlines" =:
+ unlines [ "#+begin_html"
+ , ""
+ , "<span>boring</span>"
+ , ""
+ , "#+end_html"
+ ] =?>
+ rawBlock "html" "\n<span>boring</span>\n\n"
+
+ , "Accept `ATTR_HTML` attributes for generic block" =:
+ unlines [ "#+ATTR_HTML: :title hello, world :id test :class fun code"
+ , "#+BEGIN_TEST"
+ , "nonsense"
+ , "#+END_TEST"
+ ] =?>
+ let attr = ("test", ["fun", "code", "TEST"], [("title", "hello, world")])
+ in divWith attr (para "nonsense")
+
+ , "Non-letter chars in source block parameters" =:
+ unlines [ "#+BEGIN_SRC C :tangle xxxx.c :city Zürich"
+ , "code body"
+ , "#+END_SRC"
+ ] =?>
+ let classes = [ "c", "rundoc-block" ]
+ params = [ ("rundoc-language", "C")
+ , ("rundoc-tangle", "xxxx.c")
+ , ("rundoc-city", "Zürich")
+ ]
+ in codeBlockWith ( "", classes, params) "code body\n"
+ ]
+
+ , testGroup "Smart punctuation"
+ [ test orgSmart "quote before ellipses"
+ ("'...hi'"
+ =?> para (singleQuoted "…hi"))
+
+ , test orgSmart "apostrophe before emph"
+ ("D'oh! A l'/aide/!"
+ =?> para ("D’oh! A l’" <> emph "aide" <> "!"))
+
+ , test orgSmart "apostrophe in French"
+ ("À l'arrivée de la guerre, le thème de l'«impossibilité du socialisme»"
+ =?> para "À l’arrivée de la guerre, le thème de l’«impossibilité du socialisme»")
+
+ , test orgSmart "Quotes cannot occur at the end of emphasized text"
+ ("/say \"yes\"/" =?>
+ para ("/say" <> space <> doubleQuoted "yes" <> "/"))
+
+ , test orgSmart "Dashes are allowed at the borders of emphasis'"
+ ("/foo---/" =?>
+ para (emph "foo—"))
+
+ , test orgSmart "Single quotes can be followed by emphasized text"
+ ("Singles on the '/meat market/'" =?>
+ para ("Singles on the " <> (singleQuoted $ emph "meat market")))
+
+ , test orgSmart "Double quotes can be followed by emphasized text"
+ ("Double income, no kids: \"/DINK/\"" =?>
+ para ("Double income, no kids: " <> (doubleQuoted $ emph "DINK")))
+ ]
+ ]
diff --git a/test/Tests/Readers/RST.hs b/test/Tests/Readers/RST.hs
new file mode 100644
index 000000000..464720496
--- /dev/null
+++ b/test/Tests/Readers/RST.hs
@@ -0,0 +1,174 @@
+{-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-}
+module Tests.Readers.RST (tests) where
+
+import Text.Pandoc.Definition
+import Test.Framework
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+import Text.Pandoc.Builder
+import Text.Pandoc
+
+rst :: String -> Pandoc
+rst = purely $ readRST def{ readerStandalone = True }
+
+infix 4 =:
+(=:) :: ToString c
+ => String -> (String, c) -> Test
+(=:) = test rst
+
+tests :: [Test]
+tests = [ "line block with blank line" =:
+ "| a\n|\n| b" =?> lineBlock [ "a", mempty, "\160b" ]
+ , testGroup "field list"
+ [ "general" =: unlines
+ [ "para"
+ , ""
+ , ":Hostname: media08"
+ , ":IP address: 10.0.0.19"
+ , ":Size: 3ru"
+ , ":Version: 1"
+ , ":Indentation: Since the field marker may be quite long, the second"
+ , " and subsequent lines of the field body do not have to line up"
+ , " with the first line, but they must be indented relative to the"
+ , " field name marker, and they must line up with each other."
+ , ":Parameter i: integer"
+ , ":Final: item"
+ , " on two lines" ]
+ =?> ( doc
+ $ para "para" <>
+ definitionList [ (str "Hostname", [para "media08"])
+ , (text "IP address", [para "10.0.0.19"])
+ , (str "Size", [para "3ru"])
+ , (str "Version", [para "1"])
+ , (str "Indentation", [para "Since the field marker may be quite long, the second\nand subsequent lines of the field body do not have to line up\nwith the first line, but they must be indented relative to the\nfield name marker, and they must line up with each other."])
+ , (text "Parameter i", [para "integer"])
+ , (str "Final", [para "item\non two lines"])
+ ])
+ , "metadata" =: unlines
+ [ "====="
+ , "Title"
+ , "====="
+ , "--------"
+ , "Subtitle"
+ , "--------"
+ , ""
+ , ":Version: 1"
+ ]
+ =?> ( setMeta "version" (para "1")
+ $ setMeta "title" ("Title" :: Inlines)
+ $ setMeta "subtitle" ("Subtitle" :: Inlines)
+ $ doc mempty )
+ , "with inline markup" =: unlines
+ [ ":*Date*: today"
+ , ""
+ , ".."
+ , ""
+ , ":*one*: emphasis"
+ , ":two_: reference"
+ , ":`three`_: another one"
+ , ":``four``: literal"
+ , ""
+ , ".. _two: http://example.com"
+ , ".. _three: http://example.org"
+ ]
+ =?> ( setMeta "date" (str "today")
+ $ doc
+ $ definitionList [ (emph "one", [para "emphasis"])
+ , (link "http://example.com" "" "two", [para "reference"])
+ , (link "http://example.org" "" "three", [para "another one"])
+ , (code "four", [para "literal"])
+ ])
+ ]
+ , "URLs with following punctuation" =:
+ ("http://google.com, http://yahoo.com; http://foo.bar.baz.\n" ++
+ "http://foo.bar/baz_(bam) (http://foo.bar)") =?>
+ para (link "http://google.com" "" "http://google.com" <> ", " <>
+ link "http://yahoo.com" "" "http://yahoo.com" <> "; " <>
+ link "http://foo.bar.baz" "" "http://foo.bar.baz" <> ". " <>
+ softbreak <>
+ link "http://foo.bar/baz_(bam)" "" "http://foo.bar/baz_(bam)"
+ <> " (" <> link "http://foo.bar" "" "http://foo.bar" <> ")")
+ , "Reference names with special characters" =:
+ ("A-1-B_2_C:3:D+4+E.5.F_\n\n" ++
+ ".. _A-1-B_2_C:3:D+4+E.5.F: https://example.com\n") =?>
+ para (link "https://example.com" "" "A-1-B_2_C:3:D+4+E.5.F")
+ , "Code directive with class and number-lines" =: unlines
+ [ ".. code::python"
+ , " :number-lines: 34"
+ , " :class: class1 class2 class3"
+ , ""
+ , " def func(x):"
+ , " return y"
+ ] =?>
+ ( doc $ codeBlockWith
+ ( ""
+ , ["sourceCode", "python", "numberLines", "class1", "class2", "class3"]
+ , [ ("startFrom", "34") ]
+ )
+ "def func(x):\n return y"
+ )
+ , "Code directive with number-lines, no line specified" =: unlines
+ [ ".. code::python"
+ , " :number-lines: "
+ , ""
+ , " def func(x):"
+ , " return y"
+ ] =?>
+ ( doc $ codeBlockWith
+ ( ""
+ , ["sourceCode", "python", "numberLines"]
+ , [ ("startFrom", "") ]
+ )
+ "def func(x):\n return y"
+ )
+ , testGroup "literal / line / code blocks"
+ [ "indented literal block" =: unlines
+ [ "::"
+ , ""
+ , " block quotes"
+ , ""
+ , " can go on for many lines"
+ , "but must stop here"]
+ =?> (doc $
+ codeBlock "block quotes\n\ncan go on for many lines" <>
+ para "but must stop here")
+ , "line block with 3 lines" =: "| a\n| b\n| c"
+ =?> lineBlock ["a", "b", "c"]
+ , "quoted literal block using >" =: "::\n\n> quoted\n> block\n\nOrdinary paragraph"
+ =?> codeBlock "> quoted\n> block" <> para "Ordinary paragraph"
+ , "quoted literal block using | (not a line block)" =: "::\n\n| quoted\n| block\n\nOrdinary paragraph"
+ =?> codeBlock "| quoted\n| block" <> para "Ordinary paragraph"
+ , "class directive with single paragraph" =: ".. class:: special\n\nThis is a \"special\" paragraph."
+ =?> divWith ("", ["special"], []) (para "This is a \"special\" paragraph.")
+ , "class directive with two paragraphs" =: ".. class:: exceptional remarkable\n\n First paragraph.\n\n Second paragraph."
+ =?> divWith ("", ["exceptional", "remarkable"], []) (para "First paragraph." <> para "Second paragraph.")
+ , "class directive around literal block" =: ".. class:: classy\n\n::\n\n a\n b"
+ =?> divWith ("", ["classy"], []) (codeBlock "a\nb")]
+ , testGroup "interpreted text roles"
+ [ "literal role prefix" =: ":literal:`a`" =?> para (code "a")
+ , "literal role postfix" =: "`a`:literal:" =?> para (code "a")
+ , "literal text" =: "``text``" =?> para (code "text")
+ , "code role" =: ":code:`a`" =?> para (codeWith ("", ["sourceCode"], []) "a")
+ , "inherited code role" =: ".. role:: codeLike(code)\n\n:codeLike:`a`"
+ =?> para (codeWith ("", ["codeLike", "sourceCode"], []) "a")
+ , "custom code role with language field"
+ =: ".. role:: lhs(code)\n :language: haskell\n\n:lhs:`a`"
+ =?> para (codeWith ("", ["lhs", "haskell","sourceCode"], []) "a")
+ , "custom role with unspecified parent role"
+ =: ".. role:: classy\n\n:classy:`text`"
+ =?> para (spanWith ("", ["classy"], []) "text")
+ , "role with recursive inheritance"
+ =: ".. role:: haskell(code)\n.. role:: lhs(haskell)\n\n:lhs:`text`"
+ =?> para (codeWith ("", ["lhs", "haskell", "sourceCode"], []) "text")
+ , "unknown role" =: ":unknown:`text`" =?> para (str "text")
+ ]
+ , testGroup "footnotes"
+ [ "remove space before note" =: unlines
+ [ "foo [1]_"
+ , ""
+ , ".. [1]"
+ , " bar"
+ ] =?>
+ (para $ "foo" <> (note $ para "bar"))
+ ]
+ ]
diff --git a/test/Tests/Readers/Txt2Tags.hs b/test/Tests/Readers/Txt2Tags.hs
new file mode 100644
index 000000000..46831d86f
--- /dev/null
+++ b/test/Tests/Readers/Txt2Tags.hs
@@ -0,0 +1,436 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Readers.Txt2Tags (tests) where
+
+import Text.Pandoc.Definition
+import Test.Framework
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Data.List (intersperse)
+import Text.Pandoc.Class
+
+
+t2t :: String -> Pandoc
+-- t2t = handleError . readTxt2Tags (T2TMeta "date" "mtime" "in" "out") def
+t2t = purely $ \s -> do
+ putCommonState
+ def { stInputFiles = Just ["in"]
+ , stOutputFile = Just "out"
+ }
+ readTxt2Tags def s
+
+infix 4 =:
+(=:) :: ToString c
+ => String -> (String, c) -> Test
+(=:) = test t2t
+
+spcSep :: [Inlines] -> Inlines
+spcSep = mconcat . intersperse space
+
+simpleTable' :: Int
+ -> [Blocks]
+ -> [[Blocks]]
+ -> Blocks
+simpleTable' n = table "" (take n $ repeat (AlignCenter, 0.0))
+
+tests :: [Test]
+tests =
+ [ testGroup "Inlines" $
+ [ "Plain String" =:
+ "Hello, World" =?>
+ para (spcSep [ "Hello,", "World" ])
+
+ , "Emphasis" =:
+ "//Planet Punk//" =?>
+ para (emph . spcSep $ ["Planet", "Punk"])
+
+ , "Strong" =:
+ "**Cider**" =?>
+ para (strong "Cider")
+
+ , "Strong Emphasis" =:
+ "//**strength**//" =?>
+ para (emph . strong $ "strength")
+
+ , "Strikeout" =:
+ "--Kill Bill--" =?>
+ para (strikeout . spcSep $ [ "Kill", "Bill" ])
+
+ , "Verbatim" =:
+ "``Robot.rock()``" =?>
+ para (code "Robot.rock()")
+
+ , "Symbol" =:
+ "A * symbol" =?>
+ para (str "A" <> space <> str "*" <> space <> "symbol")
+
+ , "No empty markup" =:
+ "//// **** ____ ---- ```` \"\"\"\" ''''" =?>
+ para (spcSep [ "////", "****", "____", "----", "````", "\"\"\"\"", "''''" ])
+
+ , "Inline markup is greedy" =:
+ "***** ///// _____ ----- ````` \"\"\"\"\" '''''" =?>
+ para (spcSep [strong "*", emph "/", emph "_"
+ , strikeout "-", code "`", text "\""
+ , rawInline "html" "'"])
+ , "Markup must be greedy" =:
+ "********** ////////// __________ ---------- `````````` \"\"\"\"\"\"\"\"\"\" ''''''''''" =?>
+ para (spcSep [strong "******", emph "//////", emph "______"
+ , strikeout "------", code "``````", text "\"\"\"\"\"\""
+ , rawInline "html" "''''''"])
+ , "Inlines must be glued" =:
+ "** a** **a ** ** a **" =?>
+ para (text "** a** **a ** ** a **")
+
+ , "Macros: Date" =:
+ "%%date" =?>
+ para "1970-01-01"
+ , "Macros: Mod Time" =:
+ "%%mtime" =?>
+ para (str "")
+ , "Macros: Infile" =:
+ "%%infile" =?>
+ para "in"
+ , "Macros: Outfile" =:
+ "%%outfile" =?>
+ para "out"
+ , "Autolink" =:
+ "http://www.google.com" =?>
+ para (link "http://www.google.com" "" (str "http://www.google.com"))
+ , "Image" =:
+ "[image.jpg]" =?>
+ para (image "image.jpg" "" mempty)
+
+ , "Link" =:
+ "[title http://google.com]" =?>
+ para (link "http://google.com" "" (str "title"))
+
+ , "Image link" =:
+ "[[image.jpg] abc]" =?>
+ para (link "abc" "" (image "image.jpg" "" mempty))
+ , "Invalid link: No trailing space" =:
+ "[title invalid ]" =?>
+ para (text "[title invalid ]")
+
+
+ ]
+
+ , testGroup "Basic Blocks" $
+ ["Paragraph, lines grouped together" =:
+ "A paragraph\n A blank line ends the \n current paragraph\n"
+ =?> para "A paragraph\n A blank line ends the\n current paragraph"
+ , "Paragraph, ignore leading and trailing spaces" =:
+ " Leading and trailing spaces are ignored. \n" =?>
+ para "Leading and trailing spaces are ignored."
+ , "Comment line in paragraph" =:
+ "A comment line can be placed inside a paragraph.\n% this comment will be ignored \nIt will not affect it.\n"
+ =?> para "A comment line can be placed inside a paragraph.\nIt will not affect it."
+ , "Paragraph" =:
+ "Paragraph\n" =?>
+ para "Paragraph"
+
+ , "First Level Header" =:
+ "+ Headline +\n" =?>
+ header 1 "Headline"
+
+ , "Third Level Header" =:
+ "=== Third Level Headline ===\n" =?>
+ header 3 ("Third" <> space <>
+ "Level" <> space <>
+ "Headline")
+
+ , "Header with label" =:
+ "= header =[label]" =?>
+ headerWith ("label", [], []) 1 ("header")
+
+ , "Invalid header, mismatched delimiters" =:
+ "== header =" =?>
+ para (text "== header =")
+
+ , "Invalid header, spaces in label" =:
+ "== header ==[ haha ]" =?>
+ para (text "== header ==[ haha ]")
+
+ , "Invalid header, invalid label character" =:
+ "== header ==[lab/el]" =?>
+ para (text "== header ==[lab/el]")
+ , "Headers not preceded by a blank line" =:
+ unlines [ "++ eat dinner ++"
+ , "Spaghetti and meatballs tonight."
+ , "== walk dog =="
+ ] =?>
+ mconcat [ header 2 ("eat" <> space <> "dinner")
+ , para $ spcSep [ "Spaghetti", "and", "meatballs", "tonight." ]
+ , header 2 ("walk" <> space <> "dog")
+ ]
+
+ , "Paragraph starting with an equals" =:
+ "=five" =?>
+ para "=five"
+
+ , "Paragraph containing asterisk at beginning of line" =:
+ unlines [ "lucky"
+ , "*star"
+ ] =?>
+ para ("lucky" <> softbreak <> "*star")
+
+ , "Horizontal Rule" =:
+ unlines [ "before"
+ , replicate 20 '-'
+ , replicate 20 '='
+ , replicate 20 '_'
+ , "after"
+ ] =?>
+ mconcat [ para "before"
+ , horizontalRule
+ , horizontalRule
+ , horizontalRule
+ , para "after"
+ ]
+
+ , "Comment Block" =:
+ unlines [ "%%%"
+ , "stuff"
+ , "bla"
+ , "%%%"] =?>
+ (mempty::Blocks)
+
+
+ ]
+
+ , testGroup "Lists" $
+ [ "Simple Bullet Lists" =:
+ ("- Item1\n" ++
+ "- Item2\n") =?>
+ bulletList [ plain "Item1"
+ , plain "Item2"
+ ]
+
+ , "Indented Bullet Lists" =:
+ (" - Item1\n" ++
+ " - Item2\n") =?>
+ bulletList [ plain "Item1"
+ , plain "Item2"
+ ]
+
+
+
+ , "Nested Bullet Lists" =:
+ ("- Discovery\n" ++
+ " + One More Time\n" ++
+ " + Harder, Better, Faster, Stronger\n" ++
+ "- Homework\n" ++
+ " + Around the World\n"++
+ "- Human After All\n" ++
+ " + Technologic\n" ++
+ " + Robot Rock\n") =?>
+ bulletList [ mconcat
+ [ plain "Discovery"
+ , orderedList [ plain ("One" <> space <>
+ "More" <> space <>
+ "Time")
+ , plain ("Harder," <> space <>
+ "Better," <> space <>
+ "Faster," <> space <>
+ "Stronger")
+ ]
+ ]
+ , mconcat
+ [ plain "Homework"
+ , orderedList [ plain ("Around" <> space <>
+ "the" <> space <>
+ "World")
+ ]
+ ]
+ , mconcat
+ [ plain ("Human" <> space <> "After" <> space <> "All")
+ , orderedList [ plain "Technologic"
+ , plain ("Robot" <> space <> "Rock")
+ ]
+ ]
+ ]
+
+ , "Simple Ordered List" =:
+ ("+ Item1\n" ++
+ "+ Item2\n") =?>
+ let listStyle = (1, DefaultStyle, DefaultDelim)
+ listStructure = [ plain "Item1"
+ , plain "Item2"
+ ]
+ in orderedListWith listStyle listStructure
+
+
+ , "Indented Ordered List" =:
+ (" + Item1\n" ++
+ " + Item2\n") =?>
+ let listStyle = (1, DefaultStyle, DefaultDelim)
+ listStructure = [ plain "Item1"
+ , plain "Item2"
+ ]
+ in orderedListWith listStyle listStructure
+
+ , "Nested Ordered Lists" =:
+ ("+ One\n" ++
+ " + One-One\n" ++
+ " + One-Two\n" ++
+ "+ Two\n" ++
+ " + Two-One\n"++
+ " + Two-Two\n") =?>
+ let listStyle = (1, DefaultStyle, DefaultDelim)
+ listStructure = [ mconcat
+ [ plain "One"
+ , orderedList [ plain "One-One"
+ , plain "One-Two"
+ ]
+ ]
+ , mconcat
+ [ plain "Two"
+ , orderedList [ plain "Two-One"
+ , plain "Two-Two"
+ ]
+ ]
+ ]
+ in orderedListWith listStyle listStructure
+
+ , "Ordered List in Bullet List" =:
+ ("- Emacs\n" ++
+ " + Org\n") =?>
+ bulletList [ (plain "Emacs") <>
+ (orderedList [ plain "Org"])
+ ]
+
+ , "Bullet List in Ordered List" =:
+ ("+ GNU\n" ++
+ " - Freedom\n") =?>
+ orderedList [ (plain "GNU") <> bulletList [ (plain "Freedom") ] ]
+
+ , "Definition List" =:
+ unlines [ ": PLL"
+ , " phase-locked loop"
+ , ": TTL"
+ , " transistor-transistor logic"
+ , ": PSK"
+ , " a digital"
+ ] =?>
+ definitionList [ ("PLL", [ plain $ "phase-locked" <> space <> "loop" ])
+ , ("TTL", [ plain $ "transistor-transistor" <> space <> "logic" ])
+ , ("PSK", [ plain $ "a" <> space <> "digital" ])
+ ]
+
+
+ , "Loose bullet list" =:
+ unlines [ "- apple"
+ , ""
+ , "- orange"
+ , ""
+ , "- peach"
+ ] =?>
+ bulletList [ para "apple"
+ , para "orange"
+ , para "peach"
+ ]
+ ]
+
+ , testGroup "Tables"
+ [ "Single cell table" =:
+ "| Test " =?>
+ simpleTable' 1 mempty [[plain "Test"]]
+
+ , "Multi cell table" =:
+ "| One | Two |" =?>
+ simpleTable' 2 mempty [ [ plain "One", plain "Two" ] ]
+
+ , "Multi line table" =:
+ unlines [ "| One |"
+ , "| Two |"
+ , "| Three |"
+ ] =?>
+ simpleTable' 1 mempty
+ [ [ plain "One" ]
+ , [ plain "Two" ]
+ , [ plain "Three" ]
+ ]
+
+ , "Empty table" =:
+ "| |" =?>
+ simpleTable' 1 mempty [[mempty]]
+
+ , "Glider Table" =:
+ unlines [ "| 1 | 0 | 0 |"
+ , "| 0 | 1 | 1 |"
+ , "| 1 | 1 | 0 |"
+ ] =?>
+ simpleTable' 3 mempty
+ [ [ plain "1", plain "0", plain "0" ]
+ , [ plain "0", plain "1", plain "1" ]
+ , [ plain "1", plain "1", plain "0" ]
+ ]
+
+
+ , "Table with Header" =:
+ unlines [ "|| Species | Status |"
+ , "| cervisiae | domesticated |"
+ , "| paradoxus | wild |"
+ ] =?>
+ simpleTable [ plain "Species", plain "Status" ]
+ [ [ plain "cervisiae", plain "domesticated" ]
+ , [ plain "paradoxus", plain "wild" ]
+ ]
+
+ , "Table alignment determined by spacing" =:
+ unlines [ "| Numbers | Text | More |"
+ , "| 1 | One | foo |"
+ , "| 2 | Two | bar |"
+ ] =?>
+ table "" (zip [AlignCenter, AlignRight, AlignDefault] [0, 0, 0])
+ []
+ [ [ plain "Numbers", plain "Text", plain "More" ]
+ , [ plain "1" , plain "One" , plain "foo" ]
+ , [ plain "2" , plain "Two" , plain "bar" ]
+ ]
+
+ , "Pipe within text doesn't start a table" =:
+ "Ceci n'est pas une | pipe " =?>
+ para (spcSep [ "Ceci", "n'est", "pas", "une", "|", "pipe" ])
+
+
+ , "Table with differing row lengths" =:
+ unlines [ "|| Numbers | Text "
+ , "| 1 | One | foo |"
+ , "| 2 "
+ ] =?>
+ table "" (zip [AlignCenter, AlignLeft, AlignLeft] [0, 0, 0])
+ [ plain "Numbers", plain "Text" , plain mempty ]
+ [ [ plain "1" , plain "One" , plain "foo" ]
+ , [ plain "2" , plain mempty , plain mempty ]
+ ]
+
+ ]
+
+ , testGroup "Blocks and fragments"
+ [ "Source block" =:
+ unlines [ "```"
+ , "main = putStrLn greeting"
+ , " where greeting = \"moin\""
+ , "```" ] =?>
+ let code' = "main = putStrLn greeting\n" ++
+ " where greeting = \"moin\"\n"
+ in codeBlock code'
+
+ , "tagged block" =:
+ unlines [ "'''"
+ , "<aside>HTML5 is pretty nice.</aside>"
+ , "'''"
+ ] =?>
+ rawBlock "html" "<aside>HTML5 is pretty nice.</aside>\n"
+
+ , "Quote block" =:
+ unlines ["\t//Niemand// hat die Absicht, eine Mauer zu errichten!"
+ ] =?>
+ blockQuote (para (spcSep [ emph "Niemand", "hat", "die", "Absicht,"
+ , "eine", "Mauer", "zu", "errichten!"
+ ]))
+
+ ]
+ ]
diff --git a/test/Tests/Shared.hs b/test/Tests/Shared.hs
new file mode 100644
index 000000000..9b9aeb6a3
--- /dev/null
+++ b/test/Tests/Shared.hs
@@ -0,0 +1,40 @@
+module Tests.Shared (tests) where
+
+import Text.Pandoc.Shared
+import Test.Framework
+import Text.Pandoc.Arbitrary()
+import Test.Framework.Providers.HUnit
+import Test.HUnit ( assertBool, (@?=) )
+import Text.Pandoc.Builder
+import System.FilePath.Posix (joinPath)
+
+tests :: [Test]
+tests = [ testGroup "compactifyDL"
+ [ testCase "compactifyDL with empty def" $
+ assertBool "compactifyDL"
+ (let x = [(str "word", [para (str "def"), mempty])]
+ in compactifyDL x == x)
+ ]
+ , testGroup "collapseFilePath" testCollapse
+ ]
+
+testCollapse :: [Test]
+testCollapse = map (testCase "collapse")
+ [ (collapseFilePath (joinPath [ ""]) @?= (joinPath [ ""]))
+ , (collapseFilePath (joinPath [ ".","foo"]) @?= (joinPath [ "foo"]))
+ , (collapseFilePath (joinPath [ ".",".","..","foo"]) @?= (joinPath [ joinPath ["..", "foo"]]))
+ , (collapseFilePath (joinPath [ "..","foo"]) @?= (joinPath [ "..","foo"]))
+ , (collapseFilePath (joinPath [ "","bar","..","baz"]) @?= (joinPath [ "","baz"]))
+ , (collapseFilePath (joinPath [ "","..","baz"]) @?= (joinPath [ "","..","baz"]))
+ , (collapseFilePath (joinPath [ ".","foo","..",".","bar","..",".",".","baz"]) @?= (joinPath [ "baz"]))
+ , (collapseFilePath (joinPath [ ".",""]) @?= (joinPath [ ""]))
+ , (collapseFilePath (joinPath [ ".",".",""]) @?= (joinPath [ ""]))
+ , (collapseFilePath (joinPath [ "..",""]) @?= (joinPath [ ".."]))
+ , (collapseFilePath (joinPath [ "..",".",""]) @?= (joinPath [ ".."]))
+ , (collapseFilePath (joinPath [ ".","..",""]) @?= (joinPath [ ".."]))
+ , (collapseFilePath (joinPath [ "..","..",""]) @?= (joinPath [ "..",".."]))
+ , (collapseFilePath (joinPath [ "parent","foo","baz","..","bar"]) @?= (joinPath [ "parent","foo","bar"]))
+ , (collapseFilePath (joinPath [ "parent","foo","baz","..","..","bar"]) @?= (joinPath [ "parent","bar"]))
+ , (collapseFilePath (joinPath [ "parent","foo",".."]) @?= (joinPath [ "parent"]))
+ , (collapseFilePath (joinPath [ "","parent","foo","..","..","bar"]) @?= (joinPath [ "","bar"]))
+ , (collapseFilePath (joinPath [ "",".","parent","foo"]) @?= (joinPath [ "","parent","foo"]))]
diff --git a/test/Tests/Writers/AsciiDoc.hs b/test/Tests/Writers/AsciiDoc.hs
new file mode 100644
index 000000000..7103b838b
--- /dev/null
+++ b/test/Tests/Writers/AsciiDoc.hs
@@ -0,0 +1,55 @@
+module Tests.Writers.AsciiDoc (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+
+asciidoc :: (ToPandoc a) => a -> String
+asciidoc = purely (writeAsciiDoc def{ writerWrapText = WrapNone }) . toPandoc
+
+tests :: [Test]
+tests = [ testGroup "emphasis"
+ [ test asciidoc "emph word before" $
+ para (text "foo" <> emph (text "bar")) =?>
+ "foo__bar__"
+ , test asciidoc "emph word after" $
+ para (emph (text "foo") <> text "bar") =?>
+ "__foo__bar"
+ , test asciidoc "emph quoted" $
+ para (doubleQuoted (emph (text "foo"))) =?>
+ "``__foo__''"
+ , test asciidoc "strong word before" $
+ para (text "foo" <> strong (text "bar")) =?>
+ "foo**bar**"
+ , test asciidoc "strong word after" $
+ para (strong (text "foo") <> text "bar") =?>
+ "**foo**bar"
+ , test asciidoc "strong quoted" $
+ para (singleQuoted (strong (text "foo"))) =?>
+ "`**foo**'"
+ ]
+ , testGroup "tables"
+ [ test asciidoc "empty cells" $
+ simpleTable [] [[mempty],[mempty]] =?> unlines
+ [ "[cols=\"\",]"
+ , "|===="
+ , "|"
+ , "|"
+ , "|===="
+ ]
+ , test asciidoc "multiblock cells" $
+ simpleTable [] [[para (text "Para 1") <> para (text "Para 2")]]
+ =?> unlines
+ [ "[cols=\"\",]"
+ , "|====="
+ , "a|"
+ , "Para 1"
+ , ""
+ , "Para 2"
+ , ""
+ , "|====="
+ ]
+ ]
+ ]
diff --git a/test/Tests/Writers/ConTeXt.hs b/test/Tests/Writers/ConTeXt.hs
new file mode 100644
index 000000000..b3e12a571
--- /dev/null
+++ b/test/Tests/Writers/ConTeXt.hs
@@ -0,0 +1,70 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Writers.ConTeXt (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+
+context :: (ToPandoc a) => a -> String
+context = purely (writeConTeXt def) . toPandoc
+
+context' :: (ToPandoc a) => a -> String
+context' = purely (writeConTeXt def{ writerWrapText = WrapNone }) . toPandoc
+
+{-
+ "my test" =: X =?> Y
+
+is shorthand for
+
+ test context "my test" $ X =?> Y
+
+which is in turn shorthand for
+
+ test context "my test" (X,Y)
+-}
+
+infix 4 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test context
+
+tests :: [Test]
+tests = [ testGroup "inline code"
+ [ "with '}'" =: code "}" =?> "\\mono{\\}}"
+ , "without '}'" =: code "]" =?> "\\type{]}"
+ , property "code property" $ \s -> null s ||
+ if '{' `elem` s || '}' `elem` s
+ then (context' $ code s) == "\\mono{" ++
+ (context' $ str s) ++ "}"
+ else (context' $ code s) == "\\type{" ++ s ++ "}"
+ ]
+ , testGroup "headers"
+ [ "level 1" =:
+ headerWith ("my-header",[],[]) 1 "My header" =?> "\\section[my-header]{My header}"
+ ]
+ , testGroup "bullet lists"
+ [ "nested" =:
+ bulletList [
+ plain (text "top")
+ <> bulletList [
+ plain (text "next")
+ <> bulletList [plain (text "bot")]
+ ]
+ ] =?> unlines
+ [ "\\startitemize[packed]"
+ , "\\item"
+ , " top"
+ , " \\startitemize[packed]"
+ , " \\item"
+ , " next"
+ , " \\startitemize[packed]"
+ , " \\item"
+ , " bot"
+ , " \\stopitemize"
+ , " \\stopitemize"
+ , "\\stopitemize" ]
+ ]
+ ]
+
diff --git a/test/Tests/Writers/Docbook.hs b/test/Tests/Writers/Docbook.hs
new file mode 100644
index 000000000..f34f2495c
--- /dev/null
+++ b/test/Tests/Writers/Docbook.hs
@@ -0,0 +1,302 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Writers.Docbook (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+
+docbook :: (ToPandoc a) => a -> String
+docbook = docbookWithOpts def{ writerWrapText = WrapNone }
+
+docbookWithOpts :: ToPandoc a => WriterOptions -> a -> String
+docbookWithOpts opts = purely (writeDocbook4 opts) . toPandoc
+
+{-
+ "my test" =: X =?> Y
+
+is shorthand for
+
+ test docbook "my test" $ X =?> Y
+
+which is in turn shorthand for
+
+ test docbook "my test" (X,Y)
+-}
+
+infix 4 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test docbook
+
+lineblock :: Blocks
+lineblock = para ("some text" <> linebreak <>
+ "and more lines" <> linebreak <>
+ "and again")
+lineblock_out :: [String]
+lineblock_out = [ "<literallayout>some text"
+ , "and more lines"
+ , "and again</literallayout>"
+ ]
+
+tests :: [Test]
+tests = [ testGroup "line blocks"
+ [ "none" =: para "This is a test"
+ =?> unlines
+ [ "<para>"
+ , " This is a test"
+ , "</para>"
+ ]
+ , "basic" =: lineblock
+ =?> unlines lineblock_out
+ , "blockquote" =: blockQuote lineblock
+ =?> unlines
+ ( [ "<blockquote>" ] ++
+ lineblock_out ++
+ [ "</blockquote>" ]
+ )
+ , "footnote" =: para ("This is a test" <>
+ note lineblock <>
+ " of footnotes")
+ =?> unlines
+ ( [ "<para>"
+ , " This is a test<footnote>" ] ++
+ lineblock_out ++
+ [ " </footnote> of footnotes"
+ , "</para>" ]
+ )
+ ]
+ , testGroup "compact lists"
+ [ testGroup "bullet"
+ [ "compact" =: bulletList [plain "a", plain "b", plain "c"]
+ =?> unlines
+ [ "<itemizedlist spacing=\"compact\">"
+ , " <listitem>"
+ , " <para>"
+ , " a"
+ , " </para>"
+ , " </listitem>"
+ , " <listitem>"
+ , " <para>"
+ , " b"
+ , " </para>"
+ , " </listitem>"
+ , " <listitem>"
+ , " <para>"
+ , " c"
+ , " </para>"
+ , " </listitem>"
+ , "</itemizedlist>"
+ ]
+ , "loose" =: bulletList [para "a", para "b", para "c"]
+ =?> unlines
+ [ "<itemizedlist>"
+ , " <listitem>"
+ , " <para>"
+ , " a"
+ , " </para>"
+ , " </listitem>"
+ , " <listitem>"
+ , " <para>"
+ , " b"
+ , " </para>"
+ , " </listitem>"
+ , " <listitem>"
+ , " <para>"
+ , " c"
+ , " </para>"
+ , " </listitem>"
+ , "</itemizedlist>"
+ ]
+ ]
+ , testGroup "ordered"
+ [ "compact" =: orderedList [plain "a", plain "b", plain "c"]
+ =?> unlines
+ [ "<orderedlist spacing=\"compact\">"
+ , " <listitem>"
+ , " <para>"
+ , " a"
+ , " </para>"
+ , " </listitem>"
+ , " <listitem>"
+ , " <para>"
+ , " b"
+ , " </para>"
+ , " </listitem>"
+ , " <listitem>"
+ , " <para>"
+ , " c"
+ , " </para>"
+ , " </listitem>"
+ , "</orderedlist>"
+ ]
+ , "loose" =: orderedList [para "a", para "b", para "c"]
+ =?> unlines
+ [ "<orderedlist>"
+ , " <listitem>"
+ , " <para>"
+ , " a"
+ , " </para>"
+ , " </listitem>"
+ , " <listitem>"
+ , " <para>"
+ , " b"
+ , " </para>"
+ , " </listitem>"
+ , " <listitem>"
+ , " <para>"
+ , " c"
+ , " </para>"
+ , " </listitem>"
+ , "</orderedlist>"
+ ]
+ ]
+ , testGroup "definition"
+ [ "compact" =: definitionList [ ("an", [plain "apple" ])
+ , ("a", [plain "banana"])
+ , ("an", [plain "orange"])]
+ =?> unlines
+ [ "<variablelist spacing=\"compact\">"
+ , " <varlistentry>"
+ , " <term>"
+ , " an"
+ , " </term>"
+ , " <listitem>"
+ , " <para>"
+ , " apple"
+ , " </para>"
+ , " </listitem>"
+ , " </varlistentry>"
+ , " <varlistentry>"
+ , " <term>"
+ , " a"
+ , " </term>"
+ , " <listitem>"
+ , " <para>"
+ , " banana"
+ , " </para>"
+ , " </listitem>"
+ , " </varlistentry>"
+ , " <varlistentry>"
+ , " <term>"
+ , " an"
+ , " </term>"
+ , " <listitem>"
+ , " <para>"
+ , " orange"
+ , " </para>"
+ , " </listitem>"
+ , " </varlistentry>"
+ , "</variablelist>"
+ ]
+ , "loose" =: definitionList [ ("an", [para "apple" ])
+ , ("a", [para "banana"])
+ , ("an", [para "orange"])]
+ =?> unlines
+ [ "<variablelist>"
+ , " <varlistentry>"
+ , " <term>"
+ , " an"
+ , " </term>"
+ , " <listitem>"
+ , " <para>"
+ , " apple"
+ , " </para>"
+ , " </listitem>"
+ , " </varlistentry>"
+ , " <varlistentry>"
+ , " <term>"
+ , " a"
+ , " </term>"
+ , " <listitem>"
+ , " <para>"
+ , " banana"
+ , " </para>"
+ , " </listitem>"
+ , " </varlistentry>"
+ , " <varlistentry>"
+ , " <term>"
+ , " an"
+ , " </term>"
+ , " <listitem>"
+ , " <para>"
+ , " orange"
+ , " </para>"
+ , " </listitem>"
+ , " </varlistentry>"
+ , "</variablelist>"
+ ]
+ ]
+ ]
+ , testGroup "writer options" $
+ [ testGroup "top-level division" $
+ let
+ headers = header 1 (text "header1")
+ <> header 2 (text "header2")
+ <> header 3 (text "header3")
+
+ docbookTopLevelDiv :: (ToPandoc a)
+ => TopLevelDivision -> a -> String
+ docbookTopLevelDiv division =
+ docbookWithOpts def{ writerTopLevelDivision = division }
+ in
+ [ test (docbookTopLevelDiv TopLevelSection) "sections as top-level" $
+ headers =?>
+ unlines [ "<sect1>"
+ , " <title>header1</title>"
+ , " <sect2>"
+ , " <title>header2</title>"
+ , " <sect3>"
+ , " <title>header3</title>"
+ , " <para>"
+ , " </para>"
+ , " </sect3>"
+ , " </sect2>"
+ , "</sect1>"
+ ]
+ , test (docbookTopLevelDiv TopLevelChapter) "chapters as top-level" $
+ headers =?>
+ unlines [ "<chapter>"
+ , " <title>header1</title>"
+ , " <sect1>"
+ , " <title>header2</title>"
+ , " <sect2>"
+ , " <title>header3</title>"
+ , " <para>"
+ , " </para>"
+ , " </sect2>"
+ , " </sect1>"
+ , "</chapter>"
+ ]
+ , test (docbookTopLevelDiv TopLevelPart) "parts as top-level" $
+ headers =?>
+ unlines [ "<part>"
+ , " <title>header1</title>"
+ , " <chapter>"
+ , " <title>header2</title>"
+ , " <sect1>"
+ , " <title>header3</title>"
+ , " <para>"
+ , " </para>"
+ , " </sect1>"
+ , " </chapter>"
+ , "</part>"
+ ]
+ , test (docbookTopLevelDiv TopLevelDefault) "default top-level" $
+ headers =?>
+ unlines [ "<sect1>"
+ , " <title>header1</title>"
+ , " <sect2>"
+ , " <title>header2</title>"
+ , " <sect3>"
+ , " <title>header3</title>"
+ , " <para>"
+ , " </para>"
+ , " </sect3>"
+ , " </sect2>"
+ , "</sect1>"
+ ]
+ ]
+ ]
+ ]
diff --git a/test/Tests/Writers/Docx.hs b/test/Tests/Writers/Docx.hs
new file mode 100644
index 000000000..fd320d224
--- /dev/null
+++ b/test/Tests/Writers/Docx.hs
@@ -0,0 +1,151 @@
+module Tests.Writers.Docx (tests) where
+
+import Text.Pandoc.Options
+import Text.Pandoc.Readers.Native
+import Text.Pandoc.Definition
+import Tests.Helpers
+import Test.Framework
+import Text.Pandoc.Readers.Docx
+import Text.Pandoc.Writers.Docx
+import System.FilePath ((</>))
+import Text.Pandoc.Class (runIOorExplode)
+
+type Options = (WriterOptions, ReaderOptions)
+
+compareOutput :: Options
+ -> FilePath
+ -> FilePath
+ -> IO (Pandoc, Pandoc)
+compareOutput opts nativeFileIn nativeFileOut = do
+ nf <- Prelude.readFile nativeFileIn
+ nf' <- Prelude.readFile nativeFileOut
+ let wopts = fst opts
+ df <- runIOorExplode $ do
+ d <- readNative def nf
+ writeDocx wopts{writerUserDataDir = Just (".." </> "data")} d
+ df' <- runIOorExplode (readNative def nf')
+ p <- runIOorExplode $ readDocx (snd opts) df
+ return (p, df')
+
+testCompareWithOptsIO :: Options -> String -> FilePath -> FilePath -> IO Test
+testCompareWithOptsIO opts name nativeFileIn nativeFileOut = do
+ (dp, np) <- compareOutput opts nativeFileIn nativeFileOut
+ return $ test id name (dp, np)
+
+testCompareWithOpts :: Options -> String -> FilePath -> FilePath -> Test
+testCompareWithOpts opts name nativeFileIn nativeFileOut =
+ buildTest $ testCompareWithOptsIO opts name nativeFileIn nativeFileOut
+
+roundTripCompareWithOpts :: Options -> String -> FilePath -> Test
+roundTripCompareWithOpts opts name nativeFile =
+ testCompareWithOpts opts name nativeFile nativeFile
+
+-- testCompare :: String -> FilePath -> FilePath -> Test
+-- testCompare = testCompareWithOpts def
+
+roundTripCompare :: String -> FilePath -> Test
+roundTripCompare = roundTripCompareWithOpts def
+
+tests :: [Test]
+tests = [ testGroup "inlines"
+ [ roundTripCompare
+ "font formatting"
+ "docx/inline_formatting_writer.native"
+ , roundTripCompare
+ "font formatting with character styles"
+ "docx/char_styles.native"
+ , roundTripCompare
+ "hyperlinks"
+ "docx/links_writer.native"
+ , roundTripCompare
+ "inline image"
+ "docx/image_no_embed_writer.native"
+ , roundTripCompare
+ "inline image in links"
+ "docx/inline_images_writer.native"
+ , roundTripCompare
+ "handling unicode input"
+ "docx/unicode.native"
+ , roundTripCompare
+ "literal tabs"
+ "docx/tabs.native"
+ , roundTripCompare
+ "normalizing inlines"
+ "docx/normalize.native"
+ , roundTripCompare
+ "normalizing inlines deep inside blocks"
+ "docx/deep_normalize.native"
+ , roundTripCompare
+ "move trailing spaces outside of formatting"
+ "docx/trailing_spaces_in_formatting.native"
+ , roundTripCompare
+ "inline code (with VerbatimChar style)"
+ "docx/inline_code.native"
+ , roundTripCompare
+ "inline code in subscript and superscript"
+ "docx/verbatim_subsuper.native"
+ ]
+ , testGroup "blocks"
+ [ roundTripCompare
+ "headers"
+ "docx/headers.native"
+ , roundTripCompare
+ "headers already having auto identifiers"
+ "docx/already_auto_ident.native"
+ , roundTripCompare
+ "numbered headers automatically made into list"
+ "docx/numbered_header.native"
+ , roundTripCompare
+ "i18n blocks (headers and blockquotes)"
+ "docx/i18n_blocks.native"
+ -- Continuation does not survive round-trip
+ , roundTripCompare
+ "lists"
+ "docx/lists_writer.native"
+ , roundTripCompare
+ "definition lists"
+ "docx/definition_list.native"
+ , roundTripCompare
+ "custom defined lists in styles"
+ "docx/german_styled_lists.native"
+ , roundTripCompare
+ "footnotes and endnotes"
+ "docx/notes.native"
+ , roundTripCompare
+ "blockquotes (parsing indent as blockquote)"
+ "docx/block_quotes_parse_indent.native"
+ , roundTripCompare
+ "hanging indents"
+ "docx/hanging_indent.native"
+ -- tables headers do not survive round-trip, should look into that
+ , roundTripCompare
+ "tables"
+ "docx/tables.native"
+ , roundTripCompare
+ "tables with lists in cells"
+ "docx/table_with_list_cell.native"
+ , roundTripCompare
+ "code block"
+ "docx/codeblock.native"
+ , roundTripCompare
+ "dropcap paragraphs"
+ "docx/drop_cap.native"
+ ]
+ , testGroup "metadata"
+ [ roundTripCompareWithOpts (def,def{readerStandalone=True})
+ "metadata fields"
+ "docx/metadata.native"
+ , roundTripCompareWithOpts (def,def{readerStandalone=True})
+ "stop recording metadata with normal text"
+ "docx/metadata_after_normal.native"
+ ]
+ , testGroup "customized styles"
+ [ testCompareWithOpts
+ ( def{writerReferenceDoc=Just "docx/custom-style-reference.docx"}
+ , def)
+ "simple customized blocks and inlines"
+ "docx/custom-style-roundtrip-start.native"
+ "docx/custom-style-roundtrip-end.native"
+ ]
+
+ ]
diff --git a/test/Tests/Writers/HTML.hs b/test/Tests/Writers/HTML.hs
new file mode 100644
index 000000000..45de2b042
--- /dev/null
+++ b/test/Tests/Writers/HTML.hs
@@ -0,0 +1,43 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Writers.HTML (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+
+html :: (ToPandoc a) => a -> String
+html = purely (writeHtml4String def{ writerWrapText = WrapNone }) . toPandoc
+
+{-
+ "my test" =: X =?> Y
+
+is shorthand for
+
+ test html "my test" $ X =?> Y
+
+which is in turn shorthand for
+
+ test html "my test" (X,Y)
+-}
+
+infix 4 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test html
+
+tests :: [Test]
+tests = [ testGroup "inline code"
+ [ "basic" =: code "@&" =?> "<code>@&amp;</code>"
+ , "haskell" =: codeWith ("",["haskell"],[]) ">>="
+ =?> "<code class=\"sourceCode haskell\"><span class=\"fu\">&gt;&gt;=</span></code>"
+ , "nolanguage" =: codeWith ("",["nolanguage"],[]) ">>="
+ =?> "<code class=\"nolanguage\">&gt;&gt;=</code>"
+ ]
+ , testGroup "images"
+ [ "alt with formatting" =:
+ image "/url" "title" ("my " <> emph "image")
+ =?> "<img src=\"/url\" title=\"title\" alt=\"my image\" />"
+ ]
+ ]
diff --git a/test/Tests/Writers/LaTeX.hs b/test/Tests/Writers/LaTeX.hs
new file mode 100644
index 000000000..f54aef4dc
--- /dev/null
+++ b/test/Tests/Writers/LaTeX.hs
@@ -0,0 +1,175 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Writers.LaTeX (tests) where
+
+import Test.Framework
+import Tests.Helpers
+import Text.Pandoc
+import Text.Pandoc.Arbitrary ()
+import Text.Pandoc.Builder
+
+latex :: (ToPandoc a) => a -> String
+latex = latexWithOpts def
+
+latexListing :: (ToPandoc a) => a -> String
+latexListing = latexWithOpts def{ writerListings = True }
+
+latexWithOpts :: (ToPandoc a) => WriterOptions -> a -> String
+latexWithOpts opts = purely (writeLaTeX opts) . toPandoc
+
+beamerWithOpts :: (ToPandoc a) => WriterOptions -> a -> String
+beamerWithOpts opts = purely (writeBeamer opts) . toPandoc
+
+{-
+ "my test" =: X =?> Y
+
+is shorthand for
+
+ test latex "my test" $ X =?> Y
+
+which is in turn shorthand for
+
+ test latex "my test" (X,Y)
+-}
+
+infix 4 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test latex
+
+tests :: [Test]
+tests = [ testGroup "code blocks"
+ [ "in footnotes" =: note (para "hi" <> codeBlock "hi") =?>
+ "\\footnote{hi\n\n\\begin{Verbatim}\nhi\n\\end{Verbatim}\n}"
+ , test latexListing "identifier" $ codeBlockWith ("id",[],[]) "hi" =?>
+ ("\\begin{lstlisting}[label=id]\nhi\n\\end{lstlisting}" :: String)
+ , test latexListing "no identifier" $ codeBlock "hi" =?>
+ ("\\begin{lstlisting}\nhi\n\\end{lstlisting}" :: String)
+ ]
+ , testGroup "definition lists"
+ [ "with internal link" =: definitionList [(link "#go" "" (str "testing"),
+ [plain (text "hi there")])] =?>
+ "\\begin{description}\n\\tightlist\n\\item[{\\protect\\hyperlink{go}{testing}}]\nhi there\n\\end{description}"
+ ]
+ , testGroup "math"
+ [ "escape |" =: para (math "\\sigma|_{\\{x\\}}") =?>
+ "\\(\\sigma|_{\\{x\\}}\\)"
+ ]
+ , testGroup "headers"
+ [ "unnumbered header" =:
+ headerWith ("foo",["unnumbered"],[]) 1
+ (text "Header 1" <> note (plain $ text "note")) =?>
+ "\\section*{\\texorpdfstring{Header 1\\footnote{note}}{Header 1}}\\label{foo}\n\\addcontentsline{toc}{section}{Header 1}\n"
+ , "in list item" =:
+ bulletList [header 2 (text "foo")] =?>
+ "\\begin{itemize}\n\\item ~\n \\subsection{foo}\n\\end{itemize}"
+ , "in definition list item" =:
+ definitionList [(text "foo", [header 2 (text "bar"),
+ para $ text "baz"])] =?>
+ "\\begin{description}\n\\item[foo] ~ \n\\subsection{bar}\n\nbaz\n\\end{description}"
+ , "containing image" =:
+ header 1 (image "imgs/foo.jpg" "" (text "Alt text")) =?>
+ "\\section{\\texorpdfstring{\\protect\\includegraphics{imgs/foo.jpg}}{Alt text}}"
+ ]
+ , testGroup "inline code"
+ [ "struck out and highlighted" =:
+ strikeout (codeWith ("",["haskell"],[]) "foo" <> space
+ <> str "bar") =?>
+ "\\sout{\\mbox{\\VERB|\\NormalTok{foo}|} bar}"
+ , "struck out and not highlighted" =:
+ strikeout (code "foo" <> space
+ <> str "bar") =?>
+ "\\sout{\\texttt{foo} bar}"
+ , "single quotes" =:
+ code "dog's" =?> "\\texttt{dog\\textquotesingle{}s}"
+ , "backtick" =:
+ code "`nu?`" =?> "\\texttt{\\textasciigrave{}nu?\\textasciigrave{}}"
+ ]
+ , testGroup "writer options"
+ [ testGroup "top-level division" $
+ let
+ headers = header 1 (text "header1")
+ <> header 2 (text "header2")
+ <> header 3 (text "header3")
+
+ latexTopLevelDiv :: (ToPandoc a) => TopLevelDivision -> a -> String
+ latexTopLevelDiv division =
+ latexWithOpts def{ writerTopLevelDivision = division }
+
+ beamerTopLevelDiv :: (ToPandoc a)
+ => TopLevelDivision -> a -> String
+ beamerTopLevelDiv division =
+ beamerWithOpts def { writerTopLevelDivision = division }
+ in
+ [ test (latexTopLevelDiv TopLevelSection)
+ "sections as top-level" $ headers =?>
+ unlines [ "\\section{header1}\n"
+ , "\\subsection{header2}\n"
+ , "\\subsubsection{header3}"
+ ]
+ , test (latexTopLevelDiv TopLevelChapter)
+ "chapters as top-level" $ headers =?>
+ unlines [ "\\chapter{header1}\n"
+ , "\\section{header2}\n"
+ , "\\subsection{header3}"
+ ]
+ , test (latexTopLevelDiv TopLevelPart)
+ "parts as top-level" $ headers =?>
+ unlines [ "\\part{header1}\n"
+ , "\\chapter{header2}\n"
+ , "\\section{header3}"
+ ]
+ , test (latexTopLevelDiv TopLevelDefault)
+ "default top-level" $ headers =?>
+ unlines [ "\\section{header1}\n"
+ , "\\subsection{header2}\n"
+ , "\\subsubsection{header3}"
+ ]
+ , test (beamerTopLevelDiv TopLevelSection)
+ "sections as top-level in beamer" $ headers =?>
+ unlines [ "\\section{header1}\n"
+ , "\\subsection{header2}\n"
+ , "\\subsubsection{header3}"
+ ]
+ , test (beamerTopLevelDiv TopLevelChapter)
+ "chapters are as part in beamer" $ headers =?>
+ unlines [ "\\part{header1}\n"
+ , "\\section{header2}\n"
+ , "\\subsection{header3}"
+ ]
+ , test (beamerTopLevelDiv TopLevelPart)
+ "parts as top-level in beamer" $ headers =?>
+ unlines [ "\\part{header1}\n"
+ , "\\section{header2}\n"
+ , "\\subsection{header3}"
+ ]
+ , test (beamerTopLevelDiv TopLevelDefault)
+ "default top-level in beamer" $ headers =?>
+ unlines [ "\\section{header1}\n"
+ , "\\subsection{header2}\n"
+ , "\\subsubsection{header3}"
+ ]
+ , test (latexTopLevelDiv TopLevelPart)
+ "part top-level, section not in toc" $
+ ( headerWith ("", ["unnumbered"], []) 1 (text "header1")
+ <> headerWith ("", ["unnumbered"], []) 2 (text "header2")
+ <> headerWith ("", ["unnumbered"], []) 3 (text "header3")
+ <> headerWith ("", ["unnumbered"], []) 4 (text "header4")
+ <> headerWith ("", ["unnumbered"], []) 5 (text "header5")
+ <> headerWith ("", ["unnumbered"], []) 6 (text "header6"))
+ =?>
+ unlines [ "\\part*{header1}"
+ , "\\addcontentsline{toc}{part}{header1}\n"
+ , "\\chapter*{header2}"
+ , "\\addcontentsline{toc}{chapter}{header2}\n"
+ , "\\section*{header3}"
+ , "\\addcontentsline{toc}{section}{header3}\n"
+ , "\\subsection*{header4}"
+ , "\\addcontentsline{toc}{subsection}{header4}\n"
+ , "\\subsubsection*{header5}"
+ , "\\addcontentsline{toc}{subsubsection}{header5}\n"
+ , "\\paragraph{header6}"
+ , "\\addcontentsline{toc}{paragraph}{header6}"
+ ]
+ ]
+ ]
+ ]
diff --git a/test/Tests/Writers/Markdown.hs b/test/Tests/Writers/Markdown.hs
new file mode 100644
index 000000000..abefe27d5
--- /dev/null
+++ b/test/Tests/Writers/Markdown.hs
@@ -0,0 +1,266 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
+module Tests.Writers.Markdown (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+
+defopts :: WriterOptions
+defopts = def{ writerExtensions = pandocExtensions }
+
+markdown :: (ToPandoc a) => a -> String
+markdown = purely (writeMarkdown defopts) . toPandoc
+
+markdownWithOpts :: (ToPandoc a) => WriterOptions -> a -> String
+markdownWithOpts opts x = purely (writeMarkdown opts) $ toPandoc x
+
+{-
+ "my test" =: X =?> Y
+
+is shorthand for
+
+ test markdown "my test" $ X =?> Y
+
+which is in turn shorthand for
+
+ test markdown "my test" (X,Y)
+-}
+
+infix 4 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test markdown
+
+tests :: [Test]
+tests = [ "indented code after list"
+ =: (orderedList [ para "one" <> para "two" ] <> codeBlock "test")
+ =?> "1. one\n\n two\n\n<!-- -->\n\n test"
+ , "list with tight sublist"
+ =: bulletList [ plain "foo" <> bulletList [ plain "bar" ],
+ plain "baz" ]
+ =?> "- foo\n - bar\n- baz\n"
+ ] ++ [noteTests] ++ [shortcutLinkRefsTests]
+
+{-
+
+Testing with the following text:
+
+First Header
+============
+
+This is a footnote.[^1] And this is a [link](https://www.google.com).
+
+> A note inside a block quote.[^2]
+>
+> A second paragraph.
+
+Second Header
+=============
+
+Some more text.
+
+
+[^1]: Down here.
+
+[^2]: The second note.
+
+-}
+
+noteTestDoc :: Blocks
+noteTestDoc =
+ header 1 "First Header" <>
+ para ("This is a footnote." <>
+ note (para "Down here.") <>
+ " And this is a " <>
+ link "https://www.google.com" "" "link" <>
+ ".") <>
+ blockQuote (para ("A note inside a block quote." <>
+ note (para "The second note.")) <>
+ para ("A second paragraph.")) <>
+ header 1 "Second Header" <>
+ para "Some more text."
+
+
+
+noteTests :: Test
+noteTests = testGroup "note and reference location"
+ [ test (markdownWithOpts defopts)
+ "footnotes at the end of a document" $
+ noteTestDoc =?>
+ (unlines $ [ "First Header"
+ , "============"
+ , ""
+ , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
+ , ""
+ , "> A note inside a block quote.[^2]"
+ , ">"
+ , "> A second paragraph."
+ , ""
+ , "Second Header"
+ , "============="
+ , ""
+ , "Some more text."
+ , ""
+ , "[^1]: Down here."
+ , ""
+ , "[^2]: The second note."
+ ])
+ , test (markdownWithOpts defopts{writerReferenceLocation=EndOfBlock})
+ "footnotes at the end of blocks" $
+ noteTestDoc =?>
+ (unlines $ [ "First Header"
+ , "============"
+ , ""
+ , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
+ , ""
+ , "[^1]: Down here."
+ , ""
+ , "> A note inside a block quote.[^2]"
+ , ">"
+ , "> A second paragraph."
+ , ""
+ , "[^2]: The second note."
+ , ""
+ , "Second Header"
+ , "============="
+ , ""
+ , "Some more text."
+ ])
+ , test (markdownWithOpts defopts{writerReferenceLocation=EndOfBlock, writerReferenceLinks=True})
+ "footnotes and reference links at the end of blocks" $
+ noteTestDoc =?>
+ (unlines $ [ "First Header"
+ , "============"
+ , ""
+ , "This is a footnote.[^1] And this is a [link]."
+ , ""
+ , "[^1]: Down here."
+ , ""
+ , " [link]: https://www.google.com"
+ , ""
+ , "> A note inside a block quote.[^2]"
+ , ">"
+ , "> A second paragraph."
+ , ""
+ , "[^2]: The second note."
+ , ""
+ , "Second Header"
+ , "============="
+ , ""
+ , "Some more text."
+ ])
+ , test (markdownWithOpts defopts{writerReferenceLocation=EndOfSection})
+ "footnotes at the end of section" $
+ noteTestDoc =?>
+ (unlines $ [ "First Header"
+ , "============"
+ , ""
+ , "This is a footnote.[^1] And this is a [link](https://www.google.com)."
+ , ""
+ , "> A note inside a block quote.[^2]"
+ , ">"
+ , "> A second paragraph."
+ , ""
+ , "[^1]: Down here."
+ , ""
+ , "[^2]: The second note."
+ , ""
+ , "Second Header"
+ , "============="
+ , ""
+ , "Some more text."
+ ])
+
+ ]
+
+shortcutLinkRefsTests :: Test
+shortcutLinkRefsTests =
+ let infix 4 =:
+ (=:) :: (ToString a, ToPandoc a)
+
+ => String -> (a, String) -> Test
+ (=:) = test (purely (writeMarkdown defopts{writerReferenceLinks = True}) . toPandoc)
+ in testGroup "Shortcut reference links"
+ [ "Simple link (shortcutable)"
+ =: (para (link "/url" "title" "foo"))
+ =?> "[foo]\n\n [foo]: /url \"title\""
+ , "Followed by another link (unshortcutable)"
+ =: (para ((link "/url1" "title1" "first")
+ <> (link "/url2" "title2" "second")))
+ =?> unlines [ "[first][][second]"
+ , ""
+ , " [first]: /url1 \"title1\""
+ , " [second]: /url2 \"title2\""
+ ]
+ , "Followed by space and another link (unshortcutable)"
+ =: (para ((link "/url1" "title1" "first") <> " "
+ <> (link "/url2" "title2" "second")))
+ =?> unlines [ "[first][] [second]"
+ , ""
+ , " [first]: /url1 \"title1\""
+ , " [second]: /url2 \"title2\""
+ ]
+ , "Reference link is used multiple times (unshortcutable)"
+ =: (para ((link "/url1" "" "foo") <> (link "/url2" "" "foo")
+ <> (link "/url3" "" "foo")))
+ =?> unlines [ "[foo][][foo][1][foo][2]"
+ , ""
+ , " [foo]: /url1"
+ , " [1]: /url2"
+ , " [2]: /url3"
+ ]
+ , "Reference link is used multiple times (unshortcutable)"
+ =: (para ((link "/url1" "" "foo") <> " " <> (link "/url2" "" "foo")
+ <> " " <> (link "/url3" "" "foo")))
+ =?> unlines [ "[foo][] [foo][1] [foo][2]"
+ , ""
+ , " [foo]: /url1"
+ , " [1]: /url2"
+ , " [2]: /url3"
+ ]
+ , "Reference link is followed by text in brackets"
+ =: (para ((link "/url" "" "link") <> "[text in brackets]"))
+ =?> unlines [ "[link][]\\[text in brackets\\]"
+ , ""
+ , " [link]: /url"
+ ]
+ , "Reference link is followed by space and text in brackets"
+ =: (para ((link "/url" "" "link") <> " [text in brackets]"))
+ =?> unlines [ "[link][] \\[text in brackets\\]"
+ , ""
+ , " [link]: /url"
+ ]
+ , "Reference link is followed by RawInline"
+ =: (para ((link "/url" "" "link") <> rawInline "markdown" "[rawText]"))
+ =?> unlines [ "[link][][rawText]"
+ , ""
+ , " [link]: /url"
+ ]
+ , "Reference link is followed by space and RawInline"
+ =: (para ((link "/url" "" "link") <> space <> rawInline "markdown" "[rawText]"))
+ =?> unlines [ "[link][] [rawText]"
+ , ""
+ , " [link]: /url"
+ ]
+ , "Reference link is followed by RawInline with space"
+ =: (para ((link "/url" "" "link") <> rawInline "markdown" " [rawText]"))
+ =?> unlines [ "[link][] [rawText]"
+ , ""
+ , " [link]: /url"
+ ]
+ , "Reference link is followed by citation"
+ =: (para ((link "/url" "" "link") <> cite [Citation "author" [] [] NormalCitation 0 0] (str "[@author]")))
+ =?> unlines [ "[link][][@author]"
+ , ""
+ , " [link]: /url"
+ ]
+ , "Reference link is followed by space and citation"
+ =: (para ((link "/url" "" "link") <> space <> cite [Citation "author" [] [] NormalCitation 0 0] (str "[@author]")))
+ =?> unlines [ "[link][] [@author]"
+ , ""
+ , " [link]: /url"
+ ]
+ ]
diff --git a/test/Tests/Writers/Native.hs b/test/Tests/Writers/Native.hs
new file mode 100644
index 000000000..88bad7944
--- /dev/null
+++ b/test/Tests/Writers/Native.hs
@@ -0,0 +1,21 @@
+module Tests.Writers.Native (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+
+p_write_rt :: Pandoc -> Bool
+p_write_rt d =
+ read (purely (writeNative def{ writerTemplate = Just "" }) d) == d
+
+p_write_blocks_rt :: [Block] -> Bool
+p_write_blocks_rt bs = length bs > 20 ||
+ read (purely (writeNative def) (Pandoc nullMeta bs)) ==
+ bs
+
+tests :: [Test]
+tests = [ property "p_write_rt" p_write_rt
+ , property "p_write_blocks_rt" p_write_blocks_rt
+ ]
diff --git a/test/Tests/Writers/Org.hs b/test/Tests/Writers/Org.hs
new file mode 100644
index 000000000..e2c58327b
--- /dev/null
+++ b/test/Tests/Writers/Org.hs
@@ -0,0 +1,25 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Writers.Org (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+
+infix 4 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test (purely (writeOrg def . toPandoc))
+
+tests :: [Test]
+tests = [ testGroup "links"
+ -- See http://orgmode.org/manual/Internal-links.html#Internal-links
+ [ "simple link"
+ =: link "/url" "" "foo"
+ =?> "[[/url][foo]]"
+ , "internal link to anchor"
+ =: link "#my-custom-id" "" "#my-custom-id"
+ =?> "[[#my-custom-id]]"
+ ]
+ ]
diff --git a/test/Tests/Writers/Plain.hs b/test/Tests/Writers/Plain.hs
new file mode 100644
index 000000000..bead6857c
--- /dev/null
+++ b/test/Tests/Writers/Plain.hs
@@ -0,0 +1,21 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Writers.Plain (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+
+
+infix 4 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test (purely (writePlain def) . toPandoc)
+
+
+tests :: [Test]
+tests = [ "strongly emphasized text to uppercase"
+ =: strong "Straße"
+ =?> "STRASSE"
+ ]
diff --git a/test/Tests/Writers/RST.hs b/test/Tests/Writers/RST.hs
new file mode 100644
index 000000000..dd55580c9
--- /dev/null
+++ b/test/Tests/Writers/RST.hs
@@ -0,0 +1,107 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Writers.RST (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+
+infix 4 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test (purely (writeRST def . toPandoc))
+
+tests :: [Test]
+tests = [ testGroup "rubrics"
+ [ "in list item" =:
+ bulletList [header 2 (text "foo")] =?>
+ "- .. rubric:: foo"
+ , "in definition list item" =:
+ definitionList [(text "foo", [header 2 (text "bar"),
+ para $ text "baz"])] =?>
+ unlines
+ [ "foo"
+ , " .. rubric:: bar"
+ , ""
+ , " baz"]
+ , "in block quote" =:
+ blockQuote (header 1 (text "bar")) =?>
+ " .. rubric:: bar"
+ , "with id" =:
+ blockQuote (headerWith ("foo",[],[]) 1 (text "bar")) =?>
+ unlines
+ [ " .. rubric:: bar"
+ , " :name: foo"]
+ , "with id class" =:
+ blockQuote (headerWith ("foo",["baz"],[]) 1 (text "bar")) =?>
+ unlines
+ [ " .. rubric:: bar"
+ , " :name: foo"
+ , " :class: baz"]
+ ]
+ , testGroup "headings"
+ [ "normal heading" =:
+ header 1 (text "foo") =?>
+ unlines
+ [ "foo"
+ , "==="]
+ -- note: heading normalization is only done in standalone mode
+ , test (purely (writeRST def{ writerTemplate = Just "$body$\n" }) . toPandoc)
+ "heading levels" $
+ header 1 (text "Header 1") <>
+ header 3 (text "Header 2") <>
+ header 2 (text "Header 2") <>
+ header 1 (text "Header 1") <>
+ header 4 (text "Header 2") <>
+ header 5 (text "Header 3") <>
+ header 3 (text "Header 2") =?>
+ unlines
+ [ "Header 1"
+ , "========"
+ , ""
+ , "Header 2"
+ , "--------"
+ , ""
+ , "Header 2"
+ , "--------"
+ , ""
+ , "Header 1"
+ , "========"
+ , ""
+ , "Header 2"
+ , "--------"
+ , ""
+ , "Header 3"
+ , "~~~~~~~~"
+ , ""
+ , "Header 2"
+ , "--------"]
+ , test (purely (writeRST def{ writerTemplate = Just "$body$\n" }) . toPandoc)
+ "minimal heading levels" $
+ header 2 (text "Header 1") <>
+ header 3 (text "Header 2") <>
+ header 2 (text "Header 1") <>
+ header 4 (text "Header 2") <>
+ header 5 (text "Header 3") <>
+ header 3 (text "Header 2") =?>
+ unlines
+ [ "Header 1"
+ , "========"
+ , ""
+ , "Header 2"
+ , "--------"
+ , ""
+ , "Header 1"
+ , "========"
+ , ""
+ , "Header 2"
+ , "--------"
+ , ""
+ , "Header 3"
+ , "~~~~~~~~"
+ , ""
+ , "Header 2"
+ , "--------"]
+ ]
+ ]
diff --git a/test/Tests/Writers/TEI.hs b/test/Tests/Writers/TEI.hs
new file mode 100644
index 000000000..703f565bb
--- /dev/null
+++ b/test/Tests/Writers/TEI.hs
@@ -0,0 +1,43 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Writers.TEI (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Text.Pandoc.Arbitrary()
+
+{-
+ "my test" =: X =?> Y
+
+is shorthand for
+
+ test html "my test" $ X =?> Y
+
+which is in turn shorthand for
+
+ test html "my test" (X,Y)
+-}
+
+infix 4 =:
+(=:) :: (ToString a, ToPandoc a)
+ => String -> (a, String) -> Test
+(=:) = test (purely (writeTEI def) . toPandoc)
+
+tests :: [Test]
+tests = [ testGroup "block elements"
+ ["para" =: para "Lorem ipsum cetera."
+ =?> "<p>Lorem ipsum cetera.</p>"
+ ]
+ , testGroup "inlines"
+ [
+ "Emphasis" =: emph ("emphasized")
+ =?> "<p><hi rendition=\"simple:italic\">emphasized</hi></p>"
+ ,"SingleQuoted" =: singleQuoted (text "quoted material")
+ =?> "<p><quote>quoted material</quote></p>"
+ ,"DoubleQuoted" =: doubleQuoted (text "quoted material")
+ =?> "<p><quote>quoted material</quote></p>"
+ ,"NestedQuoted" =: doubleQuoted (singleQuoted (text "quoted material"))
+ =?> "<p><quote><quote>quoted material</quote></quote></p>"
+ ]
+ ]
diff --git a/test/bodybg.gif b/test/bodybg.gif
new file mode 100644
index 000000000..5f448a16f
--- /dev/null
+++ b/test/bodybg.gif
Binary files differ
diff --git a/test/command/3422.md b/test/command/3422.md
new file mode 100644
index 000000000..a010320e9
--- /dev/null
+++ b/test/command/3422.md
@@ -0,0 +1,9 @@
+See #3422
+
+```
+% pandoc -t latex --listings
+`int main(int argc, const char *argv[]);`{.c}
+^D
+\lstinline[language=C]!int main(int argc, const char *argv[]);!
+```
+
diff --git a/test/command/3432a.md b/test/command/3432a.md
new file mode 100644
index 000000000..5f25bce60
--- /dev/null
+++ b/test/command/3432a.md
@@ -0,0 +1,19 @@
+```
+% pandoc -f rst
+* - a
+ - b
+* - c
+ - d
+^D
+<ul>
+<li><ul>
+<li>a</li>
+<li>b</li>
+</ul></li>
+<li><ul>
+<li>c</li>
+<li>d</li>
+</ul></li>
+</ul>
+```
+
diff --git a/test/command/512.md b/test/command/512.md
new file mode 100644
index 000000000..a13c434f6
--- /dev/null
+++ b/test/command/512.md
@@ -0,0 +1,41 @@
+```
+% pandoc -f rst
+`click here`__ or `click here`__
+
+.. _link1: http://www.example.com/
+.. _link2: http://johnmacfarlane.net/pandoc/
+
+__ link1_
+__ link2_
+^D
+<p><a href="http://www.example.com/">click here</a> or <a href="http://johnmacfarlane.net/pandoc/">click here</a></p>
+```
+
+Multiple indirection:
+
+```
+% pandoc -f rst
+`click here`__
+
+.. _link1: link2_
+.. _link2: http://johnmacfarlane.net/pandoc/
+
+__ link1_
+^D
+<p><a href="http://johnmacfarlane.net/pandoc/">click here</a></p>
+```
+
+Loop detection:
+
+```
+% pandoc -f rst
+`click here`__
+
+.. _link1: link2_
+.. _link2: link1_
+
+__ link1_
+^D
+<p><a href="">click here</a></p>
+```
+
diff --git a/test/command/latex-tabular-column-specs.md b/test/command/latex-tabular-column-specs.md
new file mode 100644
index 000000000..ed44a9980
--- /dev/null
+++ b/test/command/latex-tabular-column-specs.md
@@ -0,0 +1,24 @@
+See https://groups.google.com/forum/#!topic/pandoc-discuss/_VXtqihCyDU.
+
+```
+% pandoc -f latex -t native
+\begin{tabular}{>{$}l<{$}>{$}l<{$} >{$}l<{$}}
+\toprule
+& f1 & f2 \\
+\midrule
+e & 0.5 & 4 \\
+f & 0.5 & 5,5 \\
+\bottomrule
+\end{tabular}
+^D
+[Table [] [AlignLeft,AlignLeft,AlignLeft] [0.0,0.0,0.0]
+ [[Plain [Math InlineMath ""]]
+ ,[Plain [Math InlineMath "f1"]]
+ ,[Plain [Math InlineMath "f2"]]]
+ [[[Plain [Math InlineMath "e"]]
+ ,[Plain [Math InlineMath "0.5"]]
+ ,[Plain [Math InlineMath "4"]]]
+ ,[[Plain [Math InlineMath "f"]]
+ ,[Plain [Math InlineMath "0.5"]]
+ ,[Plain [Math InlineMath "5,5"]]]]]
+```
diff --git a/test/command/parse-raw.md b/test/command/parse-raw.md
new file mode 100644
index 000000000..f4e493c69
--- /dev/null
+++ b/test/command/parse-raw.md
@@ -0,0 +1,27 @@
+```
+% pandoc -f latex+raw_tex -t markdown
+\emph{Hi \foo{there}}
+^D
+*Hi \foo{there}*
+```
+
+```
+% pandoc -f latex -t markdown
+\emph{Hi \foo{there}}
+^D
+*Hi*
+```
+
+```
+% pandoc -f html+raw_html -t markdown
+<em>Hi <blink>there</blink></em>
+^D
+*Hi <blink>there</blink>*
+```
+
+```
+% pandoc -f html -t markdown
+<em>Hi <blink>there</blink></em>
+^D
+*Hi there*
+```
diff --git a/test/command/smart.md b/test/command/smart.md
new file mode 100644
index 000000000..e64d67de2
--- /dev/null
+++ b/test/command/smart.md
@@ -0,0 +1,45 @@
+```
+% pandoc -f markdown+smart -t markdown-smart
+"hi"...dog's breath---cat 5--6
+^D
+“hi”…dog’s breath—cat 5–6
+```
+
+```
+% pandoc -f markdown+smart -t markdown+smart
+"hi"...dog's breath---cat 5--6
+^D
+"hi"...dog's breath---cat 5--6
+```
+
+When we render literal quotes without smart, we need to escape:
+
+```
+% pandoc -f markdown-smart \
+ -t markdown+smart
+"hi"...dog's breath---cat 5--6
+^D
+\"hi\"\...dog\'s breath\-\--cat 5\--6
+```
+
+```
+% pandoc -f markdown+smart -t rst-smart
+"hi"...dog's breath---cat 5--6
+^D
+“hi”…dog’s breath—cat 5–6
+```
+
+```
+% pandoc -f markdown+smart -t rst+smart
+"hi"...dog's breath---cat 5--6
+^D
+"hi"...dog's breath---cat 5--6
+```
+
+```
+% pandoc -f markdown-smart -t rst+smart
+"hi"...dog's breath---cat 5--6
+^D
+\"hi\"\...dog\'s breath\-\--cat 5\--6
+```
+
diff --git a/test/docbook-reader.docbook b/test/docbook-reader.docbook
new file mode 100644
index 000000000..3a4fc77c6
--- /dev/null
+++ b/test/docbook-reader.docbook
@@ -0,0 +1,1561 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+ "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
+<article>
+ <articleinfo>
+ <title>Pandoc Test Suite</title>
+ <authorgroup>
+ <author>
+ <firstname>John</firstname>
+ <surname>MacFarlane</surname>
+ </author>
+ <author>
+ <firstname></firstname>
+ <surname>Anonymous</surname>
+ </author>
+ </authorgroup>
+ <date>July 17, 2006</date>
+ </articleinfo>
+<para>
+ This is a set of tests for pandoc. Most of them are adapted from John
+ Gruber’s markdown test suite.
+</para>
+<sect1 id="headers">
+ <title>Headers</title>
+ <sect2 id="level-2-with-an-embedded-link">
+ <title>Level 2 with an <ulink url="/url">embedded link</ulink></title>
+ <sect3 id="level-3-with-emphasis">
+ <title>Level 3 with <emphasis>emphasis</emphasis></title>
+ <sect4 id="level-4">
+ <title>Level 4</title>
+ <sect5 id="level-5">
+ <title>Level 5</title>
+ <para>
+ Hi.
+ </para>
+ </sect5>
+ </sect4>
+ </sect3>
+ </sect2>
+</sect1>
+<sect1 id="level-1">
+ <title>Level 1</title>
+ <sect2 id="level-2-with-emphasis">
+ <title>Level 2 with <emphasis>emphasis</emphasis></title>
+ <sect3 id="level-3">
+ <title>Level 3</title>
+ <para>
+ with no blank line
+ </para>
+ </sect3>
+ </sect2>
+ <sect2 id="level-2">
+ <title>Level 2</title>
+ <para>
+ with no blank line
+ </para>
+ </sect2>
+</sect1>
+<sect1 id="paragraphs">
+ <title>Paragraphs</title>
+ <para>
+ Here’s a regular paragraph.
+ </para>
+ <para>
+ In Markdown 1.0.0 and earlier. Version 8. This line turns into a list
+ item. Because a hard-wrapped line in the middle of a paragraph looked like
+ a list item.
+ </para>
+ <para>
+ Here’s one with a bullet. * criminey.
+ </para>
+</sect1>
+<sect1 id="block-quotes">
+ <title>Block Quotes</title>
+ <para>
+ E-mail style:
+ </para>
+ <blockquote>
+ <para>
+ This is a block quote. It is pretty short.
+ </para>
+ </blockquote>
+ <blockquote>
+ <para>
+ Code in a block quote:
+ </para>
+ <programlisting>
+sub status {
+ print &quot;working&quot;;
+}
+</programlisting>
+ <screen>
+% <command>ls</command>
+</screen>
+ <para>
+ A list:
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ item one
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ item two
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ Nested block quotes:
+ </para>
+ <blockquote>
+ <para>
+ nested
+ </para>
+ </blockquote>
+ <blockquote>
+ <para>
+ nested
+ </para>
+ </blockquote>
+ </blockquote>
+ <para>
+ This should not be a block quote: 2 &gt; 1.
+ </para>
+ <para>
+ And a following paragraph.
+ </para>
+</sect1>
+<sect1 id="code-blocks">
+ <title>Code Blocks</title>
+ <para>
+ Code:
+ </para>
+ <programlisting>
+---- (should be four hyphens)
+
+sub status {
+ print &quot;working&quot;;
+}
+
+this code block is indented by one tab
+</programlisting>
+ <para>
+ And:
+ </para>
+ <programlisting>
+ this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \&gt; \[ \{
+</programlisting>
+</sect1>
+<sect1 id="lists">
+ <title>Lists</title>
+ <sect2 id="unordered">
+ <title>Unordered</title>
+ <para>
+ Asterisks loose:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ asterisk 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ asterisk 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ asterisk 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Pluses loose:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Plus 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Plus 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Plus 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Minuses loose:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Minus 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Minus 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Minus 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ </sect2>
+ <sect2 id="ordered">
+ <title>Ordered</title>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ First
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Second
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Third
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ and using spaces:
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ One
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Two
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Three
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ Multiple paragraphs:
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ Item 1, graf one.
+ </para>
+ <para>
+ Item 1. graf two. The quick brown fox jumped over the lazy dog’s
+ back.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Item 2.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Item 3.
+ </para>
+ </listitem>
+ </orderedlist>
+ </sect2>
+ <sect2 id="nested">
+ <title>Nested</title>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Tab
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Tab
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Tab
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Here’s another:
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ First
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Second:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Fee
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Fie
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Foe
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem>
+ <para>
+ Third
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ Same thing but with paragraphs:
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ First
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Second:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Fee
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Fie
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Foe
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem>
+ <para>
+ Third
+ </para>
+ </listitem>
+ </orderedlist>
+ </sect2>
+ <sect2 id="tabs-and-spaces">
+ <title>Tabs and spaces</title>
+ <itemizedlist>
+ <listitem>
+ <para>
+ this is a list item indented with tabs
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ this is a list item indented with spaces
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ this is an example list item indented with tabs
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ this is an example list item indented with spaces
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </sect2>
+ <sect2 id="fancy-list-markers">
+ <title>Fancy list markers</title>
+ <orderedlist numeration="arabic">
+ <listitem override="2">
+ <para>
+ begins with 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ and now 3
+ </para>
+ <para>
+ with a continuation
+ </para>
+ <orderedlist numeration="lowerroman">
+ <listitem override="4">
+ <para>
+ sublist with roman numerals, starting with 4
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ more items
+ </para>
+ <orderedlist numeration="upperalpha">
+ <listitem>
+ <para>
+ a subsublist
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ a subsublist
+ </para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ <para>
+ Nesting:
+ </para>
+ <orderedlist numeration="upperalpha">
+ <listitem>
+ <para>
+ Upper Alpha
+ </para>
+ <orderedlist numeration="upperroman">
+ <listitem>
+ <para>
+ Upper Roman.
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem override="6">
+ <para>
+ Decimal start with 6
+ </para>
+ <orderedlist numeration="loweralpha">
+ <listitem override="3">
+ <para>
+ Lower alpha with paren
+ </para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ <para>
+ Autonumbering:
+ </para>
+ <orderedlist>
+ <listitem>
+ <para>
+ Autonumber.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ More.
+ </para>
+ <orderedlist>
+ <listitem>
+ <para>
+ Nested.
+ </para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ <para>
+ Should not be a list item:
+ </para>
+ <para>
+ M.A. 2007
+ </para>
+ <para>
+ B. Williams
+ </para>
+ </sect2>
+ <sect2 id="callout">
+ <title>Callout</title>
+ <para>Simple.</para>
+ <calloutlist>
+ <callout arearefs="loop1-letrec-co" id="loop1-letrec">
+ <para id="x_QA1">A <code>__letrec</code> is equivalent to a normal
+ Haskell &let;.</para>
+ </callout>
+ <callout arearefs="loop1-def-co" id="loop1-def">
+ <para id="x_RA1">&GHC; compiled the body of our list comprehension into
+ a loop named <function>go_s1YC</function>.</para>
+ </callout>
+ <callout arearefs="loop1-pat-empty-co" id="loop1-pat-empty">
+ <para id="x_SA1">If our &case; expression matches the empty list, we
+ return the empty list. This is reassuringly
+ familiar.</para>
+ </callout>
+ </calloutlist>
+ </sect2>
+</sect1>
+<sect1 id="definition-lists">
+ <title>Definition Lists</title>
+ <variablelist>
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ banana
+ </term>
+ <listitem>
+ <para>
+ yellow fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Multiple blocks with italics:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ <emphasis>apple</emphasis>
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ <para>
+ contains seeds, crisp, pleasant to taste
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <emphasis>orange</emphasis>
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ <programlisting>
+{ orange code block }
+</programlisting>
+ <blockquote>
+ <para>
+ orange block quote
+ </para>
+ </blockquote>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Multiple definitions, loose:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ computer
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ bank
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Blank line after term, indented marker, alternate markers:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ computer
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ sublist
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ sublist
+ </para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+</sect1>
+<sect1 id="inline-markup">
+ <title>Inline Markup</title>
+ <para>
+ This is <emphasis>emphasized</emphasis>, and so <emphasis>is
+ this</emphasis>.
+ </para>
+ <para>
+ This is <emphasis role="strong">strong</emphasis>, and so
+ <emphasis role="strong">is this</emphasis>.
+ </para>
+ <para>
+ An <emphasis><ulink url="/url">emphasized link</ulink></emphasis>.
+ </para>
+ <para>
+ <emphasis role="strong"><emphasis>This is strong and
+ em.</emphasis></emphasis>
+ </para>
+ <para>
+ So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.
+ </para>
+ <para>
+ <emphasis role="strong"><emphasis>This is strong and
+ em.</emphasis></emphasis>
+ </para>
+ <para>
+ So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.
+ </para>
+ <para>
+ This is code: <literal>&gt;</literal>, <literal>$</literal>,
+ <literal>\</literal>, <literal>\$</literal>,
+ <literal>&lt;html&gt;</literal>.
+ </para>
+ <para>
+ More code: <classname>Class</classname> and <type>Type</type>
+ </para>
+ <para>
+ <emphasis role="strikethrough">This is
+ <emphasis>strikeout</emphasis>.</emphasis>
+ </para>
+ <para>
+ Superscripts: a<superscript>bc</superscript>d
+ a<superscript><emphasis>hello</emphasis></superscript>
+ a<superscript>hello there</superscript>.
+ </para>
+ <para>
+ Subscripts: H<subscript>2</subscript>O, H<subscript>23</subscript>O,
+ H<subscript>many of them</subscript>O.
+ </para>
+ <para>
+ These should not be superscripts or subscripts, because of the unescaped
+ spaces: a^b c^d, a~b c~d.
+ </para>
+</sect1>
+<sect1 id="smart-quotes-ellipses-dashes">
+ <title>Smart quotes, ellipses, dashes</title>
+ <para>
+ <quote>Hello,</quote> said the spider. <quote><quote>Shelob</quote> is my
+ name.</quote>
+ </para>
+ <para>
+ <quote>A</quote>, <quote>B</quote>, and <quote>C</quote> are letters.
+ </para>
+ <para>
+ <quote>He said, <quote>I want to go.</quote></quote> Were you alive in the
+ 70’s?
+ </para>
+ <para>
+ Some dashes: one—two — three—four — five.
+ </para>
+ <para>
+ Dashes between numbers: 5–7, 255–66, 1987–1999.
+ </para>
+ <para>
+ Ellipses…and…and….
+ </para>
+</sect1>
+<sect1 id="math">
+ <para>
+ <equation>
+ <mml:math>
+ <mml:mrow>
+ <mml:mi>e</mml:mi>
+ <mml:mo>=</mml:mo>
+ <mml:mi>m</mml:mi>
+ <mml:msup>
+ <mml:mi>c</mml:mi>
+ <mml:mn>2</mml:mn>
+ </mml:msup>
+ </mml:mrow>
+ </mml:math>
+ <mml:math>
+ <mrow>
+ <mn>1</mn>
+ </mrow>
+ </mml:math>
+ </equation>
+ <inlineequation>
+ <mml:math>
+ <mml:mrow>
+ <mml:mi>e</mml:mi>
+ <mml:mo>=</mml:mo>
+ <mml:mi>m</mml:mi>
+ <mml:msup>
+ <mml:mi>c</mml:mi>
+ <mml:mn>2</mml:mn>
+ </mml:msup>
+ </mml:mrow>
+ </mml:math>
+ </inlineequation>
+ <informalequation>
+ <mml:math>
+ <mml:mrow>
+ <mml:mi>e</mml:mi>
+ <mml:mo>=</mml:mo>
+ <mml:mi>m</mml:mi>
+ <mml:msup>
+ <mml:mi>c</mml:mi>
+ <mml:mn>2</mml:mn>
+ </mml:msup>
+ </mml:mrow>
+ </mml:math>
+ </informalequation>
+ </para>
+</sect1>
+<sect1 id="special-characters">
+ <title>Special Characters</title>
+ <para>
+ Here is some unicode:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ I hat: Î
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ o umlaut: ö
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ section: §
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ set membership: ∈
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ copyright: ©
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ AT&amp;T has an ampersand in their name.
+ </para>
+ <para>
+ AT&amp;T is another way to write it.
+ </para>
+ <para>
+ This &amp; that.
+ </para>
+ <para>
+ 4 &lt; 5.
+ </para>
+ <para>
+ 6 &gt; 5.
+ </para>
+ <para>
+ Backslash: \
+ </para>
+ <para>
+ Backtick: `
+ </para>
+ <para>
+ Asterisk: *
+ </para>
+ <para>
+ Underscore: _
+ </para>
+ <para>
+ Left brace: {
+ </para>
+ <para>
+ Right brace: }
+ </para>
+ <para>
+ Left bracket: [
+ </para>
+ <para>
+ Right bracket: ]
+ </para>
+ <para>
+ Left paren: (
+ </para>
+ <para>
+ Right paren: )
+ </para>
+ <para>
+ Greater-than: &gt;
+ </para>
+ <para>
+ Hash: #
+ </para>
+ <para>
+ Period: .
+ </para>
+ <para>
+ Bang: !
+ </para>
+ <para>
+ Plus: +
+ </para>
+ <para>
+ Minus: -
+ </para>
+</sect1>
+<sect1 id="links">
+ <title>Links</title>
+ <sect2 id="explicit">
+ <title>Explicit</title>
+ <para>
+ Just a <ulink url="/url/">URL</ulink>.
+ </para>
+ <para>
+ <ulink url="/url/">URL and title</ulink>.
+ </para>
+ <para>
+ <ulink url="/url/">URL and title</ulink>.
+ </para>
+ <para>
+ <ulink url="/url/">URL and title</ulink>.
+ </para>
+ <para>
+ <ulink url="/url/">URL and title</ulink>
+ </para>
+ <para>
+ <ulink url="/url/">URL and title</ulink>
+ </para>
+ <para>
+ <ulink url="/url/with_underscore">with_underscore</ulink>
+ </para>
+ <para>
+ <email>nobody@nowhere.net</email>
+ </para>
+ <para>
+ <ulink url="">Empty</ulink>.
+ </para>
+ </sect2>
+ <sect2 id="reference">
+ <title>Reference</title>
+ <para>
+ Foo <ulink url="/url/">bar</ulink>.
+ </para>
+ <para>
+ Foo <ulink url="/url/">bar</ulink>.
+ </para>
+ <para>
+ Foo <ulink url="/url/">bar</ulink>.
+ </para>
+ <para>
+ With <ulink url="/url/">embedded [brackets]</ulink>.
+ </para>
+ <para>
+ <ulink url="/url/">b</ulink> by itself should be a link.
+ </para>
+ <para>
+ Indented <ulink url="/url">once</ulink>.
+ </para>
+ <para>
+ Indented <ulink url="/url">twice</ulink>.
+ </para>
+ <para>
+ Indented <ulink url="/url">thrice</ulink>.
+ </para>
+ <para>
+ This should [not][] be a link.
+ </para>
+ <programlisting>
+[not]: /url
+</programlisting>
+ <para>
+ Foo <ulink url="/url/">bar</ulink>.
+ </para>
+ <para>
+ Foo <ulink url="/url/">biz</ulink>.
+ </para>
+ </sect2>
+ <sect2 id="with-ampersands">
+ <title>With ampersands</title>
+ <para>
+ Here’s a <ulink url="http://example.com/?foo=1&amp;bar=2">link with an
+ ampersand in the URL</ulink>.
+ </para>
+ <para>
+ Here’s a link with an amersand in the link text:
+ <ulink url="http://att.com/">AT&amp;T</ulink>.
+ </para>
+ <para>
+ Here’s an <ulink url="/script?foo=1&amp;bar=2">inline link</ulink>.
+ </para>
+ <para>
+ Here’s an <ulink url="/script?foo=1&amp;bar=2">inline link in pointy
+ braces</ulink>.
+ </para>
+ </sect2>
+ <sect2 id="autolinks">
+ <title>Autolinks</title>
+ <para>
+ With an ampersand:
+ <ulink url="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</ulink>
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ In a list?
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <ulink url="http://example.com/">http://example.com/</ulink>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ It should.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ An e-mail address: <email>nobody@nowhere.net</email>
+ </para>
+ <blockquote>
+ <para>
+ Blockquoted:
+ <ulink url="http://example.com/">http://example.com/</ulink>
+ </para>
+ </blockquote>
+ <para>
+ Auto-links should not occur here:
+ <literal>&lt;http://example.com/&gt;</literal>
+ </para>
+ <programlisting>
+or here: &lt;http://example.com/&gt;
+</programlisting>
+ </sect2>
+</sect1>
+<sect1 id="images">
+ <title>Images</title>
+ <para>
+ From <quote>Voyage dans la Lune</quote> by Georges Melies (1902):
+ </para>
+ <figure>
+ <title>lalune fig caption</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="lalune.jpg" />
+ </imageobject>
+ <textobject><phrase>lalune alt text shadowed by fig caption</phrase></textobject>
+ </mediaobject>
+ </figure>
+ <para>
+ Here is a movie <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="movie.jpg" />
+ </imageobject>
+ </inlinemediaobject> icon.
+ And here a second movie <inlinemediaobject>
+ <alt>alt text</alt>
+ <imageobject>
+ <imagedata fileref="movie.jpg" />
+ </imageobject>
+ </inlinemediaobject> icon.
+ And here a third movie <inlinemediaobject>
+ <textobject><phrase>alt text</phrase></textobject>
+ <imageobject>
+ <imagedata fileref="movie.jpg" />
+ </imageobject>
+ </inlinemediaobject> icon.
+ </para>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="lalune.jpg" />
+ </imageobject>
+ <textobject><phrase>lalune no figure alt text</phrase></textobject>
+ </mediaobject>
+</sect1>
+<sect1 id="footnotes">
+ <title>Footnotes</title>
+ <para>
+ Here is a footnote reference,<footnote>
+ <para>
+ Here is the footnote. It can go anywhere after the footnote reference.
+ It need not be placed at the end of the document.
+ </para>
+ </footnote> and another.<footnote>
+ <para>
+ Here’s the long note. This one contains multiple blocks.
+ </para>
+ <para>
+ Subsequent blocks are indented to show that they belong to the
+ footnote (as with list items).
+ </para>
+ <programlisting>
+ { &lt;code&gt; }
+</programlisting>
+ <para>
+ If you want, you can indent every line, but you can also be lazy and
+ just indent the first line of each block.
+ </para>
+ </footnote> This should <emphasis>not</emphasis> be a footnote reference,
+ because it contains a space.[^my note] Here is an inline note.<footnote>
+ <para>
+ This is <emphasis>easier</emphasis> to type. Inline notes may contain
+ <ulink url="http://google.com">links</ulink> and <literal>]</literal>
+ verbatim characters, as well as [bracketed text].
+ </para>
+ </footnote>
+ </para>
+ <blockquote>
+ <para>
+ Notes can go in quotes.<footnote>
+ <para>
+ In quote.
+ </para>
+ </footnote>
+ </para>
+ </blockquote>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ And in list items.<footnote>
+ <para>
+ In list.
+ </para>
+ </footnote>
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ This paragraph should not be part of the note, as it is not indented.
+ </para>
+</sect1>
+<sect1 id="tables">
+ <title>Tables</title>
+ <para>
+ Simple table with caption:
+ </para>
+ <table>
+ <title>
+ Demonstration of simple table syntax.
+ </title>
+ <tgroup cols="4">
+ <colspec align="right" />
+ <colspec align="left" />
+ <colspec align="center" />
+ <colspec align="left" />
+ <thead>
+ <row>
+ <entry>
+ Right
+ </entry>
+ <entry>
+ Left
+ </entry>
+ <entry>
+ Center
+ </entry>
+ <entry>
+ Default
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>
+ Simple table without caption:
+ </para>
+ <informaltable>
+ <tgroup cols="4">
+ <colspec align="right" />
+ <colspec align="left" />
+ <colspec align="center" />
+ <colspec align="left" />
+ <thead>
+ <row>
+ <entry>
+ Right
+ </entry>
+ <entry>
+ Left
+ </entry>
+ <entry>
+ Center
+ </entry>
+ <entry>
+ Default
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <para>
+ Simple table indented two spaces:
+ </para>
+ <table>
+ <title>
+ Demonstration of simple table syntax.
+ </title>
+ <tgroup cols="4">
+ <colspec align="right" />
+ <colspec align="left" />
+ <colspec align="center" />
+ <colspec align="left" />
+ <thead>
+ <row>
+ <entry>
+ Right
+ </entry>
+ <entry>
+ Left
+ </entry>
+ <entry>
+ Center
+ </entry>
+ <entry>
+ Default
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>
+ Multiline table with caption:
+ </para>
+ <table>
+ <title>
+ Here's the caption. It may span multiple lines.
+ </title>
+ <tgroup cols="4">
+ <colspec colwidth="2*" align="center" />
+ <colspec colwidth="2*" align="left" />
+ <colspec colwidth="3*" align="right" />
+ <colspec colwidth="3*" align="left" />
+ <thead>
+ <row>
+ <entry>
+ Centered Header
+ </entry>
+ <entry>
+ Left Aligned
+ </entry>
+ <entry>
+ Right Aligned
+ </entry>
+ <entry>
+ Default aligned
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ First
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 12.0
+ </entry>
+ <entry>
+ Example of a row that spans multiple lines.
+ </entry>
+ </row>
+ <row>
+ <entry>
+ Second
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 5.0
+ </entry>
+ <entry>
+ Here's another one. Note the blank line between rows.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>
+ Multiline table without caption:
+ </para>
+ <informaltable>
+ <tgroup cols="4">
+ <colspec colwidth="1*" align="center" />
+ <colspec colwidth="2*" align="left" />
+ <colspec colwidth="3*" align="right" />
+ <colspec colwidth="4*" align="left" />
+ <thead>
+ <row>
+ <entry>
+ Centered Header
+ </entry>
+ <entry>
+ Left Aligned
+ </entry>
+ <entry>
+ Right Aligned
+ </entry>
+ <entry>
+ Default aligned
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ First
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 12.0
+ </entry>
+ <entry>
+ Example of a row that spans multiple lines.
+ </entry>
+ </row>
+ <row>
+ <entry>
+ Second
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 5.0
+ </entry>
+ <entry>
+ Here's another one. Note the blank line between rows.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <para>
+ Table without column headers:
+ </para>
+ <informaltable>
+ <tgroup cols="4">
+ <colspec align="right" />
+ <colspec align="left" />
+ <colspec align="center" />
+ <colspec align="right" />
+ <tbody>
+ <row>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <para>
+ Multiline table without column headers:
+ </para>
+ <informaltable>
+ <tgroup cols="4">
+ <colspec colwidth="10*" align="center" />
+ <colspec colwidth="10*" align="left" />
+ <colspec colwidth="10*" align="right" />
+ <colspec colwidth="10*" align="left" />
+ <tbody>
+ <row>
+ <entry>
+ First
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 12.0
+ </entry>
+ <entry>
+ Example of a row that spans multiple lines.
+ </entry>
+ </row>
+ <row>
+ <entry>
+ Second
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 5.0
+ </entry>
+ <entry>
+ Here's another one. Note the blank line between rows.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+</sect1>
+</article>
diff --git a/test/docbook-reader.native b/test/docbook-reader.native
new file mode 100644
index 000000000..3cce889f6
--- /dev/null
+++ b/test/docbook-reader.native
@@ -0,0 +1,397 @@
+Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",SoftBreak,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])]})
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",SoftBreak,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
+,Header 1 ("headers",[],[]) [Str "Headers"]
+,Header 2 ("level-2-with-an-embedded-link",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link ("",[],[]) [Str "embedded",Space,Str "link"] ("/url","")]
+,Header 3 ("level-3-with-emphasis",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 4 ("level-4",[],[]) [Str "Level",Space,Str "4"]
+,Header 5 ("level-5",[],[]) [Str "Level",Space,Str "5"]
+,Para [Str "Hi."]
+,Header 1 ("level-1",[],[]) [Str "Level",Space,Str "1"]
+,Header 2 ("level-2-with-emphasis",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 3 ("level-3",[],[]) [Str "Level",Space,Str "3"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,Header 2 ("level-2",[],[]) [Str "Level",Space,Str "2"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,Header 1 ("paragraphs",[],[]) [Str "Paragraphs"]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
+,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",SoftBreak,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",SoftBreak,Str "a",Space,Str "list",Space,Str "item."]
+,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]
+,Header 1 ("block-quotes",[],[]) [Str "Block",Space,Str "Quotes"]
+,Para [Str "E-mail",Space,Str "style:"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]]
+,BlockQuote
+ [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
+ ,CodeBlock ("",[],[]) "% ls"
+ ,Para [Str "A",Space,Str "list:"]
+ ,OrderedList (1,Decimal,DefaultDelim)
+ [[Para [Str "item",Space,Str "one"]]
+ ,[Para [Str "item",Space,Str "two"]]]
+ ,Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
+ ,BlockQuote
+ [Para [Str "nested"]]
+ ,BlockQuote
+ [Para [Str "nested"]]]
+,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",Space,Str ">",Space,Str "1."]
+,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."]
+,Header 1 ("code-blocks",[],[]) [Str "Code",Space,Str "Blocks"]
+,Para [Str "Code:"]
+,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"
+,Para [Str "And:"]
+,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
+,Header 1 ("lists",[],[]) [Str "Lists"]
+,Header 2 ("unordered",[],[]) [Str "Unordered"]
+,Para [Str "Asterisks",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "asterisk",Space,Str "1"]]
+ ,[Para [Str "asterisk",Space,Str "2"]]
+ ,[Para [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "Plus",Space,Str "1"]]
+ ,[Para [Str "Plus",Space,Str "2"]]
+ ,[Para [Str "Plus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "Minus",Space,Str "1"]]
+ ,[Para [Str "Minus",Space,Str "2"]]
+ ,[Para [Str "Minus",Space,Str "3"]]]
+,Header 2 ("ordered",[],[]) [Str "Ordered"]
+,OrderedList (1,Decimal,DefaultDelim)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second"]]
+ ,[Para [Str "Third"]]]
+,Para [Str "and",Space,Str "using",Space,Str "spaces:"]
+,OrderedList (1,Decimal,DefaultDelim)
+ [[Para [Str "One"]]
+ ,[Para [Str "Two"]]
+ ,[Para [Str "Three"]]]
+,Para [Str "Multiple",Space,Str "paragraphs:"]
+,OrderedList (1,Decimal,DefaultDelim)
+ [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]
+ ,Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",SoftBreak,Str "back."]]
+ ,[Para [Str "Item",Space,Str "2."]]
+ ,[Para [Str "Item",Space,Str "3."]]]
+,Header 2 ("nested",[],[]) [Str "Nested"]
+,BulletList
+ [[Para [Str "Tab"]
+ ,BulletList
+ [[Para [Str "Tab"]
+ ,BulletList
+ [[Para [Str "Tab"]]]]]]]
+,Para [Str "Here\8217s",Space,Str "another:"]
+,OrderedList (1,Decimal,DefaultDelim)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second:"]
+ ,BulletList
+ [[Para [Str "Fee"]]
+ ,[Para [Str "Fie"]]
+ ,[Para [Str "Foe"]]]]
+ ,[Para [Str "Third"]]]
+,Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"]
+,OrderedList (1,Decimal,DefaultDelim)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second:"]
+ ,BulletList
+ [[Para [Str "Fee"]]
+ ,[Para [Str "Fie"]]
+ ,[Para [Str "Foe"]]]]
+ ,[Para [Str "Third"]]]
+,Header 2 ("tabs-and-spaces",[],[]) [Str "Tabs",Space,Str "and",Space,Str "spaces"]
+,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]
+ ,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]
+,Header 2 ("fancy-list-markers",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"]
+,OrderedList (2,Decimal,DefaultDelim)
+ [[Para [Str "begins",Space,Str "with",Space,Str "2"]]
+ ,[Para [Str "and",Space,Str "now",Space,Str "3"]
+ ,Para [Str "with",Space,Str "a",Space,Str "continuation"]
+ ,OrderedList (4,LowerRoman,DefaultDelim)
+ [[Para [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"]]
+ ,[Para [Str "more",Space,Str "items"]
+ ,OrderedList (1,UpperAlpha,DefaultDelim)
+ [[Para [Str "a",Space,Str "subsublist"]]
+ ,[Para [Str "a",Space,Str "subsublist"]]]]]]]
+,Para [Str "Nesting:"]
+,OrderedList (1,UpperAlpha,DefaultDelim)
+ [[Para [Str "Upper",Space,Str "Alpha"]
+ ,OrderedList (1,UpperRoman,DefaultDelim)
+ [[Para [Str "Upper",Space,Str "Roman."]
+ ,OrderedList (6,Decimal,DefaultDelim)
+ [[Para [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
+ ,OrderedList (3,LowerAlpha,DefaultDelim)
+ [[Para [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]
+,Para [Str "Autonumbering:"]
+,OrderedList (1,Decimal,DefaultDelim)
+ [[Para [Str "Autonumber."]]
+ ,[Para [Str "More."]
+ ,OrderedList (1,Decimal,DefaultDelim)
+ [[Para [Str "Nested."]]]]]
+,Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]
+,Para [Str "M.A.\160\&2007"]
+,Para [Str "B.",Space,Str "Williams"]
+,Header 2 ("callout",[],[]) [Str "Callout"]
+,Para [Str "Simple."]
+,BulletList
+ [[Para [Str "A",Space,Code ("",[],[]) "__letrec",Space,Str "is",Space,Str "equivalent",Space,Str "to",Space,Str "a",Space,Str "normal",SoftBreak,Str "Haskell",Space,Str "LET."]]
+ ,[Para [Str "GHC",Space,Str "compiled",Space,Str "the",Space,Str "body",Space,Str "of",Space,Str "our",Space,Str "list",Space,Str "comprehension",Space,Str "into",SoftBreak,Str "a",Space,Str "loop",Space,Str "named",Space,Code ("",[],[]) "go_s1YC",Str "."]]
+ ,[Para [Str "If",Space,Str "our",Space,Str "CASE",Space,Str "expression",Space,Str "matches",Space,Str "the",Space,Str "empty",Space,Str "list,",Space,Str "we",SoftBreak,Str "return",Space,Str "the",Space,Str "empty",Space,Str "list.",Space,Str "This",Space,Str "is",Space,Str "reassuringly",SoftBreak,Str "familiar."]]]
+,Header 1 ("definition-lists",[],[]) [Str "Definition",Space,Str "Lists"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Para [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics:"]
+,DefinitionList
+ [([Emph [Str "apple"]],
+ [[Para [Str "red",Space,Str "fruit"]
+ ,Para [Str "contains",Space,Str "seeds,",Space,Str "crisp,",Space,Str "pleasant",Space,Str "to",Space,Str "taste"]]])
+ ,([Emph [Str "orange"]],
+ [[Para [Str "orange",Space,Str "fruit"]
+ ,CodeBlock ("",[],[]) "{ orange code block }"
+ ,BlockQuote
+ [Para [Str "orange",Space,Str "block",Space,Str "quote"]]]])]
+,Para [Str "Multiple",Space,Str "definitions,",Space,Str "loose:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]
+ ,[Para [Str "computer"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]
+ ,[Para [Str "bank"]]])]
+,Para [Str "Blank",Space,Str "line",Space,Str "after",Space,Str "term,",Space,Str "indented",Space,Str "marker,",Space,Str "alternate",Space,Str "markers:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]
+ ,[Para [Str "computer"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]
+ ,OrderedList (1,Decimal,DefaultDelim)
+ [[Para [Str "sublist"]]
+ ,[Para [Str "sublist"]]]]])]
+,Header 1 ("inline-markup",[],[]) [Str "Inline",Space,Str "Markup"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",SoftBreak,Str "this"],Str "."]
+,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",SoftBreak,Strong [Str "is",Space,Str "this"],Str "."]
+,Para [Str "An",Space,Emph [Link ("",[],[]) [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",SoftBreak,Str "em."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",SoftBreak,Str "em."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
+,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",SoftBreak,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",SoftBreak,Code ("",[],[]) "<html>",Str "."]
+,Para [Str "More",Space,Str "code:",Space,Code ("",[],[]) "Class",Space,Str "and",Space,Code ("",[],[]) "Type"]
+,Para [Strikeout [Str "This",Space,Str "is",SoftBreak,Emph [Str "strikeout"],Str "."]]
+,Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",SoftBreak,Str "a",Superscript [Emph [Str "hello"]],SoftBreak,Str "a",Superscript [Str "hello\160there"],Str "."]
+,Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "H",Subscript [Str "23"],Str "O,",SoftBreak,Str "H",Subscript [Str "many\160of\160them"],Str "O."]
+,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",SoftBreak,Str "spaces:",Space,Str "a^b",Space,Str "c^d,",Space,Str "a~b",Space,Str "c~d."]
+,Header 1 ("smart-quotes-ellipses-dashes",[],[]) [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
+,Para [Quoted DoubleQuote [Str "Hello,"],Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",SoftBreak,Str "name."]]
+,Para [Quoted DoubleQuote [Str "A"],Str ",",Space,Quoted DoubleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted DoubleQuote [Str "C"],Space,Str "are",Space,Str "letters."]
+,Para [Quoted DoubleQuote [Str "He",Space,Str "said,",Space,Quoted SingleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",SoftBreak,Str "70\8217s?"]
+,Para [Str "Some",Space,Str "dashes:",Space,Str "one\8212two",Space,Str "\8212",Space,Str "three\8212four",Space,Str "\8212",Space,Str "five."]
+,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5\8211\&7,",Space,Str "255\8211\&66,",Space,Str "1987\8211\&1999."]
+,Para [Str "Ellipses\8230and\8230and\8230."]
+,Header 1 ("math",[],[]) []
+,Para [Math DisplayMath "e = mc^{2}",Math DisplayMath "1",SoftBreak,Math InlineMath "e = mc^{2}",SoftBreak,Math DisplayMath "e = mc^{2}"]
+,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
+,BulletList
+ [[Para [Str "I",Space,Str "hat:",Space,Str "\206"]]
+ ,[Para [Str "o",Space,Str "umlaut:",Space,Str "\246"]]
+ ,[Para [Str "section:",Space,Str "\167"]]
+ ,[Para [Str "set",Space,Str "membership:",Space,Str "\8712"]]
+ ,[Para [Str "copyright:",Space,Str "\169"]]]
+,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]
+,Para [Str "AT&T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it."]
+,Para [Str "This",Space,Str "&",Space,Str "that."]
+,Para [Str "4",Space,Str "<",Space,Str "5."]
+,Para [Str "6",Space,Str ">",Space,Str "5."]
+,Para [Str "Backslash:",Space,Str "\\"]
+,Para [Str "Backtick:",Space,Str "`"]
+,Para [Str "Asterisk:",Space,Str "*"]
+,Para [Str "Underscore:",Space,Str "_"]
+,Para [Str "Left",Space,Str "brace:",Space,Str "{"]
+,Para [Str "Right",Space,Str "brace:",Space,Str "}"]
+,Para [Str "Left",Space,Str "bracket:",Space,Str "["]
+,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]
+,Para [Str "Left",Space,Str "paren:",Space,Str "("]
+,Para [Str "Right",Space,Str "paren:",Space,Str ")"]
+,Para [Str "Greater-than:",Space,Str ">"]
+,Para [Str "Hash:",Space,Str "#"]
+,Para [Str "Period:",Space,Str "."]
+,Para [Str "Bang:",Space,Str "!"]
+,Para [Str "Plus:",Space,Str "+"]
+,Para [Str "Minus:",Space,Str "-"]
+,Header 1 ("links",[],[]) [Str "Links"]
+,Header 2 ("explicit",[],[]) [Str "Explicit"]
+,Para [Str "Just",Space,Str "a",Space,Link ("",[],[]) [Str "URL"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","")]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","")]
+,Para [Link ("",[],[]) [Str "with_underscore"] ("/url/with_underscore","")]
+,Para [Link ("",[],[]) [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]
+,Para [Link ("",[],[]) [Str "Empty"] ("",""),Str "."]
+,Header 2 ("reference",[],[]) [Str "Reference"]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "With",Space,Link ("",[],[]) [Str "embedded",Space,Str "[brackets]"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "once"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "twice"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "thrice"] ("/url",""),Str "."]
+,Para [Str "This",Space,Str "should",Space,Str "[not][]",Space,Str "be",Space,Str "a",Space,Str "link."]
+,CodeBlock ("",[],[]) "[not]: /url"
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "biz"] ("/url/",""),Str "."]
+,Header 2 ("with-ampersands",[],[]) [Str "With",Space,Str "ampersands"]
+,Para [Str "Here\8217s",Space,Str "a",Space,Link ("",[],[]) [Str "link",Space,Str "with",Space,Str "an",SoftBreak,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",SoftBreak,Link ("",[],[]) [Str "AT&T"] ("http://att.com/",""),Str "."]
+,Para [Str "Here\8217s",Space,Str "an",Space,Link ("",[],[]) [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."]
+,Para [Str "Here\8217s",Space,Str "an",Space,Link ("",[],[]) [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",SoftBreak,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]
+,Header 2 ("autolinks",[],[]) [Str "Autolinks"]
+,Para [Str "With",Space,Str "an",Space,Str "ampersand:",SoftBreak,Link ("",[],[]) [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]
+,BulletList
+ [[Para [Str "In",Space,Str "a",Space,Str "list?"]]
+ ,[Para [Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]
+ ,[Para [Str "It",Space,Str "should."]]]
+,Para [Str "An",Space,Str "e-mail",Space,Str "address:",Space,Link ("",[],[]) [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]
+,BlockQuote
+ [Para [Str "Blockquoted:",SoftBreak,Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]
+,Para [Str "Auto-links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",SoftBreak,Code ("",[],[]) "<http://example.com/>"]
+,CodeBlock ("",[],[]) "or here: <http://example.com/>"
+,Header 1 ("images",[],[]) [Str "Images"]
+,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
+,Para [Image ("",[],[]) [Str "lalune",Space,Str "fig",Space,Str "caption"] ("lalune.jpg","fig:")]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image ("",[],[]) [] ("movie.jpg",""),Space,Str "icon.",SoftBreak,Str "And",Space,Str "here",Space,Str "a",Space,Str "second",Space,Str "movie",Space,Image ("",[],[]) [Str "alt",Space,Str "text"] ("movie.jpg",""),Space,Str "icon.",SoftBreak,Str "And",Space,Str "here",Space,Str "a",Space,Str "third",Space,Str "movie",Space,Image ("",[],[]) [Str "alt",Space,Str "text"] ("movie.jpg",""),Space,Str "icon."]
+,Para [Image ("",[],[]) [Str "lalune",Space,Str "no",Space,Str "figure",Space,Str "alt",Space,Str "text"] ("lalune.jpg","")]
+,Header 1 ("footnotes",[],[]) [Str "Footnotes"]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote.",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",Space,Str "reference.",SoftBreak,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."]],Space,Str "and",Space,Str "another.",Note [Para [Str "Here\8217s",Space,Str "the",Space,Str "long",Space,Str "note.",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",SoftBreak,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "list",Space,Str "items)."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",SoftBreak,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block."]],Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",SoftBreak,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space.[^my",Space,Str "note]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note.",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type.",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",SoftBreak,Link ("",[],[]) [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",SoftBreak,Str "verbatim",Space,Str "characters,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[bracketed",Space,Str "text]."]]]
+,BlockQuote
+ [Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes.",Note [Para [Str "In",Space,Str "quote."]]]]
+,OrderedList (1,Decimal,DefaultDelim)
+ [[Para [Str "And",Space,Str "in",Space,Str "list",Space,Str "items.",Note [Para [Str "In",Space,Str "list."]]]]]
+,Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented."]
+,Header 1 ("tables",[],[]) [Str "Tables"]
+,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."] [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"]]]]
+,Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption:"]
+,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"]]]]
+,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."] [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"]]]]
+,Para [Str "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption:"]
+,Table [Str "Here's",Space,Str "the",Space,Str "caption.",Space,Str "It",Space,Str "may",Space,Str "span",Space,Str "multiple",Space,Str "lines."] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.2,0.2,0.3,0.3]
+ [[Plain [Str "Centered",Space,Str "Header"]]
+ ,[Plain [Str "Left",Space,Str "Aligned"]]
+ ,[Plain [Str "Right",Space,Str "Aligned"]]
+ ,[Plain [Str "Default",Space,Str "aligned"]]]
+ [[[Plain [Str "First"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "12.0"]]
+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."]]]
+ ,[[Plain [Str "Second"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "5.0"]]
+ ,[Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."]]]]
+,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "caption:"]
+,Table [] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.1,0.2,0.3,0.4]
+ [[Plain [Str "Centered",Space,Str "Header"]]
+ ,[Plain [Str "Left",Space,Str "Aligned"]]
+ ,[Plain [Str "Right",Space,Str "Aligned"]]
+ ,[Plain [Str "Default",Space,Str "aligned"]]]
+ [[[Plain [Str "First"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "12.0"]]
+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."]]]
+ ,[[Plain [Str "Second"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "5.0"]]
+ ,[Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."]]]]
+,Para [Str "Table",Space,Str "without",Space,Str "column",Space,Str "headers:"]
+,Table [] [AlignRight,AlignLeft,AlignCenter,AlignRight] [0.0,0.0,0.0,0.0]
+ [[]
+ ,[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers:"]
+,Table [] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.25,0.25,0.25,0.25]
+ [[]
+ ,[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "First"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "12.0"]]
+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",Space,Str "multiple",Space,Str "lines."]]]
+ ,[[Plain [Str "Second"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "5.0"]]
+ ,[Plain [Str "Here's",Space,Str "another",Space,Str "one.",Space,Str "Note",Space,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."]]]]]
diff --git a/test/docbook-xref.docbook b/test/docbook-xref.docbook
new file mode 100644
index 000000000..ebcd94d00
--- /dev/null
+++ b/test/docbook-xref.docbook
@@ -0,0 +1,70 @@
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
+<book><title>An Example Book</title>
+<chapter id="ch01"><title>XRef Samples</title>
+<para>
+This paragraph demonstrates several features of
+<sgmltag>XRef</sgmltag>.
+</para>
+<itemizedlist>
+<listitem><para>A straight link generates the
+cross-reference text: <xref linkend="ch02"/>.
+</para></listitem>
+<listitem><para>A link to an element with an
+<sgmltag class="attribute">XRefLabel</sgmltag>:
+<xref linkend="ch03"/>.
+</para></listitem>
+<listitem><para>A link with an
+<sgmltag class="attribute">EndTerm</sgmltag>:
+<xref linkend="ch04" endterm="ch04short"/>.
+</para></listitem>
+<listitem><para>A link to an
+<sgmltag>cmdsynopsis</sgmltag> element: <xref linkend="cmd01"/>.
+</para></listitem>
+<listitem><para>A link to an
+<sgmltag>funcsynopsis</sgmltag> element: <xref linkend="func01"/>.
+</para></listitem>
+</itemizedlist>
+</chapter>
+
+<chapter id="ch02">
+ <title>The Second Chapter</title>
+ <para>Some content here</para>
+</chapter>
+
+<chapter id="ch03" xreflabel="Chapter the Third">
+ <title>The Third Chapter</title>
+ <para>Some content here</para>
+</chapter>
+
+<chapter id="ch04">
+ <title>The Fourth Chapter</title>
+ <titleabbrev id="ch04short">Chapter 4</titleabbrev>
+ <para>Some content here</para>
+
+<cmdsynopsis id="cmd01">
+ <command>chgrp</command>
+ <arg>-R
+ <group>
+ <arg>-H</arg>
+ <arg>-L</arg>
+ <arg>-P</arg>
+ </group>
+ </arg>
+ <arg>-f</arg>
+ <arg choice='plain'><replaceable>group</replaceable></arg>
+ <arg rep='repeat' choice='plain'><replaceable>file</replaceable></arg>
+</cmdsynopsis>
+
+
+<funcsynopsis id="func01">
+<funcprototype>
+<funcdef>int <function>max</function></funcdef>
+<paramdef>int <parameter>int1</parameter></paramdef>
+<paramdef>int <parameter>int2</parameter></paramdef>
+</funcprototype>
+</funcsynopsis>
+
+</chapter>
+</book>
+
diff --git a/test/docbook-xref.native b/test/docbook-xref.native
new file mode 100644
index 000000000..23bc497b2
--- /dev/null
+++ b/test/docbook-xref.native
@@ -0,0 +1,29 @@
+Pandoc (Meta {unMeta = fromList []})
+[Header 1 ("ch01",[],[]) [Str "XRef",Space,Str "Samples"]
+,Para [Str "This",Space,Str "paragraph",Space,Str "demonstrates",Space,Str "several",Space,Str "features",Space,Str "of",SoftBreak,Str "XRef."]
+,BulletList
+ [[Para [Str "A",Space,Str "straight",Space,Str "link",Space,Str "generates",Space,Str "the",SoftBreak,Str "cross-reference",Space,Str "text:",Space,Link ("",[],[]) [Str "The",Space,Str "Second",Space,Str "Chapter"] ("#ch02",""),Str "."]]
+ ,[Para [Str "A",Space,Str "link",Space,Str "to",Space,Str "an",Space,Str "element",Space,Str "with",Space,Str "an",SoftBreak,Str "XRefLabel:",SoftBreak,Link ("",[],[]) [Str "Chapter",Space,Str "the",Space,Str "Third"] ("#ch03",""),Str "."]]
+ ,[Para [Str "A",Space,Str "link",Space,Str "with",Space,Str "an",SoftBreak,Str "EndTerm:",SoftBreak,Link ("",[],[]) [Str "Chapter",Space,Str "4"] ("#ch04",""),Str "."]]
+ ,[Para [Str "A",Space,Str "link",Space,Str "to",Space,Str "an",SoftBreak,Str "cmdsynopsis",Space,Str "element:",Space,Link ("",[],[]) [Str "chgrp"] ("#cmd01",""),Str "."]]
+ ,[Para [Str "A",Space,Str "link",Space,Str "to",Space,Str "an",SoftBreak,Str "funcsynopsis",Space,Str "element:",Space,Link ("",[],[]) [Str "max"] ("#func01",""),Str "."]]]
+,Header 1 ("ch02",[],[]) [Str "The",Space,Str "Second",Space,Str "Chapter"]
+,Para [Str "Some",Space,Str "content",Space,Str "here"]
+,Header 1 ("ch03",[],[]) [Str "The",Space,Str "Third",Space,Str "Chapter"]
+,Para [Str "Some",Space,Str "content",Space,Str "here"]
+,Header 1 ("ch04",[],[]) [Str "The",Space,Str "Fourth",Space,Str "Chapter"]
+,Para [Str "Some",Space,Str "content",Space,Str "here"]
+,Plain [Str "chgrp"]
+,Plain [Str "-R"]
+,Plain [Str "-H"]
+,Plain [Str "-L"]
+,Plain [Str "-P"]
+,Plain [Str "-f"]
+,Plain [Str "group"]
+,Plain [Str "file"]
+,Plain [Str "int"]
+,Plain [Str "max"]
+,Plain [Str "int"]
+,Plain [Str "int1"]
+,Plain [Str "int"]
+,Plain [Str "int2"]]
diff --git a/test/docx/adjacent_links.docx b/test/docx/adjacent_links.docx
new file mode 100644
index 000000000..86b1c2a14
--- /dev/null
+++ b/test/docx/adjacent_links.docx
Binary files differ
diff --git a/test/docx/adjacent_links.native b/test/docx/adjacent_links.native
new file mode 100644
index 000000000..cca861890
--- /dev/null
+++ b/test/docx/adjacent_links.native
@@ -0,0 +1 @@
+[Para [Str "Le",Space,Str "plus",Space,Str "int\233ressant",Space,Str "\233tant",Space,Str "sans",Space,Str "doute",Space,Str "le",Space,Str "Marsan,",Space,Str "propos\233",Space,Str "par",Space,Str "Claude",Space,Str "Marsan",Space,Str "en",Space,Str "1976",Space,Str "qui",Space,Str "avait",Space,Str "m\234me",Space,Str "fait",Space,Str "l'objet",Space,Str "d'une",Space,Str "norme,",Space,Str "mais",Space,Str "qui",Space,Str "n'a",Space,Str "pas",Space,Str "du",Space,Str "tout",Space,Str "\233t\233",Space,Str "adopt\233",Space,Str "\224",Space,Str "cause",Space,Str "des",Space,Str "habitudes",Space,Str "trop",Space,Str "ancr\233es",Space,Str "et",Space,Str "qui",Space,Str "a",Space,Str "fini",Space,Str "par",Space,Str "tomber",Space,Str "dans",Space,Str "l'oubli,",Space,Str "gros",Space,Str "clin",Space,Str "d'\339il",Space,Str "\224",Space,Str "cela",Space,Str "d'ailleurs",Space,Str "dans",Space,Str "le",Space,Str "film",Space,Link ("",[],[]) [Emph [Str "\"Le",Space,Str "nom",Space,Str "des",Space,Str "gens\""]] ("http://www.allocine.fr/film/fichefilm_gen_cfilm=172167.html",""),Str ".",Space,Str "D\8217ailleurs",Space,Str "l\8217\233tat,",Space,Str "bien",Space,Str "conscient",Space,Str "que",Space,Str "tous",Space,Str "les",Space,Str "fran\231ais",Space,Str "\233crivent",Space,Str "sur",Space,Str "des",Space,Str "claviers",Space,Str "compl\232tement",Space,Str "inadapt\233s,",Space,Link ("",[],[]) [Emph [Str "tente",Space,Str "encore",Space,Str "une",Space,Str "fois",Space,Str "de",Space,Str "faire",Space,Str "une",Space,Str "norme",Space,Str "en",Space,Str "ce",Space,Str "moment",Space,Str "m\234me"]] ("http://www.appy-geek.com/Web/ArticleWeb.aspx?regionid=2&articleid=56103389&source=messenger",""),Str "."]]
diff --git a/test/docx/already_auto_ident.docx b/test/docx/already_auto_ident.docx
new file mode 100644
index 000000000..ec2b348d7
--- /dev/null
+++ b/test/docx/already_auto_ident.docx
Binary files differ
diff --git a/test/docx/already_auto_ident.native b/test/docx/already_auto_ident.native
new file mode 100644
index 000000000..67c37298d
--- /dev/null
+++ b/test/docx/already_auto_ident.native
@@ -0,0 +1,2 @@
+[Header 1 ("anchor-header",[],[]) [Str "Anchor",Space,Str "Header"]
+,Para [Str "A",Space,Link ("",[],[]) [Str "link"] ("#anchor-header","")]]
diff --git a/test/docx/block_quotes.docx b/test/docx/block_quotes.docx
new file mode 100644
index 000000000..729ae1f43
--- /dev/null
+++ b/test/docx/block_quotes.docx
Binary files differ
diff --git a/test/docx/block_quotes_parse_indent.native b/test/docx/block_quotes_parse_indent.native
new file mode 100644
index 000000000..842b3606a
--- /dev/null
+++ b/test/docx/block_quotes_parse_indent.native
@@ -0,0 +1,8 @@
+[Header 2 ("some-block-quotes-in-different-ways",[],[]) [Str "Some",Space,Str "block",Space,Str "quotes,",Space,Str "in",Space,Str "different",Space,Str "ways"]
+,Para [Str "This",Space,Str "is",Space,Str "the",Space,Str "proper",Space,Str "way,",Space,Str "with",Space,Str "a",Space,Str "style"]
+,BlockQuote
+ [Para [Str "I",Space,Str "don\8217t",Space,Str "know",Space,Str "why",Space,Str "this",Space,Str "would",Space,Str "be",Space,Str "in",Space,Str "italics,",Space,Str "but",Space,Str "so",Space,Str "it",Space,Str "appears",Space,Str "to",Space,Str "be",Space,Str "on",Space,Str "my",Space,Str "screen."]]
+,Para [Str "And",Space,Str "this",Space,Str "is",Space,Str "the",Space,Str "way",Space,Str "that",Space,Str "most",Space,Str "people",Space,Str "do",Space,Str "it:"]
+,BlockQuote
+ [Para [Str "I",Space,Str "just",Space,Str "indented",Space,Str "this,",Space,Str "so",Space,Str "it",Space,Str "looks",Space,Str "like",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "I",Space,Str "think",Space,Str "this",Space,Str "is",Space,Str "how",Space,Str "most",Space,Str "people",Space,Str "do",Space,Str "block",Space,Str "quotes",Space,Str "in",Space,Str "their",Space,Str "documents."]]
+,Para [Str "And",Space,Str "back",Space,Str "to",Space,Str "the",Space,Str "normal",Space,Str "style."]]
diff --git a/test/docx/char_styles.docx b/test/docx/char_styles.docx
new file mode 100644
index 000000000..05979b9a7
--- /dev/null
+++ b/test/docx/char_styles.docx
Binary files differ
diff --git a/test/docx/char_styles.native b/test/docx/char_styles.native
new file mode 100644
index 000000000..7dfc208fb
--- /dev/null
+++ b/test/docx/char_styles.native
@@ -0,0 +1,4 @@
+[Para [Emph [Str "This",Space,Str "is",Space,Str "all",Space,Str "in",Space,Str "an"],Space,Emph [Strong [Str "italic",Space,Str "style"],Str "."]]
+,Para [Emph [Str "This",Space,Str "is",Space,Str "an",Space,Str "italic"],Space,Str "style",Space,Emph [Str "with",Space,Str "some"],Space,Str "words",Space,Emph [Str "unitalicized."]]
+,Para [Strong [Str "This",Space,Str "is",Space,Str "all",Space,Str "in",Space,Str "a",Space,Emph [Str "strong",Space,Str "style"],Str "."]]
+,Para [Strong [Str "This",Space,Str "is",Space,Str "a",Space,Str "strong"],Space,Str "style",Space,Strong [Str "with",Space,Str "some"],Space,Str "words",Space,Strong [Str "ubolded."]]]
diff --git a/test/docx/codeblock.docx b/test/docx/codeblock.docx
new file mode 100644
index 000000000..8ec00953c
--- /dev/null
+++ b/test/docx/codeblock.docx
Binary files differ
diff --git a/test/docx/codeblock.native b/test/docx/codeblock.native
new file mode 100644
index 000000000..441e33511
--- /dev/null
+++ b/test/docx/codeblock.native
@@ -0,0 +1,3 @@
+[Para [Str "This",Space,Str "is",Space,Str "some",Space,Str "code:"]
+,CodeBlock ("",[],[]) "readDocx :: ReaderOptions\n -> B.ByteString\n -> Pandoc"
+,Para [Str "from",Space,Str "the",Space,Str "beginning",Space,Str "of",Space,Str "the",Space,Str "docx",Space,Str "reader."]]
diff --git a/test/docx/comments.docx b/test/docx/comments.docx
new file mode 100644
index 000000000..9df74cf0a
--- /dev/null
+++ b/test/docx/comments.docx
Binary files differ
diff --git a/test/docx/comments.native b/test/docx/comments.native
new file mode 100644
index 000000000..3357bc257
--- /dev/null
+++ b/test/docx/comments.native
@@ -0,0 +1,4 @@
+[Para [Str "I",Space,Str "want",Space,Span ("",["comment-start"],[("id","0"),("author","Jesse Rosenthal"),("date","2016-05-09T16:13:00Z")]) [Str "I",Space,Str "left",Space,Str "a",Space,Str "comment."],Str "some",Space,Str "text",Space,Str "to",Space,Str "have",Space,Str "a",Space,Str "comment",Space,Span ("",["comment-end"],[("id","0")]) [],Str "on",Space,Str "it."]
+,Para [Str "This",Space,Str "is",Space,Span ("",["comment-start"],[("id","1"),("author","Jesse Rosenthal"),("date","2016-05-09T16:13:00Z")]) [Str "A",Space,Str "comment",Space,Str "across",Space,Str "paragraphs."],Str "a",Space,Str "new",Space,Str "paragraph."]
+,Para [Str "And",Space,Str "so",Span ("",["comment-end"],[("id","1")]) [],Space,Str "is",Space,Str "this."]
+,Para [Str "One",Space,Span ("",["comment-start"],[("id","2"),("author","Jesse Rosenthal"),("date","2016-05-09T16:14:00Z")]) [Str "This",Space,Str "one",Space,Str "has",Space,Str "multiple",Space,Str "paragraphs.",Space,Str "\182",Space,Str "See?"],Str "more",Span ("",["comment-end"],[("id","2")]) [],Str ".",Space,Str "And",Space,Str "this",Space,Str "is",Space,Str "one",Space,Str "with",Space,Str "a",Space,Span ("",["comment-start"],[("id","3"),("author","Jesse Rosenthal"),("date","2016-06-22T14:35:00Z")]) [Str "Do",Space,Str "something."],Span ("",["comment-start"],[("id","4"),("author","Jesse Rosenthal"),("date","2016-06-22T14:36:00Z")]) [Str "Do",Space,Str "something",Space,Str "else."],Str "comment",Space,Str "in",Space,Str "a",Space,Str "comment",Span ("",["comment-end"],[("id","3")]) [Span ("",["comment-end"],[("id","4")]) []],Str "."]]
diff --git a/test/docx/comments_no_comments.native b/test/docx/comments_no_comments.native
new file mode 100644
index 000000000..805e9b562
--- /dev/null
+++ b/test/docx/comments_no_comments.native
@@ -0,0 +1,4 @@
+[Para [Str "I",Space,Str "want",Space,Str "some",Space,Str "text",Space,Str "to",Space,Str "have",Space,Str "a",Space,Str "comment",Space,Str "on",Space,Str "it."]
+,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "new",Space,Str "paragraph."]
+,Para [Str "And",Space,Str "so",Space,Str "is",Space,Str "this."]
+,Para [Str "One",Space,Str "more.",Space,Str "And",Space,Str "this",Space,Str "is",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "comment",Space,Str "in",Space,Str "a",Space,Str "comment."]]
diff --git a/test/docx/comments_warning.docx b/test/docx/comments_warning.docx
new file mode 100644
index 000000000..e49642b22
--- /dev/null
+++ b/test/docx/comments_warning.docx
Binary files differ
diff --git a/test/docx/custom-style-reference.docx b/test/docx/custom-style-reference.docx
new file mode 100644
index 000000000..0f53c6c88
--- /dev/null
+++ b/test/docx/custom-style-reference.docx
Binary files differ
diff --git a/test/docx/custom-style-roundtrip-end.native b/test/docx/custom-style-roundtrip-end.native
new file mode 100644
index 000000000..4313c3595
--- /dev/null
+++ b/test/docx/custom-style-roundtrip-end.native
@@ -0,0 +1,5 @@
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "test",Space,Str "of",Space,Str "custom-styles."]
+,Para [Str "Here",Space,Str "is",Space,Str "something",Space,Emph [Str "emphasized"],Str ".",Space,Str "And",Space,Str "here",Space,Str "is",Space,Str "something",Space,Strong [Str "strong"],Str "."]
+,BlockQuote
+ [Para [Str "One",Space,Str "paragraph",Space,Str "of",Space,Str "text."]
+ ,Para [Str "And",Space,Str "another",Space,Str "paragraph",Space,Str "of",Space,Emph [Str "really",Space,Str "cool"],Space,Str "text."]]]
diff --git a/test/docx/custom-style-roundtrip-start.native b/test/docx/custom-style-roundtrip-start.native
new file mode 100644
index 000000000..c4566ed85
--- /dev/null
+++ b/test/docx/custom-style-roundtrip-start.native
@@ -0,0 +1,5 @@
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "test",Space,Str "of",Space,Str "custom-styles."]
+,Para [Str "Here",Space,Str "is",Space,Str "something",Space,Span ("",[],[("custom-style","Emphatic")]) [Str "emphasized"],Str ".",Space,Str "And",SoftBreak,Str "here",Space,Str "is",Space,Str "something",Space,Span ("",[],[("custom-style","Strengthened")]) [Str "strong"],Str "."]
+,Div ("",[],[("custom-style","My Block Style")])
+ [Para [Str "One",Space,Str "paragraph",Space,Str "of",Space,Str "text."]
+ ,Para [Str "And",Space,Str "another",Space,Str "paragraph",Space,Str "of",Space,Span ("",[],[("custom-style","Emphatic")]) [Str "really",SoftBreak,Str "cool"],Space,Str "text."]]]
diff --git a/test/docx/deep_normalize.docx b/test/docx/deep_normalize.docx
new file mode 100644
index 000000000..7626d59ce
--- /dev/null
+++ b/test/docx/deep_normalize.docx
Binary files differ
diff --git a/test/docx/deep_normalize.native b/test/docx/deep_normalize.native
new file mode 100644
index 000000000..9b2089ec8
--- /dev/null
+++ b/test/docx/deep_normalize.native
@@ -0,0 +1,6 @@
+[OrderedList (1,Decimal,OneParen)
+ [[Para [Str "This",Space,Str "is",Space,Str "at",Space,Str "the",Space,Str "first",Space,Str "level"]
+ ,OrderedList (1,LowerAlpha,DefaultDelim)
+ [[Para [Str "This",Space,Str "is",Space,Str "at",Space,Str "the",Space,Str "second",Space,Str "level"]
+ ,OrderedList (1,LowerRoman,DefaultDelim)
+ [[Para [Str "This",Space,Str "is",Space,Emph [Str "at",Space,Strong [Str "the",Space,Str "third",Space,Str "level"],Str ",",Space,Str "and",Space,Str "I",Space,Str "want",Space,Str "to"],Space,Str "test",Space,Str "normalization",Space,Str "here."]]]]]]]]
diff --git a/test/docx/definition_list.docx b/test/docx/definition_list.docx
new file mode 100644
index 000000000..a19edda45
--- /dev/null
+++ b/test/docx/definition_list.docx
Binary files differ
diff --git a/test/docx/definition_list.native b/test/docx/definition_list.native
new file mode 100644
index 000000000..2e08ff1ac
--- /dev/null
+++ b/test/docx/definition_list.native
@@ -0,0 +1,7 @@
+[DefinitionList
+ [([Str "Term",Space,Str "1"],
+ [[Para [Str "Definition",Space,Str "1"]]])
+ ,([Str "Term",Space,Str "2",Space,Str "with",Space,Emph [Str "inline",Space,Str "markup"]],
+ [[Para [Str "Definition",Space,Str "2"]
+ ,CodeBlock ("",[],[]) "{ some code, part of Definition 2 }"
+ ,Para [Str "Third",Space,Str "paragraph",Space,Str "of",Space,Str "definition",Space,Str "2."]]])]]
diff --git a/test/docx/drop_cap.docx b/test/docx/drop_cap.docx
new file mode 100644
index 000000000..19fab4a52
--- /dev/null
+++ b/test/docx/drop_cap.docx
Binary files differ
diff --git a/test/docx/drop_cap.native b/test/docx/drop_cap.native
new file mode 100644
index 000000000..d361cfb0b
--- /dev/null
+++ b/test/docx/drop_cap.native
@@ -0,0 +1,4 @@
+[Para [Str "Drop",Space,Str "cap."]
+,Para [Str "Next",Space,Str "paragraph."]
+,Para [Str "Drop",Space,Str "cap",Space,Str "in",Space,Str "margin."]
+,Para [Str "Drop",Space,Str "cap",Space,Str "(not",Space,Str "really)."]]
diff --git a/test/docx/dummy_item_after_list_item.docx b/test/docx/dummy_item_after_list_item.docx
new file mode 100644
index 000000000..5e29b993c
--- /dev/null
+++ b/test/docx/dummy_item_after_list_item.docx
Binary files differ
diff --git a/test/docx/dummy_item_after_list_item.native b/test/docx/dummy_item_after_list_item.native
new file mode 100644
index 000000000..3f6231932
--- /dev/null
+++ b/test/docx/dummy_item_after_list_item.native
@@ -0,0 +1,3 @@
+[OrderedList (1,Decimal,Period)
+ [[Para [Str "One"]
+ ,Para [Str "Two",LineBreak,LineBreak,Str "Three"]]]]
diff --git a/test/docx/dummy_item_after_paragraph.docx b/test/docx/dummy_item_after_paragraph.docx
new file mode 100644
index 000000000..b0aee8843
--- /dev/null
+++ b/test/docx/dummy_item_after_paragraph.docx
Binary files differ
diff --git a/test/docx/dummy_item_after_paragraph.native b/test/docx/dummy_item_after_paragraph.native
new file mode 100644
index 000000000..2e9b831c4
--- /dev/null
+++ b/test/docx/dummy_item_after_paragraph.native
@@ -0,0 +1,3 @@
+[Para [Str "First",Space,Str "bullet",Space,Str "point",Space,Str "created",Space,Str "and",Space,Str "then",Space,Str "deleted"]
+,Para [Str "A",Space,Str "normal",Space,Str "paragraph"]
+,Para [Str "First",Space,Str "bullet",Space,Str "point",Space,Str "created",Space,Str "and",Space,Str "then",Space,Str "deleted",Space,Str "after",Space,Str "the",Space,Str "normal",Space,Str "paragraph"]]
diff --git a/test/docx/enumerated_headings.docx b/test/docx/enumerated_headings.docx
new file mode 100644
index 000000000..afa84748a
--- /dev/null
+++ b/test/docx/enumerated_headings.docx
Binary files differ
diff --git a/test/docx/enumerated_headings.native b/test/docx/enumerated_headings.native
new file mode 100644
index 000000000..67c0df5e0
--- /dev/null
+++ b/test/docx/enumerated_headings.native
@@ -0,0 +1,4 @@
+[Header 1 ("h1",[],[]) [Str "H1"]
+,Header 2 ("h2",[],[]) [Str "H2"]
+,Header 3 ("h3",[],[]) [Str "H3"]
+,Para [Str "And",Space,Str "some",Space,Str "text"]]
diff --git a/test/docx/german_styled_lists.docx b/test/docx/german_styled_lists.docx
new file mode 100644
index 000000000..ce454e9cc
--- /dev/null
+++ b/test/docx/german_styled_lists.docx
Binary files differ
diff --git a/test/docx/german_styled_lists.native b/test/docx/german_styled_lists.native
new file mode 100644
index 000000000..4d5456dfc
--- /dev/null
+++ b/test/docx/german_styled_lists.native
@@ -0,0 +1,6 @@
+[BulletList
+ [[Para [Str "One",Space,Str "level",Space,Str "of",Space,Str "the",Space,Str "list."]]
+ ,[Para [Str "Second",Space,Str "level",Space,Str "of",Space,Str "the",Space,Str "list."]
+ ,BulletList
+ [[Para [Str "Next",Space,Str "level",Space,Str "of",Space,Str "the",Space,Str "list"]]]]
+ ,[Para [Str "Back",Space,Str "to",Space,Str "the",Space,Str "top",Space,Str "level."]]]]
diff --git a/test/docx/hanging_indent.docx b/test/docx/hanging_indent.docx
new file mode 100644
index 000000000..6f62dc731
--- /dev/null
+++ b/test/docx/hanging_indent.docx
Binary files differ
diff --git a/test/docx/hanging_indent.native b/test/docx/hanging_indent.native
new file mode 100644
index 000000000..138a6967f
--- /dev/null
+++ b/test/docx/hanging_indent.native
@@ -0,0 +1,3 @@
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "hanging",Space,Str "indent,",Space,Str "with",Space,Str "the",Space,Str "left",Space,Str "side",Space,Str "set",Space,Str "to",Space,Str "the",Space,Str "left",Space,Str "margin,",Space,Str "and",Space,Str "it",Space,Str "wraps",Space,Str "around",Space,Str "the",Space,Str "line."]
+,BlockQuote
+ [Para [Str "Five",Space,Str "years",Space,Str "have",Space,Str "passed,",Space,Str "five",Space,Str "summers",Space,Str "with",Space,Str "the",Space,Str "length"]]]
diff --git a/test/docx/headers.docx b/test/docx/headers.docx
new file mode 100644
index 000000000..e1fbbcc75
--- /dev/null
+++ b/test/docx/headers.docx
Binary files differ
diff --git a/test/docx/headers.native b/test/docx/headers.native
new file mode 100644
index 000000000..5d0065239
--- /dev/null
+++ b/test/docx/headers.native
@@ -0,0 +1,13 @@
+[Header 1 ("a-test-of-headers",[],[]) [Str "A",Space,Str "Test",Space,Str "of",Space,Str "Headers"]
+,Header 2 ("second-level",[],[]) [Str "Second",Space,Str "Level"]
+,Para [Str "Some",Space,Str "plain",Space,Str "text."]
+,Header 3 ("third-level",[],[]) [Str "Third",Space,Str "level"]
+,Para [Str "Some",Space,Str "more",Space,Str "plain",Space,Str "text."]
+,Header 4 ("fourth-level",[],[]) [Str "Fourth",Space,Str "level"]
+,Para [Str "Some",Space,Str "more",Space,Str "plain",Space,Str "text."]
+,Header 5 ("fifth-level",[],[]) [Str "Fifth",Space,Str "level"]
+,Para [Str "Some",Space,Str "more",Space,Str "plain",Space,Str "text."]
+,Header 6 ("sixth-level",[],[]) [Str "Sixth",Space,Str "level"]
+,Para [Str "Some",Space,Str "more",Space,Str "plain",Space,Str "text."]
+,Para [Str "Seventh",Space,Str "level"]
+,Para [Str "Since",Space,Str "no",Space,Str "Heading",Space,Str "7",Space,Str "style",Space,Str "exists",Space,Str "in",Space,Str "styles.xml,",Space,Str "this",Space,Str "gets",Space,Str "converted",Space,Str "to",Space,Str "Span."]]
diff --git a/test/docx/i18n_blocks.docx b/test/docx/i18n_blocks.docx
new file mode 100644
index 000000000..36341c363
--- /dev/null
+++ b/test/docx/i18n_blocks.docx
Binary files differ
diff --git a/test/docx/i18n_blocks.native b/test/docx/i18n_blocks.native
new file mode 100644
index 000000000..582a7360d
--- /dev/null
+++ b/test/docx/i18n_blocks.native
@@ -0,0 +1,8 @@
+[Header 1 ("this-is-heading-1",[],[]) [Str "This",Space,Str "is",Space,Str "Heading",Space,Str "1"]
+,Header 2 ("this-is-heading-2",[],[]) [Str "This",Space,Str "is",Space,Str "Heading",Space,Str "2"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "Quote"]
+ ,Para [Str "This",Space,Str "is",Space,Str "Block",Space,Str "Text"]]
+,BulletList
+ [[Para [Str "This",Space,Str "is",Space,Str "list",Space,Str "item",Space,Str "1"]]
+ ,[Para [Str "This",Space,Str "is",Space,Str "list",Space,Str "item",Space,Str "2"]]]]
diff --git a/test/docx/image.docx b/test/docx/image.docx
new file mode 100644
index 000000000..674956e7a
--- /dev/null
+++ b/test/docx/image.docx
Binary files differ
diff --git a/test/docx/image_no_embed.native b/test/docx/image_no_embed.native
new file mode 100644
index 000000000..5f413dbf8
--- /dev/null
+++ b/test/docx/image_no_embed.native
@@ -0,0 +1,2 @@
+[Para [Str "An",Space,Str "image:"]
+,Para [Image ("",[],[("width","6.5in"),("height","5.508333333333334in")]) [Str "He",Space,Str "realizes",Space,Str "he's",Space,Str "making",Space,Str "the",Space,Str "file-size",Space,Str "too",Space,Str "big."] ("media/image1.jpg","An unhappy fish.")]]
diff --git a/test/docx/image_no_embed_writer.native b/test/docx/image_no_embed_writer.native
new file mode 100644
index 000000000..91e7f6f2b
--- /dev/null
+++ b/test/docx/image_no_embed_writer.native
@@ -0,0 +1,2 @@
+[Para [Str "An",Space,Str "image:"]
+,Para [Image ("",[],[("width","0.4166666666666667in"),("height","0.4166666666666667in")]) [Str "He",Space,Str "realizes",Space,Str "he's",Space,Str "making",Space,Str "the",Space,Str "file-size",Space,Str "too",Space,Str "big."] ("media/rId25.jpg","An unhappy fish.")]]
diff --git a/test/docx/image_vml.docx b/test/docx/image_vml.docx
new file mode 100644
index 000000000..9e4018e00
--- /dev/null
+++ b/test/docx/image_vml.docx
Binary files differ
diff --git a/test/docx/image_vml.native b/test/docx/image_vml.native
new file mode 100644
index 000000000..e9fded614
--- /dev/null
+++ b/test/docx/image_vml.native
@@ -0,0 +1,4 @@
+[Header 1 ("vml-image",[],[]) [Strong [Str "VML",Space,Str "Image"]]
+,BlockQuote
+ [Para [Str "It",Space,Str "should",Space,Str "follow",Space,Str "below:"]
+ ,Para [Image ("",[],[]) [] ("media/image4.jpeg","")]]]
diff --git a/test/docx/inline_code.docx b/test/docx/inline_code.docx
new file mode 100644
index 000000000..75c5ea3cb
--- /dev/null
+++ b/test/docx/inline_code.docx
Binary files differ
diff --git a/test/docx/inline_code.native b/test/docx/inline_code.native
new file mode 100644
index 000000000..11cf2777c
--- /dev/null
+++ b/test/docx/inline_code.native
@@ -0,0 +1 @@
+[Para [Str "This",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "of",Space,Code ("",[],[]) "inline code",Space,Str "with",Space,Str "three",Space,Str "spaces."]]
diff --git a/test/docx/inline_formatting.docx b/test/docx/inline_formatting.docx
new file mode 100644
index 000000000..eccf26425
--- /dev/null
+++ b/test/docx/inline_formatting.docx
Binary files differ
diff --git a/test/docx/inline_formatting.native b/test/docx/inline_formatting.native
new file mode 100644
index 000000000..22d8f79e8
--- /dev/null
+++ b/test/docx/inline_formatting.native
@@ -0,0 +1,5 @@
+[Para [Str "Regular",Space,Str "text",Space,Emph [Str "italics"],Space,Strong [Str "bold",Space,Emph [Str "bold",Space,Str "italics"]],Str "."]
+,Para [Str "This",Space,Str "is",Space,SmallCaps [Str "Small",Space,Str "Caps"],Str ",",Space,Str "and",Space,Str "this",Space,Str "is",Space,Strikeout [Str "strikethrough"],Str "."]
+,Para [Str "Some",Space,Str "people",Space,Str "use",Space,Emph [Str "single",Space,Str "underlines",Space,Str "for",Space,Emph [Str "emphasis"]],Str "."]
+,Para [Str "Above",Space,Str "the",Space,Str "line",Space,Str "is",Space,Superscript [Str "superscript"],Space,Str "and",Space,Str "below",Space,Str "the",Space,Str "line",Space,Str "is",Space,Subscript [Str "subscript"],Str "."]
+,Para [Str "A",Space,Str "line",LineBreak,Str "break."]]
diff --git a/test/docx/inline_formatting_writer.native b/test/docx/inline_formatting_writer.native
new file mode 100644
index 000000000..be346204e
--- /dev/null
+++ b/test/docx/inline_formatting_writer.native
@@ -0,0 +1,5 @@
+[Para [Str "Regular",Space,Str "text",Space,Emph [Str "italics"],Space,Strong [Str "bold",Space,Emph [Str "bold",Space,Str "italics"]],Str "."]
+,Para [Str "This",Space,Str "is",Space,SmallCaps [Str "Small",Space,Str "Caps"],Str ",",Space,Str "and",Space,Str "this",Space,Str "is",Space,Strikeout [Str "strikethrough"],Str "."]
+,Para [Str "Some",Space,Str "people",Space,Str "use",Space,Emph [Str "single",Space,Str "underlines",Space,Str "for",Space,Str "emphasis"],Str "."]
+,Para [Str "Above",Space,Str "the",Space,Str "line",Space,Str "is",Space,Superscript [Str "superscript"],Space,Str "and",Space,Str "below",Space,Str "the",Space,Str "line",Space,Str "is",Space,Subscript [Str "subscript"],Str "."]
+,Para [Str "A",Space,Str "line",LineBreak,Str "break."]]
diff --git a/test/docx/inline_images.docx b/test/docx/inline_images.docx
new file mode 100644
index 000000000..2f01a251e
--- /dev/null
+++ b/test/docx/inline_images.docx
Binary files differ
diff --git a/test/docx/inline_images.native b/test/docx/inline_images.native
new file mode 100644
index 000000000..389ae5db6
--- /dev/null
+++ b/test/docx/inline_images.native
@@ -0,0 +1,2 @@
+[Para [Str "This",Space,Str "picture",Space,Image ("",[],[("width","0.8888888888888888in"),("height","0.8888888888888888in")]) [Str "This",Space,Str "one",Space,Str "is",Space,Str "green",Space,Str "and",Space,Str "looks",Space,Str "like",Space,Str "Sideshow",Space,Str "Bob."] ("media/image1.jpg","First identicon"),Space,Str "is",Space,Str "an",Space,Str "identicon."]
+,Para [Str "Here",Space,Str "is",Space,Link ("",[],[]) [Str "one",Space,Image ("",[],[("width","0.8888888888888888in"),("height","0.8888888888888888in")]) [Str "This",Space,Str "one",Space,Str "is",Space,Str "reddish,",Space,Str "and",Space,Str "looks",Space,Str "like",Space,Str "a",Space,Str "heart",Space,Str "that",Space,Str "has",Space,Str "leaked",Space,Str "out."] ("media/image2.jpg","Second identicon"),Space,Str "that"] ("http://www.google.com",""),Space,Str "links."]]
diff --git a/test/docx/inline_images_writer.native b/test/docx/inline_images_writer.native
new file mode 100644
index 000000000..e5dfa5b58
--- /dev/null
+++ b/test/docx/inline_images_writer.native
@@ -0,0 +1,2 @@
+[Para [Str "This",Space,Str "picture",Space,Image ("",[],[("width","0.4166666666666667in"),("height","0.4166666666666667in")]) [] ("media/rId26.jpg",""),Space,Str "is",Space,Str "an",Space,Str "identicon."]
+,Para [Str "Here",Space,Str "is",Space,Link ("",[],[]) [Str "one",Space,Image ("",[],[("width","0.4166666666666667in"),("height","0.4166666666666667in")]) [] ("media/rId26.jpg",""),Space,Str "that"] ("http://www.google.com",""),Space,Str "links."]]
diff --git a/test/docx/link_in_notes.docx b/test/docx/link_in_notes.docx
new file mode 100644
index 000000000..f3398f438
--- /dev/null
+++ b/test/docx/link_in_notes.docx
Binary files differ
diff --git a/test/docx/link_in_notes.native b/test/docx/link_in_notes.native
new file mode 100644
index 000000000..b20358698
--- /dev/null
+++ b/test/docx/link_in_notes.native
@@ -0,0 +1 @@
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "test",Note [Para [Link ("",[],[]) [Str "http://wikipedia.org/"] ("http://wikipedia.org/","")]],Str "."]]
diff --git a/test/docx/links.docx b/test/docx/links.docx
new file mode 100644
index 000000000..80fecacaf
--- /dev/null
+++ b/test/docx/links.docx
Binary files differ
diff --git a/test/docx/links.native b/test/docx/links.native
new file mode 100644
index 000000000..2c4688629
--- /dev/null
+++ b/test/docx/links.native
@@ -0,0 +1,7 @@
+[Header 2 ("an-internal-link-and-an-external-link",[],[]) [Str "An",Space,Str "internal",Space,Str "link",Space,Str "and",Space,Str "an",Space,Str "external",Space,Str "link"]
+,Para [Str "An",Space,Link ("",[],[]) [Str "external",Space,Str "link"] ("http://google.com",""),Space,Str "to",Space,Str "a",Space,Str "popular",Space,Str "website."]
+,Para [Str "An",Space,Link ("",[],[]) [Str "external",Space,Str "link"] ("http://pandoc.org/README.html#synopsis",""),Space,Str "to",Space,Str "a",Space,Str "website",Space,Str "with",Space,Str "an",Space,Str "anchor."]
+,Para [Str "An",Space,Link ("",[],[]) [Str "internal",Space,Str "link"] ("#a-section-for-testing-link-targets",""),Space,Str "to",Space,Str "a",Space,Str "section",Space,Str "header."]
+,Para [Str "An",Space,Link ("",[],[]) [Str "internal",Space,Str "link"] ("#my_bookmark",""),Space,Str "to",Space,Str "a",Space,Str "bookmark."]
+,Header 2 ("a-section-for-testing-link-targets",[],[]) [Str "A",Space,Str "section",Space,Str "for",Space,Str "testing",Space,Str "link",Space,Str "targets"]
+,Para [Str "A",Space,Str "bookmark",Space,Str "right",Space,Span ("my_bookmark",["anchor"],[]) [],Str "here"]]
diff --git a/test/docx/links_writer.native b/test/docx/links_writer.native
new file mode 100644
index 000000000..48c1bcd81
--- /dev/null
+++ b/test/docx/links_writer.native
@@ -0,0 +1,6 @@
+[Header 2 ("an-internal-link-and-an-external-link",[],[]) [Str "An",Space,Str "internal",Space,Str "link",Space,Str "and",Space,Str "an",Space,Str "external",Space,Str "link"]
+,Para [Str "An",Space,Link ("",[],[]) [Str "external",Space,Str "link"] ("http://google.com",""),Space,Str "to",Space,Str "a",Space,Str "popular",Space,Str "website."]
+,Para [Str "An",Space,Link ("",[],[]) [Str "external",Space,Str "link"] ("http://pandoc.org/README.html#synopsis",""),Space,Str "to",Space,Str "a",Space,Str "website",Space,Str "with",Space,Str "an",Space,Str "anchor."]
+,Para [Str "An",Space,Link ("",[],[]) [Str "internal",Space,Str "link"] ("#a-section-for-testing-link-targets",""),Space,Str "to",Space,Str "a",Space,Str "section",Space,Str "header."]
+,Para [Str "An",Space,Link ("",[],[]) [Str "internal",Space,Str "link"] ("#my_bookmark",""),Space,Str "to",Space,Str "a",Space,Str "bookmark."]
+,Header 2 ("a-section-for-testing-link-targets",[],[]) [Str "A",Space,Str "section",Space,Str "for",Space,Str "testing",Space,Str "link",Space,Str "targets"]]
diff --git a/test/docx/lists.docx b/test/docx/lists.docx
new file mode 100644
index 000000000..bf7fd8ae4
--- /dev/null
+++ b/test/docx/lists.docx
Binary files differ
diff --git a/test/docx/lists.native b/test/docx/lists.native
new file mode 100644
index 000000000..af922b335
--- /dev/null
+++ b/test/docx/lists.native
@@ -0,0 +1,18 @@
+[Header 2 ("some-nested-lists",[],[]) [Str "Some",Space,Str "nested",Space,Str "lists"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "one"]]
+ ,[Para [Str "two"]
+ ,OrderedList (1,LowerAlpha,DefaultDelim)
+ [[Para [Str "a"]]
+ ,[Para [Str "b"]]]]]
+,BulletList
+ [[Para [Str "one"]]
+ ,[Para [Str "two"]
+ ,BulletList
+ [[Para [Str "three"]
+ ,BulletList
+ [[Para [Str "four"]
+ ,Para [Str "Sub",Space,Str "paragraph"]]]]]]
+ ,[Para [Str "Same",Space,Str "list"]]]
+,BulletList
+ [[Para [Str "Different",Space,Str "list",Space,Str "adjacent",Space,Str "to",Space,Str "the",Space,Str "one",Space,Str "above."]]]]
diff --git a/test/docx/lists_writer.native b/test/docx/lists_writer.native
new file mode 100644
index 000000000..4c44ea603
--- /dev/null
+++ b/test/docx/lists_writer.native
@@ -0,0 +1,17 @@
+[Header 2 ("some-nested-lists",[],[]) [Str "Some",Space,Str "nested",Space,Str "lists"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "one"]]
+ ,[Para [Str "two"]
+ ,OrderedList (1,LowerAlpha,DefaultDelim)
+ [[Para [Str "a"]]
+ ,[Para [Str "b"]]]]]
+,BulletList
+ [[Para [Str "one"]]
+ ,[Para [Str "two"]
+ ,BulletList
+ [[Para [Str "three"]
+ ,BulletList
+ [[Para [Str "four"]]]]]]
+ ,[Para [Str "Same",Space,Str "list"]]]
+,BulletList
+ [[Para [Str "Different",Space,Str "list",Space,Str "adjacent",Space,Str "to",Space,Str "the",Space,Str "one",Space,Str "above."]]]]
diff --git a/test/docx/metadata.docx b/test/docx/metadata.docx
new file mode 100644
index 000000000..ccf50b475
--- /dev/null
+++ b/test/docx/metadata.docx
Binary files differ
diff --git a/test/docx/metadata.native b/test/docx/metadata.native
new file mode 100644
index 000000000..ed7ba63cf
--- /dev/null
+++ b/test/docx/metadata.native
@@ -0,0 +1,2 @@
+Pandoc (Meta {unMeta = fromList [("abstract",MetaInlines [Str "This",Space,Str "is",Space,Str "a",Space,Str "test",Space,Str "of",Space,Str "how",Space,Str "this",Space,Str "all",Space,Str "works.",Space,Str "I\8217ve",Space,Str "skipped",Space,Str "lines",Space,Str "here,",Space,Str "which",Space,Str "pandoc",Space,Str "doesn\8217t",Space,Str "do,",Space,Str "but",Space,Str "which",Space,Str "shouldn\8217t",Space,Str "make",Space,Str "a",Space,Str "difference."]),("author",MetaList [MetaInlines [Str "Mary",Space,Str "Ann",Space,Str "Evans"],MetaInlines [Str "Aurore",Space,Str "Dupin"]]),("date",MetaInlines [Str "July",Space,Str "28,",Space,Str "2014"]),("title",MetaInlines [Str "This",Space,Str "Is",Space,Str "the",Space,Str "Title"])]})
+[Para [Str "And",Space,Str "now",Space,Str "this",Space,Str "is",Space,Str "normal",Space,Str "text."]]
diff --git a/test/docx/metadata_after_normal.docx b/test/docx/metadata_after_normal.docx
new file mode 100644
index 000000000..b94a016cb
--- /dev/null
+++ b/test/docx/metadata_after_normal.docx
Binary files differ
diff --git a/test/docx/metadata_after_normal.native b/test/docx/metadata_after_normal.native
new file mode 100644
index 000000000..f0e31f8da
--- /dev/null
+++ b/test/docx/metadata_after_normal.native
@@ -0,0 +1,7 @@
+Pandoc (Meta {unMeta = fromList [("abstract",MetaInlines [Str "This",Space,Str "is",Space,Str "a",Space,Str "test",Space,Str "of",Space,Str "how",Space,Str "this",Space,Str "all",Space,Str "works.",Space,Str "I\8217ve",Space,Str "skipped",Space,Str "lines",Space,Str "here,",Space,Str "which",Space,Str "pandoc",Space,Str "doesn\8217t",Space,Str "do,",Space,Str "but",Space,Str "which",Space,Str "shouldn\8217t",Space,Str "make",Space,Str "a",Space,Str "difference."]),("author",MetaList [MetaInlines [Str "Mary",Space,Str "Ann",Space,Str "Evans"],MetaInlines [Str "Aurore",Space,Str "Dupin"]]),("date",MetaInlines [Str "July",Space,Str "28,",Space,Str "2014"]),("title",MetaInlines [Str "This",Space,Str "Is",Space,Str "the",Space,Str "Title"])]})
+[Para [Str "And",Space,Str "now",Space,Str "this",Space,Str "is",Space,Str "normal",Space,Str "text."]
+,Para [Str "This",Space,Str "Is",Space,Str "the",Space,Str "Title"]
+,Para [Str "Mary",Space,Str "Ann",Space,Str "Evans"]
+,Para [Str "Aurore",Space,Str "Dupin"]
+,Para [Str "July",Space,Str "28,",Space,Str "2014"]
+,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "test",Space,Str "of",Space,Str "how",Space,Str "this",Space,Str "all",Space,Str "works.",Space,Str "I\8217ve",Space,Str "skipped",Space,Str "lines",Space,Str "here,",Space,Str "which",Space,Str "pandoc",Space,Str "doesn\8217t",Space,Str "do,",Space,Str "but",Space,Str "which",Space,Str "shouldn\8217t",Space,Str "make",Space,Str "a",Space,Str "difference."]]
diff --git a/test/docx/nested_anchors_in_header.docx b/test/docx/nested_anchors_in_header.docx
new file mode 100644
index 000000000..ddebb7ff4
--- /dev/null
+++ b/test/docx/nested_anchors_in_header.docx
Binary files differ
diff --git a/test/docx/nested_anchors_in_header.native b/test/docx/nested_anchors_in_header.native
new file mode 100644
index 000000000..e2b6eb1ef
--- /dev/null
+++ b/test/docx/nested_anchors_in_header.native
@@ -0,0 +1,10 @@
+[Header 1 ("short-instructions",[],[]) [Str "Short",Space,Str "instructions"]
+,Para [Link ("",[],[]) [Str "Open",Space,Str "remote",Space,Str "folder"] ("#remote-folder-or-longlonglonglonglong-file-with-manymanymanymany-letters-inside-opening","")]
+,Para [Str "Do",Space,Str "staff"]
+,Para [Link ("",[],[]) [Str "Close",Space,Str "remote",Space,Str "folder"] ("#remote-folder-or-longlonglonglonglong-file-with-manymanymanymany-letters-inside-closing","")]
+,Header 1 ("some-instructions",[],[]) [Str "Some",Space,Str "instructions"]
+,Para [Str "Lines"]
+,Header 2 ("remote-folder-or-longlonglonglonglong-file-with-manymanymanymany-letters-inside-opening",[],[]) [Str "Remote",Space,Str "folder",Space,Str "or",Space,Str "longlonglonglonglong",Space,Str "file",Space,Str "with",Space,Str "manymanymanymany",Space,Str "letters",Space,Str "inside",Space,Str "opening"]
+,Para [Str "Open",Space,Str "folder"]
+,Header 2 ("remote-folder-or-longlonglonglonglong-file-with-manymanymanymany-letters-inside-closing",[],[]) [Str "Remote",Space,Str "folder",Space,Str "or",Space,Str "longlonglonglonglong",Space,Str "file",Space,Str "with",Space,Str "manymanymanymany",Space,Str "letters",Space,Str "inside",Space,Str "closing"]
+,Para [Str "Close",Space,Str "folder"]]
diff --git a/test/docx/normalize.docx b/test/docx/normalize.docx
new file mode 100644
index 000000000..b4fc55818
--- /dev/null
+++ b/test/docx/normalize.docx
Binary files differ
diff --git a/test/docx/normalize.native b/test/docx/normalize.native
new file mode 100644
index 000000000..aeba672c4
--- /dev/null
+++ b/test/docx/normalize.native
@@ -0,0 +1,2 @@
+[Para [Str "These",Space,Str "are",Space,Str "different",Space,Str "fonts."]
+,Para [Strong [Str "These",Space,Emph [Str "are",Space,Strikeout [Str "different"]],Space,Str "fonts."]]]
diff --git a/test/docx/notes.docx b/test/docx/notes.docx
new file mode 100644
index 000000000..eb6fa12d4
--- /dev/null
+++ b/test/docx/notes.docx
Binary files differ
diff --git a/test/docx/notes.native b/test/docx/notes.native
new file mode 100644
index 000000000..ec1b414b6
--- /dev/null
+++ b/test/docx/notes.native
@@ -0,0 +1,2 @@
+[Header 2 ("a-footnote",[],[]) [Str "A",Space,Str "footnote"]
+,Para [Str "Test",Space,Str "footnote.",Note [Para [Str "My",Space,Str "note."]],Space,Str "Test",Space,Str "endnote.",Note [Para [Str "This",Space,Str "is",Space,Str "an",Space,Str "endnote",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."]]]]
diff --git a/test/docx/numbered_header.docx b/test/docx/numbered_header.docx
new file mode 100644
index 000000000..66ce7648d
--- /dev/null
+++ b/test/docx/numbered_header.docx
Binary files differ
diff --git a/test/docx/numbered_header.native b/test/docx/numbered_header.native
new file mode 100644
index 000000000..a8dd1e897
--- /dev/null
+++ b/test/docx/numbered_header.native
@@ -0,0 +1 @@
+[Header 1 ("a-numbered-header.",[],[]) [Str "A",Space,Str "Numbered",Space,Str "Header."]]
diff --git a/test/docx/special_punctuation.docx b/test/docx/special_punctuation.docx
new file mode 100644
index 000000000..8e0bb55c9
--- /dev/null
+++ b/test/docx/special_punctuation.docx
Binary files differ
diff --git a/test/docx/special_punctuation.native b/test/docx/special_punctuation.native
new file mode 100644
index 000000000..304289f44
--- /dev/null
+++ b/test/docx/special_punctuation.native
@@ -0,0 +1,2 @@
+[Para [Str "Soft",Space,Str "hyphen:",Space,Str "[\173]"]
+,Para [Str "Non-breaking",Space,Str "hyphen:",Space,Str "[\8209]"]]
diff --git a/test/docx/table_one_row.docx b/test/docx/table_one_row.docx
new file mode 100644
index 000000000..f7e0ebe43
--- /dev/null
+++ b/test/docx/table_one_row.docx
Binary files differ
diff --git a/test/docx/table_one_row.native b/test/docx/table_one_row.native
new file mode 100644
index 000000000..1ea1b446c
--- /dev/null
+++ b/test/docx/table_one_row.native
@@ -0,0 +1,7 @@
+[Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "One"]]
+ ,[Plain [Str "Row"]]
+ ,[Plain [Str "Table"]]]]]
diff --git a/test/docx/table_with_list_cell.docx b/test/docx/table_with_list_cell.docx
new file mode 100644
index 000000000..1db065770
--- /dev/null
+++ b/test/docx/table_with_list_cell.docx
Binary files differ
diff --git a/test/docx/table_with_list_cell.native b/test/docx/table_with_list_cell.native
new file mode 100644
index 000000000..81bb15a1e
--- /dev/null
+++ b/test/docx/table_with_list_cell.native
@@ -0,0 +1,11 @@
+[Table [] [AlignDefault,AlignDefault] [0.0,0.0]
+ [[Plain [Str "Cell",Space,Str "with",Space,Str "text"]]
+ ,[Plain [Str "Cell",Space,Str "with",Space,Str "text"]]]
+ [[[BulletList
+ [[Para [Str "Cell",Space,Str "with"]]
+ ,[Para [Str "A"]]
+ ,[Para [Str "Bullet",Space,Str "list"]]]]
+ ,[OrderedList (1,Decimal,Period)
+ [[Para [Str "Cell",Space,Str "with"]]
+ ,[Para [Str "A"]]
+ ,[Para [Str "Numbered",Space,Str "list."]]]]]]]
diff --git a/test/docx/tables.docx b/test/docx/tables.docx
new file mode 100644
index 000000000..28087ead5
--- /dev/null
+++ b/test/docx/tables.docx
Binary files differ
diff --git a/test/docx/tables.native b/test/docx/tables.native
new file mode 100644
index 000000000..ae326950a
--- /dev/null
+++ b/test/docx/tables.native
@@ -0,0 +1,36 @@
+[Header 2 ("a-table-with-and-without-a-header-row",[],[]) [Str "A",Space,Str "table,",Space,Str "with",Space,Str "and",Space,Str "without",Space,Str "a",Space,Str "header",Space,Str "row"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0,0.0]
+ [[Plain [Str "Name"]]
+ ,[Plain [Str "Game"]]
+ ,[Plain [Str "Fame"]]
+ ,[Plain [Str "Blame"]]]
+ [[[Plain [Str "Lebron",Space,Str "James"]]
+ ,[Plain [Str "Basketball"]]
+ ,[Plain [Str "Very",Space,Str "High"]]
+ ,[Plain [Str "Leaving",Space,Str "Cleveland"]]]
+ ,[[Plain [Str "Ryan",Space,Str "Braun"]]
+ ,[Plain [Str "Baseball"]]
+ ,[Plain [Str "Moderate"]]
+ ,[Plain [Str "Steroids"]]]
+ ,[[Plain [Str "Russell",Space,Str "Wilson"]]
+ ,[Plain [Str "Football"]]
+ ,[Plain [Str "High"]]
+ ,[Plain [Str "Tacky",Space,Str "uniform"]]]]
+,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
+ [[]
+ ,[]]
+ [[[Plain [Str "Sinple"]]
+ ,[Plain [Str "Table"]]]
+ ,[[Plain [Str "Without"]]
+ ,[Plain [Str "Header"]]]]
+,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
+ [[]
+ ,[]]
+ [[[Para [Str "Simple"]
+ ,Para [Str "Multiparagraph"]]
+ ,[Para [Str "Table"]
+ ,Para [Str "Full"]]]
+ ,[[Para [Str "Of"]
+ ,Para [Str "Paragraphs"]]
+ ,[Para [Str "In",Space,Str "each"]
+ ,Para [Str "Cell."]]]]]
diff --git a/test/docx/tabs.docx b/test/docx/tabs.docx
new file mode 100644
index 000000000..6ff5f4bb1
--- /dev/null
+++ b/test/docx/tabs.docx
Binary files differ
diff --git a/test/docx/tabs.native b/test/docx/tabs.native
new file mode 100644
index 000000000..05461f20b
--- /dev/null
+++ b/test/docx/tabs.native
@@ -0,0 +1,2 @@
+[Para [Str "Some",Space,Str "text",Space,Str "separated",Space,Str "by",Space,Str "a",Space,Str "tab."]
+,Para [Str "Tab-indented",Space,Str "text."]]
diff --git a/test/docx/track_changes_deletion.docx b/test/docx/track_changes_deletion.docx
new file mode 100644
index 000000000..5cfdbeed8
--- /dev/null
+++ b/test/docx/track_changes_deletion.docx
Binary files differ
diff --git a/test/docx/track_changes_deletion_accept.native b/test/docx/track_changes_deletion_accept.native
new file mode 100644
index 000000000..205c67810
--- /dev/null
+++ b/test/docx/track_changes_deletion_accept.native
@@ -0,0 +1 @@
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "text",Space,Str "with",Space,Str "a",Space,Str "deletion."]]
diff --git a/test/docx/track_changes_deletion_all.native b/test/docx/track_changes_deletion_all.native
new file mode 100644
index 000000000..7f4ed2a90
--- /dev/null
+++ b/test/docx/track_changes_deletion_all.native
@@ -0,0 +1 @@
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "text",Space,Str "with",Space,Str "a",Span ("",["deletion"],[("author","eng-dept"),("date","2014-06-25T10:42:00Z")]) [Str "n",Space,Str "excessively",Space,Str "modified"],Space,Str "deletion."]]
diff --git a/test/docx/track_changes_deletion_reject.native b/test/docx/track_changes_deletion_reject.native
new file mode 100644
index 000000000..04283bee5
--- /dev/null
+++ b/test/docx/track_changes_deletion_reject.native
@@ -0,0 +1 @@
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "text",Space,Str "with",Space,Str "an",Space,Str "excessively",Space,Str "modified",Space,Str "deletion."]]
diff --git a/test/docx/track_changes_insertion.docx b/test/docx/track_changes_insertion.docx
new file mode 100644
index 000000000..fbdc9003e
--- /dev/null
+++ b/test/docx/track_changes_insertion.docx
Binary files differ
diff --git a/test/docx/track_changes_insertion_accept.native b/test/docx/track_changes_insertion_accept.native
new file mode 100644
index 000000000..ca2e46df0
--- /dev/null
+++ b/test/docx/track_changes_insertion_accept.native
@@ -0,0 +1 @@
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "text",Space,Str "with",Space,Str "two",Space,Str "exciting",Space,Str "insertions."]]
diff --git a/test/docx/track_changes_insertion_all.native b/test/docx/track_changes_insertion_all.native
new file mode 100644
index 000000000..12664e425
--- /dev/null
+++ b/test/docx/track_changes_insertion_all.native
@@ -0,0 +1 @@
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "text",Space,Str "with",Space,Span ("",["insertion"],[("author","eng-dept"),("date","2014-06-25T10:40:00Z")]) [Str "two",Space,Str "exciting"],Space,Str "insertions."]]
diff --git a/test/docx/track_changes_insertion_reject.native b/test/docx/track_changes_insertion_reject.native
new file mode 100644
index 000000000..def000abd
--- /dev/null
+++ b/test/docx/track_changes_insertion_reject.native
@@ -0,0 +1 @@
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "text",Space,Str "with",Space,Str "insertions."]]
diff --git a/test/docx/track_changes_move.docx b/test/docx/track_changes_move.docx
new file mode 100644
index 000000000..b70779fd4
--- /dev/null
+++ b/test/docx/track_changes_move.docx
Binary files differ
diff --git a/test/docx/track_changes_move_accept.native b/test/docx/track_changes_move_accept.native
new file mode 100644
index 000000000..0cf276768
--- /dev/null
+++ b/test/docx/track_changes_move_accept.native
@@ -0,0 +1,3 @@
+[Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "text."]
+,Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "text",Space,Str "to",Space,Str "be",Space,Str "moved."]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "more",Space,Str "text."]]
diff --git a/test/docx/track_changes_move_all.native b/test/docx/track_changes_move_all.native
new file mode 100644
index 000000000..3afae83a5
--- /dev/null
+++ b/test/docx/track_changes_move_all.native
@@ -0,0 +1,4 @@
+[Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "text."]
+,Para [Span ("",["insertion"],[("author","Jesse Rosenthal"),("date","2016-04-16T08:20:00Z")]) [Str "Here",Space,Str "is",Space,Str "the",Space,Str "text",Space,Str "to",Space,Str "be",Space,Str "moved."]]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "more",Space,Str "text."]
+,Para [Span ("",["deletion"],[("author","Jesse Rosenthal"),("date","2016-04-16T08:20:00Z")]) [Str "Here",Space,Str "is",Space,Str "the",Space,Str "text",Space,Str "to",Space,Str "be",Space,Str "moved."]]]
diff --git a/test/docx/track_changes_move_reject.native b/test/docx/track_changes_move_reject.native
new file mode 100644
index 000000000..9c57871b6
--- /dev/null
+++ b/test/docx/track_changes_move_reject.native
@@ -0,0 +1,3 @@
+[Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "text."]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "more",Space,Str "text."]
+,Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "text",Space,Str "to",Space,Str "be",Space,Str "moved."]]
diff --git a/test/docx/trailing_spaces_in_formatting.docx b/test/docx/trailing_spaces_in_formatting.docx
new file mode 100644
index 000000000..ebe7404a9
--- /dev/null
+++ b/test/docx/trailing_spaces_in_formatting.docx
Binary files differ
diff --git a/test/docx/trailing_spaces_in_formatting.native b/test/docx/trailing_spaces_in_formatting.native
new file mode 100644
index 000000000..46ea9bca8
--- /dev/null
+++ b/test/docx/trailing_spaces_in_formatting.native
@@ -0,0 +1 @@
+[Para [Str "Turn",Space,Str "my",Space,Emph [Str "formatting"],Space,Str "off",Space,Str "after",Space,Str "the",Space,Str "spaces."]]
diff --git a/test/docx/unicode.docx b/test/docx/unicode.docx
new file mode 100644
index 000000000..cf902c6c6
--- /dev/null
+++ b/test/docx/unicode.docx
Binary files differ
diff --git a/test/docx/unicode.native b/test/docx/unicode.native
new file mode 100644
index 000000000..aee7ef74b
--- /dev/null
+++ b/test/docx/unicode.native
@@ -0,0 +1 @@
+[Para [Str "Hello,",Space,Str "\19990\30028.",Space,Str "This",Space,Str "costs",Space,Str "\8364\&10.\8744\8744("]]
diff --git a/test/docx/verbatim_subsuper.docx b/test/docx/verbatim_subsuper.docx
new file mode 100644
index 000000000..2cb0dc16d
--- /dev/null
+++ b/test/docx/verbatim_subsuper.docx
Binary files differ
diff --git a/test/docx/verbatim_subsuper.native b/test/docx/verbatim_subsuper.native
new file mode 100644
index 000000000..2e11e646a
--- /dev/null
+++ b/test/docx/verbatim_subsuper.native
@@ -0,0 +1,8 @@
+[Para [Str "m",Superscript [Str "2"]]
+,Para [Str "m",Superscript [Code ("",[],[]) "2"]]
+,Para [Code ("",[],[]) "m",Superscript [Str "2"]]
+,Para [Code ("",[],[]) "m",Superscript [Code ("",[],[]) "2"]]
+,Para [Str "m",Subscript [Str "2"]]
+,Para [Str "m",Subscript [Code ("",[],[]) "2"]]
+,Para [Code ("",[],[]) "m",Subscript [Str "2"]]
+,Para [Code ("",[],[]) "m",Subscript [Code ("",[],[]) "2"]]]
diff --git a/test/dokuwiki_external_images.dokuwiki b/test/dokuwiki_external_images.dokuwiki
new file mode 100644
index 000000000..cc7eddcda
--- /dev/null
+++ b/test/dokuwiki_external_images.dokuwiki
@@ -0,0 +1 @@
+{{https://cooluri.com/image.png|HTTPS image}} {{http://cooluri.com/image.png|HTTP image}} {{ftp://ftp.cooluri.com/image.png|FTP image}} {{file:///tmp/coolimage.png|Filesystem image}} {{:/image.jpg|Relative image 1}} {{:image.jpg|Relative image 2}}
diff --git a/test/dokuwiki_external_images.native b/test/dokuwiki_external_images.native
new file mode 100644
index 000000000..0f103461e
--- /dev/null
+++ b/test/dokuwiki_external_images.native
@@ -0,0 +1 @@
+[Para [Image ("",[],[]) [Str "HTTPS",Space,Str "image"] ("https://cooluri.com/image.png",""),Space,Image ("",[],[]) [Str "HTTP",Space,Str "image"] ("http://cooluri.com/image.png",""),Space,Image ("",[],[]) [Str "FTP",Space,Str "image"] ("ftp://ftp.cooluri.com/image.png",""),Space,Image ("",[],[]) [Str "Filesystem",Space,Str "image"] ("file:///tmp/coolimage.png",""),Space,Image ("",[],[]) [Str "Relative",Space,Str "image",Space,Str "1"] ("/image.jpg",""),Space,Image ("",[],[]) [Str "Relative",Space,Str "image",Space,Str "2"] ("image.jpg","")]]
diff --git a/test/dokuwiki_inline_formatting.dokuwiki b/test/dokuwiki_inline_formatting.dokuwiki
new file mode 100644
index 000000000..262094184
--- /dev/null
+++ b/test/dokuwiki_inline_formatting.dokuwiki
@@ -0,0 +1,14 @@
+Regular text //italics// **bold //bold italics//**.
+
+This is Small Caps, and this is <del>strikethrough</del>.
+
+Some people use single underlines for //emphasis//.
+
+Above the line is <sup>superscript</sup> and below the line is <sub>subscript</sub>.
+
+A line\\
+break.
+
+hello %%//%% world %%**%% from %%__%% me
+
+''%%hello // world ** from __ me%%''
diff --git a/test/dokuwiki_inline_formatting.native b/test/dokuwiki_inline_formatting.native
new file mode 100644
index 000000000..63e85889f
--- /dev/null
+++ b/test/dokuwiki_inline_formatting.native
@@ -0,0 +1,7 @@
+[Para [Str "Regular",Space,Str "text",Space,Emph [Str "italics"],Space,Strong [Str "bold",Space,Emph [Str "bold",Space,Str "italics"]],Str "."]
+,Para [Str "This",Space,Str "is",Space,SmallCaps [Str "Small",Space,Str "Caps"],Str ",",Space,Str "and",Space,Str "this",Space,Str "is",Space,Strikeout [Str "strikethrough"],Str "."]
+,Para [Str "Some",Space,Str "people",Space,Str "use",Space,Span ("",[],[("underline","single")]) [Str "single",Space,Str "underlines",Space,Str "for",Space,Emph [Str "emphasis"]],Str "."]
+,Para [Str "Above",Space,Str "the",Space,Str "line",Space,Str "is",Space,Superscript [Str "superscript"],Space,Str "and",Space,Str "below",Space,Str "the",Space,Str "line",Space,Str "is",Space,Subscript [Str "subscript"],Str "."]
+,Para [Str "A",Space,Str "line",LineBreak,Str "break."]
+,Para [Str "hello",Space,Str "//",Space,Str "world",Space,Str "**",Space,Str "from",Space,Str "__",Space,Str "me"]
+,Para [Code ("",[],[]) "hello // world ** from __ me"]]
diff --git a/test/dokuwiki_multiblock_table.dokuwiki b/test/dokuwiki_multiblock_table.dokuwiki
new file mode 100644
index 000000000..8b913f1f2
--- /dev/null
+++ b/test/dokuwiki_multiblock_table.dokuwiki
@@ -0,0 +1,4 @@
+Sample grid table.
+^Fruit ^Price^Advantages ^
+|Bananas|$1.34|built-in wrapper\\ \\ potassium|
+|Oranges|$2.10|* cures scurvy\\ * tasty |
diff --git a/test/dokuwiki_multiblock_table.native b/test/dokuwiki_multiblock_table.native
new file mode 100644
index 000000000..34824296d
--- /dev/null
+++ b/test/dokuwiki_multiblock_table.native
@@ -0,0 +1,13 @@
+[Table [Str "Sample",Space,Str "grid",Space,Str "table."] [AlignDefault,AlignDefault,AlignDefault] [0.2222222222222222,0.2222222222222222,0.2916666666666667]
+ [[Plain [Str "Fruit"]]
+ ,[Plain [Str "Price"]]
+ ,[Plain [Str "Advantages"]]]
+ [[[Para [Str "Bananas"]]
+ ,[Para [Str "$1.34"]]
+ ,[Para [Str "built-in",Space,Str "wrapper"]
+ ,Para [Str "potassium"]]]
+ ,[[Para [Str "Oranges"]]
+ ,[Para [Str "$2.10"]]
+ ,[BulletList
+ [[Plain [Str "cures",Space,Str "scurvy"]]
+ ,[Plain [Str "tasty"]]]]]]]
diff --git a/test/epub/features.epub b/test/epub/features.epub
new file mode 100644
index 000000000..2690eec8b
--- /dev/null
+++ b/test/epub/features.epub
Binary files differ
diff --git a/test/epub/features.native b/test/epub/features.native
new file mode 100644
index 000000000..60f3a58ba
--- /dev/null
+++ b/test/epub/features.native
@@ -0,0 +1,93 @@
+[Para [Span ("front.xhtml",[],[]) []]
+,Div ("",["section"],[])
+ [Header 1 ("",[],[]) [Str "Reflowable",Space,Str "EPUB",Space,Str "3",Space,Str "Conformance",Space,Str "Test",Space,Str "Document:",Space,Str "0100"]
+ ,Div ("",["section"],[])
+ [Header 2 ("",[],[]) [Str "Status",Space,Str "of",Space,Str "this",Space,Str "Document"]
+ ,Para [Str "This",Space,Str "publication",Space,Str "is",Space,Str "currently",Space,Str "considered",Space,Span ("",["status"],[]) [Str "[UNDER",Space,Str "DEVELOPMENT]"],Space,Str "by",Space,Str "the",Space,Str "IDPF."]
+ ,Para [Str "This",Space,Str "publication",Space,Str "is",Space,Str "part",Space,Str "of",Space,Str "version",Space,Span ("",["version"],[]) [Str "X.X"],Space,Str "of",Space,Str "the",Space,Str "EPUB",Space,Str "3.0",Space,Str "Compliance",Space,Str "Test",Space,Str "Suite",Space,Str "released",SoftBreak,Str "on",Space,RawInline (Format "html") "<time class=\"release\">",Str "TBD",RawInline (Format "html") "</time>",Str "."]
+ ,Para [Str "Before",Space,Str "using",Space,Str "this",Space,Str "publication",Space,Str "to",Space,Str "evaluate",Space,Str "reading",Space,Str "systems,",Space,Str "testers",Space,Str "are",Space,Str "strongly",Space,Str "encouraged",Space,Str "to",SoftBreak,Str "verify",Space,Str "that",Space,Str "they",Space,Str "have",Space,Str "the",Space,Str "latest",Space,Str "release",Space,Str "by",Space,Str "checking",Space,Str "the",Space,Str "current",Space,Str "release",Space,Str "version",Space,Str "and",Space,Str "date",Space,Str "of",SoftBreak,Str "the",Space,Str "test",Space,Str "suite",Space,Str "at",Space,Link ("",[],[]) [Str "TBD"] ("http://idpf.org/","")]
+ ,Para [Str "This",Space,Str "publication",Space,Str "is",Space,Str "one",Space,Str "of",Space,Str "several",Space,Str "that",Space,Str "currently",Space,Str "comprise",Space,Str "the",Space,Str "EPUB",Space,Str "3",Space,Str "conformance",Space,Str "test",Space,Str "suite",SoftBreak,Str "for",Space,Str "reflowable",Space,Str "content.",Space,Str "The",Space,Str "complete",Space,Str "test",Space,Str "suite",Space,Str "includes",Space,Str "all",Space,Str "of",Space,Str "the",Space,Str "following",Space,Str "publications:"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "."]]]]
+ ,Div ("",["section"],[])
+ [Header 2 ("",[],[]) [Str "About",Space,Str "this",Space,Str "Document"]
+ ,Para [Str "This",Space,Str "document",Space,Str "focuses",Space,Str "on",Space,Str "human-evaluated",Space,Str "binary",Space,Str "(pass/fail)",Space,Str "tests",Space,Str "in",Space,Str "a",SoftBreak,Str "reflowable",Space,Str "context.",Space,Str "Tests",Space,Str "for",Space,Str "fixed-layout",Space,Str "content",Space,Str "and",Space,Str "other",Space,Str "individual",Space,Str "tests",Space,Str "that",SoftBreak,Str "require",Space,Str "a",Space,Str "dedicated",Space,Str "epub",Space,Str "file",Space,Str "are",Space,Str "available",Space,Str "in",Space,Str "additional",Space,Str "sibling",Space,Str "documents;",Space,Str "refer",Space,Str "to",SoftBreak,Str "the",Space,Link ("",[],[]) [Str "test",Space,Str "suite",SoftBreak,Str "wiki"] ("https://github.com/mgylling/epub-testsuite/wiki/Overview",""),Space,Str "(",Code ("",[],[]) "https://github.com/mgylling/epub-testsuite/wiki/Overview",Str ")",Space,Str "for",Space,Str "additional",SoftBreak,Str "information."]]
+ ,Div ("",["section"],[])
+ [Header 2 ("",[],[]) [Str "Conventions"]
+ ,Para [Str "The",Space,Str "following",Space,Str "conventions",Space,Str "are",Space,Str "used",Space,Str "throughout",Space,Str "the",Space,Str "document:"]
+ ,DefinitionList
+ [([Str "1.",Space,Str "Locating",Space,Str "a",Space,Str "test"],
+ [[Div ("",["ctest"],[])
+ [Para [Str "Tests",Space,Str "for",Space,Emph [Str "required"],Space,Str "Reading",Space,Str "System",Space,Str "functionality",Space,Str "are",SoftBreak,Str "preceded",Space,Str "by",Space,Str "the",Space,Str "label:",Space,Span ("",["nature"],[("style","display: inline; font-size: 100%")]) [Str "[REQUIRED]"]]]
+ ,Div ("",["otest"],[])
+ [Para [Str "Tests",Space,Str "for",Space,Emph [Str "optional"],Space,Str "Reading",Space,Str "System",Space,Str "functionality",Space,Str "are",SoftBreak,Str "preceded",Space,Str "by",Space,Str "the",Space,Str "label:",Space,Span ("",["nature"],[("style","display: inline; font-size: 100%")]) [Str "[OPTIONAL]"]]]]])
+ ,([Str "2.",Space,Str "Performing",Space,Str "the",Space,Str "test"],
+ [[Plain [Str "Each",Space,Str "test",Space,Str "includes",Space,Str "a",Space,Str "description",Space,Str "of",Space,Str "its",Space,Str "purpose",Space,Str "followed",Space,Str "by",Space,Str "the",Space,Str "actual",Space,Strong [Str "test",Space,Str "statement,",SoftBreak,Str "which",Space,Str "can",Space,Str "always",Space,Str "be",Space,Str "evaluated",Space,Str "to",Space,Str "true",Space,Str "or",Space,Str "false"],Str ".",Space,Str "These",Space,Str "statements",Space,Str "typically",Space,Str "have",Space,Str "the",Space,Str "form:",SoftBreak,Str "\"If",Space,Str "[some",Space,Str "condition],",Space,Str "the",Space,Str "test",Space,Str "passes\"."]]])
+ ,([Str "3.",Space,Str "Scoring",Space,Str "in",Space,Str "the",Space,Str "results",Space,Str "form"],
+ [[Plain [Str "@@@TODO",Space,Str "provide",Space,Str "info",Space,Str "on",Space,Str "where",Space,Str "to",Space,Str "get",Space,Str "the",Space,Str "results",Space,Str "form"]]])]]]
+,Para [Span ("content-mathml-001.xhtml",[],[]) []]
+,Div ("",["section"],[])
+ [Header 2 ("content-mathml-001.xhtml#mathml",[],[]) [Str "MathML"]
+ ,Div ("content-mathml-001.xhtml#mathml-010",["section","ctest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],SoftBreak,Span ("",["test-id"],[]) [Str "mathml-010"],Space,Str "Rendering"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "MathML",Space,Str "equation",Space,Str "rendering",Space,Str "is",Space,Str "supported."]
+ ,Plain [Math DisplayMath "\\int_{- \\infty}^{\\infty}e^{- x^{2}}\\, dx = \\sqrt{\\pi}",SoftBreak,Math DisplayMath "\\sum\\limits_{n = 1}^{\\infty}\\frac{1}{n^{2}} = \\frac{\\pi^{2}}{6}",SoftBreak,Math DisplayMath "x = \\frac{- b \\pm \\sqrt{b^{2} - 4ac}}{2a}"]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "equations",Space,Str "are",Space,Str "not",Space,Str "presented",Space,Str "as",Space,Str "linear",Space,Str "text",Space,Str "(e.g.,",Space,Str "x=-b\177b2-4ac2a),",SoftBreak,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("content-mathml-001.xhtml#mathml-020",["section","otest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[OPTIONAL]"],SoftBreak,Span ("",["test-id"],[]) [Str "mathml-020"],Space,Str "CSS",Space,Str "Styling",Space,Str "of",Space,Str "the",Space,Code ("",[],[]) "math",Space,Str "element"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "basic",Space,Str "CSS",Space,Str "styling",Space,Str "of",Space,Str "MathML",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "the",Space,Code ("",[],[]) "math",Space,Str "element."]
+ ,Plain [Math InlineMath "{2x}{+ y - z}"]
+ ,Para [Str "The",Space,Str "test",Space,Str "passes",Space,Str "if",Space,Str "the",Space,Str "equation",Space,Str "has",Space,Str "a",Space,Str "yellow",Space,Str "background",Space,Str "and",Space,Str "a",Space,Str "dashed",Space,Str "border."]
+ ,Para [Str "If",Space,Str "the",Space,Str "reading",Space,Str "system",Space,Str "does",Space,Str "not",Space,Str "have",Space,Str "a",Space,Str "viewport,",Space,Str "or",Space,Str "does",Space,Str "not",Space,Str "support",SoftBreak,Str "CSS",Space,Str "styles,",Space,Str "this",Space,Str "test",Space,Str "should",Space,Str "be",Space,Str "marked",Space,Code ("",[],[]) "Not Supported",Str "."]]
+ ,Div ("content-mathml-001.xhtml#mathml-021",["section","otest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[OPTIONAL]"],SoftBreak,Span ("",["test-id"],[]) [Str "mathml-021"],Space,Str "CSS",Space,Str "Styling",Space,Str "of",Space,Str "the",Space,Code ("",[],[]) "mo",Space,Str "element"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "basic",Space,Str "CSS",Space,Str "styling",Space,Str "of",Space,Str "MathML",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "the",Space,Code ("",[],[]) "mo",Space,Str "element."]
+ ,Plain [Math InlineMath "{2x}{+ y - z}"]
+ ,Para [Str "The",Space,Str "test",Space,Str "passes",Space,Str "if",Space,Str "the",Space,Str "operators",Space,Str "are",Space,Str "enlarged",Space,Str "relative",Space,Str "to",Space,Str "the",Space,Str "other",Space,Str "symbols",Space,Str "and",Space,Str "numbers."]
+ ,Para [Str "If",Space,Str "the",Space,Str "reading",Space,Str "system",Space,Str "does",Space,Str "not",Space,Str "have",Space,Str "a",Space,Str "viewport,",Space,Str "or",Space,Str "does",Space,Str "not",Space,Str "support",SoftBreak,Str "CSS",Space,Str "styles,",Space,Str "this",Space,Str "test",Space,Str "should",Space,Str "be",Space,Str "marked",Space,Code ("",[],[]) "Not Supported",Str "."]]
+ ,Div ("content-mathml-001.xhtml#mathml-022",["section","otest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[OPTIONAL]"],SoftBreak,Span ("",["test-id"],[]) [Str "mathml-022"],Space,Str "CSS",Space,Str "Styling",Space,Str "of",Space,Str "the",Space,Code ("",[],[]) "mi",Space,Str "element"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "basic",Space,Str "CSS",Space,Str "styling",Space,Str "of",Space,Str "MathML",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "the",Space,Code ("",[],[]) "mi",Space,Str "element."]
+ ,Plain [Math InlineMath "{2x}{+ y - z}"]
+ ,Para [Str "The",Space,Str "test",Space,Str "passes",Space,Str "if",Space,Str "the",Space,Str "identifiers",Space,Str "are",Space,Str "bolded",Space,Str "and",Space,Str "blue."]
+ ,Para [Str "If",Space,Str "the",Space,Str "reading",Space,Str "system",Space,Str "does",Space,Str "not",Space,Str "have",Space,Str "a",Space,Str "viewport,",Space,Str "or",Space,Str "does",Space,Str "not",Space,Str "support",SoftBreak,Str "CSS",Space,Str "styles,",Space,Str "this",Space,Str "test",Space,Str "should",Space,Str "be",Space,Str "marked",Space,Code ("",[],[]) "Not Supported",Str "."]]
+ ,Div ("content-mathml-001.xhtml#mathml-023",["section","otest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[OPTIONAL]"],SoftBreak,Span ("",["test-id"],[]) [Str "mathml-023"],Space,Str "CSS",Space,Str "Styling",Space,Str "of",Space,Str "the",Space,Code ("",[],[]) "mn",Space,Str "element"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "basic",Space,Str "CSS",Space,Str "styling",Space,Str "of",Space,Str "MathML",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "the",Space,Code ("",[],[]) "mn",Space,Str "element."]
+ ,Plain [Math InlineMath "{2x}{+ y - z}"]
+ ,Para [Str "The",Space,Str "test",Space,Str "passes",Space,Str "if",Space,Str "the",Space,Str "number",Space,Str "2",Space,Str "is",Space,Str "italicized",Space,Str "and",Space,Str "blue."]
+ ,Para [Str "If",Space,Str "the",Space,Str "reading",Space,Str "system",Space,Str "does",Space,Str "not",Space,Str "have",Space,Str "a",Space,Str "viewport,",Space,Str "or",Space,Str "does",Space,Str "not",Space,Str "support",SoftBreak,Str "CSS",Space,Str "styles,",Space,Str "this",Space,Str "test",Space,Str "should",Space,Str "be",Space,Str "marked",Space,Code ("",[],[]) "Not Supported",Str "."]]
+ ,Div ("content-mathml-001.xhtml#mathml-024",["section","ctest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],SoftBreak,Span ("",["test-id"],[]) [Str "mathml-024"],Str "Horizontal",Space,Str "stretch,",Space,Code ("",[],[]) "mover",Str ",",Space,Code ("",[],[]) "munder",Str ",",Space,Str "and",Space,Code ("",[],[]) "mspace",Space,Str "elements"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "horizontal",Space,Str "stretch,",Space,Code ("",[],[]) "mover",Str ",",Space,Code ("",[],[]) "munder",Str ",",Space,Code ("",[],[]) "mspace",Space,Str "elements",Space,Str "are",Space,Str "supported."]
+ ,Plain [Math DisplayMath "c = \\overset{\\text{complex\\ number}}{\\overbrace{\\underset{\\text{real}}{\\underbrace{\\mspace{20mu} a\\mspace{20mu}}} + \\underset{\\text{imaginary}}{\\underbrace{\\quad b{\\mathbb{i}}\\quad}}}}"]
+ ,Para [Str "The",Space,Str "test",Space,Str "passes",Space,Str "if",Space,Str "the",Space,Str "rendering",Space,Str "looks",Space,Str "like",Space,Str "."]]
+ ,Div ("content-mathml-001.xhtml#mathml-025",["section","ctest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],SoftBreak,Span ("",["test-id"],[]) [Str "mathml-025"],Str "Testing",Space,Code ("",[],[]) "mtable",Space,Str "with",Space,Code ("",[],[]) "colspan",Space,Str "and",Space,Code ("",[],[]) "rowspan",Space,Str "attributes,",Space,Str "Hebrew",Space,Str "and",Space,Str "Script",Space,Str "fonts"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Code ("",[],[]) "mtable",Space,Str "with",Space,Code ("",[],[]) "colspan",Space,Str "and",Space,Code ("",[],[]) "mspace",Space,Str "attributes",Space,Str "(colum",Space,Str "and",Space,Str "row",Space,Str "spanning)",Space,Str "are",Space,Str "supported;",Space,Str "uses",Space,Str "Hebrew",Space,Str "and",Space,Str "Script",Space,Str "alphabets."]
+ ,Plain [Math DisplayMath "\\begin{array}{llllllllll}\n & {\\operatorname{cov}\\left( \\mathcal{L} \\right)} & \\longrightarrow & {\\operatorname{non}\\left( \\mathcal{K} \\right)} & \\longrightarrow & {\\operatorname{cof}\\left( \\mathcal{K} \\right)} & \\longrightarrow & {\\operatorname{cof}\\left( \\mathcal{L} \\right)} & \\longrightarrow & 2^{\\aleph_{0}} \\\\\n & \\uparrow & & \\uparrow & & \\uparrow & & \\uparrow & & \\\\\n & {\\mathfrak{b}} & \\longrightarrow & {\\mathfrak{d}} & & & & & & \\\\\n & \\uparrow & & \\uparrow & & & & & & \\\\\n\\aleph_{1} & \\longrightarrow & {\\operatorname{add}\\left( \\mathcal{L} \\right)} & \\longrightarrow & {\\operatorname{add}\\left( \\mathcal{K} \\right)} & \\longrightarrow & {\\operatorname{cov}\\left( \\mathcal{K} \\right)} & \\longrightarrow & {\\operatorname{non}\\left( \\mathcal{L} \\right)} & \\\\\n\\end{array}"]
+ ,Para [Str "The",Space,Str "test",Space,Str "passes",Space,Str "if",Space,Str "the",Space,Str "rendering",Space,Str "looks",Space,Str "like",Space,Link ("",[],[]) [Str "Cicho\324's",Space,Str "Diagram"] ("http://en.wikipedia.org/wiki/Cicho%C5%84's_diagram",""),Str ":",Space,Str "."]]
+ ,Div ("content-mathml-001.xhtml#mathml-026",["section","ctest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],SoftBreak,Span ("",["test-id"],[]) [Str "mathml-026"],Str "BiDi,",Space,Str "RTL",Space,Str "and",Space,Str "Arabic",Space,Str "alphabets"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "right-to-left",Space,Str "and",Space,Str "Arabic",Space,Str "alphabets",Space,Str "are",Space,Str "supported."]
+ ,Plain [Math DisplayMath "{d\\left( s \\right)} = \\begin{cases}\n{\\sum\\limits_{{\\lbrack?\\rbrack} = 1}^{S}s^{\\lbrack?\\rbrack}} & {\\text{\1573\1584\1575\1603\1575\1606}s > 0} \\\\\n{\\int_{1}^{S}{s^{\\lbrack?\\rbrack}s}} & {\\text{\1573\1584\1575\1603\1575\1606}s \\in m} \\\\\n{T\\pi} & {\\text{\1594\1610\1585\1584\1604\1603}\\left( \\text{\1605\1593}\\pi \\simeq 3,141 \\right)} \\\\\n\\end{cases}"]
+ ,Para [Str "The",Space,Str "test",Space,Str "passes",Space,Str "if",Space,Str "the",Space,Str "rendering",Space,Str "looks",Space,Str "like",Space,Str "the",Space,Str "following",Space,Str "image:"]]
+ ,Div ("content-mathml-001.xhtml#mathml-027",["section","ctest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],SoftBreak,Span ("",["test-id"],[]) [Str "mathml-027"],Str "Elementary",Space,Str "math:",Space,Str "long",Space,Str "division",Space,Str "notation"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Code ("",[],[]) "mlongdiv",Space,Str "elements",Space,Str "(from",Space,Str "elementary",Space,Str "math)",Space,Str "are",Space,Str "supported."]
+ ,Plain [Span ("",["math"],[("xmlns","http://www.w3.org/1998/Math/MathML")]) [SoftBreak,Str "3",SoftBreak,Str "435.3",SoftBreak,Str "1306",SoftBreak,Str "12",SoftBreak,Str "10",SoftBreak,Str "9",SoftBreak,Str "16",SoftBreak,Str "15",SoftBreak,Str "1.0",SoftBreak,Str "9",SoftBreak,Str "1",SoftBreak]]
+ ,Para [Str "The",Space,Str "test",Space,Str "passes",Space,Str "if",Space,Str "the",Space,Str "rendering",Space,Str "looks",Space,Str "like",Space,Str "the",Space,Str "following",Space,Str "image:",Space,Str "."]]]
+,Para [Span ("content-switch-001.xhtml",[],[]) []]
+,Div ("content-switch-001.xhtml#epub-switch",["section"],[])
+ [Header 3 ("",[],[]) [Code ("",[],[]) "epub:switch"]
+ ,Div ("content-switch-001.xhtml#switch-010",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "switch-010"],Space,Str "Support"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "epub:switch",Space,Str "element",Space,Str "is",Space,Str "supported."]
+ ,Para [Str "PASS"]
+ ,Para [Str "If",Space,Str "only",Space,Str "the",Space,Str "word",Space,Str "\"PASS\"",Space,Str "is",Space,Str "rendered",Space,Str "before",Space,Str "this",Space,Str "paragraph,",Space,Str "the",Space,Str "test",Space,Str "passes.",Space,Str "If",Space,Str "both",Space,Str "\"PASS\"",Space,Str "and",Space,Str "\"FAIL\"",Space,Str "are",Space,Str "rendered,",Space,Str "or",Space,Str "neither",SoftBreak,Str "\"PASS\"",Space,Str "nor",Space,Str "\"FAIL\"",Space,Str "is",Space,Str "rendered,",Space,Str "the",Space,Str "test",Space,Str "fails."]]
+ ,Div ("content-switch-001.xhtml#switch-020",["section","otest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[OPTIONAL]"],SoftBreak,Span ("",["test-id"],[]) [Str "switch-020"],SoftBreak,Str "MathML",Space,Str "Embedding"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Str "MathML",Space,Str "namespace",Space,Str "is",Space,Str "recognized",Space,Str "when",Space,Str "used",Space,Str "in",Space,Str "an",Space,Code ("",[],[]) "epub:case",Space,Str "element."]
+ ,Para [Math InlineMath "{2x}{+ y - z}"]
+ ,Para [Str "If",Space,Str "a",Space,Str "MathML",Space,Str "equation",Space,Str "is",Space,Str "rendered",Space,Str "before",Space,Str "this",Space,Str "paragraph,",Space,Str "the",Space,Str "test",Space,Str "passes."]
+ ,Para [Str "If",Space,Str "test",Space,Code ("",[],[]) "switch-010",Space,Str "did",Space,Str "not",Space,Str "pass,",Space,Str "this",Space,Str "test",Space,Str "should",Space,Str "be",Space,Str "marked",Space,Code ("",[],[]) "Not Supported",Str "."]]]]
diff --git a/test/epub/formatting.epub b/test/epub/formatting.epub
new file mode 100644
index 000000000..f3f9b5b93
--- /dev/null
+++ b/test/epub/formatting.epub
Binary files differ
diff --git a/test/epub/formatting.native b/test/epub/formatting.native
new file mode 100644
index 000000000..e1507ff74
--- /dev/null
+++ b/test/epub/formatting.native
@@ -0,0 +1,402 @@
+[Para [Span ("front.xhtml",[],[]) []]
+,Div ("",["section"],[])
+ [Header 1 ("",[],[]) [Str "EPUB",Space,Str "3",Space,Str "Styling",Space,Str "Test",Space,Str "Document:",Space,Str "0101"]
+ ,Div ("",["section"],[])
+ [Header 2 ("",[],[]) [Str "Status",Space,Str "of",Space,Str "this",Space,Str "Document"]
+ ,Para [Str "This",Space,Str "publication",Space,Str "is",Space,Str "currently",Space,Str "considered",Space,Span ("",["status"],[]) [Str "[UNDER",Space,Str "DEVELOPMENT]"],Space,Str "by",Space,Str "the",Space,Str "IDPF."]
+ ,Para [Str "This",Space,Str "publication",Space,Str "is",Space,Str "part",Space,Str "of",Space,Str "version",Space,Span ("",["version"],[]) [Str "X.X"],Space,Str "of",Space,Str "the",Space,Str "EPUB",Space,Str "3.0",Space,Str "Compliance",Space,Str "Test",Space,Str "Suite",Space,Str "released",SoftBreak,Str "on",Space,RawInline (Format "html") "<time class=\"release\">",Str "TBD",RawInline (Format "html") "</time>",Str "."]
+ ,Para [Str "Before",Space,Str "using",Space,Str "this",Space,Str "publication",Space,Str "to",Space,Str "evaluate",Space,Str "reading",Space,Str "systems,",Space,Str "testers",Space,Str "are",Space,Str "strongly",Space,Str "encouraged",Space,Str "to",SoftBreak,Str "verify",Space,Str "that",Space,Str "they",Space,Str "have",Space,Str "the",Space,Str "latest",Space,Str "release",Space,Str "by",Space,Str "checking",Space,Str "the",Space,Str "current",Space,Str "release",Space,Str "version",Space,Str "and",Space,Str "date",Space,Str "of",SoftBreak,Str "the",Space,Str "test",Space,Str "suite",Space,Str "at",Space,Link ("",[],[]) [Str "TBD"] ("http://idpf.org/","")]
+ ,Para [Str "This",Space,Str "publication",Space,Str "is",Space,Str "one",Space,Str "of",Space,Str "several",Space,Str "that",Space,Str "currently",Space,Str "comprise",Space,Str "the",Space,Str "EPUB",Space,Str "3",Space,Str "conformance",Space,Str "test",Space,Str "suite",SoftBreak,Str "for",Space,Str "reflowable",Space,Str "content.",Space,Str "The",Space,Str "complete",Space,Str "test",Space,Str "suite",Space,Str "includes",Space,Str "all",Space,Str "of",Space,Str "the",Space,Str "following",Space,Str "publications:"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "."]]]]
+ ,Div ("",["section"],[])
+ [Header 2 ("",[],[]) [Str "About",Space,Str "this",Space,Str "Document"]
+ ,Para [Str "This",Space,Str "document",Space,Str "focuses",Space,Str "on",Space,Str "human-evaluated",Space,Str "binary",Space,Str "(pass/fail)",Space,Str "tests",Space,Str "in",Space,Str "a",SoftBreak,Str "reflowable",Space,Str "context.",Space,Str "Tests",Space,Str "for",Space,Str "fixed-layout",Space,Str "content",Space,Str "and",Space,Str "other",Space,Str "individual",Space,Str "tests",Space,Str "that",SoftBreak,Str "require",Space,Str "a",Space,Str "dedicated",Space,Str "epub",Space,Str "file",Space,Str "are",Space,Str "available",Space,Str "in",Space,Str "additional",Space,Str "sibling",Space,Str "documents;",Space,Str "refer",Space,Str "to",SoftBreak,Str "the",Space,Link ("",[],[]) [Str "test",Space,Str "suite",SoftBreak,Str "wiki"] ("https://github.com/mgylling/epub-testsuite/wiki/Overview",""),Space,Str "(",Code ("",[],[]) "https://github.com/mgylling/epub-testsuite/wiki/Overview",Str ")",Space,Str "for",Space,Str "additional",SoftBreak,Str "information."]]
+ ,Div ("",["section"],[])
+ [Header 2 ("",[],[]) [Str "Conventions"]
+ ,Para [Str "The",Space,Str "following",Space,Str "conventions",Space,Str "are",Space,Str "used",Space,Str "throughout",Space,Str "the",Space,Str "document:"]
+ ,DefinitionList
+ [([Str "1.",Space,Str "Locating",Space,Str "a",Space,Str "test"],
+ [[Div ("",["ctest"],[])
+ [Para [Str "Tests",Space,Str "for",Space,Emph [Str "required"],Space,Str "Reading",Space,Str "System",Space,Str "functionality",Space,Str "are",SoftBreak,Str "preceded",Space,Str "by",Space,Str "the",Space,Str "label:",Space,Span ("",["nature"],[("style","display: inline; font-size: 100%")]) [Str "[REQUIRED]"]]]
+ ,Div ("",["otest"],[])
+ [Para [Str "Tests",Space,Str "for",Space,Emph [Str "optional"],Space,Str "Reading",Space,Str "System",Space,Str "functionality",Space,Str "are",SoftBreak,Str "preceded",Space,Str "by",Space,Str "the",Space,Str "label:",Space,Span ("",["nature"],[("style","display: inline; font-size: 100%")]) [Str "[OPTIONAL]"]]]]])
+ ,([Str "2.",Space,Str "Performing",Space,Str "the",Space,Str "test"],
+ [[Plain [Str "Each",Space,Str "test",Space,Str "includes",Space,Str "a",Space,Str "description",Space,Str "of",Space,Str "its",Space,Str "purpose",Space,Str "followed",Space,Str "by",Space,Str "the",Space,Str "actual",Space,Strong [Str "test",Space,Str "statement,",SoftBreak,Str "which",Space,Str "can",Space,Str "always",Space,Str "be",Space,Str "evaluated",Space,Str "to",Space,Str "true",Space,Str "or",Space,Str "false"],Str ".",Space,Str "These",Space,Str "statements",Space,Str "typically",Space,Str "have",Space,Str "the",Space,Str "form:",SoftBreak,Str "\"If",Space,Str "[some",Space,Str "condition],",Space,Str "the",Space,Str "test",Space,Str "passes\"."]]])
+ ,([Str "3.",Space,Str "Scoring",Space,Str "in",Space,Str "the",Space,Str "results",Space,Str "form"],
+ [[Plain [Str "@@@TODO",Space,Str "provide",Space,Str "info",Space,Str "on",Space,Str "where",Space,Str "to",Space,Str "get",Space,Str "the",Space,Str "results",Space,Str "form"]]])]]]
+,Para [Span ("styling-xhtml-001.xhtml",[],[]) []]
+,Div ("styling-xhtml-001.xhtml#epub-css",["section"],[])
+ [Header 1 ("",[],[]) [Str "EPUB",Space,Str "Style",Space,Str "Sheets"]
+ ,Para [Str "This",Space,Str "section",Space,Str "contains",Space,Str "tests",Space,Str "for",Space,Str "styling",Space,Str "and",Space,Str "layout."]]
+,Para [Span ("styling-xhtml-003.xhtml",[],[]) []]
+,Div ("styling-xhtml-003.xhtml#style-110",["section","ctest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-110"],Space,Str "Multi-Column",Space,Str "Layouts"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "CSS Multi-Column Layout",Space,Str "properties",Space,Str "are",Space,Str "supported."]
+ ,Div ("",["multicol"],[])
+ [Para [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat.",Space,Str "Duis",Space,Str "aute",Space,Str "irure",Space,Str "dolor",Space,Str "in",Space,Str "reprehenderit",Space,Str "in",Space,Str "voluptate",Space,Str "velit",Space,Str "esse",Space,Str "cillum",Space,Str "dolore",Space,Str "eu",Space,Str "fugiat",Space,Str "nulla",Space,Str "pariatur.",Space,Str "Excepteur",Space,Str "sint",Space,Str "occaecat",Space,Str "cupidatat",Space,Str "non",Space,Str "proident,",Space,Str "sunt",Space,Str "in",Space,Str "culpa",Space,Str "qui",Space,Str "officia",Space,Str "deserunt",Space,Str "mollit",Space,Str "anim",Space,Str "id",Space,Str "est",Space,Str "laborum."]
+ ,Para [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat.",Space,Str "Duis",Space,Str "aute",Space,Str "irure",Space,Str "dolor",Space,Str "in",Space,Str "reprehenderit",Space,Str "in",Space,Str "voluptate",Space,Str "velit",Space,Str "esse",Space,Str "cillum",Space,Str "dolore",Space,Str "eu",Space,Str "fugiat",Space,Str "nulla",Space,Str "pariatur.",Space,Str "Excepteur",Space,Str "sint",Space,Str "occaecat",Space,Str "cupidatat",Space,Str "non",Space,Str "proident,",Space,Str "sunt",Space,Str "in",Space,Str "culpa",Space,Str "qui",Space,Str "officia",Space,Str "deserunt",Space,Str "mollit",Space,Str "anim",Space,Str "id",Space,Str "est",Space,Str "laborum."]
+ ,Para [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat.",Space,Str "Duis",Space,Str "aute",Space,Str "irure",Space,Str "dolor",Space,Str "in",Space,Str "reprehenderit",Space,Str "in",Space,Str "voluptate",Space,Str "velit",Space,Str "esse",Space,Str "cillum",Space,Str "dolore",Space,Str "eu",Space,Str "fugiat",Space,Str "nulla",Space,Str "pariatur.",Space,Str "Excepteur",Space,Str "sint",Space,Str "occaecat",Space,Str "cupidatat",Space,Str "non",Space,Str "proident,",Space,Str "sunt",Space,Str "in",Space,Str "culpa",Space,Str "qui",Space,Str "officia",Space,Str "deserunt",Space,Str "mollit",Space,Str "anim",Space,Str "id",Space,Str "est",Space,Str "laborum."]
+ ,Para [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat.",Space,Str "Duis",Space,Str "aute",Space,Str "irure",Space,Str "dolor",Space,Str "in",Space,Str "reprehenderit",Space,Str "in",Space,Str "voluptate",Space,Str "velit",Space,Str "esse",Space,Str "cillum",Space,Str "dolore",Space,Str "eu",Space,Str "fugiat",Space,Str "nulla",Space,Str "pariatur.",Space,Str "Excepteur",Space,Str "sint",Space,Str "occaecat",Space,Str "cupidatat",Space,Str "non",Space,Str "proident,",Space,Str "sunt",Space,Str "in",Space,Str "culpa",Space,Str "qui",Space,Str "officia",Space,Str "deserunt",Space,Str "mollit",Space,Str "anim",Space,Str "id",Space,Str "est",Space,Str "laborum."]
+ ,Para [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat.",Space,Str "Duis",Space,Str "aute",Space,Str "irure",Space,Str "dolor",Space,Str "in",Space,Str "reprehenderit",Space,Str "in",Space,Str "voluptate",Space,Str "velit",Space,Str "esse",Space,Str "cillum",Space,Str "dolore",Space,Str "eu",Space,Str "fugiat",Space,Str "nulla",Space,Str "pariatur.",Space,Str "Excepteur",Space,Str "sint",Space,Str "occaecat",Space,Str "cupidatat",Space,Str "non",Space,Str "proident,",Space,Str "sunt",Space,Str "in",Space,Str "culpa",Space,Str "qui",Space,Str "officia",Space,Str "deserunt",Space,Str "mollit",Space,Str "anim",Space,Str "id",Space,Str "est",Space,Str "laborum."]
+ ,Para [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat.",Space,Str "Duis",Space,Str "aute",Space,Str "irure",Space,Str "dolor",Space,Str "in",Space,Str "reprehenderit",Space,Str "in",Space,Str "voluptate",Space,Str "velit",Space,Str "esse",Space,Str "cillum",Space,Str "dolore",Space,Str "eu",Space,Str "fugiat",Space,Str "nulla",Space,Str "pariatur.",Space,Str "Excepteur",Space,Str "sint",Space,Str "occaecat",Space,Str "cupidatat",Space,Str "non",Space,Str "proident,",Space,Str "sunt",Space,Str "in",Space,Str "culpa",Space,Str "qui",Space,Str "officia",Space,Str "deserunt",Space,Str "mollit",Space,Str "anim",Space,Str "id",Space,Str "est",Space,Str "laborum."]
+ ,Para [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat.",Space,Str "Duis",Space,Str "aute",Space,Str "irure",Space,Str "dolor",Space,Str "in",Space,Str "reprehenderit",Space,Str "in",Space,Str "voluptate",Space,Str "velit",Space,Str "esse",Space,Str "cillum",Space,Str "dolore",Space,Str "eu",Space,Str "fugiat",Space,Str "nulla",Space,Str "pariatur.",Space,Str "Excepteur",Space,Str "sint",Space,Str "occaecat",Space,Str "cupidatat",Space,Str "non",Space,Str "proident,",Space,Str "sunt",Space,Str "in",Space,Str "culpa",Space,Str "qui",Space,Str "officia",Space,Str "deserunt",Space,Str "mollit",Space,Str "anim",Space,Str "id",Space,Str "est",Space,Str "laborum."]
+ ,Para [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat.",Space,Str "Duis",Space,Str "aute",Space,Str "irure",Space,Str "dolor",Space,Str "in",Space,Str "reprehenderit",Space,Str "in",Space,Str "voluptate",Space,Str "velit",Space,Str "esse",Space,Str "cillum",Space,Str "dolore",Space,Str "eu",Space,Str "fugiat",Space,Str "nulla",Space,Str "pariatur.",Space,Str "Excepteur",Space,Str "sint",Space,Str "occaecat",Space,Str "cupidatat",Space,Str "non",Space,Str "proident,",Space,Str "sunt",Space,Str "in",Space,Str "culpa",Space,Str "qui",Space,Str "officia",Space,Str "deserunt",Space,Str "mollit",Space,Str "anim",Space,Str "id",Space,Str "est",Space,Str "laborum."]
+ ,Para [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat.",Space,Str "Duis",Space,Str "aute",Space,Str "irure",Space,Str "dolor",Space,Str "in",Space,Str "reprehenderit",Space,Str "in",Space,Str "voluptate",Space,Str "velit",Space,Str "esse",Space,Str "cillum",Space,Str "dolore",Space,Str "eu",Space,Str "fugiat",Space,Str "nulla",Space,Str "pariatur.",Space,Str "Excepteur",Space,Str "sint",Space,Str "occaecat",Space,Str "cupidatat",Space,Str "non",Space,Str "proident,",Space,Str "sunt",Space,Str "in",Space,Str "culpa",Space,Str "qui",Space,Str "officia",Space,Str "deserunt",Space,Str "mollit",Space,Str "anim",Space,Str "id",Space,Str "est",Space,Str "laborum."]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "text",Space,Str "is",Space,Str "rendered",Space,Str "in",Space,Str "three",Space,Str "columns,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+,Para [Span ("styling-xhtml-002.xhtml",[],[]) []]
+,Div ("styling-xhtml-002.xhtml#style-lists",["section"],[])
+ [Header 2 ("",[],[]) [Str "Lists"]
+ ,Div ("styling-xhtml-002.xhtml#style-list-style-type",["section"],[])
+ [Header 3 ("",[],[]) [Str "The",Space,Code ("",[],[]) "list-style-type",Space,Str "property"]
+ ,Div ("styling-xhtml-002.xhtml#style-009",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-009"],Space,Code ("",[],[]) "decimal"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "decimal",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "decimal",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-010",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-010"],Space,Code ("",[],[]) "circle"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "circle",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ul",Space,Str "element."]
+ ,BulletList
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "circle",Space,Str "markers,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-011",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-011"],Space,Code ("",[],[]) "square"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "square",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ul",Space,Str "element."]
+ ,BulletList
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "square",Space,Str "markers,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-012",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-012"],Space,Code ("",[],[]) "disc"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "disc",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ul",Space,Str "element."]
+ ,BulletList
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "disc",Space,Str "markers,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-013",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-013"],Space,Code ("",[],[]) "lower-latin"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "lower-latin",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "lower-latin",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-014",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-014"],Space,Code ("",[],[]) "lower-roman"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "lower-roman",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "lower-roman",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-015",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-015"],Space,Code ("",[],[]) "upper-alpha"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "upper-alpha",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "upper-alpha",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-016",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-016"],Space,Code ("",[],[]) "hiragana"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "hiragana",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "hiragana",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-017",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-017"],Space,Code ("",[],[]) "hiragana-iroha"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "hiragana-iroha",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "hiragana-iroha",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-018",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-018"],Space,Code ("",[],[]) "katakana"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "katakana",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "katakana",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-019",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-019"],Space,Code ("",[],[]) "katakana-iroha"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "katakana-iroha",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "katakana-iroha",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-020",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-020"],Space,Code ("",[],[]) "upper-roman"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "upper-roman",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "upper-roman",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-021",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-021"],Space,Code ("",[],[]) "upper-latin"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "upper-latin",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "upper-latin",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-022",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-022"],Space,Code ("",[],[]) "lower-alpha"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "lower-alpha",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "lower-alpha",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-023",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-023"],Space,Code ("",[],[]) "lower-greek"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "lower-greek",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "lower-greek",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-024",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-024"],Space,Code ("",[],[]) "armenian"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "armenian",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "armenian",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-025",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-025"],Space,Code ("",[],[]) "cjk-ideographic"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "cjk-ideographic",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "cjk-ideographic",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-026",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-026"],Space,Code ("",[],[]) "decimal-leading-zero"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "decimal-leading-zero",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "decimal-leading-zero",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-027",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-027"],Space,Code ("",[],[]) "georgian"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "georgian",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "georgian",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-028",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-028"],Space,Code ("",[],[]) "hebrew"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "hebrew",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "hebrew",Space,Str "markers",Space,Str "in",Space,Str "ascending",Space,Str "order,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-029",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-029"],Space,Code ("",[],[]) "none"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-type",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "none",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "no",Space,Str "markers,",Space,Str "the",Space,Str "test",Space,Str "passes."]]]
+ ,Div ("styling-xhtml-002.xhtml#style-list-style",["section"],[])
+ [Header 3 ("",[],[]) [Str "The",Space,Code ("",[],[]) "list-style",Space,Str "property"]
+ ,Div ("styling-xhtml-002.xhtml#style-030",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-030"],Space,Str "images"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style",Space,Str "shorthand",Space,Str "property",Space,Str "is",Space,Str "supported",Space,Str "using",Space,Str "a",Space,Str "gif",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ul",Space,Str "element."]
+ ,BulletList
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "the",Space,Str "purple",Space,Str "and",Space,Str "aqua",Space,Str "square",Space,Str "bullet",Space,Str "the",Space,Str "test",Space,Str "passes."]]]
+ ,Div ("styling-xhtml-002.xhtml#style-list-style-position",["section"],[])
+ [Header 3 ("",[],[]) [Str "The",Space,Code ("",[],[]) "list-style-position",Space,Str "property"]
+ ,Div ("styling-xhtml-002.xhtml#style-040",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-040"],Space,Str "The",Space,Code ("",[],[]) "list-style-position",Space,Str "property:",Space,Code ("",[],[]) "inside"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-position",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "inside",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ul",Space,Str "element."]
+ ,BulletList
+ [[Plain [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat."]]
+ ,[Plain [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat."]]
+ ,[Plain [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat."]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "markers",Space,Str "inside",Space,Str "the",Space,Str "indentation,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-041",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-041"],Space,Str "The",Space,Code ("",[],[]) "list-style-position",Space,Str "property:",Space,Code ("",[],[]) "outside"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "list-style-position",Space,Str "property",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "outside",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ul",Space,Str "element."]
+ ,BulletList
+ [[Plain [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat."]]
+ ,[Plain [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat."]]
+ ,[Plain [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat."]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "has",Space,Str "the",Space,Str "default",Space,Str "setting",Space,Str "(marker",Space,Str "outside",Space,Str "the",Space,Str "indentation),",Space,Str "the",Space,Str "test",Space,Str "passes."]]]
+ ,Div ("styling-xhtml-002.xhtml#style-list-start",["section"],[])
+ [Header 3 ("",[],[]) [Str "The",Space,Str "HTML",Space,Code ("",[],[]) "start",Space,Str "attribute"]
+ ,Div ("styling-xhtml-002.xhtml#style-050",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-050"],Space,Str "Without",Space,Code ("",[],[]) "list-style-type",Space,Str "set"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "start",Space,Str "attribute",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element",Space,Str "with",Space,Str "no",Space,Code ("",[],[]) "list-style-type",Space,Str "property."]
+ ,OrderedList (25,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "starts",Space,Str "at",Space,Str "25,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-002.xhtml#style-051",["section","ctest"],[])
+ [Header 4 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-051"],Space,Str "With",Space,Code ("",[],[]) "list-style-type",Space,Str "set"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "start",Space,Str "attribute",Space,Str "is",Space,Str "supported",Space,Str "on",Space,Str "a",Space,Code ("",[],[]) "ol",Space,Str "element",Space,Str "with",Space,Str "a",Space,Code ("",[],[]) "list-style-type",Space,Str "property."]
+ ,OrderedList (50,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Lorem"]]
+ ,[Plain [Str "Ipsum"]]
+ ,[Plain [Str "Dolor"]]
+ ,[Plain [Str "Sit"]]
+ ,[Plain [Str "Amet"]]]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "list",Space,Str "starts",Space,Str "at",Space,Str "'L'",Space,Str "(50),",Space,Str "the",Space,Str "test",Space,Str "passes."]]]]
+,Para [Span ("styling-xhtml-004.xhtml",[],[]) []]
+,Div ("styling-xhtml-004.xhtml#style-media-rules",["section"],[])
+ [Header 2 ("",[],[]) [Code ("",[],[]) "@media",Space,Str "Rules"]
+ ,Div ("styling-xhtml-004.xhtml#style-210",["section","ctest"],[])
+ [Header 3 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-210"],Space,Code ("",[],[]) "all"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "@media",Space,Str "rule",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "all",Space,Str "is",Space,Str "supported."]
+ ,Para [Str "FAIL"]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "paragraph",Space,Str "reads",Space,Str "\"FAIL\",",Space,Str "the",Space,Str "test",Space,Str "fails."]]
+ ,Div ("styling-xhtml-004.xhtml#style-211",["section","ctest"],[])
+ [Header 3 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-211"],Space,Code ("",[],[]) "screen"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "@media",Space,Str "rule",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "screen",Space,Str "is",Space,Str "supported."]
+ ,Para [Str "FAIL"]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "paragraph",Space,Str "reads",Space,Str "\"FAIL\",",Space,Str "the",Space,Str "test",Space,Str "fails."]]
+ ,Div ("styling-xhtml-004.xhtml#style-212",["section","ctest"],[])
+ [Header 3 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-212"],Space,Code ("",[],[]) "handheld"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "@media",Space,Str "rule",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "handheld",Space,Str "is",Space,Str "supported."]
+ ,Para [Str "FAIL"]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "paragraph",Space,Str "reads",Space,Str "\"FAIL\",",Space,Str "the",Space,Str "test",Space,Str "fails."]]
+ ,Div ("styling-xhtml-004.xhtml#style-213",["section","ctest"],[])
+ [Header 3 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-213"],Space,Code ("",[],[]) "tv"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "@media",Space,Str "rule",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "tv",Space,Str "is",Space,Str "supported."]
+ ,Para [Str "FAIL"]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "paragraph",Space,Str "reads",Space,Str "\"FAIL\",",Space,Str "the",Space,Str "test",Space,Str "fails."]]
+ ,Div ("styling-xhtml-004.xhtml#style-220",["section","ctest"],[])
+ [Header 3 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-220"],Space,Code ("",[],[]) "orientation:landscape"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "@media",Space,Str "rule",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "orientation:landscape",Space,Str "is",Space,Str "supported."]
+ ,Para [Str "FAIL"]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "paragraph",Space,Str "reads",Space,Str "\"FAIL\"",Space,Str "when",Space,Str "the",Space,Str "device",Space,Str "is",Space,Str "held",Space,Str "in",Space,Str "landscape",Space,Str "mode,",Space,Str "and",Space,Str "the",Space,Str "device",Space,Str "supports",Space,Str "multiple",Space,Str "orientations,",Space,Str "the",Space,Str "test",Space,Str "fails."]]
+ ,Div ("styling-xhtml-004.xhtml#style-221",["section","ctest"],[])
+ [Header 3 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-221"],Space,Code ("",[],[]) "orientation:portrait"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "@media",Space,Str "rule",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "orientation:portrait",Space,Str "is",Space,Str "supported."]
+ ,Para [Str "FAIL"]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "paragraph",Space,Str "reads",Space,Str "\"FAIL\"",Space,Str "when",Space,Str "the",Space,Str "device",Space,Str "is",Space,Str "held",Space,Str "in",Space,Str "portrait",Space,Str "mode,",Space,Str "and",Space,Str "the",Space,Str "device",Space,Str "supports",Space,Str "multiple",Space,Str "orientations,",Space,Str "the",Space,Str "test",Space,Str "fails."]]
+ ,Div ("styling-xhtml-004.xhtml#style-230",["section","ctest"],[])
+ [Header 3 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-230"],Space,Code ("",[],[]) "min-width"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "@media",Space,Str "rule",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "min-width:200px",Space,Str "is",Space,Str "supported."]
+ ,Para [Str "FAIL"]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "paragraph",Space,Str "reads",Space,Str "\"FAIL\",",Space,Str "the",Space,Str "test",Space,Str "fails."]]
+ ,Div ("styling-xhtml-004.xhtml#style-231",["section","ctest"],[])
+ [Header 3 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-231"],Space,Code ("",[],[]) "max-width"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "@media",Space,Str "rule",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "max-width:2000px",Space,Str "is",Space,Str "supported."]
+ ,Para [Str "FAIL"]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "paragraph",Space,Str "reads",Space,Str "\"FAIL\",",Space,Str "the",Space,Str "test",Space,Str "fails."]]
+ ,Div ("styling-xhtml-004.xhtml#style-240",["section","ctest"],[])
+ [Header 3 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-240"],Space,Code ("",[],[]) "min-device-width"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "@media",Space,Str "rule",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "min-device-width:200px",Space,Str "is",Space,Str "supported."]
+ ,Para [Str "FAIL"]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "paragraph",Space,Str "reads",Space,Str "\"FAIL\",",Space,Str "the",Space,Str "test",Space,Str "fails."]]
+ ,Div ("styling-xhtml-004.xhtml#style-241",["section","ctest"],[])
+ [Header 3 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-241"],Space,Code ("",[],[]) "max-device-width"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "@media",Space,Str "rule",Space,Str "set",Space,Str "to",Space,Code ("",[],[]) "max-device-width:2000px",Space,Str "is",Space,Str "supported."]
+ ,Para [Str "FAIL"]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "paragraph",Space,Str "reads",Space,Str "\"FAIL\",",Space,Str "the",Space,Str "test",Space,Str "fails."]]]
+,Para [Span ("styling-xhtml-005.xhtml",[],[]) []]
+,Div ("styling-xhtml-005.xhtml#style-text-xform",["section"],[])
+ [Header 2 ("",[],[]) [Str "The",Space,Code ("",[],[]) "text-transform",Space,Str "property"]
+ ,Div ("styling-xhtml-005.xhtml#style-310",["section","ctest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-310"],Space,Code ("",[],[]) "uppercase"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "text-transform",Space,Str "property",Space,Str "set",Space,Str "to",Space,Str "uppercase",Space,Str "is",Space,Str "supported."]
+ ,Para [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat.",Space,Str "Duis",Space,Str "aute",Space,Str "irure",Space,Str "dolor",Space,Str "in",Space,Str "reprehenderit",Space,Str "in",Space,Str "voluptate",Space,Str "velit",Space,Str "esse",Space,Str "cillum",Space,Str "dolore",Space,Str "eu",Space,Str "fugiat",Space,Str "nulla",Space,Str "pariatur.",Space,Str "Excepteur",Space,Str "sint",Space,Str "occaecat",Space,Str "cupidatat",Space,Str "non",Space,Str "proident,",Space,Str "sunt",Space,Str "in",Space,Str "culpa",Space,Str "qui",Space,Str "officia",Space,Str "deserunt",Space,Str "mollit",Space,Str "anim",Space,Str "id",Space,Str "est",Space,Str "laborum."]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "paragraph",Space,Str "is",Space,Str "in",Space,Str "upper",Space,Str "case,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-005.xhtml#style-311",["section","ctest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-311"],Space,Code ("",[],[]) "capitalize"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "text-transform",Space,Str "property",Space,Str "set",Space,Str "to",Space,Str "capitalize",Space,Str "is",Space,Str "supported."]
+ ,Para [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat.",Space,Str "Duis",Space,Str "aute",Space,Str "irure",Space,Str "dolor",Space,Str "in",Space,Str "reprehenderit",Space,Str "in",Space,Str "voluptate",Space,Str "velit",Space,Str "esse",Space,Str "cillum",Space,Str "dolore",Space,Str "eu",Space,Str "fugiat",Space,Str "nulla",Space,Str "pariatur.",Space,Str "Excepteur",Space,Str "sint",Space,Str "occaecat",Space,Str "cupidatat",Space,Str "non",Space,Str "proident,",Space,Str "sunt",Space,Str "in",Space,Str "culpa",Space,Str "qui",Space,Str "officia",Space,Str "deserunt",Space,Str "mollit",Space,Str "anim",Space,Str "id",Space,Str "est",Space,Str "laborum."]
+ ,Para [Str "If",Space,Str "each",Space,Str "first",Space,Str "letter",Space,Str "of",Space,Str "each",Space,Str "word",Space,Str "in",Space,Str "the",Space,Str "preceding",Space,Str "paragraph",Space,Str "is",Space,Str "in",Space,Str "upper",Space,Str "case,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-005.xhtml#style-312",["section","ctest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-312"],Space,Code ("",[],[]) "lowercase"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "text-transform",Space,Str "property",Space,Str "set",Space,Str "to",Space,Str "lowercase",Space,Str "is",Space,Str "supported."]
+ ,Para [Str "Lorem",Space,Str "ipsum",Space,Str "dolor",Space,Str "sit",Space,Str "amet,",Space,Str "consectetur",Space,Str "adipisicing",Space,Str "elit,",Space,Str "sed",Space,Str "do",Space,Str "eiusmod",Space,Str "tempor",Space,Str "incididunt",Space,Str "ut",Space,Str "labore",Space,Str "et",Space,Str "dolore",Space,Str "magna",Space,Str "aliqua.",Space,Str "Ut",Space,Str "enim",Space,Str "ad",Space,Str "minim",Space,Str "veniam,",Space,Str "quis",Space,Str "nostrud",Space,Str "exercitation",Space,Str "ullamco",Space,Str "laboris",Space,Str "nisi",Space,Str "ut",Space,Str "aliquip",Space,Str "ex",Space,Str "ea",Space,Str "commodo",Space,Str "consequat.",Space,Str "Duis",Space,Str "aute",Space,Str "irure",Space,Str "dolor",Space,Str "in",Space,Str "reprehenderit",Space,Str "in",Space,Str "voluptate",Space,Str "velit",Space,Str "esse",Space,Str "cillum",Space,Str "dolore",Space,Str "eu",Space,Str "fugiat",Space,Str "nulla",Space,Str "pariatur.",Space,Str "Excepteur",Space,Str "sint",Space,Str "occaecat",Space,Str "cupidatat",Space,Str "non",Space,Str "proident,",Space,Str "sunt",Space,Str "in",Space,Str "culpa",Space,Str "qui",Space,Str "officia",Space,Str "deserunt",Space,Str "mollit",Space,Str "anim",Space,Str "id",Space,Str "est",Space,Str "laborum."]
+ ,Para [Str "If",Space,Str "the",Space,Str "preceding",Space,Str "paragraph",Space,Str "is",Space,Str "in",Space,Str "lower",Space,Str "case,",Space,Str "the",Space,Str "test",Space,Str "passes."]]]
+,Para [Span ("styling-xhtml-006.xhtml",[],[]) []]
+,Div ("styling-xhtml-006.xhtml#style-ruby",["section"],[])
+ [Header 2 ("",[],[]) [Str "The",Space,Code ("",[],[]) "epub-ruby-position",Space,Str "property"]
+ ,Div ("styling-xhtml-006.xhtml#style-410",["section","ctest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-410"],Space,Code ("",[],[]) "over"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "-epub-ruby-position",Space,Str "property",Space,Str "set",Space,Str "to",Space,Str "over",Space,Str "is",Space,Str "supported."]
+ ,Plain [RawInline (Format "html") "<ruby class=\"ruby-over\">",Strong [Str "Lorem",Space,Str "Ipsum"],Space,RawInline (Format "html") "<rp>",Str "(",RawInline (Format "html") "</rp>",RawInline (Format "html") "<rt>",Str "Lorem",Space,Str "Ipsum",RawInline (Format "html") "</rt>",RawInline (Format "html") "<rp>",Str ")",RawInline (Format "html") "</rp>",RawInline (Format "html") "</ruby>"]
+ ,Para [Str "If",Space,Str "the",Space,Str "Ruby",Space,Str "text",Space,Str "is",Space,Str "positioned",Space,Str "on",Space,Str "the",Space,Link ("",[],[]) [Str "over"] ("http://www.w3.org/TR/css3-writing-modes/#over",""),Space,Str "side",Space,Str "of",Space,Str "the",Space,Str "ruby",Space,Str "base,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-006.xhtml#style-411",["section","ctest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-411"],Space,Code ("",[],[]) "under"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "-epub-ruby-position",Space,Str "property",Space,Str "set",Space,Str "to",Space,Str "under",Space,Str "is",Space,Str "supported."]
+ ,Plain [RawInline (Format "html") "<ruby class=\"ruby-under\">",Strong [Str "Lorem",Space,Str "Ipsum"],Space,RawInline (Format "html") "<rp>",Str "(",RawInline (Format "html") "</rp>",RawInline (Format "html") "<rt>",Str "Lorem",Space,Str "Ipsum",RawInline (Format "html") "</rt>",RawInline (Format "html") "<rp>",Str ")",RawInline (Format "html") "</rp>",RawInline (Format "html") "</ruby>"]
+ ,Para [Str "If",Space,Str "the",Space,Str "Ruby",Space,Str "text",Space,Str "is",Space,Str "positioned",Space,Str "on",Space,Str "the",Space,Link ("",[],[]) [Str "under"] ("http://www.w3.org/TR/css3-writing-modes/#under",""),Space,Str "side",Space,Str "of",Space,Str "the",Space,Str "ruby",Space,Str "base,",Space,Str "the",Space,Str "test",Space,Str "passes."]]
+ ,Div ("styling-xhtml-006.xhtml#style-412",["section","ctest"],[])
+ [Header 2 ("",[],[]) [Span ("",["nature"],[]) [Str "[REQUIRED]"],Space,Span ("",["test-id"],[]) [Str "style-412"],Space,Code ("",[],[]) "inter-character"]
+ ,Para [Str "Tests",Space,Str "whether",Space,Str "the",Space,Code ("",[],[]) "-epub-ruby-position",Space,Str "property",Space,Str "set",Space,Str "to",Space,Str "inter-caracter",Space,Str "is",Space,Str "supported."]
+ ,Plain [RawInline (Format "html") "<ruby class=\"ruby-inter-character\">",Strong [Str "Lorem",Space,Str "Ipsum"],Space,RawInline (Format "html") "<rp>",Str "(",RawInline (Format "html") "</rp>",RawInline (Format "html") "<rt>",Str "Lorem",Space,Str "Ipsum",RawInline (Format "html") "</rt>",RawInline (Format "html") "<rp>",Str ")",RawInline (Format "html") "</rp>",RawInline (Format "html") "</ruby>"]
+ ,Para [Str "If",Space,Str "the",Space,Str "Ruby",Space,Str "text",Space,Str "is",Space,Str "positioned",Space,Str "on",Space,Str "the",Space,Str "right",Space,Str "side",Space,Str "of",Space,Str "the",Space,Str "base",Space,Str "text,",Space,Str "the",Space,Str "test",Space,Str "passes."]]]]
diff --git a/test/epub/img.epub b/test/epub/img.epub
new file mode 100644
index 000000000..ebe80d935
--- /dev/null
+++ b/test/epub/img.epub
Binary files differ
diff --git a/test/epub/wasteland.epub b/test/epub/wasteland.epub
new file mode 100644
index 000000000..e4e52db7f
--- /dev/null
+++ b/test/epub/wasteland.epub
Binary files differ
diff --git a/test/epub/wasteland.native b/test/epub/wasteland.native
new file mode 100644
index 000000000..335c63bf5
--- /dev/null
+++ b/test/epub/wasteland.native
@@ -0,0 +1,941 @@
+[Para [Image ("",[],[]) [] ("wasteland-cover.jpg","")]
+,Para [Span ("wasteland-content.xhtml",[],[]) []]
+,Div ("wasteland-content.xhtml#frontmatter",["section"],[("type","frontmatter")])
+ []
+,Div ("wasteland-content.xhtml#bodymatter",["section"],[("type","bodymatter")])
+ [Div ("wasteland-content.xhtml#ch1",["section"],[])
+ [Header 2 ("",[],[]) [Str "I.",Space,Str "THE",Space,Str "BURIAL",Space,Str "OF",Space,Str "THE",Space,Str "DEAD"]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "April",Space,Str "is",Space,Str "the",Space,Str "cruellest",Space,Str "month,",Space,Str "breeding"]]
+ ,Div ("",[],[])
+ [Plain [Str "Lilacs",Space,Str "out",Space,Str "of",Space,Str "the",Space,Str "dead",Space,Str "land,",Space,Str "mixing"]]
+ ,Div ("",[],[])
+ [Plain [Str "Memory",Space,Str "and",Space,Str "desire,",Space,Str "stirring"]]
+ ,Div ("",[],[])
+ [Plain [Str "Dull",Space,Str "roots",Space,Str "with",Space,Str "spring",Space,Str "rain."]]
+ ,Div ("",[],[])
+ [Plain [Str "Winter",Space,Str "kept",Space,Str "us",Space,Str "warm,",Space,Str "covering"]]
+ ,Div ("",[],[])
+ [Plain [Str "Earth",Space,Str "in",Space,Str "forgetful",Space,Str "snow,",Space,Str "feeding"]]
+ ,Div ("",[],[])
+ [Plain [Str "A",Space,Str "little",Space,Str "life",Space,Str "with",Space,Str "dried",Space,Str "tubers."]]
+ ,Div ("",[],[])
+ [Plain [Str "Summer",Space,Str "surprised",Space,Str "us,",Space,Str "coming",Space,Str "over",Space,Str "the",Space,Str "Starnbergersee"]]
+ ,Div ("",[],[])
+ [Plain [Str "With",Space,Str "a",Space,Str "shower",Space,Str "of",Space,Str "rain;",Space,Str "we",Space,Str "stopped",Space,Str "in",Space,Str "the",Space,Str "colonnade,"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "went",Space,Str "on",Space,Str "in",Space,Str "sunlight,",Space,Str "into",Space,Str "the",Space,Str "Hofgarten,",Span ("",["lnum"],[]) [Str "10"]]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "drank",Space,Str "coffee,",Space,Str "and",Space,Str "talked",Space,Str "for",Space,Str "an",Space,Str "hour."]]
+ ,Div ("",[],[("lang","de")])
+ [Plain [Str "Bin",Space,Str "gar",Space,Str "keine",Space,Str "Russin,",Space,Str "stamm'",Space,Str "aus",Space,Str "Litauen,",Space,Str "echt",SoftBreak,Str "deutsch."]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "when",Space,Str "we",Space,Str "were",Space,Str "children,",Space,Str "staying",Space,Str "at",Space,Str "the",Space,Str "archduke's,"]]
+ ,Div ("",[],[])
+ [Plain [Str "My",Space,Str "cousin's,",Space,Str "he",Space,Str "took",Space,Str "me",Space,Str "out",Space,Str "on",Space,Str "a",Space,Str "sled,"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "I",Space,Str "was",Space,Str "frightened.",Space,Str "He",Space,Str "said,",Space,Str "Marie,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Marie,",Space,Str "hold",Space,Str "on",Space,Str "tight.",Space,Str "And",Space,Str "down",Space,Str "we",Space,Str "went."]]
+ ,Div ("",[],[])
+ [Plain [Str "In",Space,Str "the",Space,Str "mountains,",Space,Str "there",Space,Str "you",Space,Str "feel",Space,Str "free."]]
+ ,Div ("",[],[])
+ [Plain [Str "I",Space,Str "read,",Space,Str "much",Space,Str "of",Space,Str "the",Space,Str "night,",Space,Str "and",Space,Str "go",Space,Str "south",Space,Str "in",Space,Str "the",Space,Str "winter."]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "What",Space,Str "are",Space,Str "the",Space,Str "roots",Space,Str "that",Space,Str "clutch,",Space,Str "what",Space,Str "branches",Space,Str "grow"]]
+ ,Div ("wasteland-content.xhtml#ln20",[],[])
+ [Plain [Str "Out",Space,Str "of",Space,Str "this",Space,Str "stony",Space,Str "rubbish?",Space,Str "Son",Space,Str "of",Space,Str "man,",Note [Para [Link ("",[],[]) [Str "Line",Space,Str "20."] ("#wasteland-content.xhtml#ln20",""),Space,Str "Cf.",Space,Str "Ezekiel",Space,Str "2:1."]]]
+ ,Div ("",[],[])
+ [Plain [Str "You",Space,Str "cannot",Space,Str "say,",Space,Str "or",Space,Str "guess,",Space,Str "for",Space,Str "you",Space,Str "know",Space,Str "only"]]
+ ,Div ("",[],[])
+ [Plain [Str "A",Space,Str "heap",Space,Str "of",Space,Str "broken",Space,Str "images,",Space,Str "where",Space,Str "the",Space,Str "sun",Space,Str "beats,"]]
+ ,Div ("wasteland-content.xhtml#ln23",[],[])
+ [Plain [Str "And",Space,Str "the",Space,Str "dead",Space,Str "tree",Space,Str "gives",Space,Str "no",Space,Str "shelter,",Space,Str "the",Space,Str "cricket",Space,Str "no",Space,Str "relief,",Note [Para [Link ("",[],[]) [Str "23."] ("#wasteland-content.xhtml#ln23",""),Space,Str "Cf.",Space,Str "Ecclesiastes",Space,Str "12:5."]]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "the",Space,Str "dry",Space,Str "stone",Space,Str "no",Space,Str "sound",Space,Str "of",Space,Str "water.",Space,Str "Only"]]
+ ,Div ("",[],[])
+ [Plain [Str "There",Space,Str "is",Space,Str "shadow",Space,Str "under",Space,Str "this",Space,Str "red",Space,Str "rock,"]]
+ ,Div ("",[],[])
+ [Plain [Str "(Come",Space,Str "in",Space,Str "under",Space,Str "the",Space,Str "shadow",Space,Str "of",Space,Str "this",Space,Str "red",Space,Str "rock),"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "I",Space,Str "will",Space,Str "show",Space,Str "you",Space,Str "something",Space,Str "different",Space,Str "from",Space,Str "either"]]
+ ,Div ("",[],[])
+ [Plain [Str "Your",Space,Str "shadow",Space,Str "at",Space,Str "morning",Space,Str "striding",Space,Str "behind",Space,Str "you"]]
+ ,Div ("",[],[])
+ [Plain [Str "Or",Space,Str "your",Space,Str "shadow",Space,Str "at",Space,Str "evening",Space,Str "rising",Space,Str "to",Space,Str "meet",Space,Str "you;"]]
+ ,Div ("",[],[])
+ [Plain [Str "I",Space,Str "will",Space,Str "show",Space,Str "you",Space,Str "fear",Space,Str "in",Space,Str "a",Space,Str "handful",Space,Str "of",Space,Str "dust.",Span ("",["lnum"],[]) [Str "30"]]]
+ ,BlockQuote
+ [Div ("",[],[])
+ [Div ("wasteland-content.xhtml#ln31",[],[])
+ [Plain [Str "Frisch",Space,Str "weht",Space,Str "der",Space,Str "Wind",Note [Para [Link ("",[],[]) [Str "31."] ("#wasteland-content.xhtml#ln31",""),Space,Str "V.",Space,Str "Tristan",Space,Str "und",Space,Str "Isolde,",Space,Str "i,",Space,Str "verses",Space,Str "5-8."]]]
+ ,Div ("",[],[])
+ [Plain [Str "Der",Space,Str "Heimat",Space,Str "zu"]]
+ ,Div ("",[],[])
+ [Plain [Str "Mein",Space,Str "Irisch",Space,Str "Kind,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Wo",Space,Str "weilest",Space,Str "du?"]]]
+ ,RawBlock (Format "html") "</blockquote>"
+ ,Div ("",[],[])
+ [Plain [Str "\"You",Space,Str "gave",Space,Str "me",Space,Str "hyacinths",Space,Str "first",Space,Str "a",Space,Str "year",Space,Str "ago;"]]
+ ,Div ("",[],[])
+ [Plain [Str "\"They",Space,Str "called",Space,Str "me",Space,Str "the",Space,Str "hyacinth",Space,Str "girl.\""]]
+ ,Div ("",[],[])
+ [Plain [Str "\8213Yet",Space,Str "when",Space,Str "we",Space,Str "came",Space,Str "back,",Space,Str "late,",Space,Str "from",Space,Str "the",Space,Str "Hyacinth",SoftBreak,Str "garden,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Your",Space,Str "arms",Space,Str "full,",Space,Str "and",Space,Str "your",Space,Str "hair",Space,Str "wet,",Space,Str "I",Space,Str "could",Space,Str "not"]]
+ ,Div ("",[],[])
+ [Plain [Str "Speak,",Space,Str "and",Space,Str "my",Space,Str "eyes",Space,Str "failed,",Space,Str "I",Space,Str "was",Space,Str "neither"]]
+ ,Div ("",[],[])
+ [Plain [Str "Living",Space,Str "nor",Space,Str "dead,",Space,Str "and",Space,Str "I",Space,Str "knew",Space,Str "nothing,",Span ("",["lnum"],[]) [Str "40"]]]
+ ,Div ("",[],[])
+ [Plain [Str "Looking",Space,Str "into",Space,Str "the",Space,Str "heart",Space,Str "of",Space,Str "light,",Space,Str "the",Space,Str "silence."]]
+ ,Div ("wasteland-content.xhtml#ln42",[],[("lang","de")])
+ [Plain [Emph [Str "Od'",Space,Str "und",Space,Str "leer",Space,Str "das",Space,Str "Meer"],Str ".",Note [Para [Link ("",[],[]) [Str "42."] ("#wasteland-content.xhtml#ln42",""),Space,Str "Id.",Space,Str "iii,",Space,Str "verse",Space,Str "24."]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "Madame",Space,Str "Sosostris,",Space,Str "famous",Space,Str "clairvoyante,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Had",Space,Str "a",Space,Str "bad",Space,Str "cold,",Space,Str "nevertheless"]]
+ ,Div ("",[],[])
+ [Plain [Str "Is",Space,Str "known",Space,Str "to",Space,Str "be",Space,Str "the",Space,Str "wisest",Space,Str "woman",Space,Str "in",Space,Str "Europe,"]]
+ ,Div ("wasteland-content.xhtml#ln46",[],[])
+ [Plain [Str "With",Space,Str "a",Space,Str "wicked",Space,Str "pack",Space,Str "of",Space,Str "cards.",Space,Str "Here,",Space,Str "said",Space,Str "she,",Note [Para [Link ("",[],[]) [Str "46."] ("#wasteland-content.xhtml#ln46",""),Space,Str "I",Space,Str "am",Space,Str "not",Space,Str "familiar",Space,Str "with",Space,Str "the",Space,Str "exact",Space,Str "constitution",Space,Str "of",Space,Str "the",Space,Str "Tarot",Space,Str "pack",Space,Str "of",SoftBreak,Str "cards,",Space,Str "from",Space,Str "which",Space,Str "I",Space,Str "have",Space,Str "obviously",Space,Str "departed",Space,Str "to",Space,Str "suit",Space,Str "my",Space,Str "own",Space,Str "convenience.",SoftBreak,Str "The",Space,Str "Hanged",Space,Str "Man,",Space,Str "a",Space,Str "member",Space,Str "of",Space,Str "the",Space,Str "traditional",Space,Str "pack,",Space,Str "fits",Space,Str "my",Space,Str "purpose",Space,Str "in",Space,Str "two",SoftBreak,Str "ways:",Space,Str "because",Space,Str "he",Space,Str "is",Space,Str "associated",Space,Str "in",Space,Str "my",Space,Str "mind",Space,Str "with",Space,Str "the",Space,Str "Hanged",Space,Str "God",Space,Str "of",Space,Str "Frazer,",SoftBreak,Str "and",Space,Str "because",Space,Str "I",Space,Str "associate",Space,Str "him",Space,Str "with",Space,Str "the",Space,Str "hooded",Space,Str "figure",Space,Str "in",Space,Str "the",Space,Str "passage",Space,Str "of",Space,Str "the",SoftBreak,Str "disciples",Space,Str "to",Space,Str "Emmaus",Space,Str "in",Space,Str "Part",Space,Str "V.",Space,Str "The",Space,Str "Phoenician",Space,Str "Sailor",Space,Str "and",Space,Str "the",Space,Str "Merchant",SoftBreak,Str "appear",Space,Str "later;",Space,Str "also",Space,Str "the",Space,Str "\"crowds",Space,Str "of",Space,Str "people,\"",Space,Str "and",Space,Str "Death",Space,Str "by",Space,Str "Water",Space,Str "is",SoftBreak,Str "executed",Space,Str "in",Space,Str "Part",Space,Str "IV.",Space,Str "The",Space,Str "Man",Space,Str "with",Space,Str "Three",Space,Str "Staves",Space,Str "(an",Space,Str "authentic",Space,Str "member",Space,Str "of",SoftBreak,Str "the",Space,Str "Tarot",Space,Str "pack)",Space,Str "I",Space,Str "associate,",Space,Str "quite",Space,Str "arbitrarily,",Space,Str "with",Space,Str "the",Space,Str "Fisher",Space,Str "King",SoftBreak,Str "himself."]]]
+ ,Div ("",[],[])
+ [Plain [Str "Is",Space,Str "your",Space,Str "card,",Space,Str "the",Space,Str "drowned",Space,Str "Phoenician",Space,Str "Sailor,"]]
+ ,Div ("",[],[])
+ [Plain [Str "(Those",Space,Str "are",Space,Str "pearls",Space,Str "that",Space,Str "were",Space,Str "his",Space,Str "eyes.",Space,Str "Look!)"]]
+ ,Div ("",[],[])
+ [Plain [Str "Here",Space,Str "is",Space,Str "Belladonna,",Space,Str "the",Space,Str "Lady",Space,Str "of",Space,Str "the",Space,Str "Rocks,"]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "lady",Space,Str "of",Space,Str "situations.",Span ("",["lnum"],[]) [Str "50"]]]
+ ,Div ("",[],[])
+ [Plain [Str "Here",Space,Str "is",Space,Str "the",Space,Str "man",Space,Str "with",Space,Str "three",Space,Str "staves,",Space,Str "and",Space,Str "here",Space,Str "the",Space,Str "Wheel,"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "here",Space,Str "is",Space,Str "the",Space,Str "one-eyed",Space,Str "merchant,",Space,Str "and",Space,Str "this",Space,Str "card,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Which",Space,Str "is",Space,Str "blank,",Space,Str "is",Space,Str "something",Space,Str "he",Space,Str "carries",Space,Str "on",Space,Str "his",Space,Str "back,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Which",Space,Str "I",Space,Str "am",Space,Str "forbidden",Space,Str "to",Space,Str "see.",Space,Str "I",Space,Str "do",Space,Str "not",Space,Str "find"]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "Hanged",Space,Str "Man.",Space,Str "Fear",Space,Str "death",Space,Str "by",Space,Str "water."]]
+ ,Div ("",[],[])
+ [Plain [Str "I",Space,Str "see",Space,Str "crowds",Space,Str "of",Space,Str "people,",Space,Str "walking",Space,Str "round",Space,Str "in",Space,Str "a",Space,Str "ring."]]
+ ,Div ("",[],[])
+ [Plain [Str "Thank",Space,Str "you.",Space,Str "If",Space,Str "you",Space,Str "see",Space,Str "dear",Space,Str "Mrs.",Space,Str "Equitone,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Tell",Space,Str "her",Space,Str "I",Space,Str "bring",Space,Str "the",Space,Str "horoscope",Space,Str "myself:"]]
+ ,Div ("",[],[])
+ [Plain [Str "One",Space,Str "must",Space,Str "be",Space,Str "so",Space,Str "careful",Space,Str "these",Space,Str "days."]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("wasteland-content.xhtml#ln60",[],[])
+ [Plain [Str "Unreal",Space,Str "City,",Note [Para [Link ("",[],[]) [Str "60."] ("#wasteland-content.xhtml#ln60",""),Space,Str "Cf.",Space,Str "Baudelaire:"],BlockQuote [Para [Str "\"Fourmillante",Space,Str "cite;,",Space,Str "cite;",Space,Str "pleine",Space,Str "de",Space,Str "reves,",LineBreak,Str "Ou",Space,Str "le",Space,Str "spectre",Space,Str "en",SoftBreak,Str "plein",Space,Str "jour",Space,Str "raccroche",Space,Str "le",Space,Str "passant.\""]]]]
+ ,Div ("",[],[])
+ [Plain [Str "Under",Space,Str "the",Space,Str "brown",Space,Str "fog",Space,Str "of",Space,Str "a",Space,Str "winter",Space,Str "dawn,"]]
+ ,Div ("",[],[])
+ [Plain [Str "A",Space,Str "crowd",Space,Str "flowed",Space,Str "over",Space,Str "London",Space,Str "Bridge,",Space,Str "so",Space,Str "many,"]]
+ ,Div ("wasteland-content.xhtml#ln63",[],[])
+ [Plain [Str "I",Space,Str "had",Space,Str "not",Space,Str "thought",Space,Str "death",Space,Str "had",Space,Str "undone",Space,Str "so",Space,Str "many.",Note [Para [Link ("",[],[]) [Str "63."] ("#wasteland-content.xhtml#ln63",""),Space,Str "Cf.",Space,Str "Inferno,",Space,Str "iii.",Space,Str "55-7."],BlockQuote [Para [Str "\"si",Space,Str "lunga",Space,Str "tratta",LineBreak,Str "di",Space,Str "gente,",Space,Str "ch'io",Space,Str "non",Space,Str "avrei",Space,Str "mai",Space,Str "creduto",LineBreak,Str "che",SoftBreak,Str "morte",Space,Str "tanta",Space,Str "n'avesse",Space,Str "disfatta.\""]]]]
+ ,Div ("wasteland-content.xhtml#ln64",[],[])
+ [Plain [Str "Sighs,",Space,Str "short",Space,Str "and",Space,Str "infrequent,",Space,Str "were",Space,Str "exhaled,",Note [Para [Link ("",[],[]) [Str "64."] ("#wasteland-content.xhtml#ln64",""),Space,Str "Cf.",Space,Str "Inferno,",Space,Str "iv.",Space,Str "25-7:"],BlockQuote [Para [Str "\"Quivi,",Space,Str "secondo",Space,Str "che",Space,Str "per",Space,Str "ascoltahre,",LineBreak,Str "\"non",Space,Str "avea",Space,Str "pianto,",Space,Str "ma'",Space,Str "che",Space,Str "di",SoftBreak,Str "sospiri,",LineBreak,Str "\"che",Space,Str "l'aura",Space,Str "eterna",Space,Str "facevan",Space,Str "tremare.\""]]]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "each",Space,Str "man",Space,Str "fixed",Space,Str "his",Space,Str "eyes",Space,Str "before",Space,Str "his",Space,Str "feet."]]
+ ,Div ("",[],[])
+ [Plain [Str "Flowed",Space,Str "up",Space,Str "the",Space,Str "hill",Space,Str "and",Space,Str "down",Space,Str "King",Space,Str "William",Space,Str "Street,"]]
+ ,Div ("",[],[])
+ [Plain [Str "To",Space,Str "where",Space,Str "Saint",Space,Str "Mary",Space,Str "Woolnoth",Space,Str "kept",Space,Str "the",Space,Str "hours"]]
+ ,Div ("wasteland-content.xhtml#ln68",[],[])
+ [Plain [Str "With",Space,Str "a",Space,Str "dead",Space,Str "sound",Space,Str "on",Space,Str "the",Space,Str "final",Space,Str "stroke",Space,Str "of",Space,Str "nine.",Note [Para [Link ("",[],[]) [Str "68."] ("#wasteland-content.xhtml#ln68",""),Space,Str "A",Space,Str "phenomenon",Space,Str "which",Space,Str "I",Space,Str "have",Space,Str "often",Space,Str "noticed."]]]
+ ,Div ("",[],[])
+ [Plain [Str "There",Space,Str "I",Space,Str "saw",Space,Str "one",Space,Str "I",Space,Str "knew,",Space,Str "and",Space,Str "stopped",Space,Str "him,",Space,Str "crying",SoftBreak,Str "\"Stetson!"]]
+ ,Div ("",[],[])
+ [Plain [Str "\"You",Space,Str "who",Space,Str "were",Space,Str "with",Space,Str "me",Space,Str "in",Space,Str "the",Space,Str "ships",Space,Str "at",Space,Str "Mylae!",Span ("",["lnum"],[]) [Str "70"]]]
+ ,Div ("",[],[])
+ [Plain [Str "\"That",Space,Str "corpse",Space,Str "you",Space,Str "planted",Space,Str "last",Space,Str "year",Space,Str "in",Space,Str "your",Space,Str "garden,"]]
+ ,Div ("",[],[])
+ [Plain [Str "\"Has",Space,Str "it",Space,Str "begun",Space,Str "to",Space,Str "sprout?",Space,Str "Will",Space,Str "it",Space,Str "bloom",Space,Str "this",Space,Str "year?"]]
+ ,Div ("",[],[])
+ [Plain [Str "\"Or",Space,Str "has",Space,Str "the",Space,Str "sudden",Space,Str "frost",Space,Str "disturbed",Space,Str "its",Space,Str "bed?"]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("wasteland-content.xhtml#ln74",[],[])
+ [Plain [Str "\"Oh",Space,Str "keep",Space,Str "the",Space,Str "Dog",Space,Str "far",Space,Str "hence,",Space,Str "that's",Space,Str "friend",Space,Str "to",Space,Str "men,",Note [Para [Link ("",[],[]) [Str "74."] ("#wasteland-content.xhtml#ln74",""),Space,Str "Cf.",Space,Str "the",Space,Str "Dirge",Space,Str "in",Space,Str "Webster's",Space,Str "White",Space,Str "Devil",Space,Str "."]]]
+ ,Div ("",[],[])
+ [Plain [Str "\"Or",Space,Str "with",Space,Str "his",Space,Str "nails",Space,Str "he'll",Space,Str "dig",Space,Str "it",Space,Str "up",Space,Str "again!"]]
+ ,Div ("wasteland-content.xhtml#ln76",[],[])
+ [Plain [Str "\"You!",Space,Span ("",[],[("lang","fr")]) [Str "hypocrite",Space,Str "lecteur!",Space,Str "-",Space,Str "mon",Space,Str "semblable,",Space,Str "-",SoftBreak,Str "mon",Space,Str "frere"],Space,Str "!\"",Note [Para [Link ("",[],[]) [Str "76."] ("#wasteland-content.xhtml#ln76",""),Space,Str "V.",Space,Str "Baudelaire,",Space,Str "Preface",Space,Str "to",Space,Str "Fleurs",Space,Str "du",Space,Str "Mal."]]]
+ ,Div ("wasteland-content.xhtml#ch2",["section"],[])
+ [Header 2 ("",[],[]) [Str "II.",Space,Str "A",Space,Str "GAME",Space,Str "OF",Space,Str "CHESS"]
+ ,Div ("",["linegroup"],[])
+ [Div ("wasteland-content.xhtml#ln77",[],[])
+ [Plain [Str "The",Space,Str "Chair",Space,Str "she",Space,Str "sat",Space,Str "in,",Space,Str "like",Space,Str "a",Space,Str "burnished",Space,Str "throne,",Note [Para [Link ("",[],[]) [Str "77."] ("#wasteland-content.xhtml#ln77",""),Space,Str "Cf.",Space,Str "Antony",Space,Str "and",Space,Str "Cleopatra,",Space,Str "II.",Space,Str "ii.,",Space,Str "l.",Space,Str "190."]]]
+ ,Div ("",[],[])
+ [Plain [Str "Glowed",Space,Str "on",Space,Str "the",Space,Str "marble,",Space,Str "where",Space,Str "the",Space,Str "glass"]]
+ ,Div ("",[],[])
+ [Plain [Str "Held",Space,Str "up",Space,Str "by",Space,Str "standards",Space,Str "wrought",Space,Str "with",Space,Str "fruited",Space,Str "vines"]]
+ ,Div ("",[],[])
+ [Plain [Str "From",Space,Str "which",Space,Str "a",Space,Str "golden",Space,Str "Cupidon",Space,Str "peeped",Space,Str "out",Span ("",["lnum"],[]) [Str "80"]]]
+ ,Div ("",[],[])
+ [Plain [Str "(Another",Space,Str "hid",Space,Str "his",Space,Str "eyes",Space,Str "behind",Space,Str "his",Space,Str "wing)"]]
+ ,Div ("",[],[])
+ [Plain [Str "Doubled",Space,Str "the",Space,Str "flames",Space,Str "of",Space,Str "sevenbranched",Space,Str "candelabra"]]
+ ,Div ("",[],[])
+ [Plain [Str "Reflecting",Space,Str "light",Space,Str "upon",Space,Str "the",Space,Str "table",Space,Str "as"]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "glitter",Space,Str "of",Space,Str "her",Space,Str "jewels",Space,Str "rose",Space,Str "to",Space,Str "meet",Space,Str "it,"]]
+ ,Div ("",[],[])
+ [Plain [Str "From",Space,Str "satin",Space,Str "cases",Space,Str "poured",Space,Str "in",Space,Str "rich",Space,Str "profusion;"]]
+ ,Div ("",[],[])
+ [Plain [Str "In",Space,Str "vials",Space,Str "of",Space,Str "ivory",Space,Str "and",Space,Str "coloured",Space,Str "glass"]]
+ ,Div ("",[],[])
+ [Plain [Str "Unstoppered,",Space,Str "lurked",Space,Str "her",Space,Str "strange",Space,Str "synthetic",Space,Str "perfumes,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Unguent,",Space,Str "powdered,",Space,Str "or",Space,Str "liquid",Space,Str "-",Space,Str "troubled,",Space,Str "confused"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "drowned",Space,Str "the",Space,Str "sense",Space,Str "in",Space,Str "odours;",Space,Str "stirred",Space,Str "by",Space,Str "the",Space,Str "air"]]
+ ,Div ("",[],[])
+ [Plain [Str "That",Space,Str "freshened",Space,Str "from",Space,Str "the",Space,Str "window,",Space,Str "these",Space,Str "ascended",Span ("",["lnum"],[]) [Str "90"]]]
+ ,Div ("",[],[])
+ [Plain [Str "In",Space,Str "fattening",Space,Str "the",Space,Str "prolonged",Space,Str "candle-flames,"]]
+ ,Div ("wasteland-content.xhtml#ln92",[],[])
+ [Plain [Str "Flung",Space,Str "their",Space,Str "smoke",Space,Str "into",Space,Str "the",Space,Str "laquearia,",Note [Para [Link ("",[],[]) [Str "92."] ("#wasteland-content.xhtml#ln92",""),Space,Str "Laquearia.",Space,Str "V.",Space,Str "Aeneid,",Space,Str "I.",Space,Str "726:"],BlockQuote [Para [Str "dependent",Space,Str "lychni",Space,Str "laquearibus",Space,Str "aureis",Space,Str "incensi,",Space,Str "et",Space,Str "noctem",SoftBreak,Str "flammis",LineBreak,Str "funalia",Space,Str "vincunt."]]]]
+ ,Div ("",[],[])
+ [Plain [Str "Stirring",Space,Str "the",Space,Str "pattern",Space,Str "on",Space,Str "the",Space,Str "coffered",Space,Str "ceiling."]]
+ ,Div ("",[],[])
+ [Plain [Str "Huge",Space,Str "sea-wood",Space,Str "fed",Space,Str "with",Space,Str "copper"]]
+ ,Div ("",[],[])
+ [Plain [Str "Burned",Space,Str "green",Space,Str "and",Space,Str "orange,",Space,Str "framed",Space,Str "by",Space,Str "the",Space,Str "coloured",Space,Str "stone,"]]
+ ,Div ("",[],[])
+ [Plain [Str "In",Space,Str "which",Space,Str "sad",Space,Str "light",Space,Str "a",Space,Str "carved",Space,Str "dolphin",Space,Str "swam."]]
+ ,Div ("",[],[])
+ [Plain [Str "Above",Space,Str "the",Space,Str "antique",Space,Str "mantel",Space,Str "was",Space,Str "displayed"]]
+ ,Div ("wasteland-content.xhtml#ln98",[],[])
+ [Plain [Str "As",Space,Str "though",Space,Str "a",Space,Str "window",Space,Str "gave",Space,Str "upon",Space,Str "the",Space,Str "sylvan",Space,Str "scene",Note [Para [Link ("",[],[]) [Str "98."] ("#wasteland-content.xhtml#ln98",""),Space,Str "Sylvan",Space,Str "scene.",Space,Str "V.",Space,Str "Milton,",Space,Str "Paradise",Space,Str "Lost,",Space,Str "iv.",Space,Str "140."]]]
+ ,Div ("wasteland-content.xhtml#ln99",[],[])
+ [Plain [Str "The",Space,Str "change",Space,Str "of",Space,Str "Philomel,",Space,Str "by",Space,Str "the",Space,Str "barbarous",Space,Str "king",Note [Para [Link ("",[],[]) [Str "99."] ("#wasteland-content.xhtml#ln99",""),Space,Str "V.",Space,Str "Ovid,",Space,Str "Metamorphoses,",Space,Str "vi,",Space,Str "Philomela."]]]
+ ,Div ("wasteland-content.xhtml#ln100",[],[])
+ [Plain [Str "So",Space,Str "rudely",Space,Str "forced;",Space,Str "yet",Space,Str "there",Space,Str "the",Space,Str "nightingale",Note [Para [Link ("",[],[]) [Str "100."] ("#wasteland-content.xhtml#ln100",""),Space,Str "Cf.",Space,Str "Part",Space,Str "III,",Space,Str "l.",Space,Str "204."]]]
+ ,Div ("",[],[])
+ [Plain [Str "Filled",Space,Str "all",Space,Str "the",Space,Str "desert",Space,Str "with",Space,Str "inviolable",Space,Str "voice"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "still",Space,Str "she",Space,Str "cried,",Space,Str "and",Space,Str "still",Space,Str "the",Space,Str "world",Space,Str "pursues,"]]
+ ,Div ("",[],[])
+ [Plain [Str "\"Jug",Space,Str "Jug\"",Space,Str "to",Space,Str "dirty",Space,Str "ears."]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "other",Space,Str "withered",Space,Str "stumps",Space,Str "of",Space,Str "time"]]
+ ,Div ("",[],[])
+ [Plain [Str "Were",Space,Str "told",Space,Str "upon",Space,Str "the",Space,Str "walls;",Space,Str "staring",Space,Str "forms"]]
+ ,Div ("",[],[])
+ [Plain [Str "Leaned",Space,Str "out,",Space,Str "leaning,",Space,Str "hushing",Space,Str "the",Space,Str "room",Space,Str "enclosed."]]
+ ,Div ("",[],[])
+ [Plain [Str "Footsteps",Space,Str "shuffled",Space,Str "on",Space,Str "the",Space,Str "stair."]]
+ ,Div ("",[],[])
+ [Plain [Str "Under",Space,Str "the",Space,Str "firelight,",Space,Str "under",Space,Str "the",Space,Str "brush,",Space,Str "her",Space,Str "hair"]]
+ ,Div ("",[],[])
+ [Plain [Str "Spread",Space,Str "out",Space,Str "in",Space,Str "fiery",Space,Str "points"]]
+ ,Div ("",[],[])
+ [Plain [Str "Glowed",Space,Str "into",Space,Str "words,",Space,Str "then",Space,Str "would",Space,Str "be",Space,Str "savagely",Space,Str "still.",Span ("",["lnum"],[]) [Str "110"]]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "\"My",Space,Str "nerves",Space,Str "are",Space,Str "bad",Space,Str "to-night.",Space,Str "Yes,",Space,Str "bad.",Space,Str "Stay",Space,Str "with",Space,Str "me."]]
+ ,Div ("",[],[])
+ [Plain [Str "\"Speak",Space,Str "to",Space,Str "me.",Space,Str "Why",Space,Str "do",Space,Str "you",Space,Str "never",Space,Str "speak.",Space,Str "Speak."]]
+ ,Div ("",[],[])
+ [Plain [Str "\"What",Space,Str "are",Space,Str "you",Space,Str "thinking",Space,Str "of?",Space,Str "What",Space,Str "thinking?",Space,Str "What?"]]
+ ,Div ("",[],[])
+ [Plain [Str "\"I",Space,Str "never",Space,Str "know",Space,Str "what",Space,Str "you",Space,Str "are",Space,Str "thinking.",Space,Str "Think.\""]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("wasteland-content.xhtml#ln115",[],[])
+ [Plain [Str "I",Space,Str "think",Space,Str "we",Space,Str "are",Space,Str "in",Space,Str "rats'",Space,Str "alley",Note [Para [Link ("",[],[]) [Str "115."] ("#wasteland-content.xhtml#ln115",""),Space,Str "Cf.",Space,Str "Part",Space,Str "III,",Space,Str "l.",Space,Str "195."]]]
+ ,Div ("",[],[])
+ [Plain [Str "Where",Space,Str "the",Space,Str "dead",Space,Str "men",Space,Str "lost",Space,Str "their",Space,Str "bones."]]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "\"What",Space,Str "is",Space,Str "that",Space,Str "noise?\""]]
+ ,Div ("wasteland-content.xhtml#ln118",["indent"],[])
+ [Plain [Str "The",Space,Str "wind",Space,Str "under",Space,Str "the",Space,Str "door.",Note [Para [Link ("",[],[]) [Str "118."] ("#wasteland-content.xhtml#ln118",""),Space,Str "Cf.",Space,Str "Webster:"],BlockQuote [Para [Str "\"Is",Space,Str "the",Space,Str "wind",Space,Str "in",Space,Str "that",Space,Str "door",Space,Str "still?\""]]]]
+ ,Div ("",[],[])
+ [Plain [Str "\"What",Space,Str "is",Space,Str "that",Space,Str "noise",Space,Str "now?",Space,Str "What",Space,Str "is",Space,Str "the",Space,Str "wind",Space,Str "doing?\""]]
+ ,Div ("",["indent"],[])
+ [Plain [Str "Nothing",Space,Str "again",Space,Str "nothing.",Span ("",["lnum"],[]) [Str "120"]]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "\"Do"]]
+ ,Div ("",[],[])
+ [Plain [Str "\"You",Space,Str "know",Space,Str "nothing?",Space,Str "Do",Space,Str "you",Space,Str "see",Space,Str "nothing?",Space,Str "Do",Space,Str "you",Space,Str "remember"]]
+ ,Div ("",[],[])
+ [Plain [Str "\"Nothing?\""]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "I",Space,Str "remember"]]
+ ,Div ("",[],[])
+ [Plain [Str "Those",Space,Str "are",Space,Str "pearls",Space,Str "that",Space,Str "were",Space,Str "his",Space,Str "eyes."]]
+ ,Div ("wasteland-content.xhtml#ln126",[],[])
+ [Plain [Str "\"Are",Space,Str "you",Space,Str "alive,",Space,Str "or",Space,Str "not?",Space,Str "Is",Space,Str "there",Space,Str "nothing",Space,Str "in",Space,Str "your",Space,Str "head?\"",Note [Para [Link ("",[],[]) [Str "126."] ("#wasteland-content.xhtml#ln126",""),Space,Str "Cf.",Space,Str "Part",Space,Str "I,",Space,Str "l.",Space,Str "37,",Space,Str "48."]]]
+ ,Div ("",[],[])
+ [Plain [Str "But"]]
+ ,Div ("",[],[])
+ [Plain [Str "O",Space,Str "O",Space,Str "O",Space,Str "O",Space,Str "that",Space,Str "Shakespeherian",Space,Str "Rag\8213"]]
+ ,Div ("",[],[])
+ [Plain [Str "It's",Space,Str "so",Space,Str "elegant"]]
+ ,Div ("",[],[])
+ [Plain [Str "So",Space,Str "intelligent",Span ("",["lnum"],[]) [Str "130"]]]
+ ,Div ("",[],[])
+ [Plain [Str "\"What",Space,Str "shall",Space,Str "I",Space,Str "do",Space,Str "now?",Space,Str "What",Space,Str "shall",Space,Str "I",Space,Str "do?\""]]
+ ,Div ("",[],[])
+ [Plain [Str "I",Space,Str "shall",Space,Str "rush",Space,Str "out",Space,Str "as",Space,Str "I",Space,Str "am,",Space,Str "and",Space,Str "walk",Space,Str "the",Space,Str "street"]]
+ ,Div ("",[],[])
+ [Plain [Str "\"With",Space,Str "my",Space,Str "hair",Space,Str "down,",Space,Str "so.",Space,Str "What",Space,Str "shall",Space,Str "we",Space,Str "do",Space,Str "to-morrow?"]]
+ ,Div ("",[],[])
+ [Plain [Str "\"What",Space,Str "shall",Space,Str "we",Space,Str "ever",Space,Str "do?\""]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "hot",Space,Str "water",Space,Str "at",Space,Str "ten."]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "if",Space,Str "it",Space,Str "rains,",Space,Str "a",Space,Str "closed",Space,Str "car",Space,Str "at",Space,Str "four."]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "we",Space,Str "shall",Space,Str "play",Space,Str "a",Space,Str "game",Space,Str "of",Space,Str "chess,"]]
+ ,Div ("wasteland-content.xhtml#ln138",[],[])
+ [Plain [Str "Pressing",Space,Str "lidless",Space,Str "eyes",Space,Str "and",Space,Str "waiting",Space,Str "for",Space,Str "a",Space,Str "knock",Space,Str "upon",Space,Str "the",Space,Str "door.",Note [Para [Link ("",[],[]) [Str "138."] ("#wasteland-content.xhtml#ln138",""),Space,Str "Cf.",Space,Str "the",Space,Str "game",Space,Str "of",Space,Str "chess",Space,Str "in",Space,Str "Middleton's",Space,Str "Women",Space,Str "beware",Space,Str "Women."]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "When",Space,Str "Lil's",Space,Str "husband",Space,Str "got",Space,Str "demobbed,",Space,Str "I",Space,Str "said",Space,Str "-"]]
+ ,Div ("",[],[])
+ [Plain [Str "I",Space,Str "didn't",Space,Str "mince",Space,Str "my",Space,Str "words,",Space,Str "I",Space,Str "said",Space,Str "to",Space,Str "her",Space,Str "myself,",Span ("",["lnum"],[]) [Str "140"]]]
+ ,Div ("",[],[])
+ [Plain [Str "HURRY",Space,Str "UP",Space,Str "PLEASE",Space,Str "ITS",Space,Str "TIME"]]
+ ,Div ("",[],[])
+ [Plain [Str "Now",Space,Str "Albert's",Space,Str "coming",Space,Str "back,",Space,Str "make",Space,Str "yourself",Space,Str "a",Space,Str "bit",Space,Str "smart."]]
+ ,Div ("",[],[])
+ [Plain [Str "He'll",Space,Str "want",Space,Str "to",Space,Str "know",Space,Str "what",Space,Str "you",Space,Str "done",Space,Str "with",Space,Str "that",Space,Str "money",Space,Str "he",Space,Str "gave",SoftBreak,Str "you"]]
+ ,Div ("",[],[])
+ [Plain [Str "To",Space,Str "get",Space,Str "yourself",Space,Str "some",Space,Str "teeth.",Space,Str "He",Space,Str "did,",Space,Str "I",Space,Str "was",Space,Str "there."]]
+ ,Div ("",[],[])
+ [Plain [Str "You",Space,Str "have",Space,Str "them",Space,Str "all",Space,Str "out,",Space,Str "Lil,",Space,Str "and",Space,Str "get",Space,Str "a",Space,Str "nice",Space,Str "set,"]]
+ ,Div ("",[],[])
+ [Plain [Str "He",Space,Str "said,",Space,Str "I",Space,Str "swear,",Space,Str "I",Space,Str "can't",Space,Str "bear",Space,Str "to",Space,Str "look",Space,Str "at",Space,Str "you."]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "no",Space,Str "more",Space,Str "can't",Space,Str "I,",Space,Str "I",Space,Str "said,",Space,Str "and",Space,Str "think",Space,Str "of",Space,Str "poor",Space,Str "Albert,"]]
+ ,Div ("",[],[])
+ [Plain [Str "He's",Space,Str "been",Space,Str "in",Space,Str "the",Space,Str "army",Space,Str "four",Space,Str "years,",Space,Str "he",Space,Str "wants",Space,Str "a",Space,Str "good",Space,Str "time,"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "if",Space,Str "you",Space,Str "don't",Space,Str "give",Space,Str "it",Space,Str "him,",Space,Str "there's",Space,Str "others",Space,Str "will,",Space,Str "I",SoftBreak,Str "said."]]
+ ,Div ("",[],[])
+ [Plain [Str "Oh",Space,Str "is",Space,Str "there,",Space,Str "she",Space,Str "said.",Space,Str "Something",Space,Str "o'",Space,Str "that,",Space,Str "I",Space,Str "said.",Span ("",["lnum"],[]) [Str "150"]]]
+ ,Div ("",[],[])
+ [Plain [Str "Then",Space,Str "I'll",Space,Str "know",Space,Str "who",Space,Str "to",Space,Str "thank,",Space,Str "she",Space,Str "said,",Space,Str "and",Space,Str "give",Space,Str "me",Space,Str "a",Space,Str "straight",SoftBreak,Str "look."]]
+ ,Div ("",[],[])
+ [Plain [Str "HURRY",Space,Str "UP",Space,Str "PLEASE",Space,Str "ITS",Space,Str "TIME"]]
+ ,Div ("",[],[])
+ [Plain [Str "If",Space,Str "you",Space,Str "don't",Space,Str "like",Space,Str "it",Space,Str "you",Space,Str "can",Space,Str "get",Space,Str "on",Space,Str "with",Space,Str "it,",Space,Str "I",Space,Str "said."]]
+ ,Div ("",[],[])
+ [Plain [Str "Others",Space,Str "can",Space,Str "pick",Space,Str "and",Space,Str "choose",Space,Str "if",Space,Str "you",Space,Str "can't."]]
+ ,Div ("",[],[])
+ [Plain [Str "But",Space,Str "if",Space,Str "Albert",Space,Str "makes",Space,Str "off,",Space,Str "it",Space,Str "won't",Space,Str "be",Space,Str "for",Space,Str "lack",Space,Str "of",SoftBreak,Str "telling."]]
+ ,Div ("",[],[])
+ [Plain [Str "You",Space,Str "ought",Space,Str "to",Space,Str "be",Space,Str "ashamed,",Space,Str "I",Space,Str "said,",Space,Str "to",Space,Str "look",Space,Str "so",Space,Str "antique."]]
+ ,Div ("",[],[])
+ [Plain [Str "(And",Space,Str "her",Space,Str "only",Space,Str "thirty-one.)"]]
+ ,Div ("",[],[])
+ [Plain [Str "I",Space,Str "can't",Space,Str "help",Space,Str "it,",Space,Str "she",Space,Str "said,",Space,Str "pulling",Space,Str "a",Space,Str "long",Space,Str "face,"]]
+ ,Div ("",[],[])
+ [Plain [Str "It's",Space,Str "them",Space,Str "pills",Space,Str "I",Space,Str "took,",Space,Str "to",Space,Str "bring",Space,Str "it",Space,Str "off,",Space,Str "she",Space,Str "said."]]
+ ,Div ("",[],[])
+ [Plain [Str "(She's",Space,Str "had",Space,Str "five",Space,Str "already,",Space,Str "and",Space,Str "nearly",Space,Str "died",Space,Str "of",Space,Str "young",Space,Str "George.)",Span ("",["lnum"],[]) [Str "160"]]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "chemist",Space,Str "said",Space,Str "it",Space,Str "would",Space,Str "be",Space,Str "all",Space,Str "right,",Space,Str "but",Space,Str "I've",Space,Str "never",Space,Str "been",Space,Str "the",SoftBreak,Str "same."]]
+ ,Div ("",[],[])
+ [Plain [Str "You",Space,Emph [Str "are"],Space,Str "a",Space,Str "proper",Space,Str "fool,",Space,Str "I",Space,Str "said."]]
+ ,Div ("",[],[])
+ [Plain [Str "Well,",Space,Str "if",Space,Str "Albert",Space,Str "won't",Space,Str "leave",Space,Str "you",Space,Str "alone,",Space,Str "there",Space,Str "it",Space,Str "is,",Space,Str "I",SoftBreak,Str "said,"]]
+ ,Div ("",[],[])
+ [Plain [Str "What",Space,Str "you",Space,Str "get",Space,Str "married",Space,Str "for",Space,Str "if",Space,Str "you",Space,Str "don't",Space,Str "want",Space,Str "children?"]]
+ ,Div ("",[],[])
+ [Plain [Str "HURRY",Space,Str "UP",Space,Str "PLEASE",Space,Str "ITS",Space,Str "TIME"]]
+ ,Div ("",[],[])
+ [Plain [Str "Well,",Space,Str "that",Space,Str "Sunday",Space,Str "Albert",Space,Str "was",Space,Str "home,",Space,Str "they",Space,Str "had",Space,Str "a",Space,Str "hot",SoftBreak,Str "gammon,"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "they",Space,Str "asked",Space,Str "me",Space,Str "in",Space,Str "to",Space,Str "dinner,",Space,Str "to",Space,Str "get",Space,Str "the",Space,Str "beauty",Space,Str "of",Space,Str "it",SoftBreak,Str "hot\8213"]]
+ ,Div ("",[],[])
+ [Plain [Str "HURRY",Space,Str "UP",Space,Str "PLEASE",Space,Str "ITS",Space,Str "TIME"]]
+ ,Div ("",[],[])
+ [Plain [Str "HURRY",Space,Str "UP",Space,Str "PLEASE",Space,Str "ITS",Space,Str "TIME"]]
+ ,Div ("",[],[])
+ [Plain [Str "Goonight",Space,Str "Bill.",Space,Str "Goonight",Space,Str "Lou.",Space,Str "Goonight",Space,Str "May.",Space,Str "Goonight.",Span ("",["lnum"],[]) [Str "170"]]]
+ ,Div ("",[],[])
+ [Plain [Str "Ta",Space,Str "ta.",Space,Str "Goonight.",Space,Str "Goonight."]]
+ ,Div ("",[],[])
+ [Plain [Str "Good",Space,Str "night,",Space,Str "ladies,",Space,Str "good",Space,Str "night,",Space,Str "sweet",Space,Str "ladies,",Space,Str "good",Space,Str "night,",Space,Str "good",SoftBreak,Str "night."]]]
+ ,RawBlock (Format "html") "</section>"
+ ,Div ("wasteland-content.xhtml#ch3",["section"],[])
+ [Header 2 ("",[],[]) [Str "III.",Space,Str "THE",Space,Str "FIRE",Space,Str "SERMON"]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "The",Space,Str "river's",Space,Str "tent",Space,Str "is",Space,Str "broken:",Space,Str "the",Space,Str "last",Space,Str "fingers",Space,Str "of",Space,Str "leaf"]]
+ ,Div ("",[],[])
+ [Plain [Str "Clutch",Space,Str "and",Space,Str "sink",Space,Str "into",Space,Str "the",Space,Str "wet",Space,Str "bank.",Space,Str "The",Space,Str "wind"]]
+ ,Div ("",[],[])
+ [Plain [Str "Crosses",Space,Str "the",Space,Str "brown",Space,Str "land,",Space,Str "unheard.",Space,Str "The",Space,Str "nymphs",Space,Str "are",SoftBreak,Str "departed."]]
+ ,Div ("wasteland-content.xhtml#ln176",[],[])
+ [Plain [Str "Sweet",Space,Str "Thames,",Space,Str "run",Space,Str "softly,",Space,Str "till",Space,Str "I",Space,Str "end",Space,Str "my",Space,Str "song.",Note [Para [Link ("",[],[]) [Str "176."] ("#wasteland-content.xhtml#ln176",""),Space,Str "V.",Space,Str "Spenser,",Space,Str "Prothalamion."]]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "river",Space,Str "bears",Space,Str "no",Space,Str "empty",Space,Str "bottles,",Space,Str "sandwich",Space,Str "papers,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Silk",Space,Str "handkerchiefs,",Space,Str "cardboard",Space,Str "boxes,",Space,Str "cigarette",Space,Str "ends"]]
+ ,Div ("",[],[])
+ [Plain [Str "Or",Space,Str "other",Space,Str "testimony",Space,Str "of",Space,Str "summer",Space,Str "nights.",Space,Str "The",Space,Str "nymphs",Space,Str "are",SoftBreak,Str "departed."]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "their",Space,Str "friends,",Space,Str "the",Space,Str "loitering",Space,Str "heirs",Space,Str "of",Space,Str "city",Space,Str "directors;",Span ("",["lnum"],[]) [Str "180"]]]
+ ,Div ("",[],[])
+ [Plain [Str "Departed,",Space,Str "have",Space,Str "left",Space,Str "no",Space,Str "addresses."]]
+ ,Div ("",[],[])
+ [Plain [Str "By",Space,Str "the",Space,Str "waters",Space,Str "of",Space,Str "Leman",Space,Str "I",Space,Str "sat",Space,Str "down",Space,Str "and",Space,Str "wept",Space,Str ".",Space,Str ".",Space,Str "."]]
+ ,Div ("",[],[])
+ [Plain [Str "Sweet",Space,Str "Thames,",Space,Str "run",Space,Str "softly",Space,Str "till",Space,Str "I",Space,Str "end",Space,Str "my",Space,Str "song,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Sweet",Space,Str "Thames,",Space,Str "run",Space,Str "softly,",Space,Str "for",Space,Str "I",Space,Str "speak",Space,Str "not",Space,Str "loud",Space,Str "or",Space,Str "long."]]
+ ,Div ("",[],[])
+ [Plain [Str "But",Space,Str "at",Space,Str "my",Space,Str "back",Space,Str "in",Space,Str "a",Space,Str "cold",Space,Str "blast",Space,Str "I",Space,Str "hear"]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "rattle",Space,Str "of",Space,Str "the",Space,Str "bones,",Space,Str "and",Space,Str "chuckle",Space,Str "spread",Space,Str "from",Space,Str "ear",Space,Str "to",SoftBreak,Str "ear."]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "A",Space,Str "rat",Space,Str "crept",Space,Str "softly",Space,Str "through",Space,Str "the",Space,Str "vegetation"]]
+ ,Div ("",[],[])
+ [Plain [Str "Dragging",Space,Str "its",Space,Str "slimy",Space,Str "belly",Space,Str "on",Space,Str "the",Space,Str "bank"]]
+ ,Div ("",[],[])
+ [Plain [Str "While",Space,Str "I",Space,Str "was",Space,Str "fishing",Space,Str "in",Space,Str "the",Space,Str "dull",Space,Str "canal"]]
+ ,Div ("",[],[])
+ [Plain [Str "On",Space,Str "a",Space,Str "winter",Space,Str "evening",Space,Str "round",Space,Str "behind",Space,Str "the",Space,Str "gashouse",Span ("",["lnum"],[]) [Str "190"]]]
+ ,Div ("",[],[])
+ [Plain [Str "Musing",Space,Str "upon",Space,Str "the",Space,Str "king",Space,Str "my",Space,Str "brother's",Space,Str "wreck"]]
+ ,Div ("wasteland-content.xhtml#ln192",[],[])
+ [Plain [Str "And",Space,Str "on",Space,Str "the",Space,Str "king",Space,Str "my",Space,Str "father's",Space,Str "death",Space,Str "before",Space,Str "him.",Note [Para [Link ("",[],[]) [Str "192."] ("#wasteland-content.xhtml#ln192",""),Space,Str "Cf.",Space,Str "The",Space,Str "Tempest,",Space,Str "I.",Space,Str "ii."]]]
+ ,Div ("",[],[])
+ [Plain [Str "White",Space,Str "bodies",Space,Str "naked",Space,Str "on",Space,Str "the",Space,Str "low",Space,Str "damp",Space,Str "ground"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "bones",Space,Str "cast",Space,Str "in",Space,Str "a",Space,Str "little",Space,Str "low",Space,Str "dry",Space,Str "garret,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Rattled",Space,Str "by",Space,Str "the",Space,Str "rat's",Space,Str "foot",Space,Str "only,",Space,Str "year",Space,Str "to",Space,Str "year."]]
+ ,Div ("wasteland-content.xhtml#ln196",[],[])
+ [Plain [Str "But",Space,Str "at",Space,Str "my",Space,Str "back",Space,Str "from",Space,Str "time",Space,Str "to",Space,Str "time",Space,Str "I",Space,Str "hear",Note [Para [Link ("",[],[]) [Str "196."] ("#wasteland-content.xhtml#ln196",""),Space,Str "Cf.",Space,Str "Marvell,",Space,Str "To",Space,Str "His",Space,Str "Coy",Space,Str "Mistress."]]]
+ ,Div ("wasteland-content.xhtml#ln197",[],[])
+ [Plain [Str "The",Space,Str "sound",Space,Str "of",Space,Str "horns",Space,Str "and",Space,Str "motors,",Space,Str "which",Space,Str "shall",Space,Str "bring",Note [Para [Link ("",[],[]) [Str "197."] ("#wasteland-content.xhtml#ln197",""),Space,Str "Cf.",Space,Str "Day,",Space,Str "Parliament",Space,Str "of",Space,Str "Bees:"],BlockQuote [Div ("",[],[]) [Div ("",[],[]) [Plain [Str "\"When",Space,Str "of",Space,Str "the",Space,Str "sudden,",Space,Str "listening,",Space,Str "you",Space,Str "shall",SoftBreak,Str "hear,"]],Div ("",[],[]) [Plain [Str "\"A",Space,Str "noise",Space,Str "of",Space,Str "horns",Space,Str "and",Space,Str "hunting,",Space,Str "which",Space,Str "shall",SoftBreak,Str "bring"]],Div ("",[],[]) [Plain [Str "\"Actaeon",Space,Str "to",Space,Str "Diana",Space,Str "in",Space,Str "the",Space,Str "spring,"]],Div ("",[],[]) [Plain [Str "\"Where",Space,Str "all",Space,Str "shall",Space,Str "see",Space,Str "her",Space,Str "naked",Space,Str "skin",Space,Str ".",Space,Str ".",Space,Str ".\""]]]]]]
+ ,Div ("",[],[])
+ [Plain [Str "Sweeney",Space,Str "to",Space,Str "Mrs.",Space,Str "Porter",Space,Str "in",Space,Str "the",Space,Str "spring."]]
+ ,Div ("wasteland-content.xhtml#ln199",[],[])
+ [Plain [Str "O",Space,Str "the",Space,Str "moon",Space,Str "shone",Space,Str "bright",Space,Str "on",Space,Str "Mrs.",Space,Str "Porter",Note [Para [Link ("",[],[]) [Str "199."] ("#wasteland-content.xhtml#ln199",""),Space,Str "I",Space,Str "do",Space,Str "not",Space,Str "know",Space,Str "the",Space,Str "origin",Space,Str "of",Space,Str "the",Space,Str "ballad",Space,Str "from",Space,Str "which",Space,Str "these",Space,Str "lines",Space,Str "are",SoftBreak,Str "taken:",Space,Str "it",Space,Str "was",Space,Str "reported",Space,Str "to",Space,Str "me",Space,Str "from",Space,Str "Sydney,",Space,Str "Australia."]]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "on",Space,Str "her",Space,Str "daughter",Span ("",["lnum"],[]) [Str "200"]]]
+ ,Div ("",[],[])
+ [Plain [Str "They",Space,Str "wash",Space,Str "their",Space,Str "feet",Space,Str "in",Space,Str "soda",Space,Str "water"]]
+ ,Div ("wasteland-content.xhtml#ln202",[],[("lang","fr")])
+ [Plain [Emph [Str "Et",Space,Str "O",Space,Str "ces",Space,Str "voix",Space,Str "d'enfants,",Space,Str "chantant",Space,Str "dans",Space,Str "la",Space,Str "coupole"],Str "!",Note [Para [Link ("",[],[]) [Str "202."] ("#wasteland-content.xhtml#ln202",""),Space,Str "V.",Space,Str "Verlaine,",Space,Str "Parsifal."]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "Twit",Space,Str "twit",Space,Str "twit"]]
+ ,Div ("",[],[])
+ [Plain [Str "Jug",Space,Str "jug",Space,Str "jug",Space,Str "jug",Space,Str "jug",Space,Str "jug"]]
+ ,Div ("",[],[])
+ [Plain [Str "So",Space,Str "rudely",Space,Str "forc'd."]]
+ ,Div ("",[],[])
+ [Plain [Str "Tereu"]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "Unreal",Space,Str "City"]]
+ ,Div ("",[],[])
+ [Plain [Str "Under",Space,Str "the",Space,Str "brown",Space,Str "fog",Space,Str "of",Space,Str "a",Space,Str "winter",Space,Str "noon"]]
+ ,Div ("",[],[])
+ [Plain [Str "Mr.",Space,Str "Eugenides,",Space,Str "the",Space,Str "Smyrna",Space,Str "merchant"]]
+ ,Div ("wasteland-content.xhtml#ln210",[],[])
+ [Plain [Str "Unshaven,",Space,Str "with",Space,Str "a",Space,Str "pocket",Space,Str "full",Space,Str "of",Space,Str "currants",Note [Para [Link ("",[],[]) [Str "210."] ("#wasteland-content.xhtml#ln210",""),Space,Str "The",Space,Str "currants",Space,Str "were",Space,Str "quoted",Space,Str "at",Space,Str "a",Space,Str "price",Space,Str "\"cost",Space,Str "insurance",Space,Str "and",Space,Str "freight",Space,Str "to",SoftBreak,Str "London\";",Space,Str "and",Space,Str "the",Space,Str "Bill",Space,Str "of",Space,Str "Lading",Space,Str "etc.",Space,Str "were",Space,Str "to",Space,Str "be",Space,Str "handed",Space,Str "to",Space,Str "the",Space,Str "buyer",Space,Str "upon",SoftBreak,Str "payment",Space,Str "of",Space,Str "the",Space,Str "sight",Space,Str "draft."]]]
+ ,Div ("",[],[])
+ [Plain [Str "C.i.f.",Space,Str "London:",Space,Str "documents",Space,Str "at",Space,Str "sight,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Asked",Space,Str "me",Space,Str "in",Space,Str "demotic",Space,Str "French"]]
+ ,Div ("",[],[])
+ [Plain [Str "To",Space,Str "luncheon",Space,Str "at",Space,Str "the",Space,Str "Cannon",Space,Str "Street",Space,Str "Hotel"]]
+ ,Div ("",[],[])
+ [Plain [Str "Followed",Space,Str "by",Space,Str "a",Space,Str "weekend",Space,Str "at",Space,Str "the",Space,Str "Metropole."]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "At",Space,Str "the",Space,Str "violet",Space,Str "hour,",Space,Str "when",Space,Str "the",Space,Str "eyes",Space,Str "and",Space,Str "back"]]
+ ,Div ("",[],[])
+ [Plain [Str "Turn",Space,Str "upward",Space,Str "from",Space,Str "the",Space,Str "desk,",Space,Str "when",Space,Str "the",Space,Str "human",Space,Str "engine",Space,Str "waits"]]
+ ,Div ("",[],[])
+ [Plain [Str "Like",Space,Str "a",Space,Str "taxi",Space,Str "throbbing",Space,Str "waiting,"]]
+ ,Div ("wasteland-content.xhtml#ln218",[],[])
+ [Plain [Str "I",Space,Str "Tiresias,",Space,Str "though",Space,Str "blind,",Space,Str "throbbing",Space,Str "between",Space,Str "two",Space,Str "lives,",Note [Para [Link ("",[],[]) [Str "218."] ("#wasteland-content.xhtml#ln218",""),Space,Str "Tiresias,",Space,Str "although",Space,Str "a",Space,Str "mere",Space,Str "spectator",Space,Str "and",Space,Str "not",Space,Str "indeed",Space,Str "a",Space,Str "\"character,\"",Space,Str "is",SoftBreak,Str "yet",Space,Str "the",Space,Str "most",Space,Str "important",Space,Str "personage",Space,Str "in",Space,Str "the",Space,Str "poem,",Space,Str "uniting",Space,Str "all",Space,Str "the",Space,Str "rest.",Space,Str "Just",SoftBreak,Str "as",Space,Str "the",Space,Str "one-eyed",Space,Str "merchant,",Space,Str "seller",Space,Str "of",Space,Str "currants,",Space,Str "melts",Space,Str "into",Space,Str "the",Space,Str "Phoenician",SoftBreak,Str "Sailor,",Space,Str "and",Space,Str "the",Space,Str "latter",Space,Str "is",Space,Str "not",Space,Str "wholly",Space,Str "distinct",Space,Str "from",Space,Str "Ferdinand",Space,Str "Prince",Space,Str "of",SoftBreak,Str "Naples,",Space,Str "so",Space,Str "all",Space,Str "the",Space,Str "women",Space,Str "are",Space,Str "one",Space,Str "woman,",Space,Str "and",Space,Str "the",Space,Str "two",Space,Str "sexes",Space,Str "meet",Space,Str "in",SoftBreak,Str "Tiresias.",Space,Str "What",Space,Str "Tiresias",Space,Str "sees,",Space,Str "in",Space,Str "fact,",Space,Str "is",Space,Str "the",Space,Str "substance",Space,Str "of",Space,Str "the",Space,Str "poem.",Space,Str "The",SoftBreak,Str "whole",Space,Str "passage",Space,Str "from",Space,Str "Ovid",Space,Str "is",Space,Str "of",Space,Str "great",Space,Str "anthropological",Space,Str "interest:"],BlockQuote [Para [Str "'.",Space,Str ".",Space,Str ".",Space,Str "Cum",Space,Str "Iunone",Space,Str "iocos",Space,Str "et",Space,Str "maior",Space,Str "vestra",Space,Str "profecto",Space,Str "est",LineBreak,Str "Quam,",Space,Str "quae",SoftBreak,Str "contingit",Space,Str "maribus,'",Space,Str "dixisse,",Space,Str "'voluptas.'",LineBreak,Str "Illa",Space,Str "negat;",Space,Str "placuit",SoftBreak,Str "quae",Space,Str "sit",Space,Str "sententia",Space,Str "docti",LineBreak,Str "Quaerere",Space,Str "Tiresiae:",Space,Str "venus",Space,Str "huic",Space,Str "erat",SoftBreak,Str "utraque",Space,Str "nota.",LineBreak,Str "Nam",Space,Str "duo",Space,Str "magnorum",Space,Str "viridi",Space,Str "coeuntia",Space,Str "silva",LineBreak,Str "Corpora",Space,Str "serpentum",Space,Str "baculi",Space,Str "violaverat",Space,Str "ictu",LineBreak,Str "Deque",Space,Str "viro",Space,Str "factus,",SoftBreak,Str "mirabile,",Space,Str "femina",Space,Str "septem",LineBreak,Str "Egerat",Space,Str "autumnos;",Space,Str "octavo",Space,Str "rursus",SoftBreak,Str "eosdem",LineBreak,Str "Vidit",Space,Str "et",Space,Str "'est",Space,Str "vestrae",Space,Str "si",Space,Str "tanta",Space,Str "potentia",Space,Str "plagae,'",LineBreak,Str "Dixit",Space,Str "'ut",Space,Str "auctoris",Space,Str "sortem",Space,Str "in",Space,Str "contraria",Space,Str "mutet,",LineBreak,Str "Nunc",Space,Str "quoque",Space,Str "vos",SoftBreak,Str "feriam!'",Space,Str "percussis",Space,Str "anguibus",Space,Str "isdem",LineBreak,Str "Forma",Space,Str "prior",Space,Str "rediit",SoftBreak,Str "genetivaque",Space,Str "venit",Space,Str "imago.",LineBreak,Str "Arbiter",Space,Str "hic",Space,Str "igitur",Space,Str "sumptus",Space,Str "de",Space,Str "lite",SoftBreak,Str "iocosa",LineBreak,Str "Dicta",Space,Str "Iovis",Space,Str "firmat;",Space,Str "gravius",Space,Str "Saturnia",Space,Str "iusto",LineBreak,Str "Nec",SoftBreak,Str "pro",Space,Str "materia",Space,Str "fertur",Space,Str "doluisse",Space,Str "suique",LineBreak,Str "Iudicis",Space,Str "aeterna",Space,Str "damnavit",SoftBreak,Str "lumina",Space,Str "nocte,",LineBreak,Str "At",Space,Str "pater",Space,Str "omnipotens",Space,Str "(neque",Space,Str "enim",Space,Str "licet",Space,Str "inrita",SoftBreak,Str "cuiquam",LineBreak,Str "Facta",Space,Str "dei",Space,Str "fecisse",Space,Str "deo)",Space,Str "pro",Space,Str "lumine",Space,Str "adempto",LineBreak,Str "Scire",SoftBreak,Str "futura",Space,Str "dedit",Space,Str "poenamque",Space,Str "levavit",Space,Str "honore.",LineBreak]]]]
+ ,Div ("",[],[])
+ [Plain [Str "Old",Space,Str "man",Space,Str "with",Space,Str "wrinkled",Space,Str "female",Space,Str "breasts,",Space,Str "can",Space,Str "see"]]
+ ,Div ("",[],[])
+ [Plain [Str "At",Space,Str "the",Space,Str "violet",Space,Str "hour,",Space,Str "the",Space,Str "evening",Space,Str "hour",Space,Str "that",Space,Str "strives",Span ("",["lnum"],[]) [Str "220"]]]
+ ,Div ("wasteland-content.xhtml#ln221",[],[])
+ [Plain [Str "Homeward,",Space,Str "and",Space,Str "brings",Space,Str "the",Space,Str "sailor",Space,Str "home",Space,Str "from",Space,Str "sea,",Note [Para [Link ("",[],[]) [Str "221."] ("#wasteland-content.xhtml#ln221",""),Space,Str "This",Space,Str "may",Space,Str "not",Space,Str "appear",Space,Str "as",Space,Str "exact",Space,Str "as",Space,Str "Sappho's",Space,Str "lines,",Space,Str "but",Space,Str "I",Space,Str "had",Space,Str "in",Space,Str "mind",SoftBreak,Str "the",Space,Str "\"longshore\"",Space,Str "or",Space,Str "\"dory\"",Space,Str "fisherman,",Space,Str "who",Space,Str "returns",Space,Str "at",Space,Str "nightfall."]]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "typist",Space,Str "home",Space,Str "at",Space,Str "teatime,",Space,Str "clears",Space,Str "her",Space,Str "breakfast,",Space,Str "lights"]]
+ ,Div ("",[],[])
+ [Plain [Str "Her",Space,Str "stove,",Space,Str "and",Space,Str "lays",Space,Str "out",Space,Str "food",Space,Str "in",Space,Str "tins."]]
+ ,Div ("",[],[])
+ [Plain [Str "Out",Space,Str "of",Space,Str "the",Space,Str "window",Space,Str "perilously",Space,Str "spread"]]
+ ,Div ("",[],[])
+ [Plain [Str "Her",Space,Str "drying",Space,Str "combinations",Space,Str "touched",Space,Str "by",Space,Str "the",Space,Str "sun's",Space,Str "last",Space,Str "rays,"]]
+ ,Div ("",[],[])
+ [Plain [Str "On",Space,Str "the",Space,Str "divan",Space,Str "are",Space,Str "piled",Space,Str "(at",Space,Str "night",Space,Str "her",Space,Str "bed)"]]
+ ,Div ("",[],[])
+ [Plain [Str "Stockings,",Space,Str "slippers,",Space,Str "camisoles,",Space,Str "and",Space,Str "stays."]]
+ ,Div ("",[],[])
+ [Plain [Str "I",Space,Str "Tiresias,",Space,Str "old",Space,Str "man",Space,Str "with",Space,Str "wrinkled",Space,Str "dugs"]]
+ ,Div ("",[],[])
+ [Plain [Str "Perceived",Space,Str "the",Space,Str "scene,",Space,Str "and",Space,Str "foretold",Space,Str "the",Space,Str "rest",Space,Str "-"]]
+ ,Div ("",[],[])
+ [Plain [Str "I",Space,Str "too",Space,Str "awaited",Space,Str "the",Space,Str "expected",Space,Str "guest.",Span ("",["lnum"],[]) [Str "230"]]]
+ ,Div ("",[],[])
+ [Plain [Str "He,",Space,Str "the",Space,Str "young",Space,Str "man",Space,Str "carbuncular,",Space,Str "arrives,"]]
+ ,Div ("",[],[])
+ [Plain [Str "A",Space,Str "small",Space,Str "house",Space,Str "agent's",Space,Str "clerk,",Space,Str "with",Space,Str "one",Space,Str "bold",Space,Str "stare,"]]
+ ,Div ("",[],[])
+ [Plain [Str "One",Space,Str "of",Space,Str "the",Space,Str "low",Space,Str "on",Space,Str "whom",Space,Str "assurance",Space,Str "sits"]]
+ ,Div ("",[],[])
+ [Plain [Str "As",Space,Str "a",Space,Str "silk",Space,Str "hat",Space,Str "on",Space,Str "a",Space,Str "Bradford",Space,Str "millionaire."]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "time",Space,Str "is",Space,Str "now",Space,Str "propitious,",Space,Str "as",Space,Str "he",Space,Str "guesses,"]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "meal",Space,Str "is",Space,Str "ended,",Space,Str "she",Space,Str "is",Space,Str "bored",Space,Str "and",Space,Str "tired,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Endeavours",Space,Str "to",Space,Str "engage",Space,Str "her",Space,Str "in",Space,Str "caresses"]]
+ ,Div ("",[],[])
+ [Plain [Str "Which",Space,Str "still",Space,Str "are",Space,Str "unreproved,",Space,Str "if",Space,Str "undesired."]]
+ ,Div ("",[],[])
+ [Plain [Str "Flushed",Space,Str "and",Space,Str "decided,",Space,Str "he",Space,Str "assaults",Space,Str "at",Space,Str "once;"]]
+ ,Div ("",[],[])
+ [Plain [Str "Exploring",Space,Str "hands",Space,Str "encounter",Space,Str "no",Space,Str "defence;",Span ("",["lnum"],[]) [Str "240"]]]
+ ,Div ("",[],[])
+ [Plain [Str "His",Space,Str "vanity",Space,Str "requires",Space,Str "no",Space,Str "response,"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "makes",Space,Str "a",Space,Str "welcome",Space,Str "of",Space,Str "indifference."]]
+ ,Div ("",[],[])
+ [Plain [Str "(And",Space,Str "I",Space,Str "Tiresias",Space,Str "have",Space,Str "foresuffered",Space,Str "all"]]
+ ,Div ("",[],[])
+ [Plain [Str "Enacted",Space,Str "on",Space,Str "this",Space,Str "same",Space,Str "divan",Space,Str "or",Space,Str "bed;"]]
+ ,Div ("",[],[])
+ [Plain [Str "I",Space,Str "who",Space,Str "have",Space,Str "sat",Space,Str "by",Space,Str "Thebes",Space,Str "below",Space,Str "the",Space,Str "wall"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "walked",Space,Str "among",Space,Str "the",Space,Str "lowest",Space,Str "of",Space,Str "the",Space,Str "dead.)"]]
+ ,Div ("",[],[])
+ [Plain [Str "Bestows",Space,Str "one",Space,Str "final",Space,Str "patronising",Space,Str "kiss,"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "gropes",Space,Str "his",Space,Str "way,",Space,Str "finding",Space,Str "the",Space,Str "stairs",Space,Str "unlit",Space,Str ".",Space,Str ".",Space,Str "."]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "She",Space,Str "turns",Space,Str "and",Space,Str "looks",Space,Str "a",Space,Str "moment",Space,Str "in",Space,Str "the",Space,Str "glass,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Hardly",Space,Str "aware",Space,Str "of",Space,Str "her",Space,Str "departed",Space,Str "lover;",Span ("",["lnum"],[]) [Str "250"]]]
+ ,Div ("",[],[])
+ [Plain [Str "Her",Space,Str "brain",Space,Str "allows",Space,Str "one",Space,Str "half-formed",Space,Str "thought",Space,Str "to",Space,Str "pass:"]]
+ ,Div ("",[],[])
+ [Plain [Str "\"Well",Space,Str "now",Space,Str "that's",Space,Str "done:",Space,Str "and",Space,Str "I'm",Space,Str "glad",Space,Str "it's",Space,Str "over.\""]]
+ ,Div ("wasteland-content.xhtml#ln253",[],[])
+ [Plain [Str "When",Space,Str "lovely",Space,Str "woman",Space,Str "stoops",Space,Str "to",Space,Str "folly",Space,Str "and",Note [Para [Link ("",[],[]) [Str "253."] ("#wasteland-content.xhtml#ln253",""),Space,Str "V.",Space,Str "Goldsmith,",Space,Str "the",Space,Str "song",Space,Str "in",Space,Str "The",Space,Str "Vicar",Space,Str "of",Space,Str "Wakefield."]]]
+ ,Div ("",[],[])
+ [Plain [Str "Paces",Space,Str "about",Space,Str "her",Space,Str "room",Space,Str "again,",Space,Str "alone,"]]
+ ,Div ("",[],[])
+ [Plain [Str "She",Space,Str "smoothes",Space,Str "her",Space,Str "hair",Space,Str "with",Space,Str "automatic",Space,Str "hand,"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "puts",Space,Str "a",Space,Str "record",Space,Str "on",Space,Str "the",Space,Str "gramophone."]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("wasteland-content.xhtml#ln257",[],[])
+ [Plain [Str "\"This",Space,Str "music",Space,Str "crept",Space,Str "by",Space,Str "me",Space,Str "upon",Space,Str "the",Space,Str "waters\"",Note [Para [Link ("",[],[]) [Str "257."] ("#wasteland-content.xhtml#ln257",""),Space,Str "V.",Space,Str "The",Space,Str "Tempest,",Space,Str "as",Space,Str "above."]]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "along",Space,Str "the",Space,Str "Strand,",Space,Str "up",Space,Str "Queen",Space,Str "Victoria",Space,Str "Street."]]
+ ,Div ("",[],[])
+ [Plain [Str "O",Space,Str "City",Space,Str "city,",Space,Str "I",Space,Str "can",Space,Str "sometimes",Space,Str "hear"]]
+ ,Div ("",[],[])
+ [Plain [Str "Beside",Space,Str "a",Space,Str "public",Space,Str "bar",Space,Str "in",Space,Str "Lower",Space,Str "Thames",Space,Str "Street,",Span ("",["lnum"],[]) [Str "260"]]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "pleasant",Space,Str "whining",Space,Str "of",Space,Str "a",Space,Str "mandoline"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "a",Space,Str "clatter",Space,Str "and",Space,Str "a",Space,Str "chatter",Space,Str "from",Space,Str "within"]]
+ ,Div ("",[],[])
+ [Plain [Str "Where",Space,Str "fishmen",Space,Str "lounge",Space,Str "at",Space,Str "noon:",Space,Str "where",Space,Str "the",Space,Str "walls"]]
+ ,Div ("wasteland-content.xhtml#ln264",[],[])
+ [Plain [Str "Of",Space,Str "Magnus",Space,Str "Martyr",Space,Str "hold",Note [Para [Link ("",[],[]) [Str "264."] ("#wasteland-content.xhtml#ln264",""),Space,Str "The",Space,Str "interior",Space,Str "of",Space,Str "St.",Space,Str "Magnus",Space,Str "Martyr",Space,Str "is",Space,Str "to",Space,Str "my",Space,Str "mind",Space,Str "one",Space,Str "of",Space,Str "the",Space,Str "finest",SoftBreak,Str "among",Space,Str "Wren's",Space,Str "interiors.",Space,Str "See",Space,Str "The",Space,Str "Proposed",Space,Str "Demolition",Space,Str "of",Space,Str "Nineteen",Space,Str "City",SoftBreak,Str "Churches",Space,Str "(P.",Space,Str "S.",Space,Str "King",Space,Str "&",Space,Str "Son,",Space,Str "Ltd.)."]]]
+ ,Div ("",[],[])
+ [Plain [Str "Inexplicable",Space,Str "splendour",Space,Str "of",Space,Str "Ionian",Space,Str "white",Space,Str "and",Space,Str "gold."]]]
+ ,Div ("",["linegroup","indent"],[])
+ [Div ("wasteland-content.xhtml#ln266",[],[])
+ [Plain [Str "The",Space,Str "river",Space,Str "sweats",Note [Para [Link ("",[],[]) [Str "266."] ("#wasteland-content.xhtml#ln266",""),Space,Str "The",Space,Str "Song",Space,Str "of",Space,Str "the",Space,Str "(three)",Space,Str "Thames-daughters",Space,Str "begins",Space,Str "here.",Space,Str "From",Space,Str "line",Space,Str "292",SoftBreak,Str "to",Space,Str "306",Space,Str "inclusive",Space,Str "they",Space,Str "speak",Space,Str "in",Space,Str "turn.",Space,Str "V.",Space,Str "Gutterdsammerung,",Space,Str "III.",Space,Str "i:",Space,Str "the",SoftBreak,Str "Rhine-daughters."]]]
+ ,Div ("",[],[])
+ [Plain [Str "Oil",Space,Str "and",Space,Str "tar"]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "barges",Space,Str "drift"]]
+ ,Div ("",[],[])
+ [Plain [Str "With",Space,Str "the",Space,Str "turning",Space,Str "tide"]]
+ ,Div ("",[],[])
+ [Plain [Str "Red",Space,Str "sails",Span ("",["lnum"],[]) [Str "270"]]]
+ ,Div ("",[],[])
+ [Plain [Str "Wide"]]
+ ,Div ("",[],[])
+ [Plain [Str "To",Space,Str "leeward,",Space,Str "swing",Space,Str "on",Space,Str "the",Space,Str "heavy",Space,Str "spar."]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "barges",Space,Str "wash"]]
+ ,Div ("",[],[])
+ [Plain [Str "Drifting",Space,Str "logs"]]
+ ,Div ("",[],[])
+ [Plain [Str "Down",Space,Str "Greenwich",Space,Str "reach"]]
+ ,Div ("",[],[])
+ [Plain [Str "Past",Space,Str "the",Space,Str "Isle",Space,Str "of",Space,Str "Dogs."]]
+ ,Div ("",["indent"],[])
+ [Plain [Str "Weialala",Space,Str "leia"]]
+ ,Div ("",["indent"],[])
+ [Plain [Str "Wallala",Space,Str "leialala"]]]
+ ,Div ("",["linegroup","indent"],[])
+ [Div ("wasteland-content.xhtml#ln279",[],[])
+ [Plain [Str "Elizabeth",Space,Str "and",Space,Str "Leicester",Note [Para [Link ("",[],[]) [Str "279."] ("#wasteland-content.xhtml#ln279",""),Space,Str "V.",Space,Str "Froude,",Space,Str "Elizabeth,",Space,Str "Vol.",Space,Str "I,",Space,Str "ch.",Space,Str "iv,",Space,Str "letter",Space,Str "of",Space,Str "De",Space,Str "Quadra",Space,Str "to",Space,Str "Philip",SoftBreak,Str "of",Space,Str "Spain:"],BlockQuote [Div ("",[],[]) [Div ("",[],[]) [Plain [Str "\"In",Space,Str "the",Space,Str "afternoon",Space,Str "we",Space,Str "were",Space,Str "in",Space,Str "a",Space,Str "barge,",Space,Str "watching",Space,Str "the",SoftBreak,Str "games",Space,Str "on",Space,Str "the",Space,Str "river."]],Div ("",[],[]) [Plain [Str "(The",Space,Str "queen)",Space,Str "was",Space,Str "alone",Space,Str "with",Space,Str "Lord",Space,Str "Robert",Space,Str "and",Space,Str "myself",SoftBreak,Str "on",Space,Str "the",Space,Str "poop,"]],Div ("",[],[]) [Plain [Str "when",Space,Str "they",Space,Str "began",Space,Str "to",Space,Str "talk",Space,Str "nonsense,",Space,Str "and",Space,Str "went",Space,Str "so",Space,Str "far",SoftBreak,Str "that",Space,Str "Lord",Space,Str "Robert"]],Div ("",[],[]) [Plain [Str "at",Space,Str "last",Space,Str "said,",Space,Str "as",Space,Str "I",Space,Str "was",Space,Str "on",Space,Str "the",Space,Str "spot",Space,Str "there",Space,Str "was",Space,Str "no",SoftBreak,Str "reason",Space,Str "why",Space,Str "they"]],Div ("",[],[]) [Plain [Str "should",Space,Str "not",Space,Str "be",Space,Str "married",Space,Str "if",Space,Str "the",Space,Str "queen",Space,Str "pleased.\""]]]]]]
+ ,Div ("",[],[])
+ [Plain [Str "Beating",Space,Str "oars",Span ("",["lnum"],[]) [Str "280"]]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "stern",Space,Str "was",Space,Str "formed"]]
+ ,Div ("",[],[])
+ [Plain [Str "A",Space,Str "gilded",Space,Str "shell"]]
+ ,Div ("",[],[])
+ [Plain [Str "Red",Space,Str "and",Space,Str "gold"]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "brisk",Space,Str "swell"]]
+ ,Div ("",[],[])
+ [Plain [Str "Rippled",Space,Str "both",Space,Str "shores"]]
+ ,Div ("",[],[])
+ [Plain [Str "Southwest",Space,Str "wind"]]
+ ,Div ("",[],[])
+ [Plain [Str "Carried",Space,Str "down",Space,Str "stream"]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "peal",Space,Str "of",Space,Str "bells"]]
+ ,Div ("",[],[])
+ [Plain [Str "White",Space,Str "towers"]]
+ ,Div ("",["indent"],[])
+ [Plain [Str "Weialala",Space,Str "leia",Span ("",["lnum"],[]) [Str "290"]]]
+ ,Div ("",["indent"],[])
+ [Plain [Str "Wallala",Space,Str "leialala"]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "\"Trams",Space,Str "and",Space,Str "dusty",Space,Str "trees."]]
+ ,Div ("wasteland-content.xhtml#ln293",[],[])
+ [Plain [Str "Highbury",Space,Str "bore",Space,Str "me.",Space,Str "Richmond",Space,Str "and",Space,Str "Kew",Note [Para [Link ("",[],[]) [Str "293."] ("#wasteland-content.xhtml#ln293",""),Space,Str "Cf.",Space,Str "Purgatorio,",Space,Str "v.",Space,Str "133:"],BlockQuote [Para [Str "\"Ricorditi",Space,Str "di",Space,Str "me,",Space,Str "che",Space,Str "son",Space,Str "la",Space,Str "Pia;",LineBreak,Str "Siena",Space,Str "mi",Space,Str "fe',",Space,Str "disfecemi",SoftBreak,Str "Maremma.\""]]]]
+ ,Div ("",[],[])
+ [Plain [Str "Undid",Space,Str "me.",Space,Str "By",Space,Str "Richmond",Space,Str "I",Space,Str "raised",Space,Str "my",Space,Str "knees"]]
+ ,Div ("",[],[])
+ [Plain [Str "Supine",Space,Str "on",Space,Str "the",Space,Str "floor",Space,Str "of",Space,Str "a",Space,Str "narrow",Space,Str "canoe.\""]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "\"My",Space,Str "feet",Space,Str "are",Space,Str "at",Space,Str "Moorgate,",Space,Str "and",Space,Str "my",Space,Str "heart"]]
+ ,Div ("",[],[])
+ [Plain [Str "Under",Space,Str "my",Space,Str "feet.",Space,Str "After",Space,Str "the",Space,Str "event"]]
+ ,Div ("",[],[])
+ [Plain [Str "He",Space,Str "wept.",Space,Str "He",Space,Str "promised",Space,Str "'a",Space,Str "new",Space,Str "start'."]]
+ ,Div ("",[],[])
+ [Plain [Str "I",Space,Str "made",Space,Str "no",Space,Str "comment.",Space,Str "What",Space,Str "should",Space,Str "I",Space,Str "resent?\""]]
+ ,Div ("",[],[])
+ [Plain [Str "\"On",Space,Str "Margate",Space,Str "Sands.",Span ("",["lnum"],[]) [Str "300"]]]
+ ,Div ("",[],[])
+ [Plain [Str "I",Space,Str "can",Space,Str "connect"]]
+ ,Div ("",[],[])
+ [Plain [Str "Nothing",Space,Str "with",Space,Str "nothing."]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "broken",Space,Str "fingernails",Space,Str "of",Space,Str "dirty",Space,Str "hands."]]
+ ,Div ("",[],[])
+ [Plain [Str "My",Space,Str "people",Space,Str "humble",Space,Str "people",Space,Str "who",Space,Str "expect"]]
+ ,Div ("",[],[])
+ [Plain [Str "Nothing.\""]]
+ ,Div ("",["indent"],[])
+ [Plain [Str "la",Space,Str "la"]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("wasteland-content.xhtml#ln307",[],[])
+ [Plain [Str "To",Space,Str "Carthage",Space,Str "then",Space,Str "I",Space,Str "came",Note [Para [Link ("",[],[]) [Str "307."] ("#wasteland-content.xhtml#ln307",""),Space,Str "V.",Space,Str "St.",Space,Str "Augustine's",Space,Str "Confessions:",Space,Str "\"to",Space,Str "Carthage",Space,Str "then",Space,Str "I",Space,Str "came,",Space,Str "where",Space,Str "a",SoftBreak,Str "cauldron",Space,Str "of",Space,Str "unholy",Space,Str "loves",Space,Str "sang",Space,Str "all",Space,Str "about",Space,Str "mine",Space,Str "ears.\""]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("wasteland-content.xhtml#ln308",[],[])
+ [Plain [Str "Burning",Space,Str "burning",Space,Str "burning",Space,Str "burning",Note [Para [Link ("",[],[]) [Str "308."] ("#wasteland-content.xhtml#ln308",""),Space,Str "The",Space,Str "complete",Space,Str "text",Space,Str "of",Space,Str "the",Space,Str "Buddha's",Space,Str "Fire",Space,Str "Sermon",Space,Str "(which",Space,Str "corresponds",Space,Str "in",SoftBreak,Str "importance",Space,Str "to",Space,Str "the",Space,Str "Sermon",Space,Str "on",Space,Str "the",Space,Str "Mount)",Space,Str "from",Space,Str "which",Space,Str "these",Space,Str "words",Space,Str "are",Space,Str "taken,",SoftBreak,Str "will",Space,Str "be",Space,Str "found",Space,Str "translated",Space,Str "in",Space,Str "the",Space,Str "late",Space,Str "Henry",Space,Str "Clarke",Space,Str "Warren's",Space,Str "Buddhism",Space,Str "in",SoftBreak,Str "Translation",Space,Str "(Harvard",Space,Str "Oriental",Space,Str "Series).",Space,Str "Mr.",Space,Str "Warren",Space,Str "was",Space,Str "one",Space,Str "of",Space,Str "the",Space,Str "great",SoftBreak,Str "pioneers",Space,Str "of",Space,Str "Buddhist",Space,Str "studies",Space,Str "in",Space,Str "the",Space,Str "Occident."]]]
+ ,Div ("wasteland-content.xhtml#ln309",[],[])
+ [Plain [Str "O",Space,Str "Lord",Space,Str "Thou",Space,Str "pluckest",Space,Str "me",Space,Str "out",Note [Para [Link ("",[],[]) [Str "309."] ("#wasteland-content.xhtml#ln309",""),Space,Str "From",Space,Str "St.",Space,Str "Augustine's",Space,Str "Confessions",Space,Str "again.",Space,Str "The",Space,Str "collocation",Space,Str "of",Space,Str "these",Space,Str "two",SoftBreak,Str "representatives",Space,Str "of",Space,Str "eastern",Space,Str "and",Space,Str "western",Space,Str "asceticism,",Space,Str "as",Space,Str "the",Space,Str "culmination",Space,Str "of",SoftBreak,Str "this",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "poem,",Space,Str "is",Space,Str "not",Space,Str "an",Space,Str "accident."]]]
+ ,Div ("",[],[])
+ [Plain [Str "O",Space,Str "Lord",Space,Str "Thou",Space,Str "pluckest",Span ("",["lnum"],[]) [Str "310"]]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "burning"]]]
+ ,RawBlock (Format "html") "</section>"
+ ,Div ("wasteland-content.xhtml#ch4",["section"],[])
+ [Header 2 ("",[],[]) [Str "IV.",Space,Str "DEATH",Space,Str "BY",Space,Str "WATER"]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "Phlebas",Space,Str "the",Space,Str "Phoenician,",Space,Str "a",Space,Str "fortnight",Space,Str "dead,"]]
+ ,Div ("",[],[])
+ [Plain [Str "Forgot",Space,Str "the",Space,Str "cry",Space,Str "of",Space,Str "gulls,",Space,Str "and",Space,Str "the",Space,Str "deep",Space,Str "sea",Space,Str "swell"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "the",Space,Str "profit",Space,Str "and",Space,Str "loss."]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",["indent2"],[])
+ [Plain [Str "A",Space,Str "current",Space,Str "under",Space,Str "sea"]]
+ ,Div ("",[],[])
+ [Plain [Str "Picked",Space,Str "his",Space,Str "bones",Space,Str "in",Space,Str "whispers.",Space,Str "As",Space,Str "he",Space,Str "rose",Space,Str "and",Space,Str "fell"]]
+ ,Div ("",[],[])
+ [Plain [Str "He",Space,Str "passed",Space,Str "the",Space,Str "stages",Space,Str "of",Space,Str "his",Space,Str "age",Space,Str "and",Space,Str "youth"]]
+ ,Div ("",[],[])
+ [Plain [Str "Entering",Space,Str "the",Space,Str "whirlpool."]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",["indent2"],[])
+ [Plain [Str "Gentile",Space,Str "or",Space,Str "Jew"]]
+ ,Div ("",[],[])
+ [Plain [Str "O",Space,Str "you",Space,Str "who",Space,Str "turn",Space,Str "the",Space,Str "wheel",Space,Str "and",Space,Str "look",Space,Str "to",Space,Str "windward,",Span ("",["lnum"],[]) [Str "320"]]]
+ ,Div ("",[],[])
+ [Plain [Str "Consider",Space,Str "Phlebas,",Space,Str "who",Space,Str "was",Space,Str "once",Space,Str "handsome",Space,Str "and",Space,Str "tall",Space,Str "as",Space,Str "you."]]]]
+ ,Div ("wasteland-content.xhtml#ch5",["section"],[])
+ [Header 2 ("",[],[]) [Str "V.",Space,Str "WHAT",Space,Str "THE",Space,Str "THUNDER",Space,Str "SAID"]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "After",Space,Str "the",Space,Str "torchlight",Space,Str "red",Space,Str "on",Space,Str "sweaty",Space,Str "faces"]]
+ ,Div ("",[],[])
+ [Plain [Str "After",Space,Str "the",Space,Str "frosty",Space,Str "silence",Space,Str "in",Space,Str "the",Space,Str "gardens"]]
+ ,Div ("",[],[])
+ [Plain [Str "After",Space,Str "the",Space,Str "agony",Space,Str "in",Space,Str "stony",Space,Str "places"]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "shouting",Space,Str "and",Space,Str "the",Space,Str "crying"]]
+ ,Div ("",[],[])
+ [Plain [Str "Prison",Space,Str "and",Space,Str "palace",Space,Str "and",Space,Str "reverberation"]]
+ ,Div ("",[],[])
+ [Plain [Str "Of",Space,Str "thunder",Space,Str "of",Space,Str "spring",Space,Str "over",Space,Str "distant",Space,Str "mountains"]]
+ ,Div ("",[],[])
+ [Plain [Str "He",Space,Str "who",Space,Str "was",Space,Str "living",Space,Str "is",Space,Str "now",Space,Str "dead"]]
+ ,Div ("",[],[])
+ [Plain [Str "We",Space,Str "who",Space,Str "were",Space,Str "living",Space,Str "are",Space,Str "now",Space,Str "dying"]]
+ ,Div ("",[],[])
+ [Plain [Str "With",Space,Str "a",Space,Str "little",Space,Str "patience",Span ("",["lnum"],[]) [Str "330"]]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "Here",Space,Str "is",Space,Str "no",Space,Str "water",Space,Str "but",Space,Str "only",Space,Str "rock"]]
+ ,Div ("",[],[])
+ [Plain [Str "Rock",Space,Str "and",Space,Str "no",Space,Str "water",Space,Str "and",Space,Str "the",Space,Str "sandy",Space,Str "road"]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "road",Space,Str "winding",Space,Str "above",Space,Str "among",Space,Str "the",Space,Str "mountains"]]
+ ,Div ("",[],[])
+ [Plain [Str "Which",Space,Str "are",Space,Str "mountains",Space,Str "of",Space,Str "rock",Space,Str "without",Space,Str "water"]]
+ ,Div ("",[],[])
+ [Plain [Str "If",Space,Str "there",Space,Str "were",Space,Str "water",Space,Str "we",Space,Str "should",Space,Str "stop",Space,Str "and",Space,Str "drink"]]
+ ,Div ("",[],[])
+ [Plain [Str "Amongst",Space,Str "the",Space,Str "rock",Space,Str "one",Space,Str "cannot",Space,Str "stop",Space,Str "or",Space,Str "think"]]
+ ,Div ("",[],[])
+ [Plain [Str "Sweat",Space,Str "is",Space,Str "dry",Space,Str "and",Space,Str "feet",Space,Str "are",Space,Str "in",Space,Str "the",Space,Str "sand"]]
+ ,Div ("",[],[])
+ [Plain [Str "If",Space,Str "there",Space,Str "were",Space,Str "only",Space,Str "water",Space,Str "amongst",Space,Str "the",Space,Str "rock"]]
+ ,Div ("",[],[])
+ [Plain [Str "Dead",Space,Str "mountain",Space,Str "mouth",Space,Str "of",Space,Str "carious",Space,Str "teeth",Space,Str "that",Space,Str "cannot",Space,Str "spit"]]
+ ,Div ("",[],[])
+ [Plain [Str "Here",Space,Str "one",Space,Str "can",Space,Str "neither",Space,Str "stand",Space,Str "nor",Space,Str "lie",Space,Str "nor",Space,Str "sit",Span ("",["lnum"],[]) [Str "340"]]]
+ ,Div ("",[],[])
+ [Plain [Str "There",Space,Str "is",Space,Str "not",Space,Str "even",Space,Str "silence",Space,Str "in",Space,Str "the",Space,Str "mountains"]]
+ ,Div ("",[],[])
+ [Plain [Str "But",Space,Str "dry",Space,Str "sterile",Space,Str "thunder",Space,Str "without",Space,Str "rain"]]
+ ,Div ("",[],[])
+ [Plain [Str "There",Space,Str "is",Space,Str "not",Space,Str "even",Space,Str "solitude",Space,Str "in",Space,Str "the",Space,Str "mountains"]]
+ ,Div ("",[],[])
+ [Plain [Str "But",Space,Str "red",Space,Str "sullen",Space,Str "faces",Space,Str "sneer",Space,Str "and",Space,Str "snarl"]]
+ ,Div ("",[],[])
+ [Plain [Str "From",Space,Str "doors",Space,Str "of",Space,Str "mudcracked",Space,Str "houses"]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",["indent2"],[])
+ [Plain [Str "If",Space,Str "there",Space,Str "were",Space,Str "water"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "no",Space,Str "rock"]]
+ ,Div ("",[],[])
+ [Plain [Str "If",Space,Str "there",Space,Str "were",Space,Str "rock"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "also",Space,Str "water"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "water",Span ("",["lnum"],[]) [Str "350"]]]
+ ,Div ("",[],[])
+ [Plain [Str "A",Space,Str "spring"]]
+ ,Div ("",[],[])
+ [Plain [Str "A",Space,Str "pool",Space,Str "among",Space,Str "the",Space,Str "rock"]]
+ ,Div ("",[],[])
+ [Plain [Str "If",Space,Str "there",Space,Str "were",Space,Str "the",Space,Str "sound",Space,Str "of",Space,Str "water",Space,Str "only"]]
+ ,Div ("",[],[])
+ [Plain [Str "Not",Space,Str "the",Space,Str "cicada"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "dry",Space,Str "grass",Space,Str "singing"]]
+ ,Div ("",[],[])
+ [Plain [Str "But",Space,Str "sound",Space,Str "of",Space,Str "water",Space,Str "over",Space,Str "a",Space,Str "rock"]]
+ ,Div ("wasteland-content.xhtml#ln357",[],[])
+ [Plain [Str "Where",Space,Str "the",Space,Str "hermit-thrush",Space,Str "sings",Space,Str "in",Space,Str "the",Space,Str "pine",Space,Str "trees",Note [Para [Link ("",[],[]) [Str "357."] ("#wasteland-content.xhtml#ln357",""),Space,Str "This",Space,Str "is",Space,Str "Turdus",Space,Str "aonalaschkae",Space,Str "pallasii,",Space,Str "the",Space,Str "hermit-thrush",Space,Str "which",Space,Str "I",Space,Str "have",SoftBreak,Str "heard",Space,Str "in",Space,Str "Quebec",Space,Str "County.",Space,Str "Chapman",Space,Str "says",Space,Str "(Handbook",Space,Str "of",Space,Str "Birds",Space,Str "of",Space,Str "Eastern",Space,Str "North",SoftBreak,Str "America)",Space,Str "\"it",Space,Str "is",Space,Str "most",Space,Str "at",Space,Str "home",Space,Str "in",Space,Str "secluded",Space,Str "woodland",Space,Str "and",Space,Str "thickety",Space,Str "retreats.",SoftBreak,Str ".",Space,Str ".",Space,Str ".",Space,Str "Its",Space,Str "notes",Space,Str "are",Space,Str "not",Space,Str "remarkable",Space,Str "for",Space,Str "variety",Space,Str "or",Space,Str "volume,",Space,Str "but",Space,Str "in",Space,Str "purity",SoftBreak,Str "and",Space,Str "sweetness",Space,Str "of",Space,Str "tone",Space,Str "and",Space,Str "exquisite",Space,Str "modulation",Space,Str "they",Space,Str "are",Space,Str "unequalled.\"",Space,Str "Its",SoftBreak,Str "\"water-dripping",Space,Str "song\"",Space,Str "is",Space,Str "justly",Space,Str "celebrated."]]]
+ ,Div ("",[],[])
+ [Plain [Str "Drip",Space,Str "drop",Space,Str "drip",Space,Str "drop",Space,Str "drop",Space,Str "drop",Space,Str "drop"]]
+ ,Div ("",[],[])
+ [Plain [Str "But",Space,Str "there",Space,Str "is",Space,Str "no",Space,Str "water"]]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("wasteland-content.xhtml#ln360",[],[])
+ [Plain [Str "Who",Space,Str "is",Space,Str "the",Space,Str "third",Space,Str "who",Space,Str "walks",Space,Str "always",Space,Str "beside",Space,Str "you?",Note [Para [Link ("",[],[]) [Str "360."] ("#wasteland-content.xhtml#ln360",""),Space,Str "The",Space,Str "following",Space,Str "lines",Space,Str "were",Space,Str "stimulated",Space,Str "by",Space,Str "the",Space,Str "account",Space,Str "of",Space,Str "one",Space,Str "of",Space,Str "the",SoftBreak,Str "Antarctic",Space,Str "expeditions",Space,Str "(I",Space,Str "forget",Space,Str "which,",Space,Str "but",Space,Str "I",Space,Str "think",Space,Str "one",Space,Str "of",Space,Str "Shackleton's):",SoftBreak,Str "it",Space,Str "was",Space,Str "related",Space,Str "that",Space,Str "the",Space,Str "party",Space,Str "of",Space,Str "explorers,",Space,Str "at",Space,Str "the",Space,Str "extremity",Space,Str "of",Space,Str "their",SoftBreak,Str "strength,",Space,Str "had",Space,Str "the",Space,Str "constant",Space,Str "delusion",Space,Str "that",Space,Str "there",Space,Str "was",Space,Str "one",Space,Str "more",Space,Str "member",Space,Str "than",SoftBreak,Str "could",Space,Str "actually",Space,Str "be",Space,Str "counted."]]]
+ ,Div ("",[],[])
+ [Plain [Str "When",Space,Str "I",Space,Str "count,",Space,Str "there",Space,Str "are",Space,Str "only",Space,Str "you",Space,Str "and",Space,Str "I",Space,Str "together"]]
+ ,Div ("",[],[])
+ [Plain [Str "But",Space,Str "when",Space,Str "I",Space,Str "look",Space,Str "ahead",Space,Str "up",Space,Str "the",Space,Str "white",Space,Str "road"]]
+ ,Div ("",[],[])
+ [Plain [Str "There",Space,Str "is",Space,Str "always",Space,Str "another",Space,Str "one",Space,Str "walking",Space,Str "beside",Space,Str "you"]]
+ ,Div ("",[],[])
+ [Plain [Str "Gliding",Space,Str "wrapt",Space,Str "in",Space,Str "a",Space,Str "brown",Space,Str "mantle,",Space,Str "hooded"]]
+ ,Div ("",[],[])
+ [Plain [Str "I",Space,Str "do",Space,Str "not",Space,Str "know",Space,Str "whether",Space,Str "a",Space,Str "man",Space,Str "or",Space,Str "a",Space,Str "woman"]]
+ ,Div ("wasteland-content.xhtml#ln367",[],[])
+ [Plain [Str "\8213But",Space,Str "who",Space,Str "is",Space,Str "that",Space,Str "on",Space,Str "the",Space,Str "other",Space,Str "side",Space,Str "of",Space,Str "you?",Note [Para [Link ("",[],[]) [Str "367-77."] ("#wasteland-content.xhtml#ln367",""),Space,Str "Cf.",Space,Str "Hermann",Space,Str "Hesse,",Space,Str "Blick",Space,Str "ins",Space,Str "Chaos:"],BlockQuote [Para [Str "\"Schon",Space,Str "ist",Space,Str "halb",Space,Str "Europa,",Space,Str "schon",Space,Str "ist",Space,Str "zumindest",Space,Str "der",Space,Str "halbe",Space,Str "Osten",Space,Str "Europas",SoftBreak,Str "auf",Space,Str "dem",LineBreak,Str "Wege",Space,Str "zum",Space,Str "Chaos,",Space,Str "fhrt",Space,Str "betrunken",Space,Str "im",Space,Str "heiligem",Space,Str "Wahn",Space,Str "am",SoftBreak,Str "Abgrund",Space,Str "entlang",LineBreak,Str "und",Space,Str "singt",Space,Str "dazu,",Space,Str "singt",Space,Str "betrunken",Space,Str "und",Space,Str "hymnisch",SoftBreak,Str "wie",Space,Str "Dmitri",Space,Str "Karamasoff",Space,Str "sang.",LineBreak,Str "Ueber",Space,Str "diese",Space,Str "Lieder",Space,Str "lacht",Space,Str "der",SoftBreak,Str "Bsrger",Space,Str "beleidigt,",Space,Str "der",Space,Str "Heilige",LineBreak,Str "und",Space,Str "Seher",Space,Str "hrt",Space,Str "sie",Space,Str "mit",SoftBreak,Str "Trvnen.\""]]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "What",Space,Str "is",Space,Str "that",Space,Str "sound",Space,Str "high",Space,Str "in",Space,Str "the",Space,Str "air"]]
+ ,Div ("",[],[])
+ [Plain [Str "Murmur",Space,Str "of",Space,Str "maternal",Space,Str "lamentation"]]
+ ,Div ("",[],[])
+ [Plain [Str "Who",Space,Str "are",Space,Str "those",Space,Str "hooded",Space,Str "hordes",Space,Str "swarming"]]
+ ,Div ("",[],[])
+ [Plain [Str "Over",Space,Str "endless",Space,Str "plains,",Space,Str "stumbling",Space,Str "in",Space,Str "cracked",Space,Str "earth",Span ("",["lnum"],[]) [Str "370"]]]
+ ,Div ("",[],[])
+ [Plain [Str "Ringed",Space,Str "by",Space,Str "the",Space,Str "flat",Space,Str "horizon",Space,Str "only"]]
+ ,Div ("",[],[])
+ [Plain [Str "What",Space,Str "is",Space,Str "the",Space,Str "city",Space,Str "over",Space,Str "the",Space,Str "mountains"]]
+ ,Div ("",[],[])
+ [Plain [Str "Cracks",Space,Str "and",Space,Str "reforms",Space,Str "and",Space,Str "bursts",Space,Str "in",Space,Str "the",Space,Str "violet",Space,Str "air"]]
+ ,Div ("",[],[])
+ [Plain [Str "Falling",Space,Str "towers"]]
+ ,Div ("",[],[])
+ [Plain [Str "Jerusalem",Space,Str "Athens",Space,Str "Alexandria"]]
+ ,Div ("",[],[])
+ [Plain [Str "Vienna",Space,Str "London"]]
+ ,Div ("",[],[])
+ [Plain [Str "Unreal"]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "A",Space,Str "woman",Space,Str "drew",Space,Str "her",Space,Str "long",Space,Str "black",Space,Str "hair",Space,Str "out",Space,Str "tight"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "fiddled",Space,Str "whisper",Space,Str "music",Space,Str "on",Space,Str "those",Space,Str "strings"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "bats",Space,Str "with",Space,Str "baby",Space,Str "faces",Space,Str "in",Space,Str "the",Space,Str "violet",Space,Str "light",Span ("",["lnum"],[]) [Str "380"]]]
+ ,Div ("",[],[])
+ [Plain [Str "Whistled,",Space,Str "and",Space,Str "beat",Space,Str "their",Space,Str "wings"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "crawled",Space,Str "head",Space,Str "downward",Space,Str "down",Space,Str "a",Space,Str "blackened",Space,Str "wall"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "upside",Space,Str "down",Space,Str "in",Space,Str "air",Space,Str "were",Space,Str "towers"]]
+ ,Div ("",[],[])
+ [Plain [Str "Tolling",Space,Str "reminiscent",Space,Str "bells,",Space,Str "that",Space,Str "kept",Space,Str "the",Space,Str "hours"]]
+ ,Div ("",[],[])
+ [Plain [Str "And",Space,Str "voices",Space,Str "singing",Space,Str "out",Space,Str "of",Space,Str "empty",Space,Str "cisterns",Space,Str "and",Space,Str "exhausted",SoftBreak,Str "wells."]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "In",Space,Str "this",Space,Str "decayed",Space,Str "hole",Space,Str "among",Space,Str "the",Space,Str "mountains"]]
+ ,Div ("",[],[])
+ [Plain [Str "In",Space,Str "the",Space,Str "faint",Space,Str "moonlight,",Space,Str "the",Space,Str "grass",Space,Str "is",Space,Str "singing"]]
+ ,Div ("",[],[])
+ [Plain [Str "Over",Space,Str "the",Space,Str "tumbled",Space,Str "graves,",Space,Str "about",Space,Str "the",Space,Str "chapel"]]
+ ,Div ("",[],[])
+ [Plain [Str "There",Space,Str "is",Space,Str "the",Space,Str "empty",Space,Str "chapel,",Space,Str "only",Space,Str "the",Space,Str "wind's",Space,Str "home."]]
+ ,Div ("",[],[])
+ [Plain [Str "It",Space,Str "has",Space,Str "no",Space,Str "windows,",Space,Str "and",Space,Str "the",Space,Str "door",Space,Str "swings,",Span ("",["lnum"],[]) [Str "390"]]]
+ ,Div ("",[],[])
+ [Plain [Str "Dry",Space,Str "bones",Space,Str "can",Space,Str "harm",Space,Str "no",Space,Str "one."]]
+ ,Div ("",[],[])
+ [Plain [Str "Only",Space,Str "a",Space,Str "cock",Space,Str "stood",Space,Str "on",Space,Str "the",Space,Str "rooftree"]]
+ ,Div ("",[],[])
+ [Plain [Str "Co",Space,Str "co",Space,Str "rico",Space,Str "co",Space,Str "co",Space,Str "rico"]]
+ ,Div ("",[],[])
+ [Plain [Str "In",Space,Str "a",Space,Str "flash",Space,Str "of",Space,Str "lightning.",Space,Str "Then",Space,Str "a",Space,Str "damp",Space,Str "gust"]]
+ ,Div ("",[],[])
+ [Plain [Str "Bringing",Space,Str "rain"]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",[],[])
+ [Plain [Str "Ganga",Space,Str "was",Space,Str "sunken,",Space,Str "and",Space,Str "the",Space,Str "limp",Space,Str "leaves"]]
+ ,Div ("",[],[])
+ [Plain [Str "Waited",Space,Str "for",Space,Str "rain,",Space,Str "while",Space,Str "the",Space,Str "black",Space,Str "clouds"]]
+ ,Div ("",[],[])
+ [Plain [Str "Gathered",Space,Str "far",Space,Str "distant,",Space,Str "over",Space,Str "Himavant."]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "jungle",Space,Str "crouched,",Space,Str "humped",Space,Str "in",Space,Str "silence."]]
+ ,Div ("",[],[])
+ [Plain [Str "Then",Space,Str "spoke",Space,Str "the",Space,Str "thunder",Span ("",["lnum"],[]) [Str "400"]]]
+ ,Div ("",[],[])
+ [Plain [Str "DA"]]
+ ,Div ("wasteland-content.xhtml#ln402",[],[])
+ [Plain [Span ("",[],[("lang","sa")]) [Str "Datta"],Str ":",Space,Str "what",Space,Str "have",Space,Str "we",Space,Str "given?",Note [Para [Link ("",[],[]) [Str "402."] ("#wasteland-content.xhtml#ln402",""),Space,Quoted DoubleQuote [Str "\"Datta,",Space,Str "dayadhvam,",Space,Str "damyata\""],Space,Str "(Give,",Space,Str "sympathize,",SoftBreak,Str "control).",Space,Str "The",Space,Str "fable",Space,Str "of",Space,Str "the",Space,Str "meaning",Space,Str "of",Space,Str "the",Space,Str "Thunder",Space,Str "is",Space,Str "found",Space,Str "in",Space,Str "the",SoftBreak,Str "Brihadaranyaka-Upanishad,",Space,Str "5,",Space,Str "1.",Space,Str "A",Space,Str "translation",Space,Str "is",Space,Str "found",Space,Str "in",Space,Str "Deussen's",SoftBreak,Str "Sechzig",Space,Str "Upanishads",Space,Str "des",Space,Str "Veda,",Space,Str "p.",Space,Str "489."]]]
+ ,Div ("",[],[])
+ [Plain [Str "My",Space,Str "friend,",Space,Str "blood",Space,Str "shaking",Space,Str "my",Space,Str "heart"]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "awful",Space,Str "daring",Space,Str "of",Space,Str "a",Space,Str "moment's",Space,Str "surrender"]]
+ ,Div ("",[],[])
+ [Plain [Str "Which",Space,Str "an",Space,Str "age",Space,Str "of",Space,Str "prudence",Space,Str "can",Space,Str "never",Space,Str "retract"]]
+ ,Div ("",[],[])
+ [Plain [Str "By",Space,Str "this,",Space,Str "and",Space,Str "this",Space,Str "only,",Space,Str "we",Space,Str "have",Space,Str "existed"]]
+ ,Div ("",[],[])
+ [Plain [Str "Which",Space,Str "is",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "found",Space,Str "in",Space,Str "our",Space,Str "obituaries"]]
+ ,Div ("wasteland-content.xhtml#ln408",[],[])
+ [Plain [Str "Or",Space,Str "in",Space,Str "memories",Space,Str "draped",Space,Str "by",Space,Str "the",Space,Str "beneficent",Space,Str "spider",Note [Para [Link ("",[],[]) [Str "408."] ("#wasteland-content.xhtml#ln408",""),Space,Str "Cf.",Space,Str "Webster,",Space,Str "The",Space,Str "White",Space,Str "Devil,",Space,Str "v.",Space,Str "vi:"],BlockQuote [Para [Str "\".",Space,Str ".",Space,Str ".",Space,Str "they'll",Space,Str "remarry",LineBreak,Str "Ere",Space,Str "the",Space,Str "worm",Space,Str "pierce",Space,Str "your",Space,Str "winding-sheet,",SoftBreak,Str "ere",Space,Str "the",Space,Str "spider",LineBreak,Str "Make",Space,Str "a",Space,Str "thin",Space,Str "curtain",Space,Str "for",Space,Str "your",Space,Str "epitaphs.\""]]]]
+ ,Div ("",[],[])
+ [Plain [Str "Or",Space,Str "under",Space,Str "seals",Space,Str "broken",Space,Str "by",Space,Str "the",Space,Str "lean",Space,Str "solicitor"]]
+ ,Div ("",[],[])
+ [Plain [Str "In",Space,Str "our",Space,Str "empty",Space,Str "rooms",Span ("",["lnum"],[]) [Str "410"]]]
+ ,Div ("",[],[])
+ [Plain [Str "DA"]]
+ ,Div ("wasteland-content.xhtml#ln412",[],[])
+ [Plain [Span ("",[],[("lang","sa")]) [Str "Dayadhvam"],Str ":",Space,Str "I",Space,Str "have",Space,Str "heard",Space,Str "the",Space,Str "key",Note [Para [Link ("",[],[]) [Str "412."] ("#wasteland-content.xhtml#ln412",""),Space,Str "Cf.",Space,Str "Inferno,",Space,Str "xxxiii.",Space,Str "46:"],BlockQuote [Para [Str "\"ed",Space,Str "io",Space,Str "sentii",Space,Str "chiavar",Space,Str "l'uscio",Space,Str "di",Space,Str "sotto",LineBreak,Str "all'orribile",Space,Str "torre.\""]],Para [Str "Also",Space,Str "F.",Space,Str "H.",Space,Str "Bradley,",Space,Str "Appearance",Space,Str "and",Space,Str "Reality,",Space,Str "p.",Space,Str "346:"],BlockQuote [Para [Str "\"My",Space,Str "external",Space,Str "sensations",Space,Str "are",Space,Str "no",Space,Str "less",Space,Str "private",Space,Str "to",Space,Str "myself",Space,Str "than",Space,Str "are",Space,Str "my",SoftBreak,Str "thoughts",Space,Str "or",Space,Str "my",Space,Str "feelings.",Space,Str "In",Space,Str "either",Space,Str "case",Space,Str "my",Space,Str "experience",Space,Str "falls",Space,Str "within",SoftBreak,Str "my",Space,Str "own",Space,Str "circle,",Space,Str "a",Space,Str "circle",Space,Str "closed",Space,Str "on",Space,Str "the",Space,Str "outside;",Space,Str "and,",Space,Str "with",Space,Str "all",Space,Str "its",SoftBreak,Str "elements",Space,Str "alike,",Space,Str "every",Space,Str "sphere",Space,Str "is",Space,Str "opaque",Space,Str "to",Space,Str "the",Space,Str "others",Space,Str "which",Space,Str "surround",SoftBreak,Str "it.",Space,Str ".",Space,Str ".",Space,Str ".",Space,Str "In",Space,Str "brief,",Space,Str "regarded",Space,Str "as",Space,Str "an",Space,Str "existence",Space,Str "which",Space,Str "appears",Space,Str "in",Space,Str "a",SoftBreak,Str "soul,",Space,Str "the",Space,Str "whole",Space,Str "world",Space,Str "for",Space,Str "each",Space,Str "is",Space,Str "peculiar",Space,Str "and",Space,Str "private",Space,Str "to",Space,Str "that",SoftBreak,Str "soul.\""]]]]
+ ,Div ("",[],[])
+ [Plain [Str "Turn",Space,Str "in",Space,Str "the",Space,Str "door",Space,Str "once",Space,Str "and",Space,Str "turn",Space,Str "once",Space,Str "only"]]
+ ,Div ("",[],[])
+ [Plain [Str "We",Space,Str "think",Space,Str "of",Space,Str "the",Space,Str "key,",Space,Str "each",Space,Str "in",Space,Str "his",Space,Str "prison"]]
+ ,Div ("",[],[])
+ [Plain [Str "Thinking",Space,Str "of",Space,Str "the",Space,Str "key,",Space,Str "each",Space,Str "confirms",Space,Str "a",Space,Str "prison"]]
+ ,Div ("",[],[])
+ [Plain [Str "Only",Space,Str "at",Space,Str "nightfall,",Space,Str "aetherial",Space,Str "rumours"]]
+ ,Div ("",[],[])
+ [Plain [Str "Revive",Space,Str "for",Space,Str "a",Space,Str "moment",Space,Str "a",Space,Str "broken",Space,Str "Coriolanus"]]
+ ,Div ("",[],[])
+ [Plain [Str "DA"]]
+ ,Div ("",[],[])
+ [Plain [Span ("",[],[("lang","sa")]) [Str "Damyata"],Str ":",Space,Str "The",Space,Str "boat",Space,Str "responded"]]
+ ,Div ("",[],[])
+ [Plain [Str "Gaily,",Space,Str "to",Space,Str "the",Space,Str "hand",Space,Str "expert",Space,Str "with",Space,Str "sail",Space,Str "and",Space,Str "oar",Span ("",["lnum"],[]) [Str "420"]]]
+ ,Div ("",[],[])
+ [Plain [Str "The",Space,Str "sea",Space,Str "was",Space,Str "calm,",Space,Str "your",Space,Str "heart",Space,Str "would",Space,Str "have",Space,Str "responded"]]
+ ,Div ("",[],[])
+ [Plain [Str "Gaily,",Space,Str "when",Space,Str "invited,",Space,Str "beating",Space,Str "obedient"]]
+ ,Div ("",[],[])
+ [Plain [Str "To",Space,Str "controlling",Space,Str "hands"]]]
+ ,Div ("",["linegroup"],[])
+ [Div ("",["indent"],[])
+ [Plain [Str "I",Space,Str "sat",Space,Str "upon",Space,Str "the",Space,Str "shore"]]
+ ,Div ("wasteland-content.xhtml#ln425",[],[])
+ [Plain [Str "Fishing,",Space,Str "with",Space,Str "the",Space,Str "arid",Space,Str "plain",Space,Str "behind",Space,Str "me",Note [Para [Link ("",[],[]) [Str "425."] ("#wasteland-content.xhtml#ln425",""),Space,Str "V.",Space,Str "Weston,",Space,Str "From",Space,Str "Ritual",Space,Str "to",Space,Str "Romance;",Space,Str "chapter",Space,Str "on",Space,Str "the",Space,Str "Fisher",Space,Str "King."]]]
+ ,Div ("",[],[])
+ [Plain [Str "Shall",Space,Str "I",Space,Str "at",Space,Str "least",Space,Str "set",Space,Str "my",Space,Str "lands",Space,Str "in",Space,Str "order?"]]
+ ,Div ("",[],[])
+ [Plain [Str "London",Space,Str "Bridge",Space,Str "is",Space,Str "falling",Space,Str "down",Space,Str "falling",Space,Str "down",Space,Str "falling",Space,Str "down"]]
+ ,Div ("wasteland-content.xhtml#ln428",[],[("lang","it")])
+ [Plain [Emph [Str "Poi",Space,Str "s'ascose",Space,Str "nel",Space,Str "foco",Space,Str "che",Space,Str "gli",Space,Str "affina"],SoftBreak,Note [Para [Link ("",[],[]) [Str "428."] ("#wasteland-content.xhtml#ln428",""),Space,Str "V.",Space,Str "Purgatorio,",Space,Str "xxvi.",Space,Str "148."],BlockQuote [Para [Str "\"'Ara",Space,Str "vos",Space,Str "prec",Space,Str "per",Space,Str "aquella",Space,Str "valor",LineBreak,Str "'que",Space,Str "vos",Space,Str "guida",Space,Str "al",Space,Str "som",Space,Str "de",SoftBreak,Str "l'escalina,",LineBreak,Str "'sovegna",Space,Str "vos",Space,Str "a",Space,Str "temps",Space,Str "de",Space,Str "ma",Space,Str "dolor.'",LineBreak,Str "Poi",SoftBreak,Str "s'ascose",Space,Str "nel",Space,Str "foco",Space,Str "che",Space,Str "gli",Space,Str "affina.\""]]]]
+ ,Div ("wasteland-content.xhtml#ln429",[],[])
+ [Plain [Span ("",[],[("lang","it")]) [SoftBreak,Emph [Str "Quando",Space,Str "fiam",Space,Str "ceu",Space,Str "chelidon"],SoftBreak],Space,Str "-",Space,Str "O",Space,Str "swallow",Space,Str "swallow",Note [Para [Link ("",[],[]) [Str "429."] ("#wasteland-content.xhtml#ln429",""),Space,Str "V.",Space,Str "Pervigilium",Space,Str "Veneris.",Space,Str "Cf.",Space,Str "Philomela",Space,Str "in",Space,Str "Parts",Space,Str "II",Space,Str "and",Space,Str "III."]]]
+ ,Div ("wasteland-content.xhtml#ln430",[],[("lang","fr")])
+ [Plain [Emph [Str "Le",Space,Str "Prince",Space,Str "d'Aquitaine",Space,Str "a",Space,Str "la",Space,Str "tour",Space,Str "abolie"],SoftBreak,Note [Para [Link ("",[],[]) [Str "430."] ("#wasteland-content.xhtml#ln430",""),Space,Str "V.",Space,Str "Gerard",Space,Str "de",Space,Str "Nerval,",Space,Str "Sonnet",Space,Str "El",Space,Str "Desdichado."]]]
+ ,Div ("",[],[])
+ [Plain [Str "These",Space,Str "fragments",Space,Str "I",Space,Str "have",Space,Str "shored",Space,Str "against",Space,Str "my",Space,Str "ruins"]]
+ ,Div ("wasteland-content.xhtml#ln432",[],[])
+ [Plain [Str "Why",Space,Str "then",Space,Str "Ile",Space,Str "fit",Space,Str "you.",Space,Str "Hieronymo's",Space,Str "mad",Space,Str "againe.",Note [Para [Link ("",[],[]) [Str "432."] ("#wasteland-content.xhtml#ln432",""),Space,Str "V.",Space,Str "Kyd's",Space,Str "Spanish",Space,Str "Tragedy."]]]
+ ,Div ("",[],[("lang","sa")])
+ [Plain [Str "Datta.",Space,Str "Dayadhvam.",Space,Str "Damyata."]]
+ ,Div ("wasteland-content.xhtml#ln434",["linegroup","indent"],[])
+ [Plain [Span ("",[],[("lang","sa")]) [Str "Shantih",Space,Str "shantih",Space,Str "shantih",Note [Para [Link ("",[],[]) [Str "434."] ("#wasteland-content.xhtml#ln434",""),Space,Str "Shantih.",Space,Str "Repeated",Space,Str "as",Space,Str "here,",Space,Str "a",Space,Str "formal",Space,Str "ending",Space,Str "to",Space,Str "an",Space,Str "Upanishad.",Space,Str "'The",SoftBreak,Str "Peace",Space,Str "which",Space,Str "passeth",Space,Str "understanding'",Space,Str "is",Space,Str "a",Space,Str "feeble",Space,Str "translation",Space,Str "of",Space,Str "the",SoftBreak,Str "content",Space,Str "of",Space,Str "this",Space,Str "word."]]]]
+ ,Div ("wasteland-content.xhtml#backmatter",["section"],[("type","backmatter")])
+ [Div ("wasteland-content.xhtml#rearnotes",["section"],[("type","rearnotes")])
+ [Header 2 ("",[],[]) [Str "NOTES",Space,Str "ON",Space,Str "\"THE",Space,Str "WASTE",Space,Str "LAND\""]
+ ,Para [Str "Not",Space,Str "only",Space,Str "the",Space,Str "title,",Space,Str "but",Space,Str "the",Space,Str "plan",Space,Str "and",Space,Str "a",Space,Str "good",Space,Str "deal",Space,Str "of",Space,Str "the",Space,Str "incidental",Space,Str "symbolism",Space,Str "of",SoftBreak,Str "the",Space,Str "poem",Space,Str "were",Space,Str "suggested",Space,Str "by",Space,Str "Miss",Space,Str "Jessie",Space,Str "L.",Space,Str "Weston's",Space,Str "book",Space,Str "on",Space,Str "the",Space,Str "Grail",Space,Str "legend:",SoftBreak,Str "From",Space,Str "Ritual",Space,Str "to",Space,Str "Romance"]
+ ,Para [Str "Indeed,",Space,Str "so",Space,Str "deeply",Space,Str "am",Space,Str "I",Space,Str "indebted,",Space,Str "Miss",Space,Str "Weston's",Space,Str "book",Space,Str "will",Space,Str "elucidate",Space,Str "the",SoftBreak,Str "difficulties",Space,Str "of",Space,Str "the",Space,Str "poem",Space,Str "much",Space,Str "better",Space,Str "than",Space,Str "my",Space,Str "notes",Space,Str "can",Space,Str "do;",Space,Str "and",Space,Str "I",Space,Str "recommend",Space,Str "it",SoftBreak,Str "(apart",Space,Str "from",Space,Str "the",Space,Str "great",Space,Str "interest",Space,Str "of",Space,Str "the",Space,Str "book",Space,Str "itself)",Space,Str "to",Space,Str "any",Space,Str "who",Space,Str "think",Space,Str "such",SoftBreak,Str "elucidation",Space,Str "of",Space,Str "the",Space,Str "poem",Space,Str "worth",Space,Str "the",Space,Str "trouble.",Space,Str "To",Space,Str "another",Space,Str "work",Space,Str "of",Space,Str "anthropology",Space,Str "I",Space,Str "am",SoftBreak,Str "indebted",Space,Str "in",Space,Str "general,",Space,Str "one",Space,Str "which",Space,Str "has",Space,Str "influenced",Space,Str "our",Space,Str "generation",Space,Str "profoundly;",Space,Str "I",Space,Str "mean",SoftBreak,Str "The",Space,Str "Golden",Space,Str "Bough;",Space,Str "I",Space,Str "have",Space,Str "used",Space,Str "especially",Space,Str "the",Space,Str "two",Space,Str "volumes",Space,Str "Adonis,",Space,Str "Attis,",Space,Str "Osiris.",SoftBreak,Str "Anyone",Space,Str "who",Space,Str "is",Space,Str "acquainted",Space,Str "with",Space,Str "these",Space,Str "works",Space,Str "will",Space,Str "immediately",Space,Str "recognise",Space,Str "in",Space,Str "the",Space,Str "poem",SoftBreak,Str "certain",Space,Str "references",Space,Str "to",Space,Str "vegetation",Space,Str "ceremonies."]
+ ,Div ("",["section"],[])
+ [Header 3 ("",[],[]) [Str "I.",Space,Str "THE",Space,Str "BURIAL",Space,Str "OF",Space,Str "THE",Space,Str "DEAD"]]
+ ,Div ("",["section"],[])
+ [Header 3 ("",[],[]) [Str "II.",Space,Str "A",Space,Str "GAME",Space,Str "OF",Space,Str "CHESS"]]
+ ,Div ("",["section"],[])
+ [Header 3 ("",[],[]) [Str "III.",Space,Str "THE",Space,Str "FIRE",Space,Str "SERMON"]]
+ ,Div ("",["section"],[])
+ [Header 3 ("",[],[]) [Str "V.",Space,Str "WHAT",Space,Str "THE",Space,Str "THUNDER",Space,Str "SAID"]
+ ,Para [Str "In",Space,Str "the",Space,Str "first",Space,Str "part",Space,Str "of",Space,Str "Part",Space,Str "V",Space,Str "three",Space,Str "themes",Space,Str "are",Space,Str "employed:",Space,Str "the",Space,Str "journey",Space,Str "to",Space,Str "Emmaus,",SoftBreak,Str "the",Space,Str "approach",Space,Str "to",Space,Str "the",Space,Str "Chapel",Space,Str "Perilous",Space,Str "(see",Space,Str "Miss",Space,Str "Weston's",Space,Str "book)",Space,Str "and",Space,Str "the",Space,Str "present",SoftBreak,Str "decay",Space,Str "of",Space,Str "eastern",Space,Str "Europe."]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
diff --git a/test/fb2/basic.fb2 b/test/fb2/basic.fb2
new file mode 100644
index 000000000..ffb2bfbdf
--- /dev/null
+++ b/test/fb2/basic.fb2
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"><description><title-info /><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><annotation><p></p></annotation><section><title><p>Top-level title</p></title><section><title><p>Section</p></title><section><title><p>Subsection</p></title><p>This <emphasis>emphasized</emphasis> <strong>strong</strong> <code>verbatim</code> markdown. See this link<a l:href="#l1" type="note"><sup>[1]</sup></a>.</p><p>Ordered list:</p><p> 1. one</p><p> 2. two</p><p> 3. three</p><cite><p>Blockquote is for citatons.</p></cite><empty-line /><p><code>Code</code></p><p><code>block</code></p><p><code>is</code></p><p><code>for</code></p><p><code>code.</code></p><empty-line /><p><strikethrough>Strikeout</strikethrough> is Pandoc’s extension. Superscript and subscripts too: H<sub>2</sub>O is a liquid<a l:href="#n2" type="note"><sup>[2]</sup></a>. 2<sup>10</sup> is 1024.</p><p>Math is another Pandoc extension: <code>E = m c^2</code>.</p></section></section></section></body><body name="notes"><section id="l1"><title><p>1</p></title><p><code>http://example.com/</code></p></section><section id="n2"><title><p>2</p></title><p>Sometimes.</p></section></body></FictionBook>
+
diff --git a/test/fb2/basic.markdown b/test/fb2/basic.markdown
new file mode 100644
index 000000000..b798b13a4
--- /dev/null
+++ b/test/fb2/basic.markdown
@@ -0,0 +1,33 @@
+# Top-level title
+
+## Section
+
+### Subsection
+
+This *emphasized* **strong** `verbatim` markdown.
+See this [link](http://example.com/).
+
+Ordered list:
+
+ 1. one
+ 1. two
+ 1. three
+
+> Blockquote
+> is
+> for
+> citatons.
+
+ Code
+ block
+ is
+ for
+ code.
+
+~~Strikeout~~ is Pandoc's extension.
+Superscript and subscripts too: H~2~O is a liquid[^1].
+2^10^ is 1024.
+
+Math is another Pandoc extension: $E = m c^2$.
+
+[^1]: Sometimes.
diff --git a/test/fb2/images-embedded.fb2 b/test/fb2/images-embedded.fb2
new file mode 100644
index 000000000..8c22efad3
--- /dev/null
+++ b/test/fb2/images-embedded.fb2
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"><description><title-info /><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><annotation><p></p></annotation><section><image l:href="#image1" l:type="inlineImageType" alt="This image was embedded using data URI scheme" /><p>This image was embedded using data URI scheme</p></section></body><binary id="image1" content-type="image/png">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</binary></FictionBook>
diff --git a/test/fb2/images-embedded.html b/test/fb2/images-embedded.html
new file mode 100644
index 000000000..19c8f7c7a
--- /dev/null
+++ b/test/fb2/images-embedded.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <meta name="generator" content="pandoc" />
+ <title></title>
+</head>
+<body>
+<div class="figure">
+<img src="data:image/png;base64,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" alt="This image was embedded using data URI scheme" /><p class="caption">This image was embedded using data URI scheme</p>
+</div>
+</body>
+</html>
diff --git a/test/fb2/images.fb2 b/test/fb2/images.fb2
new file mode 100644
index 000000000..8b783edf5
--- /dev/null
+++ b/test/fb2/images.fb2
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"><description><title-info /><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><annotation><p></p></annotation><section><p>This example test if Pandoc correctly embeds images into FictionBook.</p><p>Small inline image: <image l:href="#image1" l:type="inlineImageType" alt="alt text a small PNG image" />.</p><p>Paragraph image:</p><image l:href="#image2" l:type="imageType" alt="alt text of a big JPEG image" title="image title text" /><p>alt text of a big missing image</p><p>A missing image inline: alt text of missing image.</p></section></body><binary id="image2" content-type="image/jpeg">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</binary><binary id="image1" content-type="image/png">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</binary></FictionBook> \ No newline at end of file
diff --git a/test/fb2/images.markdown b/test/fb2/images.markdown
new file mode 100644
index 000000000..e7d3cc1e6
--- /dev/null
+++ b/test/fb2/images.markdown
@@ -0,0 +1,13 @@
+This example test if Pandoc correctly embeds images into FictionBook.
+
+Small inline image: ![alt text a small PNG image][inline-image].
+
+Paragraph image:
+
+![alt text of a big JPEG image](fb2/test.jpg "image title text")
+
+![alt text of a big missing image](missing.jpg)
+
+A missing image inline: ![alt text of missing image](missing.jpg).
+
+[inline-image]: fb2/test-small.png
diff --git a/test/fb2/math.fb2 b/test/fb2/math.fb2
new file mode 100644
index 000000000..5a69556c1
--- /dev/null
+++ b/test/fb2/math.fb2
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"><description><title-info /><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><annotation><p></p></annotation><section><p>List math:</p><p>• <code>E = m c^2</code></p><p>• <code>A = \pi r^2</code></p><p>Inline math: <code>x=\frac{-b \pm \sqrt {b^2-4ac}}{2a}</code>.</p><p>Display math:</p><code>\int_a^b \! f(x)\,dx = F(b) - F(a).</code></section></body></FictionBook> \ No newline at end of file
diff --git a/test/fb2/math.markdown b/test/fb2/math.markdown
new file mode 100644
index 000000000..a88fb6cf1
--- /dev/null
+++ b/test/fb2/math.markdown
@@ -0,0 +1,10 @@
+List math:
+
+- $E = m c^2$
+- $A = \pi r^2$
+
+Inline math: $x=\frac{-b \pm \sqrt {b^2-4ac}}{2a}$.
+
+Display math:
+
+$$\int_a^b \! f(x)\,dx = F(b) - F(a).$$
diff --git a/test/fb2/test-small.png b/test/fb2/test-small.png
new file mode 100644
index 000000000..16e177219
--- /dev/null
+++ b/test/fb2/test-small.png
Binary files differ
diff --git a/test/fb2/test.jpg b/test/fb2/test.jpg
new file mode 100644
index 000000000..99d57db17
--- /dev/null
+++ b/test/fb2/test.jpg
Binary files differ
diff --git a/test/fb2/titles.fb2 b/test/fb2/titles.fb2
new file mode 100644
index 000000000..9e8d47e36
--- /dev/null
+++ b/test/fb2/titles.fb2
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"><description><title-info /><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><annotation><p></p></annotation><section><title><p>Simple title</p></title><p>This example tests if Pandoc doesn’t insert forbidden elements in FictionBook titles.</p></section><section><title><p>Emphasized Strong Title</p></title></section><section><title><p>Title with</p><empty-line /><p>line break</p></title></section></body></FictionBook>
+
diff --git a/test/fb2/titles.markdown b/test/fb2/titles.markdown
new file mode 100644
index 000000000..cc3d0e0d0
--- /dev/null
+++ b/test/fb2/titles.markdown
@@ -0,0 +1,10 @@
+# Simple title
+
+This example tests if Pandoc doesn't insert forbidden elements in FictionBook titles.
+
+# *Emphasized* **Strong** Title
+
+# Title with\
+line break
+
+
diff --git a/test/haddock-reader.haddock b/test/haddock-reader.haddock
new file mode 100644
index 000000000..c3ef0c9fc
--- /dev/null
+++ b/test/haddock-reader.haddock
@@ -0,0 +1,65 @@
+This file tests the Pandoc reader for Haddock.
+We've borrowed examples from Haddock's documentation: <http://www.haskell.org/haddock/doc/html/ch03s08.html>.
+
+The following characters have special meanings in Haddock, \/, \', \`, \", \@, \<, so they must be escaped.
+
+\* This is a paragraph, not a list item.
+\> This sentence is not code.
+\>\>\> This is not an example.
+
+The references &#x3BB;, &#x3bb; and &#955; all represent the lower-case letter lambda.
+
+This is a code block:
+
+> map :: (a -> b) -> [a] -> [b]
+> map _ [] = []
+> map f (x:xs) = f x : map f xs
+
+This is another code block:
+
+@
+f x = x + x.
+The \@...\@ code block /interprets markup normally/.
+"Module.Foo"
+\"Hello World\"
+@
+
+Haddock supports REPL examples:
+
+>>> fib 10
+55
+>>> putStrLn "foo\nbar"
+foo
+bar
+
+That was /really cool/!
+I had no idea @fib 10 = 55@.
+
+This module defines the type 'T'.
+The identifier 'M.T' is not in scope
+I don't have to escape my apostrophes; great, isn't it?
+This is a reference to the "Foo" module.
+
+This is a bulleted list:
+
+ * first item
+
+ * second item
+
+This is an enumerated list:
+
+ (1) first item
+
+ 2. second item
+
+This is a definition list:
+
+ [@foo@] The description of @foo@.
+
+ [@bar@] The description of @bar@.
+
+Here is a link: <http://haskell.org>
+
+<http://haskell.org Haskell> is a fun language!
+
+<http://example.com Click Here!>
diff --git a/test/haddock-reader.native b/test/haddock-reader.native
new file mode 100644
index 000000000..7e36b2f72
--- /dev/null
+++ b/test/haddock-reader.native
@@ -0,0 +1,31 @@
+Pandoc (Meta {unMeta = fromList []})
+[Para [Str "This",Space,Str "file",Space,Str "tests",Space,Str "the",Space,Str "Pandoc",Space,Str "reader",Space,Str "for",Space,Str "Haddock.",SoftBreak,Str "We've",Space,Str "borrowed",Space,Str "examples",Space,Str "from",Space,Str "Haddock's",Space,Str "documentation:",Space,Link ("",[],[]) [Str "http://www.haskell.org/haddock/doc/html/ch03s08.html"] ("http://www.haskell.org/haddock/doc/html/ch03s08.html","http://www.haskell.org/haddock/doc/html/ch03s08.html"),Str "."]
+,Para [Str "The",Space,Str "following",Space,Str "characters",Space,Str "have",Space,Str "special",Space,Str "meanings",Space,Str "in",Space,Str "Haddock,",Space,Str "/,",Space,Str "',",Space,Str "`,",Space,Str "\",",Space,Str "@,",Space,Str "<,",Space,Str "so",Space,Str "they",Space,Str "must",Space,Str "be",Space,Str "escaped."]
+,Para [Str "*",Space,Str "This",Space,Str "is",Space,Str "a",Space,Str "paragraph,",Space,Str "not",Space,Str "a",Space,Str "list",Space,Str "item.",SoftBreak,Str ">",Space,Str "This",Space,Str "sentence",Space,Str "is",Space,Str "not",Space,Str "code.",SoftBreak,Str ">>>",Space,Str "This",Space,Str "is",Space,Str "not",Space,Str "an",Space,Str "example."]
+,Para [Str "The",Space,Str "references",Space,Str "\955,",Space,Str "\955",Space,Str "and",Space,Str "\955",Space,Str "all",Space,Str "represent",Space,Str "the",Space,Str "lower-case",Space,Str "letter",Space,Str "lambda."]
+,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "code",Space,Str "block:"]
+,CodeBlock ("",[],[]) "map :: (a -> b) -> [a] -> [b]\nmap _ [] = []\nmap f (x:xs) = f x : map f xs"
+,Para [Str "This",Space,Str "is",Space,Str "another",Space,Str "code",Space,Str "block:"]
+,Para [Code ("",[],[]) "f x = x + x.",LineBreak,Code ("",[],[]) "The @...@ code block ",Emph [Code ("",[],[]) "interprets markup normally"],Code ("",[],[]) ".",Code ("",["haskell","module"],[]) "Module.Foo",Code ("",[],[]) "",LineBreak,Code ("",[],[]) "\"Hello World\""]
+,Para [Str "Haddock",Space,Str "supports",Space,Str "REPL",Space,Str "examples:"]
+,Para [Code ("",["prompt"],[]) ">>>",Space,Code ("",["haskell","expr"],[]) "fib 10",LineBreak,Code ("",["result"],[]) "55"]
+,Para [Code ("",["prompt"],[]) ">>>",Space,Code ("",["haskell","expr"],[]) "putStrLn \"foo\\nbar\"",LineBreak,Code ("",["result"],[]) "foo",LineBreak,Code ("",["result"],[]) "bar"]
+,Para [Str "That",Space,Str "was",Space,Emph [Str "really",Space,Str "cool"],Str "!",SoftBreak,Str "I",Space,Str "had",Space,Str "no",Space,Str "idea",Space,Code ("",[],[]) "fib 10 = 55",Str "."]
+,Para [Str "This",Space,Str "module",Space,Str "defines",Space,Str "the",Space,Str "type",Space,Code ("",["haskell","identifier"],[]) "T",Str ".",SoftBreak,Str "The",Space,Str "identifier",Space,Code ("",["haskell","identifier"],[]) "M.T",Space,Str "is",Space,Str "not",Space,Str "in",Space,Str "scope",SoftBreak,Str "I",Space,Str "don't",Space,Str "have",Space,Str "to",Space,Str "escape",Space,Str "my",Space,Str "apostrophes;",Space,Str "great,",Space,Str "isn't",Space,Str "it?",SoftBreak,Str "This",Space,Str "is",Space,Str "a",Space,Str "reference",Space,Str "to",Space,Str "the",Space,Code ("",["haskell","module"],[]) "Foo",Space,Str "module."]
+,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "bulleted",Space,Str "list:"]
+,BulletList
+ [[Para [Str "first",Space,Str "item"]]
+ ,[Para [Str "second",Space,Str "item"]]]
+,Para [Str "This",Space,Str "is",Space,Str "an",Space,Str "enumerated",Space,Str "list:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Para [Str "first",Space,Str "item"]]
+ ,[Para [Str "second",Space,Str "item"]]]
+,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "definition",Space,Str "list:"]
+,DefinitionList
+ [([Code ("",[],[]) "foo"],
+ [[Para [Str "The",Space,Str "description",Space,Str "of",Space,Code ("",[],[]) "foo",Str "."]]])
+ ,([Code ("",[],[]) "bar"],
+ [[Para [Str "The",Space,Str "description",Space,Str "of",Space,Code ("",[],[]) "bar",Str "."]]])]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "link:",Space,Link ("",[],[]) [Str "http://haskell.org"] ("http://haskell.org","http://haskell.org")]
+,Para [Link ("",[],[]) [Str "Haskell"] ("http://haskell.org","http://haskell.org"),Space,Str "is",Space,Str "a",Space,Str "fun",Space,Str "language!"]
+,Para [Link ("",[],[]) [Str "Click",Space,Str "Here!"] ("http://example.com","http://example.com")]]
diff --git a/test/html-reader.html b/test/html-reader.html
new file mode 100644
index 000000000..3bd5e4ce3
--- /dev/null
+++ b/test/html-reader.html
@@ -0,0 +1,708 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<meta http-equiv="Content-Style-Type" content="text/css" />
+<meta name="generator" content="pandoc" />
+<style type="text/css">
+div.pandocNote { border-left: 1px solid grey; padding-left: 1em; }
+span.pandocNoteRef { vertical-align: super; font-size: 80%; }
+span.pandocNoteMarker { }
+</style>
+<title>Pandoc Test Suite</title>
+</head>
+<body>
+<h1 class="title">Pandoc Test Suite</h1>
+<p>This is a set of tests for pandoc. Most of them are adapted from John Gruber's markdown test suite.</p>
+<hr />
+<h1>Headers</h1>
+<h2>Level 2 with an <a href="/url">embedded link</a></h2>
+<h3>Level 3 with <em>emphasis</em></h3>
+<h4>Level 4</h4>
+<h5>Level 5</h5>
+<h1>Level 1</h1>
+<h2>Level 2 with <em>emphasis</em></h2>
+<h3>Level 3</h3>
+<p>with no blank line</p>
+<h2>Level 2</h2>
+<p>with no blank line</p>
+<hr />
+<h1>Paragraphs</h1>
+<p>Here's a regular paragraph.</p>
+<p>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.</p>
+<p>Here's one with a bullet. * criminey.</p>
+<p>There should be a hard line break<br />
+ here.</p>
+<hr />
+<h1>Block Quotes</h1>
+<p>E-mail style:</p>
+<blockquote>
+<p>This is a block quote. It is pretty short.</p>
+</blockquote>
+<blockquote>
+<p>Code in a block quote:</p>
+<pre><code>sub status {
+ print "working";
+}
+</code></pre>
+<p>A list:</p>
+<ol>
+<li>item one</li>
+<li>item two</li>
+</ol>
+<p>Nested block quotes:</p>
+<blockquote>
+<p>nested</p>
+</blockquote>
+<blockquote>
+<p>nested</p>
+</blockquote>
+</blockquote>
+<p>This should not be a block quote: 2 &gt; 1.</p>
+<p>Box-style:</p>
+<blockquote>
+<p>Example:</p>
+<pre><code>sub status {
+ print "working";
+}
+</code></pre>
+</blockquote>
+<blockquote>
+<ol>
+<li>do laundry</li>
+<li>take out the trash</li>
+</ol>
+</blockquote>
+<p>Here's a nested one:</p>
+<blockquote>
+<p>Joe said:</p>
+<blockquote>
+<p>Don't quote me.</p>
+</blockquote>
+</blockquote>
+<p>And a following paragraph.</p>
+<hr />
+<h1>Code Blocks</h1>
+<p>Code:</p>
+<pre><code>---- (should be four hyphens)
+
+sub status {
+ print "working";
+}
+
+this code block is indented by one tab
+</code></pre>
+<p>And:</p>
+<pre><code> this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \> \[ \{
+</code></pre>
+<hr />
+<h1>Lists</h1>
+<h2>Unordered</h2>
+<p>Asterisks tight:</p>
+<ul>
+<li>asterisk 1</li>
+<li>asterisk 2</li>
+<li>asterisk 3</li>
+</ul>
+<p>Asterisks loose:</p>
+<ul>
+<li><p>asterisk 1</p>
+</li>
+<li><p>asterisk 2</p>
+</li>
+<li><p>asterisk 3</p>
+</li>
+</ul>
+<p>Pluses tight:</p>
+<ul>
+<li>Plus 1</li>
+<li>Plus 2</li>
+<li>Plus 3</li>
+</ul>
+<p>Pluses loose:</p>
+<ul>
+<li><p>Plus 1</p>
+</li>
+<li><p>Plus 2</p>
+</li>
+<li><p>Plus 3</p>
+</li>
+</ul>
+<p>Minuses tight:</p>
+<ul>
+<li>Minus 1</li>
+<li>Minus 2</li>
+<li>Minus 3</li>
+</ul>
+<p>Minuses loose:</p>
+<ul>
+<li><p>Minus 1</p>
+</li>
+<li><p>Minus 2</p>
+</li>
+<li><p>Minus 3</p>
+</li>
+</ul>
+<h2>Ordered</h2>
+<p>Tight:</p>
+<ol>
+<li>First</li>
+<li>Second</li>
+<li>Third</li>
+</ol>
+<p>and:</p>
+<ol>
+<li>One</li>
+<li>Two</li>
+<li>Three</li>
+</ol>
+<p>Loose using tabs:</p>
+<ol>
+<li><p>First</p>
+</li>
+<li><p>Second</p>
+</li>
+<li><p>Third</p>
+</li>
+</ol>
+<p>and using spaces:</p>
+<ol>
+<li><p>One</p>
+</li>
+<li><p>Two</p>
+</li>
+<li><p>Three</p>
+</li>
+</ol>
+<p>Multiple paragraphs:</p>
+<ol>
+<li><p>Item 1, graf one.</p>
+<p>Item 1. graf two. The quick brown fox jumped over the lazy dog's back.</p>
+</li>
+<li><p>Item 2.</p>
+</li>
+<li><p>Item 3.</p>
+</li>
+</ol>
+<p>List styles:</p>
+<ol></ol>
+<ol type="i"></ol>
+<ol class="lower-roman"></ol>
+<ol style="lower-roman"></ol>
+<ol style="list-style: lower-roman;"></ol>
+<ol style="list-style-type: lower-roman;"></ol>
+<h2>Nested</h2>
+<ul>
+<li>Tab<ul>
+<li>Tab<ul>
+<li>Tab</li>
+</ul>
+</li>
+</ul>
+</li>
+</ul>
+<p>Here's another:</p>
+<ol>
+<li>First</li>
+<li>Second:<ul>
+<li>Fee</li>
+<li>Fie</li>
+<li>Foe</li>
+</ul>
+</li>
+<li>Third</li>
+</ol>
+<p>Same thing but with paragraphs:</p>
+<ol>
+<li><p>First</p>
+</li>
+<li><p>Second:</p>
+<ul>
+<li>Fee</li>
+<li>Fie</li>
+<li>Foe</li>
+</ul>
+</li>
+<li><p>Third</p>
+</li>
+</ol>
+<h2>Tabs and spaces</h2>
+<ul>
+<li><p>this is a list item indented with tabs</p>
+</li>
+<li><p>this is a list item indented with spaces</p>
+<ul>
+<li><p>this is an example list item indented with tabs</p>
+</li>
+<li><p>this is an example list item indented with spaces</p>
+</li>
+</ul>
+</li>
+</ul>
+<h2 id="fancy-list-markers"
+ >Fancy list markers</h2
+ ><ol start="2" class="decimal"
+ ><li
+ >begins with 2</li
+ ><li
+ ><p
+ >and now 3</p
+ ><p
+ >with a continuation</p
+ ><ol start="4" class="lower-roman"
+ ><li
+ >sublist with roman numerals, starting with 4</li
+ ><li
+ >more items<ol class="upper-alpha"
+ ><li
+ >a subsublist</li
+ ><li
+ >a subsublist</li
+ ></ol
+ ></li
+ ></ol
+ ></li
+ ></ol
+ ><p
+ >Nesting:</p
+ ><ol type="A"
+ ><li
+ >Upper Alpha<ol class="upper-roman"
+ ><li
+ >Upper Roman.<ol start="6" class="decimal"
+ ><li
+ >Decimal start with 6<ol start="3" type="a"
+ ><li
+ >Lower alpha with paren</li
+ ></ol
+ ></li
+ ></ol
+ ></li
+ ></ol
+ ></li
+ ></ol
+ ><p
+ >Autonumbering:</p
+ ><ol
+ ><li
+ >Autonumber.</li
+ ><li
+ >More.<ol
+ ><li
+ >Nested.</li
+ ></ol
+ ></li
+ ></ol
+ ><hr
+ />
+<h2>Definition</h2>
+<dl>
+ <dt>Violin</dt>
+ <dd>Stringed musical instrument.</dd>
+ <dd>Torture device.</dd>
+ <dt>Cello</dt>
+ <dt>Violoncello</dt>
+ <dd>Low-voiced stringed instrument.</dd>
+</dl>
+<hr />
+<h1>Inline Markup</h1>
+<p>This is <em>emphasized</em>, and so <em>is this</em>.</p>
+<p>This is <strong>strong</strong>, and so <strong>is this</strong>.</p>
+<p>Empty <strong></strong> and <em></em>.
+<p>An <em><a href="/url">emphasized link</a></em>.</p>
+<p><strong><em>This is strong and em.</em></strong></p>
+<p>So is <strong><em>this</em></strong> word.</p>
+<p><strong><em>This is strong and em.</em></strong></p>
+<p>So is <strong><em>this</em></strong> word.</p>
+<p>This is code: <code>&gt;</code>, <code>$</code>, <code>\</code>, <code>\$</code>, <code>&lt;html&gt;</code>.</p>
+<p>This is <span style="font-variant: small-caps;">small caps</span>.</p>
+<hr />
+<h1>Smart quotes, ellipses, dashes</h1>
+<p>"Hello," said the spider. "'Shelob' is my name."</p>
+<p>'A', 'B', and 'C' are letters.</p>
+<p>'Oak,' 'elm,' and 'beech' are names of trees. So is 'pine.'</p>
+<p>'He said, "I want to go."' Were you alive in the 70's?</p>
+<p>Here is some quoted '<code>code</code>' and a "<a href="http://example.com/?foo=1&amp;bar=2">quoted link</a>".</p>
+<p>Some dashes: one---two --- three--four -- five.</p>
+<p>Dashes between numbers: 5-7, 255-66, 1987-1999.</p>
+<p>Ellipses...and. . .and . . . .</p>
+<hr />
+<h1>LaTeX</h1>
+<ul>
+<li>\cite[22-23]{smith.1899}</li>
+<li>\doublespacing</li>
+<li>$2+2=4$</li>
+<li>$x \in y$</li>
+<li>$\alpha \wedge \omega$</li>
+<li>$223$</li>
+<li>$p$-Tree</li>
+<li>$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</li>
+<li>Here's one that has a line break in it: $\alpha + \omega \times x^2$.</li>
+</ul>
+<p>These shouldn't be math:</p>
+<ul>
+<li>To get the famous equation, write <code>$e = mc^2$</code>.</li>
+<li>$22,000 is a <em>lot</em> of money. So is $34,000. (It worked if "lot" is emphasized.)</li>
+<li>Escaped <code>$</code>: $73 <em>this should be emphasized</em> 23$.</li>
+</ul>
+<p>Here's a LaTeX table:</p>
+<p>\begin{tabular}{|l|l|}\hline Animal &amp; Number \\ \hline Dog &amp; 2 \\ Cat &amp; 1 \\ \hline \end{tabular}</p>
+<hr />
+<h1>Special Characters</h1>
+<p>Here is some unicode:</p>
+<ul>
+<li>I hat: Î</li>
+<li>o umlaut: ö</li>
+<li>section: §</li>
+<li>set membership: ∈</li>
+<li>copyright: ©</li>
+</ul>
+<p>AT&amp;T has an ampersand in their name.</p>
+<p>AT&amp;T is another way to write it.</p>
+<p>This &amp; that.</p>
+<p>4 &lt; 5.</p>
+<p>6 &gt; 5.</p>
+<p>Backslash: \</p>
+<p>Backtick: `</p>
+<p>Asterisk: *</p>
+<p>Underscore: _</p>
+<p>Left brace: {</p>
+<p>Right brace: }</p>
+<p>Left bracket: [</p>
+<p>Right bracket: ]</p>
+<p>Left paren: (</p>
+<p>Right paren: )</p>
+<p>Greater-than: &gt;</p>
+<p>Hash: #</p>
+<p>Period: .</p>
+<p>Bang: !</p>
+<p>Plus: +</p>
+<p>Minus: -</p>
+<hr />
+<h1>Links</h1>
+<h2>Explicit</h2>
+<p>Just a <a href="/url/">URL</a>.</p>
+<p><a href="/url/" title="title">URL and title</a>.</p>
+<p><a href="/url/" title="title preceded by two spaces">URL and title</a>.</p>
+<p><a href="/url/" title="title preceded by a tab">URL and title</a>.</p>
+<p><a href="/url/" title="title with &quot;quotes&quot; in it">URL and title</a></p>
+<p><a href="/url/" title="title with single quotes">URL and title</a></p>
+Email link (nobody [at] nowhere.net)<p><a href="">Empty</a>.</p>
+<h2>Reference</h2>
+<p>Foo <a href="/url/">bar</a>.</p>
+<p>Foo <a href="/url/">bar</a>.</p>
+<p>Foo <a href="/url/">bar</a>.</p>
+<p>With <a href="/url/">embedded [brackets]</a>.</p>
+<p><a href="/url/">b</a> by itself should be a link.</p>
+<p>Indented <a href="/url">once</a>.</p>
+<p>Indented <a href="/url">twice</a>.</p>
+<p>Indented <a href="/url">thrice</a>.</p>
+<p>This should [not] be a link.</p>
+<pre><code>[not]: /url
+</code></pre>
+<p>Foo <a href="/url/" title="Title with &quot;quotes&quot; inside">bar</a>.</p>
+<p>Foo <a href="/url/" title="Title with &quot;quote&quot; inside">biz</a>.</p>
+<h2>With ampersands</h2>
+<p>Here's a <a href="http://example.com/?foo=1&amp;bar=2">link with an ampersand in the URL</a>.</p>
+<p>Here's a link with an amersand in the link text: <a href="http://att.com/" title="AT&T">AT&amp;T</a>.</p>
+<p>Here's an <a href="/script?foo=1&amp;bar=2">inline link</a>.</p>
+<p>Here's an <a href="/script?foo=1&amp;bar=2">inline link in pointy braces</a>.</p>
+<h2>Autolinks</h2>
+<p>With an ampersand: <a href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</a></p>
+<ul>
+<li>In a list?</li>
+<li><a href="http://example.com/">http://example.com/</a></li>
+<li>It should.</li>
+</ul>
+An e-mail address: nobody [at] nowhere.net<blockquote>
+<p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>
+</blockquote>
+<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
+<pre><code>or here: &lt;http://example.com/&gt;
+</code></pre>
+<hr />
+<h1>Images</h1>
+<p>From "Voyage dans la Lune" by Georges Melies (1902):</p>
+<p><img src="lalune.jpg" title="Voyage dans la Lune" alt="lalune"></p>
+<p>Here is a movie <img src="movie.jpg" alt="movie"> icon.</p>
+<hr />
+<h1>Footnotes</h1>
+<p>Here is a footnote reference<a href="#note_1">(1)</a>, and another<a href="#note_longnote">(longnote)</a>. This should <em>not</em> be a footnote reference, because it contains a space^(my note).</p>
+<p><a href="#ref_1">(1)</a> Here is the footnote. It can go anywhere in the document, not just at the end.</p>
+<p><a href="#ref_longnote">(longnote)</a> Here's the other note. This one contains multiple blocks.</p>
+<p>Caret characters are used to indicate that the blocks all belong to a single footnote (as with block quotes).</p>
+<pre><code> { &lt;code> }
+</code></pre>
+<p>If you want, you can use a caret at the beginning of every line, as with blockquotes, but all that you need is a caret at the beginning of the first line of the block and any preceding blank lines.</p>
+<p>text<em> Leading space</em></p>
+<p><em>Trailing space </em>text</p>
+<p>text<em> Leading spaces</em></p>
+<p><em>Trailing spaces </em>text</p>
+<h1>Tables</h1>
+<h2>Tables with Headers</h2>
+<table>
+ <tr>
+ <th>X</th>
+ <th>Y</th>
+ <th>Z</th>
+ </tr>
+ <tr>
+ <td>1</td>
+ <td>2</td>
+ <td>3</td>
+ </tr>
+ <tr>
+ <td>4</td>
+ <td>5</td>
+ <td>6</td>
+ </tr>
+</table>
+<hr />
+<table>
+ <thead>
+ <tr>
+ <th>X</th>
+ <th>Y</th>
+ <th>Z</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>1</td>
+ <td>2</td>
+ <td>3</td>
+ </tr>
+ <tr>
+ <td>4</td>
+ <td>5</td>
+ <td>6</td>
+ </tr>
+ </tbody>
+</table>
+<hr />
+<table>
+ <thead>
+ <tr>
+ <th>X</th>
+ <th>Y</th>
+ <th>Z</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th>1</th>
+ <td>2</td>
+ <td>3</td>
+ </tr>
+ <tr>
+ <th>4</th>
+ <td>5</td>
+ <td>6</td>
+ </tr>
+ </tbody>
+</table>
+<hr />
+<table>
+ <thead>
+ <tr>
+ <th>X</th>
+ <th>Y</th>
+ <th>Z</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <th>1</th>
+ <td>2</td>
+ <td>3</td>
+ </tr>
+ </tbody>
+ <tfoot>
+ <tr>
+ <th>4</th>
+ <td>5</td>
+ <td>6</td>
+ </tr>
+ </tfoot>
+</table>
+<hr />
+<table>
+ <tr>
+ <th>X</th>
+ <th>Y</th>
+ <th>Z</th>
+ </tr>
+ <tr>
+ <th>1</th>
+ <th>2</th>
+ <th>3</th>
+ </tr>
+ <tr>
+ <td>4</td>
+ <td>5</td>
+ <td>6</td>
+ </tr>
+</table>
+<hr />
+<table>
+ <tbody>
+ <tr>
+ <th>X</th>
+ <th>Y</th>
+ <th>Z</th>
+ </tr>
+ <tr>
+ <td>1</td>
+ <td>2</td>
+ <td>3</td>
+ </tr>
+ <tr>
+ <td>4</td>
+ <td>5</td>
+ <td>6</td>
+ </tr>
+ </tbody>
+</table>
+<hr />
+<table>
+ <thead>
+ </thead>
+ <tbody>
+ <tr>
+ <th>X</th>
+ <th>Y</th>
+ <th>Z</th>
+ </tr>
+ <tr>
+ <td>1</td>
+ <td>2</td>
+ <td>3</td>
+ </tr>
+ <tr>
+ <td>4</td>
+ <td>5</td>
+ <td>6</td>
+ </tr>
+ </tbody>
+</table>
+<hr />
+<table>
+ <thead>
+ <tr>
+ <th>X</th>
+ <th>Y</th>
+ <th>Z</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>1</td>
+ <td>2</td>
+ <td>3</td>
+ </tr>
+ </tbody>
+ <tbody>
+ <tr>
+ <td>4</td>
+ <td>5</td>
+ <td>6</td>
+ </tr>
+ </tbody>
+</table>
+<hr />
+<table>
+ <thead>
+ <tr>
+ <th>X</th>
+ <th>Y</th>
+ <th>Z</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>1</td>
+ <td><p>2</p></td>
+ <td>3</td>
+ </tr>
+ </tbody>
+ <tbody>
+ <tr>
+ <td>4</td>
+ <td>5</td>
+ <td>6</td>
+ </tr>
+ </tbody>
+</table>
+<h2>Tables without Headers</h2>
+<table>
+ <tbody>
+ <tr>
+ <td>1</td>
+ <td>2</td>
+ <td>3</td>
+ </tr>
+ <tr>
+ <td>4</td>
+ <td>5</td>
+ <td>6</td>
+ </tr>
+ </tbody>
+</table>
+<hr />
+<table>
+ <tr>
+ <td>1</td>
+ <td>2</td>
+ <td>3</td>
+ </tr>
+ <tr>
+ <td>4</td>
+ <td>5</td>
+ <td>6</td>
+ </tr>
+</table>
+<hr />
+<table>
+ <thead>
+ </thead>
+ <tbody>
+ <tr>
+ <td>1</td>
+ <td>2</td>
+ <td>3</td>
+ </tr>
+ <tr>
+ <td>4</td>
+ <td>5</td>
+ <td>6</td>
+ </tr>
+ </tbody>
+</table>
+<hr />
+<table>
+ <tbody>
+ <tr>
+ <td>1</td>
+ <td>2</td>
+ <td>3</td>
+ </tr>
+ </tbody>
+ <tfoot>
+ <tr>
+ <td>4</td>
+ <td>5</td>
+ <td>6</td>
+ </tr>
+ </tfoot>
+</table>
+<h2>Empty Tables</h2>
+<p>This section should be empty.</p>
+<table>
+ <tbody>
+ </tbody>
+</table>
+<table>
+</table>
+</body>
+</html>
diff --git a/test/html-reader.native b/test/html-reader.native
new file mode 100644
index 000000000..6b7799a88
--- /dev/null
+++ b/test/html-reader.native
@@ -0,0 +1,463 @@
+Pandoc (Meta {unMeta = fromList [("generator",MetaInlines [Str "pandoc"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])]})
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber's",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
+,HorizontalRule
+,Header 1 ("headers",[],[]) [Str "Headers"]
+,Header 2 ("level-2-with-an-embedded-link",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link ("",[],[]) [Str "embedded",Space,Str "link"] ("/url","")]
+,Header 3 ("level-3-with-emphasis",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 4 ("level-4",[],[]) [Str "Level",Space,Str "4"]
+,Header 5 ("level-5",[],[]) [Str "Level",Space,Str "5"]
+,Header 1 ("level-1",[],[]) [Str "Level",Space,Str "1"]
+,Header 2 ("level-2-with-emphasis",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 3 ("level-3",[],[]) [Str "Level",Space,Str "3"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,Header 2 ("level-2",[],[]) [Str "Level",Space,Str "2"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,HorizontalRule
+,Header 1 ("paragraphs",[],[]) [Str "Paragraphs"]
+,Para [Str "Here's",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
+,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]
+,Para [Str "Here's",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]
+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here."]
+,HorizontalRule
+,Header 1 ("block-quotes",[],[]) [Str "Block",Space,Str "Quotes"]
+,Para [Str "E-mail",Space,Str "style:"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]]
+,BlockQuote
+ [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
+ ,Para [Str "A",Space,Str "list:"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "item",Space,Str "one"]]
+ ,[Plain [Str "item",Space,Str "two"]]]
+ ,Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
+ ,BlockQuote
+ [Para [Str "nested"]]
+ ,BlockQuote
+ [Para [Str "nested"]]]
+,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",Space,Str ">",Space,Str "1."]
+,Para [Str "Box-style:"]
+,BlockQuote
+ [Para [Str "Example:"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"]
+,BlockQuote
+ [OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "do",Space,Str "laundry"]]
+ ,[Plain [Str "take",Space,Str "out",Space,Str "the",Space,Str "trash"]]]]
+,Para [Str "Here's",Space,Str "a",Space,Str "nested",Space,Str "one:"]
+,BlockQuote
+ [Para [Str "Joe",Space,Str "said:"]
+ ,BlockQuote
+ [Para [Str "Don't",Space,Str "quote",Space,Str "me."]]]
+,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."]
+,HorizontalRule
+,Header 1 ("code-blocks",[],[]) [Str "Code",Space,Str "Blocks"]
+,Para [Str "Code:"]
+,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"
+,Para [Str "And:"]
+,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
+,HorizontalRule
+,Header 1 ("lists",[],[]) [Str "Lists"]
+,Header 2 ("unordered",[],[]) [Str "Unordered"]
+,Para [Str "Asterisks",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "asterisk",Space,Str "1"]]
+ ,[Plain [Str "asterisk",Space,Str "2"]]
+ ,[Plain [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Asterisks",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "asterisk",Space,Str "1"]]
+ ,[Para [Str "asterisk",Space,Str "2"]]
+ ,[Para [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "Plus",Space,Str "1"]]
+ ,[Plain [Str "Plus",Space,Str "2"]]
+ ,[Plain [Str "Plus",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "Plus",Space,Str "1"]]
+ ,[Para [Str "Plus",Space,Str "2"]]
+ ,[Para [Str "Plus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "Minus",Space,Str "1"]]
+ ,[Plain [Str "Minus",Space,Str "2"]]
+ ,[Plain [Str "Minus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "Minus",Space,Str "1"]]
+ ,[Para [Str "Minus",Space,Str "2"]]
+ ,[Para [Str "Minus",Space,Str "3"]]]
+,Header 2 ("ordered",[],[]) [Str "Ordered"]
+,Para [Str "Tight:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second"]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "and:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "One"]]
+ ,[Plain [Str "Two"]]
+ ,[Plain [Str "Three"]]]
+,Para [Str "Loose",Space,Str "using",Space,Str "tabs:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second"]]
+ ,[Para [Str "Third"]]]
+,Para [Str "and",Space,Str "using",Space,Str "spaces:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Para [Str "One"]]
+ ,[Para [Str "Two"]]
+ ,[Para [Str "Three"]]]
+,Para [Str "Multiple",Space,Str "paragraphs:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]
+ ,Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog's",Space,Str "back."]]
+ ,[Para [Str "Item",Space,Str "2."]]
+ ,[Para [Str "Item",Space,Str "3."]]]
+,Para [Str "List",Space,Str "styles:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ []
+,OrderedList (1,LowerRoman,DefaultDelim)
+ []
+,OrderedList (1,LowerRoman,DefaultDelim)
+ []
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ []
+,OrderedList (1,LowerRoman,DefaultDelim)
+ []
+,OrderedList (1,LowerRoman,DefaultDelim)
+ []
+,Header 2 ("nested",[],[]) [Str "Nested"]
+,BulletList
+ [[Plain [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]]]]]]]
+,Para [Str "Here's",Space,Str "another:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second:"]
+ ,BulletList
+ [[Plain [Str "Fee"]]
+ ,[Plain [Str "Fie"]]
+ ,[Plain [Str "Foe"]]]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second:"]
+ ,BulletList
+ [[Plain [Str "Fee"]]
+ ,[Plain [Str "Fie"]]
+ ,[Plain [Str "Foe"]]]]
+ ,[Para [Str "Third"]]]
+,Header 2 ("tabs-and-spaces",[],[]) [Str "Tabs",Space,Str "and",Space,Str "spaces"]
+,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]
+ ,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]
+,Header 2 ("fancy-list-markers",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"]
+,OrderedList (2,Decimal,DefaultDelim)
+ [[Plain [Str "begins",Space,Str "with",Space,Str "2"]]
+ ,[Para [Str "and",Space,Str "now",Space,Str "3"]
+ ,Para [Str "with",Space,Str "a",Space,Str "continuation"]
+ ,OrderedList (4,LowerRoman,DefaultDelim)
+ [[Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"]]
+ ,[Plain [Str "more",Space,Str "items"]
+ ,OrderedList (1,UpperAlpha,DefaultDelim)
+ [[Plain [Str "a",Space,Str "subsublist"]]
+ ,[Plain [Str "a",Space,Str "subsublist"]]]]]]]
+,Para [Str "Nesting:"]
+,OrderedList (1,UpperAlpha,DefaultDelim)
+ [[Plain [Str "Upper",Space,Str "Alpha"]
+ ,OrderedList (1,UpperRoman,DefaultDelim)
+ [[Plain [Str "Upper",Space,Str "Roman."]
+ ,OrderedList (6,Decimal,DefaultDelim)
+ [[Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
+ ,OrderedList (3,LowerAlpha,DefaultDelim)
+ [[Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]
+,Para [Str "Autonumbering:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Autonumber."]]
+ ,[Plain [Str "More."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Nested."]]]]]
+,HorizontalRule
+,Header 2 ("definition",[],[]) [Str "Definition"]
+,DefinitionList
+ [([Str "Violin"],
+ [[Plain [Str "Stringed",Space,Str "musical",Space,Str "instrument."]]
+ ,[Plain [Str "Torture",Space,Str "device."]]])
+ ,([Str "Cello",LineBreak,Str "Violoncello"],
+ [[Plain [Str "Low-voiced",Space,Str "stringed",Space,Str "instrument."]]])]
+,HorizontalRule
+,Header 1 ("inline-markup",[],[]) [Str "Inline",Space,Str "Markup"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
+,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
+,Para [Str "Empty",Space,Strong [],Space,Str "and",Space,Emph [],Str "."]
+,Para [Str "An",Space,Emph [Link ("",[],[]) [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
+,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]
+,Para [Str "This",Space,Str "is",Space,SmallCaps [Str "small",Space,Str "caps"],Str "."]
+,HorizontalRule
+,Header 1 ("smart-quotes-ellipses-dashes",[],[]) [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
+,Para [Str "\"Hello,\"",Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Str "\"'Shelob'",Space,Str "is",Space,Str "my",Space,Str "name.\""]
+,Para [Str "'A',",Space,Str "'B',",Space,Str "and",Space,Str "'C'",Space,Str "are",Space,Str "letters."]
+,Para [Str "'Oak,'",Space,Str "'elm,'",Space,Str "and",Space,Str "'beech'",Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees.",Space,Str "So",Space,Str "is",Space,Str "'pine.'"]
+,Para [Str "'He",Space,Str "said,",Space,Str "\"I",Space,Str "want",Space,Str "to",Space,Str "go.\"'",Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70's?"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Str "'",Code ("",[],[]) "code",Str "'",Space,Str "and",Space,Str "a",Space,Str "\"",Link ("",[],[]) [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2",""),Str "\"."]
+,Para [Str "Some",Space,Str "dashes:",Space,Str "one---two",Space,Str "---",Space,Str "three--four",Space,Str "--",Space,Str "five."]
+,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5-7,",Space,Str "255-66,",Space,Str "1987-1999."]
+,Para [Str "Ellipses...and.",Space,Str ".",Space,Str ".and",Space,Str ".",Space,Str ".",Space,Str ".",Space,Str "."]
+,HorizontalRule
+,Header 1 ("latex",[],[]) [Str "LaTeX"]
+,BulletList
+ [[Plain [Str "\\cite[22-23]{smith.1899}"]]
+ ,[Plain [Str "\\doublespacing"]]
+ ,[Plain [Str "$2+2=4$"]]
+ ,[Plain [Str "$x",Space,Str "\\in",Space,Str "y$"]]
+ ,[Plain [Str "$\\alpha",Space,Str "\\wedge",Space,Str "\\omega$"]]
+ ,[Plain [Str "$223$"]]
+ ,[Plain [Str "$p$-Tree"]]
+ ,[Plain [Str "$\\frac{d}{dx}f(x)=\\lim_{h\\to",Space,Str "0}\\frac{f(x+h)-f(x)}{h}$"]]
+ ,[Plain [Str "Here's",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it:",Space,Str "$\\alpha",Space,Str "+",Space,Str "\\omega",Space,Str "\\times",Space,Str "x^2$."]]]
+,Para [Str "These",Space,Str "shouldn't",Space,Str "be",Space,Str "math:"]
+,BulletList
+ [[Plain [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation,",Space,Str "write",Space,Code ("",[],[]) "$e = mc^2$",Str "."]]
+ ,[Plain [Str "$22,000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money.",Space,Str "So",Space,Str "is",Space,Str "$34,000.",Space,Str "(It",Space,Str "worked",Space,Str "if",Space,Str "\"lot\"",Space,Str "is",Space,Str "emphasized.)"]]
+ ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23$."]]]
+,Para [Str "Here's",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"]
+,Para [Str "\\begin{tabular}{|l|l|}\\hline",Space,Str "Animal",Space,Str "&",Space,Str "Number",Space,Str "\\\\",Space,Str "\\hline",Space,Str "Dog",Space,Str "&",Space,Str "2",Space,Str "\\\\",Space,Str "Cat",Space,Str "&",Space,Str "1",Space,Str "\\\\",Space,Str "\\hline",Space,Str "\\end{tabular}"]
+,HorizontalRule
+,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
+,BulletList
+ [[Plain [Str "I",Space,Str "hat:",Space,Str "\206"]]
+ ,[Plain [Str "o",Space,Str "umlaut:",Space,Str "\246"]]
+ ,[Plain [Str "section:",Space,Str "\167"]]
+ ,[Plain [Str "set",Space,Str "membership:",Space,Str "\8712"]]
+ ,[Plain [Str "copyright:",Space,Str "\169"]]]
+,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]
+,Para [Str "AT&T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it."]
+,Para [Str "This",Space,Str "&",Space,Str "that."]
+,Para [Str "4",Space,Str "<",Space,Str "5."]
+,Para [Str "6",Space,Str ">",Space,Str "5."]
+,Para [Str "Backslash:",Space,Str "\\"]
+,Para [Str "Backtick:",Space,Str "`"]
+,Para [Str "Asterisk:",Space,Str "*"]
+,Para [Str "Underscore:",Space,Str "_"]
+,Para [Str "Left",Space,Str "brace:",Space,Str "{"]
+,Para [Str "Right",Space,Str "brace:",Space,Str "}"]
+,Para [Str "Left",Space,Str "bracket:",Space,Str "["]
+,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]
+,Para [Str "Left",Space,Str "paren:",Space,Str "("]
+,Para [Str "Right",Space,Str "paren:",Space,Str ")"]
+,Para [Str "Greater-than:",Space,Str ">"]
+,Para [Str "Hash:",Space,Str "#"]
+,Para [Str "Period:",Space,Str "."]
+,Para [Str "Bang:",Space,Str "!"]
+,Para [Str "Plus:",Space,Str "+"]
+,Para [Str "Minus:",Space,Str "-"]
+,HorizontalRule
+,Header 1 ("links",[],[]) [Str "Links"]
+,Header 2 ("explicit",[],[]) [Str "Explicit"]
+,Para [Str "Just",Space,Str "a",Space,Link ("",[],[]) [Str "URL"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title"),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by two spaces"),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by a tab"),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with \"quotes\" in it")]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with single quotes")]
+,Para [Str "Email",Space,Str "link",Space,Str "(nobody",Space,Str "[at]",Space,Str "nowhere.net)"]
+,Para [Link ("",[],[]) [Str "Empty"] ("",""),Str "."]
+,Header 2 ("reference",[],[]) [Str "Reference"]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "With",Space,Link ("",[],[]) [Str "embedded",Space,Str "[brackets]"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "once"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "twice"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "thrice"] ("/url",""),Str "."]
+,Para [Str "This",Space,Str "should",Space,Str "[not]",Space,Str "be",Space,Str "a",Space,Str "link."]
+,CodeBlock ("",[],[]) "[not]: /url"
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/","Title with \"quotes\" inside"),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "biz"] ("/url/","Title with \"quote\" inside"),Str "."]
+,Header 2 ("with-ampersands",[],[]) [Str "With",Space,Str "ampersands"]
+,Para [Str "Here's",Space,Str "a",Space,Link ("",[],[]) [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
+,Para [Str "Here's",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link ("",[],[]) [Str "AT&T"] ("http://att.com/","AT&T"),Str "."]
+,Para [Str "Here's",Space,Str "an",Space,Link ("",[],[]) [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."]
+,Para [Str "Here's",Space,Str "an",Space,Link ("",[],[]) [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]
+,Header 2 ("autolinks",[],[]) [Str "Autolinks"]
+,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link ("",[],[]) [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]
+,BulletList
+ [[Plain [Str "In",Space,Str "a",Space,Str "list?"]]
+ ,[Plain [Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]
+ ,[Plain [Str "It",Space,Str "should."]]]
+,Para [Str "An",Space,Str "e-mail",Space,Str "address:",Space,Str "nobody",Space,Str "[at]",Space,Str "nowhere.net"]
+,BlockQuote
+ [Para [Str "Blockquoted:",Space,Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]
+,Para [Str "Auto-links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"]
+,CodeBlock ("",[],[]) "or here: <http://example.com/>"
+,HorizontalRule
+,Header 1 ("images",[],[]) [Str "Images"]
+,Para [Str "From",Space,Str "\"Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune\"",Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
+,Para [Image ("",[],[]) [Str "lalune"] ("lalune.jpg","Voyage dans la Lune")]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image ("",[],[]) [Str "movie"] ("movie.jpg",""),Space,Str "icon."]
+,HorizontalRule
+,Header 1 ("footnotes",[],[]) [Str "Footnotes"]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference",Link ("",[],[]) [Str "(1)"] ("#note_1",""),Str ",",Space,Str "and",Space,Str "another",Link ("",[],[]) [Str "(longnote)"] ("#note_longnote",""),Str ".",Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space^(my",Space,Str "note)."]
+,Para [Link ("",[],[]) [Str "(1)"] ("#ref_1",""),Space,Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote.",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "in",Space,Str "the",Space,Str "document,",Space,Str "not",Space,Str "just",Space,Str "at",Space,Str "the",Space,Str "end."]
+,Para [Link ("",[],[]) [Str "(longnote)"] ("#ref_longnote",""),Space,Str "Here's",Space,Str "the",Space,Str "other",Space,Str "note.",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks."]
+,Para [Str "Caret",Space,Str "characters",Space,Str "are",Space,Str "used",Space,Str "to",Space,Str "indicate",Space,Str "that",Space,Str "the",Space,Str "blocks",Space,Str "all",Space,Str "belong",Space,Str "to",Space,Str "a",Space,Str "single",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "block",Space,Str "quotes)."]
+,CodeBlock ("",[],[]) " { <code> }"
+,Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "use",Space,Str "a",Space,Str "caret",Space,Str "at",Space,Str "the",Space,Str "beginning",Space,Str "of",Space,Str "every",Space,Str "line,",Space,Str "as",Space,Str "with",Space,Str "blockquotes,",Space,Str "but",Space,Str "all",Space,Str "that",Space,Str "you",Space,Str "need",Space,Str "is",Space,Str "a",Space,Str "caret",Space,Str "at",Space,Str "the",Space,Str "beginning",Space,Str "of",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "the",Space,Str "block",Space,Str "and",Space,Str "any",Space,Str "preceding",Space,Str "blank",Space,Str "lines."]
+,Para [Str "text",Space,Emph [Str "Leading",Space,Str "space"]]
+,Para [Emph [Str "Trailing",Space,Str "space"],Space,Str "text"]
+,Para [Str "text",Space,Emph [Str "Leading",Space,Str "spaces"]]
+,Para [Emph [Str "Trailing",Space,Str "spaces"],Space,Str "text"]
+,Header 1 ("tables",[],[]) [Str "Tables"]
+,Header 2 ("tables-with-headers",[],[]) [Str "Tables",Space,Str "with",Space,Str "Headers"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[Plain [Str "X"]]
+ ,[Plain [Str "Y"]]
+ ,[Plain [Str "Z"]]]
+ [[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]]]
+,HorizontalRule
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[Plain [Str "X"]]
+ ,[Plain [Str "Y"]]
+ ,[Plain [Str "Z"]]]
+ [[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]]]
+,HorizontalRule
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[Plain [Str "X"]]
+ ,[Plain [Str "Y"]]
+ ,[Plain [Str "Z"]]]
+ [[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]]]
+,HorizontalRule
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[Plain [Str "X"]]
+ ,[Plain [Str "Y"]]
+ ,[Plain [Str "Z"]]]
+ [[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]]]
+,HorizontalRule
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[Plain [Str "X"]]
+ ,[Plain [Str "Y"]]
+ ,[Plain [Str "Z"]]]
+ [[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]]]
+,HorizontalRule
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[Plain [Str "X"]]
+ ,[Plain [Str "Y"]]
+ ,[Plain [Str "Z"]]]
+ [[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]]]
+,HorizontalRule
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[Plain [Str "X"]]
+ ,[Plain [Str "Y"]]
+ ,[Plain [Str "Z"]]]
+ [[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]]]
+,HorizontalRule
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[Plain [Str "X"]]
+ ,[Plain [Str "Y"]]
+ ,[Plain [Str "Z"]]]
+ [[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]]]
+,HorizontalRule
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.3333333333333333,0.3333333333333333,0.3333333333333333]
+ [[Plain [Str "X"]]
+ ,[Plain [Str "Y"]]
+ ,[Plain [Str "Z"]]]
+ [[[Plain [Str "1"]]
+ ,[Para [Str "2"]]
+ ,[Plain [Str "3"]]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]]]
+,Header 2 ("tables-without-headers",[],[]) [Str "Tables",Space,Str "without",Space,Str "Headers"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ []
+ [[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]]]
+,HorizontalRule
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ []
+ [[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]]]
+,HorizontalRule
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ []
+ [[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]]]
+,HorizontalRule
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ []
+ [[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]]]
+,Header 2 ("empty-tables",[],[]) [Str "Empty",Space,Str "Tables"]
+,Para [Str "This",Space,Str "section",Space,Str "should",Space,Str "be",Space,Str "empty."]]
diff --git a/test/insert b/test/insert
new file mode 100644
index 000000000..f06069ede
--- /dev/null
+++ b/test/insert
@@ -0,0 +1 @@
+STUFF INSERTED
diff --git a/test/lalune.jpg b/test/lalune.jpg
new file mode 100644
index 000000000..5a50fc088
--- /dev/null
+++ b/test/lalune.jpg
Binary files differ
diff --git a/test/latex-reader.latex b/test/latex-reader.latex
new file mode 100644
index 000000000..2ebdfed99
--- /dev/null
+++ b/test/latex-reader.latex
@@ -0,0 +1,848 @@
+\documentclass{article}
+\usepackage[mathletters]{ucs}
+\usepackage[utf8x]{inputenc}
+\setlength{\parindent}{0pt}
+\setlength{\parskip}{6pt plus 2pt minus 1pt}
+
+\newcommand{\textsubscript}[1]{\ensuremath{_{\scriptsize\textrm{#1}}}}
+\usepackage[breaklinks=true,unicode=true]{hyperref}
+\usepackage[normalem]{ulem}
+% avoid problems with \sout in headers with hyperref:
+\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
+\usepackage{enumerate}
+\usepackage{fancyvrb}
+\usepackage{graphicx}
+\usepackage{url}
+
+\setcounter{secnumdepth}{0}
+\VerbatimFootnotes % allows verbatim text in footnotes
+\title{Pandoc Test Suite}
+\author{John MacFarlane \and Anonymous}
+\date{July 17, 2006}
+\begin{document}
+\maketitle
+
+This is a set of tests for pandoc. Most of them are adapted from
+John Gruber's markdown test suite.
+
+\begin{center}\rule{3in}{0.4pt}\end{center}
+
+\section{Headers}
+
+\subsection{Level 2 with an \href{/url}{embedded link}}
+
+\subsubsection{Level 3 with \emph{emphasis}}
+
+Level 4
+
+Level 5
+
+\section[alt title ignored]{Level 1}
+
+\subsection{Level 2 with \emph{emphasis}}
+
+\subsubsection{Level 3}
+
+with no blank line
+
+\subsection{Level 2}
+
+with no blank line
+
+\begin{center}\rule{3in}{0.4pt}\end{center}
+
+\section{Paragraphs}
+
+Here's a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a
+list item. Because a hard-wrapped line in the middle of a paragraph
+looked like a list item.
+
+Here's one with a bullet. * criminey.
+
+There should be a hard line break\\here.
+
+\begin{center}\rule{3in}{0.4pt}\end{center}
+
+\section{Block Quotes}
+
+E-mail style:
+
+\begin{quote}
+This is a block quote. It is pretty short.
+
+\end{quote}
+\begin {quote}
+Code in a block quote:
+
+\begin{verbatim}
+sub status {
+ print "working";
+}
+\end{verbatim}
+A list:
+
+\begin{enumerate}[1.]
+\item
+ item one
+\item
+ item two
+\end{enumerate}
+Nested block quotes:
+
+\begin{quote}
+nested
+
+\end{quote}
+\begin{quote}
+nested
+
+\end{quote}
+\end{quote}
+This should not be a block quote: 2 \textgreater{} 1.
+
+Box-style:
+
+\begin{quote}
+Example:
+
+\begin{verbatim}
+sub status {
+ print "working";
+}
+\end{verbatim}
+\end{quote}
+\begin{quote}
+\begin{enumerate}[1.]
+\item
+ do laundry
+\item
+ take out the trash
+\end{enumerate}
+\end{quote}
+Here's a nested one:
+
+\begin{quote}
+Joe said:
+
+\begin{quote}
+Don't quote me.
+
+\end{quote}
+\end{quote}
+And a following paragraph.
+
+\begin{center}\rule{3in}{0.4pt}\end{center}
+
+\section{Code Blocks}
+
+Code:
+
+\begin{verbatim}
+---- (should be four hyphens)
+
+sub status {
+ print "working";
+}
+
+this code block is indented by one tab
+\end{verbatim}
+And:
+
+\begin{verbatim}
+ this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \> \[ \{
+\end{verbatim}
+
+\begin{obeylines}
+this has \emph{two
+lines}
+\end{obeylines}
+\begin{center}\rule{3in}{0.4pt}\end{center}
+
+\section{Lists}
+
+\subsection{Unordered}
+
+Asterisks tight:
+
+\begin{itemize}
+\item
+ asterisk 1
+\item
+ asterisk 2
+\item
+ asterisk 3
+\end{itemize}
+Asterisks loose:
+
+\begin{itemize}
+\item
+ asterisk 1
+
+\item
+ asterisk 2
+
+\item
+ asterisk 3
+
+\end{itemize}
+Pluses tight:
+
+\begin{itemize}
+\item
+ Plus 1
+\item
+ Plus 2
+\item
+ Plus 3
+\end{itemize}
+Pluses loose:
+
+\begin{itemize}
+\item
+ Plus 1
+
+\item
+ Plus 2
+
+\item
+ Plus 3
+
+\end{itemize}
+Minuses tight:
+
+\begin{itemize}
+\item
+ Minus 1
+\item
+ Minus 2
+\item
+ Minus 3
+\end{itemize}
+Minuses loose:
+
+\begin{itemize}
+\item
+ Minus 1
+
+\item
+ Minus 2
+
+\item
+ Minus 3
+
+\end{itemize}
+\subsection{Ordered}
+
+Tight:
+
+\begin{enumerate}[1.]
+\item
+ First
+\item
+ Second
+\item
+ Third
+\end{enumerate}
+and:
+
+\begin{enumerate}[1.]
+\item
+ One
+\item
+ Two
+\item
+ Three
+\end{enumerate}
+Loose using tabs:
+
+\begin{enumerate}[1.]
+\item
+ First
+
+\item
+ Second
+
+\item
+ Third
+
+\end{enumerate}
+and using spaces:
+
+\begin{enumerate}[1.]
+\item
+ One
+
+\item
+ Two
+
+\item
+ Three
+
+\end{enumerate}
+Multiple paragraphs:
+
+\begin{enumerate}[1.]
+\item
+ Item 1, graf one.
+
+ Item 1. graf two. The quick brown fox jumped over the lazy dog's
+ back.
+
+\item
+ Item 2.
+
+\item
+ Item 3.
+
+\end{enumerate}
+\subsection{Nested}
+
+\begin{itemize}
+\item
+ Tab
+ \begin{itemize}
+ \item
+ Tab
+ \begin{itemize}
+ \item
+ Tab
+ \end{itemize}
+ \end{itemize}
+\end{itemize}
+Here's another:
+
+\begin{enumerate}[1.]
+\item
+ First
+\item
+ Second:
+ \begin{itemize}
+ \item
+ Fee
+ \item
+ Fie
+ \item
+ Foe
+ \end{itemize}
+\item
+ Third
+\end{enumerate}
+Same thing but with paragraphs:
+
+\begin{enumerate}[1.]
+\item
+ First
+
+\item
+ Second:
+
+ \begin{itemize}
+ \item
+ Fee
+ \item
+ Fie
+ \item
+ Foe
+ \end{itemize}
+\item
+ Third
+
+\end{enumerate}
+\subsection{Tabs and spaces}
+
+\begin{itemize}
+\item
+ this is a list item indented with tabs
+
+\item
+ this is a list item indented with spaces
+
+ \begin{itemize}
+ \item
+ this is an example list item indented with tabs
+
+ \item
+ this is an example list item indented with spaces
+
+ \end{itemize}
+\end{itemize}
+\subsection{Fancy list markers}
+
+\begin{enumerate}[(1)]
+\setcounter{enumi}{1}
+\item
+ begins with 2
+\item
+ and now 3
+
+ with a continuation
+
+ \begin{enumerate}[i.]
+ \setcounter{enumii}{3}
+ \item
+ sublist with roman numerals, starting with 4
+ \item
+ more items
+ \begin{enumerate}[(A)]
+ \item
+ a subsublist
+ \item
+ a subsublist
+ \end{enumerate}
+ \end{enumerate}
+\end{enumerate}
+Nesting:
+
+\begin{enumerate}[A.]
+\item
+ Upper Alpha
+ \begin{enumerate}[I.]
+ \item
+ Upper Roman.
+ \begin{enumerate}[(1)]
+ \setcounter{enumiii}{5}
+ \item
+ Decimal start with 6
+ \begin{enumerate}[a)]
+ \setcounter{enumiv}{2}
+ \item
+ Lower alpha with paren
+ \end{enumerate}
+ \end{enumerate}
+ \end{enumerate}
+\end{enumerate}
+Autonumbering:
+
+\begin{enumerate}
+\item
+ Autonumber.
+\item
+ More.
+ \begin{enumerate}
+ \item
+ Nested.
+ \end{enumerate}
+\end{enumerate}
+Should not be a list item:
+
+M.A. 2007
+
+B. Williams
+
+\begin{center}\rule{3in}{0.4pt}\end{center}
+
+\section{Definition Lists}
+
+Tight using spaces:
+
+\begin{description}
+\item[apple]
+red fruit
+\item[orange]
+orange fruit
+\item[banana]
+yellow fruit
+\end{description}
+Tight using tabs:
+
+\begin{description}
+\item[apple]
+red fruit
+\item[orange]
+orange fruit
+\item[banana]
+yellow fruit
+\end{description}
+Loose:
+
+\begin{description}
+\item[apple]
+red fruit
+
+\item[orange]
+orange fruit
+
+\item[banana]
+yellow fruit
+
+\end{description}
+Multiple blocks with italics:
+
+\begin{description}
+\item[\emph{apple}]
+red fruit
+
+contains seeds, crisp, pleasant to taste
+
+\item[\emph{orange}]
+orange fruit
+
+\begin{verbatim}
+{ orange code block }
+\end{verbatim}
+\begin{quote}
+orange block quote
+
+\end{quote}
+\end{description}
+\section{HTML Blocks}
+
+Simple block on one line:
+
+foo
+And nested without indentation:
+
+foo
+bar
+Interpreted markdown in a table:
+
+This is \emph{emphasized}
+And this is \textbf{strong}
+Here's a simple block:
+
+foo
+This should be a code block, though:
+
+\begin{verbatim}
+<div>
+ foo
+</div>
+\end{verbatim}
+As should this:
+
+\begin{verbatim}
+<div>foo</div>
+\end{verbatim}
+Now, nested:
+
+foo
+This should just be an HTML comment:
+
+Multiline:
+
+Code block:
+
+\begin{verbatim}
+<!-- Comment -->
+\end{verbatim}
+Just plain comment, with trailing spaces on the line:
+
+Code:
+
+\begin{verbatim}
+<hr />
+\end{verbatim}
+Hr's:
+
+\begin{center}\rule{3in}{0.4pt}\end{center}
+
+\section{Inline Markup}
+
+This is \emph{emphasized}, and so \emph{is this}.
+
+This is \textbf{strong}, and so \textbf{is this}.
+
+An \emph{\href{/url}{emphasized link}}.
+
+\textbf{\emph{This is strong and em.}}
+
+So is \textbf{\emph{this}} word.
+
+\textbf{\emph{This is strong and em.}}
+
+So is \textbf{\emph{this}} word.
+
+This is code: \verb!>!, \verb!$!, \verb!\!, \verb!\$!,
+\verb!<html>!.
+
+\sout{This is \emph{strikeout}.}
+
+Superscripts: a\textsuperscript{bc}d
+a\textsuperscript{\emph{hello}} a\textsuperscript{hello there}.
+
+Subscripts: H\textsubscript{2}O, H\textsubscript{23}O,
+H\textsubscript{many of them}O.
+
+These should not be superscripts or subscripts, because of the
+unescaped spaces: a\^{}b c\^{}d, a\ensuremath{\sim}b
+c\ensuremath{\sim}d.
+
+\begin{center}\rule{3in}{0.4pt}\end{center}
+
+\section{Smart quotes, ellipses, dashes}
+
+``Hello,'' said the spider. ``\,`Shelob' is my name.''
+
+`A', `B', and `C' are letters.
+
+`Oak,' `elm,' and `beech' are names of trees. So is `pine.'
+
+`He said, ``I want to go.''\,' Were you alive in the 70's?
+
+Here is some quoted `\verb!code!' and a
+``\href{http://example.com/?foo=1&bar=2}{quoted link}''.
+
+Some dashes: one---two---three---four---five.
+
+Dashes between numbers: 5--7, 255--66, 1987--1999.
+
+Ellipses\ldots{}and\ldots{}and\ldots{}.
+
+\begin{center}\rule{3in}{0.4pt}\end{center}
+
+\section{LaTeX}
+
+\begin{itemize}
+\item
+ \cite[22-23]{smith.1899}
+\item
+ \doublespacing
+\item
+ $2+2=4$
+\item
+ $x \in y$
+\item
+ $\alpha \wedge \omega$
+\item
+ $223$
+\item
+ $p$-Tree
+\item
+ $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$
+\item
+ Here's one that has a line break in it:
+ $\alpha + \omega \times x^2$.
+\end{itemize}
+These shouldn't be math:
+
+\begin{itemize}
+\item
+ To get the famous equation, write \verb!$e = mc^2$!.
+\item
+ \$22,000 is a \emph{lot} of money. So is \$34,000. (It worked if
+ ``lot'' is emphasized.)
+\item
+ Escaped \verb!$!: \$73 \emph{this should be emphasized} 23\$.
+\end{itemize}
+Here's a LaTeX table:
+
+\begin{tabular}{|l|l|}\hline
+Animal & Number \\ \hline
+Dog & 2 \\
+Cat & 1 \\ \hline
+\end{tabular}
+
+A table with one column:
+
+\begin{tabular}{c}
+Animal \\
+Vegetable
+\end{tabular}
+
+\begin{center}\rule{3in}{0.4pt}\end{center}
+
+\section{Special Characters}
+
+Here is some unicode:
+
+\begin{itemize}
+\item
+ I hat: Î
+\item
+ o umlaut: ö
+\item
+ section: §
+\item
+ set membership: ∈
+\item
+ copyright: ©
+\end{itemize}
+AT\&T has an ampersand in their name.
+
+AT\&T is another way to write it.
+
+This \& that.
+
+4 \textless{} 5.
+
+6 \textgreater{} 5.
+
+Backslash: \textbackslash{}
+
+Backtick: `
+
+Asterisk: *
+
+Underscore: \_
+
+Left brace: \{
+
+Right brace: \}
+
+Left bracket: [
+
+Right bracket: ]
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: \textgreater{}
+
+Hash: \#
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+\begin{center}\rule{3in}{0.4pt}\end{center}
+
+\section{Links}
+
+\subsection{Explicit}
+
+Just a \href{/url/}{URL}.
+
+\href{/url/}{URL and title}.
+
+\href{/url/}{URL and title}.
+
+\href{/url/}{URL and title}.
+
+\href{/url/}{URL and title}
+
+\href{/url/}{URL and title}
+
+\href{/url/with_underscore}{with\_underscore}
+
+\href{mailto:nobody@nowhere.net}{Email link}
+
+\href{}{Empty}.
+
+\subsection{Reference}
+
+Foo \href{/url/}{bar}.
+
+Foo \href{/url/}{bar}.
+
+Foo \href{/url/}{bar}.
+
+With \href{/url/}{embedded [brackets]}.
+
+\href{/url/}{b} by itself should be a link.
+
+Indented \href{/url}{once}.
+
+Indented \href{/url}{twice}.
+
+Indented \href{/url}{thrice}.
+
+This should [not][] be a link.
+
+\begin{verbatim}
+[not]: /url
+\end{verbatim}
+Foo \href{/url/}{bar}.
+
+Foo \href{/url/}{biz}.
+
+\subsection{With ampersands}
+
+Here's a
+\href{http://example.com/?foo=1&bar=2}{link with an ampersand in the URL}.
+
+Here's a link with an amersand in the link text:
+\href{http://att.com/}{AT\&T}.
+
+Here's an \href{/script?foo=1&bar=2}{inline link}.
+
+Here's an
+\href{/script?foo=1&bar=2}{inline link in pointy braces}.
+
+\subsection{Autolinks}
+
+With an ampersand: \url{http://example.com/?foo=1&bar=2}
+
+\begin{itemize}
+\item
+ In a list?
+\item
+ \url{http://example.com/}
+\item
+ It should.
+\end{itemize}
+An e-mail address:
+\href{mailto:nobody@nowhere.net}{nobody@nowhere.net}
+
+\begin{quote}
+Blockquoted: \url{http://example.com/}
+
+\end{quote}
+Auto-links should not occur here: \verb!<http://example.com/>!
+
+\begin{verbatim}
+or here: <http://example.com/>
+\end{verbatim}
+\begin{center}\rule{3in}{0.4pt}\end{center}
+
+\section{Images}
+
+From ``Voyage dans la Lune'' by Georges Melies (1902):
+
+\includegraphics{lalune.jpg}
+
+Here is a movie \includegraphics{movie.jpg} icon.
+
+\begin{center}\rule{3in}{0.4pt}\end{center}
+
+\section{Footnotes}
+
+Here is a footnote
+reference,\footnote{ Here is the footnote. It can go anywhere after the footnote
+reference. It need not be placed at the end of the document.
+}
+and
+another.\footnote{ Here's the long note. This one contains multiple blocks.
+
+Subsequent blocks are indented to show that they belong to the
+footnote (as with list items).
+
+\begin{Verbatim}
+ { <code> }
+\end{Verbatim}
+If you want, you can indent every line, but you can also be lazy
+and just indent the first line of each block.
+}
+This should \emph{not} be a footnote reference, because it contains
+a space.[\^{}my note] Here is an inline
+note.\footnote{ This is \emph{easier} to type. Inline notes may contain
+\href{http://google.com}{links} and \verb!]! verbatim characters,
+as well as [bracketed text].
+}
+
+\begin{quote}
+Notes can go in quotes.\footnote{ In quote.
+}
+
+\end{quote}
+\begin{enumerate}[1.]
+\item
+ And in list items.\footnote{ In list.
+}
+\end{enumerate}
+This paragraph should not be part of the note, as it is not
+indented.
+
+\section{Escaped characters}
+
+\$ \% \& \# \_ \{ \}
+
+\end{document}
diff --git a/test/latex-reader.native b/test/latex-reader.native
new file mode 100644
index 000000000..d1ff4c0a4
--- /dev/null
+++ b/test/latex-reader.native
@@ -0,0 +1,375 @@
+Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])]})
+[RawBlock (Format "latex") "\\maketitle"
+,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",SoftBreak,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
+,HorizontalRule
+,Header 1 ("headers",[],[]) [Str "Headers"]
+,Header 2 ("level-2-with-an-embedded-link",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link ("",[],[]) [Str "embedded",Space,Str "link"] ("/url","")]
+,Header 3 ("level-3-with-emphasis",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Para [Str "Level",Space,Str "4"]
+,Para [Str "Level",Space,Str "5"]
+,Header 1 ("level-1",[],[]) [Str "Level",Space,Str "1"]
+,Header 2 ("level-2-with-emphasis",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 3 ("level-3",[],[]) [Str "Level",Space,Str "3"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,Header 2 ("level-2",[],[]) [Str "Level",Space,Str "2"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,HorizontalRule
+,Header 1 ("paragraphs",[],[]) [Str "Paragraphs"]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
+,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",SoftBreak,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",SoftBreak,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]
+,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]
+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here."]
+,HorizontalRule
+,Header 1 ("block-quotes",[],[]) [Str "Block",Space,Str "Quotes"]
+,Para [Str "E-mail",Space,Str "style:"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]]
+,BlockQuote
+ [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
+ ,Para [Str "A",Space,Str "list:"]
+ ,OrderedList (1,Decimal,Period)
+ [[Para [Str "item",Space,Str "one"]]
+ ,[Para [Str "item",Space,Str "two"]]]
+ ,Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
+ ,BlockQuote
+ [Para [Str "nested"]]
+ ,BlockQuote
+ [Para [Str "nested"]]]
+,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",Space,Str ">",Space,Str "1."]
+,Para [Str "Box-style:"]
+,BlockQuote
+ [Para [Str "Example:"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"]
+,BlockQuote
+ [OrderedList (1,Decimal,Period)
+ [[Para [Str "do",Space,Str "laundry"]]
+ ,[Para [Str "take",Space,Str "out",Space,Str "the",Space,Str "trash"]]]]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "nested",Space,Str "one:"]
+,BlockQuote
+ [Para [Str "Joe",Space,Str "said:"]
+ ,BlockQuote
+ [Para [Str "Don\8217t",Space,Str "quote",Space,Str "me."]]]
+,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."]
+,HorizontalRule
+,Header 1 ("code-blocks",[],[]) [Str "Code",Space,Str "Blocks"]
+,Para [Str "Code:"]
+,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"
+,Para [Str "And:"]
+,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
+,Para [Str "this",Space,Str "has",Space,Emph [Str "two",LineBreak,Str "lines"]]
+,HorizontalRule
+,Header 1 ("lists",[],[]) [Str "Lists"]
+,Header 2 ("unordered",[],[]) [Str "Unordered"]
+,Para [Str "Asterisks",Space,Str "tight:"]
+,BulletList
+ [[Para [Str "asterisk",Space,Str "1"]]
+ ,[Para [Str "asterisk",Space,Str "2"]]
+ ,[Para [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Asterisks",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "asterisk",Space,Str "1"]]
+ ,[Para [Str "asterisk",Space,Str "2"]]
+ ,[Para [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "tight:"]
+,BulletList
+ [[Para [Str "Plus",Space,Str "1"]]
+ ,[Para [Str "Plus",Space,Str "2"]]
+ ,[Para [Str "Plus",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "Plus",Space,Str "1"]]
+ ,[Para [Str "Plus",Space,Str "2"]]
+ ,[Para [Str "Plus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "tight:"]
+,BulletList
+ [[Para [Str "Minus",Space,Str "1"]]
+ ,[Para [Str "Minus",Space,Str "2"]]
+ ,[Para [Str "Minus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "Minus",Space,Str "1"]]
+ ,[Para [Str "Minus",Space,Str "2"]]
+ ,[Para [Str "Minus",Space,Str "3"]]]
+,Header 2 ("ordered",[],[]) [Str "Ordered"]
+,Para [Str "Tight:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second"]]
+ ,[Para [Str "Third"]]]
+,Para [Str "and:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "One"]]
+ ,[Para [Str "Two"]]
+ ,[Para [Str "Three"]]]
+,Para [Str "Loose",Space,Str "using",Space,Str "tabs:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second"]]
+ ,[Para [Str "Third"]]]
+,Para [Str "and",Space,Str "using",Space,Str "spaces:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "One"]]
+ ,[Para [Str "Two"]]
+ ,[Para [Str "Three"]]]
+,Para [Str "Multiple",Space,Str "paragraphs:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]
+ ,Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",SoftBreak,Str "back."]]
+ ,[Para [Str "Item",Space,Str "2."]]
+ ,[Para [Str "Item",Space,Str "3."]]]
+,Header 2 ("nested",[],[]) [Str "Nested"]
+,BulletList
+ [[Para [Str "Tab"]
+ ,BulletList
+ [[Para [Str "Tab"]
+ ,BulletList
+ [[Para [Str "Tab"]]]]]]]
+,Para [Str "Here\8217s",Space,Str "another:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second:"]
+ ,BulletList
+ [[Para [Str "Fee"]]
+ ,[Para [Str "Fie"]]
+ ,[Para [Str "Foe"]]]]
+ ,[Para [Str "Third"]]]
+,Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second:"]
+ ,BulletList
+ [[Para [Str "Fee"]]
+ ,[Para [Str "Fie"]]
+ ,[Para [Str "Foe"]]]]
+ ,[Para [Str "Third"]]]
+,Header 2 ("tabs-and-spaces",[],[]) [Str "Tabs",Space,Str "and",Space,Str "spaces"]
+,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]
+ ,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",Space,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]
+,Header 2 ("fancy-list-markers",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"]
+,OrderedList (2,Decimal,TwoParens)
+ [[Para [Str "begins",Space,Str "with",Space,Str "2"]]
+ ,[Para [Str "and",Space,Str "now",Space,Str "3"]
+ ,Para [Str "with",Space,Str "a",Space,Str "continuation"]
+ ,OrderedList (4,LowerRoman,Period)
+ [[Para [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"]]
+ ,[Para [Str "more",Space,Str "items"]
+ ,OrderedList (1,UpperAlpha,TwoParens)
+ [[Para [Str "a",Space,Str "subsublist"]]
+ ,[Para [Str "a",Space,Str "subsublist"]]]]]]]
+,Para [Str "Nesting:"]
+,OrderedList (1,UpperAlpha,Period)
+ [[Para [Str "Upper",Space,Str "Alpha"]
+ ,OrderedList (1,UpperRoman,Period)
+ [[Para [Str "Upper",Space,Str "Roman."]
+ ,OrderedList (6,Decimal,TwoParens)
+ [[Para [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
+ ,OrderedList (3,LowerAlpha,OneParen)
+ [[Para [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]
+,Para [Str "Autonumbering:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Para [Str "Autonumber."]]
+ ,[Para [Str "More."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Para [Str "Nested."]]]]]
+,Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]
+,Para [Str "M.A.",Space,Str "2007"]
+,Para [Str "B.",Space,Str "Williams"]
+,HorizontalRule
+,Header 1 ("definition-lists",[],[]) [Str "Definition",Space,Str "Lists"]
+,Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Para [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Tight",Space,Str "using",Space,Str "tabs:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Para [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Loose:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Para [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics:"]
+,DefinitionList
+ [([Emph [Str "apple"]],
+ [[Para [Str "red",Space,Str "fruit"]
+ ,Para [Str "contains",Space,Str "seeds,",Space,Str "crisp,",Space,Str "pleasant",Space,Str "to",Space,Str "taste"]]])
+ ,([Emph [Str "orange"]],
+ [[Para [Str "orange",Space,Str "fruit"]
+ ,CodeBlock ("",[],[]) "{ orange code block }"
+ ,BlockQuote
+ [Para [Str "orange",Space,Str "block",Space,Str "quote"]]]])]
+,Header 1 ("html-blocks",[],[]) [Str "HTML",Space,Str "Blocks"]
+,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]
+,Para [Str "foo",SoftBreak,Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"]
+,Para [Str "foo",SoftBreak,Str "bar",SoftBreak,Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],SoftBreak,Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"],SoftBreak,Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block:"]
+,Para [Str "foo",SoftBreak,Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"]
+,CodeBlock ("",[],[]) "<div>\n foo\n</div>"
+,Para [Str "As",Space,Str "should",Space,Str "this:"]
+,CodeBlock ("",[],[]) "<div>foo</div>"
+,Para [Str "Now,",Space,Str "nested:"]
+,Para [Str "foo",SoftBreak,Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"]
+,Para [Str "Multiline:"]
+,Para [Str "Code",Space,Str "block:"]
+,CodeBlock ("",[],[]) "<!-- Comment -->"
+,Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"]
+,Para [Str "Code:"]
+,CodeBlock ("",[],[]) "<hr />"
+,Para [Str "Hr\8217s:"]
+,HorizontalRule
+,Header 1 ("inline-markup",[],[]) [Str "Inline",Space,Str "Markup"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
+,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
+,Para [Str "An",Space,Emph [Link ("",[],[]) [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
+,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",SoftBreak,Code ("",[],[]) "<html>",Str "."]
+,Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],Str "."]]
+,Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",SoftBreak,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello",Space,Str "there"],Str "."]
+,Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "H",Subscript [Str "23"],Str "O,",SoftBreak,Str "H",Subscript [Str "many",Space,Str "of",Space,Str "them"],Str "O."]
+,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",Space,Str "because",Space,Str "of",Space,Str "the",SoftBreak,Str "unescaped",Space,Str "spaces:",Space,Str "a^b",Space,Str "c^d,",Space,Str "a",Math InlineMath "\\sim",Str "b",SoftBreak,Str "c",Math InlineMath "\\sim",Str "d."]
+,HorizontalRule
+,Header 1 ("smart-quotes-ellipses-dashes",[],[]) [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
+,Para [Quoted DoubleQuote [Str "Hello,"],Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name."]]
+,Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters."]
+,Para [Quoted SingleQuote [Str "Oak,"],Space,Quoted SingleQuote [Str "elm,"],Space,Str "and",Space,Quoted SingleQuote [Str "beech"],Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees.",Space,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine."]]
+,Para [Quoted SingleQuote [Str "He",Space,Str "said,",Space,Quoted DoubleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70\8217s?"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Quoted SingleQuote [Code ("",[],[]) "code"],Space,Str "and",Space,Str "a",SoftBreak,Quoted DoubleQuote [Link ("",[],[]) [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2","")],Str "."]
+,Para [Str "Some",Space,Str "dashes:",Space,Str "one\8212two\8212three\8212four\8212five."]
+,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5\8211\&7,",Space,Str "255\8211\&66,",Space,Str "1987\8211\&1999."]
+,Para [Str "Ellipses\8230and\8230and\8230."]
+,HorizontalRule
+,Header 1 ("latex",[],[]) [Str "LaTeX"]
+,BulletList
+ [[Para [Cite [Citation {citationId = "smith.1899", citationPrefix = [], citationSuffix = [Str "22-23"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [RawInline (Format "latex") "\\cite[22-23]{smith.1899}"]]]
+ ,[Para [RawInline (Format "latex") "\\doublespacing"]]
+ ,[Para [Math InlineMath "2+2=4"]]
+ ,[Para [Math InlineMath "x \\in y"]]
+ ,[Para [Math InlineMath "\\alpha \\wedge \\omega"]]
+ ,[Para [Math InlineMath "223"]]
+ ,[Para [Math InlineMath "p",Str "-Tree"]]
+ ,[Para [Math InlineMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]
+ ,[Para [Str "Here\8217s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it:",SoftBreak,Math InlineMath "\\alpha + \\omega \\times x^2",Str "."]]]
+,Para [Str "These",Space,Str "shouldn\8217t",Space,Str "be",Space,Str "math:"]
+,BulletList
+ [[Para [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation,",Space,Str "write",Space,Code ("",[],[]) "$e = mc^2$",Str "."]]
+ ,[Para [Str "$22,000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money.",Space,Str "So",Space,Str "is",Space,Str "$34,000.",Space,Str "(It",Space,Str "worked",Space,Str "if",SoftBreak,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized.)"]]
+ ,[Para [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23$."]]]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"]
+,Table [] [AlignLeft,AlignLeft] [0.0,0.0]
+ [[Plain [Str "Animal"]]
+ ,[Plain [Str "Number"]]]
+ [[[Plain [Str "Dog"]]
+ ,[Plain [Str "2"]]]
+ ,[[Plain [Str "Cat"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "A",Space,Str "table",Space,Str "with",Space,Str "one",Space,Str "column:"]
+,Table [] [AlignCenter] [0.0]
+ [[]]
+ [[[Plain [Str "Animal"]]]
+ ,[[Plain [Str "Vegetable"]]]]
+,HorizontalRule
+,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
+,BulletList
+ [[Para [Str "I",Space,Str "hat:",Space,Str "\206"]]
+ ,[Para [Str "o",Space,Str "umlaut:",Space,Str "\246"]]
+ ,[Para [Str "section:",Space,Str "\167"]]
+ ,[Para [Str "set",Space,Str "membership:",Space,Str "\8712"]]
+ ,[Para [Str "copyright:",Space,Str "\169"]]]
+,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]
+,Para [Str "AT&T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it."]
+,Para [Str "This",Space,Str "&",Space,Str "that."]
+,Para [Str "4",Space,Str "<",Space,Str "5."]
+,Para [Str "6",Space,Str ">",Space,Str "5."]
+,Para [Str "Backslash:",Space,Str "\\"]
+,Para [Str "Backtick:",Space,Str "\8216"]
+,Para [Str "Asterisk:",Space,Str "*"]
+,Para [Str "Underscore:",Space,Str "_"]
+,Para [Str "Left",Space,Str "brace:",Space,Str "{"]
+,Para [Str "Right",Space,Str "brace:",Space,Str "}"]
+,Para [Str "Left",Space,Str "bracket:",Space,Str "["]
+,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]
+,Para [Str "Left",Space,Str "paren:",Space,Str "("]
+,Para [Str "Right",Space,Str "paren:",Space,Str ")"]
+,Para [Str "Greater-than:",Space,Str ">"]
+,Para [Str "Hash:",Space,Str "#"]
+,Para [Str "Period:",Space,Str "."]
+,Para [Str "Bang:",Space,Str "!"]
+,Para [Str "Plus:",Space,Str "+"]
+,Para [Str "Minus:",Space,Str "-"]
+,HorizontalRule
+,Header 1 ("links",[],[]) [Str "Links"]
+,Header 2 ("explicit",[],[]) [Str "Explicit"]
+,Para [Str "Just",Space,Str "a",Space,Link ("",[],[]) [Str "URL"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","")]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","")]
+,Para [Link ("",[],[]) [Str "with_underscore"] ("/url/with_underscore","")]
+,Para [Link ("",[],[]) [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]
+,Para [Link ("",[],[]) [Str "Empty"] ("",""),Str "."]
+,Header 2 ("reference",[],[]) [Str "Reference"]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "With",Space,Link ("",[],[]) [Str "embedded",Space,Str "[brackets]"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "once"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "twice"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "thrice"] ("/url",""),Str "."]
+,Para [Str "This",Space,Str "should",Space,Str "[not][]",Space,Str "be",Space,Str "a",Space,Str "link."]
+,CodeBlock ("",[],[]) "[not]: /url"
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "biz"] ("/url/",""),Str "."]
+,Header 2 ("with-ampersands",[],[]) [Str "With",Space,Str "ampersands"]
+,Para [Str "Here\8217s",Space,Str "a",SoftBreak,Link ("",[],[]) [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",SoftBreak,Link ("",[],[]) [Str "AT&T"] ("http://att.com/",""),Str "."]
+,Para [Str "Here\8217s",Space,Str "an",Space,Link ("",[],[]) [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."]
+,Para [Str "Here\8217s",Space,Str "an",SoftBreak,Link ("",[],[]) [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]
+,Header 2 ("autolinks",[],[]) [Str "Autolinks"]
+,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link ("",[],[]) [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]
+,BulletList
+ [[Para [Str "In",Space,Str "a",Space,Str "list?"]]
+ ,[Para [Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]
+ ,[Para [Str "It",Space,Str "should."]]]
+,Para [Str "An",Space,Str "e-mail",Space,Str "address:",SoftBreak,Link ("",[],[]) [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]
+,BlockQuote
+ [Para [Str "Blockquoted:",Space,Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]
+,Para [Str "Auto-links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"]
+,CodeBlock ("",[],[]) "or here: <http://example.com/>"
+,HorizontalRule
+,Header 1 ("images",[],[]) [Str "Images"]
+,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
+,Para [Image ("",[],[]) [Str "image"] ("lalune.jpg","")]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image ("",[],[]) [Str "image"] ("movie.jpg",""),Space,Str "icon."]
+,HorizontalRule
+,Header 1 ("footnotes",[],[]) [Str "Footnotes"]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",SoftBreak,Str "reference,",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote.",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",SoftBreak,Str "reference.",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."]],SoftBreak,Str "and",SoftBreak,Str "another.",Note [Para [Str "Here\8217s",Space,Str "the",Space,Str "long",Space,Str "note.",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",SoftBreak,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "list",Space,Str "items)."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",SoftBreak,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block."]],SoftBreak,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",SoftBreak,Str "a",Space,Str "space.[^my",Space,Str "note]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",SoftBreak,Str "note.",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type.",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",SoftBreak,Link ("",[],[]) [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",Space,Str "verbatim",Space,Str "characters,",SoftBreak,Str "as",Space,Str "well",Space,Str "as",Space,Str "[bracketed",Space,Str "text]."]]]
+,BlockQuote
+ [Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes.",Note [Para [Str "In",Space,Str "quote."]]]]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "And",Space,Str "in",Space,Str "list",Space,Str "items.",Note [Para [Str "In",Space,Str "list."]]]]]
+,Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",SoftBreak,Str "indented."]
+,Header 1 ("escaped-characters",[],[]) [Str "Escaped",Space,Str "characters"]
+,Para [Str "$",Space,Str "%",Space,Str "&",Space,Str "#",Space,Str "_",Space,Str "{",Space,Str "}"]]
diff --git a/test/lhs-test-markdown.native b/test/lhs-test-markdown.native
new file mode 100644
index 000000000..b6d908339
--- /dev/null
+++ b/test/lhs-test-markdown.native
@@ -0,0 +1,8 @@
+[Header 1 ("lhs-test",[],[]) [Str "lhs",Space,Str "test"]
+,Para [Code ("",[],[]) "unsplit",Space,Str "is",Space,Str "an",Space,Str "arrow",Space,Str "that",Space,Str "takes",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "and",Space,Str "combines",Space,Str "them",Space,Str "to",SoftBreak,Str "return",Space,Str "a",Space,Str "single",Space,Str "value:"]
+,CodeBlock ("",["sourceCode","literate","haskell"],[]) "unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d\nunsplit = arr . uncurry\n -- arr (\\op (x,y) -> x `op` y)"
+,Para [Code ("",[],[]) "(***)",Space,Str "combines",Space,Str "two",Space,Str "arrows",Space,Str "into",Space,Str "a",Space,Str "new",Space,Str "arrow",Space,Str "by",Space,Str "running",Space,Str "the",Space,Str "two",Space,Str "arrows",Space,Str "on",Space,Str "a",SoftBreak,Str "pair",Space,Str "of",Space,Str "values",Space,Str "(one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "first",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair",Space,Str "and",Space,Str "one",Space,Str "arrow",Space,Str "on",Space,Str "the",SoftBreak,Str "second",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair)."]
+,CodeBlock ("",[],[]) "f *** g = first f >>> second g"
+,Para [Str "Block",Space,Str "quote:"]
+,BlockQuote
+ [Para [Str "foo",Space,Str "bar"]]]
diff --git a/test/lhs-test.fragment.html+lhs b/test/lhs-test.fragment.html+lhs
new file mode 100644
index 000000000..76ba4ef1a
--- /dev/null
+++ b/test/lhs-test.fragment.html+lhs
@@ -0,0 +1,15 @@
+<h1 id="lhs-test">lhs test</h1>
+
+<p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p>
+
+<pre class="sourceCode haskell"><code>&gt; <span class="ot">unsplit </span><span class="ot">::</span> (<span class="dt">Arrow</span> a) <span class="ot">=&gt;</span> (b <span class="ot">-&gt;</span> c <span class="ot">-&gt;</span> d) <span class="ot">-&gt;</span> a (b, c) d<br/>&gt; unsplit <span class="fu">=</span> arr <span class="fu">.</span> <span class="fu">uncurry</span> <br/>&gt; <span class="co">-- arr (\op (x,y) -&gt; x `op` y) </span></code></pre>
+
+<p><code>(***)</code> combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).</p>
+
+<pre><code>f *** g = first f &gt;&gt;&gt; second g</code></pre>
+
+<p>Block quote:</p>
+
+<blockquote>
+<p>foo bar</p>
+</blockquote>
diff --git a/test/lhs-test.html b/test/lhs-test.html
new file mode 100644
index 000000000..2c3b6b0f8
--- /dev/null
+++ b/test/lhs-test.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="generator" content="pandoc">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
+ <title></title>
+ <style type="text/css">code{white-space: pre;}</style>
+ <style type="text/css">
+div.sourceCode { overflow-x: auto; }
+table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
+ margin: 0; padding: 0; vertical-align: baseline; border: none; }
+table.sourceCode { width: 100%; line-height: 100%; }
+td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
+td.sourceCode { padding-left: 5px; }
+code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
+code > span.dt { color: #902000; } /* DataType */
+code > span.dv { color: #40a070; } /* DecVal */
+code > span.bn { color: #40a070; } /* BaseN */
+code > span.fl { color: #40a070; } /* Float */
+code > span.ch { color: #4070a0; } /* Char */
+code > span.st { color: #4070a0; } /* String */
+code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
+code > span.ot { color: #007020; } /* Other */
+code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
+code > span.fu { color: #06287e; } /* Function */
+code > span.er { color: #ff0000; font-weight: bold; } /* Error */
+code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
+code > span.cn { color: #880000; } /* Constant */
+code > span.sc { color: #4070a0; } /* SpecialChar */
+code > span.vs { color: #4070a0; } /* VerbatimString */
+code > span.ss { color: #bb6688; } /* SpecialString */
+code > span.im { } /* Import */
+code > span.va { color: #19177c; } /* Variable */
+code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
+code > span.op { color: #666666; } /* Operator */
+code > span.bu { } /* BuiltIn */
+code > span.ex { } /* Extension */
+code > span.pp { color: #bc7a00; } /* Preprocessor */
+code > span.at { color: #7d9029; } /* Attribute */
+code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
+code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
+code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
+code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
+ </style>
+ <!--[if lt IE 9]>
+ <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
+ <![endif]-->
+</head>
+<body>
+<h1 id="lhs-test">lhs test</h1>
+<p><code>unsplit</code> is an arrow that takes a pair of values and combines them to
+return a single value:</p>
+<div class="sourceCode"><pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="ot">unsplit ::</span> (<span class="dt">Arrow</span> a) <span class="ot">=&gt;</span> (b <span class="ot">-&gt;</span> c <span class="ot">-&gt;</span> d) <span class="ot">-&gt;</span> a (b, c) d
+unsplit <span class="fu">=</span> arr <span class="fu">.</span> uncurry
+ <span class="co">-- arr (\op (x,y) -&gt; x `op` y)</span></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>
+<pre><code>f *** g = first f &gt;&gt;&gt; second g</code></pre>
+<p>Block quote:</p>
+<blockquote>
+<p>foo bar</p>
+</blockquote>
+</body>
+</html>
diff --git a/test/lhs-test.html+lhs b/test/lhs-test.html+lhs
new file mode 100644
index 000000000..443b0642f
--- /dev/null
+++ b/test/lhs-test.html+lhs
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="generator" content="pandoc">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
+ <title></title>
+ <style type="text/css">code{white-space: pre;}</style>
+ <style type="text/css">
+div.sourceCode { overflow-x: auto; }
+table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
+ margin: 0; padding: 0; vertical-align: baseline; border: none; }
+table.sourceCode { width: 100%; line-height: 100%; }
+td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
+td.sourceCode { padding-left: 5px; }
+code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
+code > span.dt { color: #902000; } /* DataType */
+code > span.dv { color: #40a070; } /* DecVal */
+code > span.bn { color: #40a070; } /* BaseN */
+code > span.fl { color: #40a070; } /* Float */
+code > span.ch { color: #4070a0; } /* Char */
+code > span.st { color: #4070a0; } /* String */
+code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
+code > span.ot { color: #007020; } /* Other */
+code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
+code > span.fu { color: #06287e; } /* Function */
+code > span.er { color: #ff0000; font-weight: bold; } /* Error */
+code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
+code > span.cn { color: #880000; } /* Constant */
+code > span.sc { color: #4070a0; } /* SpecialChar */
+code > span.vs { color: #4070a0; } /* VerbatimString */
+code > span.ss { color: #bb6688; } /* SpecialString */
+code > span.im { } /* Import */
+code > span.va { color: #19177c; } /* Variable */
+code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
+code > span.op { color: #666666; } /* Operator */
+code > span.bu { } /* BuiltIn */
+code > span.ex { } /* Extension */
+code > span.pp { color: #bc7a00; } /* Preprocessor */
+code > span.at { color: #7d9029; } /* Attribute */
+code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
+code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
+code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
+code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
+ </style>
+ <!--[if lt IE 9]>
+ <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
+ <![endif]-->
+</head>
+<body>
+<h1 id="lhs-test">lhs test</h1>
+<p><code>unsplit</code> is an arrow that takes a pair of values and combines them to
+return a single value:</p>
+<div class="sourceCode"><pre class="sourceCode literate literatehaskell"><code class="sourceCode literatehaskell"><span class="ot">&gt; unsplit ::</span> (<span class="dt">Arrow</span> a) <span class="ot">=&gt;</span> (b <span class="ot">-&gt;</span> c <span class="ot">-&gt;</span> d) <span class="ot">-&gt;</span> a (b, c) d
+<span class="ot">&gt;</span> unsplit <span class="fu">=</span> arr <span class="fu">.</span> uncurry
+<span class="ot">&gt;</span> <span class="co">-- arr (\op (x,y) -&gt; x `op` y)</span></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>
+<pre><code>f *** g = first f &gt;&gt;&gt; second g</code></pre>
+<p>Block quote:</p>
+<blockquote>
+<p>foo bar</p>
+</blockquote>
+</body>
+</html>
diff --git a/test/lhs-test.latex b/test/lhs-test.latex
new file mode 100644
index 000000000..bc02b6ae5
--- /dev/null
+++ b/test/lhs-test.latex
@@ -0,0 +1,121 @@
+\documentclass[]{article}
+\usepackage{lmodern}
+\usepackage{amssymb,amsmath}
+\usepackage{ifxetex,ifluatex}
+\usepackage{fixltx2e} % provides \textsubscript
+\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
+ \usepackage[T1]{fontenc}
+ \usepackage[utf8]{inputenc}
+\else % if luatex or xelatex
+ \usepackage{unicode-math}
+ \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
+\fi
+% use upquote if available, for straight quotes in verbatim environments
+\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
+% use microtype if available
+\IfFileExists{microtype.sty}{%
+\usepackage[]{microtype}
+\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
+}{}
+\PassOptionsToPackage{hyphens}{url} % url is loaded by hyperref
+\usepackage[unicode=true]{hyperref}
+\hypersetup{
+ pdfborder={0 0 0},
+ breaklinks=true}
+\urlstyle{same} % don't use monospace font for urls
+\usepackage{color}
+\usepackage{fancyvrb}
+\newcommand{\VerbBar}{|}
+\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
+\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
+% Add ',fontsize=\small' for more characters per line
+\newenvironment{Shaded}{}{}
+\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{#1}}}
+\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{#1}}
+\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{#1}}
+\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{#1}}
+\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{#1}}
+\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{#1}}
+\newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
+\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
+\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
+\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
+\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{#1}}
+\newcommand{\ImportTok}[1]{#1}
+\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{#1}}}
+\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{#1}}}
+\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
+\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
+\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{#1}}
+\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{#1}}
+\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
+\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{#1}}}
+\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
+\newcommand{\BuiltInTok}[1]{#1}
+\newcommand{\ExtensionTok}[1]{#1}
+\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{#1}}
+\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{#1}}
+\newcommand{\RegionMarkerTok}[1]{#1}
+\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
+\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
+\newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{#1}}}
+\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{#1}}}
+\newcommand{\NormalTok}[1]{#1}
+\IfFileExists{parskip.sty}{%
+\usepackage{parskip}
+}{% else
+\setlength{\parindent}{0pt}
+\setlength{\parskip}{6pt plus 2pt minus 1pt}
+}
+\setlength{\emergencystretch}{3em} % prevent overfull lines
+\providecommand{\tightlist}{%
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
+\setcounter{secnumdepth}{0}
+% Redefines (sub)paragraphs to behave more like sections
+\ifx\paragraph\undefined\else
+\let\oldparagraph\paragraph
+\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
+\fi
+\ifx\subparagraph\undefined\else
+\let\oldsubparagraph\subparagraph
+\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
+\fi
+
+% set default figure placement to htbp
+\makeatletter
+\def\fps@figure{htbp}
+\makeatother
+
+
+\date{}
+
+\begin{document}
+
+\section{lhs test}\label{lhs-test}
+
+\texttt{unsplit} is an arrow that takes a pair of values and combines them to
+return a single value:
+
+\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}
+ \CommentTok{-- arr (\textbackslash{}op (x,y) -> x `op` y)}
+\end{Highlighting}
+\end{Shaded}
+
+\texttt{(***)} combines two arrows into a new arrow by running the two arrows on a
+pair of values (one arrow on the first item of the pair and one arrow on the
+second item of the pair).
+
+\begin{verbatim}
+f *** g = first f >>> second g
+\end{verbatim}
+
+Block quote:
+
+\begin{quote}
+foo bar
+\end{quote}
+
+\end{document}
diff --git a/test/lhs-test.latex+lhs b/test/lhs-test.latex+lhs
new file mode 100644
index 000000000..64271b415
--- /dev/null
+++ b/test/lhs-test.latex+lhs
@@ -0,0 +1,83 @@
+\documentclass[]{article}
+\usepackage{lmodern}
+\usepackage{amssymb,amsmath}
+\usepackage{ifxetex,ifluatex}
+\usepackage{fixltx2e} % provides \textsubscript
+\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
+ \usepackage[T1]{fontenc}
+ \usepackage[utf8]{inputenc}
+\else % if luatex or xelatex
+ \usepackage{unicode-math}
+ \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
+\fi
+% use upquote if available, for straight quotes in verbatim environments
+\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
+% use microtype if available
+\IfFileExists{microtype.sty}{%
+\usepackage[]{microtype}
+\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
+}{}
+\PassOptionsToPackage{hyphens}{url} % url is loaded by hyperref
+\usepackage[unicode=true]{hyperref}
+\hypersetup{
+ pdfborder={0 0 0},
+ breaklinks=true}
+\urlstyle{same} % don't use monospace font for urls
+\usepackage{listings}
+\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
+\IfFileExists{parskip.sty}{%
+\usepackage{parskip}
+}{% else
+\setlength{\parindent}{0pt}
+\setlength{\parskip}{6pt plus 2pt minus 1pt}
+}
+\setlength{\emergencystretch}{3em} % prevent overfull lines
+\providecommand{\tightlist}{%
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
+\setcounter{secnumdepth}{0}
+% Redefines (sub)paragraphs to behave more like sections
+\ifx\paragraph\undefined\else
+\let\oldparagraph\paragraph
+\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
+\fi
+\ifx\subparagraph\undefined\else
+\let\oldsubparagraph\subparagraph
+\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
+\fi
+
+% set default figure placement to htbp
+\makeatletter
+\def\fps@figure{htbp}
+\makeatother
+
+
+\date{}
+
+\begin{document}
+
+\section{lhs test}\label{lhs-test}
+
+\texttt{unsplit} is an arrow that takes a pair of values and combines them to
+return a single value:
+
+\begin{code}
+unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
+unsplit = arr . uncurry
+ -- arr (\op (x,y) -> x `op` y)
+\end{code}
+
+\texttt{(***)} combines two arrows into a new arrow by running the two arrows on a
+pair of values (one arrow on the first item of the pair and one arrow on the
+second item of the pair).
+
+\begin{verbatim}
+f *** g = first f >>> second g
+\end{verbatim}
+
+Block quote:
+
+\begin{quote}
+foo bar
+\end{quote}
+
+\end{document}
diff --git a/test/lhs-test.markdown b/test/lhs-test.markdown
new file mode 100644
index 000000000..20949b75c
--- /dev/null
+++ b/test/lhs-test.markdown
@@ -0,0 +1,21 @@
+lhs test
+========
+
+`unsplit` is an arrow that takes a pair of values and combines them to
+return a single value:
+
+``` {.sourceCode .literate .haskell}
+unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
+unsplit = arr . uncurry
+ -- arr (\op (x,y) -> x `op` y)
+```
+
+`(***)` combines two arrows into a new arrow by running the two arrows on a
+pair of values (one arrow on the first item of the pair and one arrow on the
+second item of the pair).
+
+ f *** g = first f >>> second g
+
+Block quote:
+
+> foo bar
diff --git a/test/lhs-test.markdown+lhs b/test/lhs-test.markdown+lhs
new file mode 100644
index 000000000..a6a894d22
--- /dev/null
+++ b/test/lhs-test.markdown+lhs
@@ -0,0 +1,19 @@
+lhs test
+========
+
+`unsplit` is an arrow that takes a pair of values and combines them to
+return a single value:
+
+> unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
+> unsplit = arr . uncurry
+> -- arr (\op (x,y) -> x `op` y)
+
+`(***)` combines two arrows into a new arrow by running the two arrows on a
+pair of values (one arrow on the first item of the pair and one arrow on the
+second item of the pair).
+
+ f *** g = first f >>> second g
+
+Block quote:
+
+ > foo bar
diff --git a/test/lhs-test.native b/test/lhs-test.native
new file mode 100644
index 000000000..b6d908339
--- /dev/null
+++ b/test/lhs-test.native
@@ -0,0 +1,8 @@
+[Header 1 ("lhs-test",[],[]) [Str "lhs",Space,Str "test"]
+,Para [Code ("",[],[]) "unsplit",Space,Str "is",Space,Str "an",Space,Str "arrow",Space,Str "that",Space,Str "takes",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "and",Space,Str "combines",Space,Str "them",Space,Str "to",SoftBreak,Str "return",Space,Str "a",Space,Str "single",Space,Str "value:"]
+,CodeBlock ("",["sourceCode","literate","haskell"],[]) "unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d\nunsplit = arr . uncurry\n -- arr (\\op (x,y) -> x `op` y)"
+,Para [Code ("",[],[]) "(***)",Space,Str "combines",Space,Str "two",Space,Str "arrows",Space,Str "into",Space,Str "a",Space,Str "new",Space,Str "arrow",Space,Str "by",Space,Str "running",Space,Str "the",Space,Str "two",Space,Str "arrows",Space,Str "on",Space,Str "a",SoftBreak,Str "pair",Space,Str "of",Space,Str "values",Space,Str "(one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "first",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair",Space,Str "and",Space,Str "one",Space,Str "arrow",Space,Str "on",Space,Str "the",SoftBreak,Str "second",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair)."]
+,CodeBlock ("",[],[]) "f *** g = first f >>> second g"
+,Para [Str "Block",Space,Str "quote:"]
+,BlockQuote
+ [Para [Str "foo",Space,Str "bar"]]]
diff --git a/test/lhs-test.rst b/test/lhs-test.rst
new file mode 100644
index 000000000..3de2d9ff6
--- /dev/null
+++ b/test/lhs-test.rst
@@ -0,0 +1,23 @@
+lhs test
+========
+
+``unsplit`` is an arrow that takes a pair of values and combines them to
+return a single value:
+
+.. code:: haskell
+
+ unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
+ unsplit = arr . uncurry
+ -- arr (\op (x,y) -> x `op` y)
+
+``(***)`` combines two arrows into a new arrow by running the two arrows on a
+pair of values (one arrow on the first item of the pair and one arrow on the
+second item of the pair).
+
+::
+
+ f *** g = first f >>> second g
+
+Block quote:
+
+ foo bar
diff --git a/test/lhs-test.rst+lhs b/test/lhs-test.rst+lhs
new file mode 100644
index 000000000..eec79c546
--- /dev/null
+++ b/test/lhs-test.rst+lhs
@@ -0,0 +1,21 @@
+lhs test
+========
+
+``unsplit`` is an arrow that takes a pair of values and combines them to
+return a single value:
+
+> unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
+> unsplit = arr . uncurry
+> -- arr (\op (x,y) -> x `op` y)
+
+``(***)`` combines two arrows into a new arrow by running the two arrows on a
+pair of values (one arrow on the first item of the pair and one arrow on the
+second item of the pair).
+
+::
+
+ f *** g = first f >>> second g
+
+Block quote:
+
+ foo bar
diff --git a/test/markdown-citations.native b/test/markdown-citations.native
new file mode 100644
index 000000000..c77ccbbfc
--- /dev/null
+++ b/test/markdown-citations.native
@@ -0,0 +1,17 @@
+[Header 1 ("pandoc-with-citeproc-hs",[],[]) [Str "Pandoc",Space,Str "with",Space,Str "citeproc-hs"]
+,BulletList
+ [[Para [Cite [Citation {citationId = "nonexistent", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[@nonexistent]"]]]
+ ,[Para [Cite [Citation {citationId = "nonexistent", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [Str "@nonexistent"]]]
+ ,[Para [Cite [Citation {citationId = "item1", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [Str "@item1"],Space,Str "says",Space,Str "blah."]]
+ ,[Para [Cite [Citation {citationId = "item1", citationPrefix = [], citationSuffix = [Str "p.\160\&30"], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [Str "@item1",Space,Str "[p.",Space,Str "30]"],Space,Str "says",Space,Str "blah."]]
+ ,[Para [Cite [Citation {citationId = "item1", citationPrefix = [], citationSuffix = [Str "p.\160\&30,",Space,Str "with",Space,Str "suffix"], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [Str "@item1",Space,Str "[p.",Space,Str "30,",Space,Str "with",Space,Str "suffix]"],Space,Str "says",Space,Str "blah."]]
+ ,[Para [Cite [Citation {citationId = "item1", citationPrefix = [], citationSuffix = [], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0},Citation {citationId = "item2", citationPrefix = [], citationSuffix = [Space,Str "p.\160\&30"], citationMode = SuppressAuthor, citationNoteNum = 0, citationHash = 0},Citation {citationId = "\1087\1091\1085\1082\1090\&3", citationPrefix = [Str "see",Space,Str "also"], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "@item1",Space,Str "[-@item2",Space,Str "p.",Space,Str "30;",Space,Str "see",Space,Str "also",Space,Str "@\1087\1091\1085\1082\1090\&3]"],Space,Str "says",Space,Str "blah."]]
+ ,[Para [Str "In",Space,Str "a",Space,Str "note.",Note [Para [Cite [Citation {citationId = "\1087\1091\1085\1082\1090\&3", citationPrefix = [], citationSuffix = [Str "p.\160\&12"], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [Str "@\1087\1091\1085\1082\1090\&3",Space,Str "[p.",Space,Str "12]"],Space,Str "and",Space,Str "a",Space,Str "citation",Space,Str "without",Space,Str "locators",Space,Cite [Citation {citationId = "\1087\1091\1085\1082\1090\&3", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[@\1087\1091\1085\1082\1090\&3]"],Str "."]]]]
+ ,[Para [Str "A",Space,Str "citation",Space,Str "group",Space,Cite [Citation {citationId = "item1", citationPrefix = [Str "see"], citationSuffix = [Space,Str "chap.",Space,Str "3"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0},Citation {citationId = "\1087\1091\1085\1082\1090\&3", citationPrefix = [Str "also"], citationSuffix = [Space,Str "p.\160\&34-35"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[see",Space,Str "@item1",Space,Str "chap.",Space,Str "3;",Space,Str "also",Space,Str "@\1087\1091\1085\1082\1090\&3",Space,Str "p.",Space,Str "34-35]"],Str "."]]
+ ,[Para [Str "Another",Space,Str "one",Space,Cite [Citation {citationId = "item1", citationPrefix = [Str "see"], citationSuffix = [Space,Str "p.\160\&34-35"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[see",Space,Str "@item1",Space,Str "p.",Space,Str "34-35]"],Str "."]]
+ ,[Para [Str "And",Space,Str "another",Space,Str "one",Space,Str "in",Space,Str "a",Space,Str "note.",Note [Para [Str "Some",Space,Str "citations",Space,Cite [Citation {citationId = "item1", citationPrefix = [Str "see"], citationSuffix = [Space,Str "chap.",Space,Str "3"], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0},Citation {citationId = "\1087\1091\1085\1082\1090\&3", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0},Citation {citationId = "item2", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[see",Space,Str "@item1",Space,Str "chap.",Space,Str "3;",Space,Str "@\1087\1091\1085\1082\1090\&3;",Space,Str "@item2]"],Str "."]]]]
+ ,[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 "."]]]
+,Header 1 ("references",[],[]) [Str "References"]]
diff --git a/test/markdown-citations.txt b/test/markdown-citations.txt
new file mode 100644
index 000000000..dcc7985d2
--- /dev/null
+++ b/test/markdown-citations.txt
@@ -0,0 +1,39 @@
+Pandoc with citeproc-hs
+=======================
+
+- [@nonexistent]
+
+- @nonexistent
+
+- @item1 says blah.
+
+- @item1 [p. 30] says blah.
+
+- @item1 [p. 30, with suffix] says blah.
+
+- @item1 [-@item2 p. 30; see also @пункт3] says blah.
+
+- In a note.[^1]
+
+- A citation group [see @item1 chap. 3; also @пункт3 p. 34-35].
+
+- Another one [see @item1 p. 34-35].
+
+- And another one in a note.[^2]
+
+- Citation with a suffix and locator [@item1 pp. 33, 35-37, and nowhere else].
+
+- Citation with suffix only [@item1 and nowhere else].
+
+- Now some modifiers.[^3]
+
+- With some markup [*see* @item1 p. **32**].
+
+References
+==========
+
+[^1]: @пункт3 [p. 12] and a citation without locators [@пункт3].
+
+[^2]: Some citations [see @item1 chap. 3; @пункт3; @item2].
+
+[^3]: Like a citation without author: [-@item1], and now Doe with a locator [-@item2 p. 44].
diff --git a/test/markdown-reader-more.native b/test/markdown-reader-more.native
new file mode 100644
index 000000000..baafb5334
--- /dev/null
+++ b/test/markdown-reader-more.native
@@ -0,0 +1,198 @@
+Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "Author",Space,Str "One"],MetaInlines [Str "Author",Space,Str "Two"],MetaInlines [Str "Author",Space,Str "Three"],MetaInlines [Str "Author",Space,Str "Four"]]),("title",MetaInlines [Str "Title",SoftBreak,Str "spanning",Space,Str "multiple",Space,Str "lines"])]})
+[Header 1 ("additional-markdown-reader-tests",[],[]) [Str "Additional",Space,Str "markdown",Space,Str "reader",Space,Str "tests"]
+,Header 2 ("blank-line-before-url-in-link-reference",[],[]) [Str "Blank",Space,Str "line",Space,Str "before",Space,Str "URL",Space,Str "in",Space,Str "link",Space,Str "reference"]
+,Para [Link ("",[],[]) [Str "foo"] ("/url",""),Space,Str "and",Space,Link ("",[],[]) [Str "bar"] ("/url","title")]
+,Header 2 ("raw-context-environments",[],[]) [Str "Raw",Space,Str "ConTeXt",Space,Str "environments"]
+,Plain [RawInline (Format "tex") "\\placeformula "]
+,RawBlock (Format "context") "\\startformula\n L_{1} = L_{2}\n \\stopformula"
+,RawBlock (Format "context") "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]"
+,Header 2 ("raw-latex-environments",[],[]) [Str "Raw",Space,Str "LaTeX",Space,Str "environments"]
+,RawBlock (Format "latex") "\\begin{center}\n\\begin{tikzpicture}[baseline={([yshift=+-.5ex]current bounding box.center)}, level distance=24pt]\n\\Tree [.{S} [.NP John\\index{i} ] [.VP [.V likes ] [.NP himself\\index{i,*j} ]]]\n\\end{tikzpicture}\n\\end{center}"
+,Header 2 ("urls-with-spaces-and-punctuation",[],[]) [Str "URLs",Space,Str "with",Space,Str "spaces",Space,Str "and",Space,Str "punctuation"]
+,Para [Link ("",[],[]) [Str "foo"] ("/bar%20and%20baz",""),SoftBreak,Link ("",[],[]) [Str "foo"] ("/bar%20and%20baz",""),SoftBreak,Link ("",[],[]) [Str "foo"] ("/bar%20and%20baz",""),SoftBreak,Link ("",[],[]) [Str "foo"] ("bar%20baz","title")]
+,Para [Link ("",[],[]) [Str "baz"] ("/foo%20foo",""),Space,Link ("",[],[]) [Str "bam"] ("/foo%20fee",""),Space,Link ("",[],[]) [Str "bork"] ("/foo/zee%20zob","title")]
+,Para [Link ("",[],[]) [Str "Ward\8217s",Space,Str "method."] ("http://en.wikipedia.org/wiki/Ward's_method","")]
+,Header 2 ("horizontal-rules-with-spaces-at-end",[],[]) [Str "Horizontal",Space,Str "rules",Space,Str "with",Space,Str "spaces",Space,Str "at",Space,Str "end"]
+,HorizontalRule
+,HorizontalRule
+,Header 2 ("raw-html-before-header",[],[]) [Str "Raw",Space,Str "HTML",Space,Str "before",Space,Str "header"]
+,Para [RawInline (Format "html") "<a>",RawInline (Format "html") "</a>"]
+,Header 3 ("my-header",[],[]) [Str "my",Space,Str "header"]
+,Header 2 ("in-math",[],[]) [Str "$",Space,Str "in",Space,Str "math"]
+,Para [Math InlineMath "\\$2 + \\$3"]
+,Para [Math InlineMath "x = \\text{the $n$th root of $y$}"]
+,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "math:"]
+,Para [Str "$PATH",Space,Str "90",Space,Str "$PATH"]
+,Header 2 ("commented-out-list-item",[],[]) [Str "Commented-out",Space,Str "list",Space,Str "item"]
+,BulletList
+ [[Plain [Str "one",SoftBreak,RawInline (Format "html") "<!--\n- two\n-->"]]
+ ,[Plain [Str "three"]]]
+,Header 2 ("indented-code-at-beginning-of-list",[],[]) [Str "Indented",Space,Str "code",Space,Str "at",Space,Str "beginning",Space,Str "of",Space,Str "list"]
+,BulletList
+ [[CodeBlock ("",[],[]) "code\ncode"]]
+,OrderedList (1,Decimal,Period)
+ [[CodeBlock ("",[],[]) "code\ncode"]
+ ,[CodeBlock ("",[],[]) "code\ncode"]]
+,BulletList
+ [[CodeBlock ("",[],[]) "code\ncode"]
+ ,[Plain [Str "no",Space,Str "code"]]]
+,Header 2 ("backslash-newline",[],[]) [Str "Backslash",Space,Str "newline"]
+,Para [Str "hi",LineBreak,Str "there"]
+,Header 2 ("code-spans",[],[]) [Str "Code",Space,Str "spans"]
+,Para [Code ("",[],[]) "hi\\"]
+,Para [Code ("",[],[]) "hi there"]
+,Para [Code ("",[],[]) "hi````there"]
+,Para [Str "`hi"]
+,Para [Str "there`"]
+,Header 2 ("multilingual-urls",[],[]) [Str "Multilingual",Space,Str "URLs"]
+,Para [Link ("",[],[]) [Str "http://\27979.com?\27979=\27979"] ("http://\27979.com?\27979=\27979","")]
+,Para [Link ("",[],[]) [Str "foo"] ("/bar/\27979?x=\27979","title")]
+,Para [Link ("",[],[]) [Str "\27979@foo.\27979.baz"] ("mailto:\27979@foo.\27979.baz","")]
+,Header 2 ("numbered-examples",[],[]) [Str "Numbered",Space,Str "examples"]
+,OrderedList (1,Example,TwoParens)
+ [[Plain [Str "First",Space,Str "example."]]
+ ,[Plain [Str "Second",Space,Str "example."]]]
+,Para [Str "Explanation",Space,Str "of",Space,Str "examples",Space,Str "(2)",Space,Str "and",Space,Str "(3)."]
+,OrderedList (3,Example,TwoParens)
+ [[Plain [Str "Third",Space,Str "example."]]]
+,Header 2 ("macros",[],[]) [Str "Macros"]
+,Para [Math InlineMath "{\\langle x,y \\rangle}"]
+,Header 2 ("case-insensitive-references",[],[]) [Str "Case-insensitive",Space,Str "references"]
+,Para [Link ("",[],[]) [Str "Fum"] ("/fum","")]
+,Para [Link ("",[],[]) [Str "FUM"] ("/fum","")]
+,Para [Link ("",[],[]) [Str "bat"] ("/bat","")]
+,Header 2 ("curly-smart-quotes",[],[]) [Str "Curly",Space,Str "smart",Space,Str "quotes"]
+,Para [Quoted DoubleQuote [Str "Hi"]]
+,Para [Quoted SingleQuote [Str "Hi"]]
+,Header 2 ("consecutive-lists",[],[]) [Str "Consecutive",Space,Str "lists"]
+,BulletList
+ [[Plain [Str "one"]]
+ ,[Plain [Str "two"]]]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "one"]]
+ ,[Plain [Str "two"]]]
+,OrderedList (1,LowerAlpha,Period)
+ [[Plain [Str "one"]]
+ ,[Plain [Str "two"]]]
+,Header 2 ("implicit-header-references",[],[]) [Str "Implicit",Space,Str "header",Space,Str "references"]
+,Header 3 ("my-header-1",[],[]) [Str "My",Space,Str "header"]
+,Header 3 ("my-other-header",[],[]) [Str "My",Space,Str "other",Space,Str "header"]
+,Para [Str "A",Space,Str "link",Space,Str "to",Space,Link ("",[],[]) [Str "My",Space,Str "header"] ("#my-header-1",""),Str "."]
+,Para [Str "Another",Space,Str "link",Space,Str "to",Space,Link ("",[],[]) [Str "it"] ("#my-header-1",""),Str "."]
+,Para [Str "Should",Space,Str "be",Space,Link ("",[],[]) [Str "case",Space,Str "insensitive"] ("#my-header-1",""),Str "."]
+,Para [Str "Link",Space,Str "to",Space,Link ("",[],[]) [Str "Explicit",Space,Str "header",Space,Str "attributes"] ("#foobar",""),Str "."]
+,Para [Str "But",Space,Str "this",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "link",Space,Str "to",Space,Link ("",[],[]) [Str "My",Space,Str "other",Space,Str "header"] ("/foo",""),Str ",",Space,Str "since",Space,Str "the",Space,Str "reference",Space,Str "is",Space,Str "defined."]
+,Header 2 ("foobar",["baz"],[("key","val")]) [Str "Explicit",Space,Str "header",Space,Str "attributes"]
+,BlockQuote
+ [Header 2 ("foobar",["baz"],[("key","val")]) [Str "Header",Space,Str "attributes",Space,Str "inside",Space,Str "block",Space,Str "quote"]]
+,Header 2 ("line-blocks",[],[]) [Str "Line",Space,Str "blocks"]
+,LineBlock
+ [[Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be"]
+ ,[Str "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,"]
+ ,[Str "\160\160\160\160\160\160\160\160when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,"]
+ ,[Str "\160\160\160\160\160\160\160\160\160\160\160\160due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]
+ ,[]
+ ,[Str "Continuation",Space,Str "line"]
+ ,[Str "\160\160and",Space,Str "another"]]
+,Header 2 ("grid-tables",[],[]) [Str "Grid",Space,Str "Tables"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555]
+ [[Plain [Str "col",Space,Str "1"]]
+ ,[Plain [Str "col",Space,Str "2"]]
+ ,[Plain [Str "col",Space,Str "3"]]]
+ [[[Para [Str "r1",Space,Str "a",SoftBreak,Str "r1",Space,Str "bis"]]
+ ,[Para [Str "b",SoftBreak,Str "b",Space,Str "2"]]
+ ,[Para [Str "c",SoftBreak,Str "c",Space,Str "2"]]]
+ ,[[Para [Str "r2",Space,Str "d"]]
+ ,[Para [Str "e"]]
+ ,[Para [Str "f"]]]]
+,Para [Str "Headless"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555]
+ [[]
+ ,[]
+ ,[]]
+ [[[Para [Str "r1",Space,Str "a",SoftBreak,Str "r1",Space,Str "bis"]]
+ ,[Para [Str "b",SoftBreak,Str "b",Space,Str "2"]]
+ ,[Para [Str "c",SoftBreak,Str "c",Space,Str "2"]]]
+ ,[[Para [Str "r2",Space,Str "d"]]
+ ,[Para [Str "e"]]
+ ,[Para [Str "f"]]]]
+,Para [Str "With",Space,Str "alignments"]
+,Table [] [AlignRight,AlignLeft,AlignCenter] [0.2638888888888889,0.16666666666666666,0.18055555555555555]
+ [[Plain [Str "col",Space,Str "1"]]
+ ,[Plain [Str "col",Space,Str "2"]]
+ ,[Plain [Str "col",Space,Str "3"]]]
+ [[[Para [Str "r1",Space,Str "a",SoftBreak,Str "r1",Space,Str "bis"]]
+ ,[Para [Str "b",SoftBreak,Str "b",Space,Str "2"]]
+ ,[Para [Str "c",SoftBreak,Str "c",Space,Str "2"]]]
+ ,[[Para [Str "r2",Space,Str "d"]]
+ ,[Para [Str "e"]]
+ ,[Para [Str "f"]]]]
+,Para [Str "Headless",Space,Str "with",Space,Str "alignments"]
+,Table [] [AlignRight,AlignLeft,AlignCenter] [0.2638888888888889,0.16666666666666666,0.18055555555555555]
+ [[]
+ ,[]
+ ,[]]
+ [[[Para [Str "r1",Space,Str "a",SoftBreak,Str "r1",Space,Str "bis"]]
+ ,[Para [Str "b",SoftBreak,Str "b",Space,Str "2"]]
+ ,[Para [Str "c",SoftBreak,Str "c",Space,Str "2"]]]
+ ,[[Para [Str "r2",Space,Str "d"]]
+ ,[Para [Str "e"]]
+ ,[Para [Str "f"]]]]
+,Para [Str "Spaces",Space,Str "at",Space,Str "ends",Space,Str "of",Space,Str "lines"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555]
+ [[]
+ ,[]
+ ,[]]
+ [[[Para [Str "r1",Space,Str "a",SoftBreak,Str "r1",Space,Str "bis"]]
+ ,[Para [Str "b",SoftBreak,Str "b",Space,Str "2"]]
+ ,[Para [Str "c",SoftBreak,Str "c",Space,Str "2"]]]
+ ,[[Para [Str "r2",Space,Str "d"]]
+ ,[Para [Str "e"]]
+ ,[Para [Str "f"]]]]
+,Para [Str "Multiple",Space,Str "blocks",Space,Str "in",Space,Str "a",Space,Str "cell"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555]
+ [[]
+ ,[]
+ ,[]]
+ [[[Header 1 ("col-1",[],[]) [Str "col",Space,Str "1"]
+ ,Para [Str "col",Space,Str "1"]]
+ ,[Header 1 ("col-2",[],[]) [Str "col",Space,Str "2"]
+ ,Para [Str "col",Space,Str "2"]]
+ ,[Header 1 ("col-3",[],[]) [Str "col",Space,Str "3"]
+ ,Para [Str "col",Space,Str "3"]]]
+ ,[[Para [Str "r1",Space,Str "a"]
+ ,Para [Str "r1",Space,Str "bis"]]
+ ,[BulletList
+ [[Plain [Str "b"]]
+ ,[Plain [Str "b",Space,Str "2"]]
+ ,[Plain [Str "b",Space,Str "2"]]]]
+ ,[Para [Str "c",SoftBreak,Str "c",Space,Str "2",SoftBreak,Str "c",Space,Str "2"]]]]
+,Para [Str "Empty",Space,Str "cells"]
+,Table [] [AlignDefault,AlignDefault] [5.555555555555555e-2,5.555555555555555e-2]
+ [[]
+ ,[]]
+ [[[]
+ ,[]]]
+,Header 2 ("entities-in-links-and-titles",[],[]) [Str "Entities",Space,Str "in",Space,Str "links",Space,Str "and",Space,Str "titles"]
+,Para [Link ("",[],[]) [Str "link"] ("/\252rl","\246\246!")]
+,Para [Link ("",[],[]) [Str "http://g\246\246gle.com"] ("http://g\246\246gle.com","")]
+,Para [Link ("",[],[]) [Str "me@ex\228mple.com"] ("mailto:me@ex\228mple.com","")]
+,Para [Link ("",[],[]) [Str "foobar"] ("/\252rl","\246\246!")]
+,Header 2 ("parentheses-in-urls",[],[]) [Str "Parentheses",Space,Str "in",Space,Str "URLs"]
+,Para [Link ("",[],[]) [Str "link"] ("/hi(there)","")]
+,Para [Link ("",[],[]) [Str "link"] ("/hithere)","")]
+,Para [Link ("",[],[]) [Str "linky"] ("hi_(there_(nested))","")]
+,Header 2 ("backslashes-in-link-references",[],[]) [Str "Backslashes",Space,Str "in",Space,Str "link",Space,Str "references"]
+,Para [Link ("",[],[]) [Str "*",RawInline (Format "tex") "\\a"] ("b","")]
+,Header 2 ("reference-link-fallbacks",[],[]) [Str "Reference",Space,Str "link",Space,Str "fallbacks"]
+,Para [Str "[",Emph [Str "not",Space,Str "a",Space,Str "link"],Str "]",Space,Str "[",Emph [Str "nope"],Str "]\8230"]
+,Header 2 ("reference-link-followed-by-a-citation",[],[]) [Str "Reference",Space,Str "link",Space,Str "followed",Space,Str "by",Space,Str "a",Space,Str "citation"]
+,Para [Str "MapReduce",Space,Str "is",Space,Str "a",Space,Str "paradigm",Space,Str "popularized",Space,Str "by",Space,Link ("",[],[]) [Str "Google"] ("http://google.com",""),Space,Cite [Citation {citationId = "mapreduce", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[@mapreduce]"],Space,Str "as",Space,Str "its",SoftBreak,Str "most",Space,Str "vocal",Space,Str "proponent."]
+,Header 2 ("empty-reference-links",[],[]) [Str "Empty",Space,Str "reference",Space,Str "links"]
+,Para [Str "bar"]
+,Para [Link ("",[],[]) [Str "foo2"] ("","")]
+,Header 2 ("wrapping-shouldnt-introduce-new-list-items",[],[]) [Str "Wrapping",Space,Str "shouldn\8217t",Space,Str "introduce",Space,Str "new",Space,Str "list",Space,Str "items"]
+,BulletList
+ [[Plain [Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "2015."]]]
+,Header 2 ("bracketed-spans",[],[]) [Str "Bracketed",Space,Str "spans"]
+,Para [Span ("id",["class"],[("key","val")]) [Emph [Str "foo"],Space,Str "bar",Space,Str "baz",Space,Link ("",[],[]) [Str "link"] ("url","")]]]
diff --git a/test/markdown-reader-more.txt b/test/markdown-reader-more.txt
new file mode 100644
index 000000000..73c9500a0
--- /dev/null
+++ b/test/markdown-reader-more.txt
@@ -0,0 +1,320 @@
+% Title
+ spanning multiple lines
+% Author One
+ Author Two; Author Three;
+ Author Four
+
+# Additional markdown reader tests
+
+## Blank line before URL in link reference
+
+[foo] and [bar]
+
+[foo]:
+ /url
+
+[bar]:
+/url
+"title"
+
+## Raw ConTeXt environments
+
+\placeformula \startformula
+ L_{1} = L_{2}
+ \stopformula
+
+\start[a2]
+\start[a2]
+\stop[a2]
+\stop[a2]
+
+## Raw LaTeX environments
+
+\begin{center}
+\begin{tikzpicture}[baseline={([yshift=+-.5ex]current bounding box.center)}, level distance=24pt]
+\Tree [.{S} [.NP John\index{i} ] [.VP [.V likes ] [.NP himself\index{i,*j} ]]]
+\end{tikzpicture}
+\end{center}
+
+## URLs with spaces and punctuation
+
+[foo](/bar and baz)
+[foo](/bar
+ and baz )
+[foo]( /bar and baz )
+[foo](bar baz "title" )
+
+[baz][] [bam][] [bork][]
+
+[baz]: /foo foo
+[bam]: /foo fee
+[bork]: /foo/zee zob (title)
+
+[Ward's method.](http://en.wikipedia.org/wiki/Ward's_method)
+
+## Horizontal rules with spaces at end
+
+* * * * *
+
+-- - -- -- -
+
+## Raw HTML before header
+
+<a></a>
+
+### my header
+
+## $ in math
+
+$\$2 + \$3$
+
+$x = \text{the $n$th root of $y$}$
+
+This should not be math:
+
+$PATH 90 $PATH
+
+## Commented-out list item
+
+- one
+<!--
+- two
+-->
+- three
+
+## Indented code at beginning of list
+
+- code
+ code
+
+ 1. code
+ code
+
+ 12345678. code
+ code
+
+ - code
+ code
+
+ - no code
+
+## Backslash newline
+
+hi\
+there
+
+## Code spans
+
+`hi\`
+
+`hi
+there`
+
+`` hi````there ``
+
+`hi
+
+there`
+
+## Multilingual URLs
+
+<http://测.com?测=测>
+
+[foo](/bar/测?x=测 "title")
+
+<测@foo.测.baz>
+
+## Numbered examples
+
+(@) First example.
+(@foo) Second example.
+
+Explanation of examples (@foo) and (@bar).
+
+(@bar) Third example.
+
+## Macros
+
+\newcommand{\tuple}[1]{\langle #1 \rangle}
+
+$\tuple{x,y}$
+
+## Case-insensitive references
+
+[Fum]
+
+[FUM]
+
+[bat]
+
+[fum]: /fum
+[BAT]: /bat
+
+## Curly smart quotes
+
+“Hi”
+
+‘Hi’
+
+## Consecutive lists
+
+- one
+- two
+1. one
+2. two
+
+ a. one
+ b. two
+
+## Implicit header references
+
+### My header
+
+### My other header
+
+A link to [My header].
+
+Another link to [it][My header].
+
+Should be [case insensitive][my header].
+
+Link to [Explicit header attributes].
+
+[my other header]: /foo
+
+But this is not a link to [My other header], since the reference is defined.
+
+## Explicit header attributes {#foobar .baz key="val"}
+
+> ## Header attributes inside block quote {#foobar .baz key="val"}
+
+## Line blocks
+
+| But can a bee be said to be
+| or not to be an entire bee,
+| when half the bee is not a bee,
+| due to some ancient injury?
+|
+| Continuation
+ line
+| and
+ another
+
+## Grid Tables
+
++------------------+-----------+------------+
+| col 1 | col 2 | col 3 |
++==================+===========+============+
+| r1 a | b | c |
+| r1 bis | b 2 | c 2 |
++------------------+-----------+------------+
+| r2 d | e | f |
++------------------+-----------+------------+
+
+Headless
+
++------------------+-----------+------------+
+| r1 a | b | c |
+| r1 bis | b 2 | c 2 |
++------------------+-----------+------------+
+| r2 d | e | f |
++------------------+-----------+------------+
+
+With alignments
+
++------------------+-----------+------------+
+| col 1 | col 2 | col 3 |
++=================:+:==========+:==========:+
+| r1 a | b | c |
+| r1 bis | b 2 | c 2 |
++------------------+-----------+------------+
+| r2 d | e | f |
++------------------+-----------+------------+
+
+Headless with alignments
+
++-----------------:+:----------+:----------:+
+| r1 a | b | c |
+| r1 bis | b 2 | c 2 |
++------------------+-----------+------------+
+| r2 d | e | f |
++------------------+-----------+------------+
+
+Spaces at ends of lines
+
++------------------+-----------+------------+
+| r1 a | b | c |
+| r1 bis | b 2 | c 2 |
++------------------+-----------+------------+
+| r2 d | e | f |
++------------------+-----------+------------+
+
+Multiple blocks in a cell
+
++------------------+-----------+------------+
+| # col 1 | # col 2 | # col 3 |
+| col 1 | col 2 | col 3 |
++------------------+-----------+------------+
+| r1 a | - b | c |
+| | - b 2 | c 2 |
+| r1 bis | - b 2 | c 2 |
++------------------+-----------+------------+
+
+Empty cells
+
++---+---+
+| | |
++---+---+
+
+## Entities in links and titles
+
+[link](/&uuml;rl "&ouml;&ouml;!")
+
+<http://g&ouml;&ouml;gle.com>
+
+<me@ex&auml;mple.com>
+
+[foobar]
+
+[foobar]: /&uuml;rl "&ouml;&ouml;!"
+
+## Parentheses in URLs
+
+[link](/hi(there))
+
+[link](/hithere\))
+
+[linky]
+
+[linky]: hi_(there_(nested))
+
+## Backslashes in link references
+
+[\*\a](b)
+
+## Reference link fallbacks
+
+[*not a link*] [*nope*]...
+
+## Reference link followed by a citation
+
+MapReduce is a paradigm popularized by [Google] [@mapreduce] as its
+most vocal proponent.
+
+[Google]: http://google.com
+
+## Empty reference links
+
+[foo2]:
+
+bar
+
+[foo2]
+
+## Wrapping shouldn't introduce new list items
+
+- blah blah blah blah blah blah blah blah blah blah blah blah blah blah 2015.
+
+## Bracketed spans
+
+[*foo* bar baz [link](url)]{.class #id key=val}
diff --git a/test/media/rId25.jpg b/test/media/rId25.jpg
new file mode 100644
index 000000000..277ace7d1
--- /dev/null
+++ b/test/media/rId25.jpg
Binary files differ
diff --git a/test/media/rId26.jpg b/test/media/rId26.jpg
new file mode 100644
index 000000000..277ace7d1
--- /dev/null
+++ b/test/media/rId26.jpg
Binary files differ
diff --git a/test/media/rId27.jpg b/test/media/rId27.jpg
new file mode 100644
index 000000000..277ace7d1
--- /dev/null
+++ b/test/media/rId27.jpg
Binary files differ
diff --git a/test/mediawiki-reader.native b/test/mediawiki-reader.native
new file mode 100644
index 000000000..6afeb602c
--- /dev/null
+++ b/test/mediawiki-reader.native
@@ -0,0 +1,262 @@
+Pandoc (Meta {unMeta = fromList []})
+[Header 1 ("header",[],[]) [Str "header"]
+,Header 2 ("header-level-two",[],[]) [Str "header",Space,Str "level",Space,Str "two"]
+,Header 3 ("header-level-3",[],[]) [Str "header",Space,Str "level",Space,Str "3"]
+,Header 4 ("header-level-four",[],[]) [Str "header",Space,Emph [Str "level"],Space,Str "four"]
+,Header 5 ("header-level-5",[],[]) [Str "header",Space,Str "level",Space,Str "5"]
+,Header 6 ("header-level-6",[],[]) [Str "header",Space,Str "level",Space,Str "6"]
+,Para [Str "=======",Space,Str "not",Space,Str "a",Space,Str "header",Space,Str "========"]
+,Para [Code ("",[],[]) "==\160not\160a\160header\160=="]
+,Header 2 ("emph-and-strong",[],[]) [Str "emph",Space,Str "and",Space,Str "strong"]
+,Para [Emph [Str "emph"],Space,Strong [Str "strong"]]
+,Para [Strong [Emph [Str "strong",Space,Str "and",Space,Str "emph"]]]
+,Para [Strong [Emph [Str "emph",Space,Str "inside"],Space,Str "strong"]]
+,Para [Strong [Str "strong",Space,Str "with",Space,Emph [Str "emph"]]]
+,Para [Emph [Strong [Str "strong",Space,Str "inside"],Space,Str "emph"]]
+,Header 2 ("horizontal-rule",[],[]) [Str "horizontal",Space,Str "rule"]
+,Para [Str "top"]
+,HorizontalRule
+,Para [Str "bottom"]
+,HorizontalRule
+,Header 2 ("nowiki",[],[]) [Str "nowiki"]
+,Para [Str "''not",Space,Str "emph''"]
+,Header 2 ("strikeout",[],[]) [Str "strikeout"]
+,Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "struck",Space,Str "out"]]]
+,Header 2 ("entities",[],[]) [Str "entities"]
+,Para [Str "hi",Space,Str "&",Space,Str "low"]
+,Para [Str "hi",Space,Str "&",Space,Str "low"]
+,Para [Str "G\246del"]
+,Para [Str "\777\2730"]
+,Header 2 ("comments",[],[]) [Str "comments"]
+,Para [Str "inline",Space,Str "comment"]
+,Para [Str "between",Space,Str "blocks"]
+,Header 2 ("linebreaks",[],[]) [Str "linebreaks"]
+,Para [Str "hi",LineBreak,Str "there"]
+,Para [Str "hi",LineBreak,Str "there"]
+,Header 2 ("indents",[],[]) [Str ":",Space,Str "indents"]
+,Para [Str "hi"]
+,DefinitionList
+ [([],
+ [[Plain [Str "there"]]])]
+,Para [Str "bud"]
+,Para [Str "hi"]
+,DefinitionList
+ [([],
+ [[DefinitionList
+ [([],
+ [[Plain [Str "there"]]])]]])]
+,Para [Str "bud"]
+,Header 2 ("p-tags",[],[]) [Str "p",Space,Str "tags"]
+,Para [Str "hi",Space,Str "there"]
+,Para [Str "bud"]
+,Para [Str "another"]
+,Header 2 ("raw-html",[],[]) [Str "raw",Space,Str "html"]
+,Para [Str "hi",Space,RawInline (Format "html") "<span style=\"color:red\">",Emph [Str "there"],RawInline (Format "html") "</span>",Str "."]
+,Para [RawInline (Format "html") "<ins>",Str "inserted",RawInline (Format "html") "</ins>"]
+,RawBlock (Format "html") "<div class=\"special\">"
+,Para [Str "hi",Space,Emph [Str "there"]]
+,RawBlock (Format "html") "</div>"
+,Header 2 ("sup-sub-del",[],[]) [Str "sup,",Space,Str "sub,",Space,Str "del"]
+,Para [Str "H",Subscript [Str "2"],Str "O",Space,Str "base",Superscript [Emph [Str "exponent"]],SoftBreak,Strikeout [Str "hello"]]
+,Header 2 ("inline-code",[],[]) [Str "inline",Space,Str "code"]
+,Para [Code ("",[],[]) "*\8594*",Space,Code ("",[],[]) "typed",Space,Code ("",["haskell"],[]) ">>="]
+,Header 2 ("code-blocks",[],[]) [Str "code",Space,Str "blocks"]
+,CodeBlock ("",[],[]) "case xs of\n (_:_) -> reverse xs\n [] -> ['*']"
+,CodeBlock ("",["haskell"],[]) "case xs of\n (_:_) -> reverse xs\n [] -> ['*']"
+,CodeBlock ("",["ruby","numberLines"],[("startFrom","100")]) "widgets.each do |w|\n print w.price\nend"
+,Header 2 ("block-quotes",[],[]) [Str "block",Space,Str "quotes"]
+,Para [Str "Regular",Space,Str "paragraph"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote."]
+ ,Para [Str "With",Space,Str "two",Space,Str "paragraphs."]]
+,Para [Str "Nother",Space,Str "paragraph."]
+,Header 2 ("external-links",[],[]) [Str "external",Space,Str "links"]
+,Para [Link ("",[],[]) [Emph [Str "Google"],Space,Str "search",Space,Str "engine"] ("http://google.com","")]
+,Para [Link ("",[],[]) [Str "http://pandoc.org"] ("http://pandoc.org","")]
+,Para [Link ("",[],[]) [Str "1"] ("http://google.com",""),Space,Link ("",[],[]) [Str "2"] ("http://yahoo.com","")]
+,Para [Link ("",[],[]) [Str "email",Space,Str "me"] ("mailto:info@example.org","")]
+,Header 2 ("internal-links",[],[]) [Str "internal",Space,Str "links"]
+,Para [Link ("",[],[]) [Str "Help"] ("Help","wikilink")]
+,Para [Link ("",[],[]) [Str "the",Space,Str "help",Space,Str "page"] ("Help","wikilink")]
+,Para [Link ("",[],[]) [Str "Helpers"] ("Help","wikilink")]
+,Para [Link ("",[],[]) [Str "Help"] ("Help","wikilink"),Str "ers"]
+,Para [Link ("",[],[]) [Str "Contents"] ("Help:Contents","wikilink")]
+,Para [Link ("",[],[]) [Str "#My",Space,Str "anchor"] ("#My_anchor","wikilink")]
+,Para [Link ("",[],[]) [Str "and",Space,Str "text"] ("Page#with_anchor","wikilink")]
+,Header 2 ("images",[],[]) [Str "images"]
+,Para [Image ("",[],[]) [Str "caption"] ("example.jpg","fig:caption")]
+,Para [Image ("",[],[]) [Str "the",Space,Emph [Str "caption"],Space,Str "with",Space,Link ("",[],[]) [Str "external",Space,Str "link"] ("http://google.com","")] ("example.jpg","fig:the caption with external link")]
+,Para [Image ("",[],[("width","30"),("height","40")]) [Str "caption"] ("example.jpg","fig:caption")]
+,Para [Image ("",[],[("width","30")]) [Str "caption"] ("example.jpg","fig:caption")]
+,Para [Image ("",[],[("width","30")]) [Str "caption"] ("example.jpg","fig:caption")]
+,Para [Image ("",[],[]) [Str "example.jpg"] ("example.jpg","fig:example.jpg")]
+,Para [Image ("",[],[]) [Str "example_es.jpg"] ("example_es.jpg","fig:example_es.jpg")]
+,Header 2 ("lists",[],[]) [Str "lists"]
+,BulletList
+ [[Plain [Str "Start",Space,Str "each",Space,Str "line"]]
+ ,[Plain [Str "with",Space,Str "an",Space,Str "asterisk",Space,Str "(*)."]
+ ,BulletList
+ [[Plain [Str "More",Space,Str "asterisks",Space,Str "gives",Space,Str "deeper"]
+ ,BulletList
+ [[Plain [Str "and",Space,Str "deeper",Space,Str "levels."]]]]]]
+ ,[Plain [Str "Line",Space,Str "breaks",LineBreak,Str "don't",Space,Str "break",Space,Str "levels."]
+ ,BulletList
+ [[BulletList
+ [[Plain [Str "But",Space,Str "jumping",Space,Str "levels",Space,Str "creates",Space,Str "empty",Space,Str "space."]]]]]]]
+,Para [Str "Any",Space,Str "other",Space,Str "start",Space,Str "ends",Space,Str "the",Space,Str "list."]
+,BulletList
+ [[BulletList
+ [[Plain [Str "two"]]]]
+ ,[Plain [Str "one"]]]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Start",Space,Str "each",Space,Str "line"]]
+ ,[Plain [Str "with",Space,Str "a",Space,Str "number",Space,Str "sign",Space,Str "(#)."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "More",Space,Str "number",Space,Str "signs",Space,Str "gives",Space,Str "deeper"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "and",Space,Str "deeper"]]
+ ,[Plain [Str "levels."]]]]]]
+ ,[Plain [Str "Line",Space,Str "breaks",LineBreak,Str "don't",Space,Str "break",Space,Str "levels."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "But",Space,Str "jumping",Space,Str "levels",Space,Str "creates",Space,Str "empty",Space,Str "space."]]]]]]
+ ,[Plain [Str "Blank",Space,Str "lines"]]]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "end",Space,Str "the",Space,Str "list",Space,Str "and",Space,Str "start",Space,Str "another."]]]
+,Para [Str "Any",Space,Str "other",Space,Str "start",Space,Str "also",SoftBreak,Str "ends",Space,Str "the",Space,Str "list."]
+,DefinitionList
+ [([Str "item",Space,Str "1"],
+ [[Plain [Str "definition",Space,Str "1"]]])
+ ,([Str "item",Space,Str "2"],
+ [[Plain [Str "definition",Space,Str "2-1"]]
+ ,[Plain [Str "definition",Space,Str "2-2"]]])]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "one"]]
+ ,[Plain [Str "two"]
+ ,BulletList
+ [[Plain [Str "two",Space,Str "point",Space,Str "one"]]
+ ,[Plain [Str "two",Space,Str "point",Space,Str "two"]]]]
+ ,[Plain [Str "three"]
+ ,DefinitionList
+ [([Str "three",Space,Str "item",Space,Str "one"],
+ [[Plain [Str "three",Space,Str "def",Space,Str "one"]]])]]
+ ,[Plain [Str "four"]
+ ,DefinitionList
+ [([],
+ [[Plain [Str "four",Space,Str "def",Space,Str "one"]]
+ ,[Plain [Str "this",Space,Str "looks",Space,Str "like",Space,Str "a",Space,Str "continuation"]]
+ ,[Plain [Str "and",Space,Str "is",Space,Str "often",Space,Str "used"]]
+ ,[Plain [Str "instead",LineBreak,Str "of",Space,Str "<br/>"]]])]]
+ ,[Plain [RawInline (Format "mediawiki") "{{{template\n|author=John\n|title=My Book\n}}}"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "five",Space,Str "sub",Space,Str "1"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "five",Space,Str "sub",Space,Str "1",Space,Str "sub",Space,Str "1"]]]]
+ ,[Plain [Str "five",Space,Str "sub",Space,Str "2"]]]]]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "list",Space,Str "item",Space,Emph [Str "emph"]]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "list",Space,Str "item",Space,Str "B1"]]
+ ,[Plain [Str "list",Space,Str "item",Space,Str "B2"]]]
+ ,Para [Str "continuing",Space,Str "list",Space,Str "item",Space,Str "A1"]]
+ ,[Plain [Str "list",Space,Str "item",Space,Str "A2"]]]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "abc"]]
+ ,[Plain [Str "def"]]
+ ,[Plain [Str "ghi"]]]
+,OrderedList (9,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Amsterdam"]]
+ ,[Plain [Str "Rotterdam"]]
+ ,[Plain [Str "The",Space,Str "Hague"]]]
+,Header 2 ("math",[],[]) [Str "math"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Math InlineMath "x=\\frac{y^\\pi}{z}",Str "."]
+,Para [Str "With",Space,Str "spaces:",Space,Math InlineMath "x=\\frac{y^\\pi}{z}",Str "."]
+,Header 2 ("preformatted-blocks",[],[]) [Str "preformatted",Space,Str "blocks"]
+,Para [Code ("",[],[]) "Start\160each\160line\160with\160a\160space.",LineBreak,Code ("",[],[]) "Text\160is\160",Strong [Code ("",[],[]) "preformatted"],Code ("",[],[]) "\160and",LineBreak,Emph [Code ("",[],[]) "markups"],Code ("",[],[]) "\160",Strong [Emph [Code ("",[],[]) "can"]],Code ("",[],[]) "\160be\160done."]
+,Para [Code ("",[],[]) "\160hell\160\160\160\160\160\160yeah"]
+,Para [Code ("",[],[]) "Start\160with\160a\160space\160in\160the\160first\160column,",LineBreak,Code ("",[],[]) "(before\160the\160<nowiki>).",LineBreak,Code ("",[],[]) "",LineBreak,Code ("",[],[]) "Then\160your\160block\160format\160will\160be",LineBreak,Code ("",[],[]) "\160\160\160\160maintained.",LineBreak,Code ("",[],[]) "",LineBreak,Code ("",[],[]) "This\160is\160good\160for\160copying\160in\160code\160blocks:",LineBreak,Code ("",[],[]) "",LineBreak,Code ("",[],[]) "def\160function():",LineBreak,Code ("",[],[]) "\160\160\160\160\"\"\"documentation\160string\"\"\"",LineBreak,Code ("",[],[]) "",LineBreak,Code ("",[],[]) "\160\160\160\160if\160True:",LineBreak,Code ("",[],[]) "\160\160\160\160\160\160\160\160print\160True",LineBreak,Code ("",[],[]) "\160\160\160\160else:",LineBreak,Code ("",[],[]) "\160\160\160\160\160\160\160\160print\160False"]
+,Para [Str "Not"]
+,RawBlock (Format "html") "<hr/>"
+,Para [Str "preformatted"]
+,Para [Str "Don't",Space,Str "need"]
+,Para [Code ("",[],[]) "a\160blank\160line"]
+,Para [Str "around",Space,Str "a",Space,Str "preformatted",Space,Str "block."]
+,Header 2 ("templates",[],[]) [Str "templates"]
+,RawBlock (Format "mediawiki") "{{Welcome}}"
+,RawBlock (Format "mediawiki") "{{Foo:Bar}}"
+,RawBlock (Format "mediawiki") "{{Thankyou|all your effort|Me}}"
+,Para [Str "Written",Space,RawInline (Format "mediawiki") "{{{date}}}",Space,Str "by",Space,RawInline (Format "mediawiki") "{{{name}}}",Str "."]
+,Header 2 ("tables",[],[]) [Str "tables"]
+,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
+ [[]
+ ,[]]
+ [[[Para [Str "Orange"]]
+ ,[Para [Str "Apple"]]]
+ ,[[Para [Str "Bread"]]
+ ,[Para [Str "Pie"]]]
+ ,[[Para [Str "Butter"]]
+ ,[Para [Str "Ice",Space,Str "cream"]]]]
+,Table [Str "Food",Space,Str "complements"] [AlignDefault,AlignDefault] [0.0,0.0]
+ [[Para [Str "Orange"]]
+ ,[Para [Str "Apple"]]]
+ [[[Para [Str "Bread"]]
+ ,[Para [Str "Pie"]]]
+ ,[[Para [Str "Butter"]]
+ ,[Para [Str "Ice",Space,Str "cream"]]]]
+,Table [Str "Food",Space,Str "complements"] [AlignDefault,AlignDefault] [0.0,0.0]
+ [[Para [Str "Orange"]]
+ ,[Para [Str "Apple"]]]
+ [[[Para [Str "Bread"]
+ ,Para [Str "and",Space,Str "cheese"]]
+ ,[Para [Str "Pie"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "apple"]]
+ ,[Plain [Str "carrot"]]]]]]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[]
+ ,[]
+ ,[]]
+ [[[Para [Str "Orange"]]
+ ,[Para [Str "Apple"]]
+ ,[Para [Str "more"]]]
+ ,[[Para [Str "Bread"]]
+ ,[Para [Str "Pie"]]
+ ,[Para [Str "more"]]]
+ ,[[Para [Str "Butter"]]
+ ,[Para [Str "Ice",Space,Str "cream"]]
+ ,[Para [Str "and",Space,Str "more"]]]]
+,Table [] [AlignLeft,AlignRight,AlignCenter] [0.25,0.125,0.125]
+ [[Para [Str "Left"]]
+ ,[Para [Str "Right"]]
+ ,[Para [Str "Center"]]]
+ [[[Para [Str "left"]]
+ ,[Para [Str "15.00"]]
+ ,[Para [Str "centered"]]]
+ ,[[Para [Str "more"]]
+ ,[Para [Str "2.0"]]
+ ,[Para [Str "more"]]]]
+,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
+ [[]
+ ,[]]
+ [[[Para [Str "Orange"]]
+ ,[Para [Str "Apple"]]]
+ ,[[Para [Str "Bread"]]
+ ,[Table [] [AlignDefault,AlignDefault] [0.0,0.0]
+ [[Para [Str "fruit"]]
+ ,[Para [Str "topping"]]]
+ [[[Para [Str "apple"]]
+ ,[Para [Str "ice",Space,Str "cream"]]]]]]
+ ,[[Para [Str "Butter"]]
+ ,[Para [Str "Ice",Space,Str "cream"]]]]
+,Table [] [AlignDefault] [0.0]
+ [[]]
+ [[[Para [Str "Orange"]]]]
+,Para [Str "Paragraph",Space,Str "after",Space,Str "the",Space,Str "table."]
+,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
+ [[Para [Str "fruit"]]
+ ,[Para [Str "topping"]]]
+ [[[Para [Str "apple"]]
+ ,[Para [Str "ice",Space,Str "cream"]]]]
+,Header 2 ("notes",[],[]) [Str "notes"]
+,Para [Str "My",Space,Str "note!",Note [Plain [Str "This."]]]
+,Para [Str "URL",Space,Str "note.",Note [Plain [Link ("",[],[]) [Str "http://docs.python.org/library/functions.html#range"] ("http://docs.python.org/library/functions.html#range","")]]]]
diff --git a/test/mediawiki-reader.wiki b/test/mediawiki-reader.wiki
new file mode 100644
index 000000000..11cd52d9c
--- /dev/null
+++ b/test/mediawiki-reader.wiki
@@ -0,0 +1,396 @@
+= header =
+
+== header level two ==
+
+===header level 3===
+
+====header ''level'' four====
+
+===== header level 5 =====
+
+====== header level 6 ======
+
+======= not a header ========
+
+ == not a header ==
+
+== emph and strong ==
+
+''emph'' '''strong'''
+
+'''''strong and emph'''''
+
+'''''emph inside'' strong'''
+
+'''strong with ''emph'''''
+
+'''''strong inside''' emph''
+
+== horizontal rule ==
+
+top
+----
+bottom
+
+----
+
+== nowiki ==
+
+<nowiki>''not emph''</nowiki>
+
+== strikeout ==
+
+<strike> This is ''struck out''</strike>
+
+== entities ==
+
+hi & low
+
+hi &amp; low
+
+G&ouml;del
+
+&#777;&#xAAA;
+
+== comments ==
+
+inline<!-- secret --> comment
+
+<!-- secret -->
+
+between blocks
+
+ <!-- secret -->
+
+== linebreaks ==
+
+hi<br/>there
+
+hi<br>
+there
+
+== : indents ==
+
+hi
+: there
+bud
+
+hi
+:: there
+bud
+
+== p tags ==
+
+hi there
+<p>
+bud
+<p>
+another
+</p>
+
+== raw html ==
+
+hi <span style="color:red">''there''</span>.
+
+<ins>inserted</ins>
+
+<div class="special">
+hi ''there''
+</div>
+
+== sup, sub, del ==
+
+H<sub>2</sub>O base<sup>''exponent''</sup>
+<del>hello</del>
+
+== inline code ==
+
+<code>*→*</code> <tt>typed</tt> <hask>>>=</hask>
+
+== code blocks ==
+
+<pre>
+case xs of
+ (_:_) -> reverse xs
+ [] -> ['*']
+</pre>
+
+<haskell>
+case xs of
+ (_:_) -> reverse xs
+ [] -> ['*']
+</haskell>
+
+<syntaxhighlight lang="ruby" line start=100>
+widgets.each do |w|
+ print w.price
+end
+</syntaxhighlight>
+
+== block quotes ==
+
+Regular paragraph
+<blockquote>
+This is a block quote.
+
+With two paragraphs.
+</blockquote>
+Nother paragraph.
+
+== external links ==
+
+[http://google.com ''Google'' search engine]
+
+http://pandoc.org
+
+[http://google.com] [http://yahoo.com]
+
+[mailto:info@example.org email me]
+
+== internal links ==
+
+[[Help]]
+
+[[Help|the help page]]
+
+[[Help]]ers
+
+[[Help]]<nowiki/>ers
+
+[[Help:Contents|]]
+
+[[#My anchor]]
+
+[[Page#with anchor|and text]]
+
+== images ==
+
+[[File:example.jpg|caption]]
+
+[[File:example.jpg|border|the ''caption'' with [http://google.com external link]]]
+
+[[File:example.jpg|frameless|border|30x40px|caption]]
+
+[[File:example.jpg|frameless|border|30px|caption]]
+
+[[File:example.jpg|page=4|30px|border|caption]]
+
+[[File:example.jpg]]
+
+[[Archivo:example_es.jpg]]
+
+== lists ==
+
+* Start each line
+* with an asterisk (*).
+** More asterisks gives deeper
+*** and deeper levels.
+* Line breaks<br/>don't break levels.
+*** But jumping levels creates empty space.
+Any other start ends the list.
+
+** two
+* one
+
+# Start each line
+# with a number sign (#).
+## More number signs gives deeper
+### and deeper
+### levels.
+# Line breaks<br/>don't break levels.
+### But jumping levels creates empty space.
+# Blank lines
+
+# end the list and start another.
+Any other start also
+ends the list.
+
+;item 1
+: definition 1
+;item 2
+: definition 2-1
+: definition 2-2
+
+# one
+# two
+#* two point one
+#* two point two
+# three
+#; three item one
+#: three def one
+# four
+#: four def one
+#: this looks like a continuation
+#: and is often used
+#: instead<br/>of <nowiki><br/></nowiki>
+# {{{template
+|author=John
+|title=My Book
+}}}
+## five sub 1
+### five sub 1 sub 1
+## five sub 2
+
+<ol>
+ <li>list item ''emph''
+ <ol>
+ <li>list item B1</li>
+ <li>list item B2</li>
+ </ol>continuing list item A1
+ </li>
+ <li>list item A2</li>
+</ol>
+
+<ol>
+#abc
+#def
+#ghi
+</ol>
+
+<ol start="9">
+<li>Amsterdam</li>
+<li>Rotterdam</li>
+<li>The Hague</li>
+</ol>
+
+== math ==
+
+Here is some <math>x=\frac{y^\pi}{z}</math>.
+
+With spaces: <math> x=\frac{y^\pi}{z} </math>.
+
+== preformatted blocks ==
+
+ Start each line with a space.
+ Text is '''preformatted''' and
+ ''markups'' '''''can''''' be done.
+
+ hell yeah
+
+ <nowiki>Start with a space in the first column,
+(before the <nowiki>).
+
+Then your block format will be
+ maintained.
+
+This is good for copying in code blocks:
+
+def function():
+ """documentation string"""
+
+ if True:
+ print True
+ else:
+ print False</nowiki>
+
+Not<hr/> preformatted
+
+Don't need
+ a blank line
+around a preformatted block.
+
+== templates ==
+
+{{Welcome}}
+
+{{Foo:Bar}}
+
+{{Thankyou|all your effort|Me}}
+
+Written {{{date}}} by {{{name}}}.
+
+== tables ==
+
+{|
+|-
+|Orange
+|Apple
+|-
+|Bread
+|Pie
+|-
+|Butter
+|Ice cream
+|}
+
+{|
+|+Food complements
+!Orange
+!Apple
+|-
+|Bread
+|Pie
+|-
+!Butter
+|Ice cream
+|}
+
+{|
+|+Food complements
+!Orange
+!Apple
+|-
+|Bread
+
+and cheese
+|Pie
+
+# apple
+# carrot
+
+|}
+
+{|
+| Orange || Apple || more
+|-
+| Bread || Pie || more
+|-
+| Butter || Ice cream || and more
+|}
+
+{|width=50%
+! align="left" width="50%"| Left
+! align="right"|Right
+! align="center"|Center
+|-
+| left || 15.00 || centered
+|-
+| more || 2.0 || more
+|}
+
+{|
+|-
+|Orange
+|Apple
+|-
+|Bread
+|
+{|
+!fruit
+!topping
+|-
+|apple
+|ice cream
+|}
+|-
+|Butter
+|Ice cream
+|}
+
+{|
+|Orange
+|}Paragraph after the table.
+
+{|
+ !fruit
+ !topping
+ |-
+ |apple
+ |ice cream
+ |}
+
+== notes ==
+
+My note!<ref>This.</ref>
+
+URL note.<ref>http://docs.python.org/library/functions.html#range</ref>
diff --git a/test/movie.jpg b/test/movie.jpg
new file mode 100644
index 000000000..7240efa3b
--- /dev/null
+++ b/test/movie.jpg
Binary files differ
diff --git a/test/odt/markdown/bold.md b/test/odt/markdown/bold.md
new file mode 100644
index 000000000..fa4eb0431
--- /dev/null
+++ b/test/odt/markdown/bold.md
@@ -0,0 +1 @@
+Here comes **bold** text \ No newline at end of file
diff --git a/test/odt/markdown/citation.md b/test/odt/markdown/citation.md
new file mode 100644
index 000000000..adcc9f0ff
--- /dev/null
+++ b/test/odt/markdown/citation.md
@@ -0,0 +1 @@
+Some text[@Ex] with a citation. \ No newline at end of file
diff --git a/test/odt/markdown/endnote.md b/test/odt/markdown/endnote.md
new file mode 100644
index 000000000..679af3fdc
--- /dev/null
+++ b/test/odt/markdown/endnote.md
@@ -0,0 +1,3 @@
+Some text[^1] with an endnote.
+
+[^1]: Endnote text \ No newline at end of file
diff --git a/test/odt/markdown/externalLink.md b/test/odt/markdown/externalLink.md
new file mode 100644
index 000000000..14f48d0f5
--- /dev/null
+++ b/test/odt/markdown/externalLink.md
@@ -0,0 +1 @@
+Here comes an [external link](http://example.com/) to example.com. \ No newline at end of file
diff --git a/test/odt/markdown/footnote.md b/test/odt/markdown/footnote.md
new file mode 100644
index 000000000..973ae2d3a
--- /dev/null
+++ b/test/odt/markdown/footnote.md
@@ -0,0 +1,3 @@
+Some text[^1] with a footnote.
+
+[^1]: Footnote text \ No newline at end of file
diff --git a/test/odt/markdown/headers.md b/test/odt/markdown/headers.md
new file mode 100644
index 000000000..ea5d4452c
--- /dev/null
+++ b/test/odt/markdown/headers.md
@@ -0,0 +1,9 @@
+# A header (Lv 1)
+
+A paragraph
+
+## Another header (Lv 2)
+
+Another paragraph
+
+# Back to Level 1 \ No newline at end of file
diff --git a/test/odt/markdown/horizontalRule.md b/test/odt/markdown/horizontalRule.md
new file mode 100644
index 000000000..73b314ff7
--- /dev/null
+++ b/test/odt/markdown/horizontalRule.md
@@ -0,0 +1 @@
+--- \ No newline at end of file
diff --git a/test/odt/markdown/image.md b/test/odt/markdown/image.md
new file mode 100644
index 000000000..3862d709e
--- /dev/null
+++ b/test/odt/markdown/image.md
@@ -0,0 +1 @@
+![](10000000000000FA000000FAD6A15225.jpg) \ No newline at end of file
diff --git a/test/odt/markdown/imageIndex.md b/test/odt/markdown/imageIndex.md
new file mode 100644
index 000000000..6719ab8a8
--- /dev/null
+++ b/test/odt/markdown/imageIndex.md
@@ -0,0 +1,6 @@
+# Abbildungsverzeichnis
+
+Abbildung 1: Image caption
+
+![Abbildung 1: Image caption](10000000000000FA000000FAD6A15225.jpg)
+
diff --git a/test/odt/markdown/imageWithCaption.md b/test/odt/markdown/imageWithCaption.md
new file mode 100644
index 000000000..0046ae141
--- /dev/null
+++ b/test/odt/markdown/imageWithCaption.md
@@ -0,0 +1 @@
+![Abbildung 1: Image caption](10000000000000FA000000FAD6A15225.jpg) \ No newline at end of file
diff --git a/test/odt/markdown/italic.md b/test/odt/markdown/italic.md
new file mode 100644
index 000000000..b4d2f3d40
--- /dev/null
+++ b/test/odt/markdown/italic.md
@@ -0,0 +1 @@
+Here comes *italic* text \ No newline at end of file
diff --git a/test/odt/markdown/listBlocks.md b/test/odt/markdown/listBlocks.md
new file mode 100644
index 000000000..22c77bb2b
--- /dev/null
+++ b/test/odt/markdown/listBlocks.md
@@ -0,0 +1,6 @@
+<text:list xml:id="list2666723676250588421" text:style-name="L6">
+<text:list-header>
+<text:p text:style-name="P1">Indented text in a list.</text:p>
+</text:list-header>
+<text:list-item>
+<text:p text:style-name="P1">This is a numbered block.<text:line-break/>It contains several paragraphs of text.<text:line-break/>Like this.</text:p></text:list-item><text:list-item><text:p text:style-name="P1">Next item.</text:p></text:list-item></text:list></office:text></office:body></office:document-content> \ No newline at end of file
diff --git a/test/odt/markdown/paragraph.md b/test/odt/markdown/paragraph.md
new file mode 100644
index 000000000..0a822e322
--- /dev/null
+++ b/test/odt/markdown/paragraph.md
@@ -0,0 +1,5 @@
+This is a paragraph.
+
+This is another paragraph.
+
+This is a third one. \ No newline at end of file
diff --git a/test/odt/markdown/strikeout.md b/test/odt/markdown/strikeout.md
new file mode 100644
index 000000000..6ae4571dd
--- /dev/null
+++ b/test/odt/markdown/strikeout.md
@@ -0,0 +1 @@
+Here comes text that was ~~striken out~~. \ No newline at end of file
diff --git a/test/odt/markdown/trackedChanges.md b/test/odt/markdown/trackedChanges.md
new file mode 100644
index 000000000..f0bd478a3
--- /dev/null
+++ b/test/odt/markdown/trackedChanges.md
@@ -0,0 +1 @@
+Some text with and inserted text. \ No newline at end of file
diff --git a/test/odt/markdown/underlined.md b/test/odt/markdown/underlined.md
new file mode 100644
index 000000000..05fb92379
--- /dev/null
+++ b/test/odt/markdown/underlined.md
@@ -0,0 +1 @@
+Here comes *underlined* text \ No newline at end of file
diff --git a/test/odt/native/blockquote.native b/test/odt/native/blockquote.native
new file mode 100644
index 000000000..8c9409dde
--- /dev/null
+++ b/test/odt/native/blockquote.native
@@ -0,0 +1 @@
+[Para [Str "Normal"],BlockQuote [Para [Str "Indented",Space,Str "(1cm)"]]] \ No newline at end of file
diff --git a/test/odt/native/image.native b/test/odt/native/image.native
new file mode 100644
index 000000000..667442539
--- /dev/null
+++ b/test/odt/native/image.native
@@ -0,0 +1 @@
+[Para [Image ("",[],[("width","5.292cm"),("height","5.292cm")]) [] ("Pictures/10000000000000FA000000FAD6A15225.jpg","")]]
diff --git a/test/odt/native/imageIndex.native b/test/odt/native/imageIndex.native
new file mode 100644
index 000000000..fe7b69c16
--- /dev/null
+++ b/test/odt/native/imageIndex.native
@@ -0,0 +1 @@
+[Para [Image ("",[],[("width","5.292cm"),("height","5.292cm")]) [Str "Abbildung",Space,Str "1:",Space,Str "Image",Space,Str "caption"] ("Pictures/10000000000000FA000000FAD6A15225.jpg","fig:")]]
diff --git a/test/odt/native/imageWithCaption.native b/test/odt/native/imageWithCaption.native
new file mode 100644
index 000000000..fe7b69c16
--- /dev/null
+++ b/test/odt/native/imageWithCaption.native
@@ -0,0 +1 @@
+[Para [Image ("",[],[("width","5.292cm"),("height","5.292cm")]) [Str "Abbildung",Space,Str "1:",Space,Str "Image",Space,Str "caption"] ("Pictures/10000000000000FA000000FAD6A15225.jpg","fig:")]]
diff --git a/test/odt/native/inlinedCode.native b/test/odt/native/inlinedCode.native
new file mode 100644
index 000000000..6e32ff7a9
--- /dev/null
+++ b/test/odt/native/inlinedCode.native
@@ -0,0 +1 @@
+[Para [Str "Here",Space,Str "comes",Space,Code ("",[],[]) "inlined code",Space,Str "text",Space,Str "and",Space,Code ("",[],[]) "an another",Space,Str "one."]]
diff --git a/test/odt/native/orderedListMixed.native b/test/odt/native/orderedListMixed.native
new file mode 100644
index 000000000..c2c8586af
--- /dev/null
+++ b/test/odt/native/orderedListMixed.native
@@ -0,0 +1 @@
+Pandoc (Meta {unMeta = fromList []}) [OrderedList (1,Decimal,Period) [[Plain [Str "A",Space,Str "list",Space,Str "item"]],[Plain [Str "A",Space,Str "second"]],[Para [Str "A",Space,Str "third"],OrderedList (1,Decimal,Period) [[Para [Str "New",Space,Str "level!"],OrderedList (1,LowerAlpha,OneParen) [[Plain [Str "And",Space,Str "another!"]],[Plain [Str "It's",Space,Str "great",Space,Str "up",Space,Str "here!"]]]],[Plain [Str "Oh",Space,Str "noes"]],[Plain [Str "We",Space,Str "fell!"]]]],[Plain [Str "Maybe",Space,Str "someone"]],[Plain [Str "Pushed",Space,Str "us?"]]],Para [],OrderedList (4,Decimal,Period) [[Plain [Str "Start",Space,Str "new",Space,Str "list,",Space,Str "but",Space,Str "a",Space,Str "different",Space,Str "starting",Space,Str "point."]] ,[Plain [Str "Because",Space,Str "we",Space,Str "can."]]]] \ No newline at end of file
diff --git a/test/odt/native/orderedListRoman.native b/test/odt/native/orderedListRoman.native
new file mode 100644
index 000000000..73bbbf1c9
--- /dev/null
+++ b/test/odt/native/orderedListRoman.native
@@ -0,0 +1 @@
+Pandoc (Meta {unMeta = fromList []}) [OrderedList (1,UpperRoman,Period) [[Plain[Str "A",Space,Str "list",Space,Str "item"]],[Plain [Str "A",Space,Str "second"]],[Para [Str "A",Space,Str "third"],OrderedList (1,UpperRoman,Period) [[Para [Str "New",Space,Str "level!"],OrderedList (1,UpperRoman,Period) [[Plain [Str "And",Space,Str "another!"]],[Plain [Str "It's",Space,Str "great",Space,Str "up",Space,Str "here!"]]]],[Plain [Str "Oh",Space,Str "noes"]],[Plain [Str "We",Space,Str "fell!"]]]],[Plain [Str "Maybe",Space,Str "someone"]],[Plain [Str "Pushed",Space,Str "us?"]]],Para [],OrderedList (4,UpperRoman,Period) [[Plain [Str "Start",Space,Str "new",Space,Str "list,",Space,Str "but",Space,Str "a",Space,Str "different",Space,Str "starting",Space,Str "point."]] ,[Plain [Str "Because",Space,Str "we",Space,Str "can."]]]] \ No newline at end of file
diff --git a/test/odt/native/orderedListSimple.native b/test/odt/native/orderedListSimple.native
new file mode 100644
index 000000000..0b1f85231
--- /dev/null
+++ b/test/odt/native/orderedListSimple.native
@@ -0,0 +1 @@
+Pandoc (Meta {unMeta = fromList []}) [OrderedList (1,Decimal,Period) [[Plain [Str "A",Space,Str "list",Space,Str "item"]],[Plain [Str "A",Space,Str "second"]],[Para [Str "A",Space,Str "third"],OrderedList (1,Decimal,Period) [[Para [Str "New",Space,Str "level!"],OrderedList (1,Decimal,Period) [[Plain [Str "And",Space,Str "another!"]],[Plain [Str "It's",Space,Str "great",Space,Str "up",Space,Str "here!"]]]],[Plain [Str "Oh",Space,Str "noes"]],[Plain [Str "We",Space,Str "fell!"]]]],[Plain [Str "Maybe",Space,Str "someone"]],[Plain [Str "Pushed",Space,Str "us?"]]],Para [],OrderedList (4,Decimal,Period) [[Plain [Str "Start",Space,Str "new",Space,Str "list,",Space,Str "but",Space,Str "a",Space,Str "different",Space,Str "starting",Space,Str "point."]] ,[Plain [Str "Because",Space,Str "we",Space,Str "can."]]]] \ No newline at end of file
diff --git a/test/odt/native/referenceToChapter.native b/test/odt/native/referenceToChapter.native
new file mode 100644
index 000000000..544fcaaf1
--- /dev/null
+++ b/test/odt/native/referenceToChapter.native
@@ -0,0 +1 @@
+[Header 1 ("a-chapter",[],[]) [Span ("anchor",[],[]) [],Str "A",Space,Str "chapter"],Para [Str "Some",Space,Str "text."],Header 1 ("another-chapter",[],[]) [Str "Another",Space,Str "chapter"],Para [Str "A",Space,Str "reference",Space,Str "to",Space,Str "."],Para [Str "A",Space,Str "reference",Space,Str "to",Space,Link ("",[],[]) [Str "A",Space,Str "chapter"] ("#anchor",""),Str "."]]
diff --git a/test/odt/native/referenceToListItem.native b/test/odt/native/referenceToListItem.native
new file mode 100644
index 000000000..e64389ce6
--- /dev/null
+++ b/test/odt/native/referenceToListItem.native
@@ -0,0 +1 @@
+[OrderedList (1,Decimal,Period) [[Plain [Span ("anchor",[],[]) [],Str "A",Space,Str "list",Space,Str "item"]],[Plain [Str "Another",Space,Str "list",Space,Str "item"]]],Para [Str "A",Space,Str "reference",Space,Str "to",Space,Str "list",Space,Str "item",Space,Link ("",[],[]) [Str "1."] ("#anchor",""),Str "."],Para [],Para []]
diff --git a/test/odt/native/referenceToText.native b/test/odt/native/referenceToText.native
new file mode 100644
index 000000000..a2c3e588d
--- /dev/null
+++ b/test/odt/native/referenceToText.native
@@ -0,0 +1 @@
+[Para [Span ("an anchor",[],[]) [],Str "Some",Space,Str "text."],Para [Str "A",Space,Str "reference",Space,Str "to",Space,Link ("",[],[]) [Str "Some",Space,Str "text"] ("#an anchor",""),Str "."],Para [Str "Some",Space,Str "text",LineBreak,Str "Another",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "link",Span ("anchor",[],[]) []]]
diff --git a/test/odt/native/simpleTable.native b/test/odt/native/simpleTable.native
new file mode 100644
index 000000000..0a9b380a5
--- /dev/null
+++ b/test/odt/native/simpleTable.native
@@ -0,0 +1 @@
+[Table [] [AlignDefault,AlignDefault] [0.0,0.0] [[],[]] [[[Plain [Str "Content"]],[Plain [Str "More",Space,Str "content"]]]],Para []]
diff --git a/test/odt/native/simpleTableWithCaption.native b/test/odt/native/simpleTableWithCaption.native
new file mode 100644
index 000000000..18d68b772
--- /dev/null
+++ b/test/odt/native/simpleTableWithCaption.native
@@ -0,0 +1 @@
+[Table [Str "Table",Space,Str "1:",Space,Str "Some",Space,Str "caption",Space,Str "for",Space,Str "a",Space,Str "table"] [AlignDefault,AlignDefault] [0.0,0.0] [[],[]] [[[Plain [Str "Content"]],[Plain [Str "More",Space,Str "content"]]]],Para []]
diff --git a/test/odt/native/tableWithContents.native b/test/odt/native/tableWithContents.native
new file mode 100644
index 000000000..b1d3c5765
--- /dev/null
+++ b/test/odt/native/tableWithContents.native
@@ -0,0 +1 @@
+[Table [] [AlignDefault,AlignDefault] [0.0,0.0] [[],[]] [[[Plain [Str "A"]],[Plain [Str "B"]]],[[Plain [Str "C"]],[Plain [Str "D"]]]],Para []]
diff --git a/test/odt/native/textMixedStyles.native b/test/odt/native/textMixedStyles.native
new file mode 100644
index 000000000..1347867c6
--- /dev/null
+++ b/test/odt/native/textMixedStyles.native
@@ -0,0 +1,5 @@
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "simple",Space,Str "text"]
+,Para []
+,Para [Str "that",Space,Str "is",Space,Str "both",Space,Emph [Str "italic",Space],Strong [Str "bold",Space],Emph [Str "underlined",Space],Str "and",Space,Str "the",Space,Emph [Strong [Str "first",Space,Str "two"]],Space,Str "and",Space,Str "the",Space,Emph [Strong [Str "last",Space,Str "two",Space]],Space,Str "and",Space,Strong [Strikeout [Str "bold",Space,Str "and",Space,Str "line",Space,Str "through"]]]
+,Para []
+,Para [Str "And",Space,Str "with",Space,Superscript [Emph [Str "superscripts"]]]]
diff --git a/test/odt/native/unicode.native b/test/odt/native/unicode.native
new file mode 100644
index 000000000..b6ac9760c
--- /dev/null
+++ b/test/odt/native/unicode.native
@@ -0,0 +1 @@
+[Para [Str "\8220\8221\8217\231\1256\169\188\1074\1073\1060\1064\246\201\181"]] \ No newline at end of file
diff --git a/test/odt/native/unorderedList.native b/test/odt/native/unorderedList.native
new file mode 100644
index 000000000..a8c083d13
--- /dev/null
+++ b/test/odt/native/unorderedList.native
@@ -0,0 +1 @@
+[BulletList [[Plain [Str "A",Space,Str "list",Space,Str "item"]],[Plain [Str "A",Space,Str "second"]],[Para [Str "A",Space,Str "third"],BulletList [[Para [Str "New",Space,Str "level!"],BulletList [[Plain [Str "And",Space,Str "another!"]],[Plain [Str "It's",Space,Str "great",Space,Str "up",Space,Str "here!"]]]],[Plain [Str "Oh",Space,Str "noes"]],[Plain [Str "We",Space,Str "fell!"]]]],[Plain [Str "Maybe",Space,Str "someone"]],[Plain [Str "Pushed",Space,Str "us?"]]]] \ No newline at end of file
diff --git a/test/odt/odt/blockquote.odt b/test/odt/odt/blockquote.odt
new file mode 100644
index 000000000..0114e308f
--- /dev/null
+++ b/test/odt/odt/blockquote.odt
Binary files differ
diff --git a/test/odt/odt/bold.odt b/test/odt/odt/bold.odt
new file mode 100644
index 000000000..49285722e
--- /dev/null
+++ b/test/odt/odt/bold.odt
Binary files differ
diff --git a/test/odt/odt/citation.odt b/test/odt/odt/citation.odt
new file mode 100644
index 000000000..b6dbe649e
--- /dev/null
+++ b/test/odt/odt/citation.odt
Binary files differ
diff --git a/test/odt/odt/endnote.odt b/test/odt/odt/endnote.odt
new file mode 100644
index 000000000..c1aba45da
--- /dev/null
+++ b/test/odt/odt/endnote.odt
Binary files differ
diff --git a/test/odt/odt/expression.odt b/test/odt/odt/expression.odt
new file mode 100644
index 000000000..1085d7008
--- /dev/null
+++ b/test/odt/odt/expression.odt
Binary files differ
diff --git a/test/odt/odt/expressionUnevaluated.odt b/test/odt/odt/expressionUnevaluated.odt
new file mode 100644
index 000000000..64df660b6
--- /dev/null
+++ b/test/odt/odt/expressionUnevaluated.odt
Binary files differ
diff --git a/test/odt/odt/externalLink.odt b/test/odt/odt/externalLink.odt
new file mode 100644
index 000000000..1d8f55489
--- /dev/null
+++ b/test/odt/odt/externalLink.odt
Binary files differ
diff --git a/test/odt/odt/footnote.odt b/test/odt/odt/footnote.odt
new file mode 100644
index 000000000..74915c33c
--- /dev/null
+++ b/test/odt/odt/footnote.odt
Binary files differ
diff --git a/test/odt/odt/formula.odt b/test/odt/odt/formula.odt
new file mode 100644
index 000000000..5cf5f3451
--- /dev/null
+++ b/test/odt/odt/formula.odt
Binary files differ
diff --git a/test/odt/odt/headers.odt b/test/odt/odt/headers.odt
new file mode 100644
index 000000000..9212e9fb1
--- /dev/null
+++ b/test/odt/odt/headers.odt
Binary files differ
diff --git a/test/odt/odt/hiddenTextByStyle.odt b/test/odt/odt/hiddenTextByStyle.odt
new file mode 100644
index 000000000..79c40ca98
--- /dev/null
+++ b/test/odt/odt/hiddenTextByStyle.odt
Binary files differ
diff --git a/test/odt/odt/hiddenTextByVariable.odt b/test/odt/odt/hiddenTextByVariable.odt
new file mode 100644
index 000000000..ec793d466
--- /dev/null
+++ b/test/odt/odt/hiddenTextByVariable.odt
Binary files differ
diff --git a/test/odt/odt/horizontalRule.odt b/test/odt/odt/horizontalRule.odt
new file mode 100644
index 000000000..df09386bc
--- /dev/null
+++ b/test/odt/odt/horizontalRule.odt
Binary files differ
diff --git a/test/odt/odt/image.odt b/test/odt/odt/image.odt
new file mode 100644
index 000000000..c2fd1e407
--- /dev/null
+++ b/test/odt/odt/image.odt
Binary files differ
diff --git a/test/odt/odt/imageIndex.odt b/test/odt/odt/imageIndex.odt
new file mode 100644
index 000000000..220a49047
--- /dev/null
+++ b/test/odt/odt/imageIndex.odt
Binary files differ
diff --git a/test/odt/odt/imageWithCaption.odt b/test/odt/odt/imageWithCaption.odt
new file mode 100644
index 000000000..99b5b7af1
--- /dev/null
+++ b/test/odt/odt/imageWithCaption.odt
Binary files differ
diff --git a/test/odt/odt/inlinedCode.odt b/test/odt/odt/inlinedCode.odt
new file mode 100644
index 000000000..320375cc9
--- /dev/null
+++ b/test/odt/odt/inlinedCode.odt
Binary files differ
diff --git a/test/odt/odt/italic.odt b/test/odt/odt/italic.odt
new file mode 100644
index 000000000..d05cfeade
--- /dev/null
+++ b/test/odt/odt/italic.odt
Binary files differ
diff --git a/test/odt/odt/listBlocks.odt b/test/odt/odt/listBlocks.odt
new file mode 100644
index 000000000..5855e9920
--- /dev/null
+++ b/test/odt/odt/listBlocks.odt
Binary files differ
diff --git a/test/odt/odt/orderedListMixed.odt b/test/odt/odt/orderedListMixed.odt
new file mode 100644
index 000000000..2b593d635
--- /dev/null
+++ b/test/odt/odt/orderedListMixed.odt
Binary files differ
diff --git a/test/odt/odt/orderedListRoman.odt b/test/odt/odt/orderedListRoman.odt
new file mode 100644
index 000000000..0acfe92ce
--- /dev/null
+++ b/test/odt/odt/orderedListRoman.odt
Binary files differ
diff --git a/test/odt/odt/orderedListSimple.odt b/test/odt/odt/orderedListSimple.odt
new file mode 100644
index 000000000..7af312fcc
--- /dev/null
+++ b/test/odt/odt/orderedListSimple.odt
Binary files differ
diff --git a/test/odt/odt/paragraph.odt b/test/odt/odt/paragraph.odt
new file mode 100644
index 000000000..b635b2164
--- /dev/null
+++ b/test/odt/odt/paragraph.odt
Binary files differ
diff --git a/test/odt/odt/referenceAllInOne.odt b/test/odt/odt/referenceAllInOne.odt
new file mode 100644
index 000000000..e9f38e359
--- /dev/null
+++ b/test/odt/odt/referenceAllInOne.odt
Binary files differ
diff --git a/test/odt/odt/referenceToChapter.odt b/test/odt/odt/referenceToChapter.odt
new file mode 100644
index 000000000..d4be67b0b
--- /dev/null
+++ b/test/odt/odt/referenceToChapter.odt
Binary files differ
diff --git a/test/odt/odt/referenceToListItem.odt b/test/odt/odt/referenceToListItem.odt
new file mode 100644
index 000000000..be3aed245
--- /dev/null
+++ b/test/odt/odt/referenceToListItem.odt
Binary files differ
diff --git a/test/odt/odt/referenceToText.odt b/test/odt/odt/referenceToText.odt
new file mode 100644
index 000000000..19237e6f1
--- /dev/null
+++ b/test/odt/odt/referenceToText.odt
Binary files differ
diff --git a/test/odt/odt/simpleTable.odt b/test/odt/odt/simpleTable.odt
new file mode 100644
index 000000000..a00622918
--- /dev/null
+++ b/test/odt/odt/simpleTable.odt
Binary files differ
diff --git a/test/odt/odt/simpleTableWithCaption.odt b/test/odt/odt/simpleTableWithCaption.odt
new file mode 100644
index 000000000..ec6fac894
--- /dev/null
+++ b/test/odt/odt/simpleTableWithCaption.odt
Binary files differ
diff --git a/test/odt/odt/strikeout.odt b/test/odt/odt/strikeout.odt
new file mode 100644
index 000000000..3a3f1543a
--- /dev/null
+++ b/test/odt/odt/strikeout.odt
Binary files differ
diff --git a/test/odt/odt/table.odt b/test/odt/odt/table.odt
new file mode 100644
index 000000000..7a2b1cfae
--- /dev/null
+++ b/test/odt/odt/table.odt
Binary files differ
diff --git a/test/odt/odt/tableWithCaption.odt b/test/odt/odt/tableWithCaption.odt
new file mode 100644
index 000000000..d44654460
--- /dev/null
+++ b/test/odt/odt/tableWithCaption.odt
Binary files differ
diff --git a/test/odt/odt/tableWithContents.odt b/test/odt/odt/tableWithContents.odt
new file mode 100644
index 000000000..392e4202c
--- /dev/null
+++ b/test/odt/odt/tableWithContents.odt
Binary files differ
diff --git a/test/odt/odt/textMixedStyles.odt b/test/odt/odt/textMixedStyles.odt
new file mode 100644
index 000000000..382b338ad
--- /dev/null
+++ b/test/odt/odt/textMixedStyles.odt
Binary files differ
diff --git a/test/odt/odt/trackedChanges.odt b/test/odt/odt/trackedChanges.odt
new file mode 100644
index 000000000..5ac493ed7
--- /dev/null
+++ b/test/odt/odt/trackedChanges.odt
Binary files differ
diff --git a/test/odt/odt/underlined.odt b/test/odt/odt/underlined.odt
new file mode 100644
index 000000000..d645717b8
--- /dev/null
+++ b/test/odt/odt/underlined.odt
Binary files differ
diff --git a/test/odt/odt/unicode.odt b/test/odt/odt/unicode.odt
new file mode 100644
index 000000000..07e200425
--- /dev/null
+++ b/test/odt/odt/unicode.odt
Binary files differ
diff --git a/test/odt/odt/unorderedList.odt b/test/odt/odt/unorderedList.odt
new file mode 100644
index 000000000..50a950024
--- /dev/null
+++ b/test/odt/odt/unorderedList.odt
Binary files differ
diff --git a/test/odt/odt/variable.odt b/test/odt/odt/variable.odt
new file mode 100644
index 000000000..73ff5f648
--- /dev/null
+++ b/test/odt/odt/variable.odt
Binary files differ
diff --git a/test/opml-reader.native b/test/opml-reader.native
new file mode 100644
index 000000000..0819116ab
--- /dev/null
+++ b/test/opml-reader.native
@@ -0,0 +1,66 @@
+Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "Dave",Space,Str "Winer"]]),("date",MetaInlines [Str "Thu,",Space,Str "14",Space,Str "Jul",Space,Str "2005",Space,Str "23:41:05",Space,Str "GMT"]),("title",MetaInlines [Str "States"])]})
+[Header 1 ("",[],[]) [Str "United",Space,Str "States"]
+,Header 2 ("",[],[]) [Str "Far",Space,Str "West"]
+,Header 3 ("",[],[]) [Str "Alaska"]
+,Header 3 ("",[],[]) [Str "California"]
+,Header 3 ("",[],[]) [Str "Hawaii"]
+,Header 3 ("",[],[]) [Strong [Str "Nevada"]]
+,Para [Str "I",Space,Str "lived",Space,Str "here",Space,Emph [Str "once"],Str "."]
+,Para [Str "Loved",Space,Str "it."]
+,Header 4 ("",[],[]) [Link ("",[],[]) [Str "Reno"] ("http://www.reno.gov","")]
+,Header 4 ("",[],[]) [Str "Las",Space,Str "Vegas"]
+,Header 4 ("",[],[]) [Str "Ely"]
+,Header 4 ("",[],[]) [Str "Gerlach"]
+,Header 3 ("",[],[]) [Str "Oregon"]
+,Header 3 ("",[],[]) [Str "Washington"]
+,Header 2 ("",[],[]) [Str "Great",Space,Str "Plains"]
+,Header 3 ("",[],[]) [Str "Kansas"]
+,Header 3 ("",[],[]) [Str "Nebraska"]
+,Header 3 ("",[],[]) [Str "North",Space,Str "Dakota"]
+,Header 3 ("",[],[]) [Str "Oklahoma"]
+,Header 3 ("",[],[]) [Str "South",Space,Str "Dakota"]
+,Header 2 ("",[],[]) [Str "Mid-Atlantic"]
+,Header 3 ("",[],[]) [Str "Delaware"]
+,Header 3 ("",[],[]) [Str "Maryland"]
+,Header 3 ("",[],[]) [Str "New",Space,Str "Jersey"]
+,Header 3 ("",[],[]) [Str "New",Space,Str "York"]
+,Header 3 ("",[],[]) [Str "Pennsylvania"]
+,Header 2 ("",[],[]) [Str "Midwest"]
+,Header 3 ("",[],[]) [Str "Illinois"]
+,Header 3 ("",[],[]) [Str "Indiana"]
+,Header 3 ("",[],[]) [Str "Iowa"]
+,Header 3 ("",[],[]) [Str "Kentucky"]
+,Header 3 ("",[],[]) [Str "Michigan"]
+,Header 3 ("",[],[]) [Str "Minnesota"]
+,Header 3 ("",[],[]) [Str "Missouri"]
+,Header 3 ("",[],[]) [Str "Ohio"]
+,Header 3 ("",[],[]) [Str "West",Space,Str "Virginia"]
+,Header 3 ("",[],[]) [Str "Wisconsin"]
+,Header 2 ("",[],[]) [Str "Mountains"]
+,Header 3 ("",[],[]) [Str "Colorado"]
+,Header 3 ("",[],[]) [Str "Idaho"]
+,Header 3 ("",[],[]) [Str "Montana"]
+,Header 3 ("",[],[]) [Str "Utah"]
+,Header 3 ("",[],[]) [Str "Wyoming"]
+,Header 2 ("",[],[]) [Str "New",Space,Str "England"]
+,Header 3 ("",[],[]) [Str "Connecticut"]
+,Header 3 ("",[],[]) [Str "Maine"]
+,Header 3 ("",[],[]) [Str "Massachusetts"]
+,Header 3 ("",[],[]) [Str "New",Space,Str "Hampshire"]
+,Header 3 ("",[],[]) [Str "Rhode",Space,Str "Island"]
+,Header 3 ("",[],[]) [Str "Vermont"]
+,Header 2 ("",[],[]) [Str "South"]
+,Header 3 ("",[],[]) [Str "Alabama"]
+,Header 3 ("",[],[]) [Str "Arkansas"]
+,Header 3 ("",[],[]) [Str "Florida"]
+,Header 3 ("",[],[]) [Str "Georgia"]
+,Header 3 ("",[],[]) [Str "Louisiana"]
+,Header 3 ("",[],[]) [Str "Mississippi"]
+,Header 3 ("",[],[]) [Str "North",Space,Str "Carolina"]
+,Header 3 ("",[],[]) [Str "South",Space,Str "Carolina"]
+,Header 3 ("",[],[]) [Str "Tennessee"]
+,Header 3 ("",[],[]) [Str "Virginia"]
+,Header 2 ("",[],[]) [Str "Southwest"]
+,Header 3 ("",[],[]) [Str "Arizona"]
+,Header 3 ("",[],[]) [Str "New",Space,Str "Mexico"]
+,Header 3 ("",[],[]) [Str "Texas"]]
diff --git a/test/opml-reader.opml b/test/opml-reader.opml
new file mode 100644
index 000000000..18436e675
--- /dev/null
+++ b/test/opml-reader.opml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<opml version="2.0">
+ <head>
+ <title>States</title>
+ <dateModified>Thu, 14 Jul 2005 23:41:05 GMT</dateModified>
+ <ownerName>Dave Winer</ownerName>
+ </head>
+ <body>
+ <outline text="United States">
+ <outline text="Far West">
+ <outline text="Alaska"/>
+ <outline text="California"/>
+ <outline text="Hawaii"/>
+ <outline text="&lt;strong&gt;Nevada&lt;/strong&gt;" _note="I lived here *once*.&#10;&#10;Loved it.">
+ <outline text="Reno" created="Tue, 12 Jul 2005 23:56:35 GMT" type="link" url="http://www.reno.gov"/>
+ <outline text="Las Vegas" created="Tue, 12 Jul 2005 23:56:37 GMT"/>
+ <outline text="Ely" created="Tue, 12 Jul 2005 23:56:39 GMT"/>
+ <outline text="Gerlach" created="Tue, 12 Jul 2005 23:56:47 GMT"/>
+ </outline>
+ <outline text="Oregon"/>
+ <outline text="Washington"/>
+ </outline>
+ <outline text="Great Plains">
+ <outline text="Kansas"/>
+ <outline text="Nebraska"/>
+ <outline text="North Dakota"/>
+ <outline text="Oklahoma"/>
+ <outline text="South Dakota"/>
+ </outline>
+ <outline text="Mid-Atlantic">
+ <outline text="Delaware"/>
+ <outline text="Maryland"/>
+ <outline text="New Jersey"/>
+ <outline text="New York"/>
+ <outline text="Pennsylvania"/>
+ </outline>
+ <outline text="Midwest">
+ <outline text="Illinois"/>
+ <outline text="Indiana"/>
+ <outline text="Iowa"/>
+ <outline text="Kentucky"/>
+ <outline text="Michigan"/>
+ <outline text="Minnesota"/>
+ <outline text="Missouri"/>
+ <outline text="Ohio"/>
+ <outline text="West Virginia"/>
+ <outline text="Wisconsin"/>
+ </outline>
+ <outline text="Mountains">
+ <outline text="Colorado"/>
+ <outline text="Idaho"/>
+ <outline text="Montana"/>
+ <outline text="Utah"/>
+ <outline text="Wyoming"/>
+ </outline>
+ <outline text="New England">
+ <outline text="Connecticut"/>
+ <outline text="Maine"/>
+ <outline text="Massachusetts"/>
+ <outline text="New Hampshire"/>
+ <outline text="Rhode Island"/>
+ <outline text="Vermont"/>
+ </outline>
+ <outline text="South">
+ <outline text="Alabama"/>
+ <outline text="Arkansas"/>
+ <outline text="Florida"/>
+ <outline text="Georgia"/>
+ <outline text="Louisiana"/>
+ <outline text="Mississippi"/>
+ <outline text="North Carolina"/>
+ <outline text="South Carolina"/>
+ <outline text="Tennessee"/>
+ <outline text="Virginia"/>
+ </outline>
+ <outline text="Southwest">
+ <outline text="Arizona"/>
+ <outline text="New Mexico"/>
+ <outline text="Texas"/>
+ </outline>
+ </outline>
+ </body>
+</opml>
diff --git a/test/pipe-tables.native b/test/pipe-tables.native
new file mode 100644
index 000000000..63c2c17bc
--- /dev/null
+++ b/test/pipe-tables.native
@@ -0,0 +1,115 @@
+[Para [Str "Simplest",Space,Str "table",Space,Str "without",Space,Str "caption:"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[Plain [Str "Default1"]]
+ ,[Plain [Str "Default2"]]
+ ,[Plain [Str "Default3"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,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."] [AlignRight,AlignLeft,AlignDefault,AlignCenter] [0.0,0.0,0.0,0.0]
+ [[Plain [Str "Right"]]
+ ,[Plain [Str "Left"]]
+ ,[Plain [Str "Default"]]
+ ,[Plain [Str "Center"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption:"]
+,Table [] [AlignRight,AlignLeft,AlignCenter] [0.0,0.0,0.0]
+ [[Plain [Str "Right"]]
+ ,[Plain [Str "Left"]]
+ ,[Plain [Str "Center"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Headerless",Space,Str "table",Space,Str "without",Space,Str "caption:"]
+,Table [] [AlignRight,AlignLeft,AlignCenter] [0.0,0.0,0.0]
+ [[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Table",Space,Str "without",Space,Str "sides:"]
+,Table [] [AlignDefault,AlignRight] [0.0,0.0]
+ [[Plain [Str "Fruit"]]
+ ,[Plain [Str "Quantity"]]]
+ [[[Plain [Str "apple"]]
+ ,[Plain [Str "5"]]]
+ ,[[Plain [Str "orange"]]
+ ,[Plain [Str "17"]]]
+ ,[[Plain [Str "pear"]]
+ ,[Plain [Str "302"]]]]
+,Para [Str "One-column:"]
+,Table [] [AlignDefault] [0.0]
+ [[Plain [Str "hi"]]]
+ [[[Plain [Str "lo"]]]]
+,Para [Str "Header-less",Space,Str "one-column:"]
+,Table [] [AlignCenter] [0.0]
+ [[]]
+ [[[Plain [Str "hi"]]]]
+,Para [Str "Indented",Space,Str "left",Space,Str "column:"]
+,Table [] [AlignRight,AlignLeft] [0.0,0.0]
+ [[Plain [Str "Number",Space,Str "of",Space,Str "siblings"]]
+ ,[Plain [Str "Salary"]]]
+ [[[Plain [Str "3"]]
+ ,[Plain [Str "33"]]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "44"]]]]
+,Para [Str "Long",Space,Str "pipe",Space,Str "table",Space,Str "with",Space,Str "relative",Space,Str "widths:"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.125,0.1375,0.5]
+ [[Plain [Str "Default1"]]
+ ,[Plain [Str "Default2"]]
+ ,[Plain [Str "Default3"]]]
+ [[[Plain [Str "123"]]
+ ,[Plain [Str "this",Space,Str "is",Space,Str "a",Space,Str "table",Space,Str "cell"]]
+ ,[Plain [Str "and",Space,Str "this",Space,Str "is",Space,Str "a",Space,Str "really",Space,Str "long",Space,Str "table",Space,Str "cell",Space,Str "that",Space,Str "will",Space,Str "probably",Space,Str "need",Space,Str "wrapping"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]]
+,Para [Str "Pipe",Space,Str "table",Space,Str "with",Space,Str "no",Space,Str "body:"]
+,Table [] [AlignDefault] [0.0]
+ [[Plain [Str "Header"]]]
+ []
+,Para [Str "Pipe",Space,Str "table",Space,Str "with",Space,Str "tricky",Space,Str "cell",Space,Str "contents",Space,Str "(see",Space,Str "#2765):"]
+,Table [] [AlignLeft,AlignRight,AlignRight] [0.0,0.0,0.0]
+ [[]
+ ,[Plain [Str "IP_gene8-_1st"]]
+ ,[Plain [Str "IP_gene8+_1st"]]]
+ [[[Plain [Str "IP_gene8-_1st"]]
+ ,[Plain [Str "1.0000000"]]
+ ,[Plain [Str "0.4357325"]]]
+ ,[[Plain [Str "IP_gene8+_1st"]]
+ ,[Plain [Str "0.4357325"]]
+ ,[Plain [Str "1.0000000"]]]
+ ,[[Plain [Str "foo",Code ("",[],[]) "bar|baz"]]
+ ,[Plain [Str "and|escaped"]]
+ ,[Plain [Str "3.0000000"]]]]]
diff --git a/test/pipe-tables.txt b/test/pipe-tables.txt
new file mode 100644
index 000000000..c27c71113
--- /dev/null
+++ b/test/pipe-tables.txt
@@ -0,0 +1,82 @@
+Simplest table without caption:
+
+| Default1 | Default2 | Default3 |
+ |----------|----------|----------|
+|12|12|12|
+|123|123|123|
+|1|1|1|
+
+Simple table with caption:
+
+| Right | Left | Default | Center |
+| ----: | :--- | ------- | :----: |
+| 12 | 12 | 12 | 12 |
+| 123 | 123 | 123 | 123 |
+| 1 | 1 | 1 | 1 |
+
+ : Demonstration of simple table syntax.
+
+Simple table without caption:
+
+| Right | Left | Center |
+|------:|:-----|:------:|
+|12|12|12|
+|123|123|123|
+|1|1|1|
+
+
+Headerless table without caption:
+
+| | | |
+|------:|:-----|:------:|
+|12|12|12|
+|123|123|123|
+|1|1|1|
+
+Table without sides:
+
+Fruit |Quantity
+------|-------:
+apple | 5
+orange| 17
+pear | 302
+
+One-column:
+
+|hi|
+|--|
+|lo|
+
+Header-less one-column:
+
+| |
+|:-:|
+|hi|
+
+Indented left column:
+
+Number of siblings | Salary
+------------------:|:------
+ 3 | 33
+ 4 | 44
+
+Long pipe table with relative widths:
+
+| Default1 | Default2 | Default3 |
+ |---------|----------|---------------------------------------|
+|123|this is a table cell|and this is a really long table cell that will probably need wrapping|
+|123|123|123|
+
+Pipe table with no body:
+
+| Header |
+| ------ |
+
+Pipe table with tricky cell contents (see #2765):
+
+| | IP_gene8-_1st| IP_gene8+_1st|
+|:--------------|-------------:|-------------:|
+|IP_gene8-_1st | 1.0000000| 0.4357325|
+|IP_gene8+_1st | 0.4357325| 1.0000000|
+|foo`bar|baz` | and\|escaped | 3.0000000|
+
diff --git a/test/rst-reader.native b/test/rst-reader.native
new file mode 100644
index 000000000..bc4641a3f
--- /dev/null
+++ b/test/rst-reader.native
@@ -0,0 +1,335 @@
+Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("revision",MetaBlocks [Para [Str "3"]]),("subtitle",MetaInlines [Str "Subtitle"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])]})
+[Header 1 ("level-one-header",[],[]) [Str "Level",Space,Str "one",Space,Str "header"]
+,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",SoftBreak,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
+,Header 2 ("level-two-header",[],[]) [Str "Level",Space,Str "two",Space,Str "header"]
+,Header 3 ("level-three",[],[]) [Str "Level",Space,Str "three"]
+,Header 4 ("level-four-with-emphasis",[],[]) [Str "Level",Space,Str "four",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 5 ("level-five",[],[]) [Str "Level",Space,Str "five"]
+,Header 1 ("paragraphs",[],[]) [Str "Paragraphs"]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
+,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",SoftBreak,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",SoftBreak,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",SoftBreak,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",SoftBreak,Str "list",Space,Str "item."]
+,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",SoftBreak,Str "*",Space,Str "criminey."]
+,Para [Str "Horizontal",Space,Str "rule:"]
+,HorizontalRule
+,Para [Str "Another:"]
+,HorizontalRule
+,Header 1 ("block-quotes",[],[]) [Str "Block",Space,Str "Quotes"]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "block",Space,Str "quote:"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",SoftBreak,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]]
+,Para [Str "Here\8217s",Space,Str "another,",Space,Str "differently",Space,Str "indented:"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",SoftBreak,Str "It\8217s",Space,Str "indented",Space,Str "with",Space,Str "a",Space,Str "tab."]
+ ,Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
+ ,Para [Str "List",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
+ ,OrderedList (1,Decimal,Period)
+ [[Plain [Str "item",Space,Str "one"]]
+ ,[Plain [Str "item",Space,Str "two"]]]
+ ,Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
+ ,BlockQuote
+ [Para [Str "nested"]
+ ,BlockQuote
+ [Para [Str "nested"]]]]
+,Header 1 ("code-blocks",[],[]) [Str "Code",Space,Str "Blocks"]
+,Para [Str "Code:"]
+,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}"
+,CodeBlock ("",[],[]) "this code block is indented by one tab"
+,Para [Str "And:"]
+,CodeBlock ("",[],[]) "this block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
+,Para [Str "And:"]
+,CodeBlock ("",["sourceCode","python"],[]) "def my_function(x):\n return x + 1"
+,Header 1 ("lists",[],[]) [Str "Lists"]
+,Header 2 ("unordered",[],[]) [Str "Unordered"]
+,Para [Str "Asterisks",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "asterisk",Space,Str "1"]]
+ ,[Plain [Str "asterisk",Space,Str "2"]]
+ ,[Plain [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Asterisks",Space,Str "loose:"]
+,BulletList
+ [[Plain [Str "asterisk",Space,Str "1"]]
+ ,[Plain [Str "asterisk",Space,Str "2"]]
+ ,[Plain [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "Plus",Space,Str "1"]]
+ ,[Plain [Str "Plus",Space,Str "2"]]
+ ,[Plain [Str "Plus",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "loose:"]
+,BulletList
+ [[Plain [Str "Plus",Space,Str "1"]]
+ ,[Plain [Str "Plus",Space,Str "2"]]
+ ,[Plain [Str "Plus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "Minus",Space,Str "1"]]
+ ,[Plain [Str "Minus",Space,Str "2"]]
+ ,[Plain [Str "Minus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "loose:"]
+,BulletList
+ [[Plain [Str "Minus",Space,Str "1"]]
+ ,[Plain [Str "Minus",Space,Str "2"]]
+ ,[Plain [Str "Minus",Space,Str "3"]]]
+,Header 2 ("ordered",[],[]) [Str "Ordered"]
+,Para [Str "Tight:"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second"]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "and:"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "One"]]
+ ,[Plain [Str "Two"]]
+ ,[Plain [Str "Three"]]]
+,Para [Str "Loose",Space,Str "using",Space,Str "tabs:"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second"]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "and",Space,Str "using",Space,Str "spaces:"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "One"]]
+ ,[Plain [Str "Two"]]
+ ,[Plain [Str "Three"]]]
+,Para [Str "Multiple",Space,Str "paragraphs:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]
+ ,Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",SoftBreak,Str "back."]]
+ ,[Plain [Str "Item",Space,Str "2."]]
+ ,[Plain [Str "Item",Space,Str "3."]]]
+,Para [Str "Nested:"]
+,BulletList
+ [[Plain [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]]]]]]]
+,Para [Str "Here\8217s",Space,Str "another:"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "First"]]
+ ,[Para [Str "Second:"]
+ ,BlockQuote
+ [BulletList
+ [[Plain [Str "Fee"]]
+ ,[Plain [Str "Fie"]]
+ ,[Plain [Str "Foe"]]]]]
+ ,[Plain [Str "Third"]]]
+,Header 2 ("fancy-list-markers",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"]
+,OrderedList (2,Decimal,TwoParens)
+ [[Plain [Str "begins",Space,Str "with",Space,Str "2"]]
+ ,[Para [Str "and",Space,Str "now",Space,Str "3"]
+ ,Para [Str "with",Space,Str "a",Space,Str "continuation"]
+ ,OrderedList (4,LowerRoman,Period)
+ [[Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",Space,Str "starting",Space,Str "with",Space,Str "4"]]
+ ,[Plain [Str "more",Space,Str "items"]
+ ,OrderedList (1,UpperAlpha,TwoParens)
+ [[Plain [Str "a",Space,Str "subsublist"]]
+ ,[Plain [Str "a",Space,Str "subsublist"]]]]]]]
+,Para [Str "Nesting:"]
+,OrderedList (1,UpperAlpha,Period)
+ [[Plain [Str "Upper",Space,Str "Alpha"]
+ ,OrderedList (1,UpperRoman,Period)
+ [[Plain [Str "Upper",Space,Str "Roman."]
+ ,OrderedList (6,Decimal,TwoParens)
+ [[Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
+ ,OrderedList (3,LowerAlpha,OneParen)
+ [[Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]
+,Para [Str "Autonumbering:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Autonumber."]]
+ ,[Plain [Str "More."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Nested."]]]]]
+,Para [Str "Autonumbering",Space,Str "with",Space,Str "explicit",Space,Str "start:"]
+,OrderedList (4,LowerAlpha,TwoParens)
+ [[Plain [Str "item",Space,Str "1"]]
+ ,[Plain [Str "item",Space,Str "2"]]]
+,Header 2 ("definition",[],[]) [Str "Definition"]
+,DefinitionList
+ [([Str "term",Space,Str "1"],
+ [[Para [Str "Definition",Space,Str "1."]]])
+ ,([Str "term",Space,Str "2"],
+ [[Para [Str "Definition",Space,Str "2,",Space,Str "paragraph",Space,Str "1."]
+ ,Para [Str "Definition",Space,Str "2,",Space,Str "paragraph",Space,Str "2."]]])
+ ,([Str "term",Space,Str "with",Space,Emph [Str "emphasis"]],
+ [[Para [Str "Definition",Space,Str "3."]]])]
+,Header 1 ("field-lists",[],[]) [Str "Field",Space,Str "Lists"]
+,BlockQuote
+ [DefinitionList
+ [([Str "address"],
+ [[Para [Str "61",Space,Str "Main",Space,Str "St."]]])
+ ,([Str "city"],
+ [[Para [Emph [Str "Nowhere"],Str ",",Space,Str "MA,",SoftBreak,Str "USA"]]])
+ ,([Str "phone"],
+ [[Para [Str "123-4567"]]])]]
+,DefinitionList
+ [([Str "address"],
+ [[Para [Str "61",Space,Str "Main",Space,Str "St."]]])
+ ,([Str "city"],
+ [[Para [Emph [Str "Nowhere"],Str ",",Space,Str "MA,",SoftBreak,Str "USA"]]])
+ ,([Str "phone"],
+ [[Para [Str "123-4567"]]])]
+,Header 1 ("html-blocks",[],[]) [Str "HTML",Space,Str "Blocks"]
+,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]
+,RawBlock (Format "html") "<div>foo</div>"
+,Para [Str "Now,",Space,Str "nested:"]
+,RawBlock (Format "html") "<div>\n <div>\n <div>\n foo\n </div>\n </div>\n</div>"
+,Header 1 ("latex-block",[],[]) [Str "LaTeX",Space,Str "Block"]
+,RawBlock (Format "latex") "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"
+,Header 1 ("inline-markup",[],[]) [Str "Inline",Space,Str "Markup"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ".",Space,Str "This",Space,Str "is",Space,Strong [Str "strong"],Str "."]
+,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]
+,Para [Str "This",Space,Str "is",Subscript [Str "subscripted"],Space,Str "and",Space,Str "this",Space,Str "is",Space,Superscript [Str "superscripted"],Str "."]
+,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
+,BulletList
+ [[Plain [Str "I",Space,Str "hat:",Space,Str "\206"]]
+ ,[Plain [Str "o",Space,Str "umlaut:",Space,Str "\246"]]
+ ,[Plain [Str "section:",Space,Str "\167"]]
+ ,[Plain [Str "set",Space,Str "membership:",Space,Str "\8712"]]
+ ,[Plain [Str "copyright:",Space,Str "\169"]]]
+,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]
+,Para [Str "This",Space,Str "&",Space,Str "that."]
+,Para [Str "4",Space,Str "<",Space,Str "5."]
+,Para [Str "6",Space,Str ">",Space,Str "5."]
+,Para [Str "Backslash:",Space,Str "\\"]
+,Para [Str "Backtick:",Space,Str "`"]
+,Para [Str "Asterisk:",Space,Str "*"]
+,Para [Str "Underscore:",Space,Str "_"]
+,Para [Str "Left",Space,Str "brace:",Space,Str "{"]
+,Para [Str "Right",Space,Str "brace:",Space,Str "}"]
+,Para [Str "Left",Space,Str "bracket:",Space,Str "["]
+,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]
+,Para [Str "Left",Space,Str "paren:",Space,Str "("]
+,Para [Str "Right",Space,Str "paren:",Space,Str ")"]
+,Para [Str "Greater-than:",Space,Str ">"]
+,Para [Str "Hash:",Space,Str "#"]
+,Para [Str "Period:",Space,Str "."]
+,Para [Str "Bang:",Space,Str "!"]
+,Para [Str "Plus:",Space,Str "+"]
+,Para [Str "Minus:",Space,Str "-"]
+,Header 1 ("links",[],[]) [Str "Links"]
+,Para [Str "Explicit:",Space,Str "a",Space,Link ("",[],[]) [Str "URL"] ("/url/",""),Str "."]
+,Para [Str "Explicit",Space,Str "with",Space,Str "no",Space,Str "label:",Space,Link ("",[],[]) [Str "foo"] ("foo",""),Str "."]
+,Para [Str "Two",Space,Str "anonymous",Space,Str "links:",Space,Link ("",[],[]) [Str "the",Space,Str "first"] ("/url1/",""),Space,Str "and",Space,Link ("",[],[]) [Str "the",Space,Str "second"] ("/url2/","")]
+,Para [Str "Reference",Space,Str "links:",Space,Link ("",[],[]) [Str "link1"] ("/url1/",""),Space,Str "and",Space,Link ("",[],[]) [Str "link2"] ("/url2/",""),Space,Str "and",Space,Link ("",[],[]) [Str "link1"] ("/url1/",""),Space,Str "again."]
+,Para [Str "Another",Space,Link ("",[],[]) [Str "style",Space,Str "of",Space,Str "reference",Space,Str "link"] ("/url1/",""),Str "."]
+,Para [Str "Here\8217s",Space,Str "a",Space,Link ("",[],[]) [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link ("",[],[]) [Str "AT&T"] ("/url/",""),Str "."]
+,Para [Str "Autolinks:",Space,Link ("",[],[]) [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2",""),Space,Str "and",Space,Link ("",[],[]) [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net",""),Str "."]
+,Para [Str "But",Space,Str "not",Space,Str "here:"]
+,CodeBlock ("",[],[]) "http://example.com/"
+,Header 1 ("images",[],[]) [Str "Images"]
+,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
+,Para [Image ("",[],[]) [Str "image"] ("lalune.jpg","")]
+,Para [Image ("",[],[("height","2343")]) [Str "Voyage dans la Lune"] ("lalune.jpg","")]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image ("",[],[]) [Str "movie"] ("movie.jpg",""),Space,Str "icon."]
+,Para [Str "And",Space,Str "an",Space,Link ("",[],[]) [Image ("",[],[]) [Str "A movie"] ("movie.jpg","")] ("/url",""),Str "."]
+,Header 1 ("comments",[],[]) [Str "Comments"]
+,Para [Str "First",Space,Str "paragraph"]
+,Para [Str "Another",Space,Str "paragraph"]
+,Para [Str "A",Space,Str "third",Space,Str "paragraph"]
+,Header 1 ("line-blocks",[],[]) [Str "Line",Space,Str "blocks"]
+,LineBlock
+ [[Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be"]
+ ,[Str "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,"]
+ ,[Str "\160\160\160\160\160\160\160\160when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,"]
+ ,[Str "\160\160\160\160\160\160\160\160\160\160\160\160due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]
+ ,[]
+ ,[Str "Continuation",Space,Str "line"]
+ ,[Str "\160\160and",Space,Str "another"]]
+,Header 1 ("simple-tables",[],[]) [Str "Simple",Space,Str "Tables"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[Plain [Str "col",Space,Str "1"]]
+ ,[Plain [Str "col",Space,Str "2"]]
+ ,[Plain [Str "col",Space,Str "3"]]]
+ [[[Plain [Str "r1",Space,Str "a"]]
+ ,[Plain [Str "b"]]
+ ,[Plain [Str "c"]]]
+ ,[[Plain [Str "r2",Space,Str "d"]]
+ ,[Plain [Str "e"]]
+ ,[Plain [Str "f"]]]]
+,Para [Str "Headless"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "r1",Space,Str "a"]]
+ ,[Plain [Str "b"]]
+ ,[Plain [Str "c"]]]
+ ,[[Plain [Str "r2",Space,Str "d"]]
+ ,[Plain [Str "e"]]
+ ,[Plain [Str "f"]]]]
+,Header 1 ("grid-tables",[],[]) [Str "Grid",Space,Str "Tables"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625]
+ [[Plain [Str "col",Space,Str "1"]]
+ ,[Plain [Str "col",Space,Str "2"]]
+ ,[Plain [Str "col",Space,Str "3"]]]
+ [[[Plain [Str "r1",Space,Str "a",SoftBreak,Str "r1",Space,Str "bis"]]
+ ,[Plain [Str "b",SoftBreak,Str "b",Space,Str "2"]]
+ ,[Plain [Str "c",SoftBreak,Str "c",Space,Str "2"]]]
+ ,[[Plain [Str "r2",Space,Str "d"]]
+ ,[Plain [Str "e"]]
+ ,[Plain [Str "f"]]]]
+,Para [Str "Headless"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625]
+ [[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "r1",Space,Str "a",SoftBreak,Str "r1",Space,Str "bis"]]
+ ,[Plain [Str "b",SoftBreak,Str "b",Space,Str "2"]]
+ ,[Plain [Str "c",SoftBreak,Str "c",Space,Str "2"]]]
+ ,[[Plain [Str "r2",Space,Str "d"]]
+ ,[Plain [Str "e"]]
+ ,[Plain [Str "f"]]]]
+,Para [Str "Spaces",Space,Str "at",Space,Str "ends",Space,Str "of",Space,Str "lines"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625]
+ [[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "r1",Space,Str "a",SoftBreak,Str "r1",Space,Str "bis"]]
+ ,[Plain [Str "b",SoftBreak,Str "b",Space,Str "2"]]
+ ,[Plain [Str "c",SoftBreak,Str "c",Space,Str "2"]]]
+ ,[[Plain [Str "r2",Space,Str "d"]]
+ ,[Plain [Str "e"]]
+ ,[Plain [Str "f"]]]]
+,Para [Str "Multiple",Space,Str "blocks",Space,Str "in",Space,Str "a",Space,Str "cell"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2375,0.15,0.1625]
+ [[]
+ ,[]
+ ,[]]
+ [[[Para [Str "r1",Space,Str "a"]
+ ,Para [Str "r1",Space,Str "bis"]]
+ ,[BulletList
+ [[Plain [Str "b"]]
+ ,[Plain [Str "b",Space,Str "2"]]
+ ,[Plain [Str "b",Space,Str "2"]]]]
+ ,[Plain [Str "c",SoftBreak,Str "c",Space,Str "2",SoftBreak,Str "c",Space,Str "2"]]]]
+,Header 1 ("footnotes",[],[]) [Str "Footnotes"]
+,Para [Note [Para [Str "Note",Space,Str "with",Space,Str "one",Space,Str "line."]]]
+,Para [Note [Para [Str "Note",Space,Str "with",SoftBreak,Str "continuation",Space,Str "line."]]]
+,Para [Note [Para [Str "Note",Space,Str "with"],Para [Str "continuation",Space,Str "block."]]]
+,Para [Note [Para [Str "Note",Space,Str "with",SoftBreak,Str "continuation",Space,Str "line"],Para [Str "and",Space,Str "a",Space,Str "second",Space,Str "para."]]]
+,Para [Str "Not",Space,Str "in",Space,Str "note."]
+,Header 1 ("math",[],[]) [Str "Math"]
+,Para [Str "Some",Space,Str "inline",Space,Str "math",Space,Math InlineMath "E=mc^2",Str ".",Space,Str "Now",Space,Str "some",SoftBreak,Str "display",Space,Str "math:"]
+,Para [Math DisplayMath "E=mc^2"]
+,Para [Math DisplayMath "E = mc^2"]
+,Para [Math DisplayMath "E = mc^2",Math DisplayMath "\\alpha = \\beta"]
+,Para [Math DisplayMath "E &= mc^2\\\\\nF &= \\pi E",Math DisplayMath "F &= \\gamma \\alpha^2"]
+,Para [Str "All",Space,Str "done."]
+,Header 1 ("default-role",[],[]) [Str "Default-Role"]
+,Para [Str "Try",Space,Str "changing",Space,Str "the",Space,Str "default",Space,Str "role",Space,Str "to",Space,Str "a",Space,Str "few",Space,Str "different",Space,Str "things."]
+,Header 2 ("doesnt-break-title-parsing",[],[]) [Str "Doesn\8217t",Space,Str "Break",Space,Str "Title",Space,Str "Parsing"]
+,Para [Str "Inline",Space,Str "math:",Space,Math InlineMath "E=mc^2",Space,Str "or",Space,Math InlineMath "E=mc^2",Space,Str "or",Space,Math InlineMath "E=mc^2",Str ".",SoftBreak,Str "Other",Space,Str "roles:",Space,Superscript [Str "super"],Str ",",Space,Subscript [Str "sub"],Str "."]
+,Para [Math DisplayMath "\\alpha = beta",Math DisplayMath "E = mc^2"]
+,Para [Str "Some",Space,Superscript [Str "of"],Space,Str "these",Space,Superscript [Str "words"],Space,Str "are",Space,Str "in",Space,Superscript [Str "superscript"],Str "."]
+,Para [Str "Reset",Space,Str "default-role",Space,Str "to",Space,Str "the",Space,Str "default",Space,Str "default."]
+,Para [Str "And",Space,Str "now",Space,Str "some-invalid-string-3231231",Space,Str "is",Space,Str "nonsense."]
+,Para [Str "And",Space,Str "now",Space,Str "with",Space,RawInline (Format "html") "<b>inline</b> <span id=\"test\">HTML</span>",Str "."]
+,Para [Str "And",Space,Str "some",Space,Str "inline",Space,Str "haskell",Space,Code ("",["haskell","sourceCode"],[]) "fmap id [1,2..10]",Str "."]
+,Para [Str "Indirect",Space,Str "python",Space,Str "role",Space,Code ("",["py","python","indirect","sourceCode"],[]) "[x*x for x in [1,2,3,4,5]]",Str "."]
+,Para [Str "Different",Space,Str "indirect",Space,Str "C",Space,Code ("",["c","different-indirect","sourceCode"],[]) "int x = 15;",Str "."]
+,Header 2 ("literal-symbols",[],[]) [Str "Literal",Space,Str "symbols"]
+,Para [Str "2*2",Space,Str "=",Space,Str "4*1"]]
diff --git a/test/rst-reader.rst b/test/rst-reader.rst
new file mode 100644
index 000000000..cfe959f2d
--- /dev/null
+++ b/test/rst-reader.rst
@@ -0,0 +1,633 @@
+Pandoc Test Suite
+#################
+Subtitle
+^^^^^^^^
+
+:Authors: John MacFarlane; Anonymous
+:Date: July 17, 2006
+:Revision: 3
+
+Level one header
+================
+
+This is a set of tests for pandoc. Most of them are adapted from
+John Gruber's markdown test suite.
+
+Level two header
+----------------
+
+Level three
++++++++++++
+
+Level four with *emphasis*
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Level five
+''''''''''
+
+Paragraphs
+==========
+
+Here's a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version
+8. This line turns into a list item.
+Because a hard-wrapped line in the
+middle of a paragraph looked like a
+list item.
+
+Here's one with a bullet.
+* criminey.
+
+Horizontal rule:
+
+-----
+
+Another:
+
+****
+
+Block Quotes
+============
+
+Here's a block quote:
+
+ This is a block quote.
+ It is pretty short.
+
+Here's another, differently indented:
+
+ This is a block quote.
+ It's indented with a tab.
+
+ Code in a block quote::
+
+ sub status {
+ print "working";
+ }
+
+ List in a block quote:
+
+ 1. item one
+ 2. item two
+
+ Nested block quotes:
+
+ nested
+
+ nested
+
+Code Blocks
+===========
+
+Code:
+
+::
+
+ ---- (should be four hyphens)
+
+ sub status {
+ print "working";
+ }
+
+::
+
+ this code block is indented by one tab
+
+And::
+
+ this block is indented by two tabs
+
+ These should not be escaped: \$ \\ \> \[ \{
+
+And:
+
+.. code-block:: python
+
+ def my_function(x):
+ return x + 1
+
+Lists
+=====
+
+Unordered
+---------
+
+Asterisks tight:
+
+* asterisk 1
+* asterisk 2
+* asterisk 3
+
+Asterisks loose:
+
+* asterisk 1
+
+* asterisk 2
+
+* asterisk 3
+
+Pluses tight:
+
++ Plus 1
++ Plus 2
++ Plus 3
+
+Pluses loose:
+
++ Plus 1
+
++ Plus 2
+
++ Plus 3
+
+Minuses tight:
+
+- Minus 1
+- Minus 2
+- Minus 3
+
+Minuses loose:
+
+- Minus 1
+
+- Minus 2
+
+- Minus 3
+
+Ordered
+-------
+
+Tight:
+
+1. First
+2. Second
+3. Third
+
+and:
+
+1. One
+2. Two
+3. Three
+
+Loose using tabs:
+
+1. First
+
+2. Second
+
+3. Third
+
+and using spaces:
+
+1. One
+
+2. Two
+
+3. Three
+
+Multiple paragraphs:
+
+1. Item 1, graf one.
+
+ Item 1. graf two. The quick brown fox jumped over the lazy dog's
+ back.
+
+2. Item 2.
+
+3. Item 3.
+
+Nested:
+
+* Tab
+
+ * Tab
+
+ * Tab
+
+Here's another:
+
+1. First
+
+2. Second:
+
+ * Fee
+ * Fie
+ * Foe
+
+3. Third
+
+Fancy list markers
+------------------
+
+(2) begins with 2
+(3) and now 3
+
+ with a continuation
+
+ iv. sublist with roman numerals, starting with 4
+ v. more items
+
+ (A) a subsublist
+ (B) a subsublist
+
+Nesting:
+
+A. Upper Alpha
+
+ I. Upper Roman.
+
+ (6) Decimal start with 6
+
+ c) Lower alpha with paren
+
+Autonumbering:
+
+#. Autonumber.
+#. More.
+
+ #. Nested.
+
+Autonumbering with explicit start:
+
+(d) item 1
+(#) item 2
+
+Definition
+----------
+
+term 1
+ Definition 1.
+
+term 2
+ Definition 2, paragraph 1.
+
+ Definition 2, paragraph 2.
+
+term with *emphasis*
+ Definition 3.
+
+Field Lists
+===========
+
+ :address: 61 Main St.
+ :city: *Nowhere*, MA,
+ USA
+ :phone: 123-4567
+
+:address: 61 Main St.
+:city: *Nowhere*, MA,
+ USA
+:phone:
+ 123-4567
+
+HTML Blocks
+===========
+
+Simple block on one line:
+
+.. raw:: html
+
+ <div>foo</div>
+
+Now, nested:
+
+.. raw:: html
+
+ <div>
+ <div>
+ <div>
+ foo
+ </div>
+ </div>
+ </div>
+
+LaTeX Block
+===========
+
+.. raw:: latex
+
+ \begin{tabular}{|l|l|}\hline
+ Animal & Number \\ \hline
+ Dog & 2 \\
+ Cat & 1 \\ \hline
+ \end{tabular}
+
+Inline Markup
+=============
+
+This is *emphasized*. This is **strong**.
+
+This is code: ``>``, ``$``, ``\``, ``\$``, ``<html>``.
+
+This is\ :sub:`subscripted` and this is :sup:`superscripted`\ .
+
+Special Characters
+==================
+
+Here is some unicode:
+
+- I hat: Î
+- o umlaut: ö
+- section: §
+- set membership: ∈
+- copyright: ©
+
+AT&T has an ampersand in their name.
+
+This & that.
+
+4 < 5.
+
+6 > 5.
+
+Backslash: \\
+
+Backtick: \`
+
+Asterisk: \*
+
+Underscore: \_
+
+Left brace: \{
+
+Right brace: \}
+
+Left bracket: \[
+
+Right bracket: \]
+
+Left paren: \(
+
+Right paren: \)
+
+Greater-than: \>
+
+Hash: \#
+
+Period: \.
+
+Bang: \!
+
+Plus: \+
+
+Minus: \-
+
+Links
+=====
+
+Explicit: a `URL </url/>`_.
+
+Explicit with no label: `<foo>`_.
+
+Two anonymous links: `the first`__ and `the second`__
+
+__ /url1/
+__ /url2/
+
+Reference links: `link1`_ and `link2`_ and link1_ again.
+
+.. _link1: /url1/
+.. _`link2`: /url2/
+
+Another `style of reference link <link1_>`_.
+
+Here's a `link with an ampersand in the URL`_.
+
+Here's a link with an amersand in the link text: `AT&T </url/>`_.
+
+.. _link with an ampersand in the URL: http://example.com/?foo=1&bar=2
+
+Autolinks: http://example.com/?foo=1&bar=2 and nobody@nowhere.net.
+
+But not here::
+
+ http://example.com/
+
+Images
+======
+
+From "Voyage dans la Lune" by Georges Melies (1902):
+
+.. image:: lalune.jpg
+
+.. image:: lalune.jpg
+ :height: 2343
+ :alt: Voyage dans la Lune
+
+Here is a movie |movie| icon.
+
+.. |movie| image:: movie.jpg
+
+And an |image with a link|.
+
+.. |image with a link| image:: movie.jpg
+ :alt: A movie
+ :target: /url
+
+Comments
+========
+
+First paragraph
+
+.. comment
+
+..
+ Comment block, should not appear in output
+ as defined by reStructuredText
+
+Another paragraph
+
+..
+ Another comment block.
+
+ This one spans several
+ text elements.
+
+ It doesn't end until
+ indentation is restored to the
+ preceding level.
+
+A third paragraph
+
+Line blocks
+===========
+
+| But can a bee be said to be
+| or not to be an entire bee,
+| when half the bee is not a bee,
+| due to some ancient injury?
+|
+| Continuation
+ line
+| and
+ another
+
+Simple Tables
+=============
+
+================== =========== ==========
+col 1 col 2 col 3
+================== =========== ==========
+r1 a b c
+r2 d e f
+================== =========== ==========
+
+Headless
+
+================== =========== ==========
+r1 a b c
+r2 d e f
+================== =========== ==========
+
+
+Grid Tables
+===========
+
++------------------+-----------+------------+
+| col 1 | col 2 | col 3 |
++==================+===========+============+
+| r1 a | b | c |
+| r1 bis | b 2 | c 2 |
++------------------+-----------+------------+
+| r2 d | e | f |
++------------------+-----------+------------+
+
+Headless
+
++------------------+-----------+------------+
+| r1 a | b | c |
+| r1 bis | b 2 | c 2 |
++------------------+-----------+------------+
+| r2 d | e | f |
++------------------+-----------+------------+
+
+Spaces at ends of lines
+
++------------------+-----------+------------+
+| r1 a | b | c |
+| r1 bis | b 2 | c 2 |
++------------------+-----------+------------+
+| r2 d | e | f |
++------------------+-----------+------------+
+
+Multiple blocks in a cell
+
++------------------+-----------+------------+
+| r1 a | - b | c |
+| | - b 2 | c 2 |
+| r1 bis | - b 2 | c 2 |
++------------------+-----------+------------+
+
+Footnotes
+=========
+
+[1]_
+
+[#]_
+
+[#]_
+
+[*]_
+
+.. [1] Note with one line.
+
+.. [#] Note with
+ continuation line.
+
+.. [#] Note with
+
+ continuation block.
+
+.. [*] Note with
+ continuation line
+
+ and a second para.
+
+Not in note.
+
+Math
+====
+
+Some inline math :math:`E=mc^2`\ . Now some
+display math:
+
+.. math:: E=mc^2
+
+.. math::
+
+ E = mc^2
+
+.. math::
+
+ E = mc^2
+
+ \alpha = \beta
+
+.. math::
+ :label: hithere
+ :nowrap:
+
+ E &= mc^2\\
+ F &= \pi E
+
+ F &= \gamma \alpha^2
+
+All done.
+
+Default-Role
+============
+
+Try changing the default role to a few different things.
+
+.. default-role:: math
+
+Doesn't Break Title Parsing
+---------------------------
+
+Inline math: `E=mc^2` or :math:`E=mc^2` or `E=mc^2`:math:.
+Other roles: :sup:`super`, `sub`:sub:.
+
+.. math::
+ \alpha = beta
+
+ E = mc^2
+
+.. default-role:: sup
+
+Some `of` these :sup:`words` are in `superscript`:sup:.
+
+Reset default-role to the default default.
+
+.. default-role::
+
+And now `some-invalid-string-3231231` is nonsense.
+
+.. role:: html(raw)
+ :format: html
+
+And now with :html:`<b>inline</b> <span id="test">HTML</span>`.
+
+.. role:: haskell(code)
+ :language: haskell
+
+And some inline haskell :haskell:`fmap id [1,2..10]`.
+
+.. role:: indirect(code)
+
+.. role:: py(indirect)
+ :language: python
+
+Indirect python role :py:`[x*x for x in [1,2,3,4,5]]`.
+
+.. role:: different-indirect(code)
+ :language: c
+
+.. role:: c(different-indirect)
+
+Different indirect C :c:`int x = 15;`.
+
+Literal symbols
+---------------
+
+2*2 = 4*1
diff --git a/test/s5-basic.html b/test/s5-basic.html
new file mode 100644
index 000000000..6fb57e4aa
--- /dev/null
+++ b/test/s5-basic.html
@@ -0,0 +1,56 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <meta name="generator" content="pandoc" />
+ <meta name="version" content="S5 1.1" />
+ <meta name="author" content="Sam Smith" />
+ <meta name="version" content="S5 1.1" />
+ <meta name="author" content="Jen Jones" />
+ <meta name="date" content="2006-07-15" />
+ <title>My S5 Document</title>
+ <style type="text/css">code{white-space: pre;}</style>
+ <!-- configuration parameters -->
+ <meta name="defaultView" content="slideshow" />
+ <meta name="controlVis" content="hidden" />
+ <!-- style sheet links -->
+ <link rel="stylesheet" href="s5/default/slides.css" type="text/css" media="projection" id="slideProj" />
+ <link rel="stylesheet" href="s5/default/outline.css" type="text/css" media="screen" id="outlineStyle" />
+ <link rel="stylesheet" href="s5/default/print.css" type="text/css" media="print" id="slidePrint" />
+ <link rel="stylesheet" href="s5/default/opera.css" type="text/css" media="projection" id="operaFix" />
+ <!-- S5 JS -->
+ <script src="s5/default/slides.js" type="text/javascript"></script>
+</head>
+<body>
+<div class="layout">
+<div id="controls"></div>
+<div id="currentSlide"></div>
+<div id="header"></div>
+<div id="footer">
+ <h1>July 15, 2006</h1>
+ <h2>My S5 Document</h2>
+</div>
+</div>
+<div class="presentation">
+<div class="titleslide slide">
+ <h1 class="title">My S5 Document</h1>
+ <h3 class="author">Sam Smith<br/>Jen Jones</h3>
+ <h4 class="date">July 15, 2006</h4>
+</div>
+<div id="first-slide" class="slide section level1">
+<h1>First slide</h1>
+<ul>
+<li>first bullet</li>
+<li>second bullet</li>
+</ul>
+</div>
+<div id="math" class="slide section level1">
+<h1>Math</h1>
+<ul>
+<li><span class="math inline">$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span></li>
+</ul>
+</div>
+</div>
+</body>
+</html>
diff --git a/test/s5-fancy.html b/test/s5-fancy.html
new file mode 100644
index 000000000..3a2a602be
--- /dev/null
+++ b/test/s5-fancy.html
@@ -0,0 +1,257 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <meta name="generator" content="pandoc" />
+ <meta name="version" content="S5 1.1" />
+ <meta name="author" content="Sam Smith" />
+ <meta name="version" content="S5 1.1" />
+ <meta name="author" content="Jen Jones" />
+ <meta name="date" content="2006-07-15" />
+ <title>My S5 Document</title>
+ <style type="text/css">code{white-space: pre;}</style>
+ <!-- configuration parameters -->
+ <meta name="defaultView" content="slideshow" />
+ <meta name="controlVis" content="hidden" />
+ <!-- style sheet links -->
+ <link rel="stylesheet" href="s5/default/slides.css" type="text/css" media="projection" id="slideProj" />
+ <link rel="stylesheet" href="s5/default/outline.css" type="text/css" media="screen" id="outlineStyle" />
+ <link rel="stylesheet" href="s5/default/print.css" type="text/css" media="print" id="slidePrint" />
+ <link rel="stylesheet" href="s5/default/opera.css" type="text/css" media="projection" id="operaFix" />
+ <!-- S5 JS -->
+ <script src="s5/default/slides.js" type="text/javascript"></script>
+ <script type="text/javascript">/*<![CDATA[*/
+ /*
+ LaTeXMathML.js from http://math.etsu.edu/LaTeXMathML/
+ Adapted by Jeff Knisely and Douglas Woodall from ASCIIMathML.js v. 1.4.7,
+ (c) 2005 Peter Jipsen http://www.chapman.edu/~jipsen.
+ Released under the GNU General Public License version 2 or later.
+ See the GNU General Public License (at http://www.gnu.org/copyleft/gpl.html)
+ for more details.
+ */
+ var checkForMathML=true;var notifyIfNoMathML=true;var alertIfNoMathML=false;var mathcolor="";var mathfontfamily="";var showasciiformulaonhover=true;var isIE=document.createElementNS==null;if(document.getElementById==null)
+ alert("This webpage requires a recent browser such as \nMozilla/Netscape 7+ or Internet Explorer 6+MathPlayer")
+ function AMcreateElementXHTML(t){if(isIE)return document.createElement(t);else return document.createElementNS("http://www.w3.org/1999/xhtml",t);}
+ function AMnoMathMLNote(){var nd=AMcreateElementXHTML("h3");nd.setAttribute("align","center")
+ nd.appendChild(AMcreateElementXHTML("p"));nd.appendChild(document.createTextNode("To view the "));var an=AMcreateElementXHTML("a");an.appendChild(document.createTextNode("LaTeXMathML"));an.setAttribute("href","http://www.maths.nott.ac.uk/personal/drw/lm.html");nd.appendChild(an);nd.appendChild(document.createTextNode(" notation use Internet Explorer 6+"));an=AMcreateElementXHTML("a");an.appendChild(document.createTextNode("MathPlayer"));an.setAttribute("href","http://www.dessci.com/en/products/mathplayer/download.htm");nd.appendChild(an);nd.appendChild(document.createTextNode(" or Netscape/Mozilla/Firefox"));nd.appendChild(AMcreateElementXHTML("p"));return nd;}
+ function AMisMathMLavailable(){if(navigator.appName.slice(0,8)=="Netscape")
+ if(navigator.appVersion.slice(0,1)>="5")return null;else return AMnoMathMLNote();else if(navigator.appName.slice(0,9)=="Microsoft")
+ try{var ActiveX=new ActiveXObject("MathPlayer.Factory.1");return null;}catch(e){return AMnoMathMLNote();}
+ else return AMnoMathMLNote();}
+ var AMcal=[0xEF35,0x212C,0xEF36,0xEF37,0x2130,0x2131,0xEF38,0x210B,0x2110,0xEF39,0xEF3A,0x2112,0x2133,0xEF3B,0xEF3C,0xEF3D,0xEF3E,0x211B,0xEF3F,0xEF40,0xEF41,0xEF42,0xEF43,0xEF44,0xEF45,0xEF46];var AMfrk=[0xEF5D,0xEF5E,0x212D,0xEF5F,0xEF60,0xEF61,0xEF62,0x210C,0x2111,0xEF63,0xEF64,0xEF65,0xEF66,0xEF67,0xEF68,0xEF69,0xEF6A,0x211C,0xEF6B,0xEF6C,0xEF6D,0xEF6E,0xEF6F,0xEF70,0xEF71,0x2128];var AMbbb=[0xEF8C,0xEF8D,0x2102,0xEF8E,0xEF8F,0xEF90,0xEF91,0x210D,0xEF92,0xEF93,0xEF94,0xEF95,0xEF96,0x2115,0xEF97,0x2119,0x211A,0x211D,0xEF98,0xEF99,0xEF9A,0xEF9B,0xEF9C,0xEF9D,0xEF9E,0x2124];var CONST=0,UNARY=1,BINARY=2,INFIX=3,LEFTBRACKET=4,RIGHTBRACKET=5,SPACE=6,UNDEROVER=7,DEFINITION=8,TEXT=9,BIG=10,LONG=11,STRETCHY=12,MATRIX=13;var AMsqrt={input:"\\sqrt",tag:"msqrt",output:"sqrt",ttype:UNARY},AMroot={input:"\\root",tag:"mroot",output:"root",ttype:BINARY},AMfrac={input:"\\frac",tag:"mfrac",output:"/",ttype:BINARY},AMover={input:"\\stackrel",tag:"mover",output:"stackrel",ttype:BINARY},AMatop={input:"\\atop",tag:"mfrac",output:"",ttype:INFIX},AMchoose={input:"\\choose",tag:"mfrac",output:"",ttype:INFIX},AMsub={input:"_",tag:"msub",output:"_",ttype:INFIX},AMsup={input:"^",tag:"msup",output:"^",ttype:INFIX},AMtext={input:"\\mathrm",tag:"mtext",output:"text",ttype:TEXT},AMmbox={input:"\\mbox",tag:"mtext",output:"mbox",ttype:TEXT};var AMsymbols=[{input:"\\alpha",tag:"mi",output:"\u03B1",ttype:CONST},{input:"\\beta",tag:"mi",output:"\u03B2",ttype:CONST},{input:"\\gamma",tag:"mi",output:"\u03B3",ttype:CONST},{input:"\\delta",tag:"mi",output:"\u03B4",ttype:CONST},{input:"\\epsilon",tag:"mi",output:"\u03B5",ttype:CONST},{input:"\\varepsilon",tag:"mi",output:"\u025B",ttype:CONST},{input:"\\zeta",tag:"mi",output:"\u03B6",ttype:CONST},{input:"\\eta",tag:"mi",output:"\u03B7",ttype:CONST},{input:"\\theta",tag:"mi",output:"\u03B8",ttype:CONST},{input:"\\vartheta",tag:"mi",output:"\u03D1",ttype:CONST},{input:"\\iota",tag:"mi",output:"\u03B9",ttype:CONST},{input:"\\kappa",tag:"mi",output:"\u03BA",ttype:CONST},{input:"\\lambda",tag:"mi",output:"\u03BB",ttype:CONST},{input:"\\mu",tag:"mi",output:"\u03BC",ttype:CONST},{input:"\\nu",tag:"mi",output:"\u03BD",ttype:CONST},{input:"\\xi",tag:"mi",output:"\u03BE",ttype:CONST},{input:"\\pi",tag:"mi",output:"\u03C0",ttype:CONST},{input:"\\varpi",tag:"mi",output:"\u03D6",ttype:CONST},{input:"\\rho",tag:"mi",output:"\u03C1",ttype:CONST},{input:"\\varrho",tag:"mi",output:"\u03F1",ttype:CONST},{input:"\\varsigma",tag:"mi",output:"\u03C2",ttype:CONST},{input:"\\sigma",tag:"mi",output:"\u03C3",ttype:CONST},{input:"\\tau",tag:"mi",output:"\u03C4",ttype:CONST},{input:"\\upsilon",tag:"mi",output:"\u03C5",ttype:CONST},{input:"\\phi",tag:"mi",output:"\u03C6",ttype:CONST},{input:"\\varphi",tag:"mi",output:"\u03D5",ttype:CONST},{input:"\\chi",tag:"mi",output:"\u03C7",ttype:CONST},{input:"\\psi",tag:"mi",output:"\u03C8",ttype:CONST},{input:"\\omega",tag:"mi",output:"\u03C9",ttype:CONST},{input:"\\Gamma",tag:"mo",output:"\u0393",ttype:CONST},{input:"\\Delta",tag:"mo",output:"\u0394",ttype:CONST},{input:"\\Theta",tag:"mo",output:"\u0398",ttype:CONST},{input:"\\Lambda",tag:"mo",output:"\u039B",ttype:CONST},{input:"\\Xi",tag:"mo",output:"\u039E",ttype:CONST},{input:"\\Pi",tag:"mo",output:"\u03A0",ttype:CONST},{input:"\\Sigma",tag:"mo",output:"\u03A3",ttype:CONST},{input:"\\Upsilon",tag:"mo",output:"\u03A5",ttype:CONST},{input:"\\Phi",tag:"mo",output:"\u03A6",ttype:CONST},{input:"\\Psi",tag:"mo",output:"\u03A8",ttype:CONST},{input:"\\Omega",tag:"mo",output:"\u03A9",ttype:CONST},{input:"\\frac12",tag:"mo",output:"\u00BD",ttype:CONST},{input:"\\frac14",tag:"mo",output:"\u00BC",ttype:CONST},{input:"\\frac34",tag:"mo",output:"\u00BE",ttype:CONST},{input:"\\frac13",tag:"mo",output:"\u2153",ttype:CONST},{input:"\\frac23",tag:"mo",output:"\u2154",ttype:CONST},{input:"\\frac15",tag:"mo",output:"\u2155",ttype:CONST},{input:"\\frac25",tag:"mo",output:"\u2156",ttype:CONST},{input:"\\frac35",tag:"mo",output:"\u2157",ttype:CONST},{input:"\\frac45",tag:"mo",output:"\u2158",ttype:CONST},{input:"\\frac16",tag:"mo",output:"\u2159",ttype:CONST},{input:"\\frac56",tag:"mo",output:"\u215A",ttype:CONST},{input:"\\frac18",tag:"mo",output:"\u215B",ttype:CONST},{input:"\\frac38",tag:"mo",output:"\u215C",ttype:CONST},{input:"\\frac58",tag:"mo",output:"\u215D",ttype:CONST},{input:"\\frac78",tag:"mo",output:"\u215E",ttype:CONST},{input:"\\pm",tag:"mo",output:"\u00B1",ttype:CONST},{input:"\\mp",tag:"mo",output:"\u2213",ttype:CONST},{input:"\\triangleleft",tag:"mo",output:"\u22B2",ttype:CONST},{input:"\\triangleright",tag:"mo",output:"\u22B3",ttype:CONST},{input:"\\cdot",tag:"mo",output:"\u22C5",ttype:CONST},{input:"\\star",tag:"mo",output:"\u22C6",ttype:CONST},{input:"\\ast",tag:"mo",output:"\u002A",ttype:CONST},{input:"\\times",tag:"mo",output:"\u00D7",ttype:CONST},{input:"\\div",tag:"mo",output:"\u00F7",ttype:CONST},{input:"\\circ",tag:"mo",output:"\u2218",ttype:CONST},{input:"\\bullet",tag:"mo",output:"\u2022",ttype:CONST},{input:"\\oplus",tag:"mo",output:"\u2295",ttype:CONST},{input:"\\ominus",tag:"mo",output:"\u2296",ttype:CONST},{input:"\\otimes",tag:"mo",output:"\u2297",ttype:CONST},{input:"\\bigcirc",tag:"mo",output:"\u25CB",ttype:CONST},{input:"\\oslash",tag:"mo",output:"\u2298",ttype:CONST},{input:"\\odot",tag:"mo",output:"\u2299",ttype:CONST},{input:"\\land",tag:"mo",output:"\u2227",ttype:CONST},{input:"\\wedge",tag:"mo",output:"\u2227",ttype:CONST},{input:"\\lor",tag:"mo",output:"\u2228",ttype:CONST},{input:"\\vee",tag:"mo",output:"\u2228",ttype:CONST},{input:"\\cap",tag:"mo",output:"\u2229",ttype:CONST},{input:"\\cup",tag:"mo",output:"\u222A",ttype:CONST},{input:"\\sqcap",tag:"mo",output:"\u2293",ttype:CONST},{input:"\\sqcup",tag:"mo",output:"\u2294",ttype:CONST},{input:"\\uplus",tag:"mo",output:"\u228E",ttype:CONST},{input:"\\amalg",tag:"mo",output:"\u2210",ttype:CONST},{input:"\\bigtriangleup",tag:"mo",output:"\u25B3",ttype:CONST},{input:"\\bigtriangledown",tag:"mo",output:"\u25BD",ttype:CONST},{input:"\\dag",tag:"mo",output:"\u2020",ttype:CONST},{input:"\\dagger",tag:"mo",output:"\u2020",ttype:CONST},{input:"\\ddag",tag:"mo",output:"\u2021",ttype:CONST},{input:"\\ddagger",tag:"mo",output:"\u2021",ttype:CONST},{input:"\\lhd",tag:"mo",output:"\u22B2",ttype:CONST},{input:"\\rhd",tag:"mo",output:"\u22B3",ttype:CONST},{input:"\\unlhd",tag:"mo",output:"\u22B4",ttype:CONST},{input:"\\unrhd",tag:"mo",output:"\u22B5",ttype:CONST},{input:"\\sum",tag:"mo",output:"\u2211",ttype:UNDEROVER},{input:"\\prod",tag:"mo",output:"\u220F",ttype:UNDEROVER},{input:"\\bigcap",tag:"mo",output:"\u22C2",ttype:UNDEROVER},{input:"\\bigcup",tag:"mo",output:"\u22C3",ttype:UNDEROVER},{input:"\\bigwedge",tag:"mo",output:"\u22C0",ttype:UNDEROVER},{input:"\\bigvee",tag:"mo",output:"\u22C1",ttype:UNDEROVER},{input:"\\bigsqcap",tag:"mo",output:"\u2A05",ttype:UNDEROVER},{input:"\\bigsqcup",tag:"mo",output:"\u2A06",ttype:UNDEROVER},{input:"\\coprod",tag:"mo",output:"\u2210",ttype:UNDEROVER},{input:"\\bigoplus",tag:"mo",output:"\u2A01",ttype:UNDEROVER},{input:"\\bigotimes",tag:"mo",output:"\u2A02",ttype:UNDEROVER},{input:"\\bigodot",tag:"mo",output:"\u2A00",ttype:UNDEROVER},{input:"\\biguplus",tag:"mo",output:"\u2A04",ttype:UNDEROVER},{input:"\\int",tag:"mo",output:"\u222B",ttype:CONST},{input:"\\oint",tag:"mo",output:"\u222E",ttype:CONST},{input:":=",tag:"mo",output:":=",ttype:CONST},{input:"\\lt",tag:"mo",output:"<",ttype:CONST},{input:"\\gt",tag:"mo",output:">",ttype:CONST},{input:"\\ne",tag:"mo",output:"\u2260",ttype:CONST},{input:"\\neq",tag:"mo",output:"\u2260",ttype:CONST},{input:"\\le",tag:"mo",output:"\u2264",ttype:CONST},{input:"\\leq",tag:"mo",output:"\u2264",ttype:CONST},{input:"\\leqslant",tag:"mo",output:"\u2264",ttype:CONST},{input:"\\ge",tag:"mo",output:"\u2265",ttype:CONST},{input:"\\geq",tag:"mo",output:"\u2265",ttype:CONST},{input:"\\geqslant",tag:"mo",output:"\u2265",ttype:CONST},{input:"\\equiv",tag:"mo",output:"\u2261",ttype:CONST},{input:"\\ll",tag:"mo",output:"\u226A",ttype:CONST},{input:"\\gg",tag:"mo",output:"\u226B",ttype:CONST},{input:"\\doteq",tag:"mo",output:"\u2250",ttype:CONST},{input:"\\prec",tag:"mo",output:"\u227A",ttype:CONST},{input:"\\succ",tag:"mo",output:"\u227B",ttype:CONST},{input:"\\preceq",tag:"mo",output:"\u227C",ttype:CONST},{input:"\\succeq",tag:"mo",output:"\u227D",ttype:CONST},{input:"\\subset",tag:"mo",output:"\u2282",ttype:CONST},{input:"\\supset",tag:"mo",output:"\u2283",ttype:CONST},{input:"\\subseteq",tag:"mo",output:"\u2286",ttype:CONST},{input:"\\supseteq",tag:"mo",output:"\u2287",ttype:CONST},{input:"\\sqsubset",tag:"mo",output:"\u228F",ttype:CONST},{input:"\\sqsupset",tag:"mo",output:"\u2290",ttype:CONST},{input:"\\sqsubseteq",tag:"mo",output:"\u2291",ttype:CONST},{input:"\\sqsupseteq",tag:"mo",output:"\u2292",ttype:CONST},{input:"\\sim",tag:"mo",output:"\u223C",ttype:CONST},{input:"\\simeq",tag:"mo",output:"\u2243",ttype:CONST},{input:"\\approx",tag:"mo",output:"\u2248",ttype:CONST},{input:"\\cong",tag:"mo",output:"\u2245",ttype:CONST},{input:"\\Join",tag:"mo",output:"\u22C8",ttype:CONST},{input:"\\bowtie",tag:"mo",output:"\u22C8",ttype:CONST},{input:"\\in",tag:"mo",output:"\u2208",ttype:CONST},{input:"\\ni",tag:"mo",output:"\u220B",ttype:CONST},{input:"\\owns",tag:"mo",output:"\u220B",ttype:CONST},{input:"\\propto",tag:"mo",output:"\u221D",ttype:CONST},{input:"\\vdash",tag:"mo",output:"\u22A2",ttype:CONST},{input:"\\dashv",tag:"mo",output:"\u22A3",ttype:CONST},{input:"\\models",tag:"mo",output:"\u22A8",ttype:CONST},{input:"\\perp",tag:"mo",output:"\u22A5",ttype:CONST},{input:"\\smile",tag:"mo",output:"\u2323",ttype:CONST},{input:"\\frown",tag:"mo",output:"\u2322",ttype:CONST},{input:"\\asymp",tag:"mo",output:"\u224D",ttype:CONST},{input:"\\notin",tag:"mo",output:"\u2209",ttype:CONST},{input:"\\begin{eqnarray}",output:"X",ttype:MATRIX,invisible:true},{input:"\\begin{array}",output:"X",ttype:MATRIX,invisible:true},{input:"\\\\",output:"}&{",ttype:DEFINITION},{input:"\\end{eqnarray}",output:"}}",ttype:DEFINITION},{input:"\\end{array}",output:"}}",ttype:DEFINITION},{input:"\\big",tag:"mo",output:"X",atval:"1.2",ieval:"2.2",ttype:BIG},{input:"\\Big",tag:"mo",output:"X",atval:"1.6",ieval:"2.6",ttype:BIG},{input:"\\bigg",tag:"mo",output:"X",atval:"2.2",ieval:"3.2",ttype:BIG},{input:"\\Bigg",tag:"mo",output:"X",atval:"2.9",ieval:"3.9",ttype:BIG},{input:"\\left",tag:"mo",output:"X",ttype:LEFTBRACKET},{input:"\\right",tag:"mo",output:"X",ttype:RIGHTBRACKET},{input:"{",output:"{",ttype:LEFTBRACKET,invisible:true},{input:"}",output:"}",ttype:RIGHTBRACKET,invisible:true},{input:"(",tag:"mo",output:"(",atval:"1",ttype:STRETCHY},{input:"[",tag:"mo",output:"[",atval:"1",ttype:STRETCHY},{input:"\\lbrack",tag:"mo",output:"[",atval:"1",ttype:STRETCHY},{input:"\\{",tag:"mo",output:"{",atval:"1",ttype:STRETCHY},{input:"\\lbrace",tag:"mo",output:"{",atval:"1",ttype:STRETCHY},{input:"\\langle",tag:"mo",output:"\u2329",atval:"1",ttype:STRETCHY},{input:"\\lfloor",tag:"mo",output:"\u230A",atval:"1",ttype:STRETCHY},{input:"\\lceil",tag:"mo",output:"\u2308",atval:"1",ttype:STRETCHY},{input:")",tag:"mo",output:")",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"]",tag:"mo",output:"]",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"\\rbrack",tag:"mo",output:"]",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"\\}",tag:"mo",output:"}",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"\\rbrace",tag:"mo",output:"}",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"\\rangle",tag:"mo",output:"\u232A",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"\\rfloor",tag:"mo",output:"\u230B",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"\\rceil",tag:"mo",output:"\u2309",rtag:"mi",atval:"1",ttype:STRETCHY},{input:"|",tag:"mo",output:"\u2223",atval:"1",ttype:STRETCHY},{input:"\\|",tag:"mo",output:"\u2225",atval:"1",ttype:STRETCHY},{input:"\\vert",tag:"mo",output:"\u2223",atval:"1",ttype:STRETCHY},{input:"\\Vert",tag:"mo",output:"\u2225",atval:"1",ttype:STRETCHY},{input:"\\mid",tag:"mo",output:"\u2223",atval:"1",ttype:STRETCHY},{input:"\\parallel",tag:"mo",output:"\u2225",atval:"1",ttype:STRETCHY},{input:"/",tag:"mo",output:"/",atval:"1.01",ttype:STRETCHY},{input:"\\backslash",tag:"mo",output:"\u2216",atval:"1",ttype:STRETCHY},{input:"\\setminus",tag:"mo",output:"\\",ttype:CONST},{input:"\\!",tag:"mspace",atname:"width",atval:"-0.167em",ttype:SPACE},{input:"\\,",tag:"mspace",atname:"width",atval:"0.167em",ttype:SPACE},{input:"\\>",tag:"mspace",atname:"width",atval:"0.222em",ttype:SPACE},{input:"\\:",tag:"mspace",atname:"width",atval:"0.222em",ttype:SPACE},{input:"\\;",tag:"mspace",atname:"width",atval:"0.278em",ttype:SPACE},{input:"~",tag:"mspace",atname:"width",atval:"0.333em",ttype:SPACE},{input:"\\quad",tag:"mspace",atname:"width",atval:"1em",ttype:SPACE},{input:"\\qquad",tag:"mspace",atname:"width",atval:"2em",ttype:SPACE},{input:"\\prime",tag:"mo",output:"\u2032",ttype:CONST},{input:"'",tag:"mo",output:"\u02B9",ttype:CONST},{input:"''",tag:"mo",output:"\u02BA",ttype:CONST},{input:"'''",tag:"mo",output:"\u2034",ttype:CONST},{input:"''''",tag:"mo",output:"\u2057",ttype:CONST},{input:"\\ldots",tag:"mo",output:"\u2026",ttype:CONST},{input:"\\cdots",tag:"mo",output:"\u22EF",ttype:CONST},{input:"\\vdots",tag:"mo",output:"\u22EE",ttype:CONST},{input:"\\ddots",tag:"mo",output:"\u22F1",ttype:CONST},{input:"\\forall",tag:"mo",output:"\u2200",ttype:CONST},{input:"\\exists",tag:"mo",output:"\u2203",ttype:CONST},{input:"\\Re",tag:"mo",output:"\u211C",ttype:CONST},{input:"\\Im",tag:"mo",output:"\u2111",ttype:CONST},{input:"\\aleph",tag:"mo",output:"\u2135",ttype:CONST},{input:"\\hbar",tag:"mo",output:"\u210F",ttype:CONST},{input:"\\ell",tag:"mo",output:"\u2113",ttype:CONST},{input:"\\wp",tag:"mo",output:"\u2118",ttype:CONST},{input:"\\emptyset",tag:"mo",output:"\u2205",ttype:CONST},{input:"\\infty",tag:"mo",output:"\u221E",ttype:CONST},{input:"\\surd",tag:"mo",output:"\\sqrt{}",ttype:DEFINITION},{input:"\\partial",tag:"mo",output:"\u2202",ttype:CONST},{input:"\\nabla",tag:"mo",output:"\u2207",ttype:CONST},{input:"\\triangle",tag:"mo",output:"\u25B3",ttype:CONST},{input:"\\therefore",tag:"mo",output:"\u2234",ttype:CONST},{input:"\\angle",tag:"mo",output:"\u2220",ttype:CONST},{input:"\\diamond",tag:"mo",output:"\u22C4",ttype:CONST},{input:"\\Diamond",tag:"mo",output:"\u25C7",ttype:CONST},{input:"\\neg",tag:"mo",output:"\u00AC",ttype:CONST},{input:"\\lnot",tag:"mo",output:"\u00AC",ttype:CONST},{input:"\\bot",tag:"mo",output:"\u22A5",ttype:CONST},{input:"\\top",tag:"mo",output:"\u22A4",ttype:CONST},{input:"\\square",tag:"mo",output:"\u25AB",ttype:CONST},{input:"\\Box",tag:"mo",output:"\u25A1",ttype:CONST},{input:"\\wr",tag:"mo",output:"\u2240",ttype:CONST},{input:"\\arccos",tag:"mi",output:"arccos",ttype:UNARY,func:true},{input:"\\arcsin",tag:"mi",output:"arcsin",ttype:UNARY,func:true},{input:"\\arctan",tag:"mi",output:"arctan",ttype:UNARY,func:true},{input:"\\arg",tag:"mi",output:"arg",ttype:UNARY,func:true},{input:"\\cos",tag:"mi",output:"cos",ttype:UNARY,func:true},{input:"\\cosh",tag:"mi",output:"cosh",ttype:UNARY,func:true},{input:"\\cot",tag:"mi",output:"cot",ttype:UNARY,func:true},{input:"\\coth",tag:"mi",output:"coth",ttype:UNARY,func:true},{input:"\\csc",tag:"mi",output:"csc",ttype:UNARY,func:true},{input:"\\deg",tag:"mi",output:"deg",ttype:UNARY,func:true},{input:"\\det",tag:"mi",output:"det",ttype:UNARY,func:true},{input:"\\dim",tag:"mi",output:"dim",ttype:UNARY,func:true},{input:"\\exp",tag:"mi",output:"exp",ttype:UNARY,func:true},{input:"\\gcd",tag:"mi",output:"gcd",ttype:UNARY,func:true},{input:"\\hom",tag:"mi",output:"hom",ttype:UNARY,func:true},{input:"\\inf",tag:"mo",output:"inf",ttype:UNDEROVER},{input:"\\ker",tag:"mi",output:"ker",ttype:UNARY,func:true},{input:"\\lg",tag:"mi",output:"lg",ttype:UNARY,func:true},{input:"\\lim",tag:"mo",output:"lim",ttype:UNDEROVER},{input:"\\liminf",tag:"mo",output:"liminf",ttype:UNDEROVER},{input:"\\limsup",tag:"mo",output:"limsup",ttype:UNDEROVER},{input:"\\ln",tag:"mi",output:"ln",ttype:UNARY,func:true},{input:"\\log",tag:"mi",output:"log",ttype:UNARY,func:true},{input:"\\max",tag:"mo",output:"max",ttype:UNDEROVER},{input:"\\min",tag:"mo",output:"min",ttype:UNDEROVER},{input:"\\Pr",tag:"mi",output:"Pr",ttype:UNARY,func:true},{input:"\\sec",tag:"mi",output:"sec",ttype:UNARY,func:true},{input:"\\sin",tag:"mi",output:"sin",ttype:UNARY,func:true},{input:"\\sinh",tag:"mi",output:"sinh",ttype:UNARY,func:true},{input:"\\sup",tag:"mo",output:"sup",ttype:UNDEROVER},{input:"\\tan",tag:"mi",output:"tan",ttype:UNARY,func:true},{input:"\\tanh",tag:"mi",output:"tanh",ttype:UNARY,func:true},{input:"\\gets",tag:"mo",output:"\u2190",ttype:CONST},{input:"\\leftarrow",tag:"mo",output:"\u2190",ttype:CONST},{input:"\\to",tag:"mo",output:"\u2192",ttype:CONST},{input:"\\rightarrow",tag:"mo",output:"\u2192",ttype:CONST},{input:"\\leftrightarrow",tag:"mo",output:"\u2194",ttype:CONST},{input:"\\uparrow",tag:"mo",output:"\u2191",ttype:CONST},{input:"\\downarrow",tag:"mo",output:"\u2193",ttype:CONST},{input:"\\updownarrow",tag:"mo",output:"\u2195",ttype:CONST},{input:"\\Leftarrow",tag:"mo",output:"\u21D0",ttype:CONST},{input:"\\Rightarrow",tag:"mo",output:"\u21D2",ttype:CONST},{input:"\\Leftrightarrow",tag:"mo",output:"\u21D4",ttype:CONST},{input:"\\iff",tag:"mo",output:"~\\Longleftrightarrow~",ttype:DEFINITION},{input:"\\Uparrow",tag:"mo",output:"\u21D1",ttype:CONST},{input:"\\Downarrow",tag:"mo",output:"\u21D3",ttype:CONST},{input:"\\Updownarrow",tag:"mo",output:"\u21D5",ttype:CONST},{input:"\\mapsto",tag:"mo",output:"\u21A6",ttype:CONST},{input:"\\longleftarrow",tag:"mo",output:"\u2190",ttype:LONG},{input:"\\longrightarrow",tag:"mo",output:"\u2192",ttype:LONG},{input:"\\longleftrightarrow",tag:"mo",output:"\u2194",ttype:LONG},{input:"\\Longleftarrow",tag:"mo",output:"\u21D0",ttype:LONG},{input:"\\Longrightarrow",tag:"mo",output:"\u21D2",ttype:LONG},{input:"\\Longleftrightarrow",tag:"mo",output:"\u21D4",ttype:LONG},{input:"\\longmapsto",tag:"mo",output:"\u21A6",ttype:CONST},AMsqrt,AMroot,AMfrac,AMover,AMsub,AMsup,AMtext,AMmbox,AMatop,AMchoose,{input:"\\acute",tag:"mover",output:"\u00B4",ttype:UNARY,acc:true},{input:"\\grave",tag:"mover",output:"\u0060",ttype:UNARY,acc:true},{input:"\\breve",tag:"mover",output:"\u02D8",ttype:UNARY,acc:true},{input:"\\check",tag:"mover",output:"\u02C7",ttype:UNARY,acc:true},{input:"\\dot",tag:"mover",output:".",ttype:UNARY,acc:true},{input:"\\ddot",tag:"mover",output:"..",ttype:UNARY,acc:true},{input:"\\mathring",tag:"mover",output:"\u00B0",ttype:UNARY,acc:true},{input:"\\vec",tag:"mover",output:"\u20D7",ttype:UNARY,acc:true},{input:"\\overrightarrow",tag:"mover",output:"\u20D7",ttype:UNARY,acc:true},{input:"\\overleftarrow",tag:"mover",output:"\u20D6",ttype:UNARY,acc:true},{input:"\\hat",tag:"mover",output:"\u005E",ttype:UNARY,acc:true},{input:"\\widehat",tag:"mover",output:"\u0302",ttype:UNARY,acc:true},{input:"\\tilde",tag:"mover",output:"~",ttype:UNARY,acc:true},{input:"\\widetilde",tag:"mover",output:"\u02DC",ttype:UNARY,acc:true},{input:"\\bar",tag:"mover",output:"\u203E",ttype:UNARY,acc:true},{input:"\\overbrace",tag:"mover",output:"\uFE37",ttype:UNARY,acc:true},{input:"\\overbracket",tag:"mover",output:"\u23B4",ttype:UNARY,acc:true},{input:"\\overline",tag:"mover",output:"\u00AF",ttype:UNARY,acc:true},{input:"\\underbrace",tag:"munder",output:"\uFE38",ttype:UNARY,acc:true},{input:"\\underbracket",tag:"munder",output:"\u23B5",ttype:UNARY,acc:true},{input:"\\underline",tag:"munder",output:"\u00AF",ttype:UNARY,acc:true},{input:"\\displaystyle",tag:"mstyle",atname:"displaystyle",atval:"true",ttype:UNARY},{input:"\\textstyle",tag:"mstyle",atname:"displaystyle",atval:"false",ttype:UNARY},{input:"\\scriptstyle",tag:"mstyle",atname:"scriptlevel",atval:"1",ttype:UNARY},{input:"\\scriptscriptstyle",tag:"mstyle",atname:"scriptlevel",atval:"2",ttype:UNARY},{input:"\\textrm",tag:"mstyle",output:"\\mathrm",ttype:DEFINITION},{input:"\\mathbf",tag:"mstyle",atname:"mathvariant",atval:"bold",ttype:UNARY},{input:"\\textbf",tag:"mstyle",atname:"mathvariant",atval:"bold",ttype:UNARY},{input:"\\mathit",tag:"mstyle",atname:"mathvariant",atval:"italic",ttype:UNARY},{input:"\\textit",tag:"mstyle",atname:"mathvariant",atval:"italic",ttype:UNARY},{input:"\\mathtt",tag:"mstyle",atname:"mathvariant",atval:"monospace",ttype:UNARY},{input:"\\texttt",tag:"mstyle",atname:"mathvariant",atval:"monospace",ttype:UNARY},{input:"\\mathsf",tag:"mstyle",atname:"mathvariant",atval:"sans-serif",ttype:UNARY},{input:"\\mathbb",tag:"mstyle",atname:"mathvariant",atval:"double-struck",ttype:UNARY,codes:AMbbb},{input:"\\mathcal",tag:"mstyle",atname:"mathvariant",atval:"script",ttype:UNARY,codes:AMcal},{input:"\\mathfrak",tag:"mstyle",atname:"mathvariant",atval:"fraktur",ttype:UNARY,codes:AMfrk},{input:"\\textcolor",tag:"mstyle",atname:"mathvariant",atval:"mathcolor",ttype:BINARY},{input:"\\colorbox",tag:"mstyle",atname:"mathvariant",atval:"background",ttype:BINARY}];function compareNames(s1,s2){if(s1.input>s2.input)return 1
+ else return-1;}
+ var AMnames=[];function AMinitSymbols(){AMsymbols.sort(compareNames);for(i=0;i<AMsymbols.length;i++)AMnames[i]=AMsymbols[i].input;}
+ var AMmathml="http://www.w3.org/1998/Math/MathML";function AMcreateElementMathML(t){if(isIE)return document.createElement("m:"+t);else return document.createElementNS(AMmathml,t);}
+ function AMcreateMmlNode(t,frag){if(isIE)var node=document.createElement("m:"+t);else var node=document.createElementNS(AMmathml,t);node.appendChild(frag);return node;}
+ function newcommand(oldstr,newstr){AMsymbols=AMsymbols.concat([{input:oldstr,tag:"mo",output:newstr,ttype:DEFINITION}]);}
+ function AMremoveCharsAndBlanks(str,n){var st;st=str.slice(n);for(var i=0;i<st.length&&st.charCodeAt(i)<=32;i=i+1);return st.slice(i);}
+ function AMposition(arr,str,n){if(n==0){var h,m;n=-1;h=arr.length;while(n+1<h){m=(n+h)>>1;if(arr[m]<str)n=m;else h=m;}
+ return h;}else
+ for(var i=n;i<arr.length&&arr[i]<str;i++);return i;}
+ function AMgetSymbol(str){var k=0;var j=0;var mk;var st;var tagst;var match="";var more=true;for(var i=1;i<=str.length&&more;i++){st=str.slice(0,i);j=k;k=AMposition(AMnames,st,j);if(k<AMnames.length&&str.slice(0,AMnames[k].length)==AMnames[k]){match=AMnames[k];mk=k;i=match.length;}
+ more=k<AMnames.length&&str.slice(0,AMnames[k].length)>=AMnames[k];}
+ AMpreviousSymbol=AMcurrentSymbol;if(match!=""){AMcurrentSymbol=AMsymbols[mk].ttype;return AMsymbols[mk];}
+ AMcurrentSymbol=CONST;k=1;st=str.slice(0,1);if("0"<=st&&st<="9")tagst="mn";else tagst=(("A">st||st>"Z")&&("a">st||st>"z")?"mo":"mi");return{input:st,tag:tagst,output:st,ttype:CONST};}
+ var AMpreviousSymbol,AMcurrentSymbol;function AMparseSexpr(str){var symbol,node,result,result2,i,st,newFrag=document.createDocumentFragment();str=AMremoveCharsAndBlanks(str,0);symbol=AMgetSymbol(str);if(symbol==null||symbol.ttype==RIGHTBRACKET)
+ return[null,str,null];if(symbol.ttype==DEFINITION){str=symbol.output+AMremoveCharsAndBlanks(str,symbol.input.length);symbol=AMgetSymbol(str);if(symbol==null||symbol.ttype==RIGHTBRACKET)
+ return[null,str,null];}
+ str=AMremoveCharsAndBlanks(str,symbol.input.length);switch(symbol.ttype){case SPACE:node=AMcreateElementMathML(symbol.tag);node.setAttribute(symbol.atname,symbol.atval);return[node,str,symbol.tag];case UNDEROVER:if(isIE){if(symbol.input.substr(0,4)=="\\big"){str="\\"+symbol.input.substr(4)+str;symbol=AMgetSymbol(str);symbol.ttype=UNDEROVER;str=AMremoveCharsAndBlanks(str,symbol.input.length);}}
+ return[AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)),str,symbol.tag];case CONST:var output=symbol.output;if(isIE){if(symbol.input=="'")
+ output="\u2032";else if(symbol.input=="''")
+ output="\u2033";else if(symbol.input=="'''")
+ output="\u2033\u2032";else if(symbol.input=="''''")
+ output="\u2033\u2033";else if(symbol.input=="\\square")
+ output="\u25A1";else if(symbol.input.substr(0,5)=="\\frac"){var denom=symbol.input.substr(6,1);if(denom=="5"||denom=="6"){str=symbol.input.replace(/\\frac/,"\\frac ")+str;return[node,str,symbol.tag];}}}
+ node=AMcreateMmlNode(symbol.tag,document.createTextNode(output));return[node,str,symbol.tag];case LONG:node=AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output));node.setAttribute("minsize","1.5");node.setAttribute("maxsize","1.5");node=AMcreateMmlNode("mover",node);node.appendChild(AMcreateElementMathML("mspace"));return[node,str,symbol.tag];case STRETCHY:if(isIE&&symbol.input=="\\backslash")
+ symbol.output="\\";node=AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output));if(symbol.input=="|"||symbol.input=="\\vert"||symbol.input=="\\|"||symbol.input=="\\Vert"){node.setAttribute("lspace","0em");node.setAttribute("rspace","0em");}
+ node.setAttribute("maxsize",symbol.atval);if(symbol.rtag!=null)
+ return[node,str,symbol.rtag];else
+ return[node,str,symbol.tag];case BIG:var atval=symbol.atval;if(isIE)
+ atval=symbol.ieval;symbol=AMgetSymbol(str);if(symbol==null)
+ return[null,str,null];str=AMremoveCharsAndBlanks(str,symbol.input.length);node=AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output));if(isIE){var space=AMcreateElementMathML("mspace");space.setAttribute("height",atval+"ex");node=AMcreateMmlNode("mrow",node);node.appendChild(space);}else{node.setAttribute("minsize",atval);node.setAttribute("maxsize",atval);}
+ return[node,str,symbol.tag];case LEFTBRACKET:if(symbol.input=="\\left"){symbol=AMgetSymbol(str);if(symbol!=null){if(symbol.input==".")
+ symbol.invisible=true;str=AMremoveCharsAndBlanks(str,symbol.input.length);}}
+ result=AMparseExpr(str,true,false);if(symbol==null||(typeof symbol.invisible=="boolean"&&symbol.invisible))
+ node=AMcreateMmlNode("mrow",result[0]);else{node=AMcreateMmlNode("mo",document.createTextNode(symbol.output));node=AMcreateMmlNode("mrow",node);node.appendChild(result[0]);}
+ return[node,result[1],result[2]];case MATRIX:if(symbol.input=="\\begin{array}"){var mask="";symbol=AMgetSymbol(str);str=AMremoveCharsAndBlanks(str,0);if(symbol==null)
+ mask="l";else{str=AMremoveCharsAndBlanks(str,symbol.input.length);if(symbol.input!="{")
+ mask="l";else do{symbol=AMgetSymbol(str);if(symbol!=null){str=AMremoveCharsAndBlanks(str,symbol.input.length);if(symbol.input!="}")
+ mask=mask+symbol.input;}}while(symbol!=null&&symbol.input!=""&&symbol.input!="}");}
+ result=AMparseExpr("{"+str,true,true);node=AMcreateMmlNode("mtable",result[0]);mask=mask.replace(/l/g,"left ");mask=mask.replace(/r/g,"right ");mask=mask.replace(/c/g,"center ");node.setAttribute("columnalign",mask);node.setAttribute("displaystyle","false");if(isIE)
+ return[node,result[1],null];var lspace=AMcreateElementMathML("mspace");lspace.setAttribute("width","0.167em");var rspace=AMcreateElementMathML("mspace");rspace.setAttribute("width","0.167em");var node1=AMcreateMmlNode("mrow",lspace);node1.appendChild(node);node1.appendChild(rspace);return[node1,result[1],null];}else{result=AMparseExpr("{"+str,true,true);node=AMcreateMmlNode("mtable",result[0]);if(isIE)
+ node.setAttribute("columnspacing","0.25em");else
+ node.setAttribute("columnspacing","0.167em");node.setAttribute("columnalign","right center left");node.setAttribute("displaystyle","true");node=AMcreateMmlNode("mrow",node);return[node,result[1],null];}
+ case TEXT:if(str.charAt(0)=="{")i=str.indexOf("}");else i=0;if(i==-1)
+ i=str.length;st=str.slice(1,i);if(st.charAt(0)==" "){node=AMcreateElementMathML("mspace");node.setAttribute("width","0.33em");newFrag.appendChild(node);}
+ newFrag.appendChild(AMcreateMmlNode(symbol.tag,document.createTextNode(st)));if(st.charAt(st.length-1)==" "){node=AMcreateElementMathML("mspace");node.setAttribute("width","0.33em");newFrag.appendChild(node);}
+ str=AMremoveCharsAndBlanks(str,i+1);return[AMcreateMmlNode("mrow",newFrag),str,null];case UNARY:result=AMparseSexpr(str);if(result[0]==null)return[AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)),str];if(typeof symbol.func=="boolean"&&symbol.func){st=str.charAt(0);if(st=="^"||st=="_"||st==","){return[AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)),str,symbol.tag];}else{node=AMcreateMmlNode("mrow",AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)));if(isIE){var space=AMcreateElementMathML("mspace");space.setAttribute("width","0.167em");node.appendChild(space);}
+ node.appendChild(result[0]);return[node,result[1],symbol.tag];}}
+ if(symbol.input=="\\sqrt"){if(isIE){var space=AMcreateElementMathML("mspace");space.setAttribute("height","1.2ex");space.setAttribute("width","0em");node=AMcreateMmlNode(symbol.tag,result[0])
+ node.appendChild(space);return[node,result[1],symbol.tag];}else
+ return[AMcreateMmlNode(symbol.tag,result[0]),result[1],symbol.tag];}else if(typeof symbol.acc=="boolean"&&symbol.acc){node=AMcreateMmlNode(symbol.tag,result[0]);var output=symbol.output;if(isIE){if(symbol.input=="\\hat")
+ output="\u0302";else if(symbol.input=="\\widehat")
+ output="\u005E";else if(symbol.input=="\\bar")
+ output="\u00AF";else if(symbol.input=="\\grave")
+ output="\u0300";else if(symbol.input=="\\tilde")
+ output="\u0303";}
+ var node1=AMcreateMmlNode("mo",document.createTextNode(output));if(symbol.input=="\\vec"||symbol.input=="\\check")
+ node1.setAttribute("maxsize","1.2");if(isIE&&symbol.input=="\\bar")
+ node1.setAttribute("maxsize","0.5");if(symbol.input=="\\underbrace"||symbol.input=="\\underline")
+ node1.setAttribute("accentunder","true");else
+ node1.setAttribute("accent","true");node.appendChild(node1);if(symbol.input=="\\overbrace"||symbol.input=="\\underbrace")
+ node.ttype=UNDEROVER;return[node,result[1],symbol.tag];}else{if(!isIE&&typeof symbol.codes!="undefined"){for(i=0;i<result[0].childNodes.length;i++)
+ if(result[0].childNodes[i].nodeName=="mi"||result[0].nodeName=="mi"){st=(result[0].nodeName=="mi"?result[0].firstChild.nodeValue:result[0].childNodes[i].firstChild.nodeValue);var newst=[];for(var j=0;j<st.length;j++)
+ if(st.charCodeAt(j)>64&&st.charCodeAt(j)<91)newst=newst+
+ String.fromCharCode(symbol.codes[st.charCodeAt(j)-65]);else newst=newst+st.charAt(j);if(result[0].nodeName=="mi")
+ result[0]=AMcreateElementMathML("mo").appendChild(document.createTextNode(newst));else result[0].replaceChild(AMcreateElementMathML("mo").appendChild(document.createTextNode(newst)),result[0].childNodes[i]);}}
+ node=AMcreateMmlNode(symbol.tag,result[0]);node.setAttribute(symbol.atname,symbol.atval);if(symbol.input=="\\scriptstyle"||symbol.input=="\\scriptscriptstyle")
+ node.setAttribute("displaystyle","false");return[node,result[1],symbol.tag];}
+ case BINARY:result=AMparseSexpr(str);if(result[0]==null)return[AMcreateMmlNode("mo",document.createTextNode(symbol.input)),str,null];result2=AMparseSexpr(result[1]);if(result2[0]==null)return[AMcreateMmlNode("mo",document.createTextNode(symbol.input)),str,null];if(symbol.input=="\\textcolor"||symbol.input=="\\colorbox"){var tclr=str.match(/\{\s*([#\w]+)\s*\}/);str=str.replace(/\{\s*[#\w]+\s*\}/,"");if(tclr!=null){if(IsColorName.test(tclr[1].toLowerCase())){tclr=LaTeXColor[tclr[1].toLowerCase()];}else{tclr=tclr[1];}
+ node=AMcreateElementMathML("mstyle");node.setAttribute(symbol.atval,tclr);node.appendChild(result2[0]);return[node,result2[1],symbol.tag];}}
+ if(symbol.input=="\\root"||symbol.input=="\\stackrel")newFrag.appendChild(result2[0]);newFrag.appendChild(result[0]);if(symbol.input=="\\frac")newFrag.appendChild(result2[0]);return[AMcreateMmlNode(symbol.tag,newFrag),result2[1],symbol.tag];case INFIX:str=AMremoveCharsAndBlanks(str,symbol.input.length);return[AMcreateMmlNode("mo",document.createTextNode(symbol.output)),str,symbol.tag];default:return[AMcreateMmlNode(symbol.tag,document.createTextNode(symbol.output)),str,symbol.tag];}}
+ function AMparseIexpr(str){var symbol,sym1,sym2,node,result,tag,underover;str=AMremoveCharsAndBlanks(str,0);sym1=AMgetSymbol(str);result=AMparseSexpr(str);node=result[0];str=result[1];tag=result[2];symbol=AMgetSymbol(str);if(symbol.ttype==INFIX){str=AMremoveCharsAndBlanks(str,symbol.input.length);result=AMparseSexpr(str);if(result[0]==null)
+ result[0]=AMcreateMmlNode("mo",document.createTextNode("\u25A1"));str=result[1];tag=result[2];if(symbol.input=="_"||symbol.input=="^"){sym2=AMgetSymbol(str);tag=null;underover=((sym1.ttype==UNDEROVER)||(node.ttype==UNDEROVER));if(symbol.input=="_"&&sym2.input=="^"){str=AMremoveCharsAndBlanks(str,sym2.input.length);var res2=AMparseSexpr(str);str=res2[1];tag=res2[2];node=AMcreateMmlNode((underover?"munderover":"msubsup"),node);node.appendChild(result[0]);node.appendChild(res2[0]);}else if(symbol.input=="_"){node=AMcreateMmlNode((underover?"munder":"msub"),node);node.appendChild(result[0]);}else{node=AMcreateMmlNode((underover?"mover":"msup"),node);node.appendChild(result[0]);}
+ node=AMcreateMmlNode("mrow",node);}else{node=AMcreateMmlNode(symbol.tag,node);if(symbol.input=="\\atop"||symbol.input=="\\choose")
+ node.setAttribute("linethickness","0ex");node.appendChild(result[0]);if(symbol.input=="\\choose")
+ node=AMcreateMmlNode("mfenced",node);}}
+ return[node,str,tag];}
+ function AMparseExpr(str,rightbracket,matrix){var symbol,node,result,i,tag,newFrag=document.createDocumentFragment();do{str=AMremoveCharsAndBlanks(str,0);result=AMparseIexpr(str);node=result[0];str=result[1];tag=result[2];symbol=AMgetSymbol(str);if(node!=undefined){if((tag=="mn"||tag=="mi")&&symbol!=null&&typeof symbol.func=="boolean"&&symbol.func){var space=AMcreateElementMathML("mspace");space.setAttribute("width","0.167em");node=AMcreateMmlNode("mrow",node);node.appendChild(space);}
+ newFrag.appendChild(node);}}while((symbol.ttype!=RIGHTBRACKET)&&symbol!=null&&symbol.output!="");tag=null;if(symbol.ttype==RIGHTBRACKET){if(symbol.input=="\\right"){str=AMremoveCharsAndBlanks(str,symbol.input.length);symbol=AMgetSymbol(str);if(symbol!=null&&symbol.input==".")
+ symbol.invisible=true;if(symbol!=null)
+ tag=symbol.rtag;}
+ if(symbol!=null)
+ str=AMremoveCharsAndBlanks(str,symbol.input.length);var len=newFrag.childNodes.length;if(matrix&&len>0&&newFrag.childNodes[len-1].nodeName=="mrow"&&len>1&&newFrag.childNodes[len-2].nodeName=="mo"&&newFrag.childNodes[len-2].firstChild.nodeValue=="&"){var pos=[];var m=newFrag.childNodes.length;for(i=0;matrix&&i<m;i=i+2){pos[i]=[];node=newFrag.childNodes[i];for(var j=0;j<node.childNodes.length;j++)
+ if(node.childNodes[j].firstChild.nodeValue=="&")
+ pos[i][pos[i].length]=j;}
+ var row,frag,n,k,table=document.createDocumentFragment();for(i=0;i<m;i=i+2){row=document.createDocumentFragment();frag=document.createDocumentFragment();node=newFrag.firstChild;n=node.childNodes.length;k=0;for(j=0;j<n;j++){if(typeof pos[i][k]!="undefined"&&j==pos[i][k]){node.removeChild(node.firstChild);row.appendChild(AMcreateMmlNode("mtd",frag));k++;}else frag.appendChild(node.firstChild);}
+ row.appendChild(AMcreateMmlNode("mtd",frag));if(newFrag.childNodes.length>2){newFrag.removeChild(newFrag.firstChild);newFrag.removeChild(newFrag.firstChild);}
+ table.appendChild(AMcreateMmlNode("mtr",row));}
+ return[table,str];}
+ if(typeof symbol.invisible!="boolean"||!symbol.invisible){node=AMcreateMmlNode("mo",document.createTextNode(symbol.output));newFrag.appendChild(node);}}
+ return[newFrag,str,tag];}
+ function AMparseMath(str){var result,node=AMcreateElementMathML("mstyle");var cclr=str.match(/\\color\s*\{\s*([#\w]+)\s*\}/);str=str.replace(/\\color\s*\{\s*[#\w]+\s*\}/g,"");if(cclr!=null){if(IsColorName.test(cclr[1].toLowerCase())){cclr=LaTeXColor[cclr[1].toLowerCase()];}else{cclr=cclr[1];}
+ node.setAttribute("mathcolor",cclr);}else{if(mathcolor!="")node.setAttribute("mathcolor",mathcolor);};if(mathfontfamily!="")node.setAttribute("fontfamily",mathfontfamily);node.appendChild(AMparseExpr(str.replace(/^\s+/g,""),false,false)[0]);node=AMcreateMmlNode("math",node);if(showasciiformulaonhover)
+ node.setAttribute("title",str.replace(/\s+/g," "));if(false){var fnode=AMcreateElementXHTML("font");fnode.setAttribute("face",mathfontfamily);fnode.appendChild(node);return fnode;}
+ return node;}
+ function AMstrarr2docFrag(arr,linebreaks){var newFrag=document.createDocumentFragment();var expr=false;for(var i=0;i<arr.length;i++){if(expr)newFrag.appendChild(AMparseMath(arr[i]));else{var arri=(linebreaks?arr[i].split("\n\n"):[arr[i]]);newFrag.appendChild(AMcreateElementXHTML("span").appendChild(document.createTextNode(arri[0])));for(var j=1;j<arri.length;j++){newFrag.appendChild(AMcreateElementXHTML("p"));newFrag.appendChild(AMcreateElementXHTML("span").appendChild(document.createTextNode(arri[j])));}}
+ expr=!expr;}
+ return newFrag;}
+ function AMprocessNodeR(n,linebreaks){var mtch,str,arr,frg,i;if(n.childNodes.length==0){if((n.nodeType!=8||linebreaks)&&n.parentNode.nodeName!="form"&&n.parentNode.nodeName!="FORM"&&n.parentNode.nodeName!="textarea"&&n.parentNode.nodeName!="TEXTAREA"&&n.parentNode.nodeName!="pre"&&n.parentNode.nodeName!="PRE"){str=n.nodeValue;if(!(str==null)){str=str.replace(/\r\n\r\n/g,"\n\n");str=str.replace(/\x20+/g," ");str=str.replace(/\s*\r\n/g," ");mtch=(str.indexOf("\$")==-1?false:true);str=str.replace(/([^\\])\$/g,"$1 \$");str=str.replace(/^\$/," \$");arr=str.split(" \$");for(i=0;i<arr.length;i++)
+ arr[i]=arr[i].replace(/\\\$/g,"\$");if(arr.length>1||mtch){if(checkForMathML){checkForMathML=false;var nd=AMisMathMLavailable();AMnoMathML=nd!=null;if(AMnoMathML&&notifyIfNoMathML)
+ if(alertIfNoMathML)
+ alert("To view the ASCIIMathML notation use Internet Explorer 6 +\nMathPlayer (free from www.dessci.com)\nor Firefox/Mozilla/Netscape");else AMbody.insertBefore(nd,AMbody.childNodes[0]);}
+ if(!AMnoMathML){frg=AMstrarr2docFrag(arr,n.nodeType==8);var len=frg.childNodes.length;n.parentNode.replaceChild(frg,n);return len-1;}else return 0;}}}else return 0;}else if(n.nodeName!="math"){for(i=0;i<n.childNodes.length;i++)
+ i+=AMprocessNodeR(n.childNodes[i],linebreaks);}
+ return 0;}
+ function AMprocessNode(n,linebreaks,spanclassAM){var frag,st;if(spanclassAM!=null){frag=document.getElementsByTagName("span")
+ for(var i=0;i<frag.length;i++)
+ if(frag[i].className=="AM")
+ AMprocessNodeR(frag[i],linebreaks);}else{try{st=n.innerHTML;}catch(err){}
+ if(st==null||st.indexOf("\$")!=-1)
+ AMprocessNodeR(n,linebreaks);}
+ if(isIE){frag=document.getElementsByTagName('math');for(var i=0;i<frag.length;i++)frag[i].update()}}
+ var inAppendix=false;var sectionCntr=0;var IEcommentWarning=true;var biblist=[];var bibcntr=0;var LaTeXCounter=[];LaTeXCounter["definition"]=0;LaTeXCounter["proposition"]=0;LaTeXCounter["lemma"]=0;LaTeXCounter["theorem"]=0;LaTeXCounter["corollary"]=0;LaTeXCounter["example"]=0;LaTeXCounter["exercise"]=0;LaTeXCounter["subsection"]=0;LaTeXCounter["subsubsection"]=0;LaTeXCounter["figure"]=0;LaTeXCounter["equation"]=0;LaTeXCounter["table"]=0;var LaTeXColor=[];LaTeXColor["greenyellow"]="#D9FF4F";LaTeXColor["yellow"]="#FFFF00";LaTeXColor["goldenrod"]="#FFE529";LaTeXColor["dandelion"]="#FFB529";LaTeXColor["apricot"]="#FFAD7A";LaTeXColor["peach"]="#FF804D";LaTeXColor["melon"]="#FF8A80";LaTeXColor["yelloworange"]="#FF9400";LaTeXColor["orange"]="#FF6321";LaTeXColor["burntorange"]="#FF7D00";LaTeXColor["bittersweet"]="#C20300";LaTeXColor["redorange"]="#FF3B21";LaTeXColor["mahogany"]="#A60000";LaTeXColor["maroon"]="#AD0000";LaTeXColor["brickred"]="#B80000";LaTeXColor["red"]="#FF0000";LaTeXColor["orangered"]="#FF0080";LaTeXColor["rubinered"]="#FF00DE";LaTeXColor["wildstrawberry"]="#FF0A9C";LaTeXColor["salmon"]="#FF789E";LaTeXColor["carnationpink"]="#FF5EFF";LaTeXColor["magenta"]="#FF00FF";LaTeXColor["violetred"]="#FF30FF";LaTeXColor["rhodamine"]="#FF2EFF";LaTeXColor["mulberry"]="#A314FA";LaTeXColor["redviolet"]="#9600A8";LaTeXColor["fuchsia"]="#7303EB";LaTeXColor["lavender"]="#FF85FF";LaTeXColor["thistle"]="#E069FF";LaTeXColor["orchid"]="#AD5CFF";LaTeXColor["darkorchid"]="#9933CC";LaTeXColor["purple"]="#8C24FF";LaTeXColor["plum"]="#8000FF";LaTeXColor["violet"]="#361FFF";LaTeXColor["royalpurple"]="#401AFF";LaTeXColor["blueviolet"]="#1A0DF5";LaTeXColor["periwinkle"]="#6E73FF";LaTeXColor["cadetblue"]="#616EC4";LaTeXColor["cornflowerblue"]="#59DEFF";LaTeXColor["midnightblue"]="#007091";LaTeXColor["navyblue"]="#0F75FF";LaTeXColor["royalblue"]="#0080FF";LaTeXColor["blue"]="#0000FF";LaTeXColor["cerulean"]="#0FE3FF";LaTeXColor["cyan"]="#00FFFF";LaTeXColor["processblue"]="#0AFFFF";LaTeXColor["skyblue"]="#61FFE0";LaTeXColor["turquoise"]="#26FFCC";LaTeXColor["tealblue"]="#1FFAA3";LaTeXColor["aquamarine"]="#2EFFB2";LaTeXColor["bluegreen"]="#26FFAB";LaTeXColor["emerald"]="#00FF80";LaTeXColor["junglegreen"]="#03FF7A";LaTeXColor["seagreen"]="#4FFF80";LaTeXColor["green"]="#00FF00";LaTeXColor["forestgreen"]="#00E000";LaTeXColor["pinegreen"]="#00BF29";LaTeXColor["limegreen"]="#80FF00";LaTeXColor["yellowgreen"]="#8FFF42";LaTeXColor["springgreen"]="#BDFF3D";LaTeXColor["olivegreen"]="#009900";LaTeXColor["rawsienna"]="#8C0000";LaTeXColor["sepia"]="#4D0000";LaTeXColor["brown"]="#660000";LaTeXColor["tan"]="#DB9470";LaTeXColor["gray"]="#808080";LaTeXColor["grey"]="#808080";LaTeXColor["black"]="#000000";LaTeXColor["white"]="#FFFFFF";var IsColorName=/^(?:greenyellow|yellow|goldenrod|dandelion|apricot|peach|melon|yelloworange|orange|burntorange|bittersweet|redorange|mahogany|maroon|brickred|red|orangered|rubinered|wildstrawberry|salmon|carnationpink|magenta|violetred|rhodamine|mulberry|redviolet|fuchsia|lavender|thistle|orchid|darkorchid|purple|plum|violet|royalpurple|blueviolet|periwinkle|cadetblue|cornflowerblue|midnightblue|navyblue|royalblue|blue|cerulean|cyan|processblue|skyblue|turquoise|tealblue|aquamarine|bluegreen|emerald|junglegreen|seagreen|green|forestgreen|pinegreen|limegreen|yellowgreen|springgreen|olivegreen|rawsienna|sepia|brown|tan|gray|grey|black|white)$/;var IsCounter=/^(?:definition|proposition|lemma|theorem|corollary|example|exercise|subsection|subsubsection|figure|equation|table)$/;var IsLaTeXElement=/^(?:displayequation|title|author|address|date|abstract|keyword|section|subsection|subsubsection|ref|cite|thebibliography|definition|proposition|lemma|theorem|corollary|example|exercise|itemize|enumerate|enddefinition|endproposition|endlemma|endtheorem|endcorollary|endexample|endexercise|enditemize|endenumerate|LaTeXMathMLlabel|LaTeXMathML|smallskip|medskip|bigskip|quote|quotation|endquote|endquotation|center|endcenter|description|enddescription|inlinemath)$/;var IsTextOnlyArea=/^(?:form|textarea|pre)$/i;var tableid=0;function makeNumberString(cntr){if(sectionCntr>0){if(inAppendix){return"A"+sectionCntr+"."+cntr;}else{return sectionCntr+"."+cntr;}}else{return""+cntr;}};function LaTeXpreProcess(thebody){var TheBody=thebody;if(TheBody.hasChildNodes()){if(!(IsLaTeXElement.test(TheBody.className)))
+ {for(var i=0;i<TheBody.childNodes.length;i++){LaTeXpreProcess(TheBody.childNodes[i])}}}
+ else{if(TheBody.nodeType==3&&!(IsTextOnlyArea.test(TheBody.parentNode.nodeName)))
+ {var str=TheBody.nodeValue;if(!(str==null)){str=str.replace(/\\%/g,"<per>");str=str.replace(/%[^\n]*(?=\n)/g,"");str=str.replace(/%[^\r]*(?=\r)/g,"");str=str.replace(/%[^\n]*$/,"")
+ if(isIE&&str.match(/%/g)!=null&&IEcommentWarning){alert("Comments may not have parsed properly. Try putting in <pre class='LaTeX><div>..</div></pre> structure.");IEcommentWarning=false;}
+ str=str.replace(/<per>/g,"%");if(str.match(/XXX[\s\S]*/)!=null){var tmp=str.match(/XXX[\s\S]*/)[0];var tmpstr=tmp.charCodeAt(7)+"::"+tmp.charCodeAt(8)+"::"+tmp.charCodeAt(9)+"::"+tmp.charCodeAt(10)+"::"+tmp.charCodeAt(11)+"::"+tmp.charCodeAt(12)+"::"+tmp.charCodeAt(13);alert(tmpstr);}
+ str=str.replace(/([^\\])\\(\s)/g,"$1\u00A0$2");str=str.replace(/\\quad/g,"\u2001");str=str.replace(/\\qquad/g,"\u2001\u2001");str=str.replace(/\\enspace/g,"\u2002");str=str.replace(/\\;/g,"\u2004");str=str.replace(/\\:/g,"\u2005");str=str.replace(/\\,/g,"\u2006");str=str.replace(/\\thinspace/g,"\u200A");str=str.replace(/([^\\])~/g,"$1\u00A0");str=str.replace(/\\~/g,"~");str=str.replace(/\\\[/g," <DEQ> $\\displaystyle{");str=str.replace(/\\\]/g,"}$ <DEQ> ");str=str.replace(/\$\$/g,"${$<DEQ>$}$");str=str.replace(/\\begin\s*\{\s*array\s*\}/g,"\\begin{array}");str=str.replace(/\\end\s*\{\s*array\s*\}/g,"\\end{array}");str=str.replace(/\\begin\s*\{\s*eqnarray\s*\}/g," <DEQ>eqno$\\begin{eqnarray}");str=str.replace(/\\end\s*\{\s*eqnarray\s*\}/g,"\\end{eqnarray}$<DEQ> ");str=str.replace(/\\begin\s*\{\s*eqnarray\*\s*\}/g," <DEQ>$\\begin{eqnarray}");str=str.replace(/\\end\s*\{\s*eqnarray\*\s*\}/g,"\\end{eqnarray}$<DEQ> ");str=str.replace(/\\begin\s*\{\s*displaymath\s*\}/g," <DEQ> $\\displaystyle{");str=str.replace(/\\end\s*\{\s*displaymath\s*\}/g,"}$ <DEQ> ");str=str.replace(/\\begin\s*\{\s*equation\s*\*\s*\}/g," <DEQ> $\\displaystyle{");str=str.replace(/\\end\s*\{\s*equation\s*\*\s*\}/g,"}$ <DEQ> ");str=str.replace(/\\begin\s*\{\s*equation\s*\}/g," <DEQ>eqno$\\displaystyle{");str=str.replace(/\\end\s*\{\s*equation\s*\}/g,"}$ <DEQ> ");str=str.split("<DEQ>");var newFrag=document.createDocumentFragment();for(var i=0;i<str.length;i++){if(i%2){var DEQtable=document.createElement("table");DEQtable.className='displayequation';var DEQtbody=document.createElement("tbody");var DEQtr=document.createElement("tr");var DEQtdeq=document.createElement("td");DEQtdeq.className='eq';str[i]=str[i].replace(/\$\}\$/g,"$\\displaystyle{");str[i]=str[i].replace(/\$\{\$/g,"}");var lbl=str[i].match(/\\label\s*\{\s*(\w+)\s*\}/);var ISeqno=str[i].match(/^eqno/);str[i]=str[i].replace(/^eqno/," ");str[i]=str[i].replace(/\\label\s*\{\s*\w+\s*\}/," ");DEQtdeq.appendChild(document.createTextNode(str[i]));DEQtr.appendChild(DEQtdeq);str[i]=str[i].replace(/\\nonumber/g,"");if(ISeqno!=null||lbl!=null){var DEQtdno=document.createElement("td");DEQtdno.className='eqno';LaTeXCounter["equation"]++;var eqnoString=makeNumberString(LaTeXCounter["equation"]);var DEQanchor=document.createElement("a");if(lbl!=null){DEQanchor.id=lbl[1]};DEQanchor.className="eqno";var anchorSpan=document.createElement("span");anchorSpan.className="eqno";anchorSpan.style.display="none";anchorSpan.appendChild(document.createTextNode(eqnoString));DEQanchor.appendChild(anchorSpan);DEQtdno.appendChild(DEQanchor);var DEQspan=document.createElement("span");DEQspan.className="eqno";DEQspan.appendChild(document.createTextNode("("+eqnoString+")"));DEQtdno.appendChild(DEQspan);DEQtr.appendChild(DEQtdno);}
+ DEQtbody.appendChild(DEQtr);DEQtable.appendChild(DEQtbody);newFrag.appendChild(DEQtable);}
+ else{str[i]=str[i].replace(/\$\}\$/g,"");str[i]=str[i].replace(/\$\{\$/g,"");str[i]=str[i].replace(/\\maketitle/g,"");str[i]=str[i].replace(/\\begin\s*\{\s*document\s*\}/g,"");str[i]=str[i].replace(/\\end\s*\{\s*document\s*\}/g,"");str[i]=str[i].replace(/\\documentclass[^\}]*?\}/g,"");str[i]=str[i].replace(/\\usepackage[^\}]*?\}/g,"");str[i]=str[i].replace(/\\noindent/g,"");str[i]=str[i].replace(/\\notag/g,"");str[i]=str[i].replace(/\\ref\s*\{\s*(\w+)\}/g," \\[ref\\]$1\\[ ");str[i]=str[i].replace(/\\url\s*\{\s*([^\}\n]+)\}/g," \\[url\\]$1\\[ ");str[i]=str[i].replace(/\\href\s*\{\s*([^\}]+)\}\s*\{\s*([^\}]+)\}/g," \\[href\\]$1\\]$2\\[ ");str[i]=str[i].replace(/\\cite\s*\{\s*(\w+)\}/g," \\[cite\\]$1\\[ ");str[i]=str[i].replace(/\\qed/g,"\u220E");str[i]=str[i].replace(/\\endproof/g,"\u220E");str[i]=str[i].replace(/\\proof/g,"\\textbf{Proof: }");str[i]=str[i].replace(/\\n(?=\s)/g," \\[br\\] \\[ ");str[i]=str[i].replace(/\\newline/g," \\[br\\] \\[ ");str[i]=str[i].replace(/\\linebreak/g," \\[br\\] \\[ ");str[i]=str[i].replace(/\\smallskip/g," \\[logicalbreak\\]smallskip\\[ ");str[i]=str[i].replace(/\\medskip/g," \\[logicalbreak\\]medskip\\[ ");str[i]=str[i].replace(/\\bigskip/g," \\[logicalbreak\\]bigskip\\[ ");str[i]=str[i].replace(/[\n\r]+[ \f\n\r\t\v\u2028\u2029]*[\n\r]+/g," \\[logicalbreak\\]LaTeXMathML\\[ ");if(isIE){str[i]=str[i].replace(/\r/g," ");}
+ str[i]=str[i].replace(/\\bibitem\s*([^\{]*\{\s*\w*\s*\})/g," \\[bibitem\\]$1\\[ ");str[i]=str[i].replace(/\\bibitem\s*/g," \\[bibitem\\] \\[ ");str[i]=str[i].replace(/\\item\s*\[\s*(\w+)\s*\]/g," \\[alistitem\\]$1\\[ ");str[i]=str[i].replace(/\\item\s*/g," \\[alistitem\\] \\[ ");str[i]=str[i].replace(/\\appendix/g," \\[appendix\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*figure\s*\}([\s\S]+?)\\end\s*\{\s*figure\s*\}/g," \\[figure\\]$1\\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*table\s*\}([\s\S]+?)\\end\s*\{\s*table\s*\}/g," \\[table\\]$1\\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*theorem\s*\}/g," \\[theorem\\]Theorem \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*theorem\s*\}/g," \\[endtheorem\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*definition\s*\}/g," \\[definition\\]Definition \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*definition\s*\}/g," \\[enddefinition\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*lemma\s*\}/g," \\[lemma\\]Lemma \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*lemma\s*\}/g," \\[endlemma\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*corollary\s*\}/g," \\[corollary\\]Corollary \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*corollary\s*\}/g," \\[endcorollary\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*proposition\s*\}/g," \\[proposition\\]Proposition \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*proposition\s*\}/g," \\[endproposition\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*example\s*\}/g," \\[example\\]Example \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*example\s*\}/g," \\[endexample\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*exercise\s*\}/g," \\[exercise\\]Exercise \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*exercise\s*\}/g," \\[endexercise\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*thebibliography\s*\}\s*\{\s*\w+\s*\}/g," \\[thebibliography\\]References \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*thebibliography\s*\}/g," \\[thebibliography\\]References \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*thebibliography\s*\}/g," \\[endthebibliography\\]References \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*proof\s*\}/g," \\[proof\\]Proof: \\[ ");if(isIE){str[i]=str[i].replace(/\\end\s*\{\s*proof\s*\}/g,"\u220E \\[endproof\\] \\[ ");}else{str[i]=str[i].replace(/\\end\s*\{\s*proof\s*\}/g," \\[endproof\\] \\[ ");}
+ str[i]=str[i].replace(/\\title\s*\{\s*([^\}]+)\}/g," \\[title\\] \\[$1 \\[endtitle\\] \\[ ");str[i]=str[i].replace(/\\author\s*\{\s*([^\}]+)\}/g," \\[author\\] \\[$1 \\[endauthor\\] \\[ ");str[i]=str[i].replace(/\\address\s*\{\s*([^\}]+)\}/g," \\[address\\] \\[$1 \\[endaddress\\] \\[ ");str[i]=str[i].replace(/\\date\s*\{\s*([^\}]+)\}/g," \\[date\\] \\[$1 \\[enddate\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*keyword\s*\}/g," \\[keyword\\] \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*keyword\s*\}/g," \\[endkeyword\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*abstract\s*\}/g," \\[abstract\\] \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*abstract\s*\}/g," \\[endabstract\\] \\[ ");str[i]=str[i].replace(/\\begin\s*\{\s*(?!array|tabular)(\w+)\s*\}/g," \\[$1\\] \\[ ");str[i]=str[i].replace(/\\end\s*\{\s*(?!array|tabular)(\w+)\s*\}/g," \\[end$1\\] \\[ ");var sectionIndex=str[i].search(/\\section\s*\{\s*[\s\S]+\}/);while(sectionIndex>=0){str[i]=str[i].replace(/\\section\s*\{/," \\[section\\]");var delimcnt=1;for(var ii=sectionIndex;ii<str[i].length;ii++){if(str[i].charAt(ii)=="{"){delimcnt++};if(str[i].charAt(ii)=="}"){delimcnt--};if(delimcnt==0){str[i]=str[i].substring(0,ii)+"\\[ "+str[i].substring(ii+1,str[i].length);break;}};sectionIndex=str[i].search(/\\section\s*\{\s*[\s\S]+\}/);}
+ sectionIndex=str[i].search(/\\subsection\s*\{\s*[\s\S]+\}/);while(sectionIndex>=0){str[i]=str[i].replace(/\\subsection\s*\{/," \\[subsection\\]");var delimcnt=1;for(var ii=sectionIndex;ii<str[i].length;ii++){if(str[i].charAt(ii)=="{"){delimcnt++};if(str[i].charAt(ii)=="}"){delimcnt--};if(delimcnt==0){str[i]=str[i].substring(0,ii)+"\\[ "+str[i].substring(ii+1,str[i].length);break;}};sectionIndex=str[i].search(/\\subsection\s*\{\s*[\s\S]+\}/);}
+ sectionIndex=str[i].search(/\\subsubsection\s*\{\s*[\s\S]+\}/);while(sectionIndex>=0){str[i]=str[i].replace(/\\subsubsection\s*\{/," \\[subsubsection\\]");var delimcnt=1;for(var ii=sectionIndex;ii<str[i].length;ii++){if(str[i].charAt(ii)=="{"){delimcnt++};if(str[i].charAt(ii)=="}"){delimcnt--};if(delimcnt==0){str[i]=str[i].substring(0,ii)+"\\[ "+str[i].substring(ii+1,str[i].length);break;}};sectionIndex=str[i].search(/\\subsubsection\s*\{\s*[\s\S]+\}/);}
+ var CatToNextEven="";var strtmp=str[i].split("\\[");for(var j=0;j<strtmp.length;j++){if(j%2){var strtmparray=strtmp[j].split("\\]");switch(strtmparray[0]){case"section":var nodeTmp=document.createElement("H2");nodeTmp.className='section';sectionCntr++;for(var div in LaTeXCounter){LaTeXCounter[div]=0};var nodeAnchor=document.createElement("a");if(inAppendix){nodeAnchor.className='appendixsection';}else{nodeAnchor.className='section';}
+ var nodeNumString=makeNumberString("");var anchorSpan=document.createElement("span");anchorSpan.className="section";anchorSpan.style.display="none";anchorSpan.appendChild(document.createTextNode(nodeNumString));nodeAnchor.appendChild(anchorSpan);nodeTmp.appendChild(nodeAnchor);var nodeSpan=document.createElement("span");nodeSpan.className='section';nodeSpan.appendChild(document.createTextNode(nodeNumString+" "));nodeTmp.appendChild(nodeSpan);nodeTmp.appendChild(document.createTextNode(strtmparray[1]));newFrag.appendChild(nodeTmp);break;case"subsection":var nodeTmp=document.createElement("H3");nodeTmp.className='subsection';LaTeXCounter["subsection"]++;LaTeXCounter["subsubsection"]=0;var nodeAnchor=document.createElement("a");nodeAnchor.className='subsection';var nodeNumString=makeNumberString(LaTeXCounter["subsection"]);var anchorSpan=document.createElement("span");anchorSpan.className="subsection";anchorSpan.style.display="none";anchorSpan.appendChild(document.createTextNode(nodeNumString));nodeAnchor.appendChild(anchorSpan);nodeTmp.appendChild(nodeAnchor);var nodeSpan=document.createElement("span");nodeSpan.className='subsection';nodeSpan.appendChild(document.createTextNode(nodeNumString+". "));nodeTmp.appendChild(nodeSpan);nodeTmp.appendChild(document.createTextNode(strtmparray[1]));newFrag.appendChild(nodeTmp);break;case"subsubsection":var nodeTmp=document.createElement("H4");nodeTmp.className='subsubsection';LaTeXCounter["subsubsection"]++;var nodeAnchor=document.createElement("a");nodeAnchor.className='subsubsection';var nodeNumString=makeNumberString(LaTeXCounter["subsection"]+"."+LaTeXCounter["subsubsection"]);var anchorSpan=document.createElement("span");anchorSpan.className="subsubsection";anchorSpan.style.display="none";anchorSpan.appendChild(document.createTextNode(nodeNumString));nodeAnchor.appendChild(anchorSpan);nodeTmp.appendChild(nodeAnchor);var nodeSpan=document.createElement("span");nodeSpan.className='subsubsection';nodeSpan.appendChild(document.createTextNode(nodeNumString+". "));nodeTmp.appendChild(nodeSpan);nodeTmp.appendChild(document.createTextNode(strtmparray[1]));newFrag.appendChild(nodeTmp);break;case"href":var nodeTmp=document.createElement("a");nodeTmp.className='LaTeXMathML';nodeTmp.href=strtmparray[1];nodeTmp.appendChild(document.createTextNode(strtmparray[2]));newFrag.appendChild(nodeTmp);break;case"url":var nodeTmp=document.createElement("a");nodeTmp.className='LaTeXMathML';nodeTmp.href=strtmparray[1];nodeTmp.appendChild(document.createTextNode(strtmparray[1]));newFrag.appendChild(nodeTmp);break;case"figure":var nodeTmp=document.createElement("table");nodeTmp.className='figure';var FIGtbody=document.createElement("tbody");var FIGlbl=strtmparray[1].match(/\\label\s*\{\s*(\w+)\s*\}/);strtmparray[1]=strtmparray[1].replace(/\\label\s*\{\w+\}/g,"");var capIndex=strtmparray[1].search(/\\caption\s*\{[\s\S]+\}/);var FIGcap="";if(capIndex>=0){var tmp=strtmparray[1];var delimcnt=0;var capstart=-1;for(var pos=capIndex;pos<tmp.length;pos++){if(tmp.charAt(pos)=="{"){delimcnt++};if(tmp.charAt(pos)=="}"){delimcnt--};if(delimcnt==1&&capstart<0){capstart=pos+1};if(delimcnt==0&&capstart>0){capend=pos-1;FIGcap=tmp.substring(capstart,pos);break}}}
+ var FIGtr2=document.createElement("tr");var FIGtd2=document.createElement("td");FIGtd2.className="caption";var FIGanchor=document.createElement("a");FIGanchor.className="figure";if(FIGlbl!=null){FIGanchor.id=FIGlbl[1];}
+ LaTeXCounter["figure"]++;var fignmbr=makeNumberString(LaTeXCounter["figure"]);var anchorSpan=document.createElement("span");anchorSpan.className="figure";anchorSpan.style.display="none";anchorSpan.appendChild(document.createTextNode(fignmbr));FIGanchor.appendChild(anchorSpan);FIGtd2.appendChild(FIGanchor);var FIGspan=document.createElement("span");FIGspan.className="figure";FIGspan.appendChild(document.createTextNode("Figure "+fignmbr+". "));FIGtd2.appendChild(FIGspan);FIGtd2.appendChild(document.createTextNode(""+FIGcap));FIGtr2.appendChild(FIGtd2);FIGtbody.appendChild(FIGtr2);var IsSpecial=false;var FIGinfo=strtmparray[1].match(/\\includegraphics\s*\{([^\}]+)\}/);if(FIGinfo==null){FIGinfo=strtmparray[1].match(/\\includegraphics\s*\[[^\]]*\]\s*\{\s*([^\}]+)\s*\}/);}
+ if(FIGinfo==null){FIGinfo=strtmparray[1].match(/\\special\s*\{\s*([^\}]+)\}/);IsSpecial=true};if(FIGinfo!=null){var FIGtr1=document.createElement("tr");var FIGtd1=document.createElement("td");FIGtd1.className="image";var FIGimg=document.createElement("img");var FIGsrc=FIGinfo[1];FIGimg.src=FIGsrc;FIGimg.alt="Figure "+FIGsrc+" did not load";FIGimg.title="Figure "+fignmbr+". "+FIGcap;FIGimg.id="figure"+fignmbr;FIGtd1.appendChild(FIGimg);FIGtr1.appendChild(FIGtd1);FIGtbody.appendChild(FIGtr1);}
+ nodeTmp.appendChild(FIGtbody);newFrag.appendChild(nodeTmp);break;case"table":var nodeTmp=document.createElement("table");if(strtmparray[1].search(/\\centering/)>=0){nodeTmp.className='LaTeXtable centered';nodeTmp.align="center";}else{nodeTmp.className='LaTeXtable';};tableid++;nodeTmp.id="LaTeXtable"+tableid;var TABlbl=strtmparray[1].match(/\\label\s*\{\s*(\w+)\s*\}/);strtmparray[1]=strtmparray[1].replace(/\\label\s*\{\w+\}/g,"");var capIndex=strtmparray[1].search(/\\caption\s*\{[\s\S]+\}/);var TABcap="";if(capIndex>=0){var tmp=strtmparray[1];var delimcnt=0;var capstart=-1;for(var pos=capIndex;pos<tmp.length;pos++){if(tmp.charAt(pos)=="{"){delimcnt++};if(tmp.charAt(pos)=="}"){delimcnt--};if(delimcnt==1&&capstart<0){capstart=pos+1};if(delimcnt==0&&capstart>0){capend=pos-1;TABcap=tmp.substring(capstart,pos);break}}}
+ if(TABcap!=""){var TABtbody=document.createElement("tbody");var TABcaption=document.createElement("caption");TABcaption.className="LaTeXtable centered";var TABanchor=document.createElement("a");TABanchor.className="LaTeXtable";if(TABlbl!=null){TABanchor.id=TABlbl[1];}
+ LaTeXCounter["table"]++;var tabnmbr=makeNumberString(LaTeXCounter["table"]);var anchorSpan=document.createElement("span");anchorSpan.className="LaTeXtable";anchorSpan.style.display="none";anchorSpan.appendChild(document.createTextNode(tabnmbr));TABanchor.appendChild(anchorSpan);TABcaption.appendChild(TABanchor);var TABspan=document.createElement("span");TABspan.className="LaTeXtable";TABspan.appendChild(document.createTextNode("Table "+tabnmbr+". "));TABcaption.appendChild(TABspan);TABcaption.appendChild(document.createTextNode(""+TABcap));nodeTmp.appendChild(TABcaption);}
+ var TABinfo=strtmparray[1].match(/\\begin\s*\{\s*tabular\s*\}([\s\S]+)\\end\s*\{\s*tabular\s*\}/);if(TABinfo!=null){var TABtbody=document.createElement('tbody');var TABrow=null;var TABcell=null;var row=0;var col=0;var TABalign=TABinfo[1].match(/^\s*\{([^\}]+)\}/);TABinfo=TABinfo[1].replace(/^\s*\{[^\}]+\}/,"");TABinfo=TABinfo.replace(/\\hline/g,"");TABalign[1]=TABalign[1].replace(/\|/g,"");TABalign[1]=TABalign[1].replace(/\s/g,"");TABinfo=TABinfo.split("\\\\");for(row=0;row<TABinfo.length;row++){TABrow=document.createElement("tr");TABinfo[row]=TABinfo[row].split("&");for(col=0;col<TABinfo[row].length;col++){TABcell=document.createElement("td");switch(TABalign[1].charAt(col)){case"l":TABcell.align="left";break;case"c":TABcell.align="center";break;case"r":TABcell.align="right";break;default:TABcell.align="left";};TABcell.appendChild(document.createTextNode(TABinfo[row][col]));TABrow.appendChild(TABcell);}
+ TABtbody.appendChild(TABrow);}
+ nodeTmp.appendChild(TABtbody);}
+ newFrag.appendChild(nodeTmp);break;case"logicalbreak":var nodeTmp=document.createElement("p");nodeTmp.className=strtmparray[1];nodeTmp.appendChild(document.createTextNode("\u00A0"));newFrag.appendChild(nodeTmp);break;case"appendix":inAppendix=true;sectionCntr=0;break;case"alistitem":var EndDiv=document.createElement("div");EndDiv.className="endlistitem";newFrag.appendChild(EndDiv);var BegDiv=document.createElement("div");BegDiv.className="listitem";if(strtmparray[1]!=" "){var BegSpan=document.createElement("span");BegSpan.className="listitemmarker";var boldBegSpan=document.createElement("b");boldBegSpan.appendChild(document.createTextNode(strtmparray[1]+" "));BegSpan.appendChild(boldBegSpan);BegDiv.appendChild(BegSpan);}
+ newFrag.appendChild(BegDiv);break;case"br":newFrag.appendChild(document.createElement("br"));break;case"bibitem":newFrag.appendChild(document.createElement("br"));var nodeTmp=document.createElement("a");nodeTmp.className='bibitem';var nodeSpan=document.createElement("span");nodeSpan.className='bibitem';bibcntr++;var lbl=strtmparray[1].match(/\{\s*(\w+)\s*\}/);strtmparray[1]=strtmparray[1].replace(/\s*\{\s*\w+\s*\}/g,"");strtmparray[1]=strtmparray[1].replace(/^\s*\[/,"");strtmparray[1]=strtmparray[1].replace(/\s*\]$/,"");strtmparray[1]=strtmparray[1].replace(/^\s+|\s+$/g,"");if(lbl==null){biblist[bibcntr]="bibitem"+bibcntr}else{biblist[bibcntr]=lbl[1];};nodeTmp.name=biblist[bibcntr];nodeTmp.id=biblist[bibcntr];if(strtmparray[1]!=""){nodeSpan.appendChild(document.createTextNode(strtmparray[1]));}else{nodeSpan.appendChild(document.createTextNode("["+bibcntr+"]"));}
+ nodeTmp.appendChild(nodeSpan);newFrag.appendChild(nodeTmp);break;case"cite":var nodeTmp=document.createElement("a");nodeTmp.className='cite';nodeTmp.name='cite';nodeTmp.href="#"+strtmparray[1];newFrag.appendChild(nodeTmp);break;case"ref":var nodeTmp=document.createElement("a");nodeTmp.className='ref';nodeTmp.name='ref';nodeTmp.href="#"+strtmparray[1];newFrag.appendChild(nodeTmp);break;default:var nodeTmp=document.createElement("div");nodeTmp.className=strtmparray[0];if(IsCounter.test(strtmparray[0])){LaTeXCounter[strtmparray[0]]++;var nodeAnchor=document.createElement("a");nodeAnchor.className=strtmparray[0];var divnum=makeNumberString(LaTeXCounter[strtmparray[0]]);var anchorSpan=document.createElement("span");anchorSpan.className=strtmparray[0];anchorSpan.appendChild(document.createTextNode(divnum));anchorSpan.style.display="none";nodeAnchor.appendChild(anchorSpan);nodeTmp.appendChild(nodeAnchor);var nodeSpan=document.createElement("span");nodeSpan.className=strtmparray[0];nodeSpan.appendChild(document.createTextNode(strtmparray[1]+" "+divnum+". "));nodeTmp.appendChild(nodeSpan);}
+ if(isIE){if(strtmparray[0]==("thebibliography"||"abstract"||"keyword"||"proof")){var nodeSpan=document.createElement("span");nodeSpan.className=strtmparray[0];nodeSpan.appendChild(document.createTextNode(strtmparray[1]));nodeTmp.appendChild(nodeSpan);}}
+ if(strtmparray[0]=="endenumerate"||strtmparray[0]=="enditemize"||strtmparray[0]=="enddescription"){var endDiv=document.createElement("div");endDiv.className="endlistitem";newFrag.appendChild(endDiv);}
+ newFrag.appendChild(nodeTmp);if(strtmparray[0]=="enumerate"||strtmparray[0]=="itemize"||strtmparray[0]=="description"){var endDiv=document.createElement("div");endDiv.className="listitem";newFrag.appendChild(endDiv);}}}else{strtmp[j]=strtmp[j].replace(/\\\$/g,"<per>");strtmp[j]=strtmp[j].replace(/\$([^\$]+)\$/g," \\[$1\\[ ");strtmp[j]=strtmp[j].replace(/<per>/g,"\\$");strtmp[j]=strtmp[j].replace(/\\begin\s*\{\s*math\s*\}([\s\S]+?)\\end\s*\{\s*math\s*\}/g," \\[$1\\[ ");var strtmptmp=strtmp[j].split("\\[");for(var jjj=0;jjj<strtmptmp.length;jjj++){if(jjj%2){var nodeTmp=document.createElement("span");nodeTmp.className='inlinemath';nodeTmp.appendChild(document.createTextNode("$"+strtmptmp[jjj]+"$"));newFrag.appendChild(nodeTmp);}else{var TagIndex=strtmptmp[jjj].search(/\\\w+/);var tmpIndex=TagIndex;while(tmpIndex>-1){if(/^\\textcolor/.test(strtmptmp[jjj].substring(TagIndex,strtmptmp[jjj].length))){strtmptmp[jjj]=strtmptmp[jjj].replace(/\\textcolor\s*\{\s*(\w+)\s*\}\s*/," \\[textcolor\\]$1\\]|");}else{if(/^\\colorbox/.test(strtmptmp[jjj].substring(TagIndex,strtmptmp[jjj].length))){strtmptmp[jjj]=strtmptmp[jjj].replace(/\\colorbox\s*\{\s*(\w+)\s*\}\s*/," \\[colorbox\\]$1\\]|");}else{strtmptmp[jjj]=strtmptmp[jjj].substring(0,TagIndex)+strtmptmp[jjj].substring(TagIndex,strtmptmp[jjj].length).replace(/\\\s*(\w+)\s*/," \\[$1\\]|");}}
+ TagIndex+=strtmptmp[jjj].substring(TagIndex,strtmptmp[jjj].length).search(/\|/);TagIndex++;strtmptmp[jjj]=strtmptmp[jjj].replace(/\\\]\|/,"\\] ");if(strtmptmp[jjj].charAt(TagIndex)=="{"){strtmptmp[jjj]=strtmptmp[jjj].substring(0,TagIndex)+strtmptmp[jjj].substring(TagIndex+1,strtmptmp[jjj].length);var delimcnt=1;for(var kk=TagIndex;kk<strtmptmp[jjj].length;kk++){if(strtmptmp[jjj].charAt(kk)=="{"){delimcnt++};if(strtmptmp[jjj].charAt(kk)=="}"){delimcnt--};if(delimcnt==0){break;}}
+ strtmptmp[jjj]=strtmptmp[jjj].substring(0,kk)+"\\[ "+strtmptmp[jjj].substring(kk+1,strtmptmp[jjj].length);TagIndex=kk+3;}else{strtmptmp[jjj]=strtmptmp[jjj].substring(0,TagIndex)+"\\[ "+strtmptmp[jjj].substring(TagIndex+1,strtmptmp[jjj].length);TagIndex=TagIndex+3;}
+ if(TagIndex<strtmptmp[jjj].length){tmpIndex=strtmptmp[jjj].substring(TagIndex,strtmptmp[jjj].length).search(/\\\w+/);}
+ else{tmpIndex=-1};TagIndex+=tmpIndex;}
+ strtmptmp[jjj]=strtmptmp[jjj].replace(/\\\\\s*\\\\/g,"\\\\");strtmptmp[jjj]=strtmptmp[jjj].replace(/\\\\/g," \\[br\\] \\[ ");strtmptmp[jjj]=strtmptmp[jjj].replace(/\\label\s*\{\s*(\w+)\s*\}/g," \\[a\\]$1\\[ ");var strlbls=strtmptmp[jjj].split("\\[");for(var jj=0;jj<strlbls.length;jj++){if(jj%2){var strtmparray=strlbls[jj].split("\\]");switch(strtmparray[0]){case"textcolor":var nodeTmp=document.createElement("span");nodeTmp.className='LaTeXColor';if(IsColorName.test(strtmparray[1].toLowerCase())){nodeTmp.style.color=LaTeXColor[strtmparray[1].toLowerCase()];}else{nodeTmp.style.color=strtmparray[1];};nodeTmp.appendChild(document.createTextNode(strtmparray[2]));newFrag.appendChild(nodeTmp);break;case"colorbox":var nodeTmp=document.createElement("span");nodeTmp.className='LaTeXColor';if(IsColorName.test(strtmparray[1].toLowerCase())){nodeTmp.style.background=LaTeXColor[strtmparray[1].toLowerCase()];}else{nodeTmp.style.background=strtmparray[1];};nodeTmp.appendChild(document.createTextNode(strtmparray[2]));newFrag.appendChild(nodeTmp);break;case"br":newFrag.appendChild(document.createElement("br"));break;case"a":var nodeTmp=document.createElement("a");nodeTmp.className='LaTeXMathMLlabel';nodeTmp.id=strtmparray[1];nodeTmp.style.display="none";newFrag.appendChild(nodeTmp);break;default:var nodeTmp=document.createElement("span");nodeTmp.className=strtmparray[0];nodeTmp.appendChild(document.createTextNode(strtmparray[1]))
+ newFrag.appendChild(nodeTmp);}}else{newFrag.appendChild(document.createTextNode(strlbls[jj]));}}}}}}}};TheBody.parentNode.replaceChild(newFrag,TheBody);}}}
+ return TheBody;}
+ function LaTeXDivsAndRefs(thebody){var TheBody=thebody;var EndDivClass=null;var AllDivs=TheBody.getElementsByTagName("div");var lbl2id="";var lblnode=null;for(var i=AllDivs.length-1;i>=0;i--){EndDivClass=AllDivs[i].className.match(/end\w+/);if(EndDivClass!=null){EndDivClass=EndDivClass[0];var DivClass=EndDivClass.substring(3,EndDivClass.length);var EndDivNode=AllDivs[i];break;}}
+ while(EndDivClass!=null){var newFrag=document.createDocumentFragment();var RootNode=EndDivNode.parentNode;var ClassCount=1;while(EndDivNode.previousSibling!=null&&ClassCount>0){switch(EndDivNode.previousSibling.className){case EndDivClass:ClassCount++;newFrag.insertBefore(EndDivNode.previousSibling,newFrag.firstChild);break;case DivClass:if(EndDivNode.previousSibling.nodeName=="DIV"){ClassCount--;if(lbl2id!=""){EndDivNode.previousSibling.id=lbl2id;lbl2id=""}
+ if(ClassCount==0){RootNode=EndDivNode.previousSibling;}else{newFrag.insertBefore(EndDivNode.previousSibling,newFrag.firstChild);}};break;case'LaTeXMathMLlabel':lbl2id=EndDivNode.previousSibling.id;EndDivNode.parentNode.removeChild(EndDivNode.previousSibling);break;default:newFrag.insertBefore(EndDivNode.previousSibling,newFrag.firstChild);}}
+ RootNode.appendChild(newFrag);EndDivNode.parentNode.removeChild(EndDivNode);AllDivs=TheBody.getElementsByTagName("DIV");for(i=AllDivs.length-1;i>=0;i--){EndDivClass=AllDivs[i].className.match(/end\w+/);if(EndDivClass!=null){ClassCount=0;EndDivClass=EndDivClass[0];DivClass=EndDivClass.substring(3,EndDivClass.length);EndDivNode=AllDivs[i];RootNode=EndDivNode.parentNode;break;}}}
+ var AllDivs=TheBody.getElementsByTagName("div");var DIV2LI=null;for(var i=0;i<AllDivs.length;i++){if(AllDivs[i].className=="itemize"||AllDivs[i].className=="enumerate"||AllDivs[i].className=="description"){if(AllDivs[i].className=="itemize"){RootNode=document.createElement("UL");}else{RootNode=document.createElement("OL");}
+ RootNode.className='LaTeXMathML';if(AllDivs[i].hasChildNodes()){AllDivs[i].removeChild(AllDivs[i].firstChild)};while(AllDivs[i].hasChildNodes()){if(AllDivs[i].firstChild.hasChildNodes()){DIV2LI=document.createElement("LI");while(AllDivs[i].firstChild.hasChildNodes()){DIV2LI.appendChild(AllDivs[i].firstChild.firstChild);}
+ if(DIV2LI.firstChild.className=="listitemmarker"){DIV2LI.style.listStyleType="none";}
+ RootNode.appendChild(DIV2LI)}
+ AllDivs[i].removeChild(AllDivs[i].firstChild);}
+ AllDivs[i].appendChild(RootNode);}}
+ var AllAnchors=TheBody.getElementsByTagName("a");for(var i=0;i<AllAnchors.length;i++){if(AllAnchors[i].className=="ref"||AllAnchors[i].className=="cite"){var label=AllAnchors[i].href.match(/\#(\w+)/);if(label!=null){var labelNode=document.getElementById(label[1]);if(labelNode!=null){var TheSpans=labelNode.getElementsByTagName("SPAN");if(TheSpans!=null){var refNode=TheSpans[0].cloneNode(true);refNode.style.display="inline"
+ refNode.className=AllAnchors[i].className;AllAnchors[i].appendChild(refNode);}}}}}
+ return TheBody;}
+ var AMbody;var AMnoMathML=false,AMtranslated=false;function translate(spanclassAM){if(!AMtranslated){AMtranslated=true;AMinitSymbols();var LaTeXContainers=[];var AllContainers=document.getElementsByTagName('*');var ExtendName="";for(var k=0,l=0;k<AllContainers.length;k++){ExtendName=" "+AllContainers[k].className+" ";if(ExtendName.match(/\sLaTeX\s/)!=null){LaTeXContainers[l]=AllContainers[k];l++;}};if(LaTeXContainers.length>0){for(var m=0;m<LaTeXContainers.length;m++){AMbody=LaTeXContainers[m];try{AMbody=LaTeXDivsAndRefs(LaTeXpreProcess(AMbody));}catch(err){alert("Unknown Error: Defaulting to Original LaTeXMathML");}
+ if(AMbody.tagName=="PRE"){var PreChilds=document.createDocumentFragment();var DivChilds=document.createElement("DIV");while(AMbody.hasChildNodes()){DivChilds.appendChild(AMbody.firstChild);}
+ PreChilds.appendChild(DivChilds);AMbody.parentNode.replaceChild(PreChilds,AMbody);AMbody=DivChilds;}
+ AMprocessNode(AMbody,false,spanclassAM);}}else{AMbody=document.getElementsByTagName("body")[0];try{AMbody=LaTeXDivsAndRefs(LaTeXpreProcess(AMbody));}catch(err){alert("Unknown Error: Defaulting to Original LaTeXMathML");}
+ AMprocessNode(AMbody,false,spanclassAM);}}}
+ if(isIE){document.write("<object id=\"mathplayer\" classid=\"clsid:32F66A20-7614-11D4-BD11-00104BD3F987\"></object>");document.write("<?import namespace=\"m\" implementation=\"#mathplayer\"?>");}
+ function generic()
+ {translate();};if(typeof window.addEventListener!='undefined')
+ {window.addEventListener('load',generic,false);}
+ else if(typeof document.addEventListener!='undefined')
+ {document.addEventListener('load',generic,false);}
+ else if(typeof window.attachEvent!='undefined')
+ {window.attachEvent('onload',generic);}
+ else
+ {if(typeof window.onload=='function')
+ {var existing=onload;window.onload=function()
+ {existing();generic();};}
+ else
+ {window.onload=generic;}}
+ /*]]>*/
+ </script>
+</head>
+<body>
+<div class="layout">
+<div id="controls"></div>
+<div id="currentSlide"></div>
+<div id="header"></div>
+<div id="footer">
+ <h1>July 15, 2006</h1>
+ <h2>My S5 Document</h2>
+</div>
+</div>
+<div class="presentation">
+<div class="titleslide slide">
+ <h1 class="title">My S5 Document</h1>
+ <h3 class="author">Sam Smith<br/>Jen Jones</h3>
+ <h4 class="date">July 15, 2006</h4>
+</div>
+<div id="first-slide" class="slide section level1">
+<h1>First slide</h1>
+<ul class="incremental">
+<li>first bullet</li>
+<li>second bullet</li>
+</ul>
+</div>
+<div id="math" class="slide section level1">
+<h1>Math</h1>
+<ul class="incremental">
+<li><span class="LaTeX">$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span></li>
+</ul>
+</div>
+</div>
+</body>
+</html>
diff --git a/test/s5-fragment.html b/test/s5-fragment.html
new file mode 100644
index 000000000..81c578d25
--- /dev/null
+++ b/test/s5-fragment.html
@@ -0,0 +1,9 @@
+<h1 id="first-slide">First slide</h1>
+<ul>
+<li>first bullet</li>
+<li>second bullet</li>
+</ul>
+<h1 id="math">Math</h1>
+<ul>
+<li><span class="math inline">$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span></li>
+</ul>
diff --git a/test/s5-inserts.html b/test/s5-inserts.html
new file mode 100644
index 000000000..2feed4173
--- /dev/null
+++ b/test/s5-inserts.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <meta name="generator" content="pandoc" />
+ <meta name="author" content="Sam Smith" />
+ <meta name="author" content="Jen Jones" />
+ <meta name="date" content="2006-07-15" />
+ <title>My S5 Document</title>
+ <style type="text/css">code{white-space: pre;}</style>
+ <link rel="stylesheet" href="main.css" type="text/css" />
+ STUFF INSERTED
+</head>
+<body>
+STUFF INSERTED
+<div id="header">
+<h1 class="title">My S5 Document</h1>
+<h2 class="author">Sam Smith</h2>
+<h2 class="author">Jen Jones</h2>
+<h3 class="date">July 15, 2006</h3>
+</div>
+<h1 id="first-slide">First slide</h1>
+<ul>
+<li>first bullet</li>
+<li>second bullet</li>
+</ul>
+<h1 id="math">Math</h1>
+<ul>
+<li><span class="math inline">$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span></li>
+</ul>
+STUFF INSERTED
+</body>
+</html>
diff --git a/test/s5.native b/test/s5.native
new file mode 100644
index 000000000..5796b74a0
--- /dev/null
+++ b/test/s5.native
@@ -0,0 +1,8 @@
+Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "Sam",Space,Str "Smith"],MetaInlines [Str "Jen",Space,Str "Jones"]]),("date",MetaInlines [Str "July",Space,Str "15,",Space,Str "2006"]),("title",MetaInlines [Str "My",Space,Str "S5",Space,Str "Document"])]})
+[Header 1 ("first-slide",[],[]) [Str "First",Space,Str "slide"]
+,BulletList
+ [[Plain [Str "first",Space,Str "bullet"]]
+ ,[Plain [Str "second",Space,Str "bullet"]]]
+,Header 1 ("math",[],[]) [Str "Math"]
+,BulletList
+ [[Plain [Math InlineMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]]]
diff --git a/test/tables-rstsubset.native b/test/tables-rstsubset.native
new file mode 100644
index 000000000..65ced24af
--- /dev/null
+++ b/test/tables-rstsubset.native
@@ -0,0 +1,114 @@
+[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.125,0.1125,0.1375,0.15]
+ [[Plain [Str "Right"]]
+ ,[Plain [Str "Left"]]
+ ,[Plain [Str "Center"]]
+ ,[Plain [Str "Default"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption:"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15]
+ [[Plain [Str "Right"]]
+ ,[Plain [Str "Left"]]
+ ,[Plain [Str "Center"]]
+ ,[Plain [Str "Default"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Simple",Space,Str "table",Space,Str "indented",Space,Str "two",Space,Str "spaces:"]
+,Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax."] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.125,0.1125,0.1375,0.15]
+ [[Plain [Str "Right"]]
+ ,[Plain [Str "Left"]]
+ ,[Plain [Str "Center"]]
+ ,[Plain [Str "Default"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption:"]
+,Table [Str "Here\8217s",Space,Str "the",Space,Str "caption.",Space,Str "It",Space,Str "may",Space,Str "span",Space,Str "multiple",Space,Str "lines."] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625]
+ [[Plain [Str "Centered",Space,Str "Header"]]
+ ,[Plain [Str "Left",Space,Str "Aligned"]]
+ ,[Plain [Str "Right",Space,Str "Aligned"]]
+ ,[Plain [Str "Default",Space,Str "aligned"]]]
+ [[[Plain [Str "First"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "12.0"]]
+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",SoftBreak,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",SoftBreak,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",SoftBreak,Str "rows."]]]]
+,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "caption:"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625]
+ [[Plain [Str "Centered",Space,Str "Header"]]
+ ,[Plain [Str "Left",Space,Str "Aligned"]]
+ ,[Plain [Str "Right",Space,Str "Aligned"]]
+ ,[Plain [Str "Default",Space,Str "aligned"]]]
+ [[[Plain [Str "First"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "12.0"]]
+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",SoftBreak,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",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] [0.1,0.1,0.1,0.1]
+ [[]
+ ,[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers:"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault,AlignDefault] [0.175,0.1625,0.1875,0.3625]
+ [[]
+ ,[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "First"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "12.0"]]
+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",SoftBreak,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",SoftBreak,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",SoftBreak,Str "rows."]]]]]
diff --git a/test/tables.asciidoc b/test/tables.asciidoc
new file mode 100644
index 000000000..91490a27a
--- /dev/null
+++ b/test/tables.asciidoc
@@ -0,0 +1,67 @@
+Simple table with caption:
+
+.Demonstration of simple table syntax.
+[cols=">,<,^,",options="header",]
+|============================
+|Right |Left |Center |Default
+|12 |12 |12 |12
+|123 |123 |123 |123
+|1 |1 |1 |1
+|============================
+
+Simple table without caption:
+
+[cols=">,<,^,",options="header",]
+|============================
+|Right |Left |Center |Default
+|12 |12 |12 |12
+|123 |123 |123 |123
+|1 |1 |1 |1
+|============================
+
+Simple table indented two spaces:
+
+.Demonstration of simple table syntax.
+[cols=">,<,^,",options="header",]
+|============================
+|Right |Left |Center |Default
+|12 |12 |12 |12
+|123 |123 |123 |123
+|1 |1 |1 |1
+|============================
+
+Multiline table with caption:
+
+.Here’s the caption. It may span multiple lines.
+[width="78%",cols="^21%,<17%,>20%,<42%",options="header",]
+|=======================================================================
+|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.
+|=======================================================================
+
+Multiline table without caption:
+
+[width="78%",cols="^21%,<17%,>20%,<42%",options="header",]
+|=======================================================================
+|Centered Header |Left Aligned |Right Aligned |Default aligned
+|First |row |12.0 |Example of a row that spans multiple lines.
+|Second |row |5.0 |Here’s another one. Note the blank line between rows.
+|=======================================================================
+
+Table without column headers:
+
+[cols=">,<,^,>",]
+|==================
+|12 |12 |12 |12
+|123 |123 |123 |123
+|1 |1 |1 |1
+|==================
+
+Multiline table without column headers:
+
+[width="78%",cols="^21%,<17%,>20%,42%",]
+|=======================================================================
+|First |row |12.0 |Example of a row that spans multiple lines.
+|Second |row |5.0 |Here’s another one. Note the blank line between rows.
+|=======================================================================
diff --git a/test/tables.context b/test/tables.context
new file mode 100644
index 000000000..371e559e5
--- /dev/null
+++ b/test/tables.context
@@ -0,0 +1,175 @@
+Simple table with caption:
+
+\placetable{Demonstration of simple table syntax.}
+\starttable[|r|l|c|l|]
+\HL
+\NC Right
+\NC Left
+\NC Center
+\NC Default
+\NC\AR
+\HL
+\NC 12
+\NC 12
+\NC 12
+\NC 12
+\NC\AR
+\NC 123
+\NC 123
+\NC 123
+\NC 123
+\NC\AR
+\NC 1
+\NC 1
+\NC 1
+\NC 1
+\NC\AR
+\HL
+\stoptable
+
+Simple table without caption:
+
+\placetable[none]{}
+\starttable[|r|l|c|l|]
+\HL
+\NC Right
+\NC Left
+\NC Center
+\NC Default
+\NC\AR
+\HL
+\NC 12
+\NC 12
+\NC 12
+\NC 12
+\NC\AR
+\NC 123
+\NC 123
+\NC 123
+\NC 123
+\NC\AR
+\NC 1
+\NC 1
+\NC 1
+\NC 1
+\NC\AR
+\HL
+\stoptable
+
+Simple table indented two spaces:
+
+\placetable{Demonstration of simple table syntax.}
+\starttable[|r|l|c|l|]
+\HL
+\NC Right
+\NC Left
+\NC Center
+\NC Default
+\NC\AR
+\HL
+\NC 12
+\NC 12
+\NC 12
+\NC 12
+\NC\AR
+\NC 123
+\NC 123
+\NC 123
+\NC 123
+\NC\AR
+\NC 1
+\NC 1
+\NC 1
+\NC 1
+\NC\AR
+\HL
+\stoptable
+
+Multiline table with caption:
+
+\placetable{Here's the caption. It may span multiple lines.}
+\starttable[|cp(0.15\textwidth)|lp(0.14\textwidth)|rp(0.16\textwidth)|lp(0.34\textwidth)|]
+\HL
+\NC Centered Header
+\NC Left Aligned
+\NC Right Aligned
+\NC Default aligned
+\NC\AR
+\HL
+\NC First
+\NC row
+\NC 12.0
+\NC Example of a row that spans multiple lines.
+\NC\AR
+\NC Second
+\NC row
+\NC 5.0
+\NC Here's another one. Note the blank line between rows.
+\NC\AR
+\HL
+\stoptable
+
+Multiline table without caption:
+
+\placetable[none]{}
+\starttable[|cp(0.15\textwidth)|lp(0.14\textwidth)|rp(0.16\textwidth)|lp(0.34\textwidth)|]
+\HL
+\NC Centered Header
+\NC Left Aligned
+\NC Right Aligned
+\NC Default aligned
+\NC\AR
+\HL
+\NC First
+\NC row
+\NC 12.0
+\NC Example of a row that spans multiple lines.
+\NC\AR
+\NC Second
+\NC row
+\NC 5.0
+\NC Here's another one. Note the blank line between rows.
+\NC\AR
+\HL
+\stoptable
+
+Table without column headers:
+
+\placetable[none]{}
+\starttable[|r|l|c|r|]
+\HL
+\NC 12
+\NC 12
+\NC 12
+\NC 12
+\NC\AR
+\NC 123
+\NC 123
+\NC 123
+\NC 123
+\NC\AR
+\NC 1
+\NC 1
+\NC 1
+\NC 1
+\NC\AR
+\HL
+\stoptable
+
+Multiline table without column headers:
+
+\placetable[none]{}
+\starttable[|cp(0.15\textwidth)|lp(0.14\textwidth)|rp(0.16\textwidth)|lp(0.34\textwidth)|]
+\HL
+\NC First
+\NC row
+\NC 12.0
+\NC Example of a row that spans multiple lines.
+\NC\AR
+\NC Second
+\NC row
+\NC 5.0
+\NC Here's another one. Note the blank line between rows.
+\NC\AR
+\HL
+\stoptable
diff --git a/test/tables.docbook4 b/test/tables.docbook4
new file mode 100644
index 000000000..f86b1c390
--- /dev/null
+++ b/test/tables.docbook4
@@ -0,0 +1,432 @@
+<para>
+ Simple table with caption:
+</para>
+<table>
+ <title>
+ Demonstration of simple table syntax.
+ </title>
+ <tgroup cols="4">
+ <colspec align="right" />
+ <colspec align="left" />
+ <colspec align="center" />
+ <colspec align="left" />
+ <thead>
+ <row>
+ <entry>
+ Right
+ </entry>
+ <entry>
+ Left
+ </entry>
+ <entry>
+ Center
+ </entry>
+ <entry>
+ Default
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+</table>
+<para>
+ Simple table without caption:
+</para>
+<informaltable>
+ <tgroup cols="4">
+ <colspec align="right" />
+ <colspec align="left" />
+ <colspec align="center" />
+ <colspec align="left" />
+ <thead>
+ <row>
+ <entry>
+ Right
+ </entry>
+ <entry>
+ Left
+ </entry>
+ <entry>
+ Center
+ </entry>
+ <entry>
+ Default
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+</informaltable>
+<para>
+ Simple table indented two spaces:
+</para>
+<table>
+ <title>
+ Demonstration of simple table syntax.
+ </title>
+ <tgroup cols="4">
+ <colspec align="right" />
+ <colspec align="left" />
+ <colspec align="center" />
+ <colspec align="left" />
+ <thead>
+ <row>
+ <entry>
+ Right
+ </entry>
+ <entry>
+ Left
+ </entry>
+ <entry>
+ Center
+ </entry>
+ <entry>
+ Default
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+</table>
+<para>
+ Multiline table with caption:
+</para>
+<table>
+ <title>
+ Here’s the caption. It may span multiple lines.
+ </title>
+ <tgroup cols="4">
+ <colspec colwidth="15*" align="center" />
+ <colspec colwidth="13*" align="left" />
+ <colspec colwidth="16*" align="right" />
+ <colspec colwidth="33*" align="left" />
+ <thead>
+ <row>
+ <entry>
+ Centered Header
+ </entry>
+ <entry>
+ Left Aligned
+ </entry>
+ <entry>
+ Right Aligned
+ </entry>
+ <entry>
+ Default aligned
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ First
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 12.0
+ </entry>
+ <entry>
+ Example of a row that spans multiple lines.
+ </entry>
+ </row>
+ <row>
+ <entry>
+ Second
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 5.0
+ </entry>
+ <entry>
+ Here’s another one. Note the blank line between rows.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+</table>
+<para>
+ Multiline table without caption:
+</para>
+<informaltable>
+ <tgroup cols="4">
+ <colspec colwidth="15*" align="center" />
+ <colspec colwidth="13*" align="left" />
+ <colspec colwidth="16*" align="right" />
+ <colspec colwidth="33*" align="left" />
+ <thead>
+ <row>
+ <entry>
+ Centered Header
+ </entry>
+ <entry>
+ Left Aligned
+ </entry>
+ <entry>
+ Right Aligned
+ </entry>
+ <entry>
+ Default aligned
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ First
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 12.0
+ </entry>
+ <entry>
+ Example of a row that spans multiple lines.
+ </entry>
+ </row>
+ <row>
+ <entry>
+ Second
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 5.0
+ </entry>
+ <entry>
+ Here’s another one. Note the blank line between rows.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+</informaltable>
+<para>
+ Table without column headers:
+</para>
+<informaltable>
+ <tgroup cols="4">
+ <colspec align="right" />
+ <colspec align="left" />
+ <colspec align="center" />
+ <colspec align="right" />
+ <tbody>
+ <row>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+</informaltable>
+<para>
+ Multiline table without column headers:
+</para>
+<informaltable>
+ <tgroup cols="4">
+ <colspec colwidth="15*" align="center" />
+ <colspec colwidth="13*" align="left" />
+ <colspec colwidth="16*" align="right" />
+ <colspec colwidth="33*" align="left" />
+ <tbody>
+ <row>
+ <entry>
+ First
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 12.0
+ </entry>
+ <entry>
+ Example of a row that spans multiple lines.
+ </entry>
+ </row>
+ <row>
+ <entry>
+ Second
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 5.0
+ </entry>
+ <entry>
+ Here’s another one. Note the blank line between rows.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+</informaltable>
diff --git a/test/tables.docbook5 b/test/tables.docbook5
new file mode 100644
index 000000000..f86b1c390
--- /dev/null
+++ b/test/tables.docbook5
@@ -0,0 +1,432 @@
+<para>
+ Simple table with caption:
+</para>
+<table>
+ <title>
+ Demonstration of simple table syntax.
+ </title>
+ <tgroup cols="4">
+ <colspec align="right" />
+ <colspec align="left" />
+ <colspec align="center" />
+ <colspec align="left" />
+ <thead>
+ <row>
+ <entry>
+ Right
+ </entry>
+ <entry>
+ Left
+ </entry>
+ <entry>
+ Center
+ </entry>
+ <entry>
+ Default
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+</table>
+<para>
+ Simple table without caption:
+</para>
+<informaltable>
+ <tgroup cols="4">
+ <colspec align="right" />
+ <colspec align="left" />
+ <colspec align="center" />
+ <colspec align="left" />
+ <thead>
+ <row>
+ <entry>
+ Right
+ </entry>
+ <entry>
+ Left
+ </entry>
+ <entry>
+ Center
+ </entry>
+ <entry>
+ Default
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+</informaltable>
+<para>
+ Simple table indented two spaces:
+</para>
+<table>
+ <title>
+ Demonstration of simple table syntax.
+ </title>
+ <tgroup cols="4">
+ <colspec align="right" />
+ <colspec align="left" />
+ <colspec align="center" />
+ <colspec align="left" />
+ <thead>
+ <row>
+ <entry>
+ Right
+ </entry>
+ <entry>
+ Left
+ </entry>
+ <entry>
+ Center
+ </entry>
+ <entry>
+ Default
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+</table>
+<para>
+ Multiline table with caption:
+</para>
+<table>
+ <title>
+ Here’s the caption. It may span multiple lines.
+ </title>
+ <tgroup cols="4">
+ <colspec colwidth="15*" align="center" />
+ <colspec colwidth="13*" align="left" />
+ <colspec colwidth="16*" align="right" />
+ <colspec colwidth="33*" align="left" />
+ <thead>
+ <row>
+ <entry>
+ Centered Header
+ </entry>
+ <entry>
+ Left Aligned
+ </entry>
+ <entry>
+ Right Aligned
+ </entry>
+ <entry>
+ Default aligned
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ First
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 12.0
+ </entry>
+ <entry>
+ Example of a row that spans multiple lines.
+ </entry>
+ </row>
+ <row>
+ <entry>
+ Second
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 5.0
+ </entry>
+ <entry>
+ Here’s another one. Note the blank line between rows.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+</table>
+<para>
+ Multiline table without caption:
+</para>
+<informaltable>
+ <tgroup cols="4">
+ <colspec colwidth="15*" align="center" />
+ <colspec colwidth="13*" align="left" />
+ <colspec colwidth="16*" align="right" />
+ <colspec colwidth="33*" align="left" />
+ <thead>
+ <row>
+ <entry>
+ Centered Header
+ </entry>
+ <entry>
+ Left Aligned
+ </entry>
+ <entry>
+ Right Aligned
+ </entry>
+ <entry>
+ Default aligned
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ First
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 12.0
+ </entry>
+ <entry>
+ Example of a row that spans multiple lines.
+ </entry>
+ </row>
+ <row>
+ <entry>
+ Second
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 5.0
+ </entry>
+ <entry>
+ Here’s another one. Note the blank line between rows.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+</informaltable>
+<para>
+ Table without column headers:
+</para>
+<informaltable>
+ <tgroup cols="4">
+ <colspec align="right" />
+ <colspec align="left" />
+ <colspec align="center" />
+ <colspec align="right" />
+ <tbody>
+ <row>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ <entry>
+ 12
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ <entry>
+ 123
+ </entry>
+ </row>
+ <row>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ <entry>
+ 1
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+</informaltable>
+<para>
+ Multiline table without column headers:
+</para>
+<informaltable>
+ <tgroup cols="4">
+ <colspec colwidth="15*" align="center" />
+ <colspec colwidth="13*" align="left" />
+ <colspec colwidth="16*" align="right" />
+ <colspec colwidth="33*" align="left" />
+ <tbody>
+ <row>
+ <entry>
+ First
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 12.0
+ </entry>
+ <entry>
+ Example of a row that spans multiple lines.
+ </entry>
+ </row>
+ <row>
+ <entry>
+ Second
+ </entry>
+ <entry>
+ row
+ </entry>
+ <entry>
+ 5.0
+ </entry>
+ <entry>
+ Here’s another one. Note the blank line between rows.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+</informaltable>
diff --git a/test/tables.dokuwiki b/test/tables.dokuwiki
new file mode 100644
index 000000000..23c0d22cb
--- /dev/null
+++ b/test/tables.dokuwiki
@@ -0,0 +1,47 @@
+Simple table with caption:
+
+Demonstration of simple table syntax.
+^ 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 |
+
+Simple table indented two spaces:
+
+Demonstration of simple table syntax.
+^ Right^Left ^ Center ^Default^
+| 12|12 | 12 |12 |
+| 123|123 | 123 |123 |
+| 1|1 | 1 |1 |
+
+Multiline table with caption:
+
+Here’s the caption. It may span multiple lines.
+^ 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. |
+
+Multiline table without caption:
+
+^ Centered Header ^Left Aligned ^ Right Aligned^Default aligned ^
+| First |row | 12.0|Example of a row that spans multiple lines. |
+| Second |row | 5.0|Here’s another one. Note the blank line between rows. |
+
+Table without column headers:
+
+| 12|12 | 12 | 12|
+| 123|123 | 123 | 123|
+| 1|1 | 1 | 1|
+
+Multiline table without column headers:
+
+| First |row | 12.0|Example of a row that spans multiple lines. |
+| Second |row | 5.0|Here’s another one. Note the blank line between rows.|
+
diff --git a/test/tables.fb2 b/test/tables.fb2
new file mode 100644
index 000000000..df285888e
--- /dev/null
+++ b/test/tables.fb2
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"><description><title-info /><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><annotation><p></p></annotation><section><p>Simple table with caption:</p><table><tr><th align="right">Right</th><th align="left">Left</th><th align="center">Center</th><th align="left">Default</th></tr><tr><td align="right">12</td><td align="left">12</td><td align="center">12</td><td align="left">12</td></tr><tr><td align="right">123</td><td align="left">123</td><td align="center">123</td><td align="left">123</td></tr><tr><td align="right">1</td><td align="left">1</td><td align="center">1</td><td align="left">1</td></tr></table><p><emphasis>Demonstration of simple table syntax.</emphasis></p><p>Simple table without caption:</p><table><tr><th align="right">Right</th><th align="left">Left</th><th align="center">Center</th><th align="left">Default</th></tr><tr><td align="right">12</td><td align="left">12</td><td align="center">12</td><td align="left">12</td></tr><tr><td align="right">123</td><td align="left">123</td><td align="center">123</td><td align="left">123</td></tr><tr><td align="right">1</td><td align="left">1</td><td align="center">1</td><td align="left">1</td></tr></table><p><emphasis /></p><p>Simple table indented two spaces:</p><table><tr><th align="right">Right</th><th align="left">Left</th><th align="center">Center</th><th align="left">Default</th></tr><tr><td align="right">12</td><td align="left">12</td><td align="center">12</td><td align="left">12</td></tr><tr><td align="right">123</td><td align="left">123</td><td align="center">123</td><td align="left">123</td></tr><tr><td align="right">1</td><td align="left">1</td><td align="center">1</td><td align="left">1</td></tr></table><p><emphasis>Demonstration of simple table syntax.</emphasis></p><p>Multiline table with caption:</p><table><tr><th align="center">Centered Header</th><th align="left">Left Aligned</th><th align="right">Right Aligned</th><th align="left">Default aligned</th></tr><tr><td align="center">First</td><td align="left">row</td><td align="right">12.0</td><td align="left">Example of a row that spans multiple lines.</td></tr><tr><td align="center">Second</td><td align="left">row</td><td align="right">5.0</td><td align="left">Here’s another one. Note the blank line between rows.</td></tr></table><p><emphasis>Here’s the caption. It may span multiple lines.</emphasis></p><p>Multiline table without caption:</p><table><tr><th align="center">Centered Header</th><th align="left">Left Aligned</th><th align="right">Right Aligned</th><th align="left">Default aligned</th></tr><tr><td align="center">First</td><td align="left">row</td><td align="right">12.0</td><td align="left">Example of a row that spans multiple lines.</td></tr><tr><td align="center">Second</td><td align="left">row</td><td align="right">5.0</td><td align="left">Here’s another one. Note the blank line between rows.</td></tr></table><p><emphasis /></p><p>Table without column headers:</p><table><tr><th align="right" /><th align="left" /><th align="center" /><th align="right" /></tr><tr><td align="right">12</td><td align="left">12</td><td align="center">12</td><td align="right">12</td></tr><tr><td align="right">123</td><td align="left">123</td><td align="center">123</td><td align="right">123</td></tr><tr><td align="right">1</td><td align="left">1</td><td align="center">1</td><td align="right">1</td></tr></table><p><emphasis /></p><p>Multiline table without column headers:</p><table><tr><th align="center" /><th align="left" /><th align="right" /><th align="left" /></tr><tr><td align="center">First</td><td align="left">row</td><td align="right">12.0</td><td align="left">Example of a row that spans multiple lines.</td></tr><tr><td align="center">Second</td><td align="left">row</td><td align="right">5.0</td><td align="left">Here’s another one. Note the blank line between rows.</td></tr></table><p><emphasis /></p></section></body></FictionBook>
+
diff --git a/test/tables.haddock b/test/tables.haddock
new file mode 100644
index 000000000..84a15cce8
--- /dev/null
+++ b/test/tables.haddock
@@ -0,0 +1,76 @@
+Simple table with caption:
+
+> Right Left Center Default
+> ------- ------ -------- ---------
+> 12 12 12 12
+> 123 123 123 123
+> 1 1 1 1
+>
+> Demonstration of simple table syntax.
+
+Simple table without caption:
+
+> Right Left Center Default
+> ------- ------ -------- ---------
+> 12 12 12 12
+> 123 123 123 123
+> 1 1 1 1
+
+Simple table indented two spaces:
+
+> Right Left Center Default
+> ------- ------ -------- ---------
+> 12 12 12 12
+> 123 123 123 123
+> 1 1 1 1
+>
+> Demonstration of simple table syntax.
+
+Multiline table with caption:
+
+> --------------------------------------------------------------
+> Centered Left Right Default aligned
+> Header Aligned Aligned
+> ----------- ---------- ------------ --------------------------
+> First row 12.0 Example of a row that
+> spans multiple lines.
+>
+> Second row 5.0 Here’s another one. Note
+> the blank line between
+> rows.
+> --------------------------------------------------------------
+>
+> Here’s the caption. It may span multiple lines.
+
+Multiline table without caption:
+
+> --------------------------------------------------------------
+> Centered Left Right Default aligned
+> Header Aligned Aligned
+> ----------- ---------- ------------ --------------------------
+> First row 12.0 Example of a row that
+> spans multiple lines.
+>
+> Second row 5.0 Here’s another one. Note
+> the blank line between
+> rows.
+> --------------------------------------------------------------
+
+Table without column headers:
+
+> ----- ----- ----- -----
+> 12 12 12 12
+> 123 123 123 123
+> 1 1 1 1
+> ----- ----- ----- -----
+
+Multiline table without column headers:
+
+> ----------- ---------- ------------ --------------------------
+> First row 12.0 Example of a row that
+> spans multiple lines.
+>
+> Second row 5.0 Here’s another one. Note
+> the blank line between
+> rows.
+> ----------- ---------- ------------ --------------------------
diff --git a/test/tables.html4 b/test/tables.html4
new file mode 100644
index 000000000..5bb7a7de2
--- /dev/null
+++ b/test/tables.html4
@@ -0,0 +1,204 @@
+<p>Simple table with caption:</p>
+<table>
+<caption>Demonstration of simple table syntax.</caption>
+<thead>
+<tr class="header">
+<th align="right">Right</th>
+<th align="left">Left</th>
+<th align="center">Center</th>
+<th>Default</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td align="right">12</td>
+<td align="left">12</td>
+<td align="center">12</td>
+<td>12</td>
+</tr>
+<tr class="even">
+<td align="right">123</td>
+<td align="left">123</td>
+<td align="center">123</td>
+<td>123</td>
+</tr>
+<tr class="odd">
+<td align="right">1</td>
+<td align="left">1</td>
+<td align="center">1</td>
+<td>1</td>
+</tr>
+</tbody>
+</table>
+<p>Simple table without caption:</p>
+<table>
+<thead>
+<tr class="header">
+<th align="right">Right</th>
+<th align="left">Left</th>
+<th align="center">Center</th>
+<th>Default</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td align="right">12</td>
+<td align="left">12</td>
+<td align="center">12</td>
+<td>12</td>
+</tr>
+<tr class="even">
+<td align="right">123</td>
+<td align="left">123</td>
+<td align="center">123</td>
+<td>123</td>
+</tr>
+<tr class="odd">
+<td align="right">1</td>
+<td align="left">1</td>
+<td align="center">1</td>
+<td>1</td>
+</tr>
+</tbody>
+</table>
+<p>Simple table indented two spaces:</p>
+<table>
+<caption>Demonstration of simple table syntax.</caption>
+<thead>
+<tr class="header">
+<th align="right">Right</th>
+<th align="left">Left</th>
+<th align="center">Center</th>
+<th>Default</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td align="right">12</td>
+<td align="left">12</td>
+<td align="center">12</td>
+<td>12</td>
+</tr>
+<tr class="even">
+<td align="right">123</td>
+<td align="left">123</td>
+<td align="center">123</td>
+<td>123</td>
+</tr>
+<tr class="odd">
+<td align="right">1</td>
+<td align="left">1</td>
+<td align="center">1</td>
+<td>1</td>
+</tr>
+</tbody>
+</table>
+<p>Multiline table with caption:</p>
+<table style="width:79%;">
+<caption>Here’s the caption. It may span multiple lines.</caption>
+<colgroup>
+<col width="15%" />
+<col width="13%" />
+<col width="16%" />
+<col width="33%" />
+</colgroup>
+<thead>
+<tr class="header">
+<th align="center">Centered Header</th>
+<th align="left">Left Aligned</th>
+<th align="right">Right Aligned</th>
+<th align="left">Default aligned</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td align="center">First</td>
+<td align="left">row</td>
+<td align="right">12.0</td>
+<td align="left">Example of a row that spans multiple lines.</td>
+</tr>
+<tr class="even">
+<td align="center">Second</td>
+<td align="left">row</td>
+<td align="right">5.0</td>
+<td align="left">Here’s another one. Note the blank line between rows.</td>
+</tr>
+</tbody>
+</table>
+<p>Multiline table without caption:</p>
+<table style="width:79%;">
+<colgroup>
+<col width="15%" />
+<col width="13%" />
+<col width="16%" />
+<col width="33%" />
+</colgroup>
+<thead>
+<tr class="header">
+<th align="center">Centered Header</th>
+<th align="left">Left Aligned</th>
+<th align="right">Right Aligned</th>
+<th align="left">Default aligned</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td align="center">First</td>
+<td align="left">row</td>
+<td align="right">12.0</td>
+<td align="left">Example of a row that spans multiple lines.</td>
+</tr>
+<tr class="even">
+<td align="center">Second</td>
+<td align="left">row</td>
+<td align="right">5.0</td>
+<td align="left">Here’s another one. Note the blank line between rows.</td>
+</tr>
+</tbody>
+</table>
+<p>Table without column headers:</p>
+<table>
+<tbody>
+<tr class="odd">
+<td align="right">12</td>
+<td align="left">12</td>
+<td align="center">12</td>
+<td align="right">12</td>
+</tr>
+<tr class="even">
+<td align="right">123</td>
+<td align="left">123</td>
+<td align="center">123</td>
+<td align="right">123</td>
+</tr>
+<tr class="odd">
+<td align="right">1</td>
+<td align="left">1</td>
+<td align="center">1</td>
+<td align="right">1</td>
+</tr>
+</tbody>
+</table>
+<p>Multiline table without column headers:</p>
+<table style="width:79%;">
+<colgroup>
+<col width="15%" />
+<col width="13%" />
+<col width="16%" />
+<col width="33%" />
+</colgroup>
+<tbody>
+<tr class="odd">
+<td align="center">First</td>
+<td align="left">row</td>
+<td align="right">12.0</td>
+<td>Example of a row that spans multiple lines.</td>
+</tr>
+<tr class="even">
+<td align="center">Second</td>
+<td align="left">row</td>
+<td align="right">5.0</td>
+<td>Here’s another one. Note the blank line between rows.</td>
+</tr>
+</tbody>
+</table>
diff --git a/test/tables.html5 b/test/tables.html5
new file mode 100644
index 000000000..17a82110f
--- /dev/null
+++ b/test/tables.html5
@@ -0,0 +1,204 @@
+<p>Simple table with caption:</p>
+<table>
+<caption>Demonstration of simple table syntax.</caption>
+<thead>
+<tr class="header">
+<th style="text-align: right;">Right</th>
+<th style="text-align: left;">Left</th>
+<th style="text-align: center;">Center</th>
+<th>Default</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td style="text-align: right;">12</td>
+<td style="text-align: left;">12</td>
+<td style="text-align: center;">12</td>
+<td>12</td>
+</tr>
+<tr class="even">
+<td style="text-align: right;">123</td>
+<td style="text-align: left;">123</td>
+<td style="text-align: center;">123</td>
+<td>123</td>
+</tr>
+<tr class="odd">
+<td style="text-align: right;">1</td>
+<td style="text-align: left;">1</td>
+<td style="text-align: center;">1</td>
+<td>1</td>
+</tr>
+</tbody>
+</table>
+<p>Simple table without caption:</p>
+<table>
+<thead>
+<tr class="header">
+<th style="text-align: right;">Right</th>
+<th style="text-align: left;">Left</th>
+<th style="text-align: center;">Center</th>
+<th>Default</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td style="text-align: right;">12</td>
+<td style="text-align: left;">12</td>
+<td style="text-align: center;">12</td>
+<td>12</td>
+</tr>
+<tr class="even">
+<td style="text-align: right;">123</td>
+<td style="text-align: left;">123</td>
+<td style="text-align: center;">123</td>
+<td>123</td>
+</tr>
+<tr class="odd">
+<td style="text-align: right;">1</td>
+<td style="text-align: left;">1</td>
+<td style="text-align: center;">1</td>
+<td>1</td>
+</tr>
+</tbody>
+</table>
+<p>Simple table indented two spaces:</p>
+<table>
+<caption>Demonstration of simple table syntax.</caption>
+<thead>
+<tr class="header">
+<th style="text-align: right;">Right</th>
+<th style="text-align: left;">Left</th>
+<th style="text-align: center;">Center</th>
+<th>Default</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td style="text-align: right;">12</td>
+<td style="text-align: left;">12</td>
+<td style="text-align: center;">12</td>
+<td>12</td>
+</tr>
+<tr class="even">
+<td style="text-align: right;">123</td>
+<td style="text-align: left;">123</td>
+<td style="text-align: center;">123</td>
+<td>123</td>
+</tr>
+<tr class="odd">
+<td style="text-align: right;">1</td>
+<td style="text-align: left;">1</td>
+<td style="text-align: center;">1</td>
+<td>1</td>
+</tr>
+</tbody>
+</table>
+<p>Multiline table with caption:</p>
+<table style="width:79%;">
+<caption>Here’s the caption. It may span multiple lines.</caption>
+<colgroup>
+<col style="width: 15%" />
+<col style="width: 13%" />
+<col style="width: 16%" />
+<col style="width: 33%" />
+</colgroup>
+<thead>
+<tr class="header">
+<th style="text-align: center;">Centered Header</th>
+<th style="text-align: left;">Left Aligned</th>
+<th style="text-align: right;">Right Aligned</th>
+<th style="text-align: left;">Default aligned</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td style="text-align: center;">First</td>
+<td style="text-align: left;">row</td>
+<td style="text-align: right;">12.0</td>
+<td style="text-align: left;">Example of a row that spans multiple lines.</td>
+</tr>
+<tr class="even">
+<td style="text-align: center;">Second</td>
+<td style="text-align: left;">row</td>
+<td style="text-align: right;">5.0</td>
+<td style="text-align: left;">Here’s another one. Note the blank line between rows.</td>
+</tr>
+</tbody>
+</table>
+<p>Multiline table without caption:</p>
+<table style="width:79%;">
+<colgroup>
+<col style="width: 15%" />
+<col style="width: 13%" />
+<col style="width: 16%" />
+<col style="width: 33%" />
+</colgroup>
+<thead>
+<tr class="header">
+<th style="text-align: center;">Centered Header</th>
+<th style="text-align: left;">Left Aligned</th>
+<th style="text-align: right;">Right Aligned</th>
+<th style="text-align: left;">Default aligned</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td style="text-align: center;">First</td>
+<td style="text-align: left;">row</td>
+<td style="text-align: right;">12.0</td>
+<td style="text-align: left;">Example of a row that spans multiple lines.</td>
+</tr>
+<tr class="even">
+<td style="text-align: center;">Second</td>
+<td style="text-align: left;">row</td>
+<td style="text-align: right;">5.0</td>
+<td style="text-align: left;">Here’s another one. Note the blank line between rows.</td>
+</tr>
+</tbody>
+</table>
+<p>Table without column headers:</p>
+<table>
+<tbody>
+<tr class="odd">
+<td style="text-align: right;">12</td>
+<td style="text-align: left;">12</td>
+<td style="text-align: center;">12</td>
+<td style="text-align: right;">12</td>
+</tr>
+<tr class="even">
+<td style="text-align: right;">123</td>
+<td style="text-align: left;">123</td>
+<td style="text-align: center;">123</td>
+<td style="text-align: right;">123</td>
+</tr>
+<tr class="odd">
+<td style="text-align: right;">1</td>
+<td style="text-align: left;">1</td>
+<td style="text-align: center;">1</td>
+<td style="text-align: right;">1</td>
+</tr>
+</tbody>
+</table>
+<p>Multiline table without column headers:</p>
+<table style="width:79%;">
+<colgroup>
+<col style="width: 15%" />
+<col style="width: 13%" />
+<col style="width: 16%" />
+<col style="width: 33%" />
+</colgroup>
+<tbody>
+<tr class="odd">
+<td style="text-align: center;">First</td>
+<td style="text-align: left;">row</td>
+<td style="text-align: right;">12.0</td>
+<td>Example of a row that spans multiple lines.</td>
+</tr>
+<tr class="even">
+<td style="text-align: center;">Second</td>
+<td style="text-align: left;">row</td>
+<td style="text-align: right;">5.0</td>
+<td>Here’s another one. Note the blank line between rows.</td>
+</tr>
+</tbody>
+</table>
diff --git a/test/tables.icml b/test/tables.icml
new file mode 100644
index 000000000..0280cafed
--- /dev/null
+++ b/test/tables.icml
@@ -0,0 +1,757 @@
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Simple table with caption:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<Table AppliedTableStyle="TableStyle/Table" HeaderRowCount="1" BodyRowCount="3" ColumnCount="4">
+ <Column Name="0" />
+ <Column Name="1" />
+ <Column Name="2" />
+ <Column Name="3" />
+ <Cell Name="0:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Right</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Left</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Center</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Default</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+</Table>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Demonstration of simple table syntax.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Simple table without caption:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<Table AppliedTableStyle="TableStyle/Table" HeaderRowCount="1" BodyRowCount="3" ColumnCount="4">
+ <Column Name="0" />
+ <Column Name="1" />
+ <Column Name="2" />
+ <Column Name="3" />
+ <Cell Name="0:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Right</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Left</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Center</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Default</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+</Table>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Simple table indented two spaces:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<Table AppliedTableStyle="TableStyle/Table" HeaderRowCount="1" BodyRowCount="3" ColumnCount="4">
+ <Column Name="0" />
+ <Column Name="1" />
+ <Column Name="2" />
+ <Column Name="3" />
+ <Cell Name="0:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Right</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Left</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Center</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Default</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+</Table>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Demonstration of simple table syntax.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiline table with caption:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<Table AppliedTableStyle="TableStyle/Table" HeaderRowCount="1" BodyRowCount="2" ColumnCount="4">
+ <Column Name="0" SingleColumnWidth="75.0" />
+ <Column Name="1" SingleColumnWidth="68.75" />
+ <Column Name="2" SingleColumnWidth="81.25" />
+ <Column Name="3" SingleColumnWidth="168.75" />
+ <Cell Name="0:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Centered Header</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Left Aligned</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Right Aligned</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Default aligned</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>First</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>row</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12.0</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Example of a row that spans multiple lines.</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Second</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>row</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>5.0</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s another one. Note the blank line between rows.</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+</Table>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s the caption. It may span multiple lines.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiline table without caption:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<Table AppliedTableStyle="TableStyle/Table" HeaderRowCount="1" BodyRowCount="2" ColumnCount="4">
+ <Column Name="0" SingleColumnWidth="75.0" />
+ <Column Name="1" SingleColumnWidth="68.75" />
+ <Column Name="2" SingleColumnWidth="81.25" />
+ <Column Name="3" SingleColumnWidth="168.75" />
+ <Cell Name="0:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Centered Header</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Left Aligned</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Right Aligned</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Default aligned</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>First</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>row</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12.0</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Example of a row that spans multiple lines.</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Second</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>row</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>5.0</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s another one. Note the blank line between rows.</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+</Table>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Table without column headers:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<Table AppliedTableStyle="TableStyle/Table" HeaderRowCount="0" BodyRowCount="3" ColumnCount="4">
+ <Column Name="0" />
+ <Column Name="1" />
+ <Column Name="2" />
+ <Column Name="3" />
+ <Cell Name="0:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+</Table>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiline table without column headers:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<Table AppliedTableStyle="TableStyle/Table" HeaderRowCount="0" BodyRowCount="2" ColumnCount="4">
+ <Column Name="0" SingleColumnWidth="75.0" />
+ <Column Name="1" SingleColumnWidth="68.75" />
+ <Column Name="2" SingleColumnWidth="81.25" />
+ <Column Name="3" SingleColumnWidth="168.75" />
+ <Cell Name="0:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>First</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>row</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12.0</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Example of a row that spans multiple lines.</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Second</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>row</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>5.0</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s another one. Note the blank line between rows.</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Cell>
+</Table>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
+</ParagraphStyleRange>
diff --git a/test/tables.latex b/test/tables.latex
new file mode 100644
index 000000000..38d4d089e
--- /dev/null
+++ b/test/tables.latex
@@ -0,0 +1,168 @@
+Simple table with caption:
+
+\begin{longtable}[]{@{}rlcl@{}}
+\caption{Demonstration of simple table syntax.}\tabularnewline
+\toprule
+Right & Left & Center & Default\tabularnewline
+\midrule
+\endfirsthead
+\toprule
+Right & Left & Center & Default\tabularnewline
+\midrule
+\endhead
+12 & 12 & 12 & 12\tabularnewline
+123 & 123 & 123 & 123\tabularnewline
+1 & 1 & 1 & 1\tabularnewline
+\bottomrule
+\end{longtable}
+
+Simple table without caption:
+
+\begin{longtable}[]{@{}rlcl@{}}
+\toprule
+Right & Left & Center & Default\tabularnewline
+\midrule
+\endhead
+12 & 12 & 12 & 12\tabularnewline
+123 & 123 & 123 & 123\tabularnewline
+1 & 1 & 1 & 1\tabularnewline
+\bottomrule
+\end{longtable}
+
+Simple table indented two spaces:
+
+\begin{longtable}[]{@{}rlcl@{}}
+\caption{Demonstration of simple table syntax.}\tabularnewline
+\toprule
+Right & Left & Center & Default\tabularnewline
+\midrule
+\endfirsthead
+\toprule
+Right & Left & Center & Default\tabularnewline
+\midrule
+\endhead
+12 & 12 & 12 & 12\tabularnewline
+123 & 123 & 123 & 123\tabularnewline
+1 & 1 & 1 & 1\tabularnewline
+\bottomrule
+\end{longtable}
+
+Multiline table with caption:
+
+\begin{longtable}[]{@{}clrl@{}}
+\caption{Here's the caption. It may span multiple lines.}\tabularnewline
+\toprule
+\begin{minipage}[b]{0.13\columnwidth}\centering\strut
+Centered Header\strut
+\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright\strut
+Left Aligned\strut
+\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedleft\strut
+Right Aligned\strut
+\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright\strut
+Default aligned\strut
+\end{minipage}\tabularnewline
+\midrule
+\endfirsthead
+\toprule
+\begin{minipage}[b]{0.13\columnwidth}\centering\strut
+Centered Header\strut
+\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright\strut
+Left Aligned\strut
+\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedleft\strut
+Right Aligned\strut
+\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright\strut
+Default aligned\strut
+\end{minipage}\tabularnewline
+\midrule
+\endhead
+\begin{minipage}[t]{0.13\columnwidth}\centering\strut
+First\strut
+\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright\strut
+row\strut
+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft\strut
+12.0\strut
+\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright\strut
+Example of a row that spans multiple lines.\strut
+\end{minipage}\tabularnewline
+\begin{minipage}[t]{0.13\columnwidth}\centering\strut
+Second\strut
+\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright\strut
+row\strut
+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft\strut
+5.0\strut
+\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright\strut
+Here's another one. Note the blank line between rows.\strut
+\end{minipage}\tabularnewline
+\bottomrule
+\end{longtable}
+
+Multiline table without caption:
+
+\begin{longtable}[]{@{}clrl@{}}
+\toprule
+\begin{minipage}[b]{0.13\columnwidth}\centering\strut
+Centered Header\strut
+\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright\strut
+Left Aligned\strut
+\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedleft\strut
+Right Aligned\strut
+\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright\strut
+Default aligned\strut
+\end{minipage}\tabularnewline
+\midrule
+\endhead
+\begin{minipage}[t]{0.13\columnwidth}\centering\strut
+First\strut
+\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright\strut
+row\strut
+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft\strut
+12.0\strut
+\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright\strut
+Example of a row that spans multiple lines.\strut
+\end{minipage}\tabularnewline
+\begin{minipage}[t]{0.13\columnwidth}\centering\strut
+Second\strut
+\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright\strut
+row\strut
+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft\strut
+5.0\strut
+\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright\strut
+Here's another one. Note the blank line between rows.\strut
+\end{minipage}\tabularnewline
+\bottomrule
+\end{longtable}
+
+Table without column headers:
+
+\begin{longtable}[]{@{}rlcr@{}}
+\toprule
+12 & 12 & 12 & 12\tabularnewline
+123 & 123 & 123 & 123\tabularnewline
+1 & 1 & 1 & 1\tabularnewline
+\bottomrule
+\end{longtable}
+
+Multiline table without column headers:
+
+\begin{longtable}[]{@{}clrl@{}}
+\toprule
+\begin{minipage}[t]{0.13\columnwidth}\centering\strut
+First\strut
+\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright\strut
+row\strut
+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft\strut
+12.0\strut
+\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright\strut
+Example of a row that spans multiple lines.\strut
+\end{minipage}\tabularnewline
+\begin{minipage}[t]{0.13\columnwidth}\centering\strut
+Second\strut
+\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright\strut
+row\strut
+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft\strut
+5.0\strut
+\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright\strut
+Here's another one. Note the blank line between rows.\strut
+\end{minipage}\tabularnewline
+\bottomrule
+\end{longtable}
diff --git a/test/tables.man b/test/tables.man
new file mode 100644
index 000000000..dd6a3cce9
--- /dev/null
+++ b/test/tables.man
@@ -0,0 +1,267 @@
+.PP
+Simple table with caption:
+.PP
+Demonstration of simple table syntax.
+.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
+.PP
+Simple table without caption:
+.PP
+.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
+.PP
+Simple table indented two spaces:
+.PP
+Demonstration of simple table syntax.
+.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
+.PP
+Multiline table with caption:
+.PP
+Here's the caption. It may span multiple lines.
+.TS
+tab(@);
+cw(10.5n) lw(9.6n) rw(11.4n) lw(23.6n).
+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's another one.
+Note the blank line between rows.
+T}
+.TE
+.PP
+Multiline table without caption:
+.PP
+.TS
+tab(@);
+cw(10.5n) lw(9.6n) rw(11.4n) lw(23.6n).
+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'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
+.PP
+Multiline table without column headers:
+.PP
+.TS
+tab(@);
+cw(10.5n) lw(9.6n) rw(11.4n) lw(23.6n).
+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's another one.
+Note the blank line between rows.
+T}
+.TE
diff --git a/test/tables.markdown b/test/tables.markdown
new file mode 100644
index 000000000..4b5754cf9
--- /dev/null
+++ b/test/tables.markdown
@@ -0,0 +1,78 @@
+Simple table with caption:
+
+ Right Left Center Default
+ ------- ------ -------- ---------
+ 12 12 12 12
+ 123 123 123 123
+ 1 1 1 1
+
+ : Demonstration of simple table syntax.
+
+Simple table without caption:
+
+ Right Left Center Default
+ ------- ------ -------- ---------
+ 12 12 12 12
+ 123 123 123 123
+ 1 1 1 1
+
+Simple table indented two spaces:
+
+ Right Left Center Default
+ ------- ------ -------- ---------
+ 12 12 12 12
+ 123 123 123 123
+ 1 1 1 1
+
+ : Demonstration of simple table syntax.
+
+Multiline table with caption:
+
+ --------------------------------------------------------------
+ Centered Left Right Default aligned
+ Header Aligned Aligned
+ ----------- ---------- ------------ --------------------------
+ First row 12.0 Example of a row that
+ spans multiple lines.
+
+ Second row 5.0 Here's another one. Note
+ the blank line between
+ rows.
+ --------------------------------------------------------------
+
+ : Here's the caption. It may span multiple lines.
+
+Multiline table without caption:
+
+ --------------------------------------------------------------
+ Centered Left Right Default aligned
+ Header Aligned Aligned
+ ----------- ---------- ------------ --------------------------
+ First row 12.0 Example of a row that
+ spans multiple lines.
+
+ Second row 5.0 Here's another one. Note
+ the blank line between
+ rows.
+ --------------------------------------------------------------
+
+Table without column headers:
+
+ ----- ----- ----- -----
+ 12 12 12 12
+ 123 123 123 123
+ 1 1 1 1
+ ----- ----- ----- -----
+
+Multiline table without column headers:
+
+ ----------- ---------- ------------ --------------------------
+ First row 12.0 Example of a row that
+ spans multiple lines.
+
+ Second row 5.0 Here's another one. Note
+ the blank line between
+ rows.
+ ----------- ---------- ------------ --------------------------
+
+
diff --git a/test/tables.mediawiki b/test/tables.mediawiki
new file mode 100644
index 000000000..ce7c17887
--- /dev/null
+++ b/test/tables.mediawiki
@@ -0,0 +1,146 @@
+Simple table with caption:
+
+{|
+|+ Demonstration of simple table syntax.
+!align="right"| Right
+! Left
+!align="center"| Center
+! Default
+|-
+|align="right"| 12
+| 12
+|align="center"| 12
+| 12
+|-
+|align="right"| 123
+| 123
+|align="center"| 123
+| 123
+|-
+|align="right"| 1
+| 1
+|align="center"| 1
+| 1
+|}
+
+Simple table without caption:
+
+{|
+!align="right"| Right
+! Left
+!align="center"| Center
+! Default
+|-
+|align="right"| 12
+| 12
+|align="center"| 12
+| 12
+|-
+|align="right"| 123
+| 123
+|align="center"| 123
+| 123
+|-
+|align="right"| 1
+| 1
+|align="center"| 1
+| 1
+|}
+
+Simple table indented two spaces:
+
+{|
+|+ Demonstration of simple table syntax.
+!align="right"| Right
+! Left
+!align="center"| Center
+! Default
+|-
+|align="right"| 12
+| 12
+|align="center"| 12
+| 12
+|-
+|align="right"| 123
+| 123
+|align="center"| 123
+| 123
+|-
+|align="right"| 1
+| 1
+|align="center"| 1
+| 1
+|}
+
+Multiline table with caption:
+
+{|
+|+ Here’s the caption. It may span multiple lines.
+!align="center" width="15%"| Centered Header
+!width="13%"| Left Aligned
+!align="right" width="16%"| Right Aligned
+!width="33%"| Default aligned
+|-
+|align="center"| First
+| row
+|align="right"| 12.0
+| Example of a row that spans multiple lines.
+|-
+|align="center"| Second
+| row
+|align="right"| 5.0
+| Here’s another one. Note the blank line between rows.
+|}
+
+Multiline table without caption:
+
+{|
+!align="center" width="15%"| Centered Header
+!width="13%"| Left Aligned
+!align="right" width="16%"| Right Aligned
+!width="33%"| Default aligned
+|-
+|align="center"| First
+| row
+|align="right"| 12.0
+| Example of a row that spans multiple lines.
+|-
+|align="center"| Second
+| row
+|align="right"| 5.0
+| Here’s another one. Note the blank line between rows.
+|}
+
+Table without column headers:
+
+{|
+|align="right"| 12
+| 12
+|align="center"| 12
+|align="right"| 12
+|-
+|align="right"| 123
+| 123
+|align="center"| 123
+|align="right"| 123
+|-
+|align="right"| 1
+| 1
+|align="center"| 1
+|align="right"| 1
+|}
+
+Multiline table without column headers:
+
+{|
+|align="center" width="15%"| First
+|width="13%"| row
+|align="right" width="16%"| 12.0
+|width="33%"| Example of a row that spans multiple lines.
+|-
+|align="center"| Second
+| row
+|align="right"| 5.0
+| Here’s another one. Note the blank line between rows.
+|}
+
diff --git a/test/tables.native b/test/tables.native
new file mode 100644
index 000000000..a60f9b586
--- /dev/null
+++ b/test/tables.native
@@ -0,0 +1,114 @@
+[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."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0]
+ [[Plain [Str "Right"]]
+ ,[Plain [Str "Left"]]
+ ,[Plain [Str "Center"]]
+ ,[Plain [Str "Default"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Simple",Space,Str "table",Space,Str "without",Space,Str "caption:"]
+,Table [] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0]
+ [[Plain [Str "Right"]]
+ ,[Plain [Str "Left"]]
+ ,[Plain [Str "Center"]]
+ ,[Plain [Str "Default"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Simple",Space,Str "table",Space,Str "indented",Space,Str "two",Space,Str "spaces:"]
+,Table [Str "Demonstration",Space,Str "of",Space,Str "simple",Space,Str "table",Space,Str "syntax."] [AlignRight,AlignLeft,AlignCenter,AlignDefault] [0.0,0.0,0.0,0.0]
+ [[Plain [Str "Right"]]
+ ,[Plain [Str "Left"]]
+ ,[Plain [Str "Center"]]
+ ,[Plain [Str "Default"]]]
+ [[[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]
+ ,[Plain [Str "12"]]]
+ ,[[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]
+ ,[Plain [Str "123"]]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "1"]]]]
+,Para [Str "Multiline",Space,Str "table",Space,Str "with",Space,Str "caption:"]
+,Table [Str "Here\8217s",Space,Str "the",Space,Str "caption.",SoftBreak,Str "It",Space,Str "may",Space,Str "span",Space,Str "multiple",Space,Str "lines."] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.15,0.1375,0.1625,0.3375]
+ [[Plain [Str "Centered",SoftBreak,Str "Header"]]
+ ,[Plain [Str "Left",SoftBreak,Str "Aligned"]]
+ ,[Plain [Str "Right",SoftBreak,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",SoftBreak,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",SoftBreak,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."]]]]
+,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "caption:"]
+,Table [] [AlignCenter,AlignLeft,AlignRight,AlignLeft] [0.15,0.1375,0.1625,0.3375]
+ [[Plain [Str "Centered",SoftBreak,Str "Header"]]
+ ,[Plain [Str "Left",SoftBreak,Str "Aligned"]]
+ ,[Plain [Str "Right",SoftBreak,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",SoftBreak,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",SoftBreak,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"]]]]
+,Para [Str "Multiline",Space,Str "table",Space,Str "without",Space,Str "column",Space,Str "headers:"]
+,Table [] [AlignCenter,AlignLeft,AlignRight,AlignDefault] [0.15,0.1375,0.1625,0.3375]
+ [[]
+ ,[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "First"]]
+ ,[Plain [Str "row"]]
+ ,[Plain [Str "12.0"]]
+ ,[Plain [Str "Example",Space,Str "of",Space,Str "a",Space,Str "row",Space,Str "that",Space,Str "spans",SoftBreak,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",SoftBreak,Str "the",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "rows."]]]]]
diff --git a/test/tables.opendocument b/test/tables.opendocument
new file mode 100644
index 000000000..c331ecc43
--- /dev/null
+++ b/test/tables.opendocument
@@ -0,0 +1,397 @@
+<text:p text:style-name="Text_20_body">Simple table with caption:</text:p>
+<table:table table:name="Table1" table:style-name="Table1">
+ <table:table-column table:style-name="Table1.A" />
+ <table:table-column table:style-name="Table1.B" />
+ <table:table-column table:style-name="Table1.C" />
+ <table:table-column table:style-name="Table1.D" />
+ <table:table-header-rows>
+ <table:table-row>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="P1">Right</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Heading">Left</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="P2">Center</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Heading">Default</text:p>
+ </table:table-cell>
+ </table:table-row>
+ </table:table-header-rows>
+ <table:table-row>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="P3">12</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">12</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="P4">12</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">12</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="P3">123</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">123</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="P4">123</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">123</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="P3">1</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">1</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="P4">1</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">1</text:p>
+ </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="First_20_paragraph">Simple table without
+caption:</text:p>
+<table:table table:name="Table2" table:style-name="Table2">
+ <table:table-column table:style-name="Table2.A" />
+ <table:table-column table:style-name="Table2.B" />
+ <table:table-column table:style-name="Table2.C" />
+ <table:table-column table:style-name="Table2.D" />
+ <table:table-header-rows>
+ <table:table-row>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="P5">Right</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Heading">Left</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="P6">Center</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Heading">Default</text:p>
+ </table:table-cell>
+ </table:table-row>
+ </table:table-header-rows>
+ <table:table-row>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="P7">12</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">12</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="P8">12</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">12</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="P7">123</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">123</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="P8">123</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">123</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="P7">1</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">1</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="P8">1</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table2.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">1</text:p>
+ </table:table-cell>
+ </table:table-row>
+</table:table>
+<text:p text:style-name="First_20_paragraph">Simple table indented two
+spaces:</text:p>
+<table:table table:name="Table3" table:style-name="Table3">
+ <table:table-column table:style-name="Table3.A" />
+ <table:table-column table:style-name="Table3.B" />
+ <table:table-column table:style-name="Table3.C" />
+ <table:table-column table:style-name="Table3.D" />
+ <table:table-header-rows>
+ <table:table-row>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="P9">Right</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Heading">Left</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="P10">Center</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Heading">Default</text:p>
+ </table:table-cell>
+ </table:table-row>
+ </table:table-header-rows>
+ <table:table-row>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="P11">12</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">12</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="P12">12</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">12</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="P11">123</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">123</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="P12">123</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">123</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="P11">1</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">1</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="P12">1</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table3.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">1</text:p>
+ </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="First_20_paragraph">Multiline table with
+caption:</text:p>
+<table:table table:name="Table4" table:style-name="Table4">
+ <table:table-column table:style-name="Table4.A" />
+ <table:table-column table:style-name="Table4.B" />
+ <table:table-column table:style-name="Table4.C" />
+ <table:table-column table:style-name="Table4.D" />
+ <table:table-header-rows>
+ <table:table-row>
+ <table:table-cell table:style-name="Table4.A1" office:value-type="string">
+ <text:p text:style-name="P13">Centered Header</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table4.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Heading">Left Aligned</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table4.A1" office:value-type="string">
+ <text:p text:style-name="P14">Right Aligned</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table4.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Heading">Default aligned</text:p>
+ </table:table-cell>
+ </table:table-row>
+ </table:table-header-rows>
+ <table:table-row>
+ <table:table-cell table:style-name="Table4.A1" office:value-type="string">
+ <text:p text:style-name="P15">First</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table4.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">row</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table4.A1" office:value-type="string">
+ <text:p text:style-name="P16">12.0</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table4.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">Example of a row that spans
+ multiple lines.</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell table:style-name="Table4.A1" office:value-type="string">
+ <text:p text:style-name="P15">Second</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table4.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">row</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table4.A1" office:value-type="string">
+ <text:p text:style-name="P16">5.0</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table4.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">Here’s another one. Note the
+ blank line between rows.</text:p>
+ </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="First_20_paragraph">Multiline table without
+caption:</text:p>
+<table:table table:name="Table5" table:style-name="Table5">
+ <table:table-column table:style-name="Table5.A" />
+ <table:table-column table:style-name="Table5.B" />
+ <table:table-column table:style-name="Table5.C" />
+ <table:table-column table:style-name="Table5.D" />
+ <table:table-header-rows>
+ <table:table-row>
+ <table:table-cell table:style-name="Table5.A1" office:value-type="string">
+ <text:p text:style-name="P17">Centered Header</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table5.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Heading">Left Aligned</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table5.A1" office:value-type="string">
+ <text:p text:style-name="P18">Right Aligned</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table5.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Heading">Default aligned</text:p>
+ </table:table-cell>
+ </table:table-row>
+ </table:table-header-rows>
+ <table:table-row>
+ <table:table-cell table:style-name="Table5.A1" office:value-type="string">
+ <text:p text:style-name="P19">First</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table5.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">row</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table5.A1" office:value-type="string">
+ <text:p text:style-name="P20">12.0</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table5.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">Example of a row that spans
+ multiple lines.</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell table:style-name="Table5.A1" office:value-type="string">
+ <text:p text:style-name="P19">Second</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table5.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">row</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table5.A1" office:value-type="string">
+ <text:p text:style-name="P20">5.0</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table5.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">Here’s another one. Note the
+ blank line between rows.</text:p>
+ </table:table-cell>
+ </table:table-row>
+</table:table>
+<text:p text:style-name="First_20_paragraph">Table without column
+headers:</text:p>
+<table:table table:name="Table6" table:style-name="Table6">
+ <table:table-column table:style-name="Table6.A" />
+ <table:table-column table:style-name="Table6.B" />
+ <table:table-column table:style-name="Table6.C" />
+ <table:table-column table:style-name="Table6.D" />
+ <table:table-row>
+ <table:table-cell table:style-name="Table6.A1" office:value-type="string">
+ <text:p text:style-name="P24">12</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table6.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">12</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table6.A1" office:value-type="string">
+ <text:p text:style-name="P25">12</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table6.A1" office:value-type="string">
+ <text:p text:style-name="P26">12</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell table:style-name="Table6.A1" office:value-type="string">
+ <text:p text:style-name="P24">123</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table6.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">123</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table6.A1" office:value-type="string">
+ <text:p text:style-name="P25">123</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table6.A1" office:value-type="string">
+ <text:p text:style-name="P26">123</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell table:style-name="Table6.A1" office:value-type="string">
+ <text:p text:style-name="P24">1</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table6.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">1</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table6.A1" office:value-type="string">
+ <text:p text:style-name="P25">1</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table6.A1" office:value-type="string">
+ <text:p text:style-name="P26">1</text:p>
+ </table:table-cell>
+ </table:table-row>
+</table:table>
+<text:p text:style-name="First_20_paragraph">Multiline table without column
+headers:</text:p>
+<table:table table:name="Table7" table:style-name="Table7">
+ <table:table-column table:style-name="Table7.A" />
+ <table:table-column table:style-name="Table7.B" />
+ <table:table-column table:style-name="Table7.C" />
+ <table:table-column table:style-name="Table7.D" />
+ <table:table-row>
+ <table:table-cell table:style-name="Table7.A1" office:value-type="string">
+ <text:p text:style-name="P29">First</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table7.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">row</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table7.A1" office:value-type="string">
+ <text:p text:style-name="P30">12.0</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table7.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">Example of a row that spans
+ multiple lines.</text:p>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell table:style-name="Table7.A1" office:value-type="string">
+ <text:p text:style-name="P29">Second</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table7.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">row</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table7.A1" office:value-type="string">
+ <text:p text:style-name="P30">5.0</text:p>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table7.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents">Here’s another one. Note the
+ blank line between rows.</text:p>
+ </table:table-cell>
+ </table:table-row>
+</table:table>
diff --git a/test/tables.org b/test/tables.org
new file mode 100644
index 000000000..9eaf5e706
--- /dev/null
+++ b/test/tables.org
@@ -0,0 +1,51 @@
+Simple table with caption:
+
+| Right | Left | Center | Default |
+|---------+--------+----------+-----------|
+| 12 | 12 | 12 | 12 |
+| 123 | 123 | 123 | 123 |
+| 1 | 1 | 1 | 1 |
+#+CAPTION: Demonstration of simple table syntax.
+
+Simple table without caption:
+
+| Right | Left | Center | Default |
+|---------+--------+----------+-----------|
+| 12 | 12 | 12 | 12 |
+| 123 | 123 | 123 | 123 |
+| 1 | 1 | 1 | 1 |
+
+Simple table indented two spaces:
+
+| Right | Left | Center | Default |
+|---------+--------+----------+-----------|
+| 12 | 12 | 12 | 12 |
+| 123 | 123 | 123 | 123 |
+| 1 | 1 | 1 | 1 |
+#+CAPTION: Demonstration of simple table syntax.
+
+Multiline table with caption:
+
+| Centered Header | Left Aligned | Right Aligned | Default aligned |
+|-------------------+----------------+-----------------+---------------------------------------------------------|
+| First | row | 12.0 | Example of a row that spans multiple lines. |
+| Second | row | 5.0 | Here's another one. Note the blank line between rows. |
+#+CAPTION: Here's the caption. It may span multiple lines.
+
+Multiline table without caption:
+
+| Centered Header | Left Aligned | Right Aligned | Default aligned |
+|-------------------+----------------+-----------------+---------------------------------------------------------|
+| First | row | 12.0 | Example of a row that spans multiple lines. |
+| Second | row | 5.0 | Here's another one. Note the blank line between rows. |
+
+Table without column headers:
+
+| 12 | 12 | 12 | 12 |
+| 123 | 123 | 123 | 123 |
+| 1 | 1 | 1 | 1 |
+
+Multiline table without column headers:
+
+| First | row | 12.0 | Example of a row that spans multiple lines. |
+| Second | row | 5.0 | Here's another one. Note the blank line between rows. |
diff --git a/test/tables.plain b/test/tables.plain
new file mode 100644
index 000000000..4c7ebbf82
--- /dev/null
+++ b/test/tables.plain
@@ -0,0 +1,78 @@
+Simple table with caption:
+
+ Right Left Center Default
+ ------- ------ -------- ---------
+ 12 12 12 12
+ 123 123 123 123
+ 1 1 1 1
+
+ : Demonstration of simple table syntax.
+
+Simple table without caption:
+
+ Right Left Center Default
+ ------- ------ -------- ---------
+ 12 12 12 12
+ 123 123 123 123
+ 1 1 1 1
+
+Simple table indented two spaces:
+
+ Right Left Center Default
+ ------- ------ -------- ---------
+ 12 12 12 12
+ 123 123 123 123
+ 1 1 1 1
+
+ : Demonstration of simple table syntax.
+
+Multiline table with caption:
+
+ --------------------------------------------------------------
+ Centered Left Right Default aligned
+ Header Aligned Aligned
+ ----------- ---------- ------------ --------------------------
+ First row 12.0 Example of a row that
+ spans multiple lines.
+
+ Second row 5.0 Here’s another one. Note
+ the blank line between
+ rows.
+ --------------------------------------------------------------
+
+ : Here’s the caption. It may span multiple lines.
+
+Multiline table without caption:
+
+ --------------------------------------------------------------
+ Centered Left Right Default aligned
+ Header Aligned Aligned
+ ----------- ---------- ------------ --------------------------
+ First row 12.0 Example of a row that
+ spans multiple lines.
+
+ Second row 5.0 Here’s another one. Note
+ the blank line between
+ rows.
+ --------------------------------------------------------------
+
+Table without column headers:
+
+ ----- ----- ----- -----
+ 12 12 12 12
+ 123 123 123 123
+ 1 1 1 1
+ ----- ----- ----- -----
+
+Multiline table without column headers:
+
+ ----------- ---------- ------------ --------------------------
+ First row 12.0 Example of a row that
+ spans multiple lines.
+
+ Second row 5.0 Here’s another one. Note
+ the blank line between
+ rows.
+ ----------- ---------- ------------ --------------------------
+
+
diff --git a/test/tables.rst b/test/tables.rst
new file mode 100644
index 000000000..184d9894a
--- /dev/null
+++ b/test/tables.rst
@@ -0,0 +1,90 @@
+Simple table with caption:
+
+.. table:: Demonstration of simple table syntax.
+
+ +---------+--------+----------+-----------+
+ | 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 |
++---------+--------+----------+-----------+
+
+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 |
+ +---------+--------+----------+-----------+
+
+Multiline table with caption:
+
+.. table:: Here’s the caption. It may span multiple lines.
+
+ +-------------+------------+--------------+----------------------------+
+ | Centered | Left | Right | Default aligned |
+ | Header | Aligned | Aligned | |
+ +=============+============+==============+============================+
+ | First | row | 12.0 | Example of a row that |
+ | | | | spans multiple lines. |
+ +-------------+------------+--------------+----------------------------+
+ | Second | row | 5.0 | Here’s another one. Note |
+ | | | | the blank line between |
+ | | | | rows. |
+ +-------------+------------+--------------+----------------------------+
+
+Multiline table without caption:
+
++-------------+------------+--------------+----------------------------+
+| Centered | Left | Right | Default aligned |
+| Header | Aligned | Aligned | |
++=============+============+==============+============================+
+| First | row | 12.0 | Example of a row that |
+| | | | spans multiple lines. |
++-------------+------------+--------------+----------------------------+
+| Second | row | 5.0 | Here’s another one. Note |
+| | | | the blank line between |
+| | | | rows. |
++-------------+------------+--------------+----------------------------+
+
+Table without column headers:
+
++-------+-------+-------+-------+
+| 12 | 12 | 12 | 12 |
++-------+-------+-------+-------+
+| 123 | 123 | 123 | 123 |
++-------+-------+-------+-------+
+| 1 | 1 | 1 | 1 |
++-------+-------+-------+-------+
+
+Multiline table without column headers:
+
++-------------+------------+--------------+----------------------------+
+| First | row | 12.0 | Example of a row that |
+| | | | spans multiple lines. |
++-------------+------------+--------------+----------------------------+
+| Second | row | 5.0 | Here’s another one. Note |
+| | | | the blank line between |
+| | | | rows. |
++-------------+------------+--------------+----------------------------+
diff --git a/test/tables.rtf b/test/tables.rtf
new file mode 100644
index 000000000..57030b114
--- /dev/null
+++ b/test/tables.rtf
@@ -0,0 +1,360 @@
+{\pard \ql \f0 \sa180 \li0 \fi0 Simple table with caption:\par}
+{
+\trowd \trgaph120
+\clbrdrb\brdrs\cellx2160\clbrdrb\brdrs\cellx4320\clbrdrb\brdrs\cellx6480\clbrdrb\brdrs\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Center\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx2160\cellx4320\cellx6480\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx2160\cellx4320\cellx6480\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx2160\cellx4320\cellx6480\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+}
+\intbl\row}
+{\pard \ql \f0 \sa180 \li0 \fi0 Demonstration of simple table syntax.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Simple table without caption:\par}
+{
+\trowd \trgaph120
+\clbrdrb\brdrs\cellx2160\clbrdrb\brdrs\cellx4320\clbrdrb\brdrs\cellx6480\clbrdrb\brdrs\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Center\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx2160\cellx4320\cellx6480\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx2160\cellx4320\cellx6480\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx2160\cellx4320\cellx6480\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+}
+\intbl\row}
+{\pard \ql \f0 \sa180 \li0 \fi0 \par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Simple table indented two spaces:\par}
+{
+\trowd \trgaph120
+\clbrdrb\brdrs\cellx2160\clbrdrb\brdrs\cellx4320\clbrdrb\brdrs\cellx6480\clbrdrb\brdrs\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Center\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx2160\cellx4320\cellx6480\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx2160\cellx4320\cellx6480\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx2160\cellx4320\cellx6480\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+}
+\intbl\row}
+{\pard \ql \f0 \sa180 \li0 \fi0 Demonstration of simple table syntax.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Multiline table with caption:\par}
+{
+\trowd \trgaph120
+\clbrdrb\brdrs\cellx1296\clbrdrb\brdrs\cellx2484\clbrdrb\brdrs\cellx3888\clbrdrb\brdrs\cellx6804
+\trkeep\intbl
+{
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Centered Header\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left Aligned\par}
+\cell}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right Aligned\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default aligned\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx1296\cellx2484\cellx3888\cellx6804
+\trkeep\intbl
+{
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 First\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par}
+\cell}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12.0\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx1296\cellx2484\cellx3888\cellx6804
+\trkeep\intbl
+{
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Second\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par}
+\cell}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 5.0\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Here\u8217's another one. Note the blank line between rows.\par}
+\cell}
+}
+\intbl\row}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here\u8217's the caption. It may span multiple lines.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Multiline table without caption:\par}
+{
+\trowd \trgaph120
+\clbrdrb\brdrs\cellx1296\clbrdrb\brdrs\cellx2484\clbrdrb\brdrs\cellx3888\clbrdrb\brdrs\cellx6804
+\trkeep\intbl
+{
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Centered Header\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left Aligned\par}
+\cell}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right Aligned\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default aligned\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx1296\cellx2484\cellx3888\cellx6804
+\trkeep\intbl
+{
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 First\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par}
+\cell}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12.0\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx1296\cellx2484\cellx3888\cellx6804
+\trkeep\intbl
+{
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Second\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par}
+\cell}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 5.0\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Here\u8217's another one. Note the blank line between rows.\par}
+\cell}
+}
+\intbl\row}
+{\pard \ql \f0 \sa180 \li0 \fi0 \par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Table without column headers:\par}
+{
+\trowd \trgaph120
+\cellx2160\cellx4320\cellx6480\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx2160\cellx4320\cellx6480\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx2160\cellx4320\cellx6480\cellx8640
+\trkeep\intbl
+{
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par}
+\cell}
+}
+\intbl\row}
+{\pard \ql \f0 \sa180 \li0 \fi0 \par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Multiline table without column headers:\par}
+{
+\trowd \trgaph120
+\cellx1296\cellx2484\cellx3888\cellx6804
+\trkeep\intbl
+{
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 First\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par}
+\cell}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12.0\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par}
+\cell}
+}
+\intbl\row}
+{
+\trowd \trgaph120
+\cellx1296\cellx2484\cellx3888\cellx6804
+\trkeep\intbl
+{
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Second\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par}
+\cell}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 5.0\par}
+\cell}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Here\u8217's another one. Note the blank line between rows.\par}
+\cell}
+}
+\intbl\row}
+{\pard \ql \f0 \sa180 \li0 \fi0 \par}
+
diff --git a/test/tables.tei b/test/tables.tei
new file mode 100644
index 000000000..64438e520
--- /dev/null
+++ b/test/tables.tei
@@ -0,0 +1,171 @@
+<p>Simple table with caption:</p>
+<table>
+ <row role="label">
+ <cell><p>Right</p></cell>
+ <cell><p>Left</p></cell>
+ <cell><p>Center</p></cell>
+ <cell><p>Default</p></cell>
+ </row>
+ <row>
+ <cell><p>12</p></cell>
+ <cell><p>12</p></cell>
+ <cell><p>12</p></cell>
+ <cell><p>12</p></cell>
+ </row>
+ <row>
+ <cell><p>123</p></cell>
+ <cell><p>123</p></cell>
+ <cell><p>123</p></cell>
+ <cell><p>123</p></cell>
+ </row>
+ <row>
+ <cell><p>1</p></cell>
+ <cell><p>1</p></cell>
+ <cell><p>1</p></cell>
+ <cell><p>1</p></cell>
+ </row>
+</table>
+<p>Simple table without caption:</p>
+<table>
+ <row role="label">
+ <cell><p>Right</p></cell>
+ <cell><p>Left</p></cell>
+ <cell><p>Center</p></cell>
+ <cell><p>Default</p></cell>
+ </row>
+ <row>
+ <cell><p>12</p></cell>
+ <cell><p>12</p></cell>
+ <cell><p>12</p></cell>
+ <cell><p>12</p></cell>
+ </row>
+ <row>
+ <cell><p>123</p></cell>
+ <cell><p>123</p></cell>
+ <cell><p>123</p></cell>
+ <cell><p>123</p></cell>
+ </row>
+ <row>
+ <cell><p>1</p></cell>
+ <cell><p>1</p></cell>
+ <cell><p>1</p></cell>
+ <cell><p>1</p></cell>
+ </row>
+</table>
+<p>Simple table indented two spaces:</p>
+<table>
+ <row role="label">
+ <cell><p>Right</p></cell>
+ <cell><p>Left</p></cell>
+ <cell><p>Center</p></cell>
+ <cell><p>Default</p></cell>
+ </row>
+ <row>
+ <cell><p>12</p></cell>
+ <cell><p>12</p></cell>
+ <cell><p>12</p></cell>
+ <cell><p>12</p></cell>
+ </row>
+ <row>
+ <cell><p>123</p></cell>
+ <cell><p>123</p></cell>
+ <cell><p>123</p></cell>
+ <cell><p>123</p></cell>
+ </row>
+ <row>
+ <cell><p>1</p></cell>
+ <cell><p>1</p></cell>
+ <cell><p>1</p></cell>
+ <cell><p>1</p></cell>
+ </row>
+</table>
+<p>Multiline table with caption:</p>
+<table>
+ <row role="label">
+ <cell><p>Centered Header</p></cell>
+ <cell><p>Left Aligned</p></cell>
+ <cell><p>Right Aligned</p></cell>
+ <cell><p>Default aligned</p></cell>
+ </row>
+ <row>
+ <cell><p>First</p></cell>
+ <cell><p>row</p></cell>
+ <cell><p>12.0</p></cell>
+ <cell><p>Example of a row that spans multiple lines.</p></cell>
+ </row>
+ <row>
+ <cell><p>Second</p></cell>
+ <cell><p>row</p></cell>
+ <cell><p>5.0</p></cell>
+ <cell><p>Here’s another one. Note the blank line between rows.</p></cell>
+ </row>
+</table>
+<p>Multiline table without caption:</p>
+<table>
+ <row role="label">
+ <cell><p>Centered Header</p></cell>
+ <cell><p>Left Aligned</p></cell>
+ <cell><p>Right Aligned</p></cell>
+ <cell><p>Default aligned</p></cell>
+ </row>
+ <row>
+ <cell><p>First</p></cell>
+ <cell><p>row</p></cell>
+ <cell><p>12.0</p></cell>
+ <cell><p>Example of a row that spans multiple lines.</p></cell>
+ </row>
+ <row>
+ <cell><p>Second</p></cell>
+ <cell><p>row</p></cell>
+ <cell><p>5.0</p></cell>
+ <cell><p>Here’s another one. Note the blank line between rows.</p></cell>
+ </row>
+</table>
+<p>Table without column headers:</p>
+<table>
+ <row role="label">
+ <cell></cell>
+ <cell></cell>
+ <cell></cell>
+ <cell></cell>
+ </row>
+ <row>
+ <cell><p>12</p></cell>
+ <cell><p>12</p></cell>
+ <cell><p>12</p></cell>
+ <cell><p>12</p></cell>
+ </row>
+ <row>
+ <cell><p>123</p></cell>
+ <cell><p>123</p></cell>
+ <cell><p>123</p></cell>
+ <cell><p>123</p></cell>
+ </row>
+ <row>
+ <cell><p>1</p></cell>
+ <cell><p>1</p></cell>
+ <cell><p>1</p></cell>
+ <cell><p>1</p></cell>
+ </row>
+</table>
+<p>Multiline table without column headers:</p>
+<table>
+ <row role="label">
+ <cell></cell>
+ <cell></cell>
+ <cell></cell>
+ <cell></cell>
+ </row>
+ <row>
+ <cell><p>First</p></cell>
+ <cell><p>row</p></cell>
+ <cell><p>12.0</p></cell>
+ <cell><p>Example of a row that spans multiple lines.</p></cell>
+ </row>
+ <row>
+ <cell><p>Second</p></cell>
+ <cell><p>row</p></cell>
+ <cell><p>5.0</p></cell>
+ <cell><p>Here’s another one. Note the blank line between rows.</p></cell>
+ </row>
+</table>
diff --git a/test/tables.texinfo b/test/tables.texinfo
new file mode 100644
index 000000000..b82006f1a
--- /dev/null
+++ b/test/tables.texinfo
@@ -0,0 +1,158 @@
+@node Top
+@top Top
+
+Simple table with caption:
+
+@float
+@multitable {Right} {Left} {Center} {Default}
+@headitem
+Right
+ @tab Left
+ @tab Center
+ @tab Default
+@item
+12
+ @tab 12
+ @tab 12
+ @tab 12
+@item
+123
+ @tab 123
+ @tab 123
+ @tab 123
+@item
+1
+ @tab 1
+ @tab 1
+ @tab 1
+@end multitable
+@caption{Demonstration of simple table syntax.}
+@end float
+Simple table without caption:
+
+@multitable {Right} {Left} {Center} {Default}
+@headitem
+Right
+ @tab Left
+ @tab Center
+ @tab Default
+@item
+12
+ @tab 12
+ @tab 12
+ @tab 12
+@item
+123
+ @tab 123
+ @tab 123
+ @tab 123
+@item
+1
+ @tab 1
+ @tab 1
+ @tab 1
+@end multitable
+
+Simple table indented two spaces:
+
+@float
+@multitable {Right} {Left} {Center} {Default}
+@headitem
+Right
+ @tab Left
+ @tab Center
+ @tab Default
+@item
+12
+ @tab 12
+ @tab 12
+ @tab 12
+@item
+123
+ @tab 123
+ @tab 123
+ @tab 123
+@item
+1
+ @tab 1
+ @tab 1
+ @tab 1
+@end multitable
+@caption{Demonstration of simple table syntax.}
+@end float
+Multiline table with caption:
+
+@float
+@multitable @columnfractions 0.15 0.14 0.16 0.34
+@headitem
+Centered Header
+ @tab Left Aligned
+ @tab Right Aligned
+ @tab Default aligned
+@item
+First
+ @tab row
+ @tab 12.0
+ @tab Example of a row that spans multiple lines.
+@item
+Second
+ @tab row
+ @tab 5.0
+ @tab Here's another one. Note the blank line between rows.
+@end multitable
+@caption{Here's the caption. It may span multiple lines.}
+@end float
+Multiline table without caption:
+
+@multitable @columnfractions 0.15 0.14 0.16 0.34
+@headitem
+Centered Header
+ @tab Left Aligned
+ @tab Right Aligned
+ @tab Default aligned
+@item
+First
+ @tab row
+ @tab 12.0
+ @tab Example of a row that spans multiple lines.
+@item
+Second
+ @tab row
+ @tab 5.0
+ @tab Here's another one. Note the blank line between rows.
+@end multitable
+
+Table without column headers:
+
+@multitable {123} {123} {123} {123}
+@item
+12
+ @tab 12
+ @tab 12
+ @tab 12
+@item
+123
+ @tab 123
+ @tab 123
+ @tab 123
+@item
+1
+ @tab 1
+ @tab 1
+ @tab 1
+@end multitable
+
+Multiline table without column headers:
+
+@multitable @columnfractions 0.15 0.14 0.16 0.34
+@item
+First
+ @tab row
+ @tab 12.0
+ @tab Example of a row that spans multiple lines.
+@item
+Second
+ @tab row
+ @tab 5.0
+ @tab Here's another one. Note the blank line between rows.
+@end multitable
diff --git a/test/tables.textile b/test/tables.textile
new file mode 100644
index 000000000..6c6b234e6
--- /dev/null
+++ b/test/tables.textile
@@ -0,0 +1,167 @@
+Simple table with caption:
+
+<table>
+<caption>Demonstration of simple table syntax.</caption>
+<thead>
+<tr class="header">
+<th align="right">Right</th>
+<th align="left">Left</th>
+<th align="center">Center</th>
+<th align="left">Default</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td align="right">12</td>
+<td align="left">12</td>
+<td align="center">12</td>
+<td align="left">12</td>
+</tr>
+<tr class="even">
+<td align="right">123</td>
+<td align="left">123</td>
+<td align="center">123</td>
+<td align="left">123</td>
+</tr>
+<tr class="odd">
+<td align="right">1</td>
+<td align="left">1</td>
+<td align="center">1</td>
+<td align="left">1</td>
+</tr>
+</tbody>
+</table>
+
+Simple table without caption:
+
+|_. Right|_. Left|_. Center|_. Default|
+|>. 12|<. 12|=. 12|12|
+|>. 123|<. 123|=. 123|123|
+|>. 1|<. 1|=. 1|1|
+
+Simple table indented two spaces:
+
+<table>
+<caption>Demonstration of simple table syntax.</caption>
+<thead>
+<tr class="header">
+<th align="right">Right</th>
+<th align="left">Left</th>
+<th align="center">Center</th>
+<th align="left">Default</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td align="right">12</td>
+<td align="left">12</td>
+<td align="center">12</td>
+<td align="left">12</td>
+</tr>
+<tr class="even">
+<td align="right">123</td>
+<td align="left">123</td>
+<td align="center">123</td>
+<td align="left">123</td>
+</tr>
+<tr class="odd">
+<td align="right">1</td>
+<td align="left">1</td>
+<td align="center">1</td>
+<td align="left">1</td>
+</tr>
+</tbody>
+</table>
+
+Multiline table with caption:
+
+<table>
+<caption>Here's the caption. It may span multiple lines.</caption>
+<col width="15%" />
+<col width="13%" />
+<col width="16%" />
+<col width="33%" />
+<thead>
+<tr class="header">
+<th align="center">Centered Header</th>
+<th align="left">Left Aligned</th>
+<th align="right">Right Aligned</th>
+<th align="left">Default aligned</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td align="center">First</td>
+<td align="left">row</td>
+<td align="right">12.0</td>
+<td align="left">Example of a row that spans multiple lines.</td>
+</tr>
+<tr class="even">
+<td align="center">Second</td>
+<td align="left">row</td>
+<td align="right">5.0</td>
+<td align="left">Here's another one. Note the blank line between rows.</td>
+</tr>
+</tbody>
+</table>
+
+Multiline table without caption:
+
+<table>
+<col width="15%" />
+<col width="13%" />
+<col width="16%" />
+<col width="33%" />
+<thead>
+<tr class="header">
+<th align="center">Centered Header</th>
+<th align="left">Left Aligned</th>
+<th align="right">Right Aligned</th>
+<th align="left">Default aligned</th>
+</tr>
+</thead>
+<tbody>
+<tr class="odd">
+<td align="center">First</td>
+<td align="left">row</td>
+<td align="right">12.0</td>
+<td align="left">Example of a row that spans multiple lines.</td>
+</tr>
+<tr class="even">
+<td align="center">Second</td>
+<td align="left">row</td>
+<td align="right">5.0</td>
+<td align="left">Here's another one. Note the blank line between rows.</td>
+</tr>
+</tbody>
+</table>
+
+Table without column headers:
+
+|>. 12|<. 12|=. 12|>. 12|
+|>. 123|<. 123|=. 123|>. 123|
+|>. 1|<. 1|=. 1|>. 1|
+
+Multiline table without column headers:
+
+<table>
+<col width="15%" />
+<col width="13%" />
+<col width="16%" />
+<col width="33%" />
+<tbody>
+<tr class="odd">
+<td align="center">First</td>
+<td align="left">row</td>
+<td align="right">12.0</td>
+<td align="left">Example of a row that spans multiple lines.</td>
+</tr>
+<tr class="even">
+<td align="center">Second</td>
+<td align="left">row</td>
+<td align="right">5.0</td>
+<td align="left">Here's another one. Note the blank line between rows.</td>
+</tr>
+</tbody>
+</table>
+
diff --git a/test/tables.txt b/test/tables.txt
new file mode 100644
index 000000000..d70492262
--- /dev/null
+++ b/test/tables.txt
@@ -0,0 +1,75 @@
+Simple table with caption:
+
+ Right Left Center Default
+------- ------ ---------- -------
+ 12 12 12 12
+ 123 123 123 123
+ 1 1 1 1
+
+Table: Demonstration of simple table syntax.
+
+Simple table without caption:
+
+ Right Left Center Default
+------- ------ ---------- -------
+ 12 12 12 12
+ 123 123 123 123
+ 1 1 1 1
+
+Simple table indented two spaces:
+
+ Right Left Center Default
+ ------- ------ ---------- -------
+ 12 12 12 12
+ 123 123 123 123
+ 1 1 1 1
+
+ : Demonstration of simple table syntax.
+
+Multiline table with caption:
+
+: Here's the caption.
+It may span multiple lines.
+
+---------------------------------------------------------------
+ Centered Left Right
+ Header Aligned 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.
+---------------------------------------------------------------
+
+Multiline table without caption:
+
+---------------------------------------------------------------
+ Centered Left Right
+ Header Aligned Aligned Default aligned
+---------- --------- ----------- ---------------------------
+ First row 12.0 Example of a row that spans
+ multiple lines.
+
+ Second row 5.0 Here's another one. Note
+ the blank line between rows.
+---------------------------------------------------------------
+
+Table without column headers:
+
+------- ------ ---------- -------
+ 12 12 12 12
+ 123 123 123 123
+ 1 1 1 1
+------- ------ ---------- -------
+
+Multiline table without column headers:
+
+---------- --------- ----------- ---------------------------
+ First row 12.0 Example of a row that spans
+ multiple lines.
+
+ Second row 5.0 Here's another one. Note
+ the blank line between rows.
+---------- --------- ----------- ---------------------------
+
diff --git a/test/tables.zimwiki b/test/tables.zimwiki
new file mode 100644
index 000000000..2757055f6
--- /dev/null
+++ b/test/tables.zimwiki
@@ -0,0 +1,56 @@
+Simple table with caption:
+
+Demonstration of simple table syntax.
+|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 |
+
+Simple table indented two spaces:
+
+Demonstration of simple table syntax.
+|Right|Left |Center |Default|
+|----:|:----|:-----:|-------|
+| 12|12 | 12 |12 |
+| 123|123 | 123 |123 |
+| 1|1 | 1 |1 |
+
+Multiline table with caption:
+
+Here’s the caption. It may span multiple lines.
+|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. |
+
+Multiline table without caption:
+
+|Centered Header|Left Aligned|Right Aligned|Default aligned |
+|:-------------:|:-----------|------------:|:------------------------------------------------------|
+| First |row | 12.0|Example of a row that spans multiple lines. |
+| Second |row | 5.0|Here’s another one. Note the blank line between rows. |
+
+Table without column headers:
+
+| 12|12 | 12 | 12|
+|----:|:----|:-----:|----:|
+| 12|12 | 12 | 12|
+| 123|123 | 123 | 123|
+| 1|1 | 1 | 1|
+
+Multiline table without column headers:
+
+| First |row | 12.0|Example of a row that spans multiple lines. |
+|:--------:|:----|-----:|-----------------------------------------------------|
+| First |row | 12.0|Example of a row that spans multiple lines. |
+| Second |row | 5.0|Here’s another one. Note the blank line between rows.|
+
diff --git a/test/test-pandoc.hs b/test/test-pandoc.hs
new file mode 100644
index 000000000..8800dde24
--- /dev/null
+++ b/test/test-pandoc.hs
@@ -0,0 +1,69 @@
+{-# OPTIONS_GHC -Wall #-}
+
+module Main where
+
+import Test.Framework
+import GHC.IO.Encoding
+import qualified Tests.Old
+import qualified Tests.Command
+import qualified Tests.Readers.LaTeX
+import qualified Tests.Readers.Markdown
+import qualified Tests.Readers.Org
+import qualified Tests.Readers.HTML
+import qualified Tests.Readers.RST
+import qualified Tests.Readers.Docx
+import qualified Tests.Readers.Odt
+import qualified Tests.Readers.Txt2Tags
+import qualified Tests.Readers.EPUB
+import qualified Tests.Writers.ConTeXt
+import qualified Tests.Writers.LaTeX
+import qualified Tests.Writers.HTML
+import qualified Tests.Writers.Docbook
+import qualified Tests.Writers.Native
+import qualified Tests.Writers.Markdown
+import qualified Tests.Writers.Org
+import qualified Tests.Writers.Plain
+import qualified Tests.Writers.AsciiDoc
+import qualified Tests.Writers.Docx
+import qualified Tests.Writers.RST
+import qualified Tests.Writers.TEI
+import qualified Tests.Shared
+import Text.Pandoc.Shared (inDirectory)
+import System.Environment (getArgs)
+
+tests :: [Test]
+tests = [ Tests.Command.tests
+ , testGroup "Old" Tests.Old.tests
+ , testGroup "Shared" Tests.Shared.tests
+ , testGroup "Writers"
+ [ testGroup "Native" Tests.Writers.Native.tests
+ , testGroup "ConTeXt" Tests.Writers.ConTeXt.tests
+ , testGroup "LaTeX" Tests.Writers.LaTeX.tests
+ , testGroup "HTML" Tests.Writers.HTML.tests
+ , testGroup "Docbook" Tests.Writers.Docbook.tests
+ , testGroup "Markdown" Tests.Writers.Markdown.tests
+ , testGroup "Org" Tests.Writers.Org.tests
+ , testGroup "Plain" Tests.Writers.Plain.tests
+ , testGroup "AsciiDoc" Tests.Writers.AsciiDoc.tests
+ , testGroup "Docx" Tests.Writers.Docx.tests
+ , testGroup "RST" Tests.Writers.RST.tests
+ , testGroup "TEI" Tests.Writers.TEI.tests
+ ]
+ , testGroup "Readers"
+ [ testGroup "LaTeX" Tests.Readers.LaTeX.tests
+ , testGroup "Markdown" Tests.Readers.Markdown.tests
+ , testGroup "HTML" Tests.Readers.HTML.tests
+ , testGroup "Org" Tests.Readers.Org.tests
+ , testGroup "RST" Tests.Readers.RST.tests
+ , testGroup "Docx" Tests.Readers.Docx.tests
+ , testGroup "Odt" Tests.Readers.Odt.tests
+ , testGroup "Txt2Tags" Tests.Readers.Txt2Tags.tests
+ , testGroup "EPUB" Tests.Readers.EPUB.tests
+ ]
+ ]
+
+main :: IO ()
+main = do
+ setLocaleEncoding utf8
+ args <- getArgs
+ inDirectory "test" $ defaultMainWithArgs tests args
diff --git a/test/testsuite.native b/test/testsuite.native
new file mode 100644
index 000000000..fa234dfc2
--- /dev/null
+++ b/test/testsuite.native
@@ -0,0 +1,411 @@
+Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])]})
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",SoftBreak,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
+,HorizontalRule
+,Header 1 ("headers",[],[]) [Str "Headers"]
+,Header 2 ("level-2-with-an-embedded-link",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link ("",[],[]) [Str "embedded",Space,Str "link"] ("/url","")]
+,Header 3 ("level-3-with-emphasis",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 4 ("level-4",[],[]) [Str "Level",Space,Str "4"]
+,Header 5 ("level-5",[],[]) [Str "Level",Space,Str "5"]
+,Header 1 ("level-1",[],[]) [Str "Level",Space,Str "1"]
+,Header 2 ("level-2-with-emphasis",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 3 ("level-3",[],[]) [Str "Level",Space,Str "3"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,Header 2 ("level-2",[],[]) [Str "Level",Space,Str "2"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,HorizontalRule
+,Header 1 ("paragraphs",[],[]) [Str "Paragraphs"]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
+,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",SoftBreak,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",SoftBreak,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",SoftBreak,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",SoftBreak,Str "list",Space,Str "item."]
+,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",SoftBreak,Str "*",Space,Str "criminey."]
+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here."]
+,HorizontalRule
+,Header 1 ("block-quotes",[],[]) [Str "Block",Space,Str "Quotes"]
+,Para [Str "E-mail",Space,Str "style:"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",SoftBreak,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]]
+,BlockQuote
+ [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
+ ,Para [Str "A",Space,Str "list:"]
+ ,OrderedList (1,Decimal,Period)
+ [[Plain [Str "item",Space,Str "one"]]
+ ,[Plain [Str "item",Space,Str "two"]]]
+ ,Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
+ ,BlockQuote
+ [Para [Str "nested"]]
+ ,BlockQuote
+ [Para [Str "nested"]]]
+,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",SoftBreak,Str ">",Space,Str "1."]
+,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."]
+,HorizontalRule
+,Header 1 ("code-blocks",[],[]) [Str "Code",Space,Str "Blocks"]
+,Para [Str "Code:"]
+,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"
+,Para [Str "And:"]
+,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
+,HorizontalRule
+,Header 1 ("lists",[],[]) [Str "Lists"]
+,Header 2 ("unordered",[],[]) [Str "Unordered"]
+,Para [Str "Asterisks",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "asterisk",Space,Str "1"]]
+ ,[Plain [Str "asterisk",Space,Str "2"]]
+ ,[Plain [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Asterisks",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "asterisk",Space,Str "1"]]
+ ,[Para [Str "asterisk",Space,Str "2"]]
+ ,[Para [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "Plus",Space,Str "1"]]
+ ,[Plain [Str "Plus",Space,Str "2"]]
+ ,[Plain [Str "Plus",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "Plus",Space,Str "1"]]
+ ,[Para [Str "Plus",Space,Str "2"]]
+ ,[Para [Str "Plus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "Minus",Space,Str "1"]]
+ ,[Plain [Str "Minus",Space,Str "2"]]
+ ,[Plain [Str "Minus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "Minus",Space,Str "1"]]
+ ,[Para [Str "Minus",Space,Str "2"]]
+ ,[Para [Str "Minus",Space,Str "3"]]]
+,Header 2 ("ordered",[],[]) [Str "Ordered"]
+,Para [Str "Tight:"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second"]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "and:"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "One"]]
+ ,[Plain [Str "Two"]]
+ ,[Plain [Str "Three"]]]
+,Para [Str "Loose",Space,Str "using",Space,Str "tabs:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second"]]
+ ,[Para [Str "Third"]]]
+,Para [Str "and",Space,Str "using",Space,Str "spaces:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "One"]]
+ ,[Para [Str "Two"]]
+ ,[Para [Str "Three"]]]
+,Para [Str "Multiple",Space,Str "paragraphs:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]
+ ,Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",SoftBreak,Str "back."]]
+ ,[Para [Str "Item",Space,Str "2."]]
+ ,[Para [Str "Item",Space,Str "3."]]]
+,Header 2 ("nested",[],[]) [Str "Nested"]
+,BulletList
+ [[Plain [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]]]]]]]
+,Para [Str "Here\8217s",Space,Str "another:"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second:"]
+ ,BulletList
+ [[Plain [Str "Fee"]]
+ ,[Plain [Str "Fie"]]
+ ,[Plain [Str "Foe"]]]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second:"]
+ ,BulletList
+ [[Plain [Str "Fee"]]
+ ,[Plain [Str "Fie"]]
+ ,[Plain [Str "Foe"]]]]
+ ,[Para [Str "Third"]]]
+,Header 2 ("tabs-and-spaces",[],[]) [Str "Tabs",Space,Str "and",Space,Str "spaces"]
+,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",SoftBreak,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",SoftBreak,Str "indented",Space,Str "with",Space,Str "spaces"]
+ ,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",SoftBreak,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",SoftBreak,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]
+,Header 2 ("fancy-list-markers",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"]
+,OrderedList (2,Decimal,TwoParens)
+ [[Plain [Str "begins",Space,Str "with",Space,Str "2"]]
+ ,[Para [Str "and",Space,Str "now",Space,Str "3"]
+ ,Para [Str "with",Space,Str "a",Space,Str "continuation"]
+ ,OrderedList (4,LowerRoman,Period)
+ [[Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",SoftBreak,Str "starting",Space,Str "with",Space,Str "4"]]
+ ,[Plain [Str "more",Space,Str "items"]
+ ,OrderedList (1,UpperAlpha,TwoParens)
+ [[Plain [Str "a",Space,Str "subsublist"]]
+ ,[Plain [Str "a",Space,Str "subsublist"]]]]]]]
+,Para [Str "Nesting:"]
+,OrderedList (1,UpperAlpha,Period)
+ [[Plain [Str "Upper",Space,Str "Alpha"]
+ ,OrderedList (1,UpperRoman,Period)
+ [[Plain [Str "Upper",Space,Str "Roman."]
+ ,OrderedList (6,Decimal,TwoParens)
+ [[Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
+ ,OrderedList (3,LowerAlpha,OneParen)
+ [[Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]
+,Para [Str "Autonumbering:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Autonumber."]]
+ ,[Plain [Str "More."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Nested."]]]]]
+,Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]
+,Para [Str "M.A.\160\&2007"]
+,Para [Str "B.",Space,Str "Williams"]
+,HorizontalRule
+,Header 1 ("definition-lists",[],[]) [Str "Definition",Space,Str "Lists"]
+,Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Plain [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Plain [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Plain [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Tight",Space,Str "using",Space,Str "tabs:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Plain [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Plain [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Plain [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Loose:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Para [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics:"]
+,DefinitionList
+ [([Emph [Str "apple"]],
+ [[Para [Str "red",Space,Str "fruit"]
+ ,Para [Str "contains",Space,Str "seeds,",SoftBreak,Str "crisp,",Space,Str "pleasant",Space,Str "to",Space,Str "taste"]]])
+ ,([Emph [Str "orange"]],
+ [[Para [Str "orange",Space,Str "fruit"]
+ ,CodeBlock ("",[],[]) "{ orange code block }"
+ ,BlockQuote
+ [Para [Str "orange",Space,Str "block",Space,Str "quote"]]]])]
+,Para [Str "Multiple",Space,Str "definitions,",Space,Str "tight:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Plain [Str "red",Space,Str "fruit"]]
+ ,[Plain [Str "computer"]]])
+ ,([Str "orange"],
+ [[Plain [Str "orange",Space,Str "fruit"]]
+ ,[Plain [Str "bank"]]])]
+,Para [Str "Multiple",Space,Str "definitions,",Space,Str "loose:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]
+ ,[Para [Str "computer"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]
+ ,[Para [Str "bank"]]])]
+,Para [Str "Blank",Space,Str "line",Space,Str "after",Space,Str "term,",Space,Str "indented",Space,Str "marker,",Space,Str "alternate",Space,Str "markers:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]
+ ,[Para [Str "computer"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]
+ ,OrderedList (1,Decimal,Period)
+ [[Plain [Str "sublist"]]
+ ,[Plain [Str "sublist"]]]]])]
+,Header 1 ("html-blocks",[],[]) [Str "HTML",Space,Str "Blocks"]
+,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]
+,Div ("",[],[])
+ [Plain [Str "foo"]]
+,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"]
+,Div ("",[],[])
+ [Div ("",[],[])
+ [Div ("",[],[])
+ [Para [Str "foo"]]]
+ ,Div ("",[],[])
+ [Plain [Str "bar"]]]
+,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]
+,RawBlock (Format "html") "<table>"
+,RawBlock (Format "html") "<tr>"
+,RawBlock (Format "html") "<td>"
+,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]]
+,RawBlock (Format "html") "</td>"
+,RawBlock (Format "html") "<td>"
+,Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]]
+,RawBlock (Format "html") "</td>"
+,RawBlock (Format "html") "</tr>"
+,RawBlock (Format "html") "</table>"
+,RawBlock (Format "html") "<script type=\"text/javascript\">document.write('This *should not* be interpreted as markdown');</script>"
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block:"]
+,Div ("",[],[])
+ [Para [Str "foo"]]
+,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"]
+,CodeBlock ("",[],[]) "<div>\n foo\n</div>"
+,Para [Str "As",Space,Str "should",Space,Str "this:"]
+,CodeBlock ("",[],[]) "<div>foo</div>"
+,Para [Str "Now,",Space,Str "nested:"]
+,Div ("",[],[])
+ [Div ("",[],[])
+ [Div ("",[],[])
+ [Plain [Str "foo"]]]]
+,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"]
+,RawBlock (Format "html") "<!-- Comment -->"
+,Para [Str "Multiline:"]
+,RawBlock (Format "html") "<!--\nBlah\nBlah\n-->"
+,RawBlock (Format "html") "<!--\n This is another comment.\n-->"
+,Para [Str "Code",Space,Str "block:"]
+,CodeBlock ("",[],[]) "<!-- Comment -->"
+,Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"]
+,RawBlock (Format "html") "<!-- foo -->"
+,Para [Str "Code:"]
+,CodeBlock ("",[],[]) "<hr />"
+,Para [Str "Hr\8217s:"]
+,RawBlock (Format "html") "<hr>"
+,RawBlock (Format "html") "<hr />"
+,RawBlock (Format "html") "<hr />"
+,RawBlock (Format "html") "<hr>"
+,RawBlock (Format "html") "<hr />"
+,RawBlock (Format "html") "<hr />"
+,RawBlock (Format "html") "<hr class=\"foo\" id=\"bar\" />"
+,RawBlock (Format "html") "<hr class=\"foo\" id=\"bar\" />"
+,RawBlock (Format "html") "<hr class=\"foo\" id=\"bar\">"
+,HorizontalRule
+,Header 1 ("inline-markup",[],[]) [Str "Inline",Space,Str "Markup"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
+,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
+,Para [Str "An",Space,Emph [Link ("",[],[]) [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
+,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]
+,Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],Str "."]]
+,Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello\160there"],Str "."]
+,Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "H",Subscript [Str "23"],Str "O,",Space,Str "H",Subscript [Str "many\160of\160them"],Str "O."]
+,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",SoftBreak,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces:",Space,Str "a^b",Space,Str "c^d,",Space,Str "a~b",Space,Str "c~d."]
+,HorizontalRule
+,Header 1 ("smart-quotes-ellipses-dashes",[],[]) [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
+,Para [Quoted DoubleQuote [Str "Hello,"],Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name."]]
+,Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters."]
+,Para [Quoted SingleQuote [Str "Oak,"],Space,Quoted SingleQuote [Str "elm,"],Space,Str "and",Space,Quoted SingleQuote [Str "beech"],Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees.",SoftBreak,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine."]]
+,Para [Quoted SingleQuote [Str "He",Space,Str "said,",Space,Quoted DoubleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",SoftBreak,Str "70\8217s?"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Quoted SingleQuote [Code ("",[],[]) "code"],Space,Str "and",Space,Str "a",Space,Quoted DoubleQuote [Link ("",[],[]) [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2","")],Str "."]
+,Para [Str "Some",Space,Str "dashes:",Space,Str "one\8212two",Space,Str "\8212",Space,Str "three\8212four",Space,Str "\8212",Space,Str "five."]
+,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5\8211\&7,",Space,Str "255\8211\&66,",Space,Str "1987\8211\&1999."]
+,Para [Str "Ellipses\8230and\8230and\8230."]
+,HorizontalRule
+,Header 1 ("latex",[],[]) [Str "LaTeX"]
+,BulletList
+ [[Plain [RawInline (Format "tex") "\\cite[22-23]{smith.1899}"]]
+ ,[Plain [Math InlineMath "2+2=4"]]
+ ,[Plain [Math InlineMath "x \\in y"]]
+ ,[Plain [Math InlineMath "\\alpha \\wedge \\omega"]]
+ ,[Plain [Math InlineMath "223"]]
+ ,[Plain [Math InlineMath "p",Str "-Tree"]]
+ ,[Plain [Str "Here\8217s",Space,Str "some",Space,Str "display",Space,Str "math:",SoftBreak,Math DisplayMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]
+ ,[Plain [Str "Here\8217s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it:",Space,Math InlineMath "\\alpha + \\omega \\times x^2",Str "."]]]
+,Para [Str "These",Space,Str "shouldn\8217t",Space,Str "be",Space,Str "math:"]
+,BulletList
+ [[Plain [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation,",Space,Str "write",Space,Code ("",[],[]) "$e = mc^2$",Str "."]]
+ ,[Plain [Str "$22,000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money.",Space,Str "So",Space,Str "is",Space,Str "$34,000.",SoftBreak,Str "(It",Space,Str "worked",Space,Str "if",Space,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized.)"]]
+ ,[Plain [Str "Shoes",Space,Str "($20)",Space,Str "and",Space,Str "socks",Space,Str "($5)."]]
+ ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23$."]]]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"]
+,RawBlock (Format "latex") "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"
+,HorizontalRule
+,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
+,BulletList
+ [[Plain [Str "I",Space,Str "hat:",Space,Str "\206"]]
+ ,[Plain [Str "o",Space,Str "umlaut:",Space,Str "\246"]]
+ ,[Plain [Str "section:",Space,Str "\167"]]
+ ,[Plain [Str "set",Space,Str "membership:",Space,Str "\8712"]]
+ ,[Plain [Str "copyright:",Space,Str "\169"]]]
+,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]
+,Para [Str "AT&T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it."]
+,Para [Str "This",Space,Str "&",Space,Str "that."]
+,Para [Str "4",Space,Str "<",Space,Str "5."]
+,Para [Str "6",Space,Str ">",Space,Str "5."]
+,Para [Str "Backslash:",Space,Str "\\"]
+,Para [Str "Backtick:",Space,Str "`"]
+,Para [Str "Asterisk:",Space,Str "*"]
+,Para [Str "Underscore:",Space,Str "_"]
+,Para [Str "Left",Space,Str "brace:",Space,Str "{"]
+,Para [Str "Right",Space,Str "brace:",Space,Str "}"]
+,Para [Str "Left",Space,Str "bracket:",Space,Str "["]
+,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]
+,Para [Str "Left",Space,Str "paren:",Space,Str "("]
+,Para [Str "Right",Space,Str "paren:",Space,Str ")"]
+,Para [Str "Greater-than:",Space,Str ">"]
+,Para [Str "Hash:",Space,Str "#"]
+,Para [Str "Period:",Space,Str "."]
+,Para [Str "Bang:",Space,Str "!"]
+,Para [Str "Plus:",Space,Str "+"]
+,Para [Str "Minus:",Space,Str "-"]
+,HorizontalRule
+,Header 1 ("links",[],[]) [Str "Links"]
+,Header 2 ("explicit",[],[]) [Str "Explicit"]
+,Para [Str "Just",Space,Str "a",Space,Link ("",[],[]) [Str "URL"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title"),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by two spaces"),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by a tab"),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with \"quotes\" in it")]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with single quotes")]
+,Para [Link ("",[],[]) [Str "with_underscore"] ("/url/with_underscore","")]
+,Para [Link ("",[],[]) [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]
+,Para [Link ("",[],[]) [Str "Empty"] ("",""),Str "."]
+,Header 2 ("reference",[],[]) [Str "Reference"]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "With",Space,Link ("",[],[]) [Str "embedded",Space,Str "[brackets]"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "once"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "twice"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "thrice"] ("/url",""),Str "."]
+,Para [Str "This",Space,Str "should",Space,Str "[not][]",Space,Str "be",Space,Str "a",Space,Str "link."]
+,CodeBlock ("",[],[]) "[not]: /url"
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/","Title with \"quotes\" inside"),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "biz"] ("/url/","Title with \"quote\" inside"),Str "."]
+,Header 2 ("with-ampersands",[],[]) [Str "With",Space,Str "ampersands"]
+,Para [Str "Here\8217s",Space,Str "a",Space,Link ("",[],[]) [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link ("",[],[]) [Str "AT&T"] ("http://att.com/","AT&T"),Str "."]
+,Para [Str "Here\8217s",Space,Str "an",Space,Link ("",[],[]) [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."]
+,Para [Str "Here\8217s",Space,Str "an",Space,Link ("",[],[]) [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]
+,Header 2 ("autolinks",[],[]) [Str "Autolinks"]
+,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link ("",[],[]) [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]
+,BulletList
+ [[Plain [Str "In",Space,Str "a",Space,Str "list?"]]
+ ,[Plain [Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]
+ ,[Plain [Str "It",Space,Str "should."]]]
+,Para [Str "An",Space,Str "e-mail",Space,Str "address:",Space,Link ("",[],[]) [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]
+,BlockQuote
+ [Para [Str "Blockquoted:",Space,Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]
+,Para [Str "Auto-links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"]
+,CodeBlock ("",[],[]) "or here: <http://example.com/>"
+,HorizontalRule
+,Header 1 ("images",[],[]) [Str "Images"]
+,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
+,Para [Image ("",[],[]) [Str "lalune"] ("lalune.jpg","fig:Voyage dans la Lune")]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image ("",[],[]) [Str "movie"] ("movie.jpg",""),Space,Str "icon."]
+,HorizontalRule
+,Header 1 ("footnotes",[],[]) [Str "Footnotes"]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote.",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",SoftBreak,Str "reference.",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."]],Space,Str "and",Space,Str "another.",Note [Para [Str "Here\8217s",Space,Str "the",Space,Str "long",Space,Str "note.",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",SoftBreak,Str "blocks."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",SoftBreak,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "list",Space,Str "items)."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",SoftBreak,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block."]],SoftBreak,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",SoftBreak,Str "contains",Space,Str "a",Space,Str "space.[^my",Space,Str "note]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note.",Note [Para [Str "This",SoftBreak,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type.",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",SoftBreak,Link ("",[],[]) [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",Space,Str "verbatim",Space,Str "characters,",SoftBreak,Str "as",Space,Str "well",Space,Str "as",Space,Str "[bracketed",Space,Str "text]."]]]
+,BlockQuote
+ [Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes.",Note [Para [Str "In",Space,Str "quote."]]]]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items.",Note [Para [Str "In",Space,Str "list."]]]]]
+,Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented."]]
diff --git a/test/testsuite.txt b/test/testsuite.txt
new file mode 100644
index 000000000..f6b0a7c95
--- /dev/null
+++ b/test/testsuite.txt
@@ -0,0 +1,730 @@
+% Pandoc Test Suite
+% John MacFarlane; Anonymous
+% July 17, 2006
+
+This is a set of tests for pandoc. Most of them are adapted from
+John Gruber's markdown test suite.
+
+-----
+
+# Headers
+
+## Level 2 with an [embedded link](/url)
+
+### Level 3 with *emphasis*
+
+#### Level 4
+
+##### Level 5
+
+Level 1
+=======
+
+Level 2 with *emphasis*
+-----------------------
+
+### Level 3
+with no blank line
+
+Level 2
+-------
+with no blank line
+
+----------
+
+# Paragraphs
+
+Here's a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version
+8. This line turns into a list item.
+Because a hard-wrapped line in the
+middle of a paragraph looked like a
+list item.
+
+Here's one with a bullet.
+* criminey.
+
+There should be a hard line break
+here.
+
+---
+
+# Block Quotes
+
+E-mail style:
+
+> This is a block quote.
+> It is pretty short.
+
+> Code in a block quote:
+>
+> sub status {
+> print "working";
+> }
+>
+> A list:
+>
+> 1. item one
+> 2. item two
+>
+> Nested block quotes:
+>
+> > nested
+>
+>> nested
+>
+
+This should not be a block quote: 2
+> 1.
+
+And a following paragraph.
+
+* * * *
+
+# Code Blocks
+
+Code:
+
+ ---- (should be four hyphens)
+
+ sub status {
+ print "working";
+ }
+
+ this code block is indented by one tab
+
+And:
+
+ this code block is indented by two tabs
+
+ These should not be escaped: \$ \\ \> \[ \{
+
+___________
+
+# Lists
+
+## Unordered
+
+Asterisks tight:
+
+* asterisk 1
+* asterisk 2
+* asterisk 3
+
+Asterisks loose:
+
+* asterisk 1
+
+* asterisk 2
+
+* asterisk 3
+
+Pluses tight:
+
++ Plus 1
++ Plus 2
++ Plus 3
+
+Pluses loose:
+
++ Plus 1
+
++ Plus 2
+
++ Plus 3
+
+Minuses tight:
+
+- Minus 1
+- Minus 2
+- Minus 3
+
+Minuses loose:
+
+- Minus 1
+
+- Minus 2
+
+- Minus 3
+
+## Ordered
+
+Tight:
+
+1. First
+2. Second
+3. Third
+
+and:
+
+1. One
+2. Two
+3. Three
+
+Loose using tabs:
+
+1. First
+
+2. Second
+
+3. Third
+
+and using spaces:
+
+1. One
+
+2. Two
+
+3. Three
+
+Multiple paragraphs:
+
+1. Item 1, graf one.
+
+ Item 1. graf two. The quick brown fox jumped over the lazy dog's
+ back.
+
+2. Item 2.
+
+3. Item 3.
+
+## Nested
+
+* Tab
+ * Tab
+ * Tab
+
+Here's another:
+
+1. First
+2. Second:
+ * Fee
+ * Fie
+ * Foe
+3. Third
+
+Same thing but with paragraphs:
+
+1. First
+
+2. Second:
+
+ * Fee
+ * Fie
+ * Foe
+
+3. Third
+
+## Tabs and spaces
+
++ this is a list item
+ indented with tabs
+
++ this is a list item
+ indented with spaces
+
+ + this is an example list item
+ indented with tabs
+
+ + this is an example list item
+ indented with spaces
+
+## Fancy list markers
+
+(2) begins with 2
+(3) and now 3
+
+ with a continuation
+
+ iv. sublist with roman numerals,
+ starting with 4
+ v. more items
+ (A) a subsublist
+ (B) a subsublist
+
+Nesting:
+
+A. Upper Alpha
+ I. Upper Roman.
+ (6) Decimal start with 6
+ c) Lower alpha with paren
+
+Autonumbering:
+
+ #. Autonumber.
+ #. More.
+ #. Nested.
+
+Should not be a list item:
+
+M.A. 2007
+
+B. Williams
+
+ * * * * *
+
+# Definition Lists
+
+Tight using spaces:
+
+apple
+: red fruit
+
+orange
+: orange fruit
+
+banana
+: yellow fruit
+
+Tight using tabs:
+
+apple
+: red fruit
+
+orange
+: orange fruit
+
+banana
+: yellow fruit
+
+Loose:
+
+apple
+
+: red fruit
+
+orange
+
+: orange fruit
+
+banana
+
+: yellow fruit
+
+Multiple blocks with italics:
+
+*apple*
+
+: red fruit
+
+ contains seeds,
+ crisp, pleasant to taste
+
+*orange*
+
+: orange fruit
+
+ { orange code block }
+
+ > orange block quote
+
+Multiple definitions, tight:
+
+apple
+: red fruit
+: computer
+
+orange
+: orange fruit
+: bank
+
+Multiple definitions, loose:
+
+apple
+
+: red fruit
+
+: computer
+
+orange
+
+: orange fruit
+
+: bank
+
+Blank line after term, indented marker, alternate markers:
+
+apple
+
+ ~ red fruit
+
+ ~ computer
+
+orange
+
+ ~ orange fruit
+
+ 1. sublist
+ 2. sublist
+
+# HTML Blocks
+
+Simple block on one line:
+
+<div>foo</div>
+
+And nested without indentation:
+
+<div>
+<div>
+<div>
+foo
+</div>
+</div>
+<div>bar</div>
+</div>
+
+Interpreted markdown in a table:
+
+<table>
+<tr>
+<td>This is *emphasized*</td>
+<td>And this is **strong**</td>
+</tr>
+</table>
+
+<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
+
+Here's a simple block:
+
+<div>
+foo
+</div>
+
+This should be a code block, though:
+
+ <div>
+ foo
+ </div>
+
+As should this:
+
+ <div>foo</div>
+
+Now, nested:
+
+<div>
+ <div>
+ <div>
+ foo
+ </div>
+ </div>
+</div>
+
+This should just be an HTML comment:
+
+<!-- Comment -->
+
+Multiline:
+
+<!--
+Blah
+Blah
+-->
+
+<!--
+ This is another comment.
+-->
+
+Code block:
+
+ <!-- Comment -->
+
+Just plain comment, with trailing spaces on the line:
+
+<!-- foo -->
+
+Code:
+
+ <hr />
+
+Hr's:
+
+<hr>
+
+<hr />
+
+<hr />
+
+<hr>
+
+<hr />
+
+<hr />
+
+<hr class="foo" id="bar" />
+
+<hr class="foo" id="bar" />
+
+<hr class="foo" id="bar">
+
+-----
+
+# Inline Markup
+
+This is *emphasized*, and so _is this_.
+
+This is **strong**, and so __is this__.
+
+An *[emphasized link](/url)*.
+
+***This is strong and em.***
+
+So is ***this*** word.
+
+___This is strong and em.___
+
+So is ___this___ word.
+
+This is code: `>`, `$`, `\`, `\$`, `<html>`.
+
+~~This is *strikeout*.~~
+
+Superscripts: a^bc^d a^*hello*^ a^hello\ there^.
+
+Subscripts: H~2~O, H~23~O, H~many\ of\ them~O.
+
+These should not be superscripts or subscripts,
+because of the unescaped spaces: a^b c^d, a~b c~d.
+
+-----
+
+# Smart quotes, ellipses, dashes
+
+"Hello," said the spider. "'Shelob' is my name."
+
+'A', 'B', and 'C' are letters.
+
+'Oak,' 'elm,' and 'beech' are names of trees.
+So is 'pine.'
+
+'He said, "I want to go."' Were you alive in the
+70's?
+
+Here is some quoted '`code`' and a "[quoted link][1]".
+
+Some dashes: one---two --- three---four --- five.
+
+Dashes between numbers: 5--7, 255--66, 1987--1999.
+
+Ellipses...and...and....
+
+-----
+
+# LaTeX
+
+- \cite[22-23]{smith.1899}
+- $2+2=4$
+- $x \in y$
+- $\alpha \wedge \omega$
+- $223$
+- $p$-Tree
+- Here's some display math:
+ $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
+- Here's one that has a line break in it: $\alpha + \omega \times
+x^2$.
+
+These shouldn't be math:
+
+- To get the famous equation, write `$e = mc^2$`.
+- $22,000 is a *lot* of money. So is $34,000.
+ (It worked if "lot" is emphasized.)
+- Shoes ($20) and socks ($5).
+- Escaped `$`: $73 *this should be emphasized* 23\$.
+
+Here's a LaTeX table:
+
+\begin{tabular}{|l|l|}\hline
+Animal & Number \\ \hline
+Dog & 2 \\
+Cat & 1 \\ \hline
+\end{tabular}
+
+* * * * *
+
+# Special Characters
+
+Here is some unicode:
+
+- I hat: Î
+- o umlaut: ö
+- section: §
+- set membership: ∈
+- copyright: ©
+
+AT&T has an ampersand in their name.
+
+AT&amp;T is another way to write it.
+
+This & that.
+
+4 < 5.
+
+6 > 5.
+
+Backslash: \\
+
+Backtick: \`
+
+Asterisk: \*
+
+Underscore: \_
+
+Left brace: \{
+
+Right brace: \}
+
+Left bracket: \[
+
+Right bracket: \]
+
+Left paren: \(
+
+Right paren: \)
+
+Greater-than: \>
+
+Hash: \#
+
+Period: \.
+
+Bang: \!
+
+Plus: \+
+
+Minus: \-
+
+- - - - - - - - - - - - -
+
+# Links
+
+## Explicit
+
+Just a [URL](/url/).
+
+[URL and title](/url/ "title").
+
+[URL and title](/url/ "title preceded by two spaces").
+
+[URL and title](/url/ "title preceded by a tab").
+
+[URL and title](/url/ "title with "quotes" in it")
+
+[URL and title](/url/ 'title with single quotes')
+
+[with\_underscore](/url/with_underscore)
+
+[Email link](mailto:nobody@nowhere.net)
+
+[Empty]().
+
+## Reference
+
+Foo [bar] [a].
+
+Foo [bar][a].
+
+Foo [bar]
+[a].
+
+[a]: /url/
+
+With [embedded [brackets]] [b].
+
+[b] by itself should be a link.
+
+Indented [once][].
+
+Indented [twice][].
+
+Indented [thrice][].
+
+This should [not][] be a link.
+
+ [once]: /url
+ [twice]: /url
+
+ [thrice]: /url
+
+ [not]: /url
+
+[b]: /url/
+
+Foo [bar][].
+
+Foo [biz](/url/ "Title with "quote" inside").
+
+ [bar]: /url/ "Title with "quotes" inside"
+
+## With ampersands
+
+Here's a [link with an ampersand in the URL] [1].
+
+Here's a link with an amersand in the link text: [AT&T] [2].
+
+Here's an [inline link](/script?foo=1&bar=2).
+
+Here's an [inline link in pointy braces](</script?foo=1&bar=2>).
+
+[1]: http://example.com/?foo=1&bar=2
+[2]: http://att.com/ "AT&T"
+
+## Autolinks
+
+With an ampersand: <http://example.com/?foo=1&bar=2>
+
+* In a list?
+* <http://example.com/>
+* It should.
+
+An e-mail address: <nobody@nowhere.net>
+
+> Blockquoted: <http://example.com/>
+
+Auto-links should not occur here: `<http://example.com/>`
+
+ or here: <http://example.com/>
+
+----
+
+# Images
+
+From "Voyage dans la Lune" by Georges Melies (1902):
+
+![lalune][]
+
+ [lalune]: lalune.jpg "Voyage dans la Lune"
+
+Here is a movie ![movie](movie.jpg) icon.
+
+----
+
+# Footnotes
+
+Here is a footnote reference,[^1] and another.[^longnote]
+This should *not* be a footnote reference, because it
+contains a space.[^my note] Here is an inline note.^[This
+is *easier* to type. Inline notes may contain
+[links](http://google.com) and `]` verbatim characters,
+as well as [bracketed text].]
+
+> Notes can go in quotes.^[In quote.]
+
+1. And in list items.^[In list.]
+
+[^longnote]: Here's the long note. This one contains multiple
+blocks.
+
+ Subsequent blocks are indented to show that they belong to the
+footnote (as with list items).
+
+ { <code> }
+
+ If you want, you can indent every line, but you can also be
+ lazy and just indent the first line of each block.
+
+This paragraph should not be part of the note, as it is not indented.
+
+ [^1]: Here is the footnote. It can go anywhere after the footnote
+ reference. It need not be placed at the end of the document.
diff --git a/test/textile-reader.native b/test/textile-reader.native
new file mode 100644
index 000000000..8b3100ffa
--- /dev/null
+++ b/test/textile-reader.native
@@ -0,0 +1,176 @@
+Pandoc (Meta {unMeta = fromList []})
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc",Space,Str "Textile",Space,Str "Reader.",Space,Str "Part",Space,Str "of",Space,Str "it",Space,Str "comes",LineBreak,Str "from",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
+,HorizontalRule
+,Header 1 ("headers",[],[]) [Str "Headers"]
+,Header 2 ("level-2-with-an-embeded-link",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link ("",[],[]) [Str "embeded",Space,Str "link"] ("http://www.example.com","")]
+,Header 3 ("level-3-with-emphasis",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Strong [Str "emphasis"]]
+,Header 4 ("level-4",[],[]) [Str "Level",Space,Str "4"]
+,Header 5 ("level-5",[],[]) [Str "Level",Space,Str "5"]
+,Header 6 ("level-6",[],[]) [Str "Level",Space,Str "6"]
+,Header 1 ("paragraphs",[],[]) [Str "Paragraphs"]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
+,Para [Str "Line",Space,Str "breaks",Space,Str "are",Space,Str "preserved",Space,Str "in",Space,Str "textile,",Space,Str "so",Space,Str "you",Space,Str "can",Space,Str "not",Space,Str "wrap",Space,Str "your",Space,Str "very",LineBreak,Str "long",Space,Str "paragraph",Space,Str "with",Space,Str "your",Space,Str "favourite",Space,Str "text",Space,Str "editor",Space,Str "and",Space,Str "have",Space,Str "it",Space,Str "rendered",LineBreak,Str "with",Space,Str "no",Space,Str "break."]
+,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet."]
+,BulletList
+ [[Plain [Str "criminey."]]]
+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "paragraph",Space,Str "break",Space,Str "between",Space,Str "here"]
+,Para [Str "and",Space,Str "here."]
+,Para [Str "pandoc",Space,Str "converts",Space,Str "textile."]
+,Header 1 ("block-quotes",[],[]) [Str "Block",Space,Str "Quotes"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "famous",Space,Str "quote",Space,Str "from",Space,Str "somebody.",Space,Str "He",Space,Str "had",Space,Str "a",Space,Str "lot",Space,Str "of",Space,Str "things",Space,Str "to",LineBreak,Str "say,",Space,Str "so",Space,Str "the",Space,Str "text",Space,Str "is",Space,Str "really",Space,Str "really",Space,Str "long",Space,Str "and",Space,Str "spans",Space,Str "on",Space,Str "multiple",Space,Str "lines."]]
+,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."]
+,Header 1 ("code-blocks",[],[]) [Str "Code",Space,Str "Blocks"]
+,Para [Str "Code:"]
+,CodeBlock ("",[],[]) " ---- (should be four hyphens)\n\n sub status {\n print \"working\";\n }\n\n this code block is indented by one tab"
+,Para [Str "And:"]
+,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\n These should not be escaped: \\$ \\\\ \\> \\[ \\{"
+,CodeBlock ("",[],[]) "Code block with .bc\n continued\n @</\\"
+,CodeBlock ("",[],[]) "extended code block\n\n continued"
+,Para [Str "ended",Space,Str "by",Space,Str "paragraph"]
+,Para [Str "Inline",Space,Str "code:",Space,Code ("",[],[]) "<tt>",Str ",",Space,Code ("",[],[]) "@",Str "."]
+,Header 1 ("notextile",[],[]) [Str "Notextile"]
+,Para [Str "A",Space,Str "block",Space,Str "of",Space,Str "text",Space,Str "can",Space,Str "be",Space,Str "protected",Space,Str "with",Space,Str "notextile",Space,Str ":"]
+,Para [Str "\nNo *bold* and\n* no bullet\n"]
+,Para [Str "and",Space,Str "inlines",Space,Str "can",Space,Str "be",Space,Str "protected",Space,Str "with",Space,Str "double *equals (=)* markup."]
+,Header 1 ("lists",[],[]) [Str "Lists"]
+,Header 2 ("unordered",[],[]) [Str "Unordered"]
+,Para [Str "Asterisks",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "asterisk",Space,Str "1"]]
+ ,[Plain [Str "asterisk",Space,Str "2"]]
+ ,[Plain [Str "asterisk",Space,Str "3"]]]
+,Para [Str "With",Space,Str "line",Space,Str "breaks:"]
+,BulletList
+ [[Plain [Str "asterisk",Space,Str "1",LineBreak,Str "newline"]]
+ ,[Plain [Str "asterisk",Space,Str "2"]]]
+,Header 2 ("ordered",[],[]) [Str "Ordered"]
+,Para [Str "Tight:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second"]]
+ ,[Plain [Str "Third"]]]
+,Header 2 ("nested",[],[]) [Str "Nested"]
+,BulletList
+ [[Plain [Str "ui",Space,Str "1"]
+ ,BulletList
+ [[Plain [Str "ui",Space,Str "1.1"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "oi",Space,Str "1.1.1"]]
+ ,[Plain [Str "oi",Space,Str "1.1.2"]]]]
+ ,[Plain [Str "ui",Space,Str "1.2"]]]]
+ ,[Plain [Str "ui",Space,Str "2"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "oi",Space,Str "2.1"]
+ ,BulletList
+ [[Plain [Str "ui",Space,Str "2.1.1"]]
+ ,[Plain [Str "ui",Space,Str "2.1.2"]]]]]]]
+,Header 2 ("issue-1500",[],[]) [Str "Issue",Space,Str "#1500"]
+,BulletList
+ [[Plain [Str "one"]]
+ ,[Plain [Str "two",LineBreak,Str "->",Space,Str "and",Space,Str "more"]]]
+,Header 2 ("issue-1513",[],[]) [Str "Issue",Space,Str "#1513"]
+,Para [Str "List:"]
+,BulletList
+ [[Plain [Str "one"]]
+ ,[Plain [Str "two"]]]
+,Header 2 ("definition-list",[],[]) [Str "Definition",Space,Str "List"]
+,DefinitionList
+ [([Str "coffee"],
+ [[Plain [Str "Hot",Space,Str "and",Space,Str "black"]]])
+ ,([Str "tea"],
+ [[Plain [Str "Also",Space,Str "hot,",Space,Str "but",Space,Str "a",Space,Str "little",Space,Str "less",Space,Str "black"]]])
+ ,([Str "milk"],
+ [[Para [Str "Nourishing",Space,Str "beverage",Space,Str "for",Space,Str "baby",Space,Str "cows."]
+ ,Para [Str "Cold",Space,Str "drink",Space,Str "that",Space,Str "goes",Space,Str "great",Space,Str "with",Space,Str "cookies."]]])
+ ,([Str "beer"],
+ [[Plain [Str "fresh",Space,Str "and",Space,Str "bitter"]]])]
+,Header 1 ("inline-markup",[],[]) [Str "Inline",Space,Str "Markup"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str ".",LineBreak,Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str ".",LineBreak,Str "Hyphenated-words-are-ok,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "strange_underscore_notation.",LineBreak,Str "A",Space,Link ("",[],[]) [Strong [Str "strong",Space,Str "link"]] ("http://www.foobar.com",""),Str "."]
+,Para [Emph [Strong [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]],LineBreak,Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Space,Str "and",Space,Emph [Strong [Str "that",Space,Str "one"]],Str ".",LineBreak,Strikeout [Str "This",Space,Str "is",Space,Str "strikeout",Space,Str "and",Space,Strong [Str "strong"]]]
+,Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Space,Superscript [Strong [Str "hello"]],Space,Str "a",Superscript [Str "hello",Space,Str "there"],Str ".",LineBreak,Str "Subscripts:",Space,Subscript [Str "here"],Space,Str "H",Space,Subscript [Str "2"],Str "O,",Space,Str "H",Space,Subscript [Str "23"],Str "O,",Space,Str "H",Space,Subscript [Str "many",Space,Str "of",Space,Str "them"],Str "O."]
+,Para [Str "Dashes",Space,Str ":",Space,Str "How",Space,Str "cool",Space,Str "\8212",Space,Str "automatic",Space,Str "dashes."]
+,Para [Str "Elipses",Space,Str ":",Space,Str "He",Space,Str "thought",Space,Str "and",Space,Str "thought",Space,Str "\8230",Space,Str "and",Space,Str "then",Space,Str "thought",Space,Str "some",Space,Str "more."]
+,Para [Str "Quotes",Space,Str "and",Space,Str "apostrophes",Space,Str ":",Space,Quoted DoubleQuote [Str "I\8217d",Space,Str "like",Space,Str "to",Space,Str "thank",Space,Str "you"],Space,Str "for",Space,Str "example."]
+,Header 1 ("links",[],[]) [Str "Links"]
+,Header 2 ("explicit",[],[]) [Str "Explicit"]
+,Para [Str "Just",Space,Str "a",Space,Link ("",[],[]) [Str "url"] ("http://www.url.com","")]
+,Para [Link ("",[],[]) [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]
+,Para [Quoted DoubleQuote [Str "not",Space,Str "a",Space,Str "link"],Str ":",Space,Str "foo"]
+,Para [Str "Automatic",Space,Str "linking",Space,Str "to",Space,Link ("",[],[]) [Str "http://www.example.com"] ("http://www.example.com",""),Str "."]
+,Para [Link ("",[],[]) [Str "Example"] ("http://www.example.com/",""),Str ":",Space,Str "Example",Space,Str "of",Space,Str "a",Space,Str "link",Space,Str "followed",Space,Str "by",Space,Str "a",Space,Str "colon."]
+,Para [Str "A",Space,Str "link",Link ("",[],[]) [Str "with",Space,Str "brackets"] ("http://www.example.com",""),Str "and",Space,Str "no",Space,Str "spaces."]
+,Header 1 ("tables",[],[]) [Str "Tables"]
+,Para [Str "Textile",Space,Str "allows",Space,Str "tables",Space,Str "with",Space,Str "and",Space,Str "without",Space,Str "headers",Space,Str ":"]
+,Header 2 ("without-headers",[],[]) [Str "Without",Space,Str "headers"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ []
+ [[[Plain [Str "name"]]
+ ,[Plain [Str "age"]]
+ ,[Plain [Str "sex"]]]
+ ,[[Plain [Str "joan"]]
+ ,[Plain [Str "24"]]
+ ,[Plain [Str "f"]]]
+ ,[[Plain [Str "archie"]]
+ ,[Plain [Str "29"]]
+ ,[Plain [Str "m"]]]
+ ,[[Plain [Str "bella"]]
+ ,[Plain [Str "45"]]
+ ,[Plain [Str "f"]]]]
+,Para [Str "and",Space,Str "some",Space,Str "text",Space,Str "following",Space,Str "\8230"]
+,Header 2 ("with-headers",[],[]) [Str "With",Space,Str "headers"]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[Plain [Str "name"]]
+ ,[Plain [Str "age"]]
+ ,[Plain [Str "sex"]]]
+ [[[Plain [Str "joan"]]
+ ,[Plain [Str "24"]]
+ ,[Plain [Str "f"]]]
+ ,[[Plain [Str "archie"]]
+ ,[Plain [Str "29"]]
+ ,[Plain [Str "m"]]]
+ ,[[Plain [Str "bella"]]
+ ,[Plain [Str "45"]]
+ ,[Plain [Str "f"]]]]
+,Header 1 ("images",[],[]) [Str "Images"]
+,Para [Str "Textile",Space,Str "inline",Space,Str "image",Space,Str "syntax,",Space,Str "like",LineBreak,Str "here",Space,Image ("",[],[]) [Str "this is the alt text"] ("this_is_an_image.png","this is the alt text"),LineBreak,Str "and",Space,Str "here",Space,Image ("",[],[]) [Str ""] ("this_is_an_image.png",""),Str "."]
+,Header 1 ("attributes",[],[]) [Str "Attributes"]
+,Header 2 ("ident",["bar","foo"],[("style","color:red;"),("lang","en")]) [Str "HTML",Space,Str "and",Space,Str "CSS",Space,Str "attributes",Space,Str "are",Space,Str "parsed",Space,Str "in",Space,Str "headers."]
+,Header 2 ("centered",[],[("style","text-align:center;")]) [Str "Centered"]
+,Header 2 ("right",[],[("style","text-align:right;")]) [Str "Right"]
+,Header 2 ("justified",[],[("lang","en"),("style","color:blue;text-align:justify;")]) [Str "Justified"]
+,Para [Str "as",Space,Str "well",Space,Str "as",Space,Strong [Span ("",["foo"],[]) [Str "inline",Space,Str "attributes"]],Space,Str "of",Space,Span ("",[],[("style","color:red;")]) [Str "all",Space,Str "kind"]]
+,Para [Str "and",Space,Str "paragraph",Space,Str "attributes,",Space,Str "and",Space,Str "table",Space,Str "attributes."]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ []
+ [[[Plain [Str "name"]]
+ ,[Plain [Str "age"]]
+ ,[Plain [Str "sex"]]]
+ ,[[Plain [Str "joan"]]
+ ,[Plain [Str "24"]]
+ ,[Plain [Str "f"]]]]
+,Para [Emph [Str "(class#id)",Space,Str "emph"]]
+,Para [Emph [Str "(no",Space,Str "class#id)",Space,Str "emph"]]
+,Header 1 ("entities",[],[]) [Str "Entities"]
+,Para [Str "*",LineBreak,Str "&"]
+,Header 1 ("raw-html",[],[]) [Str "Raw",Space,Str "HTML"]
+,Para [Str "However,",Space,RawInline (Format "html") "<strong>",Space,Str "raw",Space,Str "HTML",Space,Str "inlines",Space,RawInline (Format "html") "</strong>",Space,Str "are",Space,Str "accepted,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str ":"]
+,RawBlock (Format "html") "<div class=\"foobar\">"
+,Para [Str "any",Space,Strong [Str "Raw",Space,Str "HTML",Space,Str "Block"],Space,Str "with",Space,Str "bold"]
+,RawBlock (Format "html") "</div>"
+,Para [Str "Html",Space,Str "blocks",Space,Str "can"]
+,RawBlock (Format "html") "<div>"
+,Para [Str "interrupt",Space,Str "paragraphs"]
+,RawBlock (Format "html") "</div>"
+,Para [Str "as",Space,Str "well."]
+,Para [Str "Can",Space,Str "you",Space,Str "prove",Space,Str "that",Space,Str "2",Space,Str "<",Space,Str "3",Space,Str "?"]
+,Header 1 ("acronyms-and-marks",[],[]) [Str "Acronyms",Space,Str "and",Space,Str "marks"]
+,Para [Str "PBS (Public Broadcasting System)"]
+,Para [Str "Hi\8482"]
+,Para [Str "Hi",Space,Str "\8482"]
+,Para [Str "\174",Space,Str "Hi\174"]
+,Para [Str "Hi\169\&2008",Space,Str "\169",Space,Str "2008"]
+,Header 1 ("footnotes",[],[]) [Str "Footnotes"]
+,Para [Str "A",Space,Str "note.",Note [Para [Str "The",Space,Str "note",LineBreak,Str "is",Space,Str "here!"]],Space,Str "Another",Space,Str "note",Note [Para [Str "Other",Space,Str "note."]],Str "."]
+,Header 1 ("comment-blocks",[],[]) [Str "Comment",Space,Str "blocks"]
+,Para [Str "not",Space,Str "a",Space,Str "comment."]]
diff --git a/test/textile-reader.textile b/test/textile-reader.textile
new file mode 100644
index 000000000..cb9a68313
--- /dev/null
+++ b/test/textile-reader.textile
@@ -0,0 +1,278 @@
+This is a set of tests for pandoc Textile Reader. Part of it comes
+from John Gruber's markdown test suite.
+
+-----
+
+h1. Headers
+
+h2. Level 2 with an "embeded link":http://www.example.com
+
+h3. Level 3 with *emphasis*
+
+h4. Level 4
+
+h5. Level 5
+
+h6. Level 6
+
+
+h1. Paragraphs
+
+Here's a regular paragraph.
+
+Line breaks are preserved in textile, so you can not wrap your very
+long paragraph with your favourite text editor and have it rendered
+with no break.
+
+
+Here's one with a bullet.
+
+* criminey.
+
+There should be a paragraph break between here
+
+and here.
+
+pandoc converts textile.
+
+h1. Block Quotes
+
+bq. This is a famous quote from somebody. He had a lot of things to
+say, so the text is really really long and spans on multiple lines.
+
+And a following paragraph.
+
+h1. Code Blocks
+
+Code:
+
+<pre>
+ ---- (should be four hyphens)
+
+ sub status {
+ print "working";
+ }
+
+ this code block is indented by one tab
+</pre>
+
+And:
+
+<pre>
+ this code block is indented by two tabs
+
+ These should not be escaped: \$ \\ \> \[ \{
+</pre>
+
+bc. Code block with .bc
+ continued
+ @</\
+
+bc.. extended code block
+
+ continued
+p. ended by paragraph
+
+Inline code: @<tt>@, <tt>@</tt>.
+
+h1. Notextile
+
+A block of text can be protected with notextile :
+
+<notextile>
+No *bold* and
+* no bullet
+</notextile>
+
+and inlines can be protected with ==double *equals (=)* markup==.
+
+h1. Lists
+
+h2. Unordered
+
+Asterisks tight:
+
+* asterisk 1
+* asterisk 2
+* asterisk 3
+
+With line breaks:
+
+* asterisk 1
+newline
+* asterisk 2
+
+h2. Ordered
+
+Tight:
+
+# First
+# Second
+# Third
+
+h2. Nested
+
+* ui 1
+** ui 1.1
+### oi 1.1.1
+### oi 1.1.2
+** ui 1.2
+* ui 2
+## oi 2.1
+*** ui 2.1.1
+*** ui 2.1.2
+
+h2. Issue #1500
+
+* one
+* two
+-> and more
+
+h2. Issue #1513
+
+List:
+* one
+* two
+
+h2. Definition List
+
+- coffee := Hot and black
+- tea := Also hot, but a little less black
+- milk :=
+Nourishing beverage for baby cows.
+
+Cold drink that goes great with cookies.=:
+- beer := fresh and bitter
+
+
+h1. Inline Markup
+
+This is _emphasized_, and so __is this__.
+This is *strong*, and so **is this**.
+Hyphenated-words-are-ok, as well as strange_underscore_notation.
+A "*strong link*":http://www.foobar.com.
+
+_*This is strong and em.*_
+So is *_this_* word and __**that one**__.
+-This is strikeout and *strong*-
+
+Superscripts: a[^bc^]d a ^*hello*^ a[^hello there^].
+Subscripts: ~here~ H[ ~2~]O, H[ ~23~]O, H[ ~many of them~]O.
+
+Dashes : How cool -- automatic dashes.
+
+Elipses : He thought and thought ... and then thought some more.
+
+Quotes and apostrophes : "I'd like to thank you" for example.
+
+
+h1. Links
+
+h2. Explicit
+
+Just a "url":http://www.url.com
+
+"Email link":mailto:nobody@nowhere.net
+
+"not a link": foo
+
+Automatic linking to "$":http://www.example.com.
+
+"Example":http://www.example.com/: Example of a link followed by a colon.
+
+A link["with brackets":http://www.example.com]and no spaces.
+
+h1. Tables
+
+Textile allows tables with and without headers :
+
+h2. Without headers
+
+| name | age | sex |
+| joan | 24 | f |
+| archie | 29 | m |
+| bella | 45 | f |
+
+and some text following ...
+
+h2. With headers
+
+|_. name |_. age |_. sex |
+| joan | 24 | f |
+| archie | 29 | m |
+| bella | 45 | f |
+
+
+
+h1. Images
+
+Textile inline image syntax, like
+here !this_is_an_image.png(this is the alt text)!
+and here !this_is_an_image.png!.
+
+h1. Attributes
+
+h2[en]{color:red}(foo bar #ident). HTML and CSS attributes are parsed in headers.
+
+h2=. Centered
+
+h2>. Right
+
+h2<>{color:blue}[en]. Justified
+
+as well as *(foo)inline attributes* of %{color:red}all kind%
+
+p{color:green}. and paragraph attributes, and table attributes.
+
+table{foo:bar}.
+| name | age | sex |
+| joan | 24 | f |
+
+_(class#id) emph_
+
+_(no class#id) emph_
+
+h1. Entities
+
+&#42;
+&amp;
+
+h1. Raw HTML
+
+However, <strong> raw HTML inlines </strong> are accepted, as well as :
+
+<div class="foobar">
+ any *Raw HTML Block* with bold
+</div>
+
+Html blocks can <div>interrupt paragraphs</div> as well.
+
+Can you prove that 2 < 3 ?
+
+h1. Acronyms and marks
+
+PBS(Public Broadcasting System)
+
+Hi(tm)
+
+Hi (TM)
+
+(r) Hi(r)
+
+Hi(c)2008 (C) 2008
+
+h1. Footnotes
+
+A note.[1] Another note[2].
+
+fn1. The note
+is here!
+
+fn2. Other note.
+
+h1. Comment blocks
+
+###. my comment
+is here.
+
+not a comment.
diff --git a/test/twiki-reader.native b/test/twiki-reader.native
new file mode 100644
index 000000000..1447dcc3d
--- /dev/null
+++ b/test/twiki-reader.native
@@ -0,0 +1,174 @@
+Pandoc (Meta {unMeta = fromList []})
+[Header 1 ("header",[],[]) [Str "header"]
+,Header 2 ("header-level-two",[],[]) [Str "header",Space,Str "level",Space,Str "two"]
+,Header 3 ("header-level-3",[],[]) [Str "header",Space,Str "level",Space,Str "3"]
+,Header 4 ("header-level-four",[],[]) [Str "header",Space,Emph [Str "level"],Space,Str "four"]
+,Header 5 ("header-level-5",[],[]) [Str "header",Space,Str "level",Space,Str "5"]
+,Header 6 ("header-level-6",[],[]) [Str "header",Space,Str "level",Space,Str "6"]
+,Para [Str "---+++++++",Space,Str "not",Space,Str "a",Space,Str "header"]
+,Para [Str "--++",Space,Str "not",Space,Str "a",Space,Str "header"]
+,Header 1 ("emph-and-strong",[],[]) [Str "emph",Space,Str "and",Space,Str "strong"]
+,Para [Emph [Str "emph"],Space,Strong [Str "strong"]]
+,Para [Emph [Strong [Str "strong",Space,Str "and",Space,Str "emph"]]]
+,Para [Strong [Emph [Str "emph",Space,Str "inside"],Space,Str "strong"]]
+,Para [Strong [Str "strong",Space,Str "with",Space,Emph [Str "emph"]]]
+,Para [Emph [Strong [Str "strong",Space,Str "inside"],Space,Str "emph"]]
+,Header 1 ("horizontal-rule",[],[]) [Str "horizontal",Space,Str "rule"]
+,Para [Str "top"]
+,HorizontalRule
+,Para [Str "bottom"]
+,HorizontalRule
+,Header 1 ("nop",[],[]) [Str "nop"]
+,Para [Str "_not",Space,Str "emph_"]
+,Header 1 ("entities",[],[]) [Str "entities"]
+,Para [Str "hi",Space,Str "&",Space,Str "low"]
+,Para [Str "hi",Space,Str "&",Space,Str "low"]
+,Para [Str "G\246del"]
+,Para [Str "\777\2730"]
+,Header 1 ("comments",[],[]) [Str "comments"]
+,Para [Str "inline",Space,Str "comment"]
+,Para [Str "between",Space,Str "blocks"]
+,Header 1 ("linebreaks",[],[]) [Str "linebreaks"]
+,Para [Str "hi",LineBreak,Str "there"]
+,Para [Str "hi",LineBreak,Str "there"]
+,Header 1 ("inline-code",[],[]) [Str "inline",Space,Str "code"]
+,Para [Code ("",[],[]) "*\8594*",Space,Code ("",[],[]) "typed",Space,Code ("",["haskell"],[]) ">>="]
+,Header 1 ("code-blocks",[],[]) [Str "code",Space,Str "blocks"]
+,CodeBlock ("",[],[]) "case xs of\n (_:_) -> reverse xs\n [] -> ['*']"
+,CodeBlock ("",["haskell"],[]) "case xs of\n (_:_) -> reverse xs\n [] -> ['*']"
+,Header 1 ("block-quotes",[],[]) [Str "block",Space,Str "quotes"]
+,Para [Str "Regular",Space,Str "paragraph"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote."]
+ ,Para [Str "With",Space,Str "two",Space,Str "paragraphs."]]
+,Para [Str "Nother",Space,Str "paragraph."]
+,Header 1 ("external-links",[],[]) [Str "external",Space,Str "links"]
+,Para [Link ("",[],[]) [Emph [Str "Google"],Space,Str "search",Space,Str "engine"] ("http://google.com","")]
+,Para [Link ("",[],[]) [Str "http://pandoc.org"] ("http://pandoc.org","")]
+,Para [Link ("",[],[]) [Str "http://google.com"] ("http://google.com",""),Space,Link ("",[],[]) [Str "http://yahoo.com"] ("http://yahoo.com","")]
+,Para [Link ("",[],[]) [Str "email",Space,Str "me"] ("mailto:info@example.org","")]
+,Para [Str "http://google.com"]
+,Para [Str "http://google.com"]
+,Para [Str "http://google.com"]
+,Para [Str "info@example.org"]
+,Para [Str "info@example.org"]
+,Para [Str "info@example.org"]
+,Header 1 ("lists",[],[]) [Str "lists"]
+,BulletList
+ [[Plain [Str "Start",Space,Str "each",Space,Str "line"]]
+ ,[Plain [Str "with",Space,Str "an",Space,Str "asterisk",Space,Str "(*)."]
+ ,BulletList
+ [[Plain [Str "More",Space,Str "asterisks",Space,Str "gives",Space,Str "deeper"]
+ ,BulletList
+ [[Plain [Str "and",Space,Str "deeper",Space,Str "levels."]]]]]]
+ ,[Plain [Str "Line",Space,Str "breaks",LineBreak,Str "don't",Space,Str "break",Space,Str "levels."]]
+ ,[Plain [Str "Continuations",Space,Str "are",Space,Str "also",Space,Str "possible"]
+ ,BulletList
+ [[Plain [Str "and",Space,Str "do",Space,Str "not",Space,Str "break",Space,Str "the",Space,Str "list",Space,Str "flow"]]]]
+ ,[Plain [Str "Level",Space,Str "one"]]]
+,Para [Str "Any",Space,Str "other",Space,Str "start",Space,Str "ends",Space,Str "the",Space,Str "list."]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Start",Space,Str "each",Space,Str "line"]]
+ ,[Plain [Str "with",Space,Str "a",Space,Str "number",Space,Str "(1.)."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "More",Space,Str "number",Space,Str "signs",Space,Str "gives",Space,Str "deeper"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "and",Space,Str "deeper"]]
+ ,[Plain [Str "levels."]]]]]]
+ ,[Plain [Str "Line",Space,Str "breaks",LineBreak,Str "don't",Space,Str "break",Space,Str "levels."]]
+ ,[Plain [Str "Blank",Space,Str "lines"]]]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "end",Space,Str "the",Space,Str "list",Space,Str "and",Space,Str "start",Space,Str "another."]]]
+,Para [Str "Any",Space,Str "other",Space,Str "start",Space,Str "also",Space,Str "ends",Space,Str "the",Space,Str "list."]
+,DefinitionList
+ [([Str "item",Space,Str "1"],
+ [[Plain [Str "definition",Space,Str "1"]]])
+ ,([Str "item",Space,Str "2"],
+ [[Plain [Str "definition",Space,Str "2-1",Space,Str "definition",Space,Str "2-2"]]])
+ ,([Str "item",Space,Emph [Str "3"]],
+ [[Plain [Str "definition",Space,Emph [Str "3"]]]])]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "one"]]
+ ,[Plain [Str "two"]
+ ,BulletList
+ [[Plain [Str "two",Space,Str "point",Space,Str "one"]]
+ ,[Plain [Str "two",Space,Str "point",Space,Str "two"]]]]
+ ,[Plain [Str "three"]
+ ,DefinitionList
+ [([Str "three",Space,Str "item",Space,Str "one"],
+ [[Plain [Str "three",Space,Str "def",Space,Str "one"]]])]]
+ ,[Plain [Str "four"]
+ ,DefinitionList
+ [([Str "four",Space,Str "def",Space,Str "one"],
+ [[Plain [Str "this",Space,Str "is",Space,Str "a",Space,Str "continuation"]]])]]
+ ,[Plain [Str "five"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "five",Space,Str "sub",Space,Str "1"]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "five",Space,Str "sub",Space,Str "1",Space,Str "sub",Space,Str "1"]]]]
+ ,[Plain [Str "five",Space,Str "sub",Space,Str "2"]]]]]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "other"]
+ ,OrderedList (1,UpperRoman,DefaultDelim)
+ [[Plain [Str "list"]]
+ ,[Plain [Str "styles"]]]]
+ ,[Plain [Str "are"]
+ ,OrderedList (1,LowerRoman,DefaultDelim)
+ [[Plain [Str "also"]]
+ ,[Plain [Str "possible"]]]]
+ ,[Plain [Str "all"]
+ ,OrderedList (1,LowerAlpha,DefaultDelim)
+ [[Plain [Str "the"]]
+ ,[Plain [Str "different"]]
+ ,[Plain [Str "styles"]]]]
+ ,[Plain [Str "are"]
+ ,OrderedList (1,UpperAlpha,DefaultDelim)
+ [[Plain [Str "implemented"]]
+ ,[Plain [Str "and"]]
+ ,[Plain [Str "supported"]]]]]
+,Header 1 ("tables",[],[]) [Str "tables"]
+,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
+ [[]
+ ,[]]
+ [[[Plain [Str "Orange"]]
+ ,[Plain [Str "Apple"]]]
+ ,[[Plain [Str "Bread"]]
+ ,[Plain [Str "Pie"]]]
+ ,[[Plain [Str "Butter"]]
+ ,[Plain [Str "Ice",Space,Str "cream"]]]]
+,Table [] [AlignLeft,AlignLeft] [0.0,0.0]
+ [[Plain [Str "Orange"]]
+ ,[Plain [Str "Apple"]]]
+ [[[Plain [Str "Bread"]]
+ ,[Plain [Str "Pie"]]]
+ ,[[Plain [Strong [Str "Butter"]]]
+ ,[Plain [Str "Ice",Space,Str "cream"]]]]
+,Table [] [AlignLeft,AlignLeft] [0.0,0.0]
+ [[Plain [Str "Orange"]]
+ ,[Plain [Str "Apple"]]]
+ [[[Plain [Str "Bread",LineBreak,LineBreak,Str "and",Space,Str "cheese"]]
+ ,[Plain [Str "Pie",LineBreak,LineBreak,Strong [Str "apple"],Space,Str "and",Space,Emph [Str "carrot"]]]]]
+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
+ [[]
+ ,[]
+ ,[]]
+ [[[Plain [Str "Orange"]]
+ ,[Plain [Str "Apple"]]
+ ,[Plain [Str "more"]]]
+ ,[[Plain [Str "Bread"]]
+ ,[Plain [Str "Pie"]]
+ ,[Plain [Str "more"]]]
+ ,[[Plain [Str "Butter"]]
+ ,[Plain [Str "Ice",Space,Str "cream"]]
+ ,[Plain [Str "and",Space,Str "more"]]]]
+,Header 1 ("macros",[],[]) [Str "macros"]
+,Para [Span ("",["twiki-macro","TEST"],[]) []]
+,Para [Span ("",["twiki-macro","TEST"],[]) [Str ""]]
+,Para [Span ("",["twiki-macro","TEST"],[]) [Str "content with spaces"]]
+,Para [Span ("",["twiki-macro","TEST"],[]) [Str "content with spaces"]]
+,Para [Span ("",["twiki-macro","TEST"],[("ARG1","test")]) [Str "content with spaces"]]
+,Para [Span ("",["twiki-macro","TEST"],[]) [Str "content with spaces ARG1=test"]]
+,Para [Span ("",["twiki-macro","TEST"],[("ARG1","test")]) [Str "content with spaces"]]
+,Para [Span ("",["twiki-macro","TEST"],[("ARG1","test"),("ARG2","test2")]) [Str ""]]
+,Para [Span ("",["twiki-macro","TEST"],[("ARG1","test"),("ARG2","test2")]) [Str ""]]
+,Para [Span ("",["twiki-macro","TEST"],[("ARG1","test"),("ARG2","test2")]) [Str "multiline\ndoes also work"]]]
diff --git a/test/twiki-reader.twiki b/test/twiki-reader.twiki
new file mode 100644
index 000000000..c2df10573
--- /dev/null
+++ b/test/twiki-reader.twiki
@@ -0,0 +1,221 @@
+---+ header
+
+---++ header level two
+
+---+++ header level 3
+
+---++++ header _level_ four
+
+---+++++ header level 5
+
+---++++++ header level 6
+
+---+++++++ not a header
+
+ --++ not a header
+
+---+ emph and strong
+
+_emph_ *strong*
+
+__strong and emph__
+
+*<i>emph inside</i> strong*
+
+*strong with <i>emph</i>*
+
+_<b>strong inside</b> emph_
+
+---+ horizontal rule
+
+top
+---
+bottom
+
+---
+
+---+ nop
+
+<nop>_not emph_
+
+---+ entities
+
+hi & low
+
+hi &amp; low
+
+G&ouml;del
+
+&#777;&#xAAA;
+
+---+ comments
+
+inline <!-- secret --> comment
+
+<!-- secret -->
+
+between blocks
+
+ <!-- secret -->
+
+---+ linebreaks
+
+hi%BR%there
+
+hi%BR%
+there
+
+---+ inline code
+
+<code>*→*</code> =typed= <code class="haskell">>>=</code>
+
+---+ code blocks
+
+<verbatim>
+case xs of
+ (_:_) -> reverse xs
+ [] -> ['*']
+</verbatim>
+
+<verbatim class="haskell">
+case xs of
+ (_:_) -> reverse xs
+ [] -> ['*']
+</verbatim>
+
+---+ block quotes
+
+Regular paragraph
+<blockquote>
+This is a block quote.
+
+With two paragraphs.
+</blockquote>
+Nother paragraph.
+
+---+ external links
+
+[[http://google.com][<i>Google</i> search engine]]
+
+http://pandoc.org
+
+[[http://google.com]] [[http://yahoo.com]]
+
+[[mailto:info@example.org][email me]]
+
+!http://google.com
+
+<nop>http://google.com
+
+<noautolink>
+http://google.com
+</noautolink>
+
+!info@example.org
+
+<nop>info@example.org
+
+<noautolink>
+info@example.org
+</noautolink>
+
+---+ lists
+
+ * Start each line
+ * with an asterisk (*).
+ * More asterisks gives deeper
+ * and deeper levels.
+ * Line breaks%BR%don't break levels.
+ * Continuations
+ are also possible
+ * and do not break the list flow
+ * Level one
+Any other start ends the list.
+
+ 1. Start each line
+ 1. with a number (1.).
+ 1. More number signs gives deeper
+ 1. and deeper
+ 1. levels.
+ 1. Line breaks%BR%don't break levels.
+ 1. Blank lines
+
+ 1. end the list and start another.
+Any other start also
+ends the list.
+
+ $ item 1: definition 1
+ $ item 2: definition 2-1
+ definition 2-2
+ $ item _3_: definition _3_
+
+ 1. one
+ 1. two
+ * two point one
+ * two point two
+ 1. three
+ $ three item one: three def one
+ 1. four
+ $ four def one: this
+ is a continuation
+ 1. five
+ 1. five sub 1
+ 1. five sub 1 sub 1
+ 1. five sub 2
+
+ 1. other
+ I. list
+ I. styles
+ 1. are
+ i. also
+ i. possible
+ 1. all
+ a. the
+ a. different
+ a. styles
+ 1. are
+ A. implemented
+ A. and
+ A. supported
+
+---+ tables
+
+|Orange|Apple|
+|Bread|Pie|
+|Butter|Ice cream|
+
+|*Orange*|*Apple*|
+|Bread|Pie|
+|*Butter*|Ice cream|
+
+|*Orange*|*Apple*|
+|Bread%BR%%BR%and cheese|Pie%BR%%BR%*apple* and <i>carrot</i>|
+
+| Orange | Apple | more |
+| Bread | Pie | more |
+| Butter | Ice cream | and more |
+
+---+ macros
+
+%TEST%
+
+%TEST{}%
+
+%TEST{content with spaces}%
+
+%TEST{"content with spaces"}%
+
+%TEST{"content with spaces" ARG1="test"}%
+
+%TEST{content with spaces ARG1=test}%
+
+%TEST{ARG1=test content with spaces}%
+
+%TEST{ARG1=test ARG2=test2}%
+
+%TEST{ARG1="test" ARG2="test2"}%
+
+%TEST{ARG1="test"
+ARG2="test2"
+multiline
+does also work}%
diff --git a/test/txt2tags.native b/test/txt2tags.native
new file mode 100644
index 000000000..2eb795fde
--- /dev/null
+++ b/test/txt2tags.native
@@ -0,0 +1,552 @@
+Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "author"]]),("date",MetaInlines [Str "date"]),("includeconf",MetaString "rules.conf"),("title",MetaInlines [Str "Txt2tags",Space,Str "Markup",Space,Str "Rules"])]})
+[Para [Str "This",Space,Str "document",Space,Str "describes",Space,Str "all",Space,Str "the",Space,Str "details",Space,Str "about",Space,Str "each",Space,Str "txt2tags",Space,Str "mark.",SoftBreak,Str "The",Space,Str "target",Space,Str "audience",Space,Str "are",Space,Strong [Str "experienced"],Space,Str "users.",Space,Str "You",Space,Str "may",Space,Str "find",Space,Str "it",SoftBreak,Str "useful",Space,Str "if",Space,Str "you",Space,Str "want",Space,Str "to",Space,Str "master",Space,Str "the",Space,Str "marks",Space,Str "or",Space,Str "solve",Space,Str "a",Space,Str "specific",Space,Str "problem",SoftBreak,Str "about",Space,Str "a",Space,Str "mark."]
+,Para [Str "If",Space,Str "you",Space,Str "are",Space,Str "new",Space,Str "to",Space,Str "txt2tags",Space,Str "or",Space,Str "just",Space,Str "want",Space,Str "to",Space,Str "know",Space,Str "which",Space,Str "are",Space,Str "the",SoftBreak,Str "available",Space,Str "marks,",Space,Str "please",Space,Str "read",Space,Str "the",Space,Link ("",[],[]) [Str "Markup",Space,Str "Demo"] ("MARKUPDEMO",""),Str "."]
+,Para [Str "Note",Space,Str "1:",Space,Str "This",Space,Str "document",Space,Str "is",Space,Str "generated",Space,Str "directly",Space,Str "from",Space,Str "the",Space,Str "txt2tags",SoftBreak,Str "test-suite.",Space,Str "All",Space,Str "the",Space,Str "rules",Space,Str "mentioned",Space,Str "here",Space,Str "are",Space,Str "100%",Space,Str "in",Space,Str "sync",Space,Str "with",Space,Str "the",SoftBreak,Str "current",Space,Str "program",Space,Str "code."]
+,Para [Str "Note",Space,Str "2:",Space,Str "A",Space,Str "good",Space,Str "practice",Space,Str "is",Space,Str "to",Space,Str "consult",Space,Link ("",[],[]) [Str "the",Space,Str "sources"] ("rules.t2t",""),Space,Str "when",SoftBreak,Str "reading,",Space,Str "to",Space,Str "see",Space,Str "how",Space,Str "the",Space,Str "texts",Space,Str "were",Space,Str "made."]
+,Para [Str "Table",Space,Str "of",Space,Str "Contents:"]
+,HorizontalRule
+,Header 1 ("paragraph",[],[]) [Str "Paragraph"]
+,Para [Str "A",Space,Str "paragraph",Space,Str "is",Space,Str "composed",Space,Str "by",Space,Str "one",Space,Str "or",Space,Str "more",Space,Str "lines.",SoftBreak,Str "A",Space,Str "blank",Space,Str "line",Space,Str "(or",Space,Str "a",Space,Str "table,",Space,Str "or",Space,Str "a",Space,Str "list)",Space,Str "ends",Space,Str "the",SoftBreak,Str "current",Space,Str "paragraph."]
+,Para [Str "Leading",Space,Str "and",Space,Str "trailing",Space,Str "spaces",Space,Str "are",Space,Str "ignored."]
+,Para [Str "A",Space,Str "comment",Space,Str "line",Space,Str "can",Space,Str "be",Space,Str "placed",Space,Str "inside",Space,Str "a",Space,Str "paragraph.",SoftBreak,Str "It",Space,Str "will",Space,Str "not",Space,Str "affect",Space,Str "it."]
+,Para [Str "The",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "file",Space,Str "(EOF)",Space,Str "closes",Space,Str "the",SoftBreak,Str "currently",Space,Str "open",Space,Str "paragraph."]
+,Header 1 ("comment",[],[]) [Str "Comment"]
+,Para [Str "%",Space,Str "not",Space,Str "on",Space,Str "the",Space,Str "line",Space,Str "beginning",Space,Str "(at",Space,Str "column",Space,Str "2)"]
+,Para [Str "some",Space,Str "text",Space,Str "%",Space,Str "half",Space,Str "line",Space,Str "comments",Space,Str "are",Space,Str "not",Space,Str "allowed"]
+,Header 1 ("line",[],[]) [Str "Line"]
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,HorizontalRule
+,Para [Strikeout [Str "-----"],SoftBreak,Strikeout [Str "-------",Space,Str "--------"]]
+,Para [Strikeout [Str "-------+--------"]]
+,Para [Str "(",Space,Strikeout [Str "----------------"],Space,Str ")"]
+,Header 1 ("inline",[],[]) [Str "Inline"]
+,Para [Str "i)",Space,Strong [Str "b"],Space,Emph [Str "i"],Space,Emph [Str "u"],Space,Strikeout [Str "s"],Space,Code ("",[],[]) "m",Space,Str "r",Space,RawInline (Format "html") "t",SoftBreak,Str "i)",Space,Strong [Str "bo"],Space,Emph [Str "it"],Space,Emph [Str "un"],Space,Strikeout [Str "st"],Space,Code ("",[],[]) "mo",Space,Str "ra",Space,RawInline (Format "html") "tg",SoftBreak,Str "i)",Space,Strong [Str "bold"],Space,Emph [Str "ital"],Space,Emph [Str "undr"],Space,Strikeout [Str "strk"],Space,Code ("",[],[]) "mono",Space,Str "raw",Space,RawInline (Format "html") "tggd",SoftBreak,Str "i)",Space,Strong [Str "bo",Space,Str "ld"],Space,Emph [Str "it",Space,Str "al"],Space,Emph [Str "un",Space,Str "dr"],Space,Strikeout [Str "st",Space,Str "rk"],Space,Code ("",[],[]) "mo no",Space,Str "r",Space,Str "aw",Space,RawInline (Format "html") "tg gd",SoftBreak,Str "i)",Space,Strong [Str "bo",Space,Str "*",Space,Str "ld"],Space,Emph [Str "it",Space,Str "/",Space,Str "al"],Space,Emph [Str "un",Space,Str "_",Space,Str "dr"],Space,Strikeout [Str "st",Space,Str "-",Space,Str "rk"],Space,Code ("",[],[]) "mo ` no",Space,Str "r",Space,Str "\"",Space,Str "aw",Space,RawInline (Format "html") "tg ' gd",SoftBreak,Str "i)",Space,Strong [Str "bo",Space,Str "**ld"],Space,Emph [Str "it",Space,Str "//al"],Space,Emph [Str "un",Space,Str "__dr"],Space,Strikeout [Str "st",Space,Str "--rk"],Space,Code ("",[],[]) "mo ``no",Space,Str "r",Space,Str "\"\"aw",Space,RawInline (Format "html") "tg ''gd",SoftBreak,Str "i)",Space,Strong [Str "bo",Space,Str "**",Space,Str "ld"],Space,Emph [Str "it",Space,Str "//",Space,Str "al"],Space,Emph [Str "un",Space,Str "__",Space,Str "dr"],Space,Strikeout [Str "st",Space,Str "--",Space,Str "rk"],Space,Code ("",[],[]) "mo `` no",Space,Str "r",Space,Str "\"\"",Space,Str "aw",Space,RawInline (Format "html") "tg '' gd",SoftBreak,Str "i)",Space,Strong [Str "**bold**"],Space,Emph [Str "//ital//"],Space,Emph [Str "__undr__"],Space,Strikeout [Str "--strk--"],Space,Code ("",[],[]) "``mono``",Space,Str "\"\"raw\"\"",Space,RawInline (Format "html") "''tggd''",SoftBreak,Str "i)",Space,Strong [Str "*bold*"],Space,Emph [Str "/ital/"],Space,Emph [Str "_undr_"],Space,Strikeout [Str "-strk-"],Space,Code ("",[],[]) "`mono`",Space,Str "\"raw\"",Space,RawInline (Format "html") "'tggd'"]
+,Para [Str "i)",Space,Strong [Str "*"],Space,Emph [Str "/"],Space,Emph [Str "_"],Space,Strikeout [Str "-"],Space,Code ("",[],[]) "`",Space,Str "\"",Space,RawInline (Format "html") "'",SoftBreak,Str "i)",Space,Strong [Str "**"],Space,Emph [Str "//"],Space,Emph [Str "__"],Space,Strikeout [Str "--"],Space,Code ("",[],[]) "``",Space,Str "\"\"",Space,RawInline (Format "html") "''",SoftBreak,Str "i)",Space,Strong [Str "***"],Space,Emph [Str "///"],Space,Emph [Str "___"],Space,Strikeout [Str "---"],Space,Code ("",[],[]) "```",Space,Str "\"\"\"",Space,RawInline (Format "html") "'''",SoftBreak,Str "i)",Space,Strong [Str "****"],Space,Emph [Str "////"],Space,Emph [Str "____"],Space,Strikeout [Str "----"],Space,Code ("",[],[]) "````",Space,Str "\"\"\"\"",Space,RawInline (Format "html") "''''",SoftBreak,Str "i)",Space,Strong [Str "*****"],Space,Emph [Str "/////"],Space,Emph [Str "_____"],Space,Strikeout [Str "-----"],Space,Code ("",[],[]) "`````",Space,Str "\"\"\"\"\"",Space,RawInline (Format "html") "'''''",SoftBreak,Str "i)",Space,Strong [Str "******"],Space,Emph [Str "//////"],Space,Emph [Str "______"],Space,Strikeout [Str "------"],Space,Code ("",[],[]) "``````",Space,Str "\"\"\"\"\"\"",Space,RawInline (Format "html") "''''''"]
+,Para [Str "i)",Space,Str "****",Space,Str "////",Space,Str "____",Space,Str "----",Space,Str "````",Space,Str "\"\"\"\"",Space,Str "''''",SoftBreak,Str "i)",Space,Str "**",Space,Str "**",Space,Str "//",Space,Str "//",Space,Str "__",Space,Str "__",Space,Str "--",Space,Str "--",Space,Str "``",Space,Str "``",Space,Str "\"\"",Space,Str "\"\"",Space,Str "''",Space,Str "''"]
+,Para [Str "i)",Space,Str "**",Space,Str "bold**",Space,Str "//",Space,Str "ital//",Space,Str "__",Space,Str "undr__",Space,Str "--",Space,Str "strk--",Space,Str "``",Space,Str "mono``",Space,Str "\"\"",Space,Str "raw\"\"",Space,Str "''",Space,Str "tggd''",SoftBreak,Str "i)",Space,Str "**bold",Space,Str "**",Space,Str "//ital",Space,Str "//",Space,Str "__undr",Space,Str "__",Space,Str "--strk",Space,Str "--",Space,Str "``mono",Space,Str "``",Space,Str "\"\"raw",Space,Str "\"\"",Space,Str "''tggd",Space,Str "''",SoftBreak,Str "i)",Space,Str "**",Space,Str "bold",Space,Str "**",Space,Str "//",Space,Str "ital",Space,Str "//",Space,Str "__",Space,Str "undr",Space,Str "__",Space,Str "--",Space,Str "strk",Space,Str "--",Space,Str "``",Space,Str "mono",Space,Str "``",Space,Str "\"\"",Space,Str "raw",Space,Str "\"\"",Space,Str "''",Space,Str "tggd",Space,Str "''"]
+,Header 1 ("link",[],[]) [Str "Link"]
+,Para [Link ("",[],[]) [Str "mailto:user@domain.com"] ("user@domain.com",""),SoftBreak,Link ("",[],[]) [Str "mailto:user@domain.com"] ("user@domain.com",""),Str ".",SoftBreak,Link ("",[],[]) [Str "mailto:user@domain.com"] ("user@domain.com",""),Str ".",Space,Str "any",Space,Str "text.",SoftBreak,Str "any",Space,Str "text:",Space,Link ("",[],[]) [Str "mailto:user@domain.com"] ("user@domain.com",""),Str ".",Space,Str "any",Space,Str "text.",SoftBreak,Link ("",[],[]) [Str "label"] ("user@domain.com",""),SoftBreak,Link ("",[],[]) [Str "mailto:user@domain.com?subject=bla"] ("user@domain.com?subject=bla",""),SoftBreak,Link ("",[],[]) [Str "mailto:user@domain.com?subject=bla"] ("user@domain.com?subject=bla",""),Str ".",SoftBreak,Link ("",[],[]) [Str "mailto:user@domain.com?subject=bla"] ("user@domain.com?subject=bla",""),Str ",",SoftBreak,Link ("",[],[]) [Str "mailto:user@domain.com?subject=bla&cc=otheruser@domain.com"] ("user@domain.com?subject=bla&cc=otheruser@domain.com",""),SoftBreak,Link ("",[],[]) [Str "mailto:user@domain.com?subject=bla&cc=otheruser@domain.com"] ("user@domain.com?subject=bla&cc=otheruser@domain.com",""),Str ".",SoftBreak,Link ("",[],[]) [Str "mailto:user@domain.com?subject=bla&cc=otheruser@domain.com"] ("user@domain.com?subject=bla&cc=otheruser@domain.com",""),Str ",",SoftBreak,Link ("",[],[]) [Str "label"] ("user@domain.com?subject=bla&cc=otheruser@domain.com",""),Str ".",SoftBreak,Link ("",[],[]) [Str "label"] ("user@domain.com?subject=bla&cc=otheruser@domain.com.",""),Str ".",SoftBreak,Link ("",[],[]) [Str "http://www.domain.com"] ("http://www.domain.com",""),SoftBreak,Link ("",[],[]) [Str "http://www.domain.com/dir/"] ("http://www.domain.com/dir/",""),SoftBreak,Link ("",[],[]) [Str "http://www.domain.com/dir///"] ("http://www.domain.com/dir///",""),SoftBreak,Link ("",[],[]) [Str "http://www.domain.com."] ("http://www.domain.com.",""),SoftBreak,Link ("",[],[]) [Str "http://www.domain.com,"] ("http://www.domain.com,",""),SoftBreak,Link ("",[],[]) [Str "http://www.domain.com."] ("http://www.domain.com.",""),Space,Str "any",Space,Str "text.",SoftBreak,Link ("",[],[]) [Str "http://www.domain.com,"] ("http://www.domain.com,",""),Space,Str "any",Space,Str "text.",SoftBreak,Link ("",[],[]) [Str "http://www.domain.com/dir/."] ("http://www.domain.com/dir/.",""),Space,Str "any",Space,Str "text.",SoftBreak,Str "any",Space,Str "text:",Space,Link ("",[],[]) [Str "http://www.domain.com."] ("http://www.domain.com.",""),Space,Str "any",Space,Str "text.",SoftBreak,Str "any",Space,Str "text:",Space,Link ("",[],[]) [Str "http://www.domain.com/dir/."] ("http://www.domain.com/dir/.",""),Space,Str "any",Space,Str "text.",SoftBreak,Str "any",Space,Str "text:",Space,Link ("",[],[]) [Str "http://www.domain.com/dir/index.html."] ("http://www.domain.com/dir/index.html.",""),Space,Str "any",Space,Str "text.",SoftBreak,Str "any",Space,Str "text:",Space,Link ("",[],[]) [Str "http://www.domain.com/dir/index.html,"] ("http://www.domain.com/dir/index.html,",""),Space,Str "any",Space,Str "text.",SoftBreak,Link ("",[],[]) [Str "http://www.domain.com/dir/#anchor"] ("http://www.domain.com/dir/#anchor",""),SoftBreak,Link ("",[],[]) [Str "http://www.domain.com/dir/index.html#anchor"] ("http://www.domain.com/dir/index.html#anchor",""),SoftBreak,Link ("",[],[]) [Str "http://www.domain.com/dir/index.html#anchor."] ("http://www.domain.com/dir/index.html#anchor.",""),SoftBreak,Link ("",[],[]) [Str "http://www.domain.com/dir/#anchor."] ("http://www.domain.com/dir/#anchor.",""),Space,Str "any",Space,Str "text.",SoftBreak,Link ("",[],[]) [Str "http://www.domain.com/dir/index.html#anchor."] ("http://www.domain.com/dir/index.html#anchor.",""),Space,Str "any",Space,Str "text.",SoftBreak,Str "any",Space,Str "text:",Space,Link ("",[],[]) [Str "http://www.domain.com/dir/#anchor."] ("http://www.domain.com/dir/#anchor.",""),Space,Str "any",Space,Str "text.",SoftBreak,Str "any",Space,Str "text:",Space,Link ("",[],[]) [Str "http://www.domain.com/dir/index.html#anchor."] ("http://www.domain.com/dir/index.html#anchor.",""),Space,Str "any",Space,Str "text.",SoftBreak,Link ("",[],[]) [Str "http://domain.com?a=a@a.a&b=a+b+c."] ("http://domain.com?a=a@a.a&b=a+b+c.",""),SoftBreak,Link ("",[],[]) [Str "http://domain.com?a=a@a.a&b=a+b+c,"] ("http://domain.com?a=a@a.a&b=a+b+c,",""),SoftBreak,Link ("",[],[]) [Str "http://domain.com/bla.cgi?a=a@a.a&b=a+b+c."] ("http://domain.com/bla.cgi?a=a@a.a&b=a+b+c.",""),SoftBreak,Link ("",[],[]) [Str "http://domain.com/bla.cgi?a=a@a.a&b=a+b+c@."] ("http://domain.com/bla.cgi?a=a@a.a&b=a+b+c@.",""),SoftBreak,Link ("",[],[]) [Str "http://domain.com?a=a@a.a&b=a+b+c.#anchor"] ("http://domain.com?a=a@a.a&b=a+b+c.#anchor",""),SoftBreak,Link ("",[],[]) [Str "http://domain.com/bla.cgi?a=a@a.a&b=a+b+c.#anchor"] ("http://domain.com/bla.cgi?a=a@a.a&b=a+b+c.#anchor",""),SoftBreak,Link ("",[],[]) [Str "http://domain.com/bla.cgi?a=a@a.a&b=a+b+c@.#anchor"] ("http://domain.com/bla.cgi?a=a@a.a&b=a+b+c@.#anchor",""),SoftBreak,Link ("",[],[]) [Str "http://user:password@domain.com/bla.html."] ("http://user:password@domain.com/bla.html.",""),SoftBreak,Link ("",[],[]) [Str "http://user:password@domain.com/dir/."] ("http://user:password@domain.com/dir/.",""),SoftBreak,Link ("",[],[]) [Str "http://user:password@domain.com."] ("http://user:password@domain.com.",""),SoftBreak,Link ("",[],[]) [Str "http://user:@domain.com."] ("http://user:@domain.com.",""),SoftBreak,Link ("",[],[]) [Str "http://user@domain.com."] ("http://user@domain.com.",""),SoftBreak,Link ("",[],[]) [Str "http://user:password@domain.com/bla.cgi?a=a@a.a&b=a+b+c.#anchor"] ("http://user:password@domain.com/bla.cgi?a=a@a.a&b=a+b+c.#anchor",""),SoftBreak,Link ("",[],[]) [Str "http://user:password@domain.com/bla.cgi?a=a@a.a&b=a+b+c@#anchor"] ("http://user:password@domain.com/bla.cgi?a=a@a.a&b=a+b+c@#anchor",""),SoftBreak,Link ("",[],[]) [Str "label"] ("www.domain.com",""),SoftBreak,Str "[",Space,Str "label",Space,Link ("",[],[]) [Str "www.domain.com"] ("www.domain.com",""),Str "]",SoftBreak,Link ("",[],[]) [Str "label",Space] ("www.domain.com",""),SoftBreak,Link ("",[],[]) [Str "anchor",Space] ("http://www.domain.com/dir/index.html#anchor.",""),SoftBreak,Link ("",[],[]) [Str "login",Space] ("http://user:password@domain.com/bla.html",""),SoftBreak,Link ("",[],[]) [Str "form",Space] ("http://www.domain.com/bla.cgi?a=a@a.a&b=a+b+c.",""),SoftBreak,Link ("",[],[]) [Str "form",Space,Str "&",Space,Str "anchor"] ("http://www.domain.com/bla.cgi?a=a@a.a&b=a+b+c.#anchor",""),SoftBreak,Link ("",[],[]) [Str "login",Space,Str "&",Space,Str "form",Space] ("http://user:password@domain.com/bla.cgi?a=a@a.a&b=a+b+c.",""),SoftBreak,Link ("",[],[]) [Str "local",Space,Str "link",Space,Str "up",Space] ("..",""),SoftBreak,Link ("",[],[]) [Str "local",Space,Str "link",Space,Str "file",Space] ("bla.html",""),SoftBreak,Link ("",[],[]) [Str "local",Space,Str "link",Space,Str "anchor",Space] ("#anchor",""),SoftBreak,Link ("",[],[]) [Str "local",Space,Str "link",Space,Str "file/anchor"] ("bla.html#anchor",""),SoftBreak,Link ("",[],[]) [Str "local",Space,Str "link",Space,Str "file/anchor"] ("bla.html#anchor.",""),SoftBreak,Link ("",[],[]) [Str "local",Space,Str "link",Space,Str "img",Space] ("abc.gif",""),SoftBreak,Link ("",[],[]) [Str "www.fake.com"] ("www.domain.com",""),SoftBreak,Link ("",[],[]) [Str "http://domain.com:8080/~user/_st-r@a=n$g,e/index%20new.htm"] ("http://domain.com:8080/~user/_st-r@a=n$g,e/index%20new.htm",""),SoftBreak,Link ("",[],[]) [Str "http://domain.com:8080/~user/_st-r@a=n$g,e/index%20new.htm?a=/%22&b=+.@*_-"] ("http://domain.com:8080/~user/_st-r@a=n$g,e/index%20new.htm?a=/%22&b=+.@*_-",""),SoftBreak,Link ("",[],[]) [Str "http://domain.com:8080/~user/_st-r@a=n$g,e/index%20new.htm?a=/%22&b=+.@*_-#anchor_"] ("http://domain.com:8080/~user/_st-r@a=n$g,e/index%20new.htm?a=/%22&b=+.@*_-#anchor_",""),Str "-1%.",SoftBreak,Link ("",[],[]) [Str "http://foo._user-9:pass!#$%&*()+word@domain.com:8080/~user/_st-r@a=n$g,e/index%20new.htm?a=/%22&b=+.@*_-#anchor_"] ("http://foo._user-9:pass!#$%&*()+word@domain.com:8080/~user/_st-r@a=n$g,e/index%20new.htm?a=/%22&b=+.@*_-#anchor_",""),Str "-1%.",SoftBreak,Link ("",[],[]) [Str "http://L1.com"] ("http://L1.com",""),Space,Str "!",Space,Link ("",[],[]) [Str "mailto:L2@www.com"] ("L2@www.com",""),Space,Str "!",Space,Link ("",[],[]) [Str "L3"] ("www.com",""),Space,Str "!",Space,Link ("",[],[]) [Str "L4"] ("w@ww.com",""),Space,Str "!",Space,Link ("",[],[]) [Str "www.L5.com"] ("www.L5.com",""),SoftBreak,Link ("",[],[]) [Str "www.domain.com"] ("www.domain.com",""),SoftBreak,Link ("",[],[]) [Str "www2.domain.com"] ("www2.domain.com",""),SoftBreak,Link ("",[],[]) [Str "ftp.domain.com"] ("ftp.domain.com",""),SoftBreak,Link ("",[],[]) [Str "WWW.DOMAIN.COM"] ("WWW.DOMAIN.COM",""),SoftBreak,Link ("",[],[]) [Str "FTP.DOMAIN.COM"] ("FTP.DOMAIN.COM",""),SoftBreak,Link ("",[],[]) [Str "label"] ("www.domain.com",""),SoftBreak,Link ("",[],[]) [Str "label"] ("ftp.domain.com",""),SoftBreak,Link ("",[],[]) [Str "label"] ("WWW.DOMAIN.COM",""),SoftBreak,Link ("",[],[]) [Str "label"] ("FTP.DOMAIN.COM",""),SoftBreak,Str "[label",Space,Link ("",[],[]) [Str "www.domain.com"] ("www.domain.com",""),Space,Str "]",SoftBreak,Str "[label]",Space,Link ("",[],[]) [Str "www.domain.com"] ("www.domain.com",""),Str "]"]
+,Header 1 ("image",[],[]) [Str "Image"]
+,Para [Image ("",[],[]) [] ("img.png","")]
+,Para [Link ("",[],[]) [Image ("",[],[]) [] ("img.png","")] ("http://txt2tags.org","")]
+,Para [Image ("",[],[]) [] ("img.png",""),Space,Str "Image",Space,Str "at",Space,Str "the",Space,Str "line",Space,Str "beginning."]
+,Para [Str "Image",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Image ("",[],[]) [] ("img.png",""),Space,Str "of",Space,Str "the",Space,Str "line."]
+,Para [Str "Image",Space,Str "at",Space,Str "the",Space,Str "line",Space,Str "end.",Space,Image ("",[],[]) [] ("img.png","")]
+,Para [Image ("",[],[]) [] ("img.png",""),SoftBreak,Image ("",[],[]) [] ("img.png",""),SoftBreak,Image ("",[],[]) [] ("img.png","")]
+,Para [Image ("",[],[]) [] ("img.png",""),Image ("",[],[]) [] ("img.png","")]
+,Para [Str "Images",Space,Image ("",[],[]) [] ("img.png",""),Space,Str "mixed",Space,Image ("",[],[]) [] ("img.png",""),Space,Str "with",Space,Image ("",[],[]) [] ("img.png",""),Space,Str "text."]
+,Para [Str "Images",Space,Str "glued",Space,Str "together:",Space,Image ("",[],[]) [] ("img.png",""),Image ("",[],[]) [] ("img.png",""),Image ("",[],[]) [] ("img.png",""),Str "."]
+,Para [Str "[img.png",Space,Str "]"]
+,Para [Str "[",Space,Str "img.png]"]
+,Para [Str "[",Space,Str "img.png",Space,Str "]"]
+,Header 1 ("numtitle",[],[]) [Str "Numbered",Space,Str "Title"]
+,Header 1 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "1"]
+,Header 2 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "2"]
+,Header 3 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Header 4 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "4"]
+,Header 5 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "5"]
+,Header 1 ("lab_el-1",[],[]) [Str "Title",Space,Str "Level",Space,Str "1"]
+,Header 2 ("lab_el-2",[],[]) [Str "Title",Space,Str "Level",Space,Str "2"]
+,Header 3 ("lab_el-3",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Header 4 ("lab_el-4",[],[]) [Str "Title",Space,Str "Level",Space,Str "4"]
+,Header 5 ("lab_el-5",[],[]) [Str "Title",Space,Str "Level",Space,Str "5"]
+,Header 3 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Header 3 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Header 3 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Header 3 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Header 3 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Header 3 ("lab_el-9",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Para [Str "+Not",Space,Str "Title"]
+,Para [Str "++Not",Space,Str "Title+"]
+,Para [Str "+++Not",Space,Str "Title++++",SoftBreak,Str "++++++Not",Space,Str "Title",Space,Str "6++++++"]
+,Para [Str "+++++++Not",Space,Str "Title",Space,Str "7+++++++",SoftBreak,Str "+Not",Space,Str "Title+",Space,Str "[label1]",SoftBreak,Str "+Not",Space,Str "Title+[",Space,Str "label",Space,Str "]",SoftBreak,Str "+Not",Space,Str "Title+[la/bel]"]
+,Header 1 ("title",[],[]) [Str "Title"]
+,Header 1 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "1"]
+,Header 2 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "2"]
+,Header 3 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Header 4 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "4"]
+,Header 5 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "5"]
+,Header 1 ("lab_el-1",[],[]) [Str "Title",Space,Str "Level",Space,Str "1"]
+,Header 2 ("lab_el-2",[],[]) [Str "Title",Space,Str "Level",Space,Str "2"]
+,Header 3 ("lab_el-3",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Header 4 ("lab_el-4",[],[]) [Str "Title",Space,Str "Level",Space,Str "4"]
+,Header 5 ("lab_el-5",[],[]) [Str "Title",Space,Str "Level",Space,Str "5"]
+,Header 3 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Header 3 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Header 3 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Header 3 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Header 3 ("",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Header 3 ("lab_el-9",[],[]) [Str "Title",Space,Str "Level",Space,Str "3"]
+,Para [Str "=Not",Space,Str "Title"]
+,Para [Str "==Not",Space,Str "Title="]
+,Para [Str "===Not",Space,Str "Title====",SoftBreak,Str "======Not",Space,Str "Title",Space,Str "6======"]
+,Para [Str "=======Not",Space,Str "Title",Space,Str "7=======",SoftBreak,Str "=Not",Space,Str "Title=",Space,Str "[label1]",SoftBreak,Str "=Not",Space,Str "Title=[",Space,Str "label",Space,Str "]",SoftBreak,Str "=Not",Space,Str "Title=[la/bel]"]
+,Header 1 ("quote",[],[]) [Str "Quote"]
+,BlockQuote
+ [Para [Str "To",Space,Str "quote",Space,Str "a",Space,Str "paragraph,",Space,Str "just",Space,Str "prefix",Space,Str "it",Space,Str "by",Space,Str "a",Space,Str "TAB",SoftBreak,Str "character.",Space,Str "All",Space,Str "the",Space,Str "lines",Space,Str "of",Space,Str "the",Space,Str "paragraph",Space,Str "must",SoftBreak,Str "begin",Space,Str "with",Space,Str "a",Space,Str "TAB."]]
+,Para [Str "Any",Space,Str "non-tabbed",Space,Str "line",Space,Str "closes",Space,Str "the",Space,Str "quote",Space,Str "block."]
+,BlockQuote
+ [Para [Str "The",Space,Str "number",Space,Str "of",Space,Str "leading",Space,Str "TABs",Space,Str "identifies",Space,Str "the",Space,Str "quote",SoftBreak,Str "block",Space,Str "depth.",Space,Str "This",Space,Str "is",Space,Str "quote",Space,Str "level",Space,Str "1."]
+ ,BlockQuote
+ [Para [Str "With",Space,Str "two",Space,Str "TABs,",Space,Str "we",Space,Str "are",Space,Str "on",Space,Str "the",Space,Str "quote",SoftBreak,Str "level",Space,Str "2."]
+ ,BlockQuote
+ [Para [Str "The",Space,Str "more",Space,Str "TABs,",Space,Str "more",Space,Str "deep",Space,Str "is",SoftBreak,Str "the",Space,Str "quote",Space,Str "level."]
+ ,BlockQuote
+ [Para [Str "There",Space,Str "isn't",Space,Str "a",Space,Str "limit."]]]]]
+,BlockQuote
+ [BlockQuote
+ [BlockQuote
+ [BlockQuote
+ [Para [Str "This",Space,Str "quote",Space,Str "starts",Space,Str "at",SoftBreak,Str "level",Space,Str "4."]]
+ ,Para [Str "Then",Space,Str "its",Space,Str "depth",Space,Str "is",Space,Str "decreased."]]
+ ,Para [Str "Counting",Space,Str "down,",Space,Str "one",Space,Str "by",Space,Str "one."]]
+ ,Para [Str "Until",Space,Str "the",Space,Str "level",Space,Str "1."]]
+,BlockQuote
+ [BlockQuote
+ [BlockQuote
+ [Para [Str "Unlike",Space,Str "lists,",Space,Str "any",Space,Str "quote",Space,Str "block",Space,Str "is",SoftBreak,Str "independent,",Space,Str "not",Space,Str "part",Space,Str "of",Space,Str "a",Space,Str "tree."]]]
+ ,Para [Str "The",Space,Str "TAB",Space,Str "count",Space,Str "don't",Space,Str "need",Space,Str "to",Space,Str "be",Space,Str "incremental",SoftBreak,Str "by",Space,Str "one."]
+ ,BlockQuote
+ [BlockQuote
+ [BlockQuote
+ [Para [Str "The",Space,Str "nesting",Space,Str "don't",Space,Str "need",SoftBreak,Str "to",Space,Str "follow",Space,Str "any",Space,Str "rule."]]]
+ ,Para [Str "Quotes",Space,Str "can",Space,Str "be",Space,Str "opened",Space,Str "and",Space,Str "closed",SoftBreak,Str "in",Space,Str "any",Space,Str "way."]
+ ,BlockQuote
+ [BlockQuote
+ [BlockQuote
+ [Para [Str "You",Space,Str "choose."]]]]]]
+,BlockQuote
+ [Para [Str "Some",Space,Str "targets",Space,Str "(as",Space,Str "sgml)",Space,Str "don't",Space,Str "support",Space,Str "the",SoftBreak,Str "nesting",Space,Str "of",Space,Str "quotes.",Space,Str "There",Space,Str "is",Space,Str "only",Space,Str "one",Space,Str "quote",SoftBreak,Str "level."]
+ ,BlockQuote
+ [Para [Str "In",Space,Str "this",Space,Str "case,",Space,Str "no",Space,Str "matter",Space,Str "how",Space,Str "much",SoftBreak,Str "TABs",Space,Str "are",Space,Str "used",Space,Str "to",Space,Str "define",Space,Str "the",Space,Str "quote",SoftBreak,Str "block,",Space,Str "it",Space,Str "always",Space,Str "will",Space,Str "be",Space,Str "level",Space,Str "1."]]]
+,BlockQuote
+ [Para [Str "Spaces",Space,Str "AFTER",Space,Str "the",Space,Str "TAB",Space,Str "character",Space,Str "are",Space,Str "allowed.",SoftBreak,Str "But",Space,Str "be",Space,Str "careful,",Space,Str "it",Space,Str "can",Space,Str "be",Space,Str "confusing."]]
+,Para [Str "Spaces",Space,Str "BEFORE",Space,Str "the",Space,Str "TAB",Space,Str "character",SoftBreak,Str "invalidate",Space,Str "the",Space,Str "mark.",Space,Str "It's",Space,Str "not",Space,Str "quote."]
+,BlockQuote
+ [Para [Str "Paragraph",Space,Str "breaks",Space,Str "inside",Space,Str "a",Space,Str "quote",Space,Str "aren't",SoftBreak,Str "possible."]
+ ,Para [Str "This",Space,Str "sample",Space,Str "are",Space,Str "two",Space,Str "separated",Space,Str "quoted",SoftBreak,Str "paragraphs,",Space,Str "not",Space,Str "a",Space,Str "quote",Space,Str "block",Space,Str "with",SoftBreak,Str "two",Space,Str "paragraphs",Space,Str "inside."]]
+,BlockQuote
+ [Para [Str "The",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "file",Space,Str "(EOF)",Space,Str "closes",Space,Str "the",SoftBreak,Str "currently",Space,Str "open",Space,Str "quote",Space,Str "block."]]
+,Header 1 ("raw",[],[]) [Str "Raw"]
+,Para [Str "A raw line.\n"]
+,Para [Str " Another raw line, with leading spaces.\n"]
+,Para [Str "A raw area delimited\n by lines with marks.\n"]
+,Para [Str "Trailing spaces and TABs after the area marks\nare allowed, but not encouraged nor documented.\n"]
+,Para [Str "\"\"\"Not",Space,Str "a",Space,Str "raw",Space,Str "line,",Space,Str "need",Space,Str "one",Space,Str "space",Space,Str "after",Space,Str "mark."]
+,Para [Str "\"\"\"",SoftBreak,Str "Not",Space,Str "a",Space,Str "raw",Space,Str "area.",SoftBreak,Str "The",Space,Str "marks",Space,Str "must",Space,Str "be",Space,Str "at",Space,Str "the",Space,Str "line",Space,Str "beginning,",SoftBreak,Str "no",Space,Str "leading",Space,Str "spaces.",SoftBreak,Str "\"\"\""]
+,Para [Str "The end of the file (EOF) closes\nthe currently open raw area.\n"]
+,Header 1 ("verbatim",[],[]) [Str "Verbatim"]
+,CodeBlock ("",[],[]) "A verbatim line.\n"
+,CodeBlock ("",[],[]) " Another verbatim line, with leading spaces.\n"
+,CodeBlock ("",[],[]) "A verbatim area delimited\n by lines with marks.\n"
+,CodeBlock ("",[],[]) "Trailing spaces and TABs after the area marks\nare allowed, but not encouraged nor documented.\n"
+,Para [Str "```Not",Space,Str "a",Space,Str "verbatim",Space,Str "line,",Space,Str "need",Space,Str "one",Space,Str "space",Space,Str "after",Space,Str "mark."]
+,Para [Str "```",SoftBreak,Str "Not",Space,Str "a",Space,Str "verbatim",Space,Str "area.",SoftBreak,Str "The",Space,Str "marks",Space,Str "must",Space,Str "be",Space,Str "at",Space,Str "the",Space,Str "line",Space,Str "beginning,",SoftBreak,Str "no",Space,Str "leading",Space,Str "spaces.",SoftBreak,Str "```"]
+,CodeBlock ("",[],[]) "The end of the file (EOF) closes\nthe currently open verbatim area.\n"
+,Header 1 ("deflist",[],[]) [Str "Definition",Space,Str "List"]
+,DefinitionList
+ [([Str "Definition",Space,Str "list"],
+ [[Plain [Str "A",Space,Str "list",Space,Str "with",Space,Str "terms"]]])
+ ,([Str "Start",Space,Str "term",Space,Str "with",Space,Str "colon"],
+ [[Plain [Str "And",Space,Str "its",Space,Str "definition",Space,Str "follows"]]])]
+,Header 1 ("numlist",[],[]) [Str "Numbered",Space,Str "List"]
+,Para [Str "See",Space,Link ("",[],[]) [Str "List"] ("#list",""),Str ",",Space,Str "the",Space,Str "same",Space,Str "rules",Space,Str "apply."]
+,Header 1 ("list",[],[]) [Str "List"]
+,BulletList
+ [[Plain [Str "Use",Space,Str "the",Space,Str "hyphen",Space,Str "to",Space,Str "prefix",Space,Str "list",Space,Str "items."]]
+ ,[Plain [Str "There",Space,Str "must",Space,Str "be",Space,Str "one",Space,Str "space",Space,Str "after",Space,Str "the",Space,Str "hyphen."]]
+ ,[Plain [Str "The",Space,Str "list",Space,Str "is",Space,Str "closed",Space,Str "by",Space,Str "two",Space,Str "consecutive",Space,Str "blank",Space,Str "lines."]]]
+,BulletList
+ [[Plain [Str "The",Space,Str "list",Space,Str "can",Space,Str "be",Space,Str "indented",Space,Str "on",Space,Str "the",Space,Str "source",Space,Str "document."]]
+ ,[Plain [Str "You",Space,Str "can",Space,Str "use",Space,Str "any",Space,Str "number",Space,Str "of",Space,Str "spaces."]]
+ ,[Plain [Str "The",Space,Str "result",Space,Str "will",Space,Str "be",Space,Str "the",Space,Str "same."]]]
+,BulletList
+ [[Para [Str "Let",Space,Str "one",Space,Str "blank",Space,Str "line",Space,Str "between",Space,Str "the",Space,Str "list",Space,Str "items."]]
+ ,[Para [Str "It",Space,Str "will",Space,Str "be",Space,Str "maintained",Space,Str "on",Space,Str "the",Space,Str "conversion."]]
+ ,[Para [Str "Some",Space,Str "targets",Space,Str "don't",Space,Str "support",Space,Str "this",Space,Str "behavior."]]
+ ,[Para [Str "This",Space,Str "one",Space,Str "was",Space,Str "separated",Space,Str "by",Space,Str "a",Space,Str "line",Space,Str "with",Space,Str "blanks.",SoftBreak,Str "You",Space,Str "can",Space,Str "also",Space,Str "put",Space,Str "a",Space,Str "blank",Space,Str "line",Space,Str "inside"]
+ ,Para [Str "the",Space,Str "item",Space,Str "contents",Space,Str "and",Space,Str "it",Space,Str "will",Space,Str "be",Space,Str "preserved."]]]
+,Para [Str "-This",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "list",Space,Str "(no",Space,Str "space)"]
+,Para [Str "-",Space,Str "This",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "list",Space,Str "(more",Space,Str "than",Space,Str "one",Space,Str "space)"]
+,Para [Str "-",Space,Str "This",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "list",Space,Str "(a",Space,Str "TAB",Space,Str "instead",Space,Str "the",Space,Str "space)"]
+,BulletList
+ [[BulletList
+ [[Plain [Str "This",Space,Str "is",Space,Str "a",Space,Str "list"]]]]
+ ,[OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "This",Space,Str "is",Space,Str "a",Space,Str "list"]]]]
+ ,[DefinitionList
+ [([Str "This",Space,Str "is",Space,Str "a",Space,Str "list"],
+ [[]])]]]
+,BulletList
+ [[Plain [Str "This",Space,Str "is",Space,Str "the",Space,Str "\"mother\"",Space,Str "list",Space,Str "first",Space,Str "item."]]
+ ,[Plain [Str "Here",Space,Str "is",Space,Str "the",Space,Str "second,",Space,Str "but",Space,Str "inside",Space,Str "this",Space,Str "item,"]
+ ,BulletList
+ [[Plain [Str "there",Space,Str "is",Space,Str "a",Space,Str "sublist,",Space,Str "with",Space,Str "its",Space,Str "own",Space,Str "items."]]
+ ,[Plain [Str "Note",Space,Str "that",Space,Str "the",Space,Str "items",Space,Str "of",Space,Str "the",Space,Str "same",Space,Str "sublist"]]
+ ,[Plain [Str "must",Space,Str "have",Space,Str "the",Space,Str "same",Space,Str "indentation."]
+ ,BulletList
+ [[Plain [Str "And",Space,Str "this",Space,Str "can",Space,Str "go",Space,Str "on,",Space,Str "opening",Space,Str "sublists."]
+ ,BulletList
+ [[Plain [Str "Just",Space,Str "add",Space,Str "leading",Space,Str "spaces",Space,Str "before",Space,Str "the"]]
+ ,[Plain [Str "hyphen",Space,Str "and",Space,Str "sublists",Space,Str "will",Space,Str "be",Space,Str "opened."]]
+ ,[Plain [Str "The",Space,Str "two",Space,Str "blank",Space,Str "lines",Space,Str "closes",Space,Str "them",Space,Str "all."]]]]]]]]]
+,BulletList
+ [[Plain [Str "When",Space,Str "nesting",Space,Str "lists,",Space,Str "the",Space,Str "additional",Space,Str "spaces",Space,Str "are",Space,Str "free."]]
+ ,[Plain [Str "You",Space,Str "can",Space,Str "add",Space,Str "just",Space,Str "one,"]
+ ,BulletList
+ [[Plain [Str "or",Space,Str "many."]
+ ,BulletList
+ [[Plain [Str "What",Space,Str "matters",Space,Str "is",Space,Str "to",Space,Str "put",Space,Str "more",Space,Str "than",Space,Str "the",Space,Str "previous."]]
+ ,[Plain [Str "But",Space,Str "remember",Space,Str "that",Space,Str "the",Space,Str "other",Space,Str "items",Space,Str "of",Space,Str "the",Space,Str "same",Space,Str "list"]]
+ ,[Plain [Str "must",Space,Str "use",Space,Str "the",Space,Str "same",Space,Str "indentation."]]]]]]]
+,BulletList
+ [[Plain [Str "There",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "depth",Space,Str "limit,"]
+ ,BulletList
+ [[Plain [Str "you",Space,Str "can",Space,Str "go",Space,Str "deeper",Space,Str "and",Space,Str "deeper."]
+ ,BulletList
+ [[Plain [Str "But",Space,Str "some",Space,Str "targets",Space,Str "may",Space,Str "have",Space,Str "restrictions."]
+ ,BulletList
+ [[Plain [Str "The",Space,Str "LaTeX",Space,Str "maximum",Space,Str "is",Space,Str "here,",Space,Str "4",Space,Str "levels."]]]]]]]]]
+,BulletList
+ [[Plain [Str "Reverse",Space,Str "nesting",Space,Str "doesn't",Space,Str "work."]]
+ ,[Plain [Str "Because",Space,Str "a",Space,Str "sublist",Space,Str "*must*",Space,Str "have",Space,Str "a",Space,Str "mother",Space,Str "list."]]
+ ,[Plain [Str "It's",Space,Str "the",Space,Str "list",Space,Str "concept,",Space,Str "not",Space,Str "a",Space,Str "txt2tags",Space,Str "limitation."]]
+ ,[Plain [Str "All",Space,Str "this",Space,Str "sublists",Space,Str "will",Space,Str "be",Space,Str "bumped",Space,Str "to",Space,Str "mother",Space,Str "lists."]]
+ ,[Plain [Str "At",Space,Str "level",Space,Str "1,",Space,Str "like",Space,Str "this",Space,Str "one."]]]
+,BulletList
+ [[Plain [Str "Level",Space,Str "1"]
+ ,BulletList
+ [[Plain [Str "Level",Space,Str "2"]
+ ,BulletList
+ [[Plain [Str "Level",Space,Str "3"]
+ ,BulletList
+ [[Plain [Str "Level",Space,Str "4"]]]]
+ ,[Plain [Str "Level",Space,Str "3",Space,Str "--",Space,Str "(closed",Space,Str "Level",Space,Str "4)"]]]]
+ ,[Plain [Str "Level",Space,Str "2",Space,Str "--",Space,Str "(closed",Space,Str "Level",Space,Str "3)"]]]]
+ ,[Plain [Str "Level",Space,Str "1",Space,Str "--",Space,Str "(closed",Space,Str "Level",Space,Str "2)"]]]
+,BulletList
+ [[Plain [Str "Level",Space,Str "1"]
+ ,BulletList
+ [[Plain [Str "Level",Space,Str "2"]
+ ,BulletList
+ [[Plain [Str "Level",Space,Str "3"]
+ ,BulletList
+ [[Plain [Str "Level",Space,Str "4"]]]]]]]]
+ ,[Plain [Str "Level",Space,Str "1",Space,Str "--",Space,Str "(closed",Space,Str "Level",Space,Str "4,",Space,Str "Level",Space,Str "3",Space,Str "and",Space,Str "Level",Space,Str "2)"]]]
+,BulletList
+ [[Para [Str "Level",Space,Str "1"]
+ ,BulletList
+ [[Para [Str "Level",Space,Str "2",Space,Str "--",Space,Str "blank",Space,Str "BEFORE",Space,Str "and",Space,Str "AFTER",Space,Str "(in)"]
+ ,BulletList
+ [[Plain [Str "Level",Space,Str "3"]]]]]]]
+,BulletList
+ [[Plain [Str "Level",Space,Str "4"]]]
+,BulletList
+ [[Para [Str "Level",Space,Str "3"]]
+ ,[Para [Str "Level",Space,Str "2",Space,Str "--",Space,Str "blank",Space,Str "BEFORE",Space,Str "and",Space,Str "AFTER",Space,Str "(out)"]]
+ ,[Para [Str "Level",Space,Str "1"]
+ ,BulletList
+ [[Para [Str "Level",Space,Str "2",Space,Str "--",Space,Str "blank",Space,Str "BEFORE",Space,Str "(spaces)",Space,Str "and",Space,Str "AFTER",Space,Str "(TAB)"]
+ ,BulletList
+ [[Plain [Str "Level",Space,Str "3"]]]]]]]
+,BulletList
+ [[Plain [Str "Level",Space,Str "1"]
+ ,BulletList
+ [[Plain [Str "Level",Space,Str "2"]
+ ,BulletList
+ [[Plain [Str "Level",Space,Str "3"]
+ ,BulletList
+ [[Plain [Str "Level",Space,Str "4"]]
+ ,[Plain [Str "Level",Space,Str "3.5",Space,Str "???"]]]]
+ ,[Plain [Str "Level",Space,Str "3"]]
+ ,[Plain [Str "Level",Space,Str "2.5",Space,Str "???"]]]]
+ ,[Plain [Str "Level",Space,Str "2"]]
+ ,[Plain [Str "Level",Space,Str "1.5",Space,Str "???"]]]]
+ ,[Plain [Str "Level",Space,Str "1"]]]
+,BulletList
+ [[Plain [Str "This",Space,Str "list",Space,Str "is",Space,Str "closed",Space,Str "by",Space,Str "a",Space,Str "line",Space,Str "with",Space,Str "spaces",Space,Str "and",Space,Str "other",Space,Str "with",Space,Str "TABs"]]]
+,BulletList
+ [[Plain [Str "This",Space,Str "list",Space,Str "is",Space,Str "NOT",Space,Str "closed",Space,Str "by",Space,Str "two",Space,Str "comment",Space,Str "lines"]]]
+,BulletList
+ [[Plain [Str "This",Space,Str "list",Space,Str "is",Space,Str "closed",Space,Str "by",Space,Str "a",Space,Str "line",Space,Str "with",Space,Str "spaces",Space,Str "and",Space,Str "TAB,"]]
+ ,[Plain [Str "then",Space,Str "a",Space,Str "comment",Space,Str "line,",Space,Str "then",Space,Str "an",Space,Str "empty",Space,Str "line."]]]
+,BulletList
+ [[Plain [Str "Level",Space,Str "1"]
+ ,BulletList
+ [[Plain [Str "Level",Space,Str "2"]
+ ,BulletList
+ [[Plain [Str "Level",Space,Str "3"]]]
+ ,Plain [Str "-",SoftBreak,Str "Level",Space,Str "2"]]]
+ ,Plain [Str "-",SoftBreak,Str "Level",Space,Str "1"]]]
+,Para [Str "-"]
+,BulletList
+ [[Plain [Str "Empty",Space,Str "item",Space,Str "with",Space,Str "trailing",Space,Str "spaces."]]]
+,Para [Str "-"]
+,BulletList
+ [[Plain [Str "Empty",Space,Str "item",Space,Str "with",Space,Str "trailing",Space,Str "TAB."]]]
+,Para [Str "-"]
+,BulletList
+ [[Plain [Str "If",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "file",Space,Str "(EOF)",Space,Str "is",Space,Str "hit,"]
+ ,BulletList
+ [[Plain [Str "all",Space,Str "the",Space,Str "currently",Space,Str "opened",Space,Str "list",Space,Str "are",Space,Str "closed,"]
+ ,BulletList
+ [[Plain [Str "just",Space,Str "like",Space,Str "when",Space,Str "using",Space,Str "the",Space,Str "two",Space,Str "blank",Space,Str "lines."]]]]]]]
+,Header 1 ("table",[],[]) [Str "Table"]
+,Table [] [AlignRight] [0.0]
+ []
+ [[[Plain [Str "Cell",Space,Str "1"]]]]
+,Table [] [AlignCenter,AlignCenter,AlignRight] [0.0,0.0,0.0]
+ []
+ [[[Plain [Str "Cell",Space,Str "1"]]
+ ,[Plain [Str "Cell",Space,Str "2"]]
+ ,[Plain [Str "Cell",Space,Str "3"]]]]
+,Table [] [AlignCenter,AlignCenter,AlignCenter] [0.0,0.0,0.0]
+ []
+ [[[Plain [Str "Cell",Space,Str "1"]]
+ ,[Plain [Str "Cell",Space,Str "2"]]
+ ,[Plain [Str "Cell",Space,Str "3"]]]]
+,Para [Str "||",Space,Str "Cell",Space,Str "1",Space,Str "|",Space,Str "Cell",Space,Str "2",Space,Str "|",Space,Str "Cell",Space,Str "3",Space,Str "|"]
+,Table [] [AlignCenter,AlignCenter,AlignCenter] [0.0,0.0,0.0]
+ []
+ [[[Plain [Str "Cell",Space,Str "1"]]
+ ,[Plain [Str "Cell",Space,Str "2"]]
+ ,[Plain [Str "Cell",Space,Str "3"]]]]
+,Table [] [AlignDefault,AlignCenter,AlignDefault] [0.0,0.0,0.0]
+ [[Plain [Str "Heading"]]
+ ,[Plain [Str "Heading"]]
+ ,[Plain [Str "Heading"]]]
+ [[[Plain [Str "<-"]]
+ ,[Plain [Str "--"]]
+ ,[Plain [Str "->"]]]
+ ,[[Plain [Str "--"]]
+ ,[Plain [Str "--"]]
+ ,[Plain [Str "--"]]]
+ ,[[Plain [Str "->"]]
+ ,[Plain [Str "--"]]
+ ,[Plain [Str "<-"]]]]
+,Table [] [AlignDefault,AlignDefault,AlignCenter,AlignCenter] [0.0,0.0,0.0,0.0]
+ [[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3+4"]]
+ ,[]]
+ [[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]
+ ,[Plain [Str "4"]]]
+ ,[[Plain [Str "1+2+3"]]
+ ,[Plain [Str "4"]]
+ ,[]
+ ,[]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "2+3"]]
+ ,[Plain [Str "4"]]
+ ,[]]
+ ,[[Plain [Str "1+2+3+4"]]
+ ,[]
+ ,[]
+ ,[]]]
+,Table [] [AlignCenter,AlignCenter,AlignCenter,AlignCenter] [0.0,0.0,0.0,0.0]
+ []
+ [[[Plain [Str "0"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[]]
+ ,[[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[]
+ ,[Plain [Str "7"]]]
+ ,[[Plain [Str "8"]]
+ ,[]
+ ,[Plain [Str "A"]]
+ ,[Plain [Str "B"]]]
+ ,[[]
+ ,[Plain [Str "D"]]
+ ,[Plain [Str "E"]]
+ ,[Plain [Str "F"]]]]
+,Table [] [AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter] [0.0,0.0,0.0,0.0,0.0]
+ []
+ [[[Plain [Str "1"]]
+ ,[]
+ ,[]
+ ,[]
+ ,[]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[]
+ ,[]
+ ,[]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]
+ ,[]
+ ,[]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]
+ ,[Plain [Str "4"]]
+ ,[]]
+ ,[[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]
+ ,[Plain [Str "4"]]
+ ,[Plain [Str "5"]]]]
+,Table [] [AlignDefault,AlignCenter,AlignCenter,AlignCenter,AlignCenter] [0.0,0.0,0.0,0.0,0.0]
+ []
+ [[[Plain [Str "Jan"]]
+ ,[]
+ ,[]
+ ,[]
+ ,[]]
+ ,[[Plain [Str "Fev"]]
+ ,[]
+ ,[]
+ ,[]
+ ,[]]
+ ,[[Plain [Str "Mar"]]
+ ,[]
+ ,[]
+ ,[]
+ ,[]]
+ ,[[Plain [Str "Apr"]]
+ ,[]
+ ,[]
+ ,[]
+ ,[]]
+ ,[[Plain [Str "May"]]
+ ,[]
+ ,[]
+ ,[]
+ ,[]]
+ ,[[Plain [Str "20%"]]
+ ,[Plain [Str "40%"]]
+ ,[Plain [Str "60%"]]
+ ,[Plain [Str "80%"]]
+ ,[Plain [Str "100%"]]]]
+,Table [] [AlignCenter,AlignDefault,AlignDefault,AlignCenter,AlignCenter] [0.0,0.0,0.0,0.0,0.0]
+ []
+ [[[]
+ ,[]
+ ,[Plain [Str "/"]]
+ ,[]
+ ,[]]
+ ,[[]
+ ,[Plain [Str "/",Space,Str "/",Space,Str "/",Space,Str "/",Space,Str "/"]]
+ ,[]
+ ,[]
+ ,[]]
+ ,[[Plain [Str "/",Space,Str "/",Space,Str "/",Space,Str "/",Space,Str "/",Space,Str "/",Space,Str "/",Space,Str "/",Space,Str "/"]]
+ ,[]
+ ,[]
+ ,[]
+ ,[]]
+ ,[[]
+ ,[Plain [Str "o"]]
+ ,[]
+ ,[Plain [Str "o"]]
+ ,[]]
+ ,[[]
+ ,[]
+ ,[Plain [Str "."]]
+ ,[]
+ ,[]]
+ ,[[]
+ ,[Plain [Str "=",Space,Str "=",Space,Str "=",Space,Str "="]]
+ ,[]
+ ,[]
+ ,[]]]
+,Table [] [AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter] [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
+ []
+ [[[Plain [Str "01"]]
+ ,[Plain [Str "02"]]
+ ,[]
+ ,[]
+ ,[Plain [Str "05"]]
+ ,[]
+ ,[Plain [Str "07"]]
+ ,[]]
+ ,[[]
+ ,[]
+ ,[Plain [Str "11"]]
+ ,[]
+ ,[Plain [Str "13"]]
+ ,[]
+ ,[]
+ ,[Plain [Str "16"]]]
+ ,[[Plain [Str "17"]]
+ ,[]
+ ,[Plain [Str "19"]]
+ ,[Plain [Str "20"]]
+ ,[]
+ ,[]
+ ,[Plain [Str "23"]]
+ ,[]]
+ ,[[Plain [Str "25"]]
+ ,[Plain [Str "26"]]
+ ,[]
+ ,[]
+ ,[Plain [Str "29"]]
+ ,[Plain [Str "30"]]
+ ,[]
+ ,[Plain [Str "32"]]]
+ ,[[]
+ ,[]
+ ,[Plain [Str "35"]]
+ ,[]
+ ,[Plain [Str "37"]]
+ ,[]
+ ,[Plain [Str "39"]]
+ ,[Plain [Str "40"]]]]
+,Table [] [AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter,AlignCenter] [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
+ []
+ [[[Plain [Str "0"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]
+ ,[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]
+ ,[Plain [Str "7"]]
+ ,[Plain [Str "8"]]
+ ,[Plain [Str "9"]]
+ ,[Plain [Str "A"]]
+ ,[Plain [Str "B"]]
+ ,[Plain [Str "C"]]
+ ,[Plain [Str "D"]]
+ ,[Plain [Str "E"]]
+ ,[Plain [Str "F"]]
+ ,[Plain [Str "0"]]
+ ,[Plain [Str "1"]]
+ ,[Plain [Str "2"]]
+ ,[Plain [Str "3"]]
+ ,[Plain [Str "4"]]
+ ,[Plain [Str "5"]]
+ ,[Plain [Str "6"]]
+ ,[Plain [Str "7"]]
+ ,[Plain [Str "8"]]
+ ,[Plain [Str "9"]]
+ ,[Plain [Str "A"]]
+ ,[Plain [Str "B"]]
+ ,[Plain [Str "C"]]
+ ,[Plain [Str "D"]]
+ ,[Plain [Str "E"]]
+ ,[Plain [Str "F"]]]]
+,Table [] [AlignCenter] [0.0]
+ []
+ [[[]]
+ ,[[]]
+ ,[[]]]
+,Para [Str "|this|is|not|a|table|"]
+,Para [Str "|this|",Space,Str "is|",Space,Str "not|",Space,Str "a|",Space,Str "table|"]
+,Para [Str "|this",Space,Str "|is",Space,Str "|not",Space,Str "|a",Space,Str "|table",Space,Str "|"]
+,Para [Str "|",Space,Str "this\t|",Space,Str "is\t|",Space,Str "not\t|",Space,Str "a\t|",Space,Str "table\t|"]
+,HorizontalRule
+,Para [Str "The",Space,Str "End."]]
diff --git a/test/txt2tags.t2t b/test/txt2tags.t2t
new file mode 100644
index 000000000..d374b7a85
--- /dev/null
+++ b/test/txt2tags.t2t
@@ -0,0 +1,797 @@
+Txt2tags Markup Rules
+author
+date
+%!includeconf: rules.conf
+
+This document describes all the details about each txt2tags mark.
+The target audience are **experienced** users. You may find it
+useful if you want to master the marks or solve a specific problem
+about a mark.
+
+If you are new to txt2tags or just want to know which are the
+available marks, please read the [Markup Demo MARKUPDEMO].
+
+Note 1: This document is generated directly from the txt2tags
+test-suite. All the rules mentioned here are 100% in sync with the
+current program code.
+
+Note 2: A good practice is to consult [the sources rules.t2t] when
+reading, to see how the texts were made.
+
+Table of Contents:
+
+%%TOC
+
+-------------------------------------------------------------
+
+= Paragraph =[paragraph]
+
+%INCLUDED(t2t) starts here: ../../../test/marks/paragraph.t2t
+
+
+%%% Syntax: Lines grouped together
+A paragraph is composed by one or more lines.
+A blank line (or a table, or a list) ends the
+current paragraph.
+
+%%% Syntax: Leading and trailing spaces are ignored
+ Leading and trailing spaces are ignored.
+
+%%% Syntax: A comment don't close a paragraph
+A comment line can be placed inside a paragraph.
+% this comment will be ignored
+It will not affect it.
+
+%%% Closing: EOF closes the open paragraph
+The end of the file (EOF) closes the
+currently open paragraph.
+
+= Comment =[comment]
+
+%INCLUDED(t2t) starts here: ../../../test/marks/comment.t2t
+
+
+%%% Syntax: The % character at the line beginning (column 1)
+%glued with the % mark
+% separated from the % mark
+% very distant from the % mark
+%%%%%%% lots of % marks
+% a blank comment, used for vertical spacing:
+%
+% NOTE: what matters is the first % being at the line beginning,
+% the rest of the line is just ignored.
+
+%%% Syntax: Area (block)
+%%%
+You're not seeing this.
+%%%
+
+%%% Syntax: Area (block) with trailing spaces
+%%%
+You're not seeing this.
+%%%
+
+%%% Invalid: The % in any other position
+ % not on the line beginning (at column 2)
+
+some text % half line comments are not allowed
+
+
+= Line =[line]
+
+%INCLUDED(t2t) starts here: ../../../test/marks/line.t2t
+
+
+%%% Syntax: At least 20 chars of - = _
+--------------------
+====================
+____________________
+%%% Syntax: Any kind of mixing is allowed
+%% Free mixing is allowed to make the line,
+%% but the first char is the identifier for
+%% the difference between separator ( - _ )
+%% and strong ( = ) lines.
+=========-----------
+-_-_-_-_-_-_-_-_-_-_
+=-=-=-=-=-=-=-=-=-=-
+=------------------=
+--------====--------
+%%% Syntax: Leading and/or trailing spaces are allowed
+ --------------------
+--------------------
+ --------------------
+%%% Invalid: Less than 20 chars (but strike matches)
+---------
+%%% Invalid: Strange chars (but strike matches)
+--------- ----------
+
+---------+----------
+
+( -------------------- )
+
+= Inline =[inline]
+
+%INCLUDED(t2t) starts here: ../../../test/marks/inline.t2t
+
+
+%%% Syntax: Marks are greedy and must be "glued" with contents
+%% GLUED: The contents must be glued with the marks, no spaces
+%% between them. Right after the opening mark there must be a
+%% non-blank character, as well as right before the closing mark.
+%%
+%% GREEDY: If the contents boundary character is the same as
+%% the mark character, it is considered contents, not mark.
+%% So ""****bold****"" turns to ""<B>**bold**</B>"" in HTML.
+
+i) **b** //i// __u__ --s-- ``m`` ""r"" ''t''
+i) **bo** //it// __un__ --st-- ``mo`` ""ra"" ''tg''
+i) **bold** //ital// __undr__ --strk-- ``mono`` ""raw"" ''tggd''
+i) **bo ld** //it al// __un dr__ --st rk-- ``mo no`` ""r aw"" ''tg gd''
+i) **bo * ld** //it / al// __un _ dr__ --st - rk-- ``mo ` no`` ""r " aw"" ''tg ' gd''
+i) **bo **ld** //it //al// __un __dr__ --st --rk-- ``mo ``no`` ""r ""aw"" ''tg ''gd''
+i) **bo ** ld** //it // al// __un __ dr__ --st -- rk-- ``mo `` no`` ""r "" aw"" ''tg '' gd''
+i) ****bold**** ////ital//// ____undr____ ----strk---- ````mono```` """"raw"""" ''''tggd''''
+i) ***bold*** ///ital/// ___undr___ ---strk--- ```mono``` """raw""" '''tggd'''
+
+%%% Syntax: Repetition is greedy
+%% When the mark character is repeated many times,
+%% the contents are expanded to the largest possible.
+%% Thats why they are greedy, the outer marks are
+%% the ones used.
+
+i) ***** ///// _____ ----- ````` """"" '''''
+i) ****** ////// ______ ------ `````` """""" ''''''
+i) ******* /////// _______ ------- ``````` """"""" '''''''
+i) ******** //////// ________ -------- ```````` """""""" ''''''''
+i) ********* ///////// _________ --------- ````````` """"""""" '''''''''
+i) ********** ////////// __________ ---------- `````````` """""""""" ''''''''''
+
+%%% Invalid: No contents
+
+i) **** //// ____ ---- ```` """" ''''
+i) ** ** // // __ __ -- -- `` `` "" "" '' ''
+
+%%% Invalid: Contents not "glued" with marks
+%% Spaces between the marks and the contents in any side
+%% invalidate the mark.
+
+i) ** bold** // ital// __ undr__ -- strk-- `` mono`` "" raw"" '' tggd''
+i) **bold ** //ital // __undr __ --strk -- ``mono `` ""raw "" ''tggd ''
+i) ** bold ** // ital // __ undr __ -- strk -- `` mono `` "" raw "" '' tggd ''
+
+= Link =[link]
+
+%INCLUDED(t2t) starts here: ../../../test/marks/link.t2t
+
+
+%%% Syntax: E-mail
+user@domain.com
+user@domain.com.
+user@domain.com. any text.
+any text: user@domain.com. any text.
+[label user@domain.com]
+%%% Syntax: E-mail with form data
+user@domain.com?subject=bla
+user@domain.com?subject=bla.
+user@domain.com?subject=bla,
+user@domain.com?subject=bla&cc=otheruser@domain.com
+user@domain.com?subject=bla&cc=otheruser@domain.com.
+user@domain.com?subject=bla&cc=otheruser@domain.com,
+[label user@domain.com?subject=bla&cc=otheruser@domain.com].
+[label user@domain.com?subject=bla&cc=otheruser@domain.com.].
+%%% Syntax: URL
+http://www.domain.com
+http://www.domain.com/dir/
+http://www.domain.com/dir///
+http://www.domain.com.
+http://www.domain.com,
+http://www.domain.com. any text.
+http://www.domain.com, any text.
+http://www.domain.com/dir/. any text.
+any text: http://www.domain.com. any text.
+any text: http://www.domain.com/dir/. any text.
+any text: http://www.domain.com/dir/index.html. any text.
+any text: http://www.domain.com/dir/index.html, any text.
+%%% Syntax: URL with anchor
+http://www.domain.com/dir/#anchor
+http://www.domain.com/dir/index.html#anchor
+http://www.domain.com/dir/index.html#anchor.
+http://www.domain.com/dir/#anchor. any text.
+http://www.domain.com/dir/index.html#anchor. any text.
+any text: http://www.domain.com/dir/#anchor. any text.
+any text: http://www.domain.com/dir/index.html#anchor. any text.
+%%% Syntax: URL with form data
+http://domain.com?a=a@a.a&b=a+b+c.
+http://domain.com?a=a@a.a&b=a+b+c,
+http://domain.com/bla.cgi?a=a@a.a&b=a+b+c.
+http://domain.com/bla.cgi?a=a@a.a&b=a+b+c@.
+%%% Syntax: URL with form data and anchor
+http://domain.com?a=a@a.a&b=a+b+c.#anchor
+http://domain.com/bla.cgi?a=a@a.a&b=a+b+c.#anchor
+http://domain.com/bla.cgi?a=a@a.a&b=a+b+c@.#anchor
+%%% Syntax: URL with login data
+http://user:password@domain.com/bla.html.
+http://user:password@domain.com/dir/.
+http://user:password@domain.com.
+http://user:@domain.com.
+http://user@domain.com.
+%%% Syntax: URL with login, form and anchor
+http://user:password@domain.com/bla.cgi?a=a@a.a&b=a+b+c.#anchor
+http://user:password@domain.com/bla.cgi?a=a@a.a&b=a+b+c@#anchor
+%%% Syntax: URL with label
+[label www.domain.com]
+%%% Syntax: URL with label (trailing spaces are discarded, leading are maintained)
+%TODO normalize this behavior
+[ label www.domain.com]
+[label www.domain.com]
+%%% Syntax: URL with label, stressing
+[anchor http://www.domain.com/dir/index.html#anchor.]
+[login http://user:password@domain.com/bla.html]
+[form http://www.domain.com/bla.cgi?a=a@a.a&b=a+b+c.]
+[form & anchor http://www.domain.com/bla.cgi?a=a@a.a&b=a+b+c.#anchor]
+[login & form http://user:password@domain.com/bla.cgi?a=a@a.a&b=a+b+c.]
+%%% Syntax: Link with label for local files
+[local link up ..]
+[local link file bla.html]
+[local link anchor #anchor]
+[local link file/anchor bla.html#anchor]
+[local link file/anchor bla.html#anchor.]
+[local link img abc.gif]
+%%% Syntax: Another link as a label
+[www.fake.com www.domain.com]
+%%% Syntax: URL with funny chars
+http://domain.com:8080/~user/_st-r@a=n$g,e/index%20new.htm
+http://domain.com:8080/~user/_st-r@a=n$g,e/index%20new.htm?a=/%22&b=+.@*_-
+http://domain.com:8080/~user/_st-r@a=n$g,e/index%20new.htm?a=/%22&b=+.@*_-#anchor_-1%.
+http://foo._user-9:pass!#$%&*()+word@domain.com:8080/~user/_st-r@a=n$g,e/index%20new.htm?a=/%22&b=+.@*_-#anchor_-1%.
+%%% Test: Various per line
+http://L1.com ! L2@www.com ! [L3 www.com] ! [L4 w@ww.com] ! www.L5.com
+%%% Feature: Guessed link, adding protocol automatically
+www.domain.com
+www2.domain.com
+ftp.domain.com
+WWW.DOMAIN.COM
+FTP.DOMAIN.COM
+[label www.domain.com]
+[label ftp.domain.com]
+[label WWW.DOMAIN.COM]
+[label FTP.DOMAIN.COM]
+%%% Invalid: Trailing space on link
+[label www.domain.com ]
+%%% Invalid: Label with ] char (use postproc)
+[label] www.domain.com]
+
+= Image =[image]
+
+%INCLUDED(t2t) starts here: ../../../test/marks/image.t2t
+
+
+%%% Syntax: Image name inside brackets: [img]
+[img.png]
+
+%%% Syntax: Image pointing to a link: [[img] link]
+[[img.png] http://txt2tags.org]
+
+%%% Align: Image position is preserved when inside paragraph
+[img.png] Image at the line beginning.
+
+Image in the middle [img.png] of the line.
+
+Image at the line end. [img.png]
+
+%%% Align: Image alone with spaces around is aligned
+[img.png]
+ [img.png]
+ [img.png]
+
+%%% Test: Two glued images with no spaces (left & right)
+[img.png][img.png]
+
+%%% Test: Various per line
+Images [img.png] mixed [img.png] with [img.png] text.
+
+Images glued together: [img.png][img.png][img.png].
+
+%%% Invalid: Spaces inside are not allowed
+[img.png ]
+
+[ img.png]
+
+[ img.png ]
+
+% Ignored as they change every time when run
+
+= Numbered Title =[numtitle]
+
+%%% Syntax: Balanced equal signs (from 1 to 5)
++ Title Level 1 +
+++ Title Level 2 ++
++++ Title Level 3 +++
+++++ Title Level 4 ++++
++++++ Title Level 5 +++++
+%%% Label: Between brackets, alphanumeric [A-Za-z0-9_-]
++ Title Level 1 +[lab_el-1]
+++ Title Level 2 ++[lab_el-2]
++++ Title Level 3 +++[lab_el-3]
+++++ Title Level 4 ++++[lab_el-4]
++++++ Title Level 5 +++++[lab_el-5]
+%%% Syntax: Spaces around and/or inside are allowed (and ignored)
+ +++Title Level 3+++
+ +++ Title Level 3 +++
+ +++ Title Level 3 +++
++++ Title Level 3 +++
++++ Title Level 3 +++
+ +++ Title Level 3 +++[lab_el-9]
+%%% Invalid: Unbalanced equal signs
+ +Not Title
+
+ ++Not Title+
+
+ +++Not Title++++
+%%% Invalid: Level deeper than 5
+ ++++++Not Title 6++++++
+
++++++++Not Title 7+++++++
+%%% Invalid: Space between title and label
++Not Title+ [label1]
+%%% Invalid: Space inside label
++Not Title+[ label ]
+%%% Invalid: Strange chars inside label
++Not Title+[la/bel]
+
+= Title =[title]
+
+%INCLUDED(t2t) starts here: ../../../test/marks/title.t2t
+
+
+%%% Syntax: Balanced equal signs (from 1 to 5)
+= Title Level 1 =
+== Title Level 2 ==
+=== Title Level 3 ===
+==== Title Level 4 ====
+===== Title Level 5 =====
+%%% Label: Between brackets, alphanumeric [A-Za-z0-9_-]
+= Title Level 1 =[lab_el-1]
+== Title Level 2 ==[lab_el-2]
+=== Title Level 3 ===[lab_el-3]
+==== Title Level 4 ====[lab_el-4]
+===== Title Level 5 =====[lab_el-5]
+%%% Syntax: Spaces around and/or inside are allowed (and ignored)
+ ===Title Level 3===
+ === Title Level 3 ===
+ === Title Level 3 ===
+=== Title Level 3 ===
+=== Title Level 3 ===
+ === Title Level 3 ===[lab_el-9]
+%%% Invalid: Unbalanced equal signs
+ =Not Title
+
+ ==Not Title=
+
+ ===Not Title====
+%%% Invalid: Level deeper than 5
+ ======Not Title 6======
+
+=======Not Title 7=======
+%%% Invalid: Space between title and label
+=Not Title= [label1]
+%%% Invalid: Space inside label
+=Not Title=[ label ]
+%%% Invalid: Strange chars inside label
+=Not Title=[la/bel]
+
+= Quote =[quote]
+
+%INCLUDED(t2t) starts here: ../../../test/marks/quote.t2t
+
+
+ To quote a paragraph, just prefix it by a TAB
+ character. All the lines of the paragraph must
+ begin with a TAB.
+Any non-tabbed line closes the quote block.
+
+%%% Nesting: Creating deeper quotes
+ The number of leading TABs identifies the quote
+ block depth. This is quote level 1.
+ With two TABs, we are on the quote
+ level 2.
+ The more TABs, more deep is
+ the quote level.
+ There isn't a limit.
+
+%%% Nesting: Reverse nesting works
+ This quote starts at
+ level 4.
+ Then its depth is decreased.
+ Counting down, one by one.
+ Until the level 1.
+
+%%% Nesting: Random count
+ Unlike lists, any quote block is
+ independent, not part of a tree.
+ The TAB count don't need to be incremental
+ by one.
+ The nesting don't need
+ to follow any rule.
+ Quotes can be opened and closed
+ in any way.
+ You choose.
+
+%%% Nesting: When not supported
+ Some targets (as sgml) don't support the
+ nesting of quotes. There is only one quote
+ level.
+ In this case, no matter how much
+ TABs are used to define the quote
+ block, it always will be level 1.
+
+%%% Syntax: Spaces after TAB
+ Spaces AFTER the TAB character are allowed.
+ But be careful, it can be confusing.
+
+%%% Invalid: Spaces before TAB
+ Spaces BEFORE the TAB character
+ invalidate the mark. It's not quote.
+
+%%% Invalid: Paragraphs inside
+ Paragraph breaks inside a quote aren't
+ possible.
+
+ This sample are two separated quoted
+ paragraphs, not a quote block with
+ two paragraphs inside.
+
+%%% Closing: EOF closes the open block
+ The end of the file (EOF) closes the
+ currently open quote block.
+
+= Raw =[raw]
+
+%%% Syntax: A single line
+""" A raw line.
+
+%%% Syntax: A single line with leading spaces
+""" Another raw line, with leading spaces.
+
+%%% Syntax: Area (block)
+"""
+A raw area delimited
+ by lines with marks.
+"""
+
+%%% Syntax: Area (block) with trailing spaces
+"""
+Trailing spaces and TABs after the area marks
+are allowed, but not encouraged nor documented.
+"""
+
+%%% Invalid: No space between mark and contents
+"""Not a raw line, need one space after mark.
+
+%%% Invalid: Leading spaces on block marks
+ """
+ Not a raw area.
+ The marks must be at the line beginning,
+ no leading spaces.
+ """
+
+%%% Closing: EOF closes the open block
+"""
+The end of the file (EOF) closes
+the currently open raw area.
+"""
+
+= Verbatim =[verbatim]
+
+%INCLUDED(t2t) starts here: ../../../test/marks/verbatim.t2t
+
+
+%%% Syntax: A single line
+``` A verbatim line.
+
+%%% Syntax: A single line with leading spaces
+``` Another verbatim line, with leading spaces.
+
+%%% Syntax: Area (block)
+```
+A verbatim area delimited
+ by lines with marks.
+```
+
+%%% Syntax: Area (block) with trailing spaces
+```
+Trailing spaces and TABs after the area marks
+are allowed, but not encouraged nor documented.
+```
+
+%%% Invalid: No space between mark and contents
+```Not a verbatim line, need one space after mark.
+
+%%% Invalid: Leading spaces on block marks
+ ```
+ Not a verbatim area.
+ The marks must be at the line beginning,
+ no leading spaces.
+ ```
+
+%%% Closing: EOF closes the open block
+```
+The end of the file (EOF) closes
+the currently open verbatim area.
+```
+
+= Definition List =[deflist]
+
+: Definition list
+ A list with terms
+: Start term with colon
+ And its definition follows
+
+
+= Numbered List =[numlist]
+
+See [List #list], the same rules apply.
+
+= List =[list]
+
+%INCLUDED(t2t) starts here: ../../../test/marks/list.t2t
+
+
+%%% Items: Prefixed by hyphen
+- Use the hyphen to prefix list items.
+- There must be one space after the hyphen.
+- The list is closed by two consecutive blank lines.
+
+
+%%% Items: Free leading spacing (indentation)
+ - The list can be indented on the source document.
+ - You can use any number of spaces.
+ - The result will be the same.
+
+
+%%% Items: Vertical spacing between items
+- Let one blank line between the list items.
+
+- It will be maintained on the conversion.
+
+- Some targets don't support this behavior.
+
+- This one was separated by a line with blanks.
+ You can also put a blank line inside
+
+ the item contents and it will be preserved.
+
+
+%%% Items: Exactly ONE space after the hyphen
+-This is not a list (no space)
+
+- This is not a list (more than one space)
+
+- This is not a list (a TAB instead the space)
+
+
+%%% Items: Catchy cases
+- - This is a list
+- + This is a list
+- : This is a list
+
+
+%%% Nesting: Creating sublists
+- This is the "mother" list first item.
+- Here is the second, but inside this item,
+ - there is a sublist, with its own items.
+ - Note that the items of the same sublist
+ - must have the same indentation.
+ - And this can go on, opening sublists.
+ - Just add leading spaces before the
+ - hyphen and sublists will be opened.
+ - The two blank lines closes them all.
+
+
+%%% Nesting: Free leading spacing (indentation)
+- When nesting lists, the additional spaces are free.
+ - You can add just one,
+ - or many.
+ - What matters is to put more than the previous.
+ - But remember that the other items of the same list
+ - must use the same indentation.
+
+
+%%% Nesting: Maximum depth
+- There is not a depth limit,
+ - you can go deeper and deeper.
+ - But some targets may have restrictions.
+ - The LaTeX maximum is here, 4 levels.
+
+
+%%% Nesting: Reverse doesn't work
+ - Reverse nesting doesn't work.
+ - Because a sublist *must* have a mother list.
+ - It's the list concept, not a txt2tags limitation.
+ - All this sublists will be bumped to mother lists.
+- At level 1, like this one.
+
+
+%%% Nesting: Going deeper and back
+
+%% When nesting back to an upper level, the previous sublist
+%% is automatically closed.
+- Level 1
+ - Level 2
+ - Level 3
+ - Level 4
+ - Level 3 -- (closed Level 4)
+ - Level 2 -- (closed Level 3)
+- Level 1 -- (closed Level 2)
+
+
+%% More than one list can be closed when nesting back.
+- Level 1
+ - Level 2
+ - Level 3
+ - Level 4
+- Level 1 -- (closed Level 4, Level 3 and Level 2)
+
+
+%%% Nesting: Vertical spacing between lists
+- Level 1
+
+ - Level 2 -- blank BEFORE and AFTER (in)
+
+ - Level 3
+% comment lines are NOT considered blank lines
+ - Level 4
+% comment lines are NOT considered blank lines
+ - Level 3
+
+ - Level 2 -- blank BEFORE and AFTER (out)
+
+- Level 1
+
+ - Level 2 -- blank BEFORE (spaces) and AFTER (TAB)
+
+ - Level 3
+
+
+%%% Nesting: Messing up
+%% Be careful when going back on the nesting,
+%% it must be on a valid level! If not, it will
+%% be bumped up to the previous valid level.
+- Level 1
+ - Level 2
+ - Level 3
+ - Level 4
+ - Level 3.5 ???
+ - Level 3
+ - Level 2.5 ???
+ - Level 2
+ - Level 1.5 ???
+- Level 1
+
+
+%%% Closing: Two (not so) empty lines
+- This list is closed by a line with spaces and other with TABs
+
+
+- This list is NOT closed by two comment lines
+% comment lines are NOT considered blank lines
+% comment lines are NOT considered blank lines
+- This list is closed by a line with spaces and TAB,
+- then a comment line, then an empty line.
+
+% comment lines are NOT considered blank lines
+
+%%% Closing: Empty item closes current (sub)list
+
+%% The two blank lines closes ALL the lists.
+%% To close just the current, use an empty item.
+- Level 1
+ - Level 2
+ - Level 3
+ -
+ Level 2
+ -
+ Level 1
+-
+
+%% The empty item can have trailing blanks.
+- Empty item with trailing spaces.
+-
+
+- Empty item with trailing TAB.
+-
+
+%%% Closing: EOF closes the lists
+- If the end of the file (EOF) is hit,
+ - all the currently opened list are closed,
+ - just like when using the two blank lines.
+
+
+= Table =[table]
+
+%INCLUDED(t2t) starts here: ../../../test/marks/table.t2t
+
+%%% Syntax: Lines starting with a pipe |
+| Cell 1
+
+%%% Syntax: Extra pipes separate cells
+| Cell 1 | Cell 2 | Cell 3
+
+%%% Syntax: With a trailing pipe, make border
+| Cell 1 | Cell 2 | Cell 3 |
+
+%%% Syntax: Table lines starting with double pipe are heading
+|| Cell 1 | Cell 2 | Cell 3 |
+
+%%% Align: Spaces before the leading pipe centralize the table
+ | Cell 1 | Cell 2 | Cell 3 |
+
+%%% Align: Spaces inside the cell denote its alignment
+ || Heading | Heading | Heading |
+% comments don't close an opened table
+ | <- | -- | -> |
+ | -- | -- | -- |
+ | -> | -- | <- |
+
+%%% Span: Column span is defined by extra pipes at cell closing
+ || 1 | 2 | 3+4 ||
+ | 1 | 2 | 3 | 4 |
+ | 1+2+3 ||| 4 |
+ | 1 | 2+3 || 4 |
+ | 1+2+3+4 ||||
+
+%%% Test: Empty cells are placed as expected
+ | 0 | 1 | 2 | |
+ | 4 | 5 | | 7 |
+ | 8 | | A | B |
+ | | D | E | F |
+
+%%% Test: Lines with different number of cells
+ | 1 |
+ | 1 | 2 |
+ | 1 | 2 | 3 |
+ | 1 | 2 | 3 | 4 |
+ | 1 | 2 | 3 | 4 | 5 |
+
+%%% Test: Empty cells + Span + Messy cell number = Fun!
+ | Jan |
+ | Fev ||
+ | Mar |||
+ | Apr ||||
+ | May |||||
+ | 20% | 40% | 60% | 80% | 100% |
+
+ | | | / | | |
+ | | / / / / / ||| |
+ | / / / / / / / / / |||||
+ | | o | | o | |
+ | | | . | | |
+ | | = = = = ||| |
+
+ | 01 | 02 | | | 05 | | 07 | |
+ | | | 11 | | 13 | | | 16 |
+ | 17 | | 19 | 20 | | | 23 | |
+ | 25 | 26 | | | 29 | 30 | | 32 |
+ | | | 35 | | 37 | | 39 | 40 |
+
+%%% Test: Lots of cells at the same line
+| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
+
+%%% Test: Empty lines
+| |
+| |
+| |
+
+%%% Invalid: There must be at least one space around the pipe
+|this|is|not|a|table|
+
+|this| is| not| a| table|
+
+|this |is |not |a |table |
+
+%%% Invalid: You must use spaces, not TABs
+| this | is | not | a | table |
+
+------------------------------------------------------------
+
+The End.
diff --git a/test/writer.asciidoc b/test/writer.asciidoc
new file mode 100644
index 000000000..2bf62e36f
--- /dev/null
+++ b/test/writer.asciidoc
@@ -0,0 +1,693 @@
+Pandoc Test Suite
+=================
+John MacFarlane; Anonymous
+July 17, 2006
+
+This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
+markdown test suite.
+
+'''''
+
+[[headers]]
+Headers
+-------
+
+[[level-2-with-an-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.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
+
+Here’s one with a bullet. * criminey.
+
+There should be a hard line break +
+here.
+
+'''''
+
+[[block-quotes]]
+Block Quotes
+------------
+
+E-mail style:
+
+__________________________________________
+This is a block quote. It is pretty short.
+__________________________________________
+
+______________________
+--
+Code in a block quote:
+
+....
+sub status {
+ print "working";
+}
+....
+
+A list:
+
+1. item one
+2. item two
+
+Nested block quotes:
+
+______
+nested
+______
+
+______
+nested
+______
+
+--
+______________________
+
+This should not be a block quote: 2 > 1.
+
+And a following paragraph.
+
+'''''
+
+[[code-blocks]]
+Code Blocks
+-----------
+
+Code:
+
+....
+---- (should be four hyphens)
+
+sub status {
+ print "working";
+}
+
+this code block is indented by one tab
+....
+
+And:
+
+....
+ this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \> \[ \{
+....
+
+'''''
+
+[[lists]]
+Lists
+-----
+
+[[unordered]]
+Unordered
+~~~~~~~~~
+
+Asterisks tight:
+
+* asterisk 1
+* asterisk 2
+* asterisk 3
+
+Asterisks loose:
+
+* asterisk 1
+* asterisk 2
+* asterisk 3
+
+Pluses tight:
+
+* Plus 1
+* Plus 2
+* Plus 3
+
+Pluses loose:
+
+* Plus 1
+* Plus 2
+* Plus 3
+
+Minuses tight:
+
+* Minus 1
+* Minus 2
+* Minus 3
+
+Minuses loose:
+
+* Minus 1
+* Minus 2
+* Minus 3
+
+[[ordered]]
+Ordered
+~~~~~~~
+
+Tight:
+
+1. First
+2. Second
+3. Third
+
+and:
+
+1. One
+2. Two
+3. Three
+
+Loose using tabs:
+
+1. First
+2. Second
+3. Third
+
+and using spaces:
+
+1. One
+2. Two
+3. Three
+
+Multiple paragraphs:
+
+1. Item 1, graf one.
++
+Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.
+2. Item 2.
+3. Item 3.
+
+[[nested]]
+Nested
+~~~~~~
+
+* Tab
+** Tab
+*** Tab
+
+Here’s another:
+
+1. First
+2. Second:
+* Fee
+* Fie
+* Foe
+3. Third
+
+Same thing but with paragraphs:
+
+1. First
+2. Second:
+* Fee
+* Fie
+* Foe
+3. Third
+
+[[tabs-and-spaces]]
+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
++
+with a continuation
+a. sublist with roman numerals, starting with 4
+b. more items
+A. a subsublist
+B. a subsublist
+
+Nesting:
+
+A. Upper Alpha
+A. Upper Roman.
+1. Decimal start with 6
+a. Lower alpha with paren
+
+Autonumbering:
+
+1. Autonumber.
+2. More.
+1. Nested.
+
+Should not be a list item:
+
+M.A. 2007
+
+B. Williams
+
+'''''
+
+[[definition-lists]]
+Definition Lists
+----------------
+
+Tight using spaces:
+
+apple::
+ red fruit
+orange::
+ orange fruit
+banana::
+ yellow fruit
+
+Tight using tabs:
+
+apple::
+ red fruit
+orange::
+ orange fruit
+banana::
+ yellow fruit
+
+Loose:
+
+apple::
+ red fruit
+orange::
+ orange fruit
+banana::
+ yellow fruit
+
+Multiple blocks with italics:
+
+_apple_::
+ red fruit
+ +
+ contains seeds, crisp, pleasant to taste
+_orange_::
+ orange fruit
+ +
+....
+{ orange code block }
+....
+ +
+ __________________
+ orange block quote
+ __________________
+
+Multiple definitions, tight:
+
+apple::
+ red fruit
+ +
+ computer
+orange::
+ orange fruit
+ +
+ bank
+
+Multiple definitions, loose:
+
+apple::
+ red fruit
+ +
+ computer
+orange::
+ orange fruit
+ +
+ bank
+
+Blank line after term, indented marker, alternate markers:
+
+apple::
+ red fruit
+ +
+ computer
+orange::
+ orange fruit
+ +
+ 1. sublist
+ 2. sublist
+
+[[html-blocks]]
+HTML Blocks
+-----------
+
+Simple block on one line:
+
+foo
+
+And nested without indentation:
+
+foo
+
+bar
+
+Interpreted markdown in a table:
+
+This is _emphasized_
+
+And this is *strong*
+
+Here’s a simple block:
+
+foo
+
+This should be a code block, though:
+
+....
+<div>
+ foo
+</div>
+....
+
+As should this:
+
+....
+<div>foo</div>
+....
+
+Now, nested:
+
+foo
+
+This should just be an HTML comment:
+
+Multiline:
+
+Code block:
+
+....
+<!-- Comment -->
+....
+
+Just plain comment, with trailing spaces on the line:
+
+Code:
+
+....
+<hr />
+....
+
+Hr’s:
+
+'''''
+
+[[inline-markup]]
+Inline Markup
+-------------
+
+This is _emphasized_, and so _is this_.
+
+This is *strong*, and so *is this*.
+
+An _link:/url[emphasized link]_.
+
+*_This is strong and em._*
+
+So is *_this_* word.
+
+*_This is strong and em._*
+
+So is *_this_* word.
+
+This is code: `>`, `$`, `\`, `\$`, `<html>`.
+
+[line-through]*This is _strikeout_.*
+
+Superscripts: a^bc^d a^_hello_^ a^hello there^.
+
+Subscripts: H~2~O, H~23~O, H~many of them~O.
+
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a^b c^d, a~b c~d.
+
+'''''
+
+[[smart-quotes-ellipses-dashes]]
+Smart quotes, ellipses, dashes
+------------------------------
+
+``Hello,'' said the spider. ```Shelob' is my name.''
+
+`A', `B', and `C' are letters.
+
+`Oak,' `elm,' and `beech' are names of trees. So is `pine.'
+
+`He said, ``I want to go.''' Were you alive in the 70’s?
+
+Here is some quoted ``code`' and a ``http://example.com/?foo=1&bar=2[quoted
+link]''.
+
+Some dashes: one—two — three—four — five.
+
+Dashes between numbers: 5–7, 255–66, 1987–1999.
+
+Ellipses…and…and….
+
+'''''
+
+[[latex]]
+LaTeX
+-----
+
+*
+* latexmath:[$2+2=4$]
+* latexmath:[$x \in y$]
+* latexmath:[$\alpha \wedge \omega$]
+* latexmath:[$223$]
+* latexmath:[$p$]-Tree
+* Here’s some display math:
+latexmath:[\[\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:
+latexmath:[$\alpha + \omega \times x^2$].
+
+These shouldn’t be math:
+
+* To get the famous equation, write `$e = mc^2$`.
+* $22,000 is a _lot_ of money. So is $34,000. (It worked if ``lot'' is
+emphasized.)
+* Shoes ($20) and socks ($5).
+* Escaped `$`: $73 _this should be emphasized_ 23$.
+
+Here’s a LaTeX table:
+
+'''''
+
+[[special-characters]]
+Special Characters
+------------------
+
+Here is some unicode:
+
+* I hat: Î
+* o umlaut: ö
+* section: §
+* set membership: ∈
+* copyright: ©
+
+AT&T has an ampersand in their name.
+
+AT&T is another way to write it.
+
+This & that.
+
+4 < 5.
+
+6 > 5.
+
+Backslash: \
+
+Backtick: `
+
+Asterisk: *
+
+Underscore: _
+
+Left brace: \{
+
+Right brace: }
+
+Left bracket: [
+
+Right bracket: ]
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: >
+
+Hash: #
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+'''''
+
+[[links]]
+Links
+-----
+
+[[explicit]]
+Explicit
+~~~~~~~~
+
+Just a link:/url/[URL].
+
+link:/url/[URL and title].
+
+link:/url/[URL and title].
+
+link:/url/[URL and title].
+
+link:/url/[URL and title]
+
+link:/url/[URL and title]
+
+link:/url/with_underscore[with_underscore]
+
+mailto:nobody@nowhere.net[Email link]
+
+link:[Empty].
+
+[[reference]]
+Reference
+~~~~~~~~~
+
+Foo link:/url/[bar].
+
+Foo link:/url/[bar].
+
+Foo link:/url/[bar].
+
+With link:/url/[embedded [brackets]].
+
+link:/url/[b] by itself should be a link.
+
+Indented link:/url[once].
+
+Indented link:/url[twice].
+
+Indented link:/url[thrice].
+
+This should [not][] be a link.
+
+....
+[not]: /url
+....
+
+Foo link:/url/[bar].
+
+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].
+
+Here’s a link with an amersand in the link text: http://att.com/[AT&T].
+
+Here’s an link:/script?foo=1&bar=2[inline link].
+
+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
+
+* In a list?
+* http://example.com/
+* It should.
+
+An e-mail address: nobody@nowhere.net
+
+________________________________
+Blockquoted: http://example.com/
+________________________________
+
+Auto-links should not occur here: `<http://example.com/>`
+
+....
+or here: <http://example.com/>
+....
+
+'''''
+
+[[images]]
+Images
+------
+
+From ``Voyage dans la Lune'' by Georges Melies (1902):
+
+image:lalune.jpg[lalune,title="Voyage dans la Lune"]
+
+Here is a movie image:movie.jpg[movie] icon.
+
+'''''
+
+[[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
+document.] and another.[multiblock footnote omitted] This should _not_ be a
+footnote reference, because it contains a space.[^my note] Here is an inline
+note.footnote:[This is _easier_ to type. Inline notes may contain
+http://google.com[links] and `]` verbatim characters, as well as [bracketed
+text].]
+
+___________________________________________
+Notes can go in quotes.footnote:[In quote.]
+___________________________________________
+
+1. And in list items.footnote:[In list.]
+
+This paragraph should not be part of the note, as it is not indented.
diff --git a/test/writer.context b/test/writer.context
new file mode 100644
index 000000000..04df66178
--- /dev/null
+++ b/test/writer.context
@@ -0,0 +1,888 @@
+% Enable hyperlinks
+\setupinteraction
+ [state=start,
+ title={Pandoc Test Suite},
+ author={John MacFarlane; Anonymous},
+ style=,
+ color=,
+ contrastcolor=]
+% make chapter, section bookmarks visible when opening document
+\placebookmarks[chapter, section, subsection, subsubsection, subsubsubsection, subsubsubsubsection][chapter, section]
+\setupinteractionscreen[option=bookmark]
+\setuptagging[state=start]
+
+% use microtypography
+\definefontfeature[default][default][script=latn, protrusion=quality, expansion=quality, itlc=yes, textitalics=yes, onum=yes, pnum=yes]
+\definefontfeature[smallcaps][script=latn, protrusion=quality, expansion=quality, smcp=yes, onum=yes, pnum=yes]
+\setupalign[hz,hanging]
+\setupitaliccorrection[global, always]
+\setupbodyfontenvironment[default][em=italic] % use italic as em, not slanted
+\usemodule[simplefonts]
+\setmainfontfallback[DejaVu Serif][range={greekandcoptic, greekextended}, force=yes, rscale=auto]
+\setupwhitespace[medium]
+
+\setuphead[chapter] [style=\tfd,header=empty]
+\setuphead[section] [style=\tfc]
+\setuphead[subsection] [style=\tfb]
+\setuphead[subsubsection] [style=\bf]
+\setuphead[subsubsubsection] [style=\sc]
+\setuphead[subsubsubsubsection][style=\it]
+
+\setuphead[chapter, section, subsection, subsubsection, subsubsubsection, subsubsubsubsection][number=no]
+
+\definedescription
+ [description]
+ [headstyle=bold, style=normal, location=hanging, width=broad, margin=1cm, alternative=hanging]
+
+\setupitemize[autointro] % prevent orphan list intro
+\setupitemize[indentnext=no]
+
+\setupfloat[figure][default={here,nonumber}]
+\setupfloat[table][default={here,nonumber}]
+
+\setupthinrules[width=15em] % width of horizontal rules
+
+
+\starttext
+\startalignment[middle]
+ {\tfd Pandoc Test Suite}
+ \smallskip
+ {\tfa John MacFarlane\crlf Anonymous}
+ \smallskip
+ {\tfa July 17, 2006}
+ \bigskip
+\stopalignment
+
+This is a set of tests for pandoc. Most of them are adapted from John Gruber's
+markdown test suite.
+
+\thinrule
+
+\section[headers]{Headers}
+
+\subsection[level-2-with-an-embedded-link]{Level 2 with an
+\useURL[url1][/url][][embedded link]\from[url1]}
+
+\subsubsection[level-3-with-emphasis]{Level 3 with {\em emphasis}}
+
+\subsubsubsection[level-4]{Level 4}
+
+\subsubsubsubsection[level-5]{Level 5}
+
+\section[level-1]{Level 1}
+
+\subsection[level-2-with-emphasis]{Level 2 with {\em emphasis}}
+
+\subsubsection[level-3]{Level 3}
+
+with no blank line
+
+\subsection[level-2]{Level 2}
+
+with no blank line
+
+\thinrule
+
+\section[paragraphs]{Paragraphs}
+
+Here's a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
+
+Here's one with a bullet. * criminey.
+
+There should be a hard line break\crlf
+here.
+
+\thinrule
+
+\section[block-quotes]{Block Quotes}
+
+E-mail style:
+
+\startblockquote
+This is a block quote. It is pretty short.
+\stopblockquote
+
+\startblockquote
+Code in a block quote:
+
+\starttyping
+sub status {
+ print "working";
+}
+\stoptyping
+
+A list:
+
+\startitemize[n,packed][stopper=.]
+\item
+ item one
+\item
+ item two
+\stopitemize
+
+Nested block quotes:
+
+\startblockquote
+nested
+\stopblockquote
+
+\startblockquote
+nested
+\stopblockquote
+\stopblockquote
+
+This should not be a block quote: 2 > 1.
+
+And a following paragraph.
+
+\thinrule
+
+\section[code-blocks]{Code Blocks}
+
+Code:
+
+\starttyping
+---- (should be four hyphens)
+
+sub status {
+ print "working";
+}
+
+this code block is indented by one tab
+\stoptyping
+
+And:
+
+\starttyping
+ this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \> \[ \{
+\stoptyping
+
+\thinrule
+
+\section[lists]{Lists}
+
+\subsection[unordered]{Unordered}
+
+Asterisks tight:
+
+\startitemize[packed]
+\item
+ asterisk 1
+\item
+ asterisk 2
+\item
+ asterisk 3
+\stopitemize
+
+Asterisks loose:
+
+\startitemize
+\item
+ asterisk 1
+\item
+ asterisk 2
+\item
+ asterisk 3
+\stopitemize
+
+Pluses tight:
+
+\startitemize[packed]
+\item
+ Plus 1
+\item
+ Plus 2
+\item
+ Plus 3
+\stopitemize
+
+Pluses loose:
+
+\startitemize
+\item
+ Plus 1
+\item
+ Plus 2
+\item
+ Plus 3
+\stopitemize
+
+Minuses tight:
+
+\startitemize[packed]
+\item
+ Minus 1
+\item
+ Minus 2
+\item
+ Minus 3
+\stopitemize
+
+Minuses loose:
+
+\startitemize
+\item
+ Minus 1
+\item
+ Minus 2
+\item
+ Minus 3
+\stopitemize
+
+\subsection[ordered]{Ordered}
+
+Tight:
+
+\startitemize[n,packed][stopper=.]
+\item
+ First
+\item
+ Second
+\item
+ Third
+\stopitemize
+
+and:
+
+\startitemize[n,packed][stopper=.]
+\item
+ One
+\item
+ Two
+\item
+ Three
+\stopitemize
+
+Loose using tabs:
+
+\startitemize[n][stopper=.]
+\item
+ First
+\item
+ Second
+\item
+ Third
+\stopitemize
+
+and using spaces:
+
+\startitemize[n][stopper=.]
+\item
+ One
+\item
+ Two
+\item
+ Three
+\stopitemize
+
+Multiple paragraphs:
+
+\startitemize[n][stopper=.]
+\item
+ Item 1, graf one.
+
+ Item 1. graf two. The quick brown fox jumped over the lazy dog's back.
+\item
+ Item 2.
+\item
+ Item 3.
+\stopitemize
+
+\subsection[nested]{Nested}
+
+\startitemize[packed]
+\item
+ Tab
+ \startitemize[packed]
+ \item
+ Tab
+ \startitemize[packed]
+ \item
+ Tab
+ \stopitemize
+ \stopitemize
+\stopitemize
+
+Here's another:
+
+\startitemize[n,packed][stopper=.]
+\item
+ First
+\item
+ Second:
+ \startitemize[packed]
+ \item
+ Fee
+ \item
+ Fie
+ \item
+ Foe
+ \stopitemize
+\item
+ Third
+\stopitemize
+
+Same thing but with paragraphs:
+
+\startitemize[n][stopper=.]
+\item
+ First
+\item
+ Second:
+
+ \startitemize[packed]
+ \item
+ Fee
+ \item
+ Fie
+ \item
+ Foe
+ \stopitemize
+\item
+ Third
+\stopitemize
+
+\subsection[tabs-and-spaces]{Tabs and spaces}
+
+\startitemize
+\item
+ this is a list item indented with tabs
+\item
+ this is a list item indented with spaces
+
+ \startitemize
+ \item
+ this is an example list item indented with tabs
+ \item
+ this is an example list item indented with spaces
+ \stopitemize
+\stopitemize
+
+\subsection[fancy-list-markers]{Fancy list markers}
+
+\startitemize[n][start=2,left=(,stopper=),width=2.0em]
+\item
+ begins with 2
+\item
+ and now 3
+
+ with a continuation
+
+ \startitemize[r,packed][start=4,stopper=.,width=2.0em]
+ \item
+ sublist with roman numerals, starting with 4
+ \item
+ more items
+ \startitemize[A,packed][left=(,stopper=),width=2.0em]
+ \item
+ a subsublist
+ \item
+ a subsublist
+ \stopitemize
+ \stopitemize
+\stopitemize
+
+Nesting:
+
+\startitemize[A,packed][stopper=.]
+\item
+ Upper Alpha
+ \startitemize[R,packed][stopper=.]
+ \item
+ Upper Roman.
+ \startitemize[n,packed][start=6,left=(,stopper=),width=2.0em]
+ \item
+ Decimal start with 6
+ \startitemize[a,packed][start=3,stopper=)]
+ \item
+ Lower alpha with paren
+ \stopitemize
+ \stopitemize
+ \stopitemize
+\stopitemize
+
+Autonumbering:
+
+\startitemize[n,packed]
+\item
+ Autonumber.
+\item
+ More.
+ \startitemize[a,packed]
+ \item
+ Nested.
+ \stopitemize
+\stopitemize
+
+Should not be a list item:
+
+M.A.~2007
+
+B. Williams
+
+\thinrule
+
+\section[definition-lists]{Definition Lists}
+
+Tight using spaces:
+
+\startdescription{apple}
+ red fruit
+\stopdescription
+
+\startdescription{orange}
+ orange fruit
+\stopdescription
+
+\startdescription{banana}
+ yellow fruit
+\stopdescription
+
+Tight using tabs:
+
+\startdescription{apple}
+ red fruit
+\stopdescription
+
+\startdescription{orange}
+ orange fruit
+\stopdescription
+
+\startdescription{banana}
+ yellow fruit
+\stopdescription
+
+Loose:
+
+\startdescription{apple}
+ red fruit
+\stopdescription
+
+\startdescription{orange}
+ orange fruit
+\stopdescription
+
+\startdescription{banana}
+ yellow fruit
+\stopdescription
+
+Multiple blocks with italics:
+
+\startdescription{{\em apple}}
+ red fruit
+
+ contains seeds, crisp, pleasant to taste
+\stopdescription
+
+\startdescription{{\em orange}}
+ orange fruit
+
+\starttyping
+{ orange code block }
+\stoptyping
+
+ \startblockquote
+ orange block quote
+ \stopblockquote
+\stopdescription
+
+Multiple definitions, tight:
+
+\startdescription{apple}
+ red fruit
+
+ computer
+\stopdescription
+
+\startdescription{orange}
+ orange fruit
+
+ bank
+\stopdescription
+
+Multiple definitions, loose:
+
+\startdescription{apple}
+ red fruit
+
+ computer
+\stopdescription
+
+\startdescription{orange}
+ orange fruit
+
+ bank
+\stopdescription
+
+Blank line after term, indented marker, alternate markers:
+
+\startdescription{apple}
+ red fruit
+
+ computer
+\stopdescription
+
+\startdescription{orange}
+ orange fruit
+
+ \startitemize[n,packed][stopper=.]
+ \item
+ sublist
+ \item
+ sublist
+ \stopitemize
+\stopdescription
+
+\section[html-blocks]{HTML Blocks}
+
+Simple block on one line:
+
+foo
+
+And nested without indentation:
+
+foo
+
+bar
+
+Interpreted markdown in a table:
+
+This is {\em emphasized}
+And this is {\bf strong}
+Here's a simple block:
+
+foo
+
+This should be a code block, though:
+
+\starttyping
+<div>
+ foo
+</div>
+\stoptyping
+
+As should this:
+
+\starttyping
+<div>foo</div>
+\stoptyping
+
+Now, nested:
+
+foo
+
+This should just be an HTML comment:
+
+Multiline:
+
+Code block:
+
+\starttyping
+<!-- Comment -->
+\stoptyping
+
+Just plain comment, with trailing spaces on the line:
+
+Code:
+
+\starttyping
+<hr />
+\stoptyping
+
+Hr's:
+
+\thinrule
+
+\section[inline-markup]{Inline Markup}
+
+This is {\em emphasized}, and so {\em is this}.
+
+This is {\bf strong}, and so {\bf is this}.
+
+An {\em \useURL[url2][/url][][emphasized link]\from[url2]}.
+
+{\bf {\em This is strong and em.}}
+
+So is {\bf {\em this}} word.
+
+{\bf {\em This is strong and em.}}
+
+So is {\bf {\em this}} word.
+
+This is code: \type{>}, \type{$}, \type{\}, \type{\$}, \type{<html>}.
+
+\overstrikes{This is {\em strikeout}.}
+
+Superscripts: a\high{bc}d a\high{{\em hello}} a\high{hello~there}.
+
+Subscripts: H\low{2}O, H\low{23}O, H\low{many~of~them}O.
+
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a^b c^d, a\lettertilde{}b c\lettertilde{}d.
+
+\thinrule
+
+\section[smart-quotes-ellipses-dashes]{Smart quotes, ellipses, dashes}
+
+\quotation{Hello,} said the spider. \quotation{\quote{Shelob} is my name.}
+
+\quote{A}, \quote{B}, and \quote{C} are letters.
+
+\quote{Oak,} \quote{elm,} and \quote{beech} are names of trees. So is
+\quote{pine.}
+
+\quote{He said, \quotation{I want to go.}} Were you alive in the 70's?
+
+Here is some quoted \quote{\type{code}} and a
+\quotation{\useURL[url3][http://example.com/?foo=1&bar=2][][quoted
+link]\from[url3]}.
+
+Some dashes: one---two --- three---four --- five.
+
+Dashes between numbers: 5--7, 255--66, 1987--1999.
+
+Ellipses\ldots{}and\ldots{}and\ldots{}.
+
+\thinrule
+
+\section[latex]{LaTeX}
+
+\startitemize[packed]
+\item
+ \cite[22-23]{smith.1899}
+\item
+ $2+2=4$
+\item
+ $x \in y$
+\item
+ $\alpha \wedge \omega$
+\item
+ $223$
+\item
+ $p$-Tree
+\item
+ Here's some display math:
+ \startformula \frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h} \stopformula
+\item
+ Here's one that has a line break in it: $\alpha + \omega \times x^2$.
+\stopitemize
+
+These shouldn't be math:
+
+\startitemize[packed]
+\item
+ To get the famous equation, write \type{$e = mc^2$}.
+\item
+ \$22,000 is a {\em lot} of money. So is \$34,000. (It worked if
+ \quotation{lot} is emphasized.)
+\item
+ Shoes (\$20) and socks (\$5).
+\item
+ Escaped \type{$}: \$73 {\em this should be emphasized} 23\$.
+\stopitemize
+
+Here's a LaTeX table:
+
+\thinrule
+
+\section[special-characters]{Special Characters}
+
+Here is some unicode:
+
+\startitemize[packed]
+\item
+ I hat: Î
+\item
+ o umlaut: ö
+\item
+ section: §
+\item
+ set membership: ∈
+\item
+ copyright: ©
+\stopitemize
+
+AT&T has an ampersand in their name.
+
+AT&T is another way to write it.
+
+This & that.
+
+4 < 5.
+
+6 > 5.
+
+Backslash: \letterbackslash{}
+
+Backtick: `
+
+Asterisk: *
+
+Underscore: _
+
+Left brace: \{
+
+Right brace: \}
+
+Left bracket: {[}
+
+Right bracket: {]}
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: >
+
+Hash: \#
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+\thinrule
+
+\section[links]{Links}
+
+\subsection[explicit]{Explicit}
+
+Just a \useURL[url4][/url/][][URL]\from[url4].
+
+\useURL[url5][/url/][][URL and title]\from[url5].
+
+\useURL[url6][/url/][][URL and title]\from[url6].
+
+\useURL[url7][/url/][][URL and title]\from[url7].
+
+\useURL[url8][/url/][][URL and title]\from[url8]
+
+\useURL[url9][/url/][][URL and title]\from[url9]
+
+\useURL[url10][/url/with_underscore][][with_underscore]\from[url10]
+
+\useURL[url11][mailto:nobody@nowhere.net][][Email link]\from[url11]
+
+\useURL[url12][][][Empty]\from[url12].
+
+\subsection[reference]{Reference}
+
+Foo \useURL[url13][/url/][][bar]\from[url13].
+
+Foo \useURL[url14][/url/][][bar]\from[url14].
+
+Foo \useURL[url15][/url/][][bar]\from[url15].
+
+With \useURL[url16][/url/][][embedded {[}brackets{]}]\from[url16].
+
+\useURL[url17][/url/][][b]\from[url17] by itself should be a link.
+
+Indented \useURL[url18][/url][][once]\from[url18].
+
+Indented \useURL[url19][/url][][twice]\from[url19].
+
+Indented \useURL[url20][/url][][thrice]\from[url20].
+
+This should {[}not{]}{[}{]} be a link.
+
+\starttyping
+[not]: /url
+\stoptyping
+
+Foo \useURL[url21][/url/][][bar]\from[url21].
+
+Foo \useURL[url22][/url/][][biz]\from[url22].
+
+\subsection[with-ampersands]{With ampersands}
+
+Here's a \useURL[url23][http://example.com/?foo=1&bar=2][][link with an
+ampersand in the URL]\from[url23].
+
+Here's a link with an amersand in the link text:
+\useURL[url24][http://att.com/][][AT&T]\from[url24].
+
+Here's an \useURL[url25][/script?foo=1&bar=2][][inline link]\from[url25].
+
+Here's an \useURL[url26][/script?foo=1&bar=2][][inline link in pointy
+braces]\from[url26].
+
+\subsection[autolinks]{Autolinks}
+
+With an ampersand: \useURL[url27][http://example.com/?foo=1&bar=2]\from[url27]
+
+\startitemize[packed]
+\item
+ In a list?
+\item
+ \useURL[url28][http://example.com/]\from[url28]
+\item
+ It should.
+\stopitemize
+
+An e-mail address:
+\useURL[url29][mailto:nobody@nowhere.net][][nobody@nowhere.net]\from[url29]
+
+\startblockquote
+Blockquoted: \useURL[url30][http://example.com/]\from[url30]
+\stopblockquote
+
+Auto-links should not occur here: \type{<http://example.com/>}
+
+\starttyping
+or here: <http://example.com/>
+\stoptyping
+
+\thinrule
+
+\section[images]{Images}
+
+From \quotation{Voyage dans la Lune} by Georges Melies (1902):
+
+\placefigure{lalune}{\externalfigure[lalune.jpg]}
+
+Here is a movie {\externalfigure[movie.jpg]} icon.
+
+\thinrule
+
+\section[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 document.} and another.\startbuffer Here's the long note. This one
+ contains multiple blocks.
+
+ Subsequent blocks are indented to show that they belong to the footnote (as
+ with list items).
+
+\starttyping
+ { <code> }
+\stoptyping
+
+ If you want, you can indent every line, but you can also be lazy and just
+ indent the first line of each block.\stopbuffer\footnote{\getbuffer} This
+should {\em not} be a footnote reference, because it contains a space.{[}^my
+note{]} Here is an inline note.\footnote{This is {\em easier} to type. Inline
+ notes may contain \useURL[url31][http://google.com][][links]\from[url31] and
+ \type{]} verbatim characters, as well as {[}bracketed text{]}.}
+
+\startblockquote
+Notes can go in quotes.\footnote{In quote.}
+\stopblockquote
+
+\startitemize[n,packed][stopper=.]
+\item
+ And in list items.\footnote{In list.}
+\stopitemize
+
+This paragraph should not be part of the note, as it is not indented.
+
+\stoptext
diff --git a/test/writer.docbook4 b/test/writer.docbook4
new file mode 100644
index 000000000..eee19cdd9
--- /dev/null
+++ b/test/writer.docbook4
@@ -0,0 +1,1422 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<article>
+ <articleinfo>
+ <title>Pandoc Test Suite</title>
+ <authorgroup>
+ <author>
+ <firstname>John</firstname>
+ <surname>MacFarlane</surname>
+ </author>
+ <author>
+ <firstname></firstname>
+ <surname>Anonymous</surname>
+ </author>
+ </authorgroup>
+ <date>July 17, 2006</date>
+ </articleinfo>
+<para>
+ This is a set of tests for pandoc. Most of them are adapted from John
+ Gruber’s markdown test suite.
+</para>
+<sect1 id="headers">
+ <title>Headers</title>
+ <sect2 id="level-2-with-an-embedded-link">
+ <title>Level 2 with an <ulink url="/url">embedded link</ulink></title>
+ <sect3 id="level-3-with-emphasis">
+ <title>Level 3 with <emphasis>emphasis</emphasis></title>
+ <sect4 id="level-4">
+ <title>Level 4</title>
+ <sect5 id="level-5">
+ <title>Level 5</title>
+ <para>
+ </para>
+ </sect5>
+ </sect4>
+ </sect3>
+ </sect2>
+</sect1>
+<sect1 id="level-1">
+ <title>Level 1</title>
+ <sect2 id="level-2-with-emphasis">
+ <title>Level 2 with <emphasis>emphasis</emphasis></title>
+ <sect3 id="level-3">
+ <title>Level 3</title>
+ <para>
+ with no blank line
+ </para>
+ </sect3>
+ </sect2>
+ <sect2 id="level-2">
+ <title>Level 2</title>
+ <para>
+ with no blank line
+ </para>
+ </sect2>
+</sect1>
+<sect1 id="paragraphs">
+ <title>Paragraphs</title>
+ <para>
+ Here’s a regular paragraph.
+ </para>
+ <para>
+ In Markdown 1.0.0 and earlier. Version 8. This line turns into a list
+ item. Because a hard-wrapped line in the middle of a paragraph looked like
+ a list item.
+ </para>
+ <para>
+ Here’s one with a bullet. * criminey.
+ </para>
+<literallayout>There should be a hard line break
+here.</literallayout>
+</sect1>
+<sect1 id="block-quotes">
+ <title>Block Quotes</title>
+ <para>
+ E-mail style:
+ </para>
+ <blockquote>
+ <para>
+ This is a block quote. It is pretty short.
+ </para>
+ </blockquote>
+ <blockquote>
+ <para>
+ Code in a block quote:
+ </para>
+ <programlisting>
+sub status {
+ print &quot;working&quot;;
+}
+</programlisting>
+ <para>
+ A list:
+ </para>
+ <orderedlist numeration="arabic" spacing="compact">
+ <listitem>
+ <para>
+ item one
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ item two
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ Nested block quotes:
+ </para>
+ <blockquote>
+ <para>
+ nested
+ </para>
+ </blockquote>
+ <blockquote>
+ <para>
+ nested
+ </para>
+ </blockquote>
+ </blockquote>
+ <para>
+ This should not be a block quote: 2 &gt; 1.
+ </para>
+ <para>
+ And a following paragraph.
+ </para>
+</sect1>
+<sect1 id="code-blocks">
+ <title>Code Blocks</title>
+ <para>
+ Code:
+ </para>
+ <programlisting>
+---- (should be four hyphens)
+
+sub status {
+ print &quot;working&quot;;
+}
+
+this code block is indented by one tab
+</programlisting>
+ <para>
+ And:
+ </para>
+ <programlisting>
+ this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \&gt; \[ \{
+</programlisting>
+</sect1>
+<sect1 id="lists">
+ <title>Lists</title>
+ <sect2 id="unordered">
+ <title>Unordered</title>
+ <para>
+ Asterisks tight:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ asterisk 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ asterisk 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ asterisk 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Asterisks loose:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ asterisk 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ asterisk 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ asterisk 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Pluses tight:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ Plus 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Plus 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Plus 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Pluses loose:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Plus 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Plus 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Plus 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Minuses tight:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ Minus 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Minus 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Minus 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Minuses loose:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Minus 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Minus 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Minus 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ </sect2>
+ <sect2 id="ordered">
+ <title>Ordered</title>
+ <para>
+ Tight:
+ </para>
+ <orderedlist numeration="arabic" spacing="compact">
+ <listitem>
+ <para>
+ First
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Second
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Third
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ and:
+ </para>
+ <orderedlist numeration="arabic" spacing="compact">
+ <listitem>
+ <para>
+ One
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Two
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Three
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ Loose using tabs:
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ First
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Second
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Third
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ and using spaces:
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ One
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Two
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Three
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ Multiple paragraphs:
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ Item 1, graf one.
+ </para>
+ <para>
+ Item 1. graf two. The quick brown fox jumped over the lazy dog’s
+ back.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Item 2.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Item 3.
+ </para>
+ </listitem>
+ </orderedlist>
+ </sect2>
+ <sect2 id="nested">
+ <title>Nested</title>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ Tab
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ Tab
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ Tab
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Here’s another:
+ </para>
+ <orderedlist numeration="arabic" spacing="compact">
+ <listitem>
+ <para>
+ First
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Second:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ Fee
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Fie
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Foe
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem>
+ <para>
+ Third
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ Same thing but with paragraphs:
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ First
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Second:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ Fee
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Fie
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Foe
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem>
+ <para>
+ Third
+ </para>
+ </listitem>
+ </orderedlist>
+ </sect2>
+ <sect2 id="tabs-and-spaces">
+ <title>Tabs and spaces</title>
+ <itemizedlist>
+ <listitem>
+ <para>
+ this is a list item indented with tabs
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ this is a list item indented with spaces
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ this is an example list item indented with tabs
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ this is an example list item indented with spaces
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </sect2>
+ <sect2 id="fancy-list-markers">
+ <title>Fancy list markers</title>
+ <orderedlist numeration="arabic">
+ <listitem override="2">
+ <para>
+ begins with 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ and now 3
+ </para>
+ <para>
+ with a continuation
+ </para>
+ <orderedlist numeration="lowerroman" spacing="compact">
+ <listitem override="4">
+ <para>
+ sublist with roman numerals, starting with 4
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ more items
+ </para>
+ <orderedlist numeration="upperalpha" spacing="compact">
+ <listitem>
+ <para>
+ a subsublist
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ a subsublist
+ </para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ <para>
+ Nesting:
+ </para>
+ <orderedlist numeration="upperalpha" spacing="compact">
+ <listitem>
+ <para>
+ Upper Alpha
+ </para>
+ <orderedlist numeration="upperroman" spacing="compact">
+ <listitem>
+ <para>
+ Upper Roman.
+ </para>
+ <orderedlist numeration="arabic" spacing="compact">
+ <listitem override="6">
+ <para>
+ Decimal start with 6
+ </para>
+ <orderedlist numeration="loweralpha" spacing="compact">
+ <listitem override="3">
+ <para>
+ Lower alpha with paren
+ </para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ <para>
+ Autonumbering:
+ </para>
+ <orderedlist spacing="compact">
+ <listitem>
+ <para>
+ Autonumber.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ More.
+ </para>
+ <orderedlist spacing="compact">
+ <listitem>
+ <para>
+ Nested.
+ </para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ <para>
+ Should not be a list item:
+ </para>
+ <para>
+ M.A. 2007
+ </para>
+ <para>
+ B. Williams
+ </para>
+ </sect2>
+</sect1>
+<sect1 id="definition-lists">
+ <title>Definition Lists</title>
+ <para>
+ Tight using spaces:
+ </para>
+ <variablelist spacing="compact">
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ banana
+ </term>
+ <listitem>
+ <para>
+ yellow fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Tight using tabs:
+ </para>
+ <variablelist spacing="compact">
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ banana
+ </term>
+ <listitem>
+ <para>
+ yellow fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Loose:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ banana
+ </term>
+ <listitem>
+ <para>
+ yellow fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Multiple blocks with italics:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ <emphasis>apple</emphasis>
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ <para>
+ contains seeds, crisp, pleasant to taste
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <emphasis>orange</emphasis>
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ <programlisting>
+{ orange code block }
+</programlisting>
+ <blockquote>
+ <para>
+ orange block quote
+ </para>
+ </blockquote>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Multiple definitions, tight:
+ </para>
+ <variablelist spacing="compact">
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ <para>
+ computer
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ <para>
+ bank
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Multiple definitions, loose:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ <para>
+ computer
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ <para>
+ bank
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Blank line after term, indented marker, alternate markers:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ <para>
+ computer
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ <orderedlist numeration="arabic" spacing="compact">
+ <listitem>
+ <para>
+ sublist
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ sublist
+ </para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+</sect1>
+<sect1 id="html-blocks">
+ <title>HTML Blocks</title>
+ <para>
+ Simple block on one line:
+ </para>
+ <para>
+ foo
+ </para>
+ <para>
+ And nested without indentation:
+ </para>
+ <para>
+ foo
+ </para>
+ <para>
+ bar
+ </para>
+ <para>
+ Interpreted markdown in a table:
+ </para>
+ <table>
+ <tr>
+ <td>
+ This is <emphasis>emphasized</emphasis>
+ </td>
+ <td>
+ And this is <emphasis role="strong">strong</emphasis>
+ </td>
+ </tr>
+ </table>
+ <script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
+ <para>
+ Here’s a simple block:
+ </para>
+ <para>
+ foo
+ </para>
+ <para>
+ This should be a code block, though:
+ </para>
+ <programlisting>
+&lt;div&gt;
+ foo
+&lt;/div&gt;
+</programlisting>
+ <para>
+ As should this:
+ </para>
+ <programlisting>
+&lt;div&gt;foo&lt;/div&gt;
+</programlisting>
+ <para>
+ Now, nested:
+ </para>
+ <para>
+ foo
+ </para>
+ <para>
+ This should just be an HTML comment:
+ </para>
+ <!-- Comment -->
+ <para>
+ Multiline:
+ </para>
+ <!--
+ Blah
+ Blah
+ -->
+ <!--
+ This is another comment.
+ -->
+ <para>
+ Code block:
+ </para>
+ <programlisting>
+&lt;!-- Comment --&gt;
+</programlisting>
+ <para>
+ Just plain comment, with trailing spaces on the line:
+ </para>
+ <!-- foo -->
+ <para>
+ Code:
+ </para>
+ <programlisting>
+&lt;hr /&gt;
+</programlisting>
+ <para>
+ Hr’s:
+ </para>
+ <hr>
+ <hr />
+ <hr />
+ <hr>
+ <hr />
+ <hr />
+ <hr class="foo" id="bar" />
+ <hr class="foo" id="bar" />
+ <hr class="foo" id="bar">
+</sect1>
+<sect1 id="inline-markup">
+ <title>Inline Markup</title>
+ <para>
+ This is <emphasis>emphasized</emphasis>, and so <emphasis>is
+ this</emphasis>.
+ </para>
+ <para>
+ This is <emphasis role="strong">strong</emphasis>, and so
+ <emphasis role="strong">is this</emphasis>.
+ </para>
+ <para>
+ An <emphasis><ulink url="/url">emphasized link</ulink></emphasis>.
+ </para>
+ <para>
+ <emphasis role="strong"><emphasis>This is strong and
+ em.</emphasis></emphasis>
+ </para>
+ <para>
+ So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.
+ </para>
+ <para>
+ <emphasis role="strong"><emphasis>This is strong and
+ em.</emphasis></emphasis>
+ </para>
+ <para>
+ So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.
+ </para>
+ <para>
+ This is code: <literal>&gt;</literal>, <literal>$</literal>,
+ <literal>\</literal>, <literal>\$</literal>,
+ <literal>&lt;html&gt;</literal>.
+ </para>
+ <para>
+ <emphasis role="strikethrough">This is
+ <emphasis>strikeout</emphasis>.</emphasis>
+ </para>
+ <para>
+ Superscripts: a<superscript>bc</superscript>d
+ a<superscript><emphasis>hello</emphasis></superscript>
+ a<superscript>hello there</superscript>.
+ </para>
+ <para>
+ Subscripts: H<subscript>2</subscript>O, H<subscript>23</subscript>O,
+ H<subscript>many of them</subscript>O.
+ </para>
+ <para>
+ These should not be superscripts or subscripts, because of the unescaped
+ spaces: a^b c^d, a~b c~d.
+ </para>
+</sect1>
+<sect1 id="smart-quotes-ellipses-dashes">
+ <title>Smart quotes, ellipses, dashes</title>
+ <para>
+ <quote>Hello,</quote> said the spider. <quote><quote>Shelob</quote> is my
+ name.</quote>
+ </para>
+ <para>
+ <quote>A</quote>, <quote>B</quote>, and <quote>C</quote> are letters.
+ </para>
+ <para>
+ <quote>Oak,</quote> <quote>elm,</quote> and <quote>beech</quote> are names
+ of trees. So is <quote>pine.</quote>
+ </para>
+ <para>
+ <quote>He said, <quote>I want to go.</quote></quote> Were you alive in the
+ 70’s?
+ </para>
+ <para>
+ Here is some quoted <quote><literal>code</literal></quote> and a
+ <quote><ulink url="http://example.com/?foo=1&amp;bar=2">quoted
+ link</ulink></quote>.
+ </para>
+ <para>
+ Some dashes: one—two — three—four — five.
+ </para>
+ <para>
+ Dashes between numbers: 5–7, 255–66, 1987–1999.
+ </para>
+ <para>
+ Ellipses…and…and….
+ </para>
+</sect1>
+<sect1 id="latex">
+ <title>LaTeX</title>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ 2 + 2 = 4
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis>x</emphasis> ∈ <emphasis>y</emphasis>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis>α</emphasis> ∧ <emphasis>ω</emphasis>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ 223
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis>p</emphasis>-Tree
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Here’s some display math:
+ $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Here’s one that has a line break in it:
+ <emphasis>α</emphasis> + <emphasis>ω</emphasis> × <emphasis>x</emphasis><superscript>2</superscript>.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ These shouldn’t be math:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ To get the famous equation, write <literal>$e = mc^2$</literal>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ $22,000 is a <emphasis>lot</emphasis> of money. So is $34,000. (It
+ worked if <quote>lot</quote> is emphasized.)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Shoes ($20) and socks ($5).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Escaped <literal>$</literal>: $73 <emphasis>this should be
+ emphasized</emphasis> 23$.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Here’s a LaTeX table:
+ </para>
+</sect1>
+<sect1 id="special-characters">
+ <title>Special Characters</title>
+ <para>
+ Here is some unicode:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ I hat: Î
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ o umlaut: ö
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ section: §
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ set membership: ∈
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ copyright: ©
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ AT&amp;T has an ampersand in their name.
+ </para>
+ <para>
+ AT&amp;T is another way to write it.
+ </para>
+ <para>
+ This &amp; that.
+ </para>
+ <para>
+ 4 &lt; 5.
+ </para>
+ <para>
+ 6 &gt; 5.
+ </para>
+ <para>
+ Backslash: \
+ </para>
+ <para>
+ Backtick: `
+ </para>
+ <para>
+ Asterisk: *
+ </para>
+ <para>
+ Underscore: _
+ </para>
+ <para>
+ Left brace: {
+ </para>
+ <para>
+ Right brace: }
+ </para>
+ <para>
+ Left bracket: [
+ </para>
+ <para>
+ Right bracket: ]
+ </para>
+ <para>
+ Left paren: (
+ </para>
+ <para>
+ Right paren: )
+ </para>
+ <para>
+ Greater-than: &gt;
+ </para>
+ <para>
+ Hash: #
+ </para>
+ <para>
+ Period: .
+ </para>
+ <para>
+ Bang: !
+ </para>
+ <para>
+ Plus: +
+ </para>
+ <para>
+ Minus: -
+ </para>
+</sect1>
+<sect1 id="links">
+ <title>Links</title>
+ <sect2 id="explicit">
+ <title>Explicit</title>
+ <para>
+ Just a <ulink url="/url/">URL</ulink>.
+ </para>
+ <para>
+ <ulink url="/url/">URL and title</ulink>.
+ </para>
+ <para>
+ <ulink url="/url/">URL and title</ulink>.
+ </para>
+ <para>
+ <ulink url="/url/">URL and title</ulink>.
+ </para>
+ <para>
+ <ulink url="/url/">URL and title</ulink>
+ </para>
+ <para>
+ <ulink url="/url/">URL and title</ulink>
+ </para>
+ <para>
+ <ulink url="/url/with_underscore">with_underscore</ulink>
+ </para>
+ <para>
+ Email link (<email>nobody@nowhere.net</email>)
+ </para>
+ <para>
+ <ulink url="">Empty</ulink>.
+ </para>
+ </sect2>
+ <sect2 id="reference">
+ <title>Reference</title>
+ <para>
+ Foo <ulink url="/url/">bar</ulink>.
+ </para>
+ <para>
+ Foo <ulink url="/url/">bar</ulink>.
+ </para>
+ <para>
+ Foo <ulink url="/url/">bar</ulink>.
+ </para>
+ <para>
+ With <ulink url="/url/">embedded [brackets]</ulink>.
+ </para>
+ <para>
+ <ulink url="/url/">b</ulink> by itself should be a link.
+ </para>
+ <para>
+ Indented <ulink url="/url">once</ulink>.
+ </para>
+ <para>
+ Indented <ulink url="/url">twice</ulink>.
+ </para>
+ <para>
+ Indented <ulink url="/url">thrice</ulink>.
+ </para>
+ <para>
+ This should [not][] be a link.
+ </para>
+ <programlisting>
+[not]: /url
+</programlisting>
+ <para>
+ Foo <ulink url="/url/">bar</ulink>.
+ </para>
+ <para>
+ Foo <ulink url="/url/">biz</ulink>.
+ </para>
+ </sect2>
+ <sect2 id="with-ampersands">
+ <title>With ampersands</title>
+ <para>
+ Here’s a <ulink url="http://example.com/?foo=1&amp;bar=2">link with an
+ ampersand in the URL</ulink>.
+ </para>
+ <para>
+ Here’s a link with an amersand in the link text:
+ <ulink url="http://att.com/">AT&amp;T</ulink>.
+ </para>
+ <para>
+ Here’s an <ulink url="/script?foo=1&amp;bar=2">inline link</ulink>.
+ </para>
+ <para>
+ Here’s an <ulink url="/script?foo=1&amp;bar=2">inline link in pointy
+ braces</ulink>.
+ </para>
+ </sect2>
+ <sect2 id="autolinks">
+ <title>Autolinks</title>
+ <para>
+ With an ampersand:
+ <ulink url="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</ulink>
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ In a list?
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <ulink url="http://example.com/">http://example.com/</ulink>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ It should.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ An e-mail address: <email>nobody@nowhere.net</email>
+ </para>
+ <blockquote>
+ <para>
+ Blockquoted:
+ <ulink url="http://example.com/">http://example.com/</ulink>
+ </para>
+ </blockquote>
+ <para>
+ Auto-links should not occur here:
+ <literal>&lt;http://example.com/&gt;</literal>
+ </para>
+ <programlisting>
+or here: &lt;http://example.com/&gt;
+</programlisting>
+ </sect2>
+</sect1>
+<sect1 id="images">
+ <title>Images</title>
+ <para>
+ From <quote>Voyage dans la Lune</quote> by Georges Melies (1902):
+ </para>
+ <figure>
+ <title>lalune</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="lalune.jpg" />
+ </imageobject>
+ <textobject><phrase>lalune</phrase></textobject>
+ </mediaobject>
+ </figure>
+ <para>
+ Here is a movie <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="movie.jpg" />
+ </imageobject>
+ </inlinemediaobject> icon.
+ </para>
+</sect1>
+<sect1 id="footnotes">
+ <title>Footnotes</title>
+ <para>
+ Here is a footnote reference,<footnote>
+ <para>
+ Here is the footnote. It can go anywhere after the footnote reference.
+ It need not be placed at the end of the document.
+ </para>
+ </footnote> and another.<footnote>
+ <para>
+ Here’s the long note. This one contains multiple blocks.
+ </para>
+ <para>
+ Subsequent blocks are indented to show that they belong to the
+ footnote (as with list items).
+ </para>
+ <programlisting>
+ { &lt;code&gt; }
+</programlisting>
+ <para>
+ If you want, you can indent every line, but you can also be lazy and
+ just indent the first line of each block.
+ </para>
+ </footnote> This should <emphasis>not</emphasis> be a footnote reference,
+ because it contains a space.[^my note] Here is an inline note.<footnote>
+ <para>
+ This is <emphasis>easier</emphasis> to type. Inline notes may contain
+ <ulink url="http://google.com">links</ulink> and <literal>]</literal>
+ verbatim characters, as well as [bracketed text].
+ </para>
+ </footnote>
+ </para>
+ <blockquote>
+ <para>
+ Notes can go in quotes.<footnote>
+ <para>
+ In quote.
+ </para>
+ </footnote>
+ </para>
+ </blockquote>
+ <orderedlist numeration="arabic" spacing="compact">
+ <listitem>
+ <para>
+ And in list items.<footnote>
+ <para>
+ In list.
+ </para>
+ </footnote>
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ This paragraph should not be part of the note, as it is not indented.
+ </para>
+</sect1>
+</article>
diff --git a/test/writer.docbook5 b/test/writer.docbook5
new file mode 100644
index 000000000..07ca0f827
--- /dev/null
+++ b/test/writer.docbook5
@@ -0,0 +1,1397 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE article>
+<article
+ xmlns="http://docbook.org/ns/docbook" version="5.0"
+ xmlns:xlink="http://www.w3.org/1999/xlink" >
+ <info>
+ <title>Pandoc Test Suite</title>
+ <authorgroup>
+ <author>
+ <firstname>John</firstname>
+ <surname>MacFarlane</surname>
+ </author>
+ <author>
+ <firstname></firstname>
+ <surname>Anonymous</surname>
+ </author>
+ </authorgroup>
+ <date>July 17, 2006</date>
+ </info>
+<para>
+ This is a set of tests for pandoc. Most of them are adapted from John
+ Gruber’s markdown test suite.
+</para>
+<section xml:id="headers">
+ <title>Headers</title>
+ <section xml:id="level-2-with-an-embedded-link">
+ <title>Level 2 with an <link xlink:href="/url">embedded
+ link</link></title>
+ <section xml:id="level-3-with-emphasis">
+ <title>Level 3 with <emphasis>emphasis</emphasis></title>
+ <section xml:id="level-4">
+ <title>Level 4</title>
+ <section xml:id="level-5">
+ <title>Level 5</title>
+ <para>
+ </para>
+ </section>
+ </section>
+ </section>
+ </section>
+</section>
+<section xml:id="level-1">
+ <title>Level 1</title>
+ <section xml:id="level-2-with-emphasis">
+ <title>Level 2 with <emphasis>emphasis</emphasis></title>
+ <section xml:id="level-3">
+ <title>Level 3</title>
+ <para>
+ with no blank line
+ </para>
+ </section>
+ </section>
+ <section xml:id="level-2">
+ <title>Level 2</title>
+ <para>
+ with no blank line
+ </para>
+ </section>
+</section>
+<section xml:id="paragraphs">
+ <title>Paragraphs</title>
+ <para>
+ Here’s a regular paragraph.
+ </para>
+ <para>
+ In Markdown 1.0.0 and earlier. Version 8. This line turns into a list
+ item. Because a hard-wrapped line in the middle of a paragraph looked like
+ a list item.
+ </para>
+ <para>
+ Here’s one with a bullet. * criminey.
+ </para>
+<literallayout>There should be a hard line break
+here.</literallayout>
+</section>
+<section xml:id="block-quotes">
+ <title>Block Quotes</title>
+ <para>
+ E-mail style:
+ </para>
+ <blockquote>
+ <para>
+ This is a block quote. It is pretty short.
+ </para>
+ </blockquote>
+ <blockquote>
+ <para>
+ Code in a block quote:
+ </para>
+ <programlisting>
+sub status {
+ print &quot;working&quot;;
+}
+</programlisting>
+ <para>
+ A list:
+ </para>
+ <orderedlist numeration="arabic" spacing="compact">
+ <listitem>
+ <para>
+ item one
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ item two
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ Nested block quotes:
+ </para>
+ <blockquote>
+ <para>
+ nested
+ </para>
+ </blockquote>
+ <blockquote>
+ <para>
+ nested
+ </para>
+ </blockquote>
+ </blockquote>
+ <para>
+ This should not be a block quote: 2 &gt; 1.
+ </para>
+ <para>
+ And a following paragraph.
+ </para>
+</section>
+<section xml:id="code-blocks">
+ <title>Code Blocks</title>
+ <para>
+ Code:
+ </para>
+ <programlisting>
+---- (should be four hyphens)
+
+sub status {
+ print &quot;working&quot;;
+}
+
+this code block is indented by one tab
+</programlisting>
+ <para>
+ And:
+ </para>
+ <programlisting>
+ this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \&gt; \[ \{
+</programlisting>
+</section>
+<section xml:id="lists">
+ <title>Lists</title>
+ <section xml:id="unordered">
+ <title>Unordered</title>
+ <para>
+ Asterisks tight:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ asterisk 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ asterisk 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ asterisk 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Asterisks loose:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ asterisk 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ asterisk 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ asterisk 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Pluses tight:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ Plus 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Plus 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Plus 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Pluses loose:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Plus 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Plus 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Plus 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Minuses tight:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ Minus 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Minus 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Minus 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Minuses loose:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ Minus 1
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Minus 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Minus 3
+ </para>
+ </listitem>
+ </itemizedlist>
+ </section>
+ <section xml:id="ordered">
+ <title>Ordered</title>
+ <para>
+ Tight:
+ </para>
+ <orderedlist numeration="arabic" spacing="compact">
+ <listitem>
+ <para>
+ First
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Second
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Third
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ and:
+ </para>
+ <orderedlist numeration="arabic" spacing="compact">
+ <listitem>
+ <para>
+ One
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Two
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Three
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ Loose using tabs:
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ First
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Second
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Third
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ and using spaces:
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ One
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Two
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Three
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ Multiple paragraphs:
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ Item 1, graf one.
+ </para>
+ <para>
+ Item 1. graf two. The quick brown fox jumped over the lazy dog’s
+ back.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Item 2.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Item 3.
+ </para>
+ </listitem>
+ </orderedlist>
+ </section>
+ <section xml:id="nested">
+ <title>Nested</title>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ Tab
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ Tab
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ Tab
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Here’s another:
+ </para>
+ <orderedlist numeration="arabic" spacing="compact">
+ <listitem>
+ <para>
+ First
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Second:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ Fee
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Fie
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Foe
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem>
+ <para>
+ Third
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ Same thing but with paragraphs:
+ </para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>
+ First
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Second:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ Fee
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Fie
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Foe
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem>
+ <para>
+ Third
+ </para>
+ </listitem>
+ </orderedlist>
+ </section>
+ <section xml:id="tabs-and-spaces">
+ <title>Tabs and spaces</title>
+ <itemizedlist>
+ <listitem>
+ <para>
+ this is a list item indented with tabs
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ this is a list item indented with spaces
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ this is an example list item indented with tabs
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ this is an example list item indented with spaces
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+ <section xml:id="fancy-list-markers">
+ <title>Fancy list markers</title>
+ <orderedlist numeration="arabic">
+ <listitem override="2">
+ <para>
+ begins with 2
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ and now 3
+ </para>
+ <para>
+ with a continuation
+ </para>
+ <orderedlist numeration="lowerroman" spacing="compact">
+ <listitem override="4">
+ <para>
+ sublist with roman numerals, starting with 4
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ more items
+ </para>
+ <orderedlist numeration="upperalpha" spacing="compact">
+ <listitem>
+ <para>
+ a subsublist
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ a subsublist
+ </para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ <para>
+ Nesting:
+ </para>
+ <orderedlist numeration="upperalpha" spacing="compact">
+ <listitem>
+ <para>
+ Upper Alpha
+ </para>
+ <orderedlist numeration="upperroman" spacing="compact">
+ <listitem>
+ <para>
+ Upper Roman.
+ </para>
+ <orderedlist numeration="arabic" spacing="compact">
+ <listitem override="6">
+ <para>
+ Decimal start with 6
+ </para>
+ <orderedlist numeration="loweralpha" spacing="compact">
+ <listitem override="3">
+ <para>
+ Lower alpha with paren
+ </para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ <para>
+ Autonumbering:
+ </para>
+ <orderedlist spacing="compact">
+ <listitem>
+ <para>
+ Autonumber.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ More.
+ </para>
+ <orderedlist spacing="compact">
+ <listitem>
+ <para>
+ Nested.
+ </para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </orderedlist>
+ <para>
+ Should not be a list item:
+ </para>
+ <para>
+ M.A. 2007
+ </para>
+ <para>
+ B. Williams
+ </para>
+ </section>
+</section>
+<section xml:id="definition-lists">
+ <title>Definition Lists</title>
+ <para>
+ Tight using spaces:
+ </para>
+ <variablelist spacing="compact">
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ banana
+ </term>
+ <listitem>
+ <para>
+ yellow fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Tight using tabs:
+ </para>
+ <variablelist spacing="compact">
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ banana
+ </term>
+ <listitem>
+ <para>
+ yellow fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Loose:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ banana
+ </term>
+ <listitem>
+ <para>
+ yellow fruit
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Multiple blocks with italics:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ <emphasis>apple</emphasis>
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ <para>
+ contains seeds, crisp, pleasant to taste
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <emphasis>orange</emphasis>
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ <programlisting>
+{ orange code block }
+</programlisting>
+ <blockquote>
+ <para>
+ orange block quote
+ </para>
+ </blockquote>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Multiple definitions, tight:
+ </para>
+ <variablelist spacing="compact">
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ <para>
+ computer
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ <para>
+ bank
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Multiple definitions, loose:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ <para>
+ computer
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ <para>
+ bank
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ Blank line after term, indented marker, alternate markers:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ apple
+ </term>
+ <listitem>
+ <para>
+ red fruit
+ </para>
+ <para>
+ computer
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ orange
+ </term>
+ <listitem>
+ <para>
+ orange fruit
+ </para>
+ <orderedlist numeration="arabic" spacing="compact">
+ <listitem>
+ <para>
+ sublist
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ sublist
+ </para>
+ </listitem>
+ </orderedlist>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+</section>
+<section xml:id="html-blocks">
+ <title>HTML Blocks</title>
+ <para>
+ Simple block on one line:
+ </para>
+ <para>
+ foo
+ </para>
+ <para>
+ And nested without indentation:
+ </para>
+ <para>
+ foo
+ </para>
+ <para>
+ bar
+ </para>
+ <para>
+ Interpreted markdown in a table:
+ </para>
+ This is <emphasis>emphasized</emphasis>
+ And this is <emphasis role="strong">strong</emphasis>
+ <para>
+ Here’s a simple block:
+ </para>
+ <para>
+ foo
+ </para>
+ <para>
+ This should be a code block, though:
+ </para>
+ <programlisting>
+&lt;div&gt;
+ foo
+&lt;/div&gt;
+</programlisting>
+ <para>
+ As should this:
+ </para>
+ <programlisting>
+&lt;div&gt;foo&lt;/div&gt;
+</programlisting>
+ <para>
+ Now, nested:
+ </para>
+ <para>
+ foo
+ </para>
+ <para>
+ This should just be an HTML comment:
+ </para>
+ <para>
+ Multiline:
+ </para>
+ <para>
+ Code block:
+ </para>
+ <programlisting>
+&lt;!-- Comment --&gt;
+</programlisting>
+ <para>
+ Just plain comment, with trailing spaces on the line:
+ </para>
+ <para>
+ Code:
+ </para>
+ <programlisting>
+&lt;hr /&gt;
+</programlisting>
+ <para>
+ Hr’s:
+ </para>
+</section>
+<section xml:id="inline-markup">
+ <title>Inline Markup</title>
+ <para>
+ This is <emphasis>emphasized</emphasis>, and so <emphasis>is
+ this</emphasis>.
+ </para>
+ <para>
+ This is <emphasis role="strong">strong</emphasis>, and so
+ <emphasis role="strong">is this</emphasis>.
+ </para>
+ <para>
+ An <emphasis><link xlink:href="/url">emphasized link</link></emphasis>.
+ </para>
+ <para>
+ <emphasis role="strong"><emphasis>This is strong and
+ em.</emphasis></emphasis>
+ </para>
+ <para>
+ So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.
+ </para>
+ <para>
+ <emphasis role="strong"><emphasis>This is strong and
+ em.</emphasis></emphasis>
+ </para>
+ <para>
+ So is <emphasis role="strong"><emphasis>this</emphasis></emphasis> word.
+ </para>
+ <para>
+ This is code: <literal>&gt;</literal>, <literal>$</literal>,
+ <literal>\</literal>, <literal>\$</literal>,
+ <literal>&lt;html&gt;</literal>.
+ </para>
+ <para>
+ <emphasis role="strikethrough">This is
+ <emphasis>strikeout</emphasis>.</emphasis>
+ </para>
+ <para>
+ Superscripts: a<superscript>bc</superscript>d
+ a<superscript><emphasis>hello</emphasis></superscript>
+ a<superscript>hello there</superscript>.
+ </para>
+ <para>
+ Subscripts: H<subscript>2</subscript>O, H<subscript>23</subscript>O,
+ H<subscript>many of them</subscript>O.
+ </para>
+ <para>
+ These should not be superscripts or subscripts, because of the unescaped
+ spaces: a^b c^d, a~b c~d.
+ </para>
+</section>
+<section xml:id="smart-quotes-ellipses-dashes">
+ <title>Smart quotes, ellipses, dashes</title>
+ <para>
+ <quote>Hello,</quote> said the spider. <quote><quote>Shelob</quote> is my
+ name.</quote>
+ </para>
+ <para>
+ <quote>A</quote>, <quote>B</quote>, and <quote>C</quote> are letters.
+ </para>
+ <para>
+ <quote>Oak,</quote> <quote>elm,</quote> and <quote>beech</quote> are names
+ of trees. So is <quote>pine.</quote>
+ </para>
+ <para>
+ <quote>He said, <quote>I want to go.</quote></quote> Were you alive in the
+ 70’s?
+ </para>
+ <para>
+ Here is some quoted <quote><literal>code</literal></quote> and a
+ <quote><link xlink:href="http://example.com/?foo=1&amp;bar=2">quoted
+ link</link></quote>.
+ </para>
+ <para>
+ Some dashes: one—two — three—four — five.
+ </para>
+ <para>
+ Dashes between numbers: 5–7, 255–66, 1987–1999.
+ </para>
+ <para>
+ Ellipses…and…and….
+ </para>
+</section>
+<section xml:id="latex">
+ <title>LaTeX</title>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ 2 + 2 = 4
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis>x</emphasis> ∈ <emphasis>y</emphasis>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis>α</emphasis> ∧ <emphasis>ω</emphasis>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ 223
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis>p</emphasis>-Tree
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Here’s some display math:
+ $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Here’s one that has a line break in it:
+ <emphasis>α</emphasis> + <emphasis>ω</emphasis> × <emphasis>x</emphasis><superscript>2</superscript>.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ These shouldn’t be math:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ To get the famous equation, write <literal>$e = mc^2$</literal>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ $22,000 is a <emphasis>lot</emphasis> of money. So is $34,000. (It
+ worked if <quote>lot</quote> is emphasized.)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Shoes ($20) and socks ($5).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Escaped <literal>$</literal>: $73 <emphasis>this should be
+ emphasized</emphasis> 23$.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Here’s a LaTeX table:
+ </para>
+</section>
+<section xml:id="special-characters">
+ <title>Special Characters</title>
+ <para>
+ Here is some unicode:
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ I hat: Î
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ o umlaut: ö
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ section: §
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ set membership: ∈
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ copyright: ©
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ AT&amp;T has an ampersand in their name.
+ </para>
+ <para>
+ AT&amp;T is another way to write it.
+ </para>
+ <para>
+ This &amp; that.
+ </para>
+ <para>
+ 4 &lt; 5.
+ </para>
+ <para>
+ 6 &gt; 5.
+ </para>
+ <para>
+ Backslash: \
+ </para>
+ <para>
+ Backtick: `
+ </para>
+ <para>
+ Asterisk: *
+ </para>
+ <para>
+ Underscore: _
+ </para>
+ <para>
+ Left brace: {
+ </para>
+ <para>
+ Right brace: }
+ </para>
+ <para>
+ Left bracket: [
+ </para>
+ <para>
+ Right bracket: ]
+ </para>
+ <para>
+ Left paren: (
+ </para>
+ <para>
+ Right paren: )
+ </para>
+ <para>
+ Greater-than: &gt;
+ </para>
+ <para>
+ Hash: #
+ </para>
+ <para>
+ Period: .
+ </para>
+ <para>
+ Bang: !
+ </para>
+ <para>
+ Plus: +
+ </para>
+ <para>
+ Minus: -
+ </para>
+</section>
+<section xml:id="links">
+ <title>Links</title>
+ <section xml:id="explicit">
+ <title>Explicit</title>
+ <para>
+ Just a <link xlink:href="/url/">URL</link>.
+ </para>
+ <para>
+ <link xlink:href="/url/">URL and title</link>.
+ </para>
+ <para>
+ <link xlink:href="/url/">URL and title</link>.
+ </para>
+ <para>
+ <link xlink:href="/url/">URL and title</link>.
+ </para>
+ <para>
+ <link xlink:href="/url/">URL and title</link>
+ </para>
+ <para>
+ <link xlink:href="/url/">URL and title</link>
+ </para>
+ <para>
+ <link xlink:href="/url/with_underscore">with_underscore</link>
+ </para>
+ <para>
+ Email link (<email>nobody@nowhere.net</email>)
+ </para>
+ <para>
+ <link xlink:href="">Empty</link>.
+ </para>
+ </section>
+ <section xml:id="reference">
+ <title>Reference</title>
+ <para>
+ Foo <link xlink:href="/url/">bar</link>.
+ </para>
+ <para>
+ Foo <link xlink:href="/url/">bar</link>.
+ </para>
+ <para>
+ Foo <link xlink:href="/url/">bar</link>.
+ </para>
+ <para>
+ With <link xlink:href="/url/">embedded [brackets]</link>.
+ </para>
+ <para>
+ <link xlink:href="/url/">b</link> by itself should be a link.
+ </para>
+ <para>
+ Indented <link xlink:href="/url">once</link>.
+ </para>
+ <para>
+ Indented <link xlink:href="/url">twice</link>.
+ </para>
+ <para>
+ Indented <link xlink:href="/url">thrice</link>.
+ </para>
+ <para>
+ This should [not][] be a link.
+ </para>
+ <programlisting>
+[not]: /url
+</programlisting>
+ <para>
+ Foo <link xlink:href="/url/">bar</link>.
+ </para>
+ <para>
+ Foo <link xlink:href="/url/">biz</link>.
+ </para>
+ </section>
+ <section xml:id="with-ampersands">
+ <title>With ampersands</title>
+ <para>
+ Here’s a <link xlink:href="http://example.com/?foo=1&amp;bar=2">link
+ with an ampersand in the URL</link>.
+ </para>
+ <para>
+ Here’s a link with an amersand in the link text:
+ <link xlink:href="http://att.com/">AT&amp;T</link>.
+ </para>
+ <para>
+ Here’s an <link xlink:href="/script?foo=1&amp;bar=2">inline link</link>.
+ </para>
+ <para>
+ Here’s an <link xlink:href="/script?foo=1&amp;bar=2">inline link in
+ pointy braces</link>.
+ </para>
+ </section>
+ <section xml:id="autolinks">
+ <title>Autolinks</title>
+ <para>
+ With an ampersand:
+ <link xlink:href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</link>
+ </para>
+ <itemizedlist spacing="compact">
+ <listitem>
+ <para>
+ In a list?
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <link xlink:href="http://example.com/">http://example.com/</link>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ It should.
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ An e-mail address: <email>nobody@nowhere.net</email>
+ </para>
+ <blockquote>
+ <para>
+ Blockquoted:
+ <link xlink:href="http://example.com/">http://example.com/</link>
+ </para>
+ </blockquote>
+ <para>
+ Auto-links should not occur here:
+ <literal>&lt;http://example.com/&gt;</literal>
+ </para>
+ <programlisting>
+or here: &lt;http://example.com/&gt;
+</programlisting>
+ </section>
+</section>
+<section xml:id="images">
+ <title>Images</title>
+ <para>
+ From <quote>Voyage dans la Lune</quote> by Georges Melies (1902):
+ </para>
+ <figure>
+ <title>lalune</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="lalune.jpg" />
+ </imageobject>
+ <textobject><phrase>lalune</phrase></textobject>
+ </mediaobject>
+ </figure>
+ <para>
+ Here is a movie <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="movie.jpg" />
+ </imageobject>
+ </inlinemediaobject> icon.
+ </para>
+</section>
+<section xml:id="footnotes">
+ <title>Footnotes</title>
+ <para>
+ Here is a footnote reference,<footnote>
+ <para>
+ Here is the footnote. It can go anywhere after the footnote reference.
+ It need not be placed at the end of the document.
+ </para>
+ </footnote> and another.<footnote>
+ <para>
+ Here’s the long note. This one contains multiple blocks.
+ </para>
+ <para>
+ Subsequent blocks are indented to show that they belong to the
+ footnote (as with list items).
+ </para>
+ <programlisting>
+ { &lt;code&gt; }
+</programlisting>
+ <para>
+ If you want, you can indent every line, but you can also be lazy and
+ just indent the first line of each block.
+ </para>
+ </footnote> This should <emphasis>not</emphasis> be a footnote reference,
+ because it contains a space.[^my note] Here is an inline note.<footnote>
+ <para>
+ This is <emphasis>easier</emphasis> to type. Inline notes may contain
+ <link xlink:href="http://google.com">links</link> and
+ <literal>]</literal> verbatim characters, as well as [bracketed text].
+ </para>
+ </footnote>
+ </para>
+ <blockquote>
+ <para>
+ Notes can go in quotes.<footnote>
+ <para>
+ In quote.
+ </para>
+ </footnote>
+ </para>
+ </blockquote>
+ <orderedlist numeration="arabic" spacing="compact">
+ <listitem>
+ <para>
+ And in list items.<footnote>
+ <para>
+ In list.
+ </para>
+ </footnote>
+ </para>
+ </listitem>
+ </orderedlist>
+ <para>
+ This paragraph should not be part of the note, as it is not indented.
+ </para>
+</section>
+</article>
diff --git a/test/writer.dokuwiki b/test/writer.dokuwiki
new file mode 100644
index 000000000..79fcdde8a
--- /dev/null
+++ b/test/writer.dokuwiki
@@ -0,0 +1,642 @@
+This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite.
+
+
+----
+
+====== Headers ======
+
+===== Level 2 with an embedded link =====
+
+==== Level 3 with emphasis ====
+
+=== Level 4 ===
+
+== Level 5 ==
+
+====== Level 1 ======
+
+===== Level 2 with emphasis =====
+
+==== Level 3 ====
+
+with no blank line
+
+===== Level 2 =====
+
+with no blank line
+
+
+----
+
+====== Paragraphs ======
+
+Here’s a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard-wrapped line in the middle of a paragraph looked like a list item.
+
+Here’s one with a bullet. * criminey.
+
+There should be a hard line break\\
+here.
+
+
+----
+
+====== Block Quotes ======
+
+E-mail style:
+
+> This is a block quote. It is pretty short.
+
+<HTML><blockquote>
+Code in a block quote:
+
+<code>
+sub status {
+ print "working";
+}
+</code>
+A list:
+
+ - item one
+ - item two
+
+Nested block quotes:
+
+> nested
+
+> nested
+</blockquote></HTML>
+This should not be a block quote: 2 > 1.
+
+And a following paragraph.
+
+
+----
+
+====== Code Blocks ======
+
+Code:
+
+<code>
+---- (should be four hyphens)
+
+sub status {
+ print "working";
+}
+
+this code block is indented by one tab
+</code>
+And:
+
+<code>
+ this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \> \[ \{
+</code>
+
+----
+
+====== Lists ======
+
+===== Unordered =====
+
+Asterisks tight:
+
+ * asterisk 1
+ * asterisk 2
+ * asterisk 3
+
+Asterisks loose:
+
+ * asterisk 1
+ * asterisk 2
+ * asterisk 3
+
+Pluses tight:
+
+ * Plus 1
+ * Plus 2
+ * Plus 3
+
+Pluses loose:
+
+ * Plus 1
+ * Plus 2
+ * Plus 3
+
+Minuses tight:
+
+ * Minus 1
+ * Minus 2
+ * Minus 3
+
+Minuses loose:
+
+ * Minus 1
+ * Minus 2
+ * Minus 3
+
+===== Ordered =====
+
+Tight:
+
+ - First
+ - Second
+ - Third
+
+and:
+
+ - One
+ - Two
+ - Three
+
+Loose using tabs:
+
+ - First
+ - Second
+ - Third
+
+and using spaces:
+
+ - One
+ - Two
+ - Three
+
+Multiple paragraphs:
+
+<HTML><ol style="list-style-type: decimal;"></HTML>
+<HTML><li></HTML><HTML><p></HTML>Item 1, graf one.<HTML></p></HTML>
+<HTML><p></HTML>Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.<HTML></p></HTML><HTML></li></HTML>
+<HTML><li></HTML><HTML><p></HTML>Item 2.<HTML></p></HTML><HTML></li></HTML>
+<HTML><li></HTML><HTML><p></HTML>Item 3.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML>
+
+===== Nested =====
+
+ * Tab
+ * Tab
+ * Tab
+
+Here’s another:
+
+ - First
+ - Second:
+ * Fee
+ * Fie
+ * Foe
+ - Third
+
+Same thing but with paragraphs:
+
+ - First
+ - Second:
+ * Fee
+ * Fie
+ * Foe
+ - Third
+
+===== Tabs and spaces =====
+
+ * this is a list item indented with tabs
+ * this is a list item indented with spaces
+ * this is an example list item indented with tabs
+ * this is an example list item indented with spaces
+
+===== Fancy list markers =====
+
+<HTML><ol start="2" style="list-style-type: decimal;"></HTML>
+<HTML><li></HTML>begins with 2<HTML></li></HTML>
+<HTML><li></HTML><HTML><p></HTML>and now 3<HTML></p></HTML>
+<HTML><p></HTML>with a continuation<HTML></p></HTML>
+<HTML><ol start="4" style="list-style-type: lower-roman;"></HTML>
+<HTML><li></HTML>sublist with roman numerals, starting with 4<HTML></li></HTML>
+<HTML><li></HTML>more items
+<HTML><ol style="list-style-type: upper-alpha;"></HTML>
+<HTML><li></HTML>a subsublist<HTML></li></HTML>
+<HTML><li></HTML>a subsublist<HTML></li></HTML><HTML></ol></HTML>
+<HTML></li></HTML><HTML></ol></HTML>
+<HTML></li></HTML><HTML></ol></HTML>
+
+Nesting:
+
+<HTML><ol style="list-style-type: upper-alpha;"></HTML>
+<HTML><li></HTML>Upper Alpha
+<HTML><ol style="list-style-type: upper-roman;"></HTML>
+<HTML><li></HTML>Upper Roman.
+<HTML><ol start="6" style="list-style-type: decimal;"></HTML>
+<HTML><li></HTML>Decimal start with 6
+<HTML><ol start="3" style="list-style-type: lower-alpha;"></HTML>
+<HTML><li></HTML>Lower alpha with paren<HTML></li></HTML><HTML></ol></HTML>
+<HTML></li></HTML><HTML></ol></HTML>
+<HTML></li></HTML><HTML></ol></HTML>
+<HTML></li></HTML><HTML></ol></HTML>
+
+Autonumbering:
+
+ - Autonumber.
+ - More.
+ - Nested.
+
+Should not be a list item:
+
+M.A. 2007
+
+B. Williams
+
+
+----
+
+====== Definition Lists ======
+
+Tight using spaces:
+
+ * **apple** red fruit
+ * **orange** orange fruit
+ * **banana** yellow fruit
+
+Tight using tabs:
+
+ * **apple** red fruit
+ * **orange** orange fruit
+ * **banana** yellow fruit
+
+Loose:
+
+ * **apple** red fruit
+ * **orange** orange fruit
+ * **banana** yellow fruit
+
+Multiple blocks with italics:
+
+<HTML><dl></HTML>
+<HTML><dt></HTML>//apple//<HTML></dt></HTML>
+<HTML><dd></HTML><HTML><p></HTML>red fruit<HTML></p></HTML>
+<HTML><p></HTML>contains seeds, crisp, pleasant to taste<HTML></p></HTML><HTML></dd></HTML>
+<HTML><dt></HTML>//orange//<HTML></dt></HTML>
+<HTML><dd></HTML><HTML><p></HTML>orange fruit<HTML></p></HTML>
+<code>
+{ orange code block }
+</code>
+> <HTML><p></HTML>orange block quote<HTML></p></HTML>
+<HTML></dd></HTML><HTML></dl></HTML>
+
+Multiple definitions, tight:
+
+ * **apple** red fruitcomputer
+ * **orange** orange fruitbank
+
+Multiple definitions, loose:
+
+ * **apple** red fruitcomputer
+ * **orange** orange fruitbank
+
+Blank line after term, indented marker, alternate markers:
+
+ * **apple** red fruitcomputer
+ * **orange** orange fruit
+ - sublist
+ - sublist
+
+====== HTML Blocks ======
+
+Simple block on one line:
+
+foo
+
+And nested without indentation:
+
+foo
+
+
+
+bar
+
+
+Interpreted markdown in a table:
+
+<HTML>
+<table>
+<tr>
+<td>
+</HTML>
+This is //emphasized//
+<HTML>
+</td>
+<td>
+</HTML>
+And this is **strong**
+<HTML>
+</td>
+</tr>
+</table>
+<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
+</HTML>
+Here’s a simple block:
+
+foo
+
+
+This should be a code block, though:
+
+<code>
+<div>
+ foo
+</div>
+</code>
+As should this:
+
+<code>
+<div>foo</div>
+</code>
+Now, nested:
+
+foo
+
+
+
+This should just be an HTML comment:
+
+<HTML>
+<!-- Comment -->
+</HTML>
+Multiline:
+
+<HTML>
+<!--
+Blah
+Blah
+-->
+<!--
+ This is another comment.
+-->
+</HTML>
+Code block:
+
+<code>
+<!-- Comment -->
+</code>
+Just plain comment, with trailing spaces on the line:
+
+<HTML>
+<!-- foo -->
+</HTML>
+Code:
+
+<code>
+<hr />
+</code>
+Hr’s:
+
+<HTML>
+<hr>
+<hr />
+<hr />
+<hr>
+<hr />
+<hr />
+<hr class="foo" id="bar" />
+<hr class="foo" id="bar" />
+<hr class="foo" id="bar">
+</HTML>
+
+----
+
+====== Inline Markup ======
+
+This is //emphasized//, and so //is this//.
+
+This is **strong**, and so **is this**.
+
+An //[[url|emphasized link]]//.
+
+**//This is strong and em.//**
+
+So is **//this//** word.
+
+**//This is strong and em.//**
+
+So is **//this//** word.
+
+This is code: ''%%>%%'', ''%%$%%'', ''%%\%%'', ''%%\$%%'', ''%%<html>%%''.
+
+<del>This is //strikeout//.</del>
+
+Superscripts: a<sup>bc</sup>d a<sup>//hello//</sup> a<sup>hello there</sup>.
+
+Subscripts: H<sub>2</sub>O, H<sub>23</sub>O, H<sub>many of them</sub>O.
+
+These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.
+
+
+----
+
+====== Smart quotes, ellipses, dashes ======
+
+“Hello,” said the spider. “‘Shelob’ is my name.”
+
+‘A’, ‘B’, and ‘C’ are letters.
+
+‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’
+
+‘He said, “I want to go.”’ Were you alive in the 70’s?
+
+Here is some quoted ‘''%%code%%''’ and a “[[http://example.com/?foo=1&bar=2|quoted link]]”.
+
+Some dashes: one—two — three—four — five.
+
+Dashes between numbers: 5–7, 255–66, 1987–1999.
+
+Ellipses…and…and….
+
+
+----
+
+====== LaTeX ======
+
+ *
+ * $2+2=4$
+ * $x \in y$
+ * $\alpha \wedge \omega$
+ * $223$
+ * $p$-Tree
+ * Here’s some display math: $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
+ * Here’s one that has a line break in it: $\alpha + \omega \times x^2$.
+
+These shouldn’t be math:
+
+ * To get the famous equation, write ''%%$e = mc^2$%%''.
+ * $22,000 is a //lot// of money. So is $34,000. (It worked if “lot” is emphasized.)
+ * Shoes ($20) and socks ($5).
+ * Escaped ''%%$%%'': $73 //this should be emphasized// 23$.
+
+Here’s a LaTeX table:
+
+
+
+----
+
+====== Special Characters ======
+
+Here is some unicode:
+
+ * I hat: Î
+ * o umlaut: ö
+ * section: §
+ * set membership: ∈
+ * copyright: ©
+
+AT&T has an ampersand in their name.
+
+AT&T is another way to write it.
+
+This & that.
+
+4 < 5.
+
+6 > 5.
+
+Backslash: \
+
+Backtick: `
+
+Asterisk: *
+
+Underscore: _
+
+Left brace: {
+
+Right brace: }
+
+Left bracket: [
+
+Right bracket: ]
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: >
+
+Hash: #
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+
+----
+
+====== Links ======
+
+===== Explicit =====
+
+Just a [[url/|URL]].
+
+[[url/|URL and title]].
+
+[[url/|URL and title]].
+
+[[url/|URL and title]].
+
+[[url/|URL and title]]
+
+[[url/|URL and title]]
+
+[[url/with_underscore|with_underscore]]
+
+[[mailto:nobody@nowhere.net|Email link]]
+
+[[|Empty]].
+
+===== Reference =====
+
+Foo [[url/|bar]].
+
+Foo [[url/|bar]].
+
+Foo [[url/|bar]].
+
+With [[url/|embedded [brackets]]].
+
+[[url/|b]] by itself should be a link.
+
+Indented [[url|once]].
+
+Indented [[url|twice]].
+
+Indented [[url|thrice]].
+
+This should [not][] be a link.
+
+<code>
+[not]: /url
+</code>
+Foo [[url/|bar]].
+
+Foo [[url/|biz]].
+
+===== With ampersands =====
+
+Here’s a [[http://example.com/?foo=1&bar=2|link with an ampersand in the URL]].
+
+Here’s a link with an amersand in the link text: [[http://att.com/|AT&T]].
+
+Here’s an [[script?foo=1&bar=2|inline link]].
+
+Here’s an [[script?foo=1&bar=2|inline link in pointy braces]].
+
+===== Autolinks =====
+
+With an ampersand: http://example.com/?foo=1&bar=2
+
+ * In a list?
+ * http://example.com/
+ * It should.
+
+An e-mail address: <nobody@nowhere.net>
+
+> Blockquoted: http://example.com/
+
+Auto-links should not occur here: ''%%<http://example.com/>%%''
+
+<code>
+or here: <http://example.com/>
+</code>
+
+----
+
+====== Images ======
+
+From “Voyage dans la Lune” by Georges Melies (1902):
+
+{{:lalune.jpg|Voyage dans la Lune lalune}}
+
+Here is a movie {{:movie.jpg|movie}} icon.
+
+
+----
+
+====== Footnotes ======
+
+Here is a footnote reference,((Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.
+)) and another.((Here’s the long note. This one contains multiple blocks.
+
+Subsequent blocks are indented to show that they belong to the footnote (as with list items).
+
+<code>
+ { <code> }
+</code>
+If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.
+)) This should //not// be a footnote reference, because it contains a space.[^my note] Here is an inline note.((This is //easier// to type. Inline notes may contain [[http://google.com|links]] and ''%%]%%'' verbatim characters, as well as [bracketed text].
+))
+
+> Notes can go in quotes.((In quote.
+> ))
+
+ - And in list items.((In list.))
+
+This paragraph should not be part of the note, as it is not indented.
diff --git a/test/writer.fb2 b/test/writer.fb2
new file mode 100644
index 000000000..0412c8cf4
--- /dev/null
+++ b/test/writer.fb2
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"><description><title-info><book-title>Pandoc Test Suite</book-title><author><first-name>John</first-name><last-name>MacFarlane</last-name></author><author><nickname>Anonymous</nickname></author><date>July 17, 2006</date></title-info><document-info><program-used>pandoc</program-used></document-info></description><body><title><p>Pandoc Test Suite</p></title><annotation><p>John MacFarlane</p><p>Anonymous</p><p>July 17, 2006</p></annotation><section><p>This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite.</p><empty-line /><p>——————————</p><empty-line /></section><section><title><p>Headers</p></title><section><title><p>Level 2 with an embedded link &lt;/url&gt;</p></title><section><title><p>Level 3 with emphasis</p></title><section><title><p>Level 4</p></title><section><title><p>Level 5</p></title></section></section></section></section></section><section><title><p>Level 1</p></title><section><title><p>Level 2 with emphasis</p></title><section><title><p>Level 3</p></title><p>with no blank line</p></section></section><section><title><p>Level 2</p></title><p>with no blank line</p><empty-line /><p>——————————</p><empty-line /></section></section><section><title><p>Paragraphs</p></title><p>Here’s a regular paragraph.</p><p>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.</p><p>Here’s one with a bullet. * criminey.</p><p>There should be a hard line break<empty-line />here.</p><empty-line /><p>——————————</p><empty-line /></section><section><title><p>Block Quotes</p></title><p>E-mail style:</p><cite><p>This is a block quote. It is pretty short.</p></cite><cite><p>Code in a block quote:</p><empty-line /><p><code>sub status {</code></p><p><code> print &quot;working&quot;;</code></p><p><code>}</code></p><empty-line /><p>A list:</p><p> 1. item one</p><p> 2. item two</p><p>Nested block quotes:</p><cite><p>nested</p></cite><cite><p>nested</p></cite></cite><p>This should not be a block quote: 2 &gt; 1.</p><p>And a following paragraph.</p><empty-line /><p>——————————</p><empty-line /></section><section><title><p>Code Blocks</p></title><p>Code:</p><empty-line /><p><code>---- (should be four hyphens)</code></p><p><code></code></p><p><code>sub status {</code></p><p><code> print &quot;working&quot;;</code></p><p><code>}</code></p><p><code></code></p><p><code>this code block is indented by one tab</code></p><empty-line /><p>And:</p><empty-line /><p><code> this code block is indented by two tabs</code></p><p><code></code></p><p><code>These should not be escaped: \$ \\ \&gt; \[ \{</code></p><empty-line /><empty-line /><p>——————————</p><empty-line /></section><section><title><p>Lists</p></title><section><title><p>Unordered</p></title><p>Asterisks tight:</p><p>• asterisk 1</p><p>• asterisk 2</p><p>• asterisk 3</p><p>Asterisks loose:</p><p>• asterisk 1<empty-line /></p><p>• asterisk 2<empty-line /></p><p>• asterisk 3<empty-line /></p><p>Pluses tight:</p><p>• Plus 1</p><p>• Plus 2</p><p>• Plus 3</p><p>Pluses loose:</p><p>• Plus 1<empty-line /></p><p>• Plus 2<empty-line /></p><p>• Plus 3<empty-line /></p><p>Minuses tight:</p><p>• Minus 1</p><p>• Minus 2</p><p>• Minus 3</p><p>Minuses loose:</p><p>• Minus 1<empty-line /></p><p>• Minus 2<empty-line /></p><p>• Minus 3<empty-line /></p></section><section><title><p>Ordered</p></title><p>Tight:</p><p> 1. First</p><p> 2. Second</p><p> 3. Third</p><p>and:</p><p> 1. One</p><p> 2. Two</p><p> 3. Three</p><p>Loose using tabs:</p><p> 1. First<empty-line /></p><p> 2. Second<empty-line /></p><p> 3. Third<empty-line /></p><p>and using spaces:</p><p> 1. One<empty-line /></p><p> 2. Two<empty-line /></p><p> 3. Three<empty-line /></p><p>Multiple paragraphs:</p><p> 1. Item 1, graf one.<empty-line />Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.<empty-line /></p><p> 2. Item 2.<empty-line /></p><p> 3. Item 3.<empty-line /></p></section><section><title><p>Nested</p></title><p>• Tab<p>◦ Tab<p>* Tab</p></p></p><p>Here’s another:</p><p> 1. First</p><p> 2. Second:<p>   • Fee</p><p>   • Fie</p><p>   • Foe</p></p><p> 3. Third</p><p>Same thing but with paragraphs:</p><p> 1. First<empty-line /></p><p> 2. Second:<empty-line /><p>   • Fee</p><p>   • Fie</p><p>   • Foe</p></p><p> 3. Third<empty-line /></p></section><section><title><p>Tabs and spaces</p></title><p>• this is a list item indented with tabs<empty-line /></p><p>• this is a list item indented with spaces<empty-line /><p>◦ this is an example list item indented with tabs<empty-line /></p><p>◦ this is an example list item indented with spaces<empty-line /></p></p></section><section><title><p>Fancy list markers</p></title><p> (2) begins with 2</p><p> (3) and now 3<empty-line />with a continuation<empty-line /><p> (3) iv. sublist with roman numerals, starting with 4</p><p> (3) v. more items<p> (3) v. (A) a subsublist</p><p> (3) v. (B) a subsublist</p></p></p><p>Nesting:</p><p> A. Upper Alpha<p> A. I. Upper Roman.<p> A. I. (6) Decimal start with 6<p> A. I. (6) c) Lower alpha with paren</p></p></p></p><p>Autonumbering:</p><p> 1. Autonumber.</p><p> 2. More.<p> 2. 1. Nested.</p></p><p>Should not be a list item:</p><p>M.A. 2007</p><p>B. Williams</p><empty-line /><p>——————————</p><empty-line /></section></section><section><title><p>Definition Lists</p></title><p>Tight using spaces:</p><p><strong>apple</strong></p><p>    red fruit<empty-line /></p><p><strong>orange</strong></p><p>    orange fruit<empty-line /></p><p><strong>banana</strong></p><p>    yellow fruit<empty-line /></p><p>Tight using tabs:</p><p><strong>apple</strong></p><p>    red fruit<empty-line /></p><p><strong>orange</strong></p><p>    orange fruit<empty-line /></p><p><strong>banana</strong></p><p>    yellow fruit<empty-line /></p><p>Loose:</p><p><strong>apple</strong></p><p>    red fruit<empty-line /></p><p><strong>orange</strong></p><p>    orange fruit<empty-line /></p><p><strong>banana</strong></p><p>    yellow fruit<empty-line /></p><p>Multiple blocks with italics:</p><p><strong><emphasis>apple</emphasis></strong></p><p>    red fruit<empty-line />    contains seeds, crisp, pleasant to taste<empty-line /></p><p><strong><emphasis>orange</emphasis></strong></p><p>    orange fruit<empty-line /><empty-line /><p><code>    { orange code block }</code></p><empty-line /><cite><p>    orange block quote</p></cite></p><p>Multiple definitions, tight:</p><p><strong>apple</strong></p><p>    red fruit<empty-line />    computer<empty-line /></p><p><strong>orange</strong></p><p>    orange fruit<empty-line />    bank<empty-line /></p><p>Multiple definitions, loose:</p><p><strong>apple</strong></p><p>    red fruit<empty-line />    computer<empty-line /></p><p><strong>orange</strong></p><p>    orange fruit<empty-line />    bank<empty-line /></p><p>Blank line after term, indented marker, alternate markers:</p><p><strong>apple</strong></p><p>    red fruit<empty-line />    computer<empty-line /></p><p><strong>orange</strong></p><p>    orange fruit<empty-line /><p> 1. sublist</p><p> 2. sublist</p></p></section><section><title><p>HTML Blocks</p></title><p>Simple block on one line:</p>foo<p>And nested without indentation:</p><p>foo</p>bar<p>Interpreted markdown in a table:</p>This is <emphasis>emphasized</emphasis>And this is <strong>strong</strong><p>Here’s a simple block:</p><p>foo</p><p>This should be a code block, though:</p><empty-line /><p><code>&lt;div&gt;</code></p><p><code> foo</code></p><p><code>&lt;/div&gt;</code></p><empty-line /><p>As should this:</p><empty-line /><p><code>&lt;div&gt;foo&lt;/div&gt;</code></p><empty-line /><p>Now, nested:</p>foo<p>This should just be an HTML comment:</p><p>Multiline:</p><p>Code block:</p><empty-line /><p><code>&lt;!-- Comment --&gt;</code></p><empty-line /><p>Just plain comment, with trailing spaces on the line:</p><p>Code:</p><empty-line /><p><code>&lt;hr /&gt;</code></p><empty-line /><p>Hr’s:</p><empty-line /><p>——————————</p><empty-line /></section><section><title><p>Inline Markup</p></title><p>This is <emphasis>emphasized</emphasis>, and so <emphasis>is this</emphasis>.</p><p>This is <strong>strong</strong>, and so <strong>is this</strong>.</p><p>An <emphasis>emphasized link<a l:href="#l1" type="note"><sup>[1]</sup></a></emphasis>.</p><p><strong><emphasis>This is strong and em.</emphasis></strong></p><p>So is <strong><emphasis>this</emphasis></strong> word.</p><p><strong><emphasis>This is strong and em.</emphasis></strong></p><p>So is <strong><emphasis>this</emphasis></strong> word.</p><p>This is code: <code>&gt;</code>, <code>$</code>, <code>\</code>, <code>\$</code>, <code>&lt;html&gt;</code>.</p><p><strikethrough>This is <emphasis>strikeout</emphasis>.</strikethrough></p><p>Superscripts: a<sup>bc</sup>d a<sup><emphasis>hello</emphasis></sup> a<sup>hello there</sup>.</p><p>Subscripts: H<sub>2</sub>O, H<sub>23</sub>O, H<sub>many of them</sub>O.</p><p>These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.</p><empty-line /><p>——————————</p><empty-line /></section><section><title><p>Smart quotes, ellipses, dashes</p></title><p>“Hello,” said the spider. “‘Shelob’ is my name.”</p><p>‘A’, ‘B’, and ‘C’ are letters.</p><p>‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’</p><p>‘He said, “I want to go.”’ Were you alive in the 70’s?</p><p>Here is some quoted ‘<code>code</code>’ and a “quoted link<a l:href="#l2" type="note"><sup>[2]</sup></a>”.</p><p>Some dashes: one—two — three—four — five.</p><p>Dashes between numbers: 5–7, 255–66, 1987–1999.</p><p>Ellipses…and…and….</p><empty-line /><p>——————————</p><empty-line /></section><section><title><p>LaTeX</p></title><p>• </p><p>• <code>2+2=4</code></p><p>• <code>x \in y</code></p><p>• <code>\alpha \wedge \omega</code></p><p>• <code>223</code></p><p>• <code>p</code>-Tree</p><p>• Here’s some display math: <code>\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</code></p><p>• Here’s one that has a line break in it: <code>\alpha + \omega \times x^2</code>.</p><p>These shouldn’t be math:</p><p>• To get the famous equation, write <code>$e = mc^2$</code>.</p><p>• $22,000 is a <emphasis>lot</emphasis> of money. So is $34,000. (It worked if “lot” is emphasized.)</p><p>• Shoes ($20) and socks ($5).</p><p>• Escaped <code>$</code>: $73 <emphasis>this should be emphasized</emphasis> 23$.</p><p>Here’s a LaTeX table:</p><empty-line /><p>——————————</p><empty-line /></section><section><title><p>Special Characters</p></title><p>Here is some unicode:</p><p>• I hat: Î</p><p>• o umlaut: ö</p><p>• section: §</p><p>• set membership: ∈</p><p>• copyright: ©</p><p>AT&amp;T has an ampersand in their name.</p><p>AT&amp;T is another way to write it.</p><p>This &amp; that.</p><p>4 &lt; 5.</p><p>6 &gt; 5.</p><p>Backslash: \</p><p>Backtick: `</p><p>Asterisk: *</p><p>Underscore: _</p><p>Left brace: {</p><p>Right brace: }</p><p>Left bracket: [</p><p>Right bracket: ]</p><p>Left paren: (</p><p>Right paren: )</p><p>Greater-than: &gt;</p><p>Hash: #</p><p>Period: .</p><p>Bang: !</p><p>Plus: +</p><p>Minus: -</p><empty-line /><p>——————————</p><empty-line /></section><section><title><p>Links</p></title><section><title><p>Explicit</p></title><p>Just a URL<a l:href="#l3" type="note"><sup>[3]</sup></a>.</p><p>URL and title<a l:href="#l4" type="note"><sup>[4]</sup></a>.</p><p>URL and title<a l:href="#l5" type="note"><sup>[5]</sup></a>.</p><p>URL and title<a l:href="#l6" type="note"><sup>[6]</sup></a>.</p><p>URL and title<a l:href="#l7" type="note"><sup>[7]</sup></a></p><p>URL and title<a l:href="#l8" type="note"><sup>[8]</sup></a></p><p>with_underscore<a l:href="#l9" type="note"><sup>[9]</sup></a></p><p>Email link<a l:href="#l10" type="note"><sup>[10]</sup></a></p><p>Empty<a l:href="#l11" type="note"><sup>[11]</sup></a>.</p></section><section><title><p>Reference</p></title><p>Foo bar<a l:href="#l12" type="note"><sup>[12]</sup></a>.</p><p>Foo bar<a l:href="#l13" type="note"><sup>[13]</sup></a>.</p><p>Foo bar<a l:href="#l14" type="note"><sup>[14]</sup></a>.</p><p>With embedded [brackets]<a l:href="#l15" type="note"><sup>[15]</sup></a>.</p><p>b<a l:href="#l16" type="note"><sup>[16]</sup></a> by itself should be a link.</p><p>Indented once<a l:href="#l17" type="note"><sup>[17]</sup></a>.</p><p>Indented twice<a l:href="#l18" type="note"><sup>[18]</sup></a>.</p><p>Indented thrice<a l:href="#l19" type="note"><sup>[19]</sup></a>.</p><p>This should [not][] be a link.</p><empty-line /><p><code>[not]: /url</code></p><empty-line /><p>Foo bar<a l:href="#l20" type="note"><sup>[20]</sup></a>.</p><p>Foo biz<a l:href="#l21" type="note"><sup>[21]</sup></a>.</p></section><section><title><p>With ampersands</p></title><p>Here’s a link with an ampersand in the URL<a l:href="#l22" type="note"><sup>[22]</sup></a>.</p><p>Here’s a link with an amersand in the link text: AT&amp;T<a l:href="#l23" type="note"><sup>[23]</sup></a>.</p><p>Here’s an inline link<a l:href="#l24" type="note"><sup>[24]</sup></a>.</p><p>Here’s an inline link in pointy braces<a l:href="#l25" type="note"><sup>[25]</sup></a>.</p></section><section><title><p>Autolinks</p></title><p>With an ampersand: http://example.com/?foo=1&amp;bar=2<a l:href="#l26" type="note"><sup>[26]</sup></a></p><p>• In a list?</p><p>• http://example.com/<a l:href="#l27" type="note"><sup>[27]</sup></a></p><p>• It should.</p><p>An e-mail address: nobody@nowhere.net<a l:href="#l28" type="note"><sup>[28]</sup></a></p><cite><p>Blockquoted: http://example.com/<a l:href="#l29" type="note"><sup>[29]</sup></a></p></cite><p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p><empty-line /><p><code>or here: &lt;http://example.com/&gt;</code></p><empty-line /><empty-line /><p>——————————</p><empty-line /></section></section><section><title><p>Images</p></title><p>From “Voyage dans la Lune” by Georges Melies (1902):</p><image l:href="#image1" l:type="imageType" alt="lalune" title="Voyage dans la Lune" /><p>Here is a movie <image l:href="#image2" l:type="inlineImageType" alt="movie" /> icon.</p><empty-line /><p>——————————</p><empty-line /></section><section><title><p>Footnotes</p></title><p>Here is a footnote reference,<a l:href="#n30" type="note"><sup>[30]</sup></a> and another.<a l:href="#n31" type="note"><sup>[31]</sup></a> This should <emphasis>not</emphasis> be a footnote reference, because it contains a space.[^my note] Here is an inline note.<a l:href="#n32" type="note"><sup>[32]</sup></a></p><cite><p>Notes can go in quotes.<a l:href="#n33" type="note"><sup>[33]</sup></a></p></cite><p> 1. And in list items.<a l:href="#n34" type="note"><sup>[34]</sup></a></p><p>This paragraph should not be part of the note, as it is not indented.</p></section></body><body name="notes"><section id="l1"><title><p>1</p></title><p><code>/url</code></p></section><section id="l2"><title><p>2</p></title><p><code>http://example.com/?foo=1&amp;bar=2</code></p></section><section id="l3"><title><p>3</p></title><p><code>/url/</code></p></section><section id="l4"><title><p>4</p></title><p>title: <code>/url/</code></p></section><section id="l5"><title><p>5</p></title><p>title preceded by two spaces: <code>/url/</code></p></section><section id="l6"><title><p>6</p></title><p>title preceded by a tab: <code>/url/</code></p></section><section id="l7"><title><p>7</p></title><p>title with &quot;quotes&quot; in it: <code>/url/</code></p></section><section id="l8"><title><p>8</p></title><p>title with single quotes: <code>/url/</code></p></section><section id="l9"><title><p>9</p></title><p><code>/url/with_underscore</code></p></section><section id="l10"><title><p>10</p></title><p><code>mailto:nobody@nowhere.net</code></p></section><section id="l11"><title><p>11</p></title><p><code></code></p></section><section id="l12"><title><p>12</p></title><p><code>/url/</code></p></section><section id="l13"><title><p>13</p></title><p><code>/url/</code></p></section><section id="l14"><title><p>14</p></title><p><code>/url/</code></p></section><section id="l15"><title><p>15</p></title><p><code>/url/</code></p></section><section id="l16"><title><p>16</p></title><p><code>/url/</code></p></section><section id="l17"><title><p>17</p></title><p><code>/url</code></p></section><section id="l18"><title><p>18</p></title><p><code>/url</code></p></section><section id="l19"><title><p>19</p></title><p><code>/url</code></p></section><section id="l20"><title><p>20</p></title><p>Title with &quot;quotes&quot; inside: <code>/url/</code></p></section><section id="l21"><title><p>21</p></title><p>Title with &quot;quote&quot; inside: <code>/url/</code></p></section><section id="l22"><title><p>22</p></title><p><code>http://example.com/?foo=1&amp;bar=2</code></p></section><section id="l23"><title><p>23</p></title><p>AT&amp;T: <code>http://att.com/</code></p></section><section id="l24"><title><p>24</p></title><p><code>/script?foo=1&amp;bar=2</code></p></section><section id="l25"><title><p>25</p></title><p><code>/script?foo=1&amp;bar=2</code></p></section><section id="l26"><title><p>26</p></title><p><code>http://example.com/?foo=1&amp;bar=2</code></p></section><section id="l27"><title><p>27</p></title><p><code>http://example.com/</code></p></section><section id="l28"><title><p>28</p></title><p><code>mailto:nobody@nowhere.net</code></p></section><section id="l29"><title><p>29</p></title><p><code>http://example.com/</code></p></section><section id="n30"><title><p>30</p></title><p>Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.</p></section><section id="n31"><title><p>31</p></title><p>Here’s the long note. This one contains multiple blocks.</p><p>Subsequent blocks are indented to show that they belong to the footnote (as with list items).</p><empty-line /><p><code> { &lt;code&gt; }</code></p><empty-line /><p>If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.</p></section><section id="n32"><title><p>32</p></title><p>This is <emphasis>easier</emphasis> to type. Inline notes may contain links<a l:href="#l32" type="note"><sup>[32]</sup></a> and <code>]</code> verbatim characters, as well as [bracketed text].</p></section><section id="n33"><title><p>33</p></title><p>In quote.</p></section><section id="n34"><title><p>34</p></title><p>In list.</p></section></body><binary id="image2" content-type="image/jpeg">/9j/4AAQSkZJRgABAQEASABIAAD//gBQVGhpcyBhcnQgaXMgaW4gdGhlIHB1YmxpYyBkb21haW4uIEtldmluIEh1Z2hlcywga2V2aW5oQGVpdC5jb20sIFNlcHRlbWJlciAxOTk1/9sAQwABAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB/9sAQwEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB/8AAEQgAFgAUAwEiAAIRAQMRAf/EABoAAQACAwEAAAAAAAAAAAAAAAAICQUGCgf/xAAjEAABBQEAAwABBQAAAAAAAAAGAwQFBwgCAAEJChEVOXa3/8QAFgEBAQEAAAAAAAAAAAAAAAAABggA/8QAJhEBAAECBQEJAAAAAAAAAAAAAQIAAwQFBhEhszE0NlFUcXR1tP/aAAwDAQACEQMRAD8AqQzziPNmpiqnIO1q4H+WkB84MdlzRSuM82/jVw/JCORtRmQz5d2VTy6WmS2eSYx3U/qkSRbgFsqRzH2Is4/mCluXc33vy8xTnJjTNqV/T8LKmkhr8Hq1da2aOvTfIh2CFeNt+GxFBP8AJFdFUbPWh+4FdXV7OtZOMR7mK9lBWNN+JBmMQ5cwmfH8DEFhTZUCRlE6CBq/ds/nBh9oYygeY1L9FnCUnBSN1t+w0l9bNomx1cllsOrL9OCTKtKOIqua6UVjP0dEvTyM7gp/3whbkAD0ScX3r6MLg+C2/XsMhCnJRn/5cVNHyJHiX6JKIFhhqnFeagm9BIgjfcJyNBTZiROBUk6Mp8CJRmT4NWU2MatV7n495DPk/wAbMJSRJOTBDItq0KR5s/nJN7LPW8AJWtYAoKQaDp+u4XShxgXhYcbHoxNTllCwETGQ8ag2jmDVsk8w/wCOp/C/hn+mWV/utpePH+D5wmF39NY6UakjUYR1Dn0YgRM5zQAAAMdfAA4AOAOArjkMNQ3vgm7UKtBR+m9QHFD5tpnDtpy+t2R20gK/OsmFtuDpaL5mVyiT5qdEVAvZci5ch5VoSGKbwlWTBr0RPoZT07av9lHfrXo6yLApWMugKpPM9SV1cDm65s/wkOHZBojoqiM+6GpMSj4FhtayNAUi5H3LfQBG2KWssFoSPuJdKyMLKtpuLi+e3jwFICUg7CSHsNVlYlKdizOTvKdq3KTsG8pQirsAG6vAB5FdhP490U4gfjxi+DedoqO4YftmKdKNulO26jiOv+2Ga/bftVNFXpHtVHrpLpRFJTpP3z77T469++fTx48e4LueE+NY6UKk7UniLP8A7rNf3X6//9k=</binary><binary id="image1" content-type="image/jpeg">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</binary></FictionBook>
+
diff --git a/test/writer.haddock b/test/writer.haddock
new file mode 100644
index 000000000..0772331e3
--- /dev/null
+++ b/test/writer.haddock
@@ -0,0 +1,660 @@
+This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
+markdown test suite.
+
+______________________________________________________________________________
+
+= Headers
+#headers#
+
+== Level 2 with an </url embedded link>
+#level-2-with-an-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.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
+
+Here’s one with a bullet. * criminey.
+
+There should be a hard line break
+here.
+
+______________________________________________________________________________
+
+= Block Quotes
+#block-quotes#
+
+E-mail style:
+
+This is a block quote. It is pretty short.
+
+Code in a block quote:
+
+> sub status {
+> print "working";
+> }
+
+A list:
+
+1. item one
+2. item two
+
+Nested block quotes:
+
+nested
+
+nested
+
+This should not be a block quote: 2 > 1.
+
+And a following paragraph.
+
+______________________________________________________________________________
+
+= Code Blocks
+#code-blocks#
+
+Code:
+
+> ---- (should be four hyphens)
+>
+> sub status {
+> print "working";
+> }
+>
+> this code block is indented by one tab
+
+And:
+
+> this code block is indented by two tabs
+>
+> These should not be escaped: \$ \\ \> \[ \{
+
+______________________________________________________________________________
+
+= Lists
+#lists#
+
+== Unordered
+#unordered#
+
+Asterisks tight:
+
+- asterisk 1
+- asterisk 2
+- asterisk 3
+
+Asterisks loose:
+
+- asterisk 1
+
+- asterisk 2
+
+- asterisk 3
+
+Pluses tight:
+
+- Plus 1
+- Plus 2
+- Plus 3
+
+Pluses loose:
+
+- Plus 1
+
+- Plus 2
+
+- Plus 3
+
+Minuses tight:
+
+- Minus 1
+- Minus 2
+- Minus 3
+
+Minuses loose:
+
+- Minus 1
+
+- Minus 2
+
+- Minus 3
+
+== Ordered
+#ordered#
+
+Tight:
+
+1. First
+2. Second
+3. Third
+
+and:
+
+1. One
+2. Two
+3. Three
+
+Loose using tabs:
+
+1. First
+
+2. Second
+
+3. Third
+
+and using spaces:
+
+1. One
+
+2. Two
+
+3. Three
+
+Multiple paragraphs:
+
+1. Item 1, graf one.
+
+ Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.
+
+2. Item 2.
+
+3. Item 3.
+
+== Nested
+#nested#
+
+- Tab
+ - Tab
+ - Tab
+
+Here’s another:
+
+1. First
+2. Second:
+ - Fee
+ - Fie
+ - Foe
+
+3. Third
+
+Same thing but with paragraphs:
+
+1. First
+
+2. Second:
+
+ - Fee
+ - Fie
+ - Foe
+
+3. Third
+
+== Tabs and spaces
+#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#
+
+(2) begins with 2
+(3) and now 3
+
+ with a continuation
+
+ 4. sublist with roman numerals, starting with 4
+ 5. more items
+ (1) a subsublist
+ (2) a subsublist
+
+Nesting:
+
+1. Upper Alpha
+ 1. Upper Roman.
+ (6) Decimal start with 6
+ 3) Lower alpha with paren
+
+Autonumbering:
+
+1. Autonumber.
+2. More.
+ 1. Nested.
+
+Should not be a list item:
+
+M.A. 2007
+
+B. Williams
+
+______________________________________________________________________________
+
+= Definition Lists
+#definition-lists#
+
+Tight using spaces:
+
+[apple]
+ red fruit
+[orange]
+ orange fruit
+[banana]
+ yellow fruit
+
+Tight using tabs:
+
+[apple]
+ red fruit
+[orange]
+ orange fruit
+[banana]
+ yellow fruit
+
+Loose:
+
+[apple]
+ red fruit
+
+[orange]
+ orange fruit
+
+[banana]
+ yellow fruit
+
+Multiple blocks with italics:
+
+[/apple/]
+ red fruit
+
+ contains seeds, crisp, pleasant to taste
+
+[/orange/]
+ orange fruit
+
+ > { orange code block }
+
+ orange block quote
+
+Multiple definitions, tight:
+
+[apple]
+ red fruit
+ computer
+[orange]
+ orange fruit
+ bank
+
+Multiple definitions, loose:
+
+[apple]
+ red fruit
+
+ computer
+
+[orange]
+ orange fruit
+
+ bank
+
+Blank line after term, indented marker, alternate markers:
+
+[apple]
+ red fruit
+
+ computer
+
+[orange]
+ orange fruit
+
+ 1. sublist
+ 2. sublist
+
+= HTML Blocks
+#html-blocks#
+
+Simple block on one line:
+
+foo
+
+And nested without indentation:
+
+foo
+
+bar
+
+Interpreted markdown in a table:
+
+This is /emphasized/
+And this is __strong__
+Here’s a simple block:
+
+foo
+
+This should be a code block, though:
+
+> <div>
+> foo
+> </div>
+
+As should this:
+
+> <div>foo</div>
+
+Now, nested:
+
+foo
+
+This should just be an HTML comment:
+
+Multiline:
+
+Code block:
+
+> <!-- Comment -->
+
+Just plain comment, with trailing spaces on the line:
+
+Code:
+
+> <hr />
+
+Hr’s:
+
+______________________________________________________________________________
+
+= Inline Markup
+#inline-markup#
+
+This is /emphasized/, and so /is this/.
+
+This is __strong__, and so __is this__.
+
+An /</url emphasized link>/.
+
+__/This is strong and em./__
+
+So is __/this/__ word.
+
+__/This is strong and em./__
+
+So is __/this/__ word.
+
+This is code: @>@, @$@, @\\@, @\\$@, @\<html>@.
+
+~~This is /strikeout/.~~
+
+Superscripts: abcd a/hello/ ahello there.
+
+Subscripts: H2O, H23O, Hmany of themO.
+
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a^b c^d, a~b c~d.
+
+______________________________________________________________________________
+
+= Smart quotes, ellipses, dashes
+#smart-quotes-ellipses-dashes#
+
+“Hello,” said the spider. “‘Shelob’ is my name.”
+
+‘A’, ‘B’, and ‘C’ are letters.
+
+‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’
+
+‘He said, “I want to go.”’ Were you alive in the 70’s?
+
+Here is some quoted ‘@code@’ and a
+“<http://example.com/?foo=1&bar=2 quoted link>”.
+
+Some dashes: one—two — three—four — five.
+
+Dashes between numbers: 5–7, 255–66, 1987–1999.
+
+Ellipses…and…and….
+
+______________________________________________________________________________
+
+= LaTeX
+#latex#
+
+-
+- 2 + 2 = 4
+- /x/ ∈ /y/
+- /α/ ∧ /ω/
+- 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: /α/ + /ω/ × /x/2.
+
+These shouldn’t be math:
+
+- To get the famous equation, write @$e = mc^2$@.
+- $22,000 is a /lot/ of money. So is $34,000. (It worked if “lot” is
+ emphasized.)
+- Shoes ($20) and socks ($5).
+- Escaped @$@: $73 /this should be emphasized/ 23$.
+
+Here’s a LaTeX table:
+
+______________________________________________________________________________
+
+= Special Characters
+#special-characters#
+
+Here is some unicode:
+
+- I hat: Î
+- o umlaut: ö
+- section: §
+- set membership: ∈
+- copyright: ©
+
+AT&T has an ampersand in their name.
+
+AT&T is another way to write it.
+
+This & that.
+
+4 \< 5.
+
+6 > 5.
+
+Backslash: \\
+
+Backtick: \`
+
+Asterisk: *
+
+Underscore: _
+
+Left brace: {
+
+Right brace: }
+
+Left bracket: [
+
+Right bracket: ]
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: >
+
+Hash: #
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+______________________________________________________________________________
+
+= Links
+#links#
+
+== Explicit
+#explicit#
+
+Just a </url/ URL>.
+
+</url/ URL and title>.
+
+</url/ URL and title>.
+
+</url/ URL and title>.
+
+</url/ URL and title>
+
+</url/ URL and title>
+
+</url/with_underscore with_underscore>
+
+<mailto:nobody@nowhere.net Email link>
+
+< Empty>.
+
+== Reference
+#reference#
+
+Foo </url/ bar>.
+
+Foo </url/ bar>.
+
+Foo </url/ bar>.
+
+With </url/ embedded [brackets]>.
+
+</url/ b> by itself should be a link.
+
+Indented </url once>.
+
+Indented </url twice>.
+
+Indented </url thrice>.
+
+This should [not][] be a link.
+
+> [not]: /url
+
+Foo </url/ bar>.
+
+Foo </url/ biz>.
+
+== With ampersands
+#with-ampersands#
+
+Here’s a <http://example.com/?foo=1&bar=2 link with an ampersand in the URL>.
+
+Here’s a link with an amersand in the link text: <http://att.com/ AT&T>.
+
+Here’s an </script?foo=1&bar=2 inline link>.
+
+Here’s an </script?foo=1&bar=2 inline link in pointy braces>.
+
+== Autolinks
+#autolinks#
+
+With an ampersand: <http://example.com/?foo=1&bar=2>
+
+- In a list?
+- <http://example.com/>
+- It should.
+
+An e-mail address: <mailto:nobody@nowhere.net nobody\@nowhere.net>
+
+Blockquoted: <http://example.com/>
+
+Auto-links should not occur here: @\<http:\/\/example.com\/>@
+
+> or here: <http://example.com/>
+
+______________________________________________________________________________
+
+= Images
+#images#
+
+From “Voyage dans la Lune” by Georges Melies (1902):
+
+<<lalune.jpg lalune>>
+
+Here is a movie <<movie.jpg movie>> icon.
+
+______________________________________________________________________________
+
+= Footnotes
+#footnotes#
+
+Here is a footnote reference,<#notes [1]> and another.<#notes [2]> This should
+/not/ be a footnote reference, because it contains a space.[^my note] Here is
+an inline note.<#notes [3]>
+
+Notes can go in quotes.<#notes [4]>
+
+1. And in list items.<#notes [5]>
+
+This paragraph should not be part of the note, as it is not indented.
+
+#notes#
+
+1. Here is the footnote. It can go anywhere after the footnote reference. It
+ need not be placed at the end of the document.
+
+2. Here’s the long note. This one contains multiple blocks.
+
+ Subsequent blocks are indented to show that they belong to the footnote
+ (as with list items).
+
+ > { <code> }
+
+ If you want, you can indent every line, but you can also be lazy and just
+ indent the first line of each block.
+
+3. This is /easier/ to type. Inline notes may contain
+ <http://google.com links> and @]@ verbatim characters, as well as
+ [bracketed text].
+
+4. In quote.
+
+5. In list.
diff --git a/test/writer.html4 b/test/writer.html4
new file mode 100644
index 000000000..3b63f4e16
--- /dev/null
+++ b/test/writer.html4
@@ -0,0 +1,546 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="Content-Style-Type" content="text/css" />
+ <meta name="generator" content="pandoc" />
+ <meta name="author" content="John MacFarlane" />
+ <meta name="author" content="Anonymous" />
+ <meta name="date" content="2006-07-17" />
+ <title>Pandoc Test Suite</title>
+ <style type="text/css">code{white-space: pre;}</style>
+</head>
+<body>
+<div id="header">
+<h1 class="title">Pandoc Test Suite</h1>
+<h2 class="author">John MacFarlane</h2>
+<h2 class="author">Anonymous</h2>
+<h3 class="date">July 17, 2006</h3>
+</div>
+<p>This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite.</p>
+<hr />
+<h1 id="headers">Headers</h1>
+<h2 id="level-2-with-an-embedded-link">Level 2 with an <a href="/url">embedded link</a></h2>
+<h3 id="level-3-with-emphasis">Level 3 with <em>emphasis</em></h3>
+<h4 id="level-4">Level 4</h4>
+<h5 id="level-5">Level 5</h5>
+<h1 id="level-1">Level 1</h1>
+<h2 id="level-2-with-emphasis">Level 2 with <em>emphasis</em></h2>
+<h3 id="level-3">Level 3</h3>
+<p>with no blank line</p>
+<h2 id="level-2">Level 2</h2>
+<p>with no blank line</p>
+<hr />
+<h1 id="paragraphs">Paragraphs</h1>
+<p>Here’s a regular paragraph.</p>
+<p>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.</p>
+<p>Here’s one with a bullet. * criminey.</p>
+<p>There should be a hard line break<br />
+here.</p>
+<hr />
+<h1 id="block-quotes">Block Quotes</h1>
+<p>E-mail style:</p>
+<blockquote>
+<p>This is a block quote. It is pretty short.</p>
+</blockquote>
+<blockquote>
+<p>Code in a block quote:</p>
+<pre><code>sub status {
+ print &quot;working&quot;;
+}</code></pre>
+<p>A list:</p>
+<ol style="list-style-type: decimal">
+<li>item one</li>
+<li>item two</li>
+</ol>
+<p>Nested block quotes:</p>
+<blockquote>
+<p>nested</p>
+</blockquote>
+<blockquote>
+<p>nested</p>
+</blockquote>
+</blockquote>
+<p>This should not be a block quote: 2 &gt; 1.</p>
+<p>And a following paragraph.</p>
+<hr />
+<h1 id="code-blocks">Code Blocks</h1>
+<p>Code:</p>
+<pre><code>---- (should be four hyphens)
+
+sub status {
+ print &quot;working&quot;;
+}
+
+this code block is indented by one tab</code></pre>
+<p>And:</p>
+<pre><code> this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \&gt; \[ \{</code></pre>
+<hr />
+<h1 id="lists">Lists</h1>
+<h2 id="unordered">Unordered</h2>
+<p>Asterisks tight:</p>
+<ul>
+<li>asterisk 1</li>
+<li>asterisk 2</li>
+<li>asterisk 3</li>
+</ul>
+<p>Asterisks loose:</p>
+<ul>
+<li><p>asterisk 1</p></li>
+<li><p>asterisk 2</p></li>
+<li><p>asterisk 3</p></li>
+</ul>
+<p>Pluses tight:</p>
+<ul>
+<li>Plus 1</li>
+<li>Plus 2</li>
+<li>Plus 3</li>
+</ul>
+<p>Pluses loose:</p>
+<ul>
+<li><p>Plus 1</p></li>
+<li><p>Plus 2</p></li>
+<li><p>Plus 3</p></li>
+</ul>
+<p>Minuses tight:</p>
+<ul>
+<li>Minus 1</li>
+<li>Minus 2</li>
+<li>Minus 3</li>
+</ul>
+<p>Minuses loose:</p>
+<ul>
+<li><p>Minus 1</p></li>
+<li><p>Minus 2</p></li>
+<li><p>Minus 3</p></li>
+</ul>
+<h2 id="ordered">Ordered</h2>
+<p>Tight:</p>
+<ol style="list-style-type: decimal">
+<li>First</li>
+<li>Second</li>
+<li>Third</li>
+</ol>
+<p>and:</p>
+<ol style="list-style-type: decimal">
+<li>One</li>
+<li>Two</li>
+<li>Three</li>
+</ol>
+<p>Loose using tabs:</p>
+<ol style="list-style-type: decimal">
+<li><p>First</p></li>
+<li><p>Second</p></li>
+<li><p>Third</p></li>
+</ol>
+<p>and using spaces:</p>
+<ol style="list-style-type: decimal">
+<li><p>One</p></li>
+<li><p>Two</p></li>
+<li><p>Three</p></li>
+</ol>
+<p>Multiple paragraphs:</p>
+<ol style="list-style-type: decimal">
+<li><p>Item 1, graf one.</p>
+<p>Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.</p></li>
+<li><p>Item 2.</p></li>
+<li><p>Item 3.</p></li>
+</ol>
+<h2 id="nested">Nested</h2>
+<ul>
+<li>Tab
+<ul>
+<li>Tab
+<ul>
+<li>Tab</li>
+</ul></li>
+</ul></li>
+</ul>
+<p>Here’s another:</p>
+<ol style="list-style-type: decimal">
+<li>First</li>
+<li>Second:
+<ul>
+<li>Fee</li>
+<li>Fie</li>
+<li>Foe</li>
+</ul></li>
+<li>Third</li>
+</ol>
+<p>Same thing but with paragraphs:</p>
+<ol style="list-style-type: decimal">
+<li><p>First</p></li>
+<li><p>Second:</p>
+<ul>
+<li>Fee</li>
+<li>Fie</li>
+<li>Foe</li>
+</ul></li>
+<li><p>Third</p></li>
+</ol>
+<h2 id="tabs-and-spaces">Tabs and spaces</h2>
+<ul>
+<li><p>this is a list item indented with tabs</p></li>
+<li><p>this is a list item indented with spaces</p>
+<ul>
+<li><p>this is an example list item indented with tabs</p></li>
+<li><p>this is an example list item indented with spaces</p></li>
+</ul></li>
+</ul>
+<h2 id="fancy-list-markers">Fancy list markers</h2>
+<ol start="2" style="list-style-type: decimal">
+<li>begins with 2</li>
+<li><p>and now 3</p>
+<p>with a continuation</p>
+<ol start="4" style="list-style-type: lower-roman">
+<li>sublist with roman numerals, starting with 4</li>
+<li>more items
+<ol style="list-style-type: upper-alpha">
+<li>a subsublist</li>
+<li>a subsublist</li>
+</ol></li>
+</ol></li>
+</ol>
+<p>Nesting:</p>
+<ol style="list-style-type: upper-alpha">
+<li>Upper Alpha
+<ol style="list-style-type: upper-roman">
+<li>Upper Roman.
+<ol start="6" style="list-style-type: decimal">
+<li>Decimal start with 6
+<ol start="3" style="list-style-type: lower-alpha">
+<li>Lower alpha with paren</li>
+</ol></li>
+</ol></li>
+</ol></li>
+</ol>
+<p>Autonumbering:</p>
+<ol>
+<li>Autonumber.</li>
+<li>More.
+<ol>
+<li>Nested.</li>
+</ol></li>
+</ol>
+<p>Should not be a list item:</p>
+<p>M.A. 2007</p>
+<p>B. Williams</p>
+<hr />
+<h1 id="definition-lists">Definition Lists</h1>
+<p>Tight using spaces:</p>
+<dl>
+<dt>apple</dt>
+<dd>red fruit
+</dd>
+<dt>orange</dt>
+<dd>orange fruit
+</dd>
+<dt>banana</dt>
+<dd>yellow fruit
+</dd>
+</dl>
+<p>Tight using tabs:</p>
+<dl>
+<dt>apple</dt>
+<dd>red fruit
+</dd>
+<dt>orange</dt>
+<dd>orange fruit
+</dd>
+<dt>banana</dt>
+<dd>yellow fruit
+</dd>
+</dl>
+<p>Loose:</p>
+<dl>
+<dt>apple</dt>
+<dd><p>red fruit</p>
+</dd>
+<dt>orange</dt>
+<dd><p>orange fruit</p>
+</dd>
+<dt>banana</dt>
+<dd><p>yellow fruit</p>
+</dd>
+</dl>
+<p>Multiple blocks with italics:</p>
+<dl>
+<dt><em>apple</em></dt>
+<dd><p>red fruit</p>
+<p>contains seeds, crisp, pleasant to taste</p>
+</dd>
+<dt><em>orange</em></dt>
+<dd><p>orange fruit</p>
+<pre><code>{ orange code block }</code></pre>
+<blockquote>
+<p>orange block quote</p>
+</blockquote>
+</dd>
+</dl>
+<p>Multiple definitions, tight:</p>
+<dl>
+<dt>apple</dt>
+<dd>red fruit
+</dd>
+<dd>computer
+</dd>
+<dt>orange</dt>
+<dd>orange fruit
+</dd>
+<dd>bank
+</dd>
+</dl>
+<p>Multiple definitions, loose:</p>
+<dl>
+<dt>apple</dt>
+<dd><p>red fruit</p>
+</dd>
+<dd><p>computer</p>
+</dd>
+<dt>orange</dt>
+<dd><p>orange fruit</p>
+</dd>
+<dd><p>bank</p>
+</dd>
+</dl>
+<p>Blank line after term, indented marker, alternate markers:</p>
+<dl>
+<dt>apple</dt>
+<dd><p>red fruit</p>
+</dd>
+<dd><p>computer</p>
+</dd>
+<dt>orange</dt>
+<dd><p>orange fruit</p>
+<ol style="list-style-type: decimal">
+<li>sublist</li>
+<li>sublist</li>
+</ol>
+</dd>
+</dl>
+<h1 id="html-blocks">HTML Blocks</h1>
+<p>Simple block on one line:</p>
+<div>
+foo
+</div>
+<p>And nested without indentation:</p>
+<div>
+<div>
+<div>
+<p>foo</p>
+</div>
+</div>
+<div>
+bar
+</div>
+</div>
+<p>Interpreted markdown in a table:</p>
+<table>
+<tr>
+<td>
+This is <em>emphasized</em>
+</td>
+<td>
+And this is <strong>strong</strong>
+</td>
+</tr>
+</table>
+<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
+<p>Here’s a simple block:</p>
+<div>
+<p>foo</p>
+</div>
+<p>This should be a code block, though:</p>
+<pre><code>&lt;div&gt;
+ foo
+&lt;/div&gt;</code></pre>
+<p>As should this:</p>
+<pre><code>&lt;div&gt;foo&lt;/div&gt;</code></pre>
+<p>Now, nested:</p>
+<div>
+<div>
+<div>
+foo
+</div>
+</div>
+</div>
+<p>This should just be an HTML comment:</p>
+<!-- Comment -->
+<p>Multiline:</p>
+<!--
+Blah
+Blah
+-->
+<!--
+ This is another comment.
+-->
+<p>Code block:</p>
+<pre><code>&lt;!-- Comment --&gt;</code></pre>
+<p>Just plain comment, with trailing spaces on the line:</p>
+<!-- foo -->
+<p>Code:</p>
+<pre><code>&lt;hr /&gt;</code></pre>
+<p>Hr’s:</p>
+<hr>
+<hr />
+<hr />
+<hr>
+<hr />
+<hr />
+<hr class="foo" id="bar" />
+<hr class="foo" id="bar" />
+<hr class="foo" id="bar">
+<hr />
+<h1 id="inline-markup">Inline Markup</h1>
+<p>This is <em>emphasized</em>, and so <em>is this</em>.</p>
+<p>This is <strong>strong</strong>, and so <strong>is this</strong>.</p>
+<p>An <em><a href="/url">emphasized link</a></em>.</p>
+<p><strong><em>This is strong and em.</em></strong></p>
+<p>So is <strong><em>this</em></strong> word.</p>
+<p><strong><em>This is strong and em.</em></strong></p>
+<p>So is <strong><em>this</em></strong> word.</p>
+<p>This is code: <code>&gt;</code>, <code>$</code>, <code>\</code>, <code>\$</code>, <code>&lt;html&gt;</code>.</p>
+<p><del>This is <em>strikeout</em>.</del></p>
+<p>Superscripts: a<sup>bc</sup>d a<sup><em>hello</em></sup> a<sup>hello there</sup>.</p>
+<p>Subscripts: H<sub>2</sub>O, H<sub>23</sub>O, H<sub>many of them</sub>O.</p>
+<p>These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.</p>
+<hr />
+<h1 id="smart-quotes-ellipses-dashes">Smart quotes, ellipses, dashes</h1>
+<p>“Hello,” said the spider. “‘Shelob’ is my name.”</p>
+<p>‘A’, ‘B’, and ‘C’ are letters.</p>
+<p>‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’</p>
+<p>‘He said, “I want to go.”’ Were you alive in the 70’s?</p>
+<p>Here is some quoted ‘<code>code</code>’ and a “<a href="http://example.com/?foo=1&amp;bar=2">quoted link</a>”.</p>
+<p>Some dashes: one—two — three—four — five.</p>
+<p>Dashes between numbers: 5–7, 255–66, 1987–1999.</p>
+<p>Ellipses…and…and….</p>
+<hr />
+<h1 id="latex">LaTeX</h1>
+<ul>
+<li></li>
+<li><span class="math inline">2 + 2 = 4</span></li>
+<li><span class="math inline"><em>x</em> ∈ <em>y</em></span></li>
+<li><span class="math inline"><em>α</em> ∧ <em>ω</em></span></li>
+<li><span class="math inline">223</span></li>
+<li><span class="math inline"><em>p</em></span>-Tree</li>
+<li>Here’s some display math: <br /><span class="math display">$$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$</span><br /></li>
+<li>Here’s one that has a line break in it: <span class="math inline"><em>α</em> + <em>ω</em> × <em>x</em><sup>2</sup></span>.</li>
+</ul>
+<p>These shouldn’t be math:</p>
+<ul>
+<li>To get the famous equation, write <code>$e = mc^2$</code>.</li>
+<li>$22,000 is a <em>lot</em> of money. So is $34,000. (It worked if “lot” is emphasized.)</li>
+<li>Shoes ($20) and socks ($5).</li>
+<li>Escaped <code>$</code>: $73 <em>this should be emphasized</em> 23$.</li>
+</ul>
+<p>Here’s a LaTeX table:</p>
+
+<hr />
+<h1 id="special-characters">Special Characters</h1>
+<p>Here is some unicode:</p>
+<ul>
+<li>I hat: Î</li>
+<li>o umlaut: ö</li>
+<li>section: §</li>
+<li>set membership: ∈</li>
+<li>copyright: ©</li>
+</ul>
+<p>AT&amp;T has an ampersand in their name.</p>
+<p>AT&amp;T is another way to write it.</p>
+<p>This &amp; that.</p>
+<p>4 &lt; 5.</p>
+<p>6 &gt; 5.</p>
+<p>Backslash: \</p>
+<p>Backtick: `</p>
+<p>Asterisk: *</p>
+<p>Underscore: _</p>
+<p>Left brace: {</p>
+<p>Right brace: }</p>
+<p>Left bracket: [</p>
+<p>Right bracket: ]</p>
+<p>Left paren: (</p>
+<p>Right paren: )</p>
+<p>Greater-than: &gt;</p>
+<p>Hash: #</p>
+<p>Period: .</p>
+<p>Bang: !</p>
+<p>Plus: +</p>
+<p>Minus: -</p>
+<hr />
+<h1 id="links">Links</h1>
+<h2 id="explicit">Explicit</h2>
+<p>Just a <a href="/url/">URL</a>.</p>
+<p><a href="/url/" title="title">URL and title</a>.</p>
+<p><a href="/url/" title="title preceded by two spaces">URL and title</a>.</p>
+<p><a href="/url/" title="title preceded by a tab">URL and title</a>.</p>
+<p><a href="/url/" title="title with &quot;quotes&quot; in it">URL and title</a></p>
+<p><a href="/url/" title="title with single quotes">URL and title</a></p>
+<p><a href="/url/with_underscore">with_underscore</a></p>
+<p><a href="mailto:nobody@nowhere.net">Email link</a></p>
+<p><a href="">Empty</a>.</p>
+<h2 id="reference">Reference</h2>
+<p>Foo <a href="/url/">bar</a>.</p>
+<p>Foo <a href="/url/">bar</a>.</p>
+<p>Foo <a href="/url/">bar</a>.</p>
+<p>With <a href="/url/">embedded [brackets]</a>.</p>
+<p><a href="/url/">b</a> by itself should be a link.</p>
+<p>Indented <a href="/url">once</a>.</p>
+<p>Indented <a href="/url">twice</a>.</p>
+<p>Indented <a href="/url">thrice</a>.</p>
+<p>This should [not][] be a link.</p>
+<pre><code>[not]: /url</code></pre>
+<p>Foo <a href="/url/" title="Title with &quot;quotes&quot; inside">bar</a>.</p>
+<p>Foo <a href="/url/" title="Title with &quot;quote&quot; inside">biz</a>.</p>
+<h2 id="with-ampersands">With ampersands</h2>
+<p>Here’s a <a href="http://example.com/?foo=1&amp;bar=2">link with an ampersand in the URL</a>.</p>
+<p>Here’s a link with an amersand in the link text: <a href="http://att.com/" title="AT&amp;T">AT&amp;T</a>.</p>
+<p>Here’s an <a href="/script?foo=1&amp;bar=2">inline link</a>.</p>
+<p>Here’s an <a href="/script?foo=1&amp;bar=2">inline link in pointy braces</a>.</p>
+<h2 id="autolinks">Autolinks</h2>
+<p>With an ampersand: <a href="http://example.com/?foo=1&amp;bar=2" class="uri">http://example.com/?foo=1&amp;bar=2</a></p>
+<ul>
+<li>In a list?</li>
+<li><a href="http://example.com/" class="uri">http://example.com/</a></li>
+<li>It should.</li>
+</ul>
+<p>An e-mail address: <a href="mailto:nobody@nowhere.net">nobody@nowhere.net</a></p>
+<blockquote>
+<p>Blockquoted: <a href="http://example.com/" class="uri">http://example.com/</a></p>
+</blockquote>
+<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
+<pre><code>or here: &lt;http://example.com/&gt;</code></pre>
+<hr />
+<h1 id="images">Images</h1>
+<p>From “Voyage dans la Lune” by Georges Melies (1902):</p>
+<div class="figure">
+<img src="lalune.jpg" title="Voyage dans la Lune" alt="lalune" />
+<p class="caption">lalune</p>
+</div>
+<p>Here is a movie <img src="movie.jpg" alt="movie" /> icon.</p>
+<hr />
+<h1 id="footnotes">Footnotes</h1>
+<p>Here is a footnote reference,<a href="#fn1" class="footnoteRef" id="fnref1"><sup>1</sup></a> and another.<a href="#fn2" class="footnoteRef" id="fnref2"><sup>2</sup></a> This should <em>not</em> be a footnote reference, because it contains a space.[^my note] Here is an inline note.<a href="#fn3" class="footnoteRef" id="fnref3"><sup>3</sup></a></p>
+<blockquote>
+<p>Notes can go in quotes.<a href="#fn4" class="footnoteRef" id="fnref4"><sup>4</sup></a></p>
+</blockquote>
+<ol style="list-style-type: decimal">
+<li>And in list items.<a href="#fn5" class="footnoteRef" id="fnref5"><sup>5</sup></a></li>
+</ol>
+<p>This paragraph should not be part of the note, as it is not indented.</p>
+<div class="footnotes">
+<hr />
+<ol>
+<li id="fn1"><p>Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.<a href="#fnref1">↩</a></p></li>
+<li id="fn2"><p>Here’s the long note. This one contains multiple blocks.</p>
+<p>Subsequent blocks are indented to show that they belong to the footnote (as with list items).</p>
+<pre><code> { &lt;code&gt; }</code></pre>
+<p>If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.<a href="#fnref2">↩</a></p></li>
+<li id="fn3"><p>This is <em>easier</em> to type. Inline notes may contain <a href="http://google.com">links</a> and <code>]</code> verbatim characters, as well as [bracketed text].<a href="#fnref3">↩</a></p></li>
+<li id="fn4"><p>In quote.<a href="#fnref4">↩</a></p></li>
+<li id="fn5"><p>In list.<a href="#fnref5">↩</a></p></li>
+</ol>
+</div>
+</body>
+</html>
diff --git a/test/writer.html5 b/test/writer.html5
new file mode 100644
index 000000000..8e0dff764
--- /dev/null
+++ b/test/writer.html5
@@ -0,0 +1,548 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name="generator" content="pandoc">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
+ <meta name="author" content="John MacFarlane">
+ <meta name="author" content="Anonymous">
+ <meta name="dcterms.date" content="2006-07-17">
+ <title>Pandoc Test Suite</title>
+ <style type="text/css">code{white-space: pre;}</style>
+ <!--[if lt IE 9]>
+ <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
+ <![endif]-->
+</head>
+<body>
+<header>
+<h1 class="title">Pandoc Test Suite</h1>
+<p class="author">John MacFarlane</p>
+<p class="author">Anonymous</p>
+<p class="date">July 17, 2006</p>
+</header>
+<p>This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite.</p>
+<hr />
+<h1 id="headers">Headers</h1>
+<h2 id="level-2-with-an-embedded-link">Level 2 with an <a href="/url">embedded link</a></h2>
+<h3 id="level-3-with-emphasis">Level 3 with <em>emphasis</em></h3>
+<h4 id="level-4">Level 4</h4>
+<h5 id="level-5">Level 5</h5>
+<h1 id="level-1">Level 1</h1>
+<h2 id="level-2-with-emphasis">Level 2 with <em>emphasis</em></h2>
+<h3 id="level-3">Level 3</h3>
+<p>with no blank line</p>
+<h2 id="level-2">Level 2</h2>
+<p>with no blank line</p>
+<hr />
+<h1 id="paragraphs">Paragraphs</h1>
+<p>Here’s a regular paragraph.</p>
+<p>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.</p>
+<p>Here’s one with a bullet. * criminey.</p>
+<p>There should be a hard line break<br />
+here.</p>
+<hr />
+<h1 id="block-quotes">Block Quotes</h1>
+<p>E-mail style:</p>
+<blockquote>
+<p>This is a block quote. It is pretty short.</p>
+</blockquote>
+<blockquote>
+<p>Code in a block quote:</p>
+<pre><code>sub status {
+ print &quot;working&quot;;
+}</code></pre>
+<p>A list:</p>
+<ol type="1">
+<li>item one</li>
+<li>item two</li>
+</ol>
+<p>Nested block quotes:</p>
+<blockquote>
+<p>nested</p>
+</blockquote>
+<blockquote>
+<p>nested</p>
+</blockquote>
+</blockquote>
+<p>This should not be a block quote: 2 &gt; 1.</p>
+<p>And a following paragraph.</p>
+<hr />
+<h1 id="code-blocks">Code Blocks</h1>
+<p>Code:</p>
+<pre><code>---- (should be four hyphens)
+
+sub status {
+ print &quot;working&quot;;
+}
+
+this code block is indented by one tab</code></pre>
+<p>And:</p>
+<pre><code> this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \&gt; \[ \{</code></pre>
+<hr />
+<h1 id="lists">Lists</h1>
+<h2 id="unordered">Unordered</h2>
+<p>Asterisks tight:</p>
+<ul>
+<li>asterisk 1</li>
+<li>asterisk 2</li>
+<li>asterisk 3</li>
+</ul>
+<p>Asterisks loose:</p>
+<ul>
+<li><p>asterisk 1</p></li>
+<li><p>asterisk 2</p></li>
+<li><p>asterisk 3</p></li>
+</ul>
+<p>Pluses tight:</p>
+<ul>
+<li>Plus 1</li>
+<li>Plus 2</li>
+<li>Plus 3</li>
+</ul>
+<p>Pluses loose:</p>
+<ul>
+<li><p>Plus 1</p></li>
+<li><p>Plus 2</p></li>
+<li><p>Plus 3</p></li>
+</ul>
+<p>Minuses tight:</p>
+<ul>
+<li>Minus 1</li>
+<li>Minus 2</li>
+<li>Minus 3</li>
+</ul>
+<p>Minuses loose:</p>
+<ul>
+<li><p>Minus 1</p></li>
+<li><p>Minus 2</p></li>
+<li><p>Minus 3</p></li>
+</ul>
+<h2 id="ordered">Ordered</h2>
+<p>Tight:</p>
+<ol type="1">
+<li>First</li>
+<li>Second</li>
+<li>Third</li>
+</ol>
+<p>and:</p>
+<ol type="1">
+<li>One</li>
+<li>Two</li>
+<li>Three</li>
+</ol>
+<p>Loose using tabs:</p>
+<ol type="1">
+<li><p>First</p></li>
+<li><p>Second</p></li>
+<li><p>Third</p></li>
+</ol>
+<p>and using spaces:</p>
+<ol type="1">
+<li><p>One</p></li>
+<li><p>Two</p></li>
+<li><p>Three</p></li>
+</ol>
+<p>Multiple paragraphs:</p>
+<ol type="1">
+<li><p>Item 1, graf one.</p>
+<p>Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.</p></li>
+<li><p>Item 2.</p></li>
+<li><p>Item 3.</p></li>
+</ol>
+<h2 id="nested">Nested</h2>
+<ul>
+<li>Tab
+<ul>
+<li>Tab
+<ul>
+<li>Tab</li>
+</ul></li>
+</ul></li>
+</ul>
+<p>Here’s another:</p>
+<ol type="1">
+<li>First</li>
+<li>Second:
+<ul>
+<li>Fee</li>
+<li>Fie</li>
+<li>Foe</li>
+</ul></li>
+<li>Third</li>
+</ol>
+<p>Same thing but with paragraphs:</p>
+<ol type="1">
+<li><p>First</p></li>
+<li><p>Second:</p>
+<ul>
+<li>Fee</li>
+<li>Fie</li>
+<li>Foe</li>
+</ul></li>
+<li><p>Third</p></li>
+</ol>
+<h2 id="tabs-and-spaces">Tabs and spaces</h2>
+<ul>
+<li><p>this is a list item indented with tabs</p></li>
+<li><p>this is a list item indented with spaces</p>
+<ul>
+<li><p>this is an example list item indented with tabs</p></li>
+<li><p>this is an example list item indented with spaces</p></li>
+</ul></li>
+</ul>
+<h2 id="fancy-list-markers">Fancy list markers</h2>
+<ol start="2" type="1">
+<li>begins with 2</li>
+<li><p>and now 3</p>
+<p>with a continuation</p>
+<ol start="4" type="i">
+<li>sublist with roman numerals, starting with 4</li>
+<li>more items
+<ol type="A">
+<li>a subsublist</li>
+<li>a subsublist</li>
+</ol></li>
+</ol></li>
+</ol>
+<p>Nesting:</p>
+<ol type="A">
+<li>Upper Alpha
+<ol type="I">
+<li>Upper Roman.
+<ol start="6" type="1">
+<li>Decimal start with 6
+<ol start="3" type="a">
+<li>Lower alpha with paren</li>
+</ol></li>
+</ol></li>
+</ol></li>
+</ol>
+<p>Autonumbering:</p>
+<ol>
+<li>Autonumber.</li>
+<li>More.
+<ol>
+<li>Nested.</li>
+</ol></li>
+</ol>
+<p>Should not be a list item:</p>
+<p>M.A. 2007</p>
+<p>B. Williams</p>
+<hr />
+<h1 id="definition-lists">Definition Lists</h1>
+<p>Tight using spaces:</p>
+<dl>
+<dt>apple</dt>
+<dd>red fruit
+</dd>
+<dt>orange</dt>
+<dd>orange fruit
+</dd>
+<dt>banana</dt>
+<dd>yellow fruit
+</dd>
+</dl>
+<p>Tight using tabs:</p>
+<dl>
+<dt>apple</dt>
+<dd>red fruit
+</dd>
+<dt>orange</dt>
+<dd>orange fruit
+</dd>
+<dt>banana</dt>
+<dd>yellow fruit
+</dd>
+</dl>
+<p>Loose:</p>
+<dl>
+<dt>apple</dt>
+<dd><p>red fruit</p>
+</dd>
+<dt>orange</dt>
+<dd><p>orange fruit</p>
+</dd>
+<dt>banana</dt>
+<dd><p>yellow fruit</p>
+</dd>
+</dl>
+<p>Multiple blocks with italics:</p>
+<dl>
+<dt><em>apple</em></dt>
+<dd><p>red fruit</p>
+<p>contains seeds, crisp, pleasant to taste</p>
+</dd>
+<dt><em>orange</em></dt>
+<dd><p>orange fruit</p>
+<pre><code>{ orange code block }</code></pre>
+<blockquote>
+<p>orange block quote</p>
+</blockquote>
+</dd>
+</dl>
+<p>Multiple definitions, tight:</p>
+<dl>
+<dt>apple</dt>
+<dd>red fruit
+</dd>
+<dd>computer
+</dd>
+<dt>orange</dt>
+<dd>orange fruit
+</dd>
+<dd>bank
+</dd>
+</dl>
+<p>Multiple definitions, loose:</p>
+<dl>
+<dt>apple</dt>
+<dd><p>red fruit</p>
+</dd>
+<dd><p>computer</p>
+</dd>
+<dt>orange</dt>
+<dd><p>orange fruit</p>
+</dd>
+<dd><p>bank</p>
+</dd>
+</dl>
+<p>Blank line after term, indented marker, alternate markers:</p>
+<dl>
+<dt>apple</dt>
+<dd><p>red fruit</p>
+</dd>
+<dd><p>computer</p>
+</dd>
+<dt>orange</dt>
+<dd><p>orange fruit</p>
+<ol type="1">
+<li>sublist</li>
+<li>sublist</li>
+</ol>
+</dd>
+</dl>
+<h1 id="html-blocks">HTML Blocks</h1>
+<p>Simple block on one line:</p>
+<div>
+foo
+</div>
+<p>And nested without indentation:</p>
+<div>
+<div>
+<div>
+<p>foo</p>
+</div>
+</div>
+<div>
+bar
+</div>
+</div>
+<p>Interpreted markdown in a table:</p>
+<table>
+<tr>
+<td>
+This is <em>emphasized</em>
+</td>
+<td>
+And this is <strong>strong</strong>
+</td>
+</tr>
+</table>
+<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
+<p>Here’s a simple block:</p>
+<div>
+<p>foo</p>
+</div>
+<p>This should be a code block, though:</p>
+<pre><code>&lt;div&gt;
+ foo
+&lt;/div&gt;</code></pre>
+<p>As should this:</p>
+<pre><code>&lt;div&gt;foo&lt;/div&gt;</code></pre>
+<p>Now, nested:</p>
+<div>
+<div>
+<div>
+foo
+</div>
+</div>
+</div>
+<p>This should just be an HTML comment:</p>
+<!-- Comment -->
+<p>Multiline:</p>
+<!--
+Blah
+Blah
+-->
+<!--
+ This is another comment.
+-->
+<p>Code block:</p>
+<pre><code>&lt;!-- Comment --&gt;</code></pre>
+<p>Just plain comment, with trailing spaces on the line:</p>
+<!-- foo -->
+<p>Code:</p>
+<pre><code>&lt;hr /&gt;</code></pre>
+<p>Hr’s:</p>
+<hr>
+<hr />
+<hr />
+<hr>
+<hr />
+<hr />
+<hr class="foo" id="bar" />
+<hr class="foo" id="bar" />
+<hr class="foo" id="bar">
+<hr />
+<h1 id="inline-markup">Inline Markup</h1>
+<p>This is <em>emphasized</em>, and so <em>is this</em>.</p>
+<p>This is <strong>strong</strong>, and so <strong>is this</strong>.</p>
+<p>An <em><a href="/url">emphasized link</a></em>.</p>
+<p><strong><em>This is strong and em.</em></strong></p>
+<p>So is <strong><em>this</em></strong> word.</p>
+<p><strong><em>This is strong and em.</em></strong></p>
+<p>So is <strong><em>this</em></strong> word.</p>
+<p>This is code: <code>&gt;</code>, <code>$</code>, <code>\</code>, <code>\$</code>, <code>&lt;html&gt;</code>.</p>
+<p><del>This is <em>strikeout</em>.</del></p>
+<p>Superscripts: a<sup>bc</sup>d a<sup><em>hello</em></sup> a<sup>hello there</sup>.</p>
+<p>Subscripts: H<sub>2</sub>O, H<sub>23</sub>O, H<sub>many of them</sub>O.</p>
+<p>These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.</p>
+<hr />
+<h1 id="smart-quotes-ellipses-dashes">Smart quotes, ellipses, dashes</h1>
+<p>“Hello,” said the spider. “‘Shelob’ is my name.”</p>
+<p>‘A’, ‘B’, and ‘C’ are letters.</p>
+<p>‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’</p>
+<p>‘He said, “I want to go.”’ Were you alive in the 70’s?</p>
+<p>Here is some quoted ‘<code>code</code>’ and a “<a href="http://example.com/?foo=1&amp;bar=2">quoted link</a>”.</p>
+<p>Some dashes: one—two — three—four — five.</p>
+<p>Dashes between numbers: 5–7, 255–66, 1987–1999.</p>
+<p>Ellipses…and…and….</p>
+<hr />
+<h1 id="latex">LaTeX</h1>
+<ul>
+<li></li>
+<li><span class="math inline">2 + 2 = 4</span></li>
+<li><span class="math inline"><em>x</em> ∈ <em>y</em></span></li>
+<li><span class="math inline"><em>α</em> ∧ <em>ω</em></span></li>
+<li><span class="math inline">223</span></li>
+<li><span class="math inline"><em>p</em></span>-Tree</li>
+<li>Here’s some display math: <br /><span class="math display">$$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$</span><br /></li>
+<li>Here’s one that has a line break in it: <span class="math inline"><em>α</em> + <em>ω</em> × <em>x</em><sup>2</sup></span>.</li>
+</ul>
+<p>These shouldn’t be math:</p>
+<ul>
+<li>To get the famous equation, write <code>$e = mc^2$</code>.</li>
+<li>$22,000 is a <em>lot</em> of money. So is $34,000. (It worked if “lot” is emphasized.)</li>
+<li>Shoes ($20) and socks ($5).</li>
+<li>Escaped <code>$</code>: $73 <em>this should be emphasized</em> 23$.</li>
+</ul>
+<p>Here’s a LaTeX table:</p>
+
+<hr />
+<h1 id="special-characters">Special Characters</h1>
+<p>Here is some unicode:</p>
+<ul>
+<li>I hat: Î</li>
+<li>o umlaut: ö</li>
+<li>section: §</li>
+<li>set membership: ∈</li>
+<li>copyright: ©</li>
+</ul>
+<p>AT&amp;T has an ampersand in their name.</p>
+<p>AT&amp;T is another way to write it.</p>
+<p>This &amp; that.</p>
+<p>4 &lt; 5.</p>
+<p>6 &gt; 5.</p>
+<p>Backslash: \</p>
+<p>Backtick: `</p>
+<p>Asterisk: *</p>
+<p>Underscore: _</p>
+<p>Left brace: {</p>
+<p>Right brace: }</p>
+<p>Left bracket: [</p>
+<p>Right bracket: ]</p>
+<p>Left paren: (</p>
+<p>Right paren: )</p>
+<p>Greater-than: &gt;</p>
+<p>Hash: #</p>
+<p>Period: .</p>
+<p>Bang: !</p>
+<p>Plus: +</p>
+<p>Minus: -</p>
+<hr />
+<h1 id="links">Links</h1>
+<h2 id="explicit">Explicit</h2>
+<p>Just a <a href="/url/">URL</a>.</p>
+<p><a href="/url/" title="title">URL and title</a>.</p>
+<p><a href="/url/" title="title preceded by two spaces">URL and title</a>.</p>
+<p><a href="/url/" title="title preceded by a tab">URL and title</a>.</p>
+<p><a href="/url/" title="title with &quot;quotes&quot; in it">URL and title</a></p>
+<p><a href="/url/" title="title with single quotes">URL and title</a></p>
+<p><a href="/url/with_underscore">with_underscore</a></p>
+<p><a href="mailto:nobody@nowhere.net">Email link</a></p>
+<p><a href="">Empty</a>.</p>
+<h2 id="reference">Reference</h2>
+<p>Foo <a href="/url/">bar</a>.</p>
+<p>Foo <a href="/url/">bar</a>.</p>
+<p>Foo <a href="/url/">bar</a>.</p>
+<p>With <a href="/url/">embedded [brackets]</a>.</p>
+<p><a href="/url/">b</a> by itself should be a link.</p>
+<p>Indented <a href="/url">once</a>.</p>
+<p>Indented <a href="/url">twice</a>.</p>
+<p>Indented <a href="/url">thrice</a>.</p>
+<p>This should [not][] be a link.</p>
+<pre><code>[not]: /url</code></pre>
+<p>Foo <a href="/url/" title="Title with &quot;quotes&quot; inside">bar</a>.</p>
+<p>Foo <a href="/url/" title="Title with &quot;quote&quot; inside">biz</a>.</p>
+<h2 id="with-ampersands">With ampersands</h2>
+<p>Here’s a <a href="http://example.com/?foo=1&amp;bar=2">link with an ampersand in the URL</a>.</p>
+<p>Here’s a link with an amersand in the link text: <a href="http://att.com/" title="AT&amp;T">AT&amp;T</a>.</p>
+<p>Here’s an <a href="/script?foo=1&amp;bar=2">inline link</a>.</p>
+<p>Here’s an <a href="/script?foo=1&amp;bar=2">inline link in pointy braces</a>.</p>
+<h2 id="autolinks">Autolinks</h2>
+<p>With an ampersand: <a href="http://example.com/?foo=1&amp;bar=2" class="uri">http://example.com/?foo=1&amp;bar=2</a></p>
+<ul>
+<li>In a list?</li>
+<li><a href="http://example.com/" class="uri">http://example.com/</a></li>
+<li>It should.</li>
+</ul>
+<p>An e-mail address: <a href="mailto:nobody@nowhere.net">nobody@nowhere.net</a></p>
+<blockquote>
+<p>Blockquoted: <a href="http://example.com/" class="uri">http://example.com/</a></p>
+</blockquote>
+<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
+<pre><code>or here: &lt;http://example.com/&gt;</code></pre>
+<hr />
+<h1 id="images">Images</h1>
+<p>From “Voyage dans la Lune” by Georges Melies (1902):</p>
+<figure>
+<img src="lalune.jpg" title="Voyage dans la Lune" alt="lalune" /><figcaption>lalune</figcaption>
+</figure>
+<p>Here is a movie <img src="movie.jpg" alt="movie" /> icon.</p>
+<hr />
+<h1 id="footnotes">Footnotes</h1>
+<p>Here is a footnote reference,<a href="#fn1" class="footnoteRef" id="fnref1"><sup>1</sup></a> and another.<a href="#fn2" class="footnoteRef" id="fnref2"><sup>2</sup></a> This should <em>not</em> be a footnote reference, because it contains a space.[^my note] Here is an inline note.<a href="#fn3" class="footnoteRef" id="fnref3"><sup>3</sup></a></p>
+<blockquote>
+<p>Notes can go in quotes.<a href="#fn4" class="footnoteRef" id="fnref4"><sup>4</sup></a></p>
+</blockquote>
+<ol type="1">
+<li>And in list items.<a href="#fn5" class="footnoteRef" id="fnref5"><sup>5</sup></a></li>
+</ol>
+<p>This paragraph should not be part of the note, as it is not indented.</p>
+<section class="footnotes">
+<hr />
+<ol>
+<li id="fn1"><p>Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.<a href="#fnref1">↩</a></p></li>
+<li id="fn2"><p>Here’s the long note. This one contains multiple blocks.</p>
+<p>Subsequent blocks are indented to show that they belong to the footnote (as with list items).</p>
+<pre><code> { &lt;code&gt; }</code></pre>
+<p>If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.<a href="#fnref2">↩</a></p></li>
+<li id="fn3"><p>This is <em>easier</em> to type. Inline notes may contain <a href="http://google.com">links</a> and <code>]</code> verbatim characters, as well as [bracketed text].<a href="#fnref3">↩</a></p></li>
+<li id="fn4"><p>In quote.<a href="#fnref4">↩</a></p></li>
+<li id="fn5"><p>In list.<a href="#fnref5">↩</a></p></li>
+</ol>
+</section>
+</body>
+</html>
diff --git a/test/writer.icml b/test/writer.icml
new file mode 100644
index 000000000..b498f568b
--- /dev/null
+++ b/test/writer.icml
@@ -0,0 +1,3317 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<?aid style="50" type="snippet" readerVersion="6.0" featureSet="513" product="8.0(370)" ?>
+<?aid SnippetType="InCopyInterchange"?>
+<Document DOMVersion="8.0" Self="pandoc_doc">
+ <RootCharacterStyleGroup Self="pandoc_character_styles">
+ <CharacterStyle Self="$ID/NormalCharacterStyle" Name="Default" />
+ <CharacterStyle Self="CharacterStyle/" Name="">
+ <Properties>
+ <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn>
+ </Properties>
+ </CharacterStyle>
+ <CharacterStyle Self="CharacterStyle/Bold" Name="Bold" FontStyle="Bold">
+ <Properties>
+ <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn>
+ </Properties>
+ </CharacterStyle>
+ <CharacterStyle Self="CharacterStyle/Bold Italic" Name="Bold Italic" FontStyle="Bold Italic">
+ <Properties>
+ <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn>
+ </Properties>
+ </CharacterStyle>
+ <CharacterStyle Self="CharacterStyle/Code" Name="Code">
+ <Properties>
+ <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn>
+ <AppliedFont type="string">Courier New</AppliedFont>
+ </Properties>
+ </CharacterStyle>
+ <CharacterStyle Self="CharacterStyle/Italic" Name="Italic" FontStyle="Italic">
+ <Properties>
+ <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn>
+ </Properties>
+ </CharacterStyle>
+ <CharacterStyle Self="CharacterStyle/Italic Link" Name="Italic Link" FontStyle="Italic">
+ <Properties>
+ <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn>
+ </Properties>
+ </CharacterStyle>
+ <CharacterStyle Self="CharacterStyle/Italic Strikeout" Name="Italic Strikeout" FontStyle="Italic" StrikeThru="true">
+ <Properties>
+ <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn>
+ </Properties>
+ </CharacterStyle>
+ <CharacterStyle Self="CharacterStyle/Italic Superscript" Name="Italic Superscript" FontStyle="Italic" Position="Superscript">
+ <Properties>
+ <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn>
+ </Properties>
+ </CharacterStyle>
+ <CharacterStyle Self="CharacterStyle/Link" Name="Link">
+ <Properties>
+ <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn>
+ </Properties>
+ </CharacterStyle>
+ <CharacterStyle Self="CharacterStyle/Strikeout" Name="Strikeout" StrikeThru="true">
+ <Properties>
+ <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn>
+ </Properties>
+ </CharacterStyle>
+ <CharacterStyle Self="CharacterStyle/Subscript" Name="Subscript" Position="Subscript">
+ <Properties>
+ <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn>
+ </Properties>
+ </CharacterStyle>
+ <CharacterStyle Self="CharacterStyle/Superscript" Name="Superscript" Position="Superscript">
+ <Properties>
+ <BasedOn type="object">$ID/NormalCharacterStyle</BasedOn>
+ </Properties>
+ </CharacterStyle>
+ </RootCharacterStyleGroup>
+ <RootParagraphStyleGroup Self="pandoc_paragraph_styles">
+ <ParagraphStyle Self="$ID/NormalParagraphStyle" Name="$ID/NormalParagraphStyle"
+ SpaceBefore="6" SpaceAfter="6"> <!-- paragraph spacing -->
+ <Properties>
+ <TabList type="list">
+ <ListItem type="record">
+ <Alignment type="enumeration">LeftAlign</Alignment>
+ <AlignmentCharacter type="string">.</AlignmentCharacter>
+ <Leader type="string"></Leader>
+ <Position type="unit">10</Position> <!-- first tab stop -->
+ </ListItem>
+ </TabList>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/" Name="" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Blockquote &gt; Blockquote &gt; Paragraph" Name="Blockquote &gt; Blockquote &gt; Paragraph" LeftIndent="30">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Blockquote &gt; CodeBlock" Name="Blockquote &gt; CodeBlock" LeftIndent="10">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <AppliedFont type="string">Courier New</AppliedFont>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Blockquote &gt; NumList" Name="Blockquote &gt; NumList" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="20">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Blockquote &gt; NumList &gt; first" Name="Blockquote &gt; NumList &gt; first" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="20">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Blockquote &gt; Paragraph" Name="Blockquote &gt; Paragraph" LeftIndent="10">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/BulList" Name="BulList" BulletsAndNumberingListType="BulletList" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <TabList type="list">
+ <ListItem type="record">
+ <Alignment type="enumeration">LeftAlign</Alignment>
+ <AlignmentCharacter type="string">.</AlignmentCharacter>
+ <Leader type="string" />
+ <Position type="unit">10</Position>
+ </ListItem>
+ </TabList>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/BulList &gt; BulList &gt; BulList &gt; first" Name="BulList &gt; BulList &gt; BulList &gt; first" BulletsAndNumberingListType="BulletList" LeftIndent="20">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <TabList type="list">
+ <ListItem type="record">
+ <Alignment type="enumeration">LeftAlign</Alignment>
+ <AlignmentCharacter type="string">.</AlignmentCharacter>
+ <Leader type="string" />
+ <Position type="unit">30</Position>
+ </ListItem>
+ </TabList>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/BulList &gt; BulList &gt; Paragraph" Name="BulList &gt; BulList &gt; Paragraph" BulletsAndNumberingListType="BulletList" LeftIndent="10">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <TabList type="list">
+ <ListItem type="record">
+ <Alignment type="enumeration">LeftAlign</Alignment>
+ <AlignmentCharacter type="string">.</AlignmentCharacter>
+ <Leader type="string" />
+ <Position type="unit">20</Position>
+ </ListItem>
+ </TabList>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/BulList &gt; BulList &gt; first" Name="BulList &gt; BulList &gt; first" BulletsAndNumberingListType="BulletList" LeftIndent="10">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <TabList type="list">
+ <ListItem type="record">
+ <Alignment type="enumeration">LeftAlign</Alignment>
+ <AlignmentCharacter type="string">.</AlignmentCharacter>
+ <Leader type="string" />
+ <Position type="unit">20</Position>
+ </ListItem>
+ </TabList>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/BulList &gt; BulList &gt; first &gt; Paragraph" Name="BulList &gt; BulList &gt; first &gt; Paragraph" BulletsAndNumberingListType="BulletList" LeftIndent="10">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <TabList type="list">
+ <ListItem type="record">
+ <Alignment type="enumeration">LeftAlign</Alignment>
+ <AlignmentCharacter type="string">.</AlignmentCharacter>
+ <Leader type="string" />
+ <Position type="unit">20</Position>
+ </ListItem>
+ </TabList>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/BulList &gt; Paragraph" Name="BulList &gt; Paragraph" BulletsAndNumberingListType="BulletList" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <TabList type="list">
+ <ListItem type="record">
+ <Alignment type="enumeration">LeftAlign</Alignment>
+ <AlignmentCharacter type="string">.</AlignmentCharacter>
+ <Leader type="string" />
+ <Position type="unit">10</Position>
+ </ListItem>
+ </TabList>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/BulList &gt; first" Name="BulList &gt; first" BulletsAndNumberingListType="BulletList" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <TabList type="list">
+ <ListItem type="record">
+ <Alignment type="enumeration">LeftAlign</Alignment>
+ <AlignmentCharacter type="string">.</AlignmentCharacter>
+ <Leader type="string" />
+ <Position type="unit">10</Position>
+ </ListItem>
+ </TabList>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/BulList &gt; first &gt; Paragraph" Name="BulList &gt; first &gt; Paragraph" BulletsAndNumberingListType="BulletList" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <TabList type="list">
+ <ListItem type="record">
+ <Alignment type="enumeration">LeftAlign</Alignment>
+ <AlignmentCharacter type="string">.</AlignmentCharacter>
+ <Leader type="string" />
+ <Position type="unit">10</Position>
+ </ListItem>
+ </TabList>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Caption" Name="Caption" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/CodeBlock" Name="CodeBlock" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <AppliedFont type="string">Courier New</AppliedFont>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/DefListDef" Name="DefListDef" LeftIndent="10">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/DefListDef &gt; Blockquote &gt; Paragraph" Name="DefListDef &gt; Blockquote &gt; Paragraph" LeftIndent="30">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/DefListDef &gt; CodeBlock" Name="DefListDef &gt; CodeBlock" LeftIndent="10">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <AppliedFont type="string">Courier New</AppliedFont>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/DefListDef &gt; NumList" Name="DefListDef &gt; NumList" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="20">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/DefListDef &gt; NumList &gt; first" Name="DefListDef &gt; NumList &gt; first" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="20">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/DefListDef &gt; Paragraph" Name="DefListDef &gt; Paragraph" LeftIndent="10">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/DefListTerm" Name="DefListTerm" LeftIndent="0" BulletsAndNumberingListType="BulletList" FontStyle="Bold">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Figure" Name="Figure" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Footnote &gt; CodeBlock" Name="Footnote &gt; CodeBlock" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <AppliedFont type="string">Courier New</AppliedFont>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Footnote &gt; Paragraph" Name="Footnote &gt; Paragraph" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Header1" Name="Header1" LeftIndent="0" PointSize="36">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Header2" Name="Header2" LeftIndent="0" PointSize="30">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Header3" Name="Header3" LeftIndent="0" PointSize="24">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Header4" Name="Header4" LeftIndent="0" PointSize="18">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Header5" Name="Header5" LeftIndent="0" PointSize="14">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList" Name="NumList" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; BulList" Name="NumList &gt; BulList" BulletsAndNumberingListType="BulletList" LeftIndent="10">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <TabList type="list">
+ <ListItem type="record">
+ <Alignment type="enumeration">LeftAlign</Alignment>
+ <AlignmentCharacter type="string">.</AlignmentCharacter>
+ <Leader type="string" />
+ <Position type="unit">20</Position>
+ </ListItem>
+ </TabList>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; BulList &gt; first" Name="NumList &gt; BulList &gt; first" BulletsAndNumberingListType="BulletList" LeftIndent="10">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <TabList type="list">
+ <ListItem type="record">
+ <Alignment type="enumeration">LeftAlign</Alignment>
+ <AlignmentCharacter type="string">.</AlignmentCharacter>
+ <Leader type="string" />
+ <Position type="unit">20</Position>
+ </ListItem>
+ </TabList>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; NumList &gt; NumList &gt; NumList &gt; first &gt; beginsWith-3 &gt; lowerAlpha" Name="NumList &gt; NumList &gt; NumList &gt; NumList &gt; first &gt; beginsWith-3 &gt; lowerAlpha" NumberingExpression="^#.^t" NumberingLevel="4" BulletsAndNumberingListType="NumberedList" LeftIndent="30">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <NumberingFormat type="string">a, b, c, d...</NumberingFormat>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; NumList &gt; NumList &gt; first &gt; beginsWith-6" Name="NumList &gt; NumList &gt; NumList &gt; first &gt; beginsWith-6" NumberingExpression="^#.^t" NumberingLevel="3" BulletsAndNumberingListType="NumberedList" LeftIndent="20">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; NumList &gt; NumList &gt; first &gt; upperAlpha" Name="NumList &gt; NumList &gt; NumList &gt; first &gt; upperAlpha" NumberingExpression="^#.^t" NumberingLevel="3" BulletsAndNumberingListType="NumberedList" LeftIndent="20">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <NumberingFormat type="string">A, B, C, D...</NumberingFormat>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; NumList &gt; NumList &gt; upperAlpha" Name="NumList &gt; NumList &gt; NumList &gt; upperAlpha" NumberingExpression="^#.^t" NumberingLevel="3" BulletsAndNumberingListType="NumberedList" LeftIndent="20">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <NumberingFormat type="string">A, B, C, D...</NumberingFormat>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; NumList &gt; beginsWith-4 &gt; lowerRoman" Name="NumList &gt; NumList &gt; beginsWith-4 &gt; lowerRoman" NumberingExpression="^#.^t" NumberingLevel="2" BulletsAndNumberingListType="NumberedList" LeftIndent="10">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <NumberingFormat type="string">i, ii, iii, iv...</NumberingFormat>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; NumList &gt; first" Name="NumList &gt; NumList &gt; first" NumberingExpression="^#.^t" NumberingLevel="2" BulletsAndNumberingListType="NumberedList" LeftIndent="10">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; NumList &gt; first &gt; beginsWith-4 &gt; lowerRoman" Name="NumList &gt; NumList &gt; first &gt; beginsWith-4 &gt; lowerRoman" NumberingExpression="^#.^t" NumberingLevel="2" BulletsAndNumberingListType="NumberedList" LeftIndent="10">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <NumberingFormat type="string">i, ii, iii, iv...</NumberingFormat>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; NumList &gt; first &gt; upperRoman" Name="NumList &gt; NumList &gt; first &gt; upperRoman" NumberingExpression="^#.^t" NumberingLevel="2" BulletsAndNumberingListType="NumberedList" LeftIndent="10">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <NumberingFormat type="string">I, II, III, IV...</NumberingFormat>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; Paragraph" Name="NumList &gt; Paragraph" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; beginsWith-2 &gt; Paragraph" Name="NumList &gt; beginsWith-2 &gt; Paragraph" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; first" Name="NumList &gt; first" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; first &gt; Paragraph" Name="NumList &gt; first &gt; Paragraph" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; first &gt; beginsWith-2" Name="NumList &gt; first &gt; beginsWith-2" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; first &gt; upperAlpha" Name="NumList &gt; first &gt; upperAlpha" NumberingExpression="^#.^t" NumberingLevel="1" BulletsAndNumberingListType="NumberedList" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ <NumberingFormat type="string">A, B, C, D...</NumberingFormat>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/NumList &gt; subParagraph &gt; Paragraph" Name="NumList &gt; subParagraph &gt; Paragraph" NumberingExpression="^#.^t" NumberingLevel="1" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ <ParagraphStyle Self="ParagraphStyle/Paragraph" Name="Paragraph" LeftIndent="0">
+ <Properties>
+ <BasedOn type="object">$ID/NormalParagraphStyle</BasedOn>
+ </Properties>
+ </ParagraphStyle>
+ </RootParagraphStyleGroup>
+ <RootTableStyleGroup Self="pandoc_table_styles">
+ <TableStyle Self="TableStyle/Table" Name="Table" />
+ </RootTableStyleGroup>
+ <RootCellStyleGroup Self="pandoc_cell_styles">
+ <CellStyle Self="CellStyle/Cell" AppliedParagraphStyle="ParagraphStyle/$ID/[No paragraph style]" Name="Cell" />
+ </RootCellStyleGroup>
+ <Story Self="pandoc_story"
+ TrackChanges="false"
+ StoryTitle=""
+ AppliedTOCStyle="n"
+ AppliedNamedGrid="n" >
+ <StoryPreference OpticalMarginAlignment="true" OpticalMarginSize="12" />
+
+<!-- body needs to be non-indented, otherwise code blocks are indented too far -->
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Headers</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 2 with an </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-1" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>embedded link</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header3">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 3 with </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>emphasis</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header4">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 4</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header5">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 5</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 1</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 2 with </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>emphasis</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header3">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 3</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>with no blank line</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 2</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>with no blank line</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Paragraphs</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s a regular paragraph.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>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.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s one with a bullet. * criminey.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>There should be a hard line break</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&#x2028;</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>here.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Block Quotes</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>E-mail style:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This is a block quote. It is pretty short.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Code in a block quote:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>sub status {
+ print &quot;working&quot;;
+}</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>A list:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>item one</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>item two</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Nested block quotes:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>nested</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>nested</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This should not be a block quote: 2 &gt; 1.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>And a following paragraph.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Code Blocks</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Code:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>---- (should be four hyphens)
+
+sub status {
+ print &quot;working&quot;;
+}
+
+this code block is indented by one tab</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>And:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \&gt; \[ \{</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Lists</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Unordered</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Asterisks tight:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>asterisk 1</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>asterisk 2</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>asterisk 3</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Asterisks loose:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>asterisk 1</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>asterisk 2</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>asterisk 3</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Pluses tight:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Plus 1</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Plus 2</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Plus 3</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Pluses loose:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Plus 1</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Plus 2</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Plus 3</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minuses tight:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minus 1</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minus 2</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minus 3</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minuses loose:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minus 1</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minus 2</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minus 3</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Ordered</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Tight:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>First</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Second</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Third</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>and:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>One</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Two</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Three</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Loose using tabs:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>First</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Second</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Third</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>and using spaces:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>One</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Two</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Three</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiple paragraphs:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Item 1, graf one.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; subParagraph &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Item 2.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Item 3.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Nested</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Tab</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Tab</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; BulList &gt; BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Tab</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s another:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>First</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Second:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Fee</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Fie</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Foe</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Third</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Same thing but with paragraphs:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>First</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Second:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Fee</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Fie</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Foe</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Third</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Tabs and spaces</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>this is a list item indented with tabs</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>this is a list item indented with spaces</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; BulList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>this is an example list item indented with tabs</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>this is an example list item indented with spaces</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Fancy list markers</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange NumberingStartAt="2" AppliedParagraphStyle="ParagraphStyle/NumList &gt; first &gt; beginsWith-2" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>begins with 2</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; beginsWith-2 &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>and now 3</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; subParagraph &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>with a continuation</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange NumberingStartAt="4" AppliedParagraphStyle="ParagraphStyle/NumList &gt; NumList &gt; first &gt; beginsWith-4 &gt; lowerRoman" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>sublist with roman numerals, starting with 4</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; NumList &gt; beginsWith-4 &gt; lowerRoman">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>more items</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; NumList &gt; NumList &gt; first &gt; upperAlpha" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>a subsublist</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; NumList &gt; NumList &gt; upperAlpha">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>a subsublist</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Nesting:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first &gt; upperAlpha" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Upper Alpha</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; NumList &gt; first &gt; upperRoman" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Upper Roman.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange NumberingStartAt="6" AppliedParagraphStyle="ParagraphStyle/NumList &gt; NumList &gt; NumList &gt; first &gt; beginsWith-6" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Decimal start with 6</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange NumberingStartAt="3" AppliedParagraphStyle="ParagraphStyle/NumList &gt; NumList &gt; NumList &gt; NumList &gt; first &gt; beginsWith-3 &gt; lowerAlpha" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Lower alpha with paren</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Autonumbering:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Autonumber.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>More.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Nested.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Should not be a list item:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>M.A. 2007</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>B. Williams</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Definition Lists</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Tight using spaces:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>apple</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>red fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>banana</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>yellow fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Tight using tabs:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>apple</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>red fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>banana</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>yellow fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Loose:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>apple</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>red fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>banana</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>yellow fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiple blocks with italics:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>apple</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>red fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>contains seeds, crisp, pleasant to taste</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>orange</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>{ orange code block }</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange block quote</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiple definitions, tight:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>apple</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>red fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>computer</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>bank</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiple definitions, loose:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>apple</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>red fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>computer</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>bank</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Blank line after term, indented marker, alternate markers:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>apple</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>red fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>computer</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange fruit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>sublist</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>sublist</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>HTML Blocks</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Simple block on one line:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>foo</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>And nested without indentation:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>foo</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>bar</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Interpreted markdown in a table:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This is </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>emphasized</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>And this is </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold">
+ <Content>strong</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s a simple block:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>foo</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This should be a code block, though:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;div&gt;
+ foo
+&lt;/div&gt;</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>As should this:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;div&gt;foo&lt;/div&gt;</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Now, nested:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>foo</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This should just be an HTML comment:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiline:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Code block:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;!-- Comment --&gt;</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Just plain comment, with trailing spaces on the line:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Code:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;hr /&gt;</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Hr’s:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Inline Markup</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This is </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>emphasized</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>, and so </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>is this</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This is </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold">
+ <Content>strong</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>, and so </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold">
+ <Content>is this</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>An </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-2" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic Link">
+ <Content>emphasized link</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold Italic">
+ <Content>This is strong and em.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>So is </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold Italic">
+ <Content>this</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> word.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold Italic">
+ <Content>This is strong and em.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>So is </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold Italic">
+ <Content>this</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> word.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This is code: </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code">
+ <Content>&gt;</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>, </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code">
+ <Content>$</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>, </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code">
+ <Content>\</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>, </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code">
+ <Content>\$</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>, </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code">
+ <Content>&lt;html&gt;</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Strikeout">
+ <Content>This is </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic Strikeout">
+ <Content>strikeout</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Strikeout">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Superscripts: a</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Superscript">
+ <Content>bc</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>d a</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic Superscript">
+ <Content>hello</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> a</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Superscript">
+ <Content>hello there</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Subscripts: H</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Subscript">
+ <Content>2</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>O, H</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Subscript">
+ <Content>23</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>O, H</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Subscript">
+ <Content>many of them</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>O.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Smart quotes, ellipses, dashes</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>“</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Hello,</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>”</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> said the spider. </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>“</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>‘</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Shelob</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>’</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> is my name.</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>”</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>‘</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>A</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>’</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>, </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>‘</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>B</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>’</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>, and </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>‘</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>C</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>’</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> are letters.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>‘</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Oak,</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>’</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>‘</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>elm,</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>’</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> and </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>‘</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>beech</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>’</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> are names of trees. So is </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>‘</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>pine.</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>’</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>‘</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>He said, </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>“</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>I want to go.</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>”</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>’</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> Were you alive in the 70’s?</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here is some quoted </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>‘</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code">
+ <Content>code</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>’</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> and a </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>“</Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-3" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>quoted link</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>”</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Some dashes: one—two — three—four — five.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Dashes between numbers: 5–7, 255–66, 1987–1999.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Ellipses…and…and….</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>LaTeX</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>2</Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>+</Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>2</Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>=</Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>4</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>x</Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>∈</Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>y</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>α</Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>∧</Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>ω</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>223</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>p</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>-Tree</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s some display math: </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>$$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s one that has a line break in it: </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>α</Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>+</Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>ω</Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>×</Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>x</Content>
+ </CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Superscript">
+ <Content>2</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>These shouldn’t be math:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>To get the famous equation, write </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code">
+ <Content>$e = mc^2$</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>$22,000 is a </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>lot</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> of money. So is $34,000. (It worked if </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>“</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>lot</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>”</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> is emphasized.)</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Shoes ($20) and socks ($5).</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Escaped </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code">
+ <Content>$</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>: $73 </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>this should be emphasized</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> 23$.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s a LaTeX table:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Special Characters</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here is some unicode:</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>I hat: Î</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>o umlaut: ö</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>section: §</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>set membership: ∈</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>copyright: ©</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>AT&amp;T has an ampersand in their name.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>AT&amp;T is another way to write it.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This &amp; that.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>4 &lt; 5.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>6 &gt; 5.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Backslash: \</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Backtick: `</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Asterisk: *</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Underscore: _</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Left brace: {</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Right brace: }</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Left bracket: [</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Right bracket: ]</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Left paren: (</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Right paren: )</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Greater-than: &gt;</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Hash: #</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Period: .</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Bang: !</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Plus: +</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minus: -</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Links</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Explicit</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Just a </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-4" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>URL</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <HyperlinkTextSource Self="htss-5" Name="title" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>URL and title</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <HyperlinkTextSource Self="htss-6" Name="title preceded by two spaces" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>URL and title</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <HyperlinkTextSource Self="htss-7" Name="title preceded by a tab" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>URL and title</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <HyperlinkTextSource Self="htss-8" Name="title with &quot;quotes&quot; in it" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>URL and title</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <HyperlinkTextSource Self="htss-9" Name="title with single quotes" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>URL and title</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <HyperlinkTextSource Self="htss-10" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>with_underscore</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <HyperlinkTextSource Self="htss-11" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>Email link</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <HyperlinkTextSource Self="htss-12" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>Empty</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Reference</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Foo </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-13" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>bar</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Foo </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-14" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>bar</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Foo </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-15" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>bar</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>With </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-16" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>embedded [brackets]</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <HyperlinkTextSource Self="htss-17" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>b</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> by itself should be a link.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Indented </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-18" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>once</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Indented </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-19" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>twice</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Indented </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-20" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>thrice</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This should [not][] be a link.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>[not]: /url</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Foo </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-21" Name="Title with &quot;quotes&quot; inside" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>bar</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Foo </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-22" Name="Title with &quot;quote&quot; inside" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>biz</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>With ampersands</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s a </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-23" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>link with an ampersand in the URL</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s a link with an amersand in the link text: </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-24" Name="AT&amp;T" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>AT&amp;T</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s an </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-25" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>inline link</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s an </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-26" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>inline link in pointy braces</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Autolinks</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>With an ampersand: </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-27" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>http://example.com/?foo=1&amp;bar=2</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>In a list?</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <HyperlinkTextSource Self="htss-28" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>http://example.com/</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>It should.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>An e-mail address: </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-29" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>nobody@nowhere.net</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Blockquoted: </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-30" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>http://example.com/</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Auto-links should not occur here: </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code">
+ <Content>&lt;http://example.com/&gt;</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>or here: &lt;http://example.com/&gt;</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Images</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>From </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>“</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Voyage dans la Lune</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>”</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> by Georges Melies (1902):</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Figure">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Rectangle Self="uec" StrokeWeight="0" ItemTransform="1.00000 0 0 1.00000 75.00000 -75.00000">
+ <Properties>
+ <PathGeometry>
+ <GeometryPathType PathOpen="false">
+ <PathPointArray>
+ <PathPointType Anchor="-75.00000 -75.00000" LeftDirection="-75.00000 -75.00000" RightDirection="-75.00000 -75.00000" />
+ <PathPointType Anchor="-75.00000 75.00000" LeftDirection="-75.00000 75.00000" RightDirection="-75.00000 75.00000" />
+ <PathPointType Anchor="75.00000 75.00000" LeftDirection="75.00000 75.00000" RightDirection="75.00000 75.00000" />
+ <PathPointType Anchor="75.00000 -75.00000" LeftDirection="75.00000 -75.00000" RightDirection="75.00000 -75.00000" />
+ </PathPointArray>
+ </GeometryPathType>
+ </PathGeometry>
+ </Properties>
+ <Image Self="ue6" ItemTransform="1.00000 0 0 1.00000 -75.00000 -75.00000">
+ <Properties>
+ <Profile type="string">
+ $ID/Embedded
+ </Profile>
+ </Properties>
+ <Link Self="ueb" LinkResourceURI="file:lalune.jpg" />
+ </Image>
+ </Rectangle>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Caption">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>lalune</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here is a movie </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Rectangle Self="uec" StrokeWeight="0" ItemTransform="1.00000 0 0 1.00000 10.00000 -11.00000">
+ <Properties>
+ <PathGeometry>
+ <GeometryPathType PathOpen="false">
+ <PathPointArray>
+ <PathPointType Anchor="-10.00000 -11.00000" LeftDirection="-10.00000 -11.00000" RightDirection="-10.00000 -11.00000" />
+ <PathPointType Anchor="-10.00000 11.00000" LeftDirection="-10.00000 11.00000" RightDirection="-10.00000 11.00000" />
+ <PathPointType Anchor="10.00000 11.00000" LeftDirection="10.00000 11.00000" RightDirection="10.00000 11.00000" />
+ <PathPointType Anchor="10.00000 -11.00000" LeftDirection="10.00000 -11.00000" RightDirection="10.00000 -11.00000" />
+ </PathPointArray>
+ </GeometryPathType>
+ </PathGeometry>
+ </Properties>
+ <Image Self="ue6" ItemTransform="1.00000 0 0 1.00000 -10.00000 -11.00000">
+ <Properties>
+ <Profile type="string">
+ $ID/Embedded
+ </Profile>
+ </Properties>
+ <Link Self="ueb" LinkResourceURI="file:movie.jpg" />
+ </Image>
+ </Rectangle>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> icon.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Footnotes</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here is a footnote reference,</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle" Position="Superscript">
+ <Footnote>
+ <ParagraphStyleRange>
+ <CharacterStyleRange>
+ <Content><?ACE 4?></Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Footnote>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> and another.</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle" Position="Superscript">
+ <Footnote>
+ <ParagraphStyleRange>
+ <CharacterStyleRange>
+ <Content><?ACE 4?></Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s the long note. This one contains multiple blocks.</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ <Br />
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Subsequent blocks are indented to show that they belong to the footnote (as with list items).</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ <Br />
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote &gt; CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> { &lt;code&gt; }</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ <Br />
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Footnote>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> This should </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>not</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> be a footnote reference, because it contains a space.[^my note] Here is an inline note.</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle" Position="Superscript">
+ <Footnote>
+ <ParagraphStyleRange>
+ <CharacterStyleRange>
+ <Content><?ACE 4?></Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This is </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>easier</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> to type. Inline notes may contain </Content>
+ </CharacterStyleRange>
+ <HyperlinkTextSource Self="htss-31" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>links</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> and </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Code">
+ <Content>]</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> verbatim characters, as well as [bracketed text].</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Footnote>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Notes can go in quotes.</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle" Position="Superscript">
+ <Footnote>
+ <ParagraphStyleRange>
+ <CharacterStyleRange>
+ <Content><?ACE 4?></Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>In quote.</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Footnote>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>And in list items.</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle" Position="Superscript">
+ <Footnote>
+ <ParagraphStyleRange>
+ <CharacterStyleRange>
+ <Content><?ACE 4?></Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>In list.</Content>
+ </CharacterStyleRange>
+ </ParagraphStyleRange>
+ </Footnote>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+<Br />
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This paragraph should not be part of the note, as it is not indented.</Content>
+ </CharacterStyleRange>
+</ParagraphStyleRange>
+
+ </Story>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/http%3a//google.com" Name="link" DestinationURL="http://google.com" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-31" Name="http://google.com" Source="htss-31" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination/http%3a//google.com</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/http%3a//example.com/" Name="link" DestinationURL="http://example.com/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-30" Name="http://example.com/" Source="htss-30" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination/http%3a//example.com/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/mailto%3anobody@nowhere.net" Name="link" DestinationURL="mailto:nobody@nowhere.net" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-29" Name="mailto:nobody@nowhere.net" Source="htss-29" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination/mailto%3anobody@nowhere.net</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/http%3a//example.com/" Name="link" DestinationURL="http://example.com/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-28" Name="http://example.com/" Source="htss-28" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination/http%3a//example.com/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/http%3a//example.com/?foo=1&amp;bar=2" Name="link" DestinationURL="http://example.com/?foo=1&amp;bar=2" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-27" Name="http://example.com/?foo=1&amp;bar=2" Source="htss-27" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination/http%3a//example.com/?foo=1&amp;bar=2</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//script?foo=1&amp;bar=2" Name="link" DestinationURL="/script?foo=1&amp;bar=2" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-26" Name="/script?foo=1&amp;bar=2" Source="htss-26" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//script?foo=1&amp;bar=2</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//script?foo=1&amp;bar=2" Name="link" DestinationURL="/script?foo=1&amp;bar=2" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-25" Name="/script?foo=1&amp;bar=2" Source="htss-25" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//script?foo=1&amp;bar=2</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/http%3a//att.com/" Name="link" DestinationURL="http://att.com/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-24" Name="http://att.com/" Source="htss-24" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination/http%3a//att.com/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/http%3a//example.com/?foo=1&amp;bar=2" Name="link" DestinationURL="http://example.com/?foo=1&amp;bar=2" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-23" Name="http://example.com/?foo=1&amp;bar=2" Source="htss-23" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination/http%3a//example.com/?foo=1&amp;bar=2</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-22" Name="/url/" Source="htss-22" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-21" Name="/url/" Source="htss-21" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url" Name="link" DestinationURL="/url" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-20" Name="/url" Source="htss-20" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url" Name="link" DestinationURL="/url" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-19" Name="/url" Source="htss-19" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url" Name="link" DestinationURL="/url" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-18" Name="/url" Source="htss-18" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-17" Name="/url/" Source="htss-17" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-16" Name="/url/" Source="htss-16" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-15" Name="/url/" Source="htss-15" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-14" Name="/url/" Source="htss-14" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-13" Name="/url/" Source="htss-13" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/" Name="link" DestinationURL="" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-12" Name="" Source="htss-12" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/mailto%3anobody@nowhere.net" Name="link" DestinationURL="mailto:nobody@nowhere.net" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-11" Name="mailto:nobody@nowhere.net" Source="htss-11" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination/mailto%3anobody@nowhere.net</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url/with_underscore" Name="link" DestinationURL="/url/with_underscore" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-10" Name="/url/with_underscore" Source="htss-10" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url/with_underscore</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-9" Name="/url/" Source="htss-9" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-8" Name="/url/" Source="htss-8" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-7" Name="/url/" Source="htss-7" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-6" Name="/url/" Source="htss-6" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-5" Name="/url/" Source="htss-5" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url/" Name="link" DestinationURL="/url/" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-4" Name="/url/" Source="htss-4" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/http%3a//example.com/?foo=1&amp;bar=2" Name="link" DestinationURL="http://example.com/?foo=1&amp;bar=2" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-3" Name="http://example.com/?foo=1&amp;bar=2" Source="htss-3" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination/http%3a//example.com/?foo=1&amp;bar=2</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url" Name="link" DestinationURL="/url" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-2" Name="/url" Source="htss-2" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination//url" Name="link" DestinationURL="/url" DestinationUniqueKey="1" />
+ <Hyperlink Self="uf-1" Name="/url" Source="htss-1" Visible="true" DestinationUniqueKey="1">
+ <Properties>
+ <BorderColor type="enumeration">Black</BorderColor>
+ <Destination type="object">HyperlinkURLDestination//url</Destination>
+ </Properties>
+ </Hyperlink>
+</Document>
diff --git a/test/writer.latex b/test/writer.latex
new file mode 100644
index 000000000..8f834df8f
--- /dev/null
+++ b/test/writer.latex
@@ -0,0 +1,967 @@
+\documentclass[]{article}
+\usepackage{lmodern}
+\usepackage{amssymb,amsmath}
+\usepackage{ifxetex,ifluatex}
+\usepackage{fixltx2e} % provides \textsubscript
+\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
+ \usepackage[T1]{fontenc}
+ \usepackage[utf8]{inputenc}
+\else % if luatex or xelatex
+ \usepackage{unicode-math}
+ \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
+\fi
+% use upquote if available, for straight quotes in verbatim environments
+\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
+% use microtype if available
+\IfFileExists{microtype.sty}{%
+\usepackage[]{microtype}
+\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
+}{}
+\PassOptionsToPackage{hyphens}{url} % url is loaded by hyperref
+\usepackage{fancyvrb}
+\usepackage[unicode=true]{hyperref}
+\hypersetup{
+ pdftitle={Pandoc Test Suite},
+ pdfauthor={John MacFarlane; Anonymous},
+ pdfborder={0 0 0},
+ breaklinks=true}
+\urlstyle{same} % don't use monospace font for urls
+\VerbatimFootnotes % allows verbatim text in footnotes
+\usepackage{graphicx,grffile}
+\makeatletter
+\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
+\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
+\makeatother
+% Scale images if necessary, so that they will not overflow the page
+% margins by default, and it is still possible to overwrite the defaults
+% using explicit options in \includegraphics[width, height, ...]{}
+\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
+\usepackage[normalem]{ulem}
+% avoid problems with \sout in headers with hyperref:
+\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
+\IfFileExists{parskip.sty}{%
+\usepackage{parskip}
+}{% else
+\setlength{\parindent}{0pt}
+\setlength{\parskip}{6pt plus 2pt minus 1pt}
+}
+\setlength{\emergencystretch}{3em} % prevent overfull lines
+\providecommand{\tightlist}{%
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
+\setcounter{secnumdepth}{0}
+% Redefines (sub)paragraphs to behave more like sections
+\ifx\paragraph\undefined\else
+\let\oldparagraph\paragraph
+\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
+\fi
+\ifx\subparagraph\undefined\else
+\let\oldsubparagraph\subparagraph
+\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
+\fi
+
+% set default figure placement to htbp
+\makeatletter
+\def\fps@figure{htbp}
+\makeatother
+
+
+\title{Pandoc Test Suite}
+\author{John MacFarlane \and Anonymous}
+\date{July 17, 2006}
+
+\begin{document}
+\maketitle
+
+This is a set of tests for pandoc. Most of them are adapted from John Gruber's
+markdown test suite.
+
+\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
+
+\section{Headers}\label{headers}
+
+\subsection{\texorpdfstring{Level 2 with an \href{/url}{embedded
+link}}{Level 2 with an embedded link}}\label{level-2-with-an-embedded-link}
+
+\subsubsection{\texorpdfstring{Level 3 with
+\emph{emphasis}}{Level 3 with emphasis}}\label{level-3-with-emphasis}
+
+\paragraph{Level 4}\label{level-4}
+
+\subparagraph{Level 5}\label{level-5}
+
+\section{Level 1}\label{level-1}
+
+\subsection{\texorpdfstring{Level 2 with
+\emph{emphasis}}{Level 2 with emphasis}}\label{level-2-with-emphasis}
+
+\subsubsection{Level 3}\label{level-3}
+
+with no blank line
+
+\subsection{Level 2}\label{level-2}
+
+with no blank line
+
+\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
+
+\section{Paragraphs}\label{paragraphs}
+
+Here's a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
+
+Here's one with a bullet. * criminey.
+
+There should be a hard line break\\
+here.
+
+\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
+
+\section{Block Quotes}\label{block-quotes}
+
+E-mail style:
+
+\begin{quote}
+This is a block quote. It is pretty short.
+\end{quote}
+
+\begin{quote}
+Code in a block quote:
+
+\begin{verbatim}
+sub status {
+ print "working";
+}
+\end{verbatim}
+
+A list:
+
+\begin{enumerate}
+\def\labelenumi{\arabic{enumi}.}
+\tightlist
+\item
+ item one
+\item
+ item two
+\end{enumerate}
+
+Nested block quotes:
+
+\begin{quote}
+nested
+\end{quote}
+
+\begin{quote}
+nested
+\end{quote}
+\end{quote}
+
+This should not be a block quote: 2 \textgreater{} 1.
+
+And a following paragraph.
+
+\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
+
+\section{Code Blocks}\label{code-blocks}
+
+Code:
+
+\begin{verbatim}
+---- (should be four hyphens)
+
+sub status {
+ print "working";
+}
+
+this code block is indented by one tab
+\end{verbatim}
+
+And:
+
+\begin{verbatim}
+ this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \> \[ \{
+\end{verbatim}
+
+\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
+
+\section{Lists}\label{lists}
+
+\subsection{Unordered}\label{unordered}
+
+Asterisks tight:
+
+\begin{itemize}
+\tightlist
+\item
+ asterisk 1
+\item
+ asterisk 2
+\item
+ asterisk 3
+\end{itemize}
+
+Asterisks loose:
+
+\begin{itemize}
+\item
+ asterisk 1
+\item
+ asterisk 2
+\item
+ asterisk 3
+\end{itemize}
+
+Pluses tight:
+
+\begin{itemize}
+\tightlist
+\item
+ Plus 1
+\item
+ Plus 2
+\item
+ Plus 3
+\end{itemize}
+
+Pluses loose:
+
+\begin{itemize}
+\item
+ Plus 1
+\item
+ Plus 2
+\item
+ Plus 3
+\end{itemize}
+
+Minuses tight:
+
+\begin{itemize}
+\tightlist
+\item
+ Minus 1
+\item
+ Minus 2
+\item
+ Minus 3
+\end{itemize}
+
+Minuses loose:
+
+\begin{itemize}
+\item
+ Minus 1
+\item
+ Minus 2
+\item
+ Minus 3
+\end{itemize}
+
+\subsection{Ordered}\label{ordered}
+
+Tight:
+
+\begin{enumerate}
+\def\labelenumi{\arabic{enumi}.}
+\tightlist
+\item
+ First
+\item
+ Second
+\item
+ Third
+\end{enumerate}
+
+and:
+
+\begin{enumerate}
+\def\labelenumi{\arabic{enumi}.}
+\tightlist
+\item
+ One
+\item
+ Two
+\item
+ Three
+\end{enumerate}
+
+Loose using tabs:
+
+\begin{enumerate}
+\def\labelenumi{\arabic{enumi}.}
+\item
+ First
+\item
+ Second
+\item
+ Third
+\end{enumerate}
+
+and using spaces:
+
+\begin{enumerate}
+\def\labelenumi{\arabic{enumi}.}
+\item
+ One
+\item
+ Two
+\item
+ Three
+\end{enumerate}
+
+Multiple paragraphs:
+
+\begin{enumerate}
+\def\labelenumi{\arabic{enumi}.}
+\item
+ Item 1, graf one.
+
+ Item 1. graf two. The quick brown fox jumped over the lazy dog's back.
+\item
+ Item 2.
+\item
+ Item 3.
+\end{enumerate}
+
+\subsection{Nested}\label{nested}
+
+\begin{itemize}
+\tightlist
+\item
+ Tab
+
+ \begin{itemize}
+ \tightlist
+ \item
+ Tab
+
+ \begin{itemize}
+ \tightlist
+ \item
+ Tab
+ \end{itemize}
+ \end{itemize}
+\end{itemize}
+
+Here's another:
+
+\begin{enumerate}
+\def\labelenumi{\arabic{enumi}.}
+\tightlist
+\item
+ First
+\item
+ Second:
+
+ \begin{itemize}
+ \tightlist
+ \item
+ Fee
+ \item
+ Fie
+ \item
+ Foe
+ \end{itemize}
+\item
+ Third
+\end{enumerate}
+
+Same thing but with paragraphs:
+
+\begin{enumerate}
+\def\labelenumi{\arabic{enumi}.}
+\item
+ First
+\item
+ Second:
+
+ \begin{itemize}
+ \tightlist
+ \item
+ Fee
+ \item
+ Fie
+ \item
+ Foe
+ \end{itemize}
+\item
+ Third
+\end{enumerate}
+
+\subsection{Tabs and spaces}\label{tabs-and-spaces}
+
+\begin{itemize}
+\item
+ this is a list item indented with tabs
+\item
+ this is a list item indented with spaces
+
+ \begin{itemize}
+ \item
+ this is an example list item indented with tabs
+ \item
+ this is an example list item indented with spaces
+ \end{itemize}
+\end{itemize}
+
+\subsection{Fancy list markers}\label{fancy-list-markers}
+
+\begin{enumerate}
+\def\labelenumi{(\arabic{enumi})}
+\setcounter{enumi}{1}
+\item
+ begins with 2
+\item
+ and now 3
+
+ with a continuation
+
+ \begin{enumerate}
+ \def\labelenumii{\roman{enumii}.}
+ \setcounter{enumii}{3}
+ \tightlist
+ \item
+ sublist with roman numerals, starting with 4
+ \item
+ more items
+
+ \begin{enumerate}
+ \def\labelenumiii{(\Alph{enumiii})}
+ \tightlist
+ \item
+ a subsublist
+ \item
+ a subsublist
+ \end{enumerate}
+ \end{enumerate}
+\end{enumerate}
+
+Nesting:
+
+\begin{enumerate}
+\def\labelenumi{\Alph{enumi}.}
+\tightlist
+\item
+ Upper Alpha
+
+ \begin{enumerate}
+ \def\labelenumii{\Roman{enumii}.}
+ \tightlist
+ \item
+ Upper Roman.
+
+ \begin{enumerate}
+ \def\labelenumiii{(\arabic{enumiii})}
+ \setcounter{enumiii}{5}
+ \tightlist
+ \item
+ Decimal start with 6
+
+ \begin{enumerate}
+ \def\labelenumiv{\alph{enumiv})}
+ \setcounter{enumiv}{2}
+ \tightlist
+ \item
+ Lower alpha with paren
+ \end{enumerate}
+ \end{enumerate}
+ \end{enumerate}
+\end{enumerate}
+
+Autonumbering:
+
+\begin{enumerate}
+\tightlist
+\item
+ Autonumber.
+\item
+ More.
+
+ \begin{enumerate}
+ \tightlist
+ \item
+ Nested.
+ \end{enumerate}
+\end{enumerate}
+
+Should not be a list item:
+
+M.A.~2007
+
+B. Williams
+
+\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
+
+\section{Definition Lists}\label{definition-lists}
+
+Tight using spaces:
+
+\begin{description}
+\tightlist
+\item[apple]
+red fruit
+\item[orange]
+orange fruit
+\item[banana]
+yellow fruit
+\end{description}
+
+Tight using tabs:
+
+\begin{description}
+\tightlist
+\item[apple]
+red fruit
+\item[orange]
+orange fruit
+\item[banana]
+yellow fruit
+\end{description}
+
+Loose:
+
+\begin{description}
+\item[apple]
+red fruit
+\item[orange]
+orange fruit
+\item[banana]
+yellow fruit
+\end{description}
+
+Multiple blocks with italics:
+
+\begin{description}
+\item[\emph{apple}]
+red fruit
+
+contains seeds, crisp, pleasant to taste
+\item[\emph{orange}]
+orange fruit
+
+\begin{verbatim}
+{ orange code block }
+\end{verbatim}
+
+\begin{quote}
+orange block quote
+\end{quote}
+\end{description}
+
+Multiple definitions, tight:
+
+\begin{description}
+\tightlist
+\item[apple]
+red fruit
+
+computer
+\item[orange]
+orange fruit
+
+bank
+\end{description}
+
+Multiple definitions, loose:
+
+\begin{description}
+\item[apple]
+red fruit
+
+computer
+\item[orange]
+orange fruit
+
+bank
+\end{description}
+
+Blank line after term, indented marker, alternate markers:
+
+\begin{description}
+\item[apple]
+red fruit
+
+computer
+\item[orange]
+orange fruit
+
+\begin{enumerate}
+\def\labelenumi{\arabic{enumi}.}
+\tightlist
+\item
+ sublist
+\item
+ sublist
+\end{enumerate}
+\end{description}
+
+\section{HTML Blocks}\label{html-blocks}
+
+Simple block on one line:
+
+foo
+
+And nested without indentation:
+
+foo
+
+bar
+
+Interpreted markdown in a table:
+
+This is \emph{emphasized}
+
+And this is \textbf{strong}
+
+Here's a simple block:
+
+foo
+
+This should be a code block, though:
+
+\begin{verbatim}
+<div>
+ foo
+</div>
+\end{verbatim}
+
+As should this:
+
+\begin{verbatim}
+<div>foo</div>
+\end{verbatim}
+
+Now, nested:
+
+foo
+
+This should just be an HTML comment:
+
+Multiline:
+
+Code block:
+
+\begin{verbatim}
+<!-- Comment -->
+\end{verbatim}
+
+Just plain comment, with trailing spaces on the line:
+
+Code:
+
+\begin{verbatim}
+<hr />
+\end{verbatim}
+
+Hr's:
+
+\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
+
+\section{Inline Markup}\label{inline-markup}
+
+This is \emph{emphasized}, and so \emph{is this}.
+
+This is \textbf{strong}, and so \textbf{is this}.
+
+An \emph{\href{/url}{emphasized link}}.
+
+\textbf{\emph{This is strong and em.}}
+
+So is \textbf{\emph{this}} word.
+
+\textbf{\emph{This is strong and em.}}
+
+So is \textbf{\emph{this}} word.
+
+This is code: \texttt{\textgreater{}}, \texttt{\$}, \texttt{\textbackslash{}},
+\texttt{\textbackslash{}\$}, \texttt{\textless{}html\textgreater{}}.
+
+\sout{This is \emph{strikeout}.}
+
+Superscripts: a\textsuperscript{bc}d a\textsuperscript{\emph{hello}}
+a\textsuperscript{hello~there}.
+
+Subscripts: H\textsubscript{2}O, H\textsubscript{23}O,
+H\textsubscript{many~of~them}O.
+
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a\^{}b c\^{}d, a\textasciitilde{}b c\textasciitilde{}d.
+
+\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
+
+\section{Smart quotes, ellipses, dashes}\label{smart-quotes-ellipses-dashes}
+
+``Hello,'' said the spider. ``\,`Shelob' is my name.''
+
+`A', `B', and `C' are letters.
+
+`Oak,' `elm,' and `beech' are names of trees. So is `pine.'
+
+`He said, ``I want to go.''\,' Were you alive in the 70's?
+
+Here is some quoted `\texttt{code}' and a
+``\href{http://example.com/?foo=1\&bar=2}{quoted link}''.
+
+Some dashes: one---two --- three---four --- five.
+
+Dashes between numbers: 5--7, 255--66, 1987--1999.
+
+Ellipses\ldots{}and\ldots{}and\ldots{}.
+
+\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
+
+\section{LaTeX}\label{latex}
+
+\begin{itemize}
+\tightlist
+\item
+ \cite[22-23]{smith.1899}
+\item
+ \(2+2=4\)
+\item
+ \(x \in y\)
+\item
+ \(\alpha \wedge \omega\)
+\item
+ \(223\)
+\item
+ \(p\)-Tree
+\item
+ Here's some display math:
+ \[\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}\]
+\item
+ Here's one that has a line break in it: \(\alpha + \omega \times x^2\).
+\end{itemize}
+
+These shouldn't be math:
+
+\begin{itemize}
+\tightlist
+\item
+ To get the famous equation, write \texttt{\$e\ =\ mc\^{}2\$}.
+\item
+ \$22,000 is a \emph{lot} of money. So is \$34,000. (It worked if ``lot'' is
+ emphasized.)
+\item
+ Shoes (\$20) and socks (\$5).
+\item
+ Escaped \texttt{\$}: \$73 \emph{this should be emphasized} 23\$.
+\end{itemize}
+
+Here's a LaTeX table:
+
+\begin{tabular}{|l|l|}\hline
+Animal & Number \\ \hline
+Dog & 2 \\
+Cat & 1 \\ \hline
+\end{tabular}
+
+\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
+
+\section{Special Characters}\label{special-characters}
+
+Here is some unicode:
+
+\begin{itemize}
+\tightlist
+\item
+ I hat: Î
+\item
+ o umlaut: ö
+\item
+ section: §
+\item
+ set membership: ∈
+\item
+ copyright: ©
+\end{itemize}
+
+AT\&T has an ampersand in their name.
+
+AT\&T is another way to write it.
+
+This \& that.
+
+4 \textless{} 5.
+
+6 \textgreater{} 5.
+
+Backslash: \textbackslash{}
+
+Backtick: `
+
+Asterisk: *
+
+Underscore: \_
+
+Left brace: \{
+
+Right brace: \}
+
+Left bracket: {[}
+
+Right bracket: {]}
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: \textgreater{}
+
+Hash: \#
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
+
+\section{Links}\label{links}
+
+\subsection{Explicit}\label{explicit}
+
+Just a \href{/url/}{URL}.
+
+\href{/url/}{URL and title}.
+
+\href{/url/}{URL and title}.
+
+\href{/url/}{URL and title}.
+
+\href{/url/}{URL and title}
+
+\href{/url/}{URL and title}
+
+\href{/url/with_underscore}{with\_underscore}
+
+\href{mailto:nobody@nowhere.net}{Email link}
+
+\href{}{Empty}.
+
+\subsection{Reference}\label{reference}
+
+Foo \href{/url/}{bar}.
+
+Foo \href{/url/}{bar}.
+
+Foo \href{/url/}{bar}.
+
+With \href{/url/}{embedded {[}brackets{]}}.
+
+\href{/url/}{b} by itself should be a link.
+
+Indented \href{/url}{once}.
+
+Indented \href{/url}{twice}.
+
+Indented \href{/url}{thrice}.
+
+This should {[}not{]}{[}{]} be a link.
+
+\begin{verbatim}
+[not]: /url
+\end{verbatim}
+
+Foo \href{/url/}{bar}.
+
+Foo \href{/url/}{biz}.
+
+\subsection{With ampersands}\label{with-ampersands}
+
+Here's a \href{http://example.com/?foo=1\&bar=2}{link with an ampersand in the
+URL}.
+
+Here's a link with an amersand in the link text:
+\href{http://att.com/}{AT\&T}.
+
+Here's an \href{/script?foo=1\&bar=2}{inline link}.
+
+Here's an \href{/script?foo=1\&bar=2}{inline link in pointy braces}.
+
+\subsection{Autolinks}\label{autolinks}
+
+With an ampersand: \url{http://example.com/?foo=1\&bar=2}
+
+\begin{itemize}
+\tightlist
+\item
+ In a list?
+\item
+ \url{http://example.com/}
+\item
+ It should.
+\end{itemize}
+
+An e-mail address:
+\href{mailto:nobody@nowhere.net}{\nolinkurl{nobody@nowhere.net}}
+
+\begin{quote}
+Blockquoted: \url{http://example.com/}
+\end{quote}
+
+Auto-links should not occur here:
+\texttt{\textless{}http://example.com/\textgreater{}}
+
+\begin{verbatim}
+or here: <http://example.com/>
+\end{verbatim}
+
+\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
+
+\section{Images}\label{images}
+
+From ``Voyage dans la Lune'' by Georges Melies (1902):
+
+\begin{figure}
+\centering
+\includegraphics{lalune.jpg}
+\caption{lalune}
+\end{figure}
+
+Here is a movie \includegraphics{movie.jpg} icon.
+
+\begin{center}\rule{0.5\linewidth}{\linethickness}\end{center}
+
+\section{Footnotes}\label{footnotes}
+
+Here is a footnote reference,\footnote{Here is the footnote. It can go
+ anywhere after the footnote reference. It need not be placed at the end of
+ the document.} and another.\footnote{Here's the long note. This one contains
+ multiple blocks.
+
+ Subsequent blocks are indented to show that they belong to the footnote (as
+ with list items).
+
+\begin{Verbatim}
+ { <code> }
+\end{Verbatim}
+
+ If you want, you can indent every line, but you can also be lazy and just
+ indent the first line of each block.} This should \emph{not} be a footnote
+reference, because it contains a space.{[}\^{}my note{]} Here is an inline
+note.\footnote{This is \emph{easier} to type. Inline notes may contain
+ \href{http://google.com}{links} and \texttt{{]}} verbatim characters, as
+ well as {[}bracketed text{]}.}
+
+\begin{quote}
+Notes can go in quotes.\footnote{In quote.}
+\end{quote}
+
+\begin{enumerate}
+\def\labelenumi{\arabic{enumi}.}
+\tightlist
+\item
+ And in list items.\footnote{In list.}
+\end{enumerate}
+
+This paragraph should not be part of the note, as it is not indented.
+
+\end{document}
diff --git a/test/writer.man b/test/writer.man
new file mode 100644
index 000000000..b0aece96b
--- /dev/null
+++ b/test/writer.man
@@ -0,0 +1,795 @@
+.TH "Pandoc Test Suite" "" "July 17, 2006" "" ""
+.hy
+.PP
+This is a set of tests for pandoc.
+Most of them are adapted from John Gruber'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 4
+.SS Level 5
+.SH Level 1
+.SS Level 2 with \f[I]emphasis\f[]
+.SS Level 3
+.PP
+with no blank line
+.SS Level 2
+.PP
+with no blank line
+.PP
+ * * * * *
+.SH Paragraphs
+.PP
+Here'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
+item.
+.PP
+Here's one with a bullet.
+* criminey.
+.PP
+There should be a hard line break
+.PD 0
+.P
+.PD
+here.
+.PP
+ * * * * *
+.SH Block Quotes
+.PP
+E\-mail style:
+.RS
+.PP
+This is a block quote.
+It is pretty short.
+.RE
+.RS
+.PP
+Code in a block quote:
+.IP
+.nf
+\f[C]
+sub\ status\ {
+\ \ \ \ print\ "working";
+}
+\f[]
+.fi
+.PP
+A list:
+.IP "1." 3
+item one
+.IP "2." 3
+item two
+.PP
+Nested block quotes:
+.RS
+.PP
+nested
+.RE
+.RS
+.PP
+nested
+.RE
+.RE
+.PP
+This should not be a block quote: 2 > 1.
+.PP
+And a following paragraph.
+.PP
+ * * * * *
+.SH Code Blocks
+.PP
+Code:
+.IP
+.nf
+\f[C]
+\-\-\-\-\ (should\ be\ four\ hyphens)
+
+sub\ status\ {
+\ \ \ \ print\ "working";
+}
+
+this\ code\ block\ is\ indented\ by\ one\ tab
+\f[]
+.fi
+.PP
+And:
+.IP
+.nf
+\f[C]
+\ \ \ \ this\ code\ block\ is\ indented\ by\ two\ tabs
+
+These\ should\ not\ be\ escaped:\ \ \\$\ \\\\\ \\>\ \\[\ \\{
+\f[]
+.fi
+.PP
+ * * * * *
+.SH Lists
+.SS Unordered
+.PP
+Asterisks tight:
+.IP \[bu] 2
+asterisk 1
+.IP \[bu] 2
+asterisk 2
+.IP \[bu] 2
+asterisk 3
+.PP
+Asterisks loose:
+.IP \[bu] 2
+asterisk 1
+.IP \[bu] 2
+asterisk 2
+.IP \[bu] 2
+asterisk 3
+.PP
+Pluses tight:
+.IP \[bu] 2
+Plus 1
+.IP \[bu] 2
+Plus 2
+.IP \[bu] 2
+Plus 3
+.PP
+Pluses loose:
+.IP \[bu] 2
+Plus 1
+.IP \[bu] 2
+Plus 2
+.IP \[bu] 2
+Plus 3
+.PP
+Minuses tight:
+.IP \[bu] 2
+Minus 1
+.IP \[bu] 2
+Minus 2
+.IP \[bu] 2
+Minus 3
+.PP
+Minuses loose:
+.IP \[bu] 2
+Minus 1
+.IP \[bu] 2
+Minus 2
+.IP \[bu] 2
+Minus 3
+.SS Ordered
+.PP
+Tight:
+.IP "1." 3
+First
+.IP "2." 3
+Second
+.IP "3." 3
+Third
+.PP
+and:
+.IP "1." 3
+One
+.IP "2." 3
+Two
+.IP "3." 3
+Three
+.PP
+Loose using tabs:
+.IP "1." 3
+First
+.IP "2." 3
+Second
+.IP "3." 3
+Third
+.PP
+and using spaces:
+.IP "1." 3
+One
+.IP "2." 3
+Two
+.IP "3." 3
+Three
+.PP
+Multiple paragraphs:
+.IP "1." 3
+Item 1, graf one.
+.RS 4
+.PP
+Item 1.
+graf two.
+The quick brown fox jumped over the lazy dog's back.
+.RE
+.IP "2." 3
+Item 2.
+.IP "3." 3
+Item 3.
+.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 but with paragraphs:
+.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 Tabs and spaces
+.IP \[bu] 2
+this is a list item indented with tabs
+.IP \[bu] 2
+this is a list item indented with spaces
+.RS 2
+.IP \[bu] 2
+this is an example list item indented with tabs
+.IP \[bu] 2
+this is an example list item indented with spaces
+.RE
+.SS Fancy list markers
+.IP "(2)" 4
+begins with 2
+.IP "(3)" 4
+and now 3
+.RS 4
+.PP
+with a continuation
+.IP "iv." 4
+sublist with roman numerals, starting with 4
+.IP " v." 4
+more items
+.RS 4
+.IP "(A)" 4
+a subsublist
+.IP "(B)" 4
+a subsublist
+.RE
+.RE
+.PP
+Nesting:
+.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
+.PP
+Autonumbering:
+.IP "1." 3
+Autonumber.
+.IP "2." 3
+More.
+.RS 4
+.IP "1." 3
+Nested.
+.RE
+.PP
+Should not be a list item:
+.PP
+M.A.\ 2007
+.PP
+B.
+Williams
+.PP
+ * * * * *
+.SH Definition Lists
+.PP
+Tight using spaces:
+.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[]
+red fruit
+.RS
+.PP
+contains seeds, crisp, pleasant to taste
+.RE
+.TP
+.B \f[I]orange\f[]
+orange fruit
+.RS
+.IP
+.nf
+\f[C]
+{\ orange\ code\ block\ }
+\f[]
+.fi
+.RS
+.PP
+orange block quote
+.RE
+.RE
+.PP
+Multiple definitions, tight:
+.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
+.RS
+.IP "1." 3
+sublist
+.IP "2." 3
+sublist
+.RE
+.SH HTML Blocks
+.PP
+Simple block on one line:
+foo
+.PP
+And nested without indentation:
+.PP
+foo
+bar
+.PP
+Interpreted markdown in a table:
+This is \f[I]emphasized\f[]
+And this is \f[B]strong\f[]
+.PP
+Here's a simple block:
+.PP
+foo
+.PP
+This should be a code block, though:
+.IP
+.nf
+\f[C]
+<div>
+\ \ \ \ foo
+</div>
+\f[]
+.fi
+.PP
+As should this:
+.IP
+.nf
+\f[C]
+<div>foo</div>
+\f[]
+.fi
+.PP
+Now, nested:
+foo
+.PP
+This should just be an HTML comment:
+.PP
+Multiline:
+.PP
+Code block:
+.IP
+.nf
+\f[C]
+<!\-\-\ Comment\ \-\->
+\f[]
+.fi
+.PP
+Just plain comment, with trailing spaces on the line:
+.PP
+Code:
+.IP
+.nf
+\f[C]
+<hr\ />
+\f[]
+.fi
+.PP
+Hr's:
+.PP
+ * * * * *
+.SH Inline Markup
+.PP
+This is \f[I]emphasized\f[], and so \f[I]is this\f[].
+.PP
+This is \f[B]strong\f[], and so \f[B]is this\f[].
+.PP
+An \f[I]emphasized link (/url)\f[].
+.PP
+\f[B]\f[I]This is strong and em.\f[]\f[]
+.PP
+So is \f[B]\f[I]this\f[]\f[] word.
+.PP
+\f[B]\f[I]This is strong and em.\f[]\f[]
+.PP
+So is \f[B]\f[I]this\f[]\f[] word.
+.PP
+This is code: \f[C]>\f[], \f[C]$\f[], \f[C]\\\f[], \f[C]\\$\f[],
+\f[C]<html>\f[].
+.PP
+[STRIKEOUT:This is \f[I]strikeout\f[].]
+.PP
+Superscripts: a^bc^d a^\f[I]hello\f[]^ a^hello\ there^.
+.PP
+Subscripts: H~2~O, H~23~O, H~many\ of\ them~O.
+.PP
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a^b c^d, a~b c~d.
+.PP
+ * * * * *
+.SH Smart quotes, ellipses, dashes
+.PP
+\[lq]Hello,\[rq] said the spider.
+\[lq]`Shelob' is my name.\[rq]
+.PP
+`A', `B', and `C' are letters.
+.PP
+`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?
+.PP
+Here is some quoted `\f[C]code\f[]' and a \[lq]quoted
+link (http://example.com/?foo=1&bar=2)\[rq].
+.PP
+Some dashes: one\[em]two \[em] three\[em]four \[em] five.
+.PP
+Dashes between numbers: 5\[en]7, 255\[en]66, 1987\[en]1999.
+.PP
+Ellipses\&...and\&...and\&....
+.PP
+ * * * * *
+.SH LaTeX
+.IP \[bu] 2
+.IP \[bu] 2
+2 + 2 = 4
+.IP \[bu] 2
+\f[I]x\f[] ∈ \f[I]y\f[]
+.IP \[bu] 2
+\f[I]α\f[] ∧ \f[I]ω\f[]
+.IP \[bu] 2
+223
+.IP \[bu] 2
+\f[I]p\f[]\-Tree
+.IP \[bu] 2
+Here's some display math:
+.RS
+$$\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\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^.
+.PP
+These shouldn't be math:
+.IP \[bu] 2
+To get the famous equation, write \f[C]$e\ =\ mc^2$\f[].
+.IP \[bu] 2
+$22,000 is a \f[I]lot\f[] 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$.
+.PP
+Here's a LaTeX table:
+.PP
+ * * * * *
+.SH Special Characters
+.PP
+Here is some unicode:
+.IP \[bu] 2
+I hat: Î
+.IP \[bu] 2
+o umlaut: ö
+.IP \[bu] 2
+section: §
+.IP \[bu] 2
+set membership: ∈
+.IP \[bu] 2
+copyright: ©
+.PP
+AT&T has an ampersand in their name.
+.PP
+AT&T is another way to write it.
+.PP
+This & that.
+.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
+.SS Explicit
+.PP
+Just a URL (/url/).
+.PP
+URL and title (/url/).
+.PP
+URL and title (/url/).
+.PP
+URL and title (/url/).
+.PP
+URL and title (/url/)
+.PP
+URL and title (/url/)
+.PP
+with_underscore (/url/with_underscore)
+.PP
+Email link (mailto:nobody@nowhere.net)
+.PP
+Empty ().
+.SS Reference
+.PP
+Foo bar (/url/).
+.PP
+Foo bar (/url/).
+.PP
+Foo bar (/url/).
+.PP
+With embedded [brackets] (/url/).
+.PP
+b (/url/) by itself should be a link.
+.PP
+Indented once (/url).
+.PP
+Indented twice (/url).
+.PP
+Indented thrice (/url).
+.PP
+This should [not][] be a link.
+.IP
+.nf
+\f[C]
+[not]:\ /url
+\f[]
+.fi
+.PP
+Foo bar (/url/).
+.PP
+Foo biz (/url/).
+.SS With ampersands
+.PP
+Here's a link with an ampersand in the URL (http://example.com/?foo=1&bar=2).
+.PP
+Here's a link with an amersand in the link text: AT&T (http://att.com/).
+.PP
+Here's an inline link (/script?foo=1&bar=2).
+.PP
+Here'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>
+.IP \[bu] 2
+In a list?
+.IP \[bu] 2
+<http://example.com/>
+.IP \[bu] 2
+It should.
+.PP
+An e\-mail address: <nobody@nowhere.net>
+.RS
+.PP
+Blockquoted: <http://example.com/>
+.RE
+.PP
+Auto\-links should not occur here: \f[C]<http://example.com/>\f[]
+.IP
+.nf
+\f[C]
+or\ here:\ <http://example.com/>
+\f[]
+.fi
+.PP
+ * * * * *
+.SH Images
+.PP
+From \[lq]Voyage dans la Lune\[rq] by Georges Melies (1902):
+.PP
+[IMAGE: lalune (lalune.jpg)]
+.PP
+Here is a movie [IMAGE: movie (movie.jpg)] icon.
+.PP
+ * * * * *
+.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]
+.RS
+.PP
+Notes can go in quotes.[4]
+.RE
+.IP "1." 3
+And in list items.[5]
+.PP
+This paragraph should not be part of the note, as it is not indented.
+.SH NOTES
+.SS [1]
+.PP
+Here is the footnote.
+It can go anywhere after the footnote reference.
+It need not be placed at the end of the document.
+.SS [2]
+.PP
+Here's the long note.
+This one contains multiple blocks.
+.PP
+Subsequent blocks are indented to show that they belong to the footnote (as
+with list items).
+.IP
+.nf
+\f[C]
+\ \ {\ <code>\ }
+\f[]
+.fi
+.PP
+If you want, you can indent every line, but you can also be lazy and just
+indent the first line of each block.
+.SS [3]
+.PP
+This is \f[I]easier\f[] to type.
+Inline notes may contain links (http://google.com) and \f[C]]\f[] verbatim
+characters, as well as [bracketed text].
+.SS [4]
+.PP
+In quote.
+.SS [5]
+.PP
+In list.
+.SH AUTHORS
+John MacFarlane; Anonymous.
diff --git a/test/writer.markdown b/test/writer.markdown
new file mode 100644
index 000000000..3fe0f4b3e
--- /dev/null
+++ b/test/writer.markdown
@@ -0,0 +1,746 @@
+---
+author:
+- John MacFarlane
+- Anonymous
+date: 'July 17, 2006'
+title: Pandoc Test Suite
+---
+
+This is a set of tests for pandoc. Most of them are adapted from John Gruber's
+markdown test suite.
+
+------------------------------------------------------------------------------
+
+Headers
+=======
+
+Level 2 with an [embedded link](/url)
+-------------------------------------
+
+### Level 3 with *emphasis*
+
+#### Level 4
+
+##### Level 5
+
+Level 1
+=======
+
+Level 2 with *emphasis*
+-----------------------
+
+### Level 3
+
+with no blank line
+
+Level 2
+-------
+
+with no blank line
+
+------------------------------------------------------------------------------
+
+Paragraphs
+==========
+
+Here's a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
+
+Here's one with a bullet. \* criminey.
+
+There should be a hard line break\
+here.
+
+------------------------------------------------------------------------------
+
+Block Quotes
+============
+
+E-mail style:
+
+> This is a block quote. It is pretty short.
+
+> Code in a block quote:
+>
+> sub status {
+> print "working";
+> }
+>
+> A list:
+>
+> 1. item one
+> 2. item two
+>
+> Nested block quotes:
+>
+> > nested
+>
+> > nested
+
+This should not be a block quote: 2 &gt; 1.
+
+And a following paragraph.
+
+------------------------------------------------------------------------------
+
+Code Blocks
+===========
+
+Code:
+
+ ---- (should be four hyphens)
+
+ sub status {
+ print "working";
+ }
+
+ this code block is indented by one tab
+
+And:
+
+ this code block is indented by two tabs
+
+ These should not be escaped: \$ \\ \> \[ \{
+
+------------------------------------------------------------------------------
+
+Lists
+=====
+
+Unordered
+---------
+
+Asterisks tight:
+
+- asterisk 1
+- asterisk 2
+- asterisk 3
+
+Asterisks loose:
+
+- asterisk 1
+
+- asterisk 2
+
+- asterisk 3
+
+Pluses tight:
+
+- Plus 1
+- Plus 2
+- Plus 3
+
+Pluses loose:
+
+- Plus 1
+
+- Plus 2
+
+- Plus 3
+
+Minuses tight:
+
+- Minus 1
+- Minus 2
+- Minus 3
+
+Minuses loose:
+
+- Minus 1
+
+- Minus 2
+
+- Minus 3
+
+Ordered
+-------
+
+Tight:
+
+1. First
+2. Second
+3. Third
+
+and:
+
+1. One
+2. Two
+3. Three
+
+Loose using tabs:
+
+1. First
+
+2. Second
+
+3. Third
+
+and using spaces:
+
+1. One
+
+2. Two
+
+3. Three
+
+Multiple paragraphs:
+
+1. Item 1, graf one.
+
+ Item 1. graf two. The quick brown fox jumped over the lazy dog's back.
+
+2. Item 2.
+
+3. Item 3.
+
+Nested
+------
+
+- Tab
+ - Tab
+ - Tab
+
+Here's another:
+
+1. First
+2. Second:
+ - Fee
+ - Fie
+ - Foe
+3. Third
+
+Same thing but with paragraphs:
+
+1. First
+
+2. Second:
+
+ - Fee
+ - Fie
+ - Foe
+
+3. Third
+
+Tabs and spaces
+---------------
+
+- this is a list item indented with tabs
+
+- this is a list item indented with spaces
+
+ - this is an example list item indented with tabs
+
+ - this is an example list item indented with spaces
+
+Fancy list markers
+------------------
+
+(2) begins with 2
+(3) and now 3
+
+ with a continuation
+
+ iv. sublist with roman numerals, starting with 4
+ v. more items
+ (A) a subsublist
+ (B) a subsublist
+
+Nesting:
+
+A. Upper Alpha
+ I. Upper Roman.
+ (6) Decimal start with 6
+ c) Lower alpha with paren
+
+Autonumbering:
+
+1. Autonumber.
+2. More.
+ 1. Nested.
+
+Should not be a list item:
+
+M.A. 2007
+
+B. Williams
+
+------------------------------------------------------------------------------
+
+Definition Lists
+================
+
+Tight using spaces:
+
+apple
+: red fruit
+
+orange
+: orange fruit
+
+banana
+: yellow fruit
+
+Tight using tabs:
+
+apple
+: red fruit
+
+orange
+: orange fruit
+
+banana
+: yellow fruit
+
+Loose:
+
+apple
+
+: red fruit
+
+orange
+
+: orange fruit
+
+banana
+
+: yellow fruit
+
+Multiple blocks with italics:
+
+*apple*
+
+: red fruit
+
+ contains seeds, crisp, pleasant to taste
+
+*orange*
+
+: orange fruit
+
+ { orange code block }
+
+ > orange block quote
+
+Multiple definitions, tight:
+
+apple
+: red fruit
+: computer
+
+orange
+: orange fruit
+: bank
+
+Multiple definitions, loose:
+
+apple
+
+: red fruit
+
+: computer
+
+orange
+
+: orange fruit
+
+: bank
+
+Blank line after term, indented marker, alternate markers:
+
+apple
+
+: red fruit
+
+: computer
+
+orange
+
+: orange fruit
+
+ 1. sublist
+ 2. sublist
+
+HTML Blocks
+===========
+
+Simple block on one line:
+
+<div>
+
+foo
+
+</div>
+
+And nested without indentation:
+
+<div>
+
+<div>
+
+<div>
+
+foo
+
+</div>
+
+</div>
+
+<div>
+
+bar
+
+</div>
+
+</div>
+
+Interpreted markdown in a table:
+
+<table>
+<tr>
+<td>
+This is *emphasized*
+</td>
+<td>
+And this is **strong**
+</td>
+</tr>
+</table>
+<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
+Here's a simple block:
+
+<div>
+
+foo
+
+</div>
+
+This should be a code block, though:
+
+ <div>
+ foo
+ </div>
+
+As should this:
+
+ <div>foo</div>
+
+Now, nested:
+
+<div>
+
+<div>
+
+<div>
+
+foo
+
+</div>
+
+</div>
+
+</div>
+
+This should just be an HTML comment:
+
+<!-- Comment -->
+Multiline:
+
+<!--
+Blah
+Blah
+-->
+<!--
+ This is another comment.
+-->
+Code block:
+
+ <!-- Comment -->
+
+Just plain comment, with trailing spaces on the line:
+
+<!-- foo -->
+Code:
+
+ <hr />
+
+Hr's:
+
+<hr>
+<hr />
+<hr />
+<hr>
+<hr />
+<hr />
+<hr class="foo" id="bar" />
+<hr class="foo" id="bar" />
+<hr class="foo" id="bar">
+
+------------------------------------------------------------------------------
+
+Inline Markup
+=============
+
+This is *emphasized*, and so *is this*.
+
+This is **strong**, and so **is this**.
+
+An *[emphasized link](/url)*.
+
+***This is strong and em.***
+
+So is ***this*** word.
+
+***This is strong and em.***
+
+So is ***this*** word.
+
+This is code: `>`, `$`, `\`, `\$`, `<html>`.
+
+~~This is *strikeout*.~~
+
+Superscripts: a^bc^d a^*hello*^ a^hello there^.
+
+Subscripts: H~2~O, H~23~O, H~many of them~O.
+
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a\^b c\^d, a\~b c\~d.
+
+------------------------------------------------------------------------------
+
+Smart quotes, ellipses, dashes
+==============================
+
+"Hello," said the spider. "'Shelob' is my name."
+
+'A', 'B', and 'C' are letters.
+
+'Oak,' 'elm,' and 'beech' are names of trees. So is 'pine.'
+
+'He said, "I want to go."' Were you alive in the 70's?
+
+Here is some quoted '`code`' and a "[quoted
+link](http://example.com/?foo=1&bar=2)".
+
+Some dashes: one---two --- three---four --- five.
+
+Dashes between numbers: 5--7, 255--66, 1987--1999.
+
+Ellipses...and...and....
+
+------------------------------------------------------------------------------
+
+LaTeX
+=====
+
+- \cite[22-23]{smith.1899}
+- $2+2=4$
+- $x \in y$
+- $\alpha \wedge \omega$
+- $223$
+- $p$-Tree
+- Here's some display math:
+ $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
+- Here's one that has a line break in it: $\alpha + \omega \times x^2$.
+
+These shouldn't be math:
+
+- To get the famous equation, write `$e = mc^2$`.
+- \$22,000 is a *lot* of money. So is \$34,000. (It worked if "lot" is
+ emphasized.)
+- Shoes (\$20) and socks (\$5).
+- Escaped `$`: \$73 *this should be emphasized* 23\$.
+
+Here's a LaTeX table:
+
+\begin{tabular}{|l|l|}\hline
+Animal & Number \\ \hline
+Dog & 2 \\
+Cat & 1 \\ \hline
+\end{tabular}
+
+------------------------------------------------------------------------------
+
+Special Characters
+==================
+
+Here is some unicode:
+
+- I hat: Î
+- o umlaut: ö
+- section: §
+- set membership: ∈
+- copyright: ©
+
+AT&T has an ampersand in their name.
+
+AT&T is another way to write it.
+
+This & that.
+
+4 &lt; 5.
+
+6 &gt; 5.
+
+Backslash: \\
+
+Backtick: \`
+
+Asterisk: \*
+
+Underscore: \_
+
+Left brace: {
+
+Right brace: }
+
+Left bracket: \[
+
+Right bracket: \]
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: &gt;
+
+Hash: \#
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+------------------------------------------------------------------------------
+
+Links
+=====
+
+Explicit
+--------
+
+Just a [URL](/url/).
+
+[URL and title](/url/ "title").
+
+[URL and title](/url/ "title preceded by two spaces").
+
+[URL and title](/url/ "title preceded by a tab").
+
+[URL and title](/url/ "title with "quotes" in it")
+
+[URL and title](/url/ "title with single quotes")
+
+[with\_underscore](/url/with_underscore)
+
+[Email link](mailto:nobody@nowhere.net)
+
+[Empty]().
+
+Reference
+---------
+
+Foo [bar](/url/).
+
+Foo [bar](/url/).
+
+Foo [bar](/url/).
+
+With [embedded \[brackets\]](/url/).
+
+[b](/url/) by itself should be a link.
+
+Indented [once](/url).
+
+Indented [twice](/url).
+
+Indented [thrice](/url).
+
+This should \[not\]\[\] be a link.
+
+ [not]: /url
+
+Foo [bar](/url/ "Title with "quotes" inside").
+
+Foo [biz](/url/ "Title with "quote" inside").
+
+With ampersands
+---------------
+
+Here's a [link with an ampersand in the URL](http://example.com/?foo=1&bar=2).
+
+Here's a link with an amersand in the link text:
+[AT&T](http://att.com/ "AT&T").
+
+Here's an [inline link](/script?foo=1&bar=2).
+
+Here's an [inline link in pointy braces](/script?foo=1&bar=2).
+
+Autolinks
+---------
+
+With an ampersand: <http://example.com/?foo=1&bar=2>
+
+- In a list?
+- <http://example.com/>
+- It should.
+
+An e-mail address: <nobody@nowhere.net>
+
+> Blockquoted: <http://example.com/>
+
+Auto-links should not occur here: `<http://example.com/>`
+
+ or here: <http://example.com/>
+
+------------------------------------------------------------------------------
+
+Images
+======
+
+From "Voyage dans la Lune" by Georges Melies (1902):
+
+![lalune](lalune.jpg "Voyage dans la Lune")
+
+Here is a movie ![movie](movie.jpg) icon.
+
+------------------------------------------------------------------------------
+
+Footnotes
+=========
+
+Here is a footnote reference,[^1] and another.[^2] This should *not* be a
+footnote reference, because it contains a space.\[\^my note\] Here is an
+inline note.[^3]
+
+> Notes can go in quotes.[^4]
+
+1. And in list items.[^5]
+
+This paragraph should not be part of the note, as it is not indented.
+
+[^1]: Here is the footnote. It can go anywhere after the footnote reference.
+ It need not be placed at the end of the document.
+
+[^2]: Here's the long note. This one contains multiple blocks.
+
+ Subsequent blocks are indented to show that they belong to the footnote
+ (as with list items).
+
+ { <code> }
+
+ If you want, you can indent every line, but you can also be lazy and just
+ indent the first line of each block.
+
+[^3]: This is *easier* to type. Inline notes may contain
+ [links](http://google.com) and `]` verbatim characters, as well as
+ \[bracketed text\].
+
+[^4]: In quote.
+
+[^5]: In list.
diff --git a/test/writer.mediawiki b/test/writer.mediawiki
new file mode 100644
index 000000000..066606c00
--- /dev/null
+++ b/test/writer.mediawiki
@@ -0,0 +1,653 @@
+This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite.
+
+
+-----
+
+= Headers =
+
+== Level 2 with an [[url|embedded link]] ==
+
+=== Level 3 with ''emphasis'' ===
+
+==== Level 4 ====
+
+===== Level 5 =====
+
+= Level 1 =
+
+== Level 2 with ''emphasis'' ==
+
+=== Level 3 ===
+
+with no blank line
+
+== Level 2 ==
+
+with no blank line
+
+
+-----
+
+= Paragraphs =
+
+Here’s a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard-wrapped line in the middle of a paragraph looked like a list item.
+
+Here’s one with a bullet. * criminey.
+
+There should be a hard line break<br />
+here.
+
+
+-----
+
+= Block Quotes =
+
+E-mail style:
+
+<blockquote>This is a block quote. It is pretty short.
+</blockquote>
+<blockquote>Code in a block quote:
+
+<pre>sub status {
+ print &quot;working&quot;;
+}</pre>
+A list:
+
+# item one
+# item two
+
+Nested block quotes:
+
+<blockquote>nested
+</blockquote>
+<blockquote>nested
+</blockquote></blockquote>
+This should not be a block quote: 2 &gt; 1.
+
+And a following paragraph.
+
+
+-----
+
+= Code Blocks =
+
+Code:
+
+<pre>---- (should be four hyphens)
+
+sub status {
+ print &quot;working&quot;;
+}
+
+this code block is indented by one tab</pre>
+And:
+
+<pre> this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \&gt; \[ \{</pre>
+
+-----
+
+= Lists =
+
+== Unordered ==
+
+Asterisks tight:
+
+* asterisk 1
+* asterisk 2
+* asterisk 3
+
+Asterisks loose:
+
+* asterisk 1
+* asterisk 2
+* asterisk 3
+
+Pluses tight:
+
+* Plus 1
+* Plus 2
+* Plus 3
+
+Pluses loose:
+
+* Plus 1
+* Plus 2
+* Plus 3
+
+Minuses tight:
+
+* Minus 1
+* Minus 2
+* Minus 3
+
+Minuses loose:
+
+* Minus 1
+* Minus 2
+* Minus 3
+
+== Ordered ==
+
+Tight:
+
+# First
+# Second
+# Third
+
+and:
+
+# One
+# Two
+# Three
+
+Loose using tabs:
+
+# First
+# Second
+# Third
+
+and using spaces:
+
+# One
+# Two
+# Three
+
+Multiple paragraphs:
+
+<ol style="list-style-type: decimal;">
+<li><p>Item 1, graf one.</p>
+<p>Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.</p></li>
+<li><p>Item 2.</p></li>
+<li><p>Item 3.</p></li></ol>
+
+== Nested ==
+
+* Tab
+** Tab
+*** Tab
+
+Here’s another:
+
+# First
+# Second:
+#* Fee
+#* Fie
+#* Foe
+# Third
+
+Same thing but with paragraphs:
+
+# First
+# Second:
+#* Fee
+#* Fie
+#* Foe
+# Third
+
+== Tabs and spaces ==
+
+* this is a list item indented with tabs
+* this is a list item indented with spaces
+** this is an example list item indented with tabs
+** this is an example list item indented with spaces
+
+== Fancy list markers ==
+
+<ol start="2" style="list-style-type: decimal;">
+<li>begins with 2</li>
+<li><p>and now 3</p>
+<p>with a continuation</p>
+<ol start="4" style="list-style-type: lower-roman;">
+<li>sublist with roman numerals, starting with 4</li>
+<li>more items
+<ol style="list-style-type: upper-alpha;">
+<li>a subsublist</li>
+<li>a subsublist</li></ol>
+</li></ol>
+</li></ol>
+
+Nesting:
+
+<ol style="list-style-type: upper-alpha;">
+<li>Upper Alpha
+<ol style="list-style-type: upper-roman;">
+<li>Upper Roman.
+<ol start="6" style="list-style-type: decimal;">
+<li>Decimal start with 6
+<ol start="3" style="list-style-type: lower-alpha;">
+<li>Lower alpha with paren</li></ol>
+</li></ol>
+</li></ol>
+</li></ol>
+
+Autonumbering:
+
+# Autonumber.
+# More.
+## Nested.
+
+Should not be a list item:
+
+M.A. 2007
+
+B. Williams
+
+
+-----
+
+= Definition Lists =
+
+Tight using spaces:
+
+; apple
+: red fruit
+; orange
+: orange fruit
+; banana
+: yellow fruit
+
+Tight using tabs:
+
+; apple
+: red fruit
+; orange
+: orange fruit
+; banana
+: yellow fruit
+
+Loose:
+
+; apple
+: red fruit
+; orange
+: orange fruit
+; banana
+: yellow fruit
+
+Multiple blocks with italics:
+
+<dl>
+<dt>''apple''</dt>
+<dd><p>red fruit</p>
+<p>contains seeds, crisp, pleasant to taste</p></dd>
+<dt>''orange''</dt>
+<dd><p>orange fruit</p>
+<pre>{ orange code block }</pre>
+<blockquote><p>orange block quote</p></blockquote></dd></dl>
+
+Multiple definitions, tight:
+
+; apple
+: red fruit
+: computer
+; orange
+: orange fruit
+: bank
+
+Multiple definitions, loose:
+
+; apple
+: red fruit
+: computer
+; orange
+: orange fruit
+: bank
+
+Blank line after term, indented marker, alternate markers:
+
+; apple
+: red fruit
+: computer
+; orange
+: orange fruit
+;# sublist
+;# sublist
+
+= HTML Blocks =
+
+Simple block on one line:
+
+<div>
+
+foo
+
+</div>
+And nested without indentation:
+
+<div>
+
+<div>
+
+<div>
+
+foo
+
+
+</div>
+
+</div>
+<div>
+
+bar
+
+</div>
+
+</div>
+Interpreted markdown in a table:
+
+<table>
+<tr>
+<td>
+This is ''emphasized''
+</td>
+<td>
+And this is '''strong'''
+</td>
+</tr>
+</table>
+<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
+Here’s a simple block:
+
+<div>
+
+foo
+
+
+</div>
+This should be a code block, though:
+
+<pre>&lt;div&gt;
+ foo
+&lt;/div&gt;</pre>
+As should this:
+
+<pre>&lt;div&gt;foo&lt;/div&gt;</pre>
+Now, nested:
+
+<div>
+
+<div>
+
+<div>
+
+foo
+
+</div>
+
+</div>
+
+</div>
+This should just be an HTML comment:
+
+<!-- Comment -->
+Multiline:
+
+<!--
+Blah
+Blah
+-->
+<!--
+ This is another comment.
+-->
+Code block:
+
+<pre>&lt;!-- Comment --&gt;</pre>
+Just plain comment, with trailing spaces on the line:
+
+<!-- foo -->
+Code:
+
+<pre>&lt;hr /&gt;</pre>
+Hr’s:
+
+<hr>
+<hr />
+<hr />
+<hr>
+<hr />
+<hr />
+<hr class="foo" id="bar" />
+<hr class="foo" id="bar" />
+<hr class="foo" id="bar">
+
+-----
+
+= Inline Markup =
+
+This is ''emphasized'', and so ''is this''.
+
+This is '''strong''', and so '''is this'''.
+
+An ''[[url|emphasized link]]''.
+
+'''''This is strong and em.'''''
+
+So is '''''this''''' word.
+
+'''''This is strong and em.'''''
+
+So is '''''this''''' word.
+
+This is code: <code>&gt;</code>, <code>$</code>, <code>\</code>, <code>\$</code>, <code>&lt;html&gt;</code>.
+
+<s>This is ''strikeout''.</s>
+
+Superscripts: a<sup>bc</sup>d a<sup>''hello''</sup> a<sup>hello there</sup>.
+
+Subscripts: H<sub>2</sub>O, H<sub>23</sub>O, H<sub>many of them</sub>O.
+
+These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.
+
+
+-----
+
+= Smart quotes, ellipses, dashes =
+
+“Hello,” said the spider. “‘Shelob’ is my name.”
+
+‘A’, ‘B’, and ‘C’ are letters.
+
+‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’
+
+‘He said, “I want to go.”’ Were you alive in the 70’s?
+
+Here is some quoted ‘<code>code</code>’ and a “[http://example.com/?foo=1&bar=2 quoted link]”.
+
+Some dashes: one—two — three—four — five.
+
+Dashes between numbers: 5–7, 255–66, 1987–1999.
+
+Ellipses…and…and….
+
+
+-----
+
+= LaTeX =
+
+*
+* <math>2+2=4</math>
+* <math>x \in y</math>
+* <math>\alpha \wedge \omega</math>
+* <math>223</math>
+* <math>p</math>-Tree
+* Here’s some display math: <math>\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</math>
+* Here’s one that has a line break in it: <math>\alpha + \omega \times x^2</math>.
+
+These shouldn’t be math:
+
+* To get the famous equation, write <code>$e = mc^2$</code>.
+* $22,000 is a ''lot'' of money. So is $34,000. (It worked if “lot” is emphasized.)
+* Shoes ($20) and socks ($5).
+* Escaped <code>$</code>: $73 ''this should be emphasized'' 23$.
+
+Here’s a LaTeX table:
+
+
+
+-----
+
+= Special Characters =
+
+Here is some unicode:
+
+* I hat: Î
+* o umlaut: ö
+* section: §
+* set membership: ∈
+* copyright: ©
+
+AT&amp;T has an ampersand in their name.
+
+AT&amp;T is another way to write it.
+
+This &amp; that.
+
+4 &lt; 5.
+
+6 &gt; 5.
+
+Backslash: \
+
+Backtick: `
+
+Asterisk: *
+
+Underscore: _
+
+Left brace: {
+
+Right brace: }
+
+Left bracket: [
+
+Right bracket: ]
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: &gt;
+
+Hash: #
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+
+-----
+
+= Links =
+
+== Explicit ==
+
+Just a [[url/|URL]].
+
+[[url/|URL and title]].
+
+[[url/|URL and title]].
+
+[[url/|URL and title]].
+
+[[url/|URL and title]]
+
+[[url/|URL and title]]
+
+[[url/with_underscore|with_underscore]]
+
+[mailto:nobody@nowhere.net Email link]
+
+[[|Empty]].
+
+== Reference ==
+
+Foo [[url/|bar]].
+
+Foo [[url/|bar]].
+
+Foo [[url/|bar]].
+
+With [[url/|embedded [brackets]]].
+
+[[url/|b]] by itself should be a link.
+
+Indented [[url|once]].
+
+Indented [[url|twice]].
+
+Indented [[url|thrice]].
+
+This should [not][] be a link.
+
+<pre>[not]: /url</pre>
+Foo [[url/|bar]].
+
+Foo [[url/|biz]].
+
+== With ampersands ==
+
+Here’s a [http://example.com/?foo=1&bar=2 link with an ampersand in the URL].
+
+Here’s a link with an amersand in the link text: [http://att.com/ AT&amp;T].
+
+Here’s an [[script?foo=1&bar=2|inline link]].
+
+Here’s an [[script?foo=1&bar=2|inline link in pointy braces]].
+
+== Autolinks ==
+
+With an ampersand: http://example.com/?foo=1&bar=2
+
+* In a list?
+* http://example.com/
+* It should.
+
+An e-mail address: [mailto:nobody@nowhere.net nobody@nowhere.net]
+
+<blockquote>Blockquoted: http://example.com/
+</blockquote>
+Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code>
+
+<pre>or here: &lt;http://example.com/&gt;</pre>
+
+-----
+
+= Images =
+
+From “Voyage dans la Lune” by Georges Melies (1902):
+
+[[File:lalune.jpg|frame|none|alt=Voyage dans la Lune|caption lalune]]
+
+Here is a movie [[File:movie.jpg|movie]] icon.
+
+
+-----
+
+= Footnotes =
+
+Here is a footnote reference,<ref>Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.
+</ref> and another.<ref>Here’s the long note. This one contains multiple blocks.
+
+Subsequent blocks are indented to show that they belong to the footnote (as with list items).
+
+<pre> { &lt;code&gt; }</pre>
+If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.
+</ref> This should ''not'' be a footnote reference, because it contains a space.[^my note] Here is an inline note.<ref>This is ''easier'' to type. Inline notes may contain [http://google.com links] and <code>]</code> verbatim characters, as well as [bracketed text].
+</ref>
+
+<blockquote>Notes can go in quotes.<ref>In quote.
+</ref>
+</blockquote>
+# And in list items.<ref>In list.</ref>
+
+This paragraph should not be part of the note, as it is not indented.
+
+<references />
diff --git a/test/writer.native b/test/writer.native
new file mode 100644
index 000000000..fa234dfc2
--- /dev/null
+++ b/test/writer.native
@@ -0,0 +1,411 @@
+Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"],MetaInlines [Str "Anonymous"]]),("date",MetaInlines [Str "July",Space,Str "17,",Space,Str "2006"]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])]})
+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",SoftBreak,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
+,HorizontalRule
+,Header 1 ("headers",[],[]) [Str "Headers"]
+,Header 2 ("level-2-with-an-embedded-link",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link ("",[],[]) [Str "embedded",Space,Str "link"] ("/url","")]
+,Header 3 ("level-3-with-emphasis",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 4 ("level-4",[],[]) [Str "Level",Space,Str "4"]
+,Header 5 ("level-5",[],[]) [Str "Level",Space,Str "5"]
+,Header 1 ("level-1",[],[]) [Str "Level",Space,Str "1"]
+,Header 2 ("level-2-with-emphasis",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 3 ("level-3",[],[]) [Str "Level",Space,Str "3"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,Header 2 ("level-2",[],[]) [Str "Level",Space,Str "2"]
+,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
+,HorizontalRule
+,Header 1 ("paragraphs",[],[]) [Str "Paragraphs"]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
+,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",SoftBreak,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",SoftBreak,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",SoftBreak,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",SoftBreak,Str "list",Space,Str "item."]
+,Para [Str "Here\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",SoftBreak,Str "*",Space,Str "criminey."]
+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here."]
+,HorizontalRule
+,Header 1 ("block-quotes",[],[]) [Str "Block",Space,Str "Quotes"]
+,Para [Str "E-mail",Space,Str "style:"]
+,BlockQuote
+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote.",SoftBreak,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]]
+,BlockQuote
+ [Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
+ ,CodeBlock ("",[],[]) "sub status {\n print \"working\";\n}"
+ ,Para [Str "A",Space,Str "list:"]
+ ,OrderedList (1,Decimal,Period)
+ [[Plain [Str "item",Space,Str "one"]]
+ ,[Plain [Str "item",Space,Str "two"]]]
+ ,Para [Str "Nested",Space,Str "block",Space,Str "quotes:"]
+ ,BlockQuote
+ [Para [Str "nested"]]
+ ,BlockQuote
+ [Para [Str "nested"]]]
+,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",SoftBreak,Str ">",Space,Str "1."]
+,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."]
+,HorizontalRule
+,Header 1 ("code-blocks",[],[]) [Str "Code",Space,Str "Blocks"]
+,Para [Str "Code:"]
+,CodeBlock ("",[],[]) "---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n\nthis code block is indented by one tab"
+,Para [Str "And:"]
+,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{"
+,HorizontalRule
+,Header 1 ("lists",[],[]) [Str "Lists"]
+,Header 2 ("unordered",[],[]) [Str "Unordered"]
+,Para [Str "Asterisks",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "asterisk",Space,Str "1"]]
+ ,[Plain [Str "asterisk",Space,Str "2"]]
+ ,[Plain [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Asterisks",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "asterisk",Space,Str "1"]]
+ ,[Para [Str "asterisk",Space,Str "2"]]
+ ,[Para [Str "asterisk",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "Plus",Space,Str "1"]]
+ ,[Plain [Str "Plus",Space,Str "2"]]
+ ,[Plain [Str "Plus",Space,Str "3"]]]
+,Para [Str "Pluses",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "Plus",Space,Str "1"]]
+ ,[Para [Str "Plus",Space,Str "2"]]
+ ,[Para [Str "Plus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "tight:"]
+,BulletList
+ [[Plain [Str "Minus",Space,Str "1"]]
+ ,[Plain [Str "Minus",Space,Str "2"]]
+ ,[Plain [Str "Minus",Space,Str "3"]]]
+,Para [Str "Minuses",Space,Str "loose:"]
+,BulletList
+ [[Para [Str "Minus",Space,Str "1"]]
+ ,[Para [Str "Minus",Space,Str "2"]]
+ ,[Para [Str "Minus",Space,Str "3"]]]
+,Header 2 ("ordered",[],[]) [Str "Ordered"]
+,Para [Str "Tight:"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second"]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "and:"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "One"]]
+ ,[Plain [Str "Two"]]
+ ,[Plain [Str "Three"]]]
+,Para [Str "Loose",Space,Str "using",Space,Str "tabs:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second"]]
+ ,[Para [Str "Third"]]]
+,Para [Str "and",Space,Str "using",Space,Str "spaces:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "One"]]
+ ,[Para [Str "Two"]]
+ ,[Para [Str "Three"]]]
+,Para [Str "Multiple",Space,Str "paragraphs:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]
+ ,Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog\8217s",SoftBreak,Str "back."]]
+ ,[Para [Str "Item",Space,Str "2."]]
+ ,[Para [Str "Item",Space,Str "3."]]]
+,Header 2 ("nested",[],[]) [Str "Nested"]
+,BulletList
+ [[Plain [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]
+ ,BulletList
+ [[Plain [Str "Tab"]]]]]]]
+,Para [Str "Here\8217s",Space,Str "another:"]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "First"]]
+ ,[Plain [Str "Second:"]
+ ,BulletList
+ [[Plain [Str "Fee"]]
+ ,[Plain [Str "Fie"]]
+ ,[Plain [Str "Foe"]]]]
+ ,[Plain [Str "Third"]]]
+,Para [Str "Same",Space,Str "thing",Space,Str "but",Space,Str "with",Space,Str "paragraphs:"]
+,OrderedList (1,Decimal,Period)
+ [[Para [Str "First"]]
+ ,[Para [Str "Second:"]
+ ,BulletList
+ [[Plain [Str "Fee"]]
+ ,[Plain [Str "Fie"]]
+ ,[Plain [Str "Foe"]]]]
+ ,[Para [Str "Third"]]]
+,Header 2 ("tabs-and-spaces",[],[]) [Str "Tabs",Space,Str "and",Space,Str "spaces"]
+,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",SoftBreak,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "a",Space,Str "list",Space,Str "item",SoftBreak,Str "indented",Space,Str "with",Space,Str "spaces"]
+ ,BulletList
+ [[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",SoftBreak,Str "indented",Space,Str "with",Space,Str "tabs"]]
+ ,[Para [Str "this",Space,Str "is",Space,Str "an",Space,Str "example",Space,Str "list",Space,Str "item",SoftBreak,Str "indented",Space,Str "with",Space,Str "spaces"]]]]]
+,Header 2 ("fancy-list-markers",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"]
+,OrderedList (2,Decimal,TwoParens)
+ [[Plain [Str "begins",Space,Str "with",Space,Str "2"]]
+ ,[Para [Str "and",Space,Str "now",Space,Str "3"]
+ ,Para [Str "with",Space,Str "a",Space,Str "continuation"]
+ ,OrderedList (4,LowerRoman,Period)
+ [[Plain [Str "sublist",Space,Str "with",Space,Str "roman",Space,Str "numerals,",SoftBreak,Str "starting",Space,Str "with",Space,Str "4"]]
+ ,[Plain [Str "more",Space,Str "items"]
+ ,OrderedList (1,UpperAlpha,TwoParens)
+ [[Plain [Str "a",Space,Str "subsublist"]]
+ ,[Plain [Str "a",Space,Str "subsublist"]]]]]]]
+,Para [Str "Nesting:"]
+,OrderedList (1,UpperAlpha,Period)
+ [[Plain [Str "Upper",Space,Str "Alpha"]
+ ,OrderedList (1,UpperRoman,Period)
+ [[Plain [Str "Upper",Space,Str "Roman."]
+ ,OrderedList (6,Decimal,TwoParens)
+ [[Plain [Str "Decimal",Space,Str "start",Space,Str "with",Space,Str "6"]
+ ,OrderedList (3,LowerAlpha,OneParen)
+ [[Plain [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]
+,Para [Str "Autonumbering:"]
+,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Autonumber."]]
+ ,[Plain [Str "More."]
+ ,OrderedList (1,DefaultStyle,DefaultDelim)
+ [[Plain [Str "Nested."]]]]]
+,Para [Str "Should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "list",Space,Str "item:"]
+,Para [Str "M.A.\160\&2007"]
+,Para [Str "B.",Space,Str "Williams"]
+,HorizontalRule
+,Header 1 ("definition-lists",[],[]) [Str "Definition",Space,Str "Lists"]
+,Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Plain [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Plain [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Plain [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Tight",Space,Str "using",Space,Str "tabs:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Plain [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Plain [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Plain [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Loose:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]])
+ ,([Str "banana"],
+ [[Para [Str "yellow",Space,Str "fruit"]]])]
+,Para [Str "Multiple",Space,Str "blocks",Space,Str "with",Space,Str "italics:"]
+,DefinitionList
+ [([Emph [Str "apple"]],
+ [[Para [Str "red",Space,Str "fruit"]
+ ,Para [Str "contains",Space,Str "seeds,",SoftBreak,Str "crisp,",Space,Str "pleasant",Space,Str "to",Space,Str "taste"]]])
+ ,([Emph [Str "orange"]],
+ [[Para [Str "orange",Space,Str "fruit"]
+ ,CodeBlock ("",[],[]) "{ orange code block }"
+ ,BlockQuote
+ [Para [Str "orange",Space,Str "block",Space,Str "quote"]]]])]
+,Para [Str "Multiple",Space,Str "definitions,",Space,Str "tight:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Plain [Str "red",Space,Str "fruit"]]
+ ,[Plain [Str "computer"]]])
+ ,([Str "orange"],
+ [[Plain [Str "orange",Space,Str "fruit"]]
+ ,[Plain [Str "bank"]]])]
+,Para [Str "Multiple",Space,Str "definitions,",Space,Str "loose:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]
+ ,[Para [Str "computer"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]]
+ ,[Para [Str "bank"]]])]
+,Para [Str "Blank",Space,Str "line",Space,Str "after",Space,Str "term,",Space,Str "indented",Space,Str "marker,",Space,Str "alternate",Space,Str "markers:"]
+,DefinitionList
+ [([Str "apple"],
+ [[Para [Str "red",Space,Str "fruit"]]
+ ,[Para [Str "computer"]]])
+ ,([Str "orange"],
+ [[Para [Str "orange",Space,Str "fruit"]
+ ,OrderedList (1,Decimal,Period)
+ [[Plain [Str "sublist"]]
+ ,[Plain [Str "sublist"]]]]])]
+,Header 1 ("html-blocks",[],[]) [Str "HTML",Space,Str "Blocks"]
+,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]
+,Div ("",[],[])
+ [Plain [Str "foo"]]
+,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"]
+,Div ("",[],[])
+ [Div ("",[],[])
+ [Div ("",[],[])
+ [Para [Str "foo"]]]
+ ,Div ("",[],[])
+ [Plain [Str "bar"]]]
+,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]
+,RawBlock (Format "html") "<table>"
+,RawBlock (Format "html") "<tr>"
+,RawBlock (Format "html") "<td>"
+,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]]
+,RawBlock (Format "html") "</td>"
+,RawBlock (Format "html") "<td>"
+,Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]]
+,RawBlock (Format "html") "</td>"
+,RawBlock (Format "html") "</tr>"
+,RawBlock (Format "html") "</table>"
+,RawBlock (Format "html") "<script type=\"text/javascript\">document.write('This *should not* be interpreted as markdown');</script>"
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block:"]
+,Div ("",[],[])
+ [Para [Str "foo"]]
+,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"]
+,CodeBlock ("",[],[]) "<div>\n foo\n</div>"
+,Para [Str "As",Space,Str "should",Space,Str "this:"]
+,CodeBlock ("",[],[]) "<div>foo</div>"
+,Para [Str "Now,",Space,Str "nested:"]
+,Div ("",[],[])
+ [Div ("",[],[])
+ [Div ("",[],[])
+ [Plain [Str "foo"]]]]
+,Para [Str "This",Space,Str "should",Space,Str "just",Space,Str "be",Space,Str "an",Space,Str "HTML",Space,Str "comment:"]
+,RawBlock (Format "html") "<!-- Comment -->"
+,Para [Str "Multiline:"]
+,RawBlock (Format "html") "<!--\nBlah\nBlah\n-->"
+,RawBlock (Format "html") "<!--\n This is another comment.\n-->"
+,Para [Str "Code",Space,Str "block:"]
+,CodeBlock ("",[],[]) "<!-- Comment -->"
+,Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"]
+,RawBlock (Format "html") "<!-- foo -->"
+,Para [Str "Code:"]
+,CodeBlock ("",[],[]) "<hr />"
+,Para [Str "Hr\8217s:"]
+,RawBlock (Format "html") "<hr>"
+,RawBlock (Format "html") "<hr />"
+,RawBlock (Format "html") "<hr />"
+,RawBlock (Format "html") "<hr>"
+,RawBlock (Format "html") "<hr />"
+,RawBlock (Format "html") "<hr />"
+,RawBlock (Format "html") "<hr class=\"foo\" id=\"bar\" />"
+,RawBlock (Format "html") "<hr class=\"foo\" id=\"bar\" />"
+,RawBlock (Format "html") "<hr class=\"foo\" id=\"bar\">"
+,HorizontalRule
+,Header 1 ("inline-markup",[],[]) [Str "Inline",Space,Str "Markup"]
+,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
+,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
+,Para [Str "An",Space,Emph [Link ("",[],[]) [Str "emphasized",Space,Str "link"] ("/url","")],Str "."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
+,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]
+,Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "strikeout"],Str "."]]
+,Para [Str "Superscripts:",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Emph [Str "hello"]],Space,Str "a",Superscript [Str "hello\160there"],Str "."]
+,Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "H",Subscript [Str "23"],Str "O,",Space,Str "H",Subscript [Str "many\160of\160them"],Str "O."]
+,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",SoftBreak,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces:",Space,Str "a^b",Space,Str "c^d,",Space,Str "a~b",Space,Str "c~d."]
+,HorizontalRule
+,Header 1 ("smart-quotes-ellipses-dashes",[],[]) [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
+,Para [Quoted DoubleQuote [Str "Hello,"],Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Quoted DoubleQuote [Quoted SingleQuote [Str "Shelob"],Space,Str "is",Space,Str "my",Space,Str "name."]]
+,Para [Quoted SingleQuote [Str "A"],Str ",",Space,Quoted SingleQuote [Str "B"],Str ",",Space,Str "and",Space,Quoted SingleQuote [Str "C"],Space,Str "are",Space,Str "letters."]
+,Para [Quoted SingleQuote [Str "Oak,"],Space,Quoted SingleQuote [Str "elm,"],Space,Str "and",Space,Quoted SingleQuote [Str "beech"],Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees.",SoftBreak,Str "So",Space,Str "is",Space,Quoted SingleQuote [Str "pine."]]
+,Para [Quoted SingleQuote [Str "He",Space,Str "said,",Space,Quoted DoubleQuote [Str "I",Space,Str "want",Space,Str "to",Space,Str "go."]],Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",SoftBreak,Str "70\8217s?"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Quoted SingleQuote [Code ("",[],[]) "code"],Space,Str "and",Space,Str "a",Space,Quoted DoubleQuote [Link ("",[],[]) [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2","")],Str "."]
+,Para [Str "Some",Space,Str "dashes:",Space,Str "one\8212two",Space,Str "\8212",Space,Str "three\8212four",Space,Str "\8212",Space,Str "five."]
+,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5\8211\&7,",Space,Str "255\8211\&66,",Space,Str "1987\8211\&1999."]
+,Para [Str "Ellipses\8230and\8230and\8230."]
+,HorizontalRule
+,Header 1 ("latex",[],[]) [Str "LaTeX"]
+,BulletList
+ [[Plain [RawInline (Format "tex") "\\cite[22-23]{smith.1899}"]]
+ ,[Plain [Math InlineMath "2+2=4"]]
+ ,[Plain [Math InlineMath "x \\in y"]]
+ ,[Plain [Math InlineMath "\\alpha \\wedge \\omega"]]
+ ,[Plain [Math InlineMath "223"]]
+ ,[Plain [Math InlineMath "p",Str "-Tree"]]
+ ,[Plain [Str "Here\8217s",Space,Str "some",Space,Str "display",Space,Str "math:",SoftBreak,Math DisplayMath "\\frac{d}{dx}f(x)=\\lim_{h\\to 0}\\frac{f(x+h)-f(x)}{h}"]]
+ ,[Plain [Str "Here\8217s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it:",Space,Math InlineMath "\\alpha + \\omega \\times x^2",Str "."]]]
+,Para [Str "These",Space,Str "shouldn\8217t",Space,Str "be",Space,Str "math:"]
+,BulletList
+ [[Plain [Str "To",Space,Str "get",Space,Str "the",Space,Str "famous",Space,Str "equation,",Space,Str "write",Space,Code ("",[],[]) "$e = mc^2$",Str "."]]
+ ,[Plain [Str "$22,000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money.",Space,Str "So",Space,Str "is",Space,Str "$34,000.",SoftBreak,Str "(It",Space,Str "worked",Space,Str "if",Space,Quoted DoubleQuote [Str "lot"],Space,Str "is",Space,Str "emphasized.)"]]
+ ,[Plain [Str "Shoes",Space,Str "($20)",Space,Str "and",Space,Str "socks",Space,Str "($5)."]]
+ ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23$."]]]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"]
+,RawBlock (Format "latex") "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"
+,HorizontalRule
+,Header 1 ("special-characters",[],[]) [Str "Special",Space,Str "Characters"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "unicode:"]
+,BulletList
+ [[Plain [Str "I",Space,Str "hat:",Space,Str "\206"]]
+ ,[Plain [Str "o",Space,Str "umlaut:",Space,Str "\246"]]
+ ,[Plain [Str "section:",Space,Str "\167"]]
+ ,[Plain [Str "set",Space,Str "membership:",Space,Str "\8712"]]
+ ,[Plain [Str "copyright:",Space,Str "\169"]]]
+,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]
+,Para [Str "AT&T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it."]
+,Para [Str "This",Space,Str "&",Space,Str "that."]
+,Para [Str "4",Space,Str "<",Space,Str "5."]
+,Para [Str "6",Space,Str ">",Space,Str "5."]
+,Para [Str "Backslash:",Space,Str "\\"]
+,Para [Str "Backtick:",Space,Str "`"]
+,Para [Str "Asterisk:",Space,Str "*"]
+,Para [Str "Underscore:",Space,Str "_"]
+,Para [Str "Left",Space,Str "brace:",Space,Str "{"]
+,Para [Str "Right",Space,Str "brace:",Space,Str "}"]
+,Para [Str "Left",Space,Str "bracket:",Space,Str "["]
+,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]
+,Para [Str "Left",Space,Str "paren:",Space,Str "("]
+,Para [Str "Right",Space,Str "paren:",Space,Str ")"]
+,Para [Str "Greater-than:",Space,Str ">"]
+,Para [Str "Hash:",Space,Str "#"]
+,Para [Str "Period:",Space,Str "."]
+,Para [Str "Bang:",Space,Str "!"]
+,Para [Str "Plus:",Space,Str "+"]
+,Para [Str "Minus:",Space,Str "-"]
+,HorizontalRule
+,Header 1 ("links",[],[]) [Str "Links"]
+,Header 2 ("explicit",[],[]) [Str "Explicit"]
+,Para [Str "Just",Space,Str "a",Space,Link ("",[],[]) [Str "URL"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title"),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by two spaces"),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title preceded by a tab"),Str "."]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with \"quotes\" in it")]
+,Para [Link ("",[],[]) [Str "URL",Space,Str "and",Space,Str "title"] ("/url/","title with single quotes")]
+,Para [Link ("",[],[]) [Str "with_underscore"] ("/url/with_underscore","")]
+,Para [Link ("",[],[]) [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]
+,Para [Link ("",[],[]) [Str "Empty"] ("",""),Str "."]
+,Header 2 ("reference",[],[]) [Str "Reference"]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/",""),Str "."]
+,Para [Str "With",Space,Link ("",[],[]) [Str "embedded",Space,Str "[brackets]"] ("/url/",""),Str "."]
+,Para [Link ("",[],[]) [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "once"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "twice"] ("/url",""),Str "."]
+,Para [Str "Indented",Space,Link ("",[],[]) [Str "thrice"] ("/url",""),Str "."]
+,Para [Str "This",Space,Str "should",Space,Str "[not][]",Space,Str "be",Space,Str "a",Space,Str "link."]
+,CodeBlock ("",[],[]) "[not]: /url"
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "bar"] ("/url/","Title with \"quotes\" inside"),Str "."]
+,Para [Str "Foo",Space,Link ("",[],[]) [Str "biz"] ("/url/","Title with \"quote\" inside"),Str "."]
+,Header 2 ("with-ampersands",[],[]) [Str "With",Space,Str "ampersands"]
+,Para [Str "Here\8217s",Space,Str "a",Space,Link ("",[],[]) [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
+,Para [Str "Here\8217s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link ("",[],[]) [Str "AT&T"] ("http://att.com/","AT&T"),Str "."]
+,Para [Str "Here\8217s",Space,Str "an",Space,Link ("",[],[]) [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."]
+,Para [Str "Here\8217s",Space,Str "an",Space,Link ("",[],[]) [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]
+,Header 2 ("autolinks",[],[]) [Str "Autolinks"]
+,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link ("",[],[]) [Str "http://example.com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]
+,BulletList
+ [[Plain [Str "In",Space,Str "a",Space,Str "list?"]]
+ ,[Plain [Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]
+ ,[Plain [Str "It",Space,Str "should."]]]
+,Para [Str "An",Space,Str "e-mail",Space,Str "address:",Space,Link ("",[],[]) [Str "nobody@nowhere.net"] ("mailto:nobody@nowhere.net","")]
+,BlockQuote
+ [Para [Str "Blockquoted:",Space,Link ("",[],[]) [Str "http://example.com/"] ("http://example.com/","")]]
+,Para [Str "Auto-links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"]
+,CodeBlock ("",[],[]) "or here: <http://example.com/>"
+,HorizontalRule
+,Header 1 ("images",[],[]) [Str "Images"]
+,Para [Str "From",Space,Quoted DoubleQuote [Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune"],Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
+,Para [Image ("",[],[]) [Str "lalune"] ("lalune.jpg","fig:Voyage dans la Lune")]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image ("",[],[]) [Str "movie"] ("movie.jpg",""),Space,Str "icon."]
+,HorizontalRule
+,Header 1 ("footnotes",[],[]) [Str "Footnotes"]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Note [Para [Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote.",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "after",Space,Str "the",Space,Str "footnote",SoftBreak,Str "reference.",Space,Str "It",Space,Str "need",Space,Str "not",Space,Str "be",Space,Str "placed",Space,Str "at",Space,Str "the",Space,Str "end",Space,Str "of",Space,Str "the",Space,Str "document."]],Space,Str "and",Space,Str "another.",Note [Para [Str "Here\8217s",Space,Str "the",Space,Str "long",Space,Str "note.",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",SoftBreak,Str "blocks."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",SoftBreak,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "list",Space,Str "items)."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",SoftBreak,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block."]],SoftBreak,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",SoftBreak,Str "contains",Space,Str "a",Space,Str "space.[^my",Space,Str "note]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note.",Note [Para [Str "This",SoftBreak,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type.",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",SoftBreak,Link ("",[],[]) [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",Space,Str "verbatim",Space,Str "characters,",SoftBreak,Str "as",Space,Str "well",Space,Str "as",Space,Str "[bracketed",Space,Str "text]."]]]
+,BlockQuote
+ [Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes.",Note [Para [Str "In",Space,Str "quote."]]]]
+,OrderedList (1,Decimal,Period)
+ [[Plain [Str "And",Space,Str "in",Space,Str "list",Space,Str "items.",Note [Para [Str "In",Space,Str "list."]]]]]
+,Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented."]]
diff --git a/test/writer.opendocument b/test/writer.opendocument
new file mode 100644
index 000000000..d613ab5b8
--- /dev/null
+++ b/test/writer.opendocument
@@ -0,0 +1,1539 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.2">
+ <office:font-face-decls>
+ <style:font-face style:name="Courier New" style:font-family-generic="modern" style:font-pitch="fixed" svg:font-family="'Courier New'" />
+ </office:font-face-decls>
+ <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.25in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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.5in" text:min-label-width="0.25in" />
+ </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.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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="1.5in" text:min-label-width="0.25in" />
+ </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="1.75in" text:min-label-width="0.25in" />
+ </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.0in" text:min-label-width="0.25in" />
+ </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="2.25in" text:min-label-width="0.25in" />
+ </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="2.5in" text:min-label-width="0.25in" />
+ </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.25in" text:min-label-width="0.25in" />
+ </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>
+ <style:style style:name="T2" style:family="text"><style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
+ <style:style style:name="T3" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" /></style:style>
+ <style:style style:name="T4" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
+ <style:style style:name="T5" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" style:text-line-through-style="solid" /></style:style>
+ <style:style style:name="T6" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>
+ <style:style style:name="T7" style:family="text"><style:text-properties fo:font-style="italic" style:font-style-asian="italic" style:font-style-complex="italic" style:text-position="super 58%" /></style:style>
+ <style:style style:name="T8" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>
+ <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Quotations">
+ <style:paragraph-properties fo:margin-left="0.5in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" />
+ </style:style>
+ <style:style style:name="P2" style:family="paragraph" style:parent-style-name="Quotations">
+ <style:paragraph-properties fo:margin-left="0.5in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" />
+ </style:style>
+ <style:style style:name="P3" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ <style:paragraph-properties fo:margin-left="0.5in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" />
+ </style:style>
+ <style:style style:name="P4" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ <style:paragraph-properties fo:margin-left="0.5in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" />
+ </style:style>
+ <style:style style:name="P5" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ <style:paragraph-properties fo:margin-left="0.5in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" />
+ </style:style>
+ <style:style style:name="P6" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L1">
+ <style:paragraph-properties fo:margin-left="0.5in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P7" style:family="paragraph" style:parent-style-name="Quotations">
+ <style:paragraph-properties fo:margin-left="1.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" />
+ </style:style>
+ <style:style style:name="P8" style:family="paragraph" style:parent-style-name="Quotations">
+ <style:paragraph-properties fo:margin-left="1.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" />
+ </style:style>
+ <style:style style:name="P9" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P10" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P11" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P12" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P13" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P14" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P15" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P16" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P17" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P18" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P19" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L2">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P20" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L3">
+ </style:style>
+ <style:style style:name="P21" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L4">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P22" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L5">
+ </style:style>
+ <style:style style:name="P23" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L6">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P24" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L7">
+ </style:style>
+ <style:style style:name="P25" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L8">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P26" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L9">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P27" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L10">
+ </style:style>
+ <style:style style:name="P28" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L11">
+ </style:style>
+ <style:style style:name="P29" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L12">
+ </style:style>
+ <style:style style:name="P30" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L13">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P31" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L14">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P32" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L15">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P33" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L16">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P34" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L17">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P35" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L18">
+ </style:style>
+ <style:style style:name="P36" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L19">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P37" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L20">
+ </style:style>
+ <style:style style:name="P38" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L21">
+ </style:style>
+ <style:style style:name="P39" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L22">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P40" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L23">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P41" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L24">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P42" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ <style:paragraph-properties fo:margin-left="0.5in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" />
+ </style:style>
+ <style:style style:name="P43" style:family="paragraph" style:parent-style-name="Quotations">
+ <style:paragraph-properties fo:margin-left="0.5in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" />
+ </style:style>
+ <style:style style:name="P44" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L25">
+ <style:paragraph-properties fo:margin-left="0.5in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P45" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P46" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P47" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P48" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P49" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P50" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P51" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L26">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P52" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L27">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P53" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L28">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P54" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P55" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L29">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ <style:style style:name="P56" style:family="paragraph" style:parent-style-name="Quotations">
+ <style:paragraph-properties fo:margin-left="0.5in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" />
+ </style:style>
+ <style:style style:name="P57" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P58" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
+ </style:style>
+ <style:style style:name="P59" style:family="paragraph" style:parent-style-name="Quotations">
+ <style:paragraph-properties fo:margin-left="0.5in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" />
+ </style:style>
+ <style:style style:name="P60" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L30">
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
+ </style:style>
+ </office:automatic-styles>
+<office:body>
+<office:text>
+<text:p text:style-name="Title">Pandoc Test Suite</text:p>
+<text:p text:style-name="Author">John MacFarlane</text:p>
+<text:p text:style-name="Author">Anonymous</text:p>
+<text:p text:style-name="Date">July 17, 2006</text:p>
+<text:p text:style-name="Text_20_body">This is a set of tests for pandoc. Most
+of them are adapted from John Gruber’s markdown test suite.</text:p>
+<text:p text:style-name="Horizontal_20_Line" />
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Headers</text:h>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Level 2 with an
+<text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition">embedded
+link</text:span></text:a></text:h>
+<text:h text:style-name="Heading_20_3" text:outline-level="3">Level 3 with
+<text:span text:style-name="T1">emphasis</text:span></text:h>
+<text:h text:style-name="Heading_20_4" text:outline-level="4">Level 4</text:h>
+<text:h text:style-name="Heading_20_5" text:outline-level="5">Level 5</text:h>
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Level 1</text:h>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Level 2 with
+<text:span text:style-name="T1">emphasis</text:span></text:h>
+<text:h text:style-name="Heading_20_3" text:outline-level="3">Level 3</text:h>
+<text:p text:style-name="First_20_paragraph">with no blank line</text:p>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Level 2</text:h>
+<text:p text:style-name="First_20_paragraph">with no blank line</text:p>
+<text:p text:style-name="Horizontal_20_Line" />
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Paragraphs</text:h>
+<text:p text:style-name="First_20_paragraph">Here’s a regular
+paragraph.</text:p>
+<text:p text:style-name="Text_20_body">In Markdown 1.0.0 and earlier. Version
+8. This line turns into a list item. Because a hard-wrapped line in the middle
+of a paragraph looked like a list item.</text:p>
+<text:p text:style-name="Text_20_body">Here’s one with a bullet. *
+criminey.</text:p>
+<text:p text:style-name="Text_20_body">There should be a hard line
+break<text:line-break />here.</text:p>
+<text:p text:style-name="Horizontal_20_Line" />
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Block
+Quotes</text:h>
+<text:p text:style-name="First_20_paragraph">E-mail style:</text:p>
+<text:p text:style-name="P1">This is a block quote. It is pretty
+short.</text:p>
+<text:p text:style-name="P2">Code in a block quote:</text:p>
+<text:p text:style-name="P3">sub status {</text:p>
+<text:p text:style-name="P4"><text:s text:c="4" />print &quot;working&quot;;</text:p>
+<text:p text:style-name="P5">}</text:p>
+<text:p text:style-name="P2">A list:</text:p>
+<text:list text:style-name="L1">
+ <text:list-item>
+ <text:p text:style-name="P6">item one</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P6">item two</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="P2">Nested block quotes:</text:p>
+<text:p text:style-name="P7">nested</text:p>
+<text:p text:style-name="P8">nested</text:p>
+<text:p text:style-name="First_20_paragraph">This should not be a block quote:
+2 &gt; 1.</text:p>
+<text:p text:style-name="Text_20_body">And a following paragraph.</text:p>
+<text:p text:style-name="Horizontal_20_Line" />
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Code
+Blocks</text:h>
+<text:p text:style-name="First_20_paragraph">Code:</text:p>
+<text:p text:style-name="P9">---- (should be four hyphens)</text:p>
+<text:p text:style-name="P10"></text:p>
+<text:p text:style-name="P11">sub status {</text:p>
+<text:p text:style-name="P12"><text:s text:c="4" />print &quot;working&quot;;</text:p>
+<text:p text:style-name="P13">}</text:p>
+<text:p text:style-name="P14"></text:p>
+<text:p text:style-name="P15">this code block is indented by one tab</text:p>
+<text:p text:style-name="First_20_paragraph">And:</text:p>
+<text:p text:style-name="P16"><text:s text:c="4" />this code block is indented by two tabs</text:p>
+<text:p text:style-name="P17"></text:p>
+<text:p text:style-name="P18">These should not be escaped: <text:s text:c="1" />\$ \\ \&gt; \[ \{</text:p>
+<text:p text:style-name="Horizontal_20_Line" />
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Lists</text:h>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Unordered</text:h>
+<text:p text:style-name="First_20_paragraph">Asterisks tight:</text:p>
+<text:list text:style-name="L2">
+ <text:list-item>
+ <text:p text:style-name="P19">asterisk 1</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P19">asterisk 2</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P19">asterisk 3</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">Asterisks loose:</text:p>
+<text:list text:style-name="L3">
+ <text:list-item>
+ <text:p text:style-name="P20">asterisk 1</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P20">asterisk 2</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P20">asterisk 3</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">Pluses tight:</text:p>
+<text:list text:style-name="L4">
+ <text:list-item>
+ <text:p text:style-name="P21">Plus 1</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P21">Plus 2</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P21">Plus 3</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">Pluses loose:</text:p>
+<text:list text:style-name="L5">
+ <text:list-item>
+ <text:p text:style-name="P22">Plus 1</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P22">Plus 2</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P22">Plus 3</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">Minuses tight:</text:p>
+<text:list text:style-name="L6">
+ <text:list-item>
+ <text:p text:style-name="P23">Minus 1</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P23">Minus 2</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P23">Minus 3</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">Minuses loose:</text:p>
+<text:list text:style-name="L7">
+ <text:list-item>
+ <text:p text:style-name="P24">Minus 1</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P24">Minus 2</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P24">Minus 3</text:p>
+ </text:list-item>
+</text:list>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Ordered</text:h>
+<text:p text:style-name="First_20_paragraph">Tight:</text:p>
+<text:list text:style-name="L8">
+ <text:list-item>
+ <text:p text:style-name="P25">First</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P25">Second</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P25">Third</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">and:</text:p>
+<text:list text:style-name="L9">
+ <text:list-item>
+ <text:p text:style-name="P26">One</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P26">Two</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P26">Three</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">Loose using tabs:</text:p>
+<text:list text:style-name="L10">
+ <text:list-item>
+ <text:p text:style-name="P27">First</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P27">Second</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P27">Third</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">and using spaces:</text:p>
+<text:list text:style-name="L11">
+ <text:list-item>
+ <text:p text:style-name="P28">One</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P28">Two</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P28">Three</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">Multiple paragraphs:</text:p>
+<text:list text:style-name="L12">
+ <text:list-item>
+ <text:p text:style-name="P29">Item 1, graf one.</text:p>
+ <text:p text:style-name="P29">Item 1. graf two. The quick brown fox jumped
+ over the lazy dog’s back.</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P29">Item 2.</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P29">Item 3.</text:p>
+ </text:list-item>
+</text:list>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Nested</text:h>
+<text:list text:style-name="L13">
+ <text:list-item>
+ <text:p text:style-name="P30">Tab</text:p><text:list text:style-name="L14">
+ <text:list-item>
+ <text:p text:style-name="P31">Tab</text:p><text:list text:style-name="L15">
+ <text:list-item>
+ <text:p text:style-name="P32">Tab</text:p>
+ </text:list-item>
+ </text:list>
+ </text:list-item>
+ </text:list>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">Here’s another:</text:p>
+<text:list text:style-name="L16">
+ <text:list-item>
+ <text:p text:style-name="P33">First</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P33">Second:</text:p>
+ <text:list text:style-name="L17">
+ <text:list-item>
+ <text:p text:style-name="P34">Fee</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P34">Fie</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P34">Foe</text:p>
+ </text:list-item>
+ </text:list>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P33">Third</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">Same thing but with
+paragraphs:</text:p>
+<text:list text:style-name="L18">
+ <text:list-item>
+ <text:p text:style-name="P35">First</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P35">Second:</text:p>
+ <text:list text:style-name="L19">
+ <text:list-item>
+ <text:p text:style-name="P36">Fee</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P36">Fie</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P36">Foe</text:p>
+ </text:list-item>
+ </text:list>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P35">Third</text:p>
+ </text:list-item>
+</text:list>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Tabs and
+spaces</text:h>
+<text:list text:style-name="L20">
+ <text:list-item>
+ <text:p text:style-name="P37">this is a list item indented with
+ tabs</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P37">this is a list item indented with
+ spaces</text:p><text:list text:style-name="L21">
+ <text:list-item>
+ <text:p text:style-name="P38">this is an example list item indented
+ with tabs</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P38">this is an example list item indented
+ with spaces</text:p>
+ </text:list-item>
+ </text:list>
+ </text:list-item>
+</text:list>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Fancy list
+markers</text:h>
+<text:list text:style-name="L22">
+ <text:list-item>
+ <text:p text:style-name="P39">begins with 2</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P39">and now 3</text:p>
+ <text:p text:style-name="P39">with a continuation</text:p>
+ <text:list>
+ <text:list-item>
+ <text:p text:style-name="P39">sublist with roman numerals, starting
+ with 4</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P39">more items</text:p>
+ <text:list>
+ <text:list-item>
+ <text:p text:style-name="P39">a subsublist</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P39">a subsublist</text:p>
+ </text:list-item>
+ </text:list>
+ </text:list-item>
+ </text:list>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">Nesting:</text:p>
+<text:list text:style-name="L23">
+ <text:list-item>
+ <text:p text:style-name="P40">Upper Alpha</text:p>
+ <text:list>
+ <text:list-item>
+ <text:p text:style-name="P40">Upper Roman.</text:p>
+ <text:list>
+ <text:list-item>
+ <text:p text:style-name="P40">Decimal start with 6</text:p>
+ <text:list>
+ <text:list-item>
+ <text:p text:style-name="P40">Lower alpha with paren</text:p>
+ </text:list-item>
+ </text:list>
+ </text:list-item>
+ </text:list>
+ </text:list-item>
+ </text:list>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">Autonumbering:</text:p>
+<text:list text:style-name="L24">
+ <text:list-item>
+ <text:p text:style-name="P41">Autonumber.</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P41">More.</text:p>
+ <text:list>
+ <text:list-item>
+ <text:p text:style-name="P41">Nested.</text:p>
+ </text:list-item>
+ </text:list>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">Should not be a list
+item:</text:p>
+<text:p text:style-name="Text_20_body">M.A. 2007</text:p>
+<text:p text:style-name="Text_20_body">B. Williams</text:p>
+<text:p text:style-name="Horizontal_20_Line" />
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Definition
+Lists</text:h>
+<text:p text:style-name="First_20_paragraph">Tight using spaces:</text:p>
+<text:p text:style-name="Definition_20_Term_20_Tight">apple</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">red fruit</text:p>
+<text:p text:style-name="Definition_20_Term_20_Tight">orange</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">orange
+fruit</text:p>
+<text:p text:style-name="Definition_20_Term_20_Tight">banana</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">yellow
+fruit</text:p>
+<text:p text:style-name="First_20_paragraph">Tight using tabs:</text:p>
+<text:p text:style-name="Definition_20_Term_20_Tight">apple</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">red fruit</text:p>
+<text:p text:style-name="Definition_20_Term_20_Tight">orange</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">orange
+fruit</text:p>
+<text:p text:style-name="Definition_20_Term_20_Tight">banana</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">yellow
+fruit</text:p>
+<text:p text:style-name="First_20_paragraph">Loose:</text:p>
+<text:p text:style-name="Definition_20_Term">apple</text:p>
+<text:p text:style-name="Definition_20_Definition">red fruit</text:p>
+<text:p text:style-name="Definition_20_Term">orange</text:p>
+<text:p text:style-name="Definition_20_Definition">orange fruit</text:p>
+<text:p text:style-name="Definition_20_Term">banana</text:p>
+<text:p text:style-name="Definition_20_Definition">yellow fruit</text:p>
+<text:p text:style-name="First_20_paragraph">Multiple blocks with
+italics:</text:p>
+<text:p text:style-name="Definition_20_Term"><text:span text:style-name="T1">apple</text:span></text:p>
+<text:p text:style-name="Definition_20_Definition">red
+fruit</text:p><text:p text:style-name="Definition_20_Definition">contains
+seeds, crisp, pleasant to taste</text:p>
+<text:p text:style-name="Definition_20_Term"><text:span text:style-name="T1">orange</text:span></text:p>
+<text:p text:style-name="Definition_20_Definition">orange fruit</text:p><text:p text:style-name="P42">{ orange code block }</text:p><text:p text:style-name="P43">orange
+block quote</text:p>
+<text:p text:style-name="First_20_paragraph">Multiple definitions,
+tight:</text:p>
+<text:p text:style-name="Definition_20_Term_20_Tight">apple</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">red fruit</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">computer</text:p>
+<text:p text:style-name="Definition_20_Term_20_Tight">orange</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">orange
+fruit</text:p>
+<text:p text:style-name="Definition_20_Definition_20_Tight">bank</text:p>
+<text:p text:style-name="First_20_paragraph">Multiple definitions,
+loose:</text:p>
+<text:p text:style-name="Definition_20_Term">apple</text:p>
+<text:p text:style-name="Definition_20_Definition">red fruit</text:p>
+<text:p text:style-name="Definition_20_Definition">computer</text:p>
+<text:p text:style-name="Definition_20_Term">orange</text:p>
+<text:p text:style-name="Definition_20_Definition">orange fruit</text:p>
+<text:p text:style-name="Definition_20_Definition">bank</text:p>
+<text:p text:style-name="First_20_paragraph">Blank line after term, indented
+marker, alternate markers:</text:p>
+<text:p text:style-name="Definition_20_Term">apple</text:p>
+<text:p text:style-name="Definition_20_Definition">red fruit</text:p>
+<text:p text:style-name="Definition_20_Definition">computer</text:p>
+<text:p text:style-name="Definition_20_Term">orange</text:p>
+<text:p text:style-name="Definition_20_Definition">orange
+fruit</text:p><text:list text:style-name="L25">
+ <text:list-item>
+ <text:p text:style-name="P44">sublist</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P44">sublist</text:p>
+ </text:list-item>
+</text:list>
+<text:h text:style-name="Heading_20_1" text:outline-level="1">HTML
+Blocks</text:h>
+<text:p text:style-name="First_20_paragraph">Simple block on one
+line:</text:p>
+<text:p text:style-name="Text_20_body">foo</text:p>
+<text:p text:style-name="Text_20_body">And nested without
+indentation:</text:p>
+<text:p text:style-name="Text_20_body">foo</text:p>
+<text:p text:style-name="Text_20_body">bar</text:p>
+<text:p text:style-name="Text_20_body">Interpreted markdown in a
+table:</text:p>
+<text:p text:style-name="Text_20_body">This is
+<text:span text:style-name="T1">emphasized</text:span></text:p>
+<text:p text:style-name="Text_20_body">And this is
+<text:span text:style-name="T2">strong</text:span></text:p>
+<text:p text:style-name="Text_20_body">Here’s a simple block:</text:p>
+<text:p text:style-name="Text_20_body">foo</text:p>
+<text:p text:style-name="Text_20_body">This should be a code block,
+though:</text:p>
+<text:p text:style-name="P45">&lt;div&gt;</text:p>
+<text:p text:style-name="P46"><text:s text:c="4" />foo</text:p>
+<text:p text:style-name="P47">&lt;/div&gt;</text:p>
+<text:p text:style-name="First_20_paragraph">As should this:</text:p>
+<text:p text:style-name="P48">&lt;div&gt;foo&lt;/div&gt;</text:p>
+<text:p text:style-name="First_20_paragraph">Now, nested:</text:p>
+<text:p text:style-name="Text_20_body">foo</text:p>
+<text:p text:style-name="Text_20_body">This should just be an HTML
+comment:</text:p>
+<text:p text:style-name="Text_20_body">Multiline:</text:p>
+<text:p text:style-name="Text_20_body">Code block:</text:p>
+<text:p text:style-name="P49">&lt;!-- Comment --&gt;</text:p>
+<text:p text:style-name="First_20_paragraph">Just plain comment, with trailing
+spaces on the line:</text:p>
+<text:p text:style-name="Text_20_body">Code:</text:p>
+<text:p text:style-name="P50">&lt;hr /&gt;</text:p>
+<text:p text:style-name="First_20_paragraph">Hr’s:</text:p>
+<text:p text:style-name="Horizontal_20_Line" />
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Inline
+Markup</text:h>
+<text:p text:style-name="First_20_paragraph">This is
+<text:span text:style-name="T1">emphasized</text:span>, and so
+<text:span text:style-name="T1">is this</text:span>.</text:p>
+<text:p text:style-name="Text_20_body">This is
+<text:span text:style-name="T2">strong</text:span>, and so
+<text:span text:style-name="T2">is this</text:span>.</text:p>
+<text:p text:style-name="Text_20_body">An
+<text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition"><text:span text:style-name="T1">emphasized
+link</text:span></text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body"><text:span text:style-name="T3">This is
+strong and em.</text:span></text:p>
+<text:p text:style-name="Text_20_body">So is
+<text:span text:style-name="T3">this</text:span> word.</text:p>
+<text:p text:style-name="Text_20_body"><text:span text:style-name="T3">This is
+strong and em.</text:span></text:p>
+<text:p text:style-name="Text_20_body">So is
+<text:span text:style-name="T3">this</text:span> word.</text:p>
+<text:p text:style-name="Text_20_body">This is code:
+<text:span text:style-name="Source_Text">&gt;</text:span>,
+<text:span text:style-name="Source_Text">$</text:span>,
+<text:span text:style-name="Source_Text">\</text:span>,
+<text:span text:style-name="Source_Text">\$</text:span>,
+<text:span text:style-name="Source_Text">&lt;html&gt;</text:span>.</text:p>
+<text:p text:style-name="Text_20_body"><text:span text:style-name="T4">This is
+</text:span><text:span text:style-name="T5">strikeout</text:span><text:span text:style-name="T4">.</text:span></text:p>
+<text:p text:style-name="Text_20_body">Superscripts:
+a<text:span text:style-name="T6">bc</text:span>d
+a<text:span text:style-name="T7">hello</text:span>
+a<text:span text:style-name="T6">hello there</text:span>.</text:p>
+<text:p text:style-name="Text_20_body">Subscripts:
+H<text:span text:style-name="T8">2</text:span>O,
+H<text:span text:style-name="T8">23</text:span>O,
+H<text:span text:style-name="T8">many of them</text:span>O.</text:p>
+<text:p text:style-name="Text_20_body">These should not be superscripts or
+subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.</text:p>
+<text:p text:style-name="Horizontal_20_Line" />
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Smart quotes,
+ellipses, dashes</text:h>
+<text:p text:style-name="First_20_paragraph">“Hello,” said the spider.
+“‘Shelob’ is my name.”</text:p>
+<text:p text:style-name="Text_20_body">‘A’, ‘B’, and ‘C’ are letters.</text:p>
+<text:p text:style-name="Text_20_body">‘Oak,’ ‘elm,’ and ‘beech’ are names of
+trees. So is ‘pine.’</text:p>
+<text:p text:style-name="Text_20_body">‘He said, “I want to go.”’ Were you
+alive in the 70’s?</text:p>
+<text:p text:style-name="Text_20_body">Here is some quoted
+‘<text:span text:style-name="Source_Text">code</text:span>’ and a
+“<text:a xlink:type="simple" xlink:href="http://example.com/?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition">quoted
+link</text:span></text:a>”.</text:p>
+<text:p text:style-name="Text_20_body">Some dashes: one—two — three—four —
+five.</text:p>
+<text:p text:style-name="Text_20_body">Dashes between numbers: 5–7, 255–66,
+1987–1999.</text:p>
+<text:p text:style-name="Text_20_body">Ellipses…and…and….</text:p>
+<text:p text:style-name="Horizontal_20_Line" />
+<text:h text:style-name="Heading_20_1" text:outline-level="1">LaTeX</text:h>
+<text:list text:style-name="L26">
+ <text:list-item>
+ <text:p text:style-name="P51"></text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P51">2 + 2 = 4</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P51"><text:span text:style-name="T1">x</text:span> ∈ <text:span text:style-name="T1">y</text:span></text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P51"><text:span text:style-name="T1">α</text:span> ∧ <text:span text:style-name="T1">ω</text:span></text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P51">223</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P51"><text:span text:style-name="T1">p</text:span>-Tree</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P51">Here’s some display math:
+ $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P51">Here’s one that has a line break in it:
+ <text:span text:style-name="T1">α</text:span> + <text:span text:style-name="T1">ω</text:span> × <text:span text:style-name="T1">x</text:span><text:span text:style-name="T6">2</text:span>.</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">These shouldn’t be math:</text:p>
+<text:list text:style-name="L27">
+ <text:list-item>
+ <text:p text:style-name="P52">To get the famous equation, write
+ <text:span text:style-name="Source_Text">$e = mc^2$</text:span>.</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P52">$22,000 is a
+ <text:span text:style-name="T1">lot</text:span> of money. So is $34,000.
+ (It worked if “lot” is emphasized.)</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P52">Shoes ($20) and socks ($5).</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P52">Escaped
+ <text:span text:style-name="Source_Text">$</text:span>: $73
+ <text:span text:style-name="T1">this should be emphasized</text:span>
+ 23$.</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">Here’s a LaTeX table:</text:p>
+<text:p text:style-name="Horizontal_20_Line" />
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Special
+Characters</text:h>
+<text:p text:style-name="First_20_paragraph">Here is some unicode:</text:p>
+<text:list text:style-name="L28">
+ <text:list-item>
+ <text:p text:style-name="P53">I hat: Î</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P53">o umlaut: ö</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P53">section: §</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P53">set membership: ∈</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P53">copyright: ©</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">AT&amp;T has an ampersand in
+their name.</text:p>
+<text:p text:style-name="Text_20_body">AT&amp;T is another way to write
+it.</text:p>
+<text:p text:style-name="Text_20_body">This &amp; that.</text:p>
+<text:p text:style-name="Text_20_body">4 &lt; 5.</text:p>
+<text:p text:style-name="Text_20_body">6 &gt; 5.</text:p>
+<text:p text:style-name="Text_20_body">Backslash: \</text:p>
+<text:p text:style-name="Text_20_body">Backtick: `</text:p>
+<text:p text:style-name="Text_20_body">Asterisk: *</text:p>
+<text:p text:style-name="Text_20_body">Underscore: _</text:p>
+<text:p text:style-name="Text_20_body">Left brace: {</text:p>
+<text:p text:style-name="Text_20_body">Right brace: }</text:p>
+<text:p text:style-name="Text_20_body">Left bracket: [</text:p>
+<text:p text:style-name="Text_20_body">Right bracket: ]</text:p>
+<text:p text:style-name="Text_20_body">Left paren: (</text:p>
+<text:p text:style-name="Text_20_body">Right paren: )</text:p>
+<text:p text:style-name="Text_20_body">Greater-than: &gt;</text:p>
+<text:p text:style-name="Text_20_body">Hash: #</text:p>
+<text:p text:style-name="Text_20_body">Period: .</text:p>
+<text:p text:style-name="Text_20_body">Bang: !</text:p>
+<text:p text:style-name="Text_20_body">Plus: +</text:p>
+<text:p text:style-name="Text_20_body">Minus: -</text:p>
+<text:p text:style-name="Horizontal_20_Line" />
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Links</text:h>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Explicit</text:h>
+<text:p text:style-name="First_20_paragraph">Just a
+<text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">URL</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title"><text:span text:style-name="Definition">URL
+and title</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title preceded by two spaces"><text:span text:style-name="Definition">URL
+and title</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title preceded by a tab"><text:span text:style-name="Definition">URL
+and title</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title with &quot;quotes&quot; in it"><text:span text:style-name="Definition">URL
+and title</text:span></text:a></text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name="title with single quotes"><text:span text:style-name="Definition">URL
+and title</text:span></text:a></text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/with_underscore" office:name=""><text:span text:style-name="Definition">with_underscore</text:span></text:a></text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="mailto:nobody@nowhere.net" office:name=""><text:span text:style-name="Definition">Email
+link</text:span></text:a></text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="" office:name=""><text:span text:style-name="Definition">Empty</text:span></text:a>.</text:p>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Reference</text:h>
+<text:p text:style-name="First_20_paragraph">Foo
+<text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">bar</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Foo
+<text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">bar</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Foo
+<text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">bar</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">With
+<text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">embedded
+[brackets]</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="/url/" office:name=""><text:span text:style-name="Definition">b</text:span></text:a>
+by itself should be a link.</text:p>
+<text:p text:style-name="Text_20_body">Indented
+<text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition">once</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Indented
+<text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition">twice</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Indented
+<text:a xlink:type="simple" xlink:href="/url" office:name=""><text:span text:style-name="Definition">thrice</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">This should [not][] be a link.</text:p>
+<text:p text:style-name="P54">[not]: /url</text:p>
+<text:p text:style-name="First_20_paragraph">Foo
+<text:a xlink:type="simple" xlink:href="/url/" office:name="Title with &quot;quotes&quot; inside"><text:span text:style-name="Definition">bar</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Foo
+<text:a xlink:type="simple" xlink:href="/url/" office:name="Title with &quot;quote&quot; inside"><text:span text:style-name="Definition">biz</text:span></text:a>.</text:p>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">With
+ampersands</text:h>
+<text:p text:style-name="First_20_paragraph">Here’s a
+<text:a xlink:type="simple" xlink:href="http://example.com/?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition">link
+with an ampersand in the URL</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Here’s a link with an amersand in the
+link text:
+<text:a xlink:type="simple" xlink:href="http://att.com/" office:name="AT&amp;T"><text:span text:style-name="Definition">AT&amp;T</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Here’s an
+<text:a xlink:type="simple" xlink:href="/script?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition">inline
+link</text:span></text:a>.</text:p>
+<text:p text:style-name="Text_20_body">Here’s an
+<text:a xlink:type="simple" xlink:href="/script?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition">inline
+link in pointy braces</text:span></text:a>.</text:p>
+<text:h text:style-name="Heading_20_2" text:outline-level="2">Autolinks</text:h>
+<text:p text:style-name="First_20_paragraph">With an ampersand:
+<text:a xlink:type="simple" xlink:href="http://example.com/?foo=1&amp;bar=2" office:name=""><text:span text:style-name="Definition">http://example.com/?foo=1&amp;bar=2</text:span></text:a></text:p>
+<text:list text:style-name="L29">
+ <text:list-item>
+ <text:p text:style-name="P55">In a list?</text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P55"><text:a xlink:type="simple" xlink:href="http://example.com/" office:name=""><text:span text:style-name="Definition">http://example.com/</text:span></text:a></text:p>
+ </text:list-item>
+ <text:list-item>
+ <text:p text:style-name="P55">It should.</text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">An e-mail address:
+<text:a xlink:type="simple" xlink:href="mailto:nobody@nowhere.net" office:name=""><text:span text:style-name="Definition">nobody@nowhere.net</text:span></text:a></text:p>
+<text:p text:style-name="P56">Blockquoted:
+<text:a xlink:type="simple" xlink:href="http://example.com/" office:name=""><text:span text:style-name="Definition">http://example.com/</text:span></text:a></text:p>
+<text:p text:style-name="First_20_paragraph">Auto-links should not occur here:
+<text:span text:style-name="Source_Text">&lt;http://example.com/&gt;</text:span></text:p>
+<text:p text:style-name="P57">or here: &lt;http://example.com/&gt;</text:p>
+<text:p text:style-name="Horizontal_20_Line" />
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Images</text:h>
+<text:p text:style-name="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="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>
+<text:p text:style-name="Horizontal_20_Line" />
+<text:h text:style-name="Heading_20_1" text:outline-level="1">Footnotes</text:h>
+<text:p text:style-name="First_20_paragraph">Here is a footnote
+reference,<text:note text:id="ftn0" text:note-class="footnote"><text:note-citation>1</text:note-citation><text:note-body><text:p text:style-name="Footnote">Here
+is the footnote. It can go anywhere after the footnote reference. It need not
+be placed at the end of the document.</text:p></text:note-body></text:note>
+and
+another.<text:note text:id="ftn1" text:note-class="footnote"><text:note-citation>2</text:note-citation><text:note-body><text:p text:style-name="Footnote">Here’s
+the long note. This one contains multiple
+blocks.</text:p><text:p text:style-name="Footnote">Subsequent blocks are
+indented to show that they belong to the footnote (as with list
+items).</text:p><text:p text:style-name="P58"><text:s text:c="2" />{ &lt;code&gt; }</text:p><text:p text:style-name="Footnote">If
+you want, you can indent every line, but you can also be lazy and just indent
+the first line of each block.</text:p></text:note-body></text:note> This
+should <text:span text:style-name="T1">not</text:span> be a footnote
+reference, because it contains a space.[^my note] Here is an inline
+note.<text:note text:id="ftn2" text:note-class="footnote"><text:note-citation>3</text:note-citation><text:note-body><text:p text:style-name="Footnote">This
+is <text:span text:style-name="T1">easier</text:span> to type. Inline notes
+may contain
+<text:a xlink:type="simple" xlink:href="http://google.com" office:name=""><text:span text:style-name="Definition">links</text:span></text:a>
+and <text:span text:style-name="Source_Text">]</text:span> verbatim
+characters, as well as [bracketed
+text].</text:p></text:note-body></text:note></text:p>
+<text:p text:style-name="P59">Notes can go in
+quotes.<text:note text:id="ftn3" text:note-class="footnote"><text:note-citation>4</text:note-citation><text:note-body><text:p text:style-name="Footnote">In
+quote.</text:p></text:note-body></text:note></text:p>
+<text:list text:style-name="L30">
+ <text:list-item>
+ <text:p text:style-name="P60">And in list
+ items.<text:note text:id="ftn4" text:note-class="footnote"><text:note-citation>5</text:note-citation><text:note-body><text:p text:style-name="Footnote">In
+ list.</text:p></text:note-body></text:note></text:p>
+ </text:list-item>
+</text:list>
+<text:p text:style-name="First_20_paragraph">This paragraph should not be part
+of the note, as it is not indented.</text:p>
+</office:text>
+</office:body>
+</office:document-content>
diff --git a/test/writer.opml b/test/writer.opml
new file mode 100644
index 000000000..261f83426
--- /dev/null
+++ b/test/writer.opml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<opml version="2.0">
+ <head>
+ <title>Pandoc Test Suite</title>
+ <dateModified>Mon, 17 Jul 2006 00:00:00 UTC</dateModified>
+ <ownerName>John MacFarlane; Anonymous</ownerName>
+ </head>
+ <body>
+<outline text="Headers">
+ <outline text="Level 2 with an &lt;a href=&quot;/url&quot;&gt;embedded link&lt;/a&gt;">
+ <outline text="Level 3 with &lt;em&gt;emphasis&lt;/em&gt;">
+ <outline text="Level 4">
+ <outline text="Level 5">
+ </outline>
+ </outline>
+ </outline>
+ </outline>
+</outline>
+<outline text="Level 1">
+ <outline text="Level 2 with &lt;em&gt;emphasis&lt;/em&gt;">
+ <outline text="Level 3" _note="with no blank line">
+ </outline>
+ </outline>
+ <outline text="Level 2" _note="with no blank line&#10;&#10;------------------------------------------------------------------------">
+ </outline>
+</outline>
+<outline text="Paragraphs" _note="Here’s a regular paragraph.&#10;&#10;In Markdown 1.0.0 and earlier. Version 8. This line turns into a list&#10;item. Because a hard-wrapped line in the middle of a paragraph looked&#10;like a list item.&#10;&#10;Here’s one with a bullet. \* criminey.&#10;&#10;There should be a hard line break &#10;here.&#10;&#10;------------------------------------------------------------------------">
+</outline>
+<outline text="Block Quotes" _note="E-mail style:&#10;&#10;&gt; This is a block quote. It is pretty short.&#10;&#10;&gt; Code in a block quote:&#10;&gt;&#10;&gt; sub status {&#10;&gt; print &quot;working&quot;;&#10;&gt; }&#10;&gt;&#10;&gt; A list:&#10;&gt;&#10;&gt; 1. item one&#10;&gt; 2. item two&#10;&gt;&#10;&gt; Nested block quotes:&#10;&gt;&#10;&gt; &gt; nested&#10;&gt;&#10;&gt; &gt; nested&#10;&#10;This should not be a block quote: 2 &amp;gt; 1.&#10;&#10;And a following paragraph.&#10;&#10;------------------------------------------------------------------------">
+</outline>
+<outline text="Code Blocks" _note="Code:&#10;&#10; ---- (should be four hyphens)&#10;&#10; sub status {&#10; print &quot;working&quot;;&#10; }&#10;&#10; this code block is indented by one tab&#10;&#10;And:&#10;&#10; this code block is indented by two tabs&#10;&#10; These should not be escaped: \$ \\ \&gt; \[ \{&#10;&#10;------------------------------------------------------------------------">
+</outline>
+<outline text="Lists">
+ <outline text="Unordered" _note="Asterisks tight:&#10;&#10;- asterisk 1&#10;- asterisk 2&#10;- asterisk 3&#10;&#10;Asterisks loose:&#10;&#10;- asterisk 1&#10;&#10;- asterisk 2&#10;&#10;- asterisk 3&#10;&#10;Pluses tight:&#10;&#10;- Plus 1&#10;- Plus 2&#10;- Plus 3&#10;&#10;Pluses loose:&#10;&#10;- Plus 1&#10;&#10;- Plus 2&#10;&#10;- Plus 3&#10;&#10;Minuses tight:&#10;&#10;- Minus 1&#10;- Minus 2&#10;- Minus 3&#10;&#10;Minuses loose:&#10;&#10;- Minus 1&#10;&#10;- Minus 2&#10;&#10;- Minus 3&#10;&#10;">
+ </outline>
+ <outline text="Ordered" _note="Tight:&#10;&#10;1. First&#10;2. Second&#10;3. Third&#10;&#10;and:&#10;&#10;1. One&#10;2. Two&#10;3. Three&#10;&#10;Loose using tabs:&#10;&#10;1. First&#10;&#10;2. Second&#10;&#10;3. Third&#10;&#10;and using spaces:&#10;&#10;1. One&#10;&#10;2. Two&#10;&#10;3. Three&#10;&#10;Multiple paragraphs:&#10;&#10;1. Item 1, graf one.&#10;&#10; Item 1. graf two. The quick brown fox jumped over the lazy dog’s&#10; back.&#10;&#10;2. Item 2.&#10;&#10;3. Item 3.&#10;&#10;">
+ </outline>
+ <outline text="Nested" _note="- Tab&#10; - Tab&#10; - Tab&#10;&#10;Here’s another:&#10;&#10;1. First&#10;2. Second:&#10; - Fee&#10; - Fie&#10; - Foe&#10;3. Third&#10;&#10;Same thing but with paragraphs:&#10;&#10;1. First&#10;&#10;2. Second:&#10;&#10; - Fee&#10; - Fie&#10; - Foe&#10;&#10;3. Third&#10;&#10;">
+ </outline>
+ <outline text="Tabs and spaces" _note="- this is a list item indented with tabs&#10;&#10;- this is a list item indented with spaces&#10;&#10; - this is an example list item indented with tabs&#10;&#10; - this is an example list item indented with spaces&#10;&#10;">
+ </outline>
+ <outline text="Fancy list markers" _note="1. begins with 2&#10;2. and now 3&#10;&#10; with a continuation&#10;&#10; 1. sublist with roman numerals, starting with 4&#10; 2. more items&#10; 1. a subsublist&#10; 2. a subsublist&#10;&#10;Nesting:&#10;&#10;1. Upper Alpha&#10; 1. Upper Roman.&#10; 1. Decimal start with 6&#10; 1. Lower alpha with paren&#10;&#10;Autonumbering:&#10;&#10;1. Autonumber.&#10;2. More.&#10; 1. Nested.&#10;&#10;Should not be a list item:&#10;&#10;M.A. 2007&#10;&#10;B. Williams&#10;&#10;------------------------------------------------------------------------">
+ </outline>
+</outline>
+<outline text="Definition Lists" _note="Tight using spaces:&#10;&#10;apple &#10;red fruit&#10;&#10;orange &#10;orange fruit&#10;&#10;banana &#10;yellow fruit&#10;&#10;Tight using tabs:&#10;&#10;apple &#10;red fruit&#10;&#10;orange &#10;orange fruit&#10;&#10;banana &#10;yellow fruit&#10;&#10;Loose:&#10;&#10;apple &#10;red fruit&#10;&#10;orange &#10;orange fruit&#10;&#10;banana &#10;yellow fruit&#10;&#10;Multiple blocks with italics:&#10;&#10;*apple* &#10;red fruit&#10;&#10;contains seeds, crisp, pleasant to taste&#10;&#10;*orange* &#10;orange fruit&#10;&#10; { orange code block }&#10;&#10;&gt; orange block quote&#10;&#10;Multiple definitions, tight:&#10;&#10;apple &#10;red fruit&#10;&#10;computer&#10;&#10;orange &#10;orange fruit&#10;&#10;bank&#10;&#10;Multiple definitions, loose:&#10;&#10;apple &#10;red fruit&#10;&#10;computer&#10;&#10;orange &#10;orange fruit&#10;&#10;bank&#10;&#10;Blank line after term, indented marker, alternate markers:&#10;&#10;apple &#10;red fruit&#10;&#10;computer&#10;&#10;orange &#10;orange fruit&#10;&#10;1. sublist&#10;2. sublist&#10;">
+</outline>
+<outline text="HTML Blocks" _note="Simple block on one line:&#10;&#10;foo&#10;&#10;And nested without indentation:&#10;&#10;foo&#10;&#10;bar&#10;&#10;Interpreted markdown in a table:&#10;&#10;This is *emphasized*&#10;And this is **strong**&#10;Here’s a simple block:&#10;&#10;foo&#10;&#10;This should be a code block, though:&#10;&#10; &lt;div&gt;&#10; foo&#10; &lt;/div&gt;&#10;&#10;As should this:&#10;&#10; &lt;div&gt;foo&lt;/div&gt;&#10;&#10;Now, nested:&#10;&#10;foo&#10;&#10;This should just be an HTML comment:&#10;&#10;Multiline:&#10;&#10;Code block:&#10;&#10; &lt;!-- Comment --&gt;&#10;&#10;Just plain comment, with trailing spaces on the line:&#10;&#10;Code:&#10;&#10; &lt;hr /&gt;&#10;&#10;Hr’s:&#10;&#10;------------------------------------------------------------------------">
+</outline>
+<outline text="Inline Markup" _note="This is *emphasized*, and so *is this*.&#10;&#10;This is **strong**, and so **is this**.&#10;&#10;An *[emphasized link](/url)*.&#10;&#10;***This is strong and em.***&#10;&#10;So is ***this*** word.&#10;&#10;***This is strong and em.***&#10;&#10;So is ***this*** word.&#10;&#10;This is code: `&gt;`, `$`, `\`, `\$`, `&lt;html&gt;`.&#10;&#10;This is *strikeout*.&#10;&#10;Superscripts: abcd a*hello* ahello there.&#10;&#10;Subscripts: H₂O, H₂₃O, Hmany of themO.&#10;&#10;These should not be superscripts or subscripts, because of the unescaped&#10;spaces: a^b c^d, a~b c~d.&#10;&#10;------------------------------------------------------------------------">
+</outline>
+<outline text="Smart quotes, ellipses, dashes" _note="“Hello,” said the spider. “‘Shelob’ is my name.”&#10;&#10;‘A’, ‘B’, and ‘C’ are letters.&#10;&#10;‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’&#10;&#10;‘He said, “I want to go.”’ Were you alive in the 70’s?&#10;&#10;Here is some quoted ‘`code`’ and a “[quoted&#10;link](http://example.com/?foo=1&amp;bar=2)”.&#10;&#10;Some dashes: one—two — three—four — five.&#10;&#10;Dashes between numbers: 5–7, 255–66, 1987–1999.&#10;&#10;Ellipses…and…and….&#10;&#10;------------------------------------------------------------------------">
+</outline>
+<outline text="LaTeX" _note="- &#10;- 2 + 2 = 4&#10;- *x* ∈ *y*&#10;- *α* ∧ *ω*&#10;- 223&#10;- *p*-Tree&#10;- Here’s some display math:&#10; $$\\frac{d}{dx}f(x)=\\lim\_{h\\to 0}\\frac{f(x+h)-f(x)}{h}$$&#10;- Here’s one that has a line break in it: *α* + *ω* × *x*².&#10;&#10;These shouldn’t be math:&#10;&#10;- To get the famous equation, write `$e = mc^2$`.&#10;- $22,000 is a *lot* of money. So is $34,000. (It worked if “lot” is&#10; emphasized.)&#10;- Shoes ($20) and socks ($5).&#10;- Escaped `$`: $73 *this should be emphasized* 23$.&#10;&#10;Here’s a LaTeX table:&#10;&#10;------------------------------------------------------------------------">
+</outline>
+<outline text="Special Characters" _note="Here is some unicode:&#10;&#10;- I hat: Î&#10;- o umlaut: ö&#10;- section: §&#10;- set membership: ∈&#10;- copyright: ©&#10;&#10;AT&amp;T has an ampersand in their name.&#10;&#10;AT&amp;T is another way to write it.&#10;&#10;This &amp; that.&#10;&#10;4 &amp;lt; 5.&#10;&#10;6 &amp;gt; 5.&#10;&#10;Backslash: \\&#10;&#10;Backtick: \`&#10;&#10;Asterisk: \*&#10;&#10;Underscore: \_&#10;&#10;Left brace: {&#10;&#10;Right brace: }&#10;&#10;Left bracket: \[&#10;&#10;Right bracket: \]&#10;&#10;Left paren: (&#10;&#10;Right paren: )&#10;&#10;Greater-than: &amp;gt;&#10;&#10;Hash: \#&#10;&#10;Period: .&#10;&#10;Bang: !&#10;&#10;Plus: +&#10;&#10;Minus: -&#10;&#10;------------------------------------------------------------------------">
+</outline>
+<outline text="Links">
+ <outline text="Explicit" _note="Just a [URL](/url/).&#10;&#10;[URL and title](/url/ &quot;title&quot;).&#10;&#10;[URL and title](/url/ &quot;title preceded by two spaces&quot;).&#10;&#10;[URL and title](/url/ &quot;title preceded by a tab&quot;).&#10;&#10;[URL and title](/url/ &quot;title with &quot;quotes&quot; in it&quot;)&#10;&#10;[URL and title](/url/ &quot;title with single quotes&quot;)&#10;&#10;[with\_underscore](/url/with_underscore)&#10;&#10;[Email link](mailto:nobody@nowhere.net)&#10;&#10;[Empty]().">
+ </outline>
+ <outline text="Reference" _note="Foo [bar](/url/).&#10;&#10;Foo [bar](/url/).&#10;&#10;Foo [bar](/url/).&#10;&#10;With [embedded \[brackets\]](/url/).&#10;&#10;[b](/url/) by itself should be a link.&#10;&#10;Indented [once](/url).&#10;&#10;Indented [twice](/url).&#10;&#10;Indented [thrice](/url).&#10;&#10;This should \[not\]\[\] be a link.&#10;&#10; [not]: /url&#10;&#10;Foo [bar](/url/ &quot;Title with &quot;quotes&quot; inside&quot;).&#10;&#10;Foo [biz](/url/ &quot;Title with &quot;quote&quot; inside&quot;).">
+ </outline>
+ <outline text="With ampersands" _note="Here’s a [link with an ampersand in the&#10;URL](http://example.com/?foo=1&amp;bar=2).&#10;&#10;Here’s a link with an amersand in the link text:&#10;[AT&amp;T](http://att.com/ &quot;AT&amp;T&quot;).&#10;&#10;Here’s an [inline link](/script?foo=1&amp;bar=2).&#10;&#10;Here’s an [inline link in pointy braces](/script?foo=1&amp;bar=2).">
+ </outline>
+ <outline text="Autolinks" _note="With an ampersand: &lt;http://example.com/?foo=1&amp;bar=2&gt;&#10;&#10;- In a list?&#10;- &lt;http://example.com/&gt;&#10;- It should.&#10;&#10;An e-mail address: &lt;nobody@nowhere.net&gt;&#10;&#10;&gt; Blockquoted: &lt;http://example.com/&gt;&#10;&#10;Auto-links should not occur here: `&lt;http://example.com/&gt;`&#10;&#10; or here: &lt;http://example.com/&gt;&#10;&#10;------------------------------------------------------------------------">
+ </outline>
+</outline>
+<outline text="Images" _note="From “Voyage dans la Lune” by Georges Melies (1902):&#10;&#10;![lalune](lalune.jpg &quot;Voyage dans la Lune&quot;)&#10;&#10;Here is a movie ![movie](movie.jpg) icon.&#10;&#10;------------------------------------------------------------------------">
+</outline>
+<outline text="Footnotes" _note="Here is a footnote reference,[1] and another.[2] This should *not* be a&#10;footnote reference, because it contains a space.\[^my note\] Here is an&#10;inline note.[3]&#10;&#10;&gt; Notes can go in quotes.[4]&#10;&#10;1. And in list items.[5]&#10;&#10;This paragraph should not be part of the note, as it is not indented.&#10;&#10;[1] Here is the footnote. It can go anywhere after the footnote&#10;reference. It need not be placed at the end of the document.&#10;&#10;[2] Here’s the long note. This one contains multiple blocks.&#10;&#10;Subsequent blocks are indented to show that they belong to the footnote&#10;(as with list items).&#10;&#10; { &lt;code&gt; }&#10;&#10;If you want, you can indent every line, but you can also be lazy and&#10;just indent the first line of each block.&#10;&#10;[3] This is *easier* to type. Inline notes may contain&#10;[links](http://google.com) and `]` verbatim characters, as well as&#10;\[bracketed text\].&#10;&#10;[4] In quote.&#10;&#10;[5] In list.">
+</outline>
+ </body>
+</opml>
diff --git a/test/writer.org b/test/writer.org
new file mode 100644
index 000000000..96db87449
--- /dev/null
+++ b/test/writer.org
@@ -0,0 +1,855 @@
+#+TITLE: Pandoc Test Suite
+
+#+AUTHOR: John MacFarlane; Anonymous
+#+DATE: July 17, 2006
+
+This is a set of tests for pandoc. Most of them are adapted from John Gruber's
+markdown test suite.
+
+--------------
+
+* Headers
+ :PROPERTIES:
+ :CUSTOM_ID: headers
+ :END:
+
+** Level 2 with an [[/url][embedded link]]
+ :PROPERTIES:
+ :CUSTOM_ID: level-2-with-an-embedded-link
+ :END:
+
+*** Level 3 with /emphasis/
+ :PROPERTIES:
+ :CUSTOM_ID: level-3-with-emphasis
+ :END:
+
+**** Level 4
+ :PROPERTIES:
+ :CUSTOM_ID: level-4
+ :END:
+
+***** Level 5
+ :PROPERTIES:
+ :CUSTOM_ID: level-5
+ :END:
+
+* Level 1
+ :PROPERTIES:
+ :CUSTOM_ID: level-1
+ :END:
+
+** Level 2 with /emphasis/
+ :PROPERTIES:
+ :CUSTOM_ID: level-2-with-emphasis
+ :END:
+
+*** Level 3
+ :PROPERTIES:
+ :CUSTOM_ID: level-3
+ :END:
+
+with no blank line
+
+** Level 2
+ :PROPERTIES:
+ :CUSTOM_ID: level-2
+ :END:
+
+with no blank line
+
+--------------
+
+* Paragraphs
+ :PROPERTIES:
+ :CUSTOM_ID: paragraphs
+ :END:
+
+Here's a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
+
+Here's one with a bullet. * criminey.
+
+There should be a hard line break\\
+here.
+
+--------------
+
+* Block Quotes
+ :PROPERTIES:
+ :CUSTOM_ID: block-quotes
+ :END:
+
+E-mail style:
+
+#+BEGIN_QUOTE
+ This is a block quote. It is pretty short.
+#+END_QUOTE
+
+#+BEGIN_QUOTE
+ Code in a block quote:
+
+ #+BEGIN_EXAMPLE
+ sub status {
+ print "working";
+ }
+ #+END_EXAMPLE
+
+ A list:
+
+ 1. item one
+ 2. item two
+
+ Nested block quotes:
+
+ #+BEGIN_QUOTE
+ nested
+ #+END_QUOTE
+
+ #+BEGIN_QUOTE
+ nested
+ #+END_QUOTE
+#+END_QUOTE
+
+This should not be a block quote: 2 > 1.
+
+And a following paragraph.
+
+--------------
+
+* Code Blocks
+ :PROPERTIES:
+ :CUSTOM_ID: code-blocks
+ :END:
+
+Code:
+
+#+BEGIN_EXAMPLE
+ ---- (should be four hyphens)
+
+ sub status {
+ print "working";
+ }
+
+ this code block is indented by one tab
+#+END_EXAMPLE
+
+And:
+
+#+BEGIN_EXAMPLE
+ this code block is indented by two tabs
+
+ These should not be escaped: \$ \\ \> \[ \{
+#+END_EXAMPLE
+
+--------------
+
+* Lists
+ :PROPERTIES:
+ :CUSTOM_ID: lists
+ :END:
+
+** Unordered
+ :PROPERTIES:
+ :CUSTOM_ID: unordered
+ :END:
+
+Asterisks tight:
+
+- asterisk 1
+- asterisk 2
+- asterisk 3
+
+Asterisks loose:
+
+- asterisk 1
+
+- asterisk 2
+
+- asterisk 3
+
+Pluses tight:
+
+- Plus 1
+- Plus 2
+- Plus 3
+
+Pluses loose:
+
+- Plus 1
+
+- Plus 2
+
+- Plus 3
+
+Minuses tight:
+
+- Minus 1
+- Minus 2
+- Minus 3
+
+Minuses loose:
+
+- Minus 1
+
+- Minus 2
+
+- Minus 3
+
+** Ordered
+ :PROPERTIES:
+ :CUSTOM_ID: ordered
+ :END:
+
+Tight:
+
+1. First
+2. Second
+3. Third
+
+and:
+
+1. One
+2. Two
+3. Three
+
+Loose using tabs:
+
+1. First
+
+2. Second
+
+3. Third
+
+and using spaces:
+
+1. One
+
+2. Two
+
+3. Three
+
+Multiple paragraphs:
+
+1. Item 1, graf one.
+
+ Item 1. graf two. The quick brown fox jumped over the lazy dog's back.
+
+2. Item 2.
+
+3. Item 3.
+
+** Nested
+ :PROPERTIES:
+ :CUSTOM_ID: nested
+ :END:
+
+- Tab
+
+ - Tab
+
+ - Tab
+
+Here's another:
+
+1. First
+2. Second:
+
+ - Fee
+ - Fie
+ - Foe
+
+3. Third
+
+Same thing but with paragraphs:
+
+1. First
+
+2. Second:
+
+ - Fee
+ - Fie
+ - Foe
+
+3. Third
+
+** Tabs and spaces
+ :PROPERTIES:
+ :CUSTOM_ID: tabs-and-spaces
+ :END:
+
+- 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
+ :PROPERTIES:
+ :CUSTOM_ID: fancy-list-markers
+ :END:
+
+2) begins with 2
+3) and now 3
+
+ with a continuation
+
+ 4. sublist with roman numerals, starting with 4
+ 5. more items
+
+ 1) a subsublist
+ 2) a subsublist
+
+Nesting:
+
+1. Upper Alpha
+
+ 1. Upper Roman.
+
+ 6) Decimal start with 6
+
+ 3) Lower alpha with paren
+
+Autonumbering:
+
+1. Autonumber.
+2. More.
+
+ 1. Nested.
+
+Should not be a list item:
+
+M.A. 2007
+
+B. Williams
+
+--------------
+
+* Definition Lists
+ :PROPERTIES:
+ :CUSTOM_ID: definition-lists
+ :END:
+
+Tight using spaces:
+
+- apple :: red fruit
+- orange :: orange fruit
+- banana :: yellow fruit
+
+Tight using tabs:
+
+- apple :: red fruit
+- orange :: orange fruit
+- banana :: yellow fruit
+
+Loose:
+
+- apple :: red fruit
+
+- orange :: orange fruit
+
+- banana :: yellow fruit
+
+Multiple blocks with italics:
+
+- /apple/ :: red fruit
+
+ contains seeds, crisp, pleasant to taste
+
+- /orange/ :: orange fruit
+
+ #+BEGIN_EXAMPLE
+ { orange code block }
+ #+END_EXAMPLE
+
+ #+BEGIN_QUOTE
+ orange block quote
+ #+END_QUOTE
+
+Multiple definitions, tight:
+
+- apple :: red fruit
+ computer
+- orange :: orange fruit
+ bank
+
+Multiple definitions, loose:
+
+- apple :: red fruit
+
+ computer
+
+- orange :: orange fruit
+
+ bank
+
+Blank line after term, indented marker, alternate markers:
+
+- apple :: red fruit
+
+ computer
+
+- orange :: orange fruit
+
+ 1. sublist
+ 2. sublist
+
+* HTML Blocks
+ :PROPERTIES:
+ :CUSTOM_ID: html-blocks
+ :END:
+
+Simple block on one line:
+
+foo
+
+And nested without indentation:
+
+foo
+
+bar
+
+Interpreted markdown in a table:
+
+#+BEGIN_HTML
+ <table>
+#+END_HTML
+
+#+BEGIN_HTML
+ <tr>
+#+END_HTML
+
+#+BEGIN_HTML
+ <td>
+#+END_HTML
+
+This is /emphasized/
+
+#+BEGIN_HTML
+ </td>
+#+END_HTML
+
+#+BEGIN_HTML
+ <td>
+#+END_HTML
+
+And this is *strong*
+
+#+BEGIN_HTML
+ </td>
+#+END_HTML
+
+#+BEGIN_HTML
+ </tr>
+#+END_HTML
+
+#+BEGIN_HTML
+ </table>
+#+END_HTML
+
+#+BEGIN_HTML
+ <script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
+#+END_HTML
+
+Here's a simple block:
+
+foo
+
+This should be a code block, though:
+
+#+BEGIN_EXAMPLE
+ <div>
+ foo
+ </div>
+#+END_EXAMPLE
+
+As should this:
+
+#+BEGIN_EXAMPLE
+ <div>foo</div>
+#+END_EXAMPLE
+
+Now, nested:
+
+foo
+
+This should just be an HTML comment:
+
+#+BEGIN_HTML
+ <!-- Comment -->
+#+END_HTML
+
+Multiline:
+
+#+BEGIN_HTML
+ <!--
+ Blah
+ Blah
+ -->
+#+END_HTML
+
+#+BEGIN_HTML
+ <!--
+ This is another comment.
+ -->
+#+END_HTML
+
+Code block:
+
+#+BEGIN_EXAMPLE
+ <!-- Comment -->
+#+END_EXAMPLE
+
+Just plain comment, with trailing spaces on the line:
+
+#+BEGIN_HTML
+ <!-- foo -->
+#+END_HTML
+
+Code:
+
+#+BEGIN_EXAMPLE
+ <hr />
+#+END_EXAMPLE
+
+Hr's:
+
+#+BEGIN_HTML
+ <hr>
+#+END_HTML
+
+#+BEGIN_HTML
+ <hr />
+#+END_HTML
+
+#+BEGIN_HTML
+ <hr />
+#+END_HTML
+
+#+BEGIN_HTML
+ <hr>
+#+END_HTML
+
+#+BEGIN_HTML
+ <hr />
+#+END_HTML
+
+#+BEGIN_HTML
+ <hr />
+#+END_HTML
+
+#+BEGIN_HTML
+ <hr class="foo" id="bar" />
+#+END_HTML
+
+#+BEGIN_HTML
+ <hr class="foo" id="bar" />
+#+END_HTML
+
+#+BEGIN_HTML
+ <hr class="foo" id="bar">
+#+END_HTML
+
+--------------
+
+* Inline Markup
+ :PROPERTIES:
+ :CUSTOM_ID: inline-markup
+ :END:
+
+This is /emphasized/, and so /is this/.
+
+This is *strong*, and so *is this*.
+
+An /[[/url][emphasized link]]/.
+
+*/This is strong and em./*
+
+So is */this/* word.
+
+*/This is strong and em./*
+
+So is */this/* word.
+
+This is code: =>=, =$=, =\=, =\$=, =<html>=.
+
++This is /strikeout/.+
+
+Superscripts: a^{bc}d a^{/hello/} a^{hello there}.
+
+Subscripts: H_{2}O, H_{23}O, H_{many of them}O.
+
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a\^b c\^d, a~b c~d.
+
+--------------
+
+* Smart quotes, ellipses, dashes
+ :PROPERTIES:
+ :CUSTOM_ID: smart-quotes-ellipses-dashes
+ :END:
+
+"Hello," said the spider. "'Shelob' is my name."
+
+'A', 'B', and 'C' are letters.
+
+'Oak,' 'elm,' and 'beech' are names of trees. So is 'pine.'
+
+'He said, "I want to go."' Were you alive in the 70's?
+
+Here is some quoted '=code=' and a "[[http://example.com/?foo=1&bar=2][quoted
+link]]".
+
+Some dashes: one---two --- three---four --- five.
+
+Dashes between numbers: 5--7, 255--66, 1987--1999.
+
+Ellipses...and...and....
+
+--------------
+
+* LaTeX
+ :PROPERTIES:
+ :CUSTOM_ID: latex
+ :END:
+
+- \cite[22-23]{smith.1899}
+- $2+2=4$
+- $x \in y$
+- $\alpha \wedge \omega$
+- $223$
+- $p$-Tree
+- Here's some display math:
+ $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
+- Here's one that has a line break in it: $\alpha + \omega \times x^2$.
+
+These shouldn't be math:
+
+- To get the famous equation, write =$e = mc^2$=.
+- $22,000 is a /lot/ of money. So is $34,000. (It worked if "lot" is
+ emphasized.)
+- Shoes ($20) and socks ($5).
+- Escaped =$=: $73 /this should be emphasized/ 23$.
+
+Here's a LaTeX table:
+
+\begin{tabular}{|l|l|}\hline
+Animal & Number \\ \hline
+Dog & 2 \\
+Cat & 1 \\ \hline
+\end{tabular}
+
+--------------
+
+* Special Characters
+ :PROPERTIES:
+ :CUSTOM_ID: special-characters
+ :END:
+
+Here is some unicode:
+
+- I hat: Î
+- o umlaut: ö
+- section: §
+- set membership: ∈
+- copyright: ©
+
+AT&T has an ampersand in their name.
+
+AT&T is another way to write it.
+
+This & that.
+
+4 < 5.
+
+6 > 5.
+
+Backslash: \
+
+Backtick: `
+
+Asterisk: *
+
+Underscore: \_
+
+Left brace: {
+
+Right brace: }
+
+Left bracket: [
+
+Right bracket: ]
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: >
+
+Hash: #
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+--------------
+
+* Links
+ :PROPERTIES:
+ :CUSTOM_ID: links
+ :END:
+
+** Explicit
+ :PROPERTIES:
+ :CUSTOM_ID: explicit
+ :END:
+
+Just a [[/url/][URL]].
+
+[[/url/][URL and title]].
+
+[[/url/][URL and title]].
+
+[[/url/][URL and title]].
+
+[[/url/][URL and title]]
+
+[[/url/][URL and title]]
+
+[[/url/with_underscore][with\_underscore]]
+
+[[mailto:nobody@nowhere.net][Email link]]
+
+[[][Empty]].
+
+** Reference
+ :PROPERTIES:
+ :CUSTOM_ID: reference
+ :END:
+
+Foo [[/url/][bar]].
+
+Foo [[/url/][bar]].
+
+Foo [[/url/][bar]].
+
+With [[/url/][embedded [brackets]]].
+
+[[/url/][b]] by itself should be a link.
+
+Indented [[/url][once]].
+
+Indented [[/url][twice]].
+
+Indented [[/url][thrice]].
+
+This should [not][] be a link.
+
+#+BEGIN_EXAMPLE
+ [not]: /url
+#+END_EXAMPLE
+
+Foo [[/url/][bar]].
+
+Foo [[/url/][biz]].
+
+** With ampersands
+ :PROPERTIES:
+ :CUSTOM_ID: with-ampersands
+ :END:
+
+Here's a [[http://example.com/?foo=1&bar=2][link with an ampersand in the
+URL]].
+
+Here's a link with an amersand in the link text: [[http://att.com/][AT&T]].
+
+Here's an [[/script?foo=1&bar=2][inline link]].
+
+Here's an [[/script?foo=1&bar=2][inline link in pointy braces]].
+
+** Autolinks
+ :PROPERTIES:
+ :CUSTOM_ID: autolinks
+ :END:
+
+With an ampersand: [[http://example.com/?foo=1&bar=2]]
+
+- In a list?
+- [[http://example.com/]]
+- It should.
+
+An e-mail address: [[mailto:nobody@nowhere.net][nobody@nowhere.net]]
+
+#+BEGIN_QUOTE
+ Blockquoted: [[http://example.com/]]
+#+END_QUOTE
+
+Auto-links should not occur here: =<http://example.com/>=
+
+#+BEGIN_EXAMPLE
+ or here: <http://example.com/>
+#+END_EXAMPLE
+
+--------------
+
+* Images
+ :PROPERTIES:
+ :CUSTOM_ID: images
+ :END:
+
+From "Voyage dans la Lune" by Georges Melies (1902):
+
+#+CAPTION: lalune
+[[file:lalune.jpg]]
+
+Here is a movie [[file:movie.jpg]] icon.
+
+--------------
+
+* Footnotes
+ :PROPERTIES:
+ :CUSTOM_ID: footnotes
+ :END:
+
+Here is a footnote reference,[fn:1] and another.[fn:2] This should /not/ be a
+footnote reference, because it contains a space.[\^my note] Here is an inline
+note.[fn:3]
+
+#+BEGIN_QUOTE
+ Notes can go in quotes.[fn:4]
+#+END_QUOTE
+
+1. And in list items.[fn:5]
+
+This paragraph should not be part of the note, as it is not indented.
+
+[fn:1] Here is the footnote. It can go anywhere after the footnote reference.
+ It need not be placed at the end of the document.
+
+[fn:2] Here's the long note. This one contains multiple blocks.
+
+ Subsequent blocks are indented to show that they belong to the footnote
+ (as with list items).
+
+ #+BEGIN_EXAMPLE
+ { <code> }
+ #+END_EXAMPLE
+
+ If you want, you can indent every line, but you can also be lazy and
+ just indent the first line of each block.
+
+[fn:3] This is /easier/ to type. Inline notes may contain
+ [[http://google.com][links]] and =]= verbatim characters, as well as
+ [bracketed text].
+
+[fn:4] In quote.
+
+[fn:5] In list.
diff --git a/test/writer.plain b/test/writer.plain
new file mode 100644
index 000000000..f34af9100
--- /dev/null
+++ b/test/writer.plain
@@ -0,0 +1,695 @@
+Pandoc Test Suite
+John MacFarlane; Anonymous
+July 17, 2006
+
+This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
+markdown test suite.
+
+------------------------------------------------------------------------------
+
+
+
+HEADERS
+
+
+Level 2 with an embedded link
+
+Level 3 with _emphasis_
+
+Level 4
+
+Level 5
+
+
+
+LEVEL 1
+
+
+Level 2 with _emphasis_
+
+Level 3
+
+with no blank line
+
+
+Level 2
+
+with no blank line
+
+------------------------------------------------------------------------------
+
+
+
+PARAGRAPHS
+
+
+Here’s a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
+
+Here’s one with a bullet. * criminey.
+
+There should be a hard line break
+here.
+
+------------------------------------------------------------------------------
+
+
+
+BLOCK QUOTES
+
+
+E-mail style:
+
+ This is a block quote. It is pretty short.
+
+ Code in a block quote:
+
+ sub status {
+ print "working";
+ }
+
+ A list:
+
+ 1. item one
+ 2. item two
+
+ Nested block quotes:
+
+ nested
+
+ nested
+
+This should not be a block quote: 2 > 1.
+
+And a following paragraph.
+
+------------------------------------------------------------------------------
+
+
+
+CODE BLOCKS
+
+
+Code:
+
+ ---- (should be four hyphens)
+
+ sub status {
+ print "working";
+ }
+
+ this code block is indented by one tab
+
+And:
+
+ this code block is indented by two tabs
+
+ These should not be escaped: \$ \\ \> \[ \{
+
+------------------------------------------------------------------------------
+
+
+
+LISTS
+
+
+Unordered
+
+Asterisks tight:
+
+- asterisk 1
+- asterisk 2
+- asterisk 3
+
+Asterisks loose:
+
+- asterisk 1
+
+- asterisk 2
+
+- asterisk 3
+
+Pluses tight:
+
+- Plus 1
+- Plus 2
+- Plus 3
+
+Pluses loose:
+
+- Plus 1
+
+- Plus 2
+
+- Plus 3
+
+Minuses tight:
+
+- Minus 1
+- Minus 2
+- Minus 3
+
+Minuses loose:
+
+- Minus 1
+
+- Minus 2
+
+- Minus 3
+
+
+Ordered
+
+Tight:
+
+1. First
+2. Second
+3. Third
+
+and:
+
+1. One
+2. Two
+3. Three
+
+Loose using tabs:
+
+1. First
+
+2. Second
+
+3. Third
+
+and using spaces:
+
+1. One
+
+2. Two
+
+3. Three
+
+Multiple paragraphs:
+
+1. Item 1, graf one.
+
+ Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.
+
+2. Item 2.
+
+3. Item 3.
+
+
+Nested
+
+- Tab
+ - Tab
+ - Tab
+
+Here’s another:
+
+1. First
+2. Second:
+ - Fee
+ - Fie
+ - Foe
+3. Third
+
+Same thing but with paragraphs:
+
+1. First
+
+2. Second:
+
+ - Fee
+ - Fie
+ - Foe
+
+3. Third
+
+
+Tabs and spaces
+
+- this is a list item indented with tabs
+
+- this is a list item indented with spaces
+
+ - this is an example list item indented with tabs
+
+ - this is an example list item indented with spaces
+
+
+Fancy list markers
+
+(2) begins with 2
+(3) and now 3
+
+ with a continuation
+
+ iv. sublist with roman numerals, starting with 4
+ v. more items
+ (A) a subsublist
+ (B) a subsublist
+
+Nesting:
+
+A. Upper Alpha
+ I. Upper Roman.
+ (6) Decimal start with 6
+ c) Lower alpha with paren
+
+Autonumbering:
+
+1. Autonumber.
+2. More.
+ 1. Nested.
+
+Should not be a list item:
+
+M.A. 2007
+
+B. Williams
+
+------------------------------------------------------------------------------
+
+
+
+DEFINITION LISTS
+
+
+Tight using spaces:
+
+apple
+ red fruit
+
+orange
+ orange fruit
+
+banana
+ yellow fruit
+
+Tight using tabs:
+
+apple
+ red fruit
+
+orange
+ orange fruit
+
+banana
+ yellow fruit
+
+Loose:
+
+apple
+
+ red fruit
+
+orange
+
+ orange fruit
+
+banana
+
+ yellow fruit
+
+Multiple blocks with italics:
+
+_apple_
+
+ red fruit
+
+ contains seeds, crisp, pleasant to taste
+
+_orange_
+
+ orange fruit
+
+ { orange code block }
+
+ orange block quote
+
+Multiple definitions, tight:
+
+apple
+ red fruit
+ computer
+
+orange
+ orange fruit
+ bank
+
+Multiple definitions, loose:
+
+apple
+
+ red fruit
+
+ computer
+
+orange
+
+ orange fruit
+
+ bank
+
+Blank line after term, indented marker, alternate markers:
+
+apple
+
+ red fruit
+
+ computer
+
+orange
+
+ orange fruit
+
+ 1. sublist
+ 2. sublist
+
+
+
+HTML BLOCKS
+
+
+Simple block on one line:
+
+foo
+
+And nested without indentation:
+
+foo
+
+bar
+
+Interpreted markdown in a table:
+
+This is _emphasized_
+And this is STRONG
+Here’s a simple block:
+
+foo
+
+This should be a code block, though:
+
+ <div>
+ foo
+ </div>
+
+As should this:
+
+ <div>foo</div>
+
+Now, nested:
+
+foo
+
+This should just be an HTML comment:
+
+Multiline:
+
+Code block:
+
+ <!-- Comment -->
+
+Just plain comment, with trailing spaces on the line:
+
+Code:
+
+ <hr />
+
+Hr’s:
+
+------------------------------------------------------------------------------
+
+
+
+INLINE MARKUP
+
+
+This is _emphasized_, and so _is this_.
+
+This is STRONG, and so IS THIS.
+
+An _emphasized link_.
+
+_THIS IS STRONG AND EM._
+
+So is _THIS_ word.
+
+_THIS IS STRONG AND EM._
+
+So is _THIS_ word.
+
+This is code: >, $, \, \$, <html>.
+
+~~This is _strikeout_.~~
+
+Superscripts: abcd a_hello_ ahello there.
+
+Subscripts: H₂O, H₂₃O, Hmany of themO.
+
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a^b c^d, a~b c~d.
+
+------------------------------------------------------------------------------
+
+
+
+SMART QUOTES, ELLIPSES, DASHES
+
+
+“Hello,” said the spider. “‘Shelob’ is my name.”
+
+‘A’, ‘B’, and ‘C’ are letters.
+
+‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’
+
+‘He said, “I want to go.”’ Were you alive in the 70’s?
+
+Here is some quoted ‘code’ and a “quoted link”.
+
+Some dashes: one—two — three—four — five.
+
+Dashes between numbers: 5–7, 255–66, 1987–1999.
+
+Ellipses…and…and….
+
+------------------------------------------------------------------------------
+
+
+
+LATEX
+
+
+-
+- 2 + 2 = 4
+- x ∈ y
+- α ∧ ω
+- 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: α + ω × x².
+
+These shouldn’t be math:
+
+- To get the famous equation, write $e = mc^2$.
+- $22,000 is a _lot_ of money. So is $34,000. (It worked if “lot” is
+ emphasized.)
+- Shoes ($20) and socks ($5).
+- Escaped $: $73 _this should be emphasized_ 23$.
+
+Here’s a LaTeX table:
+
+------------------------------------------------------------------------------
+
+
+
+SPECIAL CHARACTERS
+
+
+Here is some unicode:
+
+- I hat: Î
+- o umlaut: ö
+- section: §
+- set membership: ∈
+- copyright: ©
+
+AT&T has an ampersand in their name.
+
+AT&T is another way to write it.
+
+This & that.
+
+4 < 5.
+
+6 > 5.
+
+Backslash: \
+
+Backtick: `
+
+Asterisk: *
+
+Underscore: _
+
+Left brace: {
+
+Right brace: }
+
+Left bracket: [
+
+Right bracket: ]
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: >
+
+Hash: #
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+------------------------------------------------------------------------------
+
+
+
+LINKS
+
+
+Explicit
+
+Just a URL.
+
+URL and title.
+
+URL and title.
+
+URL and title.
+
+URL and title
+
+URL and title
+
+with_underscore
+
+Email link
+
+Empty.
+
+
+Reference
+
+Foo bar.
+
+Foo bar.
+
+Foo bar.
+
+With embedded [brackets].
+
+b by itself should be a link.
+
+Indented once.
+
+Indented twice.
+
+Indented thrice.
+
+This should [not][] be a link.
+
+ [not]: /url
+
+Foo bar.
+
+Foo biz.
+
+
+With ampersands
+
+Here’s a link with an ampersand in the URL.
+
+Here’s a link with an amersand in the link text: AT&T.
+
+Here’s an inline link.
+
+Here’s an inline link in pointy braces.
+
+
+Autolinks
+
+With an ampersand: http://example.com/?foo=1&bar=2
+
+- In a list?
+- http://example.com/
+- It should.
+
+An e-mail address: nobody@nowhere.net
+
+ Blockquoted: http://example.com/
+
+Auto-links should not occur here: <http://example.com/>
+
+ or here: <http://example.com/>
+
+------------------------------------------------------------------------------
+
+
+
+IMAGES
+
+
+From “Voyage dans la Lune” by Georges Melies (1902):
+
+[lalune]
+
+Here is a movie [movie] icon.
+
+------------------------------------------------------------------------------
+
+
+
+FOOTNOTES
+
+
+Here is a footnote reference,[1] and another.[2] This should _not_ be a
+footnote reference, because it contains a space.[^my note] Here is an inline
+note.[3]
+
+ Notes can go in quotes.[4]
+
+1. And in list items.[5]
+
+This paragraph should not be part of the note, as it is not indented.
+
+[1] Here is the footnote. It can go anywhere after the footnote reference. It
+need not be placed at the end of the document.
+
+[2] Here’s the long note. This one contains multiple blocks.
+
+Subsequent blocks are indented to show that they belong to the footnote (as
+with list items).
+
+ { <code> }
+
+If you want, you can indent every line, but you can also be lazy and just
+indent the first line of each block.
+
+[3] This is _easier_ to type. Inline notes may contain links and ] verbatim
+characters, as well as [bracketed text].
+
+[4] In quote.
+
+[5] In list.
diff --git a/test/writer.rst b/test/writer.rst
new file mode 100644
index 000000000..1aeeacacb
--- /dev/null
+++ b/test/writer.rst
@@ -0,0 +1,892 @@
+=================
+Pandoc Test Suite
+=================
+
+:Author: John MacFarlane
+:Author: Anonymous
+:Date: July 17, 2006
+
+.. role:: math(raw)
+ :format: html latex
+..
+
+.. role:: raw-latex(raw)
+ :format: latex
+..
+
+This is a set of tests for pandoc. Most of them are adapted from John Gruber’s
+markdown test suite.
+
+--------------
+
+Headers
+=======
+
+Level 2 with an `embedded link </url>`__
+----------------------------------------
+
+Level 3 with *emphasis*
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Level 4
+^^^^^^^
+
+Level 5
+'''''''
+
+Level 1
+=======
+
+Level 2 with *emphasis*
+-----------------------
+
+Level 3
+~~~~~~~
+
+with no blank line
+
+Level 2
+-------
+
+with no blank line
+
+--------------
+
+Paragraphs
+==========
+
+Here’s a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
+
+Here’s one with a bullet. \* criminey.
+
+| There should be a hard line break
+| here.
+
+--------------
+
+Block Quotes
+============
+
+E-mail style:
+
+ This is a block quote. It is pretty short.
+
+ Code in a block quote:
+
+ ::
+
+ sub status {
+ print "working";
+ }
+
+ A list:
+
+ 1. item one
+ 2. item two
+
+ Nested block quotes:
+
+ nested
+
+ nested
+
+This should not be a block quote: 2 > 1.
+
+And a following paragraph.
+
+--------------
+
+Code Blocks
+===========
+
+Code:
+
+::
+
+ ---- (should be four hyphens)
+
+ sub status {
+ print "working";
+ }
+
+ this code block is indented by one tab
+
+And:
+
+::
+
+ this code block is indented by two tabs
+
+ These should not be escaped: \$ \\ \> \[ \{
+
+--------------
+
+Lists
+=====
+
+Unordered
+---------
+
+Asterisks tight:
+
+- asterisk 1
+- asterisk 2
+- asterisk 3
+
+Asterisks loose:
+
+- asterisk 1
+
+- asterisk 2
+
+- asterisk 3
+
+Pluses tight:
+
+- Plus 1
+- Plus 2
+- Plus 3
+
+Pluses loose:
+
+- Plus 1
+
+- Plus 2
+
+- Plus 3
+
+Minuses tight:
+
+- Minus 1
+- Minus 2
+- Minus 3
+
+Minuses loose:
+
+- Minus 1
+
+- Minus 2
+
+- Minus 3
+
+Ordered
+-------
+
+Tight:
+
+1. First
+2. Second
+3. Third
+
+and:
+
+1. One
+2. Two
+3. Three
+
+Loose using tabs:
+
+1. First
+
+2. Second
+
+3. Third
+
+and using spaces:
+
+1. One
+
+2. Two
+
+3. Three
+
+Multiple paragraphs:
+
+1. Item 1, graf one.
+
+ Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.
+
+2. Item 2.
+
+3. Item 3.
+
+Nested
+------
+
+- Tab
+
+ - Tab
+
+ - Tab
+
+Here’s another:
+
+1. First
+2. Second:
+
+ - Fee
+ - Fie
+ - Foe
+
+3. Third
+
+Same thing but with paragraphs:
+
+1. First
+
+2. Second:
+
+ - Fee
+ - Fie
+ - Foe
+
+3. Third
+
+Tabs and spaces
+---------------
+
+- this is a list item indented with tabs
+
+- this is a list item indented with spaces
+
+ - this is an example list item indented with tabs
+
+ - this is an example list item indented with spaces
+
+Fancy list markers
+------------------
+
+(2) begins with 2
+(3) and now 3
+
+ with a continuation
+
+ iv. sublist with roman numerals, starting with 4
+ v. more items
+
+ (A) a subsublist
+ (B) a subsublist
+
+Nesting:
+
+A. Upper Alpha
+
+ I. Upper Roman.
+
+ (6) Decimal start with 6
+
+ c) Lower alpha with paren
+
+Autonumbering:
+
+#. Autonumber.
+#. More.
+
+ #. Nested.
+
+Should not be a list item:
+
+M.A. 2007
+
+B. Williams
+
+--------------
+
+Definition Lists
+================
+
+Tight using spaces:
+
+apple
+ red fruit
+orange
+ orange fruit
+banana
+ yellow fruit
+
+Tight using tabs:
+
+apple
+ red fruit
+orange
+ orange fruit
+banana
+ yellow fruit
+
+Loose:
+
+apple
+ red fruit
+
+orange
+ orange fruit
+
+banana
+ yellow fruit
+
+Multiple blocks with italics:
+
+*apple*
+ red fruit
+
+ contains seeds, crisp, pleasant to taste
+
+*orange*
+ orange fruit
+
+ ::
+
+ { orange code block }
+
+ orange block quote
+
+Multiple definitions, tight:
+
+apple
+ red fruit
+ computer
+orange
+ orange fruit
+ bank
+
+Multiple definitions, loose:
+
+apple
+ red fruit
+
+ computer
+
+orange
+ orange fruit
+
+ bank
+
+Blank line after term, indented marker, alternate markers:
+
+apple
+ red fruit
+
+ computer
+
+orange
+ orange fruit
+
+ 1. sublist
+ 2. sublist
+
+HTML Blocks
+===========
+
+Simple block on one line:
+
+.. raw:: html
+
+ <div>
+
+foo
+
+.. raw:: html
+
+ </div>
+
+And nested without indentation:
+
+.. raw:: html
+
+ <div>
+
+.. raw:: html
+
+ <div>
+
+.. raw:: html
+
+ <div>
+
+foo
+
+.. raw:: html
+
+ </div>
+
+.. raw:: html
+
+ </div>
+
+.. raw:: html
+
+ <div>
+
+bar
+
+.. raw:: html
+
+ </div>
+
+.. raw:: html
+
+ </div>
+
+Interpreted markdown in a table:
+
+.. raw:: html
+
+ <table>
+
+.. raw:: html
+
+ <tr>
+
+.. raw:: html
+
+ <td>
+
+This is *emphasized*
+
+.. raw:: html
+
+ </td>
+
+.. raw:: html
+
+ <td>
+
+And this is **strong**
+
+.. raw:: html
+
+ </td>
+
+.. raw:: html
+
+ </tr>
+
+.. raw:: html
+
+ </table>
+
+.. raw:: html
+
+ <script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
+
+Here’s a simple block:
+
+.. raw:: html
+
+ <div>
+
+foo
+
+.. raw:: html
+
+ </div>
+
+This should be a code block, though:
+
+::
+
+ <div>
+ foo
+ </div>
+
+As should this:
+
+::
+
+ <div>foo</div>
+
+Now, nested:
+
+.. raw:: html
+
+ <div>
+
+.. raw:: html
+
+ <div>
+
+.. raw:: html
+
+ <div>
+
+foo
+
+.. raw:: html
+
+ </div>
+
+.. raw:: html
+
+ </div>
+
+.. raw:: html
+
+ </div>
+
+This should just be an HTML comment:
+
+.. raw:: html
+
+ <!-- Comment -->
+
+Multiline:
+
+.. raw:: html
+
+ <!--
+ Blah
+ Blah
+ -->
+
+.. raw:: html
+
+ <!--
+ This is another comment.
+ -->
+
+Code block:
+
+::
+
+ <!-- Comment -->
+
+Just plain comment, with trailing spaces on the line:
+
+.. raw:: html
+
+ <!-- foo -->
+
+Code:
+
+::
+
+ <hr />
+
+Hr’s:
+
+.. raw:: html
+
+ <hr>
+
+.. raw:: html
+
+ <hr />
+
+.. raw:: html
+
+ <hr />
+
+.. raw:: html
+
+ <hr>
+
+.. raw:: html
+
+ <hr />
+
+.. raw:: html
+
+ <hr />
+
+.. raw:: html
+
+ <hr class="foo" id="bar" />
+
+.. raw:: html
+
+ <hr class="foo" id="bar" />
+
+.. raw:: html
+
+ <hr class="foo" id="bar">
+
+--------------
+
+Inline Markup
+=============
+
+This is *emphasized*, and so *is this*.
+
+This is **strong**, and so **is this**.
+
+An *`emphasized link </url>`__*.
+
+***This is strong and em.***
+
+So is ***this*** word.
+
+***This is strong and em.***
+
+So is ***this*** word.
+
+This is code: ``>``, ``$``, ``\``, ``\$``, ``<html>``.
+
+[STRIKEOUT:This is *strikeout*.]
+
+Superscripts: a\ :sup:`bc`\ d a\ :sup:`*hello*` a\ :sup:`hello there`.
+
+Subscripts: H\ :sub:`2`\ O, H\ :sub:`23`\ O, H\ :sub:`many of them`\ O.
+
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a^b c^d, a~b c~d.
+
+--------------
+
+Smart quotes, ellipses, dashes
+==============================
+
+“Hello,” said the spider. “‘Shelob’ is my name.”
+
+‘A’, ‘B’, and ‘C’ are letters.
+
+‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’
+
+‘He said, “I want to go.”’ Were you alive in the 70’s?
+
+Here is some quoted ‘``code``’ and a “`quoted
+link <http://example.com/?foo=1&bar=2>`__”.
+
+Some dashes: one—two — three—four — five.
+
+Dashes between numbers: 5–7, 255–66, 1987–1999.
+
+Ellipses…and…and….
+
+--------------
+
+LaTeX
+=====
+
+- :raw-latex:`\cite[22-23]{smith.1899}`
+- :math:`2+2=4`
+- :math:`x \in y`
+- :math:`\alpha \wedge \omega`
+- :math:`223`
+- :math:`p`-Tree
+- Here’s some display math:
+
+ .. math:: \frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}
+
+- Here’s one that has a line break in it: :math:`\alpha + \omega \times x^2`.
+
+These shouldn’t be math:
+
+- 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:
+
+.. raw:: latex
+
+ \begin{tabular}{|l|l|}\hline
+ Animal & Number \\ \hline
+ Dog & 2 \\
+ Cat & 1 \\ \hline
+ \end{tabular}
+
+--------------
+
+Special Characters
+==================
+
+Here is some unicode:
+
+- I hat: Î
+- o umlaut: ö
+- section: §
+- set membership: ∈
+- copyright: ©
+
+AT&T has an ampersand in their name.
+
+AT&T is another way to write it.
+
+This & that.
+
+4 < 5.
+
+6 > 5.
+
+Backslash: \\
+
+Backtick: \`
+
+Asterisk: \*
+
+Underscore: \_
+
+Left brace: {
+
+Right brace: }
+
+Left bracket: [
+
+Right bracket: ]
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: >
+
+Hash: #
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+--------------
+
+Links
+=====
+
+Explicit
+--------
+
+Just a `URL </url/>`__.
+
+`URL and title </url/>`__.
+
+`URL and title </url/>`__.
+
+`URL and title </url/>`__.
+
+`URL and title </url/>`__
+
+`URL and title </url/>`__
+
+`with\_underscore </url/with_underscore>`__
+
+`Email link <mailto:nobody@nowhere.net>`__
+
+`Empty <>`__.
+
+Reference
+---------
+
+Foo `bar </url/>`__.
+
+Foo `bar </url/>`__.
+
+Foo `bar </url/>`__.
+
+With `embedded [brackets] </url/>`__.
+
+`b </url/>`__ by itself should be a link.
+
+Indented `once </url>`__.
+
+Indented `twice </url>`__.
+
+Indented `thrice </url>`__.
+
+This should [not][] be a link.
+
+::
+
+ [not]: /url
+
+Foo `bar </url/>`__.
+
+Foo `biz </url/>`__.
+
+With ampersands
+---------------
+
+Here’s a `link with an ampersand in the
+URL <http://example.com/?foo=1&bar=2>`__.
+
+Here’s a link with an amersand in the link text: `AT&T <http://att.com/>`__.
+
+Here’s an `inline link </script?foo=1&bar=2>`__.
+
+Here’s an `inline link in pointy braces </script?foo=1&bar=2>`__.
+
+Autolinks
+---------
+
+With an ampersand: http://example.com/?foo=1&bar=2
+
+- In a list?
+- http://example.com/
+- It should.
+
+An e-mail address: nobody@nowhere.net
+
+ Blockquoted: http://example.com/
+
+Auto-links should not occur here: ``<http://example.com/>``
+
+::
+
+ or here: <http://example.com/>
+
+--------------
+
+Images
+======
+
+From “Voyage dans la Lune” by Georges Melies (1902):
+
+.. figure:: lalune.jpg
+ :alt: Voyage dans la Lune
+
+ lalune
+
+Here is a movie |movie| icon.
+
+--------------
+
+Footnotes
+=========
+
+Here is a footnote reference, [1]_ and another. [2]_ This should *not* be a
+footnote reference, because it contains a space.[^my note] Here is an inline
+note. [3]_
+
+ Notes can go in quotes. [4]_
+
+1. And in list items. [5]_
+
+This paragraph should not be part of the note, as it is not indented.
+
+.. [1]
+ Here is the footnote. It can go anywhere after the footnote reference. It
+ need not be placed at the end of the document.
+
+.. [2]
+ Here’s the long note. This one contains multiple blocks.
+
+ Subsequent blocks are indented to show that they belong to the footnote (as
+ with list items).
+
+ ::
+
+ { <code> }
+
+ If you want, you can indent every line, but you can also be lazy and just
+ indent the first line of each block.
+
+.. [3]
+ This is *easier* to type. Inline notes may contain
+ `links <http://google.com>`__ and ``]`` verbatim characters, as well as
+ [bracketed text].
+
+.. [4]
+ In quote.
+
+.. [5]
+ In list.
+
+.. |movie| image:: movie.jpg
diff --git a/test/writer.rtf b/test/writer.rtf
new file mode 100644
index 000000000..a79ae6fb5
--- /dev/null
+++ b/test/writer.rtf
@@ -0,0 +1,451 @@
+{\rtf1\ansi\deff0{\fonttbl{\f0 \fswiss Helvetica;}{\f1 Courier;}}
+{\colortbl;\red255\green0\blue0;\red0\green0\blue255;}
+\widowctrl\hyphauto
+
+{\pard \qc \f0 \sa180 \li0 \fi0 \b \fs36 Pandoc Test Suite\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 John MacFarlane\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 Anonymous\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 July 17, 2006\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \par}
+{\pard \ql \f0 \sa180 \li0 \fi0 This is a set of tests for pandoc. Most of them are adapted from John Gruber\u8217's markdown test suite.\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Headers\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Level 2 with an {\field{\*\fldinst{HYPERLINK "/url"}}{\fldrslt{\ul
+embedded link
+}}}
+\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs28 Level 3 with {\i emphasis}\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs24 Level 4\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs20 Level 5\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Level 1\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Level 2 with {\i emphasis}\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs28 Level 3\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 with no blank line\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Level 2\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 with no blank line\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Paragraphs\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here\u8217's a regular paragraph.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 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.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here\u8217's one with a bullet. * criminey.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 There should be a hard line break\line here.\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Block Quotes\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 E-mail style:\par}
+{\pard \ql \f0 \sa180 \li720 \fi0 This is a block quote. It is pretty short.\par}
+{\pard \ql \f0 \sa180 \li720 \fi0 Code in a block quote:\par}
+{\pard \ql \f0 \sa180 \li720 \fi0 \f1 sub status \{\line
+ print "working";\line
+\}\par}
+{\pard \ql \f0 \sa180 \li720 \fi0 A list:\par}
+{\pard \ql \f0 \sa0 \li1080 \fi-360 1.\tx360\tab item one\par}
+{\pard \ql \f0 \sa0 \li1080 \fi-360 2.\tx360\tab item two\sa180\par}
+{\pard \ql \f0 \sa180 \li720 \fi0 Nested block quotes:\par}
+{\pard \ql \f0 \sa180 \li1440 \fi0 nested\par}
+{\pard \ql \f0 \sa180 \li1440 \fi0 nested\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 This should not be a block quote: 2 > 1.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 And a following paragraph.\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Code Blocks\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Code:\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \f1 ---- (should be four hyphens)\line
+\line
+sub status \{\line
+ print "working";\line
+\}\line
+\line
+this code block is indented by one tab\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 And:\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \f1 this code block is indented by two tabs\line
+\line
+These should not be escaped: \\$ \\\\ \\> \\[ \\\{\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Lists\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Unordered\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Asterisks tight:\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab asterisk 1\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab asterisk 2\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab asterisk 3\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Asterisks loose:\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 \bullet \tx360\tab asterisk 1\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 \bullet \tx360\tab asterisk 2\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 \bullet \tx360\tab asterisk 3\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Pluses tight:\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Plus 1\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Plus 2\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Plus 3\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Pluses loose:\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 \bullet \tx360\tab Plus 1\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 \bullet \tx360\tab Plus 2\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 \bullet \tx360\tab Plus 3\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Minuses tight:\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Minus 1\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Minus 2\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Minus 3\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Minuses loose:\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 \bullet \tx360\tab Minus 1\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 \bullet \tx360\tab Minus 2\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 \bullet \tx360\tab Minus 3\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Ordered\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Tight:\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 1.\tx360\tab First\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 2.\tx360\tab Second\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 3.\tx360\tab Third\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 and:\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 1.\tx360\tab One\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 2.\tx360\tab Two\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 3.\tx360\tab Three\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Loose using tabs:\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 1.\tx360\tab First\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 2.\tx360\tab Second\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 3.\tx360\tab Third\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 and using spaces:\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 1.\tx360\tab One\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 2.\tx360\tab Two\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 3.\tx360\tab Three\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Multiple paragraphs:\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 1.\tx360\tab Item 1, graf one.\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 Item 1. graf two. The quick brown fox jumped over the lazy dog\u8217's back.\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 2.\tx360\tab Item 2.\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 3.\tx360\tab Item 3.\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Nested\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Tab\par}
+{\pard \ql \f0 \sa0 \li720 \fi-360 \endash \tx360\tab Tab\par}
+{\pard \ql \f0 \sa0 \li1080 \fi-360 \bullet \tx360\tab Tab\sa180\sa180\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here\u8217's another:\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 1.\tx360\tab First\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 2.\tx360\tab Second:\par}
+{\pard \ql \f0 \sa0 \li720 \fi-360 \endash \tx360\tab Fee\par}
+{\pard \ql \f0 \sa0 \li720 \fi-360 \endash \tx360\tab Fie\par}
+{\pard \ql \f0 \sa0 \li720 \fi-360 \endash \tx360\tab Foe\sa180\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 3.\tx360\tab Third\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Same thing but with paragraphs:\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 1.\tx360\tab First\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 2.\tx360\tab Second:\par}
+{\pard \ql \f0 \sa0 \li720 \fi-360 \endash \tx360\tab Fee\par}
+{\pard \ql \f0 \sa0 \li720 \fi-360 \endash \tx360\tab Fie\par}
+{\pard \ql \f0 \sa0 \li720 \fi-360 \endash \tx360\tab Foe\sa180\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 3.\tx360\tab Third\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Tabs and spaces\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 \bullet \tx360\tab this is a list item indented with tabs\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 \bullet \tx360\tab this is a list item indented with spaces\par}
+{\pard \ql \f0 \sa180 \li720 \fi-360 \endash \tx360\tab this is an example list item indented with tabs\par}
+{\pard \ql \f0 \sa180 \li720 \fi-360 \endash \tx360\tab this is an example list item indented with spaces\sa180\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Fancy list markers\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 (2)\tx360\tab begins with 2\par}
+{\pard \ql \f0 \sa180 \li360 \fi-360 (3)\tx360\tab and now 3\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 with a continuation\par}
+{\pard \ql \f0 \sa0 \li720 \fi-360 iv.\tx360\tab sublist with roman numerals, starting with 4\par}
+{\pard \ql \f0 \sa0 \li720 \fi-360 v.\tx360\tab more items\par}
+{\pard \ql \f0 \sa0 \li1080 \fi-360 (A)\tx360\tab a subsublist\par}
+{\pard \ql \f0 \sa0 \li1080 \fi-360 (B)\tx360\tab a subsublist\sa180\sa180\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Nesting:\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 A.\tx360\tab Upper Alpha\par}
+{\pard \ql \f0 \sa0 \li720 \fi-360 I.\tx360\tab Upper Roman.\par}
+{\pard \ql \f0 \sa0 \li1080 \fi-360 (6)\tx360\tab Decimal start with 6\par}
+{\pard \ql \f0 \sa0 \li1440 \fi-360 c)\tx360\tab Lower alpha with paren\sa180\sa180\sa180\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Autonumbering:\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 1.\tx360\tab Autonumber.\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 2.\tx360\tab More.\par}
+{\pard \ql \f0 \sa0 \li720 \fi-360 a.\tx360\tab Nested.\sa180\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Should not be a list item:\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 M.A.\u160?2007\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 B. Williams\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Definition Lists\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Tight using spaces:\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 apple\par}
+{\pard \ql \f0 \sa0 \li360 \fi0 red fruit\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 orange\par}
+{\pard \ql \f0 \sa0 \li360 \fi0 orange fruit\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 banana\par}
+{\pard \ql \f0 \sa0 \li360 \fi0 yellow fruit\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Tight using tabs:\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 apple\par}
+{\pard \ql \f0 \sa0 \li360 \fi0 red fruit\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 orange\par}
+{\pard \ql \f0 \sa0 \li360 \fi0 orange fruit\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 banana\par}
+{\pard \ql \f0 \sa0 \li360 \fi0 yellow fruit\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Loose:\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 apple\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 red fruit\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 orange\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 orange fruit\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 banana\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 yellow fruit\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Multiple blocks with italics:\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 {\i apple}\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 red fruit\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 contains seeds, crisp, pleasant to taste\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 {\i orange}\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 orange fruit\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 \f1 \{ orange code block \}\par}
+{\pard \ql \f0 \sa180 \li1080 \fi0 orange block quote\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Multiple definitions, tight:\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 apple\par}
+{\pard \ql \f0 \sa0 \li360 \fi0 red fruit\par}
+{\pard \ql \f0 \sa0 \li360 \fi0 computer\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 orange\par}
+{\pard \ql \f0 \sa0 \li360 \fi0 orange fruit\par}
+{\pard \ql \f0 \sa0 \li360 \fi0 bank\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Multiple definitions, loose:\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 apple\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 red fruit\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 computer\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 orange\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 orange fruit\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 bank\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Blank line after term, indented marker, alternate markers:\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 apple\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 red fruit\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 computer\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 orange\par}
+{\pard \ql \f0 \sa180 \li360 \fi0 orange fruit\par}
+{\pard \ql \f0 \sa0 \li720 \fi-360 1.\tx360\tab sublist\par}
+{\pard \ql \f0 \sa0 \li720 \fi-360 2.\tx360\tab sublist\sa180\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 HTML Blocks\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Simple block on one line:\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 foo\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 And nested without indentation:\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 foo\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 bar\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Interpreted markdown in a table:\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 This is {\i emphasized}\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 And this is {\b strong}\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here\u8217's a simple block:\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 foo\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 This should be a code block, though:\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \f1 <div>\line
+ foo\line
+</div>\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 As should this:\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \f1 <div>foo</div>\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Now, nested:\par}
+{\pard \ql \f0 \sa0 \li0 \fi0 foo\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 This should just be an HTML comment:\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Multiline:\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Code block:\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \f1 <!-- Comment -->\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Just plain comment, with trailing spaces on the line:\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Code:\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \f1 <hr />\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Hr\u8217's:\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Inline Markup\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 This is {\i emphasized}, and so {\i is this}.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 This is {\b strong}, and so {\b is this}.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 An {\i {\field{\*\fldinst{HYPERLINK "/url"}}{\fldrslt{\ul
+emphasized link
+}}}
+}.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\b {\i This is strong and em.}}\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 So is {\b {\i this}} word.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\b {\i This is strong and em.}}\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 So is {\b {\i this}} word.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 This is code: {\f1 >}, {\f1 $}, {\f1 \\}, {\f1 \\$}, {\f1 <html>}.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\strike This is {\i strikeout}.}\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Superscripts: a{\super bc}d a{\super {\i hello}} a{\super hello\u160?there}.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Subscripts: H{\sub 2}O, H{\sub 23}O, H{\sub many\u160?of\u160?them}O.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Smart quotes, ellipses, dashes\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \u8220"Hello,\u8221" said the spider. \u8220"\u8216'Shelob\u8217' is my name.\u8221"\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \u8216'A\u8217', \u8216'B\u8217', and \u8216'C\u8217' are letters.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \u8216'Oak,\u8217' \u8216'elm,\u8217' and \u8216'beech\u8217' are names of trees. So is \u8216'pine.\u8217'\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \u8216'He said, \u8220"I want to go.\u8221"\u8217' Were you alive in the 70\u8217's?\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here is some quoted \u8216'{\f1 code}\u8217' and a \u8220"{\field{\*\fldinst{HYPERLINK "http://example.com/?foo=1&bar=2"}}{\fldrslt{\ul
+quoted link
+}}}
+\u8221".\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Some dashes: one\u8212-two \u8212- three\u8212-four \u8212- five.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Dashes between numbers: 5\u8211-7, 255\u8211-66, 1987\u8211-1999.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Ellipses\u8230?and\u8230?and\u8230?.\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 LaTeX\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab \par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab 2\u8197?+\u8197?2\u8196?=\u8196?4\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\i x}\u8196?\u8712?\u8196?{\i y}\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\i \u945?}\u8197?\u8743?\u8197?{\i \u969?}\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab 223\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\i p}-Tree\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Here\u8217's some display math: $$\\frac\{d\}\{dx\}f(x)=\\lim_\{h\\to 0\}\\frac\{f(x+h)-f(x)\}\{h\}$$\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Here\u8217's one that has a line break in it: {\i \u945?}\u8197?+\u8197?{\i \u969?}\u8197?\u215?\u8197?{\i x}{\super 2}.\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 These shouldn\u8217't be math:\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab To get the famous equation, write {\f1 $e = mc^2$}.\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab $22,000 is a {\i lot} of money. So is $34,000. (It worked if \u8220"lot\u8221" is emphasized.)\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Shoes ($20) and socks ($5).\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab Escaped {\f1 $}: $73 {\i this should be emphasized} 23$.\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here\u8217's a LaTeX table:\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Special Characters\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here is some unicode:\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab I hat: \u206?\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab o umlaut: \u246?\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab section: \u167?\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab set membership: \u8712?\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab copyright: \u169?\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 AT&T has an ampersand in their name.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 AT&T is another way to write it.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 This & that.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 4 < 5.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 6 > 5.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Backslash: \\\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Backtick: `\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Asterisk: *\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Underscore: _\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Left brace: \{\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Right brace: \}\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Left bracket: [\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Right bracket: ]\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Left paren: (\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Right paren: )\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Greater-than: >\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Hash: #\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Period: .\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Bang: !\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Plus: +\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Minus: -\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Links\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Explicit\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Just a {\field{\*\fldinst{HYPERLINK "/url/"}}{\fldrslt{\ul
+URL
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\field{\*\fldinst{HYPERLINK "/url/"}}{\fldrslt{\ul
+URL and title
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\field{\*\fldinst{HYPERLINK "/url/"}}{\fldrslt{\ul
+URL and title
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\field{\*\fldinst{HYPERLINK "/url/"}}{\fldrslt{\ul
+URL and title
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\field{\*\fldinst{HYPERLINK "/url/"}}{\fldrslt{\ul
+URL and title
+}}}
+\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\field{\*\fldinst{HYPERLINK "/url/"}}{\fldrslt{\ul
+URL and title
+}}}
+\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\field{\*\fldinst{HYPERLINK "/url/with_underscore"}}{\fldrslt{\ul
+with_underscore
+}}}
+\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\field{\*\fldinst{HYPERLINK "mailto:nobody@nowhere.net"}}{\fldrslt{\ul
+Email link
+}}}
+\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\field{\*\fldinst{HYPERLINK ""}}{\fldrslt{\ul
+Empty
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Reference\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Foo {\field{\*\fldinst{HYPERLINK "/url/"}}{\fldrslt{\ul
+bar
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Foo {\field{\*\fldinst{HYPERLINK "/url/"}}{\fldrslt{\ul
+bar
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Foo {\field{\*\fldinst{HYPERLINK "/url/"}}{\fldrslt{\ul
+bar
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 With {\field{\*\fldinst{HYPERLINK "/url/"}}{\fldrslt{\ul
+embedded [brackets]
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\field{\*\fldinst{HYPERLINK "/url/"}}{\fldrslt{\ul
+b
+}}}
+ by itself should be a link.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Indented {\field{\*\fldinst{HYPERLINK "/url"}}{\fldrslt{\ul
+once
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Indented {\field{\*\fldinst{HYPERLINK "/url"}}{\fldrslt{\ul
+twice
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Indented {\field{\*\fldinst{HYPERLINK "/url"}}{\fldrslt{\ul
+thrice
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 This should [not][] be a link.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \f1 [not]: /url\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Foo {\field{\*\fldinst{HYPERLINK "/url/"}}{\fldrslt{\ul
+bar
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Foo {\field{\*\fldinst{HYPERLINK "/url/"}}{\fldrslt{\ul
+biz
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 With ampersands\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here\u8217's a {\field{\*\fldinst{HYPERLINK "http://example.com/?foo=1&bar=2"}}{\fldrslt{\ul
+link with an ampersand in the URL
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here\u8217's a link with an amersand in the link text: {\field{\*\fldinst{HYPERLINK "http://att.com/"}}{\fldrslt{\ul
+AT&T
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here\u8217's an {\field{\*\fldinst{HYPERLINK "/script?foo=1&bar=2"}}{\fldrslt{\ul
+inline link
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here\u8217's an {\field{\*\fldinst{HYPERLINK "/script?foo=1&bar=2"}}{\fldrslt{\ul
+inline link in pointy braces
+}}}
+.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Autolinks\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 With an ampersand: {\field{\*\fldinst{HYPERLINK "http://example.com/?foo=1&bar=2"}}{\fldrslt{\ul
+http://example.com/?foo=1&bar=2
+}}}
+\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab In a list?\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab {\field{\*\fldinst{HYPERLINK "http://example.com/"}}{\fldrslt{\ul
+http://example.com/
+}}}
+\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab It should.\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 An e-mail address: {\field{\*\fldinst{HYPERLINK "mailto:nobody@nowhere.net"}}{\fldrslt{\ul
+nobody@nowhere.net
+}}}
+\par}
+{\pard \ql \f0 \sa180 \li720 \fi0 Blockquoted: {\field{\*\fldinst{HYPERLINK "http://example.com/"}}{\fldrslt{\ul
+http://example.com/
+}}}
+\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Auto-links should not occur here: {\f1 <http://example.com/>}\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \f1 or here: <http://example.com/>\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Images\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 From \u8220"Voyage dans la Lune\u8221" by Georges Melies (1902):\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 {\pict\jpegblip\picw250\pich250\picwgoal3000\pichgoal3000\bin ffd8ffe000104a46494600010101007800780000ffdb00430006040506050406060506070706080a100a0a09090a140e0f0c1017141818171416161a1d251f1a1b231c1616202c20232627292a29191f2d302d283025282928ffdb0043010707070a080a130a0a13281a161a2828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828ffc000110800fa00fa03011100021101031101ffc4001c0000000701010000000000000000000000010203040506070008ffc4003e100002010303020404040502050500030001020300041105122106311322415107617181143291a1234252b1c115f016336272d1082443e1f1265382ffc40017010101010100000000000000000000000000010204ffc4001b11010101010003010000000000000000000001110212213141ffda000c03010002110311003f00dadd18a10a704f6a95ccc57e37750782b0d8d9ea0cd32e7c5446e07e9f4ad723119a7b89e61e348f260719278aad613cbb640002938c76a182b264fc87bd13009c0c019c76e3d68a072e1cf6f4cd502d330c28269a61bb39c923923d4fad44c08dccb95cfd28b8280769ee08a263891e1808739e4f1d8d149392172cc714050dbb9fde8960ed8c60b79b1ed44103b05c331dbdb1dc5026ac1946d20ff8140aa631c773ec738a0346a003bf93e9cf02801895e7b9a01886796c923bd0090a06393c76a0142003ce3d86680d8dd9392303f5341ccc1b3cf7a2c812c37e4923d381429757013209fa511c18146c9247a0f6a007900c0c671c6280854e086c673eb45c27c038fd68aedff2fda836ef881f136f25d5e6b7d1262964aa02b03f98fbf153131935edcc97576f35c33349212cc4f39f7ab26186dfce5b200f73451f7600dcb8cf27e7400c0b291914046c9e0718fde81371b8e7273f4ef4007691919240e714097f31f376e7b5008caee27807b0f5a02c8e1b3c6d27d33cd0201d839523144d1a149ae084b78da47638211771fd050d582c3a0faab5119b6d12f8ab1c06788a0fd4e2ac356fd1fe08754ddccaba849696309e598c9e2103fed1dcfdeadc44fea5ff00a7f956366d375e492403ca935bedcf1eea4ff6ac68a55efc1beb3b552574f8e7009ff933a927ec715bc82b3a8f4d6bba5ca1352d22fe061cf9a0383f71dea5119cc6c0baed3eaac0f1fad40897dcc3d81f7a052366c1007df3400f21edefc5008c28f30c9c5170ee4fc37830086395250a7c66770c18e78da31c0c63de8609b41f7c515c5172a30c3b76344a3e377cb2339cf7a242aea89808cce368272b8c1a2e107c672a49f5c1a181c9c7ae7da8a2119e7b1f5068099ffa68258a132062d8f9e0f34059502b61bf2824e681bb297ced2a71efda80f19c47b9c77fdbe74057c13e539cf3c1a0eeeb9c73f33405ddb4f18249c1e28062b79ae242902024465b9214614649e7bd0362a7249eddc513456e5720f38f5a1a98e96e95d6baa6ebc2d1ad1e65521649bb469f563534d6d7d31f04347d2a2fc5f535db6a0e83718906c887cbbe5a9a8bef44dce9f731ca9a2e89169d6d6f2184b1455dc07b11dcfeb4d16f119c649a681285b03d3e5500f87820ff006a0e098191de80ac9b8904647b55d11da9681a56a31f87a869f6970b8ffe4883629a289aefc16e92d441682da5b098f21ed9f033f353914d19b751fc08d66cc16d12fe2bf45ec92ff0df1fdbfb559ec667aff4eeb1a04db359d3ae6d40eccebe53f46ec7f5ab82263da7dcf3eb5174e5181076918c7de869503232491ee4515c1803824f03b51287f30e0e7d803449494832c157278a2e8c71fcb9f9d144639236824d01e142efb1768cfb9c7ef40512a818de78ff00a682518e7cc30ab9e00a02cce9953247bd41e467191ed9a04205ee99da4e4e3d283a524b0427b5026c18a8e082067db8341ce0e39ed409b6502907391edda80f2dfdc496f0c124ac6184b144cf0a4e338fd2894f7a7342d4ba9b568f4fd261f12571966270a8bfd47d8511bae85f02b47b7fc34bac5d5c5dc88a0c90ab6c8d9bedce3ef4d1ad691a6dae976a96d616d15b409f9638d70054a1dbc68ea51d4329f4619a8022b78e04548515117b05000a035c5c4702a995c26e3819f534047bcb68a458cce866719540724d02e41c0f7a012a40f6141cbc8e7bd01719e38e6838af1c0a04ca8206d3cd037bdb082fad9e0bd8a39e0718649141047d0d5d18f759fc0cd3af164b8e9999acae4e4f81236e898f7c0f55fed574615aee83a96817ef67abda3db4ebdb7f66f983d88a061bb8db9e3d45165076db83c1f950a53780d8247c80a2398f182724f1c7ad080c608cfa7a51a0062adc7afbd0130173bb9c5070f071cb37e82826106e8f615e01c9e680d6b35bc534be3c1e3831b2aa962bb188f2b71df1de819ae4b1048c7f57bd01a58268e332642ae0704f7cf6207af6a01b99e17b7b6416e227407c494139909ed9f4c0a04a4e501e0f1eb40d263e53dce7fa682c9d0bd13abf58dd6db18bc2b157c4975270ab8ef8f563f21447a73a03a1f4de8eb031582b497328066b97fcd21ff038edfde88b7e32703bd64188e7e6283864b73400cd804b67ca3268317eacea6d56ff005233592f8b6303f953fa4af7c2fa93417fe98b763e0ea171297bab98558068f695ce0e08fdbd281e5c6a57ba5e9d14d716ef7774f2ec112601da4f27ec2827ada74bab559a20e148fcae36b0f91140283729c77a0e0a7777a01dac68395719e39a029607cb901b19c501480ab9279f4a086ea8d0b48d76c0586b7143224a76c61ce1831fe93e86b43cd1f12fe19ea7d2533dcdbeebcd20b612651e68f9ece3fcf6fa5067cbcf20ff009a051724905411e94032799060723da8406d6c67e7ea68d0e1770fe5cfb5026c37039ef9a02eca098c91e6e01e71c500b1d8a49c12786cf6a06a4e256008e3d050119958007920e2801154e32fb4120927b014017eb1c523ac5209a356215c291b87be28957ef853f0d66eaa99352d515e1d190f947669ce7b0ffa7e74a8f4be996569a5d9c56b6704705b46bb5238d42851f2ac875712bc70b3c30f892019540704d01ad2669a0491936330c95ce7140b2e4939a03638c7e8680ae485e33bbe540d60d3ada162c90a02c7270a39340a4f28b68da4645007a8f6a069a746f73235ddcefc391e12b2e1916824948742c99382473c73404791c617695279dc0640f9502c578c9efeb4095cb4cb0830ba21cf999c6401f4f5a05061d430c8079a02e03b3004311c7d281b5e3cd676c65489ee594e4aafe6c7ae07a9a0a075bbea3a8ea96f047d3935ebc404f04ad29411e08e011d98fed416fd212ee5b05b4d5ad6300c615807f1171eaa49eff5ad418c7c55f8466dd66d57a521f20cbcd66a7247a9283dbe5418a63862479877cf1f6c5008e400bdf1ce684016fe53dfbd1a73794600e08ce3d6800377c8c7d6800a9cf75fd4503d91492460f7ee3d28247a7b459f5fd592d22711c206f9e563858a31f99cfd050583518ba75247b1d134f9aed21396d4669769931dc01c003f7a329c4d17458ac5b55d36c12e040a3f1da75c1cb04ede2447f7f6a94567ad7a66db4fbbb29ba7d65b8b4bd8ccd09c8231eaa07b8ab04a7c2cf87b3f53ea8d77abc72c1a5dabe2452bb5a561fc83e5ee7e541e988218ed2dd22b7855228d76a46a00000ec00a510bd4dd511f4fe84da95cc31f880022da4902b1e7d3e99ac86fd03d631f565b4ee6d4dbbc649009cab2e48c83f514165b8b94b6895c44f279c280839e78ce28178ae6de46748a789e453865570483ec6812d42e85a421fc37918b00a883924d024c6e99b7a2a966c0009e17dc9f9fed40f81c77e28139218e4ff9815b9cf23340a01c907b9140201038ed402fcafd28386464e4fd33c50272bc60032609cf00fbd024f722dc66f24822ddf972f8feff00e280f69b24844919cac9ce7de83a447f30ded823007b50459d6ecacb528349b979127651b1dc795f1f3f7a0990148054823dc5015d491c0a0c3be337c2ff00c489b5ee9c87172016b9b541c49ff5a8f7f71eb560c1fc43e0a47e1aa94277310431f91fa551c1727f29ed409b641c86e31839a3454805739c1f6a026f1fd740f64665fc8c31cfde82db79bb40e9e8f49b62eb7d7e8b717ec832c91ff247fa1dc7df2281bcc9369d671493c422b7911654c1215f92bb8827bf068624ba635392df5eb4b9924558ee5bc19b71cee43c6dc7cf34c657be8db0b0b9d0f51d2afe668934dbf9628ddb8c2b8c0073f3a80da37546a7d25174fd95dc125c69f7313ee5655dfc313bd483cf07b1f6a68d5b48d5ec758b612e9d7293211c8fe653f35ee2a084eb9e8bb1eafb3582fe496278f3e1c919fcb9f97ad03ee8dd017a6741b6d3229dae161057c5750a48249ec3eb4139238568f6a9e7b103b5037934cb3793c610a2cd9277a8da73f5140ee38f6280c4b11c65b934023006d50050030e4647de80c846de3b500fcf9fbd0197273ed4007b91400e580c8e45074a82400e72682b36fd2162b7f25ddc09af2766ceeb872db79cf00f6a0b3229550140e07007a50092db860673de818df473c862686dad6470d9cce3b7b63e740fa1de6252ebb5bd81cd00bee2d800d003a6464004763ce683ce9f1cbe1f1d3a67ea1d1a30b68edffba814708c7f9c63d0fafceaca31e6dc71e1f07daa82608c83819f7a1a11ce149238fd68d0a579ec682cfd27a7c3a86bd10bc38b3b756b8b93c1fe1a8c91f7381f7a034f752ea5aa5c5eb292f732128037619c018f6ec282e5a2cb047abda74d5ce9b6da80f136de4a496219b3e48c92000323ea73467519d3da5bb757dbda410ac90c77c23058f99007ee7ec31416882ee47d23acb5185caf8bab4691b1efe57fff0038a9457ee75a82f6e7429350466b482f2742c0f74241c80c38c64541a9cfa1e89ac0177d33ab3d8de28f2b5bca429f91140e2c7a9b5ae9fb85b6ea9b46b9b3c796fe040768f76ec0fafb1f9505df4ebdb3d4edd6e74db98ee216fe68ce47d280648f75e2485a44da385ddc13f4a025ddbdbea16a633286566ce55f9c8f6c502ad750db2c514f30dec428247e6340bbf04100b73402afb943ed2b9e30683836defe9403bc1e06734020e06280cafe8683a375941d841c77c1a0151b467b50159f00e4127e5402872371040c5046eb5aadbe9b1c02e2f6dad25b89047099c677b7b0140fe3f1010afc803f3018e68160c3041ee2823f5dba92d34db89a1d9e2843b03b6d05bd013560c1748d57aa2797c6b35bab78e6959dc47231580ff336dcfb03c1a58364b5bbb7d7fa7b7427f1f673830c8664285bd1815238fad20f2c7c41e979ba43aa2e2c1cb1b663bede438f3a13c7dc76fb5515e9065b851f7a02950002a09c51a1b83cf14176e90d3645e9ad7752752aac23b3439c066665c827e944d29a6410aea725c4567135bd840d3c88a723728c29c9efe6c50d3ee9545b0bf8ef2e6e3c2fc2c6f72f2920e5f19039ee4938a9a875d03278377acf52ddf867f036ef71923932bfe51fbd3475cdc369df0db4fb389d4ea37970fa9cc0b00511795ce7d4f181eb4cd2451755fc45ac16d637381b14ca36b641dfce723e4053170d6cb52bbb362f6d3cb19241f2b9029862f09f143549ba7e7d2eef6caf2797c66ee17fdfd69862d1a069da7dfdac579d17adcda5ea9e1a992376c4723e39e3b024fd7e94c458ac3e25dee8d31d3bae74e7b79002bf8b8549471db38f5f4ed4c165e943a06a328d4ba605b4b22a1523c420c64fbaf38a82d36f0ce7cf7463790729b53017e940e0b0ceceed8ce0500e1b70daa08f5c9ed41d271cd0132476e7d7ff00aa069797d2411168ed9a41fcc858211f73c5075acb25ca6fb82aa31e58a36c81f561dcd033d42169e158ac64b98151b3981c2966cf639f4a064c7a8ac55e4865b7d493701e1c8e52403ea3cbfda827e390ca3f2c914aa81991bd281cdacc2747215c60e0ee5c67e940cb51b0b2bcbd824bfb08ee1a252d1caea1821cfa67b1fa504982b2283ce08f518a08abb82f6dd0369a5662081e14ce40c7ae1b04fda82275cb0bfd4f4536f7114589a5412461f3e4ce4e0e060f63f6ab2893d3b4b5b5b78e22ed22aae3cc3cc7e64fad3449a22a461500007602a0cd7e3b74c26b5d2ad79147baf34eccca40e4a7f30ff3f6aba3cd0543267eb5427b86f1f4c76ef45d0eca1ad5ef224d13e1cf4fd9b22192fa67bc955f8c8c617fba9fb510d7a6ed3fd43a735e5b54964be658c048fb6cdd9e7eb8a186bac97d174e6d22e23437b7ac26b95e77c68bf950fa7279e2b22dba45b59e97a669fa4ea36aeff89cea9a90451fc355ff0096ad9f4ce3f41570675d4fa8c77da8de5cde5be26bc653171ca47dc1f6c9fed5562b97f70276808da7c24f0c1c63804e33fa8a2928c0e0383c8f7ed41d92a41393f4a2548595c2c37493db4cd04e8a08f139566edfef3445b6e7aeaf65d2df48ea2b11776ae02a93e564c772adef409f4ee8ba9a21d73a36fa579ad9f325afe599171ed9c30a960d5ba0fe2843abb47a6f510fc26a4c36890f9558fcc6783506a1147b510024e30339ce680d2c6ae9861eb9a009178a0205443b989e39cd01d8075e3047ce80563057ca381ed4011c4531e503d85013c91b804a21279c903341131cda8c3abdc8650f6d20c4321232adec3dc504bab2c113c9293bb1963df3408dd4b75e1efb2856463dbc43b4631fad047e9177ad4fe32ea16b1db4b8fe1aa92571f5f5a0916bc8e0895af5c46c17cd8c9ff7da80f6d736f7f6915c59cab35bc837238ed8a072a31c1ef4062870718a06f7702dc5b3c522ee4752ae0fa8230683c75d6ba3b74ef535fe984929149e4278ca9e47edfdab42058003763ed409f88ffd6dfad06b1f12ae612fa0c76e0b471e9916d23f973eb4158d3efeff004a984da5debc1295d8e4018dbf3145d583a2ad96f356bbd7f5d90dc59587f1e79a6392f28fcaa3ee47159444ea3aa5ddfc7acf50dcdc344d7a4dbc317f52641200f6000fdeb41b5ef51d8eab672ffa9e971c97c11638268e431a46000012a3b9a351567db823b11f3ef40948e428048207a8340ab48ae83cb83ee0f3428a982719edf3e68c9cc97d3fe15ad8c9be138f2bf38e7b8f6ef40f7a5f55bdd3f56b46d3649127f1405f08e7249c76f5fa50689d48ba5f545cdcbdb462cba9206411b2b055bb07d4fb1c73528d4fa8f52d62cf47b6b8d2e65fc458c49f8a818795c151939f977a823ba0fe253750eb7fe937b04293f9f6c90be41dbdc7ff006283473c1efc1a06f69776d73bbf0f2aca32572bc80470450284a46dfca19f819f5a04e799614def26c0bdce09cfd85045dc75769d12dc3c3e2491db0dd3c85195235f7c91cfd066ae0cdba9be31f4ec61a386c1ef9d4ee473e45cfb1cf34c101d3ff1ac9d481d46c628ed24751881880833f988e7b0fa5328dfed2f2def2ce2b9b79925b791772ca87208f7a60182ee2b95cc0c48f53823fbd40ac658b30f4f4a086d4ee1d75bb6b78f4e965596366fc5211b23238008fde81f43692da5bc30d97831a0397dc09e3d714087506bf61a2c4cd77324726d2caaec141f9fd2ae0c435bf8c57173ad7876f7a2daca10489121244cdf319ce3dbf5a834fe81f881a6f57bcb6ba7c53c72c11873e28cee1db391dbef4199ff00ea4348116a5a66a8a8a04aad04847a90723f6ad7d18c312ddc02a3815423ba0f63fa541687bd9efe1b533b3c9e0a78473e899e318a09bd0ba6eef543e3b2bd8e9b10064bd9e4da001dc81401aeeb29a984d0ba7d5e1d06d4e6594f06523bc8e7f5c0ac8af752dfc17d7090d9218ec6d9447129ee71fcc4fb9cd6842ab10dc0014f3e5a2c1704b671dfdc734525226dc939e283a362c7f940344a380393df144733e2276e38f5efcd01b4bbbfc3dda4a9298a44395902e4a9c70682660d4265d62de40b1bdc1545054f95c8fe627df141af7c3af8808f3dd68dd5d2a45765884b8908d8c3b6c27b7a77a945d7a5fa474bd2ba8e4d5748b28624955d5d8b13b79ee9e983d8d40a753758c7a46b96f6114725dc92279a2810b3a64f94900763cfafa503fd3b59b79ed84da34713c0cd890f0a158fa1f981de826e1b548959fc4dc5cee24b6467e59ed4101ff19e9f676baa5d6a72c50adb4ad1ac790ccc076200f7ad41e7df881d79a87576a5f87b0f161d381db1c2a36e7e6d8ff3416bf87ff082c6f208ef7a82f22b9761bd6d619785f6dc477fa53705ab57f83bd297ceb1e9caf67708db9c4526723e849e3e94f212dd25d117fd29a8c09a76b534fa39cf8b6b71ced38e36fb73417f52e64548e34007e673e9f21ef590a1c918c90718dc281a69b68f67118d9da5058b798f6fa7fe280daadd1b2d36eae70710c4d263df0a4d583cc7a668fd4bf11b5837d7c93dcd9a3146959822a0e781f4cfa55161e9dd7fa67a4f55b9e9aea3e9f81fc09ca0ba118998fcdb2338c7b528d39f4cd2ba76e2d357d292df4eb391809963420ce1b1b576fa1e7359119f1eb4e17dd033ca172d6b2a4df303383fdeb5c8f2eef3bce4e0e335684cb0c9f354160d36f64b0baf16072b91b5f03391f43c51aab23a5debe91c4fad4d73689e6fc3a290573ff4f03e59f4a3280d67581ce916567f84b58ce0a1fccec3d58fa9a084de08c90464e4d1a8e419059b201f4a05630a176918efc50176293872c17bf14042aa0125b03db14046c60b60123fde6827fa0c68edd5365ff11346ba6292ee64194240c807e59a32b7fc51bfe8bd5ed5db424860beb62b89218422ce09c11c01dbbd0660ae110bf1bf2154838dbebfefeb41a8f4cdac7f117458f4d9ecd2df53b4cf81a822808c47255c0f7c8e7fb54a2ec2cfabba3b4b4b8d3af12eedad40926b0f070a13f9b633649f7a82eba6ea4357d321d4ecad512daf20df26e016507fa4fbfaf3e98f9d067dd2bd2faac9aa4d72d72d1e9510ca46a7631c7a320e18f1dfd7bd059afb7da816d23de4ba5de211346a1e4785f190548e4648c63b64e6b43ce9d5baafe3b539c5b452dbda46c638a167cb281c73ee4ff9340e3a3fa5f5aea4ba58f4bb57dbfcf2b02a8bf7f7a0de3a5fa0b50d2a2d92eb3e048c0a97c867dbedcf6a944e5cf4f6b76d1b3d8ea42795066266c87c81c65b9cfaf15048e83af3cd64abac08edaf01546c38dae4e0657ee6826e5b892de3702292e2545ddb55700fd0fbfca81c4b3bc718716eef9eeaa402280d14ab3c0b2c65c06fe571823ed40df56b217fa6dd5ab9216689a33f2c8c558307e83b8d77a37aaa7d22f2512c28768800c9954671b3d33ebef568d0ef7a7749eb0b5bbbb162d657b32b46d2e1564c8ed9c5644d1b0b9bbd261d2a440af6cb0e2e5b1e7dbc1238e0f7a0375b696daa7496a3a4dac8a92cf078685b271db04d391e40d5ec4586a1716de2a49e0c8c85d3b120f715ba1899173ff305413070abd89cfe9f5a2d3ee9c8639fa874eb6b804c52dc46b20c9f302c3bd11e84d47e1af4d5dc6521d3e3b662c19a58721ff5a9a321f89bd27a374b456d158dccd34d333332c9b4b2afbe47a7cb1f7aa33d2bc0d8c0f1c8f6a2c14b6d501b39cf63450897380c319e3de8065031c038f7ed40d8faf1ce41e4d004876a8dc3cc7e743025c956c818028c904579e7f0e15695c9c0541924f6c00283d0bf07f42d6b48820b8d62d20b2b58d656404959e52f83c8ff00fcfafbd4a35bb06f12391a48dd55cee2b2f3818ed8f6a8158a159890f02242079147623e631c502b0db436d1ecb7458d4738038fb0a087d6eeb508f48bb7d32d95750752b6c26c905b3ddb6f61eb574794f5cb6b9d0fa9678b512b25d24bbe52b8c1638278fbd582c57ff12afaed45b5bc0d0d8a8c08a2731ee3eec5793f40450466a1d59af446293c186cd53ca0c36eab93dc649e49fbd048e89f1675ed35e301e293919dcbf9867b37cbe94a35fe94ea4d33aba6824306dc48015750d86c6e247b0cf63591a40b8dc23fc30f14138dcac3000f9d03687547f12e8dd5af816b13148dddbcd29039c0f6f6f7a0eb5d62caf5636825db70c9bc4328f0dc0271c8a090627d3073ce681acf6505ccf14d35bc2f2c2731bb28254fb8a075144a83ca806792400334049ee6281e2496408656d880ff0031f61fa50446bd76058ea1b9e21025a3bb48afe71df9c7b71de9c8f196a0de23ca7b827d4f7add117e0cbfd4b5059392369663ff004e71c51aa97e8f555eadd258f2bf8a889cff00dc28cbd0bf123a926e96d163bdb74490bca2321c678209ff001591e71eafd7a7d7ef45cde2c20aae144638033fb9ad2e1b5e69d058da431ccf21d4a5c3b4631b62523807feaf5c7a50222f2d648c25f5aeec8c2cd19dae3d3e87e944d3eb7e90d425b49ef2292de38224f1505c3f8724a9eeaa7bd0d57a60406059436306868a7803839c7ad1a158039c13f4a33a716767f8cb9b6b55e1ae2458813e9938cd07a9f42d0b4de99b4b7d1f41b58ff19b03c93ba06607fa8b1f5f619a5b8266d74a65d42da6ba90cce996dcdc8c9fff006a5a2c2635083b05ef83eb5028076341db4b1ed9f7a04651fc41db18ed419d75b744dbea335fcb0db0335f2057901c05da73c8f9d5d18a75174a3f4c47335e35da4ce418a489374254f707d463d33565d1529b569a489a17944b06ec8057d71dcd037b4b6b8bfba31584124b27e62a8a4f1ea68357f83da7ea5a76bfe0912453ccabb49194653cb60f6ce3dfda983d196cd108c2401711f9768e306b2297d73fc6d02773a8b591922693c5004bb9d72542fa2f6efde8314ff867aeeec27500b77bb5670e36ca19b1dff2e7f2fd2837ce8bd5dd348b78b552219022870d9c46e792a4f6c608a0b846c8e03232b29ec41cd0199f1410fd4b24b1e8f712c0a5e4452d851e6c639dbf3238a0afa42ba77475e4ba8470896681da45180b18da76af3c9029c8f26dc1df2b9c606e273e86b743331924f27f4a82c12280e59b008e79f6a2d4d74188ff00e30d203a82ad7519c1ff00b860d11ba7c5e86c9fa3afae6f4091e043e021270b21e01c7dcd6479ab4dd3aeb56be4b7b184cf2b301b57d07bfd2b4bad0fe25e9f6960ba7c7a55ac50cd750335ccaade7723b83b8f6e38a2207a5ba4e7ea3d93780cb616ca53781f99fbff009a0b675a5be9765d43a75a6ad3b25adb4185429b831c70303dfdfd2831eb8954ca48f3827819c71ed406b2b1b9bf9a5fc1c4ce2253238047957dc9345d122b792eee522811a495ce1157b93ed444ff0049f476b1aaf51c761345269d25be269259570c833c6077249e062a68f53e8ef0da69509d4ae225b92a04af232ab16f98cf1f4a5a266d4dbca8af13a329ecca723f51502d14f0cb9f05d1c8ee01c91f6a0393b4edfe63c8a031608859b38f97340d84d04e5846eae50f9829ce3eb400fb24466041f5e3d2823f56d22db57b192d6e61468a41c823ff0035651916bbf04ada7badda5cad6d1b72c09dc33f2a6875d25f0865d06fe2bc6d4c4d3282026cca8cfafcfd29a34cd234a10c768f711a78f1bb392a3001208e3ec69a26a58d640c832091c90706a084ea1d3eeafdadf4f86da3166c0b4b397c18f046140f5ce4d04f4702436e91c28a9122e028ed8a0a9f5a5b6a09a1bc5a135bc72cce048b3c5bc15c638f9d59043fc2db997481aa69dae49e1cb6bb643239211939e467818f97bd305965ebce9a10bc8da9dbaa2679dd9ce3d8530572cfac87566ab05ae9f1490692b9696e1f833738555f96793504df5f25945d2576b7ec16dc46792381c7b7ad5e60f234980e42f6c9c56a82ec3eff00bd4124e49700f1c646e3cd169ce9575f83d52cee324347323f6e3861ff008a23d47d4ba6a75074fdcd8ef317e2e2ff0098bdd4706a60c3f4ae8cd5f44eb8fc3e97248a638cbc73bf90483d463b373e9574685abf42a6b5649fea72bbdeac4a8d3b018cfae31f7a6895b6b29b41d30d8e9f6bbed9213e1b7a994e724fcbb5064bd7835a9752d3af75d8116354778f660788cbd9483dbb0a0cd20b2b8d43528ad2088bdcccf854039cff00e2827a0d34e9da1de896f2182492efc0976f998aa827d3d334113a74aa9a9298628e74570478bc0c7cf1da83724bb8246d3e6416b0384da61b5501c9f5c3704f152c037561a95f5fce61d3ad6db4ab950f34b331dd9f4191db8fdcd406d67a675ab4b6d325d1af248272a43430315ddec7038f6ad4b3f448bf47eb71cb69abddebf21d5e26896203846c30c8603b9c6452d9835901405660376319ac84bf13180779d8bb82827d4fb0a06f777367a75acd7170f1430a9f331200cfceae061a0cf6dac692d7365266191db0578f5edf3a6075a6c9278b3433188a467860d96fbd40fe540471409aa0c1140750001ed8ed4058e15133c983960077edf6a06faade5c5b7822d2d926766cb967da2341dd8f0727d85033d27597d62e2ee3163756915bbf8799d71e2f19dcbf2a092b88dd9a311950a0e5b70ce47fe6ac18af53f5b69da9752dd69da9ca906876e24465d9e69881c6ff005c679c0aa2bfd267a347512c93dbb5d42d90d3c800b68c9ce0ec3cfa528db74ad034db5905ee8be1ac728dc153984f3f980f4fb56453be2de8f647a6aff53796596f0aed46798ec033ce149c0fb0ad71479c9bb9dc3bf3c55a0b95f65a825150b481a407b93c0fda8a29c06671dc93803bd131eafd0af6dffe18d2ee25982a4b04603b7a9c631fad03bbe586381bc5945b96385718c827db3eb5288eb8ba934eb15fc3c535f05427796dcccdec7150637d5bd55d5362b7975aa4d0d919018adec8637807bb60723000e4f7cd58203538aefa8aeb478a7b9beba924547b8774cf8608036a80704639cf1f9855d1a7f4c68b67a03de5e5d59dad8d988c62e1c0f107a1e7fdf7a082ea6d07a6e3e99375a7cb6b3db093c727701e2360f7f53dfb50653d4130d42ee18f48b3f0232a15218936963ebf5fbd06dbf0cfa74855b9d46e04b730c6144691e12307d33ea7de8348ba6b5478a279a004f98c479247b81f5a9438805ac0be2e02e73c9ef8fbd40c2346d43578eefc40da7da1dc8b8eefea4fcb9fef419beabf12a4bcebcb2d2fa7ee0dc58492084b30236bb6467dce383f6a0b87556a67a7f4d95a0bbb5468816f0a69c78b2e072572719ce78357079dfab3af2e7a92c963b88d94abbbf91cedc93edf418aa2c5f0dbe2a6a9a0c90d8de34773a6a8da1186d6403fa48fec682d9adeb7a9b4c9d572dacc9a6c9700456e5ca910e000ecbd8e580352fb1ae7476bd6dd49a325e5a9f3025245fe961dea097523cc0919a032af039a006936c81423104649c703ef40dcce64bc3035a87b6f0c378f9fe7cf2b8fdf340a4b6e25962915d94a67807839f7a043586922b5636ec44c061063f31f6ab079d7fe19b7eb2d4efeef55d5d74f992e9a0fc3a441dcb13927b838c9aa2d4bf042c618e178efee6e18104870172318edf5c1e6945bbe1a748ea7d2315edbea3a99bcb190030c401010e4e783ee0fa56455be3d6b90c1a6268d69e17f1486900ee98ec29ccc183119419e7e55ba11f089f523ef5058363a8059fb8e31e9421b491056c01819e28d3d0ff07eea3d53a1e3b6b8db235aca63c139c0eea68ca47a9fa6ef757b83ff00bf68ad428c2f248c7a8f9fcea518df516adac74e7544f63a2ea172f1800291e6cee19ec78cd5826344e85b6bad25ba8fade5b99dae0ee11efc71e858f7e7d054a2d7d39a75ae8f7b6b00b8917f1516624b78429da327cec493db1db1d8540cf4aea28f58d6aeae2f6dd64b498082d880488d149fcea7d4939ab04175e6850a8d32de3b78e380c8de32c4db4e18e430fef543cf86fd0d691b4fabdf6648b3b2db69ce7dd87be68342d2f4fb9b5b891af1a28a2dc05bc5036d001e0eef7352884b961a2ea9aa7555c885e08d45b5bc52b61b686c120fb939fb541276bd4b61d53624d942e2f6200bc32290633e99f4233416dd3ad3f0d611c0c77b632e71dc9ef41156dd27a45addcb3dbd9c513b1dd941821bdc7b558333b9f873757fd69a85e3f813e9c7723b5d93265d872473c11544a68ff08fa75e290b42ec4e4124e70738fa5048e89f0f745d2aeadd2decedda6525c975121183c77f7a945c754d0e0d563682ed43425369403bff00bcd58308ba7d5fe13f5a05889974a9d8b46aede4914f707d88ff001528ddf4fd7edb54d1a1d56c312dab2e64dbc9418e78f5c541296d70b716d1cd6f8789977230ecc280cb7519b816f212b205de4e0843ce300f6cfcb39a0545c42cee88e0b458ddec33ee680eac92266360debc7b5056fad2d354b9b189745744be121daf27e550548ce3d4d58324d07a725e98ea2b7ff5381f5169a7579d021fe13904ee43ddfbe49038ab46e76cf05cc714f6d309232a4a98ce54fd6b2196bb7f2e9b631b2c427b891b6851db3eff002007341e5bf887aa2ea3d4f77378be381e42fdb711ed5a1554395caf1cd07617dcd04fc85402101da791421b49920331381c60d1a69bf02f56f03a925b12c162b98c955f775e47df19a32d99b518268e4491668704a79d4aeec7b7bd4a30feb7e9144d76e265697c3e2693631674273803e556087d76f35fd49859e9925ccf611141106f2e182e3241f727f5a94681a268f79ad1b1b8b9dd66b1c2b1ce9bb06361c1e7bf3fe6a096b0d3ba57488e485b52b40909c386901607d47bf7a0ae758eb69ac4d15be81a748f0a9c35cc90b2eff4c03c1c638a0b77405c5d5d45f87be5fe359a88b81b401dc1c7d38fb50586fed18ea3015790091591e447c1518c8c7a0a0a5754d8c9d49a8d9f4ee9dba0b3b5224b9692327728f627e7c6682f9a7e996b6b3a8b6b748a348820c7720761412c064e3041ce282b5d4bd73d3bd3f33daea97ac2e540dd0a292dc8cd043c1f15ba2a7923b65bb910371b9a12141f9d02edf13ba2ade56857551e5e77244c54fd0e280746ebfe99bbbd655d56dcdc9ce08465565f4ee3bfca82d53eb3a6dac3e25c5f5ba646402e33fa77a0aff5b74ad8757e9ca972844aa37c520fcca7d3f5ab067bd369a8f467544d626c98e9f7118f0200e4465c903049c8c9e6ad1b24334b6fa6249716cab20037c309dd83db03b5640dddac3764a4f02cb1103863919fa7a1a06d6f600c37162911b7b252b87dc773f1927393f4a079f868edae1ae6328a8b1ed38e30050226e85d5dc1f879011b3c47c2f604719f9d01eff4f4b83e3c6b18bb452b1cac9b8a83de80b16e8208a3b7b58e1407cc061427cc0ff1560ce7a8f592d69a97504cad2dac01a2b53900c3e9e51ea58f727d0551e73bfb86b99a49a46dcf21c96340dc13804f20f6f9501c0e3b8a0963316fcc4607007f57bd084d64dec01200ce483468ff0040d525d1755b4d4206ff0095207c11dc67ff0019a18f56584f6daad9dade4211e39104a8ded9152b235cd8c530613229c8c1c8ef50472e81690ee00322b0c100f0debdbb7ca8111ace856371358cba85aa5cc407891ccf83f2ef4048b4ad2e59bf116769672c72f99dd1437239078e2824a4d3e1b94559234110e781839fa0a0561b38ad532a12319c86c6307e740a9732a3a00cac870cd8e0faf0681be8b6db965bb909df3c85806eeabced5a09523647e6e0fef419a6adf116daf7ac34be9dd1da686e7f1ca2e243b76320ce57df9ff1560cc3e3f470ff00c78255b842b35bc6c4af9b6e323d3e95467b6365f8dbcf062beb68c119595d8aaff6e282422e9899b4f6bb5d46cda2562a76316c1078f4a0859e1b9b762c0bf94f0e84feb4125a57505c58ea70dd5d0174a986d92b1c13f6f5a0de7a5be366877260b5d42dee2d2423124a487507ebdf15289dd3fac7a7bab6feded74d61733473acdb5a162142ff00313d81ed505fa58fc6d809380c1b9f5c502e0e05040ea367a85dea454de2ff00a610375b04c16c7a16ef8340b5f6930dce9375636acf6a278f04c5dd4f1dbf4a084e91d06f3a52dee62bbd4a2b882494ced3c8a448063b63b638fde803ab7ae749b2b3096d792c93c8c109b55dcd18ce3710473ffdd043dc758dc5869044565aa5dda4c3c2b7bc78c1f14e3963db03e7c0ab066bf1327d41ba76ca6bc48ecad24c456f6b0c87cf8e4bbfa138c0fa9aa3297c83dd4e28395811cf2680a5b93c7ed413cd1ff0f3c797b8031406645236b0508406f30e68ba49c051b97d0e0e7d28ad57e19f575c5be8f269515dac772877c11bc464dea7ba8c739ce78f9d3193bb8ebfea2bcbd6b5b6b8b58bb7f13c2f0ce31cf0deb4c0f2dbad6d743d2ee99efae752d6c02a86e0054524f6383c7ff94c0b6af274c75149a46a5a82c46f1e1479fc3190bd8156fbe7f4a960bf74e9d253f1167a3ac09e0856610e3041ec7f6c540f67b892cee7f8d18368232ef2af2508c7047cf340ead5bf130accc9b1186541e723d09ffc5033bbb1b82d74d6b37f1244daa1b38073df3f4a08eeb1d3b50d4fa6a5b4d32f12cef1902ee73e523d476fde8306eb0d3fabfa4ba92c278af67bb7281606472f90bdd58558253a6afb40ea1d62283a8b461a66a6f931cf6a7c2466f7cfb939e7b5515fbed3747b5eb8f06eb78d35080a2ec9719c76f98049a0b4ebdd37d1bad869acbf0b03c5c16b29444adf50ded41995f68564a263a66b31cd02be152505493f51c1a088bab69ad1bc179e320f07c37c8a0692b46c4995f0381db39a0b2fc34e971d57d4705bc8db6c50ef9dd97b81fcbf7381528f5ae97a1d8e996d1db69b0c7648855b10a81b80f43c739c54134147b9a036063279fb5046e957726a0f2cfe04915b06db1788305ffeac7a0a00d72f8d9c491c06337533050ac7185cf2df6a06da2da4293488f34973328c34aea428c9ec3eded40ee7d2ad249448f6b133820ee2833df3fde819ea96897461b05b87815f2ee919e5d47704fa039ab079b3e326b70eafd4ef6d6650d8e9ebf868b69c8247723efebf2aa280eb9193ebedc5002a124e015340018fb8fde82cf32b1603d0678cd02406dce3008e47ce81b499c331383c9c9f5a2e9c69377369f7d6f796a4acf148acb83fb511e91b3b3d0bab745b7d45acedd8e3732b71b1fd73f7a5a19eafd09a56a0a96b1c705b49c48510761ce4fcfbd4d0d752826b2b583476fc3daacb295b79d768de8a32b1e71f989e49f6a7d14dd1af5ba275a45b8b093c054492ea769092373765c1da4679fbd306e36ba9595fe9f0dcdbcc92c33e1579cf27d0d409ea178f68521b6b76926ee8a7853f7ff140bc768d78f6f73748d1cd103b543f0091cf6efc502f7319dac194371d8b6326829f0c501d7ae6fa568d5d4942c806d4db81839f53c8cd59456fae6e628749b5bab8b1865b08e4726588ec11e7f2e49071c93da9a31dd4341d675e9a5bad374f9858162d0b4ac70e18f0573df35a0c759f87bd53a404f174f965dfff00f479b1ef570576e34bd4b4cc0bdb3b9b7258a00e846e3f2a94376475cee4914af7ca9150685f09ba61efb52fc7dd69bf8eb7c158d1d0b47bb38f37efde968d6eeb4eb5e91d6ad25b660aee59974db6881690918e31ce39279e062a5a34bb57b88adedd1e379679065d80036679e6a07e8391bce7e940c659ef5afe1286de3b16f2b8903094b7b2fa7ce81eb380c4260ed193f2a0cd6fa5d4a4ea0fc7bdadcce923158a3039db83c038e3ef41a0e96b2ad8a35e009291b8a939d9f227e43bd590436bbd6fa269202c974b7123602c76e779624e00e29833bf897d493e896525dbcb2a6b5a9c3e1456b91b6d60cf989c7f31f7a60c02490961ebcf3eb541308e39e067b507007b96007a67fb50178f97eb4165ce18165c2927b773fad023202d9c8dbb7818ff003408300b87f2f1c107d0d0c15a4f2e339c90467f6a18bdfc2cea8ff4bd561b4b9ba686d6e64552c4f954e7d7e46a60f4688d240af1b2bc6cbf5047ca960617ba658de1b792f2d94a5ab33461b18524633fa1a81b5c8b5168967369d23c0e0a24622dc981d81c76aba29df0bb48d660d52fceb88d069f04aeb69130037127f37b9c0ed9a8350781240bbc06da72323b1f7a0eb8816e633192ebc8c9472a78fa50349b4c83c068e24f0ddbcc1c13b837be4d055b57e98b996d4db5b4a893dc1e6620b6ccf2c467efc504ce97a38d3f4d874bf09af6d46e2f25cb82724e791db15650a43f878b51fc34f3da8f132b6d6a98c80a39ff007e99aba249631b58b9047239ec3e55368aeeb7d2da6f52c0eb7f16e87f2c6e836ba90724ab7a67b55d115ac7c3e8aed2182def4c56a14096368959a423d77e3229a27b41e9d8343b01069c8a8dc9660aa3713df3c64d4a1c695d3d6b67a8cba94b9b8d4e61869e4e4a8c636a7f4afcaa09a485519caae19b966f7a0435196582c656b74df3e308beec7b50629375775b691ac5bdb6b16d6378779f019b00a31cf391c9c2f1daae0b35ef52f5374de88d77aa45a6cd25ddc0108694ee2188c28007603d6a0d16c92430a4b2ed3230dc401855cfa0a0a07c45d7b5db9d462e9ee960b14b2ee134ef8c850012147ec78ab0670b643a2efae753d72686e6e2da211db42176079c8e768f65e39f7aa332d6f58bbd635096f6fe6692695b24f603d801e82823cb900ee00e68006460051dfd680ed9f0c905b713d8d006d5f5419fa505a18f94e40501b1b81a04186d62402c87be3d6810b81290aea8467201231cd1749dbc437f9f1e201db3de8ba07dc0175c027f28a335b17c26f888d6b6d0e8fabf892a29c453b1e547f49f7a946d6424f08236491c833ee0835073294888894120700f0280813c40a6711bc8843e00fca7d3ef40e41dc081f9a811681c6f7565329185623b7e9de812b3bcf11ff0b74563bd50494cf120071b97e5fda80d7577046c9019d5669dbc340324eec67fb734103d5da96bf67a7cf0e916f6e2765f25ddc4c11107ab1c8c647cce2816d3ec7f0f6564cae6e67da375e6d52cc4af2e4fb13ed4145f899d47b3499f4bb6d46cda49b69b92921565c3648e3dd40c81cd5c0ae89f13ec246d3e379ed2d6da180b5d34849da1780b128e49271c9f4a60ba685d5fa36bc42d95c324ec7090cc9b1d87b81ed50588958977cacaaa3b9341c655f12348d1dcb8dc1946540f99a019e2134454eeda7bed3839cd052fe2136b536b5d3563a1ca53c49da4b9507198940ce7e5c9fbe281c6b7a974cf4ee4ea7242d76dc784a3c595b3e9b464e3f6ad0ac745ccbd4fadcbabea42da56959a382ce7460d6b1a93c01f97272093ebf6a82f1ad6af0e9da5cb3cecf6902216919f82aa3818c7a9f4c530649a9f5269ba7429d472239bc991a1b0d3c3152880f0f23039e7bf3de90635ab6a377aa5ebdcdecef2c9239e59f3827e5ed54302195fcc38cd01245395c1f5f4a05b606538e483c501b6939e3b5077860f3914165754c33e549000dbe87de813b820c27fa7baafb8a04a69c98e281e42618c795338033df1f3a06c03e4e029247007ad010093c35674da71f977640340081a190658e41c820f141b0fc33f8926c218b4ed609366a02249bb2d19ce3ea4528dbece68eead926b7916689c643a9e0d643387521fea2f693c2d6efc786ee46d9bfed3eff2a04669edf5295ff057a60bd865309246d3bbbedc1efef41d63a8dec9ab4fa7dd4510fc3c69234ca186e2d9c003b7a67bd034bad0a5bb96e25d575267889cc1b54446d9bd0a37bfbfbd02925945a72cba8dddc48b3f87b1e58f23c623f292bdb7fa7cf38a0a5750f54ebba56a9a67fc516b6d6fd3970ea9234677c8dc7f38f6e4640ce282d1ac4b16bfa72c1d2bad430cd1ba822061865f5007d3daac19cf547c189357d561bbd3eee683c62cd786e9b73337b8c7bd512bd39f06adedec2de0d5ae639da372e6485363107f97767b505cee755d03a5e58ac228659af123184b7b733322e38c91dbf5a943ab3d52e64b49ee755d2e64950e238e35f10c884e17cbe87dc540e6d7509a4f110e9f7566a471712850abf6ce463e6280bacea36fd33a4497f773cf32c698dcc4beee33938edc7ad05534aea683ae61d64c4d2a69b6b88d16d5ca5c303f3e386cf61db140e27b5e99e96b64bdd562b6b30aa36c6c37cac7dc9eec6b42c1a66a962fa70beb6b516d0cbe76322f86c78f6c66831bf8b5d5d2dfa35a5dce60b1933b6ce3c788769f2b331ec1b8fd2831b79649984b239773c1dc68129725c1c640e73400ec781d8fb1a03c4a85d0c8582640257bd01e51fc42236263c9c67be280429c6037eb405dbf5fd682c2a0bb976cf07d3fc5009279ef8ec4e68193a9902b28e7dc71fb501d95b098e0f6dd9e0d0049131019b047b8390281bb292484e47c8500c4f242c3076bf704704739a0be7c3febfbae9a5daf23cd017c7e19fb107bb67d0f6fd6837cd2757d1fab34f4f05e37dde630b1c3a91edf4f7159103d6eb7da65fdbdf59dadb5e2460ac876ed9e1c8c060f9efe9c8a0a75cfc42d5742d2ee5a7e9dbb494b6d6b9bc930cce4f940e3cd81ed4160e98f88315e689fff0022b57664199cc5196f0c7a164ef8f98cd0589baffa68590985eb15c0db1985839f6c2919340b69d03f5285bdd6f4bf021424db4329cb153fccc3d09c76a090d3340d2f479a7bab3b38e2924e5e451cfd280d7dafe936f6c5e4bd89813b02a36589ce318a0358dc35cc4e17f9bf234cdbb78fa0c607a7340e6cec20b1596610c6934b8323226379edda81da8dcb9ec40a042f50b5bb21645473b58b11dbd7bfca8304f8add5d67a9ea8ba5d8ea72c1a4d8a952f10f2c920e368cf71e99fad5833dd0754d6ed66bdb2e9a91a5babb2a310465a57c1ddc1038e7bd5171d3748b8d46ee1ff005298dc6a764c27d4eeaee7fe1c01795881c9e7804fe940dbe287c4b6d75a1b1d1c986d62277c91bf131f4c0f6fad0663737135d3b497124924871f98e7803007d2811dc5b83903dc0a0333f03be7de8122df2c9a05a11e5f51f7a05ce7071804fca8033e5da0734020b0183bb23e5416269577ed0e5323078ceeefdff6a03dbcd62914c2f629a47c622689800879e4fbd046f9d8a2a03e31385c0e73da8b83ca590947dcaead8208e73da8849b3e19ce704f7c5015586d006431f5cf61f3a04ee586ff002481c8fe6191408f0011eb8e30682774dea9bbb5784492ca6385832e1ca95e3d2834be9df8c312e2db5eb4375080337000f1303d18763591a469baef4d755989ec6f6dae5a23e20b599406dd8e080ddbed41272f4dd8caf1c86d163910f9595882a3d718a035edd695d3b6a926b57d0ac65b10b4e06eedd863bf141077fd7af2782bd3fa26a1a8891d57c630948c0279393dcd04cf5875258f4de9f0cb7b7b6d66d2b81ba752d85f5214724fed41036bd79d2fe319d7a8f4b9c81e58de2f04827b9ce09a07a3acecf54b790685ace8697606009e52c377b7f2e682b097d7d36acf0f55df5edbdc0977412468cb6ce3be10af3c63b9c8a0b0751f505be9690dd5d752436f62a3fe4c6448f3b7b0c64e38f615734651f107e3045ac42b67a7693018633b965bc1bc838ee173807bf7cd33065baaeb1a95f2c11dfcd2bc51fe48880aa3e8a062a8b059f595df4ae9a74de9e9ec499d43c97b1427c6e47e525bb63e4282ad3ea3712893c599dbc4259c1627713c927de81043950df97db1406da8411c92063be280230839627078e79a0390a71b5bb5003a8c1232338e4507025573e9fbd02a0e41dc0e680c3691cf714053bb34160895dc16f291d98d02322aa39f3e14707ffaa06f202a5bb0c7201f4a343aca51090497efdfbfce89840c8db8e46573923ff14410b00490d9f5c1a0425dd8ce4673e873cd0265e4dbe7041ed814009b8cbb8e5863bd07163b7716e0607b6698060b96b7b9478dc8643918247ee39a60b7e97f133a8b4e0c63d4ee597380923970a3ef4c0e13e25dfcfab457ba95bdbddb212016501867b9cfbfda982f907c74b282da34874a9048aa479c83838edc62982b7ac7c42d235cd67f15ac5b40c366418a2cb0c1c81e6f5e31db14c160d035de8cd4a3f18ea96562cc37359dfe9cac887fef039fd6b39446f56ea5d13a9dca4579a922496b1975b8d22dfc3566cf9557230703be715ac1431d4d2275325d7fae6b4f6f182a93ef1e32a9f41938f6a60afeb1a95c5fea53dccf772cf2c8c489240031f627e7565c0d67bbf160487c1801073bc0c31f91f953420f2bc8c7c52cc540032738a809905c0f4fa501940208e73df34028e703938a0577ae013f4a001300db4f03b71407461ce0502dca8c9c7dcf6a003fafcbdcd0070bc1e0fd734070db467b8a04cb9c9e68274b93bcb1daa40200ed4099765249ec476cf340849b8b264823bf34689ee009cb671df1409bc8e8b8e770e3ec68984d9c953cf97be2860b248caaebc107dc67f7a184c31232db88fd451031ce50e76039f5c8045026efb8f93279e0fd680b239504f0483d88ef409ee25bb90c79c0e050151c6e21b39ce783eb40adbcc2cefa17bdb61322387781c950e3dbdf9c8a066f28790b22e013db3dbef54726081e63c6460d34191b1bb0720f634060e7600412c781502409c8e3d7b500ed71dbef8ed40243f181c0a02e5d4e0fad006f644e4819e3b501f7e3049e7b501bc43b4e391da80558003392d40a23305e320d02e64cf998e1bf5a032b0c927b8e68049c8c8e71c6280377043118f4e680bbff00de0504ddbb3128371c1c64668024e59f3cd02521254e4fad1a2107e48fe6a6809ddb9e78a029e1463d05027ffc744a6c3857c7b1a205ff00e637fbf4a02b12b1794e39f4a02024e7249ed409924720906800005173fd7404989698ee39e4f7a04cf723d07a501fff0097ed406ffe36a018ff00281e99a037f4d0731f3bfd28007e53400ff99a810248c0cf140bc60123233cff008a0557f9beb4056eff007a07109243e79a03778b27bfbd02b128c27039a054001b818a06609de793da815006070283ffd9}\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here is a movie {\pict\jpegblip\picw20\pich22\picwgoal400\pichgoal440\bin ffd8ffe000104a46494600010101004800480000fffe0050546869732061727420697320696e20746865207075626c696320646f6d61696e2e204b6576696e204875676865732c206b6576696e68406569742e636f6d2c2053657074656d6265722031393935ffdb00430001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101ffdb00430101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101ffc00011080016001403012200021101031101ffc4001a000100020301000000000000000000000000080905060a07ffc400231000010501000300010500000000000000060304050708020001090a11153976b7ffc400160101010100000000000000000000000000060800ffc400261101000102050109000000000000000000010200030405061121b33134365154717475b4ffda000c03010002110311003f00a90cf388f366a62aa720ed6ae07f96901f3831d973452b8cf36fe3570fc908e46d466433e5dd954f2e96992d9e498c7753faa44916e016ca91cc7d88b38fe60a5b97737defcbcc539c98d336a57f4fc2ca9a486bf07ab575ad9a3af4df221d8215e36df86c4504ff0024574551b3d687ee0575757b3ad64e311ee62bd94158d37e24198c43973099f1fc0c41614d950246513a081abf76cfe7061f6863281e6352fd1670949c148dd6dfb0d25f5b3689b1d5c965b0eacbf4e0932ad28e22ab9ae945633f4744bd3c8cee0a7fdf085b9000f449c5f7afa30b83e0b6fd7b0c8429c9467ff9715347c891e25fa24a205861aa715e6a09bd0488237dc2723414d9891381524e8ca7c0894664f835653631ab55ee7e3de433e4ff001b30949124e4c10c8b6ad0a479b3f9c937b2cf5bc0095ad600a0a41a0e9faee174a1c605e161c6c7a313539650b0113190f1a8368e60d5b24f30ff008ea7f0bf867fa6595feeb6978f1fe0f9c26177f4d63a51a9235184750e7d18811339cd000000c75f000e00380380ae390c350def826ed42ad051fa6f501c50f9b699c3b69cbeb76476d202bf3ac985b6e0e968be66572893e6a744540bd9722e5c87956848629bc2559306bd113e8653d3b6aff651dfad7a3ac8b02958cba02a93ccf525757039bae6cff090e1d90688e8aa233ee86a4c4a3e0586d6b2340522e47dcb7d0046d8a5acb05a123ee25d2b230b2ada6e2e2f9ede3c05202520ec2487b0d56562529d8b3393bca76adca4ec1bca508abb001babc007915d84fe3dd14e207e3c62f8379da2a3b861fb6629d28dba53b6ea388ebfed866bf6dfb553455e91ed547ae92e9445253a4fdf3efb4f8ebdfbe7d3c78f1ee0bb9e13e358e942a4ed49e22cff00eeb35fdd7ebfffd9} icon.\par}
+{\pard \qc \f0 \sa180 \li0 \fi0 \emdash\emdash\emdash\emdash\emdash\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Footnotes\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Here is a footnote reference,{\super\chftn}{\*\footnote\chftn\~\plain\pard {\pard \ql \f0 \sa180 \li0 \fi0 Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.\par}
+} and another.{\super\chftn}{\*\footnote\chftn\~\plain\pard {\pard \ql \f0 \sa180 \li0 \fi0 Here\u8217's the long note. This one contains multiple blocks.\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 Subsequent blocks are indented to show that they belong to the footnote (as with list items).\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 \f1 \{ <code> \}\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.\par}
+} This should {\i not} be a footnote reference, because it contains a space.[^my note] Here is an inline note.{\super\chftn}{\*\footnote\chftn\~\plain\pard {\pard \ql \f0 \sa180 \li0 \fi0 This is {\i easier} to type. Inline notes may contain {\field{\*\fldinst{HYPERLINK "http://google.com"}}{\fldrslt{\ul
+links
+}}}
+ and {\f1 ]} verbatim characters, as well as [bracketed text].\par}
+}\par}
+{\pard \ql \f0 \sa180 \li720 \fi0 Notes can go in quotes.{\super\chftn}{\*\footnote\chftn\~\plain\pard {\pard \ql \f0 \sa180 \li0 \fi0 In quote.\par}
+}\par}
+{\pard \ql \f0 \sa0 \li360 \fi-360 1.\tx360\tab And in list items.{\super\chftn}{\*\footnote\chftn\~\plain\pard {\pard \ql \f0 \sa180 \li0 \fi0 In list.\par}
+}\sa180\par}
+{\pard \ql \f0 \sa180 \li0 \fi0 This paragraph should not be part of the note, as it is not indented.\par}
+}
diff --git a/test/writer.tei b/test/writer.tei
new file mode 100644
index 000000000..41f258775
--- /dev/null
+++ b/test/writer.tei
@@ -0,0 +1,861 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TEI xmlns="http://www.tei-c.org/ns/1.0">
+<teiHeader>
+ <fileDesc>
+ <titleStmt>
+ <title>Pandoc Test Suite</title>
+ <author>John MacFarlane</author>
+ <author>Anonymous</author>
+ </titleStmt>
+ <publicationStmt>
+ <p></p>
+ </publicationStmt>
+ <sourceDesc>
+ <p>Produced by pandoc.</p>
+ </sourceDesc>
+ </fileDesc>
+</teiHeader>
+<text>
+<body>
+<p>This is a set of tests for pandoc. Most of them are adapted from John
+Gruber’s markdown test suite.</p>
+<milestone unit="undefined" type="separator" rendition="line" />
+<div type="level1">
+ <head>Headers</head>
+ <div type="level2">
+ <head>Level 2 with an <ref target="/url">embedded link</ref></head>
+ <div type="level3">
+ <head>Level 3 with <hi rendition="simple:italic">emphasis</hi></head>
+ <div type="level4">
+ <head>Level 4</head>
+ <div type="level5">
+ <head>Level 5</head>
+ <p></p>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+<div type="level1">
+ <head>Level 1</head>
+ <div type="level2">
+ <head>Level 2 with <hi rendition="simple:italic">emphasis</hi></head>
+ <div type="level3">
+ <head>Level 3</head>
+ <p>with no blank line</p>
+ </div>
+ </div>
+ <div type="level2">
+ <head>Level 2</head>
+ <p>with no blank line</p>
+ <milestone unit="undefined" type="separator" rendition="line" />
+ </div>
+</div>
+<div type="level1">
+ <head>Paragraphs</head>
+ <p>Here’s a regular paragraph.</p>
+ <p>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.</p>
+ <p>Here’s one with a bullet. * criminey.</p>
+ <p>There should be a hard line break<lb />here.</p>
+ <milestone unit="undefined" type="separator" rendition="line" />
+</div>
+<div type="level1">
+ <head>Block Quotes</head>
+ <p>E-mail style:</p>
+ <quote>
+ <p>This is a block quote. It is pretty short.</p>
+ </quote>
+ <quote>
+ <p>Code in a block quote:</p>
+ <ab type='codeblock '>
+sub status {
+ print &quot;working&quot;;
+}
+</ab>
+ <p>A list:</p>
+ <list type="ordered:arabic">
+ <item>
+ <p>item one</p>
+ </item>
+ <item>
+ <p>item two</p>
+ </item>
+ </list>
+ <p>Nested block quotes:</p>
+ <quote>
+ <p>nested</p>
+ </quote>
+ <quote>
+ <p>nested</p>
+ </quote>
+ </quote>
+ <p>This should not be a block quote: 2 &gt; 1.</p>
+ <p>And a following paragraph.</p>
+ <milestone unit="undefined" type="separator" rendition="line" />
+</div>
+<div type="level1">
+ <head>Code Blocks</head>
+ <p>Code:</p>
+ <ab type='codeblock '>
+---- (should be four hyphens)
+
+sub status {
+ print &quot;working&quot;;
+}
+
+this code block is indented by one tab
+</ab>
+ <p>And:</p>
+ <ab type='codeblock '>
+ this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \&gt; \[ \{
+</ab>
+ <milestone unit="undefined" type="separator" rendition="line" />
+</div>
+<div type="level1">
+ <head>Lists</head>
+ <div type="level2">
+ <head>Unordered</head>
+ <p>Asterisks tight:</p>
+ <list type="unordered">
+ <item>
+ <p>asterisk 1</p>
+ </item>
+ <item>
+ <p>asterisk 2</p>
+ </item>
+ <item>
+ <p>asterisk 3</p>
+ </item>
+ </list>
+ <p>Asterisks loose:</p>
+ <list type="unordered">
+ <item>
+ <p>asterisk 1</p>
+ </item>
+ <item>
+ <p>asterisk 2</p>
+ </item>
+ <item>
+ <p>asterisk 3</p>
+ </item>
+ </list>
+ <p>Pluses tight:</p>
+ <list type="unordered">
+ <item>
+ <p>Plus 1</p>
+ </item>
+ <item>
+ <p>Plus 2</p>
+ </item>
+ <item>
+ <p>Plus 3</p>
+ </item>
+ </list>
+ <p>Pluses loose:</p>
+ <list type="unordered">
+ <item>
+ <p>Plus 1</p>
+ </item>
+ <item>
+ <p>Plus 2</p>
+ </item>
+ <item>
+ <p>Plus 3</p>
+ </item>
+ </list>
+ <p>Minuses tight:</p>
+ <list type="unordered">
+ <item>
+ <p>Minus 1</p>
+ </item>
+ <item>
+ <p>Minus 2</p>
+ </item>
+ <item>
+ <p>Minus 3</p>
+ </item>
+ </list>
+ <p>Minuses loose:</p>
+ <list type="unordered">
+ <item>
+ <p>Minus 1</p>
+ </item>
+ <item>
+ <p>Minus 2</p>
+ </item>
+ <item>
+ <p>Minus 3</p>
+ </item>
+ </list>
+ </div>
+ <div type="level2">
+ <head>Ordered</head>
+ <p>Tight:</p>
+ <list type="ordered:arabic">
+ <item>
+ <p>First</p>
+ </item>
+ <item>
+ <p>Second</p>
+ </item>
+ <item>
+ <p>Third</p>
+ </item>
+ </list>
+ <p>and:</p>
+ <list type="ordered:arabic">
+ <item>
+ <p>One</p>
+ </item>
+ <item>
+ <p>Two</p>
+ </item>
+ <item>
+ <p>Three</p>
+ </item>
+ </list>
+ <p>Loose using tabs:</p>
+ <list type="ordered:arabic">
+ <item>
+ <p>First</p>
+ </item>
+ <item>
+ <p>Second</p>
+ </item>
+ <item>
+ <p>Third</p>
+ </item>
+ </list>
+ <p>and using spaces:</p>
+ <list type="ordered:arabic">
+ <item>
+ <p>One</p>
+ </item>
+ <item>
+ <p>Two</p>
+ </item>
+ <item>
+ <p>Three</p>
+ </item>
+ </list>
+ <p>Multiple paragraphs:</p>
+ <list type="ordered:arabic">
+ <item>
+ <p>Item 1, graf one.</p>
+ <p>Item 1. graf two. The quick brown fox jumped over the lazy dog’s
+ back.</p>
+ </item>
+ <item>
+ <p>Item 2.</p>
+ </item>
+ <item>
+ <p>Item 3.</p>
+ </item>
+ </list>
+ </div>
+ <div type="level2">
+ <head>Nested</head>
+ <list type="unordered">
+ <item>
+ <p>Tab</p>
+ <list type="unordered">
+ <item>
+ <p>Tab</p>
+ <list type="unordered">
+ <item>
+ <p>Tab</p>
+ </item>
+ </list>
+ </item>
+ </list>
+ </item>
+ </list>
+ <p>Here’s another:</p>
+ <list type="ordered:arabic">
+ <item>
+ <p>First</p>
+ </item>
+ <item>
+ <p>Second:</p>
+ <list type="unordered">
+ <item>
+ <p>Fee</p>
+ </item>
+ <item>
+ <p>Fie</p>
+ </item>
+ <item>
+ <p>Foe</p>
+ </item>
+ </list>
+ </item>
+ <item>
+ <p>Third</p>
+ </item>
+ </list>
+ <p>Same thing but with paragraphs:</p>
+ <list type="ordered:arabic">
+ <item>
+ <p>First</p>
+ </item>
+ <item>
+ <p>Second:</p>
+ <list type="unordered">
+ <item>
+ <p>Fee</p>
+ </item>
+ <item>
+ <p>Fie</p>
+ </item>
+ <item>
+ <p>Foe</p>
+ </item>
+ </list>
+ </item>
+ <item>
+ <p>Third</p>
+ </item>
+ </list>
+ </div>
+ <div type="level2">
+ <head>Tabs and spaces</head>
+ <list type="unordered">
+ <item>
+ <p>this is a list item indented with tabs</p>
+ </item>
+ <item>
+ <p>this is a list item indented with spaces</p>
+ <list type="unordered">
+ <item>
+ <p>this is an example list item indented with tabs</p>
+ </item>
+ <item>
+ <p>this is an example list item indented with spaces</p>
+ </item>
+ </list>
+ </item>
+ </list>
+ </div>
+ <div type="level2">
+ <head>Fancy list markers</head>
+ <list type="ordered:arabic">
+ <item n="2">
+ <p>begins with 2</p>
+ </item>
+ <item>
+ <p>and now 3</p>
+ <p>with a continuation</p>
+ <list type="ordered:lowerroman">
+ <item n="4">
+ <p>sublist with roman numerals, starting with 4</p>
+ </item>
+ <item>
+ <p>more items</p>
+ <list type="ordered:upperalpha">
+ <item>
+ <p>a subsublist</p>
+ </item>
+ <item>
+ <p>a subsublist</p>
+ </item>
+ </list>
+ </item>
+ </list>
+ </item>
+ </list>
+ <p>Nesting:</p>
+ <list type="ordered:upperalpha">
+ <item>
+ <p>Upper Alpha</p>
+ <list type="ordered:upperroman">
+ <item>
+ <p>Upper Roman.</p>
+ <list type="ordered:arabic">
+ <item n="6">
+ <p>Decimal start with 6</p>
+ <list type="ordered:loweralpha">
+ <item n="3">
+ <p>Lower alpha with paren</p>
+ </item>
+ </list>
+ </item>
+ </list>
+ </item>
+ </list>
+ </item>
+ </list>
+ <p>Autonumbering:</p>
+ <list>
+ <item>
+ <p>Autonumber.</p>
+ </item>
+ <item>
+ <p>More.</p>
+ <list>
+ <item>
+ <p>Nested.</p>
+ </item>
+ </list>
+ </item>
+ </list>
+ <p>Should not be a list item:</p>
+ <p>M.A. 2007</p>
+ <p>B. Williams</p>
+ <milestone unit="undefined" type="separator" rendition="line" />
+ </div>
+</div>
+<div type="level1">
+ <head>Definition Lists</head>
+ <p>Tight using spaces:</p>
+ <list type="definition">
+ <label>
+ apple
+ </label>
+ <item>
+ <p>red fruit</p>
+ </item>
+ <label>
+ orange
+ </label>
+ <item>
+ <p>orange fruit</p>
+ </item>
+ <label>
+ banana
+ </label>
+ <item>
+ <p>yellow fruit</p>
+ </item>
+ </list>
+ <p>Tight using tabs:</p>
+ <list type="definition">
+ <label>
+ apple
+ </label>
+ <item>
+ <p>red fruit</p>
+ </item>
+ <label>
+ orange
+ </label>
+ <item>
+ <p>orange fruit</p>
+ </item>
+ <label>
+ banana
+ </label>
+ <item>
+ <p>yellow fruit</p>
+ </item>
+ </list>
+ <p>Loose:</p>
+ <list type="definition">
+ <label>
+ apple
+ </label>
+ <item>
+ <p>red fruit</p>
+ </item>
+ <label>
+ orange
+ </label>
+ <item>
+ <p>orange fruit</p>
+ </item>
+ <label>
+ banana
+ </label>
+ <item>
+ <p>yellow fruit</p>
+ </item>
+ </list>
+ <p>Multiple blocks with italics:</p>
+ <list type="definition">
+ <label>
+ <hi rendition="simple:italic">apple</hi>
+ </label>
+ <item>
+ <p>red fruit</p>
+ <p>contains seeds, crisp, pleasant to taste</p>
+ </item>
+ <label>
+ <hi rendition="simple:italic">orange</hi>
+ </label>
+ <item>
+ <p>orange fruit</p>
+ <ab type='codeblock '>
+{ orange code block }
+</ab>
+ <quote>
+ <p>orange block quote</p>
+ </quote>
+ </item>
+ </list>
+ <p>Multiple definitions, tight:</p>
+ <list type="definition">
+ <label>
+ apple
+ </label>
+ <item>
+ <p>red fruit</p>
+ <p>computer</p>
+ </item>
+ <label>
+ orange
+ </label>
+ <item>
+ <p>orange fruit</p>
+ <p>bank</p>
+ </item>
+ </list>
+ <p>Multiple definitions, loose:</p>
+ <list type="definition">
+ <label>
+ apple
+ </label>
+ <item>
+ <p>red fruit</p>
+ <p>computer</p>
+ </item>
+ <label>
+ orange
+ </label>
+ <item>
+ <p>orange fruit</p>
+ <p>bank</p>
+ </item>
+ </list>
+ <p>Blank line after term, indented marker, alternate markers:</p>
+ <list type="definition">
+ <label>
+ apple
+ </label>
+ <item>
+ <p>red fruit</p>
+ <p>computer</p>
+ </item>
+ <label>
+ orange
+ </label>
+ <item>
+ <p>orange fruit</p>
+ <list type="ordered:arabic">
+ <item>
+ <p>sublist</p>
+ </item>
+ <item>
+ <p>sublist</p>
+ </item>
+ </list>
+ </item>
+ </list>
+</div>
+<div type="level1">
+ <head>HTML Blocks</head>
+ <p>Simple block on one line:</p>
+ <p>foo</p>
+ <p>And nested without indentation:</p>
+ <p>foo</p>
+ <p>bar</p>
+ <p>Interpreted markdown in a table:</p>
+ <p>This is <hi rendition="simple:italic">emphasized</hi></p>
+ <p>And this is <hi rendition="simple:bold">strong</hi></p>
+ <p>Here’s a simple block:</p>
+ <p>foo</p>
+ <p>This should be a code block, though:</p>
+ <ab type='codeblock '>
+&lt;div&gt;
+ foo
+&lt;/div&gt;
+</ab>
+ <p>As should this:</p>
+ <ab type='codeblock '>
+&lt;div&gt;foo&lt;/div&gt;
+</ab>
+ <p>Now, nested:</p>
+ <p>foo</p>
+ <p>This should just be an HTML comment:</p>
+ <p>Multiline:</p>
+ <p>Code block:</p>
+ <ab type='codeblock '>
+&lt;!-- Comment --&gt;
+</ab>
+ <p>Just plain comment, with trailing spaces on the line:</p>
+ <p>Code:</p>
+ <ab type='codeblock '>
+&lt;hr /&gt;
+</ab>
+ <p>Hr’s:</p>
+ <milestone unit="undefined" type="separator" rendition="line" />
+</div>
+<div type="level1">
+ <head>Inline Markup</head>
+ <p>This is <hi rendition="simple:italic">emphasized</hi>, and so
+ <hi rendition="simple:italic">is this</hi>.</p>
+ <p>This is <hi rendition="simple:bold">strong</hi>, and so
+ <hi rendition="simple:bold">is this</hi>.</p>
+ <p>An <hi rendition="simple:italic"><ref target="/url">emphasized
+ link</ref></hi>.</p>
+ <p><hi rendition="simple:bold"><hi rendition="simple:italic">This is strong
+ and em.</hi></hi></p>
+ <p>So is
+ <hi rendition="simple:bold"><hi rendition="simple:italic">this</hi></hi>
+ word.</p>
+ <p><hi rendition="simple:bold"><hi rendition="simple:italic">This is strong
+ and em.</hi></hi></p>
+ <p>So is
+ <hi rendition="simple:bold"><hi rendition="simple:italic">this</hi></hi>
+ word.</p>
+ <p>This is code: <seg type="code">&gt;</seg>, <seg type="code">$</seg>,
+ <seg type="code">\</seg>, <seg type="code">\$</seg>,
+ <seg type="code">&lt;html&gt;</seg>.</p>
+ <p><hi rendition="simple:strikethrough">This is
+ <hi rendition="simple:italic">strikeout</hi>.</hi></p>
+ <p>Superscripts: a<hi rendition="simple:superscript">bc</hi>d
+ a<hi rendition="simple:superscript"><hi rendition="simple:italic">hello</hi></hi>
+ a<hi rendition="simple:superscript">hello there</hi>.</p>
+ <p>Subscripts: H<hi rendition="simple:subscript">2</hi>O,
+ H<hi rendition="simple:subscript">23</hi>O,
+ H<hi rendition="simple:subscript">many of them</hi>O.</p>
+ <p>These should not be superscripts or subscripts, because of the unescaped
+ spaces: a^b c^d, a~b c~d.</p>
+ <milestone unit="undefined" type="separator" rendition="line" />
+</div>
+<div type="level1">
+ <head>Smart quotes, ellipses, dashes</head>
+ <p><quote>Hello,</quote> said the spider. <quote><quote>Shelob</quote> is my
+ name.</quote></p>
+ <p><quote>A</quote>, <quote>B</quote>, and <quote>C</quote> are letters.</p>
+ <p><quote>Oak,</quote> <quote>elm,</quote> and <quote>beech</quote> are
+ names of trees. So is <quote>pine.</quote></p>
+ <p><quote>He said, <quote>I want to go.</quote></quote> Were you alive in
+ the 70’s?</p>
+ <p>Here is some quoted <quote><seg type="code">code</seg></quote> and a
+ <quote><ref target="http://example.com/?foo=1&amp;bar=2">quoted
+ link</ref></quote>.</p>
+ <p>Some dashes: one—two — three—four — five.</p>
+ <p>Dashes between numbers: 5–7, 255–66, 1987–1999.</p>
+ <p>Ellipses…and…and….</p>
+ <milestone unit="undefined" type="separator" rendition="line" />
+</div>
+<div type="level1">
+ <head>LaTeX</head>
+ <list type="unordered">
+ <item>
+ <p></p>
+ </item>
+ <item>
+ <p><formula notation="TeX">2+2=4</formula></p>
+ </item>
+ <item>
+ <p><formula notation="TeX">x \in y</formula></p>
+ </item>
+ <item>
+ <p><formula notation="TeX">\alpha \wedge \omega</formula></p>
+ </item>
+ <item>
+ <p><formula notation="TeX">223</formula></p>
+ </item>
+ <item>
+ <p><formula notation="TeX">p</formula>-Tree</p>
+ </item>
+ <item>
+ <p>Here’s some display math: <figure type="math">
+ <formula notation="TeX">\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</formula>
+ </figure></p>
+ </item>
+ <item>
+ <p>Here’s one that has a line break in it:
+ <formula notation="TeX">\alpha + \omega \times x^2</formula>.</p>
+ </item>
+ </list>
+ <p>These shouldn’t be math:</p>
+ <list type="unordered">
+ <item>
+ <p>To get the famous equation, write
+ <seg type="code">$e = mc^2$</seg>.</p>
+ </item>
+ <item>
+ <p>$22,000 is a <hi rendition="simple:italic">lot</hi> of money. So is
+ $34,000. (It worked if <quote>lot</quote> is emphasized.)</p>
+ </item>
+ <item>
+ <p>Shoes ($20) and socks ($5).</p>
+ </item>
+ <item>
+ <p>Escaped <seg type="code">$</seg>: $73
+ <hi rendition="simple:italic">this should be emphasized</hi> 23$.</p>
+ </item>
+ </list>
+ <p>Here’s a LaTeX table:</p>
+ <milestone unit="undefined" type="separator" rendition="line" />
+</div>
+<div type="level1">
+ <head>Special Characters</head>
+ <p>Here is some unicode:</p>
+ <list type="unordered">
+ <item>
+ <p>I hat: Î</p>
+ </item>
+ <item>
+ <p>o umlaut: ö</p>
+ </item>
+ <item>
+ <p>section: §</p>
+ </item>
+ <item>
+ <p>set membership: ∈</p>
+ </item>
+ <item>
+ <p>copyright: ©</p>
+ </item>
+ </list>
+ <p>AT&amp;T has an ampersand in their name.</p>
+ <p>AT&amp;T is another way to write it.</p>
+ <p>This &amp; that.</p>
+ <p>4 &lt; 5.</p>
+ <p>6 &gt; 5.</p>
+ <p>Backslash: \</p>
+ <p>Backtick: `</p>
+ <p>Asterisk: *</p>
+ <p>Underscore: _</p>
+ <p>Left brace: {</p>
+ <p>Right brace: }</p>
+ <p>Left bracket: [</p>
+ <p>Right bracket: ]</p>
+ <p>Left paren: (</p>
+ <p>Right paren: )</p>
+ <p>Greater-than: &gt;</p>
+ <p>Hash: #</p>
+ <p>Period: .</p>
+ <p>Bang: !</p>
+ <p>Plus: +</p>
+ <p>Minus: -</p>
+ <milestone unit="undefined" type="separator" rendition="line" />
+</div>
+<div type="level1">
+ <head>Links</head>
+ <div type="level2">
+ <head>Explicit</head>
+ <p>Just a <ref target="/url/">URL</ref>.</p>
+ <p><ref target="/url/">URL and title</ref>.</p>
+ <p><ref target="/url/">URL and title</ref>.</p>
+ <p><ref target="/url/">URL and title</ref>.</p>
+ <p><ref target="/url/">URL and title</ref></p>
+ <p><ref target="/url/">URL and title</ref></p>
+ <p><ref target="/url/with_underscore">with_underscore</ref></p>
+ <p>Email link (nobody@nowhere.net)</p>
+ <p><ref target="">Empty</ref>.</p>
+ </div>
+ <div type="level2">
+ <head>Reference</head>
+ <p>Foo <ref target="/url/">bar</ref>.</p>
+ <p>Foo <ref target="/url/">bar</ref>.</p>
+ <p>Foo <ref target="/url/">bar</ref>.</p>
+ <p>With <ref target="/url/">embedded [brackets]</ref>.</p>
+ <p><ref target="/url/">b</ref> by itself should be a link.</p>
+ <p>Indented <ref target="/url">once</ref>.</p>
+ <p>Indented <ref target="/url">twice</ref>.</p>
+ <p>Indented <ref target="/url">thrice</ref>.</p>
+ <p>This should [not][] be a link.</p>
+ <ab type='codeblock '>
+[not]: /url
+</ab>
+ <p>Foo <ref target="/url/">bar</ref>.</p>
+ <p>Foo <ref target="/url/">biz</ref>.</p>
+ </div>
+ <div type="level2">
+ <head>With ampersands</head>
+ <p>Here’s a <ref target="http://example.com/?foo=1&amp;bar=2">link with an
+ ampersand in the URL</ref>.</p>
+ <p>Here’s a link with an amersand in the link text:
+ <ref target="http://att.com/">AT&amp;T</ref>.</p>
+ <p>Here’s an <ref target="/script?foo=1&amp;bar=2">inline link</ref>.</p>
+ <p>Here’s an <ref target="/script?foo=1&amp;bar=2">inline link in pointy
+ braces</ref>.</p>
+ </div>
+ <div type="level2">
+ <head>Autolinks</head>
+ <p>With an ampersand:
+ <ref target="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</ref></p>
+ <list type="unordered">
+ <item>
+ <p>In a list?</p>
+ </item>
+ <item>
+ <p><ref target="http://example.com/">http://example.com/</ref></p>
+ </item>
+ <item>
+ <p>It should.</p>
+ </item>
+ </list>
+ <p>An e-mail address: nobody@nowhere.net</p>
+ <quote>
+ <p>Blockquoted:
+ <ref target="http://example.com/">http://example.com/</ref></p>
+ </quote>
+ <p>Auto-links should not occur here:
+ <seg type="code">&lt;http://example.com/&gt;</seg></p>
+ <ab type='codeblock '>
+or here: &lt;http://example.com/&gt;
+</ab>
+ <milestone unit="undefined" type="separator" rendition="line" />
+ </div>
+</div>
+<div type="level1">
+ <head>Images</head>
+ <p>From <quote>Voyage dans la Lune</quote> by Georges Melies (1902):</p>
+ <p><figure>
+ <head>lalune</head>
+ <graphic url="lalune.jpg" />
+ <figDesc>fig:Voyage dans la Lune</figDesc>
+ </figure></p>
+ <p>Here is a movie <figure>
+ <head>movie</head>
+ <graphic url="movie.jpg" />
+ </figure> icon.</p>
+ <milestone unit="undefined" type="separator" rendition="line" />
+</div>
+<div type="level1">
+ <head>Footnotes</head>
+ <p>Here is a footnote reference,<note>
+ <p>Here is the footnote. It can go anywhere after the footnote reference.
+ It need not be placed at the end of the document.</p>
+ </note> and another.<note>
+ <p>Here’s the long note. This one contains multiple blocks.</p>
+ <p>Subsequent blocks are indented to show that they belong to the footnote
+ (as with list items).</p>
+ <ab type='codeblock '>
+ { &lt;code&gt; }
+</ab>
+ <p>If you want, you can indent every line, but you can also be lazy and
+ just indent the first line of each block.</p>
+ </note> This should <hi rendition="simple:italic">not</hi> be a footnote
+ reference, because it contains a space.[^my note] Here is an inline
+ note.<note>
+ <p>This is <hi rendition="simple:italic">easier</hi> to type. Inline notes
+ may contain <ref target="http://google.com">links</ref> and
+ <seg type="code">]</seg> verbatim characters, as well as [bracketed
+ text].</p>
+ </note></p>
+ <quote>
+ <p>Notes can go in quotes.<note>
+ <p>In quote.</p>
+ </note></p>
+ </quote>
+ <list type="ordered:arabic">
+ <item>
+ <p>And in list items.<note>
+ <p>In list.</p>
+ </note></p>
+ </item>
+ </list>
+ <p>This paragraph should not be part of the note, as it is not indented.</p>
+</div>
+</body>
+</text>
+</TEI>
diff --git a/test/writer.texinfo b/test/writer.texinfo
new file mode 100644
index 000000000..ca87da1a9
--- /dev/null
+++ b/test/writer.texinfo
@@ -0,0 +1,1061 @@
+\input texinfo
+@documentencoding UTF-8
+
+@macro textstrikeout{text}
+~~\text\~~
+@end macro
+
+@macro textsubscript{text}
+@iftex
+@textsubscript{\text\}
+@end iftex
+@ifnottex
+_@{\text\@}
+@end ifnottex
+@end macro
+
+@macro textsuperscript{text}
+@iftex
+@textsuperscript{\text\}
+@end iftex
+@ifnottex
+^@{\text\@}
+@end ifnottex
+@end macro
+
+@ifnottex
+@paragraphindent 0
+@end ifnottex
+@titlepage
+@title Pandoc Test Suite
+@author John MacFarlane
+@author Anonymous
+July 17, 2006
+@end titlepage
+
+@node Top
+@top Pandoc Test Suite
+
+This is a set of tests for pandoc. Most of them are adapted from John Gruber's
+markdown test suite.
+
+@iftex
+@bigskip@hrule@bigskip
+@end iftex
+@ifnottex
+------------------------------------------------------------------------
+@end ifnottex
+@menu
+* Headers::
+* Level 1::
+* Paragraphs::
+* Block Quotes::
+* Code Blocks::
+* Lists::
+* Definition Lists::
+* HTML Blocks::
+* Inline Markup::
+* Smart quotes ellipses dashes::
+* LaTeX::
+* Special Characters::
+* Links::
+* Images::
+* Footnotes::
+@end menu
+
+@node Headers
+@chapter Headers
+@anchor{#headers}
+@menu
+* Level 2 with an embedded link::
+@end menu
+
+@node Level 2 with an embedded link
+@section Level 2 with an @uref{/url,embedded link}
+@anchor{#level-2-with-an-embedded-link}
+@menu
+* Level 3 with emphasis::
+@end menu
+
+@node Level 3 with emphasis
+@subsection Level 3 with @emph{emphasis}
+@anchor{#level-3-with-emphasis}
+@menu
+* Level 4::
+@end menu
+
+@node Level 4
+@subsubsection Level 4
+@anchor{#level-4}
+Level 5
+
+@node Level 1
+@chapter Level 1
+@anchor{#level-1}
+@menu
+* Level 2 with emphasis::
+* Level 2::
+@end menu
+
+@node Level 2 with emphasis
+@section Level 2 with @emph{emphasis}
+@anchor{#level-2-with-emphasis}
+@menu
+* Level 3::
+@end menu
+
+@node Level 3
+@subsection Level 3
+@anchor{#level-3}
+with no blank line
+
+@node Level 2
+@section Level 2
+@anchor{#level-2}
+with no blank line
+
+@iftex
+@bigskip@hrule@bigskip
+@end iftex
+@ifnottex
+------------------------------------------------------------------------
+@end ifnottex
+
+@node Paragraphs
+@chapter Paragraphs
+@anchor{#paragraphs}
+Here's a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item.
+Because a hard-wrapped line in the middle of a paragraph looked like a list
+item.
+
+Here's one with a bullet. * criminey.
+
+There should be a hard line break@*
+here.
+
+@iftex
+@bigskip@hrule@bigskip
+@end iftex
+@ifnottex
+------------------------------------------------------------------------
+@end ifnottex
+
+@node Block Quotes
+@chapter Block Quotes
+@anchor{#block-quotes}
+E-mail style:
+
+@quotation
+This is a block quote. It is pretty short.
+@end quotation
+@quotation
+Code in a block quote:
+
+@verbatim
+sub status {
+ print "working";
+}
+@end verbatim
+
+A list:
+
+@enumerate
+@item
+item one
+@item
+item two
+@end enumerate
+
+Nested block quotes:
+
+@quotation
+nested
+@end quotation
+@quotation
+nested
+@end quotation
+@end quotation
+This should not be a block quote: 2 > 1.
+
+And a following paragraph.
+
+@iftex
+@bigskip@hrule@bigskip
+@end iftex
+@ifnottex
+------------------------------------------------------------------------
+@end ifnottex
+
+@node Code Blocks
+@chapter Code Blocks
+@anchor{#code-blocks}
+Code:
+
+@verbatim
+---- (should be four hyphens)
+
+sub status {
+ print "working";
+}
+
+this code block is indented by one tab
+@end verbatim
+
+And:
+
+@verbatim
+ this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \> \[ \{
+@end verbatim
+
+@iftex
+@bigskip@hrule@bigskip
+@end iftex
+@ifnottex
+------------------------------------------------------------------------
+@end ifnottex
+
+@node Lists
+@chapter Lists
+@anchor{#lists}
+@menu
+* Unordered::
+* Ordered::
+* Nested::
+* Tabs and spaces::
+* Fancy list markers::
+@end menu
+
+@node Unordered
+@section Unordered
+@anchor{#unordered}
+Asterisks tight:
+
+@itemize
+@item
+asterisk 1
+@item
+asterisk 2
+@item
+asterisk 3
+@end itemize
+
+Asterisks loose:
+
+@itemize
+@item
+asterisk 1
+
+@item
+asterisk 2
+
+@item
+asterisk 3
+
+@end itemize
+
+Pluses tight:
+
+@itemize
+@item
+Plus 1
+@item
+Plus 2
+@item
+Plus 3
+@end itemize
+
+Pluses loose:
+
+@itemize
+@item
+Plus 1
+
+@item
+Plus 2
+
+@item
+Plus 3
+
+@end itemize
+
+Minuses tight:
+
+@itemize
+@item
+Minus 1
+@item
+Minus 2
+@item
+Minus 3
+@end itemize
+
+Minuses loose:
+
+@itemize
+@item
+Minus 1
+
+@item
+Minus 2
+
+@item
+Minus 3
+
+@end itemize
+
+@node Ordered
+@section Ordered
+@anchor{#ordered}
+Tight:
+
+@enumerate
+@item
+First
+@item
+Second
+@item
+Third
+@end enumerate
+
+and:
+
+@enumerate
+@item
+One
+@item
+Two
+@item
+Three
+@end enumerate
+
+Loose using tabs:
+
+@enumerate
+@item
+First
+
+@item
+Second
+
+@item
+Third
+
+@end enumerate
+
+and using spaces:
+
+@enumerate
+@item
+One
+
+@item
+Two
+
+@item
+Three
+
+@end enumerate
+
+Multiple paragraphs:
+
+@enumerate
+@item
+Item 1, graf one.
+
+Item 1. graf two. The quick brown fox jumped over the lazy dog's back.
+
+@item
+Item 2.
+
+@item
+Item 3.
+
+@end enumerate
+
+@node Nested
+@section Nested
+@anchor{#nested}
+@itemize
+@item
+Tab
+@itemize
+@item
+Tab
+@itemize
+@item
+Tab
+@end itemize
+
+@end itemize
+
+@end itemize
+
+Here's another:
+
+@enumerate
+@item
+First
+@item
+Second:
+@itemize
+@item
+Fee
+@item
+Fie
+@item
+Foe
+@end itemize
+
+@item
+Third
+@end enumerate
+
+Same thing but with paragraphs:
+
+@enumerate
+@item
+First
+
+@item
+Second:
+
+@itemize
+@item
+Fee
+@item
+Fie
+@item
+Foe
+@end itemize
+
+@item
+Third
+
+@end enumerate
+
+@node Tabs and spaces
+@section Tabs and spaces
+@anchor{#tabs-and-spaces}
+@itemize
+@item
+this is a list item indented with tabs
+
+@item
+this is a list item indented with spaces
+
+@itemize
+@item
+this is an example list item indented with tabs
+
+@item
+this is an example list item indented with spaces
+
+@end itemize
+
+@end itemize
+
+@node Fancy list markers
+@section Fancy list markers
+@anchor{#fancy-list-markers}
+@enumerate 2
+@item
+begins with 2
+@item
+and now 3
+
+with a continuation
+
+@enumerate 4
+@item
+sublist with roman numerals, starting with 4
+@item
+more items
+@enumerate A
+@item
+a subsublist
+@item
+a subsublist
+@end enumerate
+
+@end enumerate
+
+@end enumerate
+
+Nesting:
+
+@enumerate A
+@item
+Upper Alpha
+@enumerate
+@item
+Upper Roman.
+@enumerate 6
+@item
+Decimal start with 6
+@enumerate c
+@item
+Lower alpha with paren
+@end enumerate
+
+@end enumerate
+
+@end enumerate
+
+@end enumerate
+
+Autonumbering:
+
+@enumerate
+@item
+Autonumber.
+@item
+More.
+@enumerate
+@item
+Nested.
+@end enumerate
+
+@end enumerate
+
+Should not be a list item:
+
+M.A.@ 2007
+
+B. Williams
+
+@iftex
+@bigskip@hrule@bigskip
+@end iftex
+@ifnottex
+------------------------------------------------------------------------
+@end ifnottex
+
+@node Definition Lists
+@chapter Definition Lists
+@anchor{#definition-lists}
+Tight using spaces:
+
+@table @asis
+@item apple
+
+red fruit
+@item orange
+
+orange fruit
+@item banana
+
+yellow fruit
+@end table
+
+Tight using tabs:
+
+@table @asis
+@item apple
+
+red fruit
+@item orange
+
+orange fruit
+@item banana
+
+yellow fruit
+@end table
+
+Loose:
+
+@table @asis
+@item apple
+
+red fruit
+
+@item orange
+
+orange fruit
+
+@item banana
+
+yellow fruit
+
+@end table
+
+Multiple blocks with italics:
+
+@table @asis
+@item @emph{apple}
+
+red fruit
+
+contains seeds, crisp, pleasant to taste
+
+@item @emph{orange}
+
+orange fruit
+
+@verbatim
+{ orange code block }
+@end verbatim
+
+@quotation
+orange block quote
+@end quotation
+@end table
+
+Multiple definitions, tight:
+
+@table @asis
+@item apple
+
+red fruit
+computer
+@item orange
+
+orange fruit
+bank
+@end table
+
+Multiple definitions, loose:
+
+@table @asis
+@item apple
+
+red fruit
+
+computer
+
+@item orange
+
+orange fruit
+
+bank
+
+@end table
+
+Blank line after term, indented marker, alternate markers:
+
+@table @asis
+@item apple
+
+red fruit
+
+computer
+
+@item orange
+
+orange fruit
+
+@enumerate
+@item
+sublist
+@item
+sublist
+@end enumerate
+
+@end table
+
+@node HTML Blocks
+@chapter HTML Blocks
+@anchor{#html-blocks}
+Simple block on one line:
+
+foo
+And nested without indentation:
+
+foo
+bar
+Interpreted markdown in a table:
+
+This is @emph{emphasized}
+And this is @strong{strong}
+Here's a simple block:
+
+foo
+This should be a code block, though:
+
+@verbatim
+<div>
+ foo
+</div>
+@end verbatim
+
+As should this:
+
+@verbatim
+<div>foo</div>
+@end verbatim
+
+Now, nested:
+
+foo
+This should just be an HTML comment:
+
+Multiline:
+
+Code block:
+
+@verbatim
+<!-- Comment -->
+@end verbatim
+
+Just plain comment, with trailing spaces on the line:
+
+Code:
+
+@verbatim
+<hr />
+@end verbatim
+
+Hr's:
+
+@iftex
+@bigskip@hrule@bigskip
+@end iftex
+@ifnottex
+------------------------------------------------------------------------
+@end ifnottex
+
+@node Inline Markup
+@chapter Inline Markup
+@anchor{#inline-markup}
+This is @emph{emphasized}, and so @emph{is this}.
+
+This is @strong{strong}, and so @strong{is this}.
+
+An @emph{@uref{/url,emphasized link}}.
+
+@strong{@emph{This is strong and em.}}
+
+So is @strong{@emph{this}} word.
+
+@strong{@emph{This is strong and em.}}
+
+So is @strong{@emph{this}} word.
+
+This is code: @code{>}, @code{$}, @code{\}, @code{\$}, @code{<html>}.
+
+@textstrikeout{This is @emph{strikeout}.}
+
+Superscripts: a@textsuperscript{bc}d a@textsuperscript{@emph{hello}}
+a@textsuperscript{hello@ there}.
+
+Subscripts: H@textsubscript{2}O, H@textsubscript{23}O,
+H@textsubscript{many@ of@ them}O.
+
+These should not be superscripts or subscripts, because of the unescaped
+spaces: a^b c^d, a~b c~d.
+
+@iftex
+@bigskip@hrule@bigskip
+@end iftex
+@ifnottex
+------------------------------------------------------------------------
+@end ifnottex
+
+@node Smart quotes ellipses dashes
+@chapter Smart quotes, ellipses, dashes
+@anchor{#smart-quotes-ellipses-dashes}
+``Hello,'' said the spider. ```Shelob' is my name.''
+
+`A', `B', and `C' are letters.
+
+`Oak,' `elm,' and `beech' are names of trees. So is `pine.'
+
+`He said, ``I want to go.''' Were you alive in the 70's?
+
+Here is some quoted `@code{code}' and a
+``@uref{http://example.com/?foo=1&bar=2,quoted link}''.
+
+Some dashes: one---two --- three---four --- five.
+
+Dashes between numbers: 5--7, 255--66, 1987--1999.
+
+Ellipses@dots{}and@dots{}and@dots{}.
+
+@iftex
+@bigskip@hrule@bigskip
+@end iftex
+@ifnottex
+------------------------------------------------------------------------
+@end ifnottex
+
+@node LaTeX
+@chapter LaTeX
+@anchor{#latex}
+@itemize
+@item
+@tex
+\cite[22-23]{smith.1899}
+@end tex
+@item
+@math{2+2=4}
+@item
+@math{x \in y}
+@item
+@math{\alpha \wedge \omega}
+@item
+@math{223}
+@item
+@math{p}-Tree
+@item
+Here's some display math:
+@math{\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}}
+@item
+Here's one that has a line break in it: @math{\alpha + \omega \times x^2}.
+@end itemize
+
+These shouldn't be math:
+
+@itemize
+@item
+To get the famous equation, write @code{$e = mc^2$}.
+@item
+$22,000 is a @emph{lot} of money. So is $34,000. (It worked if ``lot'' is
+emphasized.)
+@item
+Shoes ($20) and socks ($5).
+@item
+Escaped @code{$}: $73 @emph{this should be emphasized} 23$.
+@end itemize
+
+Here's a LaTeX table:
+
+@tex
+\begin{tabular}{|l|l|}\hline
+Animal & Number \\ \hline
+Dog & 2 \\
+Cat & 1 \\ \hline
+\end{tabular}
+@end tex
+@iftex
+@bigskip@hrule@bigskip
+@end iftex
+@ifnottex
+------------------------------------------------------------------------
+@end ifnottex
+
+@node Special Characters
+@chapter Special Characters
+@anchor{#special-characters}
+Here is some unicode:
+
+@itemize
+@item
+I hat: Î
+@item
+o umlaut: ö
+@item
+section: §
+@item
+set membership: ∈
+@item
+copyright: ©
+@end itemize
+
+AT&T has an ampersand in their name.
+
+AT&T is another way to write it.
+
+This & that.
+
+4 < 5.
+
+6 > 5.
+
+Backslash: \
+
+Backtick: `
+
+Asterisk: *
+
+Underscore: _
+
+Left brace: @{
+
+Right brace: @}
+
+Left bracket: [
+
+Right bracket: ]
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: >
+
+Hash: #
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+@iftex
+@bigskip@hrule@bigskip
+@end iftex
+@ifnottex
+------------------------------------------------------------------------
+@end ifnottex
+
+@node Links
+@chapter Links
+@anchor{#links}
+@menu
+* Explicit::
+* Reference::
+* With ampersands::
+* Autolinks::
+@end menu
+
+@node Explicit
+@section Explicit
+@anchor{#explicit}
+Just a @uref{/url/,URL}.
+
+@uref{/url/,URL and title}.
+
+@uref{/url/,URL and title}.
+
+@uref{/url/,URL and title}.
+
+@uref{/url/,URL and title}
+
+@uref{/url/,URL and title}
+
+@uref{/url/with_underscore,with_underscore}
+
+@uref{mailto:nobody@@nowhere.net,Email link}
+
+@uref{,Empty}.
+
+@node Reference
+@section Reference
+@anchor{#reference}
+Foo @uref{/url/,bar}.
+
+Foo @uref{/url/,bar}.
+
+Foo @uref{/url/,bar}.
+
+With @uref{/url/,embedded [brackets]}.
+
+@uref{/url/,b} by itself should be a link.
+
+Indented @uref{/url,once}.
+
+Indented @uref{/url,twice}.
+
+Indented @uref{/url,thrice}.
+
+This should [not][] be a link.
+
+@verbatim
+[not]: /url
+@end verbatim
+
+Foo @uref{/url/,bar}.
+
+Foo @uref{/url/,biz}.
+
+@node With ampersands
+@section With ampersands
+@anchor{#with-ampersands}
+Here's a @uref{http://example.com/?foo=1&bar=2,link with an ampersand in the
+URL}.
+
+Here's a link with an amersand in the link text: @uref{http://att.com/,AT&T}.
+
+Here's an @uref{/script?foo=1&bar=2,inline link}.
+
+Here's an @uref{/script?foo=1&bar=2,inline link in pointy braces}.
+
+@node Autolinks
+@section Autolinks
+@anchor{#autolinks}
+With an ampersand: @url{http://example.com/?foo=1&bar=2}
+
+@itemize
+@item
+In a list?
+@item
+@url{http://example.com/}
+@item
+It should.
+@end itemize
+
+An e-mail address: @uref{mailto:nobody@@nowhere.net,nobody@@nowhere.net}
+
+@quotation
+Blockquoted: @url{http://example.com/}
+@end quotation
+Auto-links should not occur here: @code{<http://example.com/>}
+
+@verbatim
+or here: <http://example.com/>
+@end verbatim
+
+@iftex
+@bigskip@hrule@bigskip
+@end iftex
+@ifnottex
+------------------------------------------------------------------------
+@end ifnottex
+
+@node Images
+@chapter Images
+@anchor{#images}
+From ``Voyage dans la Lune'' by Georges Melies (1902):
+
+@float
+@image{lalune,,,lalune,jpg}
+@caption{lalune}
+@end float
+
+Here is a movie @image{movie,,,movie,jpg} icon.
+
+@iftex
+@bigskip@hrule@bigskip
+@end iftex
+@ifnottex
+------------------------------------------------------------------------
+@end ifnottex
+
+@node Footnotes
+@chapter Footnotes
+@anchor{#footnotes}
+Here is a footnote reference,@footnote{Here is the footnote. It can go
+anywhere after the footnote reference. It need not be placed at the end of the
+document.} and another.@footnote{Here's the long note. This one contains
+multiple blocks.
+
+Subsequent blocks are indented to show that they belong to the footnote (as
+with list items).
+
+@verbatim
+ { <code> }
+@end verbatim
+
+If you want, you can indent every line, but you can also be lazy and just
+indent the first line of each block.} This should @emph{not} be a footnote
+reference, because it contains a space.[^my note] Here is an inline
+note.@footnote{This is @emph{easier} to type. Inline notes may contain
+@uref{http://google.com,links} and @code{]} verbatim characters, as well as
+[bracketed text].}
+
+@quotation
+Notes can go in quotes.@footnote{In quote.}
+@end quotation
+@enumerate
+@item
+And in list items.@footnote{In list.}
+@end enumerate
+
+This paragraph should not be part of the note, as it is not indented.
+
+@bye
diff --git a/test/writer.textile b/test/writer.textile
new file mode 100644
index 000000000..293418ed5
--- /dev/null
+++ b/test/writer.textile
@@ -0,0 +1,723 @@
+This is a set of tests for pandoc. Most of them are adapted from John Gruber's markdown test suite.
+
+<hr />
+
+h1(#headers). Headers
+
+h2(#level-2-with-an-embedded-link). Level 2 with an "embedded link":/url
+
+h3(#level-3-with-emphasis). Level 3 with _emphasis_
+
+h4(#level-4). Level 4
+
+h5(#level-5). Level 5
+
+h1(#level-1). Level 1
+
+h2(#level-2-with-emphasis). Level 2 with _emphasis_
+
+h3(#level-3). Level 3
+
+with no blank line
+
+h2(#level-2). Level 2
+
+with no blank line
+
+<hr />
+
+h1(#paragraphs). Paragraphs
+
+Here's a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard&#45;wrapped line in the middle of a paragraph looked like a list item.
+
+Here's one with a bullet. &#42; criminey.
+
+There should be a hard line break
+here.
+
+<hr />
+
+h1(#block-quotes). Block Quotes
+
+E&#45;mail style:
+
+bq. This is a block quote. It is pretty short.
+
+
+
+<blockquote>
+
+Code in a block quote:
+
+bc. sub status {
+ print "working";
+}
+
+
+A list:
+
+# item one
+# item two
+
+Nested block quotes:
+
+bq. nested
+
+
+
+bq. nested
+
+
+
+</blockquote>
+
+This should not be a block quote: 2 &gt; 1.
+
+And a following paragraph.
+
+<hr />
+
+h1(#code-blocks). Code Blocks
+
+Code:
+
+<pre>
+---- (should be four hyphens)
+
+sub status {
+ print &quot;working&quot;;
+}
+
+this code block is indented by one tab
+</pre>
+
+And:
+
+<pre>
+ this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \&gt; \[ \{
+</pre>
+
+<hr />
+
+h1(#lists). Lists
+
+h2(#unordered). Unordered
+
+Asterisks tight:
+
+* asterisk 1
+* asterisk 2
+* asterisk 3
+
+Asterisks loose:
+
+* asterisk 1
+* asterisk 2
+* asterisk 3
+
+Pluses tight:
+
+* Plus 1
+* Plus 2
+* Plus 3
+
+Pluses loose:
+
+* Plus 1
+* Plus 2
+* Plus 3
+
+Minuses tight:
+
+* Minus 1
+* Minus 2
+* Minus 3
+
+Minuses loose:
+
+* Minus 1
+* Minus 2
+* Minus 3
+
+h2(#ordered). Ordered
+
+Tight:
+
+# First
+# Second
+# Third
+
+and:
+
+# One
+# Two
+# Three
+
+Loose using tabs:
+
+# First
+# Second
+# Third
+
+and using spaces:
+
+# One
+# Two
+# Three
+
+Multiple paragraphs:
+
+<ol style="list-style-type: decimal;">
+<li><p>Item 1, graf one.</p>
+<p>Item 1. graf two. The quick brown fox jumped over the lazy dog's back.</p></li>
+<li><p>Item 2.</p></li>
+<li><p>Item 3.</p></li>
+</ol>
+
+h2(#nested). Nested
+
+* Tab
+** Tab
+*** Tab
+
+Here's another:
+
+# First
+# Second:
+#* Fee
+#* Fie
+#* Foe
+# Third
+
+Same thing but with paragraphs:
+
+# First
+# Second:
+#* Fee
+#* Fie
+#* Foe
+# Third
+
+h2(#tabs-and-spaces). Tabs and spaces
+
+* this is a list item indented with tabs
+* this is a list item indented with spaces
+** this is an example list item indented with tabs
+** this is an example list item indented with spaces
+
+h2(#fancy-list-markers). Fancy list markers
+
+<ol start="2" style="list-style-type: decimal;">
+<li>begins with 2</li>
+<li><p>and now 3</p>
+<p>with a continuation</p>
+<ol start="4" style="list-style-type: lower-roman;">
+<li>sublist with roman numerals, starting with 4</li>
+<li>more items
+<ol style="list-style-type: upper-alpha;">
+<li>a subsublist</li>
+<li>a subsublist</li>
+</ol>
+</li>
+</ol>
+</li>
+</ol>
+
+Nesting:
+
+<ol style="list-style-type: upper-alpha;">
+<li>Upper Alpha
+<ol style="list-style-type: upper-roman;">
+<li>Upper Roman.
+<ol start="6" style="list-style-type: decimal;">
+<li>Decimal start with 6
+<ol start="3" style="list-style-type: lower-alpha;">
+<li>Lower alpha with paren</li>
+</ol>
+</li>
+</ol>
+</li>
+</ol>
+</li>
+</ol>
+
+Autonumbering:
+
+# Autonumber.
+# More.
+## Nested.
+
+Should not be a list item:
+
+M.A. 2007
+
+B. Williams
+
+<hr />
+
+h1(#definition-lists). Definition Lists
+
+Tight using spaces:
+
+<dl>
+<dt>apple</dt>
+<dd>red fruit</dd>
+<dt>orange</dt>
+<dd>orange fruit</dd>
+<dt>banana</dt>
+<dd>yellow fruit</dd>
+</dl>
+
+Tight using tabs:
+
+<dl>
+<dt>apple</dt>
+<dd>red fruit</dd>
+<dt>orange</dt>
+<dd>orange fruit</dd>
+<dt>banana</dt>
+<dd>yellow fruit</dd>
+</dl>
+
+Loose:
+
+<dl>
+<dt>apple</dt>
+<dd><p>red fruit</p></dd>
+<dt>orange</dt>
+<dd><p>orange fruit</p></dd>
+<dt>banana</dt>
+<dd><p>yellow fruit</p></dd>
+</dl>
+
+Multiple blocks with italics:
+
+<dl>
+<dt>_apple_</dt>
+<dd><p>red fruit</p>
+<p>contains seeds, crisp, pleasant to taste</p></dd>
+<dt>_orange_</dt>
+<dd><p>orange fruit</p>
+bc. { orange code block }
+
+
+bq. <p>orange block quote</p>
+
+</dd>
+</dl>
+
+Multiple definitions, tight:
+
+<dl>
+<dt>apple</dt>
+<dd>red fruit</dd>
+<dd>computer</dd>
+<dt>orange</dt>
+<dd>orange fruit</dd>
+<dd>bank</dd>
+</dl>
+
+Multiple definitions, loose:
+
+<dl>
+<dt>apple</dt>
+<dd><p>red fruit</p></dd>
+<dd><p>computer</p></dd>
+<dt>orange</dt>
+<dd><p>orange fruit</p></dd>
+<dd><p>bank</p></dd>
+</dl>
+
+Blank line after term, indented marker, alternate markers:
+
+<dl>
+<dt>apple</dt>
+<dd><p>red fruit</p></dd>
+<dd><p>computer</p></dd>
+<dt>orange</dt>
+<dd><p>orange fruit</p>
+<ol style="list-style-type: decimal;">
+<li>sublist</li>
+<li>sublist</li>
+</ol>
+</dd>
+</dl>
+
+h1(#html-blocks). HTML Blocks
+
+Simple block on one line:
+
+<div>
+
+foo
+
+</div>
+
+And nested without indentation:
+
+<div>
+
+<div>
+
+<div>
+
+foo
+
+
+</div>
+
+
+</div>
+
+<div>
+
+bar
+
+</div>
+
+
+</div>
+
+Interpreted markdown in a table:
+
+<table>
+<tr>
+<td>
+This is _emphasized_
+</td>
+<td>
+And this is *strong*
+</td>
+</tr>
+</table>
+<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
+Here's a simple block:
+
+<div>
+
+foo
+
+
+</div>
+
+This should be a code block, though:
+
+bc. <div>
+ foo
+</div>
+
+
+As should this:
+
+bc. <div>foo</div>
+
+
+Now, nested:
+
+<div>
+
+<div>
+
+<div>
+
+foo
+
+</div>
+
+
+</div>
+
+
+</div>
+
+This should just be an HTML comment:
+
+<!-- Comment -->
+Multiline:
+
+<!--
+Blah
+Blah
+-->
+<!--
+ This is another comment.
+-->
+Code block:
+
+bc. <!-- Comment -->
+
+
+Just plain comment, with trailing spaces on the line:
+
+<!-- foo -->
+Code:
+
+bc. <hr />
+
+
+Hr's:
+
+<hr>
+<hr />
+<hr />
+<hr>
+<hr />
+<hr />
+<hr class="foo" id="bar" />
+<hr class="foo" id="bar" />
+<hr class="foo" id="bar">
+<hr />
+
+h1(#inline-markup). Inline Markup
+
+This is _emphasized_, and so _is this_.
+
+This is *strong*, and so *is this*.
+
+An _"emphasized link":/url_.
+
+*_This is strong and em._*
+
+So is *_this_* word.
+
+*_This is strong and em._*
+
+So is *_this_* word.
+
+This is code: @>@, @$@, @\@, @\$@, @<html>@.
+
+-This is _strikeout_.-
+
+Superscripts: a[^bc^]d a[^_hello_^] a[^hello there^].
+
+Subscripts: H[~2~]O, H[~23~]O, H[~many of them~]O.
+
+These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.
+
+<hr />
+
+h1(#smart-quotes-ellipses-dashes). Smart quotes, ellipses, dashes
+
+"Hello," said the spider. "'Shelob' is my name."
+
+'A', 'B', and 'C' are letters.
+
+'Oak,' 'elm,' and 'beech' are names of trees. So is 'pine.'
+
+'He said, "I want to go."' Were you alive in the 70's?
+
+Here is some quoted '@code@' and a ""quoted link":http://example.com/?foo=1&bar=2".
+
+Some dashes: one -- two -- three -- four -- five.
+
+Dashes between numbers: 5 - 7, 255 - 66, 1987 - 1999.
+
+Ellipses...and...and....
+
+<hr />
+
+h1(#latex). LaTeX
+
+*
+* <span class="math">2+2=4</math>
+* <span class="math">x \in y</math>
+* <span class="math">\alpha \wedge \omega</math>
+* <span class="math">223</math>
+* <span class="math">p</math>&#45;Tree
+* Here's some display math: <span class="math">\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</math>
+* Here's one that has a line break in it: <span class="math">\alpha + \omega \times x^2</math>.
+
+These shouldn't be math:
+
+* To get the famous equation, write @$e = mc^2$@.
+* $22,000 is a _lot_ of money. So is $34,000. (It worked if "lot" is emphasized.)
+* Shoes ($20) and socks ($5).
+* Escaped @$@: $73 _this should be emphasized_ 23$.
+
+Here's a LaTeX table:
+
+
+<hr />
+
+h1(#special-characters). Special Characters
+
+Here is some unicode:
+
+* I hat: Î
+* o umlaut: ö
+* section: §
+* set membership: ∈
+* copyright: ©
+
+AT&amp;T has an ampersand in their name.
+
+AT&amp;T is another way to write it.
+
+This &amp; that.
+
+4 &lt; 5.
+
+6 &gt; 5.
+
+Backslash: \
+
+Backtick: `
+
+Asterisk: &#42;
+
+Underscore: &#95;
+
+Left brace: {
+
+Right brace: }
+
+Left bracket: [
+
+Right bracket: ]
+
+Left paren: (
+
+Right paren: )
+
+Greater&#45;than: &gt;
+
+Hash: #
+
+Period: .
+
+Bang: !
+
+Plus: &#43;
+
+Minus: &#45;
+
+<hr />
+
+h1(#links). Links
+
+h2(#explicit). Explicit
+
+Just a "URL":/url/.
+
+"URL and title":/url/.
+
+"URL and title":/url/.
+
+"URL and title":/url/.
+
+"URL and title":/url/
+
+"URL and title":/url/
+
+"with&#95;underscore":/url/with_underscore
+
+"Email link":mailto:nobody@nowhere.net
+
+"Empty":.
+
+h2(#reference). Reference
+
+Foo "bar":/url/.
+
+Foo "bar":/url/.
+
+Foo "bar":/url/.
+
+With "embedded [brackets]":/url/.
+
+"b":/url/ by itself should be a link.
+
+Indented "once":/url.
+
+Indented "twice":/url.
+
+Indented "thrice":/url.
+
+This should [not][] be a link.
+
+bc. [not]: /url
+
+
+Foo "bar":/url/.
+
+Foo "biz":/url/.
+
+h2(#with-ampersands). With ampersands
+
+Here's a "link with an ampersand in the URL":http://example.com/?foo=1&bar=2.
+
+Here's a link with an amersand in the link text: "AT&amp;T":http://att.com/.
+
+Here's an "inline link":/script?foo=1&bar=2.
+
+Here's an "inline link in pointy braces":/script?foo=1&bar=2.
+
+h2(#autolinks). Autolinks
+
+With an ampersand: "$":http://example.com/?foo=1&bar=2
+
+* In a list?
+* "$":http://example.com/
+* It should.
+
+An e&#45;mail address: "nobody&#64;nowhere.net":mailto:nobody@nowhere.net
+
+bq. Blockquoted: "$":http://example.com/
+
+
+
+Auto&#45;links should not occur here: @<http://example.com/>@
+
+bc. or here: <http://example.com/>
+
+
+<hr />
+
+h1(#images). Images
+
+From "Voyage dans la Lune" by Georges Melies (1902):
+
+!lalune.jpg(Voyage dans la Lune)!
+lalune
+
+Here is a movie !movie.jpg(movie)! icon.
+
+<hr />
+
+h1(#footnotes). Footnotes
+
+Here is a footnote reference,[1] and another.[2] This should _not_ be a footnote reference, because it contains a space.[^my note] Here is an inline note.[3]
+
+bq. Notes can go in quotes.[4]
+
+
+
+# And in list items.[5]
+
+This paragraph should not be part of the note, as it is not indented.
+
+
+fn1. Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.
+
+
+fn2. Here's the long note. This one contains multiple blocks.
+
+Subsequent blocks are indented to show that they belong to the footnote (as with list items).
+
+bc. { <code> }
+
+
+If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.
+
+
+fn3. This is _easier_ to type. Inline notes may contain "links":http://google.com and @]@ verbatim characters, as well as [bracketed text].
+
+
+fn4. In quote.
+
+
+fn5. In list.
diff --git a/test/writer.zimwiki b/test/writer.zimwiki
new file mode 100644
index 000000000..7a15bad9d
--- /dev/null
+++ b/test/writer.zimwiki
@@ -0,0 +1,623 @@
+Content-Type: text/x-zim-wiki
+Wiki-Format: zim 0.4
+
+This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite.
+
+
+----
+
+====== Headers ======
+
+===== Level 2 with an embedded link =====
+
+==== Level 3 with emphasis ====
+
+=== Level 4 ===
+
+== Level 5 ==
+
+====== Level 1 ======
+
+===== Level 2 with emphasis =====
+
+==== Level 3 ====
+
+with no blank line
+
+===== Level 2 =====
+
+with no blank line
+
+
+----
+
+====== Paragraphs ======
+
+Here’s a regular paragraph.
+
+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard-wrapped line in the middle of a paragraph looked like a list item.
+
+Here’s one with a bullet. * criminey.
+
+There should be a hard line break
+here.
+
+
+----
+
+====== Block Quotes ======
+
+E-mail style:
+
+> This is a block quote. It is pretty short.
+
+> Code in a block quote:
+>
+> '''
+> sub status {
+> print "working";
+> }
+> '''
+>
+> A list:
+>
+> 1. item one
+> 1. item two
+>
+> Nested block quotes:
+>
+> > nested
+>
+> > nested
+
+This should not be a block quote: 2 > 1.
+
+And a following paragraph.
+
+
+----
+
+====== Code Blocks ======
+
+Code:
+
+'''
+---- (should be four hyphens)
+
+sub status {
+ print "working";
+}
+
+this code block is indented by one tab
+'''
+
+And:
+
+'''
+ this code block is indented by two tabs
+
+These should not be escaped: \$ \\ \> \[ \{
+'''
+
+
+----
+
+====== Lists ======
+
+===== Unordered =====
+
+Asterisks tight:
+
+ * asterisk 1
+ * asterisk 2
+ * asterisk 3
+
+Asterisks loose:
+
+ * asterisk 1
+ * asterisk 2
+ * asterisk 3
+
+Pluses tight:
+
+ * Plus 1
+ * Plus 2
+ * Plus 3
+
+Pluses loose:
+
+ * Plus 1
+ * Plus 2
+ * Plus 3
+
+Minuses tight:
+
+ * Minus 1
+ * Minus 2
+ * Minus 3
+
+Minuses loose:
+
+ * Minus 1
+ * Minus 2
+ * Minus 3
+
+===== Ordered =====
+
+Tight:
+
+ 1. First
+ 1. Second
+ 1. Third
+
+and:
+
+ 1. One
+ 1. Two
+ 1. Three
+
+Loose using tabs:
+
+ 1. First
+ 1. Second
+ 1. Third
+
+and using spaces:
+
+ 1. One
+ 1. Two
+ 1. Three
+
+Multiple paragraphs:
+
+ 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.
+
+===== Nested =====
+
+ * Tab
+ * Tab
+ * Tab
+
+Here’s another:
+
+ 1. First
+ 1. Second:
+ * Fee
+ * Fie
+ * Foe
+ 1. Third
+
+Same thing but with paragraphs:
+
+ 1. First
+ 1. Second:
+ * Fee
+ * Fie
+ * Foe
+ 1. Third
+
+===== Tabs and spaces =====
+
+ * this is a list item indented with tabs
+ * this is a list item indented with spaces
+ * this is an example list item indented with tabs
+ * this is an example list item indented with spaces
+
+===== Fancy list markers =====
+
+ 1. begins with 2
+ 1. and now 3
+with a continuation
+ 1. sublist with roman numerals, starting with 4
+ 1. more items
+ 1. a subsublist
+ 1. a subsublist
+
+Nesting:
+
+ 1. Upper Alpha
+ 1. Upper Roman.
+ 1. Decimal start with 6
+ 1. Lower alpha with paren
+
+Autonumbering:
+
+ 1. Autonumber.
+ 1. More.
+ 1. Nested.
+
+Should not be a list item:
+
+M.A. 2007
+
+B. Williams
+
+
+----
+
+====== Definition Lists ======
+
+Tight using spaces:
+
+* **apple** red fruit
+* **orange** orange fruit
+* **banana** yellow fruit
+Tight using tabs:
+
+* **apple** red fruit
+* **orange** orange fruit
+* **banana** yellow fruit
+Loose:
+
+* **apple** red fruit
+
+* **orange** orange fruit
+
+* **banana** yellow fruit
+
+Multiple blocks with italics:
+
+* **//apple//** red fruit
+
+contains seeds, crisp, pleasant to taste
+
+* **//orange//** orange fruit
+
+'''
+{ orange code block }
+'''
+
+> orange block quote
+
+Multiple definitions, tight:
+
+* **apple** red fruitcomputer
+* **orange** orange fruitbank
+Multiple definitions, loose:
+
+* **apple** red fruit
+computer
+
+* **orange** orange fruit
+bank
+
+Blank line after term, indented marker, alternate markers:
+
+* **apple** red fruit
+computer
+
+* **orange** orange fruit
+
+ 1. sublist
+ 1. sublist
+
+====== HTML Blocks ======
+
+Simple block on one line:
+
+foo
+
+And nested without indentation:
+
+foo
+
+
+
+bar
+
+
+Interpreted markdown in a table:
+
+
+
+
+This is //emphasized//
+
+
+And this is **strong**
+
+
+
+
+Here’s a simple block:
+
+foo
+
+
+This should be a code block, though:
+
+'''
+<div>
+ foo
+</div>
+'''
+
+As should this:
+
+'''
+<div>foo</div>
+'''
+
+Now, nested:
+
+foo
+
+
+
+This should just be an HTML comment:
+
+
+Multiline:
+
+
+
+Code block:
+
+'''
+<!-- Comment -->
+'''
+
+Just plain comment, with trailing spaces on the line:
+
+
+Code:
+
+'''
+<hr />
+'''
+
+Hr’s:
+
+
+
+
+
+
+
+
+
+
+
+----
+
+====== Inline Markup ======
+
+This is //emphasized//, and so //is this//.
+
+This is **strong**, and so **is this**.
+
+An //[[url|emphasized link]]//.
+
+**//This is strong and em.//**
+
+So is **//this//** word.
+
+**//This is strong and em.//**
+
+So is **//this//** word.
+
+This is code: ''>'', ''$'', ''\'', ''\$'', ''<html>''.
+
+~~This is //strikeout//.~~
+
+Superscripts: a^{bc}d a^{//hello//} a^{hello there}.
+
+Subscripts: H_{2}O, H_{23}O, H_{many of them}O.
+
+These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.
+
+
+----
+
+====== Smart quotes, ellipses, dashes ======
+
+“Hello,” said the spider. “‘Shelob’ is my name.”
+
+‘A’, ‘B’, and ‘C’ are letters.
+
+‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’
+
+‘He said, “I want to go.”’ Were you alive in the 70’s?
+
+Here is some quoted ‘''code''’ and a “[[http://example.com/?foo=1&bar=2|quoted link]]”.
+
+Some dashes: one—two — three—four — five.
+
+Dashes between numbers: 5–7, 255–66, 1987–1999.
+
+Ellipses…and…and….
+
+
+----
+
+====== LaTeX ======
+
+ *
+ * $2+2=4$
+ * $x \in y$
+ * $\alpha \wedge \omega$
+ * $223$
+ * $p$-Tree
+ * Here’s some display math: $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
+ * Here’s one that has a line break in it: $\alpha + \omega \times x^2$.
+
+These shouldn’t be math:
+
+ * To get the famous equation, write ''$e = mc^2$''.
+ * $22,000 is a //lot// of money. So is $34,000. (It worked if “lot” is emphasized.)
+ * Shoes ($20) and socks ($5).
+ * Escaped ''$'': $73 //this should be emphasized// 23$.
+
+Here’s a LaTeX table:
+
+
+
+----
+
+====== Special Characters ======
+
+Here is some unicode:
+
+ * I hat: Î
+ * o umlaut: ö
+ * section: §
+ * set membership: ∈
+ * copyright: ©
+
+AT&T has an ampersand in their name.
+
+AT&T is another way to write it.
+
+This & that.
+
+4 < 5.
+
+6 > 5.
+
+Backslash: \
+
+Backtick: `
+
+Asterisk: *
+
+Underscore: _
+
+Left brace: {
+
+Right brace: }
+
+Left bracket: [
+
+Right bracket: ]
+
+Left paren: (
+
+Right paren: )
+
+Greater-than: >
+
+Hash: #
+
+Period: .
+
+Bang: !
+
+Plus: +
+
+Minus: -
+
+
+----
+
+====== Links ======
+
+===== Explicit =====
+
+Just a [[url/|URL]].
+
+[[url/|URL and title]].
+
+[[url/|URL and title]].
+
+[[url/|URL and title]].
+
+[[url/|URL and title]]
+
+[[url/|URL and title]]
+
+[[url/with_underscore|with_underscore]]
+
+[[mailto:nobody@nowhere.net|Email link]]
+
+[[|Empty]].
+
+===== Reference =====
+
+Foo [[url/|bar]].
+
+Foo [[url/|bar]].
+
+Foo [[url/|bar]].
+
+With [[url/|embedded [brackets]]].
+
+[[url/|b]] by itself should be a link.
+
+Indented [[url|once]].
+
+Indented [[url|twice]].
+
+Indented [[url|thrice]].
+
+This should [not][] be a link.
+
+'''
+[not]: /url
+'''
+
+Foo [[url/|bar]].
+
+Foo [[url/|biz]].
+
+===== With ampersands =====
+
+Here’s a [[http://example.com/?foo=1&bar=2|link with an ampersand in the URL]].
+
+Here’s a link with an amersand in the link text: [[http://att.com/|AT&T]].
+
+Here’s an [[script?foo=1&bar=2|inline link]].
+
+Here’s an [[script?foo=1&bar=2|inline link in pointy braces]].
+
+===== Autolinks =====
+
+With an ampersand: http://example.com/?foo=1&bar=2
+
+ * In a list?
+ * http://example.com/
+ * It should.
+
+An e-mail address: <nobody@nowhere.net>
+
+> Blockquoted: http://example.com/
+
+Auto-links should not occur here: ''<http://example.com/>''
+
+'''
+or here: <http://example.com/>
+'''
+
+
+----
+
+====== Images ======
+
+From “Voyage dans la Lune” by Georges Melies (1902):
+
+{{:lalune.jpg|Voyage dans la Lune lalune}}
+
+Here is a movie {{:movie.jpg|movie}} icon.
+
+
+----
+
+====== Footnotes ======
+
+Here is a footnote reference, **{Note:** Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.**}** and another. **{Note:** Here’s the long note. This one contains multiple blocks.
+
+Subsequent blocks are indented to show that they belong to the footnote (as with list items).
+
+'''
+ { <code> }
+'''
+
+If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.**}** This should //not// be a footnote reference, because it contains a space.[^my note] Here is an inline note. **{Note:** This is //easier// to type. Inline notes may contain [[http://google.com|links]] and '']'' verbatim characters, as well as [bracketed text].**}**
+
+> Notes can go in quotes. **{Note:** In quote.**}**
+
+ 1. And in list items. **{Note:** In list.**}**
+
+This paragraph should not be part of the note, as it is not indented.
diff --git a/test/writers-lang-and-dir.context b/test/writers-lang-and-dir.context
new file mode 100644
index 000000000..66dab9ead
--- /dev/null
+++ b/test/writers-lang-and-dir.context
@@ -0,0 +1,109 @@
+% Enable hyperlinks
+\setupinteraction
+ [state=start,
+ style=,
+ color=,
+ contrastcolor=]
+% make chapter, section bookmarks visible when opening document
+\placebookmarks[chapter, section, subsection, subsubsection, subsubsubsection, subsubsubsubsection][chapter, section]
+\setupinteractionscreen[option=bookmark]
+\setuptagging[state=start]
+
+% use microtypography
+\definefontfeature[default][default][script=latn, protrusion=quality, expansion=quality, itlc=yes, textitalics=yes, onum=yes, pnum=yes]
+\definefontfeature[smallcaps][script=latn, protrusion=quality, expansion=quality, smcp=yes, onum=yes, pnum=yes]
+\setupalign[hz,hanging]
+\setupitaliccorrection[global, always]
+\setupbodyfontenvironment[default][em=italic] % use italic as em, not slanted
+\usemodule[simplefonts]
+\setmainfontfallback[DejaVu Serif][range={greekandcoptic, greekextended}, force=yes, rscale=auto]
+\setupwhitespace[medium]
+
+\setuphead[chapter] [style=\tfd,header=empty]
+\setuphead[section] [style=\tfc]
+\setuphead[subsection] [style=\tfb]
+\setuphead[subsubsection] [style=\bf]
+\setuphead[subsubsubsection] [style=\sc]
+\setuphead[subsubsubsubsection][style=\it]
+
+\setuphead[chapter, section, subsection, subsubsection, subsubsubsection, subsubsubsubsection][number=no]
+
+\definedescription
+ [description]
+ [headstyle=bold, style=normal, location=hanging, width=broad, margin=1cm, alternative=hanging]
+
+\setupitemize[autointro] % prevent orphan list intro
+\setupitemize[indentnext=no]
+
+\setupfloat[figure][default={here,nonumber}]
+\setupfloat[table][default={here,nonumber}]
+
+\setupthinrules[width=15em] % width of horizontal rules
+
+
+\starttext
+
+\section[empty-divs-and-spans]{Empty Divs and Spans}
+
+Some text and
+
+div contents
+
+and more text.
+
+Next paragraph with a span and a word-thatincludesaspanright?
+
+\section[directionality]{Directionality}
+
+Some text and
+
+\startalignment[righttoleft]
+rtl div contents
+
+\stopalignment
+
+and more text.
+
+\startalignment[lefttoright]
+and a ltr div. with a {\righttoleft rtl span}.
+
+\stopalignment
+
+Next paragraph with a {\righttoleft rtl span} and a
+word-that-includesa{\lefttoright ltrspan}right?
+
+\section[languages]{Languages}
+
+Some text and
+
+\start\language[de]
+German div contents
+
+\stop
+
+and more text.
+
+Next paragraph with a \start\language[en-gb]British span\stop and a
+word-that-includesa\start\language[de-ch]Swiss German span\stop right?
+
+Some \start\language[es]Spanish text\stop .
+
+\section[combined]{Combined}
+
+Some text and
+
+\start\language[fr]
+\startalignment[righttoleft]
+French rtl div contents
+
+\stopalignment
+\stop
+
+and more text.
+
+Next paragraph with a \start\language[en-gb]{\lefttoright British ltr
+span}\stop and a
+word-that-includesa\start\language[de-ch]{\lefttoright Swiss German ltr
+span}\stop right?
+
+\stoptext
diff --git a/test/writers-lang-and-dir.latex b/test/writers-lang-and-dir.latex
new file mode 100644
index 000000000..1c705399b
--- /dev/null
+++ b/test/writers-lang-and-dir.latex
@@ -0,0 +1,149 @@
+\documentclass[english,]{article}
+\usepackage{lmodern}
+\usepackage{amssymb,amsmath}
+\usepackage{ifxetex,ifluatex}
+\usepackage{fixltx2e} % provides \textsubscript
+\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
+ \usepackage[T1]{fontenc}
+ \usepackage[utf8]{inputenc}
+\else % if luatex or xelatex
+ \usepackage{unicode-math}
+ \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
+\fi
+% use upquote if available, for straight quotes in verbatim environments
+\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
+% use microtype if available
+\IfFileExists{microtype.sty}{%
+\usepackage[]{microtype}
+\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
+}{}
+\PassOptionsToPackage{hyphens}{url} % url is loaded by hyperref
+\usepackage[unicode=true]{hyperref}
+\hypersetup{
+ pdfborder={0 0 0},
+ breaklinks=true}
+\urlstyle{same} % don't use monospace font for urls
+\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
+ \usepackage[shorthands=off,ngerman,british,nswissgerman,spanish,french,main=english]{babel}
+ \newcommand{\textgerman}[2][]{\foreignlanguage{ngerman}{#2}}
+ \newenvironment{german}[2][]{\begin{otherlanguage}{ngerman}}{\end{otherlanguage}}
+ \newcommand{\textenglish}[2][]{\foreignlanguage{british}{#2}}
+ \newenvironment{english}[2][]{\begin{otherlanguage}{british}}{\end{otherlanguage}}
+ \let\oritextspanish\textspanish
+ \AddBabelHook{spanish}{beforeextras}{\renewcommand{\textspanish}{\oritextspanish}}
+ \AddBabelHook{spanish}{afterextras}{\renewcommand{\textspanish}[2][]{\foreignlanguage{spanish}{##2}}}
+ \newcommand{\textfrench}[2][]{\foreignlanguage{french}{#2}}
+ \newenvironment{french}[2][]{\begin{otherlanguage}{french}}{\end{otherlanguage}}
+\else
+ \usepackage{polyglossia}
+ \setmainlanguage[]{english}
+ \setotherlanguage[]{german}
+ \setotherlanguage[variant=british]{english}
+ \setotherlanguage[variant=swiss]{german}
+ \setotherlanguage[]{spanish}
+ \setotherlanguage[]{french}
+\fi
+\IfFileExists{parskip.sty}{%
+\usepackage{parskip}
+}{% else
+\setlength{\parindent}{0pt}
+\setlength{\parskip}{6pt plus 2pt minus 1pt}
+}
+\setlength{\emergencystretch}{3em} % prevent overfull lines
+\providecommand{\tightlist}{%
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
+\setcounter{secnumdepth}{0}
+% Redefines (sub)paragraphs to behave more like sections
+\ifx\paragraph\undefined\else
+\let\oldparagraph\paragraph
+\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
+\fi
+\ifx\subparagraph\undefined\else
+\let\oldsubparagraph\subparagraph
+\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
+\fi
+\ifxetex
+ % load bidi as late as possible as it modifies e.g. graphicx
+ \usepackage{bidi}
+ \fi
+\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
+ \TeXXeTstate=1
+ \newcommand{\RL}[1]{\beginR #1\endR}
+ \newcommand{\LR}[1]{\beginL #1\endL}
+ \newenvironment{RTL}{\beginR}{\endR}
+ \newenvironment{LTR}{\beginL}{\endL}
+\fi
+
+% set default figure placement to htbp
+\makeatletter
+\def\fps@figure{htbp}
+\makeatother
+
+
+\date{}
+
+\begin{document}
+
+\section{Empty Divs and Spans}\label{empty-divs-and-spans}
+
+Some text and
+
+div contents
+
+and more text.
+
+Next paragraph with a {span} and a word-thatincludesa{span}right?
+
+\section{Directionality}\label{directionality}
+
+Some text and
+
+\begin{RTL}
+rtl div contents
+\end{RTL}
+
+and more text.
+
+\begin{LTR}
+and a ltr div. with a \RL{rtl span}.
+\end{LTR}
+
+Next paragraph with a \RL{rtl span} and a
+word-that-includesa\LR{ltrspan}right?
+
+\section{Languages}\label{languages}
+
+Some text and
+
+\begin{german}
+
+German div contents
+
+\end{german}
+
+and more text.
+
+Next paragraph with a \textenglish[variant=british]{British span} and a
+word-that-includesa\textgerman[variant=swiss]{Swiss German span}right?
+
+Some \textspanish{Spanish text}.
+
+\section{Combined}\label{combined}
+
+Some text and
+
+\begin{RTL}
+\begin{french}
+
+French rtl div contents
+
+\end{french}
+\end{RTL}
+
+and more text.
+
+Next paragraph with a \LR{\textenglish[variant=british]{British ltr
+span}} and a word-that-includesa\LR{\textgerman[variant=swiss]{Swiss
+German ltr span}}right?
+
+\end{document}
diff --git a/test/writers-lang-and-dir.native b/test/writers-lang-and-dir.native
new file mode 100644
index 000000000..504bcf350
--- /dev/null
+++ b/test/writers-lang-and-dir.native
@@ -0,0 +1,23 @@
+Pandoc (Meta {unMeta = fromList []})
+[Header 1 ("empty-divs-and-spans",[],[]) [Str "Empty",Space,Str "Divs",Space,Str "and",Space,Str "Spans"]
+,Plain [Str "Some",Space,Str "text",Space,Str "and"]
+,Div ("",[],[]) [Para [Str "div",Space,Str "contents"]]
+,Para [Str "and",Space,Str "more",Space,Str "text."]
+,Para [Str "Next",Space,Str "paragraph",Space,Str "with",Space,Str "a",Space,Span ("",[],[]) [Str "span"],Space,Str "and",Space,Str "a",Space,Str "word-thatincludesa",Span ("",[],[]) [Str "span"],Str "right?"]
+,Header 1 ("directionality",[],[]) [Str "Directionality"]
+,Plain [Str "Some",Space,Str "text",Space,Str "and"]
+,Div ("",[],[("dir","rtl")]) [Para [Str "rtl",Space,Str "div",Space,Str "contents"]]
+,Para [Str "and",Space,Str "more",Space,Str "text."]
+,Div ("",[],[("dir","ltr")]) [Para [Str "and",Space,Str "a",Space,Str "ltr",Space,Str "div.",Space,Str "with",Space,Str "a",Space,Span ("",[],[("dir","rtl")]) [Str "rtl",Space,Str "span"],Str "."]]
+,Para [Str "Next",Space,Str "paragraph",Space,Str "with",Space,Str "a",Space,Span ("",[],[("dir","rtl")]) [Str "rtl",Space,Str "span"],Space,Str "and",Space,Str "a",Space,Str "word-that-includesa",Span ("",[],[("dir","ltr")]) [Str "ltrspan"],Str "right?"]
+,Header 1 ("languages",[],[]) [Str "Languages"]
+,Plain [Str "Some",Space,Str "text",Space,Str "and"]
+,Div ("",[],[("lang","de")]) [Para [Str "German",Space,Str "div",Space,Str "contents"]]
+,Para [Str "and",Space,Str "more",Space,Str "text."]
+,Para [Str "Next",Space,Str "paragraph",Space,Str "with",Space,Str "a",Space,Span ("",[],[("lang","en-GB")]) [Str "British",Space,Str "span"],Space,Str "and",Space,Str "a",Space,Str "word-that-includesa",Span ("",[],[("lang","de-CH")]) [Str "Swiss",Space,Str "German",Space,Str "span"],Str "right?"]
+,Para [Str "Some",Space,Span ("",[],[("lang","es")]) [Str "Spanish",Space,Str "text"],Str "."]
+,Header 1 ("combined",[],[]) [Str "Combined"]
+,Plain [Str "Some",Space,Str "text",Space,Str "and"]
+,Div ("",[],[("lang","fr"),("dir","rtl")]) [Para [Str "French",Space,Str "rtl",Space,Str "div",Space,Str "contents"]]
+,Para [Str "and",Space,Str "more",Space,Str "text."]
+,Para [Str "Next",Space,Str "paragraph",Space,Str "with",Space,Str "a",Space,Span ("",[],[("lang","en-GB"),("dir","ltr")]) [Str "British",Space,Str "ltr",Space,Str "span"],Space,Str "and",Space,Str "a",Space,Str "word-that-includesa",Span ("",[],[("lang","de-CH"),("dir","ltr")]) [Str "Swiss",Space,Str "German",Space,Str "ltr",Space,Str "span"],Str "right?"]]
diff --git a/tools/extract-changes.hs b/tools/extract-changes.hs
new file mode 100644
index 000000000..8c8160c2c
--- /dev/null
+++ b/tools/extract-changes.hs
@@ -0,0 +1,9 @@
+-- Extract changes from latest version in changelog.
+import Text.Pandoc.JSON
+
+main = toJSONFilter extractFirst
+
+extractFirst :: Pandoc -> Pandoc
+extractFirst (Pandoc meta (Para{} : BulletList bs : _)) =
+ Pandoc meta [BulletList bs]
+extractFirst x = x
diff --git a/tools/github-upload.sh b/tools/github-upload.sh
new file mode 100755
index 000000000..875d51831
--- /dev/null
+++ b/tools/github-upload.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+VERSION=$1
+FULLNAME=pandoc-$VERSION
+read -s -p "Token (https://github.com/settings/applications): " TOKEN
+
+curl -H "Authorization: token $TOKEN" \
+ -H "Accept: application/vnd.github.manifold-preview" \
+ -H "Content-Type: application/x-apple-diskimage" \
+ --data-binary @$FULLNAME.pkg.zip \
+ "https://uploads.github.com/repos/jgm/pandoc/releases/$VERSION/assets?name=$FULLNAME.pkg.zip"
+
+curl -H "Authorization: token $TOKEN" \
+ -H "Accept: application/vnd.github.manifold-preview" \
+ -H "Content-Type: application/x-msi" \
+ --data-binary @$FULLNAME.msi \
+ "https://uploads.github.com/repos/jgm/pandoc/releases/$VERSION/assets?name=$FULLNAME.msi"
+
diff --git a/trypandoc/Makefile b/trypandoc/Makefile
new file mode 100644
index 000000000..c486aea3b
--- /dev/null
+++ b/trypandoc/Makefile
@@ -0,0 +1,14 @@
+CGIBIN=/home/website/cgi-bin
+TRYPANDOC=/home/website/html/pandoc/try/
+CGI=${CGIBIN}/trypandoc
+BIN=/home/jgm/.local/bin/trypandoc
+
+install: ${CGI} ${TRYPANDOC}/index.html
+
+${TRYPANDOC}/%: %
+ cp $< $@ && chown website:www-data $@ && chmod a+r $@
+
+${CGI}: ${BIN}
+ cp $< $@ && chown website:www-data $@ && chmod a+rx $@
+
+.PHONY: install
diff --git a/trypandoc/index.html b/trypandoc/index.html
new file mode 100644
index 000000000..d9674793b
--- /dev/null
+++ b/trypandoc/index.html
@@ -0,0 +1,143 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Try pandoc!</title>
+ <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
+ <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
+ <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
+ <script type="text/javascript">
+(function($) { // http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values
+ $.QueryString = (function(a) {
+ if (a == "") return {};
+ var b = {};
+ for (var i = 0; i < a.length; ++i)
+ {
+ var p=a[i].split('=');
+ if (p.length != 2) continue;
+ b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
+ }
+ return b;
+ })(window.location.search.substr(1).split('&'))
+})(jQuery);
+
+function newpage() {
+ var input = $("#text").val();
+ var from = $("#from").val();
+ var to = $("#to").val();
+ var href = window.location.href;
+ window.location.href = href.replace(/([?].*)?$/,"?" + $.param({text: input, from: from, to: to}));
+};
+
+$(document).ready(function() {
+ var text = $.QueryString["text"];
+ $("#text").val(text);
+ var from = $.QueryString["from"] || "markdown";
+ $("#from").val(from);
+ var to = $.QueryString["to"] || "html";
+ $("#to").val(to);
+ if (text && text != "") {
+ $.getJSON("/cgi-bin/trypandoc", { from: from, to: to, text: text },
+ function(res) {
+ $("#results").text(res.html);
+ $("#version").text(res.version);
+ $("#command").text("pandoc --from " + from + " --to " + to);
+ });
+ };
+ $("#convert").click(newpage);
+});
+ </script>
+ <style type="text/css">
+ h1 { margin-bottom: 1em; }
+ body { margin: auto; }
+ textarea { height: auto; width: 100%; font-family: monospace; margin-top: 15px; }
+ div.alert { margin: 1em; }
+ h3 { margin-top: 0; margin-bottom: 0; padding: 0; font-size: 100%; }
+ pre#results { width: 100%; margin-top: 15px; }
+ footer { color: #555; text-align: center; margin: 1em; }
+ p.version { color: #555; }
+ button#convert { vertical-align: bottom; }
+ pre#command { margin-top: 1em; background-color: transparent; border: none; }
+ </style>
+</head>
+<body>
+<div class="container">
+ <div class="row">
+ <div class="col-md-6">
+ <h1>Try <a href="http://pandoc.org">pandoc</a>!</h1>
+ </div>
+ <div class="col-md-6">
+ <pre id="command"></pre>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-md-6">
+ <button class="btn btn-primary btn-xs" id="convert">Convert</button>
+ &nbsp;
+ <label for="from">
+ from
+ </label>
+ <select id="from">
+ <option value="docbook">DocBook</option>
+ <option value="haddock">Haddock markup</option>
+ <option value="html">HTML</option>
+ <option value="latex">LaTeX</option>
+ <option value="markdown" selected>Markdown (pandoc)</option>
+ <option value="markdown_strict">Markdown (strict)</option>
+ <option value="markdown_phpextra">Markdown (PHP Markdown Extra)</option>
+ <option value="markdown_github">Markdown (GitHub)</option>
+ <option value="mediawiki">MediaWiki</option>
+ <option value="markdown_mmd">MultiMarkdown</option>
+ <option value="opml">OPML</option>
+ <option value="org">Org Mode</option>
+ <option value="rst">reStructuredText</option>
+ <option value="textile">Textile</option>
+ <option value="t2t">Txt2Tags</option>
+ </select>
+ <br/>
+ <textarea id="text" maxlength="3000" rows="15"></textarea>
+ </div>
+ <div class="col-md-6">
+ <label for="to">
+ to
+ </label>
+ <select id="to">
+ <option value="asciidoc">AsciiDoc</option>
+ <option value="context">ConTeXt</option>
+ <option value="docbook">DocBook</option>
+ <option value="dokuwiki">DokuWiki</option>
+ <option value="dzslides">DZSlides</option>
+ <option value="man">Groff man</option>
+ <option value="html" selected>HTML</option>
+ <option value="html5">HTML 5</option>
+ <option value="icml">ICML</option>
+ <option value="latex">LaTeX</option>
+ <option value="beamer">LaTeX Beamer</option>
+ <option value="markdown">Markdown (pandoc)</option>
+ <option value="markdown_strict">Markdown (strict)</option>
+ <option value="markdown_phpextra">Markdown (PHP Markdown Extra)</option>
+ <option value="markdown_github">Markdown (GitHub)</option>
+ <option value="markdown_mmd">MultiMarkdown</option>
+ <option value="rst">reStructuredText</option>
+ <option value="textile">Textile</option>
+ <option value="mediawiki">MediaWiki</option>
+ <option value="org">Org Mode</option>
+ <option value="opendocument">OpenDocument</option>
+ <option value="opml">OPML</option>
+ <option value="rtf">RTF</option>
+ <option value="S5">S5</option>
+ <option value="slideous">Slideous</option>
+ <option value="slidy">Slidy</option>
+ <option value="texinfo">Texinfo</option>
+ </select>
+ <br/>
+ <pre id="results"></pre>
+ </div>
+ </div>
+</div>
+<footer>
+ <p class="version">pandoc <span id="version"></span></p>
+ <p>&copy; 2013&ndash;2015 <a href="http://johnmacfarlane.net">John MacFarlane</a></p>
+</footer>
+</body>
+</html>
diff --git a/trypandoc/trypandoc.hs b/trypandoc/trypandoc.hs
new file mode 100644
index 000000000..2fcfe35e7
--- /dev/null
+++ b/trypandoc/trypandoc.hs
@@ -0,0 +1,101 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Main where
+import Network.Wai.Handler.CGI
+import Network.Wai
+import Control.Applicative ((<$>))
+import Data.Maybe (mapMaybe, fromMaybe)
+import Network.HTTP.Types.Status (status200)
+import Network.HTTP.Types.Header (hContentType)
+import Network.HTTP.Types.URI (queryToQueryText)
+import Text.Pandoc
+import Text.Pandoc.Error (PandocError)
+import Text.Pandoc.Shared (tabFilter)
+import Data.Aeson
+import qualified Data.Text as T
+import Data.Text (Text)
+
+main :: IO ()
+main = run app
+
+app :: Application
+app req respond = do
+ let query = queryToQueryText $ queryString req
+ let getParam x = maybe (error $ T.unpack x ++ " paramater not set")
+ return $ lookup x query
+ text <- getParam "text" >>= checkLength . fromMaybe T.empty
+ fromFormat <- fromMaybe "" <$> getParam "from"
+ toFormat <- fromMaybe "" <$> getParam "to"
+ reader <- maybe (error $ "could not find reader for " ++ T.unpack fromFormat) return
+ $ lookup fromFormat fromFormats
+ let writer = maybe (error $ "could not find writer for " ++ T.unpack toFormat) id
+ $ lookup toFormat toFormats
+ let result = case reader $ tabFilter 4 $ T.unpack text of
+ Right doc -> T.pack $ writer doc
+ Left err -> error (show err)
+ let output = encode $ object [ T.pack "html" .= result
+ , T.pack "name" .=
+ if fromFormat == "markdown_strict"
+ then T.pack "pandoc (strict)"
+ else T.pack "pandoc"
+ , T.pack "version" .= pandocVersion]
+ respond $ responseLBS status200 [(hContentType,"text/json; charset=UTF-8")] output
+
+checkLength :: Text -> IO Text
+checkLength t =
+ if T.length t > 10000
+ then error "exceeds length limit of 10,000 characters"
+ else return t
+
+writerOpts :: WriterOptions
+writerOpts = def { writerReferenceLinks = True,
+ writerEmailObfuscation = NoObfuscation,
+ writerHTMLMathMethod = MathJax "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML",
+ writerHighlight = True }
+
+readerOpts :: ReaderOptions
+readerOpts = def { readerParseRaw = True,
+ readerSmart = True }
+
+fromFormats :: [(Text, String -> Either PandocError Pandoc)]
+fromFormats = [
+ ("native" , readNative)
+ ,("json" , Text.Pandoc.readJSON readerOpts)
+ ,("markdown" , readMarkdown readerOpts)
+ ,("markdown_strict" , readMarkdown readerOpts{
+ readerExtensions = strictExtensions,
+ readerSmart = False })
+ ,("markdown_phpextra" , readMarkdown readerOpts{
+ readerExtensions = phpMarkdownExtraExtensions })
+ ,("markdown_github" , readMarkdown readerOpts{
+ readerExtensions = githubMarkdownExtensions })
+ ,("markdown_mmd", readMarkdown readerOpts{
+ readerExtensions = multimarkdownExtensions })
+ ,("rst" , readRST readerOpts)
+ ,("mediawiki" , readMediaWiki readerOpts)
+ ,("docbook" , readDocBook readerOpts)
+ ,("opml" , readOPML readerOpts)
+ ,("t2t" , readTxt2TagsNoMacros readerOpts)
+ ,("org" , readOrg readerOpts)
+ ,("textile" , readTextile readerOpts) -- TODO : textile+lhs
+ ,("html" , readHtml readerOpts)
+ ,("latex" , readLaTeX readerOpts)
+ ,("haddock" , readHaddock readerOpts)
+ ]
+
+toFormats :: [(Text, Pandoc -> String)]
+toFormats = mapMaybe (\(x,y) ->
+ case y of
+ PureStringWriter w -> Just (T.pack x, w writerOpts{
+ writerExtensions =
+ case x of
+ "markdown_strict" -> strictExtensions
+ "markdown_phpextra" -> phpMarkdownExtraExtensions
+ "markdown_mmd" -> multimarkdownExtensions
+ "markdown_github" -> githubMarkdownExtensions
+ _ -> pandocExtensions
+ })
+ _ ->
+ case x of
+ "rtf" -> Just (T.pack x, writeRTF writerOpts)
+ _ -> Nothing) writers
+
diff --git a/windows/AdvancedWelcomeEulaDlg_Custom.wxs b/windows/AdvancedWelcomeEulaDlg_Custom.wxs
new file mode 100644
index 000000000..61e6d8e00
--- /dev/null
+++ b/windows/AdvancedWelcomeEulaDlg_Custom.wxs
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ <copyright file="AdvancedWelcomeEulaDlg.wxs" company="Outercurve Foundation">
+ Copyright (c) 2004, Outercurve Foundation.
+ This software is released under Microsoft Reciprocal License (MS-RL).
+ The license and further copyright text can be found in the file
+ LICENSE.TXT at the root directory of the distribution.
+ </copyright>
+-->
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
+ <Fragment>
+ <UI>
+ <Dialog Id="AdvancedWelcomeEulaDlg_Custom" Width="370" Height="270" Title="!(loc.AdvancedWelcomeEulaDlg_Title)">
+
+ <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.AdvancedWelcomeEulaDlgBannerBitmap)" />
+ <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
+ <Control Id="Title" Type="Text" X="20" Y="10" Width="300" Height="24" Transparent="yes" NoPrefix="yes" Text="!(loc.AdvancedWelcomeEulaDlgTitle)" />
+
+ <Control Id="LicenseAcceptedCheckBox" Type="CheckBox" X="20" Y="140" Width="226" Height="19" CheckBoxValue="1" Property="LicenseAccepted" Text="!(loc.WelcomeEulaDlgLicenseAcceptedCheckBox)" />
+
+ <Control Id="ScopeGroupBox" Type="GroupBox" X="20" Y="155" Height="70" Width="330" />
+
+ <Control Id="AllUsersCheckBox" Type="CheckBox" X="88" Y="200" Width="226" Height="18" CheckBoxValue="1" Property="ALLUSERS" Text="!(loc.InstallScopeDlgPerMachine)">
+ <Condition Action="enable">LicenseAccepted AND (WixUISupportPerUser = 1)</Condition>
+ <Condition Action="disable">(NOT LicenseAccepted) OR (WixUISupportPerUser = 0)</Condition>
+ </Control>
+
+ <Control Id="PerUserDescription" Type="Text" X="30" Y="167" Width="300" Height="36" NoPrefix="yes" Text="!(loc.InstallScopeDlgPerUserDescription)">
+ <Condition Action="hide">ALLUSERS</Condition>
+ <Condition Action="show">NOT (ALLUSERS = 1)</Condition>
+ <Condition Action="disable">NOT LicenseAccepted</Condition>
+ <Condition Action="enable">LicenseAccepted</Condition>
+ </Control>
+
+ <Control Id="PerMachineDescription" Type="Text" X="30" Y="167" Width="300" Height="36" Hidden="yes" NoPrefix="yes" Text="!(loc.InstallScopeDlgPerMachineDescription)">
+ <Condition Action="hide">NOT (ALLUSERS = 1)</Condition>
+ <Condition Action="show">ALLUSERS = 1</Condition>
+ <Condition Action="disable">NOT LicenseAccepted</Condition>
+ <Condition Action="enable">LicenseAccepted</Condition>
+ </Control>
+
+ <Control Id="Print" Type="PushButton" X="88" Y="243" Width="56" Height="17" Text="!(loc.WixUIPrint)">
+ <Publish Event="DoAction" Value="WixUIPrintEula">1</Publish>
+ </Control>
+
+ <Control Id="Advanced" Type="PushButton" X="156" Y="243" Width="56" Height="17" Text="!(loc.AdvancedWelcomeEulaDlgAdvanced)">
+ <Condition Action="disable">NOT LicenseAccepted OR NOT (ALLUSERS = 1)</Condition>
+ <Condition Action="enable">(LicenseAccepted = "1") AND (ALLUSERS = 1)</Condition>
+ </Control>
+
+ <Control Id="Install" Type="PushButton" ElevationShield="yes" X="212" Y="243" Width="80" Height="17" Default="yes" Text="!(loc.AdvancedWelcomeEulaDlgInstall)" Hidden="yes">
+ <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">!(wix.WixUICostingPopupOptOut) OR CostingComplete = 1</Publish>
+ <Publish Event="EndDialog" Value="Return"><![CDATA[OutOfDiskSpace <> 1]]></Publish>
+ <Publish Event="SpawnDialog" Value="OutOfRbDiskDlg">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)</Publish>
+ <Publish Event="EndDialog" Value="Return">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
+ <Publish Event="EnableRollback" Value="False">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
+ <Publish Event="SpawnDialog" Value="OutOfDiskDlg">(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")</Publish>
+ <Condition Action="disable">NOT LicenseAccepted</Condition>
+ <Condition Action="enable">LicenseAccepted = "1"</Condition>
+ <Condition Action="show">ALLUSERS = 1</Condition>
+ <Condition Action="hide">NOT (ALLUSERS = 1)</Condition>
+ </Control>
+ <Control Id="InstallNoShield" Type="PushButton" ElevationShield="no" X="212" Y="243" Width="80" Height="17" Default="yes" Text="!(loc.AdvancedWelcomeEulaDlgInstall)" Hidden="yes">
+ <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">!(wix.WixUICostingPopupOptOut) OR CostingComplete = 1</Publish>
+ <Publish Event="EndDialog" Value="Return"><![CDATA[OutOfDiskSpace <> 1]]></Publish>
+ <Publish Event="SpawnDialog" Value="OutOfRbDiskDlg">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)</Publish>
+ <Publish Event="EndDialog" Value="Return">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
+ <Publish Event="EnableRollback" Value="False">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST="D"</Publish>
+ <Publish Event="SpawnDialog" Value="OutOfDiskDlg">(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")</Publish>
+ <Condition Action="disable">NOT LicenseAccepted</Condition>
+ <Condition Action="enable">LicenseAccepted = "1"</Condition>
+ <Condition Action="show">NOT (ALLUSERS = 1)</Condition>
+ <Condition Action="hide">ALLUSERS = 1</Condition>
+ </Control>
+
+ <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
+ <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
+ </Control>
+ <Control Id="LicenseText" Type="ScrollableText" X="20" Y="55" Width="330" Height="80" Sunken="yes" TabSkip="no">
+ <!--<Text SourceFile="!(wix.WixUILicenseRtf=$(var.licenseRtf))" />-->
+ <Text SourceFile="!(loc.LicenseRtf)" />
+ </Control>
+ </Dialog>
+ </UI>
+
+ <InstallUISequence>
+ <Show Dialog="AdvancedWelcomeEulaDlg_Custom" Before="ProgressDlg">NOT Installed</Show>
+ </InstallUISequence>
+ </Fragment>
+</Wix> \ No newline at end of file
diff --git a/windows/Pandoc-en-us.wxl b/windows/Pandoc-en-us.wxl
new file mode 100644
index 000000000..1981f24e8
--- /dev/null
+++ b/windows/Pandoc-en-us.wxl
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<WixLocalization Culture="en-us" Codepage="1252" xmlns="http://schemas.microsoft.com/wix/2006/localization">
+ <String Id="Language">1033</String>
+ <!-- Supported language and codepage codes can be found here: http://www.tramontana.co.hu/wix/lesson2.php#2.4 -->
+
+ <String Id="LicenseRtf" Overridable="yes">COPYING.rtf</String>
+
+ <String Id="ExitDialogText">[ProductName] was installed in
+
+[APPLICATIONFOLDER].
+
+You may need to restart Cmd/Powershell windows before using it.</String>
+
+</WixLocalization> \ No newline at end of file
diff --git a/windows/WixUI_Advanced_Custom.wxs b/windows/WixUI_Advanced_Custom.wxs
new file mode 100644
index 000000000..6f85d9961
--- /dev/null
+++ b/windows/WixUI_Advanced_Custom.wxs
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?if $(sys.BUILDARCH)=x64?>
+<?define ProgFilesFolder="ProgramFiles64Folder"?>
+<?else?>
+<?define ProgFilesFolder="ProgramFilesFolder"?>
+<?endif?>
+<!--
+ <copyright file="WixUI_Advanced_Custom.wxs" company="Outercurve Foundation">
+ Copyright (c) 2004, Outercurve Foundation.
+ This software is released under Microsoft Reciprocal License (MS-RL).
+ The license and further copyright text can be found in the file
+ LICENSE.TXT at the root directory of the distribution.
+ </copyright>
+-->
+
+<!--
+WixUI_Advanced_Custom offers a two-click install (EULA checkbox and Install button)
+and offers an Advanced button that lets users choose per-machine or per-user
+installs, install path, and features.
+
+WiX variables used:
+ - WixUISupportPerMachine
+ - WixUISupportPerUser
+
+Todo:
+ - Clicking Install doesn't work! - APPLICATIONFOLDER isn't set; need to accept another "incoming" property.
+ - Replace this dialog set UI fragment with the UI extension.
+ = This set is still in active development.
+ = Future releases are likely to be incompatible.
+ = Future releases are likely to be much easier to use.
+ = Use at your own risk.
+
+-->
+
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
+ <Fragment>
+ <WixVariable Id="WixUISupportPerUser" Value="1" Overridable="yes" />
+ <WixVariable Id="WixUISupportPerMachine" Value="1" Overridable="yes" />
+
+ <PropertyRef Id="ApplicationFolderName" />
+
+ <CustomAction Id="WixSetDefaultPerUserFolder2" Property="WixPerUserFolder" Value="[LocalAppDataFolder][ApplicationFolderName]" Execute="immediate" />
+ <CustomAction Id="WixSetDefaultPerMachineFolder2" Property="WixPerMachineFolder" Value="[$(var.ProgFilesFolder)][ApplicationFolderName]" Execute="immediate" />
+ <CustomAction Id="WixSetPerUserFolder2" Property="APPLICATIONFOLDER" Value="[WixPerUserFolder]" Execute="immediate" />
+ <CustomAction Id="WixSetPerMachineFolder2" Property="APPLICATIONFOLDER" Value="[WixPerMachineFolder]" Execute="immediate" />
+
+ <InstallExecuteSequence>
+ <Custom Action="WixSetDefaultPerUserFolder2" Before="CostFinalize" />
+ <Custom Action="WixSetDefaultPerMachineFolder2" After="WixSetDefaultPerUserFolder2" />
+ <Custom Action="WixSetPerUserFolder2" After="WixSetDefaultPerMachineFolder2">ACTION="INSTALL" AND APPLICATIONFOLDER="" AND (ALLUSERS="" OR (ALLUSERS=2 AND (NOT Privileged)))</Custom>
+ <Custom Action="WixSetPerMachineFolder2" After="WixSetPerUserFolder2">ACTION="INSTALL" AND APPLICATIONFOLDER="" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))</Custom>
+ </InstallExecuteSequence>
+ <InstallUISequence>
+ <Custom Action="WixSetDefaultPerUserFolder2" Before="CostFinalize" />
+ <Custom Action="WixSetDefaultPerMachineFolder2" After="WixSetDefaultPerUserFolder2" />
+ <Custom Action="WixSetPerUserFolder2" After="WixSetDefaultPerMachineFolder2">ACTION="INSTALL" AND APPLICATIONFOLDER="" AND (ALLUSERS="" OR (ALLUSERS=2 AND (NOT Privileged)))</Custom>
+ <Custom Action="WixSetPerMachineFolder2" After="WixSetPerUserFolder2">ACTION="INSTALL" AND APPLICATIONFOLDER="" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))</Custom>
+ </InstallUISequence>
+
+ <UI Id="WixUI_Advanced_Custom">
+ <TextStyle Id="WixUI_Font_Normal" FaceName="!(loc.Advanced_Font_FaceName)" Size="!(loc.Advanced_Font_Normal_Size)" />
+ <TextStyle Id="WixUI_Font_Bigger" FaceName="!(loc.Advanced_Font_FaceName)" Size="!(loc.Advanced_Font_Bigger_Size)" />
+ <TextStyle Id="WixUI_Font_Title" FaceName="!(loc.Advanced_Font_FaceName)" Size="!(loc.Advanced_Font_Title_Size)" Bold="yes" />
+ <TextStyle Id="WixUI_Font_Emphasized" FaceName="!(loc.Advanced_Font_FaceName)" Size="!(loc.Advanced_Font_Emphasized_Size)" Bold="yes" />
+
+ <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
+ <Property Id="WixUI_Mode" Value="Advanced" />
+
+ <DialogRef Id="BrowseDlg" />
+ <DialogRef Id="DiskCostDlg" />
+ <DialogRef Id="ErrorDlg" />
+ <DialogRef Id="FatalError" />
+ <DialogRef Id="FilesInUse" />
+ <DialogRef Id="MsiRMFilesInUse" />
+ <DialogRef Id="PrepareDlg" />
+ <DialogRef Id="ProgressDlg" />
+ <DialogRef Id="ResumeDlg" />
+ <DialogRef Id="UserExit" />
+ <DialogRef Id="WelcomeDlg"/>
+
+ <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
+
+ <Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="1">1</Publish>
+ <Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="2"><![CDATA[WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
+
+ <!--<Publish Dialog="AdvancedWelcomeEulaDlg_Custom" Control="Advanced" Event="NewDialog" Value="InstallScopeDlg" Order="1">!(wix.WixUISupportPerMachine) AND !(wix.WixUISupportPerUser)</Publish>-->
+ <!--<Publish Dialog="AdvancedWelcomeEulaDlg_Custom" Control="Advanced" Event="NewDialog" Value="FeaturesDlg" Order="2">NOT !(wix.WixUISupportPerMachine)</Publish>-->
+ <!--<Publish Dialog="AdvancedWelcomeEulaDlg_Custom" Control="Advanced" Event="NewDialog" Value="InstallDirDlg" Order="3">!(wix.WixUISupportPerMachine) AND NOT !(wix.WixUISupportPerUser)</Publish>-->
+
+ <Publish Dialog="AdvancedWelcomeEulaDlg_Custom" Control="Advanced" Property="WixAppFolder" Value="WixPerMachineFolder" Order="1">ALLUSERS = 1</Publish>
+ <Publish Dialog="AdvancedWelcomeEulaDlg_Custom" Control="Advanced" Property="APPLICATIONFOLDER" Value="[$(var.ProgFilesFolder)][ApplicationFolderName]" Order="2">ALLUSERS = 1</Publish>
+ <Publish Dialog="AdvancedWelcomeEulaDlg_Custom" Control="Advanced" Event="NewDialog" Value="InstallDirDlg" Order="3">!(wix.WixUISupportPerMachine) AND !(wix.WixUISupportPerUser)</Publish>
+
+ <Publish Dialog="AdvancedWelcomeEulaDlg_Custom" Control="AllUsersCheckBox" Property="WixAppFolder" Value="WixPerMachineFolder" Order="1">ALLUSERS = 1</Publish>
+ <Publish Dialog="AdvancedWelcomeEulaDlg_Custom" Control="AllUsersCheckBox" Property="APPLICATIONFOLDER" Value="[$(var.ProgFilesFolder)][ApplicationFolderName]" Order="2">ALLUSERS = 1</Publish>
+
+ <Publish Dialog="AdvancedWelcomeEulaDlg_Custom" Control="AllUsersCheckBox" Property="WixAppFolder" Value="WixPerUserFolder" Order="1">NOT (ALLUSERS = 1)</Publish>
+ <Publish Dialog="AdvancedWelcomeEulaDlg_Custom" Control="AllUsersCheckBox" Property="APPLICATIONFOLDER" Value="[LocalAppDataFolder][ApplicationFolderName]" Order="2">NOT (ALLUSERS = 1)</Publish>
+
+ <!--<Publish Dialog="InstallScopeDlg" Control="Back" Event="NewDialog" Value="AdvancedWelcomeEulaDlg_Custom">1</Publish>-->
+ <!-- override default WixAppFolder of WixPerMachineFolder as standard user won't be shown the radio group to set WixAppFolder -->
+
+ <!--<Publish Dialog="InstallScopeDlg" Control="Next" Property="WixAppFolder" Value="WixPerUserFolder" Order="1">!(wix.WixUISupportPerUser) AND NOT Privileged</Publish>-->
+
+
+
+ <!--<Publish Dialog="InstallScopeDlg" Control="Next" Event="NewDialog" Value="FeaturesDlg" Order="6">WixAppFolder = "WixPerUserFolder"</Publish>
+ <Publish Dialog="InstallScopeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg" Order="7">WixAppFolder = "WixPerMachineFolder"</Publish>-->
+
+ <!--<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="InstallScopeDlg">!(wix.WixUISupportPerUser)</Publish>-->
+ <Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="AdvancedWelcomeEulaDlg_Custom">1</Publish>
+ <Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
+ <Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
+ <Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
+ <Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
+ <Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
+ <Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
+
+ <!--<Publish Dialog="FeaturesDlg" Control="Back" Event="NewDialog" Value="InstallScopeDlg">NOT Installed AND WixAppFolder = "WixPerUserFolder"</Publish>-->
+ <Publish Dialog="FeaturesDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg">NOT Installed AND WixAppFolder = "WixPerMachineFolder"</Publish>
+ <Publish Dialog="FeaturesDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg">Installed</Publish>
+
+ <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
+
+ <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+ <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
+ <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
+
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH</Publish>
+ <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="3">Installed AND PATCH</Publish>
+
+ <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>
+ </UI>
+
+ <InstallUISequence>
+ <Show Dialog="WelcomeDlg" Before="AdvancedWelcomeEulaDlg_Custom" >Installed AND PATCH</Show>
+ </InstallUISequence>
+
+ <Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONFOLDER" />
+ <UIRef Id="WixUI_Common" />
+ </Fragment>
+</Wix> \ No newline at end of file
diff --git a/windows/make-windows-installer.bat b/windows/make-windows-installer.bat
new file mode 100644
index 000000000..1517e9bf9
--- /dev/null
+++ b/windows/make-windows-installer.bat
@@ -0,0 +1,29 @@
+@echo off
+stack install --test --stack-yaml=..\stack.pkg.yml
+if %errorlevel% neq 0 exit /b %errorlevel%
+for /f "delims=" %%a in ('stack path --local-bin-path') do @set BINPATH=%%a
+%BINPATH%\pandoc.exe -s --toc ..\MANUAL.txt -o MANUAL.html
+if %errorlevel% neq 0 exit /b %errorlevel%
+%BINPATH%\pandoc.exe -s ..\COPYING.md -t rtf -o COPYING.rtf
+if %errorlevel% neq 0 exit /b %errorlevel%
+copy ..\COPYRIGHT COPYRIGHT.txt
+for /f "tokens=1-2 delims= " %%a in ('%BINPATH%\pandoc.exe --version') do (
+ @set VERSION=%%b
+ goto :next
+ )
+:next
+if "%VERSION%" == "" (
+ echo Error: could not determine version number.
+ exit /b 1
+)
+echo Detected version %VERSION%
+echo Creating msi...
+candle -dVERSION=%VERSION% -dBINPATH=%BINPATH% *.wxs -out wixobj\
+if %errorlevel% neq 0 exit /b %errorlevel%
+light -sw1076 -ext WixUIExtension -ext WixUtilExtension -cultures:en-us -loc Pandoc-en-us.wxl -out pandoc-%VERSION%-windows.msi wixobj\*.wixobj
+if %errorlevel% neq 0 exit /b %errorlevel%
+echo Starting kSign: sign, then quit kSign to complete the build...
+kSign
+
+echo Copying to shared drive
+copy pandoc-%VERSION%-windows.msi \\VBOXSVR\WindowsShared\
diff --git a/windows/pandoc.wxs b/windows/pandoc.wxs
new file mode 100644
index 000000000..dcdd3f582
--- /dev/null
+++ b/windows/pandoc.wxs
@@ -0,0 +1,188 @@
+<?define UpgradeCode = "A68E8EF6-ABB1-4F22-A3C5-68DFDF0AB562" ?>
+<?if $(sys.BUILDARCH)=x64?>
+<?define ProgFilesFolder="ProgramFiles64Folder"?>
+<?else?>
+<?define ProgFilesFolder="ProgramFilesFolder"?>
+<?endif?>
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
+ <Product Id="*"
+ UpgradeCode="$(var.UpgradeCode)" Name="Pandoc $(var.VERSION)"
+ Version="$(var.VERSION)" Manufacturer="John MacFarlane"
+ Language="1033">
+
+ <Package InstallerVersion="301" Compressed="yes"
+ Comments="Windows Installer Package" />
+ <Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
+ <Property Id="PREVIOUSVERSIONSINSTALLED" Secure="yes" />
+ <Upgrade Id="$(var.UpgradeCode)">
+ <UpgradeVersion Property='PREVIOUSVERSIONSINSTALLED'
+ Minimum='0.0.0.0' IncludeMinimum='yes'
+ Maximum="99.0.0.0" IncludeMaximum="no" />
+ </Upgrade>
+
+ <InstallExecuteSequence>
+ <RemoveExistingProducts After="InstallFinalize"/>
+ </InstallExecuteSequence>
+
+ <Property Id="DISABLEADVTSHORTCUTS" Value="1" />
+
+ <Directory Id="TARGETDIR" Name="SourceDir">
+
+ <Directory Id="$(var.ProgFilesFolder)">
+ <Directory Id="APPLICATIONFOLDER" Name="Pandoc">
+ <Component Id="MainExecutable"
+ Guid="ECD35082-4C28-49E1-977E-B90FC7C400C7">
+ <RegistryValue Root="HKMU"
+ Key="Software\John MacFarlane\Pandoc"
+ Name="Version" Type="string" Value="[ProductVersion]"
+ KeyPath="yes"/>
+ <RemoveFolder Id="APPLICATIONFOLDER" On="uninstall"/>
+ <File Id="pandocEXE" Name="pandoc.exe"
+ Source="$(var.BINPATH)\pandoc.exe" />
+ <File Id="pandocCOPYRIGHT" Name="COPYRIGHT.txt"
+ Source="COPYRIGHT.txt" />
+ <File Id="pandocCOPYING" Name="COPYING.rtf"
+ Source="COPYING.rtf" />
+ </Component>
+
+ <Component Id="CitationSupport"
+ Guid="0A214839-2E69-4026-8DBB-0F0A9DB75C12">
+ <RegistryValue Root="HKMU"
+ Key="Software\John MacFarlane\Pandoc"
+ Name="Version" Type="string" Value="[ProductVersion]"
+ KeyPath="yes"/>
+ <File Id="pandoc_citeprocEXE" Name="pandoc-citeproc.exe"
+ Source="$(var.BINPATH)\pandoc-citeproc.exe" />
+ </Component>
+
+ <Component Id="Documentation"
+ Guid="A8D54A76-1A3D-4647-8327-81B69D39D8A3">
+ <File Id="pandocMANUAL" Name="Pandoc User's Guide.html"
+ Source="MANUAL.html" KeyPath="yes">
+ <Shortcut Id="ApplicationStartMenuShortcut"
+ Directory="ApplicationProgramsFolder"
+ Name="Pandoc User’s Guide" Advertise="yes" />
+ </File>
+ </Component>
+
+
+ <Component Id="UpdateUserPath"
+ Guid="7ECEAD05-CA5C-4147-82CB-F7CADABAC7F3"
+ KeyPath="yes">
+ <Condition>ALLUSERS = "" OR ALLUSERS = 2</Condition>
+ <Environment Id='SetUserPath' Name='PATH' Action='set'
+ Permanent='no' System='no' Part='last'
+ Value='[APPLICATIONFOLDER]' />
+ </Component>
+
+ <Component Id="UpdateSystemPath"
+ Guid="F8AC4135-C0AE-48C7-BAC5-311DAC97CFD8"
+ KeyPath="yes">
+ <Condition>ALLUSERS = 1</Condition>
+ <Environment Id='SetSystemPath' Name='PATH' Action='set'
+ Permanent='no' System='yes' Part='last'
+ Value='[APPLICATIONFOLDER]' />
+ </Component>
+
+ </Directory>
+ </Directory>
+
+ <Directory Id="ProgramMenuFolder">
+ <Directory Id="ApplicationProgramsFolder" Name="Pandoc">
+ <Component Id="ApplicationShortcut"
+ Guid="7F807DD5-CC54-474A-B571-89630893F563">
+ <RemoveFolder Id="ApplicationProgramsFolder"
+ On="uninstall"/>
+ <RegistryValue Root="HKMU" Key="Software\John MacFarlane\Pandoc"
+ Name="ShortcutInstalled" Type="integer" Value="1"
+ KeyPath="yes"/>
+ </Component>
+ </Directory>
+ </Directory>
+
+ </Directory>
+
+ <Feature Id="Complete" Level="1" Title="Pandoc $(var.VERSION)"
+ Description="Complete package" Display="expand"
+ ConfigurableDirectory="APPLICATIONFOLDER">
+ <Feature Id="MainProgram"
+ Title="Program"
+ Description="The main executable."
+ Level="1">
+ <ComponentRef Id="MainExecutable" />
+ <ComponentRef Id="UpdateUserPath" />
+ <ComponentRef Id="UpdateSystemPath" />
+ </Feature>
+ <Feature Id="Manual" Title="Manual">
+ <ComponentRef Id="Documentation" />
+ <ComponentRef Id="ApplicationShortcut" />
+ </Feature>
+ <Feature Id="Citation" Title="Citation Support"
+ Description="Citation support.">
+ <ComponentRef Id="CitationSupport" />
+ </Feature>
+ </Feature>
+
+
+ <!-- Set properties for add/remove programs -->
+ <Property Id="ARPURLINFOABOUT" Value="http://pandoc.org" />
+ <Property Id="ARPHELPLINK" Value="http://pandoc.org" />
+ <Property Id="ARPNOREPAIR" Value="yes" Secure="yes" /> <!-- Remove repair -->
+ <Property Id="ARPNOMODIFY" Value="yes" Secure="yes" /> <!-- Remove modify -->
+
+
+ <!--Needed for WixUI_Advanced-->
+ <Property Id="ApplicationFolderName" Value="Pandoc" />
+ <Property Id="WixAppFolder" Value="WixPerUserFolder" />
+
+ <!--For Single Package for dual purpose i.e. per User/Machine-->
+ <!--<Property Id="ALLUSERS" Value="2" Secure="yes" />-->
+ <Property Id="MSIINSTALLPERUSER" Value="1" />
+
+ <!--Inform about installed location-->
+ <SetProperty Id="ARPINSTALLLOCATION" Value="[APPLICATIONFOLDER]"
+ After="CostFinalize" />
+ <CustomAction Id="SetExitDialogOptText"
+ Property="WIXUI_EXITDIALOGOPTIONALTEXT"
+ Value="!(loc.ExitDialogText)" />
+
+ <!--Offer Per User installs only on workstations (block on servers)-->
+ <!--Unless ALLUSERS=1 is specified on command line-->
+ <SetProperty Id="WixUISupportPerUser" Value="0" Before="FindRelatedProducts">
+ <!--https://msdn.microsoft.com/en-us/library/windows/desktop/aa370329(v=vs.85).aspx-->
+ MsiNTProductType > 1
+ </SetProperty>
+ <SetProperty Id="WixUISupportPerUser" Value="1" Before="FindRelatedProducts" Action="CASupportPerUser">
+ MsiNTProductType = 1
+ </SetProperty>
+ <SetProperty Id="ALLUSERS" Value="1" Before="FindRelatedProducts">
+ MsiNTProductType > 1
+ </SetProperty>
+ <SetProperty Id="ALLUSERS" Value="{}" Before="FindRelatedProducts" Action="CASetPuaPackage">
+ (NOT ALLUSERS = 1) AND MsiNTProductType = 1
+ </SetProperty>
+ <SetProperty Id="MSIINSTALLPERUSER" Value="1" Before="FindRelatedProducts">
+ (NOT ALLUSERS = 1) AND MsiNTProductType = 1
+ </SetProperty>
+ <SetProperty Id="WixAppFolder" Value="WixPerMachineFolder" Before="FindRelatedProducts">
+ MsiNTProductType > 1
+ </SetProperty>
+
+ <!--Make changes to PATH visible immeidiately-->
+ <CustomActionRef Id="WixBroadcastSettingChange" />
+ <CustomActionRef Id="WixBroadcastEnvironmentChange" />
+
+ <InstallUISequence>
+ <Custom Action="SetExitDialogOptText" Before="ExecuteAction">
+ NOT Installed
+ </Custom>
+ </InstallUISequence>
+
+ <UIRef Id="WixUI_Advanced_Custom"/>
+ <!--Enable better description when debug logging-->
+ <UIRef Id="WixUI_ErrorProgressText" />
+
+ </Product>
+
+
+</Wix>