aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.editorconfig16
-rw-r--r--.gitignore6
-rw-r--r--.travis.yml31
-rw-r--r--CONTRIBUTING.md3
-rw-r--r--COPYRIGHT62
-rw-r--r--INSTALL90
-rw-r--r--Interact.hs4
-rw-r--r--Makefile48
-rw-r--r--README553
-rw-r--r--RELEASE-CHECKLIST2
-rw-r--r--Setup.hs28
-rw-r--r--benchmark/benchmark-pandoc.hs21
-rw-r--r--changelog1449
-rw-r--r--data/MathMLinHTML.js20
-rw-r--r--data/default.csl458
-rw-r--r--data/epub.css21
-rw-r--r--data/reference.docxbin9782 -> 8473 bytes
-rw-r--r--data/reference.odtbin7058 -> 10890 bytes
-rw-r--r--data/s5/default/blank.gifbin49 -> 0 bytes
-rw-r--r--data/s5/default/bodybg.gifbin10119 -> 0 bytes
-rw-r--r--data/s5/default/framing.css23
-rw-r--r--data/s5/default/iepngfix.htc42
-rw-r--r--data/s5/default/opera.css7
-rw-r--r--data/s5/default/outline.css15
-rw-r--r--data/s5/default/pretty.css86
-rw-r--r--data/s5/default/print.css24
-rw-r--r--data/s5/default/s5-core.css9
-rw-r--r--data/s5/default/slides.css3
-rw-r--r--data/s5/default/slides.js553
-rw-r--r--data/sample.lua22
-rw-r--r--data/slideous/slideous.css95
-rw-r--r--data/slideous/slideous.js321
-rw-r--r--data/slidy/graphics/fold-dim.gifbin56 -> 0 bytes
-rw-r--r--data/slidy/graphics/fold.gifbin56 -> 0 bytes
-rw-r--r--data/slidy/graphics/nofold-dim.gifbin48 -> 0 bytes
-rw-r--r--data/slidy/graphics/unfold-dim.gifbin59 -> 0 bytes
-rw-r--r--data/slidy/graphics/unfold.gifbin59 -> 0 bytes
-rw-r--r--data/slidy/scripts/slidy.js3016
-rw-r--r--data/slidy/styles/slidy.css405
-rwxr-xr-xgithub-upload.sh18
-rwxr-xr-xgooglecode-upload.sh2
-rwxr-xr-xmake_osx_package.sh74
-rw-r--r--man/make-pandoc-man-pages.hs1
-rwxr-xr-xosx/osx-resources/InstallationCheck (renamed from osx-resources/InstallationCheck)0
-rw-r--r--osx/osx-resources/InstallationCheck.strings (renamed from osx-resources/InstallationCheck.strings)0
-rwxr-xr-xosx/uninstall-pandoc.pl79
-rw-r--r--pandoc.cabal235
-rw-r--r--pandoc.hs355
-rw-r--r--src/Text/Pandoc.hs192
-rw-r--r--src/Text/Pandoc/Asciify.hs4
-rw-r--r--src/Text/Pandoc/Biblio.hs187
-rw-r--r--src/Text/Pandoc/Compat/Monoid.hs20
-rw-r--r--src/Text/Pandoc/Compat/TagSoupEntity.hs15
-rw-r--r--src/Text/Pandoc/Highlighting.hs11
-rw-r--r--src/Text/Pandoc/ImageSize.hs267
-rw-r--r--src/Text/Pandoc/MIME.hs20
-rw-r--r--src/Text/Pandoc/Options.hs29
-rw-r--r--src/Text/Pandoc/PDF.hs135
-rw-r--r--src/Text/Pandoc/Parsing.hs238
-rw-r--r--src/Text/Pandoc/Pretty.hs20
-rw-r--r--src/Text/Pandoc/Process.hs104
-rw-r--r--src/Text/Pandoc/Readers/DocBook.hs140
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs489
-rw-r--r--src/Text/Pandoc/Readers/Docx/Lists.hs227
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse.hs596
-rw-r--r--src/Text/Pandoc/Readers/Docx/Reducible.hs181
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs343
-rw-r--r--src/Text/Pandoc/Readers/Haddock.hs139
-rw-r--r--src/Text/Pandoc/Readers/Haddock/Lex.x171
-rw-r--r--src/Text/Pandoc/Readers/Haddock/Parse.y178
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs719
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs500
-rw-r--r--src/Text/Pandoc/Readers/MediaWiki.hs107
-rw-r--r--src/Text/Pandoc/Readers/Native.hs4
-rw-r--r--src/Text/Pandoc/Readers/OPML.hs2
-rw-r--r--src/Text/Pandoc/Readers/Org.hs1379
-rw-r--r--src/Text/Pandoc/Readers/RST.hs163
-rw-r--r--src/Text/Pandoc/Readers/TeXMath.hs110
-rw-r--r--src/Text/Pandoc/Readers/Textile.hs364
-rw-r--r--src/Text/Pandoc/SelfContained.hs33
-rw-r--r--src/Text/Pandoc/Shared.hs184
-rw-r--r--src/Text/Pandoc/Slides.hs11
-rw-r--r--src/Text/Pandoc/Templates.hs88
-rw-r--r--src/Text/Pandoc/UTF8.hs8
-rw-r--r--src/Text/Pandoc/UUID.hs4
-rw-r--r--src/Text/Pandoc/Writers/AsciiDoc.hs20
-rw-r--r--src/Text/Pandoc/Writers/ConTeXt.hs34
-rw-r--r--src/Text/Pandoc/Writers/Custom.hs19
-rw-r--r--src/Text/Pandoc/Writers/Docbook.hs64
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs325
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs918
-rw-r--r--src/Text/Pandoc/Writers/FB2.hs17
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs158
-rw-r--r--src/Text/Pandoc/Writers/Haddock.hs346
-rw-r--r--src/Text/Pandoc/Writers/ICML.hs525
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs389
-rw-r--r--src/Text/Pandoc/Writers/Man.hs23
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs168
-rw-r--r--src/Text/Pandoc/Writers/MediaWiki.hs113
-rw-r--r--src/Text/Pandoc/Writers/Native.hs4
-rw-r--r--src/Text/Pandoc/Writers/ODT.hs85
-rw-r--r--src/Text/Pandoc/Writers/OPML.hs4
-rw-r--r--src/Text/Pandoc/Writers/OpenDocument.hs65
-rw-r--r--src/Text/Pandoc/Writers/Org.hs19
-rw-r--r--src/Text/Pandoc/Writers/RST.hs49
-rw-r--r--src/Text/Pandoc/Writers/RTF.hs31
-rw-r--r--src/Text/Pandoc/Writers/Shared.hs52
-rw-r--r--src/Text/Pandoc/Writers/Texinfo.hs38
-rw-r--r--src/Text/Pandoc/Writers/Textile.hs30
-rw-r--r--src/Text/Pandoc/XML.hs6
-rwxr-xr-xtests/MarkdownTest_1.0.3/MarkdownTest.pl176
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Amps and angle encoding.html17
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Amps and angle encoding.text21
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Auto links.html18
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Auto links.text13
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Backslash escapes.html118
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Backslash escapes.text120
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.html15
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.text11
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Code Blocks.html18
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Code Blocks.text14
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Code Spans.html6
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Code Spans.text6
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.html8
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.text8
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Horizontal rules.html71
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Horizontal rules.text67
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).html15
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).text15
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).html72
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).text69
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Inline HTML comments.html13
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Inline HTML comments.text13
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Links, inline style.html11
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Links, inline style.text12
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Links, reference style.html52
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Links, reference style.text71
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Links, shortcut references.html9
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Links, shortcut references.text20
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Literal quotes in titles.html3
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Literal quotes in titles.text7
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.html314
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.text306
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.html942
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.text888
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Nested blockquotes.html9
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Nested blockquotes.text5
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.html148
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.text131
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Strong and em together.html7
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Strong and em together.text7
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Tabs.html25
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Tabs.text21
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Tidyness.html8
-rw-r--r--tests/MarkdownTest_1.0.3/Tests/Tidyness.text5
-rw-r--r--tests/Tests/Arbitrary.hs19
-rw-r--r--tests/Tests/Old.hs33
-rw-r--r--tests/Tests/Readers/Docx.hs160
-rw-r--r--tests/Tests/Readers/LaTeX.hs55
-rw-r--r--tests/Tests/Readers/Markdown.hs23
-rw-r--r--tests/Tests/Readers/Org.hs994
-rw-r--r--tests/Tests/Walk.hs47
-rw-r--r--tests/Tests/Writers/AsciiDoc.hs37
-rw-r--r--tests/Tests/Writers/Docbook.hs229
-rw-r--r--tests/Tests/Writers/HTML.hs5
-rw-r--r--tests/Tests/Writers/LaTeX.hs32
-rw-r--r--tests/Tests/Writers/Markdown.hs4
-rw-r--r--tests/biblio.bib26
-rw-r--r--tests/chicago-author-date.csl458
-rw-r--r--tests/docbook-reader.docbook18
-rw-r--r--tests/docx.block_quotes.docxbin0 -> 41855 bytes
-rw-r--r--tests/docx.block_quotes_parse_indent.native8
-rw-r--r--tests/docx.codeblock.docxbin0 -> 8465 bytes
-rw-r--r--tests/docx.codeblock.native3
-rw-r--r--tests/docx.deep_normalize.docxbin0 -> 29246 bytes
-rw-r--r--tests/docx.deep_normalize.native6
-rw-r--r--tests/docx.definition_list.docxbin0 -> 8455 bytes
-rw-r--r--tests/docx.definition_list.native7
-rw-r--r--tests/docx.headers.docxbin0 -> 30298 bytes
-rw-r--r--tests/docx.headers.native5
-rw-r--r--tests/docx.image.docxbin0 -> 109656 bytes
-rw-r--r--tests/docx.image_no_embed.native2
-rw-r--r--tests/docx.inline_code.docxbin0 -> 8379 bytes
-rw-r--r--tests/docx.inline_code.native1
-rw-r--r--tests/docx.inline_formatting.docxbin0 -> 32322 bytes
-rw-r--r--tests/docx.inline_formatting.native5
-rw-r--r--tests/docx.links.docxbin0 -> 41751 bytes
-rw-r--r--tests/docx.links.native6
-rw-r--r--tests/docx.lists.docxbin0 -> 31775 bytes
-rw-r--r--tests/docx.lists.native18
-rw-r--r--tests/docx.normalize.docxbin0 -> 25994 bytes
-rw-r--r--tests/docx.normalize.native2
-rw-r--r--tests/docx.notes.docxbin0 -> 30734 bytes
-rw-r--r--tests/docx.notes.native2
-rw-r--r--tests/docx.tables.docxbin0 -> 42792 bytes
-rw-r--r--tests/docx.tables.native24
-rw-r--r--tests/docx.tabs.docxbin0 -> 12919 bytes
-rw-r--r--tests/docx.tabs.native2
-rw-r--r--tests/docx.track_changes_deletion.docxbin0 -> 13350 bytes
-rw-r--r--tests/docx.track_changes_deletion_accept.native1
-rw-r--r--tests/docx.track_changes_deletion_all.native1
-rw-r--r--tests/docx.track_changes_deletion_reject.native1
-rw-r--r--tests/docx.track_changes_insertion.docxbin0 -> 12956 bytes
-rw-r--r--tests/docx.track_changes_insertion_accept.native1
-rw-r--r--tests/docx.track_changes_insertion_all.native1
-rw-r--r--tests/docx.track_changes_insertion_reject.native1
-rw-r--r--tests/docx.trailing_spaces_in_formatting.docxbin0 -> 12916 bytes
-rw-r--r--tests/docx.trailing_spaces_in_formatting.native1
-rw-r--r--tests/docx.unicode.docxbin0 -> 13098 bytes
-rw-r--r--tests/docx.unicode.native1
-rw-r--r--tests/haddock-reader.haddock20
-rw-r--r--tests/haddock-reader.native16
-rw-r--r--tests/html-reader.html24
-rw-r--r--tests/html-reader.native158
-rw-r--r--tests/ieee.csl302
-rw-r--r--tests/latex-reader.native70
-rw-r--r--tests/lhs-test.html4
-rw-r--r--tests/lhs-test.html+lhs4
-rw-r--r--tests/lhs-test.latex11
-rw-r--r--tests/lhs-test.latex+lhs9
-rw-r--r--tests/lhs-test.markdown4
-rw-r--r--tests/lhs-test.native2
-rw-r--r--tests/markdown-citations.chicago-author-date.txt45
-rw-r--r--tests/markdown-citations.ieee.txt45
-rw-r--r--tests/markdown-citations.mhra.txt63
-rw-r--r--tests/markdown-citations.native17
-rw-r--r--tests/markdown-reader-more.native19
-rw-r--r--tests/markdown-reader-more.txt12
-rw-r--r--tests/mediawiki-reader.native92
-rw-r--r--tests/mediawiki-reader.wiki11
-rw-r--r--tests/mhra.csl399
-rw-r--r--tests/opml-reader.native2
-rw-r--r--tests/pipe-tables.native10
-rw-r--r--tests/pipe-tables.txt10
-rw-r--r--tests/rst-reader.native76
-rw-r--r--tests/rst-reader.rst24
-rw-r--r--tests/tables.asciidoc11
-rw-r--r--tests/tables.context14
-rw-r--r--tests/tables.haddock77
-rw-r--r--tests/tables.html6
-rw-r--r--tests/tables.icml748
-rw-r--r--tests/tables.latex154
-rw-r--r--tests/tables.mediawiki316
-rw-r--r--tests/tables.rtf184
-rw-r--r--tests/test-pandoc.hs16
-rw-r--r--tests/testsuite.native36
-rw-r--r--tests/testsuite.txt12
-rw-r--r--tests/textile-reader.native167
-rw-r--r--tests/textile-reader.textile6
-rw-r--r--tests/writer.context15
-rw-r--r--tests/writer.docbook124
-rw-r--r--tests/writer.fb22
-rw-r--r--tests/writer.haddock660
-rw-r--r--tests/writer.html20
-rw-r--r--tests/writer.icml3023
-rw-r--r--tests/writer.latex28
-rw-r--r--tests/writer.man2
-rw-r--r--tests/writer.markdown29
-rw-r--r--tests/writer.mediawiki28
-rw-r--r--tests/writer.native36
-rw-r--r--tests/writer.opendocument163
-rw-r--r--tests/writer.opml12
-rw-r--r--tests/writer.org37
-rw-r--r--tests/writer.plain5
-rw-r--r--tests/writer.rst35
-rw-r--r--tests/writer.rtf2
-rw-r--r--tests/writer.textile31
-rw-r--r--windows/make-windows-installer.bat20
-rw-r--r--windows/pandoc.wxs13
269 files changed, 18085 insertions, 14621 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
index 3e9ae6904..97150be15 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,15 +1,19 @@
+*~
dist/*
README.*
!README.Debian
INSTALL.*
.configure-stamp
+.cabal-sandbox
+cabal.sandbox.config
+pandoc.cabal.orig
man/man?/*.1
man/man?/*.5
man/man?/*.html
*.diff
-pandoc.cabal.orig
*.o
*.hi
+*.pyc
/COPYING.rtf
/COPYRIGHT.txt
/cabal-dev/
diff --git a/.travis.yml b/.travis.yml
index 934a8ea5b..1ca7a1228 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,28 @@
-language: haskell
+# NB: don't set `language: haskell` here
+
+# The following enables several GHC versions to be tested; often it's enough to test only against the last release in a major GHC version. Feel free to omit lines listings versions you don't need/want testing for.
+env:
+# - GHCVER=6.12.3
+ - GHCVER=7.4.2
+ - GHCVER=7.6.3
+ - GHCVER=7.8.2 # see note about Alex/Happy
+# - GHCVER=head # see section about GHC HEAD snapshots
+
+# Note: the distinction between `before_install` and `install` is not important.
before_install:
- - git submodule update --init --recursive
+ - travis_retry sudo add-apt-repository -y ppa:hvr/ghc
+ - travis_retry sudo apt-get update
+ - travis_retry sudo apt-get install cabal-install-1.18 ghc-$GHCVER
+ - export PATH=/opt/ghc/$GHCVER/bin:$PATH
+
install:
- - cabal update
- - cabal install --enable-tests
-script: cabal configure --enable-tests && cabal build && cabal test
+ - cabal-1.18 update
+# - git clone https://github.com/jgm/pandoc-types && cd pandoc-types && cabal-1.18 install && cd ..
+ - cabal-1.18 install --only-dependencies --enable-tests
+
+# Here starts the actual work to be performed for the package under test; any command which exits with a non-zero exit code causes the build to fail.
+script:
+ - cabal-1.18 configure --enable-tests -v2 # -v2 provides useful information for debugging
+ - cabal-1.18 build --ghc-options=-Werror # this builds all libraries and executables (including tests/benchmarks)
+ - cabal-1.18 test
+ - cabal-1.18 check
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index eeee77b25..824d1465e 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -60,6 +60,8 @@ Please follow these guidelines:
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).
@@ -177,5 +179,6 @@ The library is structured as follows:
[issue tracker]: https://github.com/jgm/pandoc/issues
[User's Guide]: http://johnmacfarlane.net/pandoc/README.html
[FAQs]: http://johnmacfarlane.net/pandoc/faqs.html
+[EditorConfig]: http://editorconfig.org/
[Haskell platform]: http://www.haskell.org/platform/
[hsb2hs]: http://hackage.haskell.org/package/hsb2hs
diff --git a/COPYRIGHT b/COPYRIGHT
index 8bf62135e..065090018 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,5 +1,5 @@
Pandoc
-Copyright (C) 2006-2013 John MacFarlane <jgm at berkeley dot edu>
+Copyright (C) 2006-2014 John MacFarlane <jgm at berkeley dot edu>
This code is released under the [GPL], version 2 or later:
@@ -33,33 +33,34 @@ licenses.
----------------------------------------------------------------------
src/Text/Pandoc/Writers/Texinfo.hs
-Copyright (C) 2008-2010 John MacFarlane and Peter Wang
+Copyright (C) 2008-2014 John MacFarlane and Peter Wang
-Released under the GPL.
+Released under the GNU General Public License version 2 or later.
----------------------------------------------------------------------
src/Text/Pandoc/Writers/OpenDocument.hs
-Copyright (C) 2008-2010 Andrea Rossato and John MacFarlane
+Copyright (C) 2008-2014 Andrea Rossato and John MacFarlane
-Released under the GPL.
+Released under the GNU General Public License version 2 or later.
----------------------------------------------------------------------
src/Text/Pandoc/Writers/Org.hs
-Copyright (C) 2010 Puneeth Chaganti
+Copyright (C) 2010-2014 Puneeth Chaganti and JohnMacFarlane
-Released under the GPL.
+Released under the GNU General Public License version 2 or later.
----------------------------------------------------------------------
src/Text/Pandoc/Readers/Textile.hs
-Copyright (C) 2010 Paul Rivier
+Copyright (C) 2010-2014 Paul Rivier and John MacFarlane
-Released under the GPL.
+Released under the GNU General Public License version 2 or later.
----------------------------------------------------------------------
-src/Text/Pandoc/Biblio.hs
-Copyright (C) 2008-2010 Andrea Rossato
+src/Text/Pandoc/Readers/Org.hs
+tests/Tests/Readers/Org.hs
+Copyright (C) 2014 Albert Krewinkel
-Released under the GPL.
+Released under the GNU General Public License version 2 or later.
----------------------------------------------------------------------
data/LaTeXMathML.js
@@ -67,46 +68,13 @@ Adapted by Jeff Knisely and Douglas Woodall from
ASCIIMathML.js v. 1.4.7
Copyright (C) 2005 Peter Jipsen
-Released under the GPL.
+Released under the GNU General Public License version 2 or later.
----------------------------------------------------------------------
-data/MathMLInHTML.js
+data/MathMLinHTML.js
Copyright (C) 2004 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.
-
-----------------------------------------------------------------------
-s5/default
-S5 slides.js and css files
-by Eric A. Meyer
-<http://meyerweb.com/eric/tools/s5
-
-Released under an explicit Public Domain License
-
-----------------------------------------------------------------------
-slidy/default
-Slidy javascript and CSS
-by Dave Raggett
-http://www.w3.org/Talks/Tools/Slidy2
-
-Released under W3C document and software licenses
-
-----------------------------------------------------------------------
-slideous/default
-Slideous javascript and CSS
-by Stefan Gössner
-http://goessner.net/
-
-Released under Creative Commons GNU LGPL License
-
-------------------------------------------------------------------------
-windows/modpath.iss
-Copyright (c) 2007 Jared Breland
-http://legroom.net/software
-
-Released under the GPL.
------------------------------------------------------------------------
The dzslides template contains javascript and CSS from Paul Rouget's
diff --git a/INSTALL b/INSTALL
index fa1cf62f8..eb9b2b030 100644
--- a/INSTALL
+++ b/INSTALL
@@ -3,15 +3,22 @@
These instructions explain how to install pandoc from source.
Binary packages or ports of pandoc are available for freebsd
and several linux distributions, so check your package manager.
-There is also a Windows installer.
+There are also binary installers for Windows and Mac OS X.
+
+If you are installing the development version from github, see also:
+https://github.com/jgm/pandoc/wiki/Installing-the-development-version-of-pandoc
Quick install
-------------
1. Install the [Haskell platform]. This will give you [GHC] and
-the [cabal-install] build tool.
+ the [cabal-install] build tool.
+
+2. Update your package database:
+
+ cabal update
-2. Use `cabal` to install pandoc and its dependencies:
+3. Use `cabal` to install pandoc and its dependencies:
cabal install pandoc
@@ -23,16 +30,47 @@ the [cabal-install] build tool.
cabal install
-3. Make sure the `$CABALDIR/bin` directory is in your path. You should
-now be able to run `pandoc`:
+ 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
-4. Make sure the `$CABALDIR/share/man/man1` directory is in your `MANPATH`.
-You should now be able to access the `pandoc` man page:
+ [Not sure where `$CABALDIR` is?](http://www.haskell.org/haskellwiki/Cabal-Install#The_cabal-install_configuration_file)
+
+5. Make sure the `$CABALDIR/share/man/man1` directory is in your `MANPATH`.
+ You should now be able to access the `pandoc` man page:
man pandoc
+6. 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
+
[GHC]: http://www.haskell.org/ghc/
[Haskell platform]: http://hackage.haskell.org/platform/
[cabal-install]: http://hackage.haskell.org/trac/hackage/wiki/CabalInstall
@@ -43,14 +81,19 @@ Custom install
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].
+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 [zip-archive], [blaze-html], and [highlighting-kate].
+ you will need a number of additional libraries. You can install
+ them all with
+
+ cabal update
+ cabal install --only-dependencies
2. Configure:
- runghc Setup.hs configure --prefix=DIR --bindir=DIR --libdir=DIR \
+ 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
@@ -62,26 +105,33 @@ you will need [zip-archive], [blaze-html], and [highlighting-kate].
preceded by a `-` (to force the flag to `false`), and separated
by spaces. Pandoc's flags include:
- - `blaze_html_0_5`: Use blaze-html >= 0.5 (default yes)
- - `embed_data_files`: embed all data files into the binary (default no)
+ - `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
+
+ - `https`: enable support for downloading resources over https
+ (using the `http-client` and `http-client-tls` libraries).
3. Build:
- runghc Setup.hs build
+ cabal build
4. Build API documentation:
- runghc Setup.hs haddock --html-location=URL --hyperlink-source
+ cabal haddock --html-location=URL --hyperlink-source
5. Copy the files:
- runghc Setup.hs copy --destdir=PATH
+ cabal copy --destdir=PATH
The default destdir is `/`.
6. Register pandoc as a GHC package:
- runghc Setup.hs register
+ 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
@@ -107,7 +157,6 @@ you please.
[blaze-html]: http://hackage.haskell.org/package/blaze-html
[Cabal User's Guide]: http://www.haskell.org/cabal/release/latest/doc/users-guide/builders.html#setup-configure-paths
-
Running tests
-------------
@@ -116,13 +165,6 @@ To build the tests:
cabal configure --enable-tests && cabal build
-Note: If you obtained the source via git, you should first do
-
- git submodule update --init data/templates
-
-to populate the templates subdirectory. (You can skip this step
-if you obtained the source from a release tarball.)
-
To run the tests:
cabal test
diff --git a/Interact.hs b/Interact.hs
index 80b5a34f5..4d24904c5 100644
--- a/Interact.hs
+++ b/Interact.hs
@@ -9,6 +9,10 @@
-- You must have first done a 'cabal configure' or 'cabal install'
+-- Note: Interact.hs doesn't work with Cabal >= 1.18. I recommend
+-- using cabal sandboxes and the new 'cabal repl' command if you are
+-- using a recent version.
+
import System.Process
import Distribution.Simple.LocalBuildInfo
import Distribution.Package
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 52115818a..000000000
--- a/Makefile
+++ /dev/null
@@ -1,48 +0,0 @@
-# This Makefile is for development only. It requires cabal-dev.
-# To get started, do 'make prep' and then 'make' or 'make quick'.
-
-.PHONY: prep submodules all quick bench clean veryclean install sdist
-
-all:
- cabal-dev configure --enable-tests --enable-benchmarks && cabal-dev build
-
-prof:
- cabal-dev configure --disable-tests --enable-library-profiling --enable-executable-profiling && cabal-dev build
-
-prep: submodules pandoc-types citeproc-hs
- (cabal-dev --version || (cabal update && cabal install cabal-dev)) && \
- cabal-dev update && \
- cabal-dev install-deps --enable-library-profiling --enable-tests --enable-benchmarks
-
-submodules:
- git submodule update --init
-
-quick:
- cabal-dev configure --enable-tests --disable-optimization && cabal-dev build
-
-relocatable:
- cabal-dev configure -fembed_data_files && cabal-dev build
-
-bench:
- cabal-dev configure --enable-benchmarks && cabal-dev build
-
-sdist:
- dist/setup/setup sdist
- # cabal sdist won't work, see https://github.com/haskell/cabal/issues/403
-
-clean:
- cabal-dev clean
-
-veryclean: clean
- cabal-dev clean && rm -rf pandoc-types citeproc-hs
-
-pandoc-types:
- git clone https://github.com/jgm/pandoc-types && \
- cabal-dev add-source pandoc-types
-
-citeproc-hs: pandoc-types
- darcs get --lazy http://gorgias.mine.nu/repos/citeproc-hs && \
- cabal-dev add-source citeproc-hs
-
-install:
- cabal-dev install --enable-tests --enable-benchmarks
diff --git a/README b/README
index 43e522976..80371e6f7 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
% Pandoc User's Guide
% John MacFarlane
-% January 19, 2013
+% May 16, 2014
Synopsis
========
@@ -13,14 +13,15 @@ Description
Pandoc is a [Haskell] library for converting from one markup format to
another, and a command-line tool that uses this library. It can read
[markdown] and (subsets of) [Textile], [reStructuredText], [HTML],
-[LaTeX], [MediaWiki markup], [Haddock markup], [OPML], and [DocBook]; and
-it can write plain text, [markdown], [reStructuredText], [XHTML], [HTML 5],
-[LaTeX] (including [beamer] slide shows), [ConTeXt], [RTF], [OPML], [DocBook],
+[LaTeX], [MediaWiki markup], [Haddock markup], [OPML], [Emacs
+Org-mode], [DocBook], and [Word docx]; and it can write plain text,
+[markdown], [reStructuredText], [XHTML], [HTML 5], [LaTeX] (including
+[beamer] slide shows), [ConTeXt], [RTF], [OPML], [DocBook],
[OpenDocument], [ODT], [Word docx], [GNU Texinfo], [MediaWiki markup],
-[EPUB] (v2 or v3), [FictionBook2], [Textile], [groff man] pages, [Emacs
-Org-Mode], [AsciiDoc], and [Slidy], [Slideous], [DZSlides], [reveal.js]
-or [S5] HTML slide shows. It can also produce [PDF] output on systems
-where LaTeX is installed.
+[Haddock markup], [EPUB] (v2 or v3), [FictionBook2], [Textile],
+[groff man] pages, [Emacs Org-Mode], [AsciiDoc], [InDesign ICML],
+and [Slidy], [Slideous], [DZSlides], [reveal.js] or [S5] HTML slide shows.
+It can also produce [PDF] output on systems where LaTeX is installed.
Pandoc's enhanced version of markdown includes syntax for footnotes,
tables, flexible ordered lists, definition lists, fenced code blocks,
@@ -108,7 +109,7 @@ to 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: `amssymb`, `amsmath`, `ifxetex`, `ifluatex`, `listings` (if the
-`--listings` option is used), `fancyvrb`, `longtable`, `url`,
+`--listings` option is used), `fancyvrb`, `longtable`, `booktabs`, `url`,
`graphicx`, `hyperref`, `ulem`, `babel` (if the `lang` variable is set),
`fontspec` (if `xelatex` or `lualatex` is used as the LaTeX engine), `xltxtra`
and `xunicode` (if `xelatex` is used).
@@ -143,14 +144,14 @@ General options
`markdown_phpextra` (PHP Markdown Extra extended markdown),
`markdown_github` (github extended markdown),
`textile` (Textile), `rst` (reStructuredText), `html` (HTML),
- `docbook` (DocBook), `opml` (OPML), `mediawiki` (MediaWiki 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](#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`
+ `docbook` (DocBook), `opml` (OPML), `org` (Emacs Org-mode),
+ `mediawiki` (MediaWiki 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](#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
@@ -168,22 +169,22 @@ General options
`context` (ConTeXt), `man` (groff man), `mediawiki` (MediaWiki markup),
`textile` (Textile), `org` (Emacs Org-Mode), `texinfo` (GNU Texinfo),
`opml` (OPML), `docbook` (DocBook), `opendocument` (OpenDocument), `odt`
- (OpenOffice text document), `docx` (Word docx),
- `rtf` (rich text format), `epub` (EPUB v2 book), `epub3`
- (EPUB v3), `fb2` (FictionBook2 e-book), `asciidoc` (AsciiDoc), `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](#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`, `html`, or
- `html5`, the output will be rendered as literate Haskell source: see
- [Literate Haskell support](#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`.
+ (OpenOffice text document), `docx` (Word docx), `haddock` (Haddock
+ markup), `rtf` (rich text format), `epub` (EPUB v2 book), `epub3`
+ (EPUB v3), `fb2` (FictionBook2 e-book), `asciidoc` (AsciiDoc),
+ `icml` (InDesign ICML), `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](#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`,
+ `html`, or `html5`, the output will be rendered as literate Haskell
+ source: see [Literate Haskell support](#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`.
`-o` *FILE*, `--output=`*FILE*
: Write output to *FILE* instead of *stdout*. If *FILE* is
@@ -259,6 +260,42 @@ Reader options
require different kinds of images. Currently this option only affects
the markdown and LaTeX readers.
+`--filter=`*EXECUTABLE*
+: 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. See
+ <http://github.com/jgm/pandocfilters> for the module and several
+ examples. Note that the *EXECUTABLE* will be sought in the user's
+ `PATH`, and not in the working directory, if no directory is
+ provided. If you want to run a script in the working directory,
+ preface the filename with `./`.
+
+`-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).
+
`--normalize`
: Normalize the document after reading: merge adjacent
`Str` or `Emph` elements, for example, and remove repeated `Space`s.
@@ -271,6 +308,17 @@ Reader options
`--tab-stop=`*NUMBER*
: Specify the number of spaces per tab (default is 4).
+`--track-changes=`*accept|reject|all*
+: Specifies what to do with insertions and deletions 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. *all* puts in both insertions
+ and deletions, wrapped in spans with `insertion` and `deletion`
+ 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.
+
General writer options
----------------------
@@ -303,9 +351,8 @@ General writer options
: Print the default template for an output *FORMAT*. (See `-t`
for a list of possible *FORMAT*s.)
-`--print-sample-lua-writer`
-: Print a sample lua custom writer (see [Custom writers](#custom-writers),
- below.
+`--print-default-data-file=`*FILE*
+: Print a default data file.
`--no-wrap`
: Disable text wrapping in output. By default, text is wrapped
@@ -318,7 +365,7 @@ General writer options
: Include an automatically generated table of contents (or, in
the case of `latex`, `context`, and `rst`, an instruction to create
one) in the output document. This option has no effect on `man`,
- `docbook`, `slidy`, `slideous`, or `s5` output.
+ `docbook`, `slidy`, `slideous`, `s5`, `docx`, or `odt` output.
`--toc-depth=`*NUMBER*
: Specify the number of section levels to include in the table
@@ -399,8 +446,8 @@ Options affecting specific writers
`--chapters`
: Treat top-level headers as chapters in LaTeX, ConTeXt, and DocBook
output. When the LaTeX template uses the report, book, or
- memoir class, this option is implied. If `--beamer` is used,
- top-level headers will become `\part{..}`.
+ memoir class, this option is implied. If `beamer` is the output
+ format, top-level headers will become `\part{..}`.
`-N`, `--number-sections`
: Number section headings in LaTeX, ConTeXt, HTML, or EPUB output.
@@ -471,7 +518,7 @@ Options affecting specific writers
`-c` *URL*, `--css=`*URL*
: Link to a CSS style sheet. This option can be be used repeatedly to
- include multiple files. They will be included in the order specified.
+ include multiple files. They will be included in the order specified.
`--reference-odt=`*FILE*
: Use the specified file as a style reference in producing an ODT.
@@ -487,7 +534,8 @@ Options affecting specific writers
: 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 are used in the new docx. If no
+ 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
@@ -506,7 +554,9 @@ Options affecting specific writers
`--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.
+ 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.
@@ -525,6 +575,10 @@ Options affecting specific writers
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. To use embedded fonts, you
@@ -575,58 +629,32 @@ Citation rendering
------------------
`--bibliography=`*FILE*
-: Specify bibliography database to be used in resolving
- citations. The database type will be determined from the
- extension of *FILE*, which may be `.mods` (MODS format),
- `.bib` (BibLaTeX format, which will normally work for BibTeX
- files as well), `.bibtex` (BibTeX format),
- `.ris` (RIS format), `.enl` (EndNote format),
- `.xml` (EndNote XML format), `.wos` (ISI format),
- `.medline` (MEDLINE format), `.copac` (Copac format),
- or `.json` (citeproc JSON). If you want to use multiple
- bibliographies, just use this option repeatedly.
+: 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`.)
`--csl=`*FILE*
-: Specify [CSL] style to be used in formatting citations and
- the bibliography. If *FILE* is not found, pandoc will look
- for it in
-
- $HOME/.csl
-
- in unix,
-
- C:\Documents And Settings\USERNAME\Application Data\csl
-
- in Windows XP, and
-
- C:\Users\USERNAME\AppData\Roaming\csl
-
- in Windows 7. If the `--csl` option is not specified, pandoc
- will use a default style: either `default.csl` in the
- user data directory (see `--data-dir`), or, if that is
- not present, the Chicago author-date style.
+: 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`.)
`--citation-abbreviations=`*FILE*
-: Specify a file containing abbreviations for journal titles and
- other bibliographic fields (indicated by setting `form="short"`
- in the CSL node for the field). The format is described at
- <http://citationstylist.org/2011/10/19/abbreviations-for-zotero-test-release/>.
- Here is a short example:
-
- { "default": {
- "container-title": {
- "Lloyd's Law Reports": "Lloyd's Rep",
- "Estates Gazette": "EG",
- "Scots Law Times": "SLT"
- }
- }
- }
+: 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`.)
`--natbib`
-: Use natbib for citations in LaTeX output.
+: 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 pdflatex and
+ bibtex.
`--biblatex`
-: Use biblatex for citations in LaTeX output.
+: 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 pdflatex and
+ bibtex or biber.
Math rendering in HTML
----------------------
@@ -755,29 +783,41 @@ as `title`, `author`, and `date`) as well as the following:
: base URL for Slidy documents (defaults to
`http://www.w3.org/Talks/Tools/Slidy2`)
`slideous-url`
-: base URL for Slideous documents (defaults to `default`)
+: base URL for Slideous documents (defaults to `slideous`)
`s5-url`
-: base URL for S5 documents (defaults to `ui/default`)
+: base URL for S5 documents (defaults to `s5/default`)
`revealjs-url`
: base URL for reveal.js documents (defaults to `reveal.js`)
`theme`
-: reveal.js theme
+: reveal.js or LaTeX beamer theme
`transition`
: reveal.js transition
`fontsize`
: font size (10pt, 11pt, 12pt) for LaTeX documents
`documentclass`
: document class for LaTeX documents
+`classoption`
+: option for LaTeX documentclass, e.g. `oneside`; may be repeated
+ for multiple options
`geometry`
: options for LaTeX `geometry` class, e.g. `margin=1in`;
may be repeated for multiple options
+`linestretch`
+: adjusts line spacing (requires the `setspace` package)
+`fontfamily`
+: font package to use for LaTeX documents (with pdflatex):
+ TeXLive has `bookman` (Bookman), `utopia` or `fourier` (Utopia),
+ `fouriernc` (New Century Schoolbook), `times` or `txfonts` (Times),
+ `mathpazo` or `pxfonts` or `mathpple` (Palatino),
+ `libertine` (Linux Libertine), `arev` (Arev Sans),
+ and the default `lmodern`, among others.
`mainfont`, `sansfont`, `monofont`, `mathfont`
: fonts for LaTeX documents (works only with xelatex
and lualatex)
-`theme`
-: theme for LaTeX beamer documents
`colortheme`
: colortheme for LaTeX beamer documents
+`fonttheme`
+: fonttheme for LaTeX beamer documents
`linkcolor`
: color for internal links in LaTeX documents (`red`, `green`,
`magenta`, `cyan`, `blue`, `black`)
@@ -787,6 +827,10 @@ as `title`, `author`, and `date`) as well as the following:
: color for citation links in LaTeX documents
`links-as-notes`
: causes links to be printed as footnotes in LaTeX documents
+`biblio-style`
+: bibliography style in LaTeX, when used with `--natbib`
+`biblio-files`
+: bibliography files to use in LaTeX, with `--natbib` or `--biblatex`
`section`
: section number in man pages
`header`
@@ -880,6 +924,9 @@ 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
-------
@@ -889,7 +936,7 @@ 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) of `-` signs (for a level two header):
+(for a level one header) or `-` signs (for a level two header):
A level-one header
==================
@@ -936,10 +983,8 @@ of the line containing the header text:
{#identifier .class .class key=value key=value}
-Although this syntax allows assignment of classes and key/value attributes,
-only identifiers currently have any affect in the writers (and only in some
-writers: HTML, LaTeX, ConTeXt, Textile, AsciiDoc). Thus, for example,
-the following headers will all be assigned the identifier `foo`:
+Thus, for example, the following headers will all be assigned the identifier
+`foo`:
# My header {#foo}
@@ -950,6 +995,12 @@ the following headers will all be assigned the identifier `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
@@ -968,6 +1019,7 @@ 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.
@@ -1262,7 +1314,7 @@ one tab:
+ pears
+ peaches
* vegetables
- + brocolli
+ + broccoli
+ chard
As noted above, markdown allows you to write list items "lazily," instead of
@@ -1337,6 +1389,12 @@ capital letter with a period, by at least two spaces.[^2]
(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
@@ -1779,14 +1837,21 @@ YAML metadata block
**Extension: `yaml_metadata_block`**
-If the file begins with a YAML object, delimited by a line of three
-hyphens (`---`) at the top and a line of three hyphens (`---`) or three
-dots (`...`) at the bottom, metadata will be taken from the fields
-of the YAML object. Metadata can contain lists and objects (nested
-arbitrarily), but all string scalars will be interpreted as markdown.
+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.
+
+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.)
-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.
Note that YAML escaping rules must be followed. Thus, for example,
if a title contains a colon, it must be quoted. The pipe character
@@ -1794,27 +1859,39 @@ if a title contains a colon, it must be quoted. The pipe character
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:
- - name: Author One
- affiliation: University of Somewhere
- - name: Author Two
- affiliation: University of Nowhere
- tags: [nothing, nothingness]
- abstract: |
- This is the abstract.
-
- It consists of two paragraphs.
- ...
-
-Template variables will be set from the metadata. Thus, for example,
-in writing HTML, the variable `abstract` will be set to the HTML
+ ---
+ title: 'This is the title: it contains a colon'
+ author:
+ - name: Author One
+ affiliation: University of Somewhere
+ - name: Author Two
+ affiliation: University of Nowhere
+ 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>
+Note: The `author` variable in the default templates expects a simple list or
+string. To use the structured authors in the example, you would need a
+custom template. For example:
+
+ $for(author)$
+ $if(author.name)$
+ $author.name$$if(author.affiliation)$ ($author.affiliation$)$endif$
+ $else$
+ $author$
+ $endif$
+ $endfor$
+
Backslash escapes
-----------------
@@ -1954,6 +2031,14 @@ Attributes can be attached to verbatim text, just as with
`<$>`{.haskell}
+### Small caps ###
+
+To write small caps, you can use an HTML span tag:
+
+ <span style="font-variant:small-caps;">Small caps</span>
+
+This will work in all output formats that support small caps.
+
Math
----
@@ -2063,7 +2148,7 @@ Raw HTML
Markdown allows you to insert raw HTML (or DocBook) anywhere in a document
(except verbatim contexts, where `<`, `>`, and `&` are interpreted
-literally). (Techncially this is not an extension, since standard
+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.)
@@ -2335,9 +2420,14 @@ Citations
**Extension: `citations`**
-Pandoc can automatically generate citations and a bibliography in a number of
-styles (using Andrea Rossato's `hs-citeproc`). In order to use this feature,
-you will need a bibliographic database in one of the following formats:
+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.
+The bibliography may have any of these formats:
Format File extension
------------ --------------
@@ -2355,23 +2445,47 @@ you will need a bibliographic database in one of the following formats:
Note that `.bib` can generally be used with both BibTeX and BibLaTeX
files, but you can use `.bibtex` to force BibTeX.
-You will need to specify the bibliography file using the `--bibliography`
-command-line option (which may be repeated if you have several
-bibliographies).
+Alternatively you can use a `references` field in the document's YAML
+metadata. This should include an array of YAML-encoded references,
+for example:
-By default, pandoc will use a Chicago author-date format for citations
-and references. To use another style, you will need to use the
-`--csl` option to specify a [CSL] 1.0 style file. A primer on
-creating and modifying CSL styles can be found at
-<http://citationstyles.org/downloads/primer.html>.
-A repository of CSL styles can be found at
-<https://github.com/citation-style-language/styles>.
-See also <http://zotero.org/styles> for easy browsing.
+ ---
+ references:
+ - id: fenner2012a
+ title: One-click science marketing
+ author:
+ - family: Fenner
+ given: Martin
+ container-title: Nature Materials
+ volume: 11
+ URL: 'http://dx.doi.org/10.1038/nmat3283'
+ DOI: 10.1038/nmat3283
+ issue: 4
+ publisher: Nature Publishing Group
+ page: 261-263
+ type: article-journal
+ issued:
+ year: 2012
+ month: 3
+ ...
+
+(The program `mods2yaml`, which comes with `pandoc-citeproc`, can help produce
+these from a MODS reference collection.)
+
+By default, `pandoc-citeproc` will use a Chicago author-date format for
+citations and references. To use another style, you will need to specify
+a [CSL] 1.0 style file in the `csl` metadata field. A primer on creating and
+modifying CSL styles can be found at
+<http://citationstyles.org/downloads/primer.html>. A repository of CSL styles
+can be found at <https://github.com/citation-style-language/styles>. See also
+<http://zotero.org/styles> for easy browsing.
Citations go inside square brackets and are separated by semicolons.
Each citation must have a key, composed of '@' + the citation
identifier from the database, and may optionally have a prefix,
-a locator, and a suffix. Here are some examples:
+a locator, and a suffix. The citation key must begin with a letter
+or `_`, and may contain alphanumerics, `_`, and internal punctuation
+characters (`:.#$%&-+?<>~/`). Here are some examples:
Blah blah [see @doe99, pp. 33-35; also @smith04, ch. 1].
@@ -2399,7 +2513,24 @@ document with an appropriate header:
# References
-The bibliography will be inserted after this header.
+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`.
Non-pandoc extensions
---------------------
@@ -2409,10 +2540,20 @@ 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: `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: `tex_math_single_backslash`**\
Causes anything between `\(` and `\)` to be interpreted as inline
TeX math, and anything between `\[` and `\]` to be interpreted
@@ -2439,10 +2580,9 @@ the document, for example:
Comment: This is a sample mmd title block, with
a field spanning multiple lines.
-See the MultiMarkdown documentation for details. Note that only title,
-author, and date are recognized; other fields are simply ignored by
-pandoc. If `pandoc_title_block` or `yaml_metadata_block` is enabled,
-it will take precedence over `mmd_title_block`.
+See the MultiMarkdown documentation for details. If `pandoc_title_block` or
+`yaml_metadata_block` is enabled, it will take precedence over
+`mmd_title_block`.
[MultiMarkdown]: http://fletcherpenney.net/multimarkdown/
@@ -2500,6 +2640,20 @@ variants are supported:
`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
=================================
@@ -2625,9 +2779,8 @@ a single document.
Inserting pauses
----------------
-In reveal.js and beamer slide shows, you can add "pauses" within
-a slide by including a paragraph containing three dots, separated
-by spaces:
+You can add "pauses" within a slide by including a paragraph containing
+three dots, separated by spaces:
# Slide with a pause
@@ -2663,11 +2816,109 @@ 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.
+
+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. 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: (c) 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](http://www.loc.gov/marc/relators/relaterm.html), 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.
+`language`
+ ~ A string value in [RFC5646] 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).
+
Literate Haskell support
========================
If you append `+lhs` (or `+literate_haskell`) to an appropriate input or output
-format (`markdown`, `mardkown_strict`, `rst`, or `latex` for input or output;
+format (`markdown`, `markdown_strict`, `rst`, or `latex` for input or output;
`beamer`, `html` or `html5` for output only), pandoc will treat the document as
literate Haskell source. This means that
@@ -2724,7 +2975,7 @@ 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-sample-lua-writer
+ pandoc --print-default-data-file sample.lua
Authors
=======
@@ -2738,7 +2989,9 @@ Puneeth Chaganti, Paul Rivier, rodja.trappe, Bradley Kuhn, thsutton,
Nathan Gass, Jonathan Daugherty, Jérémy Bobbio, Justin Bogner, qerub,
Christopher Sawicki, Kelsey Hightower, Masayoshi Takahashi, Antoine
Latter, Ralf Stephan, Eric Seidel, B. Scott Michel, Gavin Beatty,
-Sergey Astanin, Arlo O'Keeffe, Denis Laxalde, Brent Yorgey.
+Sergey Astanin, Arlo O'Keeffe, Denis Laxalde, Brent Yorgey, David Lazar,
+Jamie F. Olson, Matthew Pickering, Albert Krewinkel, mb21, Jesse
+Rosenthal.
[markdown]: http://daringfireball.net/projects/markdown/
[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
@@ -2772,5 +3025,7 @@ Sergey Astanin, Arlo O'Keeffe, Denis Laxalde, Brent Yorgey.
[PDF]: http://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
-[lua]: TODO
-
+[lua]: http://www.lua.org
+[marc relators]: http://www.loc.gov/marc/relators/relaterm.html
+[RFC5646]: http://tools.ietf.org/html/rfc5646
+[InDesign ICML]: https://www.adobe.com/content/dam/Adobe/en/devnet/indesign/cs55-docs/IDML/idml-specification.pdf
diff --git a/RELEASE-CHECKLIST b/RELEASE-CHECKLIST
index 80a6738a5..af0102622 100644
--- a/RELEASE-CHECKLIST
+++ b/RELEASE-CHECKLIST
@@ -16,6 +16,8 @@ _ Upload to Google Code (googlecode-upload.sh)
_ Go to Google code and deprecate the old versions
+- Add release on github (and upload files)
+
_ Upload to HackageDB
_ Update website, including short description of changes
diff --git a/Setup.hs b/Setup.hs
index 4245df203..c1c3f6472 100644
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,16 +1,34 @@
{-# LANGUAGE CPP #-}
+{-
+Copyright (C) 2006-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 Distribution.Simple
import Distribution.Simple.PreProcess
import Distribution.Simple.Setup
- (copyDest, copyVerbosity, fromFlag, installVerbosity, BuildFlags(..))
+ (copyDest, copyVerbosity, fromFlag, installVerbosity, BuildFlags(..),
+ TestFlags(..))
import Distribution.PackageDescription (PackageDescription(..), Executable(..))
import Distribution.Simple.LocalBuildInfo
(LocalBuildInfo(..), absoluteInstallDirs)
import Distribution.Verbosity ( Verbosity, silent )
-import Distribution.Simple.InstallDirs (mandir, CopyDest (NoCopyDest))
+import Distribution.Simple.InstallDirs (mandir, CopyDest (NoCopyDest), toPathTemplate)
import Distribution.Simple.Utils (installOrdinaryFiles, info)
-import Prelude hiding (catch)
+import Distribution.Simple.Test (test)
import System.Process ( rawSystem )
import System.FilePath ( (</>) )
import System.Directory ( findExecutable )
@@ -20,6 +38,10 @@ main :: IO ()
main = do
defaultMainWithHooks $ simpleUserHooks {
postBuild = makeManPages
+ , testHook = \pkg lbi _ flags ->
+ -- pass build directory as first argument to test program
+ test pkg lbi flags{ testOptions =
+ toPathTemplate (buildDir lbi) : testOptions flags }
, postCopy = \ _ flags pkg lbi ->
installManpages pkg lbi (fromFlag $ copyVerbosity flags)
(fromFlag $ copyDest flags)
diff --git a/benchmark/benchmark-pandoc.hs b/benchmark/benchmark-pandoc.hs
index 60b543e1a..9238b09d7 100644
--- a/benchmark/benchmark-pandoc.hs
+++ b/benchmark/benchmark-pandoc.hs
@@ -1,3 +1,20 @@
+{-
+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 Criterion.Main
import Criterion.Config
@@ -31,8 +48,8 @@ main = do
inp2 <- readFile "tests/testsuite.txt"
let opts = def{ readerSmart = True }
let doc = readMarkdown opts $ inp ++ unlines (drop 3 $ lines inp2)
- let readerBs = map (readerBench doc) readers
+ let readerBs = map (readerBench doc)
+ $ filter (\(n,_) -> n /="haddock") readers
let writers' = [(n,w) | (n, PureStringWriter w) <- writers]
defaultMainWith conf (return ()) $
map (writerBench doc) writers' ++ readerBs
-
diff --git a/changelog b/changelog
index 1f96011cd..fe3b1845b 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,1364 @@
+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 (mb21).
+
+ * MediaWiki reader:
+
+ + Accept image links in more languages (Jaime Marquínez Ferrándiz).
+ + Fixed bug in certain nested lists (#1213). If a level 2 list was
+ followed by a level 1 list, the first item of the level 1 list
+ would be lost.
+ + Handle table rows containing just an HTML comment (#1230).
+
+ * LaTeX reader:
+
+ + Give better location information on errors, pointing to line
+ numbers within included files (#1274).
+ + LaTeX reader: Better handling of `table` environment (#1204).
+ Positioning options no longer rendered verbatim.
+ + Better handling of figure and table with caption (#1204).
+ + Handle `@{}` and `p{length}` in tabular. The length is not actually
+ recorded, but at least we get a table (#1180).
+ + Properly handle `\nocite`. It now adds a `nocite` metadata
+ field. Citations there will appear in the bibliography but not
+ in the text (unless you explicitly put a `$nocite$` variable
+ in your template).
+
+ * Markdown reader:
+
+ + Ensure that whole numbers in YAML metadata are rendered without
+ decimal points. (This became necessary with changes to aeson
+ and yaml libraries. aeson >= 0.7 and yaml >= 0.8.8.2 are now required.)
+ + Fixed regression on line breaks in strict mode (#1203).
+ + Small efficiency improvements.
+ + Improved parsing of nested `div`s. Formerly a closing `div` tag
+ would be missed if it came right after other block-level tags.
+ + Avoid backtracking when closing `</div>` not found.
+ + Fixed bug in reference link parsing in `markdown_mmd`.
+ + Fixed a bug in list parsing (#1154). When reading a raw list
+ item, we now strip off up to 4 spaces.
+ + Fixed parsing of empty reference link definitions (#1186).
+ + Made one-column pipe tables work (#1218).
+
+ * Textile reader:
+
+ + Better support for attributes. Instead of being ignored, attributes
+ are now parsed and included in Span inlines. The output will be a bit
+ different from stock textile: e.g. for `*(foo)hi*`, we'll get
+ `<em><span class="foo">hi</span></em>` instead of
+ `<em class="foo">hi</em>`. But at least the data is not lost.
+ + Improved treatment of HTML spans (%) (#1115).
+ + Improved link parsing. In particular we now pick up on attributes.
+ Since pandoc links can't have attributes, we enclose the whole link in
+ a span if there are attributes (#1008).
+ + Implemented correct parsing rules for inline markup (#1175, Matthew
+ Pickering).
+ + Use Builder (Matthew Pickering).
+
+ * DocBook reader:
+
+ + Better treatment of `formalpara`. We now emit the title (if present)
+ as a separate paragraph with boldface text (#1215).
+ + Set metadata `author` not `authors`.
+ + Added recognition of `authorgroup` and `releaseinfo` elements (#1214,
+ Matthew Pickering).
+ + Converted current meta information parsing in DocBook to a more
+ extensible version which is aware of the more recent meta
+ representation (Matthew Pickering).
+
+ * HTML reader:
+
+ + Require tagsoup 0.13.1, to fix a bug with parsing of script tags
+ (#1248).
+ + Treat processing instructions & declarations as block. Previously
+ these were treated as inline, and included in paragraph tags in HTML
+ or DocBook output, which is generally not what is wanted (#1233).
+ + Updated `closes` with rules from HTML5 spec.
+ + Use Builder (Matthew Pickering, #1162).
+
+ * RST reader:
+
+ + Remove duplicate `http` in PEP links (Albert Krewinkel).
+ + Make rst figures true figures (#1168, CasperVector)
+ + Enhanced Pandoc's support for rST roles (Merijn Verstaaten).
+ rST parser now supports: all built-in rST roles, new role definition,
+ role inheritance, though with some limitations.
+ + Use `author` rather than `authors` in metadata.
+ + Better handling of directives. We now correctly handle field
+ lists that are indented more than three spaces. We treat an
+ `aafig` directive as a code block with attributes, so it can be
+ processed in a filter (#1212).
+
+ * LaTeX writer:
+
+ + Mark span contents with label if span has an ID (Albert Krewinkel).
+ + Made `--toc-depth` work well with books in latex/pdf output (#1210).
+ + Handle line breaks in simple table cells (#1217).
+ + Workaround for level 4-5 headers in quotes. These previously produced
+ invalid LaTeX: `\paragraph` or `\subparagraph` in a `quote` environment.
+ This adds an `mbox{}` in these contexts to work around the problem.
+ See <http://tex.stackexchange.com/a/169833/22451> (#1221).
+ + Use `\/` to avoid en-dash ligature instead of `-{}-` (Vaclav Zeman).
+ This is to fix LuaLaTeX output. The `-{}-` sequence does not avoid the
+ ligature with LuaLaTeX but `\/` does.
+ + Fixed string escaping in `hyperref` and `hyperdef` (#1130).
+
+ * ConTeXt writer: Improved autolinks (#1270).
+
+ * DocBook writer:
+
+ + Improve handling of hard line breaks in Docbook writer
+ (Neil Mayhew). Use a `<literallayout>` for the entire paragraph, not
+ just for the newline character.
+ + Don't let line breaks inside footnotes influence the enclosing
+ paragraph (Neil Mayhew).
+ + Distinguish tight and loose lists in DocBook output, using
+ `spacing="compact"` (Neil Mayhew, #1250).
+
+ * Docx writer: When needed files are not present in the user's
+ `reference.docx`, fall back on the versions in the `reference.docx`
+ in pandoc's data files. This fixes a bug that occurs when a
+ `reference.docx` saved by LibreOffice is used. (#1185)
+
+ * EPUB writer:
+
+ + Include extension in epub ids. This fixes a problem with duplicate
+ extensions for fonts and images with the same base name but different
+ extensions (#1254).
+ + Handle files linked in raw `img` tags (#1170).
+ + Handle media in `audio` source tags (#1170).
+ Note that we now use a `media` directory rather than `images`.
+ + Incorporate files linked in `video` tags (#1170). `src` and `poster`
+ will both be incorporated into `content.opf` and the epub container.
+
+ * HTML writer:
+
+ + Add colgroup around col tags (#877). Also affects EPUB writer.
+ + Fixed bug with unnumbered section headings. Unnumbered section
+ headings (with class `unnumbered`) were getting numbers.
+ + Improved detection of image links. Previously image links with
+ queries were not recognized, causing `<embed>` to be used instead
+ of `<img>`.
+
+ * Man writer: Ensure that terms in definition lists aren't line wrapped
+ (#1195).
+
+ * Markdown writer:
+
+ + Use proper escapes to avoid unwanted lists (#980). Previously we used
+ 0-width spaces, an ugly hack.
+ + Use longer backtick fences if needed (#1206). If the content contains a
+ backtick fence and there are attributes, make sure longer fences are
+ used to delimit the code. Note: This works well in pandoc, but github
+ markdown is more limited, and will interpret the first string of three
+ or more backticks as ending the code block.
+
+ * RST writer: Avoid stack overflow with certain tables (#1197).
+
+ * RTF writer: Fixed table cells containing paragraphs.
+
+ * Custom writer:
+
+ + Correctly handle UTF-8 in custom lua scripts (#1189).
+ + Fix bugs with lua scripts with mixed-case filenames and
+ paths containing `+` or `-` (#1267). Note that `getWriter`
+ in `Text.Pandoc` no longer returns a custom writer on input
+ `foo.lua`.
+
+ * AsciiDoc writer: Handle multiblock and empty table cells
+ (#1245, #1246). Added tests.
+
+ * `Text.Pandoc.Options`: Added `readerTrace` to `ReaderOptions`
+
+ * `Text.Pandoc.Shared`:
+
+ + Added `compactify'DL` (formerly in markdown reader) (Albert Krewinkel).
+ + Fixed bug in `toRomanNumeral`: numbers ending with '9' would
+ be rendered as Roman numerals ending with 'IXIV' (#1249). Thanks to
+ Jesse Rosenthal.
+ + `openURL`: set proxy with value of http_proxy env variable (#1211).
+ Note: proxies with non-root paths are not supported, due to
+ limitations in `http-conduit`.
+
+ * `Text.Pandoc.PDF`:
+
+ + Ensure that temp directories deleted on Windows (#1192). The PDF is
+ now read as a strict bytestring, ensuring that process ownership will
+ be terminated, so the temp directory can be deleted.
+ + Use `/` as path separators in a few places, even on Windows.
+ This seems to be necessary for texlive (#1151, thanks to Tim Lin).
+ + Use `;` for `TEXINPUTS` separator on Windows (#1151).
+ + Changes to error reporting, to handle non-UTF8 error output.
+
+ * `Text.Pandoc.Templates`:
+
+ + Removed unneeded datatype context (Merijn Verstraaten).
+
+ + YAML objects resolve to "true" in conditionals (#1133).
+ Note: If `address` is a YAML object and you just have `$address$`
+ in your template, the word `true` will appear, which may be
+ unexpected. (Previously nothing would appear.)
+
+ * `Text.Pandoc.SelfContained`: Handle `poster` attribute in `video`
+ tags (#1188).
+
+ * `Text.Pandoc.Parsing`:
+
+ + Made `F` an instance of Applicative (#1138).
+ + Added `stateCaption`.
+ + Added `HasMacros`, simplified other typeclasses.
+ Removed `updateHeaderMap`, `setHeaderMap`, `getHeaderMap`,
+ `updateIdentifierList`, `setIdentifierList`, `getIdentifierList`.
+ + Changed the smart punctuation parser to return `Inlines`
+ rather than `Inline` (Matthew Pickering).
+ + Changed `HasReaderOptions`, `HasHeaderMap`, `HasIdentifierList`
+ from typeclasses of monads to typeclasses of states. This simplifies
+ the instance definitions and provides more flexibility. Generalized
+ type of `getOption` and added a default definition. Removed
+ `askReaderOption`. Added `extractReaderOption`. Added
+ `extractHeaderMap` and `updateHeaderMap` in `HasHeaderMap`.
+ Gave default definitions for `getHeaderMap`, `putHeaderMap`,
+ `modifyHeaderMap`. Added `extractIdentifierList` and
+ `updateIdentifierList` in `HasIdentifierList`. Gave defaults
+ for `getIdentifierList`, `putIdentifierList`, and
+ `modifyIdentifierList`. The ultimate goal here is to allow different
+ parsers to use their own, tailored parser states (instead of
+ `ParserState`) while still using shared functions.
+
+ * Template changes:
+
+ + LaTeX template: Use `fontenc` package only with `pdflatex` (#1164).
+ + LaTeX template: Add `linestretch` and `fontfamily` variables.
+ + LaTeX template: Conditionalize author and date commands.
+ + Beamer template: Consistent styles for figure and table captions
+ (aaronwolen).
+ + LaTeX and beamer template: Adjust widths correctly for oversized
+ images. Use `\setkeys{Gin}{}` to set appropriate defaults for
+ `\includegraphics` (Yihui Xie, Garrick Aden-Buie). Load
+ `upquote` only after `fontenc` (Yihui Xie).
+ + Beamer template: Added caption package (#1200).
+ + Beamer template: changes for better unicode handling (KarolS).
+ + DocBook template: use `authorgroup` if there are authors.
+ + revealjs template: Move `include-after` to end (certainlyakey).
+ + revealjs template: Fixed PDF print function (#1220, kevinkenan).
+
+ * Bumped version bounds of dependencies.
+
+ * Added a `--trace` command line option, for debugging backtracking
+ bugs. So far this only works with the markdown reader.
+
+ * MathMLinHTML: Fixed deprecation warning (#362, gwern, Albert Krewinkel).
+
+ * Updated travis script to test with multiple GHC versions.
+
+ * Force failure of a Travis build if GHC produces warnings (Albert
+ Krewinkel).
+
+ * Add `.editorconfig` (Albert Krewinkel).
+ See <http://editorconfig.org/> for details.
+
+ * Give more useful error message if '-t pdf' is specified (#1155).
+
+ * Added `Cite`, `SmallCaps` to `Arbitrary` instance (#1269).
+
+ * Allow `html4` as a synonym of `html` as a reader (it already works
+ as a writer).
+
+ * README:
+
+ + Added an explanation of how to use YAML metadata to
+ force items to appear in the bibliography without citations in
+ the text (like LaTeX `\nocite`).
+ + Added note to `--bibtex/--natbib`: not for use in making PDF
+ (#1194, thanks to nahoj).
+ + Added explanatory notes about `--natbib` and `--biblatex`.
+ + Added specification of legal syntax for citation keys.
+ + Fixed variable defaults documentation (Albert Krewinkel).
+
+ * Removed copyright statements for files that have been removed
+ (Albert Krewinkel).
+
+ * Moved some doc files from `data-files` to `extra-source-files` (#1123).
+ They aren't needed at runtime. We keep README and COPYRIGHT in data
+ to ensure that they'll be available on all systems on which pandoc
+ is installed.
+
+ * Use cabal sandboxes in Windows build script.
+
+pandoc (1.12.3.3)
+
+ * 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.Pretty`: Added `nestle`. API change.
+
+ * `Text.Pandoc.MIME`: Added `wmf`, `emf`.
+
+ * `Text.Pandoc.Shared`: `fetchItem` now handles image URLs beginning
+ with `//`.
+
+ * `Text.Pandoc.ImageSize`: Parse EXIF format JPEGs. Previously
+ we could only get size information for JFIF format, which led
+ to squished images in Word documents. Closes #976.
+
+ * Removed old `MarkdownTest_1.0.3` directory (#1104).
+
+pandoc (1.12.2.1)
+
+ * 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.Parsing`:
+
+ + Generalized type of `registerHeader`, using new type classes
+ `HasReadeOptions`, `HasIdentifierList`, `HasHeaderMap`.
+ These allow certain common functions to be reused
+ even in parsers that use custom state (instead of `ParserState`),
+ such as the MediaWiki reader.
+ + Moved inlineMath, displayMath from Markdown reader to Parsing.
+ Generalize their types and export them from Parsing. (API change.)
+
+ * `Text.Pandoc.Readers.TexMath`: Export `readTeXMath'`, which attends
+ to display/inline. Deprecate `readTeXMath`, and use `readTeXMath'`
+ in all the writers. Require `texmath >= 0.6.5.2`.
+
+ * `Text.Pandoc.MIME`:
+
+ + Add entry for `jfif`.
+ + In looking up extensions, drop the encoding info.
+ E.g. for 'image/jpg;base64' we should lookup 'image/jpg'.
+
+ * Templates: Changed how array variables are resolved. Previously if
+ `foo` is an array (which might be because multiple values were set on
+ the command line), `$foo$` would resolve to the concatenation of the
+ elements of foo. This is rarely useful behavior. It has been changed
+ so that the first value is rendered. Of course, you can still iterate
+ over the values using `$for(foo)$`. This has the result that you can
+ override earlier settings using `-V` by putting new values later on the
+ command line, which is useful for many purposes.
+
+ * `Text.Pandoc`: Don't default to `pandocExtensions` for all writers.
+
+ * Allow "epub2" as synonym for "epub", "html4" for "html".
+
+ * Don't look for slidy files in data files with `--self-contained`.
+
+ * Allow `https:` command line arguments to be downloaded.
+
+ * Fixed `make_osx_package.sh` so data files embedded in `pandoc-citeproc`.
+
+pandoc (1.12.1)
+
+ * `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:
@@ -10,7 +1371,7 @@ pandoc (1.11.1)
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.
@@ -45,7 +1406,7 @@ 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.
@@ -96,7 +1457,7 @@ pandoc (1.11)
+ 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.
@@ -122,7 +1483,7 @@ pandoc (1.11)
Closes #723.
* Textile reader:
-
+
+ Handle attributes on headers.
* LaTeX reader:
@@ -155,7 +1516,7 @@ pandoc (1.11)
`unnumbered` class.
* Textile writer:
-
+
+ Support header attributes.
* Markdown writer:
@@ -169,11 +1530,11 @@ pandoc (1.11)
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).
@@ -191,7 +1552,7 @@ pandoc (1.11)
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.
@@ -214,7 +1575,7 @@ pandoc (1.11)
section number.
* `Text.Pandoc.Pretty`:
-
+
+ Fixed `chomp` so it works inside `Prefixed` elements.
+ Changed `Show` instance so it is better for debugging.
@@ -284,7 +1645,7 @@ pandoc (1.10.1)
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`.
@@ -307,7 +1668,7 @@ pandoc (1.10.0.5)
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}`).
@@ -338,7 +1699,7 @@ pandoc (1.10.0.5)
`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.
@@ -1090,19 +2451,19 @@ pandoc (1.9.4.2)
checks for the base version that intelligibly enable encoding/decoding
when needed. Fixes a bug with multilingual filenames when pandoc was
compiled with ghc 7.4 (#540).
-
+
* Don't generate an empty H1 after hrule slide breaks.
We now use a slide-level header with contents `[Str "\0"]` to mark
an hrule break. This avoids creation of an empty H1 in these
contexts. Closes #484.
-
+
* Docbook reader: Added support for "bold" emphasis. Thanks to mb21.
-
+
* In make_osx_package.sh, ensure citeproc-hs is built with the
embed_data_files flag.
-
+
* MediaWiki writer: Avoid extra blank lines after sublists (Gavin Beatty).
-
+
* ConTeXt writer: Don't escape `&`, `^`, `<`, `>`, `_`,
simplified escapes for `}` and `{` to `\{` and `\}` (Aditya Mahajan).
@@ -1113,7 +2474,7 @@ pandoc (1.9.4.2)
* 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)
@@ -1131,7 +2492,7 @@ pandoc (1.9.4.1)
+ 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]`.
@@ -1435,12 +2796,12 @@ pandoc (1.9.1.1)
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):
@@ -1659,7 +3020,7 @@ pandoc (1.9)
</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
@@ -2835,7 +4196,7 @@ pandoc (1.5.1.1)
[ John MacFarlane ]
- * Fixed uniqueIdent in Shared so that header identifiers work as
+ * Fixed uniqueIdent in Shared so that header identifiers work as
advertized in the README and are are valid XHTML names.
pandoc (1.5.1)
@@ -4077,7 +5438,7 @@ pandoc (0.46) unstable; urgency=low
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>).
+ + Fixed bug (emph parser was looking for `<IT>` tag, not `<I>`).
+ Don't interpret contents of style tags as markdown.
(Resolves Issue #40.)
@@ -4162,15 +5523,15 @@ pandoc (0.45) unstable; urgency=low
+ 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
+ + 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
+ + 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
+ + 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.
@@ -4184,13 +5545,13 @@ pandoc (0.45) unstable; urgency=low
+ 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
+ + 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.
+ 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.
+ `<pre>...</pre>` in codeBlock parser.
* Markdown reader:
@@ -4512,8 +5873,8 @@ pandoc (0.43) unstable; urgency=low
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'.
+ 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].
@@ -4521,7 +5882,7 @@ pandoc (0.43) unstable; urgency=low
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>.
+ ` h ``` i ` -> `<code>h ``` i</code>`.
+ Split 'title' into 'linkTitle' and 'referenceTitle', since the
rules are slightly different.
+ Rewrote 'para' for greater efficiency.
@@ -4628,7 +5989,7 @@ pandoc (0.41) unstable; urgency=low
[ John MacFarlane ]
* Fixed bugs in HTML reader:
- + Skip material at end *only if* </html> is present (previously,
+ + 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
@@ -4837,9 +6198,9 @@ pandoc (0.4) unstable; urgency=low
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.
+ 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),
@@ -4903,7 +6264,7 @@ pandoc (0.4) unstable; urgency=low
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
+ 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.
@@ -4935,8 +6296,8 @@ pandoc (0.4) unstable; urgency=low
+ 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>.
+ + Use autolinks when possible. Instead of `[site.com](site.com)`,
+ use `<site.com>`.
* LaTeX writer:
@@ -5152,7 +6513,7 @@ pandoc (0.3) unstable; urgency=low
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.
+ + 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.
@@ -5182,7 +6543,7 @@ pandoc (0.3) unstable; urgency=low
* 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
+ 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.
diff --git a/data/MathMLinHTML.js b/data/MathMLinHTML.js
index ad718cf7e..2ab05c686 100644
--- a/data/MathMLinHTML.js
+++ b/data/MathMLinHTML.js
@@ -1,4 +1,4 @@
-/*
+/*
March 19, 2004 MathHTML (c) 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)
@@ -7,15 +7,15 @@ for more details.
function convertMath(node) {// for Gecko
if (node.nodeType==1) {
- var newnode =
+ var newnode =
document.createElementNS("http://www.w3.org/1998/Math/MathML",
node.nodeName.toLowerCase());
for(var i=0; i < node.attributes.length; i++)
newnode.setAttribute(node.attributes[i].nodeName,
- node.attributes[i].nodeValue);
+ node.attributes[i].value);
for (var i=0; i<node.childNodes.length; i++) {
var st = node.childNodes[i].nodeValue;
- if (st==null || st.slice(0,1)!=" " && st.slice(0,1)!="\n")
+ if (st==null || st.slice(0,1)!=" " && st.slice(0,1)!="\n")
newnode.appendChild(convertMath(node.childNodes[i]));
}
return newnode;
@@ -37,14 +37,14 @@ function convert() {
if (st=="#text") str += node.nodeValue;
else {
str += (st.slice(0,1)=="/" ? "</m:"+st.slice(1) : "<m:"+st);
- if (st.slice(0,1)!="/")
+ if (st.slice(0,1)!="/")
for(var j=0; j < node.attributes.length; j++)
- if (node.attributes[j].nodeValue!="italic" &&
- node.attributes[j].nodeValue!="" &&
- node.attributes[j].nodeValue!="inherit" &&
- node.attributes[j].nodeValue!=undefined)
+ if (node.attributes[j].value!="italic" &&
+ node.attributes[j].value!="" &&
+ node.attributes[j].value!="inherit" &&
+ node.attributes[j].value!=undefined)
str += " "+node.attributes[j].nodeName+"="+
- "\""+node.attributes[j].nodeValue+"\"";
+ "\""+node.attributes[j].value+"\"";
str += ">";
}
node = node.nextSibling;
diff --git a/data/default.csl b/data/default.csl
deleted file mode 100644
index 83a70d0b5..000000000
--- a/data/default.csl
+++ /dev/null
@@ -1,458 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never">
- <info>
- <title>Chicago Manual of Style (author-date)</title>
- <id>http://www.zotero.org/styles/chicago-author-date</id>
- <link href="http://www.zotero.org/styles/chicago-author-date" rel="self"/>
- <link href="http://www.chicagomanualofstyle.org/tools_citationguide.html" rel="documentation"/>
- <author>
- <name>Julian Onions</name>
- <email>julian.onions@gmail.com</email>
- </author>
- <contributor>
- <name>Sebastian Karcher</name>
- </contributor>
- <contributor>
- <name>Richard Karnesky</name>
- <email>karnesky+zotero@gmail.com</email>
- <uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri>
- </contributor>
- <category citation-format="author-date"/>
- <category field="generic-base"/>
- <summary>The author-date variant of the Chicago style</summary>
- <updated>2013-03-28T05:37:10+00:00</updated>
- <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
- </info>
- <locale>
- <terms>
- <term name="editor" form="verb-short">ed.</term>
- <term name="container-author" form="verb">by</term>
- <term name="translator" form="verb-short">trans.</term>
- <term name="translator" form="short">trans.</term>
- </terms>
- </locale>
- <macro name="secondary-contributors">
- <choose>
- <if type="chapter paper-conference" match="none">
- <group delimiter=". ">
- <names variable="editor translator">
- <label form="verb" text-case="capitalize-first" suffix=" " plural="never"/>
- <name and="text" delimiter=", "/>
- </names>
- </group>
- </if>
- </choose>
- </macro>
- <macro name="container-contributors">
- <choose>
- <if type="chapter paper-conference" match="any">
- <group prefix=", " delimiter=", ">
- <names variable="container-author editor" delimiter=", ">
- <label form="verb" suffix=" " plural="never"/>
- <name and="text" delimiter=", "/>
- </names>
- </group>
- </if>
- </choose>
- </macro>
- <macro name="editor">
- <names variable="editor">
- <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
- <label form="short" prefix=", "/>
- </names>
- </macro>
- <macro name="translator">
- <names variable="translator">
- <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
- <label form="short" prefix=", " plural="never"/>
- </names>
- </macro>
- <macro name="recipient">
- <choose>
- <if type="personal_communication">
- <choose>
- <if variable="genre">
- <text variable="genre" text-case="capitalize-first"/>
- </if>
- <else>
- <text term="letter" text-case="capitalize-first"/>
- </else>
- </choose>
- </if>
- </choose>
- <names variable="recipient" delimiter=", ">
- <label form="verb" prefix=" " text-case="lowercase" suffix=" "/>
- <name and="text" delimiter=", "/>
- </names>
- </macro>
- <macro name="contributors">
- <names variable="author">
- <name and="text" name-as-sort-order="first" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
- <label form="short" plural="never" prefix=", "/>
- <substitute>
- <names variable="editor"/>
- <names variable="translator"/>
- <text macro="title"/>
- </substitute>
- </names>
- <text macro="recipient"/>
- </macro>
- <macro name="contributors-short">
- <names variable="author">
- <name form="short" and="text" delimiter=", " initialize-with=". "/>
- <substitute>
- <names variable="editor"/>
- <names variable="translator"/>
- <text macro="title"/>
- </substitute>
- </names>
- </macro>
- <macro name="interviewer">
- <names variable="interviewer" delimiter=", ">
- <label form="verb" prefix=" " text-case="capitalize-first" suffix=" "/>
- <name and="text" delimiter=", "/>
- </names>
- </macro>
- <macro name="archive">
- <group delimiter=". ">
- <text variable="archive_location" text-case="capitalize-first"/>
- <text variable="archive"/>
- <text variable="archive-place"/>
- </group>
- </macro>
- <macro name="access">
- <group delimiter=". ">
- <choose>
- <if type="graphic report" match="any">
- <text macro="archive"/>
- </if>
- <else-if type="article-magazine article-newspaper bill book chapter graphic legal_case legislation motion_picture paper-conference report song thesis" match="none">
- <text macro="archive"/>
- </else-if>
- </choose>
- <text variable="DOI" prefix="doi:"/>
- <choose>
- <if variable="DOI issued" match="none">
- <choose>
- <if variable="URL accessed" match="all">
- <group delimiter=" ">
- <text term="accessed" text-case="capitalize-first"/>
- <date variable="accessed" delimiter=" ">
- <date-part name="month"/>
- <date-part name="day"/>
- </date>
- </group>
- </if>
- </choose>
- </if>
- <else-if type="webpage">
- <date variable="issued" delimiter=" ">
- <date-part name="month"/>
- <date-part name="day"/>
- </date>
- </else-if>
- </choose>
- <choose>
- <if type="legal_case" match="none">
- <text variable="URL"/>
- </if>
- </choose>
- </group>
- </macro>
- <macro name="title">
- <choose>
- <if variable="title" match="none">
- <choose>
- <if type="personal_communication" match="none">
- <text variable="genre" text-case="capitalize-first"/>
- </if>
- </choose>
- </if>
- <else-if type="bill book graphic legal_case legislation motion_picture song" match="any">
- <text variable="title" text-case="title" font-style="italic"/>
- </else-if>
- <else>
- <text variable="title" text-case="title" quotes="true"/>
- </else>
- </choose>
- </macro>
- <macro name="edition">
- <choose>
- <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
- <choose>
- <if is-numeric="edition">
- <group delimiter=" " prefix=". ">
- <number variable="edition" form="ordinal"/>
- <text term="edition" form="short" strip-periods="true"/>
- </group>
- </if>
- <else>
- <text variable="edition" prefix=". "/>
- </else>
- </choose>
- </if>
- <else-if type="chapter paper-conference" match="any">
- <choose>
- <if is-numeric="edition">
- <group delimiter=" " prefix=", ">
- <number variable="edition" form="ordinal"/>
- <text term="edition" form="short"/>
- </group>
- </if>
- <else>
- <text variable="edition" prefix=", "/>
- </else>
- </choose>
- </else-if>
- </choose>
- </macro>
- <macro name="locators">
- <choose>
- <if type="article-journal">
- <text variable="volume" prefix=" "/>
- <text variable="issue" prefix=" (" suffix=")"/>
- </if>
- <else-if type="legal_case">
- <text variable="volume" prefix=", "/>
- <text variable="container-title" prefix=" "/>
- <text variable="page" prefix=" "/>
- </else-if>
- <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
- <group prefix=". " delimiter=". ">
- <group>
- <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
- <number variable="volume" form="numeric"/>
- </group>
- <group>
- <number variable="number-of-volumes" form="numeric"/>
- <text term="volume" form="short" prefix=" " plural="true"/>
- </group>
- </group>
- </else-if>
- <else-if type="chapter paper-conference" match="any">
- <choose>
- <if variable="page" match="none">
- <group prefix=". ">
- <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
- <number variable="volume" form="numeric"/>
- </group>
- </if>
- </choose>
- </else-if>
- </choose>
- </macro>
- <macro name="locators-chapter">
- <choose>
- <if type="chapter paper-conference" match="any">
- <choose>
- <if variable="page">
- <group prefix=", ">
- <text variable="volume" suffix=":"/>
- <text variable="page"/>
- </group>
- </if>
- </choose>
- </if>
- </choose>
- </macro>
- <macro name="locators-article">
- <choose>
- <if type="article-newspaper">
- <group prefix=", " delimiter=", ">
- <group>
- <text variable="edition" suffix=" "/>
- <text term="edition" prefix=" "/>
- </group>
- <group>
- <text term="section" form="short" suffix=" "/>
- <text variable="section"/>
- </group>
- </group>
- </if>
- <else-if type="article-journal">
- <text variable="page" prefix=": "/>
- </else-if>
- </choose>
- </macro>
- <macro name="point-locators">
- <choose>
- <if variable="locator">
- <choose>
- <if locator="page" match="none">
- <choose>
- <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
- <choose>
- <if variable="volume">
- <group>
- <text term="volume" form="short" suffix=" "/>
- <number variable="volume" form="numeric"/>
- <label variable="locator" form="short" prefix=", " suffix=" "/>
- </group>
- </if>
- <else>
- <label variable="locator" form="short" suffix=" "/>
- </else>
- </choose>
- </if>
- <else>
- <label variable="locator" form="short" suffix=" "/>
- </else>
- </choose>
- </if>
- <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
- <number variable="volume" form="numeric" suffix=":"/>
- </else-if>
- </choose>
- <text variable="locator"/>
- </if>
- </choose>
- </macro>
- <macro name="container-prefix">
- <text term="in" text-case="capitalize-first"/>
- </macro>
- <macro name="container-title">
- <choose>
- <if type="chapter paper-conference" match="any">
- <text macro="container-prefix" suffix=" "/>
- </if>
- </choose>
- <choose>
- <if type="legal_case" match="none">
- <text variable="container-title" text-case="title" font-style="italic"/>
- </if>
- </choose>
- </macro>
- <macro name="publisher">
- <group delimiter=": ">
- <text variable="publisher-place"/>
- <text variable="publisher"/>
- </group>
- </macro>
- <macro name="date">
- <choose>
- <if variable="issued">
- <date variable="issued">
- <date-part name="year"/>
- </date>
- </if>
- <else-if variable="accessed">
- <date variable="accessed">
- <date-part name="year"/>
- </date>
- </else-if>
- </choose>
- </macro>
- <macro name="day-month">
- <date variable="issued">
- <date-part name="month"/>
- <date-part name="day" prefix=" "/>
- </date>
- </macro>
- <macro name="collection-title">
- <text variable="collection-title" text-case="title"/>
- <text variable="collection-number" prefix=" "/>
- </macro>
- <macro name="event">
- <group>
- <text term="presented at" suffix=" "/>
- <text variable="event"/>
- </group>
- </macro>
- <macro name="description">
- <choose>
- <if type="interview">
- <group delimiter=". ">
- <text macro="interviewer"/>
- <text variable="medium" text-case="capitalize-first"/>
- </group>
- </if>
- <else>
- <text variable="medium" text-case="capitalize-first" prefix=". "/>
- </else>
- </choose>
- <choose>
- <if variable="title" match="none"/>
- <else-if type="thesis"/>
- <else>
- <group delimiter=" " prefix=". ">
- <text variable="genre" text-case="capitalize-first"/>
- <choose>
- <if type="report">
- <text variable="number"/>
- </if>
- </choose>
- </group>
- </else>
- </choose>
- <!--This is for computer programs only. Localization new to 1.0.1, so may be missing in many locales-->
- <group delimiter=" " prefix=" (" suffix=")">
- <text term="version"/>
- <text variable="version"/>
- </group>
- </macro>
- <macro name="issue">
- <choose>
- <if type="article-journal">
- <text macro="day-month" prefix=" (" suffix=")"/>
- </if>
- <else-if type="legal_case">
- <text variable="authority" prefix=". "/>
- </else-if>
- <else-if type="speech">
- <group prefix=" " delimiter=", ">
- <text macro="event"/>
- <text macro="day-month"/>
- <text variable="event-place"/>
- </group>
- </else-if>
- <else-if type="article-newspaper article-magazine" match="any">
- <text macro="day-month" prefix=", "/>
- </else-if>
- <else>
- <group prefix=". " delimiter=", ">
- <choose>
- <if type="thesis">
- <text variable="genre" text-case="capitalize-first"/>
- </if>
- </choose>
- <text macro="publisher"/>
- </group>
- </else>
- </choose>
- </macro>
- <citation et-al-min="4" et-al-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true" disambiguate-add-givenname="true" givenname-disambiguation-rule="primary-name">
- <layout prefix="(" suffix=")" delimiter="; ">
- <group delimiter=", ">
- <group delimiter=" ">
- <text macro="contributors-short"/>
- <text macro="date"/>
- </group>
- <text macro="point-locators"/>
- </group>
- </layout>
- </citation>
- <bibliography hanging-indent="true" et-al-min="11" et-al-use-first="7" subsequent-author-substitute="&#8212;&#8212;&#8212;" entry-spacing="0">
- <sort>
- <key macro="contributors"/>
- <key variable="issued"/>
- </sort>
- <layout suffix=".">
- <group delimiter=". ">
- <text macro="contributors"/>
- <text macro="date"/>
- <text macro="title"/>
- </group>
- <text macro="description"/>
- <text macro="secondary-contributors" prefix=". "/>
- <text macro="container-title" prefix=". "/>
- <text macro="container-contributors"/>
- <text macro="edition"/>
- <text macro="locators-chapter"/>
- <text macro="locators"/>
- <text macro="collection-title" prefix=". "/>
- <text macro="issue"/>
- <text macro="locators-article"/>
- <text macro="access" prefix=". "/>
- </layout>
- </bibliography>
-</style>
diff --git a/data/epub.css b/data/epub.css
index a87fff9bb..93153d62a 100644
--- a/data/epub.css
+++ b/data/epub.css
@@ -1,5 +1,5 @@
/* This defines styles and classes used in the book */
-body { margin-left: 5%; margin-right: 5%; margin-top: 5%; margin-bottom: 5%; text-align: justify; font-size: medium; }
+body { margin: 5%; text-align: justify; font-size: medium; }
code { font-family: monospace; }
h1 { text-align: left; }
h2 { text-align: left; }
@@ -12,22 +12,3 @@ h2.author { }
h3.date { }
ol.toc { padding: 0; margin-left: 1em; }
ol.toc li { list-style-type: none; margin: 0; padding: 0; }
-/* For source-code highlighting */
-table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre
- { margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }
-td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
-td.sourceCode { padding-left: 5px; }
-pre.sourceCode { }
-code.sourceCode span.kw { color: #007020; font-weight: bold; }
-code.sourceCode span.dt { color: #902000; }
-code.sourceCode span.dv { color: #40a070; }
-code.sourceCode span.bn { color: #40a070; }
-code.sourceCode span.fl { color: #40a070; }
-code.sourceCode span.ch { color: #4070a0; }
-code.sourceCode span.st { color: #4070a0; }
-code.sourceCode span.co { color: #60a0b0; font-style: italic; }
-code.sourceCode span.ot { color: #007020; }
-code.sourceCode span.al { color: red; font-weight: bold; }
-code.sourceCode span.fu { color: #06287e; }
-code.sourceCode span.re { }
-code.sourceCode span.er { color: red; font-weight: bold; }
diff --git a/data/reference.docx b/data/reference.docx
index 42c14a906..7efc62458 100644
--- a/data/reference.docx
+++ b/data/reference.docx
Binary files differ
diff --git a/data/reference.odt b/data/reference.odt
index 6307119d3..c01345612 100644
--- a/data/reference.odt
+++ b/data/reference.odt
Binary files differ
diff --git a/data/s5/default/blank.gif b/data/s5/default/blank.gif
deleted file mode 100644
index 75b945d25..000000000
--- a/data/s5/default/blank.gif
+++ /dev/null
Binary files differ
diff --git a/data/s5/default/bodybg.gif b/data/s5/default/bodybg.gif
deleted file mode 100644
index 5f448a16f..000000000
--- a/data/s5/default/bodybg.gif
+++ /dev/null
Binary files differ
diff --git a/data/s5/default/framing.css b/data/s5/default/framing.css
deleted file mode 100644
index 14d8509e9..000000000
--- a/data/s5/default/framing.css
+++ /dev/null
@@ -1,23 +0,0 @@
-/* The following styles size, place, and layer the slide components.
- Edit these if you want to change the overall slide layout.
- The commented lines can be uncommented (and modified, if necessary)
- to help you with the rearrangement process. */
-
-/* target = 1024x768 */
-
-div#header, div#footer, .slide {width: 100%; top: 0; left: 0;}
-div#header {top: 0; height: 3em; z-index: 1;}
-div#footer {top: auto; bottom: 0; height: 2.5em; z-index: 5;}
-.slide {top: 0; width: 92%; padding: 3.5em 4% 4%; z-index: 2; list-style: none;}
-div#controls {left: 50%; bottom: 0; width: 50%; z-index: 100;}
-div#controls form {position: absolute; bottom: 0; right: 0; width: 100%;
- margin: 0;}
-#currentSlide {position: absolute; width: 10%; left: 45%; bottom: 1em; z-index: 10;}
-html>body #currentSlide {position: fixed;}
-
-/*
-div#header {background: #FCC;}
-div#footer {background: #CCF;}
-div#controls {background: #BBD;}
-div#currentSlide {background: #FFC;}
-*/
diff --git a/data/s5/default/iepngfix.htc b/data/s5/default/iepngfix.htc
deleted file mode 100644
index bba2db756..000000000
--- a/data/s5/default/iepngfix.htc
+++ /dev/null
@@ -1,42 +0,0 @@
-<public:component>
-<public:attach event="onpropertychange" onevent="doFix()" />
-
-<script>
-
-// IE5.5+ PNG Alpha Fix v1.0 by Angus Turnbull http://www.twinhelix.com
-// Free usage permitted as long as this notice remains intact.
-
-// This must be a path to a blank image. That's all the configuration you need here.
-var blankImg = 'ui/default/blank.gif';
-
-var f = 'DXImageTransform.Microsoft.AlphaImageLoader';
-
-function filt(s, m) {
- if (filters[f]) {
- filters[f].enabled = s ? true : false;
- if (s) with (filters[f]) { src = s; sizingMethod = m }
- } else if (s) style.filter = 'progid:'+f+'(src="'+s+'",sizingMethod="'+m+'")';
-}
-
-function doFix() {
- if ((parseFloat(navigator.userAgent.match(/MSIE (\S+)/)[1]) < 5.5) ||
- (event && !/(background|src)/.test(event.propertyName))) return;
-
- if (tagName == 'IMG') {
- if ((/\.png$/i).test(src)) {
- filt(src, 'image'); // was 'scale'
- src = blankImg;
- } else if (src.indexOf(blankImg) < 0) filt();
- } else if (style.backgroundImage) {
- if (style.backgroundImage.match(/^url[("']+(.*\.png)[)"']+$/i)) {
- var s = RegExp.$1;
- style.backgroundImage = '';
- filt(s, 'crop');
- } else filt();
- }
-}
-
-doFix();
-
-</script>
-</public:component> \ No newline at end of file
diff --git a/data/s5/default/opera.css b/data/s5/default/opera.css
deleted file mode 100644
index 9e9d2a3c5..000000000
--- a/data/s5/default/opera.css
+++ /dev/null
@@ -1,7 +0,0 @@
-/* DO NOT CHANGE THESE unless you really want to break Opera Show */
-.slide {
- visibility: visible !important;
- position: static !important;
- page-break-before: always;
-}
-#slide0 {page-break-before: avoid;}
diff --git a/data/s5/default/outline.css b/data/s5/default/outline.css
deleted file mode 100644
index 62db519ed..000000000
--- a/data/s5/default/outline.css
+++ /dev/null
@@ -1,15 +0,0 @@
-/* don't change this unless you want the layout stuff to show up in the outline view! */
-
-.layout div, #footer *, #controlForm * {display: none;}
-#footer, #controls, #controlForm, #navLinks, #toggle {
- display: block; visibility: visible; margin: 0; padding: 0;}
-#toggle {float: right; padding: 0.5em;}
-html>body #toggle {position: fixed; top: 0; right: 0;}
-
-/* making the outline look pretty-ish */
-
-#slide0 h1, #slide0 h2, #slide0 h3, #slide0 h4 {border: none; margin: 0;}
-#slide0 h1 {padding-top: 1.5em;}
-.slide h1 {margin: 1.5em 0 0; padding-top: 0.25em;
- border-top: 1px solid #888; border-bottom: 1px solid #AAA;}
-#toggle {border: 1px solid; border-width: 0 0 1px 1px; background: #FFF;}
diff --git a/data/s5/default/pretty.css b/data/s5/default/pretty.css
deleted file mode 100644
index a87b24375..000000000
--- a/data/s5/default/pretty.css
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Following are the presentation styles -- edit away! */
-
-body {background: #FFF url(bodybg.gif) -16px 0 no-repeat; color: #000; font-size: 2em;}
-:link, :visited {text-decoration: none; color: #00C;}
-#controls :active {color: #88A !important;}
-#controls :focus {outline: 1px dotted #227;}
-h1, h2, h3, h4 {font-size: 100%; margin: 0; padding: 0; font-weight: inherit;}
-ul, pre {margin: 0; line-height: 1em;}
-html, body {margin: 0; padding: 0;}
-
-blockquote, q {font-style: italic;}
-blockquote {padding: 0 2em 0.5em; margin: 0 1.5em 0.5em; text-align: center; font-size: 1em;}
-blockquote p {margin: 0;}
-blockquote i {font-style: normal;}
-blockquote b {display: block; margin-top: 0.5em; font-weight: normal; font-size: smaller; font-style: normal;}
-blockquote b i {font-style: italic;}
-
-kbd {font-weight: bold; font-size: 1em;}
-sup {font-size: smaller; line-height: 1px;}
-
-.slide code {padding: 2px 0.25em; font-weight: bold; color: #533;}
-.slide code.bad, code del {color: red;}
-.slide code.old {color: silver;}
-.slide pre {padding: 0; margin: 0.25em 0 0.5em 0.5em; color: #533; font-size: 90%;}
-.slide pre code {display: block;}
-.slide ul {margin-left: 5%; margin-right: 7%; list-style: disc;}
-.slide li {margin-top: 0.75em; margin-right: 0;}
-.slide ul ul {line-height: 1;}
-.slide ul ul li {margin: .2em; font-size: 85%; list-style: square;}
-.slide img.leader {display: block; margin: 0 auto;}
-
-div#header, div#footer {background: #005; color: #AAB;
- font-family: Verdana, Helvetica, sans-serif;}
-div#header {background: #005 url(bodybg.gif) -16px 0 no-repeat;
- line-height: 1px;}
-div#footer {font-size: 0.5em; font-weight: bold; padding: 1em 0;}
-#footer h1, #footer h2 {display: block; padding: 0 1em;}
-#footer h2 {font-style: italic;}
-
-div.long {font-size: 0.75em;}
-.slide h1 {position: absolute; top: 0.7em; left: 87px; z-index: 1;
- margin: 0; padding: 0.3em 0 0 50px; white-space: nowrap;
- font: bold 150%/1em Helvetica, sans-serif; text-transform: capitalize;
- color: #DDE; background: #005;}
-.slide h3 {font-size: 130%;}
-h1 abbr {font-variant: small-caps;}
-
-div#controls {position: absolute; left: 50%; bottom: 0;
- width: 50%;
- text-align: right; font: bold 0.9em Verdana, Helvetica, sans-serif;}
-html>body div#controls {position: fixed; padding: 0 0 1em 0;
- top: auto;}
-div#controls form {position: absolute; bottom: 0; right: 0; width: 100%;
- margin: 0; padding: 0;}
-#controls #navLinks a {padding: 0; margin: 0 0.5em;
- background: #005; border: none; color: #779;
- cursor: pointer;}
-#controls #navList {height: 1em;}
-#controls #navList #jumplist {position: absolute; bottom: 0; right: 0; background: #DDD; color: #227;}
-
-#currentSlide {text-align: center; font-size: 0.5em; color: #449;}
-
-#slide0 {padding-top: 3.5em; font-size: 90%;}
-#slide0 h1 {position: static; margin: 1em 0 0; padding: 0;
- font: bold 2em Helvetica, sans-serif; white-space: normal;
- color: #000; background: transparent;}
-#slide0 h2 {font: bold italic 1em Helvetica, sans-serif; margin: 0.25em;}
-#slide0 h3 {margin-top: 1.5em; font-size: 1.5em;}
-#slide0 h4 {margin-top: 0; font-size: 1em;}
-
-ul.urls {list-style: none; display: inline; margin: 0;}
-.urls li {display: inline; margin: 0;}
-.note {display: none;}
-.external {border-bottom: 1px dotted gray;}
-html>body .external {border-bottom: none;}
-.external:after {content: " \274F"; font-size: smaller; color: #77B;}
-
-.incremental, .incremental *, .incremental *:after {color: #DDE; visibility: visible;}
-img.incremental {visibility: hidden;}
-.slide .current {color: #B02;}
-
-
-/* diagnostics
-
-li:after {content: " [" attr(class) "]"; color: #F88;}
-*/
diff --git a/data/s5/default/print.css b/data/s5/default/print.css
deleted file mode 100644
index 4a3554ddd..000000000
--- a/data/s5/default/print.css
+++ /dev/null
@@ -1,24 +0,0 @@
-/* The following rule is necessary to have all slides appear in print! DO NOT REMOVE IT! */
-.slide, ul {page-break-inside: avoid; visibility: visible !important;}
-h1 {page-break-after: avoid;}
-
-body {font-size: 12pt; background: white;}
-* {color: black;}
-
-#slide0 h1 {font-size: 200%; border: none; margin: 0.5em 0 0.25em;}
-#slide0 h3 {margin: 0; padding: 0;}
-#slide0 h4 {margin: 0 0 0.5em; padding: 0;}
-#slide0 {margin-bottom: 3em;}
-
-h1 {border-top: 2pt solid gray; border-bottom: 1px dotted silver;}
-.extra {background: transparent !important;}
-div.extra, pre.extra, .example {font-size: 10pt; color: #333;}
-ul.extra a {font-weight: bold;}
-p.example {display: none;}
-
-#header {display: none;}
-#footer h1 {margin: 0; border-bottom: 1px solid; color: gray; font-style: italic;}
-#footer h2, #controls {display: none;}
-
-/* The following rule keeps the layout stuff out of print. Remove at your own risk! */
-.layout, .layout * {display: none !important;}
diff --git a/data/s5/default/s5-core.css b/data/s5/default/s5-core.css
deleted file mode 100644
index 86444e041..000000000
--- a/data/s5/default/s5-core.css
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Do not edit or override these styles! The system will likely break if you do. */
-
-div#header, div#footer, div#controls, .slide {position: absolute;}
-html>body div#header, html>body div#footer,
- html>body div#controls, html>body .slide {position: fixed;}
-.handout {display: none;}
-.layout {display: block;}
-.slide, .hideme, .incremental {visibility: hidden;}
-#slide0 {visibility: visible;}
diff --git a/data/s5/default/slides.css b/data/s5/default/slides.css
deleted file mode 100644
index 0786d7dbd..000000000
--- a/data/s5/default/slides.css
+++ /dev/null
@@ -1,3 +0,0 @@
-@import url(s5-core.css); /* required to make the slide show run at all */
-@import url(framing.css); /* sets basic placement and size of slide components */
-@import url(pretty.css); /* stuff that makes the slides look better than blah */ \ No newline at end of file
diff --git a/data/s5/default/slides.js b/data/s5/default/slides.js
deleted file mode 100644
index 38fe8531c..000000000
--- a/data/s5/default/slides.js
+++ /dev/null
@@ -1,553 +0,0 @@
-// S5 v1.1 slides.js -- released into the Public Domain
-//
-// Please see http://www.meyerweb.com/eric/tools/s5/credits.html for information
-// about all the wonderful and talented contributors to this code!
-
-var undef;
-var slideCSS = '';
-var snum = 0;
-var smax = 1;
-var incpos = 0;
-var number = undef;
-var s5mode = true;
-var defaultView = 'slideshow';
-var controlVis = 'visible';
-
-var isIE = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0;
-var isOp = navigator.userAgent.indexOf('Opera') > -1 ? 1 : 0;
-var isGe = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') < 1 ? 1 : 0;
-
-function hasClass(object, className) {
- if (!object.className) return false;
- return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1);
-}
-
-function hasValue(object, value) {
- if (!object) return false;
- return (object.search('(^|\\s)' + value + '(\\s|$)') != -1);
-}
-
-function removeClass(object,className) {
- if (!object) return;
- object.className = object.className.replace(new RegExp('(^|\\s)'+className+'(\\s|$)'), RegExp.$1+RegExp.$2);
-}
-
-function addClass(object,className) {
- if (!object || hasClass(object, className)) return;
- if (object.className) {
- object.className += ' '+className;
- } else {
- object.className = className;
- }
-}
-
-function GetElementsWithClassName(elementName,className) {
- var allElements = document.getElementsByTagName(elementName);
- var elemColl = new Array();
- for (var i = 0; i< allElements.length; i++) {
- if (hasClass(allElements[i], className)) {
- elemColl[elemColl.length] = allElements[i];
- }
- }
- return elemColl;
-}
-
-function isParentOrSelf(element, id) {
- if (element == null || element.nodeName=='BODY') return false;
- else if (element.id == id) return true;
- else return isParentOrSelf(element.parentNode, id);
-}
-
-function nodeValue(node) {
- var result = "";
- if (node.nodeType == 1) {
- var children = node.childNodes;
- for (var i = 0; i < children.length; ++i) {
- result += nodeValue(children[i]);
- }
- }
- else if (node.nodeType == 3) {
- result = node.nodeValue;
- }
- return(result);
-}
-
-function slideLabel() {
- var slideColl = GetElementsWithClassName('*','slide');
- var list = document.getElementById('jumplist');
- smax = slideColl.length;
- for (var n = 0; n < smax; n++) {
- var obj = slideColl[n];
-
- var did = 'slide' + n.toString();
- obj.setAttribute('id',did);
- if (isOp) continue;
-
- var otext = '';
- var menu = obj.firstChild;
- if (!menu) continue; // to cope with empty slides
- while (menu && menu.nodeType == 3) {
- menu = menu.nextSibling;
- }
- if (!menu) continue; // to cope with slides with only text nodes
-
- var menunodes = menu.childNodes;
- for (var o = 0; o < menunodes.length; o++) {
- otext += nodeValue(menunodes[o]);
- }
- list.options[list.length] = new Option(n + ' : ' + otext, n);
- }
-}
-
-function currentSlide() {
- var cs;
- if (document.getElementById) {
- cs = document.getElementById('currentSlide');
- } else {
- cs = document.currentSlide;
- }
- cs.innerHTML = '<span id="csHere">' + snum + '<\/span> ' +
- '<span id="csSep">\/<\/span> ' +
- '<span id="csTotal">' + (smax-1) + '<\/span>';
- if (snum == 0) {
- cs.style.visibility = 'hidden';
- } else {
- cs.style.visibility = 'visible';
- }
-}
-
-function go(step) {
- if (document.getElementById('slideProj').disabled || step == 0) return;
- var jl = document.getElementById('jumplist');
- var cid = 'slide' + snum;
- var ce = document.getElementById(cid);
- if (incrementals[snum].length > 0) {
- for (var i = 0; i < incrementals[snum].length; i++) {
- removeClass(incrementals[snum][i], 'current');
- removeClass(incrementals[snum][i], 'incremental');
- }
- }
- if (step != 'j') {
- snum += step;
- lmax = smax - 1;
- if (snum > lmax) snum = lmax;
- if (snum < 0) snum = 0;
- } else
- snum = parseInt(jl.value);
- var nid = 'slide' + snum;
- var ne = document.getElementById(nid);
- if (!ne) {
- ne = document.getElementById('slide0');
- snum = 0;
- }
- if (step < 0) {incpos = incrementals[snum].length} else {incpos = 0;}
- if (incrementals[snum].length > 0 && incpos == 0) {
- for (var i = 0; i < incrementals[snum].length; i++) {
- if (hasClass(incrementals[snum][i], 'current'))
- incpos = i + 1;
- else
- addClass(incrementals[snum][i], 'incremental');
- }
- }
- if (incrementals[snum].length > 0 && incpos > 0)
- addClass(incrementals[snum][incpos - 1], 'current');
- ce.style.visibility = 'hidden';
- ne.style.visibility = 'visible';
- jl.selectedIndex = snum;
- currentSlide();
- number = 0;
-}
-
-function goTo(target) {
- if (target >= smax || target == snum) return;
- go(target - snum);
-}
-
-function subgo(step) {
- if (step > 0) {
- removeClass(incrementals[snum][incpos - 1],'current');
- removeClass(incrementals[snum][incpos], 'incremental');
- addClass(incrementals[snum][incpos],'current');
- incpos++;
- } else {
- incpos--;
- removeClass(incrementals[snum][incpos],'current');
- addClass(incrementals[snum][incpos], 'incremental');
- addClass(incrementals[snum][incpos - 1],'current');
- }
-}
-
-function toggle() {
- var slideColl = GetElementsWithClassName('*','slide');
- var slides = document.getElementById('slideProj');
- var outline = document.getElementById('outlineStyle');
- if (!slides.disabled) {
- slides.disabled = true;
- outline.disabled = false;
- s5mode = false;
- fontSize('1em');
- for (var n = 0; n < smax; n++) {
- var slide = slideColl[n];
- slide.style.visibility = 'visible';
- }
- } else {
- slides.disabled = false;
- outline.disabled = true;
- s5mode = true;
- fontScale();
- for (var n = 0; n < smax; n++) {
- var slide = slideColl[n];
- slide.style.visibility = 'hidden';
- }
- slideColl[snum].style.visibility = 'visible';
- }
-}
-
-function showHide(action) {
- var obj = GetElementsWithClassName('*','hideme')[0];
- switch (action) {
- case 's': obj.style.visibility = 'visible'; break;
- case 'h': obj.style.visibility = 'hidden'; break;
- case 'k':
- if (obj.style.visibility != 'visible') {
- obj.style.visibility = 'visible';
- } else {
- obj.style.visibility = 'hidden';
- }
- break;
- }
-}
-
-// 'keys' code adapted from MozPoint (http://mozpoint.mozdev.org/)
-function keys(key) {
- if (!key) {
- key = event;
- key.which = key.keyCode;
- }
- if (key.which == 84) {
- toggle();
- return;
- }
- if (s5mode) {
- switch (key.which) {
- case 10: // return
- case 13: // enter
- if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return;
- if (key.target && isParentOrSelf(key.target, 'controls')) return;
- if(number != undef) {
- goTo(number);
- break;
- }
- case 32: // spacebar
- case 34: // page down
- case 39: // rightkey
- case 40: // downkey
- if(number != undef) {
- go(number);
- } else if (!incrementals[snum] || incpos >= incrementals[snum].length) {
- go(1);
- } else {
- subgo(1);
- }
- break;
- case 33: // page up
- case 37: // leftkey
- case 38: // upkey
- if(number != undef) {
- go(-1 * number);
- } else if (!incrementals[snum] || incpos <= 0) {
- go(-1);
- } else {
- subgo(-1);
- }
- break;
- case 36: // home
- goTo(0);
- break;
- case 35: // end
- goTo(smax-1);
- break;
- case 67: // c
- showHide('k');
- break;
- }
- if (key.which < 48 || key.which > 57) {
- number = undef;
- } else {
- if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return;
- if (key.target && isParentOrSelf(key.target, 'controls')) return;
- number = (((number != undef) ? number : 0) * 10) + (key.which - 48);
- }
- }
- return false;
-}
-
-function clicker(e) {
- number = undef;
- var target;
- if (window.event) {
- target = window.event.srcElement;
- e = window.event;
- } else target = e.target;
- if (target.getAttribute('href') != null || hasValue(target.rel, 'external') || isParentOrSelf(target, 'controls') || isParentOrSelf(target,'embed') || isParentOrSelf(target,'object')) return true;
- if (!e.which || e.which == 1) {
- if (!incrementals[snum] || incpos >= incrementals[snum].length) {
- go(1);
- } else {
- subgo(1);
- }
- }
-}
-
-function findSlide(hash) {
- var target = null;
- var slides = GetElementsWithClassName('*','slide');
- for (var i = 0; i < slides.length; i++) {
- var targetSlide = slides[i];
- if ( (targetSlide.name && targetSlide.name == hash)
- || (targetSlide.id && targetSlide.id == hash) ) {
- target = targetSlide;
- break;
- }
- }
- while(target != null && target.nodeName != 'BODY') {
- if (hasClass(target, 'slide')) {
- return parseInt(target.id.slice(5));
- }
- target = target.parentNode;
- }
- return null;
-}
-
-function slideJump() {
- if (window.location.hash == null) return;
- var sregex = /^#slide(\d+)$/;
- var matches = sregex.exec(window.location.hash);
- var dest = null;
- if (matches != null) {
- dest = parseInt(matches[1]);
- } else {
- dest = findSlide(window.location.hash.slice(1));
- }
- if (dest != null)
- go(dest - snum);
-}
-
-function fixLinks() {
- var thisUri = window.location.href;
- thisUri = thisUri.slice(0, thisUri.length - window.location.hash.length);
- var aelements = document.getElementsByTagName('A');
- for (var i = 0; i < aelements.length; i++) {
- var a = aelements[i].href;
- var slideID = a.match('\#slide[0-9]{1,2}');
- if ((slideID) && (slideID[0].slice(0,1) == '#')) {
- var dest = findSlide(slideID[0].slice(1));
- if (dest != null) {
- if (aelements[i].addEventListener) {
- aelements[i].addEventListener("click", new Function("e",
- "if (document.getElementById('slideProj').disabled) return;" +
- "go("+dest+" - snum); " +
- "if (e.preventDefault) e.preventDefault();"), true);
- } else if (aelements[i].attachEvent) {
- aelements[i].attachEvent("onclick", new Function("",
- "if (document.getElementById('slideProj').disabled) return;" +
- "go("+dest+" - snum); " +
- "event.returnValue = false;"));
- }
- }
- }
- }
-}
-
-function externalLinks() {
- if (!document.getElementsByTagName) return;
- var anchors = document.getElementsByTagName('a');
- for (var i=0; i<anchors.length; i++) {
- var anchor = anchors[i];
- if (anchor.getAttribute('href') && hasValue(anchor.rel, 'external')) {
- anchor.target = '_blank';
- addClass(anchor,'external');
- }
- }
-}
-
-function createControls() {
- var controlsDiv = document.getElementById("controls");
- if (!controlsDiv) return;
- var hider = ' onmouseover="showHide(\'s\');" onmouseout="showHide(\'h\');"';
- var hideDiv, hideList = '';
- if (controlVis == 'hidden') {
- hideDiv = hider;
- } else {
- hideList = hider;
- }
- controlsDiv.innerHTML = '<form action="#" id="controlForm"' + hideDiv + '>' +
- '<div id="navLinks">' +
- '<a accesskey="t" id="toggle" href="javascript:toggle();">&#216;<\/a>' +
- '<a accesskey="z" id="prev" href="javascript:go(-1);">&laquo;<\/a>' +
- '<a accesskey="x" id="next" href="javascript:go(1);">&raquo;<\/a>' +
- '<div id="navList"' + hideList + '><select id="jumplist" onchange="go(\'j\');"><\/select><\/div>' +
- '<\/div><\/form>';
- if (controlVis == 'hidden') {
- var hidden = document.getElementById('navLinks');
- } else {
- var hidden = document.getElementById('jumplist');
- }
- addClass(hidden,'hideme');
-}
-
-function fontScale() { // causes layout problems in FireFox that get fixed if browser's Reload is used; same may be true of other Gecko-based browsers
- if (!s5mode) return false;
- var vScale = 22; // both yield 32 (after rounding) at 1024x768
- var hScale = 32; // perhaps should auto-calculate based on theme's declared value?
- if (window.innerHeight) {
- var vSize = window.innerHeight;
- var hSize = window.innerWidth;
- } else if (document.documentElement.clientHeight) {
- var vSize = document.documentElement.clientHeight;
- var hSize = document.documentElement.clientWidth;
- } else if (document.body.clientHeight) {
- var vSize = document.body.clientHeight;
- var hSize = document.body.clientWidth;
- } else {
- var vSize = 700; // assuming 1024x768, minus chrome and such
- var hSize = 1024; // these do not account for kiosk mode or Opera Show
- }
- var newSize = Math.min(Math.round(vSize/vScale),Math.round(hSize/hScale));
- fontSize(newSize + 'px');
- if (isGe) { // hack to counter incremental reflow bugs
- var obj = document.getElementsByTagName('body')[0];
- obj.style.display = 'none';
- obj.style.display = 'block';
- }
-}
-
-function fontSize(value) {
- if (!(s5ss = document.getElementById('s5ss'))) {
- if (!isIE) {
- document.getElementsByTagName('head')[0].appendChild(s5ss = document.createElement('style'));
- s5ss.setAttribute('media','screen, projection');
- s5ss.setAttribute('id','s5ss');
- } else {
- document.createStyleSheet();
- document.s5ss = document.styleSheets[document.styleSheets.length - 1];
- }
- }
- if (!isIE) {
- while (s5ss.lastChild) s5ss.removeChild(s5ss.lastChild);
- s5ss.appendChild(document.createTextNode('body {font-size: ' + value + ' !important;}'));
- } else {
- document.s5ss.addRule('body','font-size: ' + value + ' !important;');
- }
-}
-
-function notOperaFix() {
- slideCSS = document.getElementById('slideProj').href;
- var slides = document.getElementById('slideProj');
- var outline = document.getElementById('outlineStyle');
- slides.setAttribute('media','screen');
- outline.disabled = true;
- if (isGe) {
- slides.setAttribute('href','null'); // Gecko fix
- slides.setAttribute('href',slideCSS); // Gecko fix
- }
- if (isIE && document.styleSheets && document.styleSheets[0]) {
- document.styleSheets[0].addRule('img', 'behavior: url(ui/default/iepngfix.htc)');
- document.styleSheets[0].addRule('div', 'behavior: url(ui/default/iepngfix.htc)');
- document.styleSheets[0].addRule('.slide', 'behavior: url(ui/default/iepngfix.htc)');
- }
-}
-
-function getIncrementals(obj) {
- var incrementals = new Array();
- if (!obj)
- return incrementals;
- var children = obj.childNodes;
- for (var i = 0; i < children.length; i++) {
- var child = children[i];
- if (hasClass(child, 'incremental')) {
- if (child.nodeName == 'OL' || child.nodeName == 'UL') {
- removeClass(child, 'incremental');
- for (var j = 0; j < child.childNodes.length; j++) {
- if (child.childNodes[j].nodeType == 1) {
- addClass(child.childNodes[j], 'incremental');
- }
- }
- } else {
- incrementals[incrementals.length] = child;
- removeClass(child,'incremental');
- }
- }
- if (hasClass(child, 'show-first')) {
- if (child.nodeName == 'OL' || child.nodeName == 'UL') {
- removeClass(child, 'show-first');
- if (child.childNodes[isGe].nodeType == 1) {
- removeClass(child.childNodes[isGe], 'incremental');
- }
- } else {
- incrementals[incrementals.length] = child;
- }
- }
- incrementals = incrementals.concat(getIncrementals(child));
- }
- return incrementals;
-}
-
-function createIncrementals() {
- var incrementals = new Array();
- for (var i = 0; i < smax; i++) {
- incrementals[i] = getIncrementals(document.getElementById('slide'+i));
- }
- return incrementals;
-}
-
-function defaultCheck() {
- var allMetas = document.getElementsByTagName('meta');
- for (var i = 0; i< allMetas.length; i++) {
- if (allMetas[i].name == 'defaultView') {
- defaultView = allMetas[i].content;
- }
- if (allMetas[i].name == 'controlVis') {
- controlVis = allMetas[i].content;
- }
- }
-}
-
-// Key trap fix, new function body for trap()
-function trap(e) {
- if (!e) {
- e = event;
- e.which = e.keyCode;
- }
- try {
- modifierKey = e.ctrlKey || e.altKey || e.metaKey;
- }
- catch(e) {
- modifierKey = false;
- }
- return modifierKey || e.which == 0;
-}
-
-function startup() {
- defaultCheck();
- if (!isOp)
- createControls();
- slideLabel();
- fixLinks();
- externalLinks();
- fontScale();
- if (!isOp) {
- notOperaFix();
- incrementals = createIncrementals();
- slideJump();
- if (defaultView == 'outline') {
- toggle();
- }
- document.onkeyup = keys;
- document.onkeypress = trap;
- document.onclick = clicker;
- }
-}
-
-window.onload = startup;
-window.onresize = function(){setTimeout('fontScale()', 50);} \ No newline at end of file
diff --git a/data/sample.lua b/data/sample.lua
index 36eb9f6ef..a0c3c29a2 100644
--- a/data/sample.lua
+++ b/data/sample.lua
@@ -77,16 +77,16 @@ function Doc(body, metadata, variables)
add('<!DOCTYPE html>')
add('<html>')
add('<head>')
- add('<title>' .. metadata.title .. '</title>')
+ add('<title>' .. (metadata['title'] or '') .. '</title>')
add('</head>')
add('<body>')
- if title ~= "" then
- add('<h1 class="title">' .. metadata.title .. '</h1>')
+ if metadata['title'] and metadata['title'] ~= "" then
+ add('<h1 class="title">' .. metadata['title'] .. '</h1>')
end
- for _, author in pairs(metadata.author) do
+ for _, author in pairs(metadata['author'] or {}) do
add('<h2 class="author">' .. author .. '</h2>')
end
- if date ~= "" then
+ if metadata['date'] and metadata['date'] ~= "" then
add('<h3 class="date">' .. metadata.date .. '</h3>')
end
add(body)
@@ -177,6 +177,14 @@ function Note(s)
'"><sup>' .. num .. '</sup></a>'
end
+function Span(s, attr)
+ return "<span" .. attributes(attr) .. ">" .. s .. "</span>"
+end
+
+function Cite(s)
+ return "<span class=\"cite\">" .. s .. "</span>"
+end
+
function Plain(s)
return s
end
@@ -299,6 +307,10 @@ function Table(caption, aligns, widths, headers, rows)
return table.concat(buffer,'\n')
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.
diff --git a/data/slideous/slideous.css b/data/slideous/slideous.css
deleted file mode 100644
index 7d6057069..000000000
--- a/data/slideous/slideous.css
+++ /dev/null
@@ -1,95 +0,0 @@
-/* This work is licensed under Creative Commons GNU LGPL License.
-
- License: http://creativecommons.org/licenses/LGPL/2.1/
- Version: 1.0
-
- Author: Stefan Goessner/2005
- Web: http://goessner.net/
-*/
-@media screen, projection {
-body {
- background-color: #e3eee7;
- padding: 0;
- margin: 0;
- color: #132;
- border-color: #678;
- font-size: 125%;
-}
-#statusbar {
- display: none;
- position: absolute; z-index: 10;
- top: auto; bottom: 0; left: 0; right: 0;
- height: 2em;
- background-color: #f0fff8;
- color: #132;
- font-size: 75%;
- padding: 0.5em 0.5em 0 2px;
- border-top: solid 1px #000;
-}
-#statusbar button, #tocbox {
- cursor: pointer;
- color: #031;
- background-color: #e0eee7;
- margin: 1px;
- padding: 0 0.5em;
- border: inset 1px black;
-}
-#statusbar button:hover, #tocbox:hover {
- color: #031;
- background-color: #c0ccc6;
- border: outset 1px black;
-}
-#tocbox {
- width: 15em;
-}
-#eos {
- visibility: hidden;
- color: #021;
- background-color: #fffafa;
- border: inset 1px black;
- font-size: 120%;
-}
-div.slide {
- display: block;
- margin: 0 0 2em 0;
- padding: 0 150px;
-}
-
-div.slide h1 {
- background: #a0aaa4;
- color: #f0fff8;
- padding: 0 0.5em 0 0.5em;
- margin: 0 -150px;
- font-size: 120%;
- border-bottom: solid 1px black;
-}
-
-div.slide h1:before { content: "# "; }
-div.handout { display: block; }
-
-body>#statusbar { /* ie6 hack for fixing the statusbar - in quirks mode */
- position: fixed; /* thanks to Anne van Kesteren and Arthur Steiner */
-} /* see http://limpid.nl/lab/css/fixed/footer */
-* html body {
- overflow: hidden;
-}
-* html div.slide {
- height: 100%;
- padding-bottom: 2em;
- overflow: auto;
-} /* end ie6-hack */
-
-} /* @media screen, projection */
-
-@media print {
-body {
- color: black;
- font-family: sans-serif;
- font-size: 11pt;
-}
-
-#statusbar { display: none; }
-div.slide { page-break-after: always; }
-div.handout { display: block; }
-
-} /* @media print */
diff --git a/data/slideous/slideous.js b/data/slideous/slideous.js
deleted file mode 100644
index 3e7a63d4a..000000000
--- a/data/slideous/slideous.js
+++ /dev/null
@@ -1,321 +0,0 @@
-/* This work is licensed under Creative Commons GNU LGPL License.
-
- License: http://creativecommons.org/licenses/LGPL/2.1/
-
- Author: Stefan Goessner/2005-2006
- Web: http://goessner.net/
-*/
-var Slideous = {
- version: 1.0,
- // == user customisable ===
- clickables: { a: true, button: true, img: true, input: true, object: true, textarea: true, select: true, option: true },
- incrementables: { blockquote: { filter: "self, parent" },
- dd: { filter: "self, parent" },
- dt: { filter: "self, parent" },
- h2: { filter: "self, parent" },
- h3: { filter: "self, parent" },
- h4: { filter: "self, parent" },
- h5: { filter: "self, parent" },
- h6: { filter: "self, parent" },
- li: { filter: "self, parent" },
- p: { filter: "self" },
- pre: { filter: "self" },
- img: { filter: "self, parent" },
- object: { filter: "self, parent" },
- table: { filter: "self, parent" },
- td: { filter: "self, parent" },
- th: { filter: "self, parent" },
- tr: { filter: "parent, grandparent" }
- },
- autoincrementables: { ol: true, ul: true, dl: true },
- autoincrement: false,
- statusbar: true,
- navbuttons: { incfontbutton: function(){Slideous.changefontsize(+Slideous.fontdelta);},
- decfontbutton: function(){Slideous.changefontsize(-Slideous.fontdelta);},
- contentbutton: function(){Slideous.gotoslide(Slideous.tocidx(), true, true);},
- homebutton: function(){Slideous.gotoslide(1, true, true);},
- prevslidebutton: function(){Slideous.previous(false);},
- previtembutton: function(){Slideous.previous(true);},
- nextitembutton: function(){Slideous.next(true);},
- nextslidebutton: function(){Slideous.next(false);},
- endbutton: function(){Slideous.gotoslide(Slideous.count,true,true);} },
- fontsize: 125, // in percent, corresponding to body.font-size in css file
- fontdelta: 5, // increase/decrease fontsize by this value
- mousesensitive: true,
- tocidx: 0,
- tocitems: { toc: "<li><a href=\"#s{\$slideidx}\">{\$slidetitle}</a></li>",
- tocbox: "<option value=\"#s{\$slideidx}\" title=\"{\$slidetitle}\">{\$slidetitle}</option>" },
- keydown: function(evt) {
- evt = evt || window.event;
- var key = evt.keyCode || evt.which;
- if (key && !evt.ctrlKey && !evt.altKey) {
- switch (key) {
- case 33: // page up ... previous slide
- Slideous.previous(false); evt.cancel = !Slideous.showall; break;
- case 37: // left arrow ... previous item
- Slideous.previous(true); evt.cancel = !Slideous.showall; break;
- case 32: // space bar
- case 39: // right arrow
- Slideous.next(true); evt.cancel = !Slideous.showall; break;
- case 13: // carriage return ... next slide
- case 34: // page down
- Slideous.next(false); evt.cancel = !Slideous.showall; break;
- case 35: // end ... last slide (not recognised by opera)
- Slideous.gotoslide(Slideous.count, true, true); evt.cancel = !Slideous.showall; break;
- case 36: // home ... first slide (not recognised by opera)
- Slideous.gotoslide(1, true, true); evt.cancel = !Slideous.showall; break;
- case 65: // A ... show All
- case 80: // P ... Print mode
- Slideous.toggleshowall(!Slideous.showall); evt.cancel = true; break;
- case 67: // C ... goto contents
- Slideous.gotoslide(Slideous.tocidx, true, true); evt.cancel = true; break;
- case 77: // M ... toggle mouse sensitivity
- Slideous.mousenavigation(Slideous.mousesensitive = !Slideous.mousesensitive); evt.cancel = true; break;
- case 83: // S ... toggle statusbar
- Slideous.togglestatusbar(); evt.cancel = true; break;
- case 61: // + ... increase fontsize
- case 107:
- Slideous.changefontsize(+Slideous.fontdelta); evt.cancel = true; break;
- case 109: // - ... decrease fontsize
- Slideous.changefontsize(-Slideous.fontdelta); evt.cancel = true; break;
- default: break;
- }
- if (evt.cancel) evt.returnValue = false;
- }
- return !evt.cancel;
- },
-
- // == program logic ===
- count: 0, // # of slides ..
- curidx: 0, // current slide index ..
- mousedownpos: null, // last mouse down position ..
- contentselected: false, // indicates content selection ..
- showall: true,
- init: function() {
- Slideous.curidx = 1;
- Slideous.importproperties();
- Slideous.registerslides();
- document.body.innerHTML = Slideous.injectproperties(document.body.innerHTML);
- Slideous.buildtocs();
- Slideous.registeranchors();
- Slideous.toggleshowall(false);
- Slideous.updatestatus();
- document.body.style.fontSize = Slideous.fontsize+"%";
- document.getElementById("s1").style.display = "block";
- document.onkeydown = Slideous.keydown;
- Slideous.mousenavigation(Slideous.mousesensitive);
- Slideous.registerbuttons();
- if (window.location.hash)
- Slideous.gotoslide(window.location.hash.substr(2), true, true);
- },
- registerslides: function() {
- var div = document.getElementsByTagName("div");
- Slideous.count = 0;
- for (var i in div)
- if (Slideous.hasclass(div[i], "slide"))
- div[i].setAttribute("id", "s"+(++Slideous.count));
- },
- registeranchors: function() {
- var a = document.getElementsByTagName("a"),
- loc = (window.location.hostname+window.location.pathname).replace(/\\/g, "/");
- for (var i in a) {
- if (a[i].href && a[i].href.indexOf(loc) >= 0 && a[i].href.lastIndexOf("#") >= 0) {
- a[i].href = "javascript:Slideous.gotoslide(" + a[i].href.substr(a[i].href.lastIndexOf("#")+2)+",true,true)";
- }
- }
- },
- registerbuttons: function() {
- var button;
- for (var b in Slideous.navbuttons)
- if (button = document.getElementById(b))
- button.onclick = Slideous.navbuttons[b];
- },
- importproperties: function() { // from html meta section ..
- var meta = document.getElementsByTagName("meta"), elem;
- for (var i in meta)
- if (meta[i].attributes && meta[i].attributes["name"] && meta[i].attributes["name"].value in Slideous)
- switch (typeof(Slideous[meta[i].attributes["name"].value])) {
- case "number": Slideous[meta[i].attributes["name"].value] = parseInt(meta[i].attributes["content"].value); break;
- case "boolean": Slideous[meta[i].attributes["name"].value] = meta[i].attributes["content"].value == "true" ? true : false; break;
- default: Slideous[meta[i].attributes["name"].value] = meta[i].attributes["content"].value; break;
- }
- },
- injectproperties: function(str) {
- var meta = document.getElementsByTagName("meta"), elem;
- for (var i in meta) {
- if (meta[i].attributes && meta[i].attributes["name"])
- str = str.replace(new RegExp("{\\$"+meta[i].attributes["name"].value+"}","g"), meta[i].attributes["content"].value);
- }
- return str = str.replace(/{\$generator}/g, "Slideous")
- .replace(/{\$version}/g, Slideous.version)
- .replace(/{\$title}/g, document.title)
- .replace(/{\$slidecount}/g, Slideous.count);
- },
- buildtocs: function() {
- var toc = document.getElementById("toc"), list = "",
- tocbox = document.getElementById("tocbox");
- if (toc) {
- for (var i=0; i<Slideous.count; i++)
- list += Slideous.tocitems.toc.replace(/{\$slideidx}/g, i+1).replace(/{\$slidetitle}/, document.getElementById("s"+(i+1)).getElementsByTagName("h1")[0].innerHTML);
- toc.innerHTML = list;
- while (toc && !Slideous.hasclass(toc, "slide")) toc = toc.parentNode;
- if (toc) Slideous.tocidx = toc.getAttribute("id").substr(1);
- }
- if (tocbox) {
- tocbox.innerHTML = "";
- for (var i=0; i<Slideous.count; i++)
- tocbox.options[tocbox.length] = new Option((i+1)+". "+document.getElementById("s"+(i+1)).getElementsByTagName("h1")[0].innerHTML, "#s"+(i+1));
- tocbox.onchange = function() { Slideous.gotoslide(this.selectedIndex+1, true, true); };
- }
- },
- next: function(deep) {
- if (!Slideous.showall) {
- var slide = document.getElementById("s"+Slideous.curidx),
- item = Slideous.firstitem(slide, Slideous.isitemhidden);
- if (deep) { // next item
- if (item)
- Slideous.displayitem(item, true);
- else
- Slideous.gotoslide(Slideous.curidx+1, false, false);
- }
- else if (item) // complete slide ..
- while (item = Slideous.firstitem(slide, Slideous.isitemhidden))
- Slideous.displayitem(item, true);
- else // next slide
- Slideous.gotoslide(Slideous.curidx+1, true, false);
- Slideous.updatestatus();
- }
- },
- previous: function(deep) {
- if (!Slideous.showall) {
- var slide = document.getElementById("s"+Slideous.curidx);
- if (deep) {
- var item = Slideous.lastitem(slide, Slideous.isitemvisible);
- if (item)
- Slideous.displayitem(item, false);
- else
- Slideous.gotoslide(Slideous.curidx-1, true, false);
- }
- else
- Slideous.gotoslide(Slideous.curidx-1, true, false);
- Slideous.updatestatus();
- }
- },
- gotoslide: function(i, showitems, updatestatus) {
- if (!Slideous.showall && i > 0 && i <= Slideous.count && i != Slideous.curidx) {
- document.getElementById("s"+Slideous.curidx).style.display = "none";
- var slide = document.getElementById("s"+(Slideous.curidx=i)), item;
- while (item = Slideous.firstitem(slide, showitems ? Slideous.isitemhidden : Slideous.isitemvisible))
- Slideous.displayitem(item, showitems);
- slide.style.display = "block";
- if (updatestatus)
- Slideous.updatestatus();
- }
- },
- firstitem: function(root, filter) {
- var found = filter(root);
- for (var node=root.firstChild; node!=null && !found; node = node.nextSibling)
- found = Slideous.firstitem(node, filter);
- return found;
- },
- lastitem: function(root, filter) {
- var found = null;
- for (var node=root.lastChild; node!=null && !found; node = node.previousSibling)
- found = Slideous.lastitem(node, filter);
- return found || filter(root);
- },
- isitem: function(node, visible) {
- var nodename;
- return node && node.nodeType == 1 // elements only ..
- && (nodename=node.nodeName.toLowerCase()) in Slideous.incrementables
- && ( Slideous.incrementables[nodename].filter.match("\\bself\\b") && (Slideous.hasclass(node, "incremental") || (Slideous.autoincrement && nodename in Slideous.autoincrementables))
- || Slideous.incrementables[nodename].filter.match("\\bparent\\b") && (Slideous.hasclass(node.parentNode, "incremental") || (Slideous.autoincrement && node.parentNode.nodeName.toLowerCase() in Slideous.autoincrementables))
- || Slideous.incrementables[nodename].filter.match("\\bgrandparent\\b") && (Slideous.hasclass(node.parentNode.parentNode, "incremental") || (Slideous.autoincrement && node.parentNode.parentNode.nodeName.toLowerCase() in Slideous.autoincrementables))
- )
- && (visible ? (node.style.visibility != "hidden")
- : (node.style.visibility == "hidden"))
- ? node : null;
- },
- isitemvisible: function(node) { return Slideous.isitem(node, true); },
- isitemhidden: function(node) { return Slideous.isitem(node, false); },
- displayitem: function(item, show) {
- if (item) item.style.visibility = (show ? "visible" : "hidden");
- },
- updatestatus: function() {
- if (Slideous.statusbar) {
- var eos = document.getElementById("eos"),
- idx = document.getElementById("slideidx"),
- tocbox = document.getElementById("tocbox");
- if (eos)
- eos.style.visibility = Slideous.firstitem(document.getElementById("s"+Slideous.curidx), Slideous.isitemhidden) != null
- ? "visible" : "hidden";
- if (idx)
- idx.innerHTML = Slideous.curidx;
- if (tocbox)
- tocbox.selectedIndex = Slideous.curidx-1;
- }
- },
- changefontsize: function(delta) {
- document.body.style.fontSize = (Slideous.fontsize+=delta)+"%";
- },
- togglestatusbar: function() {
- document.getElementById("statusbar").style.display = (Slideous.statusbar = !Slideous.statusbar) ? "block" : "none";
- },
- toggleshowall: function(showall) {
- var slide, item;
- for (var i=0; i<Slideous.count; i++) {
- slide = document.getElementById("s"+(i+1));
- slide.style.display = showall ? "block" : "none";
- while (item = Slideous.firstitem(slide, showall ? Slideous.isitemhidden : Slideous.isitemvisible))
- Slideous.displayitem(item, showall);
- var divs = slide.getElementsByTagName("div");
- for (var j in divs)
- if (Slideous.hasclass(divs[j], "handout"))
- divs[j].style.display = showall ? "block" : "none";
- }
- if (!showall)
- document.getElementById("s"+Slideous.curidx).style.display = "block";
- if (Slideous.statusbar)
- document.getElementById("statusbar").style.display = showall ? "none" : "block";
- Slideous.showall = showall;
- },
- hasclass: function(elem, classname) {
- var classattr = null;
- return (classattr=(elem.attributes && elem.attributes["class"]))
- && classattr.nodeValue.match("\\b"+classname+"\\b");
- },
- selectedcontent: function() {
- return window.getSelection ? window.getSelection().toString()
- : document.getSelection ? document.getSelection()
- : document.selection ? document.selection.createRange().text
- : "";
- },
- mousenavigation: function(on) {
- if (on) {
- document.onmousedown = Slideous.mousedown;
- document.onmouseup = Slideous.mouseup;
- }
- else
- document.onmousedown = document.onmouseup = null;
- },
- mousepos: function(e) {
- return e.pageX ? {x: e.pageX, y: e.pageY}
- : {x: e.x+document.body.scrollLeft, y: e.y+document.body.scrollTop};
- },
- mousedown: function(evt) {
- evt = evt||window.event;
- Slideous.mousedownpos = Slideous.mousepos(evt);
- Slideous.contentselected = !!Slideous.selectedcontent() || ((evt.target || evt.srcElement).nodeName.toLowerCase() in Slideous.clickables);
- return true;
- },
- mouseup: function(evt) {
- evt = evt||window.event;
- var pos = Slideous.mousepos(evt);
- if (pos.x == Slideous.mousedownpos.x && pos.y == Slideous.mousedownpos.y && !Slideous.contentselected) {
- Slideous.next(true);
- return evt.returnValue = !(evt.cancel = true);
- }
- return false;
- }
-};
-window.onload = Slideous.init;
diff --git a/data/slidy/graphics/fold-dim.gif b/data/slidy/graphics/fold-dim.gif
deleted file mode 100644
index 346fcbf3e..000000000
--- a/data/slidy/graphics/fold-dim.gif
+++ /dev/null
Binary files differ
diff --git a/data/slidy/graphics/fold.gif b/data/slidy/graphics/fold.gif
deleted file mode 100644
index 133e594fd..000000000
--- a/data/slidy/graphics/fold.gif
+++ /dev/null
Binary files differ
diff --git a/data/slidy/graphics/nofold-dim.gif b/data/slidy/graphics/nofold-dim.gif
deleted file mode 100644
index 996fb5eda..000000000
--- a/data/slidy/graphics/nofold-dim.gif
+++ /dev/null
Binary files differ
diff --git a/data/slidy/graphics/unfold-dim.gif b/data/slidy/graphics/unfold-dim.gif
deleted file mode 100644
index bee567117..000000000
--- a/data/slidy/graphics/unfold-dim.gif
+++ /dev/null
Binary files differ
diff --git a/data/slidy/graphics/unfold.gif b/data/slidy/graphics/unfold.gif
deleted file mode 100644
index 0753ae4d2..000000000
--- a/data/slidy/graphics/unfold.gif
+++ /dev/null
Binary files differ
diff --git a/data/slidy/scripts/slidy.js b/data/slidy/scripts/slidy.js
deleted file mode 100644
index a4101fe2c..000000000
--- a/data/slidy/scripts/slidy.js
+++ /dev/null
@@ -1,3016 +0,0 @@
-/* slidy.js
-
- Copyright (c) 2005-2011 W3C (MIT, ERCIM, Keio), All Rights Reserved.
- W3C liability, trademark, document use and software licensing
- rules apply, see:
-
- http://www.w3.org/Consortium/Legal/copyright-documents
- http://www.w3.org/Consortium/Legal/copyright-software
-
- Defines single name "w3c_slidy" in global namespace
- Adds event handlers without trampling on any others
-*/
-
-// the slidy object implementation
-var w3c_slidy = {
- // classify which kind of browser we're running under
- ns_pos: (typeof window.pageYOffset!='undefined'),
- khtml: ((navigator.userAgent).indexOf("KHTML") >= 0 ? true : false),
- opera: ((navigator.userAgent).indexOf("Opera") >= 0 ? true : false),
- ipad: ((navigator.userAgent).indexOf("iPad") >= 0 ? true : false),
- iphone: ((navigator.userAgent).indexOf("iPhone") >= 0 ? true : false),
- android: ((navigator.userAgent).indexOf("Android") >= 0 ? true : false),
- ie: (typeof document.all != "undefined" && !this.opera),
- ie6: (!this.ns_pos && navigator.userAgent.indexOf("MSIE 6") != -1),
- ie7: (!this.ns_pos && navigator.userAgent.indexOf("MSIE 7") != -1),
- ie8: (!this.ns_pos && navigator.userAgent.indexOf("MSIE 8") != -1),
- ie9: (!this.ns_pos && navigator.userAgent.indexOf("MSIE 9") != -1),
-
- // data for swipe and double tap detection on touch screens
- last_tap: 0,
- prev_tap: 0,
- start_x: 0,
- start_y: 0,
- delta_x: 0,
- delta_y: 0,
-
- // are we running as XHTML? (doesn't work on Opera)
- is_xhtml: /xml/.test(document.contentType),
-
- slide_number: 0, // integer slide count: 0, 1, 2, ...
- slide_number_element: null, // element containing slide number
- slides: [], // set to array of slide div's
- notes: [], // set to array of handout div's
- backgrounds: [], // set to array of background div's
- toolbar: null, // element containing toolbar
- title: null, // document title
- last_shown: null, // last incrementally shown item
- eos: null, // span element for end of slide indicator
- toc: null, // table of contents
- outline: null, // outline element with the focus
- selected_text_len: 0, // length of drag selection on document
- view_all: 0, // 1 to view all slides + handouts
- want_toolbar: true, // user preference to show/hide toolbar
- mouse_click_enabled: true, // enables left click for next slide
- scroll_hack: 0, // IE work around for position: fixed
- disable_slide_click: false, // used by clicked anchors
-
- lang: "en", // updated to language specified by html file
-
- help_anchor: null, // used for keyboard focus hack in showToolbar()
- help_page: "http://www.w3.org/Talks/Tools/Slidy2/help/help.html",
- help_text: "Navigate with mouse click, space bar, Cursor Left/Right, " +
- "or Pg Up and Pg Dn. Use S and B to change font size.",
-
- size_index: 0,
- size_adjustment: 0,
- sizes: new Array("10pt", "12pt", "14pt", "16pt", "18pt", "20pt",
- "22pt", "24pt", "26pt", "28pt", "30pt", "32pt"),
-
- // needed for efficient resizing
- last_width: 0,
- last_height: 0,
-
-
- // Needed for cross browser support for relative width/height on
- // object elements. The work around is to save width/height attributes
- // and then to recompute absolute width/height dimensions on resizing
- objects: [],
-
- // attach initialiation event handlers
- set_up: function () {
- var init = function() { w3c_slidy.init(); };
- if (typeof window.addEventListener != "undefined")
- window.addEventListener("load", init, false);
- else
- window.attachEvent("onload", init);
- },
-
- hide_slides: function () {
- if (document.body && !w3c_slidy.initialized)
- document.body.style.visibility = "hidden";
- else
- setTimeout(w3c_slidy.hide_slides, 50);
- },
-
- // hack to persuade IE to compute correct document height
- // as needed for simulating fixed positioning of toolbar
- ie_hack: function () {
- window.resizeBy(0,-1);
- window.resizeBy(0, 1);
- },
-
- init: function () {
- //alert("slidy starting test 10");
- document.body.style.visibility = "visible";
- this.init_localization();
- this.add_toolbar();
- this.wrap_implicit_slides();
- this.collect_slides();
- this.collect_notes();
- this.collect_backgrounds();
- this.objects = document.body.getElementsByTagName("object");
- this.patch_anchors();
- this.slide_number = this.find_slide_number(location.href);
- window.offscreenbuffering = true;
- this.size_adjustment = this.find_size_adjust();
- this.time_left = this.find_duration();
- this.hide_image_toolbar(); // suppress IE image toolbar popup
- this.init_outliner(); // activate fold/unfold support
- this.title = document.title;
- this.keyboardless = (this.ipad||this.iphone||this.android);
-
- if (this.keyboardless)
- {
- w3c_slidy.remove_class(w3c_slidy.toolbar, "hidden")
- this.want_toolbar = 0;
- }
-
- // work around for opera bug
- this.is_xhtml = (document.body.tagName == "BODY" ? false : true);
-
- if (this.slides.length > 0)
- {
- var slide = this.slides[this.slide_number];
-
- if (this.slide_number > 0)
- {
- this.set_visibility_all_incremental("visible");
- this.last_shown = this.previous_incremental_item(null);
- this.set_eos_status(true);
- }
- else
- {
- this.last_shown = null;
- this.set_visibility_all_incremental("hidden");
- this.set_eos_status(!this.next_incremental_item(this.last_shown));
- }
-
- this.set_location();
- this.add_class(this.slides[0], "first-slide");
- w3c_slidy.show_slide(slide);
- }
-
- this.toc = this.table_of_contents();
-
- this.add_initial_prompt();
-
- // bind event handlers without interfering with custom page scripts
- // Tap events behave too weirdly to support clicks reliably on
- // iPhone and iPad, so exclude these from click handler
-
- if (!this.keyboardless)
- {
- this.add_listener(document.body, "click", this.mouse_button_click);
- this.add_listener(document.body, "mousedown", this.mouse_button_down);
- }
-
- this.add_listener(document, "keydown", this.key_down);
- this.add_listener(document, "keypress", this.key_press);
- this.add_listener(window, "resize", this.resized);
- this.add_listener(window, "scroll", this.scrolled);
- this.add_listener(window, "unload", this.unloaded);
-
- //this.add_listener(document.body, "touchstart", this.touchstart);
- //this.add_listener(document.body, "touchmove", this.touchmove);
- //this.add_listener(document.body, "touchend", this.touchend);
-
- this.add_listener(document, "gesturechange", function ()
- {
- return false;
- });
-
- this.attach_touch_handers(this.slides);
-
- // this seems to be a debugging hack
- //if (!document.body.onclick)
- // document.body.onclick = function () { };
-
- this.single_slide_view();
-
- //this.set_location();
-
- this.resized();
-
- if (this.ie7)
- setTimeout(w3c_slidy.ie_hack, 100);
-
- this.show_toolbar();
-
- // for back button detection
- setInterval(function () { w3c_slidy.check_location(); }, 200);
- w3c_slidy.initialized = true;
- },
-
- // create div element with links to each slide
- table_of_contents: function () {
- var toc = this.create_element("div");
- this.add_class(toc, "slidy_toc hidden");
- //toc.setAttribute("tabindex", "0");
-
- var heading = this.create_element("div");
- this.add_class(heading, "toc-heading");
- heading.innerHTML = this.localize("Table of Contents");
-
- toc.appendChild(heading);
- var previous = null;
-
- for (var i = 0; i < this.slides.length; ++i)
- {
- var title = this.has_class(this.slides[i], "title");
- var num = document.createTextNode((i + 1) + ". ");
-
- toc.appendChild(num);
-
- var a = this.create_element("a");
- a.setAttribute("href", "#(" + (i+1) + ")");
-
- if (title)
- this.add_class(a, "titleslide");
-
- var name = document.createTextNode(this.slide_name(i));
- a.appendChild(name);
- a.onclick = w3c_slidy.toc_click;
- a.onkeydown = w3c_slidy.toc_key_down;
- a.previous = previous;
-
- if (previous)
- previous.next = a;
-
- toc.appendChild(a);
-
- if (i == 0)
- toc.first = a;
-
- if (i < this.slides.length - 1)
- {
- var br = this.create_element("br");
- toc.appendChild(br);
- }
-
- previous = a;
- }
-
- toc.focus = function () {
- if (this.first)
- this.first.focus();
- }
-
- toc.onmouseup = w3c_slidy.mouse_button_up;
-
- toc.onclick = function (e) {
- e||(e=window.event);
-
- if (w3c_slidy.selected_text_len <= 0)
- w3c_slidy.hide_table_of_contents(true);
-
- w3c_slidy.stop_propagation(e);
-
- if (e.cancel != undefined)
- e.cancel = true;
-
- if (e.returnValue != undefined)
- e.returnValue = false;
-
- return false;
- };
-
- document.body.insertBefore(toc, document.body.firstChild);
- return toc;
- },
-
- is_shown_toc: function () {
- return !w3c_slidy.has_class(w3c_slidy.toc, "hidden");
- },
-
- show_table_of_contents: function () {
- w3c_slidy.remove_class(w3c_slidy.toc, "hidden");
- var toc = w3c_slidy.toc;
- toc.focus();
-
- if (w3c_slidy.ie7 && w3c_slidy.slide_number == 0)
- setTimeout(w3c_slidy.ie_hack, 100);
- },
-
- hide_table_of_contents: function (focus) {
- w3c_slidy.add_class(w3c_slidy.toc, "hidden");
-
- if (focus && !w3c_slidy.opera &&
- !w3c_slidy.has_class(w3c_slidy.toc, "hidden"))
- w3c_slidy.help_anchor.focus();
- },
-
- toggle_table_of_contents: function () {
- if (w3c_slidy.is_shown_toc())
- w3c_slidy.hide_table_of_contents(true);
- else
- w3c_slidy.show_table_of_contents();
- },
-
- // called on clicking toc entry
- toc_click: function (e) {
- if (!e)
- e = window.event;
-
- var target = w3c_slidy.get_target(e);
-
- if (target && target.nodeType == 1)
- {
- var uri = target.getAttribute("href");
-
- if (uri)
- {
- //alert("going to " + uri);
- var slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.hide_slide(slide);
- w3c_slidy.slide_number = w3c_slidy.find_slide_number(uri);
- slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.last_shown = null;
- w3c_slidy.set_location();
- w3c_slidy.set_visibility_all_incremental("hidden");
- w3c_slidy.set_eos_status(!w3c_slidy.next_incremental_item(w3c_slidy.last_shown));
- w3c_slidy.show_slide(slide);
- //target.focus();
-
- try
- {
- if (!w3c_slidy.opera)
- w3c_slidy.help_anchor.focus();
- }
- catch (e)
- {
- }
- }
- }
-
- w3c_slidy.hide_table_of_contents(true);
- if (w3c_slidy.ie7) w3c_slidy.ie_hack();
- w3c_slidy.stop_propagation(e);
- return w3c_slidy.cancel(e);
- },
-
- // called onkeydown for toc entry
- toc_key_down: function (event) {
- var key;
-
- if (!event)
- var event = window.event;
-
- // kludge around NS/IE differences
- if (window.event)
- key = window.event.keyCode;
- else if (event.which)
- key = event.which;
- else
- return true; // Yikes! unknown browser
-
- // ignore event if key value is zero
- // as for alt on Opera and Konqueror
- if (!key)
- return true;
-
- // check for concurrent control/command/alt key
- // but are these only present on mouse events?
-
- if (event.ctrlKey || event.altKey)
- return true;
-
- if (key == 13)
- {
- var uri = this.getAttribute("href");
-
- if (uri)
- {
- //alert("going to " + uri);
- var slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.hide_slide(slide);
- w3c_slidy.slide_number = w3c_slidy.find_slide_number(uri);
- slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.last_shown = null;
- w3c_slidy.set_location();
- w3c_slidy.set_visibility_all_incremental("hidden");
- w3c_slidy.set_eos_status(!w3c_slidy.next_incremental_item(w3c_slidy.last_shown));
- w3c_slidy.show_slide(slide);
- //target.focus();
-
- try
- {
- if (!w3c_slidy.opera)
- w3c_slidy.help_anchor.focus();
- }
- catch (e)
- {
- }
- }
-
- w3c_slidy.hide_table_of_contents(true);
-
- if (self.ie7)
- w3c_slidy.ie_hack();
-
- return w3c_slidy.cancel(event);
- }
-
- if (key == 40 && this.next)
- {
- this.next.focus();
- return w3c_slidy.cancel(event);
- }
-
- if (key == 38 && this.previous)
- {
- this.previous.focus();
- return w3c_slidy.cancel(event);
- }
-
- return true;
- },
-
- touchstart: function (e)
- {
- //e.preventDefault();
- this.prev_tap = this.last_tap;
- this.last_tap = (new Date).getTime();
-
- var tap_delay = this.last_tap - this.prev_tap;
-
- if (tap_delay <= 200)
- {
- // double tap
- }
-
- var touch = e.touches[0];
-
- this.start_x = touch.pageX;
- this.start_y = touch.pageY;
- this.delta_x = this.delta_y = 0;
- },
-
- touchmove: function (e)
- {
- //e.preventDefault();
- var touch = e.touches[0];
- this.delta_x = touch.pageX - this.start_x;
- this.delta_y = touch.pageY - this.start_y;
- },
-
- touchend: function (e)
- {
- //e.preventDefault();
- var delay = (new Date).getTime() - this.last_tap;
- var dx = this.delta_x;
- var dy = this.delta_y;
- var abs_dx = Math.abs(dx);
- var abs_dy = Math.abs(dy);
-
- if (delay < 500 && (abs_dx > 100 || abs_dy > 100))
- {
- if (abs_dx > 0.5 * abs_dy)
- {
- if (dx < 0)
- w3c_slidy.next_slide(true);
- else
- w3c_slidy.previous_slide(true);
- }
- else if (abs_dy > 2 * abs_dx)
- {
- w3c_slidy.toggle_table_of_contents();
- }
- }
- },
-
- // ### OBSOLETE ###
- before_print: function () {
- this.show_all_slides();
- this.hide_toolbar();
- alert("before print");
- },
-
- // ### OBSOLETE ###
- after_print: function () {
- if (!this.view_all)
- {
- this.single_slide_view();
- this.show_toolbar();
- }
- alert("after print");
- },
-
- // ### OBSOLETE ###
- print_slides: function () {
- this.before_print();
- window.print();
- this.after_print();
- },
-
- // ### OBSOLETE ?? ###
- toggle_view: function () {
- if (this.view_all)
- {
- this.single_slide_view();
- this.show_toolbar();
- this.view_all = 0;
- }
- else
- {
- this.show_all_slides();
- this.hide_toolbar();
- this.view_all = 1;
- }
- },
-
- // prepare for printing ### OBSOLETE ###
- show_all_slides: function () {
- this.remove_class(document.body, "single_slide");
- this.set_visibility_all_incremental("visible");
- },
-
- // restore after printing ### OBSOLETE ###
- single_slide_view: function () {
- this.add_class(document.body, "single_slide");
- this.set_visibility_all_incremental("visible");
- this.last_shown = this.previous_incremental_item(null);
- },
-
- // suppress IE's image toolbar pop up
- hide_image_toolbar: function () {
- if (!this.ns_pos)
- {
- var images = document.getElementsByTagName("IMG");
-
- for (var i = 0; i < images.length; ++i)
- images[i].setAttribute("galleryimg", "no");
- }
- },
-
- unloaded: function (e) {
- //alert("unloaded");
- },
-
- // Safari and Konqueror don't yet support getComputedStyle()
- // and they always reload page when location.href is updated
- is_KHTML: function () {
- var agent = navigator.userAgent;
- return (agent.indexOf("KHTML") >= 0 ? true : false);
- },
-
- // find slide name from first h1 element
- // default to document title + slide number
- slide_name: function (index) {
- var name = null;
- var slide = this.slides[index];
-
- var heading = this.find_heading(slide);
-
- if (heading)
- name = this.extract_text(heading);
-
- if (!name)
- name = this.title + "(" + (index + 1) + ")";
-
- name.replace(/\&/g, "&amp;");
- name.replace(/\</g, "&lt;");
- name.replace(/\>/g, "&gt;");
-
- return name;
- },
-
- // find first h1 element in DOM tree
- find_heading: function (node) {
- if (!node || node.nodeType != 1)
- return null;
-
- if (node.nodeName == "H1" || node.nodeName == "h1")
- return node;
-
- var child = node.firstChild;
-
- while (child)
- {
- node = this.find_heading(child);
-
- if (node)
- return node;
-
- child = child.nextSibling;
- }
-
- return null;
- },
-
- // recursively extract text from DOM tree
- extract_text: function (node) {
- if (!node)
- return "";
-
- // text nodes
- if (node.nodeType == 3)
- return node.nodeValue;
-
- // elements
- if (node.nodeType == 1)
- {
- node = node.firstChild;
- var text = "";
-
- while (node)
- {
- text = text + this.extract_text(node);
- node = node.nextSibling;
- }
-
- return text;
- }
-
- return "";
- },
-
- // find copyright text from meta element
- find_copyright: function () {
- var name, content;
- var meta = document.getElementsByTagName("meta");
-
- for (var i = 0; i < meta.length; ++i)
- {
- name = meta[i].getAttribute("name");
- content = meta[i].getAttribute("content");
-
- if (name == "copyright")
- return content;
- }
-
- return null;
- },
-
- find_size_adjust: function () {
- var name, content, offset;
- var meta = document.getElementsByTagName("meta");
-
- for (var i = 0; i < meta.length; ++i)
- {
- name = meta[i].getAttribute("name");
- content = meta[i].getAttribute("content");
-
- if (name == "font-size-adjustment")
- return 1 * content;
- }
-
- return 1;
- },
-
- // <meta name="duration" content="20" /> for 20 minutes
- find_duration: function () {
- var name, content, offset;
- var meta = document.getElementsByTagName("meta");
-
- for (var i = 0; i < meta.length; ++i)
- {
- name = meta[i].getAttribute("name");
- content = meta[i].getAttribute("content");
-
- if (name == "duration")
- return 60000 * content;
- }
-
- return null;
- },
-
- replace_by_non_breaking_space: function (str) {
- for (var i = 0; i < str.length; ++i)
- str[i] = 160;
- },
-
- // ### CHECK ME ### is use of "li" okay for text/html?
- // for XHTML do we also need to specify namespace?
- init_outliner: function () {
- var items = document.getElementsByTagName("li");
-
- for (var i = 0; i < items.length; ++i)
- {
- var target = items[i];
-
- if (!this.has_class(target.parentNode, "outline"))
- continue;
-
- target.onclick = this.outline_click;
-/* ### more work needed for IE6
- if (!this.ns_pos)
- {
- target.onmouseover = this.hover_outline;
- target.onmouseout = this.unhover_outline;
- }
-*/
- if (this.foldable(target))
- {
- target.foldable = true;
- target.onfocus = function () {w3c_slidy.outline = this;};
- target.onblur = function () {w3c_slidy.outline = null;};
-
- if (!target.getAttribute("tabindex"))
- target.setAttribute("tabindex", "0");
-
- if (this.has_class(target, "expand"))
- this.unfold(target);
- else
- this.fold(target);
- }
- else
- {
- this.add_class(target, "nofold");
- target.visible = true;
- target.foldable = false;
- }
- }
- },
-
- foldable: function (item) {
- if (!item || item.nodeType != 1)
- return false;
-
- var node = item.firstChild;
-
- while (node)
- {
- if (node.nodeType == 1 && this.is_block(node))
- return true;
-
- node = node.nextSibling;
- }
-
- return false;
- },
-
- // ### CHECK ME ### switch to add/remove "hidden" class
- fold: function (item) {
- if (item)
- {
- this.remove_class(item, "unfolded");
- this.add_class(item, "folded");
- }
-
- var node = item ? item.firstChild : null;
-
- while (node)
- {
- if (node.nodeType == 1 && this.is_block(node)) // element
- {
- w3c_slidy.add_class(node, "hidden");
- }
-
- node = node.nextSibling;
- }
-
- item.visible = false;
- },
-
- // ### CHECK ME ### switch to add/remove "hidden" class
- unfold: function (item) {
- if (item)
- {
- this.add_class(item, "unfolded");
- this.remove_class(item, "folded");
- }
-
- var node = item ? item.firstChild : null;
-
- while (node)
- {
- if (node.nodeType == 1 && this.is_block(node)) // element
- {
- w3c_slidy.remove_class(node, "hidden");
- }
-
- node = node.nextSibling;
- }
-
- item.visible = true;
- },
-
- outline_click: function (e) {
- if (!e)
- e = window.event;
-
- var rightclick = false;
- var target = w3c_slidy.get_target(e);
-
- while (target && target.visible == undefined)
- target = target.parentNode;
-
- if (!target)
- return true;
-
- if (e.which)
- rightclick = (e.which == 3);
- else if (e.button)
- rightclick = (e.button == 2);
-
- if (!rightclick && target.visible != undefined)
- {
- if (target.foldable)
- {
- if (target.visible)
- w3c_slidy.fold(target);
- else
- w3c_slidy.unfold(target);
- }
-
- w3c_slidy.stop_propagation(e);
- e.cancel = true;
- e.returnValue = false;
- }
-
- return false;
- },
-
- add_initial_prompt: function () {
- var prompt = this.create_element("div");
- prompt.setAttribute("class", "initial_prompt");
-
- var p1 = this.create_element("p");
- prompt.appendChild(p1);
- p1.setAttribute("class", "help");
-
- if (this.keyboardless)
- p1.innerHTML = "swipe left to move to next slide";
- else
- p1.innerHTML = "Space, Right Arrow or swipe left to move to " +
- "next slide, click help below for more details";
-
- this.add_listener(prompt, "click", function (e) {
- document.body.removeChild(prompt);
- w3c_slidy.stop_propagation(e);
-
- if (e.cancel != undefined)
- e.cancel = true;
-
- if (e.returnValue != undefined)
- e.returnValue = false;
-
- return false;
- });
-
- document.body.appendChild(prompt);
- this.initial_prompt = prompt;
- setTimeout(function() {document.body.removeChild(prompt);}, 5000);
- },
-
- add_toolbar: function () {
- var counter, page;
-
- this.toolbar = this.create_element("div");
- this.toolbar.setAttribute("class", "toolbar");
-
- // a reasonably behaved browser
- if (this.ns_pos || !this.ie6)
- {
- var right = this.create_element("div");
- right.setAttribute("style", "float: right; text-align: right");
-
- counter = this.create_element("span")
- counter.innerHTML = this.localize("slide") + " n/m";
- right.appendChild(counter);
- this.toolbar.appendChild(right);
-
- var left = this.create_element("div");
- left.setAttribute("style", "text-align: left");
-
- // global end of slide indicator
- this.eos = this.create_element("span");
- this.eos.innerHTML = "* ";
- left.appendChild(this.eos);
-
- var help = this.create_element("a");
- help.setAttribute("href", this.help_page);
- help.setAttribute("title", this.localize(this.help_text));
- help.innerHTML = this.localize("help?");
- left.appendChild(help);
- this.help_anchor = help; // save for focus hack
-
- var gap1 = document.createTextNode(" ");
- left.appendChild(gap1);
-
- var contents = this.create_element("a");
- contents.setAttribute("href", "javascript:w3c_slidy.toggle_table_of_contents()");
- contents.setAttribute("title", this.localize("table of contents"));
- contents.innerHTML = this.localize("contents?");
- left.appendChild(contents);
-
- var gap2 = document.createTextNode(" ");
- left.appendChild(gap2);
-
- var copyright = this.find_copyright();
-
- if (copyright)
- {
- var span = this.create_element("span");
- span.className = "copyright";
- span.innerHTML = copyright;
- left.appendChild(span);
- }
-
- this.toolbar.setAttribute("tabindex", "0");
- this.toolbar.appendChild(left);
- }
- else // IE6 so need to work around its poor CSS support
- {
- this.toolbar.style.position = (this.ie7 ? "fixed" : "absolute");
- this.toolbar.style.zIndex = "200";
- this.toolbar.style.width = "99.9%";
- this.toolbar.style.height = "1.2em";
- this.toolbar.style.top = "auto";
- this.toolbar.style.bottom = "0";
- this.toolbar.style.left = "0";
- this.toolbar.style.right = "0";
- this.toolbar.style.textAlign = "left";
- this.toolbar.style.fontSize = "60%";
- this.toolbar.style.color = "red";
- this.toolbar.borderWidth = 0;
- this.toolbar.className = "toolbar";
- this.toolbar.style.background = "rgb(240,240,240)";
-
- // would like to have help text left aligned
- // and page counter right aligned, floating
- // div's don't work, so instead use nested
- // absolutely positioned div's.
-
- var sp = this.create_element("span");
- sp.innerHTML = "&nbsp;&nbsp;*&nbsp;";
- this.toolbar.appendChild(sp);
- this.eos = sp; // end of slide indicator
-
- var help = this.create_element("a");
- help.setAttribute("href", this.help_page);
- help.setAttribute("title", this.localize(this.help_text));
- help.innerHTML = this.localize("help?");
- this.toolbar.appendChild(help);
- this.help_anchor = help; // save for focus hack
-
- var gap1 = document.createTextNode(" ");
- this.toolbar.appendChild(gap1);
-
- var contents = this.create_element("a");
- contents.setAttribute("href", "javascript:toggleTableOfContents()");
- contents.setAttribute("title", this.localize("table of contents".localize));
- contents.innerHTML = this.localize("contents?");
- this.toolbar.appendChild(contents);
-
- var gap2 = document.createTextNode(" ");
- this.toolbar.appendChild(gap2);
-
- var copyright = this.find_copyright();
-
- if (copyright)
- {
- var span = this.create_element("span");
- span.innerHTML = copyright;
- span.style.color = "black";
- span.style.marginLeft = "0.5em";
- this.toolbar.appendChild(span);
- }
-
- counter = this.create_element("div")
- counter.style.position = "absolute";
- counter.style.width = "auto"; //"20%";
- counter.style.height = "1.2em";
- counter.style.top = "auto";
- counter.style.bottom = 0;
- counter.style.right = "0";
- counter.style.textAlign = "right";
- counter.style.color = "red";
- counter.style.background = "rgb(240,240,240)";
-
- counter.innerHTML = this.localize("slide") + " n/m";
- this.toolbar.appendChild(counter);
- }
-
- // ensure that click isn't passed through to the page
- this.toolbar.onclick =
- function (e) {
- if (!e)
- e = window.event;
-
- var target = e.target;
-
- if (!target && e.srcElement)
- target = e.srcElement;
-
- // work around Safari bug
- if (target && target.nodeType == 3)
- target = target.parentNode;
-
- w3c_slidy.stop_propagation(e);
-
- if (target && target.nodeName.toLowerCase() != "a")
- w3c_slidy.mouse_button_click(e);
- };
-
- this.slide_number_element = counter;
- this.set_eos_status(false);
- document.body.appendChild(this.toolbar);
- },
-
- // wysiwyg editors make it hard to use div elements
- // e.g. amaya loses the div when you copy and paste
- // this function wraps div elements around implicit
- // slides which start with an h1 element and continue
- // up to the next heading or div element
- wrap_implicit_slides: function () {
- var i, heading, node, next, div;
- var headings = document.getElementsByTagName("h1");
-
- if (!headings)
- return;
-
- for (i = 0; i < headings.length; ++i)
- {
- heading = headings[i];
-
- if (heading.parentNode != document.body)
- continue;
-
- node = heading.nextSibling;
-
- div = document.createElement("div");
- this.add_class(div, "slide");
- document.body.replaceChild(div, heading);
- div.appendChild(heading);
-
- while (node)
- {
- if (node.nodeType == 1) // an element
- {
- if (node.nodeName == "H1" || node.nodeName == "h1")
- break;
-
- if (node.nodeName == "DIV" || node.nodeName == "div")
- {
- if (this.has_class(node, "slide"))
- break;
-
- if (this.has_class(node, "handout"))
- break;
- }
- }
-
- next = node.nextSibling;
- node = document.body.removeChild(node);
- div.appendChild(node);
- node = next;
- }
- }
- },
-
- attach_touch_handers: function(slides)
- {
- var i, slide;
-
- for (i = 0; i < slides.length; ++i)
- {
- slide = slides[i];
- this.add_listener(slide, "touchstart", this.touchstart);
- this.add_listener(slide, "touchmove", this.touchmove);
- this.add_listener(slide, "touchend", this.touchend);
- }
- },
-
-// return new array of all slides
- collect_slides: function () {
- var slides = new Array();
- var divs = document.body.getElementsByTagName("div");
-
- for (var i = 0; i < divs.length; ++i)
- {
- div = divs.item(i);
-
- if (this.has_class(div, "slide"))
- {
- // add slide to collection
- slides[slides.length] = div;
-
- // hide each slide as it is found
- this.add_class(div, "hidden");
-
- // add dummy <br/> at end for scrolling hack
- var node1 = document.createElement("br");
- div.appendChild(node1);
- var node2 = document.createElement("br");
- div.appendChild(node2);
- }
- else if (this.has_class(div, "background"))
- { // work around for Firefox SVG reload bug
- // which otherwise replaces 1st SVG graphic with 2nd
- div.style.display = "block";
- }
- }
-
- this.slides = slides;
- },
-
- // return new array of all <div class="handout">
- collect_notes: function () {
- var notes = new Array();
- var divs = document.body.getElementsByTagName("div");
-
- for (var i = 0; i < divs.length; ++i)
- {
- div = divs.item(i);
-
- if (this.has_class(div, "handout"))
- {
- // add note to collection
- notes[notes.length] = div;
-
- // and hide it
- this.add_class(div, "hidden");
- }
- }
-
- this.notes = notes;
- },
-
- // return new array of all <div class="background">
- // including named backgrounds e.g. class="background titlepage"
- collect_backgrounds: function () {
- var backgrounds = new Array();
- var divs = document.body.getElementsByTagName("div");
-
- for (var i = 0; i < divs.length; ++i)
- {
- div = divs.item(i);
-
- if (this.has_class(div, "background"))
- {
- // add background to collection
- backgrounds[backgrounds.length] = div;
-
- // and hide it
- this.add_class(div, "hidden");
- }
- }
-
- this.backgrounds = backgrounds;
- },
-
- // set click handlers on all anchors
- patch_anchors: function () {
- var self = w3c_slidy;
- var handler = function (event) {
- // compare this.href with location.href
- // for link to another slide in this doc
-
- if (self.page_address(this.href) == self.page_address(location.href))
- {
- // yes, so find new slide number
- var newslidenum = self.find_slide_number(this.href);
-
- if (newslidenum != self.slide_number)
- {
- var slide = self.slides[self.slide_number];
- self.hide_slide(slide);
- self.slide_number = newslidenum;
- slide = self.slides[self.slide_number];
- self.show_slide(slide);
- self.set_location();
- }
- }
- else
- w3c_slidy.stop_propagation(event);
-
-// else if (this.target == null)
-// location.href = this.href;
-
- this.blur();
- self.disable_slide_click = true;
- };
-
- var anchors = document.body.getElementsByTagName("a");
-
- for (var i = 0; i < anchors.length; ++i)
- {
- if (window.addEventListener)
- anchors[i].addEventListener("click", handler, false);
- else
- anchors[i].attachEvent("onclick", handler);
- }
- },
-
- // ### CHECK ME ### see which functions are invoked via setTimeout
- // either directly or indirectly for use of w3c_slidy vs this
- show_slide_number: function () {
- var timer = w3c_slidy.get_timer();
- w3c_slidy.slide_number_element.innerHTML = timer + w3c_slidy.localize("slide") + " " +
- (w3c_slidy.slide_number + 1) + "/" + w3c_slidy.slides.length;
- },
-
- // every 200mS check if the location has been changed as a
- // result of the user activating the Back button/menu item
- // doesn't work for Opera < 9.5
- check_location: function () {
- var hash = location.hash;
-
- if (w3c_slidy.slide_number > 0 && (hash == "" || hash == "#"))
- w3c_slidy.goto_slide(0);
- else if (hash.length > 2 && hash != "#("+(w3c_slidy.slide_number+1)+")")
- {
- var num = parseInt(location.hash.substr(2));
-
- if (!isNaN(num))
- w3c_slidy.goto_slide(num-1);
- }
-
- if (w3c_slidy.time_left && w3c_slidy.slide_number > 0)
- {
- w3c_slidy.show_slide_number();
-
- if (w3c_slidy.time_left > 0)
- w3c_slidy.time_left -= 200;
- }
- },
-
- get_timer: function () {
- var timer = "";
- if (w3c_slidy.time_left)
- {
- var mins, secs;
- secs = Math.floor(w3c_slidy.time_left/1000);
- mins = Math.floor(secs / 60);
- secs = secs % 60;
- timer = (mins ? mins+"m" : "") + secs + "s ";
- }
-
- return timer;
- },
-
- // this doesn't push location onto history stack for IE
- // for which a hidden iframe hack is needed: load page into
- // the iframe with script that set's parent's location.hash
- // but that won't work for standalone use unless we can
- // create the page dynamically via a javascript: URL
- // ### use history.pushState if available
- set_location: function () {
- var uri = w3c_slidy.page_address(location.href);
- var hash = "#(" + (w3c_slidy.slide_number+1) + ")";
-
- if (w3c_slidy.slide_number >= 0)
- uri = uri + hash;
-
- if (typeof(history.pushState) != "undefined")
- {
- document.title = w3c_slidy.title + " (" + (w3c_slidy.slide_number+1) + ")";
- history.pushState(0, document.title, hash);
- w3c_slidy.show_slide_number();
- return;
- }
-
- if (w3c_slidy.ie && (w3c_slidy.ie6 || w3c_slidy.ie7))
- w3c_slidy.push_hash(hash);
-
- if (uri != location.href) // && !khtml
- location.href = uri;
-
- if (this.khtml)
- hash = "(" + (w3c_slidy.slide_number+1) + ")";
-
- if (!this.ie && location.hash != hash && location.hash != "")
- location.hash = hash;
-
- document.title = w3c_slidy.title + " (" + (w3c_slidy.slide_number+1) + ")";
- w3c_slidy.show_slide_number();
- },
-
- page_address: function (uri) {
- var i = uri.indexOf("#");
-
- if (i < 0)
- i = uri.indexOf("%23");
-
- // check if anchor is entire page
-
- if (i < 0)
- return uri; // yes
-
- return uri.substr(0, i);
- },
-
- // only used for IE6 and IE7
- on_frame_loaded: function (hash) {
- location.hash = hash;
- var uri = w3c_slidy.page_address(location.href);
- location.href = uri + hash;
- },
-
- // history hack with thanks to Bertrand Le Roy
- push_hash: function (hash) {
- if (hash == "") hash = "#(1)";
- window.location.hash = hash;
-
- var doc = document.getElementById("historyFrame").contentWindow.document;
- doc.open("javascript:'<html></html>'");
- doc.write("<html><head><script type=\"text/javascript\">window.parent.w3c_slidy.on_frame_loaded('"+
- (hash) + "');</script></head><body>hello mum</body></html>");
- doc.close();
- },
-
- // find current slide based upon location
- // first find target anchor and then look
- // for associated div element enclosing it
- // finally map that to slide number
- find_slide_number: function (uri) {
- // first get anchor from page location
-
- var i = uri.indexOf("#");
-
- // check if anchor is entire page
- if (i < 0)
- return 0; // yes
-
- var anchor = unescape(uri.substr(i+1));
-
- // now use anchor as XML ID to find target
- var target = document.getElementById(anchor);
-
- if (!target)
- {
- // does anchor look like "(2)" for slide 2 ??
- // where first slide is (1)
- var re = /\((\d)+\)/;
-
- if (anchor.match(re))
- {
- var num = parseInt(anchor.substring(1, anchor.length-1));
-
- if (num > this.slides.length)
- num = 1;
-
- if (--num < 0)
- num = 0;
-
- return num;
- }
-
- // accept [2] for backwards compatibility
- re = /\[(\d)+\]/;
-
- if (anchor.match(re))
- {
- var num = parseInt(anchor.substring(1, anchor.length-1));
-
- if (num > this.slides.length)
- num = 1;
-
- if (--num < 0)
- num = 0;
-
- return num;
- }
-
- // oh dear unknown anchor
- return 0;
- }
-
- // search for enclosing slide
-
- while (true)
- {
- // browser coerces html elements to uppercase!
- if (target.nodeName.toLowerCase() == "div" &&
- this.has_class(target, "slide"))
- {
- // found the slide element
- break;
- }
-
- // otherwise try parent element if any
-
- target = target.parentNode;
-
- if (!target)
- {
- return 0; // no luck!
- }
- };
-
- for (i = 0; i < slides.length; ++i)
- {
- if (slides[i] == target)
- return i; // success
- }
-
- // oh dear still no luck
- return 0;
- },
-
- previous_slide: function (incremental) {
- if (!w3c_slidy.view_all)
- {
- var slide;
-
- if ((incremental || w3c_slidy.slide_number == 0) && w3c_slidy.last_shown != null)
- {
- w3c_slidy.last_shown = w3c_slidy.hide_previous_item(w3c_slidy.last_shown);
- w3c_slidy.set_eos_status(false);
- }
- else if (w3c_slidy.slide_number > 0)
- {
- slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.hide_slide(slide);
-
- w3c_slidy.slide_number = w3c_slidy.slide_number - 1;
- slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.set_visibility_all_incremental("visible");
- w3c_slidy.last_shown = w3c_slidy.previous_incremental_item(null);
- w3c_slidy.set_eos_status(true);
- w3c_slidy.show_slide(slide);
- }
-
- w3c_slidy.set_location();
-
- if (!w3c_slidy.ns_pos)
- w3c_slidy.refresh_toolbar(200);
- }
- },
-
- next_slide: function (incremental) {
- if (!w3c_slidy.view_all)
- {
- var slide, last = w3c_slidy.last_shown;
-
- if (incremental || w3c_slidy.slide_number == w3c_slidy.slides.length - 1)
- w3c_slidy.last_shown = w3c_slidy.reveal_next_item(w3c_slidy.last_shown);
-
- if ((!incremental || w3c_slidy.last_shown == null) &&
- w3c_slidy.slide_number < w3c_slidy.slides.length - 1)
- {
- slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.hide_slide(slide);
-
- w3c_slidy.slide_number = w3c_slidy.slide_number + 1;
- slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.last_shown = null;
- w3c_slidy.set_visibility_all_incremental("hidden");
- w3c_slidy.show_slide(slide);
- }
- else if (!w3c_slidy.last_shown)
- {
- if (last && incremental)
- w3c_slidy.last_shown = last;
- }
-
- w3c_slidy.set_location();
-
- w3c_slidy.set_eos_status(!w3c_slidy.next_incremental_item(w3c_slidy.last_shown));
-
- if (!w3c_slidy.ns_pos)
- w3c_slidy.refresh_toolbar(200);
- }
- },
-
- // to first slide with nothing revealed
- // i.e. state at start of presentation
- first_slide: function () {
- if (!w3c_slidy.view_all)
- {
- var slide;
-
- if (w3c_slidy.slide_number != 0)
- {
- slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.hide_slide(slide);
-
- w3c_slidy.slide_number = 0;
- slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.last_shown = null;
- w3c_slidy.set_visibility_all_incremental("hidden");
- w3c_slidy.show_slide(slide);
- }
-
- w3c_slidy.set_eos_status(
- !w3c_slidy.next_incremental_item(w3c_slidy.last_shown));
- w3c_slidy.set_location();
- }
- },
-
- // goto last slide with everything revealed
- // i.e. state at end of presentation
- last_slide: function () {
- if (!w3c_slidy.view_all)
- {
- var slide;
-
- w3c_slidy.last_shown = null; //revealNextItem(lastShown);
-
- if (w3c_slidy.last_shown == null &&
- w3c_slidy.slide_number < w3c_slidy.slides.length - 1)
- {
- slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.hide_slide(slide);
- w3c_slidy.slide_number = w3c_slidy.slides.length - 1;
- slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.set_visibility_all_incremental("visible");
- w3c_slidy.last_shown = w3c_slidy.previous_incremental_item(null);
-
- w3c_slidy.show_slide(slide);
- }
- else
- {
- w3c_slidy.set_visibility_all_incremental("visible");
- w3c_slidy.last_shown = w3c_slidy.previous_incremental_item(null);
- }
-
- w3c_slidy.set_eos_status(true);
- w3c_slidy.set_location();
- }
- },
-
-
- // ### check this and consider add/remove class
- set_eos_status: function (state) {
- if (this.eos)
- this.eos.style.color = (state ? "rgb(240,240,240)" : "red");
- },
-
- // first slide is 0
- goto_slide: function (num) {
- //alert("going to slide " + (num+1));
- var slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.hide_slide(slide);
- w3c_slidy.slide_number = num;
- slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.last_shown = null;
- w3c_slidy.set_visibility_all_incremental("hidden");
- w3c_slidy.set_eos_status(!w3c_slidy.next_incremental_item(w3c_slidy.last_shown));
- document.title = w3c_slidy.title + " (" + (w3c_slidy.slide_number+1) + ")";
- w3c_slidy.show_slide(slide);
- w3c_slidy.show_slide_number();
- },
-
-
- show_slide: function (slide) {
- this.sync_background(slide);
- this.remove_class(slide, "hidden");
-
- // work around IE9 object rendering bug
- setTimeout("window.scrollTo(0,0);", 1);
- },
-
- hide_slide: function (slide) {
- this.add_class(slide, "hidden");
- },
-
- // show just the backgrounds pertinent to this slide
- // when slide background-color is transparent
- // this should now work with rgba color values
- sync_background: function (slide) {
- var background;
- var bgColor;
-
- if (slide.currentStyle)
- bgColor = slide.currentStyle["backgroundColor"];
- else if (document.defaultView)
- {
- var styles = document.defaultView.getComputedStyle(slide,null);
-
- if (styles)
- bgColor = styles.getPropertyValue("background-color");
- else // broken implementation probably due Safari or Konqueror
- {
- //alert("defective implementation of getComputedStyle()");
- bgColor = "transparent";
- }
- }
- else
- bgColor == "transparent";
-
- if (bgColor == "transparent" ||
- bgColor.indexOf("rgba") >= 0 ||
- bgColor.indexOf("opacity") >= 0)
- {
- var slideClass = this.get_class_list(slide);
-
- for (var i = 0; i < this.backgrounds.length; i++)
- {
- background = this.backgrounds[i];
-
- var bgClass = this.get_class_list(background);
-
- if (this.matching_background(slideClass, bgClass))
- this.remove_class(background, "hidden");
- else
- this.add_class(background, "hidden");
- }
- }
- else // forcibly hide all backgrounds
- this.hide_backgrounds();
- },
-
- hide_backgrounds: function () {
- for (var i = 0; i < this.backgrounds.length; i++)
- {
- background = this.backgrounds[i];
- this.add_class(background, "hidden");
- }
- },
-
- // compare classes for slide and background
- matching_background: function (slideClass, bgClass) {
- var i, count, pattern, result;
-
- // define pattern as regular expression
- pattern = /\w+/g;
-
- // check background class names
- result = bgClass.match(pattern);
-
- for (i = count = 0; i < result.length; i++)
- {
- if (result[i] == "hidden")
- continue;
-
- if (result[i] == "background")
- continue;
-
- ++count;
- }
-
- if (count == 0) // default match
- return true;
-
- // check for matches and place result in array
- result = slideClass.match(pattern);
-
- // now check if desired name is present for background
- for (i = count = 0; i < result.length; i++)
- {
- if (result[i] == "hidden")
- continue;
-
- if (this.has_token(bgClass, result[i]))
- return true;
- }
-
- return false;
- },
-
- resized: function () {
- var width = 0;
-
- if ( typeof( window.innerWidth ) == 'number' )
- width = window.innerWidth; // Non IE browser
- else if (document.documentElement && document.documentElement.clientWidth)
- width = document.documentElement.clientWidth; // IE6
- else if (document.body && document.body.clientWidth)
- width = document.body.clientWidth; // IE4
-
- var height = 0;
-
- if ( typeof( window.innerHeight ) == 'number' )
- height = window.innerHeight; // Non IE browser
- else if (document.documentElement && document.documentElement.clientHeight)
- height = document.documentElement.clientHeight; // IE6
- else if (document.body && document.body.clientHeight)
- height = document.body.clientHeight; // IE4
-
- if (height && (width/height > 1.05*1024/768))
- {
- width = height * 1024.0/768;
- }
-
- // IE fires onresize even when only font size is changed!
- // so we do a check to avoid blocking < and > actions
- if (width != w3c_slidy.last_width || height != w3c_slidy.last_height)
- {
- if (width >= 1100)
- w3c_slidy.size_index = 5; // 4
- else if (width >= 1000)
- w3c_slidy.size_index = 4; // 3
- else if (width >= 800)
- w3c_slidy.size_index = 3; // 2
- else if (width >= 600)
- w3c_slidy.size_index = 2; // 1
- else if (width)
- w3c_slidy.size_index = 0;
-
- // add in font size adjustment from meta element e.g.
- // <meta name="font-size-adjustment" content="-2" />
- // useful when slides have too much content ;-)
-
- if (0 <= w3c_slidy.size_index + w3c_slidy.size_adjustment &&
- w3c_slidy.size_index + w3c_slidy.size_adjustment < w3c_slidy.sizes.length)
- w3c_slidy.size_index = w3c_slidy.size_index + w3c_slidy.size_adjustment;
-
- // enables cross browser use of relative width/height
- // on object elements for use with SVG and Flash media
- w3c_slidy.adjust_object_dimensions(width, height);
-
- if (document.body.style.fontSize != w3c_slidy.sizes[w3c_slidy.size_index])
- {
- document.body.style.fontSize = w3c_slidy.sizes[w3c_slidy.size_index];
- }
-
- w3c_slidy.last_width = width;
- w3c_slidy.last_height = height;
-
- // force reflow to work around Mozilla bug
- if (w3c_slidy.ns_pos)
- {
- var slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.hide_slide(slide);
- w3c_slidy.show_slide(slide);
- }
-
- // force correct positioning of toolbar
- w3c_slidy.refresh_toolbar(200);
- }
- },
-
- scrolled: function () {
- if (w3c_slidy.toolbar && !w3c_slidy.ns_pos && !w3c_slidy.ie7)
- {
- w3c_slidy.hack_offset = w3c_slidy.scroll_x_offset();
- // hide toolbar
- w3c_slidy.toolbar.style.display = "none";
-
- // make it reappear later
- if (w3c_slidy.scrollhack == 0 && !w3c_slidy.view_all)
- {
- setTimeout(function () {w3c_slidy.show_toolbar(); }, 1000);
- w3c_slidy.scrollhack = 1;
- }
- }
- },
-
- hide_toolbar: function () {
- w3c_slidy.add_class(w3c_slidy.toolbar, "hidden");
- window.focus();
- },
-
- // used to ensure IE refreshes toolbar in correct position
- refresh_toolbar: function (interval) {
- if (!w3c_slidy.ns_pos && !w3c_slidy.ie7)
- {
- w3c_slidy.hide_toolbar();
- setTimeout(function () {w3c_slidy.show_toolbar();}, interval);
- }
- },
-
- // restores toolbar after short delay
- show_toolbar: function () {
- if (w3c_slidy.want_toolbar)
- {
- w3c_slidy.toolbar.style.display = "block";
-
- if (!w3c_slidy.ns_pos)
- {
- // adjust position to allow for scrolling
- var xoffset = w3c_slidy.scroll_x_offset();
- w3c_slidy.toolbar.style.left = xoffset;
- w3c_slidy.toolbar.style.right = xoffset;
-
- // determine vertical scroll offset
- //var yoffset = scrollYOffset();
-
- // bottom is doc height - window height - scroll offset
- //var bottom = documentHeight() - lastHeight - yoffset
-
- //if (yoffset > 0 || documentHeight() > lastHeight)
- // bottom += 16; // allow for height of scrollbar
-
- w3c_slidy.toolbar.style.bottom = 0; //bottom;
- }
-
- w3c_slidy.remove_class(w3c_slidy.toolbar, "hidden");
- }
-
- w3c_slidy.scrollhack = 0;
-
-
- // set the keyboard focus to the help link on the
- // toolbar to ensure that document has the focus
- // IE doesn't always work with window.focus()
- // and this hack has benefit of Enter for help
-
- try
- {
- if (!w3c_slidy.opera)
- w3c_slidy.help_anchor.focus();
- }
- catch (e)
- {
- }
- },
-
-// invoked via F key
- toggle_toolbar: function () {
- if (!w3c_slidy.view_all)
- {
- if (w3c_slidy.has_class(w3c_slidy.toolbar, "hidden"))
- {
- w3c_slidy.remove_class(w3c_slidy.toolbar, "hidden")
- w3c_slidy.want_toolbar = 1;
- }
- else
- {
- w3c_slidy.add_class(w3c_slidy.toolbar, "hidden")
- w3c_slidy.want_toolbar = 0;
- }
- }
- },
-
- scroll_x_offset: function () {
- if (window.pageXOffset)
- return self.pageXOffset;
-
- if (document.documentElement &&
- document.documentElement.scrollLeft)
- return document.documentElement.scrollLeft;
-
- if (document.body)
- return document.body.scrollLeft;
-
- return 0;
- },
-
- scroll_y_offset: function () {
- if (window.pageYOffset)
- return self.pageYOffset;
-
- if (document.documentElement &&
- document.documentElement.scrollTop)
- return document.documentElement.scrollTop;
-
- if (document.body)
- return document.body.scrollTop;
-
- return 0;
- },
-
- // looking for a way to determine height of slide content
- // the slide itself is set to the height of the window
- optimize_font_size: function () {
- var slide = w3c_slidy.slides[w3c_slidy.slide_number];
-
- //var dh = documentHeight(); //getDocHeight(document);
- var dh = slide.scrollHeight;
- var wh = getWindowHeight();
- var u = 100 * dh / wh;
-
- alert("window utilization = " + u + "% (doc "
- + dh + " win " + wh + ")");
- },
-
- // from document object
- get_doc_height: function (doc) {
- if (!doc)
- doc = document;
-
- if (doc && doc.body && doc.body.offsetHeight)
- return doc.body.offsetHeight; // ns/gecko syntax
-
- if (doc && doc.body && doc.body.scrollHeight)
- return doc.body.scrollHeight;
-
- alert("couldn't determine document height");
- },
-
- get_window_height: function () {
- if ( typeof( window.innerHeight ) == 'number' )
- return window.innerHeight; // Non IE browser
-
- if (document.documentElement && document.documentElement.clientHeight)
- return document.documentElement.clientHeight; // IE6
-
- if (document.body && document.body.clientHeight)
- return document.body.clientHeight; // IE4
- },
-
- document_height: function () {
- var sh, oh;
-
- sh = document.body.scrollHeight;
- oh = document.body.offsetHeight;
-
- if (sh && oh)
- {
- return (sh > oh ? sh : oh);
- }
-
- // no idea!
- return 0;
- },
-
- smaller: function () {
- if (w3c_slidy.size_index > 0)
- {
- --w3c_slidy.size_index;
- }
-
- w3c_slidy.toolbar.style.display = "none";
- document.body.style.fontSize = w3c_slidy.sizes[w3c_slidy.size_index];
- var slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.hide_slide(slide);
- w3c_slidy.show_slide(slide);
- setTimeout(function () {w3c_slidy.show_toolbar(); }, 50);
- },
-
- bigger: function () {
- if (w3c_slidy.size_index < w3c_slidy.sizes.length - 1)
- {
- ++w3c_slidy.size_index;
- }
-
- w3c_slidy.toolbar.style.display = "none";
- document.body.style.fontSize = w3c_slidy.sizes[w3c_slidy.size_index];
- var slide = w3c_slidy.slides[w3c_slidy.slide_number];
- w3c_slidy.hide_slide(slide);
- w3c_slidy.show_slide(slide);
- setTimeout(function () {w3c_slidy.show_toolbar(); }, 50);
- },
-
- // enables cross browser use of relative width/height
- // on object elements for use with SVG and Flash media
- // with thanks to Ivan Herman for the suggestion
- adjust_object_dimensions: function (width, height) {
- for( var i = 0; i < w3c_slidy.objects.length; i++ )
- {
- var obj = this.objects[i];
- var mimeType = obj.getAttribute("type");
-
- if (mimeType == "image/svg+xml" || mimeType == "application/x-shockwave-flash")
- {
- if ( !obj.initialWidth )
- obj.initialWidth = obj.getAttribute("width");
-
- if ( !obj.initialHeight )
- obj.initialHeight = obj.getAttribute("height");
-
- if ( obj.initialWidth && obj.initialWidth.charAt(obj.initialWidth.length-1) == "%" )
- {
- var w = parseInt(obj.initialWidth.slice(0, obj.initialWidth.length-1));
- var newW = width * (w/100.0);
- obj.setAttribute("width",newW);
- }
-
- if ( obj.initialHeight &&
- obj.initialHeight.charAt(obj.initialHeight.length-1) == "%" )
- {
- var h = parseInt(obj.initialHeight.slice(0, obj.initialHeight.length-1));
- var newH = height * (h/100.0);
- obj.setAttribute("height", newH);
- }
- }
- }
- },
-
- // needed for Opera to inhibit default behavior
- // since Opera delivers keyPress even if keyDown
- // was cancelled
- key_press: function (event) {
- if (!event)
- event = window.event;
-
- if (!w3c_slidy.key_wanted)
- return w3c_slidy.cancel(event);
-
- return true;
- },
-
- // See e.g. http://www.quirksmode.org/js/events/keys.html for keycodes
- key_down: function (event) {
- var key, target, tag;
-
- w3c_slidy.key_wanted = true;
-
- if (!event)
- event = window.event;
-
- // kludge around NS/IE differences
- if (window.event)
- {
- key = window.event.keyCode;
- target = window.event.srcElement;
- }
- else if (event.which)
- {
- key = event.which;
- target = event.target;
- }
- else
- return true; // Yikes! unknown browser
-
- // ignore event if key value is zero
- // as for alt on Opera and Konqueror
- if (!key)
- return true;
-
- // avoid interfering with keystroke
- // behavior for non-slidy chrome elements
- if (!w3c_slidy.slidy_chrome(target) &&
- w3c_slidy.special_element(target))
- return true;
-
- // check for concurrent control/command/alt key
- // but are these only present on mouse events?
-
- if (event.ctrlKey || event.altKey || event.metaKey)
- return true;
-
- // dismiss table of contents if visible
- if (w3c_slidy.is_shown_toc() && key != 9 && key != 16 && key != 38 && key != 40)
- {
- w3c_slidy.hide_table_of_contents(true);
-
- if (key == 27 || key == 84 || key == 67)
- return w3c_slidy.cancel(event);
- }
-
- if (key == 34) // Page Down
- {
- if (w3c_slidy.view_all)
- return true;
-
- w3c_slidy.next_slide(false);
- return w3c_slidy.cancel(event);
- }
- else if (key == 33) // Page Up
- {
- if (w3c_slidy.view_all)
- return true;
-
- w3c_slidy.previous_slide(false);
- return w3c_slidy.cancel(event);
- }
- else if (key == 32) // space bar
- {
- w3c_slidy.next_slide(true);
- return w3c_slidy.cancel(event);
- }
- else if (key == 37) // Left arrow
- {
- w3c_slidy.previous_slide(!event.shiftKey);
- return w3c_slidy.cancel(event);
- }
- else if (key == 36) // Home
- {
- w3c_slidy.first_slide();
- return w3c_slidy.cancel(event);
- }
- else if (key == 35) // End
- {
- w3c_slidy.last_slide();
- return w3c_slidy.cancel(event);
- }
- else if (key == 39) // Right arrow
- {
- w3c_slidy.next_slide(!event.shiftKey);
- return w3c_slidy.cancel(event);
- }
- else if (key == 13) // Enter
- {
- if (w3c_slidy.outline)
- {
- if (w3c_slidy.outline.visible)
- w3c_slidy.fold(w3c_slidy.outline);
- else
- w3c_slidy.unfold(w3c_slidy.outline);
-
- return w3c_slidy.cancel(event);
- }
- }
- else if (key == 188) // < for smaller fonts
- {
- w3c_slidy.smaller();
- return w3c_slidy.cancel(event);
- }
- else if (key == 190) // > for larger fonts
- {
- w3c_slidy.bigger();
- return w3c_slidy.cancel(event);
- }
- else if (key == 189 || key == 109) // - for smaller fonts
- {
- w3c_slidy.smaller();
- return w3c_slidy.cancel(event);
- }
- else if (key == 187 || key == 191 || key == 107) // = + for larger fonts
- {
- w3c_slidy.bigger();
- return w3c_slidy.cancel(event);
- }
- else if (key == 83) // S for smaller fonts
- {
- w3c_slidy.smaller();
- return w3c_slidy.cancel(event);
- }
- else if (key == 66) // B for larger fonts
- {
- w3c_slidy.bigger();
- return w3c_slidy.cancel(event);
- }
- else if (key == 90) // Z for last slide
- {
- w3c_slidy.last_slide();
- return w3c_slidy.cancel(event);
- }
- else if (key == 70) // F for toggle toolbar
- {
- w3c_slidy.toggle_toolbar();
- return w3c_slidy.cancel(event);
- }
- else if (key == 65) // A for toggle view single/all slides
- {
- w3c_slidy.toggle_view();
- return w3c_slidy.cancel(event);
- }
- else if (key == 75) // toggle action of left click for next page
- {
- w3c_slidy.mouse_click_enabled = !w3c_slidy.mouse_click_enabled;
- var alert_msg = (w3c_slidy.mouse_click_enabled ?
- "enabled" : "disabled") + " mouse click advance";
-
- alert(w3c_slidy.localize(alert_msg));
- return w3c_slidy.cancel(event);
- }
- else if (key == 84 || key == 67) // T or C for table of contents
- {
- if (w3c_slidy.toc)
- w3c_slidy.toggle_table_of_contents();
-
- return w3c_slidy.cancel(event);
- }
- else if (key == 72) // H for help
- {
- window.location = w3c_slidy.help_page;
- return w3c_slidy.cancel(event);
- }
- //else alert("key code is "+ key);
-
- return true;
- },
-
- // safe for both text/html and application/xhtml+xml
- create_element: function (name) {
- if (this.xhtml && (typeof document.createElementNS != 'undefined'))
- return document.createElementNS("http://www.w3.org/1999/xhtml", name)
-
- return document.createElement(name);
- },
-
- get_element_style: function (elem, IEStyleProp, CSSStyleProp) {
- if (elem.currentStyle)
- {
- return elem.currentStyle[IEStyleProp];
- }
- else if (window.getComputedStyle)
- {
- var compStyle = window.getComputedStyle(elem, "");
- return compStyle.getPropertyValue(CSSStyleProp);
- }
- return "";
- },
-
- // the string str is a whitespace separated list of tokens
- // test if str contains a particular token, e.g. "slide"
- has_token: function (str, token) {
- if (str)
- {
- // define pattern as regular expression
- var pattern = /\w+/g;
-
- // check for matches
- // place result in array
- var result = str.match(pattern);
-
- // now check if desired token is present
- for (var i = 0; i < result.length; i++)
- {
- if (result[i] == token)
- return true;
- }
- }
-
- return false;
- },
-
- get_class_list: function (element) {
- if (typeof element.className != 'undefined')
- return element.className;
-
- return element.getAttribute("class");
- },
-
- has_class: function (element, name) {
- if (element.nodeType != 1)
- return false;
-
- var regexp = new RegExp("(^| )" + name + "\W*");
-
- if (typeof element.className != 'undefined')
- return regexp.test(element.className);
-
- return regexp.test(element.getAttribute("class"));
- },
-
- remove_class: function (element, name) {
- var regexp = new RegExp("(^| )" + name + "\W*");
- var clsval = "";
-
- if (typeof element.className != 'undefined')
- {
- clsval = element.className;
-
- if (clsval)
- {
- clsval = clsval.replace(regexp, "");
- element.className = clsval;
- }
- }
- else
- {
- clsval = element.getAttribute("class");
-
- if (clsval)
- {
- clsval = clsval.replace(regexp, "");
- element.setAttribute("class", clsval);
- }
- }
- },
-
- add_class: function (element, name) {
- if (!this.has_class(element, name))
- {
- if (typeof element.className != 'undefined')
- element.className += " " + name;
- else
- {
- var clsval = element.getAttribute("class");
- clsval = clsval ? clsval + " " + name : name;
- element.setAttribute("class", clsval);
- }
- }
- },
-
- // HTML elements that can be used with class="incremental"
- // note that you can also put the class on containers like
- // up, ol, dl, and div to make their contents appear
- // incrementally. Upper case is used since this is what
- // browsers report for HTML node names (text/html).
- incremental_elements: null,
- okay_for_incremental: function (name) {
- if (!this.incremental_elements)
- {
- var inclist = new Array();
- inclist["p"] = true;
- inclist["pre"] = true;
- inclist["li"] = true;
- inclist["blockquote"] = true;
- inclist["dt"] = true;
- inclist["dd"] = true;
- inclist["h2"] = true;
- inclist["h3"] = true;
- inclist["h4"] = true;
- inclist["h5"] = true;
- inclist["h6"] = true;
- inclist["span"] = true;
- inclist["address"] = true;
- inclist["table"] = true;
- inclist["tr"] = true;
- inclist["th"] = true;
- inclist["td"] = true;
- inclist["img"] = true;
- inclist["object"] = true;
- this.incremental_elements = inclist;
- }
- return this.incremental_elements[name.toLowerCase()];
- },
-
- next_incremental_item: function (node) {
- var br = this.is_xhtml ? "br" : "BR";
- var slide = w3c_slidy.slides[w3c_slidy.slide_number];
-
- for (;;)
- {
- node = w3c_slidy.next_node(slide, node);
-
- if (node == null || node.parentNode == null)
- break;
-
- if (node.nodeType == 1) // ELEMENT
- {
- if (node.nodeName == br)
- continue;
-
- if (w3c_slidy.has_class(node, "incremental")
- && w3c_slidy.okay_for_incremental(node.nodeName))
- return node;
-
- if (w3c_slidy.has_class(node.parentNode, "incremental")
- && !w3c_slidy.has_class(node, "non-incremental"))
- return node;
- }
- }
-
- return node;
- },
-
- previous_incremental_item: function (node) {
- var br = this.is_xhtml ? "br" : "BR";
- var slide = w3c_slidy.slides[w3c_slidy.slide_number];
-
- for (;;)
- {
- node = w3c_slidy.previous_node(slide, node);
-
- if (node == null || node.parentNode == null)
- break;
-
- if (node.nodeType == 1)
- {
- if (node.nodeName == br)
- continue;
-
- if (w3c_slidy.has_class(node, "incremental")
- && w3c_slidy.okay_for_incremental(node.nodeName))
- return node;
-
- if (w3c_slidy.has_class(node.parentNode, "incremental")
- && !w3c_slidy.has_class(node, "non-incremental"))
- return node;
- }
- }
-
- return node;
- },
-
- // set visibility for all elements on current slide with
- // a parent element with attribute class="incremental"
- set_visibility_all_incremental: function (value) {
- var node = this.next_incremental_item(null);
-
- if (value == "hidden")
- {
- while (node)
- {
- w3c_slidy.add_class(node, "invisible");
- node = w3c_slidy.next_incremental_item(node);
- }
- }
- else // value == "visible"
- {
- while (node)
- {
- w3c_slidy.remove_class(node, "invisible");
- node = w3c_slidy.next_incremental_item(node);
- }
- }
- },
-
- // reveal the next hidden item on the slide
- // node is null or the node that was last revealed
- reveal_next_item: function (node) {
- node = w3c_slidy.next_incremental_item(node);
-
- if (node && node.nodeType == 1) // an element
- w3c_slidy.remove_class(node, "invisible");
-
- return node;
- },
-
- // exact inverse of revealNextItem(node)
- hide_previous_item: function (node) {
- if (node && node.nodeType == 1) // an element
- w3c_slidy.add_class(node, "invisible");
-
- return this.previous_incremental_item(node);
- },
-
- // left to right traversal of root's content
- next_node: function (root, node) {
- if (node == null)
- return root.firstChild;
-
- if (node.firstChild)
- return node.firstChild;
-
- if (node.nextSibling)
- return node.nextSibling;
-
- for (;;)
- {
- node = node.parentNode;
-
- if (!node || node == root)
- break;
-
- if (node && node.nextSibling)
- return node.nextSibling;
- }
-
- return null;
- },
-
- // right to left traversal of root's content
- previous_node: function (root, node) {
- if (node == null)
- {
- node = root.lastChild;
-
- if (node)
- {
- while (node.lastChild)
- node = node.lastChild;
- }
-
- return node;
- }
-
- if (node.previousSibling)
- {
- node = node.previousSibling;
-
- while (node.lastChild)
- node = node.lastChild;
-
- return node;
- }
-
- if (node.parentNode != root)
- return node.parentNode;
-
- return null;
- },
-
- previous_sibling_element: function (el) {
- el = el.previousSibling;
-
- while (el && el.nodeType != 1)
- el = el.previousSibling;
-
- return el;
- },
-
- next_sibling_element: function (el) {
- el = el.nextSibling;
-
- while (el && el.nodeType != 1)
- el = el.nextSibling;
-
- return el;
- },
-
- first_child_element: function (el) {
- var node;
-
- for (node = el.firstChild; node; node = node.nextSibling)
- {
- if (node.nodeType == 1)
- break;
- }
-
- return node;
- },
-
- first_tag: function (element, tag) {
- var node;
-
- if (!this.is_xhtml)
- tag = tag.toUpperCase();
-
- for (node = element.firstChild; node; node = node.nextSibling)
- {
- if (node.nodeType == 1 && node.nodeName == tag)
- break;
- }
-
- return node;
- },
-
- hide_selection: function () {
- if (window.getSelection) // Firefox, Chromium, Safari, Opera
- {
- var selection = window.getSelection();
-
- if (selection.rangeCount > 0)
- {
- var range = selection.getRangeAt(0);
- range.collapse (false);
- }
- }
- else // Internet Explorer
- {
- var textRange = document.selection.createRange ();
- textRange.collapse (false);
- }
- },
-
- get_selected_text: function () {
- try
- {
- if (window.getSelection)
- return window.getSelection().toString();
-
- if (document.getSelection)
- return document.getSelection().toString();
-
- if (document.selection)
- return document.selection.createRange().text;
- }
- catch (e)
- {
- }
-
- return "";
- },
-
- // make note of length of selected text
- // as this evaluates to zero in click event
- mouse_button_up: function (e) {
- w3c_slidy.selected_text_len = w3c_slidy.get_selected_text().length;
- },
-
- mouse_button_down: function (e) {
- w3c_slidy.selected_text_len = w3c_slidy.get_selected_text().length;
- w3c_slidy.mouse_x = e.clientX;
- w3c_slidy.mouse_y = e.clientY;
- },
-
- // right mouse button click is reserved for context menus
- // it is more reliable to detect rightclick than leftclick
- mouse_button_click: function (e) {
- if (!e)
- var e = window.event;
-
- if (Math.abs(e.clientX -w3c_slidy.mouse_x) +
- Math.abs(e.clientY -w3c_slidy.mouse_y) > 10)
- return true;
-
- if (w3c_slidy.selected_text_len > 0)
- return true;
-
- var rightclick = false;
- var leftclick = false;
- var middleclick = false;
- var target;
-
- if (!e)
- var e = window.event;
-
- if (e.target)
- target = e.target;
- else if (e.srcElement)
- target = e.srcElement;
-
- // work around Safari bug
- if (target.nodeType == 3)
- target = target.parentNode;
-
- if (e.which) // all browsers except IE
- {
- leftclick = (e.which == 1);
- middleclick = (e.which == 2);
- rightclick = (e.which == 3);
- }
- else if (e.button)
- {
- // Konqueror gives 1 for left, 4 for middle
- // IE6 gives 0 for left and not 1 as I expected
-
- if (e.button == 4)
- middleclick = true;
-
- // all browsers agree on 2 for right button
- rightclick = (e.button == 2);
- }
- else
- leftclick = true;
-
- if (w3c_slidy.selected_text_len > 0)
- {
- w3c_slidy.stop_propagation(e);
- e.cancel = true;
- e.returnValue = false;
- return false;
- }
-
- // dismiss table of contents
- w3c_slidy.hide_table_of_contents(false);
-
- // check if target is something that probably want's clicks
- // e.g. a, embed, object, input, textarea, select, option
- var tag = target.nodeName.toLowerCase();
-
- if (w3c_slidy.mouse_click_enabled && leftclick &&
- !w3c_slidy.special_element(target) &&
- !target.onclick)
- {
- w3c_slidy.next_slide(true);
- w3c_slidy.stop_propagation(e);
- e.cancel = true;
- e.returnValue = false;
- return false;
- }
-
- return true;
- },
-
- special_element: function (element) {
- if (this.has_class(element, "non-interactive"))
- return false;
-
- var tag = element.nodeName.toLowerCase();
-
- return element.onkeydown ||
- element.onclick ||
- tag == "a" ||
- tag == "embed" ||
- tag == "object" ||
- tag == "video" ||
- tag == "audio" ||
- tag == "svg" ||
- tag == "canvas" ||
- tag == "input" ||
- tag == "textarea" ||
- tag == "select" ||
- tag == "option";
- },
-
- slidy_chrome: function (el) {
- while (el)
- {
- if (el == w3c_slidy.toc ||
- el == w3c_slidy.toolbar ||
- w3c_slidy.has_class(el, "outline"))
- return true;
-
- el = el.parentNode;
- }
-
- return false;
- },
-
- get_key: function (e)
- {
- var key;
-
- // kludge around NS/IE differences
- if (typeof window.event != "undefined")
- key = window.event.keyCode;
- else if (e.which)
- key = e.which;
-
- return key;
- },
-
- get_target: function (e) {
- var target;
-
- if (!e)
- e = window.event;
-
- if (e.target)
- target = e.target;
- else if (e.srcElement)
- target = e.srcElement;
-
- if (target.nodeType != 1)
- target = target.parentNode;
-
- return target;
- },
-
- // does display property provide correct defaults?
- is_block: function (elem) {
- var tag = elem.nodeName.toLowerCase();
-
- return tag == "ol" || tag == "ul" || tag == "p" ||
- tag == "li" || tag == "table" || tag == "pre" ||
- tag == "h1" || tag == "h2" || tag == "h3" ||
- tag == "h4" || tag == "h5" || tag == "h6" ||
- tag == "blockquote" || tag == "address";
- },
-
- add_listener: function (element, event, handler) {
- if (window.addEventListener)
- element.addEventListener(event, handler, false);
- else
- element.attachEvent("on"+event, handler);
- },
-
- // used to prevent event propagation from field controls
- stop_propagation: function (event) {
- event = event ? event : window.event;
- event.cancelBubble = true; // for IE
-
- if (event.stopPropagation)
- event.stopPropagation();
-
- return true;
- },
-
- cancel: function (event) {
- if (event)
- {
- event.cancel = true;
- event.returnValue = false;
-
- if (event.preventDefault)
- event.preventDefault();
- }
-
- w3c_slidy.key_wanted = false;
- return false;
- },
-
-// for each language define an associative array
-// and also the help text which is longer
-
- strings_es: {
- "slide":"pág.",
- "help?":"Ayuda",
- "contents?":"Índice",
- "table of contents":"tabla de contenidos",
- "Table of Contents":"Tabla de Contenidos",
- "restart presentation":"Reiniciar presentación",
- "restart?":"Inicio"
- },
- help_es:
- "Utilice el ratón, barra espaciadora, teclas Izda/Dcha, " +
- "o Re pág y Av pág. Use S y B para cambiar el tamaño de fuente.",
-
- strings_ca: {
- "slide":"pàg..",
- "help?":"Ajuda",
- "contents?":"Índex",
- "table of contents":"taula de continguts",
- "Table of Contents":"Taula de Continguts",
- "restart presentation":"Reiniciar presentació",
- "restart?":"Inici"
- },
- help_ca:
- "Utilitzi el ratolí, barra espaiadora, tecles Esq./Dta. " +
- "o Re pàg y Av pàg. Usi S i B per canviar grandària de font.",
-
- strings_cs: {
- "slide":"snímek",
- "help?":"nápověda",
- "contents?":"obsah",
- "table of contents":"obsah prezentace",
- "Table of Contents":"Obsah prezentace",
- "restart presentation":"znovu spustit prezentaci",
- "restart?":"restart"
- },
- help_cs:
- "Prezentaci můžete procházet pomocí kliknutí myši, mezerníku, " +
- "šipek vlevo a vpravo nebo kláves PageUp a PageDown. Písmo se " +
- "dá zvětšit a zmenšit pomocí kláves B a S.",
-
- strings_nl: {
- "slide":"pagina",
- "help?":"Help?",
- "contents?":"Inhoud?",
- "table of contents":"inhoudsopgave",
- "Table of Contents":"Inhoudsopgave",
- "restart presentation":"herstart presentatie",
- "restart?":"Herstart?"
- },
- help_nl:
- "Navigeer d.m.v. het muis, spatiebar, Links/Rechts toetsen, " +
- "of PgUp en PgDn. Gebruik S en B om de karaktergrootte te veranderen.",
-
- strings_de: {
- "slide":"Seite",
- "help?":"Hilfe",
- "contents?":"Übersicht",
- "table of contents":"Inhaltsverzeichnis",
- "Table of Contents":"Inhaltsverzeichnis",
- "restart presentation":"Präsentation neu starten",
- "restart?":"Neustart"
- },
- help_de:
- "Benutzen Sie die Maus, Leerschlag, die Cursortasten links/rechts oder " +
- "Page up/Page Down zum Wechseln der Seiten und S und B für die Schriftgrösse.",
-
- strings_pl: {
- "slide":"slajd",
- "help?":"pomoc?",
- "contents?":"spis treści?",
- "table of contents":"spis treści",
- "Table of Contents":"Spis Treści",
- "restart presentation":"Restartuj prezentację",
- "restart?":"restart?"
- },
- help_pl:
- "Zmieniaj slajdy klikając myszą, naciskając spację, strzałki lewo/prawo" +
- "lub PgUp / PgDn. Użyj klawiszy S i B, aby zmienić rozmiar czczionki.",
-
- strings_fr: {
- "slide":"page",
- "help?":"Aide",
- "contents?":"Index",
- "table of contents":"table des matières",
- "Table of Contents":"Table des matières",
- "restart presentation":"Recommencer l'exposé",
- "restart?":"Début"
- },
- help_fr:
- "Naviguez avec la souris, la barre d'espace, les flèches " +
- "gauche/droite ou les touches Pg Up, Pg Dn. Utilisez " +
- "les touches S et B pour modifier la taille de la police.",
-
- strings_hu: {
- "slide":"oldal",
- "help?":"segítség",
- "contents?":"tartalom",
- "table of contents":"tartalomjegyzék",
- "Table of Contents":"Tartalomjegyzék",
- "restart presentation":"bemutató újraindítása",
- "restart?":"újraindítás"
- },
- help_hu:
- "Az oldalak közti lépkedéshez kattintson az egérrel, vagy " +
- "használja a szóköz, a bal, vagy a jobb nyíl, illetve a Page Down, " +
- "Page Up billentyűket. Az S és a B billentyűkkel változtathatja " +
- "a szöveg méretét.",
-
- strings_it: {
- "slide":"pag.",
- "help?":"Aiuto",
- "contents?":"Indice",
- "table of contents":"indice",
- "Table of Contents":"Indice",
- "restart presentation":"Ricominciare la presentazione",
- "restart?":"Inizio"
- },
- help_it:
- "Navigare con mouse, barra spazio, frecce sinistra/destra o " +
- "PgUp e PgDn. Usare S e B per cambiare la dimensione dei caratteri.",
-
- strings_el: {
- "slide":"σελίδα",
- "help?":"βοήθεια;",
- "contents?":"περιεχόμενα;",
- "table of contents":"πίνακας περιεχομένων",
- "Table of Contents":"Πίνακας Περιεχομένων",
- "restart presentation":"επανεκκίνηση παρουσίασης",
- "restart?":"επανεκκίνηση;"
- },
- help_el:
- "Πλοηγηθείτε με το κλίκ του ποντικιού, το space, τα βέλη αριστερά/δεξιά, " +
- "ή Page Up και Page Down. Χρησιμοποιήστε τα πλήκτρα S και B για να αλλάξετε " +
- "το μέγεθος της γραμματοσειράς.",
-
- strings_ja: {
- "slide":"スライド",
- "help?":"ヘルプ",
- "contents?":"目次",
- "table of contents":"目次を表示",
- "Table of Contents":"目次",
- "restart presentation":"最初から再生",
- "restart?":"最初から"
- },
- help_ja:
- "マウス左クリック ・ スペース ・ 左右キー " +
- "または Page Up ・ Page Downで操作, S ・ Bでフォントサイズ変更",
-
- strings_zh: {
- "slide":"幻灯片",
- "help?":"帮助?",
- "contents?":"内容?",
- "table of contents":"目录",
- "Table of Contents":"目录",
- "restart presentation":"重新启动展示",
- "restart?":"重新启动?"
- },
- help_zh:
- "用鼠标点击, 空格条, 左右箭头, Pg Up 和 Pg Dn 导航. " +
- "用 S, B 改变字体大小.",
-
- strings_ru: {
- "slide":"слайд",
- "help?":"помощь?",
- "contents?":"содержание?",
- "table of contents":"оглавление",
- "Table of Contents":"Оглавление",
- "restart presentation":"перезапустить презентацию",
- "restart?":"перезапуск?"
- },
- help_ru:
- "Перемещайтесь кликая мышкой, используя клавишу пробел, стрелки" +
- "влево/вправо или Pg Up и Pg Dn. Клавиши S и B меняют размер шрифта.",
-
- strings_sv: {
- "slide":"sida",
- "help?":"hjälp",
- "contents?":"innehåll",
- "table of contents":"innehållsförteckning",
- "Table of Contents":"Innehållsförteckning",
- "restart presentation":"visa presentationen från början",
- "restart?":"börja om"
- },
- help_sv:
- "Bläddra med ett klick med vänstra musknappen, mellanslagstangenten, " +
- "vänster- och högerpiltangenterna eller tangenterna Pg Up, Pg Dn. " +
- "Använd tangenterna S och B för att ändra textens storlek.",
-
- strings: { },
-
- localize: function (src) {
- if (src == "")
- return src;
-
- // try full language code, e.g. en-US
- var s, lookup = w3c_slidy.strings[w3c_slidy.lang];
-
- if (lookup)
- {
- s = lookup[src];
-
- if (s)
- return s;
- }
-
- // strip country code suffix, e.g.
- // try en if undefined for en-US
- var lg = w3c_slidy.lang.split("-");
-
- if (lg.length > 1)
- {
- lookup = w3c_slidy.strings[lg[0]];
-
- if (lookup)
- {
- s = lookup[src];
-
- if (s)
- return s;
- }
- }
-
- // otherwise string as is
- return src;
- },
-
- init_localization: function () {
- var i18n = w3c_slidy;
- var help_text = w3c_slidy.help_text;
-
- // each such language array is declared in the localize array
- // this is used as in w3c_slidy.localize("foo");
- this.strings = {
- "es":this.strings_es,
- "ca":this.strings_ca,
- "cs":this.strings_cs,
- "nl":this.strings_nl,
- "de":this.strings_de,
- "pl":this.strings_pl,
- "fr":this.strings_fr,
- "hu":this.strings_hu,
- "it":this.strings_it,
- "el":this.strings_el,
- "jp":this.strings_ja,
- "zh":this.strings_zh,
- "ru":this.strings_ru,
- "sv":this.strings_sv
- },
-
- i18n.strings_es[help_text] = i18n.help_es;
- i18n.strings_ca[help_text] = i18n.help_ca;
- i18n.strings_cs[help_text] = i18n.help_cs;
- i18n.strings_nl[help_text] = i18n.help_nl;
- i18n.strings_de[help_text] = i18n.help_de;
- i18n.strings_pl[help_text] = i18n.help_pl;
- i18n.strings_fr[help_text] = i18n.help_fr;
- i18n.strings_hu[help_text] = i18n.help_hu;
- i18n.strings_it[help_text] = i18n.help_it;
- i18n.strings_el[help_text] = i18n.help_el;
- i18n.strings_ja[help_text] = i18n.help_ja;
- i18n.strings_zh[help_text] = i18n.help_zh;
- i18n.strings_ru[help_text] = i18n.help_ru;
- i18n.strings_sv[help_text] = i18n.help_sv;
-
- w3c_slidy.lang = document.body.parentNode.getAttribute("lang");
-
- if (!w3c_slidy.lang)
- w3c_slidy.lang = document.body.parentNode.getAttribute("xml:lang");
-
- if (!w3c_slidy.lang)
- w3c_slidy.lang = "en";
- }
-};
-
-// hack for back button behavior
-if (w3c_slidy.ie6 || w3c_slidy.ie7)
-{
- document.write("<iframe id='historyFrame' " +
- "src='javascript:\"<html"+"></"+"html>\"' " +
- "height='1' width='1' " +
- "style='position:absolute;left:-800px'></iframe>");
-}
-
-// attach event listeners for initialization
-w3c_slidy.set_up();
-
-// hide the slides as soon as body element is available
-// to reduce annoying screen mess before the onload event
-setTimeout(w3c_slidy.hide_slides, 50);
-
diff --git a/data/slidy/styles/slidy.css b/data/slidy/styles/slidy.css
deleted file mode 100644
index 0197e64d0..000000000
--- a/data/slidy/styles/slidy.css
+++ /dev/null
@@ -1,405 +0,0 @@
-/* slidy.css
-
- Copyright (c) 2005-2010 W3C (MIT, ERCIM, Keio), All Rights Reserved.
- W3C liability, trademark, document use and software licensing
- rules apply, see:
-
- http://www.w3.org/Consortium/Legal/copyright-documents
- http://www.w3.org/Consortium/Legal/copyright-software
-*/
-body
-{
- margin: 0 0 0 0;
- padding: 0 0 0 0;
- width: 100%;
- height: 100%;
- color: black;
- background-color: white;
- font-family: "Gill Sans MT", "Gill Sans", GillSans, sans-serif;
- font-size: 14pt;
-}
-
-div.toolbar {
- position: fixed; z-index: 200;
- top: auto; bottom: 0; left: 0; right: 0;
- height: 1.2em; text-align: right;
- padding-left: 1em;
- padding-right: 1em;
- font-size: 60%;
- color: red;
- background-color: rgb(240,240,240);
- border-top: solid 1px rgb(180,180,180);
-}
-
-div.toolbar span.copyright {
- color: black;
- margin-left: 0.5em;
-}
-
-div.initial_prompt {
- position: absolute;
- z-index: 1000;
- bottom: 1.2em;
- width: 100%;
- background-color: rgb(200,200,200);
- opacity: 0.35;
- background-color: rgb(200,200,200, 0.35);
- cursor: pointer;
-}
-
-div.initial_prompt p.help {
- text-align: center;
-}
-
-div.initial_prompt p.close {
- text-align: right;
- font-style: italic;
-}
-
-div.slidy_toc {
- position: absolute;
- z-index: 300;
- width: 60%;
- max-width: 30em;
- height: 30em;
- overflow: auto;
- top: auto;
- right: auto;
- left: 4em;
- bottom: 4em;
- padding: 1em;
- background: rgb(240,240,240);
- border-style: solid;
- border-width: 2px;
- font-size: 60%;
-}
-
-div.slidy_toc .toc_heading {
- text-align: center;
- width: 100%;
- margin: 0;
- margin-bottom: 1em;
- border-bottom-style: solid;
- border-bottom-color: rgb(180,180,180);
- border-bottom-width: 1px;
-}
-
-div.slide {
- z-index: 20;
- margin: 0 0 0 0;
- padding-top: 0;
- padding-bottom: 0;
- padding-left: 20px;
- padding-right: 20px;
- border-width: 0;
- clear: both;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- line-height: 120%;
- background-color: transparent;
-}
-
-div.background {
- display: none;
-}
-
-div.handout {
- margin-left: 20px;
- margin-right: 20px;
-}
-
-div.slide.titlepage {
- text-align: center;
-}
-
-div.slide.titlepage h1 {
- padding-top: 10%;
- margin-right: 0;
-}
-
-div.slide h1 {
- padding-left: 0;
- padding-right: 20pt;
- padding-top: 4pt;
- padding-bottom: 4pt;
- margin-top: 0;
- margin-left: 0;
- margin-right: 60pt;
- margin-bottom: 0.5em;
- display: block;
- font-size: 160%;
- line-height: 1.2em;
- background: transparent;
-}
-
-div.toc {
- position: absolute;
- top: auto;
- bottom: 4em;
- left: 4em;
- right: auto;
- width: 60%;
- max-width: 30em;
- height: 30em;
- border: solid thin black;
- padding: 1em;
- background: rgb(240,240,240);
- color: black;
- z-index: 300;
- overflow: auto;
- display: block;
- visibility: visible;
-}
-
-div.toc-heading {
- width: 100%;
- border-bottom: solid 1px rgb(180,180,180);
- margin-bottom: 1em;
- text-align: center;
-}
-
-img {
- image-rendering: optimize-quality;
-}
-
-pre {
- font-size: 80%;
- font-weight: bold;
- line-height: 120%;
- padding-top: 0.2em;
- padding-bottom: 0.2em;
- padding-left: 1em;
- padding-right: 1em;
- border-style: solid;
- border-left-width: 1em;
- border-top-width: thin;
- border-right-width: thin;
- border-bottom-width: thin;
- border-color: #95ABD0;
- color: #00428C;
- background-color: #E4E5E7;
-}
-
-li pre { margin-left: 0; }
-
-blockquote { font-style: italic }
-
-img { background-color: transparent }
-
-p.copyright { font-size: smaller }
-
-.center { text-align: center }
-.footnote { font-size: smaller; margin-left: 2em; }
-
-a img { border-width: 0; border-style: none }
-
-a:visited { color: navy }
-a:link { color: navy }
-a:hover { color: red; text-decoration: underline }
-a:active { color: red; text-decoration: underline }
-
-a {text-decoration: none}
-.navbar a:link {color: white}
-.navbar a:visited {color: yellow}
-.navbar a:active {color: red}
-.navbar a:hover {color: red}
-
-ul { list-style-type: square; }
-ul ul { list-style-type: disc; }
-ul ul ul { list-style-type: circle; }
-ul ul ul ul { list-style-type: disc; }
-li { margin-left: 0.5em; margin-top: 0.5em; }
-li li { font-size: 85%; font-style: italic }
-li li li { font-size: 85%; font-style: normal }
-
-div dt
-{
- margin-left: 0;
- margin-top: 1em;
- margin-bottom: 0.5em;
- font-weight: bold;
-}
-div dd
-{
- margin-left: 2em;
- margin-bottom: 0.5em;
-}
-
-
-p,pre,ul,ol,blockquote,h2,h3,h4,h5,h6,dl,table {
- margin-left: 1em;
- margin-right: 1em;
-}
-
-p.subhead { font-weight: bold; margin-top: 2em; }
-
-.smaller { font-size: smaller }
-.bigger { font-size: 130% }
-
-td,th { padding: 0.2em }
-
-ul {
- margin: 0.5em 1.5em 0.5em 1.5em;
- padding: 0;
-}
-
-ol {
- margin: 0.5em 1.5em 0.5em 1.5em;
- padding: 0;
-}
-
-ul { list-style-type: square; }
-ul ul { list-style-type: disc; }
-ul ul ul { list-style-type: circle; }
-ul ul ul ul { list-style-type: disc; }
-
-ul li {
- list-style: square;
- margin: 0.1em 0em 0.6em 0;
- padding: 0 0 0 0;
- line-height: 140%;
-}
-
-ol li {
- margin: 0.1em 0em 0.6em 1.5em;
- padding: 0 0 0 0px;
- line-height: 140%;
- list-style-type: decimal;
-}
-
-li ul li {
- font-size: 85%;
- font-style: italic;
- list-style-type: disc;
- background: transparent;
- padding: 0 0 0 0;
-}
-li li ul li {
- font-size: 85%;
- font-style: normal;
- list-style-type: circle;
- background: transparent;
- padding: 0 0 0 0;
-}
-li li li ul li {
- list-style-type: disc;
- background: transparent;
- padding: 0 0 0 0;
-}
-
-li ol li {
- list-style-type: decimal;
-}
-
-
-li li ol li {
- list-style-type: decimal;
-}
-
-/*
- setting class="outline on ol or ul makes it behave as an
- ouline list where blocklevel content in li elements is
- hidden by default and can be expanded or collapsed with
- mouse click. Set class="expand" on li to override default
-*/
-
-ol.outline li:hover { cursor: pointer }
-ol.outline li.nofold:hover { cursor: default }
-
-ul.outline li:hover { cursor: pointer }
-ul.outline li.nofold:hover { cursor: default }
-
-ol.outline { list-style:decimal; }
-ol.outline ol { list-style-type:lower-alpha }
-
-ol.outline li.nofold {
- padding: 0 0 0 20px;
- background: transparent url(../graphics/nofold-dim.gif) no-repeat 0px 0.5em;
-}
-ol.outline li.unfolded {
- padding: 0 0 0 20px;
- background: transparent url(../graphics/fold-dim.gif) no-repeat 0px 0.5em;
-}
-ol.outline li.folded {
- padding: 0 0 0 20px;
- background: transparent url(../graphics/unfold-dim.gif) no-repeat 0px 0.5em;
-}
-ol.outline li.unfolded:hover {
- padding: 0 0 0 20px;
- background: transparent url(../graphics/fold.gif) no-repeat 0px 0.5em;
-}
-ol.outline li.folded:hover {
- padding: 0 0 0 20px;
- background: transparent url(../graphics/unfold.gif) no-repeat 0px 0.5em;
-}
-
-ul.outline li.nofold {
- padding: 0 0 0 20px;
- background: transparent url(../graphics/nofold-dim.gif) no-repeat 0px 0.5em;
-}
-ul.outline li.unfolded {
- padding: 0 0 0 20px;
- background: transparent url(../graphics/fold-dim.gif) no-repeat 0px 0.5em;
-}
-ul.outline li.folded {
- padding: 0 0 0 20px;
- background: transparent url(../graphics/unfold-dim.gif) no-repeat 0px 0.5em;
-}
-ul.outline li.unfolded:hover {
- padding: 0 0 0 20px;
- background: transparent url(../graphics/fold.gif) no-repeat 0px 0.5em;
-}
-ul.outline li.folded:hover {
- padding: 0 0 0 20px;
- background: transparent url(../graphics/unfold.gif) no-repeat 0px 0.5em;
-}
-
-/* for slides with class "title" in table of contents */
-a.titleslide { font-weight: bold; font-style: italic }
-
-/*
- hide images for work around for save as bug
- where browsers fail to save images used by CSS
-*/
-img.hidden { display: none; visibility: hidden }
-div.initial_prompt { display: none; visibility: hidden }
-
- div.slide {
- visibility: visible;
- position: inherit;
- }
- div.handout {
- border-top-style: solid;
- border-top-width: thin;
- border-top-color: black;
- }
-
-@media screen {
- .hidden { display: none; visibility: visible }
-
- div.slide.hidden { display: block; visibility: visible }
- div.handout.hidden { display: block; visibility: visible }
- div.background { display: none; visibility: hidden }
- body.single_slide div.initial_prompt { display: block; visibility: visible }
- body.single_slide div.background { display: block; visibility: visible }
- body.single_slide div.background.hidden { display: none; visibility: hidden }
- body.single_slide .invisible { visibility: hidden }
- body.single_slide .hidden { display: none; visibility: hidden }
- body.single_slide div.slide { position: absolute }
- body.single_slide div.handout { display: none; visibility: hidden }
-}
-
-@media print {
- .hidden { display: block; visibility: visible }
-
- div.slide pre { font-size: 60%; padding-left: 0.5em; }
- div.toolbar { display: none; visibility: hidden; }
- div.slidy_toc { display: none; visibility: hidden; }
- div.background { display: none; visibility: hidden; }
- div.slide { page-break-before: always }
- /* :first-child isn't reliable for print media */
- div.slide.first-slide { page-break-before: avoid }
-}
-
diff --git a/github-upload.sh b/github-upload.sh
new file mode 100755
index 000000000..875d51831
--- /dev/null
+++ b/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/googlecode-upload.sh b/googlecode-upload.sh
index 19975ca91..40fba78e2 100755
--- a/googlecode-upload.sh
+++ b/googlecode-upload.sh
@@ -2,4 +2,4 @@
VERSION=$1
googlecode_upload.py -s "Source tarball" -p pandoc -u fiddlosopher --labels=Featured,Type-Source,OpSys-All dist/pandoc-$VERSION.tar.gz
googlecode_upload.py -s "Windows installer" -p pandoc -u fiddlosopher --labels=Featured,Type-Installer,OpSys-Windows pandoc-$VERSION.msi
-googlecode_upload.py -s "Mac OS X installer" -p pandoc -u fiddlosopher --labels=Featured,Type-Installer,OpSys-OSX pandoc-$VERSION.dmg
+googlecode_upload.py -s "Mac OS X installer" -p pandoc -u fiddlosopher --labels=Featured,Type-Installer,OpSys-OSX pandoc-$VERSION.pkg.zip
diff --git a/make_osx_package.sh b/make_osx_package.sh
index dcf06fad4..3e4317140 100755
--- a/make_osx_package.sh
+++ b/make_osx_package.sh
@@ -1,64 +1,88 @@
-#!/bin/sh -e
+#!/bin/bash -e
-DIST=osx_package
+DIST=`pwd`/osx_package
+SANDBOX=`pwd`/.cabal-sandbox
VERSION=$(grep -e '^Version' pandoc.cabal | awk '{print $2}')
RESOURCES=$DIST/Resources
ROOT=$DIST/pandoc
-SCRIPTS=osx-resources
+DEST=$ROOT/usr/local
+OSX=osx
+SCRIPTS=$OSX/osx-resources
BASE=pandoc-$VERSION
-ME=jgm
+ME=$(whoami)
CODESIGNID="Developer ID Application: John Macfarlane"
-PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
+PACKAGEMAKER=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
+EXES="pandoc pandoc-citeproc"
+
+read -s -p "sudo password: " PASSWORD
+echo $PASSWORD | sudo -S echo "Password valid, continuing."
echo Removing old files...
rm -rf $DIST
mkdir -p $RESOURCES
+cabal sandbox init
+# echo Updating database
+# cabal update
+
echo Building pandoc...
-cabal-dev install-deps
-cabal-dev install --reinstall --force-reinstalls --flags="embed_data_files" citeproc-hs
-cabal-dev configure --prefix=/usr/local --datasubdir=$BASE --docdir=/usr/local/doc/$BASE
-cabal-dev build
-cabal-dev copy --destdir=$ROOT
-# remove library files
-rm -r $ROOT/usr/local/lib
-chown -R $ME:staff $DIST
+cabal clean
+# Use cpphs to avoid problems with clang cpp on ghc 7.8 osx:
+cabal install cpphs alex happy hsb2hs
+cabal install --ghc-options="-optl-mmacosx-version-min=10.6" --reinstall --flags="embed_data_files" --ghc-options '-pgmPcpphs -optP--cpp'
+cabal install --ghc-options="-optl-mmacosx-version-min=10.6" --reinstall --flags="embed_data_files" pandoc-citeproc --ghc-options '-pgmPcpphs -optP--cpp'
-gzip $ROOT/usr/local/share/man/man?/*.*
+mkdir -p $DEST/bin
+mkdir -p $DEST/share/man/man1
+mkdir -p $DEST/share/man/man5
+for f in $EXES; do
+ cp $SANDBOX/bin/$f $DEST/bin/;
+ cp $SANDBOX/share/man/man1/$f.1 $DEST/share/man/man1/
+done
+cp $SANDBOX/share/man/man5/pandoc_markdown.5 $DEST/share/man/man5/
+
+chown -R $ME:staff $DIST
+# gzip $DEST/share/man/man?/*.*
# cabal gives man pages the wrong permissions
-chmod +r $ROOT/usr/local/share/man/man?/*.*
+chmod +r $DEST/share/man/man?/*.*
echo Copying license...
-dist/build/pandoc/pandoc --data data -t rtf -s COPYING -o $RESOURCES/License.rtf
+$SANDBOX/bin/pandoc --data data -t rtf -s COPYING -o $RESOURCES/License.rtf
echo Signing pandoc executable...
-codesign --force --sign "$CODESIGNID" $ROOT/usr/local/bin/pandoc
+codesign --force --sign "$CODESIGNID" $DEST/bin/pandoc
# make sure it's valid... returns nonzero exit code if it isn't:
-spctl --assess --type execute $ROOT/usr/local/bin/pandoc
+spctl --assess --type execute $DEST/bin/pandoc
echo Creating OSX package...
+# remove old package first
+echo $PASSWORD | sudo -S rm -rf $BASE.pkg $BASE.dmg
sudo $PACKAGEMAKER \
--root $ROOT \
--id net.johnmacfarlane.pandoc \
--resources $RESOURCES \
--version $VERSION \
- --no-relocate \
--scripts $SCRIPTS \
--out $BASE.pkg
+ # --no-relocate
+
echo Signing package...
sudo codesign --force --sign "$CODESIGNID" $BASE.pkg
# make sure it's valid...
spctl --assess --type install $BASE.pkg
-echo Creating disk image...
+echo Creating zip...
+zip -9 -r $BASE-osx.zip $BASE.pkg
+zip -9 -j -r $BASE-osx.zip $OSX/uninstall-pandoc.pl
-sudo hdiutil create "$BASE.dmg" \
- -format UDZO -ov \
- -volname "pandoc $VERSION" \
- -srcfolder $BASE.pkg
-sudo hdiutil internet-enable "$BASE.dmg"
+# echo Creating disk image...
+# sudo hdiutil create "$BASE.dmg" \
+# -format UDZO -ov \
+# -volname "pandoc $VERSION" \
+# -srcfolder $BASE.pkg
+# sudo hdiutil internet-enable "$BASE.dmg"
diff --git a/man/make-pandoc-man-pages.hs b/man/make-pandoc-man-pages.hs
index eca1276eb..008294433 100644
--- a/man/make-pandoc-man-pages.hs
+++ b/man/make-pandoc-man-pages.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
-- Create pandoc.1 man and pandoc_markdown.5 man pages from README
import Text.Pandoc
import qualified Text.Pandoc.UTF8 as UTF8
diff --git a/osx-resources/InstallationCheck b/osx/osx-resources/InstallationCheck
index 2bd691f5c..2bd691f5c 100755
--- a/osx-resources/InstallationCheck
+++ b/osx/osx-resources/InstallationCheck
diff --git a/osx-resources/InstallationCheck.strings b/osx/osx-resources/InstallationCheck.strings
index 6c8efe0d4..6c8efe0d4 100644
--- a/osx-resources/InstallationCheck.strings
+++ b/osx/osx-resources/InstallationCheck.strings
diff --git a/osx/uninstall-pandoc.pl b/osx/uninstall-pandoc.pl
new file mode 100755
index 000000000..a5194d9bd
--- /dev/null
+++ b/osx/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/pandoc.cabal b/pandoc.cabal
index 6028b8a2b..93c9b4dc7 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -1,29 +1,29 @@
Name: pandoc
-Version: 1.12
+Version: 1.13
Cabal-Version: >= 1.10
Build-Type: Custom
License: GPL
License-File: COPYING
-Copyright: (c) 2006-2013 John MacFarlane
+Copyright: (c) 2006-2014 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://johnmacfarlane.net/pandoc
Category: Text
-Tested-With: GHC == 7.4.2, GHC == 7.6.1
+Tested-With: GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.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 markdown and (subsets of) HTML,
reStructuredText, LaTeX, DocBook, MediaWiki markup, Haddock
- markup, OPML, and Textile, and it can write markdown,
- reStructuredText, HTML, LaTeX, ConTeXt, Docbook, OPML,
+ markup, OPML, Emacs Org-Mode, 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,
- EPUB (v2 and v3), FictionBook2, and several kinds of
- HTML/javascript slide shows (S5, Slidy, Slideous, DZSlides,
- reveal.js).
+ Haddock markup, EPUB (v2 and v3), FictionBook2,
+ InDesign ICML, and several kinds of HTML/javascript
+ slide shows (S5, Slidy, Slideous, DZSlides, reveal.js).
.
Pandoc extends standard markdown syntax with footnotes,
embedded LaTeX, definition lists, tables, and other
@@ -45,12 +45,13 @@ Data-Files:
data/templates/default.docbook,
data/templates/default.beamer,
data/templates/default.opendocument,
+ data/templates/default.icml,
data/templates/default.opml,
- data/templates/default.latex,
+ data/templates/default.latex,
data/templates/default.context,
- data/templates/default.texinfo,
+ data/templates/default.texinfo,
data/templates/default.man,
- data/templates/default.markdown,
+ data/templates/default.markdown,
data/templates/default.rst,
data/templates/default.plain,
data/templates/default.mediawiki,
@@ -60,7 +61,8 @@ Data-Files:
data/templates/default.slideous,
data/templates/default.revealjs,
data/templates/default.dzslides,
- data/templates/default.asciidoc,
+ data/templates/default.asciidoc,
+ data/templates/default.haddock,
data/templates/default.textile,
data/templates/default.org,
data/templates/default.epub,
@@ -74,38 +76,15 @@ Data-Files:
-- data for LaTeXMathML writer
data/LaTeXMathML.js,
data/MathMLinHTML.js,
- -- data for S5 writer
- data/s5/default/slides.js,
- data/s5/default/s5-core.css,
- data/s5/default/framing.css,
- data/s5/default/pretty.css,
- data/s5/default/opera.css,
- data/s5/default/outline.css,
- data/s5/default/print.css,
- data/s5/default/slides.css,
- data/s5/default/iepngfix.htc,
- data/s5/default/blank.gif,
- data/s5/default/bodybg.gif,
- -- data for slidy writer
- data/slidy/styles/slidy.css,
- data/slidy/scripts/slidy.js,
- data/slidy/graphics/fold.gif,
- data/slidy/graphics/unfold.gif,
- data/slidy/graphics/nofold-dim.gif,
- data/slidy/graphics/unfold-dim.gif,
- data/slidy/graphics/fold-dim.gif,
- -- data for slideous writer
- data/slideous/slideous.css,
- data/slideous/slideous.js,
-- data for dzslides writer
data/dzslides/template.html,
- -- data for citeproc
- data/default.csl,
-- sample lua custom writer
data/sample.lua
-- documentation
- README, INSTALL, COPYRIGHT, BUGS, CONTRIBUTING.md, changelog
+ README, COPYRIGHT
Extra-Source-Files:
+ -- documentation
+ INSTALL, BUGS, CONTRIBUTING.md, changelog
-- code to create pandoc.1 man page
man/man1/pandoc.1.template,
man/man5/pandoc_markdown.5.template,
@@ -118,17 +97,13 @@ Extra-Source-Files:
tests/docbook-reader.native
tests/html-reader.html,
tests/html-reader.native,
- tests/opml-reader.html,
+ tests/opml-reader.opml,
tests/opml-reader.native,
- tests/haddock-reader.html,
+ tests/haddock-reader.haddock,
tests/haddock-reader.native,
tests/insert,
tests/lalune.jpg,
tests/movie.jpg,
- tests/biblio.bib,
- tests/chicago-author-date.csl,
- tests/ieee.csl,
- tests/mhra.csl,
tests/latex-reader.latex,
tests/latex-reader.native,
tests/textile-reader.textile,
@@ -136,9 +111,7 @@ Extra-Source-Files:
tests/markdown-reader-more.txt,
tests/markdown-reader-more.native,
tests/markdown-citations.txt,
- tests/markdown-citations.chicago-author-date.txt,
- tests/markdown-citations.mhra.txt,
- tests/markdown-citations.ieee.txt,
+ tests/markdown-citations.native,
tests/textile-reader.textile,
tests/mediawiki-reader.wiki,
tests/mediawiki-reader.native,
@@ -162,6 +135,7 @@ Extra-Source-Files:
tests/tables.opendocument,
tests/tables.org,
tests/tables.asciidoc,
+ tests/tables.haddock,
tests/tables.texinfo,
tests/tables.rst,
tests/tables.rtf,
@@ -183,6 +157,7 @@ Extra-Source-Files:
tests/writer.opendocument,
tests/writer.org,
tests/writer.asciidoc,
+ tests/writer.haddock,
tests/writer.rst,
tests/writer.rtf,
tests/writer.texinfo,
@@ -212,7 +187,25 @@ Extra-Source-Files:
tests/fb2.math.markdown,
tests/fb2.math.fb2,
tests/fb2.test-small.png,
- tests/fb2.test.jpg
+ tests/fb2.test.jpg,
+ tests/docx.block_quotes.docx,
+ tests/docx.block_quotes_parse_indent.native,
+ tests/docx.headers.docx,
+ tests/docx.headers.native,
+ tests/docx.image.docx,
+ tests/docx.image_no_embed.native,
+ tests/docx.inline_formatting.docx,
+ tests/docx.inline_formatting.native,
+ tests/docx.links.docx,
+ tests/docx.links.native,
+ tests/docx.lists.docx,
+ tests/docx.lists.native,
+ tests/docx.notes.docx,
+ tests/docx.notes.native,
+ tests/docx.tables.docx,
+ tests/docx.tables.native,
+ tests/docx.unicode.docx,
+ tests/docx.unicode.native
Extra-Tmp-Files: man/man1/pandoc.1,
man/man5/pandoc_markdown.5
@@ -224,8 +217,8 @@ Flag embed_data_files
Description: Embed data files in binary for relocatable executable.
Default: False
-Flag http-conduit
- Description: Enable downloading of resources over https.
+Flag https
+ Description: Enable support for downloading of resources over https.
Default: True
Library
@@ -233,60 +226,54 @@ Library
syb >= 0.1 && < 0.5,
containers >= 0.1 && < 0.6,
unordered-containers >= 0.2 && < 0.3,
- array >= 0.3 && < 0.5,
+ array >= 0.3 && < 0.6,
parsec >= 3.1 && < 3.2,
- mtl >= 1.1 && < 2.2,
- network >= 2 && < 2.5,
+ mtl >= 1.1 && < 2.3,
+ network >= 2 && < 2.6,
filepath >= 1.1 && < 1.4,
- process >= 1 && < 1.2,
+ process >= 1 && < 1.3,
directory >= 1 && < 1.3,
bytestring >= 0.9 && < 0.11,
- text >= 0.11 && < 0.12,
- zip-archive >= 0.1.3.3 && < 0.2,
+ text >= 0.11 && < 1.2,
+ zip-archive >= 0.2.3.2 && < 0.3,
old-locale >= 1 && < 1.1,
time >= 1.2 && < 1.5,
HTTP >= 4000.0.5 && < 4000.3,
- texmath >= 0.6.1.5 && < 0.7,
+ texmath >= 0.6.6.3 && < 0.7,
xml >= 1.3.12 && < 1.4,
random >= 1 && < 1.1,
extensible-exceptions >= 0.1 && < 0.2,
- citeproc-hs >= 0.3.7 && < 0.4,
- pandoc-types >= 1.12 && < 1.13,
- aeson >= 0.6 && < 0.7,
- tagsoup >= 0.12.5 && < 0.13,
+ pandoc-types >= 1.12.3.3 && < 1.13,
+ aeson >= 0.7 && < 0.8,
+ tagsoup >= 0.13.1 && < 0.14,
base64-bytestring >= 0.1 && < 1.1,
zlib >= 0.5 && < 0.6,
- highlighting-kate >= 0.5.4 && < 0.6,
+ highlighting-kate >= 0.5.8.3 && < 0.6,
data-default >= 0.4 && < 0.6,
- temporary >= 1.1 && < 1.2,
- blaze-html >= 0.5 && < 0.7,
- blaze-markup >= 0.5.1 && < 0.6,
- attoparsec >= 0.10 && < 0.11,
- stringable >= 0.1 && < 0.2,
- yaml >= 0.8.3 && < 0.9,
+ temporary >= 1.1 && < 1.3,
+ blaze-html >= 0.5 && < 0.8,
+ blaze-markup >= 0.5.1 && < 0.7,
+ yaml >= 0.8.8.2 && < 0.9,
+ scientific >= 0.2 && < 0.4,
vector >= 0.10 && < 0.11,
- hslua >= 0.3 && < 0.4
- if flag(http-conduit)
- Build-Depends: http-conduit >= 1.9 && < 1.10,
+ hslua >= 0.3 && < 0.4,
+ binary >= 0.5 && < 0.8,
+ SHA >= 1.6 && < 1.7,
+ haddock-library >= 1.1 && < 1.2
+ if flag(https)
+ Build-Depends: http-client >= 0.3.2 && < 0.4,
+ http-client-tls >= 0.2 && < 0.3,
http-types >= 0.8 && < 0.9
- cpp-options: -DHTTP_CONDUIT
+ cpp-options: -DHTTP_CLIENT
if flag(embed_data_files)
cpp-options: -DEMBED_DATA_FILES
- -- build-tools: hsb2hs
+ -- Build-Tools: hsb2hs -- not yet recognized by cabal
other-modules: Text.Pandoc.Data
- if impl(ghc >= 7.0.1)
- Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind
- else
- if impl(ghc >= 6.12)
- Ghc-Options: -Wall -fno-warn-unused-do-bind
- else
- Ghc-Options: -Wall
- if impl(ghc >= 7.0.1)
- Ghc-Prof-Options: -auto-all -caf-all -rtsopts
- else
- Ghc-Prof-Options: -auto-all -caf-all
+ if os(windows)
+ Cpp-options: -D_WINDOWS
+ Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind
+ Ghc-Prof-Options: -auto-all -caf-all -rtsopts
Default-Language: Haskell98
- Default-Extensions: CPP
Other-Extensions: PatternGuards, OverloadedStrings,
ScopedTypeVariables, GeneralizedNewtypeDeriving,
RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,
@@ -302,22 +289,26 @@ Library
Text.Pandoc.Readers.Markdown,
Text.Pandoc.Readers.MediaWiki,
Text.Pandoc.Readers.RST,
+ Text.Pandoc.Readers.Org,
Text.Pandoc.Readers.DocBook,
Text.Pandoc.Readers.OPML,
Text.Pandoc.Readers.TeXMath,
Text.Pandoc.Readers.Textile,
Text.Pandoc.Readers.Native,
Text.Pandoc.Readers.Haddock,
+ Text.Pandoc.Readers.Docx,
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.Haddock,
Text.Pandoc.Writers.RST,
Text.Pandoc.Writers.Org,
Text.Pandoc.Writers.AsciiDoc,
@@ -334,10 +325,11 @@ Library
Text.Pandoc.UTF8,
Text.Pandoc.Templates,
Text.Pandoc.XML,
- Text.Pandoc.Biblio,
- Text.Pandoc.SelfContained
- Other-Modules: Text.Pandoc.Readers.Haddock.Lex,
- Text.Pandoc.Readers.Haddock.Parse,
+ Text.Pandoc.SelfContained,
+ Text.Pandoc.Process
+ Other-Modules: Text.Pandoc.Readers.Docx.Lists,
+ Text.Pandoc.Readers.Docx.Reducible,
+ Text.Pandoc.Readers.Docx.Parse,
Text.Pandoc.Writers.Shared,
Text.Pandoc.Asciify,
Text.Pandoc.MIME,
@@ -346,37 +338,32 @@ Library
Text.Pandoc.ImageSize,
Text.Pandoc.Slides,
Text.Pandoc.Highlighting,
+ Text.Pandoc.Compat.Monoid,
+ Text.Pandoc.Compat.TagSoupEntity,
Paths_pandoc
Buildable: True
Executable pandoc
Build-Depends: pandoc,
+ pandoc-types >= 1.12.3.3 && < 1.13,
base >= 4.2 && <5,
directory >= 1 && < 1.3,
filepath >= 1.1 && < 1.4,
- network >= 2 && < 2.5,
- text >= 0.11 && < 0.12,
+ network >= 2 && < 2.6,
+ text >= 0.11 && < 1.2,
bytestring >= 0.9 && < 0.11,
extensible-exceptions >= 0.1 && < 0.2,
- highlighting-kate >= 0.5.4 && < 0.6,
- HTTP >= 4000.0.5 && < 4000.3,
- citeproc-hs >= 0.3.7 && < 0.4
- if impl(ghc >= 7.0.1)
- Ghc-Options: -rtsopts -with-rtsopts=-K16m -Wall -fno-warn-unused-do-bind
- else
- if impl(ghc >= 6.12)
- Ghc-Options: -Wall -fno-warn-unused-do-bind
- else
- Ghc-Options: -Wall
- if impl(ghc >= 7.0.1)
- Ghc-Prof-Options: -auto-all -caf-all -rtsopts -with-rtsopts=-K16m
- else
- Ghc-Prof-Options: -auto-all -caf-all
+ highlighting-kate >= 0.5.8.3 && < 0.6,
+ aeson >= 0.7.0.5 && < 0.8,
+ yaml >= 0.8.8.2 && < 0.9,
+ containers >= 0.1 && < 0.6,
+ HTTP >= 4000.0.5 && < 4000.3
+ Ghc-Options: -rtsopts -with-rtsopts=-K16m -Wall -fno-warn-unused-do-bind
+ Ghc-Prof-Options: -auto-all -caf-all -rtsopts -with-rtsopts=-K16m
if os(windows)
Cpp-options: -D_WINDOWS
Default-Language: Haskell98
- Default-Extensions: CPP
Other-Extensions: PatternGuards, OverloadedStrings,
ScopedTypeVariables, GeneralizedNewtypeDeriving,
RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,
@@ -396,7 +383,6 @@ Executable make-pandoc-man-pages
old-time >= 1.0 && < 1.2,
time >= 1.2 && < 1.5
Default-Language: Haskell98
- Default-Extensions: CPP
Test-Suite test-pandoc
Type: exitcode-stdio-1.0
@@ -405,18 +391,18 @@ Test-Suite test-pandoc
Build-Depends: base >= 4.2 && < 5,
syb >= 0.1 && < 0.5,
pandoc,
- pandoc-types >= 1.12 && < 1.13,
+ pandoc-types >= 1.12.3.3 && < 1.13,
bytestring >= 0.9 && < 0.11,
- text >= 0.11 && < 0.12,
+ text >= 0.11 && < 1.2,
directory >= 1 && < 1.3,
filepath >= 1.1 && < 1.4,
- process >= 1 && < 1.2,
- highlighting-kate >= 0.5.4 && < 0.6,
+ process >= 1 && < 1.3,
+ highlighting-kate >= 0.5.8.3 && < 0.6,
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.7,
+ QuickCheck >= 2.4 && < 2.8,
HUnit >= 1.2 && < 1.3,
containers >= 0.1 && < 0.6,
ansi-terminal >= 0.5 && < 0.7
@@ -424,27 +410,20 @@ Test-Suite test-pandoc
Tests.Helpers
Tests.Arbitrary
Tests.Shared
+ Tests.Walk
Tests.Readers.LaTeX
Tests.Readers.Markdown
+ Tests.Readers.Org
Tests.Readers.RST
+ Tests.Readers.Docx
Tests.Writers.Native
Tests.Writers.ConTeXt
Tests.Writers.HTML
Tests.Writers.Markdown
+ Tests.Writers.AsciiDoc
Tests.Writers.LaTeX
- if impl(ghc >= 7.0.1)
- Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind
- else
- if impl(ghc >= 6.12)
- Ghc-Options: -Wall -fno-warn-unused-do-bind
- else
- Ghc-Options: -Wall
- if impl(ghc >= 7)
- cpp-options: -D_LIT=lit
- else
- cpp-options: -D_LIT=$lit
+ Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind
Default-Language: Haskell98
- Default-Extensions: CPP
benchmark benchmark-pandoc
Type: exitcode-stdio-1.0
@@ -454,11 +433,5 @@ benchmark benchmark-pandoc
base >= 4.2 && < 5,
syb >= 0.1 && < 0.5,
criterion >= 0.5 && < 0.9
- if impl(ghc >= 7.0.1)
- Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind
- else
- if impl(ghc >= 6.12)
- Ghc-Options: -Wall -fno-warn-unused-do-bind
- else
- Ghc-Options: -Wall
+ Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind
Default-Language: Haskell98
diff --git a/pandoc.hs b/pandoc.hs
index 33e9a84b3..03481ca05 100644
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE CPP #-}
{-
-Copyright (C) 2006-2013 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Main
- Copyright : Copyright (C) 2006-2013 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley@edu>
@@ -31,12 +31,15 @@ writers.
-}
module Main where
import Text.Pandoc
-import Text.Pandoc.PDF (tex2pdf)
+import Text.Pandoc.Builder (setMeta)
+import Text.Pandoc.PDF (makePDF)
import Text.Pandoc.Readers.LaTeX (handleIncludes)
-import Text.Pandoc.Shared ( tabFilter, readDataFileUTF8, safeRead,
- headerShift, normalize, err, warn )
-import Text.Pandoc.XML ( toEntities, fromEntities )
+import Text.Pandoc.Shared ( tabFilter, readDataFileUTF8, readDataFile,
+ safeRead, headerShift, normalize, err, warn,
+ openURL )
+import Text.Pandoc.XML ( toEntities )
import Text.Pandoc.SelfContained ( makeSelfContained )
+import Text.Pandoc.Process (pipeProcess)
import Text.Highlighting.Kate ( languages, Style, tango, pygments,
espresso, zenburn, kate, haddock, monochrome )
import System.Environment ( getArgs, getProgName )
@@ -44,29 +47,34 @@ import System.Exit ( exitWith, ExitCode (..) )
import System.FilePath
import System.Console.GetOpt
import Data.Char ( toLower )
-import Data.List ( intercalate, isPrefixOf, sort )
-import System.Directory ( getAppUserDataDirectory, doesFileExist, findExecutable )
-import System.IO ( stdout )
+import Data.List ( intercalate, isPrefixOf, isSuffixOf, sort )
+import System.Directory ( getAppUserDataDirectory, findExecutable,
+ doesFileExist )
+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 qualified Text.CSL as CSL
import Control.Monad (when, unless, liftM)
-import Network.HTTP (simpleHTTP, mkRequest, getResponseBody, RequestMethod(..))
+import Data.Foldable (foldrM)
import Network.URI (parseURI, isURI, URI(..))
import qualified Data.ByteString.Lazy as B
-import Text.CSL.Reference (Reference(..))
+import qualified Data.ByteString as BS
+import Data.Aeson (eitherDecode', encode)
+import qualified Data.Map as M
+import Data.Yaml (decode)
+import qualified Data.Yaml as Yaml
+import qualified Data.Text as T
copyrightMessage :: String
-copyrightMessage = "\nCopyright (C) 2006-2013 John MacFarlane\n" ++
+copyrightMessage = "\nCopyright (C) 2006-2014 John MacFarlane\n" ++
"Web: http://johnmacfarlane.net/pandoc\n" ++
"This is free software; see the source for copying conditions. There is no\n" ++
"warranty, not even for merchantability or fitness for a particular purpose."
compileInfo :: String
compileInfo =
- "\nCompiled with citeproc-hs " ++ VERSION_citeproc_hs ++ ", texmath " ++
+ "\nCompiled with texmath " ++
VERSION_texmath ++ ", highlighting-kate " ++ VERSION_highlighting_kate ++
".\nSyntax highlighting is supported for the following languages:\n " ++
wrapWords 4 78
@@ -86,6 +94,35 @@ wrapWords indent c = wrap' (c - indent) (c - indent)
isTextFormat :: String -> Bool
isTextFormat s = takeWhile (`notElem` "+-") s `notElem` ["odt","docx","epub","epub3"]
+externalFilter :: FilePath -> [String] -> Pandoc -> IO Pandoc
+externalFilter f args' d = do
+ mbexe <- if '/' `elem` f -- don't check PATH if filter name it has a path
+ then return Nothing
+ else findExecutable f
+ (f', args'') <- case mbexe of
+ Just x -> return (x, args')
+ Nothing -> do
+ exists <- doesFileExist f
+ if exists
+ then return $
+ case map toLower $ takeExtension f of
+ ".py" -> ("python", f:args')
+ ".hs" -> ("runhaskell", f:args')
+ ".pl" -> ("perl", f:args')
+ ".rb" -> ("ruby", f:args')
+ ".php" -> ("php", f:args')
+ _ -> (f, args')
+ else err 85 $ "Filter " ++ f ++ " not found"
+ (exitcode, outbs, errbs) <- E.handle filterException $
+ pipeProcess Nothing f' args'' $ encode d
+ when (not $ B.null errbs) $ B.hPutStr stderr errbs
+ case exitcode of
+ ExitSuccess -> return $ either error id $ eitherDecode' outbs
+ ExitFailure _ -> err 83 $ "Error running filter " ++ f
+ 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
@@ -98,6 +135,7 @@ data Opt = Opt
, optTransforms :: [Pandoc -> Pandoc] -- ^ Doc transforms to apply
, optTemplate :: Maybe FilePath -- ^ Custom template
, optVariables :: [(String,String)] -- ^ Template variables to set
+ , optMetadata :: M.Map String MetaValue -- ^ Metadata fields to set
, optOutputFile :: String -- ^ Name of output file
, optNumberSections :: Bool -- ^ Number sections in LaTeX
, optNumberOffset :: [Int] -- ^ Starting number for sections
@@ -124,15 +162,12 @@ data Opt = Opt
, optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
, optWrapText :: Bool -- ^ Wrap text
, optColumns :: Int -- ^ Line length in characters
- , optPlugins :: [Pandoc -> IO Pandoc] -- ^ Plugins to apply
+ , 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
- , optBibliography :: [String]
- , optCslFile :: Maybe FilePath
- , optAbbrevsFile :: Maybe FilePath
, optListings :: Bool -- ^ Use listings package for code blocks
, optLaTeXEngine :: String -- ^ Program to use for latex -> pdf
, optSlideLevel :: Maybe Int -- ^ Header level that creates slides
@@ -140,6 +175,8 @@ data Opt = Opt
, optAscii :: Bool -- ^ Use ascii characters only in html
, optTeXLigatures :: Bool -- ^ Use TeX ligatures for quotes/dashes
, optDefaultImageExtension :: String -- ^ Default image extension
+ , optTrace :: Bool -- ^ Print debug information
+ , optTrackChanges :: TrackChanges -- ^ Accept or reject MS Word track-changes.
}
-- | Defaults for command-line options.
@@ -155,6 +192,7 @@ defaultOpts = Opt
, optTransforms = []
, optTemplate = Nothing
, optVariables = []
+ , optMetadata = M.empty
, optOutputFile = "-" -- "-" means stdout
, optNumberSections = False
, optNumberOffset = [0,0,0,0,0,0]
@@ -181,15 +219,12 @@ defaultOpts = Opt
, optReferenceLinks = False
, optWrapText = True
, optColumns = 72
- , optPlugins = []
+ , optFilters = []
, optEmailObfuscation = JavascriptObfuscation
, optIdentifierPrefix = ""
, optIndentedCodeClasses = []
, optDataDir = Nothing
, optCiteMethod = Citeproc
- , optBibliography = []
- , optCslFile = Nothing
- , optAbbrevsFile = Nothing
, optListings = False
, optLaTeXEngine = "pdflatex"
, optSlideLevel = Nothing
@@ -197,6 +232,8 @@ defaultOpts = Opt
, optAscii = False
, optTeXLigatures = True
, optDefaultImageExtension = ""
+ , optTrace = False
+ , optTrackChanges = AcceptChanges
}
-- | A list of functions, each transforming the options data structure
@@ -205,13 +242,13 @@ options :: [OptDescr (Opt -> IO Opt)]
options =
[ Option "fr" ["from","read"]
(ReqArg
- (\arg opt -> return opt { optReader = map toLower arg })
+ (\arg opt -> return opt { optReader = arg })
"FORMAT")
""
, Option "tw" ["to","write"]
(ReqArg
- (\arg opt -> return opt { optWriter = map toLower arg })
+ (\arg opt -> return opt { optWriter = arg })
"FORMAT")
""
@@ -272,6 +309,12 @@ options =
"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 "" ["normalize"]
(NoArg
(\opt -> return opt { optTransforms =
@@ -306,6 +349,17 @@ options =
"FILENAME")
"" -- "Use custom template"
+ , Option "M" ["metadata"]
+ (ReqArg
+ (\arg opt -> do
+ let (key,val) = case break (`elem` ":=") arg of
+ (k,_:v) -> (k, readMetaValue v)
+ (k,_) -> (k, MetaBool True)
+ return opt{ optMetadata = addMetadata key val
+ $ optMetadata opt })
+ "KEY[:VALUE]")
+ ""
+
, Option "V" ["variable"]
(ReqArg
(\arg opt -> do
@@ -314,7 +368,7 @@ options =
(k,_) -> (k,"true")
return opt{ optVariables = (key,val) : optVariables opt })
"KEY[:VALUE]")
- "" -- "Use custom template"
+ ""
, Option "D" ["print-default-template"]
(ReqArg
@@ -327,13 +381,13 @@ options =
"FORMAT")
"" -- "Print default template for FORMAT"
- , Option "" ["print-sample-lua-writer"]
- (NoArg
- (\_ -> do
- sample <- readDataFileUTF8 Nothing "sample.lua"
- UTF8.hPutStr stdout sample
- exitWith ExitSuccess))
- "" -- "Print sample lua custom writer"
+ , Option "" ["print-default-data-file"]
+ (ReqArg
+ (\arg _ -> do
+ readDataFile Nothing arg >>= BS.hPutStr stdout
+ exitWith ExitSuccess)
+ "FILE")
+ "" -- "Print default data file"
, Option "" ["no-wrap"]
(NoArg
@@ -424,8 +478,6 @@ options =
, Option "" ["self-contained"]
(NoArg
(\opt -> return opt { optSelfContained = True,
- optVariables = ("slidy-url","slidy") :
- optVariables opt,
optStandalone = True }))
"" -- "Make slide shows include all the needed js and css"
@@ -621,7 +673,7 @@ options =
(ReqArg
(\arg opt -> do
let b = takeBaseName arg
- if (b == "pdflatex" || b == "lualatex" || b == "xelatex")
+ if b `elem` ["pdflatex", "lualatex", "xelatex"]
then return opt { optLaTeXEngine = arg }
else err 45 "latex-engine must be pdflatex, lualatex, or xelatex.")
"PROGRAM")
@@ -629,20 +681,33 @@ options =
, Option "" ["bibliography"]
(ReqArg
- (\arg opt -> return opt { optBibliography = (optBibliography opt) ++ [arg] })
- "FILENAME")
+ (\arg opt -> return opt{ optMetadata = addMetadata
+ "bibliography" (readMetaValue arg)
+ $ optMetadata opt
+ , optVariables =
+ ("biblio-files", dropExtension arg) :
+ optVariables opt
+ })
+ "FILE")
""
- , Option "" ["csl"]
+ , Option "" ["csl"]
(ReqArg
- (\arg opt -> return opt { optCslFile = Just arg })
- "FILENAME")
+ (\arg opt ->
+ return opt{ optMetadata = addMetadata "csl"
+ (readMetaValue arg)
+ $ optMetadata opt })
+ "FILE")
""
- , Option "" ["citation-abbreviations"]
+ , Option "" ["citation-abbreviations"]
(ReqArg
- (\arg opt -> return opt { optAbbrevsFile = Just arg })
- "FILENAME")
+ (\arg opt ->
+ return opt{ optMetadata = addMetadata
+ "citation-abbreviations"
+ (readMetaValue arg)
+ $ optMetadata opt })
+ "FILE")
""
, Option "" ["natbib"]
@@ -710,6 +775,24 @@ options =
(\opt -> return opt { optHTMLMathMethod = GladTeX }))
"" -- "Use gladtex for HTML math"
+ , Option "" ["trace"]
+ (NoArg
+ (\opt -> return opt { optTrace = True }))
+ "" -- "Turn on diagnostic tracing in readers."
+
+ , 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 "" ["dump-args"]
(NoArg
(\opt -> return opt { optDumpArgs = True }))
@@ -741,6 +824,20 @@ options =
]
+addMetadata :: String -> MetaValue -> M.Map String MetaValue
+ -> M.Map String MetaValue
+addMetadata k v m = case M.lookup k m of
+ Nothing -> M.insert k v m
+ Just (MetaList xs) -> M.insert k
+ (MetaList (xs ++ [v])) m
+ Just x -> M.insert k (MetaList [v, x]) m
+
+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
+
-- Returns usage message
usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
usageMessage programName = usageInfo
@@ -765,6 +862,7 @@ defaultReaderName fallback (x:xs) =
".latex" -> "latex"
".ltx" -> "latex"
".rst" -> "rst"
+ ".org" -> "org"
".lhs" -> "markdown+lhs"
".db" -> "docbook"
".opml" -> "opml"
@@ -773,6 +871,7 @@ defaultReaderName fallback (x:xs) =
".textile" -> "textile"
".native" -> "native"
".json" -> "json"
+ ".docx" -> "docx"
_ -> defaultReaderName fallback xs
-- Returns True if extension of first source is .lhs
@@ -848,6 +947,7 @@ main = do
, optWriter = writerName
, optParseRaw = parseRaw
, optVariables = variables
+ , optMetadata = metadata
, optTableOfContents = toc
, optTransforms = transforms
, optTemplate = templatePath
@@ -877,13 +977,11 @@ main = do
, optReferenceLinks = referenceLinks
, optWrapText = wrap
, optColumns = columns
+ , optFilters = filters
, optEmailObfuscation = obfuscationMethod
, optIdentifierPrefix = idPrefix
, optIndentedCodeClasses = codeBlockClasses
, optDataDir = mbDataDir
- , optBibliography = reffiles
- , optCslFile = mbCsl
- , optAbbrevsFile = cslabbrevs
, optCiteMethod = citeMethod
, optListings = listings
, optLaTeXEngine = latexEngine
@@ -892,6 +990,8 @@ main = do
, optAscii = ascii
, optTeXLigatures = texLigatures
, optDefaultImageExtension = defaultImageExtension
+ , optTrace = trace
+ , optTrackChanges = trackChanges
} = opts
when dumpArgs $
@@ -899,6 +999,15 @@ main = do
mapM_ (\arg -> UTF8.hPutStrLn stdout arg) args
exitWith ExitSuccess
+ -- --bibliography implies -F pandoc-citeproc for backwards compatibility:
+ let filters' = case M.lookup "bibliography" metadata of
+ Just _ | optCiteMethod opts /= Natbib &&
+ optCiteMethod opts /= Biblatex &&
+ all (\f -> takeBaseName f /= "pandoc-citeproc")
+ filters -> "pandoc-citeproc" : filters
+ _ -> filters
+ let plugins = map externalFilter filters'
+
let sources = if ignoreArgs then [] else args
datadir <- case mbDataDir of
@@ -909,33 +1018,37 @@ main = do
Just _ -> return mbDataDir
-- assign reader and writer based on options and filenames
- let readerName' = if null readerName
- then let fallback = if any isURI sources
- then "html"
- else "markdown"
- in defaultReaderName fallback sources
- else readerName
-
- let writerName' = if null writerName
- then defaultWriterName outputFile
- else writerName
+ let readerName' = case map toLower readerName of
+ [] -> defaultReaderName
+ (if any isURI sources
+ then "html"
+ else "markdown") sources
+ "html4" -> "html"
+ x -> x
+
+ let writerName' = case map toLower writerName of
+ [] -> defaultWriterName outputFile
+ "epub2" -> "epub"
+ "html4" -> "html"
+ x -> x
let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"
let laTeXOutput = "latex" `isPrefixOf` writerName' ||
"beamer" `isPrefixOf` writerName'
- when pdfOutput $ do
- -- make sure writer is latex or beamer
- unless laTeXOutput $
- err 47 $ "cannot produce pdf output with " ++ writerName' ++ " writer"
- -- check for latex program
- mbLatex <- findExecutable latexEngine
- case mbLatex of
- Nothing -> err 41 $
- latexEngine ++ " not found. " ++
- latexEngine ++ " is needed for pdf output."
- Just _ -> return ()
+ writer <- if ".lua" `isSuffixOf` writerName'
+ -- note: use non-lowercased version writerName
+ then return $ IOStringWriter $ writeCustom writerName
+ else case getWriter writerName' of
+ Left e -> err 9 $
+ if writerName' == "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
reader <- case getReader readerName' of
Right r -> return r
@@ -967,12 +1080,10 @@ main = do
variables' <- case mathMethod of
LaTeXMathML Nothing -> do
- s <- readDataFileUTF8 datadir
- ("LaTeXMathML.js")
+ s <- readDataFileUTF8 datadir "LaTeXMathML.js"
return $ ("mathml-script", s) : variables
MathML Nothing -> do
- s <- readDataFileUTF8 datadir
- ("MathMLinHTML.js")
+ s <- readDataFileUTF8 datadir "MathMLinHTML.js"
return $ ("mathml-script", s) : variables
_ -> return variables
@@ -984,43 +1095,15 @@ main = do
$ lines dztempl
return $ ("dzslides-core", dzcore) : variables'
else return variables'
-
- -- unescape reference ids, which may contain XML entities, so
- -- that we can do lookups with regular string equality
- let unescapeRefId ref = ref{ refId = fromEntities (refId ref) }
-
- refs <- mapM (\f -> E.catch (CSL.readBiblioFile f)
- (\e -> let _ = (e :: E.SomeException)
- in err 23 $ "Error reading bibliography `" ++ f ++
- "'" ++ "\n" ++ show e))
- reffiles >>=
- return . map unescapeRefId . concat
-
- mbsty <- if citeMethod == Citeproc && not (null refs)
- then do
- csl <- CSL.parseCSL =<<
- case mbCsl of
- Nothing -> readDataFileUTF8 datadir
- "default.csl"
- Just cslfile -> do
- exists <- doesFileExist cslfile
- if exists
- then UTF8.readFile cslfile
- else do
- csldir <- getAppUserDataDirectory "csl"
- readDataFileUTF8 (Just csldir)
- (replaceExtension cslfile "csl")
- abbrevs <- maybe (return []) CSL.readJsonAbbrevFile cslabbrevs
- return $ Just csl { CSL.styleAbbrevs = abbrevs }
- else return Nothing
-
- let sourceDir = case sources of
- [] -> "."
+ let sourceURL = case sources of
+ [] -> Nothing
(x:_) -> case parseURI x of
Just u
| uriScheme u `elem` ["http:","https:"] ->
- show u{ uriPath = "", uriQuery = "", uriFragment = "" }
- _ -> takeDirectory x
+ Just $ show u{ uriPath = "",
+ uriQuery = "",
+ uriFragment = "" }
+ _ -> Nothing
let readerOpts = def{ readerSmart = smart || (texLigatures &&
(laTeXOutput || "context" `isPrefixOf` writerName'))
@@ -1029,11 +1112,11 @@ main = do
, readerColumns = columns
, readerTabStop = tabStop
, readerOldDashes = oldDashes
- , readerReferences = refs
- , readerCitationStyle = mbsty
, readerIndentedCodeClasses = codeBlockClasses
, readerApplyMacros = not laTeXOutput
, readerDefaultImageExtension = defaultImageExtension
+ , readerTrace = trace
+ , readerTrackChanges = trackChanges
}
let writerOptions = def { writerStandalone = standalone',
@@ -1044,7 +1127,6 @@ main = do
writerHTMLMathMethod = mathMethod,
writerIncremental = incremental,
writerCiteMethod = citeMethod,
- writerBiblioFiles = reffiles,
writerIgnoreNotes = False,
writerNumberSections = numberSections,
writerNumberOffset = numberFrom,
@@ -1054,7 +1136,7 @@ main = do
writerColumns = columns,
writerEmailObfuscation = obfuscationMethod,
writerIdentifierPrefix = idPrefix,
- writerSourceDirectory = sourceDir,
+ writerSourceURL = sourceURL,
writerUserDataDir = datadir,
writerHtml5 = html5,
writerHtmlQTags = htmlQTags,
@@ -1084,10 +1166,16 @@ main = do
readSource "-" = UTF8.getContents
readSource src = case parseURI src of
Just u | uriScheme u `elem` ["http:","https:"] ->
- readURI u
+ readURI src
_ -> UTF8.readFile src
- readURI uri = simpleHTTP (mkRequest GET uri) >>= getResponseBody >>=
- return . UTF8.toStringLazy -- treat all as UTF8
+ readURI src = do
+ res <- openURL src
+ case res of
+ Left e -> throwIO e
+ Right (bs,_) -> return $ UTF8.toString bs
+
+ let readFiles [] = error "Cannot read archive from stdin"
+ readFiles (x:_) = B.readFile x
let convertTabs = tabFilter (if preserveTabs then 0 else tabStop)
@@ -1095,11 +1183,17 @@ main = do
then handleIncludes
else return
- doc <- readSources sources >>=
- handleIncludes' . convertTabs . intercalate "\n" >>=
- reader readerOpts
+ doc <- case reader of
+ StringReader r->
+ readSources sources >>=
+ handleIncludes' . convertTabs . intercalate "\n" >>=
+ r readerOpts
+ ByteStringReader r -> readFiles sources >>= r readerOpts
+
- let doc0 = foldr ($) doc transforms
+ let doc0 = M.foldWithKey setMeta doc metadata
+ let doc1 = foldr ($) doc0 transforms
+ doc2 <- foldrM ($) doc1 $ map ($ [writerName']) plugins
let writeBinary :: B.ByteString -> IO ()
writeBinary = B.writeFile (UTF8.encodePath outputFile)
@@ -1108,17 +1202,30 @@ main = do
writerFn "-" = UTF8.putStr
writerFn f = UTF8.writeFile f
- case getWriter writerName' of
- Left e -> err 9 e
- Right (IOStringWriter f) -> f writerOptions doc0 >>= writerFn outputFile
- Right (IOByteStringWriter f) -> f writerOptions doc0 >>= writeBinary
- Right (PureStringWriter f)
+ case writer of
+ IOStringWriter f -> f writerOptions doc2 >>= writerFn outputFile
+ IOByteStringWriter f -> f writerOptions doc2 >>= writeBinary
+ PureStringWriter f
| pdfOutput -> do
- res <- tex2pdf latexEngine $ f writerOptions doc0
+ -- make sure writer is latex or beamer
+ unless laTeXOutput $
+ err 47 $ "cannot produce pdf output with " ++ writerName' ++
+ " writer"
+
+ -- check for latex program
+ mbLatex <- findExecutable latexEngine
+ when (mbLatex == Nothing) $
+ err 41 $ latexEngine ++ " not found. " ++
+ latexEngine ++ " is needed for pdf output."
+
+ res <- makePDF latexEngine f writerOptions doc2
case res of
Right pdf -> writeBinary pdf
- Left err' -> err 43 $ UTF8.toStringLazy err'
- | otherwise -> selfcontain (f writerOptions doc0 ++
+ Left err' -> do
+ B.hPutStr stderr $ err'
+ B.hPut stderr $ B.pack [10]
+ err 43 "Error producing PDF from TeX source"
+ | otherwise -> selfcontain (f writerOptions doc2 ++
['\n' | not standalone'])
>>= writerFn outputFile . handleEntities
where htmlFormat = writerName' `elem`
diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs
index 4cebd2f75..23b97e6c1 100644
--- a/src/Text/Pandoc.hs
+++ b/src/Text/Pandoc.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE ScopedTypeVariables, FlexibleInstances #-}
{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc
- Copyright : Copyright (C) 2006-2010 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -62,9 +62,12 @@ module Text.Pandoc
, readers
, writers
-- * Readers: converting /to/ Pandoc format
+ , Reader (..)
+ , readDocx
, readMarkdown
, readMediaWiki
, readRST
+ , readOrg
, readLaTeX
, readHtml
, readTextile
@@ -72,9 +75,11 @@ module Text.Pandoc
, readOPML
, readHaddock
, readNative
+ , readJSON
-- * Writers: converting /from/ Pandoc format
, Writer (..)
, writeNative
+ , writeJSON
, writeMarkdown
, writePlain
, writeRST
@@ -83,6 +88,7 @@ module Text.Pandoc
, writeTexinfo
, writeHtml
, writeHtmlString
+ , writeICML
, writeDocbook
, writeOPML
, writeOpenDocument
@@ -97,6 +103,7 @@ module Text.Pandoc
, writeFB2
, writeOrg
, writeAsciiDoc
+ , writeHaddock
, writeCustom
-- * Rendering templates and default templates
, module Text.Pandoc.Templates
@@ -105,15 +112,16 @@ module Text.Pandoc
-- * Miscellaneous
, getReader
, getWriter
- , jsonFilter
, ToJsonFilter(..)
) where
import Text.Pandoc.Definition
import Text.Pandoc.Generic
+import Text.Pandoc.JSON
import Text.Pandoc.Readers.Markdown
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
@@ -121,6 +129,7 @@ import Text.Pandoc.Readers.HTML
import Text.Pandoc.Readers.Textile
import Text.Pandoc.Readers.Native
import Text.Pandoc.Readers.Haddock
+import Text.Pandoc.Readers.Docx
import Text.Pandoc.Writers.Native
import Text.Pandoc.Writers.Markdown
import Text.Pandoc.Writers.RST
@@ -132,6 +141,7 @@ 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
@@ -142,17 +152,16 @@ import Text.Pandoc.Writers.DokuWiki
import Text.Pandoc.Writers.Textile
import Text.Pandoc.Writers.Org
import Text.Pandoc.Writers.AsciiDoc
+import Text.Pandoc.Writers.Haddock
import Text.Pandoc.Writers.Custom
import Text.Pandoc.Templates
import Text.Pandoc.Options
import Text.Pandoc.Shared (safeRead, warn)
-import Data.ByteString.Lazy (ByteString)
+import Data.Aeson
import qualified Data.ByteString.Lazy as BL
-import Data.List (intercalate, isSuffixOf)
+import Data.List (intercalate)
import Data.Version (showVersion)
-import Data.Aeson.Generic
import Data.Set (Set)
-import Data.Data
import qualified Data.Set as Set
import Text.Parsec
import Text.Parsec.Error
@@ -190,45 +199,56 @@ markdown o s = do
mapM_ warn warnings
return doc
+data Reader = StringReader (ReaderOptions -> String -> IO Pandoc)
+ | ByteStringReader (ReaderOptions -> BL.ByteString -> IO Pandoc)
+
+mkStringReader :: (ReaderOptions -> String -> Pandoc) -> Reader
+mkStringReader r = StringReader (\o s -> return $ r o s)
+
+mkBSReader :: (ReaderOptions -> BL.ByteString -> Pandoc) -> Reader
+mkBSReader r = ByteStringReader (\o s -> return $ r o s)
+
-- | Association list of formats and readers.
-readers :: [(String, ReaderOptions -> String -> IO Pandoc)]
-readers = [("native" , \_ s -> return $ readNative s)
- ,("json" , \_ s -> return $ checkJSON
- $ decode $ UTF8.fromStringLazy s)
- ,("markdown" , markdown)
- ,("markdown_strict" , markdown)
- ,("markdown_phpextra" , markdown)
- ,("markdown_github" , markdown)
- ,("markdown_mmd", markdown)
- ,("rst" , \o s -> return $ readRST o s)
- ,("mediawiki" , \o s -> return $ readMediaWiki o s)
- ,("docbook" , \o s -> return $ readDocBook o s)
- ,("opml" , \o s -> return $ readOPML o s)
- ,("textile" , \o s -> return $ readTextile o s) -- TODO : textile+lhs
- ,("html" , \o s -> return $ readHtml o s)
- ,("latex" , \o s -> return $ readLaTeX o s)
- ,("haddock" , \o s -> return $ readHaddock o s)
- ]
+readers :: [(String, Reader)]
+readers = [ ("native" , StringReader $ \_ s -> return $ readNative s)
+ ,("json" , mkStringReader readJSON )
+ ,("markdown" , StringReader markdown)
+ ,("markdown_strict" , StringReader markdown)
+ ,("markdown_phpextra" , StringReader markdown)
+ ,("markdown_github" , StringReader markdown)
+ ,("markdown_mmd", StringReader markdown)
+ ,("rst" , mkStringReader readRST )
+ ,("mediawiki" , mkStringReader readMediaWiki)
+ ,("docbook" , mkStringReader readDocBook)
+ ,("opml" , mkStringReader readOPML)
+ ,("org" , mkStringReader readOrg)
+ ,("textile" , mkStringReader readTextile) -- TODO : textile+lhs
+ ,("html" , mkStringReader readHtml)
+ ,("latex" , mkStringReader readLaTeX)
+ ,("haddock" , mkStringReader readHaddock)
+ ,("docx" , mkBSReader readDocx)
+ ]
data Writer = PureStringWriter (WriterOptions -> Pandoc -> String)
| IOStringWriter (WriterOptions -> Pandoc -> IO String)
- | IOByteStringWriter (WriterOptions -> Pandoc -> IO ByteString)
+ | IOByteStringWriter (WriterOptions -> Pandoc -> IO BL.ByteString)
-- | Association list of formats and writers.
writers :: [ ( String, Writer ) ]
writers = [
("native" , PureStringWriter writeNative)
- ,("json" , PureStringWriter $ \_ -> UTF8.toStringLazy . encode)
+ ,("json" , PureStringWriter writeJSON)
,("docx" , IOByteStringWriter writeDocx)
- ,("odt" , IOByteStringWriter writeODT)
- ,("epub" , IOByteStringWriter $ \o ->
+ ,("odt" , IOByteStringWriter writeODT)
+ ,("epub" , IOByteStringWriter $ \o ->
writeEPUB o{ writerEpubVersion = Just EPUB2 })
- ,("epub3" , IOByteStringWriter $ \o ->
+ ,("epub3" , IOByteStringWriter $ \o ->
writeEPUB o{ writerEpubVersion = Just EPUB3 })
,("fb2" , IOStringWriter writeFB2)
,("html" , PureStringWriter writeHtmlString)
,("html5" , PureStringWriter $ \o ->
writeHtmlString o{ writerHtml5 = True })
+ ,("icml" , PureStringWriter writeICML)
,("s5" , PureStringWriter $ \o ->
writeHtmlString o{ writerSlideVariant = S5Slides
, writerTableOfContents = False })
@@ -264,6 +284,7 @@ writers = [
,("rtf" , IOStringWriter writeRTFWithEmbeddedImages)
,("org" , PureStringWriter writeOrg)
,("asciidoc" , PureStringWriter writeAsciiDoc)
+ ,("haddock" , PureStringWriter writeHaddock)
]
getDefaultExtensions :: String -> Set Extension
@@ -271,94 +292,53 @@ getDefaultExtensions "markdown_strict" = strictExtensions
getDefaultExtensions "markdown_phpextra" = phpMarkdownExtraExtensions
getDefaultExtensions "markdown_mmd" = multimarkdownExtensions
getDefaultExtensions "markdown_github" = githubMarkdownExtensions
-getDefaultExtensions _ = pandocExtensions
+getDefaultExtensions "markdown" = pandocExtensions
+getDefaultExtensions "plain" = pandocExtensions
+getDefaultExtensions "org" = Set.fromList [Ext_citations]
+getDefaultExtensions "textile" = Set.fromList [Ext_auto_identifiers, Ext_raw_tex]
+getDefaultExtensions _ = Set.fromList [Ext_auto_identifiers]
-- | Retrieve reader based on formatSpec (format+extensions).
-getReader :: String -> Either String (ReaderOptions -> String -> IO Pandoc)
+getReader :: String -> Either String Reader
getReader s =
case parseFormatSpec s of
Left e -> Left $ intercalate "\n" $ [m | Message m <- errorMessages e]
- Right (readerName, setExts) ->
+ Right (readerName, setExts) ->
case lookup readerName readers of
Nothing -> Left $ "Unknown reader: " ++ readerName
- Just r -> Right $ \o ->
+ Just (StringReader r) -> Right $ StringReader $ \o ->
+ r o{ readerExtensions = setExts $
+ getDefaultExtensions readerName }
+ Just (ByteStringReader r) -> Right $ ByteStringReader $ \o ->
r o{ readerExtensions = setExts $
getDefaultExtensions readerName }
-- | Retrieve writer based on formatSpec (format+extensions).
getWriter :: String -> Either String Writer
-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
- | ".lua" `isSuffixOf` s ->
- Right $ IOStringWriter $ writeCustom s
- | otherwise -> Left $ "Unknown writer: " ++ writerName
- Just (PureStringWriter r) -> Right $ PureStringWriter $
- \o -> r o{ writerExtensions = setExts $
- getDefaultExtensions writerName }
- Just (IOStringWriter r) -> Right $ IOStringWriter $
- \o -> r o{ writerExtensions = setExts $
- getDefaultExtensions writerName }
- Just (IOByteStringWriter r) -> Right $ IOByteStringWriter $
- \o -> r o{ writerExtensions = setExts $
- getDefaultExtensions writerName }
-
-{-# DEPRECATED jsonFilter "Use toJsonFilter instead" #-}
--- | Converts a transformation on the Pandoc AST into a function
--- that reads and writes a JSON-encoded string. This is useful
--- for writing small scripts.
-jsonFilter :: (Pandoc -> Pandoc) -> String -> String
-jsonFilter f = UTF8.toStringLazy . encode . f . checkJSON . decode . UTF8.fromStringLazy
-
--- | 'toJsonFilter' convert a function into a filter that reads pandoc's json output
--- from stdin, transforms it by walking the AST and applying the specified
--- function, and writes the result as json to stdout. Usage example:
---
--- > -- capitalize.hs
--- > -- compile with: ghc --make capitalize
--- > -- run with: pandoc -t json | ./capitalize | pandoc -f json
--- >
--- > import Text.Pandoc
--- > import Data.Char (toUpper)
--- >
--- > main :: IO ()
--- > main = toJsonFilter capitalizeStrings
--- >
--- > capitalizeStrings :: Inline -> Inline
--- > capitalizeStrings (Str s) = Str $ map toUpper s
--- > capitalizeStrings x = x
---
--- The function can be any type @(a -> a)@, @(a -> IO a)@, @(a -> [a])@,
--- or @(a -> IO [a])@, where @a@ is an instance of 'Data'.
--- So, for example, @a@ can be 'Pandoc', 'Inline', 'Block', ['Inline'],
--- ['Block'], 'Meta', 'ListNumberStyle', 'Alignment', 'ListNumberDelim',
--- 'QuoteType', etc. See 'Text.Pandoc.Definition'.
-class ToJsonFilter a where
- toJsonFilter :: a -> IO ()
-
-instance (Data a) => ToJsonFilter (a -> a) where
- toJsonFilter f = BL.getContents >>=
- BL.putStr . encode . (bottomUp f :: Pandoc -> Pandoc) . checkJSON . decode
-
-instance (Data a) => ToJsonFilter (a -> IO a) where
- toJsonFilter f = BL.getContents >>=
- (bottomUpM f :: Pandoc -> IO Pandoc) . checkJSON . decode >>=
- BL.putStr . encode
+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 (PureStringWriter r) -> Right $ PureStringWriter $
+ \o -> r o{ writerExtensions = setExts $
+ getDefaultExtensions writerName }
+ Just (IOStringWriter r) -> Right $ IOStringWriter $
+ \o -> r o{ writerExtensions = setExts $
+ getDefaultExtensions writerName }
+ Just (IOByteStringWriter r) -> Right $ IOByteStringWriter $
+ \o -> r o{ writerExtensions = setExts $
+ getDefaultExtensions writerName }
-instance (Data a) => ToJsonFilter (a -> [a]) where
- toJsonFilter f = BL.getContents >>=
- BL.putStr . encode . (bottomUp (concatMap f) :: Pandoc -> Pandoc) .
- checkJSON . decode
+{-# DEPRECATED toJsonFilter "Use 'toJSONFilter' from 'Text.Pandoc.JSON' instead" #-}
+-- | Deprecated. Use @toJSONFilter@ from @Text.Pandoc.JSON@ instead.
+class ToJSONFilter a => ToJsonFilter a
+ where toJsonFilter :: a -> IO ()
+ toJsonFilter = toJSONFilter
-instance (Data a) => ToJsonFilter (a -> IO [a]) where
- toJsonFilter f = BL.getContents >>=
- (bottomUpM (fmap concat . mapM f) :: Pandoc -> IO Pandoc)
- . checkJSON . decode >>=
- BL.putStr . encode
+readJSON :: ReaderOptions -> String -> Pandoc
+readJSON _ = either error id . eitherDecode' . UTF8.fromStringLazy
-checkJSON :: Maybe a -> a
-checkJSON Nothing = error "Error parsing JSON"
-checkJSON (Just r) = r
+writeJSON :: WriterOptions -> Pandoc -> String
+writeJSON _ = UTF8.toStringLazy . encode
diff --git a/src/Text/Pandoc/Asciify.hs b/src/Text/Pandoc/Asciify.hs
index 1c177da90..8a5ccec5c 100644
--- a/src/Text/Pandoc/Asciify.hs
+++ b/src/Text/Pandoc/Asciify.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2013 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2013-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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.SelfContained
- Copyright : Copyright (C) 2013 John MacFarlane
+ Copyright : Copyright (C) 2013-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Biblio.hs b/src/Text/Pandoc/Biblio.hs
deleted file mode 100644
index 4dd82dd08..000000000
--- a/src/Text/Pandoc/Biblio.hs
+++ /dev/null
@@ -1,187 +0,0 @@
-{-# LANGUAGE PatternGuards #-}
-{-
-Copyright (C) 2008 Andrea Rossato <andrea.rossato@ing.unitn.it>
-
-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.Biblio
- Copyright : Copyright (C) 2008-2010 Andrea Rossato
- License : GNU GPL, version 2 or above
-
- Maintainer : Andrea Rossato <andrea.rossato@unitn.it>
- Stability : alpha
- Portability : portable
--}
-
-module Text.Pandoc.Biblio ( processBiblio ) where
-
-import Data.List
-import Data.Char ( isDigit, isPunctuation )
-import qualified Data.Map as M
-import Text.CSL hiding ( Cite(..), Citation(..) )
-import qualified Text.CSL as CSL ( Cite(..) )
-import Text.Pandoc.Definition
-import Text.Pandoc.Generic
-import Text.Pandoc.Shared (stringify)
-import Text.Parsec hiding (State)
-import Control.Monad
-import Control.Monad.State
-
--- | Process a 'Pandoc' document by adding citations formatted
--- according to a CSL style, using 'citeproc' from citeproc-hs.
-processBiblio :: Maybe Style -> [Reference] -> Pandoc -> Pandoc
-processBiblio Nothing _ p = p
-processBiblio _ [] p = p
-processBiblio (Just style) r p =
- let p' = evalState (bottomUpM setHash p) 1
- grps = queryWith getCitation p'
- result = citeproc procOpts style r (setNearNote style $
- map (map toCslCite) grps)
- cits_map = M.fromList $ zip grps (citations result)
- biblioList = map (renderPandoc' style) (bibliography result)
- Pandoc m b = bottomUp mvPunct . deNote . bottomUp (processCite style cits_map) $ p'
- in Pandoc m $ b ++ biblioList
-
--- | Substitute 'Cite' elements with formatted citations.
-processCite :: Style -> M.Map [Citation] [FormattedOutput] -> Inline -> Inline
-processCite s cs (Cite t _) =
- case M.lookup t cs of
- Just (x:xs)
- | isTextualCitation t && not (null xs) ->
- let xs' = renderPandoc s xs
- in if styleClass s == "note"
- then Cite t (renderPandoc s [x] ++ [Note [Para xs']])
- else Cite t (renderPandoc s [x] ++ [Space | not (startWithPunct xs')] ++ xs')
- | otherwise -> if styleClass s == "note"
- then Cite t [Note [Para $ renderPandoc s (x:xs)]]
- else Cite t (renderPandoc s (x:xs))
- _ -> Strong [Str "???"] -- TODO raise error instead?
-processCite _ _ x = x
-
-isNote :: Inline -> Bool
-isNote (Note _) = True
-isNote (Cite _ [Note _]) = True
-isNote _ = False
-
-mvPunct :: [Inline] -> [Inline]
-mvPunct (Space : Space : xs) = Space : xs
-mvPunct (Space : x : ys) | isNote x, startWithPunct ys =
- Str (headInline ys) : x : tailFirstInlineStr ys
-mvPunct (Space : x : ys) | isNote x = x : ys
-mvPunct xs = xs
-
-sanitize :: [Inline] -> [Inline]
-sanitize xs | endWithPunct xs = toCapital xs
- | otherwise = toCapital (xs ++ [Str "."])
-
-deNote :: Pandoc -> Pandoc
-deNote = topDown go
- where go (Note [Para xs]) = Note $ bottomUp go' [Para $ sanitize xs]
- go (Note xs) = Note $ bottomUp go' xs
- go x = x
- go' (Note [Para xs]:ys) =
- if startWithPunct ys && endWithPunct xs
- then initInline xs ++ ys
- else xs ++ ys
- go' xs = xs
-
-isTextualCitation :: [Citation] -> Bool
-isTextualCitation (c:_) = citationMode c == AuthorInText
-isTextualCitation _ = False
-
--- | Retrieve all citations from a 'Pandoc' docuument. To be used with
--- 'queryWith'.
-getCitation :: Inline -> [[Citation]]
-getCitation i | Cite t _ <- i = [t]
- | otherwise = []
-
-setHash :: Citation -> State Int Citation
-setHash c = do
- ident <- get
- put $ ident + 1
- return c{ citationHash = ident }
-
-toCslCite :: Citation -> CSL.Cite
-toCslCite c
- = let (l, s) = locatorWords $ citationSuffix c
- (la,lo) = parseLocator l
- s' = case (l,s,citationMode c) of
- -- treat a bare locator as if it begins with comma
- -- so @item1 [blah] is like [@item1, blah]
- ("",(x:_),AuthorInText) | not (isPunct x)
- -> [Str ",",Space] ++ s
- _ -> s
- isPunct (Str (x:_)) = isPunctuation x
- isPunct _ = False
- citMode = case citationMode c of
- AuthorInText -> (True, False)
- SuppressAuthor -> (False,True )
- NormalCitation -> (False,False)
- in emptyCite { CSL.citeId = citationId c
- , CSL.citePrefix = PandocText $ citationPrefix c
- , CSL.citeSuffix = PandocText s'
- , CSL.citeLabel = la
- , CSL.citeLocator = lo
- , CSL.citeNoteNumber = show $ citationNoteNum c
- , CSL.authorInText = fst citMode
- , CSL.suppressAuthor = snd citMode
- , CSL.citeHash = citationHash c
- }
-
-locatorWords :: [Inline] -> (String, [Inline])
-locatorWords inp =
- case parse pLocatorWords "suffix" $ breakup inp of
- Right r -> r
- Left _ -> ("",inp)
- where breakup [] = []
- breakup (Str x : xs) = map Str (splitup x) ++ breakup xs
- breakup (x : xs) = x : breakup xs
- splitup = groupBy (\x y -> x /= '\160' && y /= '\160')
-
-pLocatorWords :: Parsec [Inline] st (String, [Inline])
-pLocatorWords = do
- l <- pLocator
- s <- getInput -- rest is suffix
- if length l > 0 && last l == ','
- then return (init l, Str "," : s)
- else return (l, s)
-
-pMatch :: (Inline -> Bool) -> Parsec [Inline] st Inline
-pMatch condition = try $ do
- t <- anyToken
- guard $ condition t
- return t
-
-pSpace :: Parsec [Inline] st Inline
-pSpace = pMatch (\t -> t == Space || t == Str "\160")
-
-pLocator :: Parsec [Inline] st String
-pLocator = try $ do
- optional $ pMatch (== Str ",")
- optional pSpace
- f <- many1 (notFollowedBy pSpace >> anyToken)
- gs <- many1 pWordWithDigits
- return $ stringify f ++ (' ' : unwords gs)
-
-pWordWithDigits :: Parsec [Inline] st String
-pWordWithDigits = try $ do
- pSpace
- r <- many1 (notFollowedBy pSpace >> anyToken)
- let s = stringify r
- guard $ any isDigit s
- return s
-
diff --git a/src/Text/Pandoc/Compat/Monoid.hs b/src/Text/Pandoc/Compat/Monoid.hs
new file mode 100644
index 000000000..cb7ea2527
--- /dev/null
+++ b/src/Text/Pandoc/Compat/Monoid.hs
@@ -0,0 +1,20 @@
+{-# LANGUAGE CPP #-}
+module Text.Pandoc.Compat.Monoid ( Monoid(..)
+ , (<>)
+ ) where
+
+#if MIN_VERSION_base(4,5,0)
+import Data.Monoid ((<>), Monoid(..))
+#else
+import Data.Monoid (mappend, Monoid(..))
+#endif
+
+#if MIN_VERSION_base(4,5,0)
+#else
+infixr 6 <>
+
+-- | An infix synonym for 'mappend'.
+(<>) :: Monoid m => m -> m -> m
+(<>) = mappend
+{-# INLINE (<>) #-}
+#endif
diff --git a/src/Text/Pandoc/Compat/TagSoupEntity.hs b/src/Text/Pandoc/Compat/TagSoupEntity.hs
new file mode 100644
index 000000000..80985aef9
--- /dev/null
+++ b/src/Text/Pandoc/Compat/TagSoupEntity.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE CPP #-}
+module Text.Pandoc.Compat.TagSoupEntity (lookupEntity
+ ) where
+
+import qualified Text.HTML.TagSoup.Entity as TE
+
+lookupEntity :: String -> Maybe Char
+#if MIN_VERSION_tagsoup(0,13,0)
+lookupEntity = str2chr . TE.lookupEntity
+ where str2chr :: Maybe String -> Maybe Char
+ str2chr (Just [c]) = Just c
+ str2chr _ = Nothing
+#else
+lookupEntity = TE.lookupEntity
+#endif
diff --git a/src/Text/Pandoc/Highlighting.hs b/src/Text/Pandoc/Highlighting.hs
index 11d608db6..7f975d4c6 100644
--- a/src/Text/Pandoc/Highlighting.hs
+++ b/src/Text/Pandoc/Highlighting.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2008 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2008-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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Highlighting
- Copyright : Copyright (C) 2008 John MacFarlane
+ Copyright : Copyright (C) 2008-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -74,7 +74,12 @@ highlight formatter (_, classes, keyvals) rawCode =
["number","numberLines", "number-lines"]) classes }
lcclasses = map (map toLower) classes
in case find (`elem` lcLanguages) lcclasses of
- Nothing -> Nothing
+ Nothing
+ | numberLines fmtOpts -> Just
+ $ formatter fmtOpts{ codeClasses = [],
+ containerClasses = classes }
+ $ map (\ln -> [(NormalTok, ln)]) $ lines rawCode
+ | otherwise -> Nothing
Just language -> Just
$ formatter fmtOpts{ codeClasses = [language],
containerClasses = classes }
diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs
index 273a1a428..68b34dcf3 100644
--- a/src/Text/Pandoc/ImageSize.hs
+++ b/src/Text/Pandoc/ImageSize.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-}
{-
- Copyright (C) 2011 John MacFarlane <jgm@berkeley.edu>
+ Copyright (C) 2011-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
@@ -19,7 +19,7 @@
{- |
Module : Text.Pandoc.ImageSize
-Copyright : Copyright (C) 2011 John MacFarlane
+Copyright : Copyright (C) 2011-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -32,13 +32,19 @@ module Text.Pandoc.ImageSize ( ImageType(..), imageType, imageSize,
sizeInPixels, sizeInPoints ) where
import Data.ByteString (ByteString, unpack)
import qualified Data.ByteString.Char8 as B
+import qualified Data.ByteString.Lazy as BL
+import Control.Applicative
import Control.Monad
import Data.Bits
+import Data.Binary
+import Data.Binary.Get
+import Text.Pandoc.Shared (safeRead)
+import qualified Data.Map as M
-- quick and dirty functions to get image sizes
-- algorithms borrowed from wwwis.pl
-data ImageType = Png | Gif | Jpeg | Pdf deriving Show
+data ImageType = Png | Gif | Jpeg | Pdf | Eps deriving Show
data ImageSize = ImageSize{
pxX :: Integer
@@ -52,8 +58,12 @@ 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
+ "\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
_ -> fail "Unknown image type"
imageSize :: ByteString -> Maybe ImageSize
@@ -63,14 +73,35 @@ imageSize img = do
Png -> pngSize img
Gif -> gifSize img
Jpeg -> jpegSize img
+ Eps -> epsSize img
Pdf -> Nothing -- TODO
+defaultSize :: (Integer, Integer)
+defaultSize = (72, 72)
+
sizeInPixels :: ImageSize -> (Integer, Integer)
sizeInPixels s = (pxX s, pxY s)
sizeInPoints :: ImageSize -> (Integer, Integer)
sizeInPoints s = (pxX s * 72 `div` dpiX s, pxY s * 72 `div` dpiY s)
+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
@@ -117,8 +148,14 @@ gifSize img = do
jpegSize :: ByteString -> Maybe ImageSize
jpegSize img = do
let (hdr, rest) = B.splitAt 4 img
- guard $ hdr == "\xff\xd8\xff\xe0"
guard $ B.length rest >= 14
+ case hdr of
+ "\xff\xd8\xff\xe0" -> jfifSize rest
+ "\xff\xd8\xff\xe1" -> exifSize $ B.takeWhile (/= '\xff') rest
+ _ -> mzero
+
+jfifSize :: ByteString -> Maybe ImageSize
+jfifSize rest = do
let [dpiDensity,dpix1,dpix2,dpiy1,dpiy2] = map fromIntegral
$ unpack $ B.take 5 $ B.drop 9 $ rest
let factor = case dpiDensity of
@@ -127,11 +164,11 @@ jpegSize img = do
_ -> const 72
let dpix = factor (shift dpix1 8 + dpix2)
let dpiy = factor (shift dpiy1 8 + dpiy2)
- (w,h) <- findJpegSize rest
+ (w,h) <- findJfifSize rest
return $ ImageSize { pxX = w, pxY = h, dpiX = dpix, dpiY = dpiy }
-findJpegSize :: ByteString -> Maybe (Integer,Integer)
-findJpegSize bs = do
+findJfifSize :: ByteString -> Maybe (Integer,Integer)
+findJfifSize bs = do
let bs' = B.dropWhile (=='\xff') $ B.dropWhile (/='\xff') bs
case B.uncons bs' of
Just (c,bs'') | c >= '\xc0' && c <= '\xc3' -> do
@@ -143,8 +180,220 @@ findJpegSize bs = do
[c1,c2] -> do
let len = shift c1 8 + c2
-- skip variables
- findJpegSize $ B.drop len bs''
+ findJfifSize $ B.drop len bs''
_ -> fail "JPEG parse error"
Nothing -> fail "Did not find length record"
+exifSize :: ByteString -> Maybe ImageSize
+exifSize bs = runGet (Just <$> exifHeader bl) bl
+ where bl = BL.fromChunks [bs]
+-- 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 -> Get ImageSize
+exifHeader hdr = do
+ _app1DataSize <- getWord16be
+ exifHdr <- getWord32be
+ unless (exifHdr == 0x45786966) $ fail "Did not find exif header"
+ zeros <- getWord16be
+ unless (zeros == 0) $ fail "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 <- 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 <- getWord16
+ unless (tagmark == 0x002a) $ fail "Failed alignment sanity check"
+ ifdOffset <- getWord32
+ skip (fromIntegral ifdOffset - 8) -- skip to IDF
+ numentries <- getWord16
+ let ifdEntry = do
+ tag <- getWord16 >>= \t ->
+ maybe (return UnknownTagType) return
+ (M.lookup t tagTypeTable)
+ dataFormat <- getWord16
+ numComponents <- getWord32
+ (fmt, bytesPerComponent) <-
+ case dataFormat of
+ 1 -> return (UnsignedByte . runGet getWord8, 1)
+ 2 -> return (AsciiString, 1)
+ 3 -> return (UnsignedShort . runGet getWord16, 2)
+ 4 -> return (UnsignedLong . runGet getWord32, 4)
+ 5 -> return (UnsignedRational . runGet getRational, 8)
+ 6 -> return (SignedByte . runGet getWord8, 1)
+ 7 -> return (Undefined . runGet getWord8, 1)
+ 8 -> return (SignedShort . runGet getWord16, 2)
+ 9 -> return (SignedLong . runGet getWord32, 4)
+ 10 -> return (SignedRational . runGet getRational, 8)
+ 11 -> return (SingleFloat . runGet getWord32 {- TODO -}, 4)
+ 12 -> return (DoubleFloat . runGet getWord64 {- TODO -}, 8)
+ _ -> fail $ "Unknown data format " ++ show dataFormat
+ let totalBytes = fromIntegral $ numComponents * bytesPerComponent
+ payload <- if totalBytes <= 4 -- data is right here
+ then fmt <$>
+ (getLazyByteString (fromIntegral totalBytes) <*
+ skip (4 - totalBytes))
+ else do -- get data from offset
+ offs <- getWord32
+ return $ fmt $ BL.take (fromIntegral totalBytes) $
+ BL.drop (fromIntegral offs) tiffHeader
+ return (tag, payload)
+ entries <- sequence $ replicate (fromIntegral numentries) ifdEntry
+ subentries <- case lookup ExifOffset entries of
+ Just (UnsignedLong offset) -> do
+ pos <- bytesRead
+ skip (fromIntegral offset - (fromIntegral pos - 8))
+ numsubentries <- getWord16
+ sequence $
+ replicate (fromIntegral numsubentries) ifdEntry
+ _ -> return []
+ let allentries = entries ++ subentries
+ (width, height) <- 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 = width
+ , pxY = height
+ , dpiX = xres
+ , dpiY = yres }
+
+data DataFormat = UnsignedByte Word8
+ | AsciiString BL.ByteString
+ | UnsignedShort Word16
+ | UnsignedLong Word32
+ | UnsignedRational Rational
+ | SignedByte Word8
+ | Undefined Word8
+ | 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/MIME.hs b/src/Text/Pandoc/MIME.hs
index eb54bd48d..6e6284b25 100644
--- a/src/Text/Pandoc/MIME.hs
+++ b/src/Text/Pandoc/MIME.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2011 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2011-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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.MIME
- Copyright : Copyright (C) 2011 John MacFarlane
+ Copyright : Copyright (C) 2011-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Mime type lookup for ODT writer.
-}
-module Text.Pandoc.MIME ( getMimeType )
+module Text.Pandoc.MIME ( getMimeType, extensionFromMimeType )
where
import System.FilePath
import Data.Char ( toLower )
@@ -37,7 +37,15 @@ import qualified Data.Map as M
getMimeType :: FilePath -> Maybe String
getMimeType "layout-cache" = Just "application/binary" -- in ODT
getMimeType f = M.lookup (map toLower $ drop 1 $ takeExtension f) mimeTypes
- where mimeTypes = M.fromList -- List borrowed from happstack-server.
+ where mimeTypes = M.fromList mimeTypesList
+
+extensionFromMimeType :: String -> Maybe String
+extensionFromMimeType mimetype = M.lookup (takeWhile (/=';') mimetype) reverseMimeTypes
+ -- note: we just look up the basic mime type, dropping the content-encoding etc.
+ where reverseMimeTypes = M.fromList $ map (\(k,v) -> (v,k)) mimeTypesList
+
+mimeTypesList :: [(String, String)]
+mimeTypesList = -- List borrowed from happstack-server.
[("gz","application/x-gzip")
,("cabal","application/x-cabal")
,("%","application/x-trash")
@@ -139,6 +147,7 @@ getMimeType f = M.lookup (map toLower $ drop 1 $ takeExtension f) mimeTypes
,("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")
@@ -212,6 +221,7 @@ getMimeType f = M.lookup (map toLower $ drop 1 $ takeExtension f) mimeTypes
,("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")
@@ -236,6 +246,7 @@ getMimeType f = M.lookup (map toLower $ drop 1 $ takeExtension f) mimeTypes
,("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")
@@ -456,6 +467,7 @@ getMimeType f = M.lookup (map toLower $ drop 1 $ takeExtension f) mimeTypes
,("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")
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
index c9a5e27da..b7a3a4b7b 100644
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2012 John MacFarlane <jgm@berkeley.edu>
+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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Options
- Copyright : Copyright (C) 2012 John MacFarlane
+ Copyright : Copyright (C) 2012-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -41,6 +41,7 @@ module Text.Pandoc.Options ( Extension(..)
, HTMLSlideVariant (..)
, EPUBVersion (..)
, WriterOptions (..)
+ , TrackChanges (..)
, def
, isEnabled
) where
@@ -48,7 +49,6 @@ import Data.Set (Set)
import qualified Data.Set as Set
import Data.Default
import Text.Pandoc.Highlighting (Style, pygments)
-import qualified Text.CSL as CSL
-- | Individually selectable syntax extensions.
data Extension =
@@ -81,6 +81,7 @@ data Extension =
| Ext_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_example_lists -- ^ Markdown-style numbered examples
@@ -92,6 +93,7 @@ data Extension =
| 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_literate_haskell -- ^ Enable literate Haskell conventions
| Ext_abbreviations -- ^ PHP markdown extra abbreviation definitions
| Ext_auto_identifiers -- ^ Automatic identifiers for headers
@@ -169,6 +171,7 @@ githubMarkdownExtensions = Set.fromList
, Ext_intraword_underscores
, Ext_strikeout
, Ext_hard_line_breaks
+ , Ext_lists_without_preceding_blankline
]
multimarkdownExtensions :: Set Extension
@@ -204,12 +207,12 @@ data ReaderOptions = ReaderOptions{
, readerOldDashes :: Bool -- ^ Use pandoc <= 1.8.2.1 behavior
-- in parsing dashes; -- is em-dash;
-- - before numerial is en-dash
- , readerReferences :: [CSL.Reference] -- ^ Bibliographic references
- , readerCitationStyle :: Maybe CSL.Style -- ^ Citation style
, readerApplyMacros :: Bool -- ^ Apply macros to TeX math
, readerIndentedCodeClasses :: [String] -- ^ Default classes for
-- indented code blocks
, readerDefaultImageExtension :: String -- ^ Default extension for images
+ , readerTrace :: Bool -- ^ Print debugging info
+ , readerTrackChanges :: TrackChanges
} deriving (Show, Read)
instance Default ReaderOptions
@@ -222,11 +225,11 @@ instance Default ReaderOptions
, readerColumns = 80
, readerTabStop = 4
, readerOldDashes = False
- , readerReferences = []
- , readerCitationStyle = Nothing
, readerApplyMacros = True
, readerIndentedCodeClasses = []
, readerDefaultImageExtension = ""
+ , readerTrace = False
+ , readerTrackChanges = AcceptChanges
}
--
@@ -264,6 +267,12 @@ data HTMLSlideVariant = S5Slides
| NoSlides
deriving (Show, Read, Eq)
+-- | Options for accepting or rejecting MS Word track-changes.
+data TrackChanges = AcceptChanges
+ | RejectChanges
+ | AllChanges
+ deriving (Show, Read, Eq)
+
-- | Options for writers
data WriterOptions = WriterOptions
{ writerStandalone :: Bool -- ^ Include header and footer
@@ -285,10 +294,9 @@ data WriterOptions = WriterOptions
, writerEmailObfuscation :: ObfuscationMethod -- ^ How to obfuscate emails
, writerIdentifierPrefix :: String -- ^ Prefix for section & note ids in HTML
-- and for footnote marks in markdown
- , writerSourceDirectory :: FilePath -- ^ Directory path of 1st source file
+ , writerSourceURL :: Maybe String -- ^ Absolute URL + directory of 1st source file
, writerUserDataDir :: Maybe FilePath -- ^ Path of user data directory
, writerCiteMethod :: CiteMethod -- ^ How to print cites
- , writerBiblioFiles :: [FilePath] -- ^ Biblio files to use for citations
, writerHtml5 :: Bool -- ^ Produce HTML5
, writerHtmlQTags :: Bool -- ^ Use @<q>@ tags for quotes in HTML
, writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show
@@ -328,10 +336,9 @@ instance Default WriterOptions where
, writerColumns = 72
, writerEmailObfuscation = JavascriptObfuscation
, writerIdentifierPrefix = ""
- , writerSourceDirectory = "."
+ , writerSourceURL = Nothing
, writerUserDataDir = Nothing
, writerCiteMethod = Citeproc
- , writerBiblioFiles = []
, writerHtml5 = False
, writerHtmlQTags = False
, writerBeamer = False
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
index 3227fd0bd..bd55c565f 100644
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings, CPP #-}
{-
-Copyright (C) 2012 John MacFarlane <jgm@berkeley.edu>
+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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.PDF
- Copyright : Copyright (C) 2012 John MacFarlane
+ Copyright : Copyright (C) 2012-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -28,22 +28,32 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Conversion of LaTeX documents to PDF.
-}
-module Text.Pandoc.PDF ( tex2pdf ) where
+module Text.Pandoc.PDF ( makePDF ) where
import System.IO.Temp
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 System.Exit (ExitCode (..))
import System.FilePath
import System.Directory
-import System.Process
-import Control.Exception (evaluate)
-import System.IO (hClose)
-import Control.Concurrent (putMVar, takeMVar, newEmptyMVar, forkIO)
-import Text.Pandoc.UTF8 as UTF8
+import Data.Digest.Pure.SHA (showDigest, sha1)
+import System.Environment
import Control.Monad (unless)
import Data.List (isInfixOf)
+import Data.Maybe (fromMaybe)
+import qualified Text.Pandoc.UTF8 as UTF8
+import Text.Pandoc.Definition
+import Text.Pandoc.Walk (walkM)
+import Text.Pandoc.Shared (fetchItem, warn)
+import Text.Pandoc.Options (WriterOptions(..))
+import Text.Pandoc.MIME (extensionFromMimeType)
+import Text.Pandoc.Process (pipeProcess)
+import qualified Data.ByteString.Lazy as BL
+#ifdef _WINDOWS
+import Data.List (intercalate)
+#endif
withTempDir :: String -> (FilePath -> IO a) -> IO a
withTempDir =
@@ -53,12 +63,50 @@ withTempDir =
withSystemTempDirectory
#endif
-tex2pdf :: String -- ^ tex program (pdflatex, lualatex, xelatex)
- -> String -- ^ latex source
+#ifdef _WINDOWS
+changePathSeparators :: FilePath -> FilePath
+changePathSeparators = intercalate "/" . splitDirectories
+#endif
+
+makePDF :: String -- ^ pdf creator (pdflatex, lualatex, xelatex)
+ -> (WriterOptions -> Pandoc -> String) -- ^ writer
+ -> WriterOptions -- ^ options
+ -> Pandoc -- ^ document
-> IO (Either ByteString ByteString)
-tex2pdf program source = withTempDir "tex2pdf." $ \tmpdir ->
+makePDF program writer opts doc = withTempDir "tex2pdf." $ \tmpdir -> do
+ doc' <- handleImages (writerSourceURL opts) tmpdir doc
+ let source = writer opts doc'
tex2pdf' tmpdir program source
+handleImages :: Maybe String -- ^ source base URL
+ -> FilePath -- ^ temp dir to store images
+ -> Pandoc -- ^ document
+ -> IO Pandoc
+handleImages baseURL tmpdir = walkM (handleImage' baseURL tmpdir)
+
+handleImage' :: Maybe String
+ -> FilePath
+ -> Inline
+ -> IO Inline
+handleImage' baseURL tmpdir (Image ils (src,tit)) = do
+ exists <- doesFileExist src
+ if exists
+ then return $ Image ils (src,tit)
+ else do
+ res <- fetchItem baseURL 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 ils (fname,tit)
+ _ -> do
+ warn $ "Could not find image `" ++ src ++ "', skipping..."
+ return $ Image ils (src,tit)
+handleImage' _ _ x = return x
+
tex2pdf' :: FilePath -- ^ temp directory for output
-> String -- ^ tex program
-> String -- ^ tex source
@@ -68,11 +116,16 @@ tex2pdf' tmpDir program source = do
then 3 -- to get page numbers
else 2 -- 1 run won't give you PDF bookmarks
(exit, log', mbPdf) <- runTeXProgram program numruns tmpDir source
- let msg = "Error producing PDF from TeX source."
case (exit, mbPdf) of
- (ExitFailure _, _) -> return $ Left $
- msg <> "\n" <> extractMsg log'
- (ExitSuccess, Nothing) -> return $ Left msg
+ (ExitFailure _, _) -> do
+ let logmsg = extractMsg log'
+ let extramsg =
+ case logmsg of
+ x | "! Package inputenc Error" `BC.isPrefixOf` x ->
+ "\nTry running pandoc with --latex-engine=xelatex."
+ _ -> ""
+ return $ Left $ logmsg <> extramsg
+ (ExitSuccess, Nothing) -> return $ Left ""
(ExitSuccess, Just pdf) -> return $ Right pdf
(<>) :: ByteString -> ByteString -> ByteString
@@ -100,45 +153,33 @@ runTeXProgram program runsLeft 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, file]
- (exit, out, err) <- readCommand program programArgs
+ "-output-directory", tmpDir', 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"]
+ (exit, out, err) <- pipeProcess (Just env'') program programArgs BL.empty
if runsLeft > 1
then runTeXProgram program (runsLeft - 1) tmpDir source
else do
let pdfFile = replaceDirectory (replaceExtension file ".pdf") tmpDir
pdfExists <- doesFileExist pdfFile
pdf <- if pdfExists
- then Just `fmap` B.readFile pdfFile
+ -- 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 <> err, pdf)
--- utility functions
-
--- Run a command and return exitcode, contents of stdout, and
--- contents of stderr. (Based on
--- 'readProcessWithExitCode' from 'System.Process'.)
-readCommand :: FilePath -- ^ command to run
- -> [String] -- ^ any arguments
- -> IO (ExitCode,ByteString,ByteString) -- ^ exit, stdout, stderr
-readCommand cmd args = do
- (Just inh, Just outh, Just errh, pid) <-
- createProcess (proc cmd args){ std_in = CreatePipe,
- std_out = CreatePipe,
- std_err = CreatePipe }
- outMVar <- newEmptyMVar
- -- fork off a thread to start consuming stdout
- out <- B.hGetContents outh
- _ <- forkIO $ evaluate (B.length out) >> putMVar outMVar ()
- -- fork off a thread to start consuming stderr
- err <- B.hGetContents errh
- _ <- forkIO $ evaluate (B.length err) >> putMVar outMVar ()
- -- now write and flush any input
- hClose inh -- done with stdin
- -- wait on the output
- takeMVar outMVar
- takeMVar outMVar
- hClose outh
- -- wait on the process
- ex <- waitForProcess pid
- return (ex, out, err)
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 0913d8c6c..8bc042e28 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -1,6 +1,7 @@
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving, TypeSynonymInstances,
+ FlexibleInstances#-}
{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -19,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Parsing
- Copyright : Copyright (C) 2006-2010 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -47,11 +48,12 @@ module Text.Pandoc.Parsing ( (>>~),
romanNumeral,
emailAddress,
uri,
+ mathInline,
+ mathDisplay,
withHorizDisplacement,
withRaw,
escaped,
characterReference,
- updateLastStrPos,
anyOrderedListMarker,
orderedListMarker,
charRef,
@@ -61,10 +63,16 @@ module Text.Pandoc.Parsing ( (>>~),
gridTableWith,
readWith,
testStringWith,
- getOption,
guardEnabled,
guardDisabled,
+ updateLastStrPos,
+ notAfterString,
ParserState (..),
+ HasReaderOptions (..),
+ HasHeaderMap (..),
+ HasIdentifierList (..),
+ HasMacros (..),
+ HasLastStrPosition (..),
defaultParserState,
HeaderType (..),
ParserContext (..),
@@ -75,6 +83,7 @@ module Text.Pandoc.Parsing ( (>>~),
SubstTable,
Key (..),
toKey,
+ registerHeader,
smartPunctuation,
withQuoteContext,
singleQuoteStart,
@@ -85,6 +94,7 @@ module Text.Pandoc.Parsing ( (>>~),
apostrophe,
dash,
nested,
+ citeKey,
macro,
applyMacros',
Parser,
@@ -151,6 +161,7 @@ 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
@@ -161,16 +172,18 @@ import Data.List ( intercalate, transpose )
import Text.Pandoc.Shared
import qualified Data.Map as M
import Text.TeXMath.Macros (applyMacros, Macro, parseMacroDefinitions)
-import Text.HTML.TagSoup.Entity ( lookupEntity )
+import Text.Pandoc.Compat.TagSoupEntity ( lookupEntity )
+import Text.Pandoc.Asciify (toAsciiChar)
import Data.Default
import qualified Data.Set as Set
import Control.Monad.Reader
-import Control.Applicative ((*>), (<*), (<$), liftA2)
+import Control.Applicative ((*>), (<*), (<$), liftA2, Applicative)
import Data.Monoid
+import Data.Maybe (catMaybes)
type Parser t s = Parsec t s
-newtype F a = F { unF :: Reader ParserState a } deriving (Monad, Functor)
+newtype F a = F { unF :: Reader ParserState a } deriving (Monad, Applicative, Functor)
runF :: F a -> ParserState -> a
runF = runReader . unF
@@ -261,7 +274,7 @@ spaceChar = satisfy $ \c -> c == ' ' || c == '\t'
-- | Parses a nonspace, nonnewline character.
nonspaceChar :: Parser [Char] st Char
-nonspaceChar = satisfy $ \x -> x /= '\t' && x /= '\n' && x /= ' ' && x /= '\r'
+nonspaceChar = satisfy $ flip notElem ['\t', '\n', ' ', '\r']
-- | Skips zero or more spaces or tabs.
skipSpaces :: Parser [Char] st ()
@@ -421,7 +434,6 @@ uri :: Parser [Char] st (String, String)
uri = try $ do
scheme <- uriScheme
char ':'
- -- /^[\/\w\u0080-\uffff]+|%[A-Fa-f0-9]+|&#?\w+;|(?:[,]+|[\S])[%&~\w\u0080-\uffff]/
-- We allow 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)
@@ -448,6 +460,41 @@ uri = try $ do
let uri' = scheme ++ ":" ++ fromEntities str'
return (uri', escapeURI uri')
+mathInlineWith :: String -> String -> Parser [Char] st String
+mathInlineWith op cl = try $ do
+ string op
+ notFollowedBy space
+ words' <- many1Till (count 1 (noneOf " \t\n\\")
+ <|> (char '\\' >> anyChar >>= \c -> return ['\\',c])
+ <|> 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'
+
+mathDisplayWith :: String -> String -> Parser [Char] st String
+mathDisplayWith op cl = try $ do
+ string op
+ many1Till (noneOf "\n" <|> (newline >>~ notFollowedBy' blankline)) (try $ string cl)
+
+mathDisplay :: Parser [Char] ParserState String
+mathDisplay =
+ (guardEnabled Ext_tex_math_dollars >> mathDisplayWith "$$" "$$")
+ <|> (guardEnabled Ext_tex_math_single_backslash >>
+ mathDisplayWith "\\[" "\\]")
+ <|> (guardEnabled Ext_tex_math_double_backslash >>
+ mathDisplayWith "\\\\[" "\\\\]")
+
+mathInline :: Parser [Char] ParserState 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
@@ -462,7 +509,7 @@ withHorizDisplacement parser = do
-- | Applies a parser and returns the raw string that was parsed,
-- along with the value produced by the parser.
-withRaw :: Parser [Char] st a -> Parser [Char] st (a, [Char])
+withRaw :: Monad m => ParsecT [Char] st m a -> ParsecT [Char] st m (a, [Char])
withRaw parser = do
pos1 <- getPosition
inp <- getInput
@@ -802,6 +849,7 @@ data ParserState = ParserState
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 :: [String], -- ^ List of header identifiers used
@@ -810,6 +858,11 @@ data ParserState = ParserState
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 -> (String, Attr)), -- ^ Current rST custom text roles
+ -- Triple represents: 1) Base role, 2) Optional format (only for :raw:
+ -- roles), 3) Source language annotation for code (could be used to
+ -- annotate role classes too).
+ stateCaption :: Maybe Inlines, -- ^ Caption in current environment
stateWarnings :: [String] -- ^ Warnings generated by the parser
}
@@ -822,6 +875,48 @@ instance HasMeta ParserState where
deleteMeta field st =
st{ stateMeta = deleteMeta field $ stateMeta st }
+class HasReaderOptions st where
+ extractReaderOptions :: st -> ReaderOptions
+ getOption :: (ReaderOptions -> b) -> Parser s st b
+ -- default
+ getOption f = (f . extractReaderOptions) `fmap` getState
+
+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 -> [String]
+ updateIdentifierList :: ([String] -> [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
+
defaultParserState :: ParserState
defaultParserState =
ParserState { stateOptions = def,
@@ -835,6 +930,7 @@ defaultParserState =
stateNotes = [],
stateNotes' = [],
stateMeta = nullMeta,
+ stateMeta' = return nullMeta,
stateHeaderTable = [],
stateHeaders = M.empty,
stateIdentifiers = [],
@@ -843,19 +939,29 @@ defaultParserState =
stateHasChapters = False,
stateMacros = [],
stateRstDefaultRole = "title-reference",
+ stateRstCustomRoles = M.empty,
+ stateCaption = Nothing,
stateWarnings = []}
-getOption :: (ReaderOptions -> a) -> Parser s ParserState a
-getOption f = (f . stateOptions) `fmap` getState
-
-- | Succeed only if the extension is enabled.
-guardEnabled :: Extension -> Parser s ParserState ()
+guardEnabled :: HasReaderOptions st => Extension -> Parser s st ()
guardEnabled ext = getOption readerExtensions >>= guard . Set.member ext
-- | Succeed only if the extension is disabled.
-guardDisabled :: Extension -> Parser s ParserState ()
+guardDisabled :: HasReaderOptions st => Extension -> Parser s st ()
guardDisabled ext = getOption readerExtensions >>= guard . not . Set.member ext
+-- | Update the position on which the last string ended.
+updateLastStrPos :: HasLastStrPosition st => Parser s st ()
+updateLastStrPos = getPosition >>= updateState . setLastStrPos
+
+-- | Whether we are right after the end of a string.
+notAfterString :: HasLastStrPosition st => Parser s st 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
@@ -885,21 +991,47 @@ type KeyTable = M.Map Key Target
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 :: (HasReaderOptions st, HasHeaderMap st, HasIdentifierList st)
+ => Attr -> Inlines -> Parser s st Attr
+registerHeader (ident,classes,kvs) header' = do
+ ids <- extractIdentifierList `fmap` getState
+ exts <- getOption readerExtensions
+ let insert' = M.insertWith (\_new old -> old)
+ if null ident && Ext_auto_identifiers `Set.member` exts
+ then do
+ let id' = uniqueIdent (B.toList header') ids
+ let id'' = if Ext_ascii_identifiers `Set.member` exts
+ then catMaybes $ map toAsciiChar id'
+ else id'
+ updateState $ updateIdentifierList $
+ if id' == id'' then (id' :) else ([id', id''] ++)
+ updateState $ updateHeaderMap $ insert' header' id'
+ return (id'',classes,kvs)
+ else do
+ unless (null ident) $
+ updateState $ updateHeaderMap $ insert' header' ident
+ return (ident,classes,kvs)
+
-- | Fail unless we're in "smart typography" mode.
-failUnlessSmart :: Parser [tok] ParserState ()
+failUnlessSmart :: HasReaderOptions st => Parser s st ()
failUnlessSmart = getOption readerSmart >>= guard
-smartPunctuation :: Parser [Char] ParserState Inline
- -> Parser [Char] ParserState Inline
+smartPunctuation :: Parser [Char] ParserState Inlines
+ -> Parser [Char] ParserState Inlines
smartPunctuation inlineParser = do
failUnlessSmart
choice [ quoted inlineParser, apostrophe, dash, ellipses ]
-apostrophe :: Parser [Char] ParserState Inline
-apostrophe = (char '\'' <|> char '\8217') >> return (Str "\x2019")
+apostrophe :: Parser [Char] ParserState Inlines
+apostrophe = (char '\'' <|> char '\8217') >> return (B.str "\x2019")
-quoted :: Parser [Char] ParserState Inline
- -> Parser [Char] ParserState Inline
+quoted :: Parser [Char] ParserState Inlines
+ -> Parser [Char] ParserState Inlines
quoted inlineParser = doubleQuoted inlineParser <|> singleQuoted inlineParser
withQuoteContext :: QuoteContext
@@ -914,20 +1046,19 @@ withQuoteContext context parser = do
setState newState { stateQuoteContext = oldQuoteContext }
return result
-singleQuoted :: Parser [Char] ParserState Inline
- -> Parser [Char] ParserState Inline
+singleQuoted :: Parser [Char] ParserState Inlines
+ -> Parser [Char] ParserState Inlines
singleQuoted inlineParser = try $ do
singleQuoteStart
withQuoteContext InSingleQuote $ many1Till inlineParser singleQuoteEnd >>=
- return . Quoted SingleQuote . normalizeSpaces
+ return . B.singleQuoted . mconcat
-doubleQuoted :: Parser [Char] ParserState Inline
- -> Parser [Char] ParserState Inline
+doubleQuoted :: Parser [Char] ParserState Inlines
+ -> Parser [Char] ParserState Inlines
doubleQuoted inlineParser = try $ do
doubleQuoteStart
- withQuoteContext InDoubleQuote $ do
- contents <- manyTill inlineParser doubleQuoteEnd
- return . Quoted DoubleQuote . normalizeSpaces $ contents
+ withQuoteContext InDoubleQuote $ manyTill inlineParser doubleQuoteEnd >>=
+ return . B.doubleQuoted . mconcat
failIfInQuoteContext :: QuoteContext -> Parser [tok] ParserState ()
failIfInQuoteContext context = do
@@ -942,17 +1073,11 @@ charOrRef cs =
guard (c `elem` cs)
return c)
-updateLastStrPos :: Parser [Char] ParserState ()
-updateLastStrPos = getPosition >>= \p ->
- updateState $ \s -> s{ stateLastStrPos = Just p }
-
singleQuoteStart :: Parser [Char] ParserState ()
singleQuoteStart = do
failIfInQuoteContext InSingleQuote
- pos <- getPosition
- st <- getState
-- single quote start can't be right after str
- guard $ stateLastStrPos st /= Just pos
+ guard =<< notAfterString
() <$ charOrRef "'\8216\145"
singleQuoteEnd :: Parser [Char] st ()
@@ -964,24 +1089,24 @@ doubleQuoteStart :: Parser [Char] ParserState ()
doubleQuoteStart = do
failIfInQuoteContext InDoubleQuote
try $ do charOrRef "\"\8220\147"
- notFollowedBy (satisfy (\c -> c == ' ' || c == '\t' || c == '\n'))
+ notFollowedBy . satisfy $ flip elem [' ', '\t', '\n']
doubleQuoteEnd :: Parser [Char] st ()
doubleQuoteEnd = do
charOrRef "\"\8221\148"
return ()
-ellipses :: Parser [Char] st Inline
+ellipses :: Parser [Char] st Inlines
ellipses = do
try (charOrRef "\8230\133") <|> try (string "..." >> return '…')
- return (Str "\8230")
+ return (B.str "\8230")
-dash :: Parser [Char] ParserState Inline
+dash :: Parser [Char] ParserState Inlines
dash = do
oldDashes <- getOption readerOldDashes
if oldDashes
then emDashOld <|> enDashOld
- else Str `fmap` (hyphenDash <|> emDash <|> enDash)
+ else B.str `fmap` (hyphenDash <|> emDash <|> enDash)
-- Two hyphens = en-dash, three = em-dash
hyphenDash :: Parser [Char] st String
@@ -999,16 +1124,16 @@ enDash = do
try (charOrRef "\8212\151")
return "\8211"
-enDashOld :: Parser [Char] st Inline
+enDashOld :: Parser [Char] st Inlines
enDashOld = do
try (charOrRef "\8211\150") <|>
try (char '-' >> lookAhead (satisfy isDigit) >> return '–')
- return (Str "\8211")
+ return (B.str "\8211")
-emDashOld :: Parser [Char] st Inline
+emDashOld :: Parser [Char] st Inlines
emDashOld = do
try (charOrRef "\8212\151") <|> (try $ string "--" >> optional (char '-') >> return '-')
- return (Str "\8212")
+ return (B.str "\8212")
-- This is used to prevent exponential blowups for things like:
-- a**a*a**a*a**a*a**a*a**a*a**a*a**
@@ -1022,12 +1147,24 @@ nested p = do
updateState $ \st -> st{ stateMaxNestingLevel = nestlevel }
return res
+citeKey :: HasLastStrPosition st => Parser [Char] st (Bool, String)
+citeKey = try $ do
+ guard =<< notAfterString
+ suppress_author <- option False (char '-' *> return True)
+ char '@'
+ firstChar <- letter <|> char '_'
+ let regchar = satisfy (\c -> isAlphaNum c || c == '_')
+ let internal p = try $ p <* lookAhead regchar
+ rest <- many $ regchar <|> internal (oneOf ":.#$%&-+?<>~/")
+ let key = firstChar:rest
+ return (suppress_author, key)
+
--
-- Macros
--
-- | Parse a \newcommand or \renewcommand macro definition.
-macro :: Parser [Char] ParserState Blocks
+macro :: (HasMacros st, HasReaderOptions st) => Parser [Char] st Blocks
macro = do
apply <- getOption readerApplyMacros
inp <- getInput
@@ -1037,7 +1174,7 @@ macro = do
if apply
then do
updateState $ \st ->
- st { stateMacros = ms ++ stateMacros st }
+ updateMacros (ms ++) st
return mempty
else return $ rawBlock "latex" def'
@@ -1046,7 +1183,6 @@ applyMacros' :: String -> Parser [Char] ParserState String
applyMacros' target = do
apply <- getOption readerApplyMacros
if apply
- then do macros <- liftM stateMacros getState
+ then do macros <- extractMacros `fmap` getState
return $ applyMacros macros target
else return target
-
diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs
index 21121a506..d25ba725f 100644
--- a/src/Text/Pandoc/Pretty.hs
+++ b/src/Text/Pandoc/Pretty.hs
@@ -1,6 +1,6 @@
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving, CPP #-}
{-
-Copyright (C) 2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2010-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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111(-1)307 USA
{- |
Module : Text.Pandoc.Pretty
- Copyright : Copyright (C) 2010 John MacFarlane
+ Copyright : Copyright (C) 2010-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -60,6 +60,7 @@ module Text.Pandoc.Pretty (
, hsep
, vcat
, vsep
+ , nestle
, chomp
, inside
, braces
@@ -72,7 +73,7 @@ module Text.Pandoc.Pretty (
)
where
-import Data.Sequence (Seq, fromList, (<|), singleton, mapWithIndex)
+import Data.Sequence (Seq, fromList, (<|), singleton, mapWithIndex, viewl, ViewL(..))
import Data.Foldable (toList)
import Data.List (intercalate)
import Data.Monoid
@@ -80,8 +81,7 @@ import Data.String
import Control.Monad.State
import Data.Char (isSpace)
-data Monoid a =>
- RenderState a = RenderState{
+data RenderState a = RenderState{
output :: [a] -- ^ In reverse order
, prefix :: String
, usePrefix :: Bool
@@ -186,6 +186,14 @@ vcat = foldr ($$) empty
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
+ (BlankLine :< rest) -> go rest
+ (NewLine :< rest) -> go rest
+ _ -> x
+
-- | Chomps trailing blank space off of a 'Doc'.
chomp :: Doc -> Doc
chomp d = Doc (fromList dl')
diff --git a/src/Text/Pandoc/Process.hs b/src/Text/Pandoc/Process.hs
new file mode 100644
index 000000000..19872b405
--- /dev/null
+++ b/src/Text/Pandoc/Process.hs
@@ -0,0 +1,104 @@
+{-
+Copyright (C) 2013-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.Process
+ Copyright : Copyright (C) 2013-2014 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 and standard error strictly, waits until the process
+terminates, and then returns the 'ExitCode' of the process,
+the standard output, and the standard error.
+
+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,BL.ByteString) -- ^ exitcode, stdout, stderr
+pipeProcess mbenv cmd args input =
+ mask $ \restore -> do
+ (Just inh, Just outh, Just errh, pid) <- createProcess (proc cmd args)
+ { env = mbenv,
+ std_in = CreatePipe,
+ std_out = CreatePipe,
+ std_err = CreatePipe }
+ flip onException
+ (do hClose inh; hClose outh; hClose errh;
+ terminateProcess pid; waitForProcess pid) $ restore $ do
+ -- fork off a thread to start consuming stdout
+ out <- BL.hGetContents outh
+ waitOut <- forkWait $ evaluate $ BL.length out
+
+ -- fork off a thread to start consuming stderr
+ err <- BL.hGetContents errh
+ waitErr <- forkWait $ evaluate $ BL.length err
+
+ -- 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
+ waitErr
+
+ hClose outh
+ hClose errh
+
+ -- wait on the process
+ ex <- waitForProcess pid
+
+ return (ex, out, err)
+
+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/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs
index 0058e889c..cf1d5132e 100644
--- a/src/Text/Pandoc/Readers/DocBook.hs
+++ b/src/Text/Pandoc/Readers/DocBook.hs
@@ -1,16 +1,18 @@
module Text.Pandoc.Readers.DocBook ( readDocBook ) where
-import Data.Char (toUpper, isDigit)
+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 Text.Pandoc.Compat.TagSoupEntity (lookupEntity)
import Data.Generics
import Data.Monoid
import Data.Char (isSpace)
import Control.Monad.State
import Control.Applicative ((<$>))
import Data.List (intersperse)
+import Data.Maybe (fromMaybe)
{-
@@ -43,7 +45,7 @@ List of all DocBook tags, with [x] indicating implemented,
[ ] 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
-[ ] authorgroup - Wrapper for author information when a document has
+[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
@@ -339,7 +341,7 @@ List of all DocBook tags, with [x] indicating implemented,
[x] refsectioninfo - Meta-information for a refsection
[ ] refsynopsisdiv - A syntactic synopsis of the subject of the reference page
[ ] refsynopsisdivinfo - Meta-information for a RefSynopsisDiv
-[ ] releaseinfo - Information about a particular release of a document
+[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
@@ -490,34 +492,40 @@ List of all DocBook tags, with [x] indicating implemented,
anything else
[ ] 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 = State DBState
data DBState = DBState{ dbSectionLevel :: Int
, dbQuoteType :: QuoteType
- , dbDocTitle :: Inlines
- , dbDocAuthors :: [Inlines]
- , dbDocDate :: Inlines
+ , dbMeta :: Meta
+ , dbAcceptsMeta :: Bool
, dbBook :: Bool
, dbFigureTitle :: Inlines
} deriving Show
readDocBook :: ReaderOptions -> String -> Pandoc
-readDocBook _ inp = setTitle (dbDocTitle st')
- $ setAuthors (dbDocAuthors st')
- $ setDate (dbDocDate st')
- $ doc $ mconcat bs
- where (bs, st') = runState (mapM parseBlock $ normalizeTree $ parseXML inp)
+readDocBook _ inp = Pandoc (dbMeta st') (toList $ mconcat bs)
+ where (bs, st') = runState (mapM parseBlock $ normalizeTree $ parseXML inp')
DBState{ dbSectionLevel = 0
, dbQuoteType = DoubleQuote
- , dbDocTitle = mempty
- , dbDocAuthors = []
- , dbDocDate = mempty
+ , dbMeta = mempty
+ , dbAcceptsMeta = False
, dbBook = False
, dbFigureTitle = mempty
}
+ inp' = handleInstructions inp
+
+-- 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 :: Element -> DB Blocks
getFigure e = do
@@ -558,6 +566,30 @@ attrValue attr elt =
named :: String -> Element -> Bool
named s e = qName (elName e) == s
+--
+
+acceptingMetadata :: DB a -> DB a
+acceptingMetadata p = do
+ modify (\s -> s { dbAcceptsMeta = True } )
+ res <- p
+ modify (\s -> s { dbAcceptsMeta = False })
+ return res
+
+checkInMeta :: Monoid a => DB () -> DB a
+checkInMeta p = do
+ accepts <- dbAcceptsMeta <$> get
+ when accepts p
+ return mempty
+
+
+
+addMeta :: ToMetaValue a => String -> a -> DB ()
+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",
@@ -604,6 +636,7 @@ getImage e = do
getBlocks :: Element -> DB Blocks
getBlocks e = mconcat <$> (mapM parseBlock $ elContent e)
+
parseBlock :: Content -> DB Blocks
parseBlock (Text (CData CDataRaw _ _)) = return mempty -- DOCTYPE
parseBlock (Text (CData _ s _)) = if all isSpace s
@@ -617,10 +650,10 @@ parseBlock (Elem e) =
"para" -> parseMixed para (elContent e)
"formalpara" -> do
tit <- case filterChild (named "title") e of
- Just t -> (<> str "." <> linebreak) <$> emph
- <$> getInlines t
+ Just t -> (para . strong . (<> str ".")) <$>
+ getInlines t
Nothing -> return mempty
- addToStart tit <$> parseMixed para (elContent e)
+ (tit <>) <$> parseMixed para (elContent e)
"simpara" -> parseMixed para (elContent e)
"ackno" -> parseMixed para (elContent e)
"epigraph" -> parseBlockquote
@@ -628,7 +661,11 @@ parseBlock (Elem e) =
"attribution" -> return mempty
"titleabbrev" -> return mempty
"authorinitials" -> return mempty
- "title" -> return mempty -- handled by getTitle or sect or figure
+ "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)
@@ -682,18 +719,17 @@ parseBlock (Elem e) =
"lowerroman" -> LowerRoman
"upperroman" -> UpperRoman
_ -> Decimal
- let start = case attrValue "override" <$>
- filterElement (named "listitem") e of
- Just x@(_:_) | all isDigit x -> read x
- _ -> 1
+ let start = fromMaybe 1 $
+ (attrValue "override" <$> filterElement (named "listitem") e)
+ >>= safeRead
orderedListWith (start,listStyle,DefaultDelim)
<$> listitems
"variablelist" -> definitionList <$> deflistitems
"figure" -> getFigure e
"mediaobject" -> para <$> getImage e
"caption" -> return mempty
- "info" -> getTitle >> getAuthors >> getDate >> return mempty
- "articleinfo" -> getTitle >> getAuthors >> getDate >> return mempty
+ "info" -> metaBlock
+ "articleinfo" -> metaBlock
"sectioninfo" -> return mempty -- keywords & other metadata
"refsectioninfo" -> return mempty -- keywords & other metadata
"refsect1info" -> return mempty -- keywords & other metadata
@@ -707,10 +743,10 @@ parseBlock (Elem e) =
"chapterinfo" -> return mempty -- keywords & other metadata
"glossaryinfo" -> return mempty -- keywords & other metadata
"appendixinfo" -> return mempty -- keywords & other metadata
- "bookinfo" -> getTitle >> getAuthors >> getDate >> return mempty
+ "bookinfo" -> metaBlock
"article" -> modify (\st -> st{ dbBook = False }) >>
- getTitle >> getBlocks e
- "book" -> modify (\st -> st{ dbBook = True }) >> getTitle >> getBlocks e
+ getBlocks e
+ "book" -> modify (\st -> st{ dbBook = True }) >> getBlocks e
"table" -> parseTable
"informaltable" -> parseTable
"literallayout" -> codeBlockWithLang
@@ -756,30 +792,25 @@ parseBlock (Elem e) =
terms' <- mapM getInlines terms
items' <- mapM getBlocks items
return (mconcat $ intersperse (str "; ") terms', items')
- getTitle = case filterChild (named "title") e of
- Just t -> do
- tit <- getInlines t
- subtit <- case filterChild (named "subtitle") e of
- Just s -> (text ": " <>) <$>
- getInlines s
- Nothing -> return mempty
- modify $ \st -> st{dbDocTitle = tit <> subtit}
- Nothing -> return ()
- getAuthors = do
- auths <- mapM getInlines
- $ filterChildren (named "author") e
- modify $ \st -> st{dbDocAuthors = auths}
- getDate = case filterChild (named "date") e of
- Just t -> do
- dat <- getInlines t
- modify $ \st -> st{dbDocDate = dat}
- Nothing -> return ()
+ 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' = maybe e id $ filterChild (named "tgroup") e
+ 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
@@ -801,11 +832,14 @@ parseBlock (Elem e) =
Just "center" -> AlignCenter
_ -> AlignDefault
let toWidth c = case findAttr (unqual "colwidth") c of
- Just w -> read $ filter (\x ->
+ Just w -> fromMaybe 0
+ $ safeRead $ '0': filter (\x ->
(x >= '0' && x <= '9')
|| x == '.') w
Nothing -> 0 :: Double
- let numrows = maximum $ map length bodyrows
+ let numrows = case bodyrows of
+ [] -> 0
+ xs -> maximum $ map length xs
let aligns = case colspecs of
[] -> replicate numrows AlignDefault
cs -> map toAlignment cs
@@ -832,6 +866,7 @@ parseBlock (Elem e) =
b <- getBlocks e
modify $ \st -> st{ dbSectionLevel = n - 1 }
return $ header n' headerText <> b
+ metaBlock = acceptingMetadata (getBlocks e) >> return mempty
getInlines :: Element -> DB Inlines
getInlines e' = (trimInlines . mconcat) <$> (mapM parseInline $ elContent e')
@@ -895,6 +930,11 @@ parseInline (Elem e) =
_ -> 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)
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
new file mode 100644
index 000000000..71baa5dde
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -0,0 +1,489 @@
+{-# LANGUAGE PatternGuards #-}
+
+{-
+Copyright (C) 2014 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 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 (From italics. `underline` currently read as span. In
+ future, it might optionally be emph as well)
+ - [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)
+ - [ ] Math
+ - [X] Link (links to an arbitrary bookmark create a span with the target as
+ id and "anchor" class)
+ - [-] Image (Links to path in archive. Future option for
+ data-encoded URI likely.)
+ - [X] Note (Footnotes and Endnotes are silently combined.)
+-}
+
+module Text.Pandoc.Readers.Docx
+ ( readDocx
+ ) where
+
+import Codec.Archive.Zip
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import Text.Pandoc.Builder (text, toList)
+import Text.Pandoc.MIME (getMimeType)
+import Text.Pandoc.UTF8 (toString)
+import Text.Pandoc.Walk
+import Text.Pandoc.Readers.Docx.Parse
+import Text.Pandoc.Readers.Docx.Lists
+import Text.Pandoc.Readers.Docx.Reducible
+import Text.Pandoc.Shared
+import Data.Maybe (mapMaybe)
+import Data.List (delete, isPrefixOf, (\\))
+import qualified Data.ByteString as BS
+import qualified Data.ByteString.Lazy as B
+import Data.ByteString.Base64 (encode)
+import System.FilePath (combine)
+import qualified Data.Map as M
+import Control.Monad.Reader
+import Control.Monad.State
+
+readDocx :: ReaderOptions
+ -> B.ByteString
+ -> Pandoc
+readDocx opts bytes =
+ case archiveToDocx (toArchive bytes) of
+ Just docx -> Pandoc nullMeta (docxToBlocks opts docx)
+ Nothing -> error $ "couldn't parse docx file"
+
+data DState = DState { docxAnchorMap :: M.Map String String }
+
+data DEnv = DEnv { docxOptions :: ReaderOptions
+ , docxDocument :: Docx}
+
+type DocxContext = ReaderT DEnv (State DState)
+
+evalDocxContext :: DocxContext a -> DEnv -> DState -> a
+evalDocxContext ctx env st = evalState (runReaderT ctx env) st
+
+concatMapM :: (Monad m) => (a -> m [b]) -> [a] -> m [b]
+concatMapM f xs = liftM concat (mapM f xs)
+
+-- This is empty, but we put it in for future-proofing.
+spansToKeep :: [String]
+spansToKeep = []
+
+divsToKeep :: [String]
+divsToKeep = ["list-item", "Definition", "DefinitionTerm"]
+
+runStyleToContainers :: RunStyle -> [Container Inline]
+runStyleToContainers rPr =
+ let spanClassToContainers :: String -> [Container Inline]
+ spanClassToContainers s | s `elem` codeSpans =
+ [Container $ (\ils -> Code ("", [], []) (concatMap ilToCode ils))]
+ spanClassToContainers s | s `elem` spansToKeep =
+ [Container $ Span ("", [s], [])]
+ spanClassToContainers _ = []
+
+ classContainers = case rStyle rPr of
+ Nothing -> []
+ Just s -> spanClassToContainers s
+
+ formatters = map Container $ mapMaybe id
+ [ if isBold rPr then (Just Strong) else Nothing
+ , if isItalic rPr then (Just Emph) else Nothing
+ , if isSmallCaps rPr then (Just SmallCaps) else Nothing
+ , if isStrike rPr then (Just Strikeout) else Nothing
+ , if isSuperScript rPr then (Just Superscript) else Nothing
+ , if isSubScript rPr then (Just Subscript) else Nothing
+ , underline rPr >>= (\f -> Just $ Span ("", [], [("underline", f)]))
+ ]
+ in
+ classContainers ++ formatters
+
+
+divAttrToContainers :: [String] -> [(String, String)] -> [Container Block]
+divAttrToContainers (c:cs) _ | Just n <- isHeaderClass c =
+ [Container $ \_ ->
+ Header n ("", delete ("Heading" ++ show n) cs, []) []]
+divAttrToContainers (c:cs) kvs | c `elem` divsToKeep =
+ (Container $ Div ("", [c], [])) : (divAttrToContainers cs kvs)
+divAttrToContainers (c:cs) kvs | c `elem` codeDivs =
+ -- This is a bit of a cludge. We make the codeblock from the raw
+ -- parparts in bodyPartToBlocks. But we need something to match against.
+ (Container $ \_ -> CodeBlock ("", [], []) "") : (divAttrToContainers cs kvs)
+divAttrToContainers (c:cs) kvs | c `elem` listParagraphDivs =
+ let kvs' = filter (\(k,_) -> k /= "indent") kvs
+ in
+ (Container $ Div ("", [c], [])) : (divAttrToContainers cs kvs')
+divAttrToContainers (c:cs) kvs | c `elem` blockQuoteDivs =
+ (Container BlockQuote) : (divAttrToContainers (cs \\ blockQuoteDivs) kvs)
+divAttrToContainers (_:cs) kvs = divAttrToContainers cs kvs
+divAttrToContainers [] kvs | Just numString <- lookup "indent" kvs =
+ let kvs' = filter (\(k,_) -> k /= "indent") kvs
+ in
+ case numString of
+ "0" -> divAttrToContainers [] kvs'
+ ('-' : _) -> divAttrToContainers [] kvs'
+ _ -> (Container BlockQuote) : divAttrToContainers [] kvs'
+divAttrToContainers _ _ = []
+
+
+parStyleToContainers :: ParagraphStyle -> [Container Block]
+parStyleToContainers pPr =
+ let classes = pStyle pPr
+ kvs = case indent pPr of
+ Just n -> [("indent", show n)]
+ Nothing -> []
+ in
+ divAttrToContainers classes kvs
+
+
+strToInlines :: String -> [Inline]
+strToInlines = toList . text
+
+codeSpans :: [String]
+codeSpans = ["VerbatimChar"]
+
+blockQuoteDivs :: [String]
+blockQuoteDivs = ["Quote", "BlockQuote"]
+
+codeDivs :: [String]
+codeDivs = ["SourceCode"]
+
+runElemToInlines :: RunElem -> [Inline]
+runElemToInlines (TextRun s) = strToInlines s
+runElemToInlines (LnBrk) = [LineBreak]
+runElemToInlines (Tab) = [Space]
+
+runElemToString :: RunElem -> String
+runElemToString (TextRun s) = s
+runElemToString (LnBrk) = ['\n']
+runElemToString (Tab) = ['\t']
+
+runElemsToString :: [RunElem] -> String
+runElemsToString = concatMap runElemToString
+
+runToString :: Run -> String
+runToString (Run _ runElems) = runElemsToString runElems
+runToString _ = ""
+
+parPartToString :: ParPart -> String
+parPartToString (PlainRun run) = runToString run
+parPartToString (InternalHyperLink _ runs) = concatMap runToString runs
+parPartToString (ExternalHyperLink _ runs) = concatMap runToString runs
+parPartToString _ = ""
+
+
+inlineCodeContainer :: Container Inline -> Bool
+inlineCodeContainer (Container f) = case f [] of
+ Code _ "" -> True
+ _ -> False
+inlineCodeContainer _ = False
+
+
+runToInlines :: Run -> DocxContext [Inline]
+runToInlines (Run rs runElems)
+ | any inlineCodeContainer (runStyleToContainers rs) =
+ return $
+ rebuild (runStyleToContainers rs) $ [Str $ runElemsToString runElems]
+ | otherwise =
+ return $
+ rebuild (runStyleToContainers rs) (concatMap runElemToInlines runElems)
+runToInlines (Footnote fnId) = do
+ (Docx _ notes _ _ _ ) <- asks docxDocument
+ case (getFootNote fnId notes) of
+ Just bodyParts -> do
+ blks <- concatMapM bodyPartToBlocks bodyParts
+ return $ [Note blks]
+ Nothing -> return [Note []]
+runToInlines (Endnote fnId) = do
+ (Docx _ notes _ _ _ ) <- asks docxDocument
+ case (getEndNote fnId notes) of
+ Just bodyParts -> do
+ blks <- concatMapM bodyPartToBlocks bodyParts
+ return $ [Note blks]
+ Nothing -> return [Note []]
+
+parPartToInlines :: ParPart -> DocxContext [Inline]
+parPartToInlines (PlainRun r) = runToInlines r
+parPartToInlines (Insertion _ author date runs) = do
+ opts <- asks docxOptions
+ case readerTrackChanges opts of
+ AcceptChanges -> concatMapM runToInlines runs >>= return
+ RejectChanges -> return []
+ AllChanges -> do
+ ils <- (concatMapM runToInlines runs)
+ return [Span
+ ("", ["insertion"], [("author", author), ("date", date)])
+ ils]
+parPartToInlines (Deletion _ author date runs) = do
+ opts <- asks docxOptions
+ case readerTrackChanges opts of
+ AcceptChanges -> return []
+ RejectChanges -> concatMapM runToInlines runs >>= return
+ AllChanges -> do
+ ils <- concatMapM runToInlines runs
+ return [Span
+ ("", ["deletion"], [("author", author), ("date", date)])
+ ils]
+parPartToInlines (BookMark _ anchor) | anchor `elem` dummyAnchors = return []
+parPartToInlines (BookMark _ anchor) =
+ -- We record these, so we can make sure not to overwrite
+ -- user-defined anchor links with header auto ids.
+ do
+ -- Get the anchor map.
+ anchorMap <- gets docxAnchorMap
+ -- 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 = case anchor `elem` (M.elems anchorMap) of
+ True -> uniqueIdent [Str anchor] (M.elems anchorMap)
+ False -> anchor
+ put DState{ docxAnchorMap = M.insert anchor newAnchor anchorMap}
+ return [Span (anchor, ["anchor"], []) []]
+parPartToInlines (Drawing relid) = do
+ (Docx _ _ _ rels _) <- asks docxDocument
+ return $ case lookupRelationship relid rels of
+ Just target -> [Image [] (combine "word" target, "")]
+ Nothing -> [Image [] ("", "")]
+parPartToInlines (InternalHyperLink anchor runs) = do
+ ils <- concatMapM runToInlines runs
+ return [Link ils ('#' : anchor, "")]
+parPartToInlines (ExternalHyperLink relid runs) = do
+ (Docx _ _ _ rels _) <- asks docxDocument
+ rs <- concatMapM runToInlines runs
+ return $ case lookupRelationship relid rels of
+ Just target ->
+ [Link rs (target, "")]
+ Nothing ->
+ [Link rs ("", "")]
+
+isAnchorSpan :: Inline -> Bool
+isAnchorSpan (Span (ident, classes, kvs) ils) =
+ (not . null) ident &&
+ classes == ["anchor"] &&
+ null kvs &&
+ null ils
+isAnchorSpan _ = False
+
+dummyAnchors :: [String]
+dummyAnchors = ["_GoBack"]
+
+makeHeaderAnchor :: Block -> DocxContext 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 (_, classes, kvs) ils)
+ | (x : xs) <- filter isAnchorSpan ils
+ , (Span (ident, _, _) _) <- x
+ , notElem ident dummyAnchors =
+ do
+ hdrIDMap <- gets docxAnchorMap
+ let newIdent = uniqueIdent ils (M.elems hdrIDMap)
+ put DState{docxAnchorMap = M.insert ident newIdent hdrIDMap}
+ return $ Header n (newIdent, classes, kvs) (ils \\ (x:xs))
+-- Otherwise we just give it a name, and register that name (associate
+-- it with itself.)
+makeHeaderAnchor (Header n (_, classes, kvs) ils) =
+ do
+ hdrIDMap <- gets docxAnchorMap
+ let newIdent = uniqueIdent ils (M.elems hdrIDMap)
+ put DState{docxAnchorMap = M.insert newIdent newIdent hdrIDMap}
+ return $ Header n (newIdent, classes, kvs) ils
+makeHeaderAnchor blk = return blk
+
+
+parPartsToInlines :: [ParPart] -> DocxContext [Inline]
+parPartsToInlines parparts = do
+ ils <- concatMapM parPartToInlines parparts >>=
+ -- TODO: Option for self-containted images
+ (if False then (walkM makeImagesSelfContained) else return)
+ return $ reduceList $ ils
+
+cellToBlocks :: Cell -> DocxContext [Block]
+cellToBlocks (Cell bps) = concatMapM bodyPartToBlocks bps
+
+rowToBlocksList :: Row -> DocxContext [[Block]]
+rowToBlocksList (Row cells) = mapM cellToBlocks cells
+
+isBlockCodeContainer :: Container Block -> Bool
+isBlockCodeContainer (Container f) | CodeBlock _ _ <- f [] = True
+isBlockCodeContainer _ = False
+
+isHeaderContainer :: Container Block -> Bool
+isHeaderContainer (Container f) | Header _ _ _ <- f [] = True
+isHeaderContainer _ = False
+
+bodyPartToBlocks :: BodyPart -> DocxContext [Block]
+bodyPartToBlocks (Paragraph pPr parparts)
+ | any isBlockCodeContainer (parStyleToContainers pPr) =
+ let
+ otherConts = filter (not . isBlockCodeContainer) (parStyleToContainers pPr)
+ in
+ return $
+ rebuild
+ otherConts
+ [CodeBlock ("", [], []) (concatMap parPartToString parparts)]
+bodyPartToBlocks (Paragraph pPr parparts)
+ | any isHeaderContainer (parStyleToContainers pPr) = do
+ ils <- parPartsToInlines parparts >>= (return . normalizeSpaces)
+ let (Container hdrFun) = head $ filter isHeaderContainer (parStyleToContainers pPr)
+ Header n attr _ = hdrFun []
+ hdr <- makeHeaderAnchor $ Header n attr ils
+ return [hdr]
+bodyPartToBlocks (Paragraph pPr parparts) = do
+ ils <- parPartsToInlines parparts >>= (return . normalizeSpaces)
+ case ils of
+ [] -> return []
+ _ -> do
+ return $
+ rebuild
+ (parStyleToContainers pPr)
+ [Para ils]
+bodyPartToBlocks (ListItem pPr numId lvl parparts) = do
+ (Docx _ _ numbering _ _) <- asks docxDocument
+ let
+ kvs = case lookupLevel numId lvl numbering of
+ Just (_, fmt, txt, Just start) -> [ ("level", lvl)
+ , ("num-id", numId)
+ , ("format", fmt)
+ , ("text", txt)
+ , ("start", (show start))
+ ]
+
+ Just (_, fmt, txt, Nothing) -> [ ("level", lvl)
+ , ("num-id", numId)
+ , ("format", fmt)
+ , ("text", txt)
+ ]
+ Nothing -> []
+ blks <- bodyPartToBlocks (Paragraph pPr parparts)
+ return $ [Div ("", ["list-item"], kvs) blks]
+bodyPartToBlocks (Tbl _ _ _ []) =
+ return [Para []]
+bodyPartToBlocks (Tbl cap _ look (r:rs)) = do
+ let caption = strToInlines cap
+ (hdr, rows) = case firstRowFormatting look of
+ True -> (Just r, rs)
+ False -> (Nothing, r:rs)
+ hdrCells <- case hdr of
+ Just r' -> rowToBlocksList r'
+ Nothing -> return []
+
+ cells <- mapM rowToBlocksList rows
+
+ let size = case null hdrCells of
+ True -> length $ head cells
+ False -> length $ hdrCells
+ --
+ -- 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.
+ alignments = replicate size AlignDefault
+ widths = replicate size 0 :: [Double]
+
+ return [Table caption alignments widths hdrCells cells]
+
+-- replace targets with generated anchors.
+rewriteLink :: Inline -> DocxContext Inline
+rewriteLink l@(Link ils ('#':target, title)) = do
+ anchorMap <- gets docxAnchorMap
+ return $ case M.lookup target anchorMap of
+ Just newTarget -> (Link ils ('#':newTarget, title))
+ Nothing -> l
+rewriteLink il = return il
+
+makeImagesSelfContained :: Inline -> DocxContext Inline
+makeImagesSelfContained i@(Image alt (uri, title)) = do
+ (Docx _ _ _ _ media) <- asks docxDocument
+ return $ case lookup uri media of
+ Just bs ->
+ case getMimeType uri of
+ Just mime ->
+ let data_uri = "data:" ++ mime ++ ";base64," ++
+ toString (encode $ BS.concat $ B.toChunks bs)
+ in
+ Image alt (data_uri, title)
+ Nothing -> i
+ Nothing -> i
+makeImagesSelfContained inline = return inline
+
+bodyToBlocks :: Body -> DocxContext [Block]
+bodyToBlocks (Body bps) = do
+ blks <- concatMapM bodyPartToBlocks bps >>=
+ walkM rewriteLink
+ return $
+ blocksToDefinitions $
+ blocksToBullets $ blks
+
+docxToBlocks :: ReaderOptions -> Docx -> [Block]
+docxToBlocks opts d@(Docx (Document _ body) _ _ _ _) =
+ let dState = DState { docxAnchorMap = M.empty }
+ dEnv = DEnv { docxOptions = opts
+ , docxDocument = d}
+ in
+ evalDocxContext (bodyToBlocks body) dEnv dState
+
+ilToCode :: Inline -> String
+ilToCode (Str s) = s
+ilToCode Space = " "
+ilToCode _ = ""
+
+isHeaderClass :: String -> Maybe Int
+isHeaderClass s | "Heading" `isPrefixOf` s =
+ case reads (drop (length "Heading") s) :: [(Int, String)] of
+ [] -> Nothing
+ ((n, "") : []) -> Just n
+ _ -> Nothing
+isHeaderClass _ = Nothing
diff --git a/src/Text/Pandoc/Readers/Docx/Lists.hs b/src/Text/Pandoc/Readers/Docx/Lists.hs
new file mode 100644
index 000000000..1e37d0076
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Docx/Lists.hs
@@ -0,0 +1,227 @@
+{-
+Copyright (C) 2014 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 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
+
+blocksToBullets :: [Block] -> [Block]
+blocksToBullets blks =
+ 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..07f34450d
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -0,0 +1,596 @@
+{-
+Copyright (C) 2014 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 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(..)
+ , ParPart(..)
+ , Run(..)
+ , RunElem(..)
+ , Notes
+ , Numbering
+ , Relationship
+ , Media
+ , RunStyle(..)
+ , ParagraphStyle(..)
+ , Row(..)
+ , Cell(..)
+ , getFootNote
+ , getEndNote
+ , lookupLevel
+ , lookupRelationship
+ , archiveToDocx
+ ) 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
+
+attrToNSPair :: Attr -> Maybe (String, String)
+attrToNSPair (Attr (QName s _ (Just "xmlns")) val) = Just (s, val)
+attrToNSPair _ = Nothing
+
+
+type NameSpaces = [(String, String)]
+
+data Docx = Docx Document Notes Numbering [Relationship] Media
+ deriving Show
+
+archiveToDocx :: Archive -> Maybe Docx
+archiveToDocx archive = do
+ let notes = archiveToNotes archive
+ rels = archiveToRelationships archive
+ media = archiveToMedia archive
+ doc <- archiveToDocument archive
+ numbering <- archiveToNumbering archive
+ return $ Docx doc notes numbering rels media
+
+data Document = Document NameSpaces Body
+ deriving Show
+
+archiveToDocument :: Archive -> Maybe Document
+archiveToDocument zf = do
+ entry <- findEntryByPath "word/document.xml" zf
+ docElem <- (parseXMLDoc . UTF8.toStringLazy . fromEntry) entry
+ let namespaces = mapMaybe attrToNSPair (elAttribs docElem)
+ bodyElem <- findChild (QName "body" (lookup "w" namespaces) Nothing) docElem
+ body <- elemToBody namespaces bodyElem
+ return $ Document namespaces body
+
+type Media = [(FilePath, B.ByteString)]
+
+filePathIsMedia :: FilePath -> Bool
+filePathIsMedia fp =
+ let (dir, _) = splitFileName fp
+ in
+ (dir == "word/media/")
+
+getMediaPair :: Archive -> FilePath -> Maybe (FilePath, B.ByteString)
+getMediaPair zf fp =
+ case findEntryByPath fp zf of
+ Just e -> Just (fp, fromEntry e)
+ Nothing -> Nothing
+
+archiveToMedia :: Archive -> Media
+archiveToMedia zf =
+ mapMaybe (getMediaPair zf) (filter filePathIsMedia (filesInArchive zf))
+
+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)
+
+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 |
+ qName (elName element) == "num" &&
+ qURI (elName element) == (lookup "w" ns) = do
+ numId <- findAttr (QName "numId" (lookup "w" ns) (Just "w")) element
+ absNumId <- findChild (QName "abstractNumId" (lookup "w" ns) (Just "w")) element
+ >>= findAttr (QName "val" (lookup "w" ns) (Just "w"))
+ return $ Numb numId absNumId
+numElemToNum _ _ = Nothing
+
+absNumElemToAbsNum :: NameSpaces -> Element -> Maybe AbstractNumb
+absNumElemToAbsNum ns element |
+ qName (elName element) == "abstractNum" &&
+ qURI (elName element) == (lookup "w" ns) = do
+ absNumId <- findAttr
+ (QName "abstractNumId" (lookup "w" ns) (Just "w"))
+ element
+ let levelElems = findChildren
+ (QName "lvl" (lookup "w" ns) (Just "w"))
+ element
+ levels = mapMaybe (levelElemToLevel ns) levelElems
+ return $ AbstractNumb absNumId levels
+absNumElemToAbsNum _ _ = Nothing
+
+levelElemToLevel :: NameSpaces -> Element -> Maybe Level
+levelElemToLevel ns element |
+ qName (elName element) == "lvl" &&
+ qURI (elName element) == (lookup "w" ns) = do
+ ilvl <- findAttr (QName "ilvl" (lookup "w" ns) (Just "w")) element
+ fmt <- findChild (QName "numFmt" (lookup "w" ns) (Just "w")) element
+ >>= findAttr (QName "val" (lookup "w" ns) (Just "w"))
+ txt <- findChild (QName "lvlText" (lookup "w" ns) (Just "w")) element
+ >>= findAttr (QName "val" (lookup "w" ns) (Just "w"))
+ let start = findChild (QName "start" (lookup "w" ns) (Just "w")) element
+ >>= findAttr (QName "val" (lookup "w" ns) (Just "w"))
+ >>= (\s -> listToMaybe (map fst (reads s :: [(Integer, String)])))
+ return (ilvl, fmt, txt, start)
+levelElemToLevel _ _ = Nothing
+
+archiveToNumbering :: Archive -> Maybe Numbering
+archiveToNumbering zf =
+ case findEntryByPath "word/numbering.xml" zf of
+ Nothing -> Just $ Numbering [] [] []
+ Just entry -> do
+ numberingElem <- (parseXMLDoc . UTF8.toStringLazy . fromEntry) entry
+ let namespaces = mapMaybe attrToNSPair (elAttribs numberingElem)
+ numElems = findChildren
+ (QName "num" (lookup "w" namespaces) (Just "w"))
+ numberingElem
+ absNumElems = findChildren
+ (QName "abstractNum" (lookup "w" namespaces) (Just "w"))
+ numberingElem
+ nums = mapMaybe (numElemToNum namespaces) numElems
+ absNums = mapMaybe (absNumElemToAbsNum namespaces) absNumElems
+ return $ Numbering namespaces nums absNums
+
+data Notes = Notes NameSpaces (Maybe [(String, [BodyPart])]) (Maybe [(String, [BodyPart])])
+ deriving Show
+
+noteElemToNote :: NameSpaces -> Element -> Maybe (String, [BodyPart])
+noteElemToNote ns element
+ | qName (elName element) `elem` ["endnote", "footnote"] &&
+ qURI (elName element) == (lookup "w" ns) =
+ do
+ noteId <- findAttr (QName "id" (lookup "w" ns) (Just "w")) element
+ let bps = mapMaybe (elemToBodyPart ns)
+ $ elChildren element
+ return $ (noteId, bps)
+noteElemToNote _ _ = Nothing
+
+getFootNote :: String -> Notes -> Maybe [BodyPart]
+getFootNote s (Notes _ fns _) = fns >>= (lookup s)
+
+getEndNote :: String -> Notes -> Maybe [BodyPart]
+getEndNote s (Notes _ _ ens) = ens >>= (lookup s)
+
+elemToNotes :: NameSpaces -> String -> Element -> Maybe [(String, [BodyPart])]
+elemToNotes ns notetype element
+ | qName (elName element) == (notetype ++ "s") &&
+ qURI (elName element) == (lookup "w" ns) =
+ Just $ mapMaybe (noteElemToNote ns)
+ $ findChildren (QName notetype (lookup "w" ns) (Just "w")) element
+elemToNotes _ _ _ = Nothing
+
+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 -> mapMaybe attrToNSPair (elAttribs e)
+ Nothing -> []
+ en_namespaces = case enElem of
+ Just e -> mapMaybe attrToNSPair (elAttribs 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
+
+
+data Relationship = Relationship (RelId, Target)
+ deriving Show
+
+lookupRelationship :: RelId -> [Relationship] -> Maybe Target
+lookupRelationship relid rels =
+ lookup relid (map (\(Relationship pair) -> pair) rels)
+
+filePathIsRel :: FilePath -> Bool
+filePathIsRel fp =
+ let (dir, name) = splitFileName fp
+ in
+ (dir == "word/_rels/") && ((takeExtension name) == ".rels")
+
+relElemToRelationship :: Element -> Maybe Relationship
+relElemToRelationship element | qName (elName element) == "Relationship" =
+ do
+ relId <- findAttr (QName "Id" Nothing Nothing) element
+ target <- findAttr (QName "Target" Nothing Nothing) element
+ return $ Relationship (relId, target)
+relElemToRelationship _ = Nothing
+
+
+archiveToRelationships :: Archive -> [Relationship]
+archiveToRelationships archive =
+ let relPaths = filter filePathIsRel (filesInArchive archive)
+ entries = mapMaybe (\f -> findEntryByPath f archive) relPaths
+ relElems = mapMaybe (parseXMLDoc . UTF8.toStringLazy . fromEntry) entries
+ rels = mapMaybe relElemToRelationship $ concatMap elChildren relElems
+ in
+ rels
+
+data Body = Body [BodyPart]
+ deriving Show
+
+elemToBody :: NameSpaces -> Element -> Maybe Body
+elemToBody ns element | qName (elName element) == "body" && qURI (elName element) == (lookup "w" ns) =
+ Just $ Body
+ $ mapMaybe (elemToBodyPart ns) $ elChildren element
+elemToBody _ _ = Nothing
+
+elemToNumInfo :: NameSpaces -> Element -> Maybe (String, String)
+elemToNumInfo ns element
+ | qName (elName element) == "p" &&
+ qURI (elName element) == (lookup "w" ns) =
+ do
+ pPr <- findChild (QName "pPr" (lookup "w" ns) (Just "w")) element
+ numPr <- findChild (QName "numPr" (lookup "w" ns) (Just "w")) pPr
+ lvl <- findChild (QName "ilvl" (lookup "w" ns) (Just "w")) numPr >>=
+ findAttr (QName "val" (lookup "w" ns) (Just "w"))
+ numId <- findChild (QName "numId" (lookup "w" ns) (Just "w")) numPr >>=
+ findAttr (QName "val" (lookup "w" ns) (Just "w"))
+ return (numId, lvl)
+elemToNumInfo _ _ = Nothing
+
+elemToBodyPart :: NameSpaces -> Element -> Maybe BodyPart
+elemToBodyPart ns element
+ | qName (elName element) == "p" &&
+ qURI (elName element) == (lookup "w" ns) =
+ let parstyle = elemToParagraphStyle ns element
+ parparts = mapMaybe (elemToParPart ns)
+ $ elChildren element
+ in
+ case elemToNumInfo ns element of
+ Just (numId, lvl) -> Just $ ListItem parstyle numId lvl parparts
+ Nothing -> Just $ Paragraph parstyle parparts
+ | qName (elName element) == "tbl" &&
+ qURI (elName element) == (lookup "w" ns) =
+ let
+ caption = findChild (QName "tblPr" (lookup "w" ns) (Just "w")) element
+ >>= findChild (QName "tblCaption" (lookup "w" ns) (Just "w"))
+ >>= findAttr (QName "val" (lookup "w" ns) (Just "w"))
+ grid = case
+ findChild (QName "tblGrid" (lookup "w" ns) (Just "w")) element
+ of
+ Just g -> elemToTblGrid ns g
+ Nothing -> []
+ tblLook = findChild (QName "tblPr" (lookup "w" ns) (Just "w")) element
+ >>= findChild (QName "tblLook" (lookup "w" ns) (Just "w"))
+ >>= elemToTblLook ns
+ in
+ Just $ Tbl
+ (fromMaybe "" caption)
+ grid
+ (fromMaybe defaultTblLook tblLook)
+ (mapMaybe (elemToRow ns) (elChildren element))
+ | otherwise = Nothing
+
+elemToTblLook :: NameSpaces -> Element -> Maybe TblLook
+elemToTblLook ns element
+ | qName (elName element) == "tblLook" &&
+ qURI (elName element) == (lookup "w" ns) =
+ let firstRow = findAttr (QName "firstRow" (lookup "w" ns) (Just "w")) element
+ val = findAttr (QName "val" (lookup "w" ns) (Just "w")) element
+ firstRowFmt =
+ case firstRow of
+ Just "1" -> True
+ Just _ -> False
+ Nothing -> case val of
+ Just bitMask -> testBitMask bitMask 0x020
+ Nothing -> False
+ in
+ Just $ TblLook{firstRowFormatting = firstRowFmt}
+elemToTblLook _ _ = Nothing
+
+testBitMask :: String -> Int -> Bool
+testBitMask bitMaskS n =
+ case (reads ("0x" ++ bitMaskS) :: [(Int, String)]) of
+ [] -> False
+ ((n', _) : _) -> ((n' .|. n) /= 0)
+
+data ParagraphStyle = ParagraphStyle { pStyle :: [String]
+ , indent :: Maybe Integer
+ }
+ deriving Show
+
+defaultParagraphStyle :: ParagraphStyle
+defaultParagraphStyle = ParagraphStyle { pStyle = []
+ , indent = Nothing
+ }
+
+elemToParagraphStyle :: NameSpaces -> Element -> ParagraphStyle
+elemToParagraphStyle ns element =
+ case findChild (QName "pPr" (lookup "w" ns) (Just "w")) element of
+ Just pPr ->
+ ParagraphStyle
+ {pStyle =
+ mapMaybe
+ (findAttr (QName "val" (lookup "w" ns) (Just "w")))
+ (findChildren (QName "pStyle" (lookup "w" ns) (Just "w")) pPr)
+ , indent =
+ findChild (QName "ind" (lookup "w" ns) (Just "w")) pPr >>=
+ findAttr (QName "left" (lookup "w" ns) (Just "w")) >>=
+ stringToInteger
+ }
+ Nothing -> defaultParagraphStyle
+
+
+data BodyPart = Paragraph ParagraphStyle [ParPart]
+ | ListItem ParagraphStyle String String [ParPart]
+ | Tbl String TblGrid TblLook [Row]
+
+ deriving Show
+
+type TblGrid = [Integer]
+
+data TblLook = TblLook {firstRowFormatting::Bool}
+ deriving Show
+
+defaultTblLook :: TblLook
+defaultTblLook = TblLook{firstRowFormatting = False}
+
+stringToInteger :: String -> Maybe Integer
+stringToInteger s = listToMaybe $ map fst (reads s :: [(Integer, String)])
+
+elemToTblGrid :: NameSpaces -> Element -> TblGrid
+elemToTblGrid ns element
+ | qName (elName element) == "tblGrid" &&
+ qURI (elName element) == (lookup "w" ns) =
+ let
+ cols = findChildren (QName "gridCol" (lookup "w" ns) (Just "w")) element
+ in
+ mapMaybe (\e ->
+ findAttr (QName "val" (lookup "w" ns) (Just ("w"))) e
+ >>= stringToInteger
+ )
+ cols
+elemToTblGrid _ _ = []
+
+data Row = Row [Cell]
+ deriving Show
+
+
+elemToRow :: NameSpaces -> Element -> Maybe Row
+elemToRow ns element
+ | qName (elName element) == "tr" &&
+ qURI (elName element) == (lookup "w" ns) =
+ let
+ cells = findChildren (QName "tc" (lookup "w" ns) (Just "w")) element
+ in
+ Just $ Row (mapMaybe (elemToCell ns) cells)
+elemToRow _ _ = Nothing
+
+data Cell = Cell [BodyPart]
+ deriving Show
+
+elemToCell :: NameSpaces -> Element -> Maybe Cell
+elemToCell ns element
+ | qName (elName element) == "tc" &&
+ qURI (elName element) == (lookup "w" ns) =
+ Just $ Cell (mapMaybe (elemToBodyPart ns) (elChildren element))
+elemToCell _ _ = Nothing
+
+data ParPart = PlainRun Run
+ | Insertion ChangeId Author ChangeDate [Run]
+ | Deletion ChangeId Author ChangeDate [Run]
+ | BookMark BookMarkId Anchor
+ | InternalHyperLink Anchor [Run]
+ | ExternalHyperLink RelId [Run]
+ | Drawing String
+ deriving Show
+
+data Run = Run RunStyle [RunElem]
+ | Footnote String
+ | Endnote String
+ deriving Show
+
+data RunElem = TextRun String | LnBrk | Tab
+ deriving Show
+
+data RunStyle = RunStyle { isBold :: Bool
+ , isItalic :: Bool
+ , isSmallCaps :: Bool
+ , isStrike :: Bool
+ , isSuperScript :: Bool
+ , isSubScript :: Bool
+ , underline :: Maybe String
+ , rStyle :: Maybe String }
+ deriving Show
+
+defaultRunStyle :: RunStyle
+defaultRunStyle = RunStyle { isBold = False
+ , isItalic = False
+ , isSmallCaps = False
+ , isStrike = False
+ , isSuperScript = False
+ , isSubScript = False
+ , underline = Nothing
+ , rStyle = Nothing
+ }
+
+elemToRunStyle :: NameSpaces -> Element -> RunStyle
+elemToRunStyle ns element =
+ case findChild (QName "rPr" (lookup "w" ns) (Just "w")) element of
+ Just rPr ->
+ RunStyle
+ {
+ isBold = isJust $ findChild (QName "b" (lookup "w" ns) (Just "w")) rPr
+ , isItalic = isJust $ findChild (QName "i" (lookup "w" ns) (Just "w")) rPr
+ , isSmallCaps = isJust $ findChild (QName "smallCaps" (lookup "w" ns) (Just "w")) rPr
+ , isStrike = isJust $ findChild (QName "strike" (lookup "w" ns) (Just "w")) rPr
+ , isSuperScript =
+ (Just "superscript" ==
+ (findChild (QName "vertAlign" (lookup "w" ns) (Just "w")) rPr >>=
+ findAttr (QName "val" (lookup "w" ns) (Just "w"))))
+ , isSubScript =
+ (Just "subscript" ==
+ (findChild (QName "vertAlign" (lookup "w" ns) (Just "w")) rPr >>=
+ findAttr (QName "val" (lookup "w" ns) (Just "w"))))
+ , underline =
+ findChild (QName "u" (lookup "w" ns) (Just "w")) rPr >>=
+ findAttr (QName "val" (lookup "w" ns) (Just "w"))
+ , rStyle =
+ findChild (QName "rStyle" (lookup "w" ns) (Just "w")) rPr >>=
+ findAttr (QName "val" (lookup "w" ns) (Just "w"))
+ }
+ Nothing -> defaultRunStyle
+
+elemToRun :: NameSpaces -> Element -> Maybe Run
+elemToRun ns element
+ | qName (elName element) == "r" &&
+ qURI (elName element) == (lookup "w" ns) =
+ case
+ findChild (QName "footnoteReference" (lookup "w" ns) (Just "w")) element >>=
+ findAttr (QName "id" (lookup "w" ns) (Just "w"))
+ of
+ Just s -> Just $ Footnote s
+ Nothing ->
+ case
+ findChild (QName "endnoteReference" (lookup "w" ns) (Just "w")) element >>=
+ findAttr (QName "id" (lookup "w" ns) (Just "w"))
+ of
+ Just s -> Just $ Endnote s
+ Nothing -> Just $
+ Run (elemToRunStyle ns element)
+ (elemToRunElems ns element)
+elemToRun _ _ = Nothing
+
+elemToRunElem :: NameSpaces -> Element -> Maybe RunElem
+elemToRunElem ns element
+ | (qName (elName element) == "t" || qName (elName element) == "delText") &&
+ qURI (elName element) == (lookup "w" ns) =
+ Just $ TextRun (strContent element)
+ | qName (elName element) == "br" &&
+ qURI (elName element) == (lookup "w" ns) =
+ Just $ LnBrk
+ | qName (elName element) == "tab" &&
+ qURI (elName element) == (lookup "w" ns) =
+ Just $ Tab
+ | otherwise = Nothing
+
+
+elemToRunElems :: NameSpaces -> Element -> [RunElem]
+elemToRunElems ns element
+ | qName (elName element) == "r" &&
+ qURI (elName element) == (lookup "w" ns) =
+ mapMaybe (elemToRunElem ns) (elChildren element)
+ | otherwise = []
+
+elemToDrawing :: NameSpaces -> Element -> Maybe ParPart
+elemToDrawing ns element
+ | qName (elName element) == "drawing" &&
+ qURI (elName element) == (lookup "w" ns) =
+ let a_ns = "http://schemas.openxmlformats.org/drawingml/2006/main"
+ in
+ findElement (QName "blip" (Just a_ns) (Just "a")) element
+ >>= findAttr (QName "embed" (lookup "r" ns) (Just "r"))
+ >>= (\s -> Just $ Drawing s)
+elemToDrawing _ _ = Nothing
+
+
+elemToParPart :: NameSpaces -> Element -> Maybe ParPart
+elemToParPart ns element
+ | qName (elName element) == "r" &&
+ qURI (elName element) == (lookup "w" ns) =
+ case findChild (QName "drawing" (lookup "w" ns) (Just "w")) element of
+ Just drawingElem -> elemToDrawing ns drawingElem
+ Nothing -> do
+ r <- elemToRun ns element
+ return $ PlainRun r
+elemToParPart ns element
+ | qName (elName element) == "ins" &&
+ qURI (elName element) == (lookup "w" ns) = do
+ cId <- findAttr (QName "id" (lookup "w" ns) (Just "w")) element
+ cAuthor <- findAttr (QName "author" (lookup "w" ns) (Just "w")) element
+ cDate <- findAttr (QName "date" (lookup "w" ns) (Just "w")) element
+ let runs = mapMaybe (elemToRun ns) (elChildren element)
+ return $ Insertion cId cAuthor cDate runs
+elemToParPart ns element
+ | qName (elName element) == "del" &&
+ qURI (elName element) == (lookup "w" ns) = do
+ cId <- findAttr (QName "id" (lookup "w" ns) (Just "w")) element
+ cAuthor <- findAttr (QName "author" (lookup "w" ns) (Just "w")) element
+ cDate <- findAttr (QName "date" (lookup "w" ns) (Just "w")) element
+ let runs = mapMaybe (elemToRun ns) (elChildren element)
+ return $ Deletion cId cAuthor cDate runs
+elemToParPart ns element
+ | qName (elName element) == "bookmarkStart" &&
+ qURI (elName element) == (lookup "w" ns) = do
+ bmId <- findAttr (QName "id" (lookup "w" ns) (Just "w")) element
+ bmName <- findAttr (QName "name" (lookup "w" ns) (Just "w")) element
+ return $ BookMark bmId bmName
+elemToParPart ns element
+ | qName (elName element) == "hyperlink" &&
+ qURI (elName element) == (lookup "w" ns) =
+ let runs = mapMaybe (elemToRun ns)
+ $ findChildren (QName "r" (lookup "w" ns) (Just "w")) element
+ in
+ case findAttr (QName "anchor" (lookup "w" ns) (Just "w")) element of
+ Just anchor ->
+ Just $ InternalHyperLink anchor runs
+ Nothing ->
+ case findAttr (QName "id" (lookup "r" ns) (Just "r")) element of
+ Just relId -> Just $ ExternalHyperLink relId runs
+ Nothing -> Nothing
+elemToParPart _ _ = Nothing
+
+type Target = String
+type Anchor = String
+type BookMarkId = String
+type RelId = String
+type ChangeId = String
+type Author = String
+type ChangeDate = String
diff --git a/src/Text/Pandoc/Readers/Docx/Reducible.hs b/src/Text/Pandoc/Readers/Docx/Reducible.hs
new file mode 100644
index 000000000..8c105d1f1
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Docx/Reducible.hs
@@ -0,0 +1,181 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+{-
+Copyright (C) 2014 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.Reducible
+ Copyright : Copyright (C) 2014 Jesse Rosenthal
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>
+ Stability : alpha
+ Portability : portable
+
+Typeclass for combining adjacent blocks and inlines correctly.
+-}
+
+
+module Text.Pandoc.Readers.Docx.Reducible ((<++>),
+ (<+++>),
+ Reducible,
+ Container(..),
+ container,
+ innards,
+ reduceList,
+ reduceListB,
+ rebuild)
+ where
+
+import Text.Pandoc.Builder
+import Data.List ((\\), intersect)
+
+data Container a = Container ([a] -> a) | NullContainer
+
+instance (Eq a) => Eq (Container a) where
+ (Container x) == (Container y) = ((x []) == (y []))
+ NullContainer == NullContainer = True
+ _ == _ = False
+
+instance (Show a) => Show (Container a) where
+ show (Container x) = "Container {" ++
+ (reverse $ drop 3 $ reverse $ show $ x []) ++
+ "}"
+ show (NullContainer) = "NullContainer"
+
+class Reducible a where
+ (<++>) :: a -> a -> [a]
+ container :: a -> Container a
+ innards :: a -> [a]
+ isSpace :: a -> Bool
+
+(<+++>) :: (Reducible a) => Many a -> Many a -> Many a
+mr <+++> ms = fromList $ reduceList $ toList mr ++ toList ms
+
+reduceListB :: (Reducible a) => Many a -> Many a
+reduceListB = fromList . reduceList . toList
+
+reduceList' :: (Reducible a) => [a] -> [a] -> [a]
+reduceList' acc [] = acc
+reduceList' [] (x:xs) = reduceList' [x] xs
+reduceList' as (x:xs) = reduceList' (init as ++ (last as <++> x) ) xs
+
+reduceList :: (Reducible a) => [a] -> [a]
+reduceList = reduceList' []
+
+combineReducibles :: (Reducible a, Eq a) => a -> a -> [a]
+combineReducibles r s =
+ let (conts, rs) = topLevelContainers r
+ (conts', ss) = topLevelContainers s
+ shared = conts `intersect` conts'
+ remaining = conts \\ shared
+ remaining' = conts' \\ shared
+ in
+ case null shared of
+ True -> case (not . null) rs && isSpace (last rs) of
+ True -> rebuild conts (init rs) ++ [last rs, s]
+ False -> [r,s]
+ False -> rebuild
+ shared $
+ reduceList $
+ (rebuild remaining rs) ++ (rebuild remaining' ss)
+
+instance Reducible Inline where
+ s1@(Span (id1, classes1, kvs1) ils1) <++> s2@(Span (id2, classes2, kvs2) ils2) =
+ let classes' = classes1 `intersect` classes2
+ kvs' = kvs1 `intersect` kvs2
+ classes1' = classes1 \\ classes'
+ kvs1' = kvs1 \\ kvs'
+ classes2' = classes2 \\ classes'
+ kvs2' = kvs2 \\ kvs'
+ in
+ case null classes' && null kvs' of
+ True -> [s1,s2]
+ False -> let attr' = ("", classes', kvs')
+ attr1' = (id1, classes1', kvs1')
+ attr2' = (id2, classes2', kvs2')
+ s1' = case null classes1' && null kvs1' of
+ True -> ils1
+ False -> [Span attr1' ils1]
+ s2' = case null classes2' && null kvs2' of
+ True -> ils2
+ False -> [Span attr2' ils2]
+ in
+ [Span attr' $ reduceList $ s1' ++ s2']
+
+ (Str x) <++> (Str y) = [Str (x++y)]
+ il <++> il' = combineReducibles il il'
+
+ container (Emph _) = Container Emph
+ container (Strong _) = Container Strong
+ container (Strikeout _) = Container Strikeout
+ container (Subscript _) = Container Subscript
+ container (Superscript _) = Container Superscript
+ container (Quoted qt _) = Container $ Quoted qt
+ container (Cite cs _) = Container $ Cite cs
+ container (Span attr _) = Container $ Span attr
+ container _ = NullContainer
+
+ innards (Emph ils) = ils
+ innards (Strong ils) = ils
+ innards (Strikeout ils) = ils
+ innards (Subscript ils) = ils
+ innards (Superscript ils) = ils
+ innards (Quoted _ ils) = ils
+ innards (Cite _ ils) = ils
+ innards (Span _ ils) = ils
+ innards _ = []
+
+ isSpace Space = True
+ isSpace _ = False
+
+instance Reducible Block where
+ (Div (ident, classes, kvs) blks) <++> blk | "list-item" `elem` classes =
+ [Div (ident, classes, kvs) (reduceList blks), blk]
+
+ blk <++> blk' = combineReducibles blk blk'
+
+ container (BlockQuote _) = Container BlockQuote
+ container (Div attr _) = Container $ Div attr
+ container _ = NullContainer
+
+ innards (BlockQuote bs) = bs
+ innards (Div _ bs) = bs
+ innards _ = []
+
+ isSpace _ = False
+
+
+topLevelContainers' :: (Reducible a) => [a] -> ([Container a], [a])
+topLevelContainers' (r : []) = case container r of
+ NullContainer -> ([], [r])
+ _ ->
+ let (conts, inns) = topLevelContainers' (innards r)
+ in
+ ((container r) : conts, inns)
+topLevelContainers' rs = ([], rs)
+
+topLevelContainers :: (Reducible a) => a -> ([Container a], [a])
+topLevelContainers il = topLevelContainers' [il]
+
+rebuild :: [Container a] -> [a] -> [a]
+rebuild [] xs = xs
+rebuild ((Container f) : cs) xs = rebuild cs $ [f xs]
+rebuild (NullContainer : cs) xs = rebuild cs $ xs
+
+
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index f6657a4d1..552e8a251 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Readers.HTML
- Copyright : Copyright (C) 2006-2010 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -40,6 +40,7 @@ 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)
import Text.Pandoc.Shared
import Text.Pandoc.Options
import Text.Pandoc.Parsing
@@ -47,7 +48,10 @@ import Data.Maybe ( fromMaybe, isJust )
import Data.List ( intercalate )
import Data.Char ( isDigit )
import Control.Monad ( liftM, guard, when, mzero )
-import Control.Applicative ( (<$>), (<$) )
+import Control.Applicative ( (<$>), (<$), (<*) )
+import Data.Monoid
+import Text.Printf (printf)
+import Debug.Trace (trace)
isSpace :: Char -> Bool
isSpace ' ' = True
@@ -66,39 +70,56 @@ readHtml opts inp =
where tags = canonicalizeTags $
parseTagsOptions parseOptions{ optTagPosition = True } inp
parseDoc = do
- blocks <- (fixPlains False . concat) <$> manyTill block eof
+ blocks <- (fixPlains False) . mconcat <$> manyTill block eof
meta <- stateMeta <$> getState
- return $ Pandoc meta blocks
+ return $ Pandoc meta (B.toList blocks)
type TagParser = Parser [Tag String] ParserState
-pBody :: TagParser [Block]
+pBody :: TagParser Blocks
pBody = pInTags "body" block
-pHead :: TagParser [Block]
-pHead = pInTags "head" $ pTitle <|> ([] <$ pAnyTag)
- where pTitle = pInTags "title" inline >>= setTitle . normalizeSpaces
- setTitle t = [] <$ (updateState $ B.setMeta "title" (B.fromList t))
-
-block :: TagParser [Block]
-block = choice
+pHead :: TagParser Blocks
+pHead = pInTags "head" $ pTitle <|> pMetaTag <|> (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 $ B.setMeta name (B.text content)
+ return mempty
+
+block :: TagParser Blocks
+block = do
+ tr <- getOption readerTrace
+ pos <- getPosition
+ res <- choice
[ pPara
, pHeader
, pBlockQuote
, pCodeBlock
, pList
, pHrule
- , pSimpleTable
+ , pTable
, pHead
, pBody
, pPlain
+ , pDiv
, pRawHtmlBlock
]
+ when tr $ trace (printf "line %d: %s" (sourceLine pos)
+ (take 60 $ show $ B.toList res)) (return ())
+ return res
-pList :: TagParser [Block]
+
+pList :: TagParser Blocks
pList = pBulletList <|> pOrderedList <|> pDefinitionList
-pBulletList :: TagParser [Block]
+pBulletList :: TagParser Blocks
pBulletList = try $ do
pSatisfy (~== TagOpen "ul" [])
let nonItem = pSatisfy (\t ->
@@ -108,9 +129,9 @@ pBulletList = try $ do
-- treat it as a list item, though it's not valid xhtml...
skipMany nonItem
items <- manyTill (pInTags "li" block >>~ skipMany nonItem) (pCloses "ul")
- return [BulletList $ map (fixPlains True) items]
+ return $ B.bulletList $ map (fixPlains True) items
-pOrderedList :: TagParser [Block]
+pOrderedList :: TagParser Blocks
pOrderedList = try $ do
TagOpen _ attribs <- pSatisfy (~== TagOpen "ol" [])
let (start, style) = (sta', sty')
@@ -136,27 +157,27 @@ pOrderedList = try $ do
-- treat it as a list item, though it's not valid xhtml...
skipMany nonItem
items <- manyTill (pInTags "li" block >>~ skipMany nonItem) (pCloses "ol")
- return [OrderedList (start, style, DefaultDelim) $ map (fixPlains True) items]
+ return $ B.orderedListWith (start, style, DefaultDelim) $ map (fixPlains True) items
-pDefinitionList :: TagParser [Block]
+pDefinitionList :: TagParser Blocks
pDefinitionList = try $ do
pSatisfy (~== TagOpen "dl" [])
items <- manyTill pDefListItem (pCloses "dl")
- return [DefinitionList items]
+ return $ B.definitionList items
-pDefListItem :: TagParser ([Inline],[[Block]])
+pDefListItem :: TagParser (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 = intercalate [LineBreak] terms
+ let term = foldl1 (\x y -> x <> B.linebreak <> y) terms
return (term, map (fixPlains True) defs)
-fixPlains :: Bool -> [Block] -> [Block]
-fixPlains inList bs = if any isParaish bs
- then map plainToPara bs
+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
@@ -168,6 +189,7 @@ fixPlains inList bs = if any isParaish bs
isParaish _ = False
plainToPara (Plain xs) = Para xs
plainToPara x = x
+ bs' = B.toList bs
pRawTag :: TagParser String
pRawTag = do
@@ -177,13 +199,20 @@ pRawTag = do
then return []
else return $ renderTags' [tag]
-pRawHtmlBlock :: TagParser [Block]
+pDiv :: TagParser Blocks
+pDiv = try $ do
+ getOption readerParseRaw >>= guard
+ TagOpen _ attr <- lookAhead $ pSatisfy $ tagOpen (=="div") (const True)
+ contents <- pInTags "div" block
+ return $ B.divWith (mkAttr attr) contents
+
+pRawHtmlBlock :: TagParser Blocks
pRawHtmlBlock = do
raw <- pHtmlBlock "script" <|> pHtmlBlock "style" <|> pRawTag
parseRaw <- getOption readerParseRaw
if parseRaw && not (null raw)
- then return [RawBlock "html" raw]
- else return []
+ then return $ B.rawBlock "html" raw
+ else return mempty
pHtmlBlock :: String -> TagParser String
pHtmlBlock t = try $ do
@@ -191,70 +220,96 @@ pHtmlBlock t = try $ do
contents <- manyTill pAnyTag (pSatisfy (~== TagClose t))
return $ renderTags' $ [open] ++ contents ++ [TagClose t]
-pHeader :: TagParser [Block]
+pHeader :: TagParser 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")]
let level = read (drop 1 tagtype)
- contents <- liftM concat $ manyTill inline (pCloses tagtype <|> eof)
- let ident = maybe "" id $ lookup "id" attr
+ 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"]
return $ if bodyTitle
- then [] -- skip a representation of the title in the body
- else [Header level (ident, classes, keyvals) $
- normalizeSpaces contents]
+ then mempty -- skip a representation of the title in the body
+ else B.headerWith (ident, classes, keyvals) level contents
-pHrule :: TagParser [Block]
+pHrule :: TagParser Blocks
pHrule = do
pSelfClosing (=="hr") (const True)
- return [HorizontalRule]
+ return B.horizontalRule
-pSimpleTable :: TagParser [Block]
-pSimpleTable = try $ do
+pTable :: TagParser Blocks
+pTable = try $ do
TagOpen _ _ <- pSatisfy (~== TagOpen "table" [])
skipMany pBlank
- caption <- option [] $ pInTags "caption" inline >>~ skipMany pBlank
- skipMany $ (pInTags "col" block >> skipMany pBlank) <|>
- (pInTags "colgroup" block >> skipMany pBlank)
+ caption <- option mempty $ pInTags "caption" inline >>~ skipMany pBlank
+ -- TODO actually read these and take width information from them
+ widths' <- pColgroup <|> many pCol
head' <- option [] $ pOptInTag "thead" $ pInTags "tr" (pCell "th")
skipMany pBlank
rows <- pOptInTag "tbody"
$ many1 $ try $ skipMany pBlank >> pInTags "tr" (pCell "td")
skipMany pBlank
TagClose _ <- pSatisfy (~== TagClose "table")
- let cols = maximum $ map length rows
- let aligns = replicate cols AlignLeft
- let widths = replicate cols 0
- return [Table caption aligns widths head' rows]
+ let isSinglePlain x = case B.toList x of
+ [Plain _] -> True
+ _ -> False
+ let isSimple = all isSinglePlain $ concat (head':rows)
+ let cols = length $ if null head' then head rows else head'
+ -- fail if there are colspans or rowspans
+ guard $ all (\r -> length r == cols) 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 :: TagParser Double
+pCol = try $ do
+ TagOpen _ attribs <- pSatisfy (~== TagOpen "col" [])
+ skipMany pBlank
+ optional $ pSatisfy (~== TagClose "col")
+ skipMany pBlank
+ return $ case lookup "width" attribs of
+ Just x | not (null x) && last x == '%' ->
+ fromMaybe 0.0 $ safeRead ('0':'.':init x)
+ _ -> 0.0
+
+pColgroup :: TagParser [Double]
+pColgroup = try $ do
+ pSatisfy (~== TagOpen "colgroup" [])
+ skipMany pBlank
+ manyTill pCol (pCloses "colgroup" <|> eof) <* skipMany pBlank
-pCell :: String -> TagParser [TableCell]
+pCell :: String -> TagParser [Blocks]
pCell celltype = try $ do
skipMany pBlank
- res <- pInTags celltype pPlain
+ res <- pInTags celltype block
skipMany pBlank
return [res]
-pBlockQuote :: TagParser [Block]
+pBlockQuote :: TagParser Blocks
pBlockQuote = do
contents <- pInTags "blockquote" block
- return [BlockQuote $ fixPlains False contents]
+ return $ B.blockQuote $ fixPlains False contents
-pPlain :: TagParser [Block]
+pPlain :: TagParser Blocks
pPlain = do
- contents <- liftM (normalizeSpaces . concat) $ many1 inline
- if null contents
- then return []
- else return [Plain contents]
+ contents <- trimInlines . mconcat <$> many1 inline
+ if B.isNull contents
+ then return mempty
+ else return $ B.plain contents
-pPara :: TagParser [Block]
+pPara :: TagParser Blocks
pPara = do
- contents <- pInTags "p" inline
- return [Para $ normalizeSpaces contents]
+ contents <- trimInlines <$> pInTags "p" inline
+ return $ B.para contents
-pCodeBlock :: TagParser [Block]
+pCodeBlock :: TagParser Blocks
pCodeBlock = try $ do
TagOpen _ attr <- pSatisfy (~== TagOpen "pre" [])
contents <- manyTill pAnyTag (pCloses "pre" <|> eof)
@@ -267,13 +322,9 @@ pCodeBlock = try $ do
let result = case reverse result' of
'\n':_ -> init result'
_ -> result'
- let attribsId = fromMaybe "" $ lookup "id" attr
- let attribsClasses = words $ fromMaybe "" $ lookup "class" attr
- let attribsKV = filter (\(k,_) -> k /= "class" && k /= "id") attr
- let attribs = (attribsId, attribsClasses, attribsKV)
- return [CodeBlock attribs result]
+ return $ B.codeBlockWith (mkAttr attr) result
-inline :: TagParser [Inline]
+inline :: TagParser Inlines
inline = choice
[ pTagText
, pQ
@@ -286,6 +337,7 @@ inline = choice
, pLink
, pImage
, pCode
+ , pSpan
, pRawHtmlInline
]
@@ -312,7 +364,7 @@ pSelfClosing f g = do
optional $ pSatisfy (tagClose f)
return open
-pQ :: TagParser [Inline]
+pQ :: TagParser Inlines
pQ = do
quoteContext <- stateQuoteContext `fmap` getState
let quoteType = case quoteContext of
@@ -321,79 +373,84 @@ pQ = do
let innerQuoteContext = if quoteType == SingleQuote
then InSingleQuote
else InDoubleQuote
- withQuoteContext innerQuoteContext $ pInlinesInTags "q" (Quoted quoteType)
+ let constructor = case quoteType of
+ SingleQuote -> B.singleQuoted
+ DoubleQuote -> B.doubleQuoted
+ withQuoteContext innerQuoteContext $
+ pInlinesInTags "q" constructor
-pEmph :: TagParser [Inline]
-pEmph = pInlinesInTags "em" Emph <|> pInlinesInTags "i" Emph
+pEmph :: TagParser Inlines
+pEmph = pInlinesInTags "em" B.emph <|> pInlinesInTags "i" B.emph
-pStrong :: TagParser [Inline]
-pStrong = pInlinesInTags "strong" Strong <|> pInlinesInTags "b" Strong
+pStrong :: TagParser Inlines
+pStrong = pInlinesInTags "strong" B.strong <|> pInlinesInTags "b" B.strong
-pSuperscript :: TagParser [Inline]
-pSuperscript = pInlinesInTags "sup" Superscript
+pSuperscript :: TagParser Inlines
+pSuperscript = pInlinesInTags "sup" B.superscript
-pSubscript :: TagParser [Inline]
-pSubscript = pInlinesInTags "sub" Subscript
+pSubscript :: TagParser Inlines
+pSubscript = pInlinesInTags "sub" B.subscript
-pStrikeout :: TagParser [Inline]
+pStrikeout :: TagParser Inlines
pStrikeout = do
- pInlinesInTags "s" Strikeout <|>
- pInlinesInTags "strike" Strikeout <|>
- pInlinesInTags "del" Strikeout <|>
+ pInlinesInTags "s" B.strikeout <|>
+ pInlinesInTags "strike" B.strikeout <|>
+ pInlinesInTags "del" B.strikeout <|>
try (do pSatisfy (~== TagOpen "span" [("class","strikeout")])
- contents <- liftM concat $ manyTill inline (pCloses "span")
- return [Strikeout contents])
+ contents <- mconcat <$> manyTill inline (pCloses "span")
+ return $ B.strikeout contents)
-pLineBreak :: TagParser [Inline]
+pLineBreak :: TagParser Inlines
pLineBreak = do
pSelfClosing (=="br") (const True)
- return [LineBreak]
+ return B.linebreak
-pLink :: TagParser [Inline]
+pLink :: TagParser Inlines
pLink = try $ do
tag <- pSatisfy (tagOpenLit "a" (isJust . lookup "href"))
let url = fromAttrib "href" tag
let title = fromAttrib "title" tag
- lab <- liftM concat $ manyTill inline (pCloses "a")
- return [Link (normalizeSpaces lab) (escapeURI url, title)]
+ lab <- trimInlines . mconcat <$> manyTill inline (pCloses "a")
+ return $ B.link (escapeURI url) title lab
-pImage :: TagParser [Inline]
+pImage :: TagParser Inlines
pImage = do
tag <- pSelfClosing (=="img") (isJust . lookup "src")
let url = fromAttrib "src" tag
let title = fromAttrib "title" tag
let alt = fromAttrib "alt" tag
- return [Image (B.toList $ B.text alt) (escapeURI url, title)]
+ return $ B.image (escapeURI url) title (B.text alt)
-pCode :: TagParser [Inline]
+pCode :: TagParser Inlines
pCode = try $ do
(TagOpen open attr) <- pSatisfy $ tagOpen (`elem` ["code","tt"]) (const True)
result <- manyTill pAnyTag (pCloses open)
- let ident = fromMaybe "" $ lookup "id" attr
- let classes = words $ fromMaybe [] $ lookup "class" attr
- let rest = filter (\(x,_) -> x /= "id" && x /= "class") attr
- return [Code (ident,classes,rest)
- $ intercalate " " $ lines $ innerText result]
+ return $ B.codeWith (mkAttr attr) $ intercalate " " $ lines $ innerText result
-pRawHtmlInline :: TagParser [Inline]
+pSpan :: TagParser Inlines
+pSpan = try $ do
+ getOption readerParseRaw >>= guard
+ TagOpen _ attr <- lookAhead $ pSatisfy $ tagOpen (=="span") (const True)
+ contents <- pInTags "span" inline
+ return $ B.spanWith (mkAttr attr) contents
+
+pRawHtmlInline :: TagParser Inlines
pRawHtmlInline = do
result <- pSatisfy (tagComment (const True)) <|> pSatisfy isInlineTag
parseRaw <- getOption readerParseRaw
if parseRaw
- then return [RawInline "html" $ renderTags' [result]]
- else return []
+ then return $ B.rawInline "html" $ renderTags' [result]
+ else return mempty
-pInlinesInTags :: String -> ([Inline] -> Inline)
- -> TagParser [Inline]
-pInlinesInTags tagtype f = do
- contents <- pInTags tagtype inline
- return [f $ normalizeSpaces contents]
+pInlinesInTags :: String -> (Inlines -> Inlines)
+ -> TagParser Inlines
+pInlinesInTags tagtype f = extractSpaces f <$> pInTags tagtype inline
-pInTags :: String -> TagParser [a]
- -> TagParser [a]
+pInTags :: (Monoid a) => String -> TagParser a
+ -> TagParser a
pInTags tagtype parser = try $ do
pSatisfy (~== TagOpen tagtype [])
- liftM concat $ manyTill parser (pCloses tagtype <|> eof)
+ mconcat <$> manyTill parser (pCloses tagtype <|> eof)
pOptInTag :: String -> TagParser a
-> TagParser a
@@ -409,56 +466,65 @@ pCloses :: String -> TagParser ()
pCloses tagtype = try $ do
t <- lookAhead $ pSatisfy $ \tag -> isTagClose tag || isTagOpen tag
case t of
- (TagClose t') | t' == tagtype -> pAnyTag >> return ()
+ (TagClose t') | t' == tagtype -> pAnyTag >> return ()
(TagOpen t' _) | t' `closes` tagtype -> return ()
(TagClose "ul") | tagtype == "li" -> return ()
(TagClose "ol") | tagtype == "li" -> return ()
(TagClose "dl") | tagtype == "li" -> return ()
+ (TagClose "table") | tagtype == "td" -> return ()
+ (TagClose "table") | tagtype == "tr" -> return ()
_ -> mzero
-pTagText :: TagParser [Inline]
+pTagText :: TagParser Inlines
pTagText = try $ do
(TagText str) <- pSatisfy isTagText
st <- getState
case runParser (many pTagContents) st "text" str of
Left _ -> fail $ "Could not parse `" ++ str ++ "'"
- Right result -> return result
+ Right result -> return $ mconcat result
pBlank :: TagParser ()
pBlank = try $ do
(TagText str) <- pSatisfy isTagText
guard $ all isSpace str
-pTagContents :: Parser [Char] ParserState Inline
+pTagContents :: Parser [Char] ParserState Inlines
pTagContents =
- pStr <|> pSpace <|> smartPunctuation pTagContents <|> pSymbol <|> pBad
-
-pStr :: Parser [Char] ParserState Inline
+ B.displayMath <$> mathDisplay
+ <|> B.math <$> mathInline
+ <|> pStr
+ <|> pSpace
+ <|> smartPunctuation pTagContents
+ <|> pSymbol
+ <|> pBad
+
+pStr :: Parser [Char] ParserState Inlines
pStr = do
result <- many1 $ satisfy $ \c ->
not (isSpace c) && not (isSpecial c) && not (isBad c)
pos <- getPosition
updateState $ \s -> s{ stateLastStrPos = Just pos }
- return $ Str result
+ 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 :: Parser [Char] ParserState Inline
-pSymbol = satisfy isSpecial >>= return . Str . (:[])
+pSymbol :: Parser [Char] ParserState Inlines
+pSymbol = satisfy isSpecial >>= return . B.str . (:[])
isBad :: Char -> Bool
isBad c = c >= '\128' && c <= '\159' -- not allowed in HTML
-pBad :: Parser [Char] ParserState Inline
+pBad :: Parser [Char] ParserState Inlines
pBad = do
c <- satisfy isBad
let c' = case c of
@@ -490,10 +556,10 @@ pBad = do
'\158' -> '\382'
'\159' -> '\376'
_ -> '?'
- return $ Str [c']
+ return $ B.str [c']
-pSpace :: Parser [Char] ParserState Inline
-pSpace = many1 (satisfy isSpace) >> return Space
+pSpace :: Parser [Char] ParserState Inlines
+pSpace = many1 (satisfy isSpace) >> return B.space
--
-- Constants
@@ -521,7 +587,7 @@ blockHtmlTags = ["address", "article", "aside", "blockquote", "body", "button",
"noframes", "noscript", "object", "ol", "output", "p", "pre", "progress",
"section", "table", "tbody", "textarea", "thead", "tfoot", "ul", "dd",
"dt", "frameset", "li", "tbody", "td", "tfoot",
- "th", "thead", "tr", "script", "style", "video"]
+ "th", "thead", "tr", "script", "style", "svg", "video"]
-- We want to allow raw docbook in markdown documents, so we
-- include docbook block tags here too.
@@ -543,15 +609,19 @@ blockTags :: [String]
blockTags = blockHtmlTags ++ blockDocBookTags
isInlineTag :: Tag String -> Bool
-isInlineTag t = tagOpen (`notElem` blockTags) (const True) t ||
- tagClose (`notElem` blockTags) t ||
+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 (`elem` blocktags) (const True) t ||
- tagClose (`elem` blocktags) t ||
+isBlockTag t = tagOpen isBlockTagName (const True) t ||
+ tagClose isBlockTagName t ||
tagComment (const True) t
- where blocktags = blockTags ++ eitherBlockOrInline
+ where isBlockTagName ('?':_) = True
+ isBlockTagName ('!':_) = True
+ isBlockTagName x = x `elem` blockTags
+ || x `elem` eitherBlockOrInline
isTextTag :: Tag String -> Bool
isTextTag = tagText (const True)
@@ -560,7 +630,7 @@ 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
@@ -568,11 +638,18 @@ _ `closes` "html" = False
"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
-"hr" `closes` "p" = True
-"p" `closes` "p" = 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
-"colgroup" `closes` "colgroup" = True
"form" `closes` "form" = True
"label" `closes` "label" = True
"map" `closes` "map" = True
@@ -620,3 +697,11 @@ htmlTag f = try $ do
_ -> do
rendered <- manyTill anyChar (char '>')
return (next, rendered ++ ">")
+
+mkAttr :: [(String, String)] -> Attr
+mkAttr attr = (attribsId, attribsClasses, attribsKV)
+ where attribsId = fromMaybe "" $ lookup "id" attr
+ attribsClasses = words $ fromMaybe "" $ lookup "class" attr
+ attribsKV = filter (\(k,_) -> k /= "class" && k /= "id") attr
+
+
diff --git a/src/Text/Pandoc/Readers/Haddock.hs b/src/Text/Pandoc/Readers/Haddock.hs
index 0e74406ef..4b46c869d 100644
--- a/src/Text/Pandoc/Readers/Haddock.hs
+++ b/src/Text/Pandoc/Readers/Haddock.hs
@@ -3,7 +3,8 @@
Copyright : Copyright (C) 2013 David Lazar
License : GNU GPL, version 2 or above
- Maintainer : David Lazar <lazar6@illinois.edu>
+ Maintainer : David Lazar <lazar6@illinois.edu>,
+ John MacFarlane <jgm@berkeley.edu>
Stability : alpha
Conversion of Haddock markup to 'Pandoc' document.
@@ -12,30 +13,126 @@ module Text.Pandoc.Readers.Haddock
( readHaddock
) where
-import Text.Pandoc.Builder
+import Text.Pandoc.Builder (Blocks, Inlines)
+import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.Shared (trim, splitBy)
+import Data.Monoid
+import Data.List (intersperse, stripPrefix)
+import Data.Maybe (fromMaybe)
+import Text.Pandoc.Definition
import Text.Pandoc.Options
-import Text.Pandoc.Readers.Haddock.Lex
-import Text.Pandoc.Readers.Haddock.Parse
+import Documentation.Haddock.Parser
+import Documentation.Haddock.Types
+import Debug.Trace (trace)
-- | Parse Haddock markup and return a 'Pandoc' document.
readHaddock :: ReaderOptions -- ^ Reader options
-> String -- ^ String to parse
-> Pandoc
-readHaddock _ s = Pandoc nullMeta blocks
+readHaddock opts = B.doc . docHToBlocks . trace' . parseParas
+ where trace' x = if readerTrace opts
+ then trace (show x) x
+ else x
+
+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
+ 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)
+ 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
- blocks = case parseParas (tokenise s (0,0)) of
- Left [] -> error "parse failure"
- Left (tok:_) -> error $ "parse failure " ++ pos (tokenPos tok)
- where pos (l, c) = "(line " ++ show l ++ ", column " ++ show c ++ ")"
- Right x -> mergeLists (toList x)
-
--- similar to 'docAppend' in Haddock.Doc
-mergeLists :: [Block] -> [Block]
-mergeLists (BulletList xs : BulletList ys : blocks)
- = mergeLists (BulletList (xs ++ ys) : blocks)
-mergeLists (OrderedList _ xs : OrderedList a ys : blocks)
- = mergeLists (OrderedList a (xs ++ ys) : blocks)
-mergeLists (DefinitionList xs : DefinitionList ys : blocks)
- = mergeLists (DefinitionList (xs ++ ys) : blocks)
-mergeLists (x : blocks) = x : mergeLists blocks
-mergeLists [] = []
+ -- 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/Haddock/Lex.x b/src/Text/Pandoc/Readers/Haddock/Lex.x
deleted file mode 100644
index 120e96ebf..000000000
--- a/src/Text/Pandoc/Readers/Haddock/Lex.x
+++ /dev/null
@@ -1,171 +0,0 @@
---
--- Haddock - A Haskell Documentation Tool
---
--- (c) Simon Marlow 2002
---
--- This file was modified and integrated into GHC by David Waern 2006.
--- Then moved back into Haddock by Isaac Dupree in 2009 :-)
--- Then copied into Pandoc by David Lazar in 2013 :-D
-
-{
-{-# LANGUAGE BangPatterns #-} -- Generated by Alex
-{-# OPTIONS -Wwarn -w #-}
--- The above warning supression flag is a temporary kludge.
--- While working on this module you are encouraged to remove it and fix
--- any warnings in the module. See
--- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
--- for details
-
-module Text.Pandoc.Readers.Haddock.Lex (
- Token(..),
- LToken,
- tokenise,
- tokenPos
- ) where
-
-import Data.Char
-import Numeric (readHex)
-}
-
-%wrapper "posn"
-
-$ws = $white # \n
-$digit = [0-9]
-$hexdigit = [0-9a-fA-F]
-$special = [\"\@]
-$alphanum = [A-Za-z0-9]
-$ident = [$alphanum \'\_\.\!\#\$\%\&\*\+\/\<\=\>\?\@\\\\\^\|\-\~\:]
-
-:-
-
--- beginning of a paragraph
-<0,para> {
- $ws* \n ;
- $ws* \> { begin birdtrack }
- $ws* prop \> .* \n { strtoken TokProperty `andBegin` property}
- $ws* \>\>\> { strtoken TokExamplePrompt `andBegin` exampleexpr }
- $ws* [\*\-] { token TokBullet `andBegin` string }
- $ws* \[ { token TokDefStart `andBegin` def }
- $ws* \( $digit+ \) { token TokNumber `andBegin` string }
- $ws* $digit+ \. { token TokNumber `andBegin` string }
- $ws* { begin string }
-}
-
--- beginning of a line
-<line> {
- $ws* \> { begin birdtrack }
- $ws* \>\>\> { strtoken TokExamplePrompt `andBegin` exampleexpr }
-
- $ws* \n { token TokPara `andBegin` para }
- -- ^ Here, we really want to be able to say
- -- $ws* (\n | <eof>) { token TokPara `andBegin` para}
- -- because otherwise a trailing line of whitespace will result in
- -- a spurious TokString at the end of a docstring. We don't have <eof>,
- -- though (NOW I realise what it was for :-). To get around this, we always
- -- append \n to the end of a docstring.
-
- () { begin string }
-}
-
-<birdtrack> .* \n? { strtokenNL TokBirdTrack `andBegin` line }
-
-<property> () { token TokPara `andBegin` para }
-
-<example> {
- $ws* \n { token TokPara `andBegin` para }
- $ws* \>\>\> { strtoken TokExamplePrompt `andBegin` exampleexpr }
- () { begin exampleresult }
-}
-
-<exampleexpr> .* \n { strtokenNL TokExampleExpression `andBegin` example }
-
-<exampleresult> .* \n { strtokenNL TokExampleResult `andBegin` example }
-
-<string,def> {
- $special { strtoken $ \s -> TokSpecial (head s) }
- \<\< [^\>]* \>\> { strtoken $ \s -> TokPic (init $ init $ tail $ tail s) }
- \< [^\>]* \> { strtoken $ \s -> TokURL (init (tail s)) }
- \# [^\#]* \# { strtoken $ \s -> TokAName (init (tail s)) }
- \/ [^\/]* \/ { strtoken $ \s -> TokEmphasis (init (tail s)) }
- [\'\`] $ident+ [\'\`] { strtoken $ \s -> TokIdent (init (tail s)) }
- \\ . { strtoken (TokString . tail) }
- "&#" $digit+ \; { strtoken $ \s -> TokString [chr (read (init (drop 2 s)))] }
- "&#" [xX] $hexdigit+ \;
- { strtoken $ \s -> case readHex (init (drop 3 s)) of [(n,_)] -> TokString [chr n] }
- -- allow special characters through if they don't fit one of the previous
- -- patterns.
- [\/\'\`\<\#\&\\] { strtoken TokString }
- [^ $special \/ \< \# \n \'\` \& \\ \]]* \n { strtokenNL TokString `andBegin` line }
- [^ $special \/ \< \# \n \'\` \& \\ \]]+ { strtoken TokString }
-}
-
-<def> {
- \] { token TokDefEnd `andBegin` string }
-}
-
--- ']' doesn't have any special meaning outside of the [...] at the beginning
--- of a definition paragraph.
-<string> {
- \] { strtoken TokString }
-}
-
-{
--- | A located token
-type LToken = (Token, AlexPosn)
-
-data Token
- = TokPara
- | TokNumber
- | TokBullet
- | TokDefStart
- | TokDefEnd
- | TokSpecial Char
- | TokIdent String
- | TokString String
- | TokURL String
- | TokPic String
- | TokEmphasis String
- | TokAName String
- | TokBirdTrack String
- | TokProperty String
- | TokExamplePrompt String
- | TokExampleExpression String
- | TokExampleResult String
- deriving Show
-
-tokenPos :: LToken -> (Int, Int)
-tokenPos t = let AlexPn _ line col = snd t in (line, col)
-
-type StartCode = Int
-type Action = AlexPosn -> String -> StartCode -> (StartCode -> [LToken]) -> [LToken]
-
-tokenise :: String -> (Int, Int) -> [LToken]
-tokenise str (line, col) = go (posn,'\n',[],eofHack str) para
- where posn = AlexPn 0 line col
- go inp@(pos,_,_,str) sc =
- case alexScan inp sc of
- AlexEOF -> []
- AlexError _ -> []
- AlexSkip inp' len -> go inp' sc
- AlexToken inp' len act -> act pos (take len str) sc (\sc -> go inp' sc)
-
--- NB. we add a final \n to the string, (see comment in the beginning of line
--- production above).
-eofHack str = str++"\n"
-
-andBegin :: Action -> StartCode -> Action
-andBegin act new_sc = \pos str _ cont -> act pos str new_sc cont
-
-token :: Token -> Action
-token t = \pos _ sc cont -> (t, pos) : cont sc
-
-strtoken, strtokenNL :: (String -> Token) -> Action
-strtoken t = \pos str sc cont -> (t str, pos) : cont sc
-strtokenNL t = \pos str sc cont -> (t (filter (/= '\r') str), pos) : cont sc
--- ^ We only want LF line endings in our internal doc string format, so we
--- filter out all CRs.
-
-begin :: StartCode -> Action
-begin sc = \_ _ _ cont -> cont sc
-
-}
diff --git a/src/Text/Pandoc/Readers/Haddock/Parse.y b/src/Text/Pandoc/Readers/Haddock/Parse.y
deleted file mode 100644
index 9c2bbc8a9..000000000
--- a/src/Text/Pandoc/Readers/Haddock/Parse.y
+++ /dev/null
@@ -1,178 +0,0 @@
--- This code was copied from the 'haddock' package, modified, and integrated
--- into Pandoc by David Lazar.
-{
-{-# LANGUAGE BangPatterns #-} -- required for versions of Happy before 1.18.6
--- The above warning supression flag is a temporary kludge.
--- While working on this module you are encouraged to remove it and fix
--- any warnings in the module. See
--- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
--- for details
-
-module Text.Pandoc.Readers.Haddock.Parse (parseString, parseParas) where
-
-import Text.Pandoc.Readers.Haddock.Lex
-import Text.Pandoc.Builder
-import Text.Pandoc.Shared (trim, trimr)
-import Data.Generics (everywhere, mkT)
-import Data.Char (isSpace)
-import Data.Maybe (fromMaybe)
-import Data.List (stripPrefix, intersperse)
-import Data.Monoid (mempty, mconcat)
-}
-
-%expect 0
-
-%tokentype { LToken }
-
-%token
- '/' { (TokSpecial '/',_) }
- '@' { (TokSpecial '@',_) }
- '[' { (TokDefStart,_) }
- ']' { (TokDefEnd,_) }
- DQUO { (TokSpecial '\"',_) }
- URL { (TokURL $$,_) }
- PIC { (TokPic $$,_) }
- ANAME { (TokAName $$,_) }
- '/../' { (TokEmphasis $$,_) }
- '-' { (TokBullet,_) }
- '(n)' { (TokNumber,_) }
- '>..' { (TokBirdTrack $$,_) }
- PROP { (TokProperty $$,_) }
- PROMPT { (TokExamplePrompt $$,_) }
- RESULT { (TokExampleResult $$,_) }
- EXP { (TokExampleExpression $$,_) }
- IDENT { (TokIdent $$,_) }
- PARA { (TokPara,_) }
- STRING { (TokString $$,_) }
-
-%monad { Either [LToken] }
-
-%name parseParas doc
-%name parseString seq
-
-%%
-
-doc :: { Blocks }
- : apara PARA doc { $1 <> $3 }
- | PARA doc { $2 }
- | apara { $1 }
- | {- empty -} { mempty }
-
-apara :: { Blocks }
- : ulpara { bulletList [$1] }
- | olpara { orderedList [$1] }
- | defpara { definitionList [$1] }
- | para { $1 }
-
-ulpara :: { Blocks }
- : '-' para { $2 }
-
-olpara :: { Blocks }
- : '(n)' para { $2 }
-
-defpara :: { (Inlines, [Blocks]) }
- : '[' seq ']' seq { (trimInlines $2, [plain $ trimInlines $4]) }
-
-para :: { Blocks }
- : seq { para' $1 }
- | codepara { codeBlockWith ([], ["haskell"], []) $1 }
- | property { $1 }
- | examples { $1 }
-
-codepara :: { String }
- : '>..' codepara { $1 ++ $2 }
- | '>..' { $1 }
-
-property :: { Blocks }
- : PROP { makeProperty $1 }
-
-examples :: { Blocks }
- : example examples { $1 <> $2 }
- | example { $1 }
-
-example :: { Blocks }
- : PROMPT EXP result { makeExample $1 $2 (lines $3) }
- | PROMPT EXP { makeExample $1 $2 [] }
-
-result :: { String }
- : RESULT result { $1 ++ $2 }
- | RESULT { $1 }
-
-seq :: { Inlines }
- : elem seq { $1 <> $2 }
- | elem { $1 }
-
-elem :: { Inlines }
- : elem1 { $1 }
- | '@' seq1 '@' { monospace $2 }
-
-seq1 :: { Inlines }
- : PARA seq1 { linebreak <> $2 }
- | elem1 seq1 { $1 <> $2 }
- | elem1 { $1 }
-
-elem1 :: { Inlines }
- : STRING { text $1 }
- | '/../' { emph (str $1) }
- | URL { makeHyperlink $1 }
- | PIC { image $1 $1 mempty }
- | ANAME { mempty } -- TODO
- | IDENT { codeWith ([], ["haskell"], []) $1 }
- | DQUO strings DQUO { codeWith ([], ["haskell"], []) $2 }
-
-strings :: { String }
- : STRING { $1 }
- | STRING strings { $1 ++ $2 }
-
-{
-happyError :: [LToken] -> Either [LToken] a
-happyError toks = Left toks
-
-para' :: Inlines -> Blocks
-para' = para . trimInlines
-
-monospace :: Inlines -> Inlines
-monospace = everywhere (mkT go)
- where
- go (Str s) = Code nullAttr s
- go x = x
-
--- | Create a `Hyperlink` from given string.
---
--- A hyperlink consists of a URL and an optional label. The label is separated
--- from the url by one or more whitespace characters.
-makeHyperlink :: String -> Inlines
-makeHyperlink input = case break isSpace $ trim input of
- (url, "") -> link url url (str url)
- (url, lb) -> link url url (trimInlines $ text lb)
-
-makeProperty :: String -> Blocks
-makeProperty s = case trim s of
- 'p':'r':'o':'p':'>':xs ->
- codeBlockWith ([], ["property"], []) (dropWhile isSpace xs)
- xs ->
- error $ "makeProperty: invalid input " ++ show xs
-
--- | Create an 'Example', stripping superfluous characters as appropriate
-makeExample :: String -> String -> [String] -> Blocks
-makeExample prompt expression result =
- para $ codeWith ([], ["haskell","expr"], []) (trim expression)
- <> linebreak
- <> (mconcat $ intersperse linebreak $ map coder result')
- where
- -- 1. drop trailing whitespace from the prompt, remember the prefix
- prefix = takeWhile isSpace 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 = codeWith ([], ["result"], [])
-}
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 1a22f2ad2..97bfaa455 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1,6 +1,6 @@
-{-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE ScopedTypeVariables, OverloadedStrings #-}
{-
-Copyright (C) 2006-2012 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Readers.LaTeX
- Copyright : Copyright (C) 2006-2012 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -31,22 +31,26 @@ Conversion of LaTeX to 'Pandoc' document.
module Text.Pandoc.Readers.LaTeX ( readLaTeX,
rawLaTeXInline,
rawLaTeXBlock,
+ inlineCommand,
handleIncludes
) where
import Text.Pandoc.Definition
-import Text.Pandoc.Generic
+import Text.Pandoc.Walk
import Text.Pandoc.Shared
import Text.Pandoc.Options
-import Text.Pandoc.Biblio (processBiblio)
-import Text.Pandoc.Parsing hiding ((<|>), many, optional, space)
+import Text.Pandoc.Parsing hiding ((<|>), many, optional, space,
+ mathDisplay, mathInline)
+import Text.Parsec.Prim (ParsecT, runParserT)
import qualified Text.Pandoc.UTF8 as UTF8
import Data.Char ( chr, ord )
+import Control.Monad.Trans (lift)
import Control.Monad
import Text.Pandoc.Builder
-import Data.Char (isLetter, isPunctuation, isSpace)
+import Data.Char (isLetter, isAlphaNum)
import Control.Applicative
import Data.Monoid
+import Data.Maybe (fromMaybe)
import System.Environment (getEnv)
import System.FilePath (replaceExtension, (</>))
import Data.List (intercalate, intersperse)
@@ -67,9 +71,7 @@ parseLaTeX = do
eof
st <- getState
let meta = stateMeta st
- refs <- getOption readerReferences
- mbsty <- getOption readerCitationStyle
- let (Pandoc _ bs') = processBiblio mbsty refs $ doc bs
+ let (Pandoc _ bs') = doc bs
return $ Pandoc meta bs'
type LP = Parser [Char] ParserState
@@ -124,7 +126,7 @@ comment :: LP ()
comment = do
char '%'
skipMany (satisfy (/='\n'))
- newline
+ optional newline
return ()
bgroup :: LP ()
@@ -165,28 +167,40 @@ mathChars = concat <$>
<|> (\c -> ['\\',c]) <$> (try $ char '\\' *> anyChar)
)
+quoted' :: (Inlines -> Inlines) -> LP String -> LP () -> LP Inlines
+quoted' f starter ender = do
+ startchs <- starter
+ try ((f . mconcat) <$> manyTill inline ender) <|> lit startchs
+
double_quote :: LP Inlines
-double_quote = (doubleQuoted . mconcat) <$>
- (try $ string "``" *> manyTill inline (try $ string "''"))
+double_quote =
+ ( 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 '"')
+ )
single_quote :: LP Inlines
-single_quote = (singleQuoted . mconcat) <$>
- (try $ char '`' *> manyTill inline (try $ char '\'' >> notFollowedBy letter))
+single_quote =
+ ( quoted' singleQuoted (string "`") (try $ char '\'' >> notFollowedBy letter)
+ <|> quoted' singleQuoted (string "‘") (try $ char '’' >> notFollowedBy letter)
+ )
inline :: LP Inlines
inline = (mempty <$ comment)
<|> (space <$ sp)
<|> inlineText
<|> inlineCommand
- <|> grouped inline
+ <|> inlineGroup
<|> (char '-' *> option (str "-")
((char '-') *> option (str "–") (str "—" <$ char '-')))
<|> double_quote
<|> single_quote
- <|> (str "“" <$ try (string "``")) -- nb. {``} won't be caught by double_quote
<|> (str "”" <$ try (string "''"))
- <|> (str "‘" <$ char '`') -- nb. {`} won't be caught by single_quote
+ <|> (str "”" <$ char '”')
<|> (str "’" <$ char '\'')
+ <|> (str "’" <$ char '’')
<|> (str "\160" <$ char '~')
<|> (mathDisplay $ string "$$" *> mathChars <* string "$$")
<|> (mathInline $ char '$' *> mathChars <* char '$')
@@ -201,6 +215,15 @@ inline = (mempty <$ comment)
inlines :: LP Inlines
inlines = mconcat <$> many (notFollowedBy (char '}') *> inline)
+inlineGroup :: LP 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 :: LP Blocks
block = (mempty <$ comment)
<|> (mempty <$ ((spaceChar <|> newline) *> spaces))
@@ -282,6 +305,13 @@ blockCommands = M.fromList $
, ("item", skipopts *> loose_item)
, ("documentclass", skipopts *> braced *> preamble)
, ("centerline", (para . trimInlines) <$> (skipopts *> tok))
+ , ("caption", skipopts *> tok >>= setCaption)
+ , ("PandocStartInclude", startInclude)
+ , ("PandocEndInclude", endInclude)
+ , ("bibliography", mempty <$ (skipopts *> braced >>=
+ addMeta "bibliography" . splitBibs))
+ , ("addbibresource", mempty <$ (skipopts *> braced >>=
+ addMeta "bibliography" . splitBibs))
] ++ map ignoreBlocks
-- these commands will be ignored unless --parse-raw is specified,
-- in which case they will appear as raw latex blocks
@@ -289,7 +319,7 @@ blockCommands = M.fromList $
-- 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"
- , "bibliography", "bibliographystyle"
+ , "bibliographystyle"
, "maketitle", "makeindex", "makeglossary"
, "addcontentsline", "addtocontents", "addtocounter"
-- \ignore{} is used conventionally in literate haskell for definitions
@@ -301,7 +331,19 @@ blockCommands = M.fromList $
]
addMeta :: ToMetaValue a => String -> a -> LP ()
-addMeta field val = updateState $ setMeta field val
+addMeta field val = updateState $ \st ->
+ st{ stateMeta = addMetaField field val $ stateMeta st }
+
+splitBibs :: String -> [Inlines]
+splitBibs = map (str . flip replaceExtension "bib" . trim) . splitBy (==',')
+
+setCaption :: Inlines -> LP Blocks
+setCaption ils = do
+ updateState $ \st -> st{ stateCaption = Just ils }
+ return mempty
+
+resetCaption :: LP ()
+resetCaption = updateState $ \st -> st{ stateCaption = Nothing }
authors :: LP ()
authors = try $ do
@@ -312,15 +354,17 @@ authors = try $ do
-- skip e.g. \vspace{10pt}
auths <- sepBy oneAuthor (controlSeq "and")
char '}'
- addMeta "authors" (map trimInlines auths)
+ addMeta "author" (map trimInlines auths)
section :: Attr -> Int -> LP Blocks
-section attr lvl = do
+section (ident, classes, kvs) lvl = do
hasChapters <- stateHasChapters `fmap` getState
let lvl' = if hasChapters then lvl + 1 else lvl
skipopts
contents <- grouped inline
- return $ headerWith attr lvl' contents
+ lab <- option ident $ try (spaces >> controlSeq "label" >> spaces >> braced)
+ attr' <- registerHeader (lab, classes, kvs) contents
+ return $ headerWith attr' lvl' contents
inlineCommand :: LP Inlines
inlineCommand = try $ do
@@ -353,17 +397,18 @@ isBlockCommand s = maybe False (const True) $ M.lookup s blockCommands
inlineCommands :: M.Map String (LP Inlines)
inlineCommands = M.fromList $
- [ ("emph", emph <$> tok)
- , ("textit", emph <$> tok)
- , ("textsl", emph <$> tok)
- , ("textsc", smallcaps <$> tok)
- , ("sout", strikeout <$> tok)
- , ("textsuperscript", superscript <$> tok)
- , ("textsubscript", subscript <$> tok)
+ [ ("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", strong <$> tok)
+ , ("textbf", extractSpaces strong <$> tok)
+ , ("textnormal", extractSpaces (spanWith ("",["nodecor"],[])) <$> tok)
, ("ldots", lit "…")
, ("dots", lit "…")
, ("mdots", lit "…")
@@ -383,15 +428,15 @@ inlineCommands = M.fromList $
, ("{", lit "{")
, ("}", lit "}")
-- old TeX commands
- , ("em", emph <$> inlines)
- , ("it", emph <$> inlines)
- , ("sl", emph <$> inlines)
- , ("bf", strong <$> inlines)
+ , ("em", extractSpaces emph <$> inlines)
+ , ("it", extractSpaces emph <$> inlines)
+ , ("sl", extractSpaces emph <$> inlines)
+ , ("bf", extractSpaces strong <$> inlines)
, ("rm", inlines)
- , ("itshape", emph <$> inlines)
- , ("slshape", emph <$> inlines)
- , ("scshape", smallcaps <$> inlines)
- , ("bfseries", strong <$> 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 "Å")
@@ -402,6 +447,8 @@ inlineCommands = M.fromList $
, ("l", lit "ł")
, ("ae", lit "æ")
, ("AE", lit "Æ")
+ , ("oe", lit "œ")
+ , ("OE", lit "Œ")
, ("pounds", lit "£")
, ("euro", lit "€")
, ("copyright", lit "©")
@@ -415,6 +462,8 @@ inlineCommands = M.fromList $
, (".", 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) *> optional sp))
, (",", pure mempty)
@@ -430,6 +479,7 @@ inlineCommands = M.fromList $
, ("footnote", (note . mconcat) <$> (char '{' *> manyTill block (char '}')))
, ("verb", doverb)
, ("lstinline", doverb)
+ , ("Verb", doverb)
, ("texttt", (code . stringify . toList) <$> tok)
, ("url", (unescapeURL <$> braced) >>= \url ->
pure (link url "" (str url)))
@@ -488,25 +538,21 @@ inlineCommands = M.fromList $
, ("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:
- [ "noindent", "index", "nocite" ]
+ [ "noindent", "index" ]
mkImage :: String -> LP Inlines
mkImage src = do
- -- try for a caption
- (alt, tit) <- option (str "image", "") $ try $ do
- spaces
- controlSeq "caption"
- optional (char '*')
- ils <- grouped inline
- return (ils, "fig:")
+ let alt = str "image"
case takeExtension src of
"" -> do
defaultExt <- getOption readerDefaultImageExtension
- return $ image (addExtension src defaultExt) tit alt
- _ -> return $ image src tit alt
+ return $ image (addExtension src defaultExt) "" alt
+ _ -> return $ image src "" alt
inNote :: Inlines -> Inlines
inNote ils =
@@ -514,9 +560,7 @@ inNote ils =
unescapeURL :: String -> String
unescapeURL ('\\':x:xs) | isEscapable x = x:unescapeURL xs
- where isEscapable '%' = True
- isEscapable '#' = True
- isEscapable _ = False
+ where isEscapable c = c `elem` "#$%&~_^\\{}"
unescapeURL (x:xs) = x:unescapeURL xs
unescapeURL [] = ""
@@ -539,137 +583,196 @@ doLHSverb = codeWith ("",["haskell"],[]) <$> manyTill (satisfy (/='\n')) (char '
lit :: String -> LP Inlines
lit = pure . str
-accent :: (Char -> Char) -> Inlines -> LP Inlines
+accent :: (Char -> String) -> Inlines -> LP Inlines
accent f ils =
case toList ils of
- (Str (x:xs) : ys) -> return $ fromList $ (Str (f x : xs) : ys)
+ (Str (x:xs) : ys) -> return $ fromList $ (Str (f x ++ xs) : ys)
[] -> mzero
_ -> return ils
-grave :: Char -> Char
-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 -> Char
-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 -> Char
-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 -> Char
-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 -> Char
-umlaut 'A' = 'Ä'
-umlaut 'E' = 'Ë'
-umlaut 'I' = 'Ï'
-umlaut 'O' = 'Ö'
-umlaut 'U' = 'Ü'
-umlaut 'a' = 'ä'
-umlaut 'e' = 'ë'
-umlaut 'i' = 'ï'
-umlaut 'o' = 'ö'
-umlaut 'u' = 'ü'
-umlaut c = c
-
-dot :: Char -> Char
-dot 'C' = 'Ċ'
-dot 'c' = 'ċ'
-dot 'E' = 'Ė'
-dot 'e' = 'ė'
-dot 'G' = 'Ġ'
-dot 'g' = 'ġ'
-dot 'I' = 'İ'
-dot 'Z' = 'Ż'
-dot 'z' = 'ż'
-dot c = c
-
-macron :: Char -> Char
-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 -> Char
-cedilla 'c' = 'ç'
-cedilla 'C' = 'Ç'
-cedilla 's' = 'ş'
-cedilla 'S' = 'Ş'
-cedilla c = c
+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]
+
+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 :: LP Inlines
tok = try $ grouped inline <|> inlineCommand <|> str <$> (count 1 $ inlineChar)
@@ -684,7 +787,7 @@ inlineText :: LP Inlines
inlineText = str <$> many1 inlineChar
inlineChar :: LP Char
-inlineChar = noneOf "\\$%^_&~#{}^'`-[] \t\n"
+inlineChar = noneOf "\\$%^_&~#{}^'`\"‘’“”-[] \t\n"
environment :: LP Blocks
environment = do
@@ -703,31 +806,107 @@ rawEnv name = do
(withRaw (env name blocks) >>= applyMacros' . snd)
else env name blocks
+----
+
+type IncludeParser = ParsecT [Char] [String] IO String
+
-- | Replace "include" commands with file contents.
handleIncludes :: String -> IO String
-handleIncludes = handleIncludes' []
-
--- parents parameter prevents infinite include loops
-handleIncludes' :: [FilePath] -> String -> IO String
-handleIncludes' _ [] = return []
-handleIncludes' parents ('\\':'%':xs) =
- ("\\%"++) `fmap` handleIncludes' parents xs
-handleIncludes' parents ('%':xs) = handleIncludes' parents
- $ drop 1 $ dropWhile (/='\n') xs
-handleIncludes' parents ('\\':xs) =
- case runParser include defaultParserState "input" ('\\':xs) of
- Right (fs, rest) -> do yss <- mapM (\f -> if f `elem` parents
- then "" <$ warn ("Include file loop in '"
- ++ f ++ "'.")
- else readTeXFile f >>=
- handleIncludes' (f:parents)) fs
- rest' <- handleIncludes' parents rest
- return $ intercalate "\n" yss ++ rest'
- _ -> case runParser (verbCmd <|> verbatimEnv) defaultParserState
- "input" ('\\':xs) of
- Right (r, rest) -> (r ++) `fmap` handleIncludes' parents rest
- _ -> ('\\':) `fmap` handleIncludes' parents xs
-handleIncludes' parents (x:xs) = (x:) `fmap` handleIncludes' parents xs
+handleIncludes s = do
+ res <- runParserT includeParser' [] "input" s
+ case res of
+ Right s' -> return s'
+ Left e -> error $ show e
+
+includeParser' :: IncludeParser
+includeParser' =
+ concat <$> many (comment' <|> escaped' <|> blob' <|> include'
+ <|> startMarker' <|> endMarker'
+ <|> verbCmd' <|> verbatimEnv' <|> backslash')
+
+comment' :: IncludeParser
+comment' = do
+ char '%'
+ xs <- manyTill anyChar newline
+ return ('%':xs ++ "\n")
+
+escaped' :: IncludeParser
+escaped' = try $ string "\\%" <|> string "\\\\"
+
+verbCmd' :: IncludeParser
+verbCmd' = fmap snd <$>
+ withRaw $ try $ do
+ string "\\verb"
+ c <- anyChar
+ manyTill anyChar (char c)
+
+verbatimEnv' :: IncludeParser
+verbatimEnv' = fmap snd <$>
+ withRaw $ try $ do
+ string "\\begin"
+ name <- braced'
+ guard $ name `elem` ["verbatim", "Verbatim", "lstlisting",
+ "minted", "alltt"]
+ manyTill anyChar (try $ string $ "\\end{" ++ name ++ "}")
+
+blob' :: IncludeParser
+blob' = try $ many1 (noneOf "\\%")
+
+backslash' :: IncludeParser
+backslash' = string "\\"
+
+braced' :: IncludeParser
+braced' = try $ char '{' *> manyTill (satisfy (/='}')) (char '}')
+
+include' :: IncludeParser
+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 (flip replaceExtension ".sty") fs
+ else map (flip replaceExtension ".tex") fs
+ pos <- getPosition
+ containers <- getState
+ let fn = case containers of
+ (f':_) -> f'
+ [] -> "input"
+ -- now process each include file in order...
+ rest <- getInput
+ results' <- forM fs' (\f -> do
+ when (f `elem` containers) $
+ fail "Include file loop!"
+ contents <- lift $ readTeXFile f
+ return $ "\\PandocStartInclude{" ++ f ++ "}" ++
+ contents ++ "\\PandocEndInclude{" ++
+ fn ++ "}{" ++ show (sourceLine pos) ++ "}{"
+ ++ show (sourceColumn pos) ++ "}")
+ setInput $ concat results' ++ rest
+ return ""
+
+startMarker' :: IncludeParser
+startMarker' = try $ do
+ string "\\PandocStartInclude"
+ fn <- braced'
+ updateState (fn:)
+ setPosition $ newPos fn 1 1
+ return $ "\\PandocStartInclude{" ++ fn ++ "}"
+
+endMarker' :: IncludeParser
+endMarker' = try $ do
+ string "\\PandocEndInclude"
+ fn <- braced'
+ ln <- braced'
+ co <- braced'
+ updateState tail
+ setPosition $ newPos fn (fromMaybe 1 $ safeRead ln) (fromMaybe 1 $ safeRead co)
+ return $ "\\PandocEndInclude{" ++ fn ++ "}{" ++ ln ++ "}{" ++
+ co ++ "}"
readTeXFile :: FilePath -> IO String
readTeXFile f = do
@@ -742,27 +921,7 @@ readFileFromDirs (d:ds) f =
E.catch (UTF8.readFile $ d </> f) $ \(_ :: E.SomeException) ->
readFileFromDirs ds f
-include :: LP ([FilePath], String)
-include = do
- name <- controlSeq "include"
- <|> controlSeq "input"
- <|> controlSeq "usepackage"
- skipopts
- fs <- (splitBy (==',')) <$> braced
- rest <- getInput
- let fs' = if name == "usepackage"
- then map (flip replaceExtension ".sty") fs
- else map (flip replaceExtension ".tex") fs
- return (fs', rest)
-
-verbCmd :: LP (String, String)
-verbCmd = do
- (_,r) <- withRaw $ do
- controlSeq "verb"
- c <- anyChar
- manyTill anyChar (char c)
- rest <- getInput
- return (r, rest)
+----
keyval :: LP (String, String)
keyval = try $ do
@@ -778,24 +937,12 @@ keyvals :: LP [(String, String)]
keyvals = try $ char '[' *> manyTill keyval (char ']')
alltt :: String -> LP Blocks
-alltt t = bottomUp strToCode <$> parseFromString blocks
+alltt t = walk strToCode <$> parseFromString blocks
(substitute " " "\\ " $ substitute "%" "\\%" $
concat $ intersperse "\\\\\n" $ lines t)
where strToCode (Str s) = Code nullAttr s
strToCode x = x
-verbatimEnv :: LP (String, String)
-verbatimEnv = do
- (_,r) <- withRaw $ do
- controlSeq "begin"
- name <- braced
- guard $ name == "verbatim" || name == "Verbatim" ||
- name == "lstlisting" || name == "minted" ||
- name == "alltt"
- verbEnv name
- rest <- getInput
- return (r,rest)
-
rawLaTeXBlock :: Parser [Char] ParserState String
rawLaTeXBlock = snd <$> try (withRaw (environment <|> blockCommand))
@@ -804,12 +951,33 @@ rawLaTeXInline = do
raw <- (snd <$> withRaw inlineCommand) <|> (snd <$> withRaw blockCommand)
RawInline "latex" <$> applyMacros' raw
+addImageCaption :: Blocks -> LP Blocks
+addImageCaption = walkM go
+ where go (Image alt (src,tit)) = do
+ mbcapt <- stateCaption <$> getState
+ case mbcapt of
+ Just ils -> return (Image (toList ils) (src, "fig:"))
+ Nothing -> return (Image alt (src,tit))
+ go x = return x
+
+addTableCaption :: Blocks -> LP Blocks
+addTableCaption = walkM go
+ where go (Table c als ws hs rs) = do
+ mbcapt <- stateCaption <$> getState
+ case mbcapt of
+ Just ils -> return (Table (toList ils) als ws hs rs)
+ Nothing -> return (Table c als ws hs rs)
+ go x = return x
+
environments :: M.Map String (LP Blocks)
environments = M.fromList
[ ("document", env "document" blocks <* skipMany anyChar)
, ("letter", env "letter" letter_contents)
- , ("figure", env "figure" $ skipopts *> blocks)
+ , ("figure", env "figure" $
+ resetCaption *> skipopts *> blocks >>= addImageCaption)
, ("center", env "center" blocks)
+ , ("table", env "table" $
+ resetCaption *> skipopts *> blocks >>= addTableCaption)
, ("tabular", env "tabular" simpTable)
, ("quote", blockQuote <$> env "quote" blocks)
, ("quotation", blockQuote <$> env "quotation" blocks)
@@ -838,7 +1006,7 @@ environments = M.fromList
lookup "numbers" options == Just "left" ]
++ maybe [] (:[]) (lookup "language" options
>>= fromListingsLanguage)
- let attr = ("",classes,kvs)
+ let attr = (fromMaybe "" (lookup "label" options),classes,kvs)
codeBlockWith attr <$> (verbEnv "lstlisting"))
, ("minted", do options <- option [] keyvals
lang <- grouped (many1 $ satisfy (/='}'))
@@ -966,15 +1134,15 @@ paragraph = do
preamble :: LP Blocks
preamble = mempty <$> manyTill preambleBlock beginDoc
- where beginDoc = lookAhead $ controlSeq "begin" *> string "{document}"
- preambleBlock = (mempty <$ comment)
- <|> (mempty <$ sp)
- <|> (mempty <$ blanklines)
- <|> (mempty <$ macro)
- <|> blockCommand
- <|> (mempty <$ anyControlSeq)
- <|> (mempty <$ braced)
- <|> (mempty <$ anyChar)
+ where beginDoc = lookAhead $ try $ controlSeq "begin" *> string "{document}"
+ preambleBlock = (void comment)
+ <|> (void sp)
+ <|> (void blanklines)
+ <|> (void macro)
+ <|> (void blockCommand)
+ <|> (void anyControlSeq)
+ <|> (void braced)
+ <|> (void anyChar)
-------
@@ -986,12 +1154,8 @@ addPrefix _ _ = []
addSuffix :: [Inline] -> [Citation] -> [Citation]
addSuffix s ks@(_:_) =
- let k = last ks
- s' = case s of
- (Str (c:_):_)
- | not (isPunctuation c || isSpace c) -> Str "," : Space : s
- _ -> s
- in init ks ++ [k {citationSuffix = citationSuffix k ++ s'}]
+ let k = last ks
+ in init ks ++ [k {citationSuffix = citationSuffix k ++ s}]
addSuffix _ _ = []
simpleCiteArgs :: LP [Citation]
@@ -999,6 +1163,7 @@ 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 )
@@ -1014,18 +1179,24 @@ simpleCiteArgs = try $ do
return $ addPrefix pre $ addSuffix suf $ map conv keys
citationLabel :: LP String
-citationLabel = trim <$>
- (many1 (satisfy $ \c -> c /=',' && c /='}') <* optional (char ',') <* optional sp)
+citationLabel = optional sp *>
+ (many1 (satisfy isBibtexKeyChar)
+ <* optional sp
+ <* optional (char ',')
+ <* optional sp)
+ where isBibtexKeyChar c = isAlphaNum c || c `elem` ".:;?!`'()/*@_+=-[]*"
cites :: CitationMode -> Bool -> LP [Citation]
cites mode multi = try $ do
cits <- if multi
then many1 simpleCiteArgs
else count 1 simpleCiteArgs
- let (c:cs) = concat cits
+ let cs = concat cits
return $ case mode of
- AuthorInText -> c {citationMode = mode} : cs
- _ -> map (\a -> a {citationMode = mode}) (c:cs)
+ AuthorInText -> case cs of
+ (c:rest) -> c {citationMode = mode} : rest
+ [] -> []
+ _ -> map (\a -> a {citationMode = mode}) cs
citation :: String -> CitationMode -> Bool -> LP Inlines
citation name mode multi = do
@@ -1057,12 +1228,14 @@ complexNatbibCitation mode = try $ do
parseAligns :: LP [Alignment]
parseAligns = try $ do
char '{'
- optional $ char '|'
+ let maybeBar = skipMany $ sp <|> () <$ char '|' <|> () <$ try (string "@{}")
+ maybeBar
let cAlign = AlignCenter <$ char 'c'
let lAlign = AlignLeft <$ char 'l'
let rAlign = AlignRight <$ char 'r'
- let alignChar = optional sp *> (cAlign <|> lAlign <|> rAlign)
- aligns' <- sepEndBy alignChar (optional $ char '|')
+ let parAlign = AlignLeft <$ (char 'p' >> braced)
+ let alignChar = cAlign <|> lAlign <|> rAlign <|> parAlign
+ aligns' <- sepEndBy alignChar maybeBar
spaces
char '}'
spaces
@@ -1082,10 +1255,14 @@ parseTableRow :: Int -- ^ number of columns
parseTableRow cols = try $ do
let tableCellInline = notFollowedBy (amp <|> lbreak) >> inline
let tableCell = (plain . trimInlines . mconcat) <$> many tableCellInline
- cells' <- sepBy tableCell amp
- guard $ length cells' == cols
+ cells' <- sepBy1 tableCell amp
+ 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'
+ return cells''
simpTable :: LP Blocks
simpTable = try $ do
@@ -1096,9 +1273,23 @@ simpTable = try $ do
header' <- option [] $ try (parseTableRow cols <* lbreak <* hline)
rows <- sepEndBy (parseTableRow cols) (lbreak <* optional hline)
spaces
+ skipMany (comment *> 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
+startInclude :: LP Blocks
+startInclude = do
+ fn <- braced
+ setPosition $ newPos fn 1 1
+ return mempty
+
+endInclude :: LP Blocks
+endInclude = do
+ fn <- braced
+ ln <- braced
+ co <- braced
+ setPosition $ newPos fn (fromMaybe 1 $ safeRead ln) (fromMaybe 1 $ safeRead co)
+ return mempty
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index a3500fbcf..690256224 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE RelaxedPolyRec #-} -- needed for inlinesBetween on GHC < 7
{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Readers.Markdown
- Copyright : Copyright (C) 2006-2013 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -33,6 +33,7 @@ module Text.Pandoc.Readers.Markdown ( readMarkdown,
import Data.List ( transpose, sortBy, findIndex, intersperse, intercalate )
import qualified Data.Map as M
+import Data.Scientific (coefficient, base10Exponent)
import Data.Ord ( comparing )
import Data.Char ( isAlphaNum, toLower )
import Data.Maybe
@@ -49,13 +50,10 @@ import Text.Pandoc.Builder (Inlines, Blocks, trimInlines, (<>))
import Text.Pandoc.Options
import Text.Pandoc.Shared
import Text.Pandoc.XML (fromEntities)
-import Text.Pandoc.Asciify (toAsciiChar)
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 Text.Pandoc.Biblio (processBiblio)
-import qualified Text.CSL as CSL
import Data.Monoid (mconcat, mempty)
import Control.Applicative ((<$>), (<*), (*>), (<$))
import Control.Monad
@@ -63,6 +61,8 @@ import System.FilePath (takeExtension, addExtension)
import Text.HTML.TagSoup
import Text.HTML.TagSoup.Match (tagOpen)
import qualified Data.Set as Set
+import Text.Printf (printf)
+import Debug.Trace (trace)
type MarkdownParser = Parser [Char] ParserState
@@ -203,13 +203,10 @@ dateLine = try $ do
skipSpaces
trimInlinesF . mconcat <$> manyTill inline newline
-titleBlock :: MarkdownParser (F (Pandoc -> Pandoc))
-titleBlock = pandocTitleBlock
- <|> yamlTitleBlock
- <|> mmdTitleBlock
- <|> return (return id)
+titleBlock :: MarkdownParser ()
+titleBlock = pandocTitleBlock <|> mmdTitleBlock
-pandocTitleBlock :: MarkdownParser (F (Pandoc -> Pandoc))
+pandocTitleBlock :: MarkdownParser ()
pandocTitleBlock = try $ do
guardEnabled Ext_pandoc_title_block
lookAhead (char '%')
@@ -217,49 +214,61 @@ pandocTitleBlock = try $ do
author <- option (return []) authorsLine
date <- option mempty dateLine
optional blanklines
- return $ do
- title' <- title
- author' <- author
- date' <- date
- return $ B.setMeta "title" title'
- . B.setMeta "author" author'
- . B.setMeta "date" date'
-
-yamlTitleBlock :: MarkdownParser (F (Pandoc -> Pandoc))
-yamlTitleBlock = try $ do
+ 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' }
+
+yamlMetaBlock :: MarkdownParser (F Blocks)
+yamlMetaBlock = try $ do
guardEnabled Ext_yaml_metadata_block
pos <- getPosition
string "---"
blankline
- rawYaml <- unlines <$> manyTill anyLine stopLine
+ 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
- case Yaml.decodeEither' $ UTF8.fromString rawYaml of
- Right (Yaml.Object hashmap) -> return $ return $
- H.foldrWithKey (\k v f ->
- if ignorable k
- then f
- else B.setMeta (T.unpack k) (yamlToMeta opts v) . f)
- id hashmap
- Right _ -> do
- addWarning (Just pos) "YAML header is not an object"
- return $ return id
- Left err' -> do
- case err' of
- InvalidYaml (Just YamlParseException{
- yamlProblem = problem
- , yamlContext = _ctxt
- , yamlProblemMark = Yaml.YamlMark {
- yamlLine = yline
- , yamlColumn = ycol
- }}) ->
- addWarning (Just $ setSourceLine
- (setSourceColumn pos (sourceColumn pos + ycol))
- (sourceLine pos + 1 + yline))
- $ "Could not parse YAML header: " ++ problem
- _ -> addWarning (Just pos)
- $ "Could not parse YAML header: " ++ show err'
- return $ return id
+ meta' <- case Yaml.decodeEither' $ UTF8.fromString rawYaml of
+ Right (Yaml.Object hashmap) -> return $ return $
+ H.foldrWithKey (\k v m ->
+ if ignorable k
+ then m
+ else B.setMeta (T.unpack k)
+ (yamlToMeta opts v) m)
+ nullMeta hashmap
+ Right Yaml.Null -> return $ return nullMeta
+ Right _ -> do
+ addWarning (Just pos) "YAML header is not an object"
+ return $ return nullMeta
+ Left err' -> do
+ case err' of
+ InvalidYaml (Just YamlParseException{
+ yamlProblem = problem
+ , yamlContext = _ctxt
+ , yamlProblemMark = Yaml.YamlMark {
+ yamlLine = yline
+ , yamlColumn = ycol
+ }}) ->
+ addWarning (Just $ setSourceLine
+ (setSourceColumn pos
+ (sourceColumn pos + ycol))
+ (sourceLine pos + 1 + yline))
+ $ "Could not parse YAML header: " ++
+ problem
+ _ -> addWarning (Just pos)
+ $ "Could not parse YAML header: " ++
+ show err'
+ return $ return nullMeta
+ updateState $ \st -> st{ stateMeta' = stateMeta' st <> meta' }
+ return mempty
-- ignore fields ending with _
ignorable :: Text -> Bool
@@ -277,8 +286,12 @@ toMetaValue opts x =
yamlToMeta :: ReaderOptions -> Yaml.Value -> MetaValue
yamlToMeta opts (Yaml.String t) = toMetaValue opts t
-yamlToMeta _ (Yaml.Number n) = MetaString $ show n
-yamlToMeta _ (Yaml.Bool b) = MetaString $ map toLower $ show b
+yamlToMeta _ (Yaml.Number n)
+ -- avoid decimal points for numbers that don't need them:
+ | base10Exponent n >= 0 = MetaString $ show
+ $ coefficient n * (10 ^ base10Exponent n)
+ | otherwise = MetaString $ show n
+yamlToMeta _ (Yaml.Bool b) = MetaBool b
yamlToMeta opts (Yaml.Array xs) = B.toMetaValue $ map (yamlToMeta opts)
$ V.toList xs
yamlToMeta opts (Yaml.Object o) = MetaMap $ H.foldrWithKey (\k v m ->
@@ -292,13 +305,13 @@ yamlToMeta _ _ = MetaString ""
stopLine :: MarkdownParser ()
stopLine = try $ (string "---" <|> string "...") >> blankline >> return ()
-mmdTitleBlock :: MarkdownParser (F (Pandoc -> Pandoc))
+mmdTitleBlock :: MarkdownParser ()
mmdTitleBlock = try $ do
guardEnabled Ext_mmd_title_block
kvPairs <- many1 kvPair
blanklines
- return $ return $ \(Pandoc m bs) ->
- Pandoc (foldl (\m' (k,v) -> addMetaField k v m') m kvPairs) bs
+ updateState $ \st -> st{ stateMeta' = stateMeta' st <>
+ return (Meta $ M.fromList kvPairs) }
kvPair :: MarkdownParser (String, MetaValue)
kvPair = try $ do
@@ -315,15 +328,12 @@ parseMarkdown = do
updateState $ \state -> state { stateOptions =
let oldOpts = stateOptions state in
oldOpts{ readerParseRaw = True } }
- titleTrans <- option (return id) titleBlock
+ optional titleBlock
blocks <- parseBlocks
st <- getState
- mbsty <- getOption readerCitationStyle
- refs <- getOption readerReferences
- return $ processBiblio mbsty refs
- $ runF titleTrans st
- $ B.doc
- $ runF blocks st
+ let meta = runF (stateMeta' st) st
+ let Pandoc _ bs = B.doc $ runF blocks st
+ return $ Pandoc meta bs
addWarning :: Maybe SourcePos -> String -> MarkdownParser ()
addWarning mbpos msg =
@@ -339,10 +349,8 @@ referenceKey = try $ do
char ':'
skipSpaces >> optional newline >> skipSpaces >> notFollowedBy (char '[')
let sourceURL = liftM unwords $ many $ try $ do
- notFollowedBy' referenceTitle
- skipMany spaceChar
- optional $ newline >> notFollowedBy blankline
skipMany spaceChar
+ notFollowedBy' referenceTitle
notFollowedBy' (() <$ reference)
many1 $ notFollowedBy space >> litChar
let betweenAngles = try $ char '<' >>
@@ -351,7 +359,7 @@ referenceKey = try $ do
tit <- option "" referenceTitle
-- currently we just ignore MMD-style link/image attributes
_kvs <- option [] $ guardEnabled Ext_link_attributes
- >> many (spnl >> keyValAttr)
+ >> many (try $ spnl >> keyValAttr)
blanklines
let target = (escapeURI $ trimr src, tit)
st <- getState
@@ -437,19 +445,26 @@ parseBlocks :: MarkdownParser (F Blocks)
parseBlocks = mconcat <$> manyTill block eof
block :: MarkdownParser (F Blocks)
-block = choice [ mempty <$ blanklines
+block = do
+ tr <- getOption readerTrace
+ pos <- getPosition
+ res <- choice [ mempty <$ blanklines
, codeBlockFenced
+ , yamlMetaBlock
, guardEnabled Ext_latex_macros *> (macro >>= return . return)
+ -- note: bulletList needs to be before header because of
+ -- the possibility of empty list items: -
+ , bulletList
, header
, lhsCodeBlock
, rawTeXBlock
+ , divHtml
, htmlBlock
, table
, lineBlock
, codeBlockIndented
, blockQuote
, hrule
- , bulletList
, orderedList
, definitionList
, noteBlock
@@ -458,6 +473,11 @@ block = choice [ mempty <$ blanklines
, para
, plain
] <?> "block"
+ when tr $ do
+ st <- getState
+ trace (printf "line %d: %s" (sourceLine pos)
+ (take 60 $ show $ B.toList $ runF res st)) (return ())
+ return res
--
-- header blocks
@@ -466,39 +486,15 @@ block = choice [ mempty <$ blanklines
header :: MarkdownParser (F Blocks)
header = setextHeader <|> atxHeader <?> "header"
--- returns unique identifier
-addToHeaderList :: Attr -> F Inlines -> MarkdownParser Attr
-addToHeaderList (ident,classes,kvs) text = do
- let header' = runF text defaultParserState
- exts <- getOption readerExtensions
- let insert' = M.insertWith (\_new old -> old)
- if null ident && Ext_auto_identifiers `Set.member` exts
- then do
- ids <- stateIdentifiers `fmap` getState
- let id' = uniqueIdent (B.toList header') ids
- let id'' = if Ext_ascii_identifiers `Set.member` exts
- then catMaybes $ map toAsciiChar id'
- else id'
- updateState $ \st -> st{
- stateIdentifiers = if id' == id''
- then id' : ids
- else id' : id'' : ids,
- stateHeaders = insert' header' id' $ stateHeaders st }
- return (id'',classes,kvs)
- else do
- unless (null ident) $
- updateState $ \st -> st{
- stateHeaders = insert' header' ident $ stateHeaders st }
- return (ident,classes,kvs)
-
atxHeader :: MarkdownParser (F Blocks)
atxHeader = try $ do
level <- many1 (char '#') >>= return . length
- notFollowedBy (char '.' <|> char ')') -- this would be a list
+ notFollowedBy $ guardEnabled Ext_fancy_lists >>
+ (char '.' <|> char ')') -- this would be a list
skipSpaces
text <- trimInlinesF . mconcat <$> many (notFollowedBy atxClosing >> inline)
attr <- atxClosing
- attr' <- addToHeaderList attr text
+ attr' <- registerHeader attr (runF text defaultParserState)
return $ B.headerWith attr' level <$> text
atxClosing :: MarkdownParser Attr
@@ -537,7 +533,7 @@ setextHeader = try $ do
many (char underlineChar)
blanklines
let level = (fromMaybe 0 $ findIndex (== underlineChar) setextHChars) + 1
- attr' <- addToHeaderList attr text
+ attr' <- registerHeader attr (runF text defaultParserState)
return $ B.headerWith attr' level <$> text
--
@@ -622,12 +618,19 @@ codeBlockFenced = try $ do
skipMany spaceChar
attr <- option ([],[],[]) $
try (guardEnabled Ext_fenced_code_attributes >> attributes)
- <|> ((\x -> ("",[x],[])) <$> identifier)
+ <|> ((\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 :: MarkdownParser (F Blocks)
codeBlockIndented = do
contents <- many1 (indentedLine <|>
@@ -718,7 +721,7 @@ bulletListStart = try $ do
skipNonindentSpaces
notFollowedBy' (() <$ hrule) -- because hrules start out just like lists
satisfy isBulletListMarker
- spaceChar
+ spaceChar <|> lookAhead newline
skipSpaces
anyOrderedListStart :: MarkdownParser (Int, ListNumberStyle, ListNumberDelim)
@@ -746,11 +749,16 @@ listStart = bulletListStart <|> (anyOrderedListStart >> return ())
-- parse a line of a list item (start = parser for beginning of list item)
listLine :: MarkdownParser String
listLine = try $ do
- notFollowedBy blankline
notFollowedBy' (do indentSpaces
- many (spaceChar)
+ many spaceChar
listStart)
- chunks <- manyTill (liftM snd (htmlTag isCommentTag) <|> count 1 anyChar) newline
+ notFollowedBy' $ htmlTag (~== TagClose "div")
+ optional (() <$ indentSpaces)
+ chunks <- manyTill
+ ( many1 (satisfy $ \c -> c /= '\n' && c /= '<')
+ <|> liftM snd (htmlTag isCommentTag)
+ <|> count 1 anyChar
+ ) newline
return $ concat chunks
-- parse raw text for one list item, excluding start marker and continuations
@@ -759,7 +767,7 @@ rawListItem :: MarkdownParser a
rawListItem start = try $ do
start
first <- listLine
- rest <- many (notFollowedBy listStart >> listLine)
+ rest <- many (notFollowedBy listStart >> notFollowedBy blankline >> listLine)
blanks <- many blankline
return $ unlines (first:rest) ++ blanks
@@ -777,6 +785,7 @@ listContinuationLine :: MarkdownParser String
listContinuationLine = try $ do
notFollowedBy blankline
notFollowedBy' listStart
+ notFollowedBy' $ htmlTag (~== TagClose "div")
optional indentSpaces
result <- anyLine
return $ result ++ "\n"
@@ -801,8 +810,8 @@ listItem start = try $ do
orderedList :: MarkdownParser (F Blocks)
orderedList = try $ do
(start, style, delim) <- lookAhead anyOrderedListStart
- unless ((style == DefaultStyle || style == Decimal || style == Example) &&
- (delim == DefaultDelim || delim == Period)) $
+ 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
@@ -863,22 +872,6 @@ definitionList = do
items <- fmap sequence $ many1 definitionListItem
return $ B.definitionList <$> fmap compactify'DL items
-compactify'DL :: [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]
-compactify'DL items =
- let defs = concatMap snd items
- defBlocks = reverse $ concatMap B.toList defs
- isPara (Para _) = True
- isPara _ = False
- in case defBlocks of
- (Para x:_) -> if not $ any isPara (drop 1 defBlocks)
- then let (t,ds) = last items
- lastDef = B.toList $ last ds
- ds' = init ds ++
- [B.fromList $ init lastDef ++ [Plain x]]
- in init items ++ [(t, ds')]
- else items
- _ -> items
-
--
-- paragraph block
--
@@ -891,8 +884,11 @@ para = try $ do
$ try $ do
newline
(blanklines >> return mempty)
- <|> (guardDisabled Ext_blank_before_blockquote >> lookAhead blockQuote)
- <|> (guardDisabled Ext_blank_before_header >> lookAhead header)
+ <|> (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 >>
+ () <$ lookAhead listStart)
return $ do
result' <- result
case B.toList result' of
@@ -911,7 +907,9 @@ plain = fmap B.plain . trimInlinesF . mconcat <$> many1 inline
--
htmlElement :: MarkdownParser String
-htmlElement = strictHtmlBlock <|> liftM snd (htmlTag isBlockTag)
+htmlElement = rawVerbatimBlock
+ <|> strictHtmlBlock
+ <|> liftM snd (htmlTag isBlockTag)
htmlBlock :: MarkdownParser (F Blocks)
htmlBlock = do
@@ -932,8 +930,8 @@ strictHtmlBlock = htmlInBalanced (not . isInlineTag)
rawVerbatimBlock :: MarkdownParser String
rawVerbatimBlock = try $ do
- (TagOpen tag _, open) <- htmlTag (tagOpen (\t ->
- t == "pre" || t == "style" || t == "script")
+ (TagOpen tag _, open) <- htmlTag (tagOpen (flip elem
+ ["pre", "style", "script"])
(const True))
contents <- manyTill anyChar (htmlTag (~== TagClose tag))
return $ open ++ contents ++ renderTags [TagClose tag]
@@ -941,8 +939,10 @@ rawVerbatimBlock = try $ do
rawTeXBlock :: MarkdownParser (F Blocks)
rawTeXBlock = do
guardEnabled Ext_raw_tex
- result <- (B.rawBlock "latex" <$> rawLaTeXBlock)
- <|> (B.rawBlock "context" <$> rawConTeXtEnvironment)
+ result <- (B.rawBlock "latex" . concat <$>
+ rawLaTeXBlock `sepEndBy1` blankline)
+ <|> (B.rawBlock "context" . concat <$>
+ rawConTeXtEnvironment `sepEndBy1` blankline)
spaces
return $ return result
@@ -951,6 +951,8 @@ rawHtmlBlocks = do
htmlBlocks <- many1 $ try $ do
s <- rawVerbatimBlock <|> try (
do (t,raw) <- htmlTag isBlockTag
+ guard $ t ~/= TagOpen "div" [] &&
+ t ~/= TagClose "div"
exts <- getOption readerExtensions
-- if open tag, need markdown="1" if
-- markdown_attributes extension is set
@@ -1117,13 +1119,11 @@ multilineTable headless =
multilineTableHeader :: Bool -- ^ Headerless table
-> MarkdownParser (F [Blocks], [Alignment], [Int])
multilineTableHeader headless = try $ do
- if headless
- then return '\n'
- else tableSep >>~ notFollowedBy blankline
+ unless headless $
+ tableSep >> notFollowedBy blankline
rawContent <- if headless
then return $ repeat ""
- else many1
- (notFollowedBy tableSep >> many1Till anyChar newline)
+ else many1 $ notFollowedBy tableSep >> anyLine
initSp <- nonindentSpaces
dashes <- many1 (dashedLine '-')
newline
@@ -1133,12 +1133,12 @@ multilineTableHeader headless = try $ do
then liftM (map (:[]) . tail .
splitStringByIndices (init indices)) $ lookAhead anyLine
else return $ transpose $ map
- (\ln -> tail $ splitStringByIndices (init indices) ln)
+ (tail . splitStringByIndices (init indices))
rawContent
let aligns = zipWith alignType rawHeadsList lengths
let rawHeads = if headless
then replicate (length dashes) ""
- else map unwords rawHeadsList
+ else map (unlines . map trim) rawHeadsList
heads <- fmap sequence $
mapM (parseFromString (mconcat <$> many plain)) $
map trim rawHeads
@@ -1195,7 +1195,7 @@ gridTableHeader headless = try $ do
-- RST does not have a notion of alignments
let rawHeads = if headless
then replicate (length dashes) ""
- else map unwords $ transpose
+ else map (unlines . map trim) $ transpose
$ map (gridTableSplitLine indices) rawContent
heads <- fmap sequence $ mapM (parseFromString parseBlocks . trim) rawHeads
return (heads, aligns, indices)
@@ -1227,11 +1227,20 @@ removeOneLeadingSpace xs =
gridTableFooter :: MarkdownParser [Char]
gridTableFooter = blanklines
+pipeBreak :: MarkdownParser [Alignment]
+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 (first:rest)
+
pipeTable :: MarkdownParser ([Alignment], [Double], F [Blocks], F [[Blocks]])
pipeTable = try $ do
- let pipeBreak = nonindentSpaces *> optional (char '|') *>
- pipeTableHeaderPart `sepBy1` sepPipe <*
- optional (char '|') <* blankline
(heads,aligns) <- try ( pipeBreak >>= \als ->
return (return $ replicate (length als) mempty, als))
<|> ( pipeTableRow >>= \row -> pipeBreak >>= \als ->
@@ -1250,12 +1259,13 @@ sepPipe = try $ do
pipeTableRow :: MarkdownParser (F [Blocks])
pipeTableRow = do
nonindentSpaces
- optional (char '|')
+ openPipe <- (True <$ char '|') <|> return False
let cell = mconcat <$>
many (notFollowedBy (blankline <|> char '|') >> inline)
first <- cell
- sepPipe
- rest <- cell `sepBy1` sepPipe
+ rest <- many $ sepPipe *> cell
+ -- surrounding pipes needed for a one-column table:
+ guard $ not (null rest && not openPipe)
optional (char '|')
blankline
let cells = sequence (first:rest)
@@ -1340,19 +1350,18 @@ inline = choice [ whitespace
, str
, endline
, code
- , fours
- , strong
- , emph
+ , strongOrEmph
, note
, cite
, link
, image
, math
, strikeout
- , superscript
, subscript
+ , superscript
, inlineNote -- after superscript because of ^[link](/foo)^
, autoLink
+ , spanHtml
, rawHtmlInline
, escapedChar
, rawLaTeXInline'
@@ -1382,7 +1391,7 @@ ltSign :: MarkdownParser (F Inlines)
ltSign = do
guardDisabled Ext_raw_html
<|> guardDisabled Ext_markdown_in_html_blocks
- <|> (notFollowedBy' rawHtmlBlocks >> return ())
+ <|> (notFollowedBy' (htmlTag isBlockTag) >> return ())
char '<'
return $ return $ B.str "<"
@@ -1422,47 +1431,57 @@ math :: MarkdownParser (F Inlines)
math = (return . B.displayMath <$> (mathDisplay >>= applyMacros'))
<|> (return . B.math <$> (mathInline >>= applyMacros'))
-mathDisplay :: MarkdownParser String
-mathDisplay =
- (guardEnabled Ext_tex_math_dollars >> mathDisplayWith "$$" "$$")
- <|> (guardEnabled Ext_tex_math_single_backslash >>
- mathDisplayWith "\\[" "\\]")
- <|> (guardEnabled Ext_tex_math_double_backslash >>
- mathDisplayWith "\\\\[" "\\\\]")
-
-mathDisplayWith :: String -> String -> MarkdownParser String
-mathDisplayWith op cl = try $ do
- string op
- many1Till (noneOf "\n" <|> (newline >>~ notFollowedBy' blankline)) (try $ string cl)
-
-mathInline :: MarkdownParser String
-mathInline =
- (guardEnabled Ext_tex_math_dollars >> mathInlineWith "$" "$")
- <|> (guardEnabled Ext_tex_math_single_backslash >>
- mathInlineWith "\\(" "\\)")
- <|> (guardEnabled Ext_tex_math_double_backslash >>
- mathInlineWith "\\\\(" "\\\\)")
-
-mathInlineWith :: String -> String -> MarkdownParser String
-mathInlineWith op cl = try $ do
- string op
- notFollowedBy space
- words' <- many1Till (count 1 (noneOf "\n\\")
- <|> (char '\\' >> anyChar >>= \c -> return ['\\',c])
- <|> count 1 newline <* notFollowedBy' blankline
- *> return " ")
- (try $ string cl)
- notFollowedBy digit -- to prevent capture of $5
- return $ concat words'
-
--- to avoid performance problems, treat 4 or more _ or * or ~ or ^ in a row
--- as a literal rather than attempting to parse for emph/strong/strikeout/super/sub
-fours :: Parser [Char] st (F Inlines)
-fours = try $ do
- x <- char '*' <|> char '_' <|> char '~' <|> char '^'
- count 2 $ satisfy (==x)
- rest <- many1 (satisfy (==x))
- return $ return $ B.str (x:x:x:rest)
+-- Parses material enclosed in *s, **s, _s, or __s.
+-- Designed to avoid backtracking.
+enclosure :: Char
+ -> MarkdownParser (F Inlines)
+enclosure c = do
+ cs <- many1 (char c)
+ (return (B.str cs) <>) <$> whitespace
+ <|> case length cs of
+ 3 -> three c
+ 2 -> two c mempty
+ 1 -> one c mempty
+ _ -> return (return $ B.str cs)
+
+-- 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 :: Char -> MarkdownParser (F Inlines)
+three c = do
+ contents <- mconcat <$> many (notFollowedBy (char c) >> inline)
+ (try (string [c,c,c]) >> return ((B.strong . B.emph) <$> contents))
+ <|> (try (string [c,c]) >> one c (B.strong <$> contents))
+ <|> (char c >> 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 :: Char -> F Inlines -> MarkdownParser (F Inlines)
+two c prefix' = do
+ let ender = try $ string [c,c]
+ contents <- mconcat <$> many (try $ notFollowedBy ender >> inline)
+ (ender >> 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 :: Char -> F Inlines -> MarkdownParser (F Inlines)
+one c prefix' = do
+ contents <- mconcat <$> many ( (notFollowedBy (char c) >> inline)
+ <|> try (string [c,c] >>
+ notFollowedBy (char c) >>
+ two c mempty) )
+ (char c >> return (B.emph <$> (prefix' <> contents)))
+ <|> return (return (B.str [c]) <> (prefix' <> contents))
+
+strongOrEmph :: MarkdownParser (F Inlines)
+strongOrEmph = enclosure '*' <|> (checkIntraword >> enclosure '_')
+ where checkIntraword = do
+ exts <- getOption readerExtensions
+ when (Ext_intraword_underscores `Set.member` exts) $ do
+ guard =<< notAfterString
-- | Parses a list of inlines between start and end delimiters.
inlinesBetween :: (Show b)
@@ -1474,28 +1493,6 @@ inlinesBetween start end =
where inner = innerSpace <|> (notFollowedBy' (() <$ whitespace) >> inline)
innerSpace = try $ whitespace >>~ notFollowedBy' end
-emph :: MarkdownParser (F Inlines)
-emph = fmap B.emph <$> nested
- (inlinesBetween starStart starEnd <|> inlinesBetween ulStart ulEnd)
- where starStart = char '*' >> lookAhead nonspaceChar
- starEnd = notFollowedBy' (() <$ strong) >> char '*'
- ulStart = checkIntraword >> char '_' >> lookAhead nonspaceChar
- ulEnd = notFollowedBy' (() <$ strong) >> char '_'
- checkIntraword = do
- exts <- getOption readerExtensions
- when (Ext_intraword_underscores `Set.member` exts) $ do
- pos <- getPosition
- lastStrPos <- stateLastStrPos <$> getState
- guard $ lastStrPos /= Just pos
-
-strong :: MarkdownParser (F Inlines)
-strong = fmap B.strong <$> nested
- (inlinesBetween starStart starEnd <|> inlinesBetween ulStart ulEnd)
- where starStart = string "**" >> lookAhead nonspaceChar
- starEnd = try $ string "**"
- ulStart = string "__" >> lookAhead nonspaceChar
- ulEnd = try $ string "__"
-
strikeout :: MarkdownParser (F Inlines)
strikeout = fmap B.strikeout <$>
(guardEnabled Ext_strikeout >> inlinesBetween strikeStart strikeEnd)
@@ -1526,8 +1523,7 @@ nonEndline = satisfy (/='\n')
str :: MarkdownParser (F Inlines)
str = do
result <- many1 alphaNum
- pos <- getPosition
- updateState $ \s -> s{ stateLastStrPos = Just pos }
+ updateLastStrPos
let spacesToNbr = map (\c -> if c == ' ' then '\160' else c)
isSmart <- getOption readerSmart
if isSmart
@@ -1558,14 +1554,17 @@ endline :: MarkdownParser (F Inlines)
endline = try $ do
newline
notFollowedBy blankline
- guardEnabled Ext_blank_before_blockquote <|> notFollowedBy emailBlockQuoteStart
- guardEnabled Ext_blank_before_header <|> notFollowedBy (char '#') -- atx header
-- parse potential list-starts differently if in a list:
st <- getState
- when (stateParserContext st == ListItemState) $ do
- notFollowedBy' bulletListStart
- notFollowedBy' anyOrderedListStart
- (guardEnabled Ext_hard_line_breaks >> return (return B.linebreak))
+ when (stateParserContext st == ListItemState) $ notFollowedBy listStart
+ guardDisabled Ext_lists_without_preceding_blankline <|> notFollowedBy listStart
+ guardEnabled Ext_blank_before_blockquote <|> notFollowedBy emailBlockQuoteStart
+ guardEnabled Ext_blank_before_header <|> notFollowedBy (char '#') -- atx header
+ guardDisabled Ext_backtick_code_blocks <|>
+ notFollowedBy (() <$ (lookAhead (char '`') >> codeBlockFenced))
+ (eof >> return mempty)
+ <|> (guardEnabled Ext_hard_line_breaks >> return (return B.linebreak))
+ <|> (guardEnabled Ext_ignore_line_breaks >> return mempty)
<|> (return $ return B.space)
--
@@ -1660,6 +1659,7 @@ bareURL :: MarkdownParser (F Inlines)
bareURL = try $ do
guardEnabled Ext_autolink_bare_uris
(orig, src) <- uri <|> emailAddress
+ notFollowedBy $ try $ spaces >> htmlTag (~== TagClose "a")
return $ return $ B.link src "" (B.str orig)
autoLink :: MarkdownParser (F Inlines)
@@ -1730,6 +1730,38 @@ inBrackets parser = do
char ']'
return $ "[" ++ contents ++ "]"
+spanHtml :: MarkdownParser (F Inlines)
+spanHtml = try $ do
+ guardEnabled Ext_markdown_in_html_blocks
+ (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 :: MarkdownParser (F Blocks)
+divHtml = try $ do
+ guardEnabled Ext_markdown_in_html_blocks
+ (TagOpen _ attrs, rawtag) <- htmlTag (~== TagOpen "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
+ 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 :: MarkdownParser (F Inlines)
rawHtmlInline = do
guardEnabled Ext_raw_html
@@ -1745,11 +1777,12 @@ rawHtmlInline = do
cite :: MarkdownParser (F Inlines)
cite = do
guardEnabled Ext_citations
- getOption readerReferences >>= guard . not . null
- citations <- textualCite <|> normalCite
- return $ flip B.cite mempty <$> citations
+ citations <- textualCite
+ <|> do (cs, raw) <- withRaw normalCite
+ return $ (flip B.cite (B.text raw)) <$> cs
+ return citations
-textualCite :: MarkdownParser (F [Citation])
+textualCite :: MarkdownParser (F Inlines)
textualCite = try $ do
(_, key) <- citeKey
let first = Citation{ citationId = key
@@ -1759,10 +1792,18 @@ textualCite = try $ do
, citationNoteNum = 0
, citationHash = 0
}
- mbrest <- option Nothing $ try $ spnl >> Just <$> normalCite
+ mbrest <- option Nothing $ try $ spnl >> Just <$> withRaw normalCite
case mbrest of
- Just rest -> return $ (first:) <$> rest
- Nothing -> option (return [first]) $ bareloc first
+ Just (rest, raw) ->
+ return $ (flip B.cite (B.text $ '@':key ++ " " ++ raw) . (first:))
+ <$> rest
+ Nothing ->
+ (do (cs, raw) <- withRaw $ bareloc first
+ return $ (flip B.cite (B.text $ '@':key ++ " " ++ raw)) <$> cs)
+ <|> 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 :: Citation -> MarkdownParser (F [Citation])
bareloc c = try $ do
@@ -1786,18 +1827,6 @@ normalCite = try $ do
char ']'
return citations
-citeKey :: MarkdownParser (Bool, String)
-citeKey = try $ do
- suppress_author <- option False (char '-' >> return True)
- char '@'
- first <- letter
- let internal p = try $ p >>~ lookAhead (letter <|> digit)
- rest <- many $ letter <|> digit <|> internal (oneOf ":.#$%&-_+?<>~/")
- let key = first:rest
- citations' <- map CSL.refId <$> getOption readerReferences
- guard $ key `elem` citations'
- return (suppress_author, key)
-
suffix :: MarkdownParser (F Inlines)
suffix = try $ do
hasSpace <- option False (notFollowedBy nonspaceChar >> return True)
@@ -1836,7 +1865,7 @@ smart :: MarkdownParser (F Inlines)
smart = do
getOption readerSmart >>= guard
doubleQuoted <|> singleQuoted <|>
- choice (map (return . B.singleton <$>) [apostrophe, dash, ellipses])
+ choice (map (return <$>) [apostrophe, dash, ellipses])
singleQuoted :: MarkdownParser (F Inlines)
singleQuoted = try $ do
@@ -1855,4 +1884,3 @@ doubleQuoted = try $ do
(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
index 56049e035..f1dcce8f7 100644
--- a/src/Text/Pandoc/Readers/MediaWiki.hs
+++ b/src/Text/Pandoc/Readers/MediaWiki.hs
@@ -1,6 +1,7 @@
-{-# LANGUAGE RelaxedPolyRec #-} -- needed for inlinesBetween on GHC < 7
+{-# LANGUAGE RelaxedPolyRec, FlexibleInstances, TypeSynonymInstances #-}
+-- RelaxedPolyRec needed for inlinesBetween on GHC < 7
{-
- Copyright (C) 2012 John MacFarlane <jgm@berkeley.edu>
+ 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
@@ -19,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Readers.MediaWiki
- Copyright : Copyright (C) 2012 John MacFarlane
+ Copyright : Copyright (C) 2012-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -42,8 +43,8 @@ import Text.Pandoc.Options
import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag, isCommentTag )
import Text.Pandoc.XML ( fromEntities )
import Text.Pandoc.Parsing hiding ( nested )
-import Text.Pandoc.Generic ( bottomUp )
-import Text.Pandoc.Shared ( stripTrailingNewlines, safeRead )
+import Text.Pandoc.Walk ( walk )
+import Text.Pandoc.Shared ( stripTrailingNewlines, safeRead, stringify, trim )
import Data.Monoid (mconcat, mempty)
import Control.Applicative ((<$>), (<*), (*>), (<$))
import Control.Monad
@@ -51,7 +52,11 @@ 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 Data.Char (isDigit, isSpace)
+import Data.Maybe (fromMaybe)
+import Text.Printf (printf)
+import Debug.Trace (trace)
-- | Read mediawiki from an input string and return a Pandoc document.
readMediaWiki :: ReaderOptions -- ^ Reader options
@@ -62,6 +67,8 @@ readMediaWiki opts s =
, mwMaxNestingLevel = 4
, mwNextLinkNumber = 1
, mwCategoryLinks = []
+ , mwHeaderMap = M.empty
+ , mwIdentifierList = []
}
"source" (s ++ "\n") of
Left err' -> error $ "\nError:\n" ++ show err'
@@ -71,10 +78,23 @@ data MWState = MWState { mwOptions :: ReaderOptions
, mwMaxNestingLevel :: Int
, mwNextLinkNumber :: Int
, mwCategoryLinks :: [Inlines]
+ , mwHeaderMap :: M.Map Inlines String
+ , mwIdentifierList :: [String]
}
type MWParser = Parser [Char] MWState
+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
--
@@ -91,7 +111,7 @@ nested p = do
return res
specialChars :: [Char]
-specialChars = "'[]<=&*{}|\""
+specialChars = "'[]<=&*{}|\":\\"
spaceChars :: [Char]
spaceChars = " \n\t"
@@ -131,9 +151,16 @@ inlinesInTags tag = try $ do
blocksInTags :: String -> MWParser 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 (htmlTag (~== TagClose tag))
+ else mconcat <$> manyTill block closer
charsInTags :: String -> MWParser [Char]
charsInTags tag = try $ do
@@ -162,7 +189,10 @@ parseMediaWiki = do
--
block :: MWParser Blocks
-block = mempty <$ skipMany1 blankline
+block = do
+ tr <- getOption readerTrace
+ pos <- getPosition
+ res <- mempty <$ skipMany1 blankline
<|> table
<|> header
<|> hrule
@@ -174,6 +204,10 @@ block = mempty <$ skipMany1 blankline
<|> blockTag
<|> (B.rawBlock "mediawiki" <$> template)
<|> para
+ when tr $
+ trace (printf "line %d: %s" (sourceLine pos)
+ (take 60 $ show $ B.toList res)) (return ())
+ return res
para :: MWParser Blocks
para = do
@@ -187,7 +221,7 @@ table = do
tableStart
styles <- option [] parseAttrs <* blankline
let tableWidth = case lookup "width" styles of
- Just w -> maybe 1.0 id $ parseWidth w
+ Just w -> fromMaybe 1.0 $ parseWidth w
Nothing -> 1.0
caption <- option mempty tableCaption
optional rowsep
@@ -202,6 +236,7 @@ table = do
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
@@ -250,7 +285,7 @@ tableCaption = try $ do
(trimInlines . mconcat) <$> many (notFollowedBy (cellsep <|> rowsep) *> inline)
tableRow :: MWParser [((Alignment, Double), Blocks)]
-tableRow = try $ many tableCell
+tableRow = try $ skipMany htmlComment *> many tableCell
tableCell :: MWParser ((Alignment, Double), Blocks)
tableCell = try $ do
@@ -268,7 +303,7 @@ tableCell = try $ do
Just "center" -> AlignCenter
_ -> AlignDefault
let width = case lookup "width" attrs of
- Just xs -> maybe 0.0 id $ parseWidth xs
+ Just xs -> fromMaybe 0.0 $ parseWidth xs
Nothing -> 0.0
return ((align, width), bs)
@@ -282,6 +317,7 @@ template :: MWParser 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 ++ "}}"
@@ -342,7 +378,7 @@ preformatted = try $ do
spacesStr _ = False
if F.all spacesStr contents
then return mempty
- else return $ B.para $ bottomUp strToCode contents
+ else return $ B.para $ walk strToCode contents
header :: MWParser Blocks
header = try $ do
@@ -351,7 +387,8 @@ header = try $ do
let lev = length eqs
guard $ lev <= 6
contents <- trimInlines . mconcat <$> manyTill inline (count lev $ char '=')
- return $ B.header lev contents
+ attr <- registerHeader nullAttr contents
+ return $ B.headerWith attr lev contents
bulletList :: MWParser Blocks
bulletList = B.bulletList <$>
@@ -362,15 +399,13 @@ bulletList = B.bulletList <$>
orderedList :: MWParser Blocks
orderedList =
(B.orderedList <$> many1 (listItem '#'))
- <|> (B.orderedList <$> (htmlTag (~== TagOpen "ul" []) *> spaces *>
- many (listItem '#' <|> li) <*
- optional (htmlTag (~== TagClose "ul"))))
- <|> do (tag,_) <- htmlTag (~== TagOpen "ol" [])
- spaces
- items <- many (listItem '#' <|> li)
- optional (htmlTag (~== TagClose "ol"))
- let start = maybe 1 id $ safeRead $ fromAttrib "start" tag
- return $ B.orderedListWith (start, DefaultStyle, DefaultDelim) items
+ <|> 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 :: MWParser Blocks
definitionList = B.definitionList <$> many1 defListItem
@@ -380,8 +415,9 @@ 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 many1 $ listItem ':'
- else many $ listItem ':'
+ then notFollowedBy (try $ string ":<math>") *>
+ many1 (listItem ':')
+ else many (listItem ':')
return (terms, defs)
defListTerm :: MWParser Inlines
@@ -413,7 +449,8 @@ listItem c = try $ do
skipMany spaceChar
first <- concat <$> manyTill listChunk newline
rest <- many
- (try $ string extras *> (concat <$> manyTill listChunk newline))
+ (try $ string extras *> lookAhead listStartChar *>
+ (concat <$> manyTill listChunk newline))
contents <- parseFromString (many1 $ listItem' c)
(unlines (first : rest))
case c of
@@ -462,6 +499,7 @@ inline = whitespace
<|> image
<|> internalLink
<|> externalLink
+ <|> math
<|> inlineTag
<|> B.singleton <$> charRef
<|> inlineHtml
@@ -472,6 +510,16 @@ inline = whitespace
str :: MWParser Inlines
str = B.str <$> many1 (noneOf $ specialChars ++ spaceChars)
+math :: MWParser Inlines
+math = (B.displayMath . trim <$> try (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 :: MWParser String
variable = try $ do
string "{{{"
@@ -495,7 +543,6 @@ inlineTag = do
TagOpen "del" _ -> B.strikeout <$> inlinesInTags "del"
TagOpen "sub" _ -> B.subscript <$> inlinesInTags "sub"
TagOpen "sup" _ -> B.superscript <$> inlinesInTags "sup"
- TagOpen "math" _ -> B.math <$> charsInTags "math"
TagOpen "code" _ -> B.code <$> charsInTags "code"
TagOpen "tt" _ -> B.code <$> charsInTags "tt"
TagOpen "hask" _ -> B.codeWith ("",["haskell"],[]) <$> charsInTags "hask"
@@ -520,15 +567,19 @@ endline = () <$ try (newline <*
notFollowedBy' header <*
notFollowedBy anyListStart)
+imageIdentifiers :: [MWParser ()]
+imageIdentifiers = [sym (identifier ++ ":") | identifier <- identifiers]
+ where identifiers = ["File", "Image", "Archivo", "Datei", "Fichier"]
+
image :: MWParser Inlines
image = try $ do
sym "[["
- sym "File:"
+ choice imageIdentifiers
fname <- many1 (noneOf "|]")
_ <- many (try $ char '|' *> imageOption)
caption <- (B.str fname <$ sym "]]")
<|> try (char '|' *> (mconcat <$> manyTill inline (sym "]]")))
- return $ B.image fname "image" caption
+ return $ B.image fname ("fig:" ++ stringify caption) caption
imageOption :: MWParser String
imageOption =
diff --git a/src/Text/Pandoc/Readers/Native.hs b/src/Text/Pandoc/Readers/Native.hs
index c5d4cb98a..f4dfa62c1 100644
--- a/src/Text/Pandoc/Readers/Native.hs
+++ b/src/Text/Pandoc/Readers/Native.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2011 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2011-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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Readers.Native
- Copyright : Copyright (C) 2011 John MacFarlane
+ Copyright : Copyright (C) 2011-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers/OPML.hs b/src/Text/Pandoc/Readers/OPML.hs
index c9726d195..35d01e877 100644
--- a/src/Text/Pandoc/Readers/OPML.hs
+++ b/src/Text/Pandoc/Readers/OPML.hs
@@ -6,7 +6,7 @@ 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 Text.Pandoc.Compat.TagSoupEntity (lookupEntity)
import Data.Generics
import Data.Monoid
import Control.Monad.State
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
new file mode 100644
index 000000000..7a35e2ca0
--- /dev/null
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -0,0 +1,1379 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-
+Copyright (C) 2014 Albert Krewinkel <tarleb@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 Albert Krewinkel
+ License : GNU GPL, version 2 or above
+
+ Maintainer : Albert Krewinkel <tarleb@moltkeplatz.de>
+
+Conversion of org-mode formatted plain text to 'Pandoc' document.
+-}
+module Text.Pandoc.Readers.Org ( readOrg ) where
+
+import qualified Text.Pandoc.Builder as B
+import Text.Pandoc.Builder ( Inlines, Blocks, HasMeta(..), (<>)
+ , trimInlines )
+import Text.Pandoc.Definition
+import Text.Pandoc.Options
+import qualified Text.Pandoc.Parsing as P
+import Text.Pandoc.Parsing hiding ( F, unF, askF, asksF, runF
+ , newline, orderedListMarker
+ , parseFromString
+ )
+import Text.Pandoc.Readers.LaTeX (inlineCommand, rawLaTeXInline)
+import Text.Pandoc.Shared (compactify', compactify'DL)
+import Text.TeXMath (texMathToPandoc, DisplayType(..))
+
+import Control.Applicative ( Applicative, pure
+ , (<$>), (<$), (<*>), (<*), (*>), (<**>) )
+import Control.Arrow (first)
+import Control.Monad (foldM, guard, liftM, liftM2, mplus, mzero, when)
+import Control.Monad.Reader (Reader, runReader, ask, asks)
+import Data.Char (isAlphaNum, toLower)
+import Data.Default
+import Data.List (intersperse, isPrefixOf, isSuffixOf)
+import qualified Data.Map as M
+import Data.Maybe (fromMaybe, isJust)
+import Data.Monoid (Monoid, mconcat, mempty, mappend)
+import Network.HTTP (urlEncode)
+
+-- | Parse org-mode string and return a Pandoc document.
+readOrg :: ReaderOptions -- ^ Reader options
+ -> String -- ^ String to parse (assuming @'\n'@ line endings)
+ -> Pandoc
+readOrg opts s = readWith parseOrg def{ orgStateOptions = opts } (s ++ "\n\n")
+
+type OrgParser = Parser [Char] OrgParserState
+
+parseOrg :: OrgParser Pandoc
+parseOrg = do
+ blocks' <- parseBlocks
+ st <- getState
+ let meta = runF (orgStateMeta' st) st
+ return $ Pandoc meta $ filter (/= Null) (B.toList $ runF blocks' st)
+
+--
+-- Parser State for Org
+--
+
+type OrgNoteRecord = (String, F Blocks)
+type OrgNoteTable = [OrgNoteRecord]
+
+type OrgBlockAttributes = M.Map String String
+
+type OrgLinkFormatters = M.Map String (String -> String)
+
+-- | Org-mode parser state
+data OrgParserState = OrgParserState
+ { orgStateOptions :: ReaderOptions
+ , orgStateAnchorIds :: [String]
+ , orgStateBlockAttributes :: OrgBlockAttributes
+ , orgStateEmphasisCharStack :: [Char]
+ , orgStateEmphasisNewlines :: Maybe Int
+ , orgStateLastForbiddenCharPos :: Maybe SourcePos
+ , orgStateLastPreCharPos :: Maybe SourcePos
+ , orgStateLastStrPos :: Maybe SourcePos
+ , orgStateLinkFormatters :: OrgLinkFormatters
+ , orgStateMeta :: Meta
+ , orgStateMeta' :: F Meta
+ , orgStateNotes' :: OrgNoteTable
+ }
+
+instance HasReaderOptions OrgParserState where
+ extractReaderOptions = orgStateOptions
+
+instance HasMeta OrgParserState where
+ setMeta field val st =
+ st{ orgStateMeta = setMeta field val $ orgStateMeta st }
+ deleteMeta field st =
+ st{ orgStateMeta = deleteMeta field $ orgStateMeta st }
+
+instance HasLastStrPosition OrgParserState where
+ getLastStrPos = orgStateLastStrPos
+ setLastStrPos pos st = st{ orgStateLastStrPos = Just pos }
+
+instance Default OrgParserState where
+ def = defaultOrgParserState
+
+defaultOrgParserState :: OrgParserState
+defaultOrgParserState = OrgParserState
+ { orgStateOptions = def
+ , orgStateAnchorIds = []
+ , orgStateBlockAttributes = M.empty
+ , orgStateEmphasisCharStack = []
+ , orgStateEmphasisNewlines = Nothing
+ , orgStateLastForbiddenCharPos = Nothing
+ , orgStateLastPreCharPos = Nothing
+ , orgStateLastStrPos = Nothing
+ , orgStateLinkFormatters = M.empty
+ , orgStateMeta = nullMeta
+ , orgStateMeta' = return nullMeta
+ , orgStateNotes' = []
+ }
+
+recordAnchorId :: String -> OrgParser ()
+recordAnchorId i = updateState $ \s ->
+ s{ orgStateAnchorIds = i : (orgStateAnchorIds s) }
+
+addBlockAttribute :: String -> String -> OrgParser ()
+addBlockAttribute key val = updateState $ \s ->
+ let attrs = orgStateBlockAttributes s
+ in s{ orgStateBlockAttributes = M.insert key val attrs }
+
+lookupBlockAttribute :: String -> OrgParser (Maybe String)
+lookupBlockAttribute key =
+ M.lookup key . orgStateBlockAttributes <$> getState
+
+resetBlockAttributes :: OrgParser ()
+resetBlockAttributes = updateState $ \s ->
+ s{ orgStateBlockAttributes = orgStateBlockAttributes def }
+
+updateLastForbiddenCharPos :: OrgParser ()
+updateLastForbiddenCharPos = getPosition >>= \p ->
+ updateState $ \s -> s{ orgStateLastForbiddenCharPos = Just p}
+
+updateLastPreCharPos :: OrgParser ()
+updateLastPreCharPos = getPosition >>= \p ->
+ updateState $ \s -> s{ orgStateLastPreCharPos = Just p}
+
+pushToInlineCharStack :: Char -> OrgParser ()
+pushToInlineCharStack c = updateState $ \s ->
+ s{ orgStateEmphasisCharStack = c:orgStateEmphasisCharStack s }
+
+popInlineCharStack :: OrgParser ()
+popInlineCharStack = updateState $ \s ->
+ s{ orgStateEmphasisCharStack = drop 1 . orgStateEmphasisCharStack $ s }
+
+surroundingEmphasisChar :: OrgParser [Char]
+surroundingEmphasisChar =
+ take 1 . drop 1 . orgStateEmphasisCharStack <$> getState
+
+startEmphasisNewlinesCounting :: Int -> OrgParser ()
+startEmphasisNewlinesCounting maxNewlines = updateState $ \s ->
+ s{ orgStateEmphasisNewlines = Just maxNewlines }
+
+decEmphasisNewlinesCount :: OrgParser ()
+decEmphasisNewlinesCount = updateState $ \s ->
+ s{ orgStateEmphasisNewlines = (\n -> n - 1) <$> orgStateEmphasisNewlines s }
+
+newlinesCountWithinLimits :: OrgParser Bool
+newlinesCountWithinLimits = do
+ st <- getState
+ return $ ((< 0) <$> orgStateEmphasisNewlines st) /= Just True
+
+resetEmphasisNewlines :: OrgParser ()
+resetEmphasisNewlines = updateState $ \s ->
+ s{ orgStateEmphasisNewlines = Nothing }
+
+addLinkFormat :: String
+ -> (String -> String)
+ -> OrgParser ()
+addLinkFormat key formatter = updateState $ \s ->
+ let fs = orgStateLinkFormatters s
+ in s{ orgStateLinkFormatters = M.insert key formatter fs }
+
+addToNotesTable :: OrgNoteRecord -> OrgParser ()
+addToNotesTable note = do
+ oldnotes <- orgStateNotes' <$> getState
+ updateState $ \s -> s{ orgStateNotes' = note:oldnotes }
+
+-- The version Text.Pandoc.Parsing cannot be used, as we need additional parts
+-- of the state saved and restored.
+parseFromString :: OrgParser a -> String -> OrgParser 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
+
+
+--
+-- Adaptions and specializations of parsing utilities
+--
+
+newtype F a = F { unF :: Reader OrgParserState a
+ } deriving (Monad, Applicative, Functor)
+
+runF :: F a -> OrgParserState -> a
+runF = runReader . unF
+
+askF :: F OrgParserState
+askF = F ask
+
+asksF :: (OrgParserState -> a) -> F a
+asksF f = F $ asks f
+
+instance Monoid a => Monoid (F a) where
+ mempty = return mempty
+ mappend = liftM2 mappend
+ mconcat = fmap mconcat . sequence
+
+trimInlinesF :: F Inlines -> F Inlines
+trimInlinesF = liftM trimInlines
+
+returnF :: a -> OrgParser (F a)
+returnF = return . return
+
+
+-- | Like @Text.Parsec.Char.newline@, but causes additional state changes.
+newline :: OrgParser Char
+newline =
+ P.newline
+ <* updateLastPreCharPos
+ <* updateLastForbiddenCharPos
+
+--
+-- parsing blocks
+--
+
+parseBlocks :: OrgParser (F Blocks)
+parseBlocks = mconcat <$> manyTill block eof
+
+block :: OrgParser (F Blocks)
+block = choice [ mempty <$ blanklines
+ , optionalAttributes $ choice
+ [ orgBlock
+ , figure
+ , table
+ ]
+ , example
+ , drawer
+ , specialLine
+ , header
+ , return <$> hline
+ , list
+ , latexFragment
+ , noteBlock
+ , paraOrPlain
+ ] <?> "block"
+
+optionalAttributes :: OrgParser (F Blocks) -> OrgParser (F Blocks)
+optionalAttributes parser = try $
+ resetBlockAttributes *> parseBlockAttributes *> parser
+
+parseBlockAttributes :: OrgParser ()
+parseBlockAttributes = do
+ attrs <- many attribute
+ () <$ mapM (uncurry parseAndAddAttribute) attrs
+ where
+ attribute :: OrgParser (String, String)
+ attribute = try $ do
+ key <- metaLineStart *> many1Till nonspaceChar (char ':')
+ val <- skipSpaces *> anyLine
+ return (map toLower key, val)
+
+parseAndAddAttribute :: String -> String -> OrgParser ()
+parseAndAddAttribute key value = do
+ let key' = map toLower key
+ () <$ addBlockAttribute key' value
+
+lookupInlinesAttr :: String -> OrgParser (Maybe (F Inlines))
+lookupInlinesAttr attr = try $ do
+ val <- lookupBlockAttribute attr
+ maybe (return Nothing)
+ (fmap Just . parseFromString parseInlines)
+ val
+
+
+--
+-- Org Blocks (#+BEGIN_... / #+END_...)
+--
+
+type BlockProperties = (Int, String) -- (Indentation, Block-Type)
+
+orgBlock :: OrgParser (F Blocks)
+orgBlock = try $ do
+ blockProp@(_, blkType) <- blockHeaderStart
+ ($ blockProp) $
+ case blkType of
+ "comment" -> withRaw' (const mempty)
+ "html" -> withRaw' (return . (B.rawBlock blkType))
+ "latex" -> withRaw' (return . (B.rawBlock blkType))
+ "ascii" -> withRaw' (return . (B.rawBlock blkType))
+ "example" -> withRaw' (return . exampleCode)
+ "quote" -> withParsed (fmap B.blockQuote)
+ "verse" -> verseBlock
+ "src" -> codeBlock
+ _ -> withParsed (fmap $ divWithClass blkType)
+
+blockHeaderStart :: OrgParser (Int, String)
+blockHeaderStart = try $ (,) <$> indent <*> blockType
+ where
+ indent = length <$> many spaceChar
+ blockType = map toLower <$> (stringAnyCase "#+begin_" *> orgArgWord)
+
+withRaw' :: (String -> F Blocks) -> BlockProperties -> OrgParser (F Blocks)
+withRaw' f blockProp = (ignHeaders *> (f <$> rawBlockContent blockProp))
+
+withParsed :: (F Blocks -> F Blocks) -> BlockProperties -> OrgParser (F Blocks)
+withParsed f blockProp = (ignHeaders *> (f <$> parsedBlockContent blockProp))
+
+ignHeaders :: OrgParser ()
+ignHeaders = (() <$ newline) <|> (() <$ anyLine)
+
+divWithClass :: String -> Blocks -> Blocks
+divWithClass cls = B.divWith ("", [cls], [])
+
+verseBlock :: BlockProperties -> OrgParser (F Blocks)
+verseBlock blkProp = try $ do
+ ignHeaders
+ content <- rawBlockContent blkProp
+ fmap B.para . mconcat . intersperse (pure B.linebreak)
+ <$> mapM (parseFromString parseInlines) (lines content)
+
+codeBlock :: BlockProperties -> OrgParser (F Blocks)
+codeBlock blkProp = do
+ skipSpaces
+ (classes, kv) <- codeHeaderArgs <|> (mempty <$ ignHeaders)
+ id' <- fromMaybe "" <$> lookupBlockAttribute "name"
+ content <- rawBlockContent blkProp
+ let codeBlck = B.codeBlockWith ( id', classes, kv ) content
+ maybe (pure codeBlck) (labelDiv codeBlck) <$> lookupInlinesAttr "caption"
+ where
+ labelDiv blk value =
+ B.divWith nullAttr <$> (mappend <$> labelledBlock value
+ <*> pure blk)
+ labelledBlock = fmap (B.plain . B.spanWith ("", ["label"], []))
+
+rawBlockContent :: BlockProperties -> OrgParser String
+rawBlockContent (indent, blockType) = try $
+ unlines . map commaEscaped <$> manyTill indentedLine blockEnder
+ where
+ indentedLine = try $ ("" <$ blankline) <|> (indentWith indent *> anyLine)
+ blockEnder = try $ indentWith indent *> stringAnyCase ("#+end_" <> blockType)
+
+parsedBlockContent :: BlockProperties -> OrgParser (F Blocks)
+parsedBlockContent blkProps = try $ do
+ raw <- rawBlockContent blkProps
+ parseFromString parseBlocks (raw ++ "\n")
+
+-- indent by specified number of spaces (or equiv. tabs)
+indentWith :: Int -> OrgParser 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 ' ')) ]
+
+type SwitchOption = (Char, Maybe String)
+
+orgArgWord :: OrgParser String
+orgArgWord = many1 orgArgWordChar
+
+-- | Parse code block arguments
+-- TODO: We currently don't handle switches.
+codeHeaderArgs :: OrgParser ([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 :: OrgParser SwitchOption
+switch = try $ simpleSwitch <|> lineNumbersSwitch
+ where
+ simpleSwitch = (\c -> (c, Nothing)) <$> (oneOf "-+" *> letter)
+ lineNumbersSwitch = (\ls -> ('l', Just ls)) <$>
+ (string "-l \"" *> many1Till nonspaceChar (char '"'))
+
+translateLang :: String -> String
+translateLang "C" = "c"
+translateLang "C++" = "cpp"
+translateLang "emacs-lisp" = "commonlisp" -- emacs lisp is not supported
+translateLang "js" = "javascript"
+translateLang "lisp" = "commonlisp"
+translateLang "R" = "r"
+translateLang "sh" = "bash"
+translateLang "sqlite" = "sql"
+translateLang cs = cs
+
+-- | Prefix used for Rundoc classes and arguments.
+rundocPrefix :: String
+rundocPrefix = "rundoc-"
+
+-- | The class-name used to mark rundoc blocks.
+rundocBlockClass :: String
+rundocBlockClass = rundocPrefix ++ "block"
+
+blockOption :: OrgParser (String, String)
+blockOption = try $ (,) <$> orgArgKey <*> orgParamValue
+
+inlineBlockOption :: OrgParser (String, String)
+inlineBlockOption = try $ (,) <$> orgArgKey <*> orgInlineParamValue
+
+orgArgKey :: OrgParser String
+orgArgKey = try $
+ skipSpaces *> char ':'
+ *> many1 orgArgWordChar
+
+orgParamValue :: OrgParser String
+orgParamValue = try $
+ skipSpaces *> many1 (noneOf "\t\n\r ") <* skipSpaces
+
+orgInlineParamValue :: OrgParser String
+orgInlineParamValue = try $
+ skipSpaces *> many1 (noneOf "\t\n\r ]") <* skipSpaces
+
+orgArgWordChar :: OrgParser Char
+orgArgWordChar = alphaNum <|> oneOf "-_"
+
+toRundocAttrib :: (String, String) -> (String, String)
+toRundocAttrib = first ("rundoc-" ++)
+
+commaEscaped :: String -> String
+commaEscaped (',':cs@('*':_)) = cs
+commaEscaped (',':cs@('#':'+':_)) = cs
+commaEscaped cs = cs
+
+example :: OrgParser (F Blocks)
+example = try $ do
+ return . return . exampleCode =<< unlines <$> many1 exampleLine
+
+exampleCode :: String -> Blocks
+exampleCode = B.codeBlockWith ("", ["example"], [])
+
+exampleLine :: OrgParser String
+exampleLine = try $ string ": " *> anyLine
+
+-- Drawers for properties or a logbook
+drawer :: OrgParser (F Blocks)
+drawer = try $ do
+ drawerStart
+ manyTill drawerLine (try drawerEnd)
+ return mempty
+
+drawerStart :: OrgParser String
+drawerStart = try $
+ skipSpaces *> drawerName <* skipSpaces <* P.newline
+ where drawerName = try $ char ':' *> validDrawerName <* char ':'
+ validDrawerName = stringAnyCase "PROPERTIES"
+ <|> stringAnyCase "LOGBOOK"
+
+drawerLine :: OrgParser String
+drawerLine = try anyLine
+
+drawerEnd :: OrgParser String
+drawerEnd = try $
+ skipSpaces *> stringAnyCase ":END:" <* skipSpaces <* P.newline
+
+
+--
+-- Figures
+--
+
+-- Figures (Image on a line by itself, preceded by name and/or caption)
+figure :: OrgParser (F Blocks)
+figure = try $ do
+ (cap, nam) <- nameAndCaption
+ src <- skipSpaces *> selfTarget <* skipSpaces <* P.newline
+ guard (isImageFilename src)
+ return $ do
+ cap' <- cap
+ return $ B.para $ B.image src nam cap'
+ where
+ nameAndCaption =
+ do
+ maybeCap <- lookupInlinesAttr "caption"
+ maybeNam <- lookupBlockAttribute "name"
+ guard $ isJust maybeCap || isJust maybeNam
+ return ( fromMaybe mempty maybeCap
+ , maybe mempty withFigPrefix maybeNam )
+ withFigPrefix cs =
+ if "fig:" `isPrefixOf` cs
+ then cs
+ else "fig:" ++ cs
+
+--
+-- Comments, Options and Metadata
+specialLine :: OrgParser (F Blocks)
+specialLine = fmap return . try $ metaLine <|> commentLine
+
+metaLine :: OrgParser Blocks
+metaLine = try $ mempty
+ <$ (metaLineStart *> (optionLine <|> declarationLine))
+
+commentLine :: OrgParser Blocks
+commentLine = try $ commentLineStart *> anyLine *> pure mempty
+
+-- 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
+metaLineStart :: OrgParser String
+metaLineStart = try $ mappend <$> many spaceChar <*> string "#+"
+
+commentLineStart :: OrgParser String
+commentLineStart = try $ mappend <$> many spaceChar <*> string "# "
+
+declarationLine :: OrgParser ()
+declarationLine = try $ do
+ key <- metaKey
+ inlinesF <- metaInlines
+ updateState $ \st ->
+ let meta' = B.setMeta <$> pure key <*> inlinesF <*> pure nullMeta
+ in st { orgStateMeta' = orgStateMeta' st <> meta' }
+ return ()
+
+metaInlines :: OrgParser (F MetaValue)
+metaInlines = fmap (MetaInlines . B.toList) <$> inlinesTillNewline
+
+metaKey :: OrgParser String
+metaKey = map toLower <$> many1 (noneOf ": \n\r")
+ <* char ':'
+ <* skipSpaces
+
+optionLine :: OrgParser ()
+optionLine = try $ do
+ key <- metaKey
+ case key of
+ "link" -> parseLinkFormat >>= uncurry addLinkFormat
+ _ -> mzero
+
+parseLinkFormat :: OrgParser ((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 :: OrgParser (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:""))
+
+--
+-- Headers
+--
+
+-- | Headers
+header :: OrgParser (F Blocks)
+header = try $ do
+ level <- headerStart
+ title <- inlinesTillNewline
+ return $ B.header level <$> title
+
+headerStart :: OrgParser Int
+headerStart = try $
+ (length <$> many1 (char '*')) <* many1 (char ' ')
+
+
+-- Don't use (or need) the reader wrapper here, we want hline to be
+-- @show@able. Otherwise we can't use it with @notFollowedBy'@.
+
+-- | Horizontal Line (five -- dashes or more)
+hline :: OrgParser Blocks
+hline = try $ do
+ skipSpaces
+ string "-----"
+ many (char '-')
+ skipSpaces
+ newline
+ return B.horizontalRule
+
+--
+-- Tables
+--
+
+data OrgTableRow = OrgContentRow (F [Blocks])
+ | OrgAlignRow [Alignment]
+ | OrgHlineRow
+
+data OrgTable = OrgTable
+ { orgTableColumns :: Int
+ , orgTableAlignments :: [Alignment]
+ , orgTableHeader :: [Blocks]
+ , orgTableRows :: [[Blocks]]
+ }
+
+table :: OrgParser (F Blocks)
+table = try $ do
+ lookAhead tableStart
+ do
+ rows <- tableRows
+ cptn <- fromMaybe (pure "") <$> lookupInlinesAttr "caption"
+ return $ (<$> cptn) . orgToPandocTable . normalizeTable =<< rowsToTable rows
+
+orgToPandocTable :: OrgTable
+ -> Inlines
+ -> Blocks
+orgToPandocTable (OrgTable _ aligns heads lns) caption =
+ B.table caption (zip aligns $ repeat 0) heads lns
+
+tableStart :: OrgParser Char
+tableStart = try $ skipSpaces *> char '|'
+
+tableRows :: OrgParser [OrgTableRow]
+tableRows = try $ many (tableAlignRow <|> tableHline <|> tableContentRow)
+
+tableContentRow :: OrgParser OrgTableRow
+tableContentRow = try $
+ OrgContentRow . sequence <$> (tableStart *> manyTill tableContentCell newline)
+
+tableContentCell :: OrgParser (F Blocks)
+tableContentCell = try $
+ fmap B.plain . trimInlinesF . mconcat <$> many1Till inline endOfCell
+
+endOfCell :: OrgParser Char
+endOfCell = try $ char '|' <|> lookAhead newline
+
+tableAlignRow :: OrgParser OrgTableRow
+tableAlignRow = try $
+ OrgAlignRow <$> (tableStart *> manyTill tableAlignCell newline)
+
+tableAlignCell :: OrgParser Alignment
+tableAlignCell =
+ choice [ try $ emptyCell *> return AlignDefault
+ , try $ skipSpaces
+ *> char '<'
+ *> tableAlignFromChar
+ <* many digit
+ <* char '>'
+ <* emptyCell
+ ] <?> "alignment info"
+ where emptyCell = try $ skipSpaces *> endOfCell
+
+tableAlignFromChar :: OrgParser Alignment
+tableAlignFromChar = try $ choice [ char 'l' *> return AlignLeft
+ , char 'c' *> return AlignCenter
+ , char 'r' *> return AlignRight
+ ]
+
+tableHline :: OrgParser OrgTableRow
+tableHline = try $
+ OrgHlineRow <$ (tableStart *> char '-' *> anyLine)
+
+rowsToTable :: [OrgTableRow]
+ -> F OrgTable
+rowsToTable = foldM (flip rowToContent) zeroTable
+ where zeroTable = OrgTable 0 mempty mempty mempty
+
+normalizeTable :: OrgTable
+ -> OrgTable
+normalizeTable (OrgTable cols aligns heads lns) =
+ let aligns' = fillColumns aligns AlignDefault
+ heads' = if heads == mempty
+ then mempty
+ else fillColumns heads (B.plain mempty)
+ lns' = map (`fillColumns` B.plain mempty) lns
+ fillColumns base padding = take cols $ base ++ repeat padding
+ in OrgTable cols aligns' heads' lns'
+
+
+-- One or more horizontal rules after the first content line mark the previous
+-- line as a header. All other horizontal lines are discarded.
+rowToContent :: OrgTableRow
+ -> OrgTable
+ -> F OrgTable
+rowToContent OrgHlineRow t = maybeBodyToHeader t
+rowToContent (OrgAlignRow as) t = setLongestRow as =<< setAligns as t
+rowToContent (OrgContentRow rf) t = do
+ rs <- rf
+ setLongestRow rs =<< appendToBody rs t
+
+setLongestRow :: [a]
+ -> OrgTable
+ -> F OrgTable
+setLongestRow rs t =
+ return t{ orgTableColumns = max (length rs) (orgTableColumns t) }
+
+maybeBodyToHeader :: OrgTable
+ -> F OrgTable
+maybeBodyToHeader t = case t of
+ OrgTable{ orgTableHeader = [], orgTableRows = b:[] } ->
+ return t{ orgTableHeader = b , orgTableRows = [] }
+ _ -> return t
+
+appendToBody :: [Blocks]
+ -> OrgTable
+ -> F OrgTable
+appendToBody r t = return t{ orgTableRows = orgTableRows t ++ [r] }
+
+setAligns :: [Alignment]
+ -> OrgTable
+ -> F OrgTable
+setAligns aligns t = return $ t{ orgTableAlignments = aligns }
+
+
+--
+-- LaTeX fragments
+--
+latexFragment :: OrgParser (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"
+ ]
+
+latexEnvStart :: OrgParser String
+latexEnvStart = try $ do
+ skipSpaces *> string "\\begin{"
+ *> latexEnvName
+ <* string "}"
+ <* blankline
+
+latexEnd :: String -> OrgParser ()
+latexEnd envName = try $
+ () <$ skipSpaces
+ <* string ("\\end{" ++ envName ++ "}")
+ <* blankline
+
+-- | Parses a LaTeX environment name.
+latexEnvName :: OrgParser String
+latexEnvName = try $ do
+ mappend <$> many1 alphaNum
+ <*> option "" (string "*")
+
+
+--
+-- Footnote defintions
+--
+noteBlock :: OrgParser (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 :: OrgParser (F Blocks)
+paraOrPlain = try $
+ parseInlines <**> (fmap <$> option B.plain (try $ newline *> pure B.para))
+
+inlinesTillNewline :: OrgParser (F Inlines)
+inlinesTillNewline = trimInlinesF . mconcat <$> manyTill inline newline
+
+
+--
+-- list blocks
+--
+
+list :: OrgParser (F Blocks)
+list = choice [ definitionList, bulletList, orderedList ] <?> "list"
+
+definitionList :: OrgParser (F Blocks)
+definitionList = fmap B.definitionList . fmap compactify'DL . sequence
+ <$> many1 (definitionListItem bulletListStart)
+
+bulletList :: OrgParser (F Blocks)
+bulletList = fmap B.bulletList . fmap compactify' . sequence
+ <$> many1 (listItem bulletListStart)
+
+orderedList :: OrgParser (F Blocks)
+orderedList = fmap B.orderedList . fmap compactify' . sequence
+ <$> many1 (listItem orderedListStart)
+
+genericListStart :: OrgParser String
+ -> OrgParser Int
+genericListStart listMarker = try $
+ (+) <$> (length <$> many spaceChar)
+ <*> (length <$> listMarker <* many1 spaceChar)
+
+-- parses bullet list start and returns its length (excl. following whitespace)
+bulletListStart :: OrgParser Int
+bulletListStart = genericListStart bulletListMarker
+ where bulletListMarker = pure <$> oneOf "*-+"
+
+orderedListStart :: OrgParser Int
+orderedListStart = genericListStart orderedListMarker
+ -- Ordered list markers allowed in org-mode
+ where orderedListMarker = mappend <$> many1 digit <*> (pure <$> oneOf ".)")
+
+definitionListItem :: OrgParser Int
+ -> OrgParser (F (Inlines, [Blocks]))
+definitionListItem parseMarkerGetLength = try $ do
+ markerLength <- parseMarkerGetLength
+ term <- manyTill (noneOf "\n\r") (try $ string "::")
+ line1 <- anyLineNewline
+ blank <- option "" ("\n" <$ blankline)
+ cont <- concat <$> many (listContinuation markerLength)
+ term' <- parseFromString inline term
+ contents' <- parseFromString parseBlocks $ line1 ++ blank ++ cont
+ return $ (,) <$> term' <*> fmap (:[]) contents'
+
+
+-- parse raw text for one list item, excluding start marker and continuations
+listItem :: OrgParser Int
+ -> OrgParser (F Blocks)
+listItem start = try $ do
+ markerLength <- try start
+ firstLine <- anyLineNewline
+ blank <- option "" ("\n" <$ blankline)
+ rest <- concat <$> many (listContinuation markerLength)
+ parseFromString parseBlocks $ firstLine ++ blank ++ rest
+
+-- continuation of a list item - indented and separated by blankline or endline.
+-- Note: nested lists are parsed as continuations.
+listContinuation :: Int
+ -> OrgParser String
+listContinuation markerLength = try $
+ notFollowedBy' blankline
+ *> (mappend <$> (concat <$> many1 listLine)
+ <*> many blankline)
+ where listLine = try $ indentWith markerLength *> anyLineNewline
+
+anyLineNewline :: OrgParser String
+anyLineNewline = (++ "\n") <$> anyLine
+
+
+--
+-- inline
+--
+
+inline :: OrgParser (F Inlines)
+inline =
+ choice [ whitespace
+ , linebreak
+ , cite
+ , footnote
+ , linkOrImage
+ , anchor
+ , inlineCodeBlock
+ , str
+ , endline
+ , emph
+ , strong
+ , strikeout
+ , underline
+ , code
+ , math
+ , displayMath
+ , verbatim
+ , subscript
+ , superscript
+ , inlineLaTeX
+ , symbol
+ ] <* (guard =<< newlinesCountWithinLimits)
+ <?> "inline"
+
+parseInlines :: OrgParser (F Inlines)
+parseInlines = trimInlinesF . mconcat <$> many1 inline
+
+-- treat these as potentially non-text when parsing inline:
+specialChars :: [Char]
+specialChars = "\"$'()*+-./:<=>[\\]^_{|}~"
+
+
+whitespace :: OrgParser (F Inlines)
+whitespace = pure B.space <$ skipMany1 spaceChar
+ <* updateLastPreCharPos
+ <* updateLastForbiddenCharPos
+ <?> "whitespace"
+
+linebreak :: OrgParser (F Inlines)
+linebreak = try $ pure B.linebreak <$ string "\\\\" <* skipSpaces <* newline
+
+str :: OrgParser (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 :: OrgParser (F Inlines)
+endline = try $ do
+ newline
+ notFollowedBy blankline
+ notFollowedBy' exampleLine
+ notFollowedBy' hline
+ notFollowedBy' noteMarker
+ notFollowedBy' tableStart
+ notFollowedBy' drawerStart
+ notFollowedBy' headerStart
+ notFollowedBy' metaLineStart
+ notFollowedBy' latexEnvStart
+ notFollowedBy' commentLineStart
+ notFollowedBy' bulletListStart
+ notFollowedBy' orderedListStart
+ decEmphasisNewlinesCount
+ guard =<< newlinesCountWithinLimits
+ updateLastPreCharPos
+ return . return $ B.space
+
+cite :: OrgParser (F Inlines)
+cite = try $ do
+ guardEnabled Ext_citations
+ (cs, raw) <- withRaw normalCite
+ return $ (flip B.cite (B.text raw)) <$> cs
+
+normalCite :: OrgParser (F [Citation])
+normalCite = try $ char '['
+ *> skipSpaces
+ *> citeList
+ <* skipSpaces
+ <* char ']'
+
+citeList :: OrgParser (F [Citation])
+citeList = sequence <$> sepBy1 citation (try $ char ';' *> skipSpaces)
+
+citation :: OrgParser (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 :: OrgParser (F Inlines)
+footnote = try $ inlineNote <|> referencedNote
+
+inlineNote :: OrgParser (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 :: OrgParser (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'
+
+noteMarker :: OrgParser String
+noteMarker = try $ do
+ char '['
+ choice [ many1Till digit (char ']')
+ , (++) <$> string "fn:"
+ <*> many1Till (noneOf "\n\r\t ") (char ']')
+ ]
+
+linkOrImage :: OrgParser (F Inlines)
+linkOrImage = explicitOrImageLink
+ <|> selflinkOrImage
+ <|> angleLink
+ <|> plainLink
+ <?> "link or image"
+
+explicitOrImageLink :: OrgParser (F Inlines)
+explicitOrImageLink = try $ do
+ char '['
+ srcF <- applyCustomLinkFormat =<< linkTarget
+ title <- enclosedRaw (char '[') (char ']')
+ title' <- parseFromString (mconcat <$> many inline) title
+ char ']'
+ return $ do
+ src <- srcF
+ if isImageFilename src && isImageFilename title
+ then pure $ B.link src "" $ B.image title mempty mempty
+ else linkToInlinesF src =<< title'
+
+selflinkOrImage :: OrgParser (F Inlines)
+selflinkOrImage = try $ do
+ src <- char '[' *> linkTarget <* char ']'
+ return $ linkToInlinesF src (B.str src)
+
+plainLink :: OrgParser (F Inlines)
+plainLink = try $ do
+ (orig, src) <- uri
+ returnF $ B.link src "" (B.str orig)
+
+angleLink :: OrgParser (F Inlines)
+angleLink = try $ do
+ char '<'
+ link <- plainLink
+ char '>'
+ return link
+
+selfTarget :: OrgParser String
+selfTarget = try $ char '[' *> linkTarget <* char ']'
+
+linkTarget :: OrgParser String
+linkTarget = enclosedByPair '[' ']' (noneOf "\n\r[]")
+
+applyCustomLinkFormat :: String -> OrgParser (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
+
+
+linkToInlinesF :: String -> Inlines -> F Inlines
+linkToInlinesF s@('#':_) = pure . B.link s ""
+linkToInlinesF s
+ | isImageFilename s = const . pure $ B.image s "" ""
+ | isUri s = pure . B.link s ""
+ | isRelativeUrl s = pure . B.link s ""
+linkToInlinesF s = \title -> do
+ anchorB <- (s `elem`) <$> asksF orgStateAnchorIds
+ if anchorB
+ then pure $ B.link ('#':s) "" title
+ else pure $ B.emph title
+
+isRelativeUrl :: String -> Bool
+isRelativeUrl s = (':' `notElem` s) && ("./" `isPrefixOf` s)
+
+isUri :: String -> Bool
+isUri s = let (scheme, path) = break (== ':') s
+ in all (\c -> isAlphaNum c || c `elem` ".-") scheme
+ && not (null path)
+
+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" ]
+
+-- | 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 :: OrgParser (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` "_.-:" = c
+ | otherwise = '-'
+
+-- | Parses an inline code block and marks it as an babel block.
+inlineCodeBlock :: OrgParser (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
+
+enclosedByPair :: Char -- ^ opening char
+ -> Char -- ^ closing char
+ -> OrgParser a -- ^ parser
+ -> OrgParser [a]
+enclosedByPair s e p = char s *> many1Till p (char e)
+
+emph :: OrgParser (F Inlines)
+emph = fmap B.emph <$> emphasisBetween '/'
+
+strong :: OrgParser (F Inlines)
+strong = fmap B.strong <$> emphasisBetween '*'
+
+strikeout :: OrgParser (F Inlines)
+strikeout = fmap B.strikeout <$> emphasisBetween '+'
+
+-- There is no underline, so we use strong instead.
+underline :: OrgParser (F Inlines)
+underline = fmap B.strong <$> emphasisBetween '_'
+
+verbatim :: OrgParser (F Inlines)
+verbatim = return . B.code <$> verbatimBetween '='
+
+code :: OrgParser (F Inlines)
+code = return . B.code <$> verbatimBetween '~'
+
+subscript :: OrgParser (F Inlines)
+subscript = fmap B.subscript <$> try (char '_' *> subOrSuperExpr)
+
+superscript :: OrgParser (F Inlines)
+superscript = fmap B.superscript <$> try (char '^' *> subOrSuperExpr)
+
+math :: OrgParser (F Inlines)
+math = return . B.math <$> choice [ math1CharBetween '$'
+ , mathStringBetween '$'
+ , rawMathBetween "\\(" "\\)"
+ ]
+
+displayMath :: OrgParser (F Inlines)
+displayMath = return . B.displayMath <$> choice [ rawMathBetween "\\[" "\\]"
+ , rawMathBetween "$$" "$$"
+ ]
+symbol :: OrgParser (F Inlines)
+symbol = return . B.str . (: "") <$> (oneOf specialChars >>= updatePositions)
+ where updatePositions c
+ | c `elem` emphasisPreChars = c <$ updateLastPreCharPos
+ | c `elem` emphasisForbiddenBorderChars = c <$ updateLastForbiddenCharPos
+ | otherwise = return c
+
+emphasisBetween :: Char
+ -> OrgParser (F Inlines)
+emphasisBetween c = try $ do
+ startEmphasisNewlinesCounting emphasisAllowedNewlines
+ res <- enclosedInlines (emphasisStart c) (emphasisEnd c)
+ isTopLevelEmphasis <- null . orgStateEmphasisCharStack <$> getState
+ when isTopLevelEmphasis
+ resetEmphasisNewlines
+ return res
+
+verbatimBetween :: Char
+ -> OrgParser String
+verbatimBetween c = try $
+ emphasisStart c *>
+ many1TillNOrLessNewlines 1 (noneOf "\n\r") (emphasisEnd c)
+
+-- | Parses a raw string delimited by @c@ using Org's math rules
+mathStringBetween :: Char
+ -> OrgParser 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 :: Char
+ -> OrgParser String
+math1CharBetween c = try $ do
+ char c
+ res <- noneOf $ c:mathForbiddenBorderChars
+ char c
+ eof <|> () <$ lookAhead (oneOf mathPostChars)
+ return [res]
+
+rawMathBetween :: String
+ -> String
+ -> OrgParser String
+rawMathBetween s e = try $ string s *> manyTill anyChar (try $ string e)
+
+-- | Parses the start (opening character) of emphasis
+emphasisStart :: Char -> OrgParser Char
+emphasisStart c = try $ do
+ guard =<< afterEmphasisPreChar
+ guard =<< notAfterString
+ char c
+ lookAhead (noneOf emphasisForbiddenBorderChars)
+ pushToInlineCharStack c
+ return c
+
+-- | Parses the closing character of emphasis
+emphasisEnd :: Char -> OrgParser Char
+emphasisEnd c = try $ do
+ guard =<< notAfterForbiddenBorderChar
+ char c
+ eof <|> () <$ lookAhead acceptablePostChars
+ updateLastStrPos
+ popInlineCharStack
+ return c
+ where acceptablePostChars =
+ surroundingEmphasisChar >>= \x -> oneOf (x ++ emphasisPostChars)
+
+mathStart :: Char -> OrgParser Char
+mathStart c = try $
+ char c <* notFollowedBy' (oneOf (c:mathForbiddenBorderChars))
+
+mathEnd :: Char -> OrgParser Char
+mathEnd c = try $ do
+ res <- noneOf (c:mathForbiddenBorderChars)
+ char c
+ eof <|> () <$ lookAhead (oneOf mathPostChars)
+ return res
+
+
+enclosedInlines :: OrgParser a
+ -> OrgParser b
+ -> OrgParser (F Inlines)
+enclosedInlines start end = try $
+ trimInlinesF . mconcat <$> enclosed start end inline
+
+enclosedRaw :: OrgParser a
+ -> OrgParser b
+ -> OrgParser 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 :: Int
+ -> OrgParser Char
+ -> OrgParser a
+ -> OrgParser 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 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 :: OrgParser Bool
+afterEmphasisPreChar = do
+ pos <- getPosition
+ lastPrePos <- orgStateLastPreCharPos <$> getState
+ return . fromMaybe True $ (== pos) <$> lastPrePos
+
+-- | Whether the parser is right after a forbidden border char
+notAfterForbiddenBorderChar :: OrgParser Bool
+notAfterForbiddenBorderChar = do
+ pos <- getPosition
+ lastFBCPos <- orgStateLastForbiddenCharPos <$> getState
+ return $ lastFBCPos /= Just pos
+
+-- | Read a sub- or superscript expression
+subOrSuperExpr :: OrgParser (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 :: OrgParser String
+simpleSubOrSuperString = try $
+ choice [ string "*"
+ , mappend <$> option [] ((:[]) <$> oneOf "+-")
+ <*> many1 alphaNum
+ ]
+
+inlineLaTeX :: OrgParser (F Inlines)
+inlineLaTeX = try $ do
+ cmd <- inlineLaTeXCommand
+ maybe mzero returnF $ parseAsMath cmd `mplus` parseAsInlineLaTeX cmd
+ where
+ parseAsMath :: String -> Maybe Inlines
+ parseAsMath cs = maybeRight $ B.fromList <$> texMathToPandoc DisplayInline cs
+
+ parseAsInlineLaTeX :: String -> Maybe Inlines
+ parseAsInlineLaTeX cs = maybeRight $ runParser inlineCommand state "" cs
+
+ state :: ParserState
+ state = def{ stateOptions = def{ readerParseRaw = True }}
+
+maybeRight :: Either a b -> Maybe b
+maybeRight = either (const Nothing) Just
+
+inlineLaTeXCommand :: OrgParser String
+inlineLaTeXCommand = try $ do
+ rest <- getInput
+ case runParser rawLaTeXInline def "source" rest of
+ Right (RawInline _ cs) -> do
+ let len = length cs
+ count len anyChar
+ return cs
+ _ -> mzero
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 34962b553..fa8438e70 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -1,5 +1,6 @@
+{-# LANGUAGE OverloadedStrings #-}
{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -18,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Readers.RST
- Copyright : Copyright (C) 2006-2010 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -35,12 +36,13 @@ import Text.Pandoc.Builder (setMeta, fromList)
import Text.Pandoc.Shared
import Text.Pandoc.Parsing
import Text.Pandoc.Options
-import Control.Monad ( when, liftM, guard, mzero )
+import Control.Monad ( when, liftM, guard, mzero, mplus )
import Data.List ( findIndex, intersperse, intercalate,
transpose, sort, deleteFirstsBy, isSuffixOf )
+import Data.Maybe (fromMaybe)
import qualified Data.Map as M
import Text.Printf ( printf )
-import Control.Applicative ((<$>), (<$), (<*), (*>))
+import Control.Applicative ((<$>), (<$), (<*), (*>), (<*>))
import Text.Pandoc.Builder (Inlines, Blocks, trimInlines, (<>))
import qualified Text.Pandoc.Builder as B
import Data.Monoid (mconcat, mempty)
@@ -111,15 +113,16 @@ titleTransform (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 toPlain "author"
+ adjustAuthors (Meta metamap) = Meta $ M.adjust splitAuthors "author"
$ M.adjust toPlain "date"
$ M.adjust toPlain "title"
- $ M.adjust splitAuthors "authors"
+ $ 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 (MetaBlocks [Para xs])
+ = MetaList $ map MetaInlines
+ $ splitAuthors' xs
splitAuthors x = x
splitAuthors' = map normalizeSpaces .
splitOnSemi . concatMap factorSemi
@@ -183,22 +186,22 @@ block = choice [ codeBlock
-- field list
--
-rawFieldListItem :: String -> RSTParser (String, String)
-rawFieldListItem indent = try $ do
- string indent
+rawFieldListItem :: Int -> RSTParser (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 (string indent >> spaceChar)
+ 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 :: String
- -> RSTParser (Inlines, [Blocks])
-fieldListItem indent = try $ do
- (name, raw) <- rawFieldListItem indent
+fieldListItem :: Int -> RSTParser (Inlines, [Blocks])
+fieldListItem minIndent = try $ do
+ (name, raw) <- rawFieldListItem minIndent
let term = B.str name
contents <- parseFromString parseBlocks raw
optional blanklines
@@ -206,7 +209,7 @@ fieldListItem indent = try $ do
fieldList :: RSTParser Blocks
fieldList = try $ do
- indent <- lookAhead $ many spaceChar
+ indent <- length <$> lookAhead (many spaceChar)
items <- many1 $ fieldListItem indent
case items of
[] -> return mempty
@@ -274,7 +277,8 @@ doubleHeader = try $ do
Just ind -> (headerTable, ind + 1)
Nothing -> (headerTable ++ [DoubleHeader c], (length headerTable) + 1)
setState (state { stateHeaderTable = headerTable' })
- return $ B.header level txt
+ attr <- registerHeader nullAttr txt
+ return $ B.headerWith attr level txt
-- a header with line on the bottom only
singleHeader :: RSTParser Blocks
@@ -294,7 +298,8 @@ singleHeader = try $ do
Just ind -> (headerTable, ind + 1)
Nothing -> (headerTable ++ [SingleHeader c], (length headerTable) + 1)
setState (state { stateHeaderTable = headerTable' })
- return $ B.header level txt
+ attr <- registerHeader nullAttr txt
+ return $ B.headerWith attr level txt
--
-- hrule block
@@ -344,14 +349,25 @@ lhsCodeBlock = try $ do
getPosition >>= guard . (==1) . sourceColumn
guardEnabled Ext_literate_haskell
optional codeBlockStart
- lns <- many1 birdTrackLine
- -- 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
+ lns <- latexCodeBlock <|> birdCodeBlock
blanklines
return $ B.codeBlockWith ("", ["sourceCode", "literate", "haskell"], [])
- $ intercalate "\n" lns'
+ $ intercalate "\n" lns
+
+latexCodeBlock :: Parser [Char] st [[Char]]
+latexCodeBlock = try $ do
+ try (latexBlockLine "\\begin{code}")
+ many1Till anyLine (try $ latexBlockLine "\\end{code}")
+ where
+ latexBlockLine s = skipMany spaceChar >> string s >> blankline
+
+birdCodeBlock :: Parser [Char] st [[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 :: Parser [Char] st [Char]
birdTrackLine = char '>' >> anyLine
@@ -506,17 +522,17 @@ directive' = do
skipMany spaceChar
top <- many $ satisfy (/='\n')
<|> try (char '\n' <*
- notFollowedBy' (rawFieldListItem " ") <*
+ notFollowedBy' (rawFieldListItem 3) <*
count 3 (char ' ') <*
notFollowedBy blankline)
newline
- fields <- many $ rawFieldListItem " "
+ fields <- many $ rawFieldListItem 3
body <- option "" $ try $ blanklines >> indentedBlock
optional blanklines
let body' = body ++ "\n\n"
case label of
"raw" -> return $ B.rawBlock (trim top) (stripTrailingNewlines body)
- "role" -> return mempty
+ "role" -> addNewRole top $ map (\(k,v) -> (k, trim v)) fields
"container" -> parseFromString parseBlocks body'
"replace" -> B.para <$> -- consumed by substKey
parseFromString (trimInlines . mconcat <$> many inline)
@@ -561,12 +577,15 @@ directive' = do
role -> role })
"code" -> codeblock (lookup "number-lines" fields) (trim top) body
"code-block" -> codeblock (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.image src "" caption) <> legend
+ return $ B.para (B.image src "fig:" caption) <> legend
"image" -> do
let src = escapeURI $ trim top
let alt = B.str $ maybe "image" trim $ lookup "alt" fields
@@ -577,7 +596,38 @@ directive' = do
Nothing -> B.image src "" alt
_ -> return mempty
--- Can contain haracter codes as decimal numbers or
+-- TODO:
+-- - Silently ignores illegal fields
+-- - Silently drops classes
+-- - Only supports :format: fields with a single format for :raw: roles,
+-- change Text.Pandoc.Definition.Format to fix
+addNewRole :: String -> [(String, String)] -> RSTParser Blocks
+addNewRole roleString fields = do
+ (role, parentRole) <- parseFromString inheritedRole roleString
+ customRoles <- stateRstCustomRoles <$> getState
+ baseRole <- case M.lookup parentRole customRoles of
+ Just (base, _, _) -> return base
+ Nothing -> return parentRole
+
+ let fmt = if baseRole == "raw" then lookup "format" fields else Nothing
+ annotate = maybe id addLanguage $
+ if baseRole == "code"
+ then lookup "language" fields
+ else Nothing
+
+ updateState $ \s -> s {
+ stateRstCustomRoles =
+ M.insert role (baseRole, fmt, (,) parentRole . annotate) customRoles
+ }
+
+ return $ B.singleton Null
+ where
+ addLanguage lang (ident, classes, keyValues) =
+ (ident, "sourceCode" : lang : classes, keyValues)
+ inheritedRole =
+ (,) <$> roleNameEndingIn (char '(') <*> roleNameEndingIn (char ')')
+
+-- 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 ..
@@ -916,17 +966,56 @@ strong = B.strong . trimInlines . mconcat <$>
-- 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 :: RSTParser Inlines
interpretedRole = try $ do
(role, contents) <- roleBefore <|> roleAfter
- case role of
- "sup" -> return $ B.superscript $ B.str contents
- "sub" -> return $ B.subscript $ B.str contents
- "math" -> return $ B.math contents
- _ -> return $ B.str contents --unknown
+ renderRole contents Nothing role nullAttr
+
+renderRole :: String -> Maybe String -> String -> Attr -> RSTParser 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.str contents
+ "math" -> return $ B.math contents
+ "title-reference" -> titleRef contents
+ "title" -> titleRef contents
+ "t" -> titleRef contents
+ "code" -> return $ B.codeWith attr contents
+ "raw" -> return $ B.rawInline (fromMaybe "" fmt) contents
+ custom -> do
+ customRole <- stateRstCustomRoles <$> getState
+ case M.lookup custom customRole of
+ Just (_, newFmt, inherit) -> let
+ fmtStr = fmt `mplus` newFmt
+ (newRole, newAttr) = inherit attr
+ in renderRole contents fmtStr newRole newAttr
+ Nothing -> 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 ++ "/"
+
+roleNameEndingIn :: RSTParser Char -> RSTParser String
+roleNameEndingIn end = many1Till (letter <|> char '-') end
roleMarker :: RSTParser String
-roleMarker = char ':' *> many1Till (letter <|> char '-') (char ':')
+roleMarker = char ':' *> roleNameEndingIn (char ':')
roleBefore :: RSTParser (String,String)
roleBefore = try $ do
@@ -1055,7 +1144,7 @@ smart :: RSTParser Inlines
smart = do
getOption readerSmart >>= guard
doubleQuoted <|> singleQuoted <|>
- choice (map (B.singleton <$>) [apostrophe, dash, ellipses])
+ choice [apostrophe, dash, ellipses]
singleQuoted :: RSTParser Inlines
singleQuoted = try $ do
diff --git a/src/Text/Pandoc/Readers/TeXMath.hs b/src/Text/Pandoc/Readers/TeXMath.hs
index fe49a992e..f03eae044 100644
--- a/src/Text/Pandoc/Readers/TeXMath.hs
+++ b/src/Text/Pandoc/Readers/TeXMath.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2007-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2007-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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Readers.TeXMath
- Copyright : Copyright (C) 2007-2010 John MacFarlane
+ Copyright : Copyright (C) 2007-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -27,96 +27,30 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Conversion of TeX math to a list of 'Pandoc' inline elements.
-}
-module Text.Pandoc.Readers.TeXMath ( readTeXMath ) where
+module Text.Pandoc.Readers.TeXMath ( readTeXMath, readTeXMath' ) where
import Text.Pandoc.Definition
-import Text.TeXMath.Types
-import Text.TeXMath.Parser
+import Text.TeXMath
-- | Converts a raw TeX math formula to a list of 'Pandoc' inlines.
--- Defaults to raw formula between @$@ characters if entire formula
+-- Defaults to raw formula between @$@ or @$$@ characters if entire formula
-- can't be converted.
+readTeXMath' :: MathType
+ -> String -- ^ String to parse (assumes @'\n'@ line endings)
+ -> [Inline]
+readTeXMath' mt inp = case texMathToPandoc dt inp of
+ Left _ -> [Str (delim ++ inp ++ delim)]
+ Right res -> res
+ where (dt, delim) = case mt of
+ DisplayMath -> (DisplayBlock, "$$")
+ InlineMath -> (DisplayInline, "$")
+
+{-# DEPRECATED readTeXMath "Use readTeXMath' from Text.Pandoc.JSON instead" #-}
+-- | Converts a raw TeX math formula to a list of 'Pandoc' inlines.
+-- Defaults to raw formula between @$@ characters if entire formula
+-- can't be converted. (This is provided for backwards compatibility;
+-- it is better to use @readTeXMath'@, which properly distinguishes
+-- between display and inline math.)
readTeXMath :: String -- ^ String to parse (assumes @'\n'@ line endings)
-> [Inline]
-readTeXMath inp = case texMathToPandoc inp of
- Left _ -> [Str ("$" ++ inp ++ "$")]
- Right res -> res
-
-texMathToPandoc :: String -> Either String [Inline]
-texMathToPandoc inp = inp `seq`
- case parseFormula inp of
- Left err -> Left err
- Right exps -> case expsToInlines exps of
- Nothing -> Left "Formula too complex for [Inline]"
- Just r -> Right r
-
-expsToInlines :: [Exp] -> Maybe [Inline]
-expsToInlines xs = do
- res <- mapM expToInlines xs
- return (concat res)
-
-expToInlines :: Exp -> Maybe [Inline]
-expToInlines (ENumber s) = Just [Str s]
-expToInlines (EIdentifier s) = Just [Emph [Str s]]
-expToInlines (EMathOperator s) = Just [Str s]
-expToInlines (ESymbol t s) = Just $ addSpace t (Str s)
- where addSpace Op x = [x, thinspace]
- addSpace Bin x = [medspace, x, medspace]
- addSpace Rel x = [widespace, x, widespace]
- addSpace Pun x = [x, thinspace]
- addSpace _ x = [x]
- thinspace = Str "\x2006"
- medspace = Str "\x2005"
- widespace = Str "\x2004"
-expToInlines (EStretchy x) = expToInlines x
-expToInlines (EDelimited start end xs) = do
- xs' <- mapM expToInlines xs
- return $ [Str start] ++ concat xs' ++ [Str end]
-expToInlines (EGrouped xs) = expsToInlines xs
-expToInlines (ESpace "0.167em") = Just [Str "\x2009"]
-expToInlines (ESpace "0.222em") = Just [Str "\x2005"]
-expToInlines (ESpace "0.278em") = Just [Str "\x2004"]
-expToInlines (ESpace "0.333em") = Just [Str "\x2004"]
-expToInlines (ESpace "1em") = Just [Str "\x2001"]
-expToInlines (ESpace "2em") = Just [Str "\x2001\x2001"]
-expToInlines (ESpace _) = Just [Str " "]
-expToInlines (EBinary _ _ _) = Nothing
-expToInlines (ESub x y) = do
- x' <- expToInlines x
- y' <- expToInlines y
- return $ x' ++ [Subscript y']
-expToInlines (ESuper x y) = do
- x' <- expToInlines x
- y' <- expToInlines y
- return $ x' ++ [Superscript y']
-expToInlines (ESubsup x y z) = do
- x' <- expToInlines x
- y' <- expToInlines y
- z' <- expToInlines z
- return $ x' ++ [Subscript y'] ++ [Superscript z']
-expToInlines (EDown x y) = expToInlines (ESub x y)
-expToInlines (EUp x y) = expToInlines (ESuper x y)
-expToInlines (EDownup x y z) = expToInlines (ESubsup x y z)
-expToInlines (EText TextNormal x) = Just [Str x]
-expToInlines (EText TextBold x) = Just [Strong [Str x]]
-expToInlines (EText TextMonospace x) = Just [Code nullAttr x]
-expToInlines (EText TextItalic x) = Just [Emph [Str x]]
-expToInlines (EText _ x) = Just [Str x]
-expToInlines (EOver (EGrouped [EIdentifier [c]]) (ESymbol Accent [accent])) =
- case accent of
- '\x203E' -> Just [Emph [Str [c,'\x0304']]] -- bar
- '\x00B4' -> Just [Emph [Str [c,'\x0301']]] -- acute
- '\x0060' -> Just [Emph [Str [c,'\x0300']]] -- grave
- '\x02D8' -> Just [Emph [Str [c,'\x0306']]] -- breve
- '\x02C7' -> Just [Emph [Str [c,'\x030C']]] -- check
- '.' -> Just [Emph [Str [c,'\x0307']]] -- dot
- '\x00B0' -> Just [Emph [Str [c,'\x030A']]] -- ring
- '\x20D7' -> Just [Emph [Str [c,'\x20D7']]] -- arrow right
- '\x20D6' -> Just [Emph [Str [c,'\x20D6']]] -- arrow left
- '\x005E' -> Just [Emph [Str [c,'\x0302']]] -- hat
- '\x0302' -> Just [Emph [Str [c,'\x0302']]] -- hat
- '~' -> Just [Emph [Str [c,'\x0303']]] -- tilde
- _ -> Nothing
-expToInlines _ = Nothing
-
-
+readTeXMath = readTeXMath' InlineMath
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs
index a1687a691..6d839ec1d 100644
--- a/src/Text/Pandoc/Readers/Textile.hs
+++ b/src/Text/Pandoc/Readers/Textile.hs
@@ -1,5 +1,6 @@
{-
-Copyright (C) 2010 Paul Rivier <paul*rivier#demotera*com> | tr '*#' '.@'
+Copyright (C) 2010-2014 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
@@ -18,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Readers.Textile
- Copyright : Copyright (C) 2010-2012 Paul Rivier and John MacFarlane
+ Copyright : Copyright (C) 2010-2014 Paul Rivier and John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : Paul Rivier <paul*rivier#demotera*com>
@@ -50,18 +51,22 @@ TODO : refactor common patterns across readers :
module Text.Pandoc.Readers.Textile ( readTextile) where
-
import Text.Pandoc.Definition
-import Text.Pandoc.Shared
+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.Readers.HTML ( htmlTag, isInlineTag, isBlockTag )
import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )
+import Text.HTML.TagSoup (parseTags, innerText, fromAttrib, Tag(..))
import Text.HTML.TagSoup.Match
import Data.List ( intercalate )
-import Data.Char ( digitToInt, isUpper )
-import Control.Monad ( guard, liftM )
-import Control.Applicative ((<$>), (*>), (<*))
+import Data.Char ( digitToInt, isUpper)
+import Control.Monad ( guard, liftM, when )
+import Text.Printf
+import Control.Applicative ((<$>), (*>), (<*), (<$))
+import Data.Monoid
+import Debug.Trace (trace)
-- | Parse a Textile text and return a Pandoc document.
readTextile :: ReaderOptions -- ^ Reader options
@@ -93,7 +98,7 @@ parseTextile = do
updateState $ \s -> s { stateNotes = reverse reversedNotes }
-- now parse it for real...
blocks <- parseBlocks
- return $ Pandoc nullMeta blocks -- FIXME
+ return $ Pandoc nullMeta (B.toList blocks) -- FIXME
noteMarker :: Parser [Char] ParserState [Char]
noteMarker = skipMany spaceChar >> string "fn" >> manyTill digit (char '.')
@@ -113,11 +118,11 @@ noteBlock = try $ do
return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
-- | Parse document blocks
-parseBlocks :: Parser [Char] ParserState [Block]
-parseBlocks = manyTill block eof
+parseBlocks :: Parser [Char] ParserState Blocks
+parseBlocks = mconcat <$> manyTill block eof
-- | Block parsers list tried in definition order
-blockParsers :: [Parser [Char] ParserState Block]
+blockParsers :: [Parser [Char] ParserState Blocks]
blockParsers = [ codeBlock
, header
, blockQuote
@@ -128,32 +133,45 @@ blockParsers = [ codeBlock
, rawLaTeXBlock'
, maybeExplicitBlock "table" table
, maybeExplicitBlock "p" para
+ , endBlock
]
--- | Any block in the order of definition of blockParsers
-block :: Parser [Char] ParserState Block
-block = choice blockParsers <?> "block"
+endBlock :: Parser [Char] ParserState Blocks
+endBlock = string "\n\n" >> return mempty
-commentBlock :: Parser [Char] ParserState Block
+-- | Any block in the order of definition of blockParsers
+block :: Parser [Char] ParserState Blocks
+block = do
+ res <- choice blockParsers <?> "block"
+ pos <- getPosition
+ tr <- getOption readerTrace
+ when tr $
+ trace (printf "line %d: %s" (sourceLine pos)
+ (take 60 $ show $ B.toList res)) (return ())
+ return res
+
+commentBlock :: Parser [Char] ParserState Blocks
commentBlock = try $ do
string "###."
manyTill anyLine blanklines
- return Null
+ return mempty
-codeBlock :: Parser [Char] ParserState Block
+codeBlock :: Parser [Char] ParserState Blocks
codeBlock = codeBlockBc <|> codeBlockPre
-codeBlockBc :: Parser [Char] ParserState Block
+codeBlockBc :: Parser [Char] ParserState Blocks
codeBlockBc = try $ do
string "bc. "
contents <- manyTill anyLine blanklines
- return $ CodeBlock ("",[],[]) $ unlines contents
+ return $ B.codeBlock (unlines contents)
-- | Code Blocks in Textile are between <pre> and </pre>
-codeBlockPre :: Parser [Char] ParserState Block
+codeBlockPre :: Parser [Char] ParserState Blocks
codeBlockPre = try $ do
- htmlTag (tagOpen (=="pre") null)
- result' <- manyTill anyChar (try $ htmlTag (tagClose (=="pre")) >> blockBreak)
+ (t@(TagOpen _ attrs),_) <- htmlTag (tagOpen (=="pre") (const True))
+ result' <- (innerText . parseTags) `fmap` -- remove internal tags
+ manyTill anyChar (htmlTag (tagClose (=="pre")))
+ optional blanklines
-- drop leading newline if any
let result'' = case result' of
'\n':xs -> xs
@@ -162,28 +180,32 @@ codeBlockPre = try $ do
let result''' = case reverse result'' of
'\n':_ -> init result''
_ -> result''
- return $ CodeBlock ("",[],[]) 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 :: Parser [Char] ParserState Block
+header :: Parser [Char] ParserState Blocks
header = try $ do
char 'h'
level <- digitToInt <$> oneOf "123456"
attr <- attributes
char '.'
- whitespace
- name <- normalizeSpaces <$> manyTill inline blockBreak
- return $ Header level attr name
+ lookAhead whitespace
+ name <- trimInlines . mconcat <$> manyTill inline blockBreak
+ attr' <- registerHeader attr name
+ return $ B.headerWith attr' level name
-- | Blockquote of the form "bq. content"
-blockQuote :: Parser [Char] ParserState Block
+blockQuote :: Parser [Char] ParserState Blocks
blockQuote = try $ do
string "bq" >> attributes >> char '.' >> whitespace
- BlockQuote . singleton <$> para
+ B.blockQuote <$> para
-- Horizontal rule
-hrule :: Parser [Char] st Block
+hrule :: Parser [Char] st Blocks
hrule = try $ do
skipSpaces
start <- oneOf "-*"
@@ -191,62 +213,62 @@ hrule = try $ do
skipMany (spaceChar <|> char start)
newline
optional blanklines
- return HorizontalRule
+ 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 :: Parser [Char] ParserState Block
+anyList :: Parser [Char] ParserState Blocks
anyList = try $ anyListAtDepth 1 <* blanklines
-- | This allow one type of list to be nested into an other type,
-- provided correct nesting
-anyListAtDepth :: Int -> Parser [Char] ParserState Block
+anyListAtDepth :: Int -> Parser [Char] ParserState Blocks
anyListAtDepth depth = choice [ bulletListAtDepth depth,
orderedListAtDepth depth,
definitionList ]
-- | Bullet List of given depth, depth being the number of leading '*'
-bulletListAtDepth :: Int -> Parser [Char] ParserState Block
-bulletListAtDepth depth = try $ BulletList <$> many1 (bulletListItemAtDepth depth)
+bulletListAtDepth :: Int -> Parser [Char] ParserState Blocks
+bulletListAtDepth depth = try $ B.bulletList <$> many1 (bulletListItemAtDepth depth)
-- | Bullet List Item of given depth, depth being the number of
-- leading '*'
-bulletListItemAtDepth :: Int -> Parser [Char] ParserState [Block]
+bulletListItemAtDepth :: Int -> Parser [Char] ParserState Blocks
bulletListItemAtDepth = genericListItemAtDepth '*'
-- | Ordered List of given depth, depth being the number of
-- leading '#'
-orderedListAtDepth :: Int -> Parser [Char] ParserState Block
+orderedListAtDepth :: Int -> Parser [Char] ParserState Blocks
orderedListAtDepth depth = try $ do
items <- many1 (orderedListItemAtDepth depth)
- return (OrderedList (1, DefaultStyle, DefaultDelim) items)
+ return $ B.orderedList items
-- | Ordered List Item of given depth, depth being the number of
-- leading '#'
-orderedListItemAtDepth :: Int -> Parser [Char] ParserState [Block]
+orderedListItemAtDepth :: Int -> Parser [Char] ParserState Blocks
orderedListItemAtDepth = genericListItemAtDepth '#'
-- | Common implementation of list items
-genericListItemAtDepth :: Char -> Int -> Parser [Char] ParserState [Block]
+genericListItemAtDepth :: Char -> Int -> Parser [Char] ParserState Blocks
genericListItemAtDepth c depth = try $ do
count depth (char c) >> attributes >> whitespace
- p <- many listInline
+ p <- mconcat <$> many listInline
newline
- sublist <- option [] (singleton <$> anyListAtDepth (depth + 1))
- return (Plain p : sublist)
+ sublist <- option mempty (anyListAtDepth (depth + 1))
+ return $ (B.plain p) <> sublist
-- | A definition list is a set of consecutive definition items
-definitionList :: Parser [Char] ParserState Block
-definitionList = try $ DefinitionList <$> many1 definitionListItem
+definitionList :: Parser [Char] ParserState Blocks
+definitionList = try $ B.definitionList <$> many1 definitionListItem
-- | List start character.
listStart :: Parser [Char] st Char
listStart = oneOf "*#-"
-listInline :: Parser [Char] ParserState Inline
+listInline :: Parser [Char] ParserState Inlines
listInline = try (notFollowedBy newline >> inline)
<|> try (endline <* notFollowedBy listStart)
@@ -254,16 +276,16 @@ listInline = try (notFollowedBy newline >> inline)
-- the term defined, then spaces and ":=". The definition follows, on
-- the same single line, or spaned on multiple line, after a line
-- break.
-definitionListItem :: Parser [Char] ParserState ([Inline], [[Block]])
+definitionListItem :: Parser [Char] ParserState (Inlines, [Blocks])
definitionListItem = try $ do
string "- "
- term <- many1Till inline (try (whitespace >> string ":="))
+ term <- mconcat <$> many1Till inline (try (whitespace >> string ":="))
def' <- multilineDef <|> inlineDef
return (term, def')
- where inlineDef :: Parser [Char] ParserState [[Block]]
- inlineDef = liftM (\d -> [[Plain d]])
- $ optional whitespace >> many listInline <* newline
- multilineDef :: Parser [Char] ParserState [[Block]]
+ where inlineDef :: Parser [Char] ParserState [Blocks]
+ inlineDef = liftM (\d -> [B.plain d])
+ $ optional whitespace >> (trimInlines . mconcat <$> many listInline) <* newline
+ multilineDef :: Parser [Char] ParserState [Blocks]
multilineDef = try $ do
optional whitespace >> newline
s <- many1Till anyChar (try (string "=:" >> newline))
@@ -275,64 +297,62 @@ definitionListItem = try $ do
-- blocks support, we have to lookAhead for a rawHtmlBlock.
blockBreak :: Parser [Char] ParserState ()
blockBreak = try (newline >> blanklines >> return ()) <|>
- (lookAhead rawHtmlBlock >> return ())
+ try (optional spaces >> lookAhead rawHtmlBlock >> return ())
-- raw content
-- | A raw Html Block, optionally followed by blanklines
-rawHtmlBlock :: Parser [Char] ParserState Block
+rawHtmlBlock :: Parser [Char] ParserState Blocks
rawHtmlBlock = try $ do
(_,b) <- htmlTag isBlockTag
optional blanklines
- return $ RawBlock "html" b
+ return $ B.rawBlock "html" b
-- | Raw block of LaTeX content
-rawLaTeXBlock' :: Parser [Char] ParserState Block
+rawLaTeXBlock' :: Parser [Char] ParserState Blocks
rawLaTeXBlock' = do
guardEnabled Ext_raw_tex
- RawBlock "latex" <$> (rawLaTeXBlock <* spaces)
+ B.rawBlock "latex" <$> (rawLaTeXBlock <* spaces)
-- | In textile, paragraphs are separated by blank lines.
-para :: Parser [Char] ParserState Block
-para = try $ Para . normalizeSpaces <$> manyTill inline blockBreak
-
+para :: Parser [Char] ParserState Blocks
+para = B.para . trimInlines . mconcat <$> manyTill inline blockBreak
-- Tables
-- | A table cell spans until a pipe |
-tableCell :: Parser [Char] ParserState TableCell
+tableCell :: Parser [Char] ParserState Blocks
tableCell = do
c <- many1 (noneOf "|\n")
- content <- parseFromString (many1 inline) c
- return $ [ Plain $ normalizeSpaces content ]
+ content <- trimInlines . mconcat <$> parseFromString (many1 inline) c
+ return $ B.plain content
-- | A table row is made of many table cells
-tableRow :: Parser [Char] ParserState [TableCell]
+tableRow :: Parser [Char] ParserState [Blocks]
tableRow = try $ ( char '|' *>
(endBy1 tableCell (optional blankline *> char '|')) <* newline)
-- | Many table rows
-tableRows :: Parser [Char] ParserState [[TableCell]]
+tableRows :: Parser [Char] ParserState [[Blocks]]
tableRows = many1 tableRow
-- | Table headers are made of cells separated by a tag "|_."
-tableHeaders :: Parser [Char] ParserState [TableCell]
+tableHeaders :: Parser [Char] ParserState [Blocks]
tableHeaders = let separator = (try $ string "|_.") in
try $ ( separator *> (sepBy1 tableCell separator) <* char '|' <* newline )
-- | A table with an optional header. Current implementation can
-- handle tables with and without header, but will parse cells
-- alignment attributes as content.
-table :: Parser [Char] ParserState Block
+table :: Parser [Char] ParserState Blocks
table = try $ do
- headers <- option [] tableHeaders
+ headers <- option mempty tableHeaders
rows <- tableRows
blanklines
let nbOfCols = max (length headers) (length $ head rows)
- return $ Table []
- (replicate nbOfCols AlignDefault)
- (replicate nbOfCols 0.0)
+ return $ B.table mempty
+ (zip (replicate nbOfCols AlignDefault) (replicate nbOfCols 0.0))
headers
rows
@@ -340,8 +360,8 @@ table = try $ do
-- | Blocks like 'p' and 'table' do not need explicit block tag.
-- However, they can be used to set HTML/CSS attributes when needed.
maybeExplicitBlock :: String -- ^ block tag name
- -> Parser [Char] ParserState Block -- ^ implicit block
- -> Parser [Char] ParserState Block
+ -> Parser [Char] ParserState Blocks -- ^ implicit block
+ -> Parser [Char] ParserState Blocks
maybeExplicitBlock name blk = try $ do
optional $ try $ string name >> attributes >> char '.' >>
optional whitespace >> optional endline
@@ -355,73 +375,74 @@ maybeExplicitBlock name blk = try $ do
-- | Any inline element
-inline :: Parser [Char] ParserState Inline
-inline = choice inlineParsers <?> "inline"
+inline :: Parser [Char] ParserState Inlines
+inline = do
+ choice inlineParsers <?> "inline"
-- | Inline parsers tried in order
-inlineParsers :: [Parser [Char] ParserState Inline]
+inlineParsers :: [Parser [Char] ParserState Inlines]
inlineParsers = [ str
, whitespace
, endline
, code
, escapedInline
- , htmlSpan
+ , inlineMarkup
+ , groupedInlineMarkup
, rawHtmlInline
, rawLaTeXInline'
, note
- , try $ (char '[' *> inlineMarkup <* char ']')
- , inlineMarkup
, link
, image
, mark
- , (Str . (:[])) <$> characterReference
+ , (B.str . (:[])) <$> characterReference
, smartPunctuation inline
, symbol
]
-- | Inline markups
-inlineMarkup :: Parser [Char] ParserState Inline
-inlineMarkup = choice [ simpleInline (string "??") (Cite [])
- , simpleInline (string "**") Strong
- , simpleInline (string "__") Emph
- , simpleInline (char '*') Strong
- , simpleInline (char '_') Emph
- , simpleInline (char '+') Emph -- approximates underline
- , simpleInline (char '-' <* notFollowedBy (char '-')) Strikeout
- , simpleInline (char '^') Superscript
- , simpleInline (char '~') Subscript
+inlineMarkup :: Parser [Char] ParserState 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 :: Parser [Char] st Inline
+mark :: Parser [Char] st Inlines
mark = try $ char '(' >> (try tm <|> try reg <|> copy)
-reg :: Parser [Char] st Inline
+reg :: Parser [Char] st Inlines
reg = do
oneOf "Rr"
char ')'
- return $ Str "\174"
+ return $ B.str "\174"
-tm :: Parser [Char] st Inline
+tm :: Parser [Char] st Inlines
tm = do
oneOf "Tt"
oneOf "Mm"
char ')'
- return $ Str "\8482"
+ return $ B.str "\8482"
-copy :: Parser [Char] st Inline
+copy :: Parser [Char] st Inlines
copy = do
oneOf "Cc"
char ')'
- return $ Str "\169"
+ return $ B.str "\169"
-note :: Parser [Char] ParserState Inline
+note :: Parser [Char] ParserState Inlines
note = try $ do
ref <- (char '[' *> many1 digit <* char ']')
notes <- stateNotes <$> getState
case lookup ref notes of
Nothing -> fail "note not found"
- Just raw -> liftM Note $ parseFromString parseBlocks raw
+ Just raw -> B.note <$> parseFromString parseBlocks raw
-- | Special chars
markupChars :: [Char]
@@ -442,7 +463,7 @@ wordBoundaries = markupChars ++ stringBreakers
hyphenedWords :: Parser [Char] ParserState String
hyphenedWords = do
x <- wordChunk
- xs <- many (try $ char '-' >> wordChunk)
+ xs <- many (try $ char '-' >> wordChunk)
return $ intercalate "-" (x:xs)
wordChunk :: Parser [Char] ParserState String
@@ -454,99 +475,99 @@ wordChunk = try $ do
return $ hd:tl
-- | Any string
-str :: Parser [Char] ParserState Inline
+str :: Parser [Char] ParserState 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
+ acro <- enclosed (char '(') (char ')') anyChar'
return $ concat [baseStr, " (", acro, ")"]
updateLastStrPos
- return $ Str fullStr
-
--- | Textile allows HTML span infos, we discard them
-htmlSpan :: Parser [Char] ParserState Inline
-htmlSpan = try $ Str <$> ( char '%' *> attributes *> manyTill anyChar (char '%') )
+ return $ B.str fullStr
-- | Some number of space chars
-whitespace :: Parser [Char] ParserState Inline
-whitespace = many1 spaceChar >> return Space <?> "whitespace"
+whitespace :: Parser [Char] ParserState Inlines
+whitespace = many1 spaceChar >> return B.space <?> "whitespace"
-- | In Textile, an isolated endline character is a line break
-endline :: Parser [Char] ParserState Inline
+endline :: Parser [Char] ParserState Inlines
endline = try $ do
newline >> notFollowedBy blankline
- return LineBreak
+ return B.linebreak
-rawHtmlInline :: Parser [Char] ParserState Inline
-rawHtmlInline = RawInline "html" . snd <$> htmlTag isInlineTag
+rawHtmlInline :: Parser [Char] ParserState Inlines
+rawHtmlInline = B.rawInline "html" . snd <$> htmlTag isInlineTag
-- | Raw LaTeX Inline
-rawLaTeXInline' :: Parser [Char] ParserState Inline
+rawLaTeXInline' :: Parser [Char] ParserState Inlines
rawLaTeXInline' = try $ do
guardEnabled Ext_raw_tex
- rawLaTeXInline
+ B.singleton <$> rawLaTeXInline
-- | Textile standard link syntax is "label":target. But we
-- can also have ["label":target].
-link :: Parser [Char] ParserState Inline
-link = linkB <|> linkNoB
-
-linkNoB :: Parser [Char] ParserState Inline
-linkNoB = try $ do
- name <- surrounded (char '"') inline
- char ':'
- let stopChars = "!.,;:"
- url <- manyTill nonspaceChar (lookAhead $ space <|> try (oneOf stopChars >> (space <|> newline)))
- let name' = if name == [Str "$"] then [Str url] else name
- return $ Link name' (url, "")
-
-linkB :: Parser [Char] ParserState Inline
-linkB = try $ do
- char '['
- name <- surrounded (char '"') inline
+link :: Parser [Char] ParserState 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 ':'
- url <- manyTill nonspaceChar (char ']')
- let name' = if name == [Str "$"] then [Str url] else name
- return $ Link name' (url, "")
+ let stop = if bracketed
+ then char ']'
+ else lookAhead $ space <|>
+ try (oneOf "!.,;:" *> (space <|> newline))
+ url <- manyTill 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 :: Parser [Char] ParserState Inline
+image :: Parser [Char] ParserState Inlines
image = try $ do
char '!' >> notFollowedBy space
- src <- manyTill anyChar (lookAhead $ oneOf "!(")
- alt <- option "" (try $ (char '(' >> manyTill anyChar (char ')')))
+ src <- manyTill anyChar' (lookAhead $ oneOf "!(")
+ alt <- option "" (try $ (char '(' >> manyTill anyChar' (char ')')))
char '!'
- return $ Image [Str alt] (src, alt)
+ return $ B.image src alt (B.str alt)
-escapedInline :: Parser [Char] ParserState Inline
+escapedInline :: Parser [Char] ParserState Inlines
escapedInline = escapedEqs <|> escapedTag
-escapedEqs :: Parser [Char] ParserState Inline
-escapedEqs = Str <$> (try $ string "==" *> manyTill anyChar (try $ string "=="))
+escapedEqs :: Parser [Char] ParserState Inlines
+escapedEqs = B.str <$>
+ (try $ string "==" *> manyTill anyChar' (try $ string "=="))
-- | literal text escaped btw <notextile> tags
-escapedTag :: Parser [Char] ParserState Inline
-escapedTag = Str <$>
- (try $ string "<notextile>" *> manyTill anyChar (try $ string "</notextile>"))
+escapedTag :: Parser [Char] ParserState Inlines
+escapedTag = B.str <$>
+ (try $ string "<notextile>" *>
+ manyTill anyChar' (try $ string "</notextile>"))
-- | Any special symbol defined in wordBoundaries
-symbol :: Parser [Char] ParserState Inline
-symbol = Str . singleton <$> (oneOf wordBoundaries <|> oneOf markupChars)
+symbol :: Parser [Char] ParserState Inlines
+symbol = B.str . singleton <$> (oneOf wordBoundaries <|> oneOf markupChars)
-- | Inline code
-code :: Parser [Char] ParserState Inline
+code :: Parser [Char] ParserState Inlines
code = code1 <|> code2
-code1 :: Parser [Char] ParserState Inline
-code1 = Code nullAttr <$> surrounded (char '@') anyChar
+-- any character except a newline before a blank line
+anyChar' :: Parser [Char] ParserState Char
+anyChar' =
+ satisfy (/='\n') <|> (try $ char '\n' <* notFollowedBy blankline)
+
+code1 :: Parser [Char] ParserState Inlines
+code1 = B.code <$> surrounded (char '@') anyChar'
-code2 :: Parser [Char] ParserState Inline
+code2 :: Parser [Char] ParserState Inlines
code2 = do
htmlTag (tagOpen (=="tt") null)
- Code nullAttr <$> manyTill anyChar (try $ htmlTag $ tagClose (=="tt"))
+ B.code <$> manyTill anyChar' (try $ htmlTag $ tagClose (=="tt"))
-- | Html / CSS attributes
attributes :: Parser [Char] ParserState Attr
@@ -558,7 +579,7 @@ attribute = classIdAttr <|> styleAttr <|> langAttr
classIdAttr :: Parser [Char] ParserState (Attr -> Attr)
classIdAttr = try $ do -- (class class #id)
char '('
- ws <- words `fmap` manyTill anyChar (char ')')
+ ws <- words `fmap` manyTill anyChar' (char ')')
case reverse ws of
[] -> return $ \(_,_,keyvals) -> ("",[],keyvals)
(('#':ident'):classes') -> return $ \(_,_,keyvals) ->
@@ -568,28 +589,49 @@ classIdAttr = try $ do -- (class class #id)
styleAttr :: Parser [Char] ParserState (Attr -> Attr)
styleAttr = do
- style <- try $ enclosed (char '{') (char '}') anyChar
+ style <- try $ enclosed (char '{') (char '}') anyChar'
return $ \(id',classes,keyvals) -> (id',classes,("style",style):keyvals)
langAttr :: Parser [Char] ParserState (Attr -> Attr)
langAttr = do
- lang <- try $ enclosed (char '[') (char ']') anyChar
+ lang <- try $ enclosed (char '[') (char ']') alphaNum
return $ \(id',classes,keyvals) -> (id',classes,("lang",lang):keyvals)
-- | Parses material surrounded by a parser.
surrounded :: Parser [Char] st t -- ^ surrounding parser
-> Parser [Char] st a -- ^ content parser (to be used repeatedly)
-> Parser [Char] st [a]
-surrounded border = enclosed (border *> notFollowedBy (oneOf " \t\n\r")) (try border)
+surrounded border =
+ enclosed (border *> notFollowedBy (oneOf " \t\n\r")) (try border)
--- | Inlines are most of the time of the same form
simpleInline :: Parser [Char] ParserState t -- ^ surrounding parser
- -> ([Inline] -> Inline) -- ^ Inline constructor
- -> Parser [Char] ParserState Inline -- ^ content parser (to be used repeatedly)
-simpleInline border construct = surrounded border (inlineWithAttribute) >>=
- return . construct . normalizeSpaces
- where inlineWithAttribute = (try $ optional attributes) >> inline
+ -> (Inlines -> Inlines) -- ^ Inline constructor
+ -> Parser [Char] ParserState Inlines -- ^ content parser (to be used repeatedly)
+simpleInline border construct = try $ do
+ st <- getState
+ pos <- getPosition
+ let afterString = stateLastStrPos st == Just pos
+ guard $ not afterString
+ border *> notFollowedBy (oneOf " \t\n\r")
+ attr <- attributes
+ body <- trimInlines . mconcat <$>
+ withQuoteContext InSingleQuote
+ (manyTill inline (try border <* notFollowedBy alphaNum))
+ return $ construct $
+ if attr == nullAttr
+ then body
+ else B.spanWith attr body
+
+groupedInlineMarkup :: Parser [Char] ParserState 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/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs
index c4613992a..2a2f56281 100644
--- a/src/Text/Pandoc/SelfContained.hs
+++ b/src/Text/Pandoc/SelfContained.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}
{-
-Copyright (C) 2011 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2011-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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.SelfContained
- Copyright : Copyright (C) 2011 John MacFarlane
+ Copyright : Copyright (C) 2011-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -32,7 +32,7 @@ the HTML using data URIs.
-}
module Text.Pandoc.SelfContained ( makeSelfContained ) where
import Text.HTML.TagSoup
-import Network.URI (isAbsoluteURI, escapeURIString)
+import Network.URI (isURI, escapeURIString)
import Data.ByteString.Base64
import qualified Data.ByteString.Char8 as B
import Data.ByteString (ByteString)
@@ -40,7 +40,7 @@ import System.FilePath (takeExtension, dropExtension, takeDirectory, (</>))
import Data.Char (toLower, isAscii, isAlphaNum)
import Codec.Compression.GZip as Gzip
import qualified Data.ByteString.Lazy as L
-import Text.Pandoc.Shared (renderTags', openURL, readDataFile)
+import Text.Pandoc.Shared (renderTags', openURL, readDataFile, err)
import Text.Pandoc.UTF8 (toString, fromString)
import Text.Pandoc.MIME (getMimeType)
import System.Directory (doesFileExist)
@@ -50,14 +50,16 @@ isOk c = isAscii c && isAlphaNum c
convertTag :: Maybe FilePath -> Tag String -> IO (Tag String)
convertTag userdata t@(TagOpen tagname as)
- | tagname `elem` ["img", "embed", "video", "input", "audio", "source"] =
- case fromAttrib "src" t of
- [] -> return t
- src -> do
- (raw, mime) <- getRaw userdata (fromAttrib "type" t) src
- let enc = "data:" ++ mime ++ ";base64," ++ toString (encode raw)
- return $ TagOpen tagname
- (("src",enc) : [(x,y) | (x,y) <- as, x /= "src"])
+ | tagname `elem` ["img", "embed", "video", "input", "audio", "source"] = do
+ as' <- mapM processAttribute as
+ return $ TagOpen tagname as'
+ where processAttribute (x,y) =
+ if x == "src" || x == "href" || x == "poster"
+ then do
+ (raw, mime) <- getRaw userdata (fromAttrib "type" t) y
+ let enc = "data:" ++ mime ++ ";base64," ++ toString (encode raw)
+ return (x, enc)
+ else return (x,y)
convertTag userdata t@(TagOpen "script" as) =
case fromAttrib "src" t of
[] -> return t
@@ -86,7 +88,7 @@ cssURLs userdata d orig =
"\"" -> B.takeWhile (/='"') $ B.drop 1 u
"'" -> B.takeWhile (/='\'') $ B.drop 1 u
_ -> u
- let url' = if isAbsoluteURI url
+ let url' = if isURI url
then url
else d </> url
(raw, mime) <- getRaw userdata "" url'
@@ -97,8 +99,8 @@ cssURLs userdata d orig =
getItem :: Maybe FilePath -> String -> IO (ByteString, Maybe String)
getItem userdata f =
- if isAbsoluteURI f
- then openURL f
+ if isURI f
+ then openURL f >>= either handleErr return
else do
-- strip off trailing query or fragment part, if relative URL.
-- this is needed for things like cmunrm.eot?#iefix,
@@ -110,6 +112,7 @@ getItem userdata f =
exists <- doesFileExist f'
cont <- if exists then B.readFile f' else readDataFile userdata f'
return (cont, mime)
+ where handleErr e = err 61 $ "Failed to retrieve " ++ f ++ "\n" ++ show e
getRaw :: Maybe FilePath -> String -> String -> IO (ByteString, String)
getRaw userdata mimetype src = do
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 09086da1f..5b0d9b6b4 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -1,6 +1,7 @@
-{-# LANGUAGE DeriveDataTypeable, CPP #-}
+{-# LANGUAGE DeriveDataTypeable, CPP, MultiParamTypeClasses,
+ FlexibleContexts, ScopedTypeVariables #-}
{-
-Copyright (C) 2006-2013 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -19,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Shared
- Copyright : Copyright (C) 2006-2013 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -34,6 +35,7 @@ module Text.Pandoc.Shared (
splitByIndices,
splitStringByIndices,
substitute,
+ ordNub,
-- * Text processing
backslashEscapes,
escapeStringUsing,
@@ -51,10 +53,12 @@ module Text.Pandoc.Shared (
-- * Pandoc block and inline list processing
orderedListMarkers,
normalizeSpaces,
+ extractSpaces,
normalize,
stringify,
compactify,
compactify',
+ compactify'DL,
Element (..),
hierarchicalize,
uniqueIdent,
@@ -79,8 +83,9 @@ module Text.Pandoc.Shared (
) where
import Text.Pandoc.Definition
+import Text.Pandoc.Walk
import Text.Pandoc.Generic
-import Text.Pandoc.Builder (Blocks, ToMetaValue(..))
+import Text.Pandoc.Builder (Inlines, Blocks, ToMetaValue(..))
import qualified Text.Pandoc.Builder as B
import qualified Text.Pandoc.UTF8 as UTF8
import System.Environment (getProgName)
@@ -89,12 +94,15 @@ import Data.Char ( toLower, isLower, isUpper, isAlpha,
isLetter, isDigit, isSpace )
import Data.List ( find, isPrefixOf, intercalate )
import qualified Data.Map as M
-import Network.URI ( escapeURIString, isAbsoluteURI, unEscapeString )
+import Network.URI ( escapeURIString, isURI, nonStrictRelativeTo,
+ unEscapeString, parseURIReference )
+import qualified Data.Set as Set
import System.Directory
import Text.Pandoc.MIME (getMimeType)
import System.FilePath ( (</>), takeExtension, dropExtension )
import Data.Generics (Typeable, Data)
import qualified Control.Monad.State as S
+import qualified Control.Exception as E
import Control.Monad (msum, unless)
import Text.Pandoc.Pretty (charWidth)
import System.Locale (defaultTimeLocale)
@@ -103,8 +111,10 @@ import System.IO (stderr)
import Text.HTML.TagSoup (renderTagsOptions, RenderOptions(..), Tag(..),
renderOptions)
import qualified Data.ByteString as BS
-import Data.ByteString.Lazy (toChunks)
import qualified Data.ByteString.Char8 as B8
+import Text.Pandoc.Compat.Monoid
+import Data.ByteString.Base64 (decodeLenient)
+import Data.Sequence (ViewR(..), ViewL(..), viewl, viewr)
#ifdef EMBED_DATA_FILES
import Text.Pandoc.Data (dataFiles)
@@ -112,10 +122,16 @@ import System.FilePath ( joinPath, splitDirectories )
#else
import Paths_pandoc (getDataFileName)
#endif
-#ifdef HTTP_CONDUIT
-import Network.HTTP.Conduit (httpLbs, parseUrl, withManager,
- responseBody, responseHeaders)
+#ifdef HTTP_CLIENT
+import Data.ByteString.Lazy (toChunks)
+import Network.HTTP.Client (httpLbs, parseUrl, withManager,
+ responseBody, responseHeaders,
+ Request(port,host))
+import Network.HTTP.Client.Internal (addProxy)
+import Network.HTTP.Client.TLS (tlsManagerSettings)
+import System.Environment (getEnv)
import Network.HTTP.Types.Header ( hContentType)
+import Network (withSocketsDo)
#else
import Network.URI (parseURI)
import Network.HTTP (findHeader, rspBody,
@@ -162,6 +178,13 @@ substitute target replacement lst@(x:xs) =
then replacement ++ substitute target replacement (drop (length target) lst)
else 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
--
@@ -225,9 +248,9 @@ toRomanNumeral x =
_ | x >= 50 -> "L" ++ toRomanNumeral (x - 50)
_ | x >= 40 -> "XL" ++ toRomanNumeral (x - 40)
_ | x >= 10 -> "X" ++ toRomanNumeral (x - 10)
- _ | x >= 9 -> "IX" ++ toRomanNumeral (x - 5)
+ _ | x == 9 -> "IX"
_ | x >= 5 -> "V" ++ toRomanNumeral (x - 5)
- _ | x >= 4 -> "IV" ++ toRomanNumeral (x - 4)
+ _ | x == 4 -> "IV"
_ | x >= 1 -> "I" ++ toRomanNumeral (x - 1)
_ -> ""
@@ -265,7 +288,7 @@ normalizeDate s = fmap (formatTime defaultTimeLocale "%F")
(msum $ map (\fs -> parsetimeWith fs s) formats :: Maybe Day)
where parsetimeWith = parseTime defaultTimeLocale
formats = ["%x","%m/%d/%Y", "%D","%F", "%d %b %Y",
- "%d %B %Y", "%b. %d, %Y", "%B %d, %Y"]
+ "%d %B %Y", "%b. %d, %Y", "%B %d, %Y", "%Y"]
--
-- Pandoc block and inline list processing
@@ -310,6 +333,20 @@ 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.
+
+extractSpaces :: (Inlines -> Inlines) -> Inlines -> Inlines
+extractSpaces f is =
+ let contents = B.unMany is
+ left = case viewl contents of
+ (Space :< _) -> B.space
+ _ -> mempty
+ right = case viewr contents of
+ (_ :> Space) -> B.space
+ _ -> mempty in
+ (left <> f (B.trimInlines . B.Many $ contents) <> right)
+
-- | Normalize @Pandoc@ document, consolidating doubled 'Space's,
-- combining adjacent 'Str's and 'Emph's, remove 'Null's and
-- empty elements, etc.
@@ -380,9 +417,11 @@ consolidateInlines (Code a1 x : Code a2 y : zs) | a1 == a2 =
consolidateInlines (x : xs) = x : consolidateInlines xs
consolidateInlines [] = []
--- | Convert list of inlines to a string with formatting removed.
-stringify :: [Inline] -> String
-stringify = queryWith go
+-- | 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 (Str x) = x
@@ -390,6 +429,8 @@ stringify = queryWith go
go (Math _ x) = x
go LineBreak = " "
go _ = ""
+ deNote (Note _) = Str ""
+ deNote x = x
-- | Change final list item from @Para@ to @Plain@ if the list contains
-- no other @Para@ blocks.
@@ -422,6 +463,21 @@ compactify' items =
_ -> items
_ -> items
+-- | Like @compactify'@, but akts on items of definition lists.
+compactify'DL :: [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]
+compactify'DL items =
+ let defs = concatMap snd items
+ defBlocks = reverse $ concatMap B.toList defs
+ in case defBlocks of
+ (Para x:_) -> if not $ any isPara (drop 1 defBlocks)
+ then let (t,ds) = last items
+ lastDef = B.toList $ last ds
+ ds' = init ds ++
+ [B.fromList $ init lastDef ++ [Plain x]]
+ in init items ++ [(t, ds')]
+ else items
+ _ -> items
+
isPara :: Block -> Bool
isPara (Para _) = True
isPara _ = False
@@ -432,6 +488,29 @@ data Element = Blk Block
-- 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 _-.
@@ -492,14 +571,14 @@ isHeaderBlock _ = False
-- | Shift header levels up or down.
headerShift :: Int -> Pandoc -> Pandoc
-headerShift n = bottomUp shift
+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 = and . map firstIsPlain
+isTightList = all firstIsPlain
where firstIsPlain (Plain _ : _) = True
firstIsPlain _ = False
@@ -512,8 +591,10 @@ addMetaField :: ToMetaValue a
-> Meta
addMetaField key val (Meta meta) =
Meta $ M.insertWith combine key (toMetaValue val) meta
- where combine newval (MetaList xs) = MetaList (xs ++ [newval])
+ 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.
@@ -531,14 +612,10 @@ makeMeta title authors date =
-- | Render HTML tags.
renderTags' :: [Tag String] -> String
renderTags' = renderTagsOptions
- renderOptions{ optMinimize = \x ->
- let y = map toLower x
- in y == "hr" || y == "br" ||
- y == "img" || y == "meta" ||
- y == "link"
- , optRawTag = \x ->
- let y = map toLower x
- in y == "script" || y == "style" }
+ renderOptions{ optMinimize = matchTags ["hr", "br", "img",
+ "meta", "link"]
+ , optRawTag = matchTags ["script", "style"] }
+ where matchTags = \tags -> flip elem tags . map toLower
--
-- File handling
@@ -557,8 +634,7 @@ readDefaultDataFile :: FilePath -> IO BS.ByteString
readDefaultDataFile fname =
#ifdef EMBED_DATA_FILES
case lookup (makeCanonical fname) dataFiles of
- Nothing -> ioError $ userError
- $ "Data file `" ++ fname ++ "' does not exist"
+ Nothing -> err 97 $ "Could not find data file " ++ fname
Just contents -> return contents
where makeCanonical = joinPath . transformPathParts . splitDirectories
transformPathParts = reverse . foldl go []
@@ -566,7 +642,12 @@ readDefaultDataFile fname =
go (_:as) ".." = as
go as x = x : as
#else
- getDataFileName ("data" </> fname) >>= BS.readFile
+ getDataFileName ("data" </> fname) >>= checkExistence >>= BS.readFile
+ where checkExistence fn = do
+ exists <- doesFileExist fn
+ if exists
+ then return fn
+ else err 97 ("Could not find data file " ++ fname)
#endif
-- | Read file from specified user data directory or, if not found there, from
@@ -586,34 +667,45 @@ readDataFileUTF8 userDir fname =
-- | Fetch an image or other item from the local filesystem or the net.
-- Returns raw content and maybe mime type.
-fetchItem :: String -> String -> IO (BS.ByteString, Maybe String)
-fetchItem sourceDir s =
- case s of
- _ | isAbsoluteURI s -> openURL s
- | isAbsoluteURI sourceDir -> openURL $ sourceDir ++ "/" ++ s
- | otherwise -> do
+fetchItem :: Maybe String -> String
+ -> IO (Either E.SomeException (BS.ByteString, Maybe String))
+fetchItem sourceURL s
+ | isURI s = openURL s
+ | otherwise =
+ case sourceURL >>= parseURIReference of
+ Just u -> case parseURIReference s of
+ Just s' -> openURL $ show $
+ s' `nonStrictRelativeTo` u
+ Nothing -> openURL $ show u ++ "/" ++ s
+ Nothing -> E.try readLocalFile
+ where readLocalFile = do
let mime = case takeExtension s of
- ".gz" -> getMimeType $ dropExtension s
- x -> getMimeType x
- let f = sourceDir </> s
- cont <- BS.readFile f
+ ".gz" -> getMimeType $ dropExtension s
+ x -> getMimeType x
+ cont <- BS.readFile s
return (cont, mime)
-- | Read from a URL and return raw data and maybe mime type.
-openURL :: String -> IO (BS.ByteString, Maybe String)
+openURL :: String -> IO (Either E.SomeException (BS.ByteString, Maybe String))
openURL u
| "data:" `isPrefixOf` u =
let mime = takeWhile (/=',') $ drop 5 u
contents = B8.pack $ unEscapeString $ drop 1 $ dropWhile (/=',') u
- in return (contents, Just mime)
-#ifdef HTTP_CONDUIT
- | otherwise = do
+ in return $ Right (decodeLenient contents, Just mime)
+#ifdef HTTP_CLIENT
+ | otherwise = withSocketsDo $ E.try $ do
req <- parseUrl u
- resp <- withManager $ httpLbs req
+ (proxy :: Either E.SomeException String) <- E.try $ getEnv "http_proxy"
+ let req' = case proxy of
+ Left _ -> req
+ Right pr -> case parseUrl pr of
+ Just r -> addProxy (host r) (port r) req
+ Nothing -> req
+ resp <- withManager tlsManagerSettings $ httpLbs req'
return (BS.concat $ toChunks $ responseBody resp,
UTF8.toString `fmap` lookup hContentType (responseHeaders resp))
#else
- | otherwise = getBodyAndMimeType `fmap` browse
+ | otherwise = E.try $ getBodyAndMimeType `fmap` browse
(do S.liftIO $ UTF8.hPutStrLn stderr $ "Fetching " ++ u ++ "..."
setOutHandler $ const (return ())
setAllowRedirects True
@@ -651,5 +743,3 @@ safeRead s = case reads s of
(d,x):_
| all isSpace x -> return d
_ -> fail $ "Could not read `" ++ s ++ "'"
-
-
diff --git a/src/Text/Pandoc/Slides.hs b/src/Text/Pandoc/Slides.hs
index 2bbdb120f..2b863c780 100644
--- a/src/Text/Pandoc/Slides.hs
+++ b/src/Text/Pandoc/Slides.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2012 John MacFarlane <jgm@berkeley.edu>
+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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Slides
- Copyright : Copyright (C) 2012 John MacFarlane
+ Copyright : Copyright (C) 2012-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -46,13 +46,18 @@ getSlideLevel = go 6
-- | Prepare a block list to be passed to hierarchicalize.
prepSlides :: Int -> [Block] -> [Block]
-prepSlides slideLevel = ensureStartWithH . splitHrule
+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
index c95c84ca8..4ae6a6d8a 100644
--- a/src/Text/Pandoc/Templates.hs
+++ b/src/Text/Pandoc/Templates.hs
@@ -1,7 +1,7 @@
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, CPP,
OverloadedStrings, GeneralizedNewtypeDeriving #-}
{-
-Copyright (C) 2009-2013 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2009-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
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Templates
- Copyright : Copyright (C) 2009-2013 John MacFarlane
+ Copyright : Copyright (C) 2009-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -96,14 +96,14 @@ module Text.Pandoc.Templates ( renderTemplate
import Data.Char (isAlphaNum)
import Control.Monad (guard, when)
import Data.Aeson (ToJSON(..), Value(..))
-import qualified Data.Attoparsec.Text as A
-import Data.Attoparsec.Text (Parser)
+import qualified Text.Parsec as P
+import Text.Parsec.Text (Parser)
import Control.Applicative
import qualified Data.Text as T
import Data.Text (Text)
import Data.Text.Encoding (encodeUtf8)
-import Data.Monoid ((<>), Monoid(..))
-import Data.List (intersperse, nub)
+import Text.Pandoc.Compat.Monoid ((<>), Monoid(..))
+import Data.List (intersperse)
import System.FilePath ((</>), (<.>))
import qualified Data.Map as M
import qualified Data.HashMap.Strict as H
@@ -116,7 +116,8 @@ import Text.Blaze.Internal (preEscapedText)
import Text.Blaze (preEscapedText, Html)
#endif
import Data.ByteString.Lazy (ByteString, fromChunks)
-import Text.Pandoc.Shared (readDataFileUTF8)
+import Text.Pandoc.Shared (readDataFileUTF8, ordNub)
+import Data.Vector ((!?))
-- | Get default template for the specified writer.
getDefaultTemplate :: (Maybe FilePath) -- ^ User data directory to search first
@@ -162,7 +163,7 @@ varListToJSON assoc = toJSON $ M.fromList assoc'
where assoc' = [(T.pack k, toVal [T.pack z | (y,z) <- assoc,
not (null z),
y == k])
- | k <- nub $ map fst assoc ]
+ | k <- ordNub $ map fst assoc ]
toVal [x] = toJSON x
toVal [] = Null
toVal xs = toJSON xs
@@ -171,7 +172,10 @@ renderTemplate :: (ToJSON a, TemplateTarget b) => Template -> a -> b
renderTemplate (Template f) context = toTarget $ f $ toJSON context
compileTemplate :: Text -> Either String Template
-compileTemplate template = A.parseOnly pTemplate template
+compileTemplate template =
+ case P.parse (pTemplate <* P.eof) "template" template of
+ Left e -> Left (show e)
+ Right x -> Right x
-- | Like 'renderTemplate', but compiles the template first,
-- raising an error if compilation fails.
@@ -185,10 +189,11 @@ var = Template . resolveVar
resolveVar :: Variable -> Value -> Text
resolveVar var' val =
case multiLookup var' val of
- Just (Array vec) -> mconcat $ map (resolveVar []) $ toList vec
+ Just (Array vec) -> maybe mempty (resolveVar []) $ vec !? 0
Just (String t) -> T.stripEnd t
Just (Number n) -> T.pack $ show n
Just (Bool True) -> "true"
+ Just (Object _) -> "true"
Just _ -> mempty
Nothing -> mempty
@@ -212,7 +217,7 @@ iter var' template sep = Template $ \val -> unTemplate
Just (Array vec) -> mconcat $ intersperse sep
$ map (setVar template var')
$ toList vec
- Just x -> setVar template var' x
+ Just x -> cond var' (setVar template var' x) mempty
Nothing -> mempty) val
setVar :: Template -> Variable -> Value -> Template
@@ -228,7 +233,7 @@ replaceVar _ _ old = old
pTemplate :: Parser Template
pTemplate = do
- sp <- A.option mempty pInitialSpace
+ sp <- P.option mempty pInitialSpace
rest <- mconcat <$> many (pConditional <|>
pFor <|>
pNewline <|>
@@ -237,40 +242,43 @@ pTemplate = do
pEscapedDollar)
return $ sp <> rest
+takeWhile1 :: (Char -> Bool) -> Parser Text
+takeWhile1 f = T.pack <$> P.many1 (P.satisfy f)
+
pLit :: Parser Template
-pLit = lit <$> A.takeWhile1 (\x -> x /='$' && x /= '\n')
+pLit = lit <$> takeWhile1 (\x -> x /='$' && x /= '\n')
pNewline :: Parser Template
pNewline = do
- A.char '\n'
- sp <- A.option mempty pInitialSpace
+ P.char '\n'
+ sp <- P.option mempty pInitialSpace
return $ lit "\n" <> sp
pInitialSpace :: Parser Template
pInitialSpace = do
- sps <- A.takeWhile1 (==' ')
+ sps <- takeWhile1 (==' ')
let indentVar = if T.null sps
then id
else indent (T.length sps)
- v <- A.option mempty $ indentVar <$> pVar
+ v <- P.option mempty $ indentVar <$> pVar
return $ lit sps <> v
pEscapedDollar :: Parser Template
-pEscapedDollar = lit "$" <$ A.string "$$"
+pEscapedDollar = lit "$" <$ P.try (P.string "$$")
pVar :: Parser Template
-pVar = var <$> (A.char '$' *> pIdent <* A.char '$')
+pVar = var <$> (P.try $ P.char '$' *> pIdent <* P.char '$')
pIdent :: Parser [Text]
pIdent = do
first <- pIdentPart
- rest <- many (A.char '.' *> pIdentPart)
+ rest <- many (P.char '.' *> pIdentPart)
return (first:rest)
pIdentPart :: Parser Text
-pIdentPart = do
- first <- A.letter
- rest <- A.takeWhile (\c -> isAlphaNum c || c == '_' || c == '-')
+pIdentPart = P.try $ do
+ first <- P.letter
+ rest <- T.pack <$> P.many (P.satisfy (\c -> isAlphaNum c || c == '_' || c == '-'))
let id' = T.singleton first <> rest
guard $ id' `notElem` reservedWords
return id'
@@ -279,38 +287,38 @@ reservedWords :: [Text]
reservedWords = ["else","endif","for","endfor","sep"]
skipEndline :: Parser ()
-skipEndline = A.skipWhile (`elem` " \t") >> A.char '\n' >> return ()
+skipEndline = P.try $ P.skipMany (P.satisfy (`elem` " \t")) >> P.char '\n' >> return ()
pConditional :: Parser Template
pConditional = do
- A.string "$if("
+ P.try $ P.string "$if("
id' <- pIdent
- A.string ")$"
+ P.string ")$"
-- if newline after the "if", then a newline after "endif" will be swallowed
- multiline <- A.option False (True <$ skipEndline)
+ multiline <- P.option False (True <$ skipEndline)
ifContents <- pTemplate
- elseContents <- A.option mempty $
- do A.string "$else$"
- when multiline $ A.option () skipEndline
+ elseContents <- P.option mempty $ P.try $
+ do P.string "$else$"
+ when multiline $ P.option () skipEndline
pTemplate
- A.string "$endif$"
- when multiline $ A.option () skipEndline
+ P.string "$endif$"
+ when multiline $ P.option () skipEndline
return $ cond id' ifContents elseContents
pFor :: Parser Template
pFor = do
- A.string "$for("
+ P.try $ P.string "$for("
id' <- pIdent
- A.string ")$"
+ P.string ")$"
-- if newline after the "for", then a newline after "endfor" will be swallowed
- multiline <- A.option False $ skipEndline >> return True
+ multiline <- P.option False $ skipEndline >> return True
contents <- pTemplate
- sep <- A.option mempty $
- do A.string "$sep$"
- when multiline $ A.option () skipEndline
+ sep <- P.option mempty $
+ do P.try $ P.string "$sep$"
+ when multiline $ P.option () skipEndline
pTemplate
- A.string "$endfor$"
- when multiline $ A.option () skipEndline
+ P.string "$endfor$"
+ when multiline $ P.option () skipEndline
return $ iter id' contents sep
indent :: Int -> Template -> Template
diff --git a/src/Text/Pandoc/UTF8.hs b/src/Text/Pandoc/UTF8.hs
index 9fa743cd9..cf25de85b 100644
--- a/src/Text/Pandoc/UTF8.hs
+++ b/src/Text/Pandoc/UTF8.hs
@@ -1,5 +1,6 @@
+{-# LANGUAGE CPP #-}
{-
-Copyright (C) 2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2010-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
@@ -18,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.UTF8
- Copyright : Copyright (C) 2010 John MacFarlane
+ Copyright : Copyright (C) 2010-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -50,8 +51,7 @@ import System.IO hiding (readFile, writeFile, getContents,
#if MIN_VERSION_base(4,6,0)
import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn)
#else
-import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn,
- catch)
+import Prelude hiding (readFile, writeFile, getContents, putStr, putStrLn)
#endif
import qualified System.IO as IO
import qualified Data.ByteString.Char8 as B
diff --git a/src/Text/Pandoc/UUID.hs b/src/Text/Pandoc/UUID.hs
index 082644eea..eebfe09d2 100644
--- a/src/Text/Pandoc/UUID.hs
+++ b/src/Text/Pandoc/UUID.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2010-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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.UUID
- Copyright : Copyright (C) 2010 John MacFarlane
+ Copyright : Copyright (C) 2010-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs
index 6c3c6955e..19112d8f5 100644
--- a/src/Text/Pandoc/Writers/AsciiDoc.hs
+++ b/src/Text/Pandoc/Writers/AsciiDoc.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}
{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.AsciiDoc
- Copyright : Copyright (C) 2006-2010 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -132,7 +132,9 @@ blockToAsciiDoc opts (Para inlines) = do
then text "\\"
else empty
return $ esc <> contents <> blankline
-blockToAsciiDoc _ (RawBlock _ _) = return empty
+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
@@ -215,7 +217,9 @@ blockToAsciiDoc opts (Table caption aligns widths headers rows) = do
let makeCell [Plain x] = do d <- blockListToAsciiDoc opts [Plain x]
return $ text "|" <> chomp d
makeCell [Para x] = makeCell [Plain x]
- makeCell _ = return $ text "|" <> "[multiblock cell omitted]"
+ 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
@@ -225,7 +229,7 @@ blockToAsciiDoc opts (Table caption aligns widths headers rows) = do
else 100000
let maxwidth = maximum $ map offset (head':rows')
let body = if maxwidth > colwidth then vsep rows' else vcat rows'
- let border = text $ "|" ++ replicate ((min maxwidth colwidth) - 1) '='
+ let border = text $ "|" ++ replicate (max 5 (min maxwidth colwidth) - 1) '='
return $
caption'' $$ tablespec $$ border $$ head'' $$ body $$ border $$ blankline
blockToAsciiDoc opts (BulletList items) = do
@@ -246,6 +250,7 @@ blockToAsciiDoc opts (OrderedList (_start, sty, _delim) items) = do
blockToAsciiDoc opts (DefinitionList items) = do
contents <- mapM (definitionListItemToAsciiDoc opts) items
return $ cat contents <> blankline
+blockToAsciiDoc opts (Div _ bs) = blockListToAsciiDoc opts bs
-- | Convert bullet list item (list of blocks) to asciidoc.
bulletListItemToAsciiDoc :: WriterOptions -> [Block] -> State WriterState Doc
@@ -346,7 +351,9 @@ inlineToAsciiDoc _ (Math InlineMath str) =
return $ "latexmath:[$" <> text str <> "$]"
inlineToAsciiDoc _ (Math DisplayMath str) =
return $ "latexmath:[\\[" <> text str <> "\\]]"
-inlineToAsciiDoc _ (RawInline _ _) = return empty
+inlineToAsciiDoc _ (RawInline f s)
+ | f == "asciidoc" = return $ text s
+ | otherwise = return empty
inlineToAsciiDoc _ (LineBreak) = return $ " +" <> cr
inlineToAsciiDoc _ Space = return space
inlineToAsciiDoc opts (Cite _ lst) = inlineListToAsciiDoc opts lst
@@ -383,3 +390,4 @@ inlineToAsciiDoc opts (Note [Plain inlines]) = do
return $ text "footnote:[" <> contents <> "]"
-- asciidoc can't handle blank lines in notes
inlineToAsciiDoc _ (Note _) = return "[multiblock footnote omitted]"
+inlineToAsciiDoc opts (Span _ ils) = inlineListToAsciiDoc opts ils
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs
index 32588dc8f..3b321cc19 100644
--- a/src/Text/Pandoc/Writers/ConTeXt.hs
+++ b/src/Text/Pandoc/Writers/ConTeXt.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}
{-
-Copyright (C) 2007-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2007-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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.ConTeXt
- Copyright : Copyright (C) 2007-2010 John MacFarlane
+ Copyright : Copyright (C) 2007-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -33,9 +33,9 @@ import Text.Pandoc.Definition
import Text.Pandoc.Shared
import Text.Pandoc.Writers.Shared
import Text.Pandoc.Options
-import Text.Pandoc.Generic (queryWith)
+import Text.Pandoc.Walk (query)
import Text.Printf ( printf )
-import Data.List ( intercalate, isPrefixOf )
+import Data.List ( intercalate )
import Control.Monad.State
import Text.Pandoc.Pretty
import Text.Pandoc.Templates ( renderTemplate' )
@@ -130,7 +130,7 @@ blockToConTeXt (Plain lst) = inlineListToConTeXt lst
-- title beginning with fig: indicates that the image is a figure
blockToConTeXt (Para [Image txt (src,'f':'i':'g':':':_)]) = do
capt <- inlineListToConTeXt txt
- return $ blankline $$ "\\placefigure[here,nonumber]" <> braces capt <>
+ return $ blankline $$ "\\placefigure" <> braces capt <>
braces ("\\externalfigure" <> brackets (text src)) <> blankline
blockToConTeXt (Para lst) = do
contents <- inlineListToConTeXt lst
@@ -143,6 +143,7 @@ blockToConTeXt (CodeBlock _ str) =
-- blankline because \stoptyping can't have anything after it, inc. '}'
blockToConTeXt (RawBlock "context" str) = return $ text str <> blankline
blockToConTeXt (RawBlock _ _ ) = return empty
+blockToConTeXt (Div _ bs) = blockListToConTeXt bs
blockToConTeXt (BulletList lst) = do
contents <- mapM listItemToConTeXt lst
return $ ("\\startitemize" <> if isTightList lst
@@ -204,9 +205,9 @@ blockToConTeXt (Table caption aligns widths heads rows) = do
else liftM ($$ "\\HL") $ tableRowToConTeXt heads
captionText <- inlineListToConTeXt caption
rows' <- mapM tableRowToConTeXt rows
- return $ "\\placetable" <> brackets ("here" <> if null caption
- then ",none"
- else "")
+ return $ "\\placetable" <> (if null caption
+ then brackets "none"
+ else empty)
<> braces captionText $$
"\\starttable" <> brackets (text colDescriptors) $$
"\\HL" $$ headers $$
@@ -282,14 +283,6 @@ inlineToConTeXt (RawInline "tex" str) = return $ text str
inlineToConTeXt (RawInline _ _) = return empty
inlineToConTeXt (LineBreak) = return $ text "\\crlf" <> cr
inlineToConTeXt Space = return space
--- autolink
-inlineToConTeXt (Link [Str str] (src, tit))
- | if "mailto:" `isPrefixOf` src
- then src == escapeURI ("mailto:" ++ str)
- else src == escapeURI str =
- inlineToConTeXt (Link
- [RawInline "context" "\\hyphenatedurl{", Str str, RawInline "context" "}"]
- (src, tit))
-- Handle HTML-like internal document references to sections
inlineToConTeXt (Link txt (('#' : ref), _)) = do
opts <- gets stOptions
@@ -304,6 +297,7 @@ inlineToConTeXt (Link txt (('#' : ref), _)) = do
<> brackets (text ref)
inlineToConTeXt (Link txt (src, _)) = do
+ let isAutolink = txt == [Str src]
st <- get
let next = stNextRef st
put $ st {stNextRef = next + 1}
@@ -312,8 +306,9 @@ inlineToConTeXt (Link txt (src, _)) = do
return $ "\\useURL"
<> brackets (text ref)
<> brackets (text $ escapeStringUsing [('#',"\\#"),('%',"\\%")] src)
- <> brackets empty
- <> brackets label
+ <> (if isAutolink
+ then empty
+ else brackets empty <> brackets label)
<> "\\from"
<> brackets (text ref)
inlineToConTeXt (Image _ (src, _)) = do
@@ -325,11 +320,12 @@ inlineToConTeXt (Note contents) = do
contents' <- blockListToConTeXt contents
let codeBlock x@(CodeBlock _ _) = [x]
codeBlock _ = []
- let codeBlocks = queryWith codeBlock contents
+ 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 _ ils) = inlineListToConTeXt ils
-- | Craft the section header, inserting the secton reference, if supplied.
sectionHeader :: Attr
diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs
index 732497616..88f590c43 100644
--- a/src/Text/Pandoc/Writers/Custom.hs
+++ b/src/Text/Pandoc/Writers/Custom.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE OverlappingInstances, FlexibleInstances, OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
-{- Copyright (C) 2012 John MacFarlane <jgm@berkeley.edu>
+{- 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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.Custom
- Copyright : Copyright (C) 2012 John MacFarlane
+ Copyright : Copyright (C) 2012-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -33,6 +33,7 @@ module Text.Pandoc.Writers.Custom ( writeCustom ) where
import Text.Pandoc.Definition
import Text.Pandoc.Options
import Data.List ( intersperse )
+import Data.Char ( toLower )
import Scripting.Lua (LuaState, StackValue, callfunc)
import qualified Scripting.Lua as Lua
import Text.Pandoc.UTF8 (fromString, toString)
@@ -78,6 +79,11 @@ instance StackValue a => StackValue [a] where
return (Just lst)
valuetype _ = Lua.TTABLE
+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
@@ -110,12 +116,14 @@ instance StackValue [Block] where
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
@@ -123,7 +131,7 @@ instance StackValue MetaValue where
-- | Convert Pandoc to custom markup.
writeCustom :: FilePath -> WriterOptions -> Pandoc -> IO String
writeCustom luaFile opts doc = do
- luaScript <- readFile luaFile
+ luaScript <- C8.unpack `fmap` C8.readFile luaFile
lua <- Lua.newstate
Lua.openlibs lua
Lua.loadstring lua luaScript "custom"
@@ -176,6 +184,9 @@ blockToCustom lua (OrderedList (num,sty,delim) items) =
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
@@ -238,3 +249,5 @@ inlineToCustom lua (Image alt (src,tit)) =
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
index 6f4b61a79..ba6a92a08 100644
--- a/src/Text/Pandoc/Writers/Docbook.hs
+++ b/src/Text/Pandoc/Writers/Docbook.hs
@@ -1,5 +1,6 @@
+{-# LANGUAGE OverloadedStrings #-}
{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -18,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.Docbook
- Copyright : Copyright (C) 2006-2010 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -31,12 +32,14 @@ module Text.Pandoc.Writers.Docbook ( writeDocbook) 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.Readers.TeXMath
import Data.List ( isPrefixOf, intercalate, isSuffixOf )
import Data.Char ( toLower )
+import Data.Monoid ( Any(..) )
import Text.Pandoc.Highlighting ( languages, languagesByExtension )
import Text.Pandoc.Pretty
import qualified Text.Pandoc.Builder as B
@@ -84,8 +87,9 @@ writeDocbook opts (Pandoc meta blocks) =
auths' = map (authorToDocbook opts) $ docAuthors meta
meta' = B.setMeta "author" auths' meta
Just metadata = metaToJSON opts
- (Just . render colwidth . blocksToDocbook opts)
- (Just . render colwidth . inlinesToDocbook opts)
+ (Just . render colwidth . (vcat .
+ (map (elementToDocbook opts' startLvl)) . hierarchicalize))
+ (Just . render colwidth . inlinesToDocbook opts')
meta'
main = render' $ vcat (map (elementToDocbook opts' startLvl) elements)
context = defField "body" main
@@ -148,6 +152,7 @@ listItemToDocbook opts item =
-- | Convert a Pandoc block element to Docbook.
blockToDocbook :: WriterOptions -> Block -> Doc
blockToDocbook _ Null = empty
+blockToDocbook opts (Div _ bs) = blocksToDocbook opts $ map plainToPara bs
blockToDocbook _ (Header _ _ _) = empty -- should not occur after hierarchicalize
blockToDocbook opts (Plain lst) = inlinesToDocbook opts lst
-- title beginning with fig: indicates that the image is a figure
@@ -162,8 +167,9 @@ blockToDocbook opts (Para [Image txt (src,'f':'i':'g':':':_)]) =
(inTagsIndented "imageobject"
(selfClosingTag "imagedata" [("fileref",src)])) $$
inTagsSimple "textobject" (inTagsSimple "phrase" alt))
-blockToDocbook opts (Para lst) =
- inTagsIndented "para" $ inlinesToDocbook opts lst
+blockToDocbook opts (Para lst)
+ | hasLineBreaks lst = flush $ nowrap $ inTagsSimple "literallayout" $ inlinesToDocbook opts lst
+ | otherwise = inTagsIndented "para" $ inlinesToDocbook opts lst
blockToDocbook opts (BlockQuote blocks) =
inTagsIndented "blockquote" $ blocksToDocbook opts blocks
blockToDocbook _ (CodeBlock (_,classes,_) str) =
@@ -179,10 +185,11 @@ blockToDocbook _ (CodeBlock (_,classes,_) str) =
else languagesByExtension . map toLower $ s
langs = concatMap langsFrom classes
blockToDocbook opts (BulletList lst) =
- inTagsIndented "itemizedlist" $ listItemsToDocbook opts lst
+ let attribs = [("spacing", "compact") | isTightList lst]
+ in inTags True "itemizedlist" attribs $ listItemsToDocbook opts lst
blockToDocbook _ (OrderedList _ []) = empty
blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) =
- let attribs = case numstyle of
+ let numeration = case numstyle of
DefaultStyle -> []
Decimal -> [("numeration", "arabic")]
Example -> [("numeration", "arabic")]
@@ -190,18 +197,21 @@ blockToDocbook opts (OrderedList (start, numstyle, _) (first:rest)) =
LowerAlpha -> [("numeration", "loweralpha")]
UpperRoman -> [("numeration", "upperroman")]
LowerRoman -> [("numeration", "lowerroman")]
- items = if start == 1
- then listItemsToDocbook opts (first:rest)
- else (inTags True "listitem" [("override",show start)]
- (blocksToDocbook opts $ map plainToPara first)) $$
- listItemsToDocbook opts rest
+ spacing = [("spacing", "compact") | isTightList (first:rest)]
+ attribs = numeration ++ spacing
+ items = if start == 1
+ then listItemsToDocbook opts (first:rest)
+ else (inTags True "listitem" [("override",show start)]
+ (blocksToDocbook opts $ map plainToPara first)) $$
+ listItemsToDocbook opts rest
in inTags True "orderedlist" attribs items
blockToDocbook opts (DefinitionList lst) =
- inTagsIndented "variablelist" $ deflistItemsToDocbook opts lst
-blockToDocbook _ (RawBlock "docbook" str) = text str -- raw XML block
--- we allow html for compatibility with earlier versions of pandoc
-blockToDocbook _ (RawBlock "html" str) = text str -- raw XML block
-blockToDocbook _ (RawBlock _ _) = empty
+ let attribs = [("spacing", "compact") | isTightList $ concatMap snd lst]
+ in inTags True "variablelist" attribs $ deflistItemsToDocbook opts lst
+blockToDocbook _ (RawBlock f str)
+ | f == "docbook" = text str -- raw XML block
+ | f == "html" = text str -- allow html for backwards compatibility
+ | otherwise = empty
blockToDocbook _ HorizontalRule = empty -- not semantic
blockToDocbook opts (Table caption aligns widths headers rows) =
let captionDoc = if null caption
@@ -223,6 +233,16 @@ blockToDocbook opts (Table caption aligns widths headers rows) =
(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"
@@ -267,6 +287,8 @@ inlineToDocbook opts (Quoted _ lst) =
inTagsSimple "quote" $ inlinesToDocbook opts lst
inlineToDocbook opts (Cite _ lst) =
inlinesToDocbook opts lst
+inlineToDocbook opts (Span _ ils) =
+ inlinesToDocbook opts ils
inlineToDocbook _ (Code _ str) =
inTagsSimple "literal" $ text (escapeStringForXML str)
inlineToDocbook opts (Math t str)
@@ -277,8 +299,8 @@ inlineToDocbook opts (Math t str)
$ fixNS
$ removeAttr r
Left _ -> inlinesToDocbook opts
- $ readTeXMath str
- | otherwise = inlinesToDocbook opts $ readTeXMath str
+ $ readTeXMath' t str
+ | otherwise = inlinesToDocbook opts $ readTeXMath' t str
where (dt, tagtype) = case t of
InlineMath -> (DisplayInline,"inlineequation")
DisplayMath -> (DisplayBlock,"informalequation")
@@ -288,7 +310,7 @@ inlineToDocbook opts (Math t str)
fixNS = everywhere (mkT fixNS')
inlineToDocbook _ (RawInline f x) | f == "html" || f == "docbook" = text x
| otherwise = empty
-inlineToDocbook _ LineBreak = flush $ inTagsSimple "literallayout" (text "\n")
+inlineToDocbook _ LineBreak = text "\n"
inlineToDocbook _ Space = space
inlineToDocbook opts (Link txt (src, _)) =
if isPrefixOf "mailto:" src
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index e899200f6..31e64f14e 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-
-Copyright (C) 2012 John MacFarlane <jgm@berkeley.edu>
+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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.Docx
- Copyright : Copyright (C) 2012 John MacFarlane
+ Copyright : Copyright (C) 2012-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -29,22 +29,25 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Conversion of 'Pandoc' documents to docx.
-}
module Text.Pandoc.Writers.Docx ( writeDocx ) where
-import Data.List ( intercalate, groupBy )
+import Data.Maybe (fromMaybe)
+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 Text.Pandoc.UTF8 as UTF8
-import Data.Monoid ((<>))
+import Text.Pandoc.Compat.Monoid ((<>))
import Codec.Archive.Zip
import Data.Time.Clock.POSIX
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.Readers.TeXMath
import Text.Pandoc.Highlighting ( highlight )
+import Text.Pandoc.Walk
import Text.Highlighting.Kate.Types ()
import Text.XML.Light
import Text.TeXMath
@@ -54,8 +57,33 @@ import Data.Unique (hashUnique, newUnique)
import System.Random (randomRIO)
import Text.Printf (printf)
import qualified Control.Exception as E
-import System.FilePath (takeExtension)
-import Text.Pandoc.MIME (getMimeType)
+import Text.Pandoc.MIME (getMimeType, extensionFromMimeType)
+import Control.Applicative ((<|>))
+import Data.Maybe (mapMaybe)
+
+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 WriterState = WriterState{
stTextProperties :: [Element]
@@ -66,15 +94,9 @@ data WriterState = WriterState{
, stImages :: M.Map FilePath (String, String, Maybe String, Element, B.ByteString)
, stListLevel :: Int
, stListNumId :: Int
- , stNumStyles :: M.Map ListMarker Int
, stLists :: [ListMarker]
}
-data ListMarker = NoMarker
- | BulletMarker
- | NumberMarker ListNumberStyle ListNumberDelim Int
- deriving (Show, Read, Eq, Ord)
-
defaultWriterState :: WriterState
defaultWriterState = WriterState{
stTextProperties = []
@@ -85,7 +107,6 @@ defaultWriterState = WriterState{
, stImages = M.empty
, stListLevel = -1
, stListNumId = 1
- , stNumStyles = M.fromList [(NoMarker, 0)]
, stLists = [NoMarker]
}
@@ -108,17 +129,52 @@ writeDocx :: WriterOptions -- ^ Writer options
-> IO BL.ByteString
writeDocx opts doc@(Pandoc meta _) = do
let datadir = writerUserDataDir opts
- let doc' = bottomUp (concatMap fixDisplayMath) doc
+ let doc' = walk fixDisplayMath doc
refArchive <- liftM (toArchive . toLazy) $
case writerReferenceDocx opts of
Just f -> B.readFile f
Nothing -> readDataFile datadir "reference.docx"
+ distArchive <- liftM (toArchive . toLazy) $ readDataFile Nothing "reference.docx"
((contents, footnotes), st) <- runStateT (writeOpenXML opts{writerWrapText = False} doc')
defaultWriterState
epochtime <- floor `fmap` getPOSIXTime
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
+
+ -- adjust contents to add sectPr from reference.docx
+ parsedDoc <- parseXml refArchive distArchive "word/document.xml"
+ let wname f qn = qPrefix qn == Just "w" && f (qName qn)
+ let mbsectpr = filterElementName (wname (=="sectPr")) parsedDoc
+
+ let sectpr = maybe (mknode "w:sectPr" [] $ ()) id mbsectpr
+
+ 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")]
+
+ let contents' = contents ++ [sectpr]
+ let docContents = mknode "w:document" stdAttributes
+ $ mknode "w:body" [] $ contents'
+
+ 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 e = findAttr (QName "Target" Nothing Nothing) e
+
-- 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,
@@ -129,8 +185,12 @@ writeDocx opts doc@(Pandoc meta _) = do
let mkOverrideNode (part', contentType') = mknode "Override"
[("PartName",part'),("ContentType",contentType')] ()
let mkImageOverride (_, imgpath, mbMimeType, _, _) =
- mkOverrideNode ("/word/" ++ imgpath, maybe "application/octet-stream" id mbMimeType)
- let overrides = map mkOverrideNode
+ mkOverrideNode ("/word/" ++ imgpath,
+ fromMaybe "application/octet-stream" mbMimeType)
+ let mkMediaOverride imgpath = mkOverrideNode ('/':imgpath,
+ fromMaybe "application/octet-stream"
+ $ getMimeType imgpath)
+ let overrides = map mkOverrideNode (
[("/word/webSettings.xml",
"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml")
,("/word/numbering.xml",
@@ -151,7 +211,15 @@ writeDocx opts doc@(Pandoc meta _) = do
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml")
,("/word/footnotes.xml",
"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml")
- ] ++ map mkImageOverride imgs
+ ] ++
+ 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"
@@ -186,7 +254,9 @@ writeDocx opts doc@(Pandoc meta _) = do
"theme/theme1.xml")
,("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",
"rId7",
- "footnotes.xml")]
+ "footnotes.xml")
+ ] ++
+ headers ++ footers
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") ] ()
@@ -195,15 +265,14 @@ writeDocx opts doc@(Pandoc meta _) = do
let relEntry = toEntry "word/_rels/document.xml.rels" epochtime
$ renderXml reldoc
- -- create entries for images in word/media/...
- let toImageEntry (_,path,_,_,img) = toEntry ("word/" ++ path) epochtime $ toLazy img
- let imageEntries = map toImageEntry imgs
-- word/document.xml
- let contentEntry = toEntry "word/document.xml" epochtime $ renderXml contents
+ let contentEntry = toEntry "word/document.xml" epochtime
+ $ renderXml docContents
-- footnotes
- let footnotesEntry = toEntry "word/footnotes.xml" epochtime $ renderXml 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
@@ -213,14 +282,22 @@ writeDocx opts doc@(Pandoc meta _) = do
-- styles
let newstyles = styleToOpenXml $ writerHighlightStyle opts
let stylepath = "word/styles.xml"
- styledoc <- parseXml refArchive stylepath
- let styledoc' = styledoc{ elContent = elContent styledoc ++ map Elem newstyles }
+ styledoc <- parseXml refArchive distArchive stylepath
+ let styledoc' = styledoc{ elContent = elContent styledoc ++
+ [Elem x | x <- newstyles, writerHighlight opts] }
let styleEntry = toEntry stylepath epochtime $ renderXml styledoc'
-- construct word/numbering.xml
let numpath = "word/numbering.xml"
- numEntry <- (toEntry numpath epochtime . renderXml)
- `fmap` mkNumbering (stNumStyles st) (stLists st)
+ 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")
@@ -229,10 +306,11 @@ writeDocx opts doc@(Pandoc meta _) = do
,("xmlns:dcmitype","http://purl.org/dc/dcmitype/")
,("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance")]
$ mknode "dc:title" [] (stringify $ docTitle meta)
- : mknode "dcterms:created" [("xsi:type","dcterms:W3CDTF")]
- (maybe "" id $ normalizeDate $ stringify $ docDate meta)
- : mknode "dcterms:modified" [("xsi:type","dcterms:W3CDTF")] () -- put current time here
- : map (mknode "dc:creator" [] . stringify) (docAuthors meta)
+ : mknode "dc:creator" [] (intercalate "; " (map stringify $ docAuthors meta))
+ : maybe []
+ (\x -> [ mknode "dcterms:created" [("xsi:type","dcterms:W3CDTF")] $ x
+ , mknode "dcterms:modified" [("xsi:type","dcterms:W3CDTF")] $ x
+ ]) (normalizeDate $ stringify $ docDate meta)
let docPropsEntry = toEntry docPropsPath epochtime $ renderXml docProps
let relsPath = "_rels/.rels"
@@ -245,24 +323,41 @@ writeDocx opts doc@(Pandoc meta _) = do
,("Type","http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties")
,("Target","docProps/app.xml")]
, [("Id","rId3")
- ,("Type","http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties")
+ ,("Type","http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties")
,("Target","docProps/core.xml")]
]
let relsEntry = toEntry relsPath epochtime $ renderXml rels
- let entryFromArchive path = (toEntry path epochtime . renderXml) `fmap`
- parseXml refArchive path
- docPropsAppEntry <- entryFromArchive "docProps/app.xml"
- themeEntry <- entryFromArchive "word/theme/theme1.xml"
- fontTableEntry <- entryFromArchive "word/fontTable.xml"
- webSettingsEntry <- entryFromArchive "word/webSettings.xml"
+ let entryFromArchive arch path =
+ maybe (fail $ path ++ " corrupt or 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"
+ -- we use dist archive for settings.xml, because Word sometimes
+ -- adds references to footnotes or endnotes we don't have...
+ settingsEntry <- entryFromArchive distArchive "word/settings.xml"
+ webSettingsEntry <- entryFromArchive refArchive "word/webSettings.xml"
+ headerFooterEntries <- mapM (entryFromArchive refArchive) $
+ mapMaybe (\e -> fmap ("word/" ++) $ extractTarget e)
+ (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 : webSettingsEntry : imageEntries
+ fontTableEntry : settingsEntry : webSettingsEntry :
+ imageEntries ++ headerFooterEntries ++
+ miscRelEntries ++ otherMediaEntries
return $ fromArchive archive
styleToOpenXml :: Style -> [Element]
@@ -300,29 +395,30 @@ styleToOpenXml style = parStyle : map toStyle alltoktypes
$ backgroundColor style )
]
-mkNumbering :: M.Map ListMarker Int -> [ListMarker] -> IO Element
-mkNumbering markers lists = do
- elts <- mapM mkAbstractNum (M.toList markers)
- return $ mknode "w:numbering"
- [("xmlns:w","http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
- $ elts ++ zipWith (mkNum markers) lists [1..(length lists)]
+-- this is the lowest number used for a list numId
+baseListId :: Int
+baseListId = 1000
-mkNum :: M.Map ListMarker Int -> ListMarker -> Int -> Element
-mkNum markers marker numid =
+mkNumbering :: [ListMarker] -> IO [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",show absnumid)] ()
+ $ 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]
- where absnumid = maybe 0 id $ M.lookup marker markers
-mkAbstractNum :: (ListMarker,Int) -> IO Element
-mkAbstractNum (marker,numid) = do
+mkAbstractNum :: ListMarker -> IO Element
+mkAbstractNum marker = do
nsid <- randomRIO (0x10000000 :: Integer, 0xFFFFFFFF :: Integer)
- return $ mknode "w:abstractNum" [("w:abstractNumId",show numid)]
+ 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]
@@ -374,10 +470,11 @@ mkLvl marker lvl =
patternFor _ s = s ++ "."
getNumId :: WS Int
-getNumId = length `fmap` gets stLists
+getNumId = ((999 +) . length) `fmap` gets stLists
--- | Convert Pandoc document to two OpenXML elements (the main document and footnotes).
-writeOpenXML :: WriterOptions -> Pandoc -> WS (Element, Element)
+-- | Convert Pandoc document to two lists of
+-- OpenXML elements (the main document and footnotes).
+writeOpenXML :: WriterOptions -> Pandoc -> WS ([Element], [Element])
writeOpenXML opts (Pandoc meta blocks) = do
let tit = docTitle meta ++ case lookupMeta "subtitle" meta of
Just (MetaBlocks [Plain xs]) -> LineBreak : xs
@@ -395,19 +492,7 @@ writeOpenXML opts (Pandoc meta blocks) = do
doc' <- blocksToOpenXML opts blocks'
notes' <- reverse `fmap` gets stFootnotes
let meta' = title ++ authors ++ date
- 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")]
- let doc = mknode "w:document" stdAttributes $ mknode "w:body" [] (meta' ++ doc')
- let notes = mknode "w:footnotes" stdAttributes notes'
- return (doc, notes)
+ return (meta' ++ doc', notes')
-- | Convert a list of Pandoc blocks to OpenXML.
blocksToOpenXML :: WriterOptions -> [Block] -> WS [Element]
@@ -427,6 +512,7 @@ getUniqueId = liftIO $ (show . (+ 20) . hashUnique) `fmap` newUnique
-- | Convert a Pandoc block element to OpenXML.
blockToOpenXML :: WriterOptions -> Block -> WS [Element]
blockToOpenXML _ Null = return []
+blockToOpenXML opts (Div _ bs) = blocksToOpenXML opts bs
blockToOpenXML opts (Header lev (ident,_,_) lst) = do
contents <- withParaProp (pStyle $ "Heading" ++ show lev) $
blockToOpenXML opts (Para lst)
@@ -458,8 +544,8 @@ blockToOpenXML opts (Para lst) = do
contents <- inlinesToOpenXML opts lst
return [mknode "w:p" [] (paraProps ++ contents)]
blockToOpenXML _ (RawBlock format str)
- | format == "openxml" = return [ x | Elem x <- parseXML str ]
- | otherwise = return []
+ | format == Format "openxml" = return [ x | Elem x <- parseXML str ]
+ | otherwise = return []
blockToOpenXML opts (BlockQuote blocks) =
withParaProp (pStyle "BlockQuote") $ blocksToOpenXML opts blocks
blockToOpenXML opts (CodeBlock attrs str) =
@@ -485,10 +571,12 @@ blockToOpenXML opts (Table caption aligns widths headers rows) = do
[ mknode "w:tcBorders" []
$ mknode "w:bottom" [("w:val","single")] ()
, mknode "w:vAlign" [("w:val","bottom")] () ]
+ let emptyCell = [mknode "w:p" [] [mknode "w:pPr" [] $
+ [mknode "w:pStyle" [("w:val","Compact")] ()]]]
let mkcell border contents = mknode "w:tc" []
$ [ borderProps | border ] ++
if null contents
- then [mknode "w:p" [] ()]
+ then emptyCell
else contents
let mkrow border cells = mknode "w:tr" [] $ map (mkcell border) cells
let textwidth = 7920 -- 5.5 in in twips, 1/20 pt
@@ -533,17 +621,13 @@ addList :: ListMarker -> WS ()
addList marker = do
lists <- gets stLists
modify $ \st -> st{ stLists = lists ++ [marker] }
- numStyles <- gets stNumStyles
- case M.lookup marker numStyles of
- Just _ -> return ()
- Nothing -> modify $ \st ->
- st{ stNumStyles = M.insert marker (M.size numStyles + 1) numStyles }
listItemToOpenXML :: WriterOptions -> Int -> [Block] -> WS [Element]
listItemToOpenXML _ _ [] = return []
listItemToOpenXML opts numid (first:rest) = do
first' <- withNumId numid $ blockToOpenXML opts first
- rest' <- withNumId 1 $ blocksToOpenXML opts rest
+ -- baseListId is the code for no list marker:
+ rest' <- withNumId baseListId $ blocksToOpenXML opts rest
return $ first' ++ rest'
alignmentToString :: Alignment -> [Char]
@@ -632,6 +716,12 @@ formattedString str = do
inlineToOpenXML :: WriterOptions -> Inline -> WS [Element]
inlineToOpenXML _ (Str str) = formattedString str
inlineToOpenXML opts Space = inlineToOpenXML opts (Str " ")
+inlineToOpenXML opts (Span (_,classes,_) ils) = 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) =
@@ -650,8 +740,8 @@ inlineToOpenXML opts (Strikeout lst) =
$ inlinesToOpenXML opts lst
inlineToOpenXML _ LineBreak = return [br]
inlineToOpenXML _ (RawInline f str)
- | f == "openxml" = return [ x | Elem x <- parseXML str ]
- | otherwise = return []
+ | f == Format "openxml" = return [ x | Elem x <- parseXML str ]
+ | otherwise = return []
inlineToOpenXML opts (Quoted quoteType lst) =
inlinesToOpenXML opts $ [Str open] ++ lst ++ [Str close]
where (open, close) = case quoteType of
@@ -663,15 +753,18 @@ inlineToOpenXML opts (Math mathType str) = do
else DisplayInline
case texMathToOMML displayType str of
Right r -> return [r]
- Left _ -> inlinesToOpenXML opts (readTeXMath str)
+ Left _ -> inlinesToOpenXML opts (readTeXMath' mathType str)
inlineToOpenXML opts (Cite _ lst) = inlinesToOpenXML opts lst
-inlineToOpenXML _ (Code attrs str) =
+inlineToOpenXML opts (Code attrs str) =
withTextProp (rStyle "VerbatimChar")
- $ case highlight formatOpenXML attrs str of
- Nothing -> intercalate [br]
- `fmap` (mapM formattedString $ lines str)
- Just h -> return h
- where formatOpenXML _fmtOpts = intercalate [br] . map (map toHlTok)
+ $ if writerHighlight opts
+ then case highlight formatOpenXML attrs str of
+ Nothing -> unhighlighted
+ Just h -> return h
+ else unhighlighted
+ where unhighlighted = intercalate [br] `fmap`
+ (mapM formattedString $ lines str)
+ formatOpenXML _fmtOpts = intercalate [br] . map (map toHlTok)
toHlTok (toktype,tok) = mknode "w:r" []
[ mknode "w:rPr" []
[ rStyle $ show toktype ]
@@ -682,7 +775,7 @@ inlineToOpenXML opts (Note bs) = do
let notemarker = mknode "w:r" []
[ mknode "w:rPr" [] (rStyle "FootnoteRef")
, mknode "w:footnoteRef" [] () ]
- let notemarkerXml = RawInline "openxml" $ ppElement notemarker
+ let notemarkerXml = RawInline (Format "openxml") $ ppElement notemarker
let insertNoteRef (Plain ils : xs) = Plain (notemarkerXml : ils) : xs
insertNoteRef (Para ils : xs) = Para (notemarkerXml : ils) : xs
insertNoteRef xs = Para [notemarkerXml] : xs
@@ -721,14 +814,13 @@ inlineToOpenXML opts (Image alt (src, tit)) = do
case M.lookup src imgs of
Just (_,_,_,elt,_) -> return [elt]
Nothing -> do
- let sourceDir = writerSourceDirectory opts
- res <- liftIO $ E.try $ fetchItem sourceDir src
+ res <- liftIO $ fetchItem (writerSourceURL opts) src
case res of
Left (_ :: E.SomeException) -> do
liftIO $ warn $ "Could not find image `" ++ src ++ "', skipping..."
-- emit alt text
inlinesToOpenXML opts alt
- Right (img, _) -> do
+ Right (img, mt) -> do
ident <- ("rId"++) `fmap` getUniqueId
let size = imageSize img
let (xpt,ypt) = maybe (120,120) sizeInPoints size
@@ -767,18 +859,21 @@ inlineToOpenXML opts (Image alt (src, tit)) = do
, mknode "wp:effectExtent" [("b","0"),("l","0"),("r","0"),("t","0")] ()
, mknode "wp:docPr" [("descr",tit),("id","1"),("name","Picture")] ()
, graphic ]
- let imgext = case imageType img of
- Just Png -> ".png"
- Just Jpeg -> ".jpeg"
- Just Gif -> ".gif"
- Just Pdf -> ".pdf"
- Nothing -> takeExtension src
+ 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 = getMimeType imgpath
+ 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)
@@ -788,32 +883,10 @@ inlineToOpenXML opts (Image alt (src, tit)) = do
br :: Element
br = mknode "w:r" [] [mknode "w:br" [("w:type","textWrapping")] () ]
-parseXml :: Archive -> String -> IO Element
-parseXml refArchive relpath =
- case (findEntryByPath relpath refArchive >>= parseXMLDoc . UTF8.toStringLazy . fromEntry) of
- Just d -> return d
- Nothing -> fail $ relpath ++ " missing in reference docx"
-
-isDisplayMath :: Inline -> Bool
-isDisplayMath (Math DisplayMath _) = True
-isDisplayMath _ = False
-
-stripLeadingTrailingSpace :: [Inline] -> [Inline]
-stripLeadingTrailingSpace = go . reverse . go . reverse
- where go (Space:xs) = xs
- go xs = xs
-
-fixDisplayMath :: Block -> [Block]
-fixDisplayMath (Plain lst)
- | any isDisplayMath lst && not (all isDisplayMath lst) =
- -- chop into several paragraphs so each displaymath is its own
- 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
- map (Para . stripLeadingTrailingSpace) $
- groupBy (\x y -> (isDisplayMath x && isDisplayMath y) ||
- not (isDisplayMath x || isDisplayMath y)) lst
-fixDisplayMath x = [x]
+parseXml :: Archive -> Archive -> String -> IO Element
+parseXml refArchive distArchive relpath =
+ case ((findEntryByPath relpath refArchive `mplus`
+ findEntryByPath relpath distArchive)
+ >>= parseXMLDoc . UTF8.toStringLazy . fromEntry) of
+ Just d -> return d
+ Nothing -> fail $ relpath ++ " corrupt or missing in reference docx"
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index f171a2560..b6687c330 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -1,6 +1,6 @@
-{-# LANGUAGE PatternGuards #-}
+{-# LANGUAGE PatternGuards, CPP, ScopedTypeVariables #-}
{-
-Copyright (C) 2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2010-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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.EPUB
- Copyright : Copyright (C) 2010 John MacFarlane
+ Copyright : Copyright (C) 2010-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -30,16 +30,18 @@ Conversion of 'Pandoc' documents to EPUB.
-}
module Text.Pandoc.Writers.EPUB ( writeEPUB ) where
import Data.IORef
-import Data.Maybe ( fromMaybe, isNothing )
+import qualified Data.Map as M
+import Data.Maybe ( fromMaybe )
import Data.List ( isInfixOf, intercalate )
import System.Environment ( getEnv )
import Text.Printf (printf)
-import System.FilePath ( (</>), takeBaseName, takeExtension, takeFileName )
+import System.FilePath ( (</>), takeExtension, takeFileName )
import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString.Lazy.Char8 as B8
-import Text.Pandoc.UTF8 ( fromStringLazy, toString )
+import qualified Text.Pandoc.UTF8 as UTF8
import Text.Pandoc.SelfContained ( makeSelfContained )
import Codec.Archive.Zip
+import Control.Applicative ((<$>))
import Data.Time.Clock.POSIX
import Data.Time
import System.Locale
@@ -48,25 +50,18 @@ import qualified Text.Pandoc.Shared as Shared
import Text.Pandoc.Builder (fromList, setMeta)
import Text.Pandoc.Options
import Text.Pandoc.Definition
-import Text.Pandoc.Generic
+import Text.Pandoc.Walk
import Control.Monad.State
import Text.XML.Light hiding (ppTopElement)
import Text.Pandoc.UUID
import Text.Pandoc.Writers.HTML
import Text.Pandoc.Writers.Markdown ( writePlain )
-import Data.Char ( toLower )
-import Network.URI ( isAbsoluteURI, unEscapeString )
+import Data.Char ( toLower, isDigit, isAlphaNum )
+import Network.URI ( unEscapeString )
import Text.Pandoc.MIME (getMimeType)
-#if MIN_VERSION_base(4,6,0)
-#else
-import Prelude hiding (catch)
-#endif
-import Control.Exception (catch, SomeException)
-#if MIN_VERSION_blaze_html(0,5,0)
+import qualified Control.Exception as E
import Text.Blaze.Html.Renderer.Utf8 (renderHtml)
-#else
-import Text.Blaze.Renderer.Utf8 (renderHtml)
-#endif
+import Text.HTML.TagSoup
-- A Chapter includes a list of blocks and maybe a section
-- number offset. Note, some chapters are unnumbered. The section
@@ -74,12 +69,260 @@ import Text.Blaze.Renderer.Utf8 (renderHtml)
-- in filenames, chapter0003.xhtml.
data Chapter = Chapter (Maybe [Int]) [Block]
+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
+ } 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
+
+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")
+
+plainify :: [Inline] -> String
+plainify t =
+ trimr $ writePlain def{ writerStandalone = False }
+ $ Pandoc nullMeta [Plain $ walk removeNote t]
+
+removeNote :: Inline -> Inline
+removeNote (Note _) = Str ""
+removeNote x = x
+
+toId :: FilePath -> String
+toId = map (\x -> if isAlphaNum x || x == '-' || x == '_'
+ then x
+ else '_') . takeFileName
+
+getEPUBMetadata :: WriterOptions -> Meta -> IO EPUBMetadata
+getEPUBMetadata opts meta = do
+ let md = metadataFromMeta opts meta
+ let elts = onlyElems $ parseXML $ writerEpubMetadata opts
+ let md' = foldr addMetadataFromXML md elts
+ let addIdentifier m =
+ if null (epubIdentifier m)
+ then do
+ randomId <- fmap show getRandomUUID
+ 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
+ localeLang <- E.catch (liftM
+ (map (\c -> if c == '_' then '-' else c) .
+ takeWhile (/='.')) $ getEnv "LANG")
+ (\e -> let _ = (e :: E.SomeException) in return "en-US")
+ return m{ epubLanguage = localeLang }
+ else return m
+ let fixDate m =
+ if null (epubDate m)
+ then do
+ currentTime <- 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 plainify $ 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) = plainify ils
+metaValueToString (MetaBlocks bs) = plainify $ query (:[]) bs
+metaValueToString (MetaBool b) = show b
+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
+ }
+ 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)
+
-- | Produce an EPUB file from a Pandoc document.
writeEPUB :: WriterOptions -- ^ Writer options
-> Pandoc -- ^ Document to convert
-> IO B.ByteString
writeEPUB opts doc@(Pandoc meta _) = do
- let version = maybe EPUB2 id (writerEpubVersion opts)
+ let version = fromMaybe EPUB2 (writerEpubVersion opts)
let epub3 = version == EPUB3
epochtime <- floor `fmap` getPOSIXTime
let mkEntry path content = toEntry path epochtime content
@@ -97,17 +340,16 @@ writeEPUB opts doc@(Pandoc meta _) = do
then MathML Nothing
else writerHTMLMathMethod opts
, writerWrapText = False }
- let sourceDir = writerSourceDirectory opts'
- let mbCoverImage = lookup "epub-cover-image" vars
+ metadata <- getEPUBMetadata opts' meta
-- cover page
(cpgEntry, cpicEntry) <-
- case mbCoverImage of
+ case epubCoverImage metadata of
Nothing -> return ([],[])
Just img -> do
- let coverImage = "cover-image" ++ takeExtension img
+ let coverImage = "media/" ++ takeFileName img
let cpContent = renderHtml $ writeHtml opts'
- (Pandoc meta [RawBlock "html" $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ "\" alt=\"cover image\" />\n</div>"])
+ (Pandoc meta [RawBlock (Format "html") $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ "\" alt=\"cover image\" />\n</div>"])
imgContent <- B.readFile img
return ( [mkEntry "cover.xhtml" cpContent]
, [mkEntry coverImage imgContent] )
@@ -119,14 +361,19 @@ writeEPUB opts doc@(Pandoc meta _) = do
let tpEntry = mkEntry "title_page.xhtml" tpContent
-- handle pictures
- picsRef <- newIORef []
- Pandoc _ blocks <- bottomUpM
- (transformInline opts' sourceDir picsRef) doc
- pics <- readIORef picsRef
- let readPicEntry (oldsrc, newsrc) = do
- (img,_) <- fetchItem sourceDir oldsrc
- return $ toEntry newsrc epochtime $ B.fromChunks . (:[]) $ img
- picEntries <- mapM readPicEntry pics
+ mediaRef <- newIORef []
+ Pandoc _ blocks <- walkM (transformInline opts' mediaRef) doc >>=
+ walkM (transformBlock opts' mediaRef)
+ pics <- readIORef mediaRef
+ let readPicEntry entries (oldsrc, newsrc) = do
+ res <- fetchItem (writerSourceURL opts') oldsrc
+ case res of
+ Left _ -> do
+ warn $ "Could not find media `" ++ oldsrc ++ "', skipping..."
+ return entries
+ Right (img,_) -> return $
+ (toEntry newsrc epochtime $ B.fromChunks . (:[]) $ img) : entries
+ picEntries <- foldM readPicEntry [] pics
-- handle fonts
let mkFontEntry f = mkEntry (takeFileName f) `fmap` B.readFile f
@@ -179,59 +426,60 @@ writeEPUB opts doc@(Pandoc meta _) = do
chapToEntry num (Chapter mbnum bs) = mkEntry (showChapter num)
$ renderHtml
$ writeHtml opts'{ writerNumberOffset =
- maybe [] id mbnum }
+ fromMaybe [] mbnum }
$ case bs of
(Header _ _ xs : _) ->
- Pandoc (setMeta "title" (fromList xs) nullMeta) bs
+ -- remove notes or we get doubled footnotes
+ Pandoc (setMeta "title" (walk removeNote $ fromList xs)
+ nullMeta) bs
_ ->
Pandoc nullMeta bs
let chapterEntries = zipWith chapToEntry [1..] chapters
-- incredibly inefficient (TODO):
- let containsMathML ent = "<math" `isInfixOf` (B8.unpack $ fromEntry ent)
+ 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
- localeLang <- catch (liftM (map (\c -> if c == '_' then '-' else c) .
- takeWhile (/='.')) $ getEnv "LANG")
- (\e -> let _ = (e :: SomeException) in return "en-US")
- let lang = case lookup "lang" (writerVariables opts') of
- Just x -> x
- Nothing -> localeLang
- uuid <- getRandomUUID
let chapterNode ent = unode "item" !
- ([("id", takeBaseName $ eRelativePath ent),
+ ([("id", toId $ eRelativePath ent),
("href", eRelativePath ent),
("media-type", "application/xhtml+xml")]
- ++ [("properties","mathml") | epub3 &&
- containsMathML ent]) $ ()
+ ++ case props ent of
+ [] -> []
+ xs -> [("properties", unwords xs)])
+ $ ()
let chapterRefNode ent = unode "itemref" !
- [("idref", takeBaseName $ eRelativePath ent)] $ ()
+ [("idref", toId $ eRelativePath ent)] $ ()
let pictureNode ent = unode "item" !
- [("id", takeBaseName $ eRelativePath ent),
+ [("id", toId $ eRelativePath ent),
("href", eRelativePath ent),
("media-type", fromMaybe "application/octet-stream"
- $ imageTypeOf $ eRelativePath ent)] $ ()
+ $ mediaTypeOf $ eRelativePath ent)] $ ()
let fontNode ent = unode "item" !
- [("id", takeBaseName $ eRelativePath ent),
+ [("id", toId $ eRelativePath ent),
("href", eRelativePath ent),
- ("media-type", maybe "" id $ getMimeType $ eRelativePath ent)] $ ()
- let plainify t = trimr $
- writePlain opts'{ writerStandalone = False } $
- Pandoc meta [Plain t]
- let plainTitle = plainify $ docTitle meta
- let plainAuthors = map plainify $ docAuthors meta
+ ("media-type", fromMaybe "" $ getMimeType $ eRelativePath ent)] $ ()
+ let plainTitle = case docTitle meta of
+ [] -> case epubTitle metadata of
+ [] -> "UNTITLED"
+ (x:_) -> titleText x
+ x -> plainify x
+ let uuid = case epubIdentifier metadata of
+ (x:_) -> identifierText x -- use first identifier as UUID
+ [] -> error "epubIdentifier is null" -- shouldn't happen
currentTime <- getCurrentTime
- let plainDate = maybe (showDateTimeISO8601 currentTime) id
- $ normalizeDate $ stringify $ docDate meta
- let contentsData = fromStringLazy $ ppTopElement $
+ 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","BookId")] $
- [ metadataElement version (writerEpubMetadata opts')
- uuid lang plainTitle plainAuthors plainDate currentTime mbCoverImage
+ ,("unique-identifier","epub-id-1")] $
+ [ metadataElement version metadata currentTime
, unode "manifest" $
[ unode "item" ! [("id","ncx"), ("href","toc.ncx")
,("media-type","application/x-dtbncx+xml")] $ ()
@@ -243,14 +491,19 @@ writeEPUB opts doc@(Pandoc meta _) = do
[("properties","nav") | epub3 ]) $ ()
] ++
map chapterNode (cpgEntry ++ (tpEntry : chapterEntries)) ++
- map pictureNode (cpicEntry ++ picEntries) ++
+ (case cpicEntry of
+ [] -> []
+ (x:_) -> [add_attrs
+ [Attr (unqual "properties") "cover-image" | epub3]
+ (pictureNode x)]) ++
+ map pictureNode picEntries ++
map fontNode fontEntries
, unode "spine" ! [("toc","ncx")] $
- case mbCoverImage of
+ case epubCoverImage metadata of
Nothing -> []
Just _ -> [ unode "itemref" !
- [("idref", "cover"),("linear","no")] $ () ]
- ++ ((unode "itemref" ! [("idref", "title_page")
+ [("idref", "cover_xhtml"),("linear","no")] $ () ]
+ ++ ((unode "itemref" ! [("idref", "title_page_xhtml")
,("linear", if null (docTitle meta)
then "no"
else "yes")] $ ()) :
@@ -260,8 +513,13 @@ writeEPUB opts doc@(Pandoc meta _) = do
else "no")] $ ()) :
map chapterRefNode chapterEntries)
, unode "guide" $
- unode "reference" !
- [("type","toc"),("title",plainTitle),("href","nav.xhtml")] $ ()
+ [ unode "reference" !
+ [("type","toc"),("title",plainTitle),
+ ("href","nav.xhtml")] $ ()
+ ] ++
+ [ unode "reference" !
+ [("type","cover"),("title","Cover"),("href","cover.xhtml")] $ () | epubCoverImage metadata /= Nothing
+ ]
]
let contentsEntry = mkEntry "content.opf" contentsData
@@ -303,22 +561,22 @@ writeEPUB opts doc@(Pandoc meta _) = do
[ unode "navLabel" $ unode "text" (plainify $ docTitle meta)
, unode "content" ! [("src","title_page.xhtml")] $ () ]
- let tocData = fromStringLazy $ ppTopElement $
+ 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", show uuid)] $ ()
+ ,("content", uuid)] $ ()
, unode "meta" ! [("name","dtb:depth")
,("content", "1")] $ ()
, unode "meta" ! [("name","dtb:totalPageCount")
,("content", "0")] $ ()
, unode "meta" ! [("name","dtb:maxPageNumber")
,("content", "0")] $ ()
- ] ++ case mbCoverImage of
+ ] ++ case epubCoverImage metadata of
Nothing -> []
- Just _ -> [unode "meta" ! [("name","cover"),
- ("content","cover-image")] $ ()]
+ Just img -> [unode "meta" ! [("name","cover"),
+ ("content", toId img)] $ ()]
, unode "docTitle" $ unode "text" $ plainTitle
, unode "navMap" $
tpNode : evalState (mapM (navPointNode navMapFormatter) secs) 1
@@ -335,7 +593,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
(_:_) -> [unode "ol" ! [("class","toc")] $ subs]
let navtag = if epub3 then "nav" else "div"
- let navData = fromStringLazy $ ppTopElement $
+ let navData = UTF8.fromStringLazy $ ppTopElement $
unode "html" ! [("xmlns","http://www.w3.org/1999/xhtml")
,("xmlns:epub","http://www.idpf.org/2007/ops")] $
[ unode "head" $
@@ -349,10 +607,10 @@ writeEPUB opts doc@(Pandoc meta _) = do
let navEntry = mkEntry "nav.xhtml" navData
-- mimetype
- let mimetypeEntry = mkEntry "mimetype" $ fromStringLazy "application/epub+zip"
+ let mimetypeEntry = mkEntry "mimetype" $ UTF8.fromStringLazy "application/epub+zip"
-- container.xml
- let containerData = fromStringLazy $ ppTopElement $
+ let containerData = UTF8.fromStringLazy $ ppTopElement $
unode "container" ! [("version","1.0")
,("xmlns","urn:oasis:names:tc:opendocument:xmlns:container")] $
unode "rootfiles" $
@@ -361,18 +619,19 @@ writeEPUB opts doc@(Pandoc meta _) = do
let containerEntry = mkEntry "META-INF/container.xml" containerData
-- com.apple.ibooks.display-options.xml
- let apple = fromStringLazy $ ppTopElement $
+ 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 writerEpubStylesheet opts of
- Just s -> return s
- Nothing -> toString `fmap`
+ stylesheet <- case epubStylesheet metadata of
+ Just (StylesheetPath fp) -> UTF8.readFile fp
+ Just (StylesheetContents s) -> return s
+ Nothing -> UTF8.toString `fmap`
readDataFile (writerUserDataDir opts) "epub.css"
- let stylesheetEntry = mkEntry "stylesheet.css" $ fromStringLazy stylesheet
+ let stylesheetEntry = mkEntry "stylesheet.css" $ UTF8.fromStringLazy stylesheet
-- construct archive
let archive = foldr addEntryToArchive emptyArchive
@@ -381,64 +640,167 @@ writeEPUB opts doc@(Pandoc meta _) = do
(picEntries ++ cpicEntry ++ cpgEntry ++ chapterEntries ++ fontEntries))
return $ fromArchive archive
-metadataElement :: EPUBVersion -> String -> UUID -> String -> String -> [String]
- -> String -> UTCTime -> Maybe a -> Element
-metadataElement version metadataXML uuid lang title authors date currentTime mbCoverImage =
- let userNodes = parseXML metadataXML
- elt = unode "metadata" ! [("xmlns:dc","http://purl.org/dc/elements/1.1/")
- ,("xmlns:opf","http://www.idpf.org/2007/opf")] $
- filter isMetadataElement $ onlyElems userNodes
- dublinElements = ["contributor","coverage","creator","date",
- "description","format","identifier","language","publisher",
- "relation","rights","source","subject","title","type"]
- isMetadataElement e = (qPrefix (elName e) == Just "dc" &&
- qName (elName e) `elem` dublinElements) ||
- (qPrefix (elName e) == Nothing &&
- qName (elName e) `elem` ["link","meta"])
- contains e n = not (null (findElements (QName n Nothing (Just "dc")) e))
- newNodes = [ unode "dc:title" title | not (elt `contains` "title") ] ++
- [ unode "dc:language" lang | not (elt `contains` "language") ] ++
- [ unode "dc:identifier" ! [("id","BookId")] $ show uuid |
- not (elt `contains` "identifier") ] ++
- [ unode "dc:creator" ! [("opf:role","aut") | version == EPUB2]
- $ a | a <- authors, not (elt `contains` "creator") ] ++
- [ unode "dc:date" date | not (elt `contains` "date") ] ++
- [ unode "meta" ! [("property", "dcterms:modified")] $
- (showDateTimeISO8601 currentTime) | version == EPUB3] ++
- [ unode "meta" ! [("name","cover"), ("content","cover-image")] $ () |
- not (isNothing mbCoverImage) ]
- in elt{ elContent = elContent elt ++ map Elem newNodes }
+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') :
+ maybe [] (\x -> [("opf:file-as",x)]) (titleFileAs title) ++
+ maybe [] (\x -> [("opf:title-type",x)]) (titleType 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 :: WriterOptions
+ -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) media
+ -> Tag String
+ -> IO (Tag String)
+transformTag opts mediaRef tag@(TagOpen name attr)
+ | name == "video" || name == "source" || name == "img" = do
+ let src = fromAttrib "src" tag
+ let poster = fromAttrib "poster" tag
+ let oldsrc = maybe src (</> src) $ writerSourceURL opts
+ let oldposter = maybe poster (</> poster) $ writerSourceURL opts
+ newsrc <- modifyMediaRef mediaRef oldsrc
+ newposter <- modifyMediaRef mediaRef oldposter
+ 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 :: IORef [(FilePath, FilePath)] -> FilePath -> IO FilePath
+modifyMediaRef _ "" = return ""
+modifyMediaRef mediaRef oldsrc = do
+ media <- readIORef mediaRef
+ case lookup oldsrc media of
+ Just n -> return n
+ Nothing -> do
+ let new = "media/file" ++ show (length media) ++
+ takeExtension oldsrc
+ modifyIORef mediaRef ( (oldsrc, new): )
+ return new
+
+transformBlock :: WriterOptions
+ -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) media
+ -> Block
+ -> IO Block
+transformBlock opts mediaRef (RawBlock fmt raw)
+ | fmt == Format "html" = do
+ let tags = parseTags raw
+ tags' <- mapM (transformTag opts mediaRef) tags
+ return $ RawBlock fmt (renderTags tags')
+transformBlock _ _ b = return b
+
transformInline :: WriterOptions
- -> FilePath
- -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) images
+ -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) media
-> Inline
-> IO Inline
-transformInline opts sourceDir picsRef (Image lab (src,tit))
- | isAbsoluteURI src = do
- raw <- makeSelfContained Nothing
- $ writeHtmlInline opts (Image lab (src,tit))
- return $ RawInline "html" raw
- | otherwise = do
+transformInline opts mediaRef (Image lab (src,tit)) = do
let src' = unEscapeString src
- pics <- readIORef picsRef
- let oldsrc = sourceDir </> src'
- let ext = takeExtension src'
- newsrc <- case lookup oldsrc pics of
- Just n -> return n
- Nothing -> do
- let new = "images/img" ++ show (length pics) ++ ext
- modifyIORef picsRef ( (oldsrc, new): )
- return new
+ let oldsrc = maybe src' (</> src) $ writerSourceURL opts
+ newsrc <- modifyMediaRef mediaRef oldsrc
return $ Image lab (newsrc, tit)
-transformInline opts _ _ (x@(Math _ _))
+transformInline opts _ (x@(Math _ _))
| WebTeX _ <- writerHTMLMathMethod opts = do
raw <- makeSelfContained Nothing $ writeHtmlInline opts x
- return $ RawInline "html" raw
-transformInline _ _ _ x = return x
+ return $ RawInline (Format "html") raw
+transformInline _ _ x = return x
writeHtmlInline :: WriterOptions -> Inline -> String
writeHtmlInline opts z = trimr $
@@ -462,16 +824,12 @@ ppTopElement = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ++) . unEntity .
Nothing -> '&':'#':unEntity xs
unEntity (x:xs) = x : unEntity xs
-imageTypeOf :: FilePath -> Maybe String
-imageTypeOf x = case drop 1 (map toLower (takeExtension x)) of
- "jpg" -> Just "image/jpeg"
- "jpeg" -> Just "image/jpeg"
- "jfif" -> Just "image/jpeg"
- "png" -> Just "image/png"
- "gif" -> Just "image/gif"
- "svg" -> Just "image/svg+xml"
- _ -> Nothing
-
+mediaTypeOf :: FilePath -> Maybe String
+mediaTypeOf x = case getMimeType x of
+ Just y@('i':'m':'a':'g':'e':_) -> Just y
+ Just y@('v':'i':'d':'e':'o':_) -> Just y
+ Just y@('a':'u':'d':'i':'o':_) -> Just y
+ _ -> Nothing
data IdentState = IdentState{
chapterNumber :: Int,
@@ -519,9 +877,293 @@ correlateRefs chapterHeaderLevel bs =
-- Replace internal link references using the table produced
-- by correlateRefs.
replaceRefs :: [(String,String)] -> [Block] -> [Block]
-replaceRefs refTable = bottomUp replaceOneRef
+replaceRefs refTable = walk replaceOneRef
where replaceOneRef x@(Link lab ('#':xs,tit)) =
case lookup xs refTable of
Just url -> Link lab (url,tit)
Nothing -> x
replaceOneRef x = 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")
+ ]
+
diff --git a/src/Text/Pandoc/Writers/FB2.hs b/src/Text/Pandoc/Writers/FB2.hs
index 27f0c8305..803617f95 100644
--- a/src/Text/Pandoc/Writers/FB2.hs
+++ b/src/Text/Pandoc/Writers/FB2.hs
@@ -44,8 +44,8 @@ import qualified Text.XML.Light.Cursor as XC
import Text.Pandoc.Definition
import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..), def)
-import Text.Pandoc.Shared (orderedListMarkers)
-import Text.Pandoc.Generic (bottomUp)
+import Text.Pandoc.Shared (orderedListMarkers, isHeaderBlock)
+import Text.Pandoc.Walk
-- | Data to be written at the end of the document:
-- (foot)notes, URLs, references, images.
@@ -157,9 +157,7 @@ renderSection level (ttl, body) = do
else cMapM blockToXml body
return $ el "section" (title ++ content)
where
- hasSubsections = any isHeader
- isHeader (Header _ _ _) = True
- isHeader _ = False
+ hasSubsections = any isHeaderBlock
-- | Only <p> and <empty-line> are allowed within <title> in FB2.
formatTitle :: [Inline] -> [Content]
@@ -324,6 +322,7 @@ blockToXml (CodeBlock _ s) = return . spaceBeforeAfter .
map (el "p" . el "code") . lines $ s
blockToXml (RawBlock _ s) = return . spaceBeforeAfter .
map (el "p" . el "code") . lines $ s
+blockToXml (Div _ bs) = cMapM blockToXml bs
blockToXml (BlockQuote bs) = liftM (list . el "cite") $ cMapM blockToXml bs
blockToXml (OrderedList a bss) = do
state <- get
@@ -422,15 +421,20 @@ indent = indentBlock
indentLines ins = let lns = split isLineBreak ins :: [[Inline]]
in intercalate [LineBreak] $ map ((Str spacer):) lns
+capitalize :: Inline -> Inline
+capitalize (Str xs) = Str $ map toUpper xs
+capitalize x = x
+
-- | Convert a Pandoc's Inline element to FictionBook XML representation.
toXml :: Inline -> FBM [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 $ bottomUp (map toUpper) ss
+toXml (SmallCaps ss) = cMapM toXml $ walk capitalize ss
toXml (Quoted SingleQuote ss) = do -- FIXME: should be language-specific
inner <- cMapM toXml ss
return $ [txt "‘"] ++ inner ++ [txt "’"]
@@ -560,6 +564,7 @@ list = (:[])
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)
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 57bf2a349..9a26cf2ac 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -1,7 +1,7 @@
{-# LANGUAGE OverloadedStrings, CPP #-}
{-# OPTIONS_GHC -fno-warn-deprecations #-}
{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.HTML
- Copyright : Copyright (C) 2006-2010 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -39,13 +39,14 @@ import Text.Pandoc.Readers.TeXMath
import Text.Pandoc.Slides
import Text.Pandoc.Highlighting ( highlight, styleToCss,
formatHtmlInline, formatHtmlBlock )
-import Text.Pandoc.XML (fromEntities)
+import Text.Pandoc.XML (fromEntities, escapeStringForXML)
+import Network.URI ( parseURIReference, URI(..) )
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 )
+import Data.Maybe ( catMaybes, fromMaybe )
import Control.Monad.State
import Text.Blaze.Html hiding(contents)
import Text.Blaze.Internal(preEscapedString)
@@ -115,9 +116,10 @@ pandocToHtml opts (Pandoc meta blocks) = do
(fmap renderHtml . blockListToHtml opts)
(fmap renderHtml . inlineListToHtml opts)
meta
- let authsMeta = map stringify $ docAuthors meta
- let dateMeta = stringify $ docDate meta
- let slideLevel = maybe (getSlideLevel blocks) id $ writerSlideLevel opts
+ let stringifyHTML = escapeStringForXML . stringify
+ let authsMeta = map stringifyHTML $ docAuthors meta
+ let dateMeta = stringifyHTML $ docDate meta
+ let slideLevel = fromMaybe (getSlideLevel blocks) $ writerSlideLevel opts
let sects = hierarchicalize $
if writerSlideVariant opts == NoSlides
then blocks
@@ -143,7 +145,11 @@ pandocToHtml opts (Pandoc meta blocks) = do
MathJax url ->
H.script ! A.src (toValue url)
! A.type_ "text/javascript"
- $ mempty
+ $ case writerSlideVariant opts of
+ SlideousSlides ->
+ preEscapedString
+ "MathJax.Hub.Queue([\"Typeset\",MathJax.Hub]);"
+ _ -> mempty
JsMath (Just url) ->
H.script ! A.src (toValue url)
! A.type_ "text/javascript"
@@ -167,7 +173,7 @@ pandocToHtml opts (Pandoc meta blocks) = do
maybe id (defField "toc" . renderHtml) toc $
defField "author-meta" authsMeta $
maybe id (defField "date-meta") (normalizeDate dateMeta) $
- defField "pagetitle" (stringify $ docTitle meta) $
+ defField "pagetitle" (stringifyHTML $ docTitle meta) $
defField "idprefix" (writerIdentifierPrefix opts) $
-- these should maybe be set in pandoc.hs
defField "slidy-url"
@@ -267,11 +273,23 @@ elementToHtml slideLevel opts (Sec level num (id',classes,keyvals) title' elemen
else blockToHtml opts (Header level' (id',classes,keyvals) title')
let isSec (Sec _ _ _ _ _) = True
isSec (Blk _) = False
+ let isPause (Blk x) = x == Para [Str ".",Space,Str ".",Space,Str "."]
+ isPause _ = False
+ let fragmentClass = case writerSlideVariant opts 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 elements
+ else if slide
+ then case splitBy isPause elements of
+ [] -> []
+ (x:xs) -> x ++ concatMap inDiv xs
+ else elements
let inNl x = mconcat $ nl opts : intersperse (nl opts) x ++ [nl opts]
let classes' = ["titleslide" | titleSlide] ++ ["slide" | slide] ++
["section" | (slide || writerSectionDivs opts) &&
@@ -379,7 +397,10 @@ imageExts = [ "art", "bmp", "cdr", "cdt", "cpt", "cr2", "crw", "djvu", "erf",
treatAsImage :: FilePath -> Bool
treatAsImage fp =
- let ext = map toLower $ drop 1 $ takeExtension 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.
@@ -400,15 +421,22 @@ blockToHtml opts (Para [Image txt (s,'f':'i':'g':':':tit)]) = do
[nl opts, img, capt, nl opts]
else H.div ! A.class_ "figure" $ mconcat
[nl opts, img, capt, nl opts]
--- . . . indicates a pause in a slideshow
-blockToHtml opts (Para [Str ".",Space,Str ".",Space,Str "."])
- | writerSlideVariant opts == RevealJsSlides =
- blockToHtml opts (RawBlock "html" "<div class=\"fragment\" />")
blockToHtml opts (Para lst) = do
contents <- inlineListToHtml opts lst
return $ H.p contents
-blockToHtml _ (RawBlock "html" str) = return $ preEscapedString str
-blockToHtml _ (RawBlock _ _) = return mempty
+blockToHtml opts (Div attr@(_,classes,_) bs) = do
+ contents <- blockListToHtml opts bs
+ let contents' = nl opts >> contents >> nl opts
+ return $
+ if "notes" `elem` classes
+ then case writerSlideVariant opts of
+ RevealJsSlides -> addAttrs opts attr $ H5.aside $ contents'
+ NoSlides -> addAttrs opts attr $ H.div $ contents'
+ _ -> mempty
+ else addAttrs opts attr $ H.div $ contents'
+blockToHtml _ (RawBlock f str)
+ | f == Format "html" = return $ preEscapedString str
+ | otherwise = return mempty
blockToHtml opts (HorizontalRule) = return $ if writerHtml5 opts then H5.hr else H.hr
blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do
let tolhs = isEnabled Ext_literate_haskell opts &&
@@ -422,7 +450,10 @@ blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do
adjCode = if tolhs
then unlines . map ("> " ++) . lines $ rawCode
else rawCode
- case highlight formatHtmlBlock (id',classes',keyvals) adjCode of
+ hlCode = if writerHighlight opts -- check highlighting options
+ 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 }) >>
@@ -448,28 +479,22 @@ blockToHtml opts (BlockQuote blocks) =
else do
contents <- blockListToHtml opts blocks
return $ H.blockquote $ nl opts >> contents >> nl opts
-blockToHtml opts (Header level (ident,_,_) lst) = do
+blockToHtml opts (Header level (_,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
- let revealSlash = ['/' | writerSlideVariant opts == RevealJsSlides]
- let contents'' = if writerTableOfContents opts && not (null ident)
- then H.a ! A.href (toValue $
- '#' : revealSlash ++
- writerIdentifierPrefix opts ++
- ident) $ contents'
- else contents'
return $ 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''
+ 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
return $ unordList opts contents
@@ -497,7 +522,7 @@ blockToHtml opts (DefinitionList lst) = do
contents <- mapM (\(term, defs) ->
do term' <- if null term
then return mempty
- else liftM (H.dt) $ inlineListToHtml opts term
+ 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 :
@@ -512,11 +537,16 @@ blockToHtml opts (Table capt aligns widths headers rows') = do
let percent w = show (truncate (100*w) :: Integer) ++ "%"
let coltags = if all (== 0.0) widths
then mempty
- else mconcat $ map (\w ->
- if writerHtml5 opts
- then H.col ! A.style (toValue $ "width: " ++ percent w)
- else H.col ! A.width (toValue $ percent w) >> nl opts)
- widths
+ else do
+ H.colgroup $ do
+ nl opts
+ mapM_ (\w -> do
+ if writerHtml5 opts
+ 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
@@ -572,8 +602,7 @@ toListItem opts item = nl opts >> H.li item
blockListToHtml :: WriterOptions -> [Block] -> State WriterState Html
blockListToHtml opts lst =
- mapM (blockToHtml opts) lst >>=
- return . mconcat . intersperse (nl opts)
+ fmap (mconcat . intersperse (nl opts)) $ mapM (blockToHtml opts) lst
-- | Convert list of Pandoc inline elements to HTML.
inlineListToHtml :: WriterOptions -> [Inline] -> State WriterState Html
@@ -587,16 +616,35 @@ inlineToHtml opts inline =
(Str str) -> return $ strToHtml str
(Space) -> return $ strToHtml " "
(LineBreak) -> return $ if writerHtml5 opts then H5.br else H.br
+ (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 highlight formatHtmlInline attr str of
+ (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
+ where (id',_,keyvals) = attr
+ hlCode = if writerHighlight opts
+ then highlight formatHtmlInline attr str
+ else Nothing
(Strikeout lst) -> inlineListToHtml opts lst >>=
return . H.del
(SmallCaps lst) -> inlineListToHtml opts lst >>=
@@ -654,25 +702,27 @@ inlineToHtml opts inline =
Right r -> return $ preEscapedString $
ppcElement conf r
Left _ -> inlineListToHtml opts
- (readTeXMath str) >>= return .
+ (readTeXMath' t str) >>= return .
(H.span ! A.class_ "math")
MathJax _ -> return $ H.span ! A.class_ "math" $ toHtml $
case t of
InlineMath -> "\\(" ++ str ++ "\\)"
DisplayMath -> "\\[" ++ str ++ "\\]"
PlainMath -> do
- x <- inlineListToHtml opts (readTeXMath str)
+ x <- inlineListToHtml opts (readTeXMath' t str)
let m = H.span ! A.class_ "math" $ x
let brtag = if writerHtml5 opts then H5.br else H.br
return $ case t of
InlineMath -> m
DisplayMath -> brtag >> m >> brtag )
- (RawInline "latex" str) -> case writerHTMLMathMethod opts of
+ (RawInline f str)
+ | f == Format "latex" ->
+ case writerHTMLMathMethod opts of
LaTeXMathML _ -> do modify (\st -> st {stMath = True})
return $ toHtml str
_ -> return mempty
- (RawInline "html" str) -> return $ preEscapedString str
- (RawInline _ _) -> return mempty
+ | f == Format "html" -> return $ preEscapedString str
+ | otherwise -> return mempty
(Link [Str str] (s,_)) | "mailto:" `isPrefixOf` s &&
s == escapeURI ("mailto" ++ str) ->
-- autolink
@@ -709,7 +759,9 @@ inlineToHtml opts inline =
else [A.title $ toValue tit])
return $ foldl (!) H5.embed attributes
-- note: null title included, as in Markdown.pl
- (Note contents) -> do
+ (Note contents)
+ | writerIgnoreNotes opts -> return mempty
+ | otherwise -> do
st <- get
let notes = stNotes st
let number = (length notes) + 1
@@ -724,11 +776,11 @@ inlineToHtml opts inline =
writerIdentifierPrefix opts ++ "fn" ++ ref)
! A.class_ "footnoteRef"
! prefixedId opts ("fnref" ++ ref)
+ $ H.sup
$ toHtml ref
- let link' = case writerEpubVersion opts of
- Just EPUB3 -> link ! customAttribute "epub:type" "noteref"
- _ -> link
- return $ H.sup $ link'
+ return $ case writerEpubVersion opts 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
diff --git a/src/Text/Pandoc/Writers/Haddock.hs b/src/Text/Pandoc/Writers/Haddock.hs
new file mode 100644
index 000000000..1c82839d0
--- /dev/null
+++ b/src/Text/Pandoc/Writers/Haddock.hs
@@ -0,0 +1,346 @@
+{-# 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.Readers.TeXMath (readTeXMath')
+import Network.URI (isURI)
+import Data.Default
+
+type Notes = [[Block]]
+data WriterState = WriterState { stNotes :: Notes }
+instance Default WriterState
+ where def = WriterState{ stNotes = [] }
+
+-- | Convert Pandoc to Haddock.
+writeHaddock :: WriterOptions -> Pandoc -> String
+writeHaddock opts document =
+ evalState (pandocToHaddock opts{
+ writerWrapText = writerWrapText opts } document) def
+
+-- | Return haddock representation of document.
+pandocToHaddock :: WriterOptions -> Pandoc -> State WriterState String
+pandocToHaddock opts (Pandoc meta blocks) = do
+ let colwidth = if writerWrapText opts
+ 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
+ if writerStandalone opts
+ then return $ renderTemplate' (writerTemplate opts) context
+ else return main
+
+-- | Return haddock representation of notes.
+notesToHaddock :: WriterOptions -> [[Block]] -> State WriterState 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 :: WriterOptions -- ^ Options
+ -> Block -- ^ Block element
+ -> State WriterState 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 alt (src,'f':'i':'g':':':tit)]) =
+ blockToHaddock opts (Para [Image 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 _ (RawBlock f str)
+ | f == "haddock" = do
+ return $ text str <> text "\n"
+ | otherwise = 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 :: WriterOptions -> Bool -> [Alignment] -> [Double]
+ -> [Doc] -> [[Doc]] -> State WriterState 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 :: WriterOptions -> Bool -> [Alignment] -> [Double]
+ -> [Doc] -> [[Doc]] -> State WriterState 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 :: WriterOptions -> [Block] -> State WriterState 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 :: WriterOptions -- ^ options
+ -> String -- ^ list item marker
+ -> [Block] -- ^ list item (list of blocks)
+ -> State WriterState 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 :: WriterOptions
+ -> ([Inline],[[Block]])
+ -> State WriterState 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 :: WriterOptions -- ^ Options
+ -> [Block] -- ^ List of block elements
+ -> State WriterState Doc
+blockListToHaddock opts blocks =
+ mapM (blockToHaddock opts) blocks >>= return . cat
+
+-- | Convert list of Pandoc inline elements to haddock.
+inlineListToHaddock :: WriterOptions -> [Inline] -> State WriterState Doc
+inlineListToHaddock opts lst =
+ mapM (inlineToHaddock opts) lst >>= return . cat
+
+-- | Convert Pandoc inline element to haddock.
+inlineToHaddock :: WriterOptions -> Inline -> State WriterState 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 `fmap` (inlineListToHaddock opts $ readTeXMath' mt str)
+inlineToHaddock _ (RawInline f str)
+ | f == "haddock" = return $ text str
+ | otherwise = return empty
+-- no line break in haddock (see above on CodeBlock)
+inlineToHaddock _ (LineBreak) = return cr
+inlineToHaddock _ Space = return space
+inlineToHaddock opts (Cite _ lst) = inlineListToHaddock opts lst
+inlineToHaddock opts (Link txt (src, _)) = do
+ linktext <- inlineListToHaddock opts 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 alternate (source, tit)) = do
+ linkhaddock <- inlineToHaddock opts (Link 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..19d486b25
--- /dev/null
+++ b/src/Text/Pandoc/Writers/ICML.hs
@@ -0,0 +1,525 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+{- |
+ Module : Text.Pandoc.Writers.ICML
+ Copyright : Copyright (C) 2013 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.XML
+import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Shared (splitBy)
+import Text.Pandoc.Options
+import Text.Pandoc.Templates (renderTemplate')
+import Text.Pandoc.Pretty
+import Data.List (isPrefixOf, isInfixOf, stripPrefix)
+import Data.Text as Text (breakOnAll, pack)
+import Data.Monoid (mappend)
+import Control.Monad.State
+import qualified Data.Set as Set
+
+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 a = State WriterState a
+
+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
+codeBlockName :: String
+rawBlockName :: 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
+paragraphName = "Paragraph"
+codeBlockName = "CodeBlock"
+rawBlockName = "Rawblock"
+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"
+
+
+-- | Convert Pandoc document to string in ICML format.
+writeICML :: WriterOptions -> Pandoc -> String
+writeICML opts (Pandoc meta blocks) =
+ let colwidth = if writerWrapText opts
+ then Just $ writerColumns opts
+ else Nothing
+ render' = render colwidth
+ renderMeta f s = Just $ render' $ fst $ runState (f opts [] s) defaultWriterState
+ Just metadata = metaToJSON opts
+ (renderMeta blocksToICML)
+ (renderMeta inlinesToICML)
+ meta
+ (doc, st) = runState (blocksToICML opts [] blocks) defaultWriterState
+ main = render' doc
+ context = defField "body" main
+ $ defField "charStyles" (render' $ charStylesToDoc st)
+ $ defField "parStyles" (render' $ parStylesToDoc st)
+ $ defField "hyperlinks" (render' $ hyperlinksToDoc $ links st)
+ $ metadata
+ in if writerStandalone opts
+ then renderTemplate' (writerTemplate opts) context
+ else main
+
+-- | 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
+
+-- | 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/"++url), ("Name","link"), ("DestinationURL",url), ("DestinationUniqueKey","1")]
+ 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/"++(escapeStringForXML url))
+
+
+-- | Convert a list of Pandoc blocks to ICML.
+blocksToICML :: WriterOptions -> Style -> [Block] -> WS Doc
+blocksToICML opts style lst = vcat `fmap` mapM (blockToICML opts style) lst
+
+-- | Convert a Pandoc block element to ICML.
+blockToICML :: WriterOptions -> Style -> Block -> WS Doc
+blockToICML opts style (Plain lst) = parStyle opts style lst
+blockToICML opts style (Para lst) = parStyle opts (paragraphName:style) lst
+blockToICML opts style (CodeBlock _ str) = parStyle opts (codeBlockName:style) $ [Str str]
+blockToICML opts style (RawBlock _ str) = parStyle opts (rawBlockName:style) $ [Str str]
+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) = vcat `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 rowNr (0::Int)) $ rowsToICML rest (rowNr+1)
+ colsToICML [] _ _ = return empty
+ colsToICML (cell:rest) rowNr colNr = do
+ let stl = if rowNr == 0 && not noHeader
+ then tableHeaderName:style'
+ else style'
+ alig = aligns !! colNr
+ 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 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 :: WriterOptions -> String -> Style -> Maybe ListAttributes -> [[Block]] -> WS 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 $ vcat docs
+
+-- | Convert a list of blocks to ICML list items.
+listItemToICML :: WriterOptions -> Style -> Bool-> Maybe ListAttributes -> [Block] -> WS 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 <- fmap vcat $ mapM insertTab $ tail item
+ return $ f $$ r
+ else blocksToICML opts stl' item
+
+definitionListItemToICML :: WriterOptions -> Style -> ([Inline],[[Block]]) -> WS Doc
+definitionListItemToICML opts style (term,defs) = do
+ term' <- parStyle opts (defListTermName:style) term
+ defs' <- vcat `fmap` mapM (blocksToICML opts (defListDefName:style)) defs
+ return $ term' $$ defs'
+
+
+-- | Convert a list of inline elements to ICML.
+inlinesToICML :: WriterOptions -> Style -> [Inline] -> WS Doc
+inlinesToICML opts style lst = vcat `fmap` mapM (inlineToICML opts style) (mergeSpaces lst)
+
+-- | Convert an inline element to ICML.
+inlineToICML :: WriterOptions -> Style -> Inline -> WS 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) = footnoteToICML opts style [Para lst]
+inlineToICML _ style (Code _ str) = charStyle (codeName:style) $ text $ escapeStringForXML str
+inlineToICML _ style Space = charStyle style space
+inlineToICML _ style LineBreak = charStyle style $ text lineSeparator
+inlineToICML _ style (Math _ str) = charStyle style $ text $ escapeStringForXML str --InDesign doesn't really do math
+inlineToICML _ style (RawInline _ str) = charStyle style $ text $ escapeStringForXML str
+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 alt target) = imageICML opts style alt 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 :: WriterOptions -> Style -> [Block] -> WS 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 $$ vcat contents
+
+-- | Auxiliary function to merge Space elements into the adjacent Strs.
+mergeSpaces :: [Inline] -> [Inline]
+mergeSpaces ((Str s):(Space:((Str s'):xs))) = mergeSpaces $ Str(s++" "++s') : xs
+mergeSpaces (Space:((Str s):xs)) = mergeSpaces $ Str (" "++s) : xs
+mergeSpaces ((Str s):(Space:xs)) = mergeSpaces $ Str (s++" ") : xs
+mergeSpaces (x:xs) = x : (mergeSpaces xs)
+mergeSpaces [] = []
+
+-- | Wrap a list of inline elements in an ICML Paragraph Style
+parStyle :: WriterOptions -> Style -> [Inline] -> WS 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'
+ $ mappend content $ selfClosingTag "Br" []
+ state $ \st -> (cont, st{ blockStyles = Set.insert stlStr $ blockStyles st })
+
+-- | Wrap a Doc in an ICML Character Style.
+charStyle :: Style -> Doc -> WS 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 :: WriterOptions -> Style -> [Inline] -> Target -> WS Doc
+imageICML _ style _ (linkURI, _) =
+ let imgWidth = 300::Int --TODO: set width, height dynamically as in Docx.hs
+ imgHeight = 200::Int
+ scaleFact = show (1::Double) --TODO: set scaling factor so image is scaled exactly to imgWidth x imgHeight
+ hw = show $ imgWidth `div` 2
+ hh = show $ imgHeight `div` 2
+ qw = show $ imgWidth `div` 4
+ qh = show $ imgHeight `div` 4
+ (stlStr, attrs) = styleToStrAttr style
+ props = inTags True "Properties" [] $ inTags True "PathGeometry" []
+ $ inTags True "GeometryPathType" [("PathOpen","false")]
+ $ inTags True "PathPointArray" []
+ $ vcat [
+ selfClosingTag "PathPointType" [("Anchor", "-"++qw++" -"++qh),
+ ("LeftDirection", "-"++qw++" -"++qh), ("RightDirection", "-"++qw++" -"++qh)]
+ , selfClosingTag "PathPointType" [("Anchor", "-"++qw++" "++qh),
+ ("LeftDirection", "-"++qw++" "++qh), ("RightDirection", "-"++qw++" "++qh)]
+ , selfClosingTag "PathPointType" [("Anchor", qw++" "++qh),
+ ("LeftDirection", qw++" "++qh), ("RightDirection", qw++" "++qh)]
+ , selfClosingTag "PathPointType" [("Anchor", qw++" -"++qh),
+ ("LeftDirection", qw++" -"++qh), ("RightDirection", qw++" -"++qh)]
+ ]
+ image = inTags True "Image"
+ [("Self","ue6"), ("ItemTransform", scaleFact++" 0 0 "++scaleFact++" -"++qw++" -"++qh)]
+ $ vcat [
+ inTags True "Properties" [] $ inTags True "Profile" [("type","string")] $ text "$ID/Embedded"
+ $$ selfClosingTag "GraphicBounds" [("Left","0"), ("Top","0"), ("Right", hw), ("Bottom", hh)]
+ , selfClosingTag "Link" [("Self", "ueb"), ("LinkResourceURI", linkURI)]
+ ]
+ doc = inTags True "CharacterStyleRange" attrs
+ $ inTags True "Rectangle" [("Self","uec"), ("ItemTransform", "1 0 0 1 "++qw++" -"++qh)]
+ $ (props $$ image)
+ in do
+ 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
index 2b4a608a7..100bf900d 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings, ScopedTypeVariables #-}
{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.LaTeX
- Copyright : Copyright (C) 2006-2010 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -30,20 +30,20 @@ Conversion of 'Pandoc' format into LaTeX.
-}
module Text.Pandoc.Writers.LaTeX ( writeLaTeX ) where
import Text.Pandoc.Definition
-import Text.Pandoc.Generic
+import Text.Pandoc.Walk
import Text.Pandoc.Shared
import Text.Pandoc.Writers.Shared
import Text.Pandoc.Options
import Text.Pandoc.Templates
import Text.Printf ( printf )
-import Network.URI ( isAbsoluteURI, unEscapeString )
+import Network.URI ( isURI, unEscapeString )
import Data.List ( (\\), isSuffixOf, isInfixOf,
isPrefixOf, intercalate, intersperse )
-import Data.Char ( toLower, isPunctuation )
+import Data.Char ( toLower, isPunctuation, isAscii, isLetter, isDigit, ord )
+import Data.Maybe ( fromMaybe )
import Control.Applicative ((<|>))
import Control.Monad.State
import Text.Pandoc.Pretty
-import System.FilePath (dropExtension)
import Text.Pandoc.Slides
import Text.Pandoc.Highlighting (highlight, styleToLaTeX,
formatLaTeXInline, formatLaTeXBlock,
@@ -51,6 +51,9 @@ import Text.Pandoc.Highlighting (highlight, styleToLaTeX,
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
+ , 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
@@ -71,7 +74,8 @@ data WriterState =
writeLaTeX :: WriterOptions -> Pandoc -> String
writeLaTeX options document =
evalState (pandocToLaTeX options document) $
- WriterState { stInNote = False,
+ WriterState { stInNote = False, stInQuote = False,
+ stInMinipage = False, stNotes = [],
stOLLevel = 1, stOptions = options,
stVerbInNote = False,
stTable = False, stStrikeout = False,
@@ -83,10 +87,17 @@ writeLaTeX options document =
pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState 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 = queryWith isInternalLink blocks }
+ modify $ \s -> s{ stInternalLinks = query isInternalLink blocks' }
let template = writerTemplate options
-- set stBook depending on documentclass
let bookClasses = ["memoir","book","report","scrreprt","scrbook"]
@@ -108,30 +119,31 @@ pandocToLaTeX options (Pandoc meta blocks) = do
(fmap (render colwidth) . blockListToLaTeX)
(fmap (render colwidth) . inlineListToLaTeX)
meta
- let (blocks', lastHeader) = if writerCiteMethod options == Citeproc then
- (blocks, [])
- else case last blocks of
- Header 1 _ il -> (init blocks, il)
- _ -> (blocks, [])
- blocks'' <- if writerBeamer options
- then toSlides blocks'
- else return blocks'
- body <- mapM (elementToLaTeX options) $ hierarchicalize blocks''
+ let (blocks'', lastHeader) = if writerCiteMethod options == Citeproc then
+ (blocks', [])
+ else case last blocks' of
+ Header 1 _ il -> (init blocks', il)
+ _ -> (blocks', [])
+ blocks''' <- if writerBeamer options
+ 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
- let biblioFiles = intercalate "," $ map dropExtension $ writerBiblioFiles options
+ titleMeta <- stringToLaTeX TextString $ stringify $ docTitle meta
+ authorsMeta <- mapM (stringToLaTeX TextString . stringify) $ docAuthors meta
let context = defField "toc" (writerTableOfContents options) $
defField "toc-depth" (show (writerTOCDepth options -
- if writerChapters options
+ if stBook st
then 1
else 0)) $
defField "body" main $
- defField "title-meta" (stringify $ docTitle meta) $
- defField "author-meta" (intercalate "; " $ map stringify $ docAuthors meta) $
+ defField "title-meta" titleMeta $
+ defField "author-meta" (intercalate "; " authorsMeta) $
defField "documentclass" (if writerBeamer options
then ("beamer" :: String)
- else if writerChapters options
+ else if stBook st
then "book"
else "article") $
defField "verbatim-in-note" (stVerbInNote st) $
@@ -152,11 +164,9 @@ pandocToLaTeX options (Pandoc meta blocks) = do
$ writerHighlightStyle options )
else id) $
(case writerCiteMethod options of
- Natbib -> defField "biblio-files" biblioFiles .
- defField "biblio-title" biblioTitle .
+ Natbib -> defField "biblio-title" biblioTitle .
defField "natbib" True
- Biblatex -> defField "biblio-files" biblioFiles .
- defField "biblio-title" biblioTitle .
+ Biblatex -> defField "biblio-title" biblioTitle .
defField "biblatex" True
_ -> id) $
metadata
@@ -183,7 +193,7 @@ stringToLaTeX _ [] = return ""
stringToLaTeX ctx (x:xs) = do
opts <- gets stOptions
rest <- stringToLaTeX ctx xs
- let ligatures = writerTeXLigatures opts && not (ctx == CodeString)
+ let ligatures = writerTeXLigatures opts && ctx == TextString
let isUrl = ctx == URLString
when (x == '€') $
modify $ \st -> st{ stUsesEuro = True }
@@ -197,17 +207,20 @@ stringToLaTeX ctx (x:xs) = do
'&' -> "\\&" ++ rest
'_' | not isUrl -> "\\_" ++ rest
'#' -> "\\#" ++ rest
- '-' -> case xs of -- prevent adjacent hyphens from forming ligatures
- ('-':_) -> "-{}" ++ rest
+ '-' | not isUrl -> case xs of
+ -- prevent adjacent hyphens from forming ligatures
+ ('-':_) -> "-\\/" ++ rest
_ -> '-' : rest
'~' | not isUrl -> "\\textasciitilde{}" ++ rest
'^' -> "\\^{}" ++ rest
- '\\' -> "\\textbackslash{}" ++ rest
+ '\\'| isUrl -> '/' : rest -- NB. / works as path sep even on Windows
+ | otherwise -> "\\textbackslash{}" ++ rest
'|' -> "\\textbar{}" ++ rest
'<' -> "\\textless{}" ++ rest
'>' -> "\\textgreater{}" ++ rest
'[' -> "{[}" ++ rest -- to avoid interpretation as
']' -> "{]}" ++ rest -- optional arguments
+ '\'' | ctx == CodeString -> "\\textquotesingle{}" ++ rest
'\160' -> "~" ++ rest
'\x2026' -> "\\ldots{}" ++ rest
'\x2018' | ligatures -> "`" ++ rest
@@ -218,6 +231,14 @@ stringToLaTeX ctx (x:xs) = do
'\x2013' | ligatures -> "--" ++ rest
_ -> x : rest
+toLabel :: String -> State WriterState String
+toLabel z = go `fmap` stringToLaTeX URLString z
+ where go [] = ""
+ go (x:xs)
+ | (isLetter x || isDigit x) && isAscii x = x:go xs
+ | elem x "-+=:;." = 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
@@ -225,13 +246,13 @@ inCmd cmd contents = char '\\' <> text cmd <> braces contents
toSlides :: [Block] -> State WriterState [Block]
toSlides bs = do
opts <- gets stOptions
- let slideLevel = maybe (getSlideLevel bs) id $ writerSlideLevel opts
+ let slideLevel = fromMaybe (getSlideLevel bs) $ writerSlideLevel opts
let bs' = prepSlides slideLevel bs
concat `fmap` (mapM (elementToBeamer slideLevel) $ hierarchicalize bs')
elementToBeamer :: Int -> Element -> State WriterState [Block]
elementToBeamer _slideLevel (Blk b) = return [b]
-elementToBeamer slideLevel (Sec lvl _num (ident,classes,_) tit elts)
+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}{"
@@ -239,7 +260,7 @@ elementToBeamer slideLevel (Sec lvl _num (ident,classes,_) tit elts)
: bs ++ [RawBlock "latex" "\\end{block}"]
| lvl < slideLevel = do
bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts
- return $ (Header lvl (ident,classes,[]) tit) : bs
+ return $ (Header lvl (ident,classes,kvs) tit) : bs
| otherwise = do -- lvl == slideLevel
-- note: [fragile] is required or verbatim breaks
let hasCodeBlock (CodeBlock _ _) = [True]
@@ -247,17 +268,20 @@ elementToBeamer slideLevel (Sec lvl _num (ident,classes,_) tit elts)
let hasCode (Code _ _) = [True]
hasCode _ = []
opts <- gets stOptions
- let fragile = if not $ null $ queryWith hasCodeBlock elts ++
+ let fragile = not $ null $ query hasCodeBlock elts ++
if writerListings opts
- then queryWith hasCode elts
+ then query hasCode elts
else []
- then "[fragile]"
- else ""
- let slideStart = Para $ RawInline "latex" ("\\begin{frame}" ++ fragile) :
+ let allowframebreaks = "allowframebreaks" `elem` classes
+ let optionslist = ["fragile" | fragile] ++
+ ["allowframebreaks" | allowframebreaks]
+ 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" "\\frametitle{") : tit ++
- [RawInline "latex" "}"]
+ 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
@@ -278,16 +302,24 @@ isLineBreakOrSpace _ = False
blockToLaTeX :: Block -- ^ Block to convert
-> State WriterState Doc
blockToLaTeX Null = return empty
+blockToLaTeX (Div (_,classes,_) bs) = do
+ beamer <- writerBeamer `fmap` gets stOptions
+ contents <- blockListToLaTeX bs
+ if beamer && "notes" `elem` classes -- speaker notes
+ then return $ "\\note" <> braces contents
+ else return contents
blockToLaTeX (Plain lst) =
inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
-- title beginning with fig: indicates that the image is a figure
blockToLaTeX (Para [Image txt (src,'f':'i':'g':':':tit)]) = do
- capt <- if null txt
- then return empty
- else (\c -> "\\caption" <> braces c) `fmap` inlineListToLaTeX txt
+ inNote <- gets stInNote
+ capt <- inlineListToLaTeX txt
img <- inlineToLaTeX (Image txt (src,tit))
- return $ "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$
- capt $$ "\\end{figure}"
+ return $ if inNote
+ -- can't have figures in notes
+ then "\\begin{center}" $$ img $+$ capt $$ "\\end{center}"
+ else "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$
+ ("\\caption" <> braces capt) $$ "\\end{figure}"
-- . . . indicates pause in beamer slides
blockToLaTeX (Para [Str ".",Space,Str ".",Space,Str "."]) = do
beamer <- writerBeamer `fmap` gets stOptions
@@ -306,53 +338,68 @@ blockToLaTeX (BlockQuote lst) = do
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 (_,classes,keyvalAttr) str) = do
+blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do
opts <- gets stOptions
+ ref <- toLabel identifier
+ let linkAnchor = if null identifier
+ then empty
+ else "\\hyperdef{}" <> 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=" ++ l ]
+ Nothing -> []) ++
+ [ "numbers=left" | "numberLines" `elem` classes
+ || "number" `elem` classes
+ || "number-lines" `elem` classes ] ++
+ [ (if key == "startFrom"
+ then "firstnumber"
+ else key) ++ "=" ++ 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 h)
case () of
_ | isEnabled Ext_literate_haskell opts && "haskell" `elem` classes &&
"literate" `elem` classes -> lhsCodeBlock
| writerListings opts -> listingsCodeBlock
| writerHighlight opts && not (null classes) -> highlightedCodeBlock
| otherwise -> rawCodeBlock
- where lhsCodeBlock = do
- modify $ \s -> s{ stLHS = True }
- return $ flush ("\\begin{code}" $$ text str $$ "\\end{code}") $$ cr
- rawCodeBlock = do
- st <- get
- env <- if stInNote st
- then modify (\s -> s{ stVerbInNote = True }) >>
- return "Verbatim"
- else return "verbatim"
- return $ flush (text ("\\begin{" ++ env ++ "}") $$ text str $$
- text ("\\end{" ++ env ++ "}")) <> cr
- listingsCodeBlock = do
- st <- get
- let params = if writerListings (stOptions st)
- then (case getListingsLanguage classes of
- Just l -> [ "language=" ++ l ]
- Nothing -> []) ++
- [ "numbers=left" | "numberLines" `elem` classes
- || "number" `elem` classes
- || "number-lines" `elem` classes ] ++
- [ (if key == "startFrom"
- then "firstnumber"
- else key) ++ "=" ++ attr |
- (key,attr) <- keyvalAttr ]
- else []
- printParams
- | null params = empty
- | otherwise = brackets $ hcat (intersperse ", " (map text params))
- return $ flush ("\\begin{lstlisting}" <> printParams $$ text str $$
- "\\end{lstlisting}") $$ cr
- highlightedCodeBlock =
- case highlight formatLaTeXBlock ("",classes,keyvalAttr) str of
- Nothing -> rawCodeBlock
- Just h -> modify (\st -> st{ stHighlighting = True }) >>
- return (flush $ text h)
-blockToLaTeX (RawBlock "latex" x) = return $ text x
-blockToLaTeX (RawBlock _ _) = return empty
+blockToLaTeX (RawBlock f x)
+ | f == Format "latex" || f == Format "tex"
+ = return $ text x
+ | otherwise = return empty
blockToLaTeX (BulletList []) = return empty -- otherwise latex error
blockToLaTeX (BulletList lst) = do
incremental <- gets stIncremental
@@ -407,7 +454,7 @@ blockToLaTeX (DefinitionList lst) = do
incremental <- gets stIncremental
let inc = if incremental then "[<+->]" else ""
items <- mapM defListItemToLaTeX lst
- let spacing = if and $ map isTightList (map snd lst)
+ let spacing = if all isTightList (map snd lst)
then text "\\itemsep1pt\\parskip0pt\\parsep0pt"
else empty
return $ text ("\\begin{description}" ++ inc) $$ spacing $$ vcat items $$
@@ -419,12 +466,12 @@ blockToLaTeX (Header level (id',classes,_) lst) =
blockToLaTeX (Table caption aligns widths heads rows) = do
headers <- if all null heads
then return empty
- else ($$ "\\hline\\noalign{\\medskip}") `fmap`
+ else ($$ "\\midrule\\endhead") `fmap`
(tableRowToLaTeX True aligns widths) heads
captionText <- inlineListToLaTeX caption
let capt = if isEmpty captionText
then empty
- else text "\\noalign{\\medskip}"
+ else text "\\addlinespace"
$$ text "\\caption" <> braces captionText
rows' <- mapM (tableRowToLaTeX False aligns widths) rows
let colDescriptors = text $ concat $ map toColDescriptor aligns
@@ -432,10 +479,10 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
return $ "\\begin{longtable}[c]" <>
braces ("@{}" <> colDescriptors <> "@{}")
-- the @{} removes extra space at beginning and end
- $$ "\\hline\\noalign{\\medskip}"
+ $$ "\\toprule\\addlinespace"
$$ headers
$$ vcat rows'
- $$ "\\hline"
+ $$ "\\bottomrule"
$$ capt
$$ "\\end{longtable}"
@@ -456,19 +503,61 @@ tableRowToLaTeX :: Bool
-> [[Block]]
-> State WriterState Doc
tableRowToLaTeX header aligns widths cols = do
- renderedCells <- mapM blockListToLaTeX cols
+ -- 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 widths' = map (scaleFactor *) widths
+ cells <- mapM (tableCellToLaTeX header) $ zip3 widths' aligns cols
+ return $ hsep (intersperse "&" cells) $$ "\\\\\\addlinespace"
+
+-- 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" "}"]
+
+tableCellToLaTeX :: Bool -> (Double, Alignment, [Block])
+ -> State WriterState Doc
+tableCellToLaTeX _ (0, _, blocks) =
+ blockListToLaTeX $ walk fixLineBreaks 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 x = case x of
- AlignLeft -> "\\raggedright"
- AlignRight -> "\\raggedleft"
- AlignCenter -> "\\centering"
- AlignDefault -> "\\raggedright"
- let toCell 0 _ c = c
- toCell w a c = "\\begin{minipage}" <> valign <>
- braces (text (printf "%.2f\\columnwidth" w)) <>
- (halign a <> cr <> c <> cr) <> "\\end{minipage}"
- let cells = zipWith3 toCell widths aligns renderedCells
- return $ hsep (intersperse "&" cells) $$ "\\\\\\noalign{\\medskip}"
+ let halign = case align of
+ AlignLeft -> "\\raggedright"
+ AlignRight -> "\\raggedleft"
+ AlignCenter -> "\\centering"
+ AlignDefault -> "\\raggedright"
+ return $ ("\\begin{minipage}" <> valign <>
+ braces (text (printf "%.2f\\columnwidth" width)) <>
+ (halign <> cr <> cellContents <> cr) <> "\\end{minipage}")
+ $$ case notes of
+ [] -> empty
+ 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 :: [Block] -> State WriterState Doc
listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .
@@ -477,8 +566,15 @@ listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .
defListItemToLaTeX :: ([Inline], [[Block]]) -> State WriterState 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 $ "\\item" <> brackets term' $$ def'
+ return $ "\\item" <> brackets term'' $$ def'
-- | Craft the section header, inserting the secton reference, if supplied.
sectionHeader :: Bool -- True for unnumbered
@@ -488,17 +584,19 @@ sectionHeader :: Bool -- True for unnumbered
-> State WriterState Doc
sectionHeader unnumbered ref level lst = do
txt <- inlineListToLaTeX lst
+ lab <- text `fmap` toLabel ref
let noNote (Note _) = Str ""
noNote x = x
- let lstNoNotes = bottomUp noNote lst
+ let lstNoNotes = walk noNote lst
+ txtNoNotes <- inlineListToLaTeX lstNoNotes
let star = if unnumbered then text "*" else empty
- -- footnotes in sections don't work unless you specify an optional
- -- argument: \section[mysec]{mysec\footnote{blah}}
- optional <- if lstNoNotes == lst
+ -- 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
then return empty
else do
- res <- inlineListToLaTeX lstNoNotes
- return $ char '[' <> res <> char ']'
+ return $ brackets txtNoNotes
let stuffing = star <> optional <> braces txt
book <- gets stBook
opts <- gets stOptions
@@ -507,13 +605,13 @@ sectionHeader unnumbered ref level lst = do
let refLabel x = (if ref `elem` internalLinks
then text "\\hyperdef"
<> braces empty
- <> braces (text ref)
+ <> braces lab
<> braces x
else x)
- let headerWith x y r = refLabel $ text x <> y <>
- if null r
+ let headerWith x y = refLabel $ text x <> y <>
+ if null ref
then empty
- else text "\\label" <> braces (text r)
+ else text "\\label" <> braces lab
let sectionType = case level' of
0 | writerBeamer opts -> "part"
| otherwise -> "chapter"
@@ -523,13 +621,20 @@ sectionHeader unnumbered ref level lst = do
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
return $ if level' > 5
then txt
- else headerWith ('\\':sectionType) stuffing ref
+ else prefix $$
+ headerWith ('\\':sectionType) stuffing
$$ if unnumbered
then "\\addcontentsline{toc}" <>
braces (text sectionType) <>
- braces txt
+ braces txtNoNotes
else empty
-- | Convert list of inline elements to LaTeX.
@@ -556,12 +661,29 @@ isQuoted _ = False
-- | Convert inline element to LaTeX
inlineToLaTeX :: Inline -- ^ Inline to convert
-> State WriterState Doc
+inlineToLaTeX (Span (id',classes,_) ils) = do
+ let noEmph = "csl-no-emph" `elem` classes
+ let noStrong = "csl-no-strong" `elem` classes
+ let noSmallCaps = "csl-no-smallcaps" `elem` classes
+ label' <- if null id'
+ then return empty
+ else toLabel id' >>= \x ->
+ return (text "\\label" <> braces (text x))
+ fmap (label' <>)
+ ((if noEmph then inCmd "textup" else id) .
+ (if noStrong then inCmd "textnormal" else id) .
+ (if noSmallCaps then inCmd "textnormal" else id) .
+ (if not (noEmph || noStrong || noSmallCaps)
+ then braces
+ else id)) `fmap` inlineListToLaTeX ils
inlineToLaTeX (Emph lst) =
inlineListToLaTeX lst >>= return . inCmd "emph"
inlineToLaTeX (Strong lst) =
inlineListToLaTeX lst >>= return . inCmd "textbf"
inlineToLaTeX (Strikeout lst) = do
- contents <- inlineListToLaTeX lst
+ -- 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) =
@@ -624,15 +746,16 @@ inlineToLaTeX (Math InlineMath str) =
return $ char '$' <> text str <> char '$'
inlineToLaTeX (Math DisplayMath str) =
return $ "\\[" <> text str <> "\\]"
-inlineToLaTeX (RawInline "latex" str) = return $ text str
-inlineToLaTeX (RawInline "tex" str) = return $ text str
-inlineToLaTeX (RawInline _ _) = return empty
+inlineToLaTeX (RawInline f str)
+ | f == Format "latex" || f == Format "tex"
+ = return $ text str
+ | otherwise = return empty
inlineToLaTeX (LineBreak) = return "\\\\"
inlineToLaTeX Space = return space
inlineToLaTeX (Link txt ('#':ident, _)) = do
contents <- inlineListToLaTeX txt
- ident' <- stringToLaTeX URLString ident
- return $ text "\\hyperref" <> brackets (text ident') <> braces contents
+ lab <- toLabel ident
+ return $ text "\\hyperref" <> brackets (text lab) <> braces contents
inlineToLaTeX (Link txt (src, _)) =
case txt of
[Str x] | x == src -> -- autolink
@@ -645,19 +768,33 @@ inlineToLaTeX (Link txt (src, _)) =
contents <> char '}'
inlineToLaTeX (Image _ (source, _)) = do
modify $ \s -> s{ stGraphics = True }
- let source' = if isAbsoluteURI source
+ let source' = if isURI source
then source
else unEscapeString source
- return $ "\\includegraphics" <> braces (text source')
+ source'' <- stringToLaTeX URLString source'
+ return $ "\\includegraphics" <> 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
- return $ "\\footnote" <> braces (nest 2 contents' <> optnl)
- -- note: a \n before } needed when note ends with a Verbatim environment
+ let noteContents = nest 2 contents' <> optnl
+ 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" <> 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 :: [Citation] -> State WriterState Doc
citationsToNatbib (one:[])
@@ -678,9 +815,9 @@ citationsToNatbib cits
| noPrefix (tail cits) && noSuffix (init cits) && ismode NormalCitation cits
= citeCommand "citep" p s ks
where
- noPrefix = and . map (null . citationPrefix)
- noSuffix = and . map (null . citationSuffix)
- ismode m = and . map (((==) m) . citationMode)
+ 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
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs
index 0508b6c27..41eb3e5be 100644
--- a/src/Text/Pandoc/Writers/Man.hs
+++ b/src/Text/Pandoc/Writers/Man.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2007-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2007-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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.Man
- Copyright : Copyright (C) 2007-2010 John MacFarlane
+ Copyright : Copyright (C) 2007-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -160,14 +160,16 @@ blockToMan :: WriterOptions -- ^ Options
-> Block -- ^ Block element
-> State WriterState 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 _ (RawBlock "man" str) = return $ text str
-blockToMan _ (RawBlock _ _) = return empty
+blockToMan _ (RawBlock f str)
+ | f == Format "man" = return $ text str
+ | otherwise = return empty
blockToMan _ HorizontalRule = return $ text ".PP" $$ text " * * * * *"
blockToMan opts (Header level _ inlines) = do
contents <- inlineListToMan opts inlines
@@ -281,7 +283,7 @@ definitionListItemToMan opts (label, defs) = do
mapM (\item -> blockToMan opts item) rest
first' <- blockToMan opts first
return $ first' $$ text ".RS" $$ rest' $$ text ".RE"
- return $ text ".TP" $$ text ".B " <> labelText $$ contents
+ return $ text ".TP" $$ nowrap (text ".B " <> labelText) $$ contents
-- | Convert list of Pandoc block elements to man.
blockListToMan :: WriterOptions -- ^ Options
@@ -300,6 +302,7 @@ inlineListToMan opts lst = mapM (inlineToMan opts) lst >>= (return . hcat)
-- | Convert Pandoc inline element to man.
inlineToMan :: WriterOptions -> Inline -> State WriterState Doc
+inlineToMan opts (Span _ ils) = inlineListToMan opts ils
inlineToMan opts (Emph lst) = do
contents <- inlineListToMan opts lst
return $ text "\\f[I]" <> contents <> text "\\f[]"
@@ -327,12 +330,14 @@ inlineToMan opts (Cite _ lst) =
inlineToMan _ (Code _ str) =
return $ text $ "\\f[C]" ++ escapeCode str ++ "\\f[]"
inlineToMan _ (Str str) = return $ text $ escapeString str
-inlineToMan opts (Math InlineMath str) = inlineListToMan opts $ readTeXMath str
+inlineToMan opts (Math InlineMath str) =
+ inlineListToMan opts $ readTeXMath' InlineMath str
inlineToMan opts (Math DisplayMath str) = do
- contents <- inlineListToMan opts $ readTeXMath str
+ contents <- inlineListToMan opts $ readTeXMath' DisplayMath str
return $ cr <> text ".RS" $$ contents $$ text ".RE"
-inlineToMan _ (RawInline "man" str) = return $ text str
-inlineToMan _ (RawInline _ _) = return empty
+inlineToMan _ (RawInline f str)
+ | f == Format "man" = return $ text str
+ | otherwise = return empty
inlineToMan _ (LineBreak) = return $
cr <> text ".PD 0" $$ text ".P" $$ text ".PD" <> cr
inlineToMan _ Space = return space
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 80402a757..a67271a5d 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings, TupleSections, ScopedTypeVariables #-}
{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.Markdown
- Copyright : Copyright (C) 2006-2010 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -32,22 +32,22 @@ Markdown: <http://daringfireball.net/projects/markdown/>
-}
module Text.Pandoc.Writers.Markdown (writeMarkdown, writePlain) where
import Text.Pandoc.Definition
-import Text.Pandoc.Generic
+import Text.Pandoc.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, char, space)
import Data.List ( group, isPrefixOf, find, intersperse, transpose, sortBy )
-import Data.Char ( isSpace )
+import Data.Char ( isSpace, isPunctuation )
import Data.Ord ( comparing )
import Text.Pandoc.Pretty
import Control.Monad.State
import qualified Data.Set as Set
import Text.Pandoc.Writers.HTML (writeHtmlString)
-import Text.Pandoc.Readers.TeXMath (readTeXMath)
+import Text.Pandoc.Readers.TeXMath (readTeXMath')
import Text.HTML.TagSoup (renderTags, parseTags, isTagText, Tag(..))
-import Network.URI (isAbsoluteURI)
+import Network.URI (isURI)
import Data.Default
import Data.Yaml (Value(Object,String,Array,Bool,Number))
import qualified Data.HashMap.Strict as H
@@ -82,7 +82,7 @@ writePlain opts document =
where document' = plainify document
plainify :: Pandoc -> Pandoc
-plainify = bottomUp go
+plainify = walk go
where go :: Inline -> Inline
go (Emph xs) = SmallCaps xs
go (Strong xs) = SmallCaps xs
@@ -143,7 +143,7 @@ jsonToYaml (Object hashmap) =
| otherwise -> (k' <> ":") $$ x
(k', Object _, x) -> (k' <> ":") $$ nest 2 x
(_, String "", _) -> empty
- (k', _, x) -> k' <> ":" <> space <> x)
+ (k', _, x) -> k' <> ":" <> space <> hang 2 "" x)
$ sortBy (comparing fst) $ H.toList hashmap
jsonToYaml (Array vec) =
vcat $ map (\v -> hang 2 "- " (jsonToYaml v)) $ V.toList vec
@@ -151,7 +151,7 @@ jsonToYaml (String "") = empty
jsonToYaml (String s) =
case T.unpack s of
x | '\n' `elem` x -> hang 2 ("|" <> cr) $ text x
- | not (any (`elem` x) "\"'#:[]{}?-") -> text x
+ | not (any isPunctuation x) -> text x
| otherwise -> text $ "'" ++ substitute "'" "''" x ++ "'"
jsonToYaml (Bool b) = text $ show b
jsonToYaml (Number n) = text $ show n
@@ -186,7 +186,13 @@ pandocToMarkdown opts (Pandoc meta blocks) = do
let toc = if writerTableOfContents opts
then tableOfContents opts headerBlocks
else empty
- body <- blockListToMarkdown opts blocks
+ -- Strip off final 'references' header if markdown citations enabled
+ let blocks' = if not isPlain && isEnabled Ext_citations opts
+ then case reverse blocks of
+ (Div (_,["references"],_) _):xs -> reverse xs
+ _ -> blocks
+ else blocks
+ body <- blockListToMarkdown opts blocks'
st <- get
notes' <- notesToMarkdown opts (reverse $ stNotes st)
st' <- get -- note that the notes may contain refs
@@ -301,22 +307,34 @@ blockToMarkdown :: WriterOptions -- ^ Options
-> Block -- ^ Block element
-> State WriterState Doc
blockToMarkdown _ Null = return empty
+blockToMarkdown opts (Div attrs ils) = do
+ isPlain <- gets stPlain
+ contents <- blockListToMarkdown opts ils
+ return $ if isPlain || not (isEnabled Ext_markdown_in_html_blocks opts)
+ then contents <> blankline
+ else tagWithAttrs "div" attrs <> blankline <>
+ contents <> blankline <> "</div>" <> blankline
blockToMarkdown opts (Plain inlines) = do
contents <- inlineListToMarkdown opts inlines
- return $ contents <> cr
+ -- escape if para starts with ordered list marker
+ st <- get
+ let colwidth = if writerWrapText opts
+ then Just $ writerColumns opts
+ else Nothing
+ let rendered = render colwidth contents
+ let escapeDelimiter (x:xs) | x `elem` ".()" = '\\':x:xs
+ | otherwise = x : escapeDelimiter xs
+ escapeDelimiter [] = []
+ let contents' = if isEnabled Ext_all_symbols_escapable opts &&
+ not (stPlain st) && beginsWithOrderedListMarker rendered
+ then text $ escapeDelimiter rendered
+ else contents
+ return $ contents' <> cr
-- title beginning with fig: indicates figure
blockToMarkdown opts (Para [Image alt (src,'f':'i':'g':':':tit)]) =
blockToMarkdown opts (Para [Image alt (src,tit)])
-blockToMarkdown opts (Para inlines) = do
- contents <- inlineListToMarkdown opts inlines
- -- escape if para starts with ordered list marker
- st <- get
- let esc = if isEnabled Ext_all_symbols_escapable opts &&
- not (stPlain st) &&
- beginsWithOrderedListMarker (render Nothing contents)
- then text "\x200B" -- zero-width space, a hack
- else empty
- return $ esc <> contents <> blankline
+blockToMarkdown opts (Para inlines) =
+ (<> blankline) `fmap` blockToMarkdown opts (Plain inlines)
blockToMarkdown opts (RawBlock f str)
| f == "html" = do
st <- get
@@ -325,7 +343,7 @@ blockToMarkdown opts (RawBlock f str)
else return $ if isEnabled Ext_markdown_attribute opts
then text (addMarkdownAttribute str) <> text "\n"
else text str <> text "\n"
- | f == "latex" || f == "tex" || f == "markdown" = do
+ | f `elem` ["latex", "tex", "markdown"] = do
st <- get
if stPlain st
then return empty
@@ -368,23 +386,27 @@ blockToMarkdown opts (CodeBlock (_,classes,_) str)
isEnabled Ext_literate_haskell opts =
return $ prefixed "> " (text str) <> blankline
blockToMarkdown opts (CodeBlock attribs str) = return $
- case attribs of
- x | x /= nullAttr && isEnabled Ext_fenced_code_blocks opts ->
- tildes <> " " <> attrs <> cr <> text str <>
- cr <> tildes <> blankline
- (_,(cls:_),_) | isEnabled Ext_backtick_code_blocks opts ->
- backticks <> " " <> text cls <> cr <> text str <>
- cr <> backticks <> blankline
+ 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 "```"
+ 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 empty
+ then nowrap $ " " <> attrsToMarkdown attribs
+ else case attribs of
+ (_,[cls],_) -> " " <> text cls
+ _ -> empty
blockToMarkdown opts (BlockQuote blocks) = do
st <- get
-- if we're writing literate haskell, put a space before the bird tracks
@@ -456,16 +478,24 @@ addMarkdownAttribute s =
pipeTable :: Bool -> [Alignment] -> [Doc] -> [[Doc]] -> State WriterState 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 "|") $ map chomp cs) <> text "|"
- let toborder (a, h) = let wid = max (offset h) 3
- in text $ case a of
- AlignLeft -> ':':replicate (wid - 1) '-'
- AlignCenter -> ':':replicate (wid - 2) '-' ++ ":"
- AlignRight -> replicate (wid - 1) '-' ++ ":"
- AlignDefault -> replicate wid '-'
+ 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) '-'
let header = if headless then empty else torow rawHeaders
- let border = torow $ map toborder $ zip aligns rawHeaders
+ let border = nowrap $ text "|" <> hcat (intersperse (text "|") $
+ map toborder $ zip aligns widths) <> text "|"
let body = vcat $ map torow rawRows
return $ header $$ border $$ body
@@ -542,7 +572,14 @@ bulletListItemToMarkdown opts items = do
contents <- blockListToMarkdown opts items
let sps = replicate (writerTabStop opts - 2) ' '
let start = text ('-' : ' ' : sps)
- return $ hang (writerTabStop opts) start $ contents <> cr
+ -- 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 markdown.
orderedListItemToMarkdown :: WriterOptions -- ^ options
@@ -608,10 +645,11 @@ getReference label (src, tit) = do
Nothing -> do
let label' = case find ((== label) . fst) (stRefs st) of
Just _ -> -- label is used; generate numerical label
- case find (\n -> not (any (== [Str (show n)])
- (map fst (stRefs st)))) [1..(10000 :: Integer)] of
- Just x -> [Str (show x)]
- Nothing -> error "no unique label"
+ case find (\n -> notElem [Str (show n)]
+ (map fst (stRefs st)))
+ [1..(10000 :: Integer)] of
+ Just x -> [Str (show x)]
+ Nothing -> error "no unique label"
Nothing -> label
modify (\s -> s{ stRefs = (label', (src,tit)) : stRefs st })
return label'
@@ -628,6 +666,12 @@ escapeSpaces x = x
-- | Convert Pandoc inline element to markdown.
inlineToMarkdown :: WriterOptions -> Inline -> State WriterState Doc
+inlineToMarkdown opts (Span attrs ils) = do
+ st <- get
+ contents <- inlineListToMarkdown opts ils
+ return $ if stPlain st
+ then contents
+ else tagWithAttrs "span" attrs <> contents <> text "</span>"
inlineToMarkdown opts (Emph lst) = do
contents <- inlineListToMarkdown opts lst
return $ "*" <> contents <> "*"
@@ -640,13 +684,13 @@ inlineToMarkdown opts (Strikeout lst) = do
then "~~" <> contents <> "~~"
else "<s>" <> contents <> "</s>"
inlineToMarkdown opts (Superscript lst) = do
- let lst' = bottomUp escapeSpaces lst
+ let lst' = walk escapeSpaces lst
contents <- inlineListToMarkdown opts lst'
return $ if isEnabled Ext_superscript opts
then "^" <> contents <> "^"
else "<sup>" <> contents <> "</sup>"
inlineToMarkdown opts (Subscript lst) = do
- let lst' = bottomUp escapeSpaces lst
+ let lst' = walk escapeSpaces lst
contents <- inlineListToMarkdown opts lst'
return $ if isEnabled Ext_subscript opts
then "~" <> contents <> "~"
@@ -681,7 +725,7 @@ inlineToMarkdown opts (Math InlineMath str)
return $ "\\(" <> text str <> "\\)"
| isEnabled Ext_tex_math_double_backslash opts =
return $ "\\\\(" <> text str <> "\\\\)"
- | otherwise = inlineListToMarkdown opts $ readTeXMath str
+ | otherwise = inlineListToMarkdown opts $ readTeXMath' InlineMath str
inlineToMarkdown opts (Math DisplayMath str)
| isEnabled Ext_tex_math_dollars opts =
return $ "$$" <> text str <> "$$"
@@ -690,7 +734,7 @@ inlineToMarkdown opts (Math DisplayMath str)
| isEnabled Ext_tex_math_double_backslash opts =
return $ "\\\\[" <> text str <> "\\\\]"
| otherwise = (\x -> cr <> x <> cr) `fmap`
- inlineListToMarkdown opts (readTeXMath str)
+ inlineListToMarkdown opts (readTeXMath' DisplayMath str)
inlineToMarkdown opts (RawInline f str)
| f == "html" || f == "markdown" ||
(isEnabled Ext_raw_tex opts && (f == "latex" || f == "tex")) =
@@ -701,17 +745,20 @@ inlineToMarkdown opts (LineBreak)
| isEnabled Ext_escaped_line_breaks opts = return $ "\\" <> cr
| otherwise = return $ " " <> cr
inlineToMarkdown _ Space = return space
-inlineToMarkdown opts (Cite (c:cs) lst@[RawInline "latex" _])
+inlineToMarkdown opts (Cite [] lst) = inlineListToMarkdown opts lst
+inlineToMarkdown opts (Cite (c:cs) lst)
| not (isEnabled Ext_citations opts) = inlineListToMarkdown opts lst
- | citationMode c == AuthorInText = do
- suffs <- inlineListToMarkdown opts $ citationSuffix c
- rest <- mapM convertOne cs
- let inbr = suffs <+> joincits rest
- br = if isEmpty inbr then empty else char '[' <> inbr <> char ']'
- return $ text ("@" ++ citationId c) <+> br
- | otherwise = do
- cits <- mapM convertOne (c:cs)
- return $ text "[" <> joincits cits <> text "]"
+ | 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
@@ -728,14 +775,13 @@ inlineToMarkdown opts (Cite (c:cs) lst@[RawInline "latex" _])
return $ pdoc <+> r
modekey SuppressAuthor = "-"
modekey _ = ""
-inlineToMarkdown opts (Cite _ lst) = inlineListToMarkdown opts lst
inlineToMarkdown opts (Link txt (src, tit)) = do
linktext <- inlineListToMarkdown opts txt
let linktitle = if null tit
then empty
else text $ " \"" ++ tit ++ "\""
let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src
- let useAuto = isAbsoluteURI src &&
+ let useAuto = isURI src &&
case txt of
[Str s] | escapeURI s == srcSuffix -> True
_ -> False
diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs
index b3b319c2a..3b987ba2b 100644
--- a/src/Text/Pandoc/Writers/MediaWiki.hs
+++ b/src/Text/Pandoc/Writers/MediaWiki.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2008-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2008-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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.MediaWiki
- Copyright : Copyright (C) 2008-2010 John MacFarlane
+ Copyright : Copyright (C) 2008-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -34,9 +34,10 @@ 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.Templates (renderTemplate')
import Text.Pandoc.XML ( escapeStringForXML )
-import Data.List ( intersect, intercalate )
+import Data.List ( intersect, intercalate, intersperse )
import Network.URI ( isURI )
import Control.Monad.State
@@ -50,7 +51,7 @@ data WriterState = WriterState {
writeMediaWiki :: WriterOptions -> Pandoc -> String
writeMediaWiki opts document =
evalState (pandocToMediaWiki opts document)
- (WriterState { stNotes = False, stListLevel = [], stUseTags = False })
+ WriterState { stNotes = False, stListLevel = [], stUseTags = False }
-- | Return MediaWiki representation of document.
pandocToMediaWiki :: WriterOptions -> Pandoc -> State WriterState String
@@ -83,6 +84,11 @@ blockToMediaWiki :: WriterOptions -- ^ Options
blockToMediaWiki _ Null = return ""
+blockToMediaWiki opts (Div attrs bs) = do
+ contents <- blockListToMediaWiki opts bs
+ return $ render Nothing (tagWithAttrs "div" attrs) ++ "\n\n" ++
+ contents ++ "\n\n" ++ "</div>"
+
blockToMediaWiki opts (Plain inlines) =
inlineListToMediaWiki opts inlines
@@ -104,9 +110,10 @@ blockToMediaWiki opts (Para inlines) = do
then "<p>" ++ contents ++ "</p>"
else contents ++ if null listLevel then "\n" else ""
-blockToMediaWiki _ (RawBlock "mediawiki" str) = return str
-blockToMediaWiki _ (RawBlock "html" str) = return str
-blockToMediaWiki _ (RawBlock _ _) = return ""
+blockToMediaWiki _ (RawBlock f str)
+ | f == Format "mediawiki" = return str
+ | f == Format "html" = return str
+ | otherwise = return ""
blockToMediaWiki _ HorizontalRule = return "\n-----\n"
@@ -135,25 +142,17 @@ blockToMediaWiki opts (BlockQuote blocks) = do
return $ "<blockquote>" ++ contents ++ "</blockquote>"
blockToMediaWiki opts (Table capt aligns widths headers rows') = do
- let alignStrings = map alignmentToString aligns
- captionDoc <- if null capt
- then return ""
- else do
- c <- inlineListToMediaWiki 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 <- tableRowToMediaWiki opts alignStrings 0 headers
- return $ "<thead>\n" ++ hs ++ "\n</thead>\n"
- body' <- zipWithM (tableRowToMediaWiki opts alignStrings) [1..] rows'
- return $ "<table>\n" ++ captionDoc ++ coltags ++ head' ++
- "<tbody>\n" ++ unlines body' ++ "</tbody>\n</table>\n"
+ caption <- if null capt
+ then return ""
+ else do
+ c <- inlineListToMediaWiki opts capt
+ return $ "|+ " ++ trimr c ++ "\n"
+ let headless = all null headers
+ let allrows = if headless then rows' else headers:rows'
+ tableBody <- (concat . intersperse "|-\n") `fmap`
+ mapM (tableRowToMediaWiki opts headless aligns widths)
+ (zip [1..] allrows)
+ return $ "{|\n" ++ caption ++ tableBody ++ "|}\n"
blockToMediaWiki opts x@(BulletList items) = do
oldUseTags <- get >>= return . stUseTags
@@ -285,20 +284,34 @@ vcat = intercalate "\n"
-- Auxiliary functions for tables:
tableRowToMediaWiki :: WriterOptions
- -> [String]
- -> Int
- -> [[Block]]
+ -> Bool
+ -> [Alignment]
+ -> [Double]
+ -> (Int, [[Block]])
-> State WriterState String
-tableRowToMediaWiki 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 -> tableItemToMediaWiki opts celltype alignment item)
- alignStrings cols'
- return $ "<tr class=\"" ++ rowclass ++ "\">\n" ++ unlines cols'' ++ "</tr>"
+tableRowToMediaWiki opts headless alignments widths (rownum, cells) = do
+ cells' <- mapM (\cellData ->
+ tableCellToMediaWiki opts headless rownum cellData)
+ $ zip3 alignments widths cells
+ return $ unlines cells'
+
+tableCellToMediaWiki :: WriterOptions
+ -> Bool
+ -> Int
+ -> (Alignment, Double, [Block])
+ -> State WriterState String
+tableCellToMediaWiki opts headless rownum (alignment, width, bs) = do
+ contents <- blockListToMediaWiki opts 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 ++ "|"
+ return $ marker ++ attr ++ trimr contents
alignmentToString :: Alignment -> [Char]
alignmentToString alignment = case alignment of
@@ -307,17 +320,6 @@ alignmentToString alignment = case alignment of
AlignCenter -> "center"
AlignDefault -> "left"
-tableItemToMediaWiki :: WriterOptions
- -> String
- -> String
- -> [Block]
- -> State WriterState String
-tableItemToMediaWiki opts celltype align' item = do
- let mkcell x = "<" ++ celltype ++ " align=\"" ++ align' ++ "\">" ++
- x ++ "</" ++ celltype ++ ">"
- contents <- blockListToMediaWiki opts item
- return $ mkcell contents
-
-- | Convert list of Pandoc block elements to MediaWiki.
blockListToMediaWiki :: WriterOptions -- ^ Options
-> [Block] -- ^ List of block elements
@@ -333,6 +335,10 @@ inlineListToMediaWiki opts lst =
-- | Convert Pandoc inline element to MediaWiki.
inlineToMediaWiki :: WriterOptions -> Inline -> State WriterState String
+inlineToMediaWiki opts (Span attrs ils) = do
+ contents <- inlineListToMediaWiki opts ils
+ return $ render Nothing (tagWithAttrs "span" attrs) ++ contents ++ "</span>"
+
inlineToMediaWiki opts (Emph lst) = do
contents <- inlineListToMediaWiki opts lst
return $ "''" ++ contents ++ "''"
@@ -373,9 +379,10 @@ inlineToMediaWiki _ (Str str) = return $ escapeString str
inlineToMediaWiki _ (Math _ str) = return $ "<math>" ++ str ++ "</math>"
-- note: str should NOT be escaped
-inlineToMediaWiki _ (RawInline "mediawiki" str) = return str
-inlineToMediaWiki _ (RawInline "html" str) = return str
-inlineToMediaWiki _ (RawInline _ _) = return ""
+inlineToMediaWiki _ (RawInline f str)
+ | f == Format "mediawiki" = return str
+ | f == Format "html" = return str
+ | otherwise = return ""
inlineToMediaWiki _ (LineBreak) = return "<br />"
diff --git a/src/Text/Pandoc/Writers/Native.hs b/src/Text/Pandoc/Writers/Native.hs
index 090b97433..cb821e40b 100644
--- a/src/Text/Pandoc/Writers/Native.hs
+++ b/src/Text/Pandoc/Writers/Native.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}
{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.Native
- Copyright : Copyright (C) 2006-2010 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs
index db27286e8..15f7c8be8 100644
--- a/src/Text/Pandoc/Writers/ODT.hs
+++ b/src/Text/Pandoc/Writers/ODT.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-
-Copyright (C) 2008-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2008-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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.ODT
- Copyright : Copyright (C) 2008-2010 John MacFarlane
+ Copyright : Copyright (C) 2008-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -30,7 +30,10 @@ Conversion of 'Pandoc' documents to ODT.
-}
module Text.Pandoc.Writers.ODT ( writeODT ) where
import Data.IORef
-import Data.List ( isPrefixOf )
+import Data.List ( isPrefixOf, isSuffixOf )
+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
@@ -39,15 +42,15 @@ import Text.Pandoc.Shared ( stringify, readDataFile, fetchItem, warn )
import Text.Pandoc.ImageSize ( imageSize, sizeInPoints )
import Text.Pandoc.MIME ( getMimeType )
import Text.Pandoc.Definition
-import Text.Pandoc.Generic
+import Text.Pandoc.Walk
+import Text.Pandoc.Writers.Shared ( fixDisplayMath )
import Text.Pandoc.Writers.OpenDocument ( writeOpenDocument )
import Control.Monad (liftM)
-import Control.Monad.Trans (liftIO)
import Text.Pandoc.XML
import Text.Pandoc.Pretty
import qualified Control.Exception as E
import Data.Time.Clock.POSIX ( getPOSIXTime )
-import System.FilePath ( takeExtension )
+import System.FilePath ( takeExtension, takeDirectory )
-- | Produce an ODT file from a Pandoc document.
writeODT :: WriterOptions -- ^ Writer options
@@ -61,34 +64,44 @@ writeODT opts doc@(Pandoc meta _) = do
Just f -> B.readFile f
Nothing -> (B.fromChunks . (:[])) `fmap`
readDataFile datadir "reference.odt"
- -- handle pictures
+ -- handle formulas and pictures
picEntriesRef <- newIORef ([] :: [Entry])
- let sourceDir = writerSourceDirectory opts
- doc' <- bottomUpM (transformPic sourceDir picEntriesRef) doc
+ doc' <- walkM (transformPicMath opts picEntriesRef) $ walk fixDisplayMath doc
let newContents = writeOpenDocument opts{writerWrapText = False} doc'
epochtime <- floor `fmap` getPOSIXTime
- let contentEntry = toEntry "content.xml" epochtime $ fromStringLazy newContents
+ let contentEntry = toEntry "content.xml" epochtime
+ $ fromStringLazy newContents
picEntries <- readIORef picEntriesRef
- let archive = foldr addEntryToArchive refArchive $ contentEntry : picEntries
+ let archive = foldr addEntryToArchive refArchive
+ $ contentEntry : picEntries
-- construct META-INF/manifest.xml based on archive
let toFileEntry fp = case getMimeType fp of
- Nothing -> empty
+ Nothing -> if "Formula-" `isPrefixOf` fp && "/" `isSuffixOf` fp
+ then selfClosingTag "manifest:file-entry"
+ [("manifest:media-type","application/vnd.oasis.opendocument.formula")
+ ,("manifest:full-path",fp)]
+ else 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 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")]
+ [("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:version","1.2")
,("manifest:full-path","/")]
$$ vcat ( map toFileEntry $ files )
+ $$ vcat ( map toFileEntry $ formulas )
)
)
let archive' = addEntryToArchive manifestEntry archive
@@ -109,19 +122,23 @@ writeODT opts doc@(Pandoc meta _) = do
)
)
)
- let archive'' = addEntryToArchive metaEntry archive'
+ -- 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''
-transformPic :: FilePath -> IORef [Entry] -> Inline -> IO Inline
-transformPic sourceDir entriesRef (Image lab (src,_)) = do
- res <- liftIO $ E.try $ fetchItem sourceDir src
+transformPicMath :: WriterOptions -> IORef [Entry] -> Inline -> IO Inline
+transformPicMath opts entriesRef (Image lab (src,_)) = do
+ res <- fetchItem (writerSourceURL opts) src
case res of
Left (_ :: E.SomeException) -> do
- liftIO $ warn $ "Could not find image `" ++ src ++ "', skipping..."
+ warn $ "Could not find image `" ++ src ++ "', skipping..."
return $ Emph lab
Right (img, _) -> do
let size = imageSize img
- let (w,h) = maybe (0,0) id $ sizeInPoints `fmap` size
+ let (w,h) = fromMaybe (0,0) $ sizeInPoints `fmap` size
let tit' = show w ++ "x" ++ show h
entries <- readIORef entriesRef
let newsrc = "Pictures/" ++ show (length entries) ++ takeExtension src
@@ -130,5 +147,29 @@ transformPic sourceDir entriesRef (Image lab (src,_)) = do
let entry = toEntry newsrc epochtime $ toLazy img
modifyIORef entriesRef (entry:)
return $ Image lab (newsrc, tit')
-transformPic _ _ x = return x
+transformPicMath _ entriesRef (Math t math) = do
+ entries <- readIORef entriesRef
+ let dt = if t == InlineMath then DisplayInline else DisplayBlock
+ case texMathToMathML dt math of
+ Left _ -> return $ Math t math
+ Right r -> do
+ let conf = useShortEmptyTags (const False) defaultConfigPP
+ let mathml = ppcTopElement conf r
+ epochtime <- floor `fmap` getPOSIXTime
+ let dirname = "Formula-" ++ show (length entries) ++ "/"
+ let fname = dirname ++ "content.xml"
+ let entry = toEntry fname epochtime (fromStringLazy mathml)
+ modifyIORef entriesRef (entry:)
+ 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
index f6926c1dc..dd359f3f5 100644
--- a/src/Text/Pandoc/Writers/OPML.hs
+++ b/src/Text/Pandoc/Writers/OPML.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2013 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2013-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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.OPML
- Copyright : Copyright (C) 2013 John MacFarlane
+ Copyright : Copyright (C) 2013-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
index 30f99c3e4..b6da2694c 100644
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -1,7 +1,7 @@
-{-# LANGUAGE PatternGuards #-}
+{-# LANGUAGE PatternGuards, OverloadedStrings #-}
{-
-Copyright (C) 2008-2010 Andrea Rossato <andrea.rossato@ing.unitn.it>
-and John MacFarlane.
+Copyright (C) 2008-2014 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
@@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.OpenDocument
- Copyright : Copyright (C) 2008-2010 Andrea Rossato and John MacFarlane
+ Copyright : Copyright (C) 2008-2014 Andrea Rossato and John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : Andrea Rossato <andrea.rossato@ing.unitn.it>
@@ -64,6 +64,7 @@ data WriterState =
, stInDefinition :: Bool
, stTight :: Bool
, stFirstPara :: Bool
+ , stImageId :: Int
}
defaultWriterState :: WriterState
@@ -78,6 +79,7 @@ defaultWriterState =
, stInDefinition = False
, stTight = False
, stFirstPara = False
+ , stImageId = 1
}
when :: Bool -> Doc -> Doc
@@ -283,8 +285,13 @@ blocksToOpenDocument o b = vcat <$> mapM (blockToOpenDocument o) b
-- | Convert a Pandoc block element to OpenDocument.
blockToOpenDocument :: WriterOptions -> Block -> State WriterState Doc
blockToOpenDocument o bs
- | Plain b <- bs = inParagraphTags =<< inlinesToOpenDocument o b
- | Para b <- bs = inParagraphTags =<< inlinesToOpenDocument o b
+ | Plain b <- bs = if null b
+ then return empty
+ else inParagraphTags =<< inlinesToOpenDocument o b
+ | Para b <- bs = if null b
+ then return empty
+ else inParagraphTags =<< inlinesToOpenDocument o b
+ | Div _ xs <- bs = blocksToOpenDocument o xs
| Header i _ b <- bs = setFirstPara >>
(inHeaderTags i =<< inlinesToOpenDocument o b)
| BlockQuote b <- bs = setFirstPara >> mkBlockQuote b
@@ -295,7 +302,9 @@ blockToOpenDocument o bs
| 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 _ _ <- bs = return empty
+ | RawBlock f s <- bs = if f == Format "opendocument"
+ then return $ text s
+ else return empty
| Null <- bs = return empty
| otherwise = return empty
where
@@ -360,6 +369,7 @@ inlinesToOpenDocument o l = hcat <$> mapM (inlineToOpenDocument o) l
inlineToOpenDocument :: WriterOptions -> Inline -> State WriterState Doc
inlineToOpenDocument o ils
| Space <- ils = inTextStyle space
+ | Span _ xs <- ils = inlinesToOpenDocument o xs
| LineBreak <- ils = return $ selfClosingTag "text:line-break" []
| Str s <- ils = inTextStyle $ handleSpaces $ escapeStringForXML s
| Emph l <- ils = withTextStyle Italic $ inlinesToOpenDocument o l
@@ -369,23 +379,27 @@ inlineToOpenDocument o ils
| Subscript l <- ils = withTextStyle Sub $ inlinesToOpenDocument o l
| SmallCaps l <- ils = withTextStyle SmallC $ inlinesToOpenDocument o l
| Quoted t l <- ils = inQuotes t <$> inlinesToOpenDocument o l
- | Code _ s <- ils = preformatted s
- | Math _ s <- ils = inlinesToOpenDocument o (readTeXMath s)
+ | Code _ s <- ils = withTextStyle Pre $ inTextStyle $ preformatted s
+ | Math t s <- ils = inlinesToOpenDocument o (readTeXMath' t s)
| Cite _ l <- ils = inlinesToOpenDocument o l
- | RawInline "opendocument" s <- ils = preformatted s
- | RawInline "html" s <- ils = preformatted s -- for backwards compat.
- | RawInline _ _ <- ils = return empty
+ | RawInline f s <- ils = if f == Format "opendocument"
+ then return $ text s
+ else return empty
| Link l (s,t) <- ils = mkLink s t <$> inlinesToOpenDocument o l
- | Image _ (s,t) <- ils = return $ mkImg s t
+ | Image _ (s,t) <- ils = mkImg s t
| Note l <- ils = mkNote l
| otherwise = return empty
where
- preformatted = return . inSpanTags "Teletype" . handleSpaces . escapeStringForXML
+ preformatted s = handleSpaces $ escapeStringForXML s
mkLink s t = inTags False "text:a" [ ("xlink:type" , "simple")
, ("xlink:href" , s )
, ("office:name", t )
] . inSpanTags "Definition"
- mkImg s t = inTags False "draw:frame" (attrsFromTitle t) $
+ mkImg s t = do
+ id' <- gets stImageId
+ modify (\st -> st{ stImageId = id' + 1 })
+ return $ inTags False "draw:frame"
+ (("draw:name", "img" ++ show id'):attrsFromTitle t) $
selfClosingTag "draw:image" [ ("xlink:href" , s )
, ("xlink:type" , "simple")
, ("xlink:show" , "embed" )
@@ -457,7 +471,8 @@ tableStyle :: Int -> [(Char,Double)] -> Doc
tableStyle num wcs =
let tableId = "Table" ++ show (num + 1)
table = inTags True "style:style"
- [("style:name", tableId)] $
+ [("style:name", tableId)
+ ,("style:family", "table")] $
selfClosingTag "style:table-properties"
[("table:align" , "center")]
colStyle (c,0) = selfClosingTag "style:style"
@@ -489,14 +504,16 @@ paraStyle parent attrs = do
tight = if t then [ ("fo:margin-top" , "0in" )
, ("fo:margin-bottom" , "0in" )]
else []
- indent = when (i /= 0 || b || t) $
- selfClosingTag "style:paragraph-properties" $
- [ ("fo:margin-left" , indentVal)
+ indent = if (i /= 0 || b)
+ then [ ("fo:margin-left" , indentVal)
, ("fo:margin-right" , "0in" )
, ("fo:text-indent" , "0in" )
, ("style:auto-text-indent" , "false" )]
- ++ tight
- addParaStyle $ inTags True "style:style" (styleAttr ++ attrs) indent
+ 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 :: Int -> State WriterState Int
@@ -517,7 +534,8 @@ paraTableStyles t s (a:xs)
[ ("fo:text-align", x)
, ("style:justify-single-word", "false")]
-data TextStyle = Italic | Bold | Strike | Sub | Sup | SmallC deriving ( Eq,Ord )
+data TextStyle = Italic | Bold | Strike | Sub | Sup | SmallC | Pre
+ deriving ( Eq,Ord )
textStyleAttr :: TextStyle -> [(String,String)]
textStyleAttr s
@@ -531,5 +549,8 @@ textStyleAttr s
| 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
index 40e8abf7e..87046537c 100644
--- a/src/Text/Pandoc/Writers/Org.hs
+++ b/src/Text/Pandoc/Writers/Org.hs
@@ -1,6 +1,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-
-Copyright (C) 2006-2010 Puneeth Chaganti <punchagan@gmail.com>
+Copyright (C) 2010-2014 Puneeth Chaganti <punchagan@gmail.com>
+ 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
@@ -19,7 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.Org
- Copyright : Copyright (C) 2010 Puneeth Chaganti
+ Copyright : Copyright (C) 2010-2014 Puneeth Chaganti and John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : Puneeth Chaganti <punchagan@gmail.com>
@@ -106,6 +107,14 @@ escapeString = escapeStringUsing $
blockToOrg :: Block -- ^ Block element
-> State WriterState Doc
blockToOrg Null = return empty
+blockToOrg (Div attrs bs) = do
+ contents <- blockListToOrg bs
+ let startTag = tagWithAttrs "div" attrs
+ let endTag = text "</div>"
+ return $ 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 txt (src,'f':'i':'g':':':tit)]) = do
@@ -121,7 +130,7 @@ blockToOrg (Para inlines) = do
blockToOrg (RawBlock "html" str) =
return $ blankline $$ "#+BEGIN_HTML" $$
nest 2 (text str) $$ "#+END_HTML" $$ blankline
-blockToOrg (RawBlock f str) | f == "org" || f == "latex" || f == "tex" =
+blockToOrg (RawBlock f str) | f `elem` ["org", "latex", "tex"] =
return $ text str
blockToOrg (RawBlock _ _) = return empty
blockToOrg HorizontalRule = return $ blankline $$ "--------------" $$ blankline
@@ -229,6 +238,8 @@ inlineListToOrg lst = mapM inlineToOrg lst >>= return . hcat
-- | Convert Pandoc inline element to Org.
inlineToOrg :: Inline -> State WriterState Doc
+inlineToOrg (Span _ lst) =
+ inlineListToOrg lst
inlineToOrg (Emph lst) = do
contents <- inlineListToOrg lst
return $ "/" <> contents <> "/"
@@ -261,7 +272,7 @@ inlineToOrg (Math t str) = do
else "$$" <> text str <> "$$"
inlineToOrg (RawInline f str) | f == "tex" || f == "latex" = return $ text str
inlineToOrg (RawInline _ _) = return empty
-inlineToOrg (LineBreak) = return cr -- there's no line break in Org
+inlineToOrg (LineBreak) = return (text "\\\\" <> cr)
inlineToOrg Space = return space
inlineToOrg (Link txt (src, _)) = do
case txt of
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
index 606793842..31c97349b 100644
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}
{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.RST
- Copyright : Copyright (C) 2006-2010 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -38,11 +38,11 @@ import Text.Pandoc.Writers.Shared
import Text.Pandoc.Templates (renderTemplate')
import Text.Pandoc.Builder (deleteMeta)
import Data.List ( isPrefixOf, intersperse, transpose )
-import Network.URI (isAbsoluteURI)
+import Network.URI (isURI)
import Text.Pandoc.Pretty
import Control.Monad.State
import Control.Applicative ( (<$>) )
-import Data.Char (isSpace)
+import Data.Char (isSpace, toLower)
type Refs = [([Inline], Target)]
@@ -161,6 +161,11 @@ bordered contents c =
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 txt (src,'f':'i':'g':':':tit)]) = do
@@ -175,9 +180,11 @@ blockToRST (Para inlines)
| otherwise = do
contents <- inlineListToRST inlines
return $ contents <> blankline
-blockToRST (RawBlock f str) =
- return $ blankline <> ".. raw:: " <> text f $+$
- (nest 3 $ text str) $$ blankline
+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 _ inlines) = do
@@ -212,11 +219,15 @@ blockToRST (Table caption _ widths headers rows) = do
else blankline <> text "Table: " <> caption'
headers' <- mapM blockListToRST headers
rawRows <- mapM (mapM blockListToRST) rows
- let isSimple = all (==0) widths && all (all (\bs -> length bs <= 1)) rows
+ -- let 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 isSimple
+ 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]
@@ -280,7 +291,7 @@ definitionListItemToRST (label, defs) = do
label' <- inlineListToRST label
contents <- liftM vcat $ mapM blockListToRST defs
tabstop <- get >>= (return . writerTabStop . stOptions)
- return $ label' $$ nest tabstop (contents <> cr)
+ return $ label' $$ nest tabstop (nestle contents <> cr)
-- | Convert list of Pandoc block elements to RST.
blockListToRST :: [Block] -- ^ List of block elements
@@ -289,8 +300,14 @@ blockListToRST blocks = mapM blockToRST blocks >>= return . vcat
-- | Convert list of Pandoc inline elements to RST.
inlineListToRST :: [Inline] -> State WriterState Doc
-inlineListToRST lst = mapM inlineToRST (insertBS lst) >>= return . hcat
- where insertBS :: [Inline] -> [Inline] -- insert '\ ' where needed
+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 : RawInline "rst" "\\ " : insertBS (z:zs)
@@ -338,6 +355,7 @@ inlineListToRST lst = mapM inlineToRST (insertBS lst) >>= return . hcat
-- | 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 <> "*"
@@ -372,13 +390,14 @@ inlineToRST (Math t str) = do
then blankline $$ ".. math::" $$
blankline $$ nest 3 (text str) $$ blankline
else blankline $$ (".. math:: " <> text str) $$ blankline
-inlineToRST (RawInline "rst" x) = return $ text x
-inlineToRST (RawInline _ _) = return empty
+inlineToRST (RawInline f x)
+ | f == "rst" = return $ text x
+ | otherwise = return empty
inlineToRST (LineBreak) = return cr -- there's no line break in RST (see Para)
inlineToRST Space = return space
-- autolink
inlineToRST (Link [Str str] (src, _))
- | isAbsoluteURI src &&
+ | isURI src &&
if "mailto:" `isPrefixOf` src
then src == escapeURI ("mailto:" ++ str)
else src == escapeURI str = do
diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs
index 0db1c52c4..e0428aaa8 100644
--- a/src/Text/Pandoc/Writers/RTF.hs
+++ b/src/Text/Pandoc/Writers/RTF.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.RTF
- Copyright : Copyright (C) 2006-2010 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -34,13 +34,13 @@ import Text.Pandoc.Shared
import Text.Pandoc.Writers.Shared
import Text.Pandoc.Readers.TeXMath
import Text.Pandoc.Templates (renderTemplate')
-import Text.Pandoc.Generic (bottomUpM)
+import Text.Pandoc.Walk
import Data.List ( isSuffixOf, intercalate )
import Data.Char ( ord, chr, isDigit, toLower )
import System.FilePath ( takeExtension )
import qualified Data.ByteString as B
import Text.Printf ( printf )
-import Network.URI ( isAbsoluteURI, unEscapeString )
+import Network.URI ( isURI, unEscapeString )
import qualified Control.Exception as E
-- | Convert Image inlines into a raw RTF embedded image, read from a file.
@@ -48,7 +48,7 @@ import qualified Control.Exception as E
rtfEmbedImage :: Inline -> IO Inline
rtfEmbedImage x@(Image _ (src,_)) = do
let ext = map toLower (takeExtension src)
- if ext `elem` [".jpg",".jpeg",".png"] && not (isAbsoluteURI src)
+ if ext `elem` [".jpg",".jpeg",".png"] && not (isURI src)
then do
let src' = unEscapeString src
imgdata <- E.catch (B.readFile src')
@@ -62,7 +62,7 @@ rtfEmbedImage x@(Image _ (src,_)) = do
let raw = "{\\pict" ++ filetype ++ " " ++ concat bytes ++ "}"
return $ if B.null imgdata
then x
- else RawInline "rtf" raw
+ else RawInline (Format "rtf") raw
else return x
rtfEmbedImage x = return x
@@ -70,7 +70,7 @@ rtfEmbedImage x = return x
-- images embedded as encoded binary data.
writeRTFWithEmbeddedImages :: WriterOptions -> Pandoc -> IO String
writeRTFWithEmbeddedImages options doc =
- writeRTF options `fmap` bottomUpM rtfEmbedImage doc
+ writeRTF options `fmap` walkM rtfEmbedImage doc
-- | Convert Pandoc to a string in rich text format.
writeRTF :: WriterOptions -> Pandoc -> String
@@ -208,6 +208,8 @@ blockToRTF :: Int -- ^ indent level
-> Block -- ^ block to convert
-> String
blockToRTF _ _ Null = ""
+blockToRTF indent alignment (Div _ bs) =
+ concatMap (blockToRTF indent alignment) bs
blockToRTF indent alignment (Plain lst) =
rtfCompact indent 0 alignment $ inlineListToRTF lst
blockToRTF indent alignment (Para lst) =
@@ -216,8 +218,9 @@ blockToRTF indent alignment (BlockQuote lst) =
concatMap (blockToRTF (indent + indentIncrement) alignment) lst
blockToRTF indent _ (CodeBlock _ str) =
rtfPar indent 0 AlignLeft ("\\f1 " ++ (codeStringToRTF str))
-blockToRTF _ _ (RawBlock "rtf" str) = str
-blockToRTF _ _ (RawBlock _ _) = ""
+blockToRTF _ _ (RawBlock f str)
+ | f == Format "rtf" = str
+ | otherwise = ""
blockToRTF indent alignment (BulletList lst) = spaceAtEnd $
concatMap (listItemToRTF alignment indent (bulletMarker indent)) lst
blockToRTF indent alignment (OrderedList attribs lst) = spaceAtEnd $ concat $
@@ -256,7 +259,7 @@ tableRowToRTF header indent aligns sizes' cols =
tableItemToRTF :: Int -> Alignment -> [Block] -> String
tableItemToRTF indent alignment item =
let contents = concatMap (blockToRTF indent alignment) item
- in "{\\intbl " ++ contents ++ "\\cell}\n"
+ in "{" ++ substitute "\\pard" "\\pard\\intbl" contents ++ "\\cell}\n"
-- | Ensure that there's the same amount of space after compact
-- lists as after regular lists.
@@ -308,6 +311,7 @@ inlineListToRTF lst = concatMap inlineToRTF lst
-- | Convert inline item to RTF.
inlineToRTF :: Inline -- ^ inline to convert
-> String
+inlineToRTF (Span _ lst) = inlineListToRTF lst
inlineToRTF (Emph lst) = "{\\i " ++ (inlineListToRTF lst) ++ "}"
inlineToRTF (Strong lst) = "{\\b " ++ (inlineListToRTF lst) ++ "}"
inlineToRTF (Strikeout lst) = "{\\strike " ++ (inlineListToRTF lst) ++ "}"
@@ -320,10 +324,11 @@ inlineToRTF (Quoted DoubleQuote lst) =
"\\u8220\"" ++ (inlineListToRTF lst) ++ "\\u8221\""
inlineToRTF (Code _ str) = "{\\f1 " ++ (codeStringToRTF str) ++ "}"
inlineToRTF (Str str) = stringToRTF str
-inlineToRTF (Math _ str) = inlineListToRTF $ readTeXMath str
+inlineToRTF (Math t str) = inlineListToRTF $ readTeXMath' t str
inlineToRTF (Cite _ lst) = inlineListToRTF lst
-inlineToRTF (RawInline "rtf" str) = str
-inlineToRTF (RawInline _ _) = ""
+inlineToRTF (RawInline f str)
+ | f == Format "rtf" = str
+ | otherwise = ""
inlineToRTF (LineBreak) = "\\line "
inlineToRTF Space = " "
inlineToRTF (Link text (src, _)) =
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs
index c6c30d070..800e741a4 100644
--- a/src/Text/Pandoc/Writers/Shared.hs
+++ b/src/Text/Pandoc/Writers/Shared.hs
@@ -1,5 +1,6 @@
+{-# LANGUAGE OverloadedStrings #-}
{-
-Copyright (C) 2013 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2013-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
@@ -18,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.Shared
- Copyright : Copyright (C) 2013 John MacFarlane
+ Copyright : Copyright (C) 2013-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -32,9 +33,13 @@ module Text.Pandoc.Writers.Shared (
, getField
, setField
, defField
+ , tagWithAttrs
+ , fixDisplayMath
)
where
import Text.Pandoc.Definition
+import Text.Pandoc.Pretty
+import Text.Pandoc.XML (escapeStringForXML)
import Control.Monad (liftM)
import Text.Pandoc.Options (WriterOptions(..))
import qualified Data.HashMap.Strict as H
@@ -42,6 +47,7 @@ import qualified Data.Map as M
import qualified Data.Text as T
import Data.Aeson (FromJSON(..), fromJSON, ToJSON (..), Value(Object), Result(..))
import qualified Data.Traversable as Traversable
+import Data.List ( groupBy )
-- | Create JSON value for template from a 'Meta' and an association list
-- of variables, specified at the command line or in the writer.
@@ -61,8 +67,7 @@ metaToJSON opts blockWriter inlineWriter (Meta metamap)
renderedMap <- Traversable.mapM
(metaValueToJSON blockWriter inlineWriter)
metamap
- return $ M.foldWithKey (\key val obj -> defField key val obj)
- baseContext renderedMap
+ return $ M.foldWithKey defField baseContext renderedMap
| otherwise = return (Object H.empty)
metaValueToJSON :: Monad m
@@ -74,6 +79,7 @@ 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
@@ -119,3 +125,41 @@ defField field val (Object 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 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
diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs
index 0f57d14b2..8ac717bab 100644
--- a/src/Text/Pandoc/Writers/Texinfo.hs
+++ b/src/Text/Pandoc/Writers/Texinfo.hs
@@ -1,5 +1,6 @@
+{-# LANGUAGE OverloadedStrings #-}
{-
-Copyright (C) 2008-2010 John MacFarlane and Peter Wang
+Copyright (C) 2008-2014 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
@@ -18,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.Texinfo
- Copyright : Copyright (C) 2008-2010 John MacFarlane and Peter Wang
+ Copyright : Copyright (C) 2008-2014 John MacFarlane and Peter Wang
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -39,7 +40,7 @@ import Data.Ord ( comparing )
import Data.Char ( chr, ord )
import Control.Monad.State
import Text.Pandoc.Pretty
-import Network.URI ( isAbsoluteURI, unEscapeString )
+import Network.URI ( isURI, unEscapeString )
import System.FilePath
data WriterState =
@@ -123,6 +124,8 @@ blockToTexinfo :: Block -- ^ Block to convert
blockToTexinfo Null = return empty
+blockToTexinfo (Div _ bs) = blockListToTexinfo bs
+
blockToTexinfo (Plain lst) =
inlineListToTexinfo lst
@@ -150,10 +153,11 @@ blockToTexinfo (CodeBlock _ str) = do
flush (text str) $$
text "@end verbatim" <> blankline
-blockToTexinfo (RawBlock "texinfo" str) = return $ text str
-blockToTexinfo (RawBlock "latex" str) =
- return $ text "@tex" $$ text str $$ text "@end tex"
-blockToTexinfo (RawBlock _ _) = return empty
+blockToTexinfo (RawBlock f str)
+ | f == "texinfo" = return $ text str
+ | f == "latex" || f == "tex" =
+ return $ text "@tex" $$ text str $$ text "@end tex"
+ | otherwise = return empty
blockToTexinfo (BulletList lst) = do
items <- mapM listItemToTexinfo lst
@@ -289,7 +293,7 @@ blockListToTexinfo (x:xs) = do
case x of
Header level _ _ -> do
-- We need need to insert a menu for this node.
- let (before, after) = break isHeader xs
+ let (before, after) = break isHeaderBlock xs
before' <- blockListToTexinfo before
let menu = if level < 4
then collectNodes (level + 1) after
@@ -311,10 +315,6 @@ blockListToTexinfo (x:xs) = do
xs' <- blockListToTexinfo xs
return $ x' $$ xs'
-isHeader :: Block -> Bool
-isHeader (Header _ _ _) = True
-isHeader _ = False
-
collectNodes :: Int -> [Block] -> [Block]
collectNodes _ [] = []
collectNodes level (x:xs) =
@@ -374,6 +374,9 @@ disallowedInNode c = c `elem` ".,:()"
inlineToTexinfo :: Inline -- ^ Inline to convert
-> State WriterState Doc
+inlineToTexinfo (Span _ lst) =
+ inlineListToTexinfo lst
+
inlineToTexinfo (Emph lst) =
inlineListToTexinfo lst >>= return . inCmd "emph"
@@ -413,10 +416,11 @@ inlineToTexinfo (Cite _ lst) =
inlineListToTexinfo lst
inlineToTexinfo (Str str) = return $ text (stringToTexinfo str)
inlineToTexinfo (Math _ str) = return $ inCmd "math" $ text str
-inlineToTexinfo (RawInline f str) | f == "latex" || f == "tex" =
- return $ text "@tex" $$ text str $$ text "@end tex"
-inlineToTexinfo (RawInline "texinfo" str) = return $ text str
-inlineToTexinfo (RawInline _ _) = return empty
+inlineToTexinfo (RawInline f str)
+ | f == "latex" || f == "tex" =
+ return $ text "@tex" $$ text str $$ text "@end tex"
+ | f == "texinfo" = return $ text str
+ | otherwise = return empty
inlineToTexinfo (LineBreak) = return $ text "@*"
inlineToTexinfo Space = return $ char ' '
@@ -440,7 +444,7 @@ inlineToTexinfo (Image alternate (source, _)) = do
where
ext = drop 1 $ takeExtension source'
base = dropExtension source'
- source' = if isAbsoluteURI source
+ source' = if isURI source
then source
else unEscapeString source
diff --git a/src/Text/Pandoc/Writers/Textile.hs b/src/Text/Pandoc/Writers/Textile.hs
index 3288ce222..3a6982a01 100644
--- a/src/Text/Pandoc/Writers/Textile.hs
+++ b/src/Text/Pandoc/Writers/Textile.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2010-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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.Writers.Textile
- Copyright : Copyright (C) 2010 John MacFarlane
+ Copyright : Copyright (C) 2010-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -33,6 +33,7 @@ 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.Writers.Shared
import Text.Pandoc.Templates (renderTemplate')
import Text.Pandoc.XML ( escapeStringForXML )
@@ -50,7 +51,7 @@ data WriterState = WriterState {
writeTextile :: WriterOptions -> Pandoc -> String
writeTextile opts document =
evalState (pandocToTextile opts document)
- (WriterState { stNotes = [], stListLevel = [], stUseTags = False })
+ WriterState { stNotes = [], stListLevel = [], stUseTags = False }
-- | Return Textile representation of document.
pandocToTextile :: WriterOptions -> Pandoc -> State WriterState String
@@ -101,6 +102,12 @@ blockToTextile :: WriterOptions -- ^ Options
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
@@ -118,10 +125,9 @@ blockToTextile opts (Para inlines) = do
then "<p>" ++ contents ++ "</p>"
else contents ++ if null listLevel then "\n" else ""
-blockToTextile _ (RawBlock f str) =
- if f == "html" || f == "textile"
- then return str
- else return ""
+blockToTextile _ (RawBlock f str)
+ | f == Format "html" || f == Format "textile" = return str
+ | otherwise = return ""
blockToTextile _ HorizontalRule = return "<hr />\n"
@@ -343,6 +349,9 @@ inlineListToTextile opts lst =
-- | 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
@@ -395,10 +404,9 @@ inlineToTextile _ (Str str) = return $ escapeStringForTextile str
inlineToTextile _ (Math _ str) =
return $ "<span class=\"math\">" ++ escapeStringForXML str ++ "</math>"
-inlineToTextile _ (RawInline f str) =
- if f == "html" || f == "textile"
- then return str
- else return ""
+inlineToTextile _ (RawInline f str)
+ | f == Format "html" || f == Format "textile" = return str
+ | otherwise = return ""
inlineToTextile _ (LineBreak) = return "\n"
diff --git a/src/Text/Pandoc/XML.hs b/src/Text/Pandoc/XML.hs
index 89ae81a10..8000368aa 100644
--- a/src/Text/Pandoc/XML.hs
+++ b/src/Text/Pandoc/XML.hs
@@ -1,5 +1,5 @@
{-
-Copyright (C) 2006-2010 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2006-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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : Text.Pandoc.XML
- Copyright : Copyright (C) 2006-2010 John MacFarlane
+ Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <jgm@berkeley.edu>
@@ -38,7 +38,7 @@ module Text.Pandoc.XML ( escapeCharForXML,
import Text.Pandoc.Pretty
import Data.Char (ord, isAscii, isSpace)
-import Text.HTML.TagSoup.Entity (lookupEntity)
+import Text.Pandoc.Compat.TagSoupEntity (lookupEntity)
-- | Escape one character as needed for XML.
escapeCharForXML :: Char -> String
diff --git a/tests/MarkdownTest_1.0.3/MarkdownTest.pl b/tests/MarkdownTest_1.0.3/MarkdownTest.pl
deleted file mode 100755
index 55553d09c..000000000
--- a/tests/MarkdownTest_1.0.3/MarkdownTest.pl
+++ /dev/null
@@ -1,176 +0,0 @@
-#!/usr/bin/perl
-
-#
-# MarkdownTester -- Run tests for Markdown implementations
-#
-# Copyright (c) 2004-2005 John Gruber
-# <http://daringfireball.net/projects/markdown/>
-#
-
-use strict;
-use warnings;
-use Getopt::Long;
-use Benchmark;
-
-our $VERSION = '1.0.2';
-# Sat 24 Dec 2005
-
-my $time_start = new Benchmark;
-my $test_dir = "Tests";
-my $script = "./Markdown.pl";
-my $use_tidy = 0;
-my ($flag_version);
-
-GetOptions (
- "script=s" => \$script,
- "testdir=s" => \$test_dir,
- "tidy" => \$use_tidy,
- "version" => \$flag_version,
- );
-
-if($flag_version) {
- my $progname = $0;
- $progname =~ s{.*/}{};
- die "$progname version $VERSION\n";
-}
-
-unless (-d $test_dir) { die "'$test_dir' is not a directory.\n"; }
-unless (-f $script) { die "$script does not exist.\n"; }
-unless (-x $script) { die "$script is not executable.\n"; }
-
-my $tests_passed = 0;
-my $tests_failed = 0;
-
-TEST:
-foreach my $testfile (glob "$test_dir/*.text") {
- my $testname = $testfile;
- $testname =~ s{.*/(.+)\.text$}{$1}i;
- print "$testname ... ";
-
- # Look for a corresponding .html file for each .text file:
- my $resultfile = $testfile;
- $resultfile =~ s{\.text$}{\.html}i;
- unless (-f $resultfile) {
- print "'$resultfile' does not exist.\n\n";
- next TEST;
- }
-
- # open(TEST, $testfile) || die("Can't open testfile: $!");
- open(RESULT, $resultfile) || die("Can't open resultfile: $!");
- undef $/;
- # my $t_input = <TEST>;
- my $t_result = <RESULT>;
-
- my $t_output = `'$script' '$testfile'`;
-
- # Normalize the output and expected result strings:
- $t_result =~ s/\s+\z//; # trim trailing whitespace
- $t_output =~ s/\s+\z//; # trim trailing whitespace
- if ($use_tidy) {
- # Escape the strings, pass them through to CLI tidy tool for tag-level equivalency
- $t_result =~ s{'}{'\\''}g; # escape ' chars for shell
- $t_output =~ s{'}{'\\''}g;
- $t_result = `echo '$t_result' | tidy --show-body-only 1 --quiet 1 --show-warnings 0`;
- $t_output = `echo '$t_output' | tidy --show-body-only 1 --quiet 1 --show-warnings 0`;
- }
-
- if ($t_output eq $t_result) {
- print "OK\n";
- $tests_passed++;
- }
- else {
- print "FAILED\n\n";
-# This part added by JM to print diffs
- open(OUT, '>tmp1') or die $!;
- print OUT $t_output or die $!;
- open(RES, '>tmp2') or die $!;
- print RES $t_result or die $!;
- print `diff tmp1 tmp2`;
- close RES;
- close OUT;
- print "\n";
- `rm tmp?`;
-# End of added part
- $tests_failed++;
- }
-}
-
-print "\n\n";
-print "$tests_passed passed; $tests_failed failed.\n";
-
-my $time_end = new Benchmark;
-my $time_diff = timediff($time_end, $time_start);
-print "Benchmark: ", timestr($time_diff), "\n";
-
-
-__END__
-
-=pod
-
-=head1 NAME
-
-B<MarkdownTest>
-
-
-=head1 SYNOPSIS
-
-B<MarkdownTest.pl> [ B<--options> ] [ I<file> ... ]
-
-
-=head1 DESCRIPTION
-
-
-=head1 OPTIONS
-
-Use "--" to end switch parsing. For example, to open a file named "-z", use:
-
- MarkdownTest.pl -- -z
-
-=over 4
-
-=item B<--script>
-
-Specify the path to the Markdown script to test. Defaults to
-"./Markdown.pl". Example:
-
- ./MarkdownTest.pl --script ./PHP-Markdown/php-markdown
-
-=item B<--testdir>
-
-Specify the path to a directory containing test data. Defaults to "Tests".
-
-=item B<--tidy>
-
-Flag to turn on using the command line 'tidy' tool to normalize HTML
-output before comparing script output to the expected test result.
-Assumes that the 'tidy' command is available in your PATH. Defaults to
-off.
-
-=back
-
-
-
-=head1 BUGS
-
-
-
-=head1 VERSION HISTORY
-
-1.0 Mon 13 Dec 2004-2005
-
-1.0.1 Mon 19 Sep 2005
-
- + Better handling of case when foo.text exists, but foo.html doesn't.
- It now prints a message and moves on, rather than dying.
-
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright (c) 2004-2005 John Gruber
-<http://daringfireball.net/>
-All rights reserved.
-
-This is free software; you may redistribute it and/or modify it under
-the same terms as Perl itself.
-
-=cut
diff --git a/tests/MarkdownTest_1.0.3/Tests/Amps and angle encoding.html b/tests/MarkdownTest_1.0.3/Tests/Amps and angle encoding.html
deleted file mode 100644
index 9606860b6..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Amps and angle encoding.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<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 > 5.</p>
-
-<p>Here's a <a href="http://example.com/?foo=1&amp;bar=2">link</a> with an ampersand in the URL.</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 inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
-
-<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Amps and angle encoding.text b/tests/MarkdownTest_1.0.3/Tests/Amps and angle encoding.text
deleted file mode 100644
index 0e9527f93..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Amps and angle encoding.text
+++ /dev/null
@@ -1,21 +0,0 @@
-AT&T has an ampersand in their name.
-
-AT&amp;T is another way to write it.
-
-This & that.
-
-4 < 5.
-
-6 > 5.
-
-Here's a [link] [1] with an ampersand in the URL.
-
-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](</script?foo=1&bar=2>).
-
-
-[1]: http://example.com/?foo=1&bar=2
-[2]: http://att.com/ "AT&T" \ No newline at end of file
diff --git a/tests/MarkdownTest_1.0.3/Tests/Auto links.html b/tests/MarkdownTest_1.0.3/Tests/Auto links.html
deleted file mode 100644
index f8df9852c..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Auto links.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<p>Link: <a href="http://example.com/">http://example.com/</a>.</p>
-
-<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>
-
-<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>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Auto links.text b/tests/MarkdownTest_1.0.3/Tests/Auto links.text
deleted file mode 100644
index abbc48869..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Auto links.text
+++ /dev/null
@@ -1,13 +0,0 @@
-Link: <http://example.com/>.
-
-With an ampersand: <http://example.com/?foo=1&bar=2>
-
-* In a list?
-* <http://example.com/>
-* It should.
-
-> Blockquoted: <http://example.com/>
-
-Auto-links should not occur here: `<http://example.com/>`
-
- or here: <http://example.com/> \ No newline at end of file
diff --git a/tests/MarkdownTest_1.0.3/Tests/Backslash escapes.html b/tests/MarkdownTest_1.0.3/Tests/Backslash escapes.html
deleted file mode 100644
index 29870dac5..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Backslash escapes.html
+++ /dev/null
@@ -1,118 +0,0 @@
-<p>These should all get escaped:</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: ></p>
-
-<p>Hash: #</p>
-
-<p>Period: .</p>
-
-<p>Bang: !</p>
-
-<p>Plus: +</p>
-
-<p>Minus: -</p>
-
-<p>These should not, because they occur within a code block:</p>
-
-<pre><code>Backslash: \\
-
-Backtick: \`
-
-Asterisk: \*
-
-Underscore: \_
-
-Left brace: \{
-
-Right brace: \}
-
-Left bracket: \[
-
-Right bracket: \]
-
-Left paren: \(
-
-Right paren: \)
-
-Greater-than: \&gt;
-
-Hash: \#
-
-Period: \.
-
-Bang: \!
-
-Plus: \+
-
-Minus: \-
-</code></pre>
-
-<p>Nor should these, which occur in code spans:</p>
-
-<p>Backslash: <code>\\</code></p>
-
-<p>Backtick: <code>\`</code></p>
-
-<p>Asterisk: <code>\*</code></p>
-
-<p>Underscore: <code>\_</code></p>
-
-<p>Left brace: <code>\{</code></p>
-
-<p>Right brace: <code>\}</code></p>
-
-<p>Left bracket: <code>\[</code></p>
-
-<p>Right bracket: <code>\]</code></p>
-
-<p>Left paren: <code>\(</code></p>
-
-<p>Right paren: <code>\)</code></p>
-
-<p>Greater-than: <code>\&gt;</code></p>
-
-<p>Hash: <code>\#</code></p>
-
-<p>Period: <code>\.</code></p>
-
-<p>Bang: <code>\!</code></p>
-
-<p>Plus: <code>\+</code></p>
-
-<p>Minus: <code>\-</code></p>
-
-
-<p>These should get escaped, even though they're matching pairs for
-other Markdown constructs:</p>
-
-<p>*asterisks*</p>
-
-<p>_underscores_</p>
-
-<p>`backticks`</p>
-
-<p>This is a code span with a literal backslash-backtick sequence: <code>\`</code></p>
-
-<p>This is a tag with unescaped backticks <span attr='`ticks`'>bar</span>.</p>
-
-<p>This is a tag with backslashes <span attr='\\backslashes\\'>bar</span>.</p>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Backslash escapes.text b/tests/MarkdownTest_1.0.3/Tests/Backslash escapes.text
deleted file mode 100644
index 5b014cb33..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Backslash escapes.text
+++ /dev/null
@@ -1,120 +0,0 @@
-These should all get escaped:
-
-Backslash: \\
-
-Backtick: \`
-
-Asterisk: \*
-
-Underscore: \_
-
-Left brace: \{
-
-Right brace: \}
-
-Left bracket: \[
-
-Right bracket: \]
-
-Left paren: \(
-
-Right paren: \)
-
-Greater-than: \>
-
-Hash: \#
-
-Period: \.
-
-Bang: \!
-
-Plus: \+
-
-Minus: \-
-
-
-
-These should not, because they occur within a code block:
-
- Backslash: \\
-
- Backtick: \`
-
- Asterisk: \*
-
- Underscore: \_
-
- Left brace: \{
-
- Right brace: \}
-
- Left bracket: \[
-
- Right bracket: \]
-
- Left paren: \(
-
- Right paren: \)
-
- Greater-than: \>
-
- Hash: \#
-
- Period: \.
-
- Bang: \!
-
- Plus: \+
-
- Minus: \-
-
-
-Nor should these, which occur in code spans:
-
-Backslash: `\\`
-
-Backtick: `` \` ``
-
-Asterisk: `\*`
-
-Underscore: `\_`
-
-Left brace: `\{`
-
-Right brace: `\}`
-
-Left bracket: `\[`
-
-Right bracket: `\]`
-
-Left paren: `\(`
-
-Right paren: `\)`
-
-Greater-than: `\>`
-
-Hash: `\#`
-
-Period: `\.`
-
-Bang: `\!`
-
-Plus: `\+`
-
-Minus: `\-`
-
-
-These should get escaped, even though they're matching pairs for
-other Markdown constructs:
-
-\*asterisks\*
-
-\_underscores\_
-
-\`backticks\`
-
-This is a code span with a literal backslash-backtick sequence: `` \` ``
-
-This is a tag with unescaped backticks <span attr='`ticks`'>bar</span>.
-
-This is a tag with backslashes <span attr='\\backslashes\\'>bar</span>.
diff --git a/tests/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.html b/tests/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.html
deleted file mode 100644
index 990202a1b..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<blockquote>
- <p>Example:</p>
-
-<pre><code>sub status {
- print "working";
-}
-</code></pre>
-
- <p>Or:</p>
-
-<pre><code>sub status {
- return "working";
-}
-</code></pre>
-</blockquote>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.text b/tests/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.text
deleted file mode 100644
index c31d17104..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.text
+++ /dev/null
@@ -1,11 +0,0 @@
-> Example:
->
-> sub status {
-> print "working";
-> }
->
-> Or:
->
-> sub status {
-> return "working";
-> }
diff --git a/tests/MarkdownTest_1.0.3/Tests/Code Blocks.html b/tests/MarkdownTest_1.0.3/Tests/Code Blocks.html
deleted file mode 100644
index 32703f5cb..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Code Blocks.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<pre><code>code block on the first line
-</code></pre>
-
-<p>Regular text.</p>
-
-<pre><code>code block indented by spaces
-</code></pre>
-
-<p>Regular text.</p>
-
-<pre><code>the lines in this block
-all contain trailing spaces
-</code></pre>
-
-<p>Regular Text.</p>
-
-<pre><code>code block on the last line
-</code></pre>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Code Blocks.text b/tests/MarkdownTest_1.0.3/Tests/Code Blocks.text
deleted file mode 100644
index b54b09285..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Code Blocks.text
+++ /dev/null
@@ -1,14 +0,0 @@
- code block on the first line
-
-Regular text.
-
- code block indented by spaces
-
-Regular text.
-
- the lines in this block
- all contain trailing spaces
-
-Regular Text.
-
- code block on the last line \ No newline at end of file
diff --git a/tests/MarkdownTest_1.0.3/Tests/Code Spans.html b/tests/MarkdownTest_1.0.3/Tests/Code Spans.html
deleted file mode 100644
index 4b8afbb70..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Code Spans.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<p><code>&lt;test a="</code> content of attribute <code>"&gt;</code></p>
-
-<p>Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span></p>
-
-<p>Here's how you put <code>`backticks`</code> in a code span.</p>
-
diff --git a/tests/MarkdownTest_1.0.3/Tests/Code Spans.text b/tests/MarkdownTest_1.0.3/Tests/Code Spans.text
deleted file mode 100644
index 750a1973d..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Code Spans.text
+++ /dev/null
@@ -1,6 +0,0 @@
-`<test a="` content of attribute `">`
-
-Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span>
-
-Here's how you put `` `backticks` `` in a code span.
-
diff --git a/tests/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.html b/tests/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.html
deleted file mode 100644
index e21ac79a2..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<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>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.text b/tests/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.text
deleted file mode 100644
index f8a5b27bf..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.text
+++ /dev/null
@@ -1,8 +0,0 @@
-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.
diff --git a/tests/MarkdownTest_1.0.3/Tests/Horizontal rules.html b/tests/MarkdownTest_1.0.3/Tests/Horizontal rules.html
deleted file mode 100644
index 2dc2ab656..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Horizontal rules.html
+++ /dev/null
@@ -1,71 +0,0 @@
-<p>Dashes:</p>
-
-<hr />
-
-<hr />
-
-<hr />
-
-<hr />
-
-<pre><code>---
-</code></pre>
-
-<hr />
-
-<hr />
-
-<hr />
-
-<hr />
-
-<pre><code>- - -
-</code></pre>
-
-<p>Asterisks:</p>
-
-<hr />
-
-<hr />
-
-<hr />
-
-<hr />
-
-<pre><code>***
-</code></pre>
-
-<hr />
-
-<hr />
-
-<hr />
-
-<hr />
-
-<pre><code>* * *
-</code></pre>
-
-<p>Underscores:</p>
-
-<hr />
-
-<hr />
-
-<hr />
-
-<hr />
-
-<pre><code>___
-</code></pre>
-
-<hr />
-
-<hr />
-
-<hr />
-
-<hr />
-
-<pre><code>_ _ _
-</code></pre>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Horizontal rules.text b/tests/MarkdownTest_1.0.3/Tests/Horizontal rules.text
deleted file mode 100644
index 1594bda27..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Horizontal rules.text
+++ /dev/null
@@ -1,67 +0,0 @@
-Dashes:
-
----
-
- ---
-
- ---
-
- ---
-
- ---
-
-- - -
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
-
-Asterisks:
-
-***
-
- ***
-
- ***
-
- ***
-
- ***
-
-* * *
-
- * * *
-
- * * *
-
- * * *
-
- * * *
-
-
-Underscores:
-
-___
-
- ___
-
- ___
-
- ___
-
- ___
-
-_ _ _
-
- _ _ _
-
- _ _ _
-
- _ _ _
-
- _ _ _
diff --git a/tests/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).html b/tests/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).html
deleted file mode 100644
index 3af9cafb1..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).html
+++ /dev/null
@@ -1,15 +0,0 @@
-<p>Simple block on one line:</p>
-
-<div>foo</div>
-
-<p>And nested without indentation:</p>
-
-<div>
-<div>
-<div>
-foo
-</div>
-<div style=">"/>
-</div>
-<div>bar</div>
-</div>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).text b/tests/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).text
deleted file mode 100644
index 86b7206d2..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).text
+++ /dev/null
@@ -1,15 +0,0 @@
-Simple block on one line:
-
-<div>foo</div>
-
-And nested without indentation:
-
-<div>
-<div>
-<div>
-foo
-</div>
-<div style=">"/>
-</div>
-<div>bar</div>
-</div>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).html b/tests/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).html
deleted file mode 100644
index 6bf78f8fc..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).html
+++ /dev/null
@@ -1,72 +0,0 @@
-<p>Here's a simple block:</p>
-
-<div>
- foo
-</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
--->
-
-<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" >
diff --git a/tests/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).text b/tests/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).text
deleted file mode 100644
index 14aa2dc27..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).text
+++ /dev/null
@@ -1,69 +0,0 @@
-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
--->
-
-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" >
-
diff --git a/tests/MarkdownTest_1.0.3/Tests/Inline HTML comments.html b/tests/MarkdownTest_1.0.3/Tests/Inline HTML comments.html
deleted file mode 100644
index 3f167a161..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Inline HTML comments.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<p>Paragraph one.</p>
-
-<!-- This is a simple comment -->
-
-<!--
- This is another comment.
--->
-
-<p>Paragraph two.</p>
-
-<!-- one comment block -- -- with two comments -->
-
-<p>The end.</p>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Inline HTML comments.text b/tests/MarkdownTest_1.0.3/Tests/Inline HTML comments.text
deleted file mode 100644
index 41d830d03..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Inline HTML comments.text
+++ /dev/null
@@ -1,13 +0,0 @@
-Paragraph one.
-
-<!-- This is a simple comment -->
-
-<!--
- This is another comment.
--->
-
-Paragraph two.
-
-<!-- one comment block -- -- with two comments -->
-
-The end.
diff --git a/tests/MarkdownTest_1.0.3/Tests/Links, inline style.html b/tests/MarkdownTest_1.0.3/Tests/Links, inline style.html
deleted file mode 100644
index f36607ddd..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Links, inline style.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<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 has spaces afterward">URL and title</a>.</p>
-
-<p><a href="">Empty</a>.</p>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Links, inline style.text b/tests/MarkdownTest_1.0.3/Tests/Links, inline style.text
deleted file mode 100644
index 09017a90c..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Links, inline style.text
+++ /dev/null
@@ -1,12 +0,0 @@
-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 has spaces afterward" ).
-
-
-[Empty]().
diff --git a/tests/MarkdownTest_1.0.3/Tests/Links, reference style.html b/tests/MarkdownTest_1.0.3/Tests/Links, reference style.html
deleted file mode 100644
index 8e70c32f4..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Links, reference style.html
+++ /dev/null
@@ -1,52 +0,0 @@
-<p>Foo <a href="/url/" title="Title">bar</a>.</p>
-
-<p>Foo <a href="/url/" title="Title">bar</a>.</p>
-
-<p>Foo <a href="/url/" title="Title">bar</a>.</p>
-
-<p>With <a href="/url/">embedded [brackets]</a>.</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>Indented [four][] times.</p>
-
-<pre><code>[four]: /url
-</code></pre>
-
-<hr />
-
-<p><a href="foo">this</a> should work</p>
-
-<p>So should <a href="foo">this</a>.</p>
-
-<p>And <a href="foo">this</a>.</p>
-
-<p>And <a href="foo">this</a>.</p>
-
-<p>And <a href="foo">this</a>.</p>
-
-<p>But not [that] [].</p>
-
-<p>Nor [that][].</p>
-
-<p>Nor [that].</p>
-
-<p>[Something in brackets like <a href="foo">this</a> should work]</p>
-
-<p>[Same with <a href="foo">this</a>.]</p>
-
-<p>In this case, <a href="/somethingelse/">this</a> points to something else.</p>
-
-<p>Backslashing should suppress [this] and [this].</p>
-
-<hr />
-
-<p>Here's one where the <a href="/url/">link
-breaks</a> across lines.</p>
-
-<p>Here's another where the <a href="/url/">link
-breaks</a> across lines, but with a line-ending space.</p>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Links, reference style.text b/tests/MarkdownTest_1.0.3/Tests/Links, reference style.text
deleted file mode 100644
index 341ec88e3..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Links, reference style.text
+++ /dev/null
@@ -1,71 +0,0 @@
-Foo [bar] [1].
-
-Foo [bar][1].
-
-Foo [bar]
-[1].
-
-[1]: /url/ "Title"
-
-
-With [embedded [brackets]] [b].
-
-
-Indented [once][].
-
-Indented [twice][].
-
-Indented [thrice][].
-
-Indented [four][] times.
-
- [once]: /url
-
- [twice]: /url
-
- [thrice]: /url
-
- [four]: /url
-
-
-[b]: /url/
-
-* * *
-
-[this] [this] should work
-
-So should [this][this].
-
-And [this] [].
-
-And [this][].
-
-And [this].
-
-But not [that] [].
-
-Nor [that][].
-
-Nor [that].
-
-[Something in brackets like [this][] should work]
-
-[Same with [this].]
-
-In this case, [this](/somethingelse/) points to something else.
-
-Backslashing should suppress \[this] and [this\].
-
-[this]: foo
-
-
-* * *
-
-Here's one where the [link
-breaks] across lines.
-
-Here's another where the [link
-breaks] across lines, but with a line-ending space.
-
-
-[link breaks]: /url/
diff --git a/tests/MarkdownTest_1.0.3/Tests/Links, shortcut references.html b/tests/MarkdownTest_1.0.3/Tests/Links, shortcut references.html
deleted file mode 100644
index bf81e939f..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Links, shortcut references.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<p>This is the <a href="/simple">simple case</a>.</p>
-
-<p>This one has a <a href="/foo">line
-break</a>.</p>
-
-<p>This one has a <a href="/foo">line
-break</a> with a line-ending space.</p>
-
-<p><a href="/that">this</a> and the <a href="/other">other</a></p>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Links, shortcut references.text b/tests/MarkdownTest_1.0.3/Tests/Links, shortcut references.text
deleted file mode 100644
index 8c44c98fe..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Links, shortcut references.text
+++ /dev/null
@@ -1,20 +0,0 @@
-This is the [simple case].
-
-[simple case]: /simple
-
-
-
-This one has a [line
-break].
-
-This one has a [line
-break] with a line-ending space.
-
-[line break]: /foo
-
-
-[this] [that] and the [other]
-
-[this]: /this
-[that]: /that
-[other]: /other
diff --git a/tests/MarkdownTest_1.0.3/Tests/Literal quotes in titles.html b/tests/MarkdownTest_1.0.3/Tests/Literal quotes in titles.html
deleted file mode 100644
index 611c1ac61..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Literal quotes in titles.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<p>Foo <a href="/url/" title="Title with &quot;quotes&quot; inside">bar</a>.</p>
-
-<p>Foo <a href="/url/" title="Title with &quot;quotes&quot; inside">bar</a>.</p>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Literal quotes in titles.text b/tests/MarkdownTest_1.0.3/Tests/Literal quotes in titles.text
deleted file mode 100644
index 29d0e4235..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Literal quotes in titles.text
+++ /dev/null
@@ -1,7 +0,0 @@
-Foo [bar][].
-
-Foo [bar](/url/ "Title with "quotes" inside").
-
-
- [bar]: /url/ "Title with "quotes" inside"
-
diff --git a/tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.html b/tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.html
deleted file mode 100644
index d5bdbb29a..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.html
+++ /dev/null
@@ -1,314 +0,0 @@
-<h1>Markdown: Basics</h1>
-
-<ul id="ProjectSubmenu">
- <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
- <li><a class="selected" title="Markdown Basics">Basics</a></li>
- <li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li>
- <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
- <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
-</ul>
-
-<h2>Getting the Gist of Markdown's Formatting Syntax</h2>
-
-<p>This page offers a brief overview of what it's like to use Markdown.
-The <a href="/projects/markdown/syntax" title="Markdown Syntax">syntax page</a> provides complete, detailed documentation for
-every feature, but Markdown should be very easy to pick up simply by
-looking at a few examples of it in action. The examples on this page
-are written in a before/after style, showing example syntax and the
-HTML output produced by Markdown.</p>
-
-<p>It's also helpful to simply try Markdown out; the <a href="/projects/markdown/dingus" title="Markdown Dingus">Dingus</a> is a
-web application that allows you type your own Markdown-formatted text
-and translate it to XHTML.</p>
-
-<p><strong>Note:</strong> This document is itself written using Markdown; you
-can <a href="/projects/markdown/basics.text">see the source for it by adding '.text' to the URL</a>.</p>
-
-<h2>Paragraphs, Headers, Blockquotes</h2>
-
-<p>A paragraph is simply one or more consecutive lines of text, separated
-by one or more blank lines. (A blank line is any line that looks like a
-blank line -- a line containing nothing spaces or tabs is considered
-blank.) Normal paragraphs should not be intended with spaces or tabs.</p>
-
-<p>Markdown offers two styles of headers: <em>Setext</em> and <em>atx</em>.
-Setext-style headers for <code>&lt;h1&gt;</code> and <code>&lt;h2&gt;</code> are created by
-"underlining" with equal signs (<code>=</code>) and hyphens (<code>-</code>), respectively.
-To create an atx-style header, you put 1-6 hash marks (<code>#</code>) at the
-beginning of the line -- the number of hashes equals the resulting
-HTML header level.</p>
-
-<p>Blockquotes are indicated using email-style '<code>&gt;</code>' angle brackets.</p>
-
-<p>Markdown:</p>
-
-<pre><code>A First Level Header
-====================
-
-A Second Level Header
----------------------
-
-Now is the time for all good men to come to
-the aid of their country. This is just a
-regular paragraph.
-
-The quick brown fox jumped over the lazy
-dog's back.
-
-### Header 3
-
-&gt; This is a blockquote.
-&gt;
-&gt; This is the second paragraph in the blockquote.
-&gt;
-&gt; ## This is an H2 in a blockquote
-</code></pre>
-
-<p>Output:</p>
-
-<pre><code>&lt;h1&gt;A First Level Header&lt;/h1&gt;
-
-&lt;h2&gt;A Second Level Header&lt;/h2&gt;
-
-&lt;p&gt;Now is the time for all good men to come to
-the aid of their country. This is just a
-regular paragraph.&lt;/p&gt;
-
-&lt;p&gt;The quick brown fox jumped over the lazy
-dog's back.&lt;/p&gt;
-
-&lt;h3&gt;Header 3&lt;/h3&gt;
-
-&lt;blockquote&gt;
- &lt;p&gt;This is a blockquote.&lt;/p&gt;
-
- &lt;p&gt;This is the second paragraph in the blockquote.&lt;/p&gt;
-
- &lt;h2&gt;This is an H2 in a blockquote&lt;/h2&gt;
-&lt;/blockquote&gt;
-</code></pre>
-
-<h3>Phrase Emphasis</h3>
-
-<p>Markdown uses asterisks and underscores to indicate spans of emphasis.</p>
-
-<p>Markdown:</p>
-
-<pre><code>Some of these words *are emphasized*.
-Some of these words _are emphasized also_.
-
-Use two asterisks for **strong emphasis**.
-Or, if you prefer, __use two underscores instead__.
-</code></pre>
-
-<p>Output:</p>
-
-<pre><code>&lt;p&gt;Some of these words &lt;em&gt;are emphasized&lt;/em&gt;.
-Some of these words &lt;em&gt;are emphasized also&lt;/em&gt;.&lt;/p&gt;
-
-&lt;p&gt;Use two asterisks for &lt;strong&gt;strong emphasis&lt;/strong&gt;.
-Or, if you prefer, &lt;strong&gt;use two underscores instead&lt;/strong&gt;.&lt;/p&gt;
-</code></pre>
-
-<h2>Lists</h2>
-
-<p>Unordered (bulleted) lists use asterisks, pluses, and hyphens (<code>*</code>,
-<code>+</code>, and <code>-</code>) as list markers. These three markers are
-interchangable; this:</p>
-
-<pre><code>* Candy.
-* Gum.
-* Booze.
-</code></pre>
-
-<p>this:</p>
-
-<pre><code>+ Candy.
-+ Gum.
-+ Booze.
-</code></pre>
-
-<p>and this:</p>
-
-<pre><code>- Candy.
-- Gum.
-- Booze.
-</code></pre>
-
-<p>all produce the same output:</p>
-
-<pre><code>&lt;ul&gt;
-&lt;li&gt;Candy.&lt;/li&gt;
-&lt;li&gt;Gum.&lt;/li&gt;
-&lt;li&gt;Booze.&lt;/li&gt;
-&lt;/ul&gt;
-</code></pre>
-
-<p>Ordered (numbered) lists use regular numbers, followed by periods, as
-list markers:</p>
-
-<pre><code>1. Red
-2. Green
-3. Blue
-</code></pre>
-
-<p>Output:</p>
-
-<pre><code>&lt;ol&gt;
-&lt;li&gt;Red&lt;/li&gt;
-&lt;li&gt;Green&lt;/li&gt;
-&lt;li&gt;Blue&lt;/li&gt;
-&lt;/ol&gt;
-</code></pre>
-
-<p>If you put blank lines between items, you'll get <code>&lt;p&gt;</code> tags for the
-list item text. You can create multi-paragraph list items by indenting
-the paragraphs by 4 spaces or 1 tab:</p>
-
-<pre><code>* A list item.
-
- With multiple paragraphs.
-
-* Another item in the list.
-</code></pre>
-
-<p>Output:</p>
-
-<pre><code>&lt;ul&gt;
-&lt;li&gt;&lt;p&gt;A list item.&lt;/p&gt;
-&lt;p&gt;With multiple paragraphs.&lt;/p&gt;&lt;/li&gt;
-&lt;li&gt;&lt;p&gt;Another item in the list.&lt;/p&gt;&lt;/li&gt;
-&lt;/ul&gt;
-</code></pre>
-
-<h3>Links</h3>
-
-<p>Markdown supports two styles for creating links: <em>inline</em> and
-<em>reference</em>. With both styles, you use square brackets to delimit the
-text you want to turn into a link.</p>
-
-<p>Inline-style links use parentheses immediately after the link text.
-For example:</p>
-
-<pre><code>This is an [example link](http://example.com/).
-</code></pre>
-
-<p>Output:</p>
-
-<pre><code>&lt;p&gt;This is an &lt;a href="http://example.com/"&gt;
-example link&lt;/a&gt;.&lt;/p&gt;
-</code></pre>
-
-<p>Optionally, you may include a title attribute in the parentheses:</p>
-
-<pre><code>This is an [example link](http://example.com/ "With a Title").
-</code></pre>
-
-<p>Output:</p>
-
-<pre><code>&lt;p&gt;This is an &lt;a href="http://example.com/" title="With a Title"&gt;
-example link&lt;/a&gt;.&lt;/p&gt;
-</code></pre>
-
-<p>Reference-style links allow you to refer to your links by names, which
-you define elsewhere in your document:</p>
-
-<pre><code>I get 10 times more traffic from [Google][1] than from
-[Yahoo][2] or [MSN][3].
-
-[1]: http://google.com/ "Google"
-[2]: http://search.yahoo.com/ "Yahoo Search"
-[3]: http://search.msn.com/ "MSN Search"
-</code></pre>
-
-<p>Output:</p>
-
-<pre><code>&lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
-title="Google"&gt;Google&lt;/a&gt; than from &lt;a href="http://search.yahoo.com/"
-title="Yahoo Search"&gt;Yahoo&lt;/a&gt; or &lt;a href="http://search.msn.com/"
-title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
-</code></pre>
-
-<p>The title attribute is optional. Link names may contain letters,
-numbers and spaces, but are <em>not</em> case sensitive:</p>
-
-<pre><code>I start my morning with a cup of coffee and
-[The New York Times][NY Times].
-
-[ny times]: http://www.nytimes.com/
-</code></pre>
-
-<p>Output:</p>
-
-<pre><code>&lt;p&gt;I start my morning with a cup of coffee and
-&lt;a href="http://www.nytimes.com/"&gt;The New York Times&lt;/a&gt;.&lt;/p&gt;
-</code></pre>
-
-<h3>Images</h3>
-
-<p>Image syntax is very much like link syntax.</p>
-
-<p>Inline (titles are optional):</p>
-
-<pre><code>![alt text](/path/to/img.jpg "Title")
-</code></pre>
-
-<p>Reference-style:</p>
-
-<pre><code>![alt text][id]
-
-[id]: /path/to/img.jpg "Title"
-</code></pre>
-
-<p>Both of the above examples produce the same output:</p>
-
-<pre><code>&lt;img src="/path/to/img.jpg" alt="alt text" title="Title" /&gt;
-</code></pre>
-
-<h3>Code</h3>
-
-<p>In a regular paragraph, you can create code span by wrapping text in
-backtick quotes. Any ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code> or
-<code>&gt;</code>) will automatically be translated into HTML entities. This makes
-it easy to use Markdown to write about HTML example code:</p>
-
-<pre><code>I strongly recommend against using any `&lt;blink&gt;` tags.
-
-I wish SmartyPants used named entities like `&amp;mdash;`
-instead of decimal-encoded entites like `&amp;#8212;`.
-</code></pre>
-
-<p>Output:</p>
-
-<pre><code>&lt;p&gt;I strongly recommend against using any
-&lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
-
-&lt;p&gt;I wish SmartyPants used named entities like
-&lt;code&gt;&amp;amp;mdash;&lt;/code&gt; instead of decimal-encoded
-entites like &lt;code&gt;&amp;amp;#8212;&lt;/code&gt;.&lt;/p&gt;
-</code></pre>
-
-<p>To specify an entire block of pre-formatted code, indent every line of
-the block by 4 spaces or 1 tab. Just like with code spans, <code>&amp;</code>, <code>&lt;</code>,
-and <code>&gt;</code> characters will be escaped automatically.</p>
-
-<p>Markdown:</p>
-
-<pre><code>If you want your page to validate under XHTML 1.0 Strict,
-you've got to put paragraph tags in your blockquotes:
-
- &lt;blockquote&gt;
- &lt;p&gt;For example.&lt;/p&gt;
- &lt;/blockquote&gt;
-</code></pre>
-
-<p>Output:</p>
-
-<pre><code>&lt;p&gt;If you want your page to validate under XHTML 1.0 Strict,
-you've got to put paragraph tags in your blockquotes:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;&amp;lt;blockquote&amp;gt;
- &amp;lt;p&amp;gt;For example.&amp;lt;/p&amp;gt;
-&amp;lt;/blockquote&amp;gt;
-&lt;/code&gt;&lt;/pre&gt;
-</code></pre>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.text b/tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.text
deleted file mode 100644
index 486055ca7..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.text
+++ /dev/null
@@ -1,306 +0,0 @@
-Markdown: Basics
-================
-
-<ul id="ProjectSubmenu">
- <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
- <li><a class="selected" title="Markdown Basics">Basics</a></li>
- <li><a href="/projects/markdown/syntax" title="Markdown Syntax Documentation">Syntax</a></li>
- <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
- <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
-</ul>
-
-
-Getting the Gist of Markdown's Formatting Syntax
-------------------------------------------------
-
-This page offers a brief overview of what it's like to use Markdown.
-The [syntax page] [s] provides complete, detailed documentation for
-every feature, but Markdown should be very easy to pick up simply by
-looking at a few examples of it in action. The examples on this page
-are written in a before/after style, showing example syntax and the
-HTML output produced by Markdown.
-
-It's also helpful to simply try Markdown out; the [Dingus] [d] is a
-web application that allows you type your own Markdown-formatted text
-and translate it to XHTML.
-
-**Note:** This document is itself written using Markdown; you
-can [see the source for it by adding '.text' to the URL] [src].
-
- [s]: /projects/markdown/syntax "Markdown Syntax"
- [d]: /projects/markdown/dingus "Markdown Dingus"
- [src]: /projects/markdown/basics.text
-
-
-## Paragraphs, Headers, Blockquotes ##
-
-A paragraph is simply one or more consecutive lines of text, separated
-by one or more blank lines. (A blank line is any line that looks like a
-blank line -- a line containing nothing spaces or tabs is considered
-blank.) Normal paragraphs should not be intended with spaces or tabs.
-
-Markdown offers two styles of headers: *Setext* and *atx*.
-Setext-style headers for `<h1>` and `<h2>` are created by
-"underlining" with equal signs (`=`) and hyphens (`-`), respectively.
-To create an atx-style header, you put 1-6 hash marks (`#`) at the
-beginning of the line -- the number of hashes equals the resulting
-HTML header level.
-
-Blockquotes are indicated using email-style '`>`' angle brackets.
-
-Markdown:
-
- A First Level Header
- ====================
-
- A Second Level Header
- ---------------------
-
- Now is the time for all good men to come to
- the aid of their country. This is just a
- regular paragraph.
-
- The quick brown fox jumped over the lazy
- dog's back.
-
- ### Header 3
-
- > This is a blockquote.
- >
- > This is the second paragraph in the blockquote.
- >
- > ## This is an H2 in a blockquote
-
-
-Output:
-
- <h1>A First Level Header</h1>
-
- <h2>A Second Level Header</h2>
-
- <p>Now is the time for all good men to come to
- the aid of their country. This is just a
- regular paragraph.</p>
-
- <p>The quick brown fox jumped over the lazy
- dog's back.</p>
-
- <h3>Header 3</h3>
-
- <blockquote>
- <p>This is a blockquote.</p>
-
- <p>This is the second paragraph in the blockquote.</p>
-
- <h2>This is an H2 in a blockquote</h2>
- </blockquote>
-
-
-
-### Phrase Emphasis ###
-
-Markdown uses asterisks and underscores to indicate spans of emphasis.
-
-Markdown:
-
- Some of these words *are emphasized*.
- Some of these words _are emphasized also_.
-
- Use two asterisks for **strong emphasis**.
- Or, if you prefer, __use two underscores instead__.
-
-Output:
-
- <p>Some of these words <em>are emphasized</em>.
- Some of these words <em>are emphasized also</em>.</p>
-
- <p>Use two asterisks for <strong>strong emphasis</strong>.
- Or, if you prefer, <strong>use two underscores instead</strong>.</p>
-
-
-
-## Lists ##
-
-Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,
-`+`, and `-`) as list markers. These three markers are
-interchangable; this:
-
- * Candy.
- * Gum.
- * Booze.
-
-this:
-
- + Candy.
- + Gum.
- + Booze.
-
-and this:
-
- - Candy.
- - Gum.
- - Booze.
-
-all produce the same output:
-
- <ul>
- <li>Candy.</li>
- <li>Gum.</li>
- <li>Booze.</li>
- </ul>
-
-Ordered (numbered) lists use regular numbers, followed by periods, as
-list markers:
-
- 1. Red
- 2. Green
- 3. Blue
-
-Output:
-
- <ol>
- <li>Red</li>
- <li>Green</li>
- <li>Blue</li>
- </ol>
-
-If you put blank lines between items, you'll get `<p>` tags for the
-list item text. You can create multi-paragraph list items by indenting
-the paragraphs by 4 spaces or 1 tab:
-
- * A list item.
-
- With multiple paragraphs.
-
- * Another item in the list.
-
-Output:
-
- <ul>
- <li><p>A list item.</p>
- <p>With multiple paragraphs.</p></li>
- <li><p>Another item in the list.</p></li>
- </ul>
-
-
-
-### Links ###
-
-Markdown supports two styles for creating links: *inline* and
-*reference*. With both styles, you use square brackets to delimit the
-text you want to turn into a link.
-
-Inline-style links use parentheses immediately after the link text.
-For example:
-
- This is an [example link](http://example.com/).
-
-Output:
-
- <p>This is an <a href="http://example.com/">
- example link</a>.</p>
-
-Optionally, you may include a title attribute in the parentheses:
-
- This is an [example link](http://example.com/ "With a Title").
-
-Output:
-
- <p>This is an <a href="http://example.com/" title="With a Title">
- example link</a>.</p>
-
-Reference-style links allow you to refer to your links by names, which
-you define elsewhere in your document:
-
- I get 10 times more traffic from [Google][1] than from
- [Yahoo][2] or [MSN][3].
-
- [1]: http://google.com/ "Google"
- [2]: http://search.yahoo.com/ "Yahoo Search"
- [3]: http://search.msn.com/ "MSN Search"
-
-Output:
-
- <p>I get 10 times more traffic from <a href="http://google.com/"
- title="Google">Google</a> than from <a href="http://search.yahoo.com/"
- title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
- title="MSN Search">MSN</a>.</p>
-
-The title attribute is optional. Link names may contain letters,
-numbers and spaces, but are *not* case sensitive:
-
- I start my morning with a cup of coffee and
- [The New York Times][NY Times].
-
- [ny times]: http://www.nytimes.com/
-
-Output:
-
- <p>I start my morning with a cup of coffee and
- <a href="http://www.nytimes.com/">The New York Times</a>.</p>
-
-
-### Images ###
-
-Image syntax is very much like link syntax.
-
-Inline (titles are optional):
-
- ![alt text](/path/to/img.jpg "Title")
-
-Reference-style:
-
- ![alt text][id]
-
- [id]: /path/to/img.jpg "Title"
-
-Both of the above examples produce the same output:
-
- <img src="/path/to/img.jpg" alt="alt text" title="Title" />
-
-
-
-### Code ###
-
-In a regular paragraph, you can create code span by wrapping text in
-backtick quotes. Any ampersands (`&`) and angle brackets (`<` or
-`>`) will automatically be translated into HTML entities. This makes
-it easy to use Markdown to write about HTML example code:
-
- I strongly recommend against using any `<blink>` tags.
-
- I wish SmartyPants used named entities like `&mdash;`
- instead of decimal-encoded entites like `&#8212;`.
-
-Output:
-
- <p>I strongly recommend against using any
- <code>&lt;blink&gt;</code> tags.</p>
-
- <p>I wish SmartyPants used named entities like
- <code>&amp;mdash;</code> instead of decimal-encoded
- entites like <code>&amp;#8212;</code>.</p>
-
-
-To specify an entire block of pre-formatted code, indent every line of
-the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`,
-and `>` characters will be escaped automatically.
-
-Markdown:
-
- If you want your page to validate under XHTML 1.0 Strict,
- you've got to put paragraph tags in your blockquotes:
-
- <blockquote>
- <p>For example.</p>
- </blockquote>
-
-Output:
-
- <p>If you want your page to validate under XHTML 1.0 Strict,
- you've got to put paragraph tags in your blockquotes:</p>
-
- <pre><code>&lt;blockquote&gt;
- &lt;p&gt;For example.&lt;/p&gt;
- &lt;/blockquote&gt;
- </code></pre>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.html b/tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.html
deleted file mode 100644
index 5c01306cc..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.html
+++ /dev/null
@@ -1,942 +0,0 @@
-<h1>Markdown: Syntax</h1>
-
-<ul id="ProjectSubmenu">
- <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
- <li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li>
- <li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li>
- <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
- <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
-</ul>
-
-<ul>
-<li><a href="#overview">Overview</a>
-<ul>
-<li><a href="#philosophy">Philosophy</a></li>
-<li><a href="#html">Inline HTML</a></li>
-<li><a href="#autoescape">Automatic Escaping for Special Characters</a></li>
-</ul></li>
-<li><a href="#block">Block Elements</a>
-<ul>
-<li><a href="#p">Paragraphs and Line Breaks</a></li>
-<li><a href="#header">Headers</a></li>
-<li><a href="#blockquote">Blockquotes</a></li>
-<li><a href="#list">Lists</a></li>
-<li><a href="#precode">Code Blocks</a></li>
-<li><a href="#hr">Horizontal Rules</a></li>
-</ul></li>
-<li><a href="#span">Span Elements</a>
-<ul>
-<li><a href="#link">Links</a></li>
-<li><a href="#em">Emphasis</a></li>
-<li><a href="#code">Code</a></li>
-<li><a href="#img">Images</a></li>
-</ul></li>
-<li><a href="#misc">Miscellaneous</a>
-<ul>
-<li><a href="#backslash">Backslash Escapes</a></li>
-<li><a href="#autolink">Automatic Links</a></li>
-</ul></li>
-</ul>
-
-<p><strong>Note:</strong> This document is itself written using Markdown; you
-can <a href="/projects/markdown/syntax.text">see the source for it by adding '.text' to the URL</a>.</p>
-
-<hr />
-
-<h2 id="overview">Overview</h2>
-
-<h3 id="philosophy">Philosophy</h3>
-
-<p>Markdown is intended to be as easy-to-read and easy-to-write as is feasible.</p>
-
-<p>Readability, however, is emphasized above all else. 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. While
-Markdown's syntax has been influenced by several existing text-to-HTML
-filters -- including <a href="http://docutils.sourceforge.net/mirror/setext.html">Setext</a>, <a href="http://www.aaronsw.com/2002/atx/">atx</a>, <a href="http://textism.com/tools/textile/">Textile</a>, <a href="http://docutils.sourceforge.net/rst.html">reStructuredText</a>,
-<a href="http://www.triptico.com/software/grutatxt.html">Grutatext</a>, and <a href="http://ettext.taint.org/doc/">EtText</a> -- the single biggest source of
-inspiration for Markdown's syntax is the format of plain text email.</p>
-
-<p>To this end, Markdown's syntax is comprised entirely of punctuation
-characters, which punctuation characters have been carefully chosen so
-as to look like what they mean. E.g., asterisks around a word actually
-look like *emphasis*. Markdown lists look like, well, lists. Even
-blockquotes look like quoted passages of text, assuming you've ever
-used email.</p>
-
-<h3 id="html">Inline HTML</h3>
-
-<p>Markdown's syntax is intended for one purpose: to be used as a
-format for <em>writing</em> for the web.</p>
-
-<p>Markdown is not a replacement for HTML, or even close to it. Its
-syntax is very small, corresponding only to a very small subset of
-HTML tags. The idea is <em>not</em> to create a syntax that makes it easier
-to insert HTML tags. In my opinion, HTML tags are already easy to
-insert. The idea for Markdown is to make it easy to read, write, and
-edit prose. HTML is a <em>publishing</em> format; Markdown is a <em>writing</em>
-format. Thus, Markdown's formatting syntax only addresses issues that
-can be conveyed in plain text.</p>
-
-<p>For any markup that is not covered by Markdown's syntax, you simply
-use HTML itself. There's no need to preface it or delimit it to
-indicate that you're switching from Markdown to HTML; you just use
-the tags.</p>
-
-<p>The only restrictions are that block-level HTML elements -- e.g. <code>&lt;div&gt;</code>,
-<code>&lt;table&gt;</code>, <code>&lt;pre&gt;</code>, <code>&lt;p&gt;</code>, etc. -- must be separated from surrounding
-content by blank lines, and the start and end tags of the block should
-not be indented with tabs or spaces. Markdown is smart enough not
-to add extra (unwanted) <code>&lt;p&gt;</code> tags around HTML block-level tags.</p>
-
-<p>For example, to add an HTML table to a Markdown article:</p>
-
-<pre><code>This is a regular paragraph.
-
-&lt;table&gt;
- &lt;tr&gt;
- &lt;td&gt;Foo&lt;/td&gt;
- &lt;/tr&gt;
-&lt;/table&gt;
-
-This is another regular paragraph.
-</code></pre>
-
-<p>Note that Markdown formatting syntax is not processed within block-level
-HTML tags. E.g., you can't use Markdown-style <code>*emphasis*</code> inside an
-HTML block.</p>
-
-<p>Span-level HTML tags -- e.g. <code>&lt;span&gt;</code>, <code>&lt;cite&gt;</code>, or <code>&lt;del&gt;</code> -- can be
-used anywhere in a Markdown paragraph, list item, or header. If you
-want, you can even use HTML tags instead of Markdown formatting; e.g. if
-you'd prefer to use HTML <code>&lt;a&gt;</code> or <code>&lt;img&gt;</code> tags instead of Markdown's
-link or image syntax, go right ahead.</p>
-
-<p>Unlike block-level HTML tags, Markdown syntax <em>is</em> processed within
-span-level tags.</p>
-
-<h3 id="autoescape">Automatic Escaping for Special Characters</h3>
-
-<p>In HTML, there are two characters that demand special treatment: <code>&lt;</code>
-and <code>&amp;</code>. Left angle brackets are used to start tags; ampersands are
-used to denote HTML entities. If you want to use them as literal
-characters, you must escape them as entities, e.g. <code>&amp;lt;</code>, and
-<code>&amp;amp;</code>.</p>
-
-<p>Ampersands in particular are bedeviling for web writers. If you want to
-write about 'AT&amp;T', you need to write '<code>AT&amp;amp;T</code>'. You even need to
-escape ampersands within URLs. Thus, if you want to link to:</p>
-
-<pre><code>http://images.google.com/images?num=30&amp;q=larry+bird
-</code></pre>
-
-<p>you need to encode the URL as:</p>
-
-<pre><code>http://images.google.com/images?num=30&amp;amp;q=larry+bird
-</code></pre>
-
-<p>in your anchor tag <code>href</code> attribute. Needless to say, this is easy to
-forget, and is probably the single most common source of HTML validation
-errors in otherwise well-marked-up web sites.</p>
-
-<p>Markdown allows you to use these characters naturally, taking care of
-all the necessary escaping for you. If you use an ampersand as part of
-an HTML entity, it remains unchanged; otherwise it will be translated
-into <code>&amp;amp;</code>.</p>
-
-<p>So, if you want to include a copyright symbol in your article, you can write:</p>
-
-<pre><code>&amp;copy;
-</code></pre>
-
-<p>and Markdown will leave it alone. But if you write:</p>
-
-<pre><code>AT&amp;T
-</code></pre>
-
-<p>Markdown will translate it to:</p>
-
-<pre><code>AT&amp;amp;T
-</code></pre>
-
-<p>Similarly, because Markdown supports <a href="#html">inline HTML</a>, if you use
-angle brackets as delimiters for HTML tags, Markdown will treat them as
-such. But if you write:</p>
-
-<pre><code>4 &lt; 5
-</code></pre>
-
-<p>Markdown will translate it to:</p>
-
-<pre><code>4 &amp;lt; 5
-</code></pre>
-
-<p>However, inside Markdown code spans and blocks, angle brackets and
-ampersands are <em>always</em> encoded automatically. This makes it easy to use
-Markdown to write about HTML code. (As opposed to raw HTML, which is a
-terrible format for writing about HTML syntax, because every single <code>&lt;</code>
-and <code>&amp;</code> in your example code needs to be escaped.)</p>
-
-<hr />
-
-<h2 id="block">Block Elements</h2>
-
-<h3 id="p">Paragraphs and Line Breaks</h3>
-
-<p>A paragraph is simply one or more consecutive lines of text, separated
-by one or more blank lines. (A blank line is any line that looks like a
-blank line -- a line containing nothing but spaces or tabs is considered
-blank.) Normal paragraphs should not be intended with spaces or tabs.</p>
-
-<p>The implication of the "one or more consecutive lines of text" rule is
-that Markdown supports "hard-wrapped" text paragraphs. This differs
-significantly from most other text-to-HTML formatters (including Movable
-Type's "Convert Line Breaks" option) which translate every line break
-character in a paragraph into a <code>&lt;br /&gt;</code> tag.</p>
-
-<p>When you <em>do</em> want to insert a <code>&lt;br /&gt;</code> break tag using Markdown, you
-end a line with two or more spaces, then type return.</p>
-
-<p>Yes, this takes a tad more effort to create a <code>&lt;br /&gt;</code>, but a simplistic
-"every line break is a <code>&lt;br /&gt;</code>" rule wouldn't work for Markdown.
-Markdown's email-style <a href="#blockquote">blockquoting</a> and multi-paragraph <a href="#list">list items</a>
-work best -- and look better -- when you format them with hard breaks.</p>
-
-<h3 id="header">Headers</h3>
-
-<p>Markdown supports two styles of headers, <a href="http://docutils.sourceforge.net/mirror/setext.html">Setext</a> and <a href="http://www.aaronsw.com/2002/atx/">atx</a>.</p>
-
-<p>Setext-style headers are "underlined" using equal signs (for first-level
-headers) and dashes (for second-level headers). For example:</p>
-
-<pre><code>This is an H1
-=============
-
-This is an H2
--------------
-</code></pre>
-
-<p>Any number of underlining <code>=</code>'s or <code>-</code>'s will work.</p>
-
-<p>Atx-style headers use 1-6 hash characters at the start of the line,
-corresponding to header levels 1-6. For example:</p>
-
-<pre><code># This is an H1
-
-## This is an H2
-
-###### This is an H6
-</code></pre>
-
-<p>Optionally, you may "close" atx-style headers. This is purely
-cosmetic -- you can use this if you think it looks better. The
-closing hashes don't even need to match the number of hashes
-used to open the header. (The number of opening hashes
-determines the header level.) :</p>
-
-<pre><code># This is an H1 #
-
-## This is an H2 ##
-
-### This is an H3 ######
-</code></pre>
-
-<h3 id="blockquote">Blockquotes</h3>
-
-<p>Markdown uses email-style <code>&gt;</code> characters for blockquoting. If you're
-familiar with quoting passages of text in an email message, then you
-know how to create a blockquote in Markdown. It looks best if you hard
-wrap the text and put a <code>&gt;</code> before every line:</p>
-
-<pre><code>&gt; This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
-&gt; consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
-&gt; Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
-&gt;
-&gt; Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
-&gt; id sem consectetuer libero luctus adipiscing.
-</code></pre>
-
-<p>Markdown allows you to be lazy and only put the <code>&gt;</code> before the first
-line of a hard-wrapped paragraph:</p>
-
-<pre><code>&gt; This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
-consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
-Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
-
-&gt; Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
-id sem consectetuer libero luctus adipiscing.
-</code></pre>
-
-<p>Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
-adding additional levels of <code>&gt;</code>:</p>
-
-<pre><code>&gt; This is the first level of quoting.
-&gt;
-&gt; &gt; This is nested blockquote.
-&gt;
-&gt; Back to the first level.
-</code></pre>
-
-<p>Blockquotes can contain other Markdown elements, including headers, lists,
-and code blocks:</p>
-
-<pre><code>&gt; ## This is a header.
-&gt;
-&gt; 1. This is the first list item.
-&gt; 2. This is the second list item.
-&gt;
-&gt; Here's some example code:
-&gt;
-&gt; return shell_exec("echo $input | $markdown_script");
-</code></pre>
-
-<p>Any decent text editor should make email-style quoting easy. For
-example, with BBEdit, you can make a selection and choose Increase
-Quote Level from the Text menu.</p>
-
-<h3 id="list">Lists</h3>
-
-<p>Markdown supports ordered (numbered) and unordered (bulleted) lists.</p>
-
-<p>Unordered lists use asterisks, pluses, and hyphens -- interchangably
--- as list markers:</p>
-
-<pre><code>* Red
-* Green
-* Blue
-</code></pre>
-
-<p>is equivalent to:</p>
-
-<pre><code>+ Red
-+ Green
-+ Blue
-</code></pre>
-
-<p>and:</p>
-
-<pre><code>- Red
-- Green
-- Blue
-</code></pre>
-
-<p>Ordered lists use numbers followed by periods:</p>
-
-<pre><code>1. Bird
-2. McHale
-3. Parish
-</code></pre>
-
-<p>It's important to note that the actual numbers you use to mark the
-list have no effect on the HTML output Markdown produces. The HTML
-Markdown produces from the above list is:</p>
-
-<pre><code>&lt;ol&gt;
-&lt;li&gt;Bird&lt;/li&gt;
-&lt;li&gt;McHale&lt;/li&gt;
-&lt;li&gt;Parish&lt;/li&gt;
-&lt;/ol&gt;
-</code></pre>
-
-<p>If you instead wrote the list in Markdown like this:</p>
-
-<pre><code>1. Bird
-1. McHale
-1. Parish
-</code></pre>
-
-<p>or even:</p>
-
-<pre><code>3. Bird
-1. McHale
-8. Parish
-</code></pre>
-
-<p>you'd get the exact same HTML output. The point is, if you want to,
-you can use ordinal numbers in your ordered Markdown lists, so that
-the numbers in your source match the numbers in your published HTML.
-But if you want to be lazy, you don't have to.</p>
-
-<p>If you do use lazy list numbering, however, you should still start the
-list with the number 1. At some point in the future, Markdown may support
-starting ordered lists at an arbitrary number.</p>
-
-<p>List markers typically start at the left margin, but may be indented by
-up to three spaces. List markers must be followed by one or more spaces
-or a tab.</p>
-
-<p>To make lists look nice, you can wrap items with hanging indents:</p>
-
-<pre><code>* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
- Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
- viverra nec, fringilla in, laoreet vitae, risus.
-* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
- Suspendisse id sem consectetuer libero luctus adipiscing.
-</code></pre>
-
-<p>But if you want to be lazy, you don't have to:</p>
-
-<pre><code>* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
-Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
-viverra nec, fringilla in, laoreet vitae, risus.
-* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
-Suspendisse id sem consectetuer libero luctus adipiscing.
-</code></pre>
-
-<p>If list items are separated by blank lines, Markdown will wrap the
-items in <code>&lt;p&gt;</code> tags in the HTML output. For example, this input:</p>
-
-<pre><code>* Bird
-* Magic
-</code></pre>
-
-<p>will turn into:</p>
-
-<pre><code>&lt;ul&gt;
-&lt;li&gt;Bird&lt;/li&gt;
-&lt;li&gt;Magic&lt;/li&gt;
-&lt;/ul&gt;
-</code></pre>
-
-<p>But this:</p>
-
-<pre><code>* Bird
-
-* Magic
-</code></pre>
-
-<p>will turn into:</p>
-
-<pre><code>&lt;ul&gt;
-&lt;li&gt;&lt;p&gt;Bird&lt;/p&gt;&lt;/li&gt;
-&lt;li&gt;&lt;p&gt;Magic&lt;/p&gt;&lt;/li&gt;
-&lt;/ul&gt;
-</code></pre>
-
-<p>List items may consist of multiple paragraphs. Each subsequent
-paragraph in a list item must be intended by either 4 spaces
-or one tab:</p>
-
-<pre><code>1. This is a list item with two paragraphs. Lorem ipsum dolor
- sit amet, consectetuer adipiscing elit. Aliquam hendrerit
- mi posuere lectus.
-
- Vestibulum enim wisi, viverra nec, fringilla in, laoreet
- vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
- sit amet velit.
-
-2. Suspendisse id sem consectetuer libero luctus adipiscing.
-</code></pre>
-
-<p>It looks nice if you indent every line of the subsequent
-paragraphs, but here again, Markdown will allow you to be
-lazy:</p>
-
-<pre><code>* This is a list item with two paragraphs.
-
- This is the second paragraph in the list item. You're
-only required to indent the first line. Lorem ipsum dolor
-sit amet, consectetuer adipiscing elit.
-
-* Another item in the same list.
-</code></pre>
-
-<p>To put a blockquote within a list item, the blockquote's <code>&gt;</code>
-delimiters need to be indented:</p>
-
-<pre><code>* A list item with a blockquote:
-
- &gt; This is a blockquote
- &gt; inside a list item.
-</code></pre>
-
-<p>To put a code block within a list item, the code block needs
-to be indented <em>twice</em> -- 8 spaces or two tabs:</p>
-
-<pre><code>* A list item with a code block:
-
- &lt;code goes here&gt;
-</code></pre>
-
-<p>It's worth noting that it's possible to trigger an ordered list by
-accident, by writing something like this:</p>
-
-<pre><code>1986. What a great season.
-</code></pre>
-
-<p>In other words, a <em>number-period-space</em> sequence at the beginning of a
-line. To avoid this, you can backslash-escape the period:</p>
-
-<pre><code>1986\. What a great season.
-</code></pre>
-
-<h3 id="precode">Code Blocks</h3>
-
-<p>Pre-formatted code blocks are used for writing about programming or
-markup source code. Rather than forming normal paragraphs, the lines
-of a code block are interpreted literally. Markdown wraps a code block
-in both <code>&lt;pre&gt;</code> and <code>&lt;code&gt;</code> tags.</p>
-
-<p>To produce a code block in Markdown, simply indent every line of the
-block by at least 4 spaces or 1 tab. For example, given this input:</p>
-
-<pre><code>This is a normal paragraph:
-
- This is a code block.
-</code></pre>
-
-<p>Markdown will generate:</p>
-
-<pre><code>&lt;p&gt;This is a normal paragraph:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;This is a code block.
-&lt;/code&gt;&lt;/pre&gt;
-</code></pre>
-
-<p>One level of indentation -- 4 spaces or 1 tab -- is removed from each
-line of the code block. For example, this:</p>
-
-<pre><code>Here is an example of AppleScript:
-
- tell application "Foo"
- beep
- end tell
-</code></pre>
-
-<p>will turn into:</p>
-
-<pre><code>&lt;p&gt;Here is an example of AppleScript:&lt;/p&gt;
-
-&lt;pre&gt;&lt;code&gt;tell application "Foo"
- beep
-end tell
-&lt;/code&gt;&lt;/pre&gt;
-</code></pre>
-
-<p>A code block continues until it reaches a line that is not indented
-(or the end of the article).</p>
-
-<p>Within a code block, ampersands (<code>&amp;</code>) and angle brackets (<code>&lt;</code> and <code>&gt;</code>)
-are automatically converted into HTML entities. This makes it very
-easy to include example HTML source code using Markdown -- just paste
-it and indent it, and Markdown will handle the hassle of encoding the
-ampersands and angle brackets. For example, this:</p>
-
-<pre><code> &lt;div class="footer"&gt;
- &amp;copy; 2004 Foo Corporation
- &lt;/div&gt;
-</code></pre>
-
-<p>will turn into:</p>
-
-<pre><code>&lt;pre&gt;&lt;code&gt;&amp;lt;div class="footer"&amp;gt;
- &amp;amp;copy; 2004 Foo Corporation
-&amp;lt;/div&amp;gt;
-&lt;/code&gt;&lt;/pre&gt;
-</code></pre>
-
-<p>Regular Markdown syntax is not processed within code blocks. E.g.,
-asterisks are just literal asterisks within a code block. This means
-it's also easy to use Markdown to write about Markdown's own syntax.</p>
-
-<h3 id="hr">Horizontal Rules</h3>
-
-<p>You can produce a horizontal rule tag (<code>&lt;hr /&gt;</code>) by placing three or
-more hyphens, asterisks, or underscores on a line by themselves. If you
-wish, you may use spaces between the hyphens or asterisks. Each of the
-following lines will produce a horizontal rule:</p>
-
-<pre><code>* * *
-
-***
-
-*****
-
-- - -
-
----------------------------------------
-
-_ _ _
-</code></pre>
-
-<hr />
-
-<h2 id="span">Span Elements</h2>
-
-<h3 id="link">Links</h3>
-
-<p>Markdown supports two style of links: <em>inline</em> and <em>reference</em>.</p>
-
-<p>In both styles, the link text is delimited by [square brackets].</p>
-
-<p>To create an inline link, use a set of regular parentheses immediately
-after the link text's closing square bracket. Inside the parentheses,
-put the URL where you want the link to point, along with an <em>optional</em>
-title for the link, surrounded in quotes. For example:</p>
-
-<pre><code>This is [an example](http://example.com/ "Title") inline link.
-
-[This link](http://example.net/) has no title attribute.
-</code></pre>
-
-<p>Will produce:</p>
-
-<pre><code>&lt;p&gt;This is &lt;a href="http://example.com/" title="Title"&gt;
-an example&lt;/a&gt; inline link.&lt;/p&gt;
-
-&lt;p&gt;&lt;a href="http://example.net/"&gt;This link&lt;/a&gt; has no
-title attribute.&lt;/p&gt;
-</code></pre>
-
-<p>If you're referring to a local resource on the same server, you can
-use relative paths:</p>
-
-<pre><code>See my [About](/about/) page for details.
-</code></pre>
-
-<p>Reference-style links use a second set of square brackets, inside
-which you place a label of your choosing to identify the link:</p>
-
-<pre><code>This is [an example][id] reference-style link.
-</code></pre>
-
-<p>You can optionally use a space to separate the sets of brackets:</p>
-
-<pre><code>This is [an example] [id] reference-style link.
-</code></pre>
-
-<p>Then, anywhere in the document, you define your link label like this,
-on a line by itself:</p>
-
-<pre><code>[id]: http://example.com/ "Optional Title Here"
-</code></pre>
-
-<p>That is:</p>
-
-<ul>
-<li>Square brackets containing the link identifier (optionally
-indented from the left margin using up to three spaces);</li>
-<li>followed by a colon;</li>
-<li>followed by one or more spaces (or tabs);</li>
-<li>followed by the URL for the link;</li>
-<li>optionally followed by a title attribute for the link, enclosed
-in double or single quotes.</li>
-</ul>
-
-<p>The link URL may, optionally, be surrounded by angle brackets:</p>
-
-<pre><code>[id]: &lt;http://example.com/&gt; "Optional Title Here"
-</code></pre>
-
-<p>You can put the title attribute on the next line and use extra spaces
-or tabs for padding, which tends to look better with longer URLs:</p>
-
-<pre><code>[id]: http://example.com/longish/path/to/resource/here
- "Optional Title Here"
-</code></pre>
-
-<p>Link definitions are only used for creating links during Markdown
-processing, and are stripped from your document in the HTML output.</p>
-
-<p>Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are <em>not</em> case sensitive. E.g. these two links:</p>
-
-<pre><code>[link text][a]
-[link text][A]
-</code></pre>
-
-<p>are equivalent.</p>
-
-<p>The <em>implicit link name</em> shortcut allows you to omit the name of the
-link, in which case the link text itself is used as the name.
-Just use an empty set of square brackets -- e.g., to link the word
-"Google" to the google.com web site, you could simply write:</p>
-
-<pre><code>[Google][]
-</code></pre>
-
-<p>And then define the link:</p>
-
-<pre><code>[Google]: http://google.com/
-</code></pre>
-
-<p>Because link names may contain spaces, this shortcut even works for
-multiple words in the link text:</p>
-
-<pre><code>Visit [Daring Fireball][] for more information.
-</code></pre>
-
-<p>And then define the link:</p>
-
-<pre><code>[Daring Fireball]: http://daringfireball.net/
-</code></pre>
-
-<p>Link definitions can be placed anywhere in your Markdown document. I
-tend to put them immediately after each paragraph in which they're
-used, but if you want, you can put them all at the end of your
-document, sort of like footnotes.</p>
-
-<p>Here's an example of reference links in action:</p>
-
-<pre><code>I get 10 times more traffic from [Google] [1] than from
-[Yahoo] [2] or [MSN] [3].
-
- [1]: http://google.com/ "Google"
- [2]: http://search.yahoo.com/ "Yahoo Search"
- [3]: http://search.msn.com/ "MSN Search"
-</code></pre>
-
-<p>Using the implicit link name shortcut, you could instead write:</p>
-
-<pre><code>I get 10 times more traffic from [Google][] than from
-[Yahoo][] or [MSN][].
-
- [google]: http://google.com/ "Google"
- [yahoo]: http://search.yahoo.com/ "Yahoo Search"
- [msn]: http://search.msn.com/ "MSN Search"
-</code></pre>
-
-<p>Both of the above examples will produce the following HTML output:</p>
-
-<pre><code>&lt;p&gt;I get 10 times more traffic from &lt;a href="http://google.com/"
-title="Google"&gt;Google&lt;/a&gt; than from
-&lt;a href="http://search.yahoo.com/" title="Yahoo Search"&gt;Yahoo&lt;/a&gt;
-or &lt;a href="http://search.msn.com/" title="MSN Search"&gt;MSN&lt;/a&gt;.&lt;/p&gt;
-</code></pre>
-
-<p>For comparison, here is the same paragraph written using
-Markdown's inline link style:</p>
-
-<pre><code>I get 10 times more traffic from [Google](http://google.com/ "Google")
-than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
-[MSN](http://search.msn.com/ "MSN Search").
-</code></pre>
-
-<p>The point of reference-style links is not that they're easier to
-write. The point is that with reference-style links, your document
-source is vastly more readable. Compare the above examples: using
-reference-style links, the paragraph itself is only 81 characters
-long; with inline-style links, it's 176 characters; and as raw HTML,
-it's 234 characters. In the raw HTML, there's more markup than there
-is text.</p>
-
-<p>With Markdown's reference-style links, a source document much more
-closely resembles the final output, as rendered in a browser. By
-allowing you to move the markup-related metadata out of the paragraph,
-you can add links without interrupting the narrative flow of your
-prose.</p>
-
-<h3 id="em">Emphasis</h3>
-
-<p>Markdown treats asterisks (<code>*</code>) and underscores (<code>_</code>) as indicators of
-emphasis. Text wrapped with one <code>*</code> or <code>_</code> will be wrapped with an
-HTML <code>&lt;em&gt;</code> tag; double <code>*</code>'s or <code>_</code>'s will be wrapped with an HTML
-<code>&lt;strong&gt;</code> tag. E.g., this input:</p>
-
-<pre><code>*single asterisks*
-
-_single underscores_
-
-**double asterisks**
-
-__double underscores__
-</code></pre>
-
-<p>will produce:</p>
-
-<pre><code>&lt;em&gt;single asterisks&lt;/em&gt;
-
-&lt;em&gt;single underscores&lt;/em&gt;
-
-&lt;strong&gt;double asterisks&lt;/strong&gt;
-
-&lt;strong&gt;double underscores&lt;/strong&gt;
-</code></pre>
-
-<p>You can use whichever style you prefer; the lone restriction is that
-the same character must be used to open and close an emphasis span.</p>
-
-<p>Emphasis can be used in the middle of a word:</p>
-
-<pre><code>un*fucking*believable
-</code></pre>
-
-<p>But if you surround an <code>*</code> or <code>_</code> with spaces, it'll be treated as a
-literal asterisk or underscore.</p>
-
-<p>To produce a literal asterisk or underscore at a position where it
-would otherwise be used as an emphasis delimiter, you can backslash
-escape it:</p>
-
-<pre><code>\*this text is surrounded by literal asterisks\*
-</code></pre>
-
-<h3 id="code">Code</h3>
-
-<p>To indicate a span of code, wrap it with backtick quotes (<code>`</code>).
-Unlike a pre-formatted code block, a code span indicates code within a
-normal paragraph. For example:</p>
-
-<pre><code>Use the `printf()` function.
-</code></pre>
-
-<p>will produce:</p>
-
-<pre><code>&lt;p&gt;Use the &lt;code&gt;printf()&lt;/code&gt; function.&lt;/p&gt;
-</code></pre>
-
-<p>To include a literal backtick character within a code span, you can use
-multiple backticks as the opening and closing delimiters:</p>
-
-<pre><code>``There is a literal backtick (`) here.``
-</code></pre>
-
-<p>which will produce this:</p>
-
-<pre><code>&lt;p&gt;&lt;code&gt;There is a literal backtick (`) here.&lt;/code&gt;&lt;/p&gt;
-</code></pre>
-
-<p>The backtick delimiters surrounding a code span may include spaces --
-one after the opening, one before the closing. This allows you to place
-literal backtick characters at the beginning or end of a code span:</p>
-
-<pre><code>A single backtick in a code span: `` ` ``
-
-A backtick-delimited string in a code span: `` `foo` ``
-</code></pre>
-
-<p>will produce:</p>
-
-<pre><code>&lt;p&gt;A single backtick in a code span: &lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
-
-&lt;p&gt;A backtick-delimited string in a code span: &lt;code&gt;`foo`&lt;/code&gt;&lt;/p&gt;
-</code></pre>
-
-<p>With a code span, ampersands and angle brackets are encoded as HTML
-entities automatically, which makes it easy to include example HTML
-tags. Markdown will turn this:</p>
-
-<pre><code>Please don't use any `&lt;blink&gt;` tags.
-</code></pre>
-
-<p>into:</p>
-
-<pre><code>&lt;p&gt;Please don't use any &lt;code&gt;&amp;lt;blink&amp;gt;&lt;/code&gt; tags.&lt;/p&gt;
-</code></pre>
-
-<p>You can write this:</p>
-
-<pre><code>`&amp;#8212;` is the decimal-encoded equivalent of `&amp;mdash;`.
-</code></pre>
-
-<p>to produce:</p>
-
-<pre><code>&lt;p&gt;&lt;code&gt;&amp;amp;#8212;&lt;/code&gt; is the decimal-encoded
-equivalent of &lt;code&gt;&amp;amp;mdash;&lt;/code&gt;.&lt;/p&gt;
-</code></pre>
-
-<h3 id="img">Images</h3>
-
-<p>Admittedly, it's fairly difficult to devise a "natural" syntax for
-placing images into a plain text document format.</p>
-
-<p>Markdown uses an image syntax that is intended to resemble the syntax
-for links, allowing for two styles: <em>inline</em> and <em>reference</em>.</p>
-
-<p>Inline image syntax looks like this:</p>
-
-<pre><code>![Alt text](/path/to/img.jpg)
-
-![Alt text](/path/to/img.jpg "Optional title")
-</code></pre>
-
-<p>That is:</p>
-
-<ul>
-<li>An exclamation mark: <code>!</code>;</li>
-<li>followed by a set of square brackets, containing the <code>alt</code>
-attribute text for the image;</li>
-<li>followed by a set of parentheses, containing the URL or path to
-the image, and an optional <code>title</code> attribute enclosed in double
-or single quotes.</li>
-</ul>
-
-<p>Reference-style image syntax looks like this:</p>
-
-<pre><code>![Alt text][id]
-</code></pre>
-
-<p>Where "id" is the name of a defined image reference. Image references
-are defined using syntax identical to link references:</p>
-
-<pre><code>[id]: url/to/image "Optional title attribute"
-</code></pre>
-
-<p>As of this writing, Markdown has no syntax for specifying the
-dimensions of an image; if this is important to you, you can simply
-use regular HTML <code>&lt;img&gt;</code> tags.</p>
-
-<hr />
-
-<h2 id="misc">Miscellaneous</h2>
-
-<h3 id="autolink">Automatic Links</h3>
-
-<p>Markdown supports a shortcut style for creating "automatic" links for URLs and email addresses: simply surround the URL or email address with angle brackets. What this means is that if you want to show the actual text of a URL or email address, and also have it be a clickable link, you can do this:</p>
-
-<pre><code>&lt;http://example.com/&gt;
-</code></pre>
-
-<p>Markdown will turn this into:</p>
-
-<pre><code>&lt;a href="http://example.com/"&gt;http://example.com/&lt;/a&gt;
-</code></pre>
-
-<p>Automatic links for email addresses work similarly, except that
-Markdown will also perform a bit of randomized decimal and hex
-entity-encoding to help obscure your address from address-harvesting
-spambots. For example, Markdown will turn this:</p>
-
-<pre><code>&lt;address@example.com&gt;
-</code></pre>
-
-<p>into something like this:</p>
-
-<pre><code>&lt;a href="&amp;#x6D;&amp;#x61;i&amp;#x6C;&amp;#x74;&amp;#x6F;:&amp;#x61;&amp;#x64;&amp;#x64;&amp;#x72;&amp;#x65;
-&amp;#115;&amp;#115;&amp;#64;&amp;#101;&amp;#120;&amp;#x61;&amp;#109;&amp;#x70;&amp;#x6C;e&amp;#x2E;&amp;#99;&amp;#111;
-&amp;#109;"&gt;&amp;#x61;&amp;#x64;&amp;#x64;&amp;#x72;&amp;#x65;&amp;#115;&amp;#115;&amp;#64;&amp;#101;&amp;#120;&amp;#x61;
-&amp;#109;&amp;#x70;&amp;#x6C;e&amp;#x2E;&amp;#99;&amp;#111;&amp;#109;&lt;/a&gt;
-</code></pre>
-
-<p>which will render in a browser as a clickable link to "address@example.com".</p>
-
-<p>(This sort of entity-encoding trick will indeed fool many, if not
-most, address-harvesting bots, but it definitely won't fool all of
-them. It's better than nothing, but an address published in this way
-will probably eventually start receiving spam.)</p>
-
-<h3 id="backslash">Backslash Escapes</h3>
-
-<p>Markdown allows you to use backslash escapes to generate literal
-characters which would otherwise have special meaning in Markdown's
-formatting syntax. For example, if you wanted to surround a word with
-literal asterisks (instead of an HTML <code>&lt;em&gt;</code> tag), you can backslashes
-before the asterisks, like this:</p>
-
-<pre><code>\*literal asterisks\*
-</code></pre>
-
-<p>Markdown provides backslash escapes for the following characters:</p>
-
-<pre><code>\ backslash
-` backtick
-* asterisk
-_ underscore
-{} curly braces
-[] square brackets
-() parentheses
-# hash mark
-+ plus sign
-- minus sign (hyphen)
-. dot
-! exclamation mark
-</code></pre>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.text b/tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.text
deleted file mode 100644
index 57360a16c..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.text
+++ /dev/null
@@ -1,888 +0,0 @@
-Markdown: Syntax
-================
-
-<ul id="ProjectSubmenu">
- <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
- <li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li>
- <li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li>
- <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
- <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
-</ul>
-
-
-* [Overview](#overview)
- * [Philosophy](#philosophy)
- * [Inline HTML](#html)
- * [Automatic Escaping for Special Characters](#autoescape)
-* [Block Elements](#block)
- * [Paragraphs and Line Breaks](#p)
- * [Headers](#header)
- * [Blockquotes](#blockquote)
- * [Lists](#list)
- * [Code Blocks](#precode)
- * [Horizontal Rules](#hr)
-* [Span Elements](#span)
- * [Links](#link)
- * [Emphasis](#em)
- * [Code](#code)
- * [Images](#img)
-* [Miscellaneous](#misc)
- * [Backslash Escapes](#backslash)
- * [Automatic Links](#autolink)
-
-
-**Note:** This document is itself written using Markdown; you
-can [see the source for it by adding '.text' to the URL][src].
-
- [src]: /projects/markdown/syntax.text
-
-* * *
-
-<h2 id="overview">Overview</h2>
-
-<h3 id="philosophy">Philosophy</h3>
-
-Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
-
-Readability, however, is emphasized above all else. 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. While
-Markdown's syntax has been influenced by several existing text-to-HTML
-filters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4],
-[Grutatext] [5], and [EtText] [6] -- the single biggest source of
-inspiration for Markdown's syntax is the format of plain text email.
-
- [1]: http://docutils.sourceforge.net/mirror/setext.html
- [2]: http://www.aaronsw.com/2002/atx/
- [3]: http://textism.com/tools/textile/
- [4]: http://docutils.sourceforge.net/rst.html
- [5]: http://www.triptico.com/software/grutatxt.html
- [6]: http://ettext.taint.org/doc/
-
-To this end, Markdown's syntax is comprised entirely of punctuation
-characters, which punctuation characters have been carefully chosen so
-as to look like what they mean. E.g., asterisks around a word actually
-look like \*emphasis\*. Markdown lists look like, well, lists. Even
-blockquotes look like quoted passages of text, assuming you've ever
-used email.
-
-
-
-<h3 id="html">Inline HTML</h3>
-
-Markdown's syntax is intended for one purpose: to be used as a
-format for *writing* for the web.
-
-Markdown is not a replacement for HTML, or even close to it. Its
-syntax is very small, corresponding only to a very small subset of
-HTML tags. The idea is *not* to create a syntax that makes it easier
-to insert HTML tags. In my opinion, HTML tags are already easy to
-insert. The idea for Markdown is to make it easy to read, write, and
-edit prose. HTML is a *publishing* format; Markdown is a *writing*
-format. Thus, Markdown's formatting syntax only addresses issues that
-can be conveyed in plain text.
-
-For any markup that is not covered by Markdown's syntax, you simply
-use HTML itself. There's no need to preface it or delimit it to
-indicate that you're switching from Markdown to HTML; you just use
-the tags.
-
-The only restrictions are that block-level HTML elements -- e.g. `<div>`,
-`<table>`, `<pre>`, `<p>`, etc. -- must be separated from surrounding
-content by blank lines, and the start and end tags of the block should
-not be indented with tabs or spaces. Markdown is smart enough not
-to add extra (unwanted) `<p>` tags around HTML block-level tags.
-
-For example, to add an HTML table to a Markdown article:
-
- This is a regular paragraph.
-
- <table>
- <tr>
- <td>Foo</td>
- </tr>
- </table>
-
- This is another regular paragraph.
-
-Note that Markdown formatting syntax is not processed within block-level
-HTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an
-HTML block.
-
-Span-level HTML tags -- e.g. `<span>`, `<cite>`, or `<del>` -- can be
-used anywhere in a Markdown paragraph, list item, or header. If you
-want, you can even use HTML tags instead of Markdown formatting; e.g. if
-you'd prefer to use HTML `<a>` or `<img>` tags instead of Markdown's
-link or image syntax, go right ahead.
-
-Unlike block-level HTML tags, Markdown syntax *is* processed within
-span-level tags.
-
-
-<h3 id="autoescape">Automatic Escaping for Special Characters</h3>
-
-In HTML, there are two characters that demand special treatment: `<`
-and `&`. Left angle brackets are used to start tags; ampersands are
-used to denote HTML entities. If you want to use them as literal
-characters, you must escape them as entities, e.g. `&lt;`, and
-`&amp;`.
-
-Ampersands in particular are bedeviling for web writers. If you want to
-write about 'AT&T', you need to write '`AT&amp;T`'. You even need to
-escape ampersands within URLs. Thus, if you want to link to:
-
- http://images.google.com/images?num=30&q=larry+bird
-
-you need to encode the URL as:
-
- http://images.google.com/images?num=30&amp;q=larry+bird
-
-in your anchor tag `href` attribute. Needless to say, this is easy to
-forget, and is probably the single most common source of HTML validation
-errors in otherwise well-marked-up web sites.
-
-Markdown allows you to use these characters naturally, taking care of
-all the necessary escaping for you. If you use an ampersand as part of
-an HTML entity, it remains unchanged; otherwise it will be translated
-into `&amp;`.
-
-So, if you want to include a copyright symbol in your article, you can write:
-
- &copy;
-
-and Markdown will leave it alone. But if you write:
-
- AT&T
-
-Markdown will translate it to:
-
- AT&amp;T
-
-Similarly, because Markdown supports [inline HTML](#html), if you use
-angle brackets as delimiters for HTML tags, Markdown will treat them as
-such. But if you write:
-
- 4 < 5
-
-Markdown will translate it to:
-
- 4 &lt; 5
-
-However, inside Markdown code spans and blocks, angle brackets and
-ampersands are *always* encoded automatically. This makes it easy to use
-Markdown to write about HTML code. (As opposed to raw HTML, which is a
-terrible format for writing about HTML syntax, because every single `<`
-and `&` in your example code needs to be escaped.)
-
-
-* * *
-
-
-<h2 id="block">Block Elements</h2>
-
-
-<h3 id="p">Paragraphs and Line Breaks</h3>
-
-A paragraph is simply one or more consecutive lines of text, separated
-by one or more blank lines. (A blank line is any line that looks like a
-blank line -- a line containing nothing but spaces or tabs is considered
-blank.) Normal paragraphs should not be intended with spaces or tabs.
-
-The implication of the "one or more consecutive lines of text" rule is
-that Markdown supports "hard-wrapped" text paragraphs. This differs
-significantly from most other text-to-HTML formatters (including Movable
-Type's "Convert Line Breaks" option) which translate every line break
-character in a paragraph into a `<br />` tag.
-
-When you *do* want to insert a `<br />` break tag using Markdown, you
-end a line with two or more spaces, then type return.
-
-Yes, this takes a tad more effort to create a `<br />`, but a simplistic
-"every line break is a `<br />`" rule wouldn't work for Markdown.
-Markdown's email-style [blockquoting][bq] and multi-paragraph [list items][l]
-work best -- and look better -- when you format them with hard breaks.
-
- [bq]: #blockquote
- [l]: #list
-
-
-
-<h3 id="header">Headers</h3>
-
-Markdown supports two styles of headers, [Setext] [1] and [atx] [2].
-
-Setext-style headers are "underlined" using equal signs (for first-level
-headers) and dashes (for second-level headers). For example:
-
- This is an H1
- =============
-
- This is an H2
- -------------
-
-Any number of underlining `=`'s or `-`'s will work.
-
-Atx-style headers use 1-6 hash characters at the start of the line,
-corresponding to header levels 1-6. For example:
-
- # This is an H1
-
- ## This is an H2
-
- ###### This is an H6
-
-Optionally, you may "close" atx-style headers. This is purely
-cosmetic -- you can use this if you think it looks better. The
-closing hashes don't even need to match the number of hashes
-used to open the header. (The number of opening hashes
-determines the header level.) :
-
- # This is an H1 #
-
- ## This is an H2 ##
-
- ### This is an H3 ######
-
-
-<h3 id="blockquote">Blockquotes</h3>
-
-Markdown uses email-style `>` characters for blockquoting. If you're
-familiar with quoting passages of text in an email message, then you
-know how to create a blockquote in Markdown. It looks best if you hard
-wrap the text and put a `>` before every line:
-
- > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
- > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
- > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
- >
- > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
- > id sem consectetuer libero luctus adipiscing.
-
-Markdown allows you to be lazy and only put the `>` before the first
-line of a hard-wrapped paragraph:
-
- > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
- consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
- Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
-
- > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
- id sem consectetuer libero luctus adipiscing.
-
-Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
-adding additional levels of `>`:
-
- > This is the first level of quoting.
- >
- > > This is nested blockquote.
- >
- > Back to the first level.
-
-Blockquotes can contain other Markdown elements, including headers, lists,
-and code blocks:
-
- > ## This is a header.
- >
- > 1. This is the first list item.
- > 2. This is the second list item.
- >
- > Here's some example code:
- >
- > return shell_exec("echo $input | $markdown_script");
-
-Any decent text editor should make email-style quoting easy. For
-example, with BBEdit, you can make a selection and choose Increase
-Quote Level from the Text menu.
-
-
-<h3 id="list">Lists</h3>
-
-Markdown supports ordered (numbered) and unordered (bulleted) lists.
-
-Unordered lists use asterisks, pluses, and hyphens -- interchangably
--- as list markers:
-
- * Red
- * Green
- * Blue
-
-is equivalent to:
-
- + Red
- + Green
- + Blue
-
-and:
-
- - Red
- - Green
- - Blue
-
-Ordered lists use numbers followed by periods:
-
- 1. Bird
- 2. McHale
- 3. Parish
-
-It's important to note that the actual numbers you use to mark the
-list have no effect on the HTML output Markdown produces. The HTML
-Markdown produces from the above list is:
-
- <ol>
- <li>Bird</li>
- <li>McHale</li>
- <li>Parish</li>
- </ol>
-
-If you instead wrote the list in Markdown like this:
-
- 1. Bird
- 1. McHale
- 1. Parish
-
-or even:
-
- 3. Bird
- 1. McHale
- 8. Parish
-
-you'd get the exact same HTML output. The point is, if you want to,
-you can use ordinal numbers in your ordered Markdown lists, so that
-the numbers in your source match the numbers in your published HTML.
-But if you want to be lazy, you don't have to.
-
-If you do use lazy list numbering, however, you should still start the
-list with the number 1. At some point in the future, Markdown may support
-starting ordered lists at an arbitrary number.
-
-List markers typically start at the left margin, but may be indented by
-up to three spaces. List markers must be followed by one or more spaces
-or a tab.
-
-To make lists look nice, you can wrap items with hanging indents:
-
- * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
- Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
- viverra nec, fringilla in, laoreet vitae, risus.
- * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
- Suspendisse id sem consectetuer libero luctus adipiscing.
-
-But if you want to be lazy, you don't have to:
-
- * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
- Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
- viverra nec, fringilla in, laoreet vitae, risus.
- * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
- Suspendisse id sem consectetuer libero luctus adipiscing.
-
-If list items are separated by blank lines, Markdown will wrap the
-items in `<p>` tags in the HTML output. For example, this input:
-
- * Bird
- * Magic
-
-will turn into:
-
- <ul>
- <li>Bird</li>
- <li>Magic</li>
- </ul>
-
-But this:
-
- * Bird
-
- * Magic
-
-will turn into:
-
- <ul>
- <li><p>Bird</p></li>
- <li><p>Magic</p></li>
- </ul>
-
-List items may consist of multiple paragraphs. Each subsequent
-paragraph in a list item must be intended by either 4 spaces
-or one tab:
-
- 1. This is a list item with two paragraphs. Lorem ipsum dolor
- sit amet, consectetuer adipiscing elit. Aliquam hendrerit
- mi posuere lectus.
-
- Vestibulum enim wisi, viverra nec, fringilla in, laoreet
- vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
- sit amet velit.
-
- 2. Suspendisse id sem consectetuer libero luctus adipiscing.
-
-It looks nice if you indent every line of the subsequent
-paragraphs, but here again, Markdown will allow you to be
-lazy:
-
- * This is a list item with two paragraphs.
-
- This is the second paragraph in the list item. You're
- only required to indent the first line. Lorem ipsum dolor
- sit amet, consectetuer adipiscing elit.
-
- * Another item in the same list.
-
-To put a blockquote within a list item, the blockquote's `>`
-delimiters need to be indented:
-
- * A list item with a blockquote:
-
- > This is a blockquote
- > inside a list item.
-
-To put a code block within a list item, the code block needs
-to be indented *twice* -- 8 spaces or two tabs:
-
- * A list item with a code block:
-
- <code goes here>
-
-
-It's worth noting that it's possible to trigger an ordered list by
-accident, by writing something like this:
-
- 1986. What a great season.
-
-In other words, a *number-period-space* sequence at the beginning of a
-line. To avoid this, you can backslash-escape the period:
-
- 1986\. What a great season.
-
-
-
-<h3 id="precode">Code Blocks</h3>
-
-Pre-formatted code blocks are used for writing about programming or
-markup source code. Rather than forming normal paragraphs, the lines
-of a code block are interpreted literally. Markdown wraps a code block
-in both `<pre>` and `<code>` tags.
-
-To produce a code block in Markdown, simply indent every line of the
-block by at least 4 spaces or 1 tab. For example, given this input:
-
- This is a normal paragraph:
-
- This is a code block.
-
-Markdown will generate:
-
- <p>This is a normal paragraph:</p>
-
- <pre><code>This is a code block.
- </code></pre>
-
-One level of indentation -- 4 spaces or 1 tab -- is removed from each
-line of the code block. For example, this:
-
- Here is an example of AppleScript:
-
- tell application "Foo"
- beep
- end tell
-
-will turn into:
-
- <p>Here is an example of AppleScript:</p>
-
- <pre><code>tell application "Foo"
- beep
- end tell
- </code></pre>
-
-A code block continues until it reaches a line that is not indented
-(or the end of the article).
-
-Within a code block, ampersands (`&`) and angle brackets (`<` and `>`)
-are automatically converted into HTML entities. This makes it very
-easy to include example HTML source code using Markdown -- just paste
-it and indent it, and Markdown will handle the hassle of encoding the
-ampersands and angle brackets. For example, this:
-
- <div class="footer">
- &copy; 2004 Foo Corporation
- </div>
-
-will turn into:
-
- <pre><code>&lt;div class="footer"&gt;
- &amp;copy; 2004 Foo Corporation
- &lt;/div&gt;
- </code></pre>
-
-Regular Markdown syntax is not processed within code blocks. E.g.,
-asterisks are just literal asterisks within a code block. This means
-it's also easy to use Markdown to write about Markdown's own syntax.
-
-
-
-<h3 id="hr">Horizontal Rules</h3>
-
-You can produce a horizontal rule tag (`<hr />`) by placing three or
-more hyphens, asterisks, or underscores on a line by themselves. If you
-wish, you may use spaces between the hyphens or asterisks. Each of the
-following lines will produce a horizontal rule:
-
- * * *
-
- ***
-
- *****
-
- - - -
-
- ---------------------------------------
-
- _ _ _
-
-
-* * *
-
-<h2 id="span">Span Elements</h2>
-
-<h3 id="link">Links</h3>
-
-Markdown supports two style of links: *inline* and *reference*.
-
-In both styles, the link text is delimited by [square brackets].
-
-To create an inline link, use a set of regular parentheses immediately
-after the link text's closing square bracket. Inside the parentheses,
-put the URL where you want the link to point, along with an *optional*
-title for the link, surrounded in quotes. For example:
-
- This is [an example](http://example.com/ "Title") inline link.
-
- [This link](http://example.net/) has no title attribute.
-
-Will produce:
-
- <p>This is <a href="http://example.com/" title="Title">
- an example</a> inline link.</p>
-
- <p><a href="http://example.net/">This link</a> has no
- title attribute.</p>
-
-If you're referring to a local resource on the same server, you can
-use relative paths:
-
- See my [About](/about/) page for details.
-
-Reference-style links use a second set of square brackets, inside
-which you place a label of your choosing to identify the link:
-
- This is [an example][id] reference-style link.
-
-You can optionally use a space to separate the sets of brackets:
-
- This is [an example] [id] reference-style link.
-
-Then, anywhere in the document, you define your link label like this,
-on a line by itself:
-
- [id]: http://example.com/ "Optional Title Here"
-
-That is:
-
-* Square brackets containing the link identifier (optionally
- indented from the left margin using up to three spaces);
-* followed by a colon;
-* followed by one or more spaces (or tabs);
-* followed by the URL for the link;
-* optionally followed by a title attribute for the link, enclosed
- in double or single quotes.
-
-The link URL may, optionally, be surrounded by angle brackets:
-
- [id]: <http://example.com/> "Optional Title Here"
-
-You can put the title attribute on the next line and use extra spaces
-or tabs for padding, which tends to look better with longer URLs:
-
- [id]: http://example.com/longish/path/to/resource/here
- "Optional Title Here"
-
-Link definitions are only used for creating links during Markdown
-processing, and are stripped from your document in the HTML output.
-
-Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are *not* case sensitive. E.g. these two links:
-
- [link text][a]
- [link text][A]
-
-are equivalent.
-
-The *implicit link name* shortcut allows you to omit the name of the
-link, in which case the link text itself is used as the name.
-Just use an empty set of square brackets -- e.g., to link the word
-"Google" to the google.com web site, you could simply write:
-
- [Google][]
-
-And then define the link:
-
- [Google]: http://google.com/
-
-Because link names may contain spaces, this shortcut even works for
-multiple words in the link text:
-
- Visit [Daring Fireball][] for more information.
-
-And then define the link:
-
- [Daring Fireball]: http://daringfireball.net/
-
-Link definitions can be placed anywhere in your Markdown document. I
-tend to put them immediately after each paragraph in which they're
-used, but if you want, you can put them all at the end of your
-document, sort of like footnotes.
-
-Here's an example of reference links in action:
-
- I get 10 times more traffic from [Google] [1] than from
- [Yahoo] [2] or [MSN] [3].
-
- [1]: http://google.com/ "Google"
- [2]: http://search.yahoo.com/ "Yahoo Search"
- [3]: http://search.msn.com/ "MSN Search"
-
-Using the implicit link name shortcut, you could instead write:
-
- I get 10 times more traffic from [Google][] than from
- [Yahoo][] or [MSN][].
-
- [google]: http://google.com/ "Google"
- [yahoo]: http://search.yahoo.com/ "Yahoo Search"
- [msn]: http://search.msn.com/ "MSN Search"
-
-Both of the above examples will produce the following HTML output:
-
- <p>I get 10 times more traffic from <a href="http://google.com/"
- title="Google">Google</a> than from
- <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>
- or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
-
-For comparison, here is the same paragraph written using
-Markdown's inline link style:
-
- I get 10 times more traffic from [Google](http://google.com/ "Google")
- than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
- [MSN](http://search.msn.com/ "MSN Search").
-
-The point of reference-style links is not that they're easier to
-write. The point is that with reference-style links, your document
-source is vastly more readable. Compare the above examples: using
-reference-style links, the paragraph itself is only 81 characters
-long; with inline-style links, it's 176 characters; and as raw HTML,
-it's 234 characters. In the raw HTML, there's more markup than there
-is text.
-
-With Markdown's reference-style links, a source document much more
-closely resembles the final output, as rendered in a browser. By
-allowing you to move the markup-related metadata out of the paragraph,
-you can add links without interrupting the narrative flow of your
-prose.
-
-
-<h3 id="em">Emphasis</h3>
-
-Markdown treats asterisks (`*`) and underscores (`_`) as indicators of
-emphasis. Text wrapped with one `*` or `_` will be wrapped with an
-HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML
-`<strong>` tag. E.g., this input:
-
- *single asterisks*
-
- _single underscores_
-
- **double asterisks**
-
- __double underscores__
-
-will produce:
-
- <em>single asterisks</em>
-
- <em>single underscores</em>
-
- <strong>double asterisks</strong>
-
- <strong>double underscores</strong>
-
-You can use whichever style you prefer; the lone restriction is that
-the same character must be used to open and close an emphasis span.
-
-Emphasis can be used in the middle of a word:
-
- un*fucking*believable
-
-But if you surround an `*` or `_` with spaces, it'll be treated as a
-literal asterisk or underscore.
-
-To produce a literal asterisk or underscore at a position where it
-would otherwise be used as an emphasis delimiter, you can backslash
-escape it:
-
- \*this text is surrounded by literal asterisks\*
-
-
-
-<h3 id="code">Code</h3>
-
-To indicate a span of code, wrap it with backtick quotes (`` ` ``).
-Unlike a pre-formatted code block, a code span indicates code within a
-normal paragraph. For example:
-
- Use the `printf()` function.
-
-will produce:
-
- <p>Use the <code>printf()</code> function.</p>
-
-To include a literal backtick character within a code span, you can use
-multiple backticks as the opening and closing delimiters:
-
- ``There is a literal backtick (`) here.``
-
-which will produce this:
-
- <p><code>There is a literal backtick (`) here.</code></p>
-
-The backtick delimiters surrounding a code span may include spaces --
-one after the opening, one before the closing. This allows you to place
-literal backtick characters at the beginning or end of a code span:
-
- A single backtick in a code span: `` ` ``
-
- A backtick-delimited string in a code span: `` `foo` ``
-
-will produce:
-
- <p>A single backtick in a code span: <code>`</code></p>
-
- <p>A backtick-delimited string in a code span: <code>`foo`</code></p>
-
-With a code span, ampersands and angle brackets are encoded as HTML
-entities automatically, which makes it easy to include example HTML
-tags. Markdown will turn this:
-
- Please don't use any `<blink>` tags.
-
-into:
-
- <p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>
-
-You can write this:
-
- `&#8212;` is the decimal-encoded equivalent of `&mdash;`.
-
-to produce:
-
- <p><code>&amp;#8212;</code> is the decimal-encoded
- equivalent of <code>&amp;mdash;</code>.</p>
-
-
-
-<h3 id="img">Images</h3>
-
-Admittedly, it's fairly difficult to devise a "natural" syntax for
-placing images into a plain text document format.
-
-Markdown uses an image syntax that is intended to resemble the syntax
-for links, allowing for two styles: *inline* and *reference*.
-
-Inline image syntax looks like this:
-
- ![Alt text](/path/to/img.jpg)
-
- ![Alt text](/path/to/img.jpg "Optional title")
-
-That is:
-
-* An exclamation mark: `!`;
-* followed by a set of square brackets, containing the `alt`
- attribute text for the image;
-* followed by a set of parentheses, containing the URL or path to
- the image, and an optional `title` attribute enclosed in double
- or single quotes.
-
-Reference-style image syntax looks like this:
-
- ![Alt text][id]
-
-Where "id" is the name of a defined image reference. Image references
-are defined using syntax identical to link references:
-
- [id]: url/to/image "Optional title attribute"
-
-As of this writing, Markdown has no syntax for specifying the
-dimensions of an image; if this is important to you, you can simply
-use regular HTML `<img>` tags.
-
-
-* * *
-
-
-<h2 id="misc">Miscellaneous</h2>
-
-<h3 id="autolink">Automatic Links</h3>
-
-Markdown supports a shortcut style for creating "automatic" links for URLs and email addresses: simply surround the URL or email address with angle brackets. What this means is that if you want to show the actual text of a URL or email address, and also have it be a clickable link, you can do this:
-
- <http://example.com/>
-
-Markdown will turn this into:
-
- <a href="http://example.com/">http://example.com/</a>
-
-Automatic links for email addresses work similarly, except that
-Markdown will also perform a bit of randomized decimal and hex
-entity-encoding to help obscure your address from address-harvesting
-spambots. For example, Markdown will turn this:
-
- <address@example.com>
-
-into something like this:
-
- <a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;
- &#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;
- &#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;
- &#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>
-
-which will render in a browser as a clickable link to "address@example.com".
-
-(This sort of entity-encoding trick will indeed fool many, if not
-most, address-harvesting bots, but it definitely won't fool all of
-them. It's better than nothing, but an address published in this way
-will probably eventually start receiving spam.)
-
-
-
-<h3 id="backslash">Backslash Escapes</h3>
-
-Markdown allows you to use backslash escapes to generate literal
-characters which would otherwise have special meaning in Markdown's
-formatting syntax. For example, if you wanted to surround a word with
-literal asterisks (instead of an HTML `<em>` tag), you can backslashes
-before the asterisks, like this:
-
- \*literal asterisks\*
-
-Markdown provides backslash escapes for the following characters:
-
- \ backslash
- ` backtick
- * asterisk
- _ underscore
- {} curly braces
- [] square brackets
- () parentheses
- # hash mark
- + plus sign
- - minus sign (hyphen)
- . dot
- ! exclamation mark
-
diff --git a/tests/MarkdownTest_1.0.3/Tests/Nested blockquotes.html b/tests/MarkdownTest_1.0.3/Tests/Nested blockquotes.html
deleted file mode 100644
index d8ec7f8e0..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Nested blockquotes.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<blockquote>
- <p>foo</p>
-
- <blockquote>
- <p>bar</p>
- </blockquote>
-
- <p>foo</p>
-</blockquote>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Nested blockquotes.text b/tests/MarkdownTest_1.0.3/Tests/Nested blockquotes.text
deleted file mode 100644
index ed3c624ff..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Nested blockquotes.text
+++ /dev/null
@@ -1,5 +0,0 @@
-> foo
->
-> > bar
->
-> foo
diff --git a/tests/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.html b/tests/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.html
deleted file mode 100644
index ba71eab39..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.html
+++ /dev/null
@@ -1,148 +0,0 @@
-<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>
-
-<hr />
-
-<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>
-
-<hr />
-
-<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 2. 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</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>
-
-
-<p>This was an error in Markdown 1.0.1:</p>
-
-<ul>
-<li><p>this</p>
-
-<ul><li>sub</li></ul>
-
-<p>that</p></li>
-</ul>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.text b/tests/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.text
deleted file mode 100644
index 7f3b49777..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.text
+++ /dev/null
@@ -1,131 +0,0 @@
-## 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 2. 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
-
-
-This was an error in Markdown 1.0.1:
-
-* this
-
- * sub
-
- that
diff --git a/tests/MarkdownTest_1.0.3/Tests/Strong and em together.html b/tests/MarkdownTest_1.0.3/Tests/Strong and em together.html
deleted file mode 100644
index 71ec78c70..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Strong and em together.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<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>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Strong and em together.text b/tests/MarkdownTest_1.0.3/Tests/Strong and em together.text
deleted file mode 100644
index 95ee690db..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Strong and em together.text
+++ /dev/null
@@ -1,7 +0,0 @@
-***This is strong and em.***
-
-So is ***this*** word.
-
-___This is strong and em.___
-
-So is ___this___ word.
diff --git a/tests/MarkdownTest_1.0.3/Tests/Tabs.html b/tests/MarkdownTest_1.0.3/Tests/Tabs.html
deleted file mode 100644
index 3301ba803..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Tabs.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<ul>
-<li><p>this is a list item
-indented with tabs</p></li>
-<li><p>this is a list item
-indented with spaces</p></li>
-</ul>
-
-<p>Code:</p>
-
-<pre><code>this code block is indented by one tab
-</code></pre>
-
-<p>And:</p>
-
-<pre><code> this code block is indented by two tabs
-</code></pre>
-
-<p>And:</p>
-
-<pre><code>+ this is an example list item
- indented with tabs
-
-+ this is an example list item
- indented with spaces
-</code></pre>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Tabs.text b/tests/MarkdownTest_1.0.3/Tests/Tabs.text
deleted file mode 100644
index 589d1136e..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Tabs.text
+++ /dev/null
@@ -1,21 +0,0 @@
-+ this is a list item
- indented with tabs
-
-+ this is a list item
- indented with spaces
-
-Code:
-
- this code block is indented by one tab
-
-And:
-
- this code block is indented by two tabs
-
-And:
-
- + this is an example list item
- indented with tabs
-
- + this is an example list item
- indented with spaces
diff --git a/tests/MarkdownTest_1.0.3/Tests/Tidyness.html b/tests/MarkdownTest_1.0.3/Tests/Tidyness.html
deleted file mode 100644
index f2a8ce70f..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Tidyness.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<blockquote>
-<p>A list within a blockquote:</p>
-<ul>
-<li>asterisk 1</li>
-<li>asterisk 2</li>
-<li>asterisk 3</li>
-</ul>
-</blockquote>
diff --git a/tests/MarkdownTest_1.0.3/Tests/Tidyness.text b/tests/MarkdownTest_1.0.3/Tests/Tidyness.text
deleted file mode 100644
index 5f18b8da2..000000000
--- a/tests/MarkdownTest_1.0.3/Tests/Tidyness.text
+++ /dev/null
@@ -1,5 +0,0 @@
-> A list within a blockquote:
->
-> * asterisk 1
-> * asterisk 2
-> * asterisk 3
diff --git a/tests/Tests/Arbitrary.hs b/tests/Tests/Arbitrary.hs
index 5939d088d..3675d97bf 100644
--- a/tests/Tests/Arbitrary.hs
+++ b/tests/Tests/Arbitrary.hs
@@ -41,15 +41,15 @@ arbInline :: Int -> Gen Inline
arbInline n = frequency $ [ (60, liftM Str realString)
, (60, return Space)
, (10, liftM2 Code arbAttr realString)
- , (5, elements [ RawInline "html" "<a id=\"eek\">"
- , RawInline "latex" "\\my{command}" ])
+ , (5, elements [ RawInline (Format "html") "<a id=\"eek\">"
+ , RawInline (Format "latex") "\\my{command}" ])
] ++ [ x | x <- nesters, n > 1]
where nesters = [ (10, liftM Emph $ arbInlines (n-1))
, (10, liftM Strong $ arbInlines (n-1))
, (10, liftM Strikeout $ arbInlines (n-1))
, (10, liftM Superscript $ arbInlines (n-1))
, (10, liftM Subscript $ arbInlines (n-1))
--- , (10, liftM SmallCaps $ arbInlines (n-1))
+ , (10, liftM SmallCaps $ arbInlines (n-1))
, (10, do x1 <- arbitrary
x2 <- arbInlines (n-1)
return $ Quoted x1 x2)
@@ -64,6 +64,7 @@ arbInline n = frequency $ [ (60, liftM Str realString)
x3 <- realString
x2 <- liftM escapeURI realString
return $ Image x1 (x2,x3))
+ , (2, liftM2 Cite arbitrary (arbInlines 1))
, (2, liftM Note $ resize 3 $ listOf1 $ arbBlock (n-1))
]
@@ -74,9 +75,9 @@ arbBlock :: Int -> Gen Block
arbBlock n = frequency $ [ (10, liftM Plain $ arbInlines (n-1))
, (15, liftM Para $ arbInlines (n-1))
, (5, liftM2 CodeBlock arbAttr realString)
- , (2, elements [ RawBlock "html"
+ , (2, elements [ RawBlock (Format "html")
"<div>\n*&amp;*\n</div>"
- , RawBlock "latex"
+ , RawBlock (Format "latex")
"\\begin[opt]{env}\nhi\n{\\end{env}"
])
, (5, do x1 <- choose (1 :: Int, 6)
@@ -111,7 +112,6 @@ instance Arbitrary Pandoc where
arbitrary = resize 8 $ liftM normalize
$ liftM2 Pandoc arbitrary arbitrary
-{-
instance Arbitrary CitationMode where
arbitrary
= do x <- choose (0 :: Int, 2)
@@ -123,14 +123,13 @@ instance Arbitrary CitationMode where
instance Arbitrary Citation where
arbitrary
- = do x1 <- liftM (filter (`notElem` ",;]@ \t\n")) arbitrary
- x2 <- arbitrary
- x3 <- arbitrary
+ = do x1 <- listOf $ elements $ ['a'..'z'] ++ ['0'..'9'] ++ ['_']
+ x2 <- arbInlines 1
+ x3 <- arbInlines 1
x4 <- arbitrary
x5 <- arbitrary
x6 <- arbitrary
return (Citation x1 x2 x3 x4 x5 x6)
--}
instance Arbitrary MathType where
arbitrary
diff --git a/tests/Tests/Old.hs b/tests/Tests/Old.hs
index 573ec1afe..44ed9f53a 100644
--- a/tests/Tests/Old.hs
+++ b/tests/Tests/Old.hs
@@ -3,7 +3,7 @@ module Tests.Old (tests) where
import Test.Framework (testGroup, Test )
import Test.Framework.Providers.HUnit
import Test.HUnit ( assertBool )
-
+import System.Environment ( getArgs )
import System.IO ( openTempFile, stderr )
import System.Process ( runProcess, waitForProcess )
import System.FilePath ( (</>), (<.>) )
@@ -22,9 +22,6 @@ import Text.Printf
readFileUTF8 :: FilePath -> IO String
readFileUTF8 f = B.readFile f >>= return . toStringLazy
-pandocPath :: FilePath
-pandocPath = ".." </> "dist" </> "build" </> "pandoc" </> "pandoc"
-
data TestResult = TestPassed
| TestError ExitCode
| TestFailed String FilePath [Diff String]
@@ -63,7 +60,10 @@ tests = [ testGroup "markdown"
"markdown-reader-more.txt" "markdown-reader-more.native"
, lhsReaderTest "markdown+lhs"
]
- , testGroup "citations" markdownCitationTests
+ , testGroup "citations"
+ [ test "citations" ["-r", "markdown", "-w", "native"]
+ "markdown-citations.txt" "markdown-citations.native"
+ ]
]
, testGroup "rst"
[ testGroup "writer" (writerTests "rst" ++ lhsWriterTests "rst")
@@ -136,11 +136,12 @@ tests = [ testGroup "markdown"
"opml-reader.opml" "opml-reader.native"
]
, testGroup "haddock"
- [ test "reader" ["-r", "haddock", "-w", "native", "-s"]
+ [ testGroup "writer" $ writerTests "haddock"
+ , test "reader" ["-r", "haddock", "-w", "native", "-s"]
"haddock-reader.haddock" "haddock-reader.native"
]
, testGroup "other writers" $ map (\f -> testGroup f $ writerTests f)
- [ "opendocument" , "context" , "texinfo"
+ [ "opendocument" , "context" , "texinfo", "icml"
, "man" , "plain" , "rtf", "org", "asciidoc"
]
]
@@ -195,19 +196,6 @@ fb2WriterTest title opts inputfile normfile =
ignoreBinary = unlines . filter (not . startsWith "<binary ") . lines
startsWith tag str = all (uncurry (==)) $ zip tag str
-markdownCitationTests :: [Test]
-markdownCitationTests
- = map styleToTest ["chicago-author-date","ieee","mhra"]
- ++ [test "natbib" wopts "markdown-citations.txt"
- "markdown-citations.txt"]
- where
- ropts = ["-r", "markdown", "-w", "markdown", "--bibliography",
- "biblio.bib", "--no-wrap"]
- wopts = ["-r", "markdown", "-w", "markdown", "--no-wrap", "--natbib"]
- styleToTest style = test style (ropts ++ ["--csl", style ++ ".csl"])
- "markdown-citations.txt"
- ("markdown-citations." ++ style ++ ".txt")
-
-- | Run a test without normalize function, return True if test passed.
test :: String -- ^ Title of test
-> [String] -- ^ Options to pass to pandoc
@@ -224,6 +212,11 @@ testWithNormalize :: (String -> String) -- ^ Normalize function for output
-> FilePath -- ^ Norm (for test results) filepath
-> Test
testWithNormalize normalizer testname opts inp norm = testCase testname $ do
+ args <- getArgs
+ let buildDir = case args of
+ (x:_) -> ".." </> x
+ _ -> error "test-pandoc: missing buildDir argument"
+ let pandocPath = buildDir </> "pandoc" </> "pandoc"
(outputPath, hOut) <- openTempFile "" "pandoc-test"
let inpPath = inp
let normPath = norm
diff --git a/tests/Tests/Readers/Docx.hs b/tests/Tests/Readers/Docx.hs
new file mode 100644
index 000000000..8c51217cf
--- /dev/null
+++ b/tests/Tests/Readers/Docx.hs
@@ -0,0 +1,160 @@
+module Tests.Readers.Docx (tests) where
+
+import Text.Pandoc.Options
+import Text.Pandoc.Readers.Native
+import Text.Pandoc.Definition
+import Tests.Helpers
+import Test.Framework
+import qualified Data.ByteString.Lazy as B
+import Text.Pandoc.Readers.Docx
+import Text.Pandoc.Writers.Native (writeNative)
+import qualified Data.Map as M
+
+-- 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
+
+instance ToString NoNormPandoc where
+ toString d = writeNative def{ writerStandalone = s } $ toPandoc d
+ where s = case d of
+ NoNormPandoc (Pandoc (Meta m) _)
+ | M.null m -> False
+ | otherwise -> True
+
+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
+ return $ (noNorm (readDocx opts df), noNorm (readNative nf))
+
+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 def
+
+
+tests :: [Test]
+tests = [ testGroup "inlines"
+ [ testCompare
+ "font formatting"
+ "docx.inline_formatting.docx"
+ "docx.inline_formatting.native"
+ , testCompare
+ "hyperlinks"
+ "docx.links.docx"
+ "docx.links.native"
+ , testCompare
+ "inline image with reference output"
+ "docx.image.docx"
+ "docx.image_no_embed.native"
+ , testCompare
+ "handling unicode input"
+ "docx.unicode.docx"
+ "docx.unicode.native"
+ , testCompare
+ "literal tabs"
+ "docx.tabs.docx"
+ "docx.tabs.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"
+ ]
+ , testGroup "blocks"
+ [ testCompare
+ "headers"
+ "docx.headers.docx"
+ "docx.headers.native"
+ , testCompare
+ "lists"
+ "docx.lists.docx"
+ "docx.lists.native"
+ , testCompare
+ "definition lists"
+ "docx.definition_list.docx"
+ "docx.definition_list.native"
+ , testCompare
+ "footnotes and endnotes"
+ "docx.notes.docx"
+ "docx.notes.native"
+ , testCompare
+ "blockquotes (parsing indent as blockquote)"
+ "docx.block_quotes.docx"
+ "docx.block_quotes_parse_indent.native"
+ , testCompare
+ "tables"
+ "docx.tables.docx"
+ "docx.tables.native"
+ , testCompare
+ "code block"
+ "docx.codeblock.docx"
+ "docx.codeblock.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"
+ ]
+ ]
+
diff --git a/tests/Tests/Readers/LaTeX.hs b/tests/Tests/Readers/LaTeX.hs
index 271b32689..8ff23ebc1 100644
--- a/tests/Tests/Readers/LaTeX.hs
+++ b/tests/Tests/Readers/LaTeX.hs
@@ -21,24 +21,24 @@ tests = [ testGroup "basic"
[ "simple" =:
"word" =?> para "word"
, "space" =:
- "some text" =?> para ("some text")
+ "some text" =?> para "some text"
, "emphasized" =:
"\\emph{emphasized}" =?> para (emph "emphasized")
]
, testGroup "headers"
[ "level 1" =:
- "\\section{header}" =?> header 1 "header"
+ "\\section{header}" =?> headerWith ("header",[],[]) 1 "header"
, "level 2" =:
- "\\subsection{header}" =?> header 2 "header"
+ "\\subsection{header}" =?> headerWith ("header",[],[]) 2 "header"
, "level 3" =:
- "\\subsubsection{header}" =?> header 3 "header"
+ "\\subsubsection{header}" =?> headerWith ("header",[],[]) 3 "header"
, "emph" =:
"\\section{text \\emph{emph}}" =?>
- header 1 ("text" <> space <> emph "emph")
+ headerWith ("text-emph",[],[]) 1 ("text" <> space <> emph "emph")
, "link" =:
"\\section{text \\href{/url}{link}}" =?>
- header 1 ("text" <> space <> link "/url" "" "link")
+ headerWith ("text-link",[],[]) 1 ("text" <> space <> link "/url" "" "link")
]
, testGroup "math"
@@ -55,6 +55,13 @@ tests = [ testGroup "basic"
"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 "citations"
[ natbibCitations
, biblatexCitations
@@ -79,14 +86,14 @@ natbibCitations = testGroup "natbib"
=?> 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}"))
+ (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}"))
+ 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 ",",Space,Str "p.\160\&30"]
+ , citationSuffix = [Str "p.\160\&30"]
, citationId = "item2" }
,baseCitation{ citationId = "item3"
, citationPrefix = [Str "see",Space,Str "also"]
@@ -95,28 +102,28 @@ natbibCitations = testGroup "natbib"
, "group" =: "\\citetext{\\citealp[see][p.~34--35]{item1}; \\citealp[also][chap. 3]{item3}}"
=?> para (cite [baseCitation{ citationMode = NormalCitation
, citationPrefix = [Str "see"]
- , citationSuffix = [Str ",",Space,Str "p.\160\&34\8211\&35"] }
+ , citationSuffix = [Str "p.\160\&34\8211\&35"] }
,baseCitation{ citationMode = NormalCitation
, citationId = "item3"
, citationPrefix = [Str "also"]
- , citationSuffix = [Str ",",Space,Str "chap.",Space,Str "3"] }
+ , 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 ",",Space,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}"))
+ , 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}"))
+ , 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 ",",Space,Str "p.\160\&44"]
+ , 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 ",",Space,Str "p.",Space,
+ , citationSuffix = [Str "p.",Space,
Strong [Str "32"]] }] (rt "\\citep[\\emph{see}][p. \\textbf{32}]{item1}"))
]
@@ -126,14 +133,14 @@ biblatexCitations = testGroup "biblatex"
=?> 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}"))
+ (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}"))
+ 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 ",",Space,Str "p.\160\&30"]
+ , citationSuffix = [Str "p.\160\&30"]
, citationId = "item2" }
,baseCitation{ citationId = "item3"
, citationPrefix = [Str "see",Space,Str "also"]
@@ -142,28 +149,28 @@ biblatexCitations = testGroup "biblatex"
, "group" =: "\\autocites[see][p.~34--35]{item1}[also][chap. 3]{item3}"
=?> para (cite [baseCitation{ citationMode = NormalCitation
, citationPrefix = [Str "see"]
- , citationSuffix = [Str ",",Space,Str "p.\160\&34\8211\&35"] }
+ , citationSuffix = [Str "p.\160\&34\8211\&35"] }
,baseCitation{ citationMode = NormalCitation
, citationId = "item3"
, citationPrefix = [Str "also"]
- , citationSuffix = [Str ",",Space,Str "chap.",Space,Str "3"] }
+ , 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 ",",Space,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}"))
+ , 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}"))
+ , 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 ",",Space,Str "p.\160\&44"]
+ , 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 ",",Space,Str "p.",Space,
+ , 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/tests/Tests/Readers/Markdown.hs b/tests/Tests/Readers/Markdown.hs
index 8a9ed9667..5a51fe759 100644
--- a/tests/Tests/Readers/Markdown.hs
+++ b/tests/Tests/Readers/Markdown.hs
@@ -24,7 +24,7 @@ infix 4 =:
testBareLink :: (String, Inlines) -> Test
testBareLink (inp, ils) =
test (readMarkdown def{ readerExtensions =
- Set.fromList [Ext_autolink_bare_uris] })
+ Set.fromList [Ext_autolink_bare_uris, Ext_raw_html] })
inp (inp, doc $ para ils)
autolink :: String -> Inlines
@@ -34,6 +34,9 @@ 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,",
@@ -133,6 +136,11 @@ tests = [ testGroup "inline code"
"`*` {.haskell .special x=\"7\"}"
=?> para (codeWith ("",["haskell","special"],[("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"))
+ ]
, testGroup "raw LaTeX"
[ "in URL" =:
"\\begin\n" =?> para (text "\\begin")
@@ -163,13 +171,13 @@ tests = [ testGroup "inline code"
, testGroup "smart punctuation"
[ test markdownSmart "quote before ellipses"
("'...hi'"
- =?> para (singleQuoted ("…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»"))
+ =?> para "À l’arrivée de la guerre, le thème de l’«impossibilité du socialisme»")
]
, testGroup "mixed emphasis and strong"
[ "emph and strong emph alternating" =:
@@ -208,4 +216,13 @@ tests = [ testGroup "inline code"
-- , testGroup "round trip"
-- [ property "p_markdown_round_trip" p_markdown_round_trip
-- ]
+ , 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 (plain $ text "first div breaks") <>
+ rawBlock "html" "<button>" <>
+ plain (text "if this button exists") <>
+ rawBlock "html" "</button>\n" <>
+ divWith nullAttr (plain $ text "with this div too.")]
+ ]
]
diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs
new file mode 100644
index 000000000..f8240ca3d
--- /dev/null
+++ b/tests/Tests/Readers/Org.hs
@@ -0,0 +1,994 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Readers.Org (tests) where
+
+import Text.Pandoc.Definition
+import Test.Framework
+import Tests.Helpers
+import Tests.Arbitrary()
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Data.List (intersperse)
+import Data.Monoid (mempty, mappend, mconcat)
+
+org :: String -> Pandoc
+org = readOrg def
+
+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")
+
+ , "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 (spcSep [ "this+that+", "+so+on"
+ , "seven*eight*", "nine*"
+ , 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") <> "."
+ ])
+
+ , "Inline math must stay within three lines" =:
+ unlines [ "$a", "b", "c$", "$d", "e", "f", "g$" ] =?>
+ para ((math "a\nb\nc") <> space <>
+ spcSep [ "$d", "e", "f", "g$" ])
+
+ , "Single-character math" =:
+ "$a$ $b$! $c$?" =?>
+ para (spcSep [ math "a"
+ , "$b$!"
+ , (math "c") <> "?"
+ ])
+
+ , "Markup may not span more than two lines" =:
+ unlines [ "/this *is +totally", "nice+ not*", "emph/" ] =?>
+ para (spcSep [ "/this"
+ , (strong (spcSep
+ [ "is"
+ , (strikeout ("totally" <> space <> "nice"))
+ , "not"
+ ]))
+ , "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 (spcSep [ "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))")
+ ])
+
+ , "Image" =:
+ "[[./sunset.jpg]]" =?>
+ (para $ image "./sunset.jpg" "" "")
+
+ , "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/")
+
+ , "Image link" =:
+ "[[sunset.png][dusk.svg]]" =?>
+ (para $ link "sunset.png" "" (image "dusk.svg" "" ""))
+
+ , "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."
+ ])
+
+ , "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'")
+
+ , "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]")
+
+ , "Inline LaTeX symbol" =:
+ "\\dots" =?>
+ para "…"
+
+ , "Inline LaTeX command" =:
+ "\\textit{Emphasised}" =?>
+ para (emph "Emphasised")
+
+ , "Inline LaTeX math symbol" =:
+ "\\tau" =?>
+ para (emph "τ")
+
+ , "Unknown inline LaTeX command" =:
+ "\\notacommand{foo}" =?>
+ para (rawInline "latex" "\\notacommand{foo}")
+
+ , "LaTeX citation" =:
+ "\\cite{Coffee}" =?>
+ let citation = Citation
+ { citationId = "Coffee"
+ , citationPrefix = []
+ , citationSuffix = []
+ , citationMode = AuthorInText
+ , 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" (MetaInlines author) $ 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 = toList . spcSep $ [ "Explanatory", "text" ]
+ meta = setMeta "description" (MetaInlines description) $ nullMeta
+ in Pandoc meta mempty
+
+ , "Properties drawer" =:
+ unlines [ " :PROPERTIES:"
+ , " :setting: foo"
+ , " :END:"
+ ] =?>
+ (mempty::Blocks)
+
+ , "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 start is the only text in first line of a drawer" =:
+ unlines [ " :LOGBOOK: foo"
+ , " :END:"
+ ] =?>
+ para (spcSep [ ":LOGBOOK:", "foo", ":END:" ])
+
+ , "Drawers with unknown names are just text" =:
+ unlines [ ":FOO:"
+ , ":END:"
+ ] =?>
+ para (":FOO:" <> space <> ":END:")
+
+ , "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 "Basic Blocks" $
+ [ "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")
+
+ , "Compact Headers with Paragraph" =:
+ unlines [ "* First Level"
+ , "** Second Level"
+ , " Text"
+ ] =?>
+ mconcat [ header 1 ("First" <> space <> "Level")
+ , header 2 ("Second" <> space <> "Level")
+ , para "Text"
+ ]
+
+ , "Separated Headers with Paragraph" =:
+ unlines [ "* First Level"
+ , ""
+ , "** Second Level"
+ , ""
+ , " Text"
+ ] =?>
+ mconcat [ header 1 ("First" <> space <> "Level")
+ , header 2 ("Second" <> space <> "Level")
+ , para "Text"
+ ]
+
+ , "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 asterisk" =:
+ "*five" =?>
+ para "*five"
+
+ , "Paragraph containing asterisk at beginning of line" =:
+ unlines [ "lucky"
+ , "*star"
+ ] =?>
+ para ("lucky" <> space <> "*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)
+
+ , "Figure" =:
+ unlines [ "#+caption: A very courageous man."
+ , "#+name: goodguy"
+ , "[[edward.jpg]]"
+ ] =?>
+ para (image "edward.jpg" "fig:goodguy" "A very courageous man.")
+
+ , "Unnamed figure" =:
+ unlines [ "#+caption: A great whistleblower."
+ , "[[snowden.png]]"
+ ] =?>
+ para (image "snowden.png" "" "A great whistleblower.")
+
+ , "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.")
+
+ , "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!")
+ ])
+ , header 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"
+ ]
+
+ , "Multi-line Bullet Lists" =:
+ ("- *Fat\n" ++
+ " Tony*\n" ++
+ "- /Sideshow\n" ++
+ " Bob/") =?>
+ bulletList [ plain $ strong ("Fat" <> space <> "Tony")
+ , plain $ emph ("Sideshow" <> space <> "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
+ [ para "Discovery"
+ , bulletList [ plain ("One" <> space <>
+ "More" <> space <>
+ "Time")
+ , plain ("Harder," <> space <>
+ "Better," <> space <>
+ "Faster," <> space <>
+ "Stronger")
+ ]
+ ]
+ , mconcat
+ [ para "Homework"
+ , bulletList [ plain ("Around" <> space <>
+ "the" <> space <>
+ "World")
+ ]
+ ]
+ , mconcat
+ [ para ("Human" <> space <> "After" <> space <> "All")
+ , bulletList [ plain "Technologic"
+ , plain ("Robot" <> space <> "Rock")
+ ]
+ ]
+ ]
+
+ , "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
+ [ para "One"
+ , orderedList [ plain "One-One"
+ , plain "One-Two"
+ ]
+ ]
+ , mconcat
+ [ para "Two"
+ , orderedList [ plain "Two-One"
+ , plain "Two-Two"
+ ]
+ ]
+ ]
+ in orderedListWith listStyle listStructure
+
+ , "Ordered List in Bullet List" =:
+ ("- Emacs\n" ++
+ " 1. Org\n") =?>
+ bulletList [ (para "Emacs") <>
+ (orderedList [ plain "Org"])
+ ]
+
+ , "Bullet List in Ordered List" =:
+ ("1. GNU\n" ++
+ " - Freedom\n") =?>
+ orderedList [ (para "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" ]
+ ]
+ ])
+ ]
+
+ , "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" ] ])
+ ]
+
+ , "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 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 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, AlignDefault] [0, 0, 0])
+ [ plain "Numbers", plain "Text" , plain mempty ]
+ [ [ plain "1" , plain "One" , plain "foo" ]
+ , [ plain "2" , plain mempty , plain mempty ]
+ ]
+
+ , "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 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'
+
+ , "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" <> ":"]
+ , para $ mconcat
+ [ spcSep [ "Habe", "nun,", "ach!", "Philosophie," ]
+ , linebreak
+ , spcSep [ "Juristerei", "und", "Medizin," ]
+ , linebreak
+ , spcSep [ "Und", "leider", "auch", "Theologie!" ]
+ , linebreak
+ , spcSep [ "Durchaus", "studiert,", "mit", "heißem", "Bemühn." ]
+ ]
+ ]
+
+ , "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"
+
+ , "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"
+ ]
+ ]
diff --git a/tests/Tests/Walk.hs b/tests/Tests/Walk.hs
new file mode 100644
index 000000000..34350e28a
--- /dev/null
+++ b/tests/Tests/Walk.hs
@@ -0,0 +1,47 @@
+{-# LANGUAGE ScopedTypeVariables, FlexibleContexts #-}
+module Tests.Walk (tests) where
+
+import Text.Pandoc.Definition
+import Text.Pandoc.Walk
+import Test.Framework
+import Tests.Helpers
+import Data.Char (toUpper)
+import Tests.Arbitrary()
+import Data.Generics
+import Data.Monoid
+
+tests :: [Test]
+tests = [ testGroup "Walk"
+ [ property "p_walk inlineTrans" (p_walk inlineTrans)
+ , property "p_walk blockTrans" (p_walk blockTrans)
+ , property "p_query inlineQuery" (p_query inlineQuery)
+ , property "p_query blockQuery" (p_query blockQuery)
+ ]
+ ]
+
+p_walk :: (Typeable a, Walkable a Pandoc)
+ => (a -> a) -> Pandoc -> Bool
+p_walk f d = everywhere (mkT f) d == walk f d
+
+p_query :: (Eq a, Typeable a1, Monoid a, Walkable a1 Pandoc)
+ => (a1 -> a) -> Pandoc -> Bool
+p_query f d = everything mappend (mempty `mkQ` f) d == query f d
+
+inlineTrans :: Inline -> Inline
+inlineTrans (Str xs) = Str $ map toUpper xs
+inlineTrans (Emph xs) = Strong xs
+inlineTrans x = x
+
+blockTrans :: Block -> Block
+blockTrans (Plain xs) = Para xs
+blockTrans (BlockQuote xs) = Div ("",["special"],[]) xs
+blockTrans x = x
+
+inlineQuery :: Inline -> String
+inlineQuery (Str xs) = xs
+inlineQuery _ = ""
+
+blockQuery :: Block -> [Int]
+blockQuery (Header lev _ _) = [lev]
+blockQuery _ = []
+
diff --git a/tests/Tests/Writers/AsciiDoc.hs b/tests/Tests/Writers/AsciiDoc.hs
new file mode 100644
index 000000000..118e648d3
--- /dev/null
+++ b/tests/Tests/Writers/AsciiDoc.hs
@@ -0,0 +1,37 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Writers.AsciiDoc (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Tests.Arbitrary()
+import Data.Monoid
+
+asciidoc :: (ToString a, ToPandoc a) => a -> String
+asciidoc = writeAsciiDoc def{ writerWrapText = False } . toPandoc
+
+tests :: [Test]
+tests = [ testGroup "tables"
+ [ test asciidoc "empty cells" $
+ simpleTable [] [[mempty],[mempty]] =?> unlines
+ [ "[cols=\"\",]"
+ , "|===="
+ , "|"
+ , "|"
+ , "|===="
+ ]
+ , test asciidoc "multiblock cells" $
+ simpleTable [] [[para "Para 1" <> para "Para 2"]]
+ =?> unlines
+ [ "[cols=\"\",]"
+ , "|====="
+ , "a|"
+ , "Para 1"
+ , ""
+ , "Para 2"
+ , ""
+ , "|====="
+ ]
+ ]
+ ]
diff --git a/tests/Tests/Writers/Docbook.hs b/tests/Tests/Writers/Docbook.hs
new file mode 100644
index 000000000..97126b473
--- /dev/null
+++ b/tests/Tests/Writers/Docbook.hs
@@ -0,0 +1,229 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Tests.Writers.Docbook (tests) where
+
+import Test.Framework
+import Text.Pandoc.Builder
+import Text.Pandoc
+import Tests.Helpers
+import Tests.Arbitrary()
+
+docbook :: (ToString a, ToPandoc a) => a -> String
+docbook = writeDocbook def{ writerWrapText = False } . 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>"
+ ]
+ ]
+ ]
+ ]
diff --git a/tests/Tests/Writers/HTML.hs b/tests/Tests/Writers/HTML.hs
index 1693f2fc1..84f4db191 100644
--- a/tests/Tests/Writers/HTML.hs
+++ b/tests/Tests/Writers/HTML.hs
@@ -6,7 +6,6 @@ import Text.Pandoc.Builder
import Text.Pandoc
import Tests.Helpers
import Tests.Arbitrary()
-import Text.Highlighting.Kate (languages) -- null if no hl support
html :: (ToString a, ToPandoc a) => a -> String
html = writeHtmlString def{ writerWrapText = False } . toPandoc
@@ -32,9 +31,7 @@ tests :: [Test]
tests = [ testGroup "inline code"
[ "basic" =: code "@&" =?> "<code>@&amp;</code>"
, "haskell" =: codeWith ("",["haskell"],[]) ">>="
- =?> if null languages
- then "<code class=\"haskell\">&gt;&gt;=</code>"
- else "<code class=\"sourceCode haskell\"><span class=\"fu\">&gt;&gt;=</span></code>"
+ =?> "<code class=\"haskell\">&gt;&gt;=</code>"
, "nolanguage" =: codeWith ("",["nolanguage"],[]) ">>="
=?> "<code class=\"nolanguage\">&gt;&gt;=</code>"
]
diff --git a/tests/Tests/Writers/LaTeX.hs b/tests/Tests/Writers/LaTeX.hs
index b1427d91f..c32ded36d 100644
--- a/tests/Tests/Writers/LaTeX.hs
+++ b/tests/Tests/Writers/LaTeX.hs
@@ -8,7 +8,10 @@ import Tests.Helpers
import Tests.Arbitrary()
latex :: (ToString a, ToPandoc a) => a -> String
-latex = writeLaTeX def . toPandoc
+latex = writeLaTeX def{ writerHighlight = True } . toPandoc
+
+latexListing :: (ToString a, ToPandoc a) => a -> String
+latexListing = writeLaTeX def{ writerListings = True } . toPandoc
{-
"my test" =: X =?> Y
@@ -31,9 +34,36 @@ 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\\itemsep1pt\\parskip0pt\\parsep0pt\n\\item[{\\hyperref[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*{Header 1\\footnote{note}}\\label{foo}\n\\addcontentsline{toc}{section}{Header 1}\n"
+ ]
+ , 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}"
+ ]
]
diff --git a/tests/Tests/Writers/Markdown.hs b/tests/Tests/Writers/Markdown.hs
index 99b85dfb7..c2a8f5903 100644
--- a/tests/Tests/Writers/Markdown.hs
+++ b/tests/Tests/Writers/Markdown.hs
@@ -31,4 +31,8 @@ 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"
]
diff --git a/tests/biblio.bib b/tests/biblio.bib
deleted file mode 100644
index 4eb2ba0d0..000000000
--- a/tests/biblio.bib
+++ /dev/null
@@ -1,26 +0,0 @@
-@Book{item1,
-author="John Doe",
-title="First Book",
-year="2005",
-address="Cambridge",
-publisher="Cambridge University Press"
-}
-
-@Article{item2,
-author="John Doe",
-title="Article",
-year="2006",
-journal="Journal of Generic Studies",
-volume="6",
-pages="33-34"
-}
-
-@InCollection{пункт3,
-author="John Doe and Jenny Roe",
-title="Why Water Is Wet",
-booktitle="Third Book",
-editor="Sam Smith",
-publisher="Oxford University Press",
-address="Oxford",
-year="2007"
-}
diff --git a/tests/chicago-author-date.csl b/tests/chicago-author-date.csl
deleted file mode 100644
index 83a70d0b5..000000000
--- a/tests/chicago-author-date.csl
+++ /dev/null
@@ -1,458 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never">
- <info>
- <title>Chicago Manual of Style (author-date)</title>
- <id>http://www.zotero.org/styles/chicago-author-date</id>
- <link href="http://www.zotero.org/styles/chicago-author-date" rel="self"/>
- <link href="http://www.chicagomanualofstyle.org/tools_citationguide.html" rel="documentation"/>
- <author>
- <name>Julian Onions</name>
- <email>julian.onions@gmail.com</email>
- </author>
- <contributor>
- <name>Sebastian Karcher</name>
- </contributor>
- <contributor>
- <name>Richard Karnesky</name>
- <email>karnesky+zotero@gmail.com</email>
- <uri>http://arc.nucapt.northwestern.edu/Richard_Karnesky</uri>
- </contributor>
- <category citation-format="author-date"/>
- <category field="generic-base"/>
- <summary>The author-date variant of the Chicago style</summary>
- <updated>2013-03-28T05:37:10+00:00</updated>
- <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
- </info>
- <locale>
- <terms>
- <term name="editor" form="verb-short">ed.</term>
- <term name="container-author" form="verb">by</term>
- <term name="translator" form="verb-short">trans.</term>
- <term name="translator" form="short">trans.</term>
- </terms>
- </locale>
- <macro name="secondary-contributors">
- <choose>
- <if type="chapter paper-conference" match="none">
- <group delimiter=". ">
- <names variable="editor translator">
- <label form="verb" text-case="capitalize-first" suffix=" " plural="never"/>
- <name and="text" delimiter=", "/>
- </names>
- </group>
- </if>
- </choose>
- </macro>
- <macro name="container-contributors">
- <choose>
- <if type="chapter paper-conference" match="any">
- <group prefix=", " delimiter=", ">
- <names variable="container-author editor" delimiter=", ">
- <label form="verb" suffix=" " plural="never"/>
- <name and="text" delimiter=", "/>
- </names>
- </group>
- </if>
- </choose>
- </macro>
- <macro name="editor">
- <names variable="editor">
- <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
- <label form="short" prefix=", "/>
- </names>
- </macro>
- <macro name="translator">
- <names variable="translator">
- <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
- <label form="short" prefix=", " plural="never"/>
- </names>
- </macro>
- <macro name="recipient">
- <choose>
- <if type="personal_communication">
- <choose>
- <if variable="genre">
- <text variable="genre" text-case="capitalize-first"/>
- </if>
- <else>
- <text term="letter" text-case="capitalize-first"/>
- </else>
- </choose>
- </if>
- </choose>
- <names variable="recipient" delimiter=", ">
- <label form="verb" prefix=" " text-case="lowercase" suffix=" "/>
- <name and="text" delimiter=", "/>
- </names>
- </macro>
- <macro name="contributors">
- <names variable="author">
- <name and="text" name-as-sort-order="first" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
- <label form="short" plural="never" prefix=", "/>
- <substitute>
- <names variable="editor"/>
- <names variable="translator"/>
- <text macro="title"/>
- </substitute>
- </names>
- <text macro="recipient"/>
- </macro>
- <macro name="contributors-short">
- <names variable="author">
- <name form="short" and="text" delimiter=", " initialize-with=". "/>
- <substitute>
- <names variable="editor"/>
- <names variable="translator"/>
- <text macro="title"/>
- </substitute>
- </names>
- </macro>
- <macro name="interviewer">
- <names variable="interviewer" delimiter=", ">
- <label form="verb" prefix=" " text-case="capitalize-first" suffix=" "/>
- <name and="text" delimiter=", "/>
- </names>
- </macro>
- <macro name="archive">
- <group delimiter=". ">
- <text variable="archive_location" text-case="capitalize-first"/>
- <text variable="archive"/>
- <text variable="archive-place"/>
- </group>
- </macro>
- <macro name="access">
- <group delimiter=". ">
- <choose>
- <if type="graphic report" match="any">
- <text macro="archive"/>
- </if>
- <else-if type="article-magazine article-newspaper bill book chapter graphic legal_case legislation motion_picture paper-conference report song thesis" match="none">
- <text macro="archive"/>
- </else-if>
- </choose>
- <text variable="DOI" prefix="doi:"/>
- <choose>
- <if variable="DOI issued" match="none">
- <choose>
- <if variable="URL accessed" match="all">
- <group delimiter=" ">
- <text term="accessed" text-case="capitalize-first"/>
- <date variable="accessed" delimiter=" ">
- <date-part name="month"/>
- <date-part name="day"/>
- </date>
- </group>
- </if>
- </choose>
- </if>
- <else-if type="webpage">
- <date variable="issued" delimiter=" ">
- <date-part name="month"/>
- <date-part name="day"/>
- </date>
- </else-if>
- </choose>
- <choose>
- <if type="legal_case" match="none">
- <text variable="URL"/>
- </if>
- </choose>
- </group>
- </macro>
- <macro name="title">
- <choose>
- <if variable="title" match="none">
- <choose>
- <if type="personal_communication" match="none">
- <text variable="genre" text-case="capitalize-first"/>
- </if>
- </choose>
- </if>
- <else-if type="bill book graphic legal_case legislation motion_picture song" match="any">
- <text variable="title" text-case="title" font-style="italic"/>
- </else-if>
- <else>
- <text variable="title" text-case="title" quotes="true"/>
- </else>
- </choose>
- </macro>
- <macro name="edition">
- <choose>
- <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
- <choose>
- <if is-numeric="edition">
- <group delimiter=" " prefix=". ">
- <number variable="edition" form="ordinal"/>
- <text term="edition" form="short" strip-periods="true"/>
- </group>
- </if>
- <else>
- <text variable="edition" prefix=". "/>
- </else>
- </choose>
- </if>
- <else-if type="chapter paper-conference" match="any">
- <choose>
- <if is-numeric="edition">
- <group delimiter=" " prefix=", ">
- <number variable="edition" form="ordinal"/>
- <text term="edition" form="short"/>
- </group>
- </if>
- <else>
- <text variable="edition" prefix=", "/>
- </else>
- </choose>
- </else-if>
- </choose>
- </macro>
- <macro name="locators">
- <choose>
- <if type="article-journal">
- <text variable="volume" prefix=" "/>
- <text variable="issue" prefix=" (" suffix=")"/>
- </if>
- <else-if type="legal_case">
- <text variable="volume" prefix=", "/>
- <text variable="container-title" prefix=" "/>
- <text variable="page" prefix=" "/>
- </else-if>
- <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
- <group prefix=". " delimiter=". ">
- <group>
- <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
- <number variable="volume" form="numeric"/>
- </group>
- <group>
- <number variable="number-of-volumes" form="numeric"/>
- <text term="volume" form="short" prefix=" " plural="true"/>
- </group>
- </group>
- </else-if>
- <else-if type="chapter paper-conference" match="any">
- <choose>
- <if variable="page" match="none">
- <group prefix=". ">
- <text term="volume" form="short" text-case="capitalize-first" suffix=" "/>
- <number variable="volume" form="numeric"/>
- </group>
- </if>
- </choose>
- </else-if>
- </choose>
- </macro>
- <macro name="locators-chapter">
- <choose>
- <if type="chapter paper-conference" match="any">
- <choose>
- <if variable="page">
- <group prefix=", ">
- <text variable="volume" suffix=":"/>
- <text variable="page"/>
- </group>
- </if>
- </choose>
- </if>
- </choose>
- </macro>
- <macro name="locators-article">
- <choose>
- <if type="article-newspaper">
- <group prefix=", " delimiter=", ">
- <group>
- <text variable="edition" suffix=" "/>
- <text term="edition" prefix=" "/>
- </group>
- <group>
- <text term="section" form="short" suffix=" "/>
- <text variable="section"/>
- </group>
- </group>
- </if>
- <else-if type="article-journal">
- <text variable="page" prefix=": "/>
- </else-if>
- </choose>
- </macro>
- <macro name="point-locators">
- <choose>
- <if variable="locator">
- <choose>
- <if locator="page" match="none">
- <choose>
- <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
- <choose>
- <if variable="volume">
- <group>
- <text term="volume" form="short" suffix=" "/>
- <number variable="volume" form="numeric"/>
- <label variable="locator" form="short" prefix=", " suffix=" "/>
- </group>
- </if>
- <else>
- <label variable="locator" form="short" suffix=" "/>
- </else>
- </choose>
- </if>
- <else>
- <label variable="locator" form="short" suffix=" "/>
- </else>
- </choose>
- </if>
- <else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
- <number variable="volume" form="numeric" suffix=":"/>
- </else-if>
- </choose>
- <text variable="locator"/>
- </if>
- </choose>
- </macro>
- <macro name="container-prefix">
- <text term="in" text-case="capitalize-first"/>
- </macro>
- <macro name="container-title">
- <choose>
- <if type="chapter paper-conference" match="any">
- <text macro="container-prefix" suffix=" "/>
- </if>
- </choose>
- <choose>
- <if type="legal_case" match="none">
- <text variable="container-title" text-case="title" font-style="italic"/>
- </if>
- </choose>
- </macro>
- <macro name="publisher">
- <group delimiter=": ">
- <text variable="publisher-place"/>
- <text variable="publisher"/>
- </group>
- </macro>
- <macro name="date">
- <choose>
- <if variable="issued">
- <date variable="issued">
- <date-part name="year"/>
- </date>
- </if>
- <else-if variable="accessed">
- <date variable="accessed">
- <date-part name="year"/>
- </date>
- </else-if>
- </choose>
- </macro>
- <macro name="day-month">
- <date variable="issued">
- <date-part name="month"/>
- <date-part name="day" prefix=" "/>
- </date>
- </macro>
- <macro name="collection-title">
- <text variable="collection-title" text-case="title"/>
- <text variable="collection-number" prefix=" "/>
- </macro>
- <macro name="event">
- <group>
- <text term="presented at" suffix=" "/>
- <text variable="event"/>
- </group>
- </macro>
- <macro name="description">
- <choose>
- <if type="interview">
- <group delimiter=". ">
- <text macro="interviewer"/>
- <text variable="medium" text-case="capitalize-first"/>
- </group>
- </if>
- <else>
- <text variable="medium" text-case="capitalize-first" prefix=". "/>
- </else>
- </choose>
- <choose>
- <if variable="title" match="none"/>
- <else-if type="thesis"/>
- <else>
- <group delimiter=" " prefix=". ">
- <text variable="genre" text-case="capitalize-first"/>
- <choose>
- <if type="report">
- <text variable="number"/>
- </if>
- </choose>
- </group>
- </else>
- </choose>
- <!--This is for computer programs only. Localization new to 1.0.1, so may be missing in many locales-->
- <group delimiter=" " prefix=" (" suffix=")">
- <text term="version"/>
- <text variable="version"/>
- </group>
- </macro>
- <macro name="issue">
- <choose>
- <if type="article-journal">
- <text macro="day-month" prefix=" (" suffix=")"/>
- </if>
- <else-if type="legal_case">
- <text variable="authority" prefix=". "/>
- </else-if>
- <else-if type="speech">
- <group prefix=" " delimiter=", ">
- <text macro="event"/>
- <text macro="day-month"/>
- <text variable="event-place"/>
- </group>
- </else-if>
- <else-if type="article-newspaper article-magazine" match="any">
- <text macro="day-month" prefix=", "/>
- </else-if>
- <else>
- <group prefix=". " delimiter=", ">
- <choose>
- <if type="thesis">
- <text variable="genre" text-case="capitalize-first"/>
- </if>
- </choose>
- <text macro="publisher"/>
- </group>
- </else>
- </choose>
- </macro>
- <citation et-al-min="4" et-al-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true" disambiguate-add-givenname="true" givenname-disambiguation-rule="primary-name">
- <layout prefix="(" suffix=")" delimiter="; ">
- <group delimiter=", ">
- <group delimiter=" ">
- <text macro="contributors-short"/>
- <text macro="date"/>
- </group>
- <text macro="point-locators"/>
- </group>
- </layout>
- </citation>
- <bibliography hanging-indent="true" et-al-min="11" et-al-use-first="7" subsequent-author-substitute="&#8212;&#8212;&#8212;" entry-spacing="0">
- <sort>
- <key macro="contributors"/>
- <key variable="issued"/>
- </sort>
- <layout suffix=".">
- <group delimiter=". ">
- <text macro="contributors"/>
- <text macro="date"/>
- <text macro="title"/>
- </group>
- <text macro="description"/>
- <text macro="secondary-contributors" prefix=". "/>
- <text macro="container-title" prefix=". "/>
- <text macro="container-contributors"/>
- <text macro="edition"/>
- <text macro="locators-chapter"/>
- <text macro="locators"/>
- <text macro="collection-title" prefix=". "/>
- <text macro="issue"/>
- <text macro="locators-article"/>
- <text macro="access" prefix=". "/>
- </layout>
- </bibliography>
-</style>
diff --git a/tests/docbook-reader.docbook b/tests/docbook-reader.docbook
index 6173fa50e..c76925917 100644
--- a/tests/docbook-reader.docbook
+++ b/tests/docbook-reader.docbook
@@ -4,14 +4,16 @@
<article>
<articleinfo>
<title>Pandoc Test Suite</title>
- <author>
- <firstname>John</firstname>
- <surname>MacFarlane</surname>
- </author>
- <author>
- <firstname></firstname>
- <surname>Anonymous</surname>
- </author>
+ <authorgroup>
+ <author>
+ <firstname>John</firstname>
+ <surname>MacFarlane</surname>
+ </author>
+ <author>
+ <firstname></firstname>
+ <surname>Anonymous</surname>
+ </author>
+ </authorgroup>
<date>July 17, 2006</date>
</articleinfo>
<para>
diff --git a/tests/docx.block_quotes.docx b/tests/docx.block_quotes.docx
new file mode 100644
index 000000000..729ae1f43
--- /dev/null
+++ b/tests/docx.block_quotes.docx
Binary files differ
diff --git a/tests/docx.block_quotes_parse_indent.native b/tests/docx.block_quotes_parse_indent.native
new file mode 100644
index 000000000..842b3606a
--- /dev/null
+++ b/tests/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/tests/docx.codeblock.docx b/tests/docx.codeblock.docx
new file mode 100644
index 000000000..8ec00953c
--- /dev/null
+++ b/tests/docx.codeblock.docx
Binary files differ
diff --git a/tests/docx.codeblock.native b/tests/docx.codeblock.native
new file mode 100644
index 000000000..441e33511
--- /dev/null
+++ b/tests/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/tests/docx.deep_normalize.docx b/tests/docx.deep_normalize.docx
new file mode 100644
index 000000000..7626d59ce
--- /dev/null
+++ b/tests/docx.deep_normalize.docx
Binary files differ
diff --git a/tests/docx.deep_normalize.native b/tests/docx.deep_normalize.native
new file mode 100644
index 000000000..9b2089ec8
--- /dev/null
+++ b/tests/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/tests/docx.definition_list.docx b/tests/docx.definition_list.docx
new file mode 100644
index 000000000..a19edda45
--- /dev/null
+++ b/tests/docx.definition_list.docx
Binary files differ
diff --git a/tests/docx.definition_list.native b/tests/docx.definition_list.native
new file mode 100644
index 000000000..2e08ff1ac
--- /dev/null
+++ b/tests/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/tests/docx.headers.docx b/tests/docx.headers.docx
new file mode 100644
index 000000000..630b6bfc5
--- /dev/null
+++ b/tests/docx.headers.docx
Binary files differ
diff --git a/tests/docx.headers.native b/tests/docx.headers.native
new file mode 100644
index 000000000..03f967728
--- /dev/null
+++ b/tests/docx.headers.native
@@ -0,0 +1,5 @@
+[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."]]
diff --git a/tests/docx.image.docx b/tests/docx.image.docx
new file mode 100644
index 000000000..060f2b204
--- /dev/null
+++ b/tests/docx.image.docx
Binary files differ
diff --git a/tests/docx.image_no_embed.native b/tests/docx.image_no_embed.native
new file mode 100644
index 000000000..063958bc7
--- /dev/null
+++ b/tests/docx.image_no_embed.native
@@ -0,0 +1,2 @@
+[Header 2 ("an-image",[],[]) [Str "An",Space,Str "image"]
+,Para [Image [] ("word/media/image1.jpeg","")]]
diff --git a/tests/docx.inline_code.docx b/tests/docx.inline_code.docx
new file mode 100644
index 000000000..75c5ea3cb
--- /dev/null
+++ b/tests/docx.inline_code.docx
Binary files differ
diff --git a/tests/docx.inline_code.native b/tests/docx.inline_code.native
new file mode 100644
index 000000000..11cf2777c
--- /dev/null
+++ b/tests/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/tests/docx.inline_formatting.docx b/tests/docx.inline_formatting.docx
new file mode 100644
index 000000000..eccf26425
--- /dev/null
+++ b/tests/docx.inline_formatting.docx
Binary files differ
diff --git a/tests/docx.inline_formatting.native b/tests/docx.inline_formatting.native
new file mode 100644
index 000000000..dc8a3d19a
--- /dev/null
+++ b/tests/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,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."]]
diff --git a/tests/docx.links.docx b/tests/docx.links.docx
new file mode 100644
index 000000000..10ec62fd7
--- /dev/null
+++ b/tests/docx.links.docx
Binary files differ
diff --git a/tests/docx.links.native b/tests/docx.links.native
new file mode 100644
index 000000000..c741fe875
--- /dev/null
+++ b/tests/docx.links.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 "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/tests/docx.lists.docx b/tests/docx.lists.docx
new file mode 100644
index 000000000..bf7fd8ae4
--- /dev/null
+++ b/tests/docx.lists.docx
Binary files differ
diff --git a/tests/docx.lists.native b/tests/docx.lists.native
new file mode 100644
index 000000000..af922b335
--- /dev/null
+++ b/tests/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/tests/docx.normalize.docx b/tests/docx.normalize.docx
new file mode 100644
index 000000000..5e4370a47
--- /dev/null
+++ b/tests/docx.normalize.docx
Binary files differ
diff --git a/tests/docx.normalize.native b/tests/docx.normalize.native
new file mode 100644
index 000000000..aeba672c4
--- /dev/null
+++ b/tests/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/tests/docx.notes.docx b/tests/docx.notes.docx
new file mode 100644
index 000000000..eb6fa12d4
--- /dev/null
+++ b/tests/docx.notes.docx
Binary files differ
diff --git a/tests/docx.notes.native b/tests/docx.notes.native
new file mode 100644
index 000000000..ec1b414b6
--- /dev/null
+++ b/tests/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/tests/docx.tables.docx b/tests/docx.tables.docx
new file mode 100644
index 000000000..7dcff8d35
--- /dev/null
+++ b/tests/docx.tables.docx
Binary files differ
diff --git a/tests/docx.tables.native b/tests/docx.tables.native
new file mode 100644
index 000000000..2564afcec
--- /dev/null
+++ b/tests/docx.tables.native
@@ -0,0 +1,24 @@
+[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]
+ [[Para [Str "Name"]]
+ ,[Para [Str "Game"]]
+ ,[Para [Str "Fame"]]
+ ,[Para [Str "Blame"]]]
+ [[[Para [Str "Lebron",Space,Str "James"]]
+ ,[Para [Str "Basketball"]]
+ ,[Para [Str "Very",Space,Str "High"]]
+ ,[Para [Str "Leaving",Space,Str "Cleveland"]]]
+ ,[[Para [Str "Ryan",Space,Str "Braun"]]
+ ,[Para [Str "Baseball"]]
+ ,[Para [Str "Moderate"]]
+ ,[Para [Str "Steroids"]]]
+ ,[[Para [Str "Russell",Space,Str "Wilson"]]
+ ,[Para [Str "Football"]]
+ ,[Para [Str "High"]]
+ ,[Para [Str "Tacky",Space,Str "uniform"]]]]
+,Table [] [AlignDefault,AlignDefault] [0.0,0.0]
+ []
+ [[[Para [Str "Sinple"]]
+ ,[Para [Str "Table"]]]
+ ,[[Para [Str "Without"]]
+ ,[Para [Str "Header"]]]]]
diff --git a/tests/docx.tabs.docx b/tests/docx.tabs.docx
new file mode 100644
index 000000000..6ff5f4bb1
--- /dev/null
+++ b/tests/docx.tabs.docx
Binary files differ
diff --git a/tests/docx.tabs.native b/tests/docx.tabs.native
new file mode 100644
index 000000000..05461f20b
--- /dev/null
+++ b/tests/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/tests/docx.track_changes_deletion.docx b/tests/docx.track_changes_deletion.docx
new file mode 100644
index 000000000..5cfdbeed8
--- /dev/null
+++ b/tests/docx.track_changes_deletion.docx
Binary files differ
diff --git a/tests/docx.track_changes_deletion_accept.native b/tests/docx.track_changes_deletion_accept.native
new file mode 100644
index 000000000..205c67810
--- /dev/null
+++ b/tests/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/tests/docx.track_changes_deletion_all.native b/tests/docx.track_changes_deletion_all.native
new file mode 100644
index 000000000..7f4ed2a90
--- /dev/null
+++ b/tests/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/tests/docx.track_changes_deletion_reject.native b/tests/docx.track_changes_deletion_reject.native
new file mode 100644
index 000000000..04283bee5
--- /dev/null
+++ b/tests/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/tests/docx.track_changes_insertion.docx b/tests/docx.track_changes_insertion.docx
new file mode 100644
index 000000000..fbdc9003e
--- /dev/null
+++ b/tests/docx.track_changes_insertion.docx
Binary files differ
diff --git a/tests/docx.track_changes_insertion_accept.native b/tests/docx.track_changes_insertion_accept.native
new file mode 100644
index 000000000..ca2e46df0
--- /dev/null
+++ b/tests/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/tests/docx.track_changes_insertion_all.native b/tests/docx.track_changes_insertion_all.native
new file mode 100644
index 000000000..12664e425
--- /dev/null
+++ b/tests/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/tests/docx.track_changes_insertion_reject.native b/tests/docx.track_changes_insertion_reject.native
new file mode 100644
index 000000000..def000abd
--- /dev/null
+++ b/tests/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/tests/docx.trailing_spaces_in_formatting.docx b/tests/docx.trailing_spaces_in_formatting.docx
new file mode 100644
index 000000000..ebe7404a9
--- /dev/null
+++ b/tests/docx.trailing_spaces_in_formatting.docx
Binary files differ
diff --git a/tests/docx.trailing_spaces_in_formatting.native b/tests/docx.trailing_spaces_in_formatting.native
new file mode 100644
index 000000000..46ea9bca8
--- /dev/null
+++ b/tests/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/tests/docx.unicode.docx b/tests/docx.unicode.docx
new file mode 100644
index 000000000..78d0107a1
--- /dev/null
+++ b/tests/docx.unicode.docx
Binary files differ
diff --git a/tests/docx.unicode.native b/tests/docx.unicode.native
new file mode 100644
index 000000000..e636355c7
--- /dev/null
+++ b/tests/docx.unicode.native
@@ -0,0 +1 @@
+[Para [Str "Hello,",Space,Str "\19990\30028.",Space,Str "This",Space,Str "costs",Space,Str "\8364\&10."]]
diff --git a/tests/haddock-reader.haddock b/tests/haddock-reader.haddock
index c4f6d6c36..c3ef0c9fc 100644
--- a/tests/haddock-reader.haddock
+++ b/tests/haddock-reader.haddock
@@ -18,10 +18,10 @@ This is a code block:
This is another code block:
@
- f x = x + x.
- The \@...\@ code block /interprets markup normally/.
- "Module.Foo"
- \"Hello World\"
+f x = x + x.
+The \@...\@ code block /interprets markup normally/.
+"Module.Foo"
+\"Hello World\"
@
Haddock supports REPL examples:
@@ -42,21 +42,21 @@ This is a reference to the "Foo" module.
This is a bulleted list:
- * first item
+ * first item
- * second item
+ * second item
This is an enumerated list:
- (1) first item
+ (1) first item
- 2. second item
+ 2. second item
This is a definition list:
- [@foo@] The description of @foo@.
+ [@foo@] The description of @foo@.
- [@bar@] The description of @bar@.
+ [@bar@] The description of @bar@.
Here is a link: <http://haskell.org>
diff --git a/tests/haddock-reader.native b/tests/haddock-reader.native
index 877719b50..b62189046 100644
--- a/tests/haddock-reader.native
+++ b/tests/haddock-reader.native
@@ -4,14 +4,14 @@ Pandoc (Meta {unMeta = fromList []})
,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.",Space,Str ">",Space,Str "This",Space,Str "sentence",Space,Str "is",Space,Str "not",Space,Str "code.",Space,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 ("",["haskell"],[]) " map :: (a -> b) -> [a] -> [b]\n map _ [] = []\n map f (x:xs) = f x : map f xs\n"
+,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",Space,Code ("",[],[]) "x",Space,Code ("",[],[]) "=",Space,Code ("",[],[]) "x",Space,Code ("",[],[]) "+",Space,Code ("",[],[]) "x.",Space,Code ("",[],[]) "The",Space,Code ("",[],[]) "@...@",Space,Code ("",[],[]) "code",Space,Code ("",[],[]) "block",Space,Emph [Code ("",[],[]) "interprets markup normally"],Code ("",[],[]) ".",Space,Code ("",["haskell"],[]) "Module.Foo",Space,Code ("",[],[]) "\"Hello",Space,Code ("",[],[]) "World\""]
+,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 ("",["haskell","expr"],[]) "fib 10",LineBreak,Code ("",["result"],[]) "55"]
-,Para [Code ("",["haskell","expr"],[]) "putStrLn \"foo\\nbar\"",LineBreak,Code ("",["result"],[]) "foo",LineBreak,Code ("",["result"],[]) "bar"]
-,Para [Str "That",Space,Str "was",Space,Emph [Str "really cool"],Str "!",Space,Str "I",Space,Str "had",Space,Str "no",Space,Str "idea",Space,Code ("",[],[]) "fib",Space,Code ("",[],[]) "10",Space,Code ("",[],[]) "=",Space,Code ("",[],[]) "55",Str "."]
-,Para [Str "This",Space,Str "module",Space,Str "defines",Space,Str "the",Space,Str "type",Space,Code ("",["haskell"],[]) "T",Str ".",Space,Str "The",Space,Str "identifier",Space,Code ("",["haskell"],[]) "M.T",Space,Str "is",Space,Str "not",Space,Str "in",Space,Str "scope",Space,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?",Space,Str "This",Space,Str "is",Space,Str "a",Space,Str "reference",Space,Str "to",Space,Str "the",Space,Code ("",["haskell"],[]) "Foo",Space,Str "module."]
+,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 "!",Space,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 ".",Space,Str "The",Space,Str "identifier",Space,Code ("",["haskell","identifier"],[]) "M.T",Space,Str "is",Space,Str "not",Space,Str "in",Space,Str "scope",Space,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?",Space,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"]]
@@ -23,9 +23,9 @@ Pandoc (Meta {unMeta = fromList []})
,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "definition",Space,Str "list:"]
,DefinitionList
[([Code ("",[],[]) "foo"],
- [[Plain [Str "The",Space,Str "description",Space,Str "of",Space,Code ("",[],[]) "foo",Str "."]]])
+ [[Para [Str "The",Space,Str "description",Space,Str "of",Space,Code ("",[],[]) "foo",Str "."]]])
,([Code ("",[],[]) "bar"],
- [[Plain [Str "The",Space,Str "description",Space,Str "of",Space,Code ("",[],[]) "bar",Str "."]]])]
+ [[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/tests/html-reader.html b/tests/html-reader.html
index 69bb9ba8a..d059d7b4b 100644
--- a/tests/html-reader.html
+++ b/tests/html-reader.html
@@ -302,6 +302,7 @@ These should not be escaped: \$ \\ \> \[ \{
<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>
@@ -426,5 +427,28 @@ An e-mail address: nobody [at] nowhere.net<blockquote>
<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>
+<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>
+</body>
</body>
</html>
diff --git a/tests/html-reader.native b/tests/html-reader.native
index 15937e594..c6ed36910 100644
--- a/tests/html-reader.native
+++ b/tests/html-reader.native
@@ -1,5 +1,5 @@
-Pandoc (Meta {unMeta = fromList [("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",Str ".",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",Space,Str "Gruber",Str "'",Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."]
+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 ("",[],[]) [Str "Headers"]
,Header 2 ("",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]
@@ -14,15 +14,15 @@ Pandoc (Meta {unMeta = fromList [("title",MetaInlines [Str "Pandoc",Space,Str "T
,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
,HorizontalRule
,Header 1 ("",[],[]) [Str "Paragraphs"]
-,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Str "regular",Space,Str "paragraph",Str "."]
-,Para [Str "In",Space,Str "Markdown",Space,Str "1",Str ".",Str "0",Str ".",Str "0",Space,Str "and",Space,Str "earlier",Str ".",Space,Str "Version",Space,Str "8",Str ".",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item",Str ".",Space,Str "Because",Space,Str "a",Space,Str "hard",Str "-",Str "wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item",Str "."]
-,Para [Str "Here",Str "'",Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str ".",Space,Str "*",Space,Str "criminey",Str "."]
-,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Space,Str "here",Str "."]
+,Para [Str "Here's",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
+,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]
+,Para [Str "Here's",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]
+,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Space,Str "here."]
,HorizontalRule
,Header 1 ("",[],[]) [Str "Block",Space,Str "Quotes"]
-,Para [Str "E",Str "-",Str "mail",Space,Str "style:"]
+,Para [Str "E-mail",Space,Str "style:"]
,BlockQuote
- [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote",Str ".",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short",Str "."]]
+ [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}"
@@ -35,8 +35,8 @@ Pandoc (Meta {unMeta = fromList [("title",MetaInlines [Str "Pandoc",Space,Str "T
[Para [Str "nested"]]
,BlockQuote
[Para [Str "nested"]]]
-,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "a",Space,Str "block",Space,Str "quote:",Space,Str "2",Space,Str ">",Space,Str "1",Str "."]
-,Para [Str "Box",Str "-",Str "style:"]
+,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}"]
@@ -44,12 +44,12 @@ Pandoc (Meta {unMeta = fromList [("title",MetaInlines [Str "Pandoc",Space,Str "T
[OrderedList (1,DefaultStyle,DefaultDelim)
[[Plain [Str "do",Space,Str "laundry"]]
,[Plain [Str "take",Space,Str "out",Space,Str "the",Space,Str "trash"]]]]
-,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Str "nested",Space,Str "one:"]
+,Para [Str "Here's",Space,Str "a",Space,Str "nested",Space,Str "one:"]
,BlockQuote
[Para [Str "Joe",Space,Str "said:"]
,BlockQuote
- [Para [Str "Don",Str "'",Str "t",Space,Str "quote",Space,Str "me",Str "."]]]
-,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]
+ [Para [Str "Don't",Space,Str "quote",Space,Str "me."]]]
+,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph."]
,HorizontalRule
,Header 1 ("",[],[]) [Str "Code",Space,Str "Blocks"]
,Para [Str "Code:"]
@@ -112,10 +112,10 @@ Pandoc (Meta {unMeta = fromList [("title",MetaInlines [Str "Pandoc",Space,Str "T
,[Para [Str "Three"]]]
,Para [Str "Multiple",Space,Str "paragraphs:"]
,OrderedList (1,DefaultStyle,DefaultDelim)
- [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one",Str "."]
- ,Para [Str "Item",Space,Str "1",Str ".",Space,Str "graf",Space,Str "two",Str ".",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog",Str "'",Str "s",Space,Str "back",Str "."]]
- ,[Para [Str "Item",Space,Str "2",Str "."]]
- ,[Para [Str "Item",Space,Str "3",Str "."]]]
+ [[Para [Str "Item",Space,Str "1,",Space,Str "graf",Space,Str "one."]
+ ,Para [Str "Item",Space,Str "1.",Space,Str "graf",Space,Str "two.",Space,Str "The",Space,Str "quick",Space,Str "brown",Space,Str "fox",Space,Str "jumped",Space,Str "over",Space,Str "the",Space,Str "lazy",Space,Str "dog's",Space,Str "back."]]
+ ,[Para [Str "Item",Space,Str "2."]]
+ ,[Para [Str "Item",Space,Str "3."]]]
,Header 2 ("",[],[]) [Str "Nested"]
,BulletList
[[Plain [Str "Tab"]
@@ -123,7 +123,7 @@ Pandoc (Meta {unMeta = fromList [("title",MetaInlines [Str "Pandoc",Space,Str "T
[[Plain [Str "Tab"]
,BulletList
[[Plain [Str "Tab"]]]]]]]
-,Para [Str "Here",Str "'",Str "s",Space,Str "another:"]
+,Para [Str "Here's",Space,Str "another:"]
,OrderedList (1,DefaultStyle,DefaultDelim)
[[Plain [Str "First"]]
,[Plain [Str "Second:"]
@@ -163,63 +163,64 @@ Pandoc (Meta {unMeta = fromList [("title",MetaInlines [Str "Pandoc",Space,Str "T
,OrderedList (1,UpperAlpha,DefaultDelim)
[[Plain [Str "Upper",Space,Str "Alpha"]
,OrderedList (1,UpperRoman,DefaultDelim)
- [[Plain [Str "Upper",Space,Str "Roman",Str "."]
+ [[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",Str "."]]
- ,[Plain [Str "More",Str "."]
+ [[Plain [Str "Autonumber."]]
+ ,[Plain [Str "More."]
,OrderedList (1,DefaultStyle,DefaultDelim)
- [[Plain [Str "Nested",Str "."]]]]]
+ [[Plain [Str "Nested."]]]]]
,HorizontalRule
,Header 2 ("",[],[]) [Str "Definition"]
,DefinitionList
[([Str "Violin"],
- [[Plain [Str "Stringed",Space,Str "musical",Space,Str "instrument",Str "."]]
- ,[Plain [Str "Torture",Space,Str "device",Str "."]]])
+ [[Plain [Str "Stringed",Space,Str "musical",Space,Str "instrument."]]
+ ,[Plain [Str "Torture",Space,Str "device."]]])
,([Str "Cello",LineBreak,Str "Violoncello"],
- [[Plain [Str "Low",Str "-",Str "voiced",Space,Str "stringed",Space,Str "instrument",Str "."]]])]
+ [[Plain [Str "Low-voiced",Space,Str "stringed",Space,Str "instrument."]]])]
,HorizontalRule
,Header 1 ("",[],[]) [Str "Inline",Space,Str "Markup"]
,Para [Str "This",Space,Str "is",Space,Emph [Str "emphasized"],Str ",",Space,Str "and",Space,Str "so",Space,Emph [Str "is",Space,Str "this"],Str "."]
,Para [Str "This",Space,Str "is",Space,Strong [Str "strong"],Str ",",Space,Str "and",Space,Str "so",Space,Strong [Str "is",Space,Str "this"],Str "."]
+,Para [Str "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",Str "."]]]
-,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]
-,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]]]
-,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Str "."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
+,Para [Strong [Emph [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em."]]]
+,Para [Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word."]
,Para [Str "This",Space,Str "is",Space,Str "code:",Space,Code ("",[],[]) ">",Str ",",Space,Code ("",[],[]) "$",Str ",",Space,Code ("",[],[]) "\\",Str ",",Space,Code ("",[],[]) "\\$",Str ",",Space,Code ("",[],[]) "<html>",Str "."]
,HorizontalRule
,Header 1 ("",[],[]) [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
-,Para [Str "\"",Str "Hello,",Str "\"",Space,Str "said",Space,Str "the",Space,Str "spider",Str ".",Space,Str "\"",Str "'",Str "Shelob",Str "'",Space,Str "is",Space,Str "my",Space,Str "name",Str ".",Str "\""]
-,Para [Str "'",Str "A",Str "'",Str ",",Space,Str "'",Str "B",Str "'",Str ",",Space,Str "and",Space,Str "'",Str "C",Str "'",Space,Str "are",Space,Str "letters",Str "."]
-,Para [Str "'",Str "Oak,",Str "'",Space,Str "'",Str "elm,",Str "'",Space,Str "and",Space,Str "'",Str "beech",Str "'",Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees",Str ".",Space,Str "So",Space,Str "is",Space,Str "'",Str "pine",Str ".",Str "'"]
-,Para [Str "'",Str "He",Space,Str "said,",Space,Str "\"",Str "I",Space,Str "want",Space,Str "to",Space,Str "go",Str ".",Str "\"",Str "'",Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70",Str "'",Str "s?"]
-,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Str "'",Code ("",[],[]) "code",Str "'",Space,Str "and",Space,Str "a",Space,Str "\"",Link [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2",""),Str "\"",Str "."]
-,Para [Str "Some",Space,Str "dashes:",Space,Str "one",Str "-",Str "-",Str "-",Str "two",Space,Str "-",Str "-",Str "-",Space,Str "three",Str "-",Str "-",Str "four",Space,Str "-",Str "-",Space,Str "five",Str "."]
-,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5",Str "-",Str "7,",Space,Str "255",Str "-",Str "66,",Space,Str "1987",Str "-",Str "1999",Str "."]
-,Para [Str "Ellipses",Str ".",Str ".",Str ".",Str "and",Str ".",Space,Str ".",Space,Str ".",Str "and",Space,Str ".",Space,Str ".",Space,Str ".",Space,Str "."]
+,Para [Str "\"Hello,\"",Space,Str "said",Space,Str "the",Space,Str "spider.",Space,Str "\"'Shelob'",Space,Str "is",Space,Str "my",Space,Str "name.\""]
+,Para [Str "'A',",Space,Str "'B',",Space,Str "and",Space,Str "'C'",Space,Str "are",Space,Str "letters."]
+,Para [Str "'Oak,'",Space,Str "'elm,'",Space,Str "and",Space,Str "'beech'",Space,Str "are",Space,Str "names",Space,Str "of",Space,Str "trees.",Space,Str "So",Space,Str "is",Space,Str "'pine.'"]
+,Para [Str "'He",Space,Str "said,",Space,Str "\"I",Space,Str "want",Space,Str "to",Space,Str "go.\"'",Space,Str "Were",Space,Str "you",Space,Str "alive",Space,Str "in",Space,Str "the",Space,Str "70's?"]
+,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Str "quoted",Space,Str "'",Code ("",[],[]) "code",Str "'",Space,Str "and",Space,Str "a",Space,Str "\"",Link [Str "quoted",Space,Str "link"] ("http://example.com/?foo=1&bar=2",""),Str "\"."]
+,Para [Str "Some",Space,Str "dashes:",Space,Str "one---two",Space,Str "---",Space,Str "three--four",Space,Str "--",Space,Str "five."]
+,Para [Str "Dashes",Space,Str "between",Space,Str "numbers:",Space,Str "5-7,",Space,Str "255-66,",Space,Str "1987-1999."]
+,Para [Str "Ellipses...and.",Space,Str ".",Space,Str ".and",Space,Str ".",Space,Str ".",Space,Str ".",Space,Str "."]
,HorizontalRule
,Header 1 ("",[],[]) [Str "LaTeX"]
,BulletList
- [[Plain [Str "\\cite[22",Str "-",Str "23]{smith",Str ".",Str "1899}"]]
+ [[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$",Str "-",Str "Tree"]]
- ,[Plain [Str "$\\frac{d}{dx}f(x)=\\lim_{h\\to",Space,Str "0}\\frac{f(x+h)",Str "-",Str "f(x)}{h}$"]]
- ,[Plain [Str "Here",Str "'",Str "s",Space,Str "one",Space,Str "that",Space,Str "has",Space,Str "a",Space,Str "line",Space,Str "break",Space,Str "in",Space,Str "it:",Space,Str "$\\alpha",Space,Str "+",Space,Str "\\omega",Space,Str "\\times",Space,Str "x^2$",Str "."]]]
-,Para [Str "These",Space,Str "shouldn",Str "'",Str "t",Space,Str "be",Space,Str "math:"]
+ ,[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",Str ".",Space,Str "So",Space,Str "is",Space,Str "$34,000",Str ".",Space,Str "(It",Space,Str "worked",Space,Str "if",Space,Str "\"",Str "lot",Str "\"",Space,Str "is",Space,Str "emphasized",Str ".",Str ")"]]
- ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23$",Str "."]]]
-,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"]
+ ,[Plain [Str "$22,000",Space,Str "is",Space,Str "a",Space,Emph [Str "lot"],Space,Str "of",Space,Str "money.",Space,Str "So",Space,Str "is",Space,Str "$34,000.",Space,Str "(It",Space,Str "worked",Space,Str "if",Space,Str "\"lot\"",Space,Str "is",Space,Str "emphasized.)"]]
+ ,[Plain [Str "Escaped",Space,Code ("",[],[]) "$",Str ":",Space,Str "$73",Space,Emph [Str "this",Space,Str "should",Space,Str "be",Space,Str "emphasized"],Space,Str "23$."]]]
+,Para [Str "Here's",Space,Str "a",Space,Str "LaTeX",Space,Str "table:"]
,Para [Str "\\begin{tabular}{|l|l|}\\hline",Space,Str "Animal",Space,Str "&",Space,Str "Number",Space,Str "\\\\",Space,Str "\\hline",Space,Str "Dog",Space,Str "&",Space,Str "2",Space,Str "\\\\",Space,Str "Cat",Space,Str "&",Space,Str "1",Space,Str "\\\\",Space,Str "\\hline",Space,Str "\\end{tabular}"]
,HorizontalRule
,Header 1 ("",[],[]) [Str "Special",Space,Str "Characters"]
@@ -230,11 +231,11 @@ Pandoc (Meta {unMeta = fromList [("title",MetaInlines [Str "Pandoc",Space,Str "T
,[Plain [Str "section:",Space,Str "\167"]]
,[Plain [Str "set",Space,Str "membership:",Space,Str "\8712"]]
,[Plain [Str "copyright:",Space,Str "\169"]]]
-,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name",Str "."]
-,Para [Str "AT&T",Space,Str "is",Space,Str "another",Space,Str "way",Space,Str "to",Space,Str "write",Space,Str "it",Str "."]
-,Para [Str "This",Space,Str "&",Space,Str "that",Str "."]
-,Para [Str "4",Space,Str "<",Space,Str "5",Str "."]
-,Para [Str "6",Space,Str ">",Space,Str "5",Str "."]
+,Para [Str "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 "*"]
@@ -245,7 +246,7 @@ Pandoc (Meta {unMeta = fromList [("title",MetaInlines [Str "Pandoc",Space,Str "T
,Para [Str "Right",Space,Str "bracket:",Space,Str "]"]
,Para [Str "Left",Space,Str "paren:",Space,Str "("]
,Para [Str "Right",Space,Str "paren:",Space,Str ")"]
-,Para [Str "Greater",Str "-",Str "than:",Space,Str ">"]
+,Para [Str "Greater-than:",Space,Str ">"]
,Para [Str "Hash:",Space,Str "#"]
,Para [Str "Period:",Space,Str "."]
,Para [Str "Bang:",Space,Str "!"]
@@ -260,47 +261,62 @@ Pandoc (Meta {unMeta = fromList [("title",MetaInlines [Str "Pandoc",Space,Str "T
,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",Str ".",Str "net)"]
+,Para [Str "Email",Space,Str "link",Space,Str "(nobody",Space,Str "[at]",Space,Str "nowhere.net)"]
,Para [Link [Str "Empty"] ("",""),Str "."]
,Header 2 ("",[],[]) [Str "Reference"]
,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
,Para [Str "With",Space,Link [Str "embedded",Space,Str "[brackets]"] ("/url/",""),Str "."]
-,Para [Link [Str "b"] ("/url/",""),Space,Str "by",Space,Str "itself",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "link",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",Str "."]
+,Para [Str "This",Space,Str "should",Space,Str "[not]",Space,Str "be",Space,Str "a",Space,Str "link."]
,CodeBlock ("",[],[]) "[not]: /url"
,Para [Str "Foo",Space,Link [Str "bar"] ("/url/","Title with \"quotes\" inside"),Str "."]
,Para [Str "Foo",Space,Link [Str "biz"] ("/url/","Title with \"quote\" inside"),Str "."]
,Header 2 ("",[],[]) [Str "With",Space,Str "ampersands"]
-,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Link [Str "link",Space,Str "with",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "the",Space,Str "URL"] ("http://example.com/?foo=1&bar=2",""),Str "."]
-,Para [Str "Here",Str "'",Str "s",Space,Str "a",Space,Str "link",Space,Str "with",Space,Str "an",Space,Str "amersand",Space,Str "in",Space,Str "the",Space,Str "link",Space,Str "text:",Space,Link [Str "AT&T"] ("http://att.com/","AT&T"),Str "."]
-,Para [Str "Here",Str "'",Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link"] ("/script?foo=1&bar=2",""),Str "."]
-,Para [Str "Here",Str "'",Str "s",Space,Str "an",Space,Link [Str "inline",Space,Str "link",Space,Str "in",Space,Str "pointy",Space,Str "braces"] ("/script?foo=1&bar=2",""),Str "."]
+,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 ("",[],[]) [Str "Autolinks"]
-,Para [Str "With",Space,Str "an",Space,Str "ampersand:",Space,Link [Str "http://example",Str ".",Str "com/?foo=1&bar=2"] ("http://example.com/?foo=1&bar=2","")]
+,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",Str ".",Str "com/"] ("http://example.com/","")]]
- ,[Plain [Str "It",Space,Str "should",Str "."]]]
-,Para [Str "An",Space,Str "e",Str "-",Str "mail",Space,Str "address:",Space,Str "nobody",Space,Str "[at]",Space,Str "nowhere",Str ".",Str "net"]
+ ,[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",Str ".",Str "com/"] ("http://example.com/","")]]
-,Para [Str "Auto",Str "-",Str "links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"]
+ [Para [Str "Blockquoted:",Space,Link [Str "http://example.com/"] ("http://example.com/","")]]
+,Para [Str "Auto-links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"]
,CodeBlock ("",[],[]) "or here: <http://example.com/>"
,HorizontalRule
,Header 1 ("",[],[]) [Str "Images"]
-,Para [Str "From",Space,Str "\"",Str "Voyage",Space,Str "dans",Space,Str "la",Space,Str "Lune",Str "\"",Space,Str "by",Space,Str "Georges",Space,Str "Melies",Space,Str "(1902):"]
+,Para [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",Str "."]
+,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "movie",Space,Image [Str "movie"] ("movie.jpg",""),Space,Str "icon."]
,HorizontalRule
,Header 1 ("",[],[]) [Str "Footnotes"]
-,Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "footnote",Space,Str "reference",Link [Str "(1)"] ("#note_1",""),Str ",",Space,Str "and",Space,Str "another",Link [Str "(longnote)"] ("#note_longnote",""),Str ".",Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space^(my",Space,Str "note)",Str "."]
-,Para [Link [Str "(1)"] ("#ref_1",""),Space,Str "Here",Space,Str "is",Space,Str "the",Space,Str "footnote",Str ".",Space,Str "It",Space,Str "can",Space,Str "go",Space,Str "anywhere",Space,Str "in",Space,Str "the",Space,Str "document,",Space,Str "not",Space,Str "just",Space,Str "at",Space,Str "the",Space,Str "end",Str "."]
-,Para [Link [Str "(longnote)"] ("#ref_longnote",""),Space,Str "Here",Str "'",Str "s",Space,Str "the",Space,Str "other",Space,Str "note",Str ".",Space,Str "This",Space,Str "one",Space,Str "contains",Space,Str "multiple",Space,Str "blocks",Str "."]
-,Para [Str "Caret",Space,Str "characters",Space,Str "are",Space,Str "used",Space,Str "to",Space,Str "indicate",Space,Str "that",Space,Str "the",Space,Str "blocks",Space,Str "all",Space,Str "belong",Space,Str "to",Space,Str "a",Space,Str "single",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "block",Space,Str "quotes)",Str "."]
+,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",Str "."]]
+,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 ("",[],[]) [Str "Tables"]
+,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"]]]]]
diff --git a/tests/ieee.csl b/tests/ieee.csl
deleted file mode 100644
index cd7ba4943..000000000
--- a/tests/ieee.csl
+++ /dev/null
@@ -1,302 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only">
- <info>
- <title>IEEE</title>
- <id>http://www.zotero.org/styles/ieee</id>
- <link href="http://www.zotero.org/styles/ieee" rel="self"/>
- <author>
- <name>Michael Berkowitz</name>
- <email>mberkowi@gmu.edu</email>
- </author>
- <contributor>
- <name>Julian Onions</name>
- <email>julian.onions@gmail.com</email>
- </contributor>
- <contributor>
- <name>Rintze Zelle</name>
- <uri>http://twitter.com/rintzezelle</uri>
- </contributor>
- <contributor>
- <name>Stephen Frank</name>
- <uri>http://www.zotero.org/sfrank</uri>
- </contributor>
- <contributor>
- <name>Sebastian Karcher</name>
- </contributor>
- <category field="engineering"/>
- <category field="generic-base"/>
- <category citation-format="numeric"/>
- <updated>2011-09-15T07:01:02+00:00</updated>
- <rights>
- This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License:
- http://creativecommons.org/licenses/by-sa/3.0/
- </rights>
- <link href="http://www.ieee.org/portal/cms_docs_iportals/iportals/publications/authors/transjnl/stylemanual.pdf" rel="documentation"/>
- <link href="http://www.ieee.org/documents/auinfo07.pdf" rel="documentation"/>
- </info>
- <!-- Macros -->
- <macro name="edition">
- <choose>
- <if type="bill book graphic legal_case motion_picture report song chapter paper-conference" match="any">
- <choose>
- <if is-numeric="edition">
- <group delimiter=" ">
- <number variable="edition" form="ordinal"/>
- <text term="edition" form="short" suffix="." strip-periods="true"/>
- </group>
- </if>
- <else>
- <text variable="edition" text-case="capitalize-first" suffix="."/>
- </else>
- </choose>
- </if>
- </choose>
- </macro>
- <macro name="issued">
- <choose>
- <if type="article-journal report" match="any">
- <date variable="issued">
- <date-part name="month" form="short" suffix=" "/>
- <date-part name="year" form="long"/>
- </date>
- </if>
- <else-if type="bill book graphic legal_case motion_picture song thesis chapter paper-conference" match="any">
- <date variable="issued">
- <date-part name="year" form="long"/>
- </date>
- </else-if>
- <else>
- <date variable="issued">
- <date-part name="day" form="numeric-leading-zeros" suffix="-"/>
- <date-part name="month" form="short" suffix="-" strip-periods="true"/>
- <date-part name="year" form="long"/>
- </date>
- </else>
- </choose>
- </macro>
- <macro name="author">
- <names variable="author">
- <name initialize-with=". " delimiter=", " and="text"/>
- <label form="short" prefix=", " text-case="capitalize-first" suffix="." strip-periods="true"/>
- <substitute>
- <names variable="editor"/>
- <names variable="translator"/>
- </substitute>
- </names>
- </macro>
- <macro name="editor">
- <names variable="editor">
- <name initialize-with=". " delimiter=", " and="text"/>
- <label form="short" prefix=", " text-case="capitalize-first" suffix="." strip-periods="true"/>
- </names>
- </macro>
- <macro name="locators">
- <group delimiter=", ">
- <text macro="edition"/>
- <group delimiter=" ">
- <text term="volume" form="short" suffix="." strip-periods="true"/>
- <number variable="volume" form="numeric"/>
- </group>
- <group delimiter=" ">
- <number variable="number-of-volumes" form="numeric"/>
- <text term="volume" form="short" suffix="." plural="true" strip-periods="true"/>
- </group>
- <group delimiter=" ">
- <text term="issue" form="short" suffix="." strip-periods="true"/>
- <number variable="issue" form="numeric"/>
- </group>
- </group>
- </macro>
- <macro name="title">
- <choose>
- <if type="bill book graphic legal_case motion_picture song" match="any">
- <text variable="title" font-style="italic"/>
- </if>
- <else>
- <text variable="title" quotes="true"/>
- </else>
- </choose>
- </macro>
- <macro name="publisher">
- <choose>
- <if type="bill book graphic legal_case motion_picture song chapter paper-conference" match="any">
- <text variable="publisher-place" suffix=": "/>
- <text variable="publisher"/>
- </if>
- <else>
- <group delimiter=", ">
- <text variable="publisher"/>
- <text variable="publisher-place"/>
- </group>
- </else>
- </choose>
- </macro>
- <macro name="event">
- <choose>
- <if type="paper-conference">
- <choose>
- <!-- Published Conference Paper -->
- <if variable="container-title">
- <group delimiter=", ">
- <text variable="container-title" prefix="in " font-style="italic"/>
- <text variable="event-place"/>
- </group>
- </if>
- <!-- Unpublished Conference Paper -->
- <else>
- <group delimiter=", ">
- <text variable="event" prefix="presented at the "/>
- <text variable="event-place"/>
- </group>
- </else>
- </choose>
- </if>
- </choose>
- </macro>
- <macro name="access">
- <choose>
- <if type="webpage">
- <choose>
- <if variable="URL">
- <group delimiter=". ">
- <text value="[Online]"/>
- <text variable="URL" prefix="Available: "/>
- <group prefix="[" suffix="]">
- <date variable="accessed" prefix="Accessed: ">
- <date-part name="day" form="numeric-leading-zeros" suffix="-"/>
- <date-part name="month" form="short" suffix="-" strip-periods="true"/>
- <date-part name="year" form="long"/>
- </date>
- </group>
- </group>
- </if>
- </choose>
- </if>
- </choose>
- </macro>
- <macro name="page">
- <group>
- <label variable="page" form="short" suffix=". " strip-periods="true"/>
- <text variable="page"/>
- </group>
- </macro>
- <!-- Citation -->
- <citation collapse="citation-number">
- <sort>
- <key variable="citation-number"/>
- </sort>
- <layout prefix="[" suffix="]" delimiter="], [">
- <text variable="citation-number"/>
- </layout>
- </citation>
- <!-- Bibliography -->
- <bibliography entry-spacing="0" second-field-align="flush">
- <layout suffix=".">
- <!-- Citation Number -->
- <text variable="citation-number" prefix="[" suffix="]"/>
- <!-- Author(s) -->
- <text macro="author" prefix=" " suffix=", "/>
- <!-- Rest of Citation -->
- <choose>
- <!-- Specific Formats -->
- <if type="article-journal">
- <group delimiter=", ">
- <text macro="title"/>
- <text variable="container-title" font-style="italic" form="short"/>
- <text macro="locators"/>
- <text macro="page"/>
- <text macro="issued"/>
- </group>
- </if>
- <else-if type="paper-conference">
- <group delimiter=", ">
- <text macro="title"/>
- <text macro="event"/>
- <text macro="issued"/>
- <text macro="locators"/>
- <text macro="page"/>
- </group>
- </else-if>
- <else-if type="report">
- <group delimiter=", ">
- <text macro="title"/>
- <text macro="publisher"/>
- <group delimiter=" ">
- <text variable="genre"/>
- <text variable="number"/>
- </group>
- <text macro="issued"/>
- </group>
- </else-if>
- <else-if type="thesis">
- <group delimiter=", ">
- <text macro="title"/>
- <text variable="genre"/>
- <text macro="publisher"/>
- <text macro="issued"/>
- </group>
- </else-if>
- <else-if type="webpage">
- <group delimiter=", " suffix=". ">
- <text macro="title"/>
- <text variable="container-title" font-style="italic"/>
- <text macro="issued"/>
- </group>
- <text macro="access"/>
- </else-if>
- <else-if type="patent">
- <text macro="title" suffix=", "/>
- <text variable="number" prefix="U.S. Patent "/>
- <text macro="issued"/>
- </else-if>
- <!-- Generic/Fallback Formats -->
- <else-if type="bill book graphic legal_case motion_picture report song" match="any">
- <group delimiter=", " suffix=". ">
- <text macro="title"/>
- <text macro="locators"/>
- </group>
- <group delimiter=", ">
- <text macro="publisher"/>
- <text macro="issued"/>
- <text macro="page"/>
- </group>
- </else-if>
- <else-if type="article-magazine article-newspaper broadcast interview manuscript map patent personal_communication song speech thesis webpage" match="any">
- <group delimiter=", ">
- <text macro="title"/>
- <text variable="container-title" font-style="italic"/>
- <text macro="locators"/>
- <text macro="publisher"/>
- <text macro="page"/>
- <text macro="issued"/>
- </group>
- </else-if>
- <else-if type="chapter paper-conference" match="any">
- <group delimiter=", " suffix=", ">
- <text macro="title"/>
- <text variable="container-title" prefix="in " font-style="italic"/>
- <text macro="locators"/>
- </group>
- <text macro="editor" suffix=" "/>
- <group delimiter=", ">
- <text macro="publisher"/>
- <text macro="issued"/>
- <text macro="page"/>
- </group>
- </else-if>
- <else>
- <group delimiter=", " suffix=". ">
- <text macro="title"/>
- <text variable="container-title" font-style="italic"/>
- <text macro="locators"/>
- </group>
- <group delimiter=", ">
- <text macro="publisher"/>
- <text macro="page"/>
- <text macro="issued"/>
- </group>
- </else>
- </choose>
- </layout>
- </bibliography>
-</style> \ No newline at end of file
diff --git a/tests/latex-reader.native b/tests/latex-reader.native
index d8769e605..abc4b05a7 100644
--- a/tests/latex-reader.native
+++ b/tests/latex-reader.native
@@ -1,26 +1,26 @@
-Pandoc (Meta {unMeta = fromList [("authors",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 "latex" "\\maketitle"
+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",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
,HorizontalRule
-,Header 1 ("",[],[]) [Str "Headers"]
-,Header 2 ("",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embedded",Space,Str "link"] ("/url","")]
-,Header 3 ("",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
+,Header 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 ("",[],[]) [Str "Level",Space,Str "1"]
-,Header 2 ("",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Emph [Str "emphasis"]]
-,Header 3 ("",[],[]) [Str "Level",Space,Str "3"]
+,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 ("",[],[]) [Str "Level",Space,Str "2"]
+,Header 2 ("level-2",[],[]) [Str "Level",Space,Str "2"]
,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
,HorizontalRule
-,Header 1 ("",[],[]) [Str "Paragraphs"]
+,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",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\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 ("",[],[]) [Str "Block",Space,Str "Quotes"]
+,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."]]
@@ -52,15 +52,15 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
[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 ("",[],[]) [Str "Code",Space,Str "Blocks"]
+,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 ("",[],[]) [Str "Lists"]
-,Header 2 ("",[],[]) [Str "Unordered"]
+,Header 1 ("lists",[],[]) [Str "Lists"]
+,Header 2 ("unordered",[],[]) [Str "Unordered"]
,Para [Str "Asterisks",Space,Str "tight:"]
,BulletList
[[Para [Str "asterisk",Space,Str "1"]]
@@ -91,7 +91,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
[[Para [Str "Minus",Space,Str "1"]]
,[Para [Str "Minus",Space,Str "2"]]
,[Para [Str "Minus",Space,Str "3"]]]
-,Header 2 ("",[],[]) [Str "Ordered"]
+,Header 2 ("ordered",[],[]) [Str "Ordered"]
,Para [Str "Tight:"]
,OrderedList (1,Decimal,Period)
[[Para [Str "First"]]
@@ -118,7 +118,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,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",Space,Str "back."]]
,[Para [Str "Item",Space,Str "2."]]
,[Para [Str "Item",Space,Str "3."]]]
-,Header 2 ("",[],[]) [Str "Nested"]
+,Header 2 ("nested",[],[]) [Str "Nested"]
,BulletList
[[Para [Str "Tab"]
,BulletList
@@ -143,14 +143,14 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,[Para [Str "Fie"]]
,[Para [Str "Foe"]]]]
,[Para [Str "Third"]]]
-,Header 2 ("",[],[]) [Str "Tabs",Space,Str "and",Space,Str "spaces"]
+,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 ("",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"]
+,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"]
@@ -180,7 +180,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,Para [Str "M.A.",Space,Str "2007"]
,Para [Str "B.",Space,Str "Williams"]
,HorizontalRule
-,Header 1 ("",[],[]) [Str "Definition",Space,Str "Lists"]
+,Header 1 ("definition-lists",[],[]) [Str "Definition",Space,Str "Lists"]
,Para [Str "Tight",Space,Str "using",Space,Str "spaces:"]
,DefinitionList
[([Str "apple"],
@@ -215,7 +215,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,CodeBlock ("",[],[]) "{ orange code block }"
,BlockQuote
[Para [Str "orange",Space,Str "block",Space,Str "quote"]]]])]
-,Header 1 ("",[],[]) [Str "HTML",Space,Str "Blocks"]
+,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",Space,Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"]
,Para [Str "foo",Space,Str "bar",Space,Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]
@@ -234,7 +234,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,CodeBlock ("",[],[]) "<hr />"
,Para [Str "Hr\8217s:"]
,HorizontalRule
-,Header 1 ("",[],[]) [Str "Inline",Space,Str "Markup"]
+,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 "."]
@@ -248,7 +248,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,Para [Str "Subscripts:",Space,Str "H",Subscript [Str "2"],Str "O,",Space,Str "H",Subscript [Str "23"],Str "O,",Space,Str "H",Subscript [Str "many",Space,Str "of",Space,Str "them"],Str "O."]
,Para [Str "These",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "superscripts",Space,Str "or",Space,Str "subscripts,",Space,Str "because",Space,Str "of",Space,Str "the",Space,Str "unescaped",Space,Str "spaces:",Space,Str "a^b",Space,Str "c^d,",Space,Str "a",Math InlineMath "\\sim",Str "b",Space,Str "c",Math InlineMath "\\sim",Str "d."]
,HorizontalRule
-,Header 1 ("",[],[]) [Str "Smart",Space,Str "quotes,",Space,Str "ellipses,",Space,Str "dashes"]
+,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."]]
@@ -258,10 +258,10 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,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 ("",[],[]) [Str "LaTeX"]
+,Header 1 ("latex",[],[]) [Str "LaTeX"]
,BulletList
- [[Para [Cite [Citation {citationId = "smith.1899", citationPrefix = [], citationSuffix = [Str ",",Space,Str "22-23"], citationMode = AuthorInText, citationNoteNum = 0, citationHash = 0}] [RawInline "latex" "\\cite[22-23]{smith.1899}"]]]
- ,[Para [RawInline "latex" "\\doublespacing"]]
+ [[Para [Cite [Citation {citationId = "smith.1899", citationPrefix = [], citationSuffix = [Str "22-23"], citationMode = AuthorInText, 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"]]
@@ -288,7 +288,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
[[[Plain [Str "Animal"]]]
,[[Plain [Str "Vegetable"]]]]
,HorizontalRule
-,Header 1 ("",[],[]) [Str "Special",Space,Str "Characters"]
+,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"]]
@@ -302,7 +302,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,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 "Backtick:",Space,Str "`"]
,Para [Str "Asterisk:",Space,Str "*"]
,Para [Str "Underscore:",Space,Str "_"]
,Para [Str "Left",Space,Str "brace:",Space,Str "{"]
@@ -318,8 +318,8 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,Para [Str "Plus:",Space,Str "+"]
,Para [Str "Minus:",Space,Str "-"]
,HorizontalRule
-,Header 1 ("",[],[]) [Str "Links"]
-,Header 2 ("",[],[]) [Str "Explicit"]
+,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 "."]
@@ -329,7 +329,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,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 ("",[],[]) [Str "Reference"]
+,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 "."]
@@ -342,12 +342,12 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,CodeBlock ("",[],[]) "[not]: /url"
,Para [Str "Foo",Space,Link [Str "bar"] ("/url/",""),Str "."]
,Para [Str "Foo",Space,Link [Str "biz"] ("/url/",""),Str "."]
-,Header 2 ("",[],[]) [Str "With",Space,Str "ampersands"]
+,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/",""),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 ("",[],[]) [Str "Autolinks"]
+,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?"]]
@@ -359,17 +359,17 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,Para [Str "Auto-links",Space,Str "should",Space,Str "not",Space,Str "occur",Space,Str "here:",Space,Code ("",[],[]) "<http://example.com/>"]
,CodeBlock ("",[],[]) "or here: <http://example.com/>"
,HorizontalRule
-,Header 1 ("",[],[]) [Str "Images"]
+,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 ("",[],[]) [Str "Footnotes"]
+,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.",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",Space,Str "blocks."],Para [Str "Subsequent",Space,Str "blocks",Space,Str "are",Space,Str "indented",Space,Str "to",Space,Str "show",Space,Str "that",Space,Str "they",Space,Str "belong",Space,Str "to",Space,Str "the",Space,Str "footnote",Space,Str "(as",Space,Str "with",Space,Str "list",Space,Str "items)."],CodeBlock ("",[],[]) " { <code> }",Para [Str "If",Space,Str "you",Space,Str "want,",Space,Str "you",Space,Str "can",Space,Str "indent",Space,Str "every",Space,Str "line,",Space,Str "but",Space,Str "you",Space,Str "can",Space,Str "also",Space,Str "be",Space,Str "lazy",Space,Str "and",Space,Str "just",Space,Str "indent",Space,Str "the",Space,Str "first",Space,Str "line",Space,Str "of",Space,Str "each",Space,Str "block."]],Space,Str "This",Space,Str "should",Space,Emph [Str "not"],Space,Str "be",Space,Str "a",Space,Str "footnote",Space,Str "reference,",Space,Str "because",Space,Str "it",Space,Str "contains",Space,Str "a",Space,Str "space.[^my",Space,Str "note]",Space,Str "Here",Space,Str "is",Space,Str "an",Space,Str "inline",Space,Str "note.",Note [Para [Str "This",Space,Str "is",Space,Emph [Str "easier"],Space,Str "to",Space,Str "type.",Space,Str "Inline",Space,Str "notes",Space,Str "may",Space,Str "contain",Space,Link [Str "links"] ("http://google.com",""),Space,Str "and",Space,Code ("",[],[]) "]",Space,Str "verbatim",Space,Str "characters,",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "[bracketed",Space,Str "text]."]]]
,BlockQuote
[Para [Str "Notes",Space,Str "can",Space,Str "go",Space,Str "in",Space,Str "quotes.",Note [Para [Str "In",Space,Str "quote."]]]]
,OrderedList (1,Decimal,Period)
[[Para [Str "And",Space,Str "in",Space,Str "list",Space,Str "items.",Note [Para [Str "In",Space,Str "list."]]]]]
,Para [Str "This",Space,Str "paragraph",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "part",Space,Str "of",Space,Str "the",Space,Str "note,",Space,Str "as",Space,Str "it",Space,Str "is",Space,Str "not",Space,Str "indented."]
-,Header 1 ("",[],[]) [Str "Escaped",Space,Str "characters"]
+,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/tests/lhs-test.html b/tests/lhs-test.html
index 9cea03a9f..bde505a1e 100644
--- a/tests/lhs-test.html
+++ b/tests/lhs-test.html
@@ -27,10 +27,10 @@ code > span.er { color: #ff0000; font-weight: bold; }
</style>
</head>
<body>
-<h1>lhs test</h1>
+<h1 id="lhs-test">lhs test</h1>
<p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p>
<pre class="sourceCode literate haskell"><code 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> <span class="fu">uncurry</span>
+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>
<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>
diff --git a/tests/lhs-test.html+lhs b/tests/lhs-test.html+lhs
index 487a8a26b..fcdcad303 100644
--- a/tests/lhs-test.html+lhs
+++ b/tests/lhs-test.html+lhs
@@ -27,10 +27,10 @@ code > span.er { color: #ff0000; font-weight: bold; }
</style>
</head>
<body>
-<h1>lhs test</h1>
+<h1 id="lhs-test">lhs test</h1>
<p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p>
<pre class="sourceCode literate 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> <span class="fu">uncurry</span>
+<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>
<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>
diff --git a/tests/lhs-test.latex b/tests/lhs-test.latex
index 3028063fe..6600608fe 100644
--- a/tests/lhs-test.latex
+++ b/tests/lhs-test.latex
@@ -1,12 +1,10 @@
\documentclass[]{article}
-\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
-% use upquote if available, for straight quotes in verbatim environments
-\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
+ \usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\else % if luatex or xelatex
\ifxetex
@@ -18,6 +16,8 @@
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\newcommand{\euro}{€}
\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}}{}
\usepackage{color}
@@ -63,12 +63,11 @@
\setlength{\emergencystretch}{3em} % prevent overfull lines
\setcounter{secnumdepth}{0}
-\author{}
\date{}
\begin{document}
-\section{lhs test}
+\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:
@@ -76,7 +75,7 @@ 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{.} \FunctionTok{uncurry}
+\NormalTok{unsplit }\FunctionTok{=} \NormalTok{arr }\FunctionTok{.} \NormalTok{uncurry}
\CommentTok{-- arr (\textbackslash{}op (x,y) -> x `op` y)}
\end{Highlighting}
\end{Shaded}
diff --git a/tests/lhs-test.latex+lhs b/tests/lhs-test.latex+lhs
index ce91b37e1..d6cb7c497 100644
--- a/tests/lhs-test.latex+lhs
+++ b/tests/lhs-test.latex+lhs
@@ -1,12 +1,10 @@
\documentclass[]{article}
-\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
-% use upquote if available, for straight quotes in verbatim environments
-\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
+ \usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\else % if luatex or xelatex
\ifxetex
@@ -18,6 +16,8 @@
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\newcommand{\euro}{€}
\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}}{}
\usepackage{listings}
@@ -44,12 +44,11 @@
\setlength{\emergencystretch}{3em} % prevent overfull lines
\setcounter{secnumdepth}{0}
-\author{}
\date{}
\begin{document}
-\section{lhs test}
+\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:
diff --git a/tests/lhs-test.markdown b/tests/lhs-test.markdown
index 47ec920d3..75a253bf4 100644
--- a/tests/lhs-test.markdown
+++ b/tests/lhs-test.markdown
@@ -4,11 +4,11 @@ lhs test
`unsplit` is an arrow that takes a pair of values and combines them to return
a single value:
-~~~~ {.sourceCode .literate .haskell}
+``` {.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
diff --git a/tests/lhs-test.native b/tests/lhs-test.native
index 3a22d1f8a..63037d9e3 100644
--- a/tests/lhs-test.native
+++ b/tests/lhs-test.native
@@ -1,4 +1,4 @@
-[Header 1 ("",[],[]) [Str "lhs",Space,Str "test"]
+[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",Space,Str "return",Space,Str "a",Space,Str "single",Space,Str "value:"]
,CodeBlock ("",["sourceCode","literate","haskell"],[]) "unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d\nunsplit = arr . uncurry\n -- arr (\\op (x,y) -> x `op` y)"
,Para [Code ("",[],[]) "(***)",Space,Str "combines",Space,Str "two",Space,Str "arrows",Space,Str "into",Space,Str "a",Space,Str "new",Space,Str "arrow",Space,Str "by",Space,Str "running",Space,Str "the",Space,Str "two",Space,Str "arrows",Space,Str "on",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "(one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "first",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair",Space,Str "and",Space,Str "one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "second",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair)."]
diff --git a/tests/markdown-citations.chicago-author-date.txt b/tests/markdown-citations.chicago-author-date.txt
deleted file mode 100644
index de242300d..000000000
--- a/tests/markdown-citations.chicago-author-date.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-Pandoc with citeproc-hs
-=======================
-
-- [@nonexistent]
-
-- @nonexistent
-
-- Doe (2005) says blah.
-
-- Doe (2005, 30) says blah.
-
-- Doe (2005, 30, with suffix) says blah.
-
-- Doe (2005; 2006, 30; see also Doe and Roe 2007) says blah.
-
-- In a note.[^1]
-
-- A citation group (see Doe 2005, chap. 3; also Doe and Roe 2007, 34–35).
-
-- Another one (see Doe 2005, 34–35).
-
-- And another one in a note.[^2]
-
-- Citation with a suffix and locator (Doe 2005, 33, 35–37, and nowhere else).
-
-- Citation with suffix only (Doe 2005 and nowhere else).
-
-- Now some modifiers.[^3]
-
-- With some markup (*see* Doe 2005, 32).
-
-References
-==========
-
-Doe, John. 2005. *First Book*. Cambridge: Cambridge University Press.
-
-———. 2006. “Article.” *Journal of Generic Studies* 6: 33–34.
-
-Doe, John, and Jenny Roe. 2007. “Why Water Is Wet.” In *Third Book*, edited by Sam Smith. Oxford: Oxford University Press.
-
-[^1]: Doe and Roe (2007, 12) and a citation without locators (Doe and Roe 2007).
-
-[^2]: Some citations (see Doe 2005, chap. 3; Doe and Roe 2007; Doe 2006).
-
-[^3]: Like a citation without author: (2005), and now Doe with a locator (2006, 44).
diff --git a/tests/markdown-citations.ieee.txt b/tests/markdown-citations.ieee.txt
deleted file mode 100644
index a397e3f38..000000000
--- a/tests/markdown-citations.ieee.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-Pandoc with citeproc-hs
-=======================
-
-- [@nonexistent]
-
-- @nonexistent
-
-- Reference 1 says blah.
-
-- Reference 1 says blah.
-
-- Reference 1 says blah.
-
-- Reference 1 [3] says blah.
-
-- In a note.[^1]
-
-- A citation group [1], [3].
-
-- Another one [1].
-
-- And another one in a note.[^2]
-
-- Citation with a suffix and locator [1].
-
-- Citation with suffix only [1].
-
-- Now some modifiers.[^3]
-
-- With some markup [1].
-
-References
-==========
-
-[1] J. Doe, *First Book*. Cambridge: Cambridge University Press, 2005.
-
-[2] J. Doe, “Article,” *Journal of Generic Studies*, vol. 6, pp. 33–34, 2006.
-
-[3] J. Doe and J. Roe, “Why Water Is Wet,” in *Third Book*, S. Smith, Ed. Oxford: Oxford University Press, 2007.
-
-[^1]: Reference 3 and a citation without locators [3].
-
-[^2]: Some citations [1–3].
-
-[^3]: Like a citation without author: [1], and now Doe with a locator [2].
diff --git a/tests/markdown-citations.mhra.txt b/tests/markdown-citations.mhra.txt
deleted file mode 100644
index d33a1b94b..000000000
--- a/tests/markdown-citations.mhra.txt
+++ /dev/null
@@ -1,63 +0,0 @@
-Pandoc with citeproc-hs
-=======================
-
-- [@nonexistent]
-
-- @nonexistent
-
-- John Doe[^1] says blah.
-
-- Doe[^2] says blah.
-
-- Doe[^3] says blah.
-
-- Doe[^4] says blah.
-
-- In a note.[^5]
-
-- A citation group.[^6]
-
-- Another one.[^7]
-
-- And another one in a note.[^8]
-
-- Citation with a suffix and locator.[^9]
-
-- Citation with suffix only.[^10]
-
-- Now some modifiers.[^11]
-
-- With some markup.[^12]
-
-References
-==========
-
-Doe, John, ‘Article’, *Journal of Generic Studies*, 6 (2006), 33–34.
-
----, *First Book* (Cambridge: Cambridge University Press, 2005).
-
-Doe, John, and Jenny Roe, ‘Why Water Is Wet’, in *Third Book*, ed. by Sam Smith (Oxford: Oxford University Press, 2007).
-
-[^1]: *First Book* (Cambridge: Cambridge University Press, 2005).
-
-[^2]: *First Book*, p. 30.
-
-[^3]: *First Book*, p. 30, with suffix.
-
-[^4]: *First Book*; ‘Article’, *Journal of Generic Studies*, 6 (2006), 33–34 (p. 30); see also John Doe and Jenny Roe, ‘Why Water Is Wet’, in *Third Book*, ed. by Sam Smith (Oxford: Oxford University Press, 2007).
-
-[^5]: Doe and Roe, p. 12 and a citation without locators Doe and Roe.
-
-[^6]: See Doe, *First Book*, chap. 3; also Doe and Roe, pp. 34–35.
-
-[^7]: See Doe, *First Book*, pp. 34–35.
-
-[^8]: Some citations see Doe, *First Book*, chap. 3; Doe and Roe; Doe, ‘Article’, 33–34.
-
-[^9]: Doe, *First Book*, pp. 33, 35–37, and nowhere else.
-
-[^10]: Doe, *First Book* and nowhere else.
-
-[^11]: Like a citation without author: *First Book*, and now Doe with a locator ‘Article’, 33–34 (p. 44).
-
-[^12]: *See* Doe, *First Book*, p. 32.
diff --git a/tests/markdown-citations.native b/tests/markdown-citations.native
new file mode 100644
index 000000000..d9738fb4f
--- /dev/null
+++ b/tests/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.",Space,Str "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.",Space,Str "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.",Space,Str "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.",Space,Str "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.",Space,Str "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.",Space,Str "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.",Space,Str "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.",Space,Str "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/tests/markdown-reader-more.native b/tests/markdown-reader-more.native
index 2e8dc9dde..b4713bc93 100644
--- a/tests/markdown-reader-more.native
+++ b/tests/markdown-reader-more.native
@@ -2,9 +2,9 @@
,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 "tex" "\\placeformula "]
-,RawBlock "context" "\\startformula\n L_{1} = L_{2}\n \\stopformula"
-,RawBlock "context" "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]"
+,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 ("urls-with-spaces",[],[]) [Str "URLs",Space,Str "with",Space,Str "spaces"]
,Para [Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("bar%20baz","title")]
,Para [Link [Str "baz"] ("/foo%20foo",""),Space,Link [Str "bam"] ("/foo%20fee",""),Space,Link [Str "bork"] ("/foo/zee%20zob","title")]
@@ -12,13 +12,15 @@
,HorizontalRule
,HorizontalRule
,Header 2 ("raw-html-before-header",[],[]) [Str "Raw",Space,Str "HTML",Space,Str "before",Space,Str "header"]
-,Para [RawInline "html" "<a>",RawInline "html" "</a>"]
+,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 [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",Space,RawInline "html" "<!--\n- two\n-->"]]
+ [[Plain [Str "one",Space,RawInline (Format "html") "<!--\n- two\n-->"]]
,[Plain [Str "three"]]]
,Header 2 ("backslash-newline",[],[]) [Str "Backslash",Space,Str "newline"]
,Para [Str "hi",LineBreak,Str "there"]
@@ -40,7 +42,7 @@
,OrderedList (3,Example,TwoParens)
[[Plain [Str "Third",Space,Str "example."]]]
,Header 2 ("macros",[],[]) [Str "Macros"]
-,Para [Math InlineMath "\\langle x,y \\rangle"]
+,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","")]
@@ -136,4 +138,7 @@
,Para [Link [Str "link"] ("/hithere)","")]
,Para [Link [Str "linky"] ("hi_(there_(nested))","")]
,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"]]
+,Para [Str "[",Emph [Str "not",Space,Str "a",Space,Str "link"],Str "]",Space,Str "[",Emph [Str "nope"],Str "]\8230"]
+,Header 2 ("empty-reference-links",[],[]) [Str "Empty",Space,Str "reference",Space,Str "links"]
+,Para [Str "bar"]
+,Para [Link [Str "foo2"] ("","")]]
diff --git a/tests/markdown-reader-more.txt b/tests/markdown-reader-more.txt
index d133b3dbb..4cd69c9d8 100644
--- a/tests/markdown-reader-more.txt
+++ b/tests/markdown-reader-more.txt
@@ -58,6 +58,10 @@
$\$2 + \$3$
+This should not be math:
+
+$PATH 90 $PATH
+
## Commented-out list item
- one
@@ -235,3 +239,11 @@ Empty cells
## Reference link fallbacks
[*not a link*] [*nope*]...
+
+## Empty reference links
+
+[foo2]:
+
+bar
+
+[foo2]
diff --git a/tests/mediawiki-reader.native b/tests/mediawiki-reader.native
index f16518b65..2e97e9484 100644
--- a/tests/mediawiki-reader.native
+++ b/tests/mediawiki-reader.native
@@ -1,39 +1,39 @@
Pandoc (Meta {unMeta = fromList []})
-[Header 1 ("",[],[]) [Str "header"]
-,Header 2 ("",[],[]) [Str "header",Space,Str "level",Space,Str "two"]
-,Header 3 ("",[],[]) [Str "header",Space,Str "level",Space,Str "3"]
-,Header 4 ("",[],[]) [Str "header",Space,Emph [Str "level"],Space,Str "four"]
-,Header 5 ("",[],[]) [Str "header",Space,Str "level",Space,Str "5"]
-,Header 6 ("",[],[]) [Str "header",Space,Str "level",Space,Str "6"]
+[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 ("",[],[]) [Str "emph",Space,Str "and",Space,Str "strong"]
+,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 ("",[],[]) [Str "horizontal",Space,Str "rule"]
+,Header 2 ("horizontal-rule",[],[]) [Str "horizontal",Space,Str "rule"]
,Para [Str "top"]
,HorizontalRule
,Para [Str "bottom"]
,HorizontalRule
-,Header 2 ("",[],[]) [Str "nowiki"]
+,Header 2 ("nowiki",[],[]) [Str "nowiki"]
,Para [Str "''not",Space,Str "emph''"]
-,Header 2 ("",[],[]) [Str "strikeout"]
+,Header 2 ("strikeout",[],[]) [Str "strikeout"]
,Para [Strikeout [Str "This",Space,Str "is",Space,Emph [Str "struck",Space,Str "out"]]]
-,Header 2 ("",[],[]) [Str "entities"]
+,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 ("",[],[]) [Str "comments"]
+,Header 2 ("comments",[],[]) [Str "comments"]
,Para [Str "inline",Space,Str "comment"]
,Para [Str "between",Space,Str "blocks"]
-,Header 2 ("",[],[]) [Str "linebreaks"]
+,Header 2 ("linebreaks",[],[]) [Str "linebreaks"]
,Para [Str "hi",LineBreak,Str "there"]
,Para [Str "hi",LineBreak,Str "there"]
-,Header 2 ("",[],[]) [Str ":",Space,Str "indents"]
+,Header 2 ("indents",[],[]) [Str ":",Space,Str "indents"]
,Para [Str "hi"]
,DefinitionList
[([],
@@ -46,36 +46,36 @@ Pandoc (Meta {unMeta = fromList []})
[([],
[[Plain [Str "there"]]])]]])]
,Para [Str "bud"]
-,Header 2 ("",[],[]) [Str "p",Space,Str "tags"]
+,Header 2 ("p-tags",[],[]) [Str "p",Space,Str "tags"]
,Para [Str "hi",Space,Str "there"]
,Para [Str "bud"]
,Para [Str "another"]
-,Header 2 ("",[],[]) [Str "raw",Space,Str "html"]
-,Para [Str "hi",Space,RawInline "html" "<span style=\"color:red\">",Emph [Str "there"],RawInline "html" "</span>",Str "."]
-,Para [RawInline "html" "<ins>",Str "inserted",RawInline "html" "</ins>"]
-,RawBlock "html" "<div class=\"special\">"
+,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 "html" "</div>"
-,Header 2 ("",[],[]) [Str "sup,",Space,Str "sub,",Space,Str "del"]
+,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"]],Space,Strikeout [Str "hello"]]
-,Header 2 ("",[],[]) [Str "inline",Space,Str "code"]
+,Header 2 ("inline-code",[],[]) [Str "inline",Space,Str "code"]
,Para [Code ("",[],[]) "*\8594*",Space,Code ("",[],[]) "typed",Space,Code ("",["haskell"],[]) ">>="]
-,Header 2 ("",[],[]) [Str "code",Space,Str "blocks"]
+,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 ("",[],[]) [Str "block",Space,Str "quotes"]
+,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 ("",[],[]) [Str "external",Space,Str "links"]
+,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://johnmacfarlane.net/pandoc/"] ("http://johnmacfarlane.net/pandoc/","")]
,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 ("",[],[]) [Str "internal",Space,Str "links"]
+,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")]
@@ -83,12 +83,13 @@ Pandoc (Meta {unMeta = fromList []})
,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 ("",[],[]) [Str "images"]
-,Para [Image [Str "caption"] ("example.jpg","image")]
-,Para [Image [Str "the",Space,Emph [Str "caption"],Space,Str "with",Space,Link [Str "external",Space,Str "link"] ("http://google.com","")] ("example.jpg","image")]
-,Para [Image [Str "caption"] ("example.jpg","image")]
-,Para [Image [Str "example.jpg"] ("example.jpg","image")]
-,Header 2 ("",[],[]) [Str "lists"]
+,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 [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 "(*)."]
@@ -101,6 +102,10 @@ Pandoc (Meta {unMeta = fromList []})
[[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 "(#)."]
@@ -140,7 +145,7 @@ Pandoc (Meta {unMeta = fromList []})
,[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 "mediawiki" "{{{template\n|author=John\n|title=My Book\n}}}"]
+ ,[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)
@@ -161,24 +166,25 @@ Pandoc (Meta {unMeta = fromList []})
[[Plain [Str "Amsterdam"]]
,[Plain [Str "Rotterdam"]]
,[Plain [Str "The",Space,Str "Hague"]]]
-,Header 2 ("",[],[]) [Str "math"]
+,Header 2 ("math",[],[]) [Str "math"]
,Para [Str "Here",Space,Str "is",Space,Str "some",Space,Math InlineMath "x=\\frac{y^\\pi}{z}",Str "."]
-,Header 2 ("",[],[]) [Str "preformatted",Space,Str "blocks"]
+,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 "html" "<hr/>"
+,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 ("",[],[]) [Str "templates"]
-,RawBlock "mediawiki" "{{Welcome}}"
-,RawBlock "mediawiki" "{{Foo:Bar}}"
-,RawBlock "mediawiki" "{{Thankyou|all your effort|Me}}"
-,Para [Str "Written",Space,RawInline "mediawiki" "{{{date}}}",Space,Str "by",Space,RawInline "mediawiki" "{{{name}}}",Str "."]
-,Header 2 ("",[],[]) [Str "tables"]
+,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]
[[]
,[]]
@@ -244,6 +250,6 @@ Pandoc (Meta {unMeta = fromList []})
[[]]
[[[Para [Str "Orange"]]]]
,Para [Str "Paragraph",Space,Str "after",Space,Str "the",Space,Str "table."]
-,Header 2 ("",[],[]) [Str "notes"]
+,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/tests/mediawiki-reader.wiki b/tests/mediawiki-reader.wiki
index 1e885daf0..6a6bc226d 100644
--- a/tests/mediawiki-reader.wiki
+++ b/tests/mediawiki-reader.wiki
@@ -173,6 +173,8 @@ http://johnmacfarlane.net/pandoc/
[[File:example.jpg]]
+[[Archivo:example_es.jpg]]
+
== lists ==
* Start each line
@@ -183,6 +185,9 @@ http://johnmacfarlane.net/pandoc/
*** 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
@@ -232,11 +237,11 @@ ends the list.
<li>list item A2</li>
</ol>
-<ul>
+<ol>
#abc
#def
#ghi
-</ul>
+</ol>
<ol start="9">
<li>Amsterdam</li>
@@ -248,6 +253,8 @@ ends the list.
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.
diff --git a/tests/mhra.csl b/tests/mhra.csl
deleted file mode 100644
index fe34c8f84..000000000
--- a/tests/mhra.csl
+++ /dev/null
@@ -1,399 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<style xmlns="http://purl.org/net/xbiblio/csl" class="note" version="1.0" demote-non-dropping-particle="sort-only">
- <info>
- <title>Modern Humanities Research Association (Note with Bibliography)</title>
- <id>http://www.zotero.org/styles/mhra</id>
- <link href="http://www.zotero.org/styles/mhra" rel="self"/>
- <link href="http://www.mhra.org.uk/Publications/Books/StyleGuide/download.shtml" rel="documentation"/>
- <author>
- <name>Rintze Zelle</name>
- <uri>http://twitter.com/rintzezelle</uri>
- </author>
- <contributor>
- <name>Sebastian Karcher</name>
- </contributor>
- <summary>MHRA format with full notes and bibliography</summary>
- <category field="generic-base"/>
- <category citation-format="note"/>
- <updated>2011-08-18T16:08:33+00:00</updated>
- <rights>This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/</rights>
- </info>
- <locale xml:lang="en">
- <terms>
- <term name="et-al">and others</term>
- <term name="editor" form="verb-short">ed. by</term>
- <term name="edition" form="short">edn</term>
- <term name="translator" form="verb-short">trans. by</term>
- </terms>
- </locale>
- <macro name="author">
- <names variable="author">
- <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
- <label form="short" prefix=", " suffix="."/>
- <substitute>
- <names variable="editor"/>
- <names variable="translator"/>
- <text macro="title-note"/>
- </substitute>
- </names>
- </macro>
- <macro name="contributors-note">
- <names variable="author">
- <name and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="never"/>
- </names>
- <text macro="recipient-note"/>
- </macro>
- <macro name="title-note">
- <choose>
- <if type="bill book graphic legal_case motion_picture report song" match="any">
- <text variable="title" font-style="italic" text-case="title"/>
- </if>
- <else>
- <text variable="title" prefix="‘" suffix="’" text-case="title"/>
- </else>
- </choose>
- </macro>
- <macro name="title-short">
- <choose>
- <if disambiguate="true">
- <choose>
- <if type="bill book graphic legal_case motion_picture report song" match="any">
- <text variable="title" font-style="italic" text-case="title" form="short"/>
- </if>
- <else>
- <text variable="title" prefix="‘" suffix="’" text-case="title" form="short"/>
- </else>
- </choose>
- </if>
- </choose>
- </macro>
- <macro name="editor-translator">
- <group delimiter=", ">
- <names variable="editor" delimiter=", ">
- <label form="verb-short" text-case="lowercase" suffix=" "/>
- <name and="text" delimiter=", " delimiter-precedes-last="never"/>
- </names>
- <choose>
- <if variable="author editor" match="any">
- <names variable="translator" delimiter=", ">
- <label form="verb-short" text-case="lowercase" suffix=" "/>
- <name and="text" delimiter=", " delimiter-precedes-last="never"/>
- </names>
- </if>
- </choose>
- </group>
- </macro>
- <macro name="collection-title">
- <text variable="collection-title" text-case="title"/>
- <text variable="collection-number" prefix=", "/>
- </macro>
- <macro name="locators-note">
- <choose>
- <if type="article-journal">
- <text variable="volume"/>
- </if>
- <else-if type="bill book graphic legal_case motion_picture report song chapter paper-conference" match="any">
- <group delimiter=", ">
- <text macro="edition-note"/>
- <group>
- <number variable="number-of-volumes" form="numeric"/>
- <text term="volume" form="short" prefix=" " plural="true"/>
- </group>
- </group>
- </else-if>
- </choose>
- </macro>
- <macro name="volume">
- <choose>
- <if type="article-journal">
- <text variable="volume"/>
- </if>
- <else-if type="bill book graphic legal_case motion_picture report song chapter paper-conference" match="any">
- <group delimiter=", ">
- <text macro="edition-note"/>
- <group>
- <number variable="number-of-volumes" form="numeric"/>
- <text term="volume" form="short" prefix=" " plural="true"/>
- </group>
- </group>
- </else-if>
- </choose>
- </macro>
- <macro name="issue-note">
- <choose>
- <if type="article-journal">
- <choose>
- <if variable="volume">
- <text macro="issued" prefix=" (" suffix=")"/>
- </if>
- <else>
- <text macro="issued" prefix=", "/>
- </else>
- </choose>
- </if>
- <else-if variable="publisher-place publisher" match="any">
- <group prefix=" (" suffix=")" delimiter=", ">
- <group delimiter=" ">
- <choose>
- <if variable="title" match="none"/>
- <else-if type="thesis speech" match="any">
- <text variable="genre" prefix="unpublished "/>
- </else-if>
- </choose>
- <text macro="event"/>
- </group>
- <text macro="publisher"/>
- <text macro="issued"/>
- </group>
- </else-if>
- <else>
- <text macro="issued" prefix=", "/>
- </else>
- </choose>
- </macro>
- <macro name="locators-specific-note">
- <choose>
- <if type="bill book graphic legal_case motion_picture report song chapter paper-conference" match="any">
- <choose>
- <if is-numeric="volume">
- <number variable="volume" form="roman" font-variant="small-caps"/>
- </if>
- </choose>
- </if>
- </choose>
- </macro>
- <macro name="container-title-note">
- <choose>
- <if type="chapter paper-conference" match="any">
- <text term="in" text-case="lowercase" suffix=" "/>
- </if>
- </choose>
- <text variable="container-title" font-style="italic" text-case="title"/>
- </macro>
- <macro name="edition-note">
- <choose>
- <if type="bill book graphic legal_case motion_picture report song chapter paper-conference" match="any">
- <choose>
- <if is-numeric="edition">
- <group delimiter=" ">
- <number variable="edition" form="ordinal"/>
- <text term="edition" form="short"/>
- </group>
- </if>
- <else>
- <text variable="edition"/>
- </else>
- </choose>
- </if>
- </choose>
- </macro>
- <macro name="editor-note">
- <names variable="editor">
- <name and="text" sort-separator=", " delimiter=", "/>
- <label form="short" prefix=", " suffix="."/>
- </names>
- </macro>
- <macro name="translator-note">
- <names variable="translator">
- <name and="text" sort-separator=", " delimiter=", "/>
- <label form="verb-short" prefix=", " suffix="."/>
- </names>
- </macro>
- <macro name="recipient-note">
- <names variable="recipient" delimiter=", ">
- <label form="verb" prefix=" " text-case="lowercase" suffix=" "/>
- <name and="text" delimiter=", "/>
- </names>
- </macro>
- <macro name="recipient-short">
- <names variable="recipient">
- <label form="verb" prefix=" " text-case="lowercase" suffix=" "/>
- <name form="short" and="text" delimiter=", "/>
- </names>
- </macro>
- <macro name="contributors-short">
- <names variable="author">
- <name form="short" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="never"/>
- <substitute>
- <names variable="editor"/>
- <names variable="translator"/>
- </substitute>
- </names>
- <text macro="recipient-short"/>
- </macro>
- <macro name="interviewer-note">
- <names variable="interviewer" delimiter=", ">
- <label form="verb" prefix=" " text-case="lowercase" suffix=" "/>
- <name and="text" delimiter=", "/>
- </names>
- </macro>
- <macro name="locators-newspaper">
- <choose>
- <if type="article-newspaper">
- <group delimiter=", ">
- <group>
- <text variable="edition" suffix=" "/>
- <text term="edition" prefix=" "/>
- </group>
- <group>
- <text term="section" suffix=" "/>
- <text variable="section"/>
- </group>
- </group>
- </if>
- </choose>
- </macro>
- <macro name="event">
- <group>
- <text term="presented at" suffix=" "/>
- <text variable="event"/>
- </group>
- </macro>
- <macro name="publisher">
- <group delimiter=": ">
- <text variable="publisher-place"/>
- <text variable="publisher"/>
- </group>
- </macro>
- <macro name="issued">
- <choose>
- <if type="graphic report article-newspaper" match="any">
- <date variable="issued">
- <date-part name="day" suffix=" "/>
- <date-part name="month" suffix=" "/>
- <date-part name="year"/>
- </date>
- </if>
- <else-if type="bill book graphic legal_case motion_picture report song thesis chapter paper-conference" match="any">
- <date variable="issued">
- <date-part name="year"/>
- </date>
- </else-if>
- <else>
- <date variable="issued">
- <date-part name="year"/>
- </date>
- </else>
- </choose>
- </macro>
- <macro name="pages">
- <choose>
- <if type="article-journal">
- <text variable="page" prefix=", "/>
- </if>
- <else>
- <choose>
- <if variable="volume">
- <text variable="page" prefix=", "/>
- </if>
- <else>
- <label variable="page" form="short" prefix=", " suffix=" "/>
- <text variable="page"/>
- </else>
- </choose>
- </else>
- </choose>
- </macro>
- <macro name="point-locators">
- <text macro="pages"/>
- <choose>
- <if variable="page">
- <group prefix=" (" suffix=")">
- <label variable="locator" form="short" suffix=" "/>
- <text variable="locator"/>
- </group>
- </if>
- <else>
- <label variable="locator" form="short" prefix=", " suffix=" "/>
- <text variable="locator"/>
- </else>
- </choose>
- </macro>
- <macro name="archive-note">
- <group delimiter=", ">
- <text variable="archive_location"/>
- <text variable="archive"/>
- <text variable="archive-place"/>
- </group>
- </macro>
- <macro name="access-note">
- <group delimiter=", ">
- <choose>
- <if type="graphic report" match="any">
- <text macro="archive-note" prefix=", "/>
- </if>
- <else-if type="bill book graphic legal_case motion_picture report song article-journal article-magazine article-newspaper thesis chapter paper-conference" match="none">
- <text macro="archive-note" prefix=", "/>
- </else-if>
- </choose>
- </group>
- <choose>
- <if variable="DOI">
- <text variable="DOI" prefix=" &lt;doi:" suffix="&gt;"/>
- </if>
- <else>
- <choose>
- <if variable="URL">
- <text variable="URL" prefix=" &lt;" suffix="&gt;"/>
- <group prefix=" [" suffix="]">
- <text term="accessed" text-case="lowercase"/>
- <date variable="accessed">
- <date-part name="day" prefix=" "/>
- <date-part name="month" prefix=" "/>
- <date-part name="year" prefix=" "/>
- </date>
- </group>
- </if>
- </choose>
- </else>
- </choose>
- </macro>
- <citation et-al-min="4" et-al-use-first="1" et-al-subsequent-min="4" et-al-subsequent-use-first="1" disambiguate-add-names="true" disambiguate-add-givenname="true">
- <layout prefix="" suffix="." delimiter="; ">
- <choose>
- <if position="subsequent">
- <text macro="contributors-short"/>
- <text macro="title-short" prefix=", "/>
- <text macro="locators-specific-note" prefix=", "/>
- <text macro="point-locators"/>
- </if>
- <else>
- <group delimiter=", ">
- <text macro="contributors-note"/>
- <text macro="title-note"/>
- <text macro="container-title-note"/>
- <text macro="editor-translator"/>
- <text macro="collection-title"/>
- <text macro="locators-note"/>
- </group>
- <text macro="issue-note"/>
- <text macro="locators-specific-note" prefix=", "/>
- <text macro="locators-newspaper" prefix=", "/>
- <text macro="point-locators"/>
- <text macro="access-note"/>
- </else>
- </choose>
- </layout>
- </citation>
- <bibliography hanging-indent="true" et-al-min="6" et-al-use-first="6" subsequent-author-substitute="---">
- <sort>
- <key macro="author"/>
- <key variable="title"/>
- </sort>
- <layout suffix=".">
- <group delimiter=", ">
- <text macro="author"/>
- <text macro="title-note"/>
- <text macro="container-title-note"/>
- <text macro="editor-translator"/>
- <text macro="collection-title"/>
- <text macro="volume"/>
- </group>
- <text macro="issue-note"/>
- <text macro="locators-specific-note" prefix=", "/>
- <text macro="locators-newspaper" prefix=", "/>
- <text macro="pages"/>
- <text macro="access-note"/>
- </layout>
- </bibliography>
-</style> \ No newline at end of file
diff --git a/tests/opml-reader.native b/tests/opml-reader.native
index e71857680..14aff2c03 100644
--- a/tests/opml-reader.native
+++ b/tests/opml-reader.native
@@ -19,7 +19,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "Dave",Spa
,Header 3 ("",[],[]) [Str "North",Space,Str "Dakota"]
,Header 3 ("",[],[]) [Str "Oklahoma"]
,Header 3 ("",[],[]) [Str "South",Space,Str "Dakota"]
-,Header 2 ("",[],[]) [Str "Mid",Str "-",Str "Atlantic"]
+,Header 2 ("",[],[]) [Str "Mid-Atlantic"]
,Header 3 ("",[],[]) [Str "Delaware"]
,Header 3 ("",[],[]) [Str "Maryland"]
,Header 3 ("",[],[]) [Str "New",Space,Str "Jersey"]
diff --git a/tests/pipe-tables.native b/tests/pipe-tables.native
index 5420a7bd3..eafd21d22 100644
--- a/tests/pipe-tables.native
+++ b/tests/pipe-tables.native
@@ -67,4 +67,12 @@
,[[Plain [Str "orange"]]
,[Plain [Str "17"]]]
,[[Plain [Str "pear"]]
- ,[Plain [Str "302"]]]]]
+ ,[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"]]]]]
diff --git a/tests/pipe-tables.txt b/tests/pipe-tables.txt
index 79d79200f..ee8d54d9f 100644
--- a/tests/pipe-tables.txt
+++ b/tests/pipe-tables.txt
@@ -40,3 +40,13 @@ apple | 5
orange| 17
pear | 302
+One-column:
+
+|hi|
+|--|
+|lo|
+
+Header-less one-column:
+
+|:-:|
+|hi|
diff --git a/tests/rst-reader.native b/tests/rst-reader.native
index 49677d958..c77d15775 100644
--- a/tests/rst-reader.native
+++ b/tests/rst-reader.native
@@ -1,11 +1,11 @@
-Pandoc (Meta {unMeta = fromList [("authors",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 ("",[],[]) [Str "Level",Space,Str "one",Space,Str "header"]
+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",Space,Str "John",Space,Str "Gruber\8217s",Space,Str "markdown",Space,Str "test",Space,Str "suite."]
-,Header 2 ("",[],[]) [Str "Level",Space,Str "two",Space,Str "header"]
-,Header 3 ("",[],[]) [Str "Level",Space,Str "three"]
-,Header 4 ("",[],[]) [Str "Level",Space,Str "four",Space,Str "with",Space,Emph [Str "emphasis"]]
-,Header 5 ("",[],[]) [Str "Level",Space,Str "five"]
-,Header 1 ("",[],[]) [Str "Paragraphs"]
+,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",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\8217s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]
@@ -13,7 +13,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,HorizontalRule
,Para [Str "Another:"]
,HorizontalRule
-,Header 1 ("",[],[]) [Str "Block",Space,Str "Quotes"]
+,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.",Space,Str "It",Space,Str "is",Space,Str "pretty",Space,Str "short."]]
@@ -31,7 +31,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
[Para [Str "nested"]
,BlockQuote
[Para [Str "nested"]]]]
-,Header 1 ("",[],[]) [Str "Code",Space,Str "Blocks"]
+,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"
@@ -39,8 +39,8 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,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 ("",[],[]) [Str "Lists"]
-,Header 2 ("",[],[]) [Str "Unordered"]
+,Header 1 ("lists",[],[]) [Str "Lists"]
+,Header 2 ("unordered",[],[]) [Str "Unordered"]
,Para [Str "Asterisks",Space,Str "tight:"]
,BulletList
[[Plain [Str "asterisk",Space,Str "1"]]
@@ -71,7 +71,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
[[Plain [Str "Minus",Space,Str "1"]]
,[Plain [Str "Minus",Space,Str "2"]]
,[Plain [Str "Minus",Space,Str "3"]]]
-,Header 2 ("",[],[]) [Str "Ordered"]
+,Header 2 ("ordered",[],[]) [Str "Ordered"]
,Para [Str "Tight:"]
,OrderedList (1,Decimal,Period)
[[Plain [Str "First"]]
@@ -115,7 +115,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,[Plain [Str "Fie"]]
,[Plain [Str "Foe"]]]]]
,[Plain [Str "Third"]]]
-,Header 2 ("",[],[]) [Str "Fancy",Space,Str "list",Space,Str "markers"]
+,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"]
@@ -145,7 +145,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,OrderedList (4,LowerAlpha,TwoParens)
[[Plain [Str "item",Space,Str "1"]]
,[Plain [Str "item",Space,Str "2"]]]
-,Header 2 ("",[],[]) [Str "Definition"]
+,Header 2 ("definition",[],[]) [Str "Definition"]
,DefinitionList
[([Str "term",Space,Str "1"],
[[Para [Str "Definition",Space,Str "1."]]])
@@ -154,7 +154,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,Para [Str "Definition",Space,Str "2,",Space,Str "paragraph",Space,Str "2."]]])
,([Str "term",Space,Str "with",Space,Emph [Str "emphasis"]],
[[Para [Str "Definition",Space,Str "3."]]])]
-,Header 1 ("",[],[]) [Str "Field",Space,Str "Lists"]
+,Header 1 ("field-lists",[],[]) [Str "Field",Space,Str "Lists"]
,BlockQuote
[DefinitionList
[([Str "address"],
@@ -170,18 +170,18 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
[[Para [Emph [Str "Nowhere"],Str ",",Space,Str "MA,",Space,Str "USA"]]])
,([Str "phone"],
[[Para [Str "123-4567"]]])]
-,Header 1 ("",[],[]) [Str "HTML",Space,Str "Blocks"]
+,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 "html" "<div>foo</div>"
+,RawBlock (Format "html") "<div>foo</div>"
,Para [Str "Now,",Space,Str "nested:"]
-,RawBlock "html" "<div>\n <div>\n <div>\n foo\n </div>\n </div>\n</div>"
-,Header 1 ("",[],[]) [Str "LaTeX",Space,Str "Block"]
-,RawBlock "latex" "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"
-,Header 1 ("",[],[]) [Str "Inline",Space,Str "Markup"]
+,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 ("",[],[]) [Str "Special",Space,Str "Characters"]
+,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"]]
@@ -209,7 +209,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,Para [Str "Bang:",Space,Str "!"]
,Para [Str "Plus:",Space,Str "+"]
,Para [Str "Minus:",Space,Str "-"]
-,Header 1 ("",[],[]) [Str "Links"]
+,Header 1 ("links",[],[]) [Str "Links"]
,Para [Str "Explicit:",Space,Str "a",Space,Link [Str "URL"] ("/url/",""),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."]
@@ -218,20 +218,20 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,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 ("",[],[]) [Str "Images"]
+,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 [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 ("",[],[]) [Str "Comments"]
+,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 ("",[],[]) [Str "Line",Space,Str "blocks"]
+,Header 1 ("line-blocks",[],[]) [Str "Line",Space,Str "blocks"]
,Para [Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be",LineBreak,Str "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,",LineBreak,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,",LineBreak,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?"]
,Para [Str "Continuation",Space,Str "line",LineBreak,Str "\160\160and",Space,Str "another"]
-,Header 1 ("",[],[]) [Str "Simple",Space,Str "Tables"]
+,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"]]
@@ -253,7 +253,7 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,[[Plain [Str "r2",Space,Str "d"]]
,[Plain [Str "e"]]
,[Plain [Str "f"]]]]
-,Header 1 ("",[],[]) [Str "Grid",Space,Str "Tables"]
+,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"]]
@@ -298,26 +298,36 @@ Pandoc (Meta {unMeta = fromList [("authors",MetaList [MetaInlines [Str "John",Sp
,[Plain [Str "b",Space,Str "2"]]
,[Plain [Str "b",Space,Str "2"]]]]
,[Plain [Str "c",Space,Str "c",Space,Str "2",Space,Str "c",Space,Str "2"]]]]
-,Header 1 ("",[],[]) [Str "Footnotes"]
+,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",Space,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",Space,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 ("",[],[]) [Str "Math"]
+,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",Space,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 ("",[],[]) [Str "Default-Role"]
+,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 ("",[],[]) [Str "Doesn\8217t",Space,Str "Break",Space,Str "Title",Space,Str "Parsing"]
+,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 ".",Space,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."]
-,Header 2 ("",[],[]) [Str "Literal",Space,Str "symbols"]
+,Null
+,Para [Str "And",Space,Str "now",Space,Str "with",Space,RawInline (Format "html") "<b>inline</b> <span id=\"test\">HTML</span>",Str "."]
+,Null
+,Para [Str "And",Space,Str "some",Space,Str "inline",Space,Str "haskell",Space,Code ("",["sourceCode","haskell"],[]) "fmap id [1,2..10]",Str "."]
+,Null
+,Null
+,Para [Str "Indirect",Space,Str "python",Space,Str "role",Space,Code ("",["sourceCode","python"],[]) "[x*x for x in [1,2,3,4,5]]",Str "."]
+,Null
+,Null
+,Para [Str "Different",Space,Str "indirect",Space,Str "C",Space,Code ("",["sourceCode","c"],[]) "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/tests/rst-reader.rst b/tests/rst-reader.rst
index 748bfe0a5..930bf2ed2 100644
--- a/tests/rst-reader.rst
+++ b/tests/rst-reader.rst
@@ -599,6 +599,30 @@ Reset default-role to the default default.
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:: python(indirect)
+ :language: python
+
+Indirect python role :python:`[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
---------------
diff --git a/tests/tables.asciidoc b/tests/tables.asciidoc
index 38daca192..ba647866a 100644
--- a/tests/tables.asciidoc
+++ b/tests/tables.asciidoc
@@ -52,20 +52,17 @@ Multiline table without caption:
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/tests/tables.context b/tests/tables.context
index e113a8e6a..371e559e5 100644
--- a/tests/tables.context
+++ b/tests/tables.context
@@ -1,6 +1,6 @@
Simple table with caption:
-\placetable[here]{Demonstration of simple table syntax.}
+\placetable{Demonstration of simple table syntax.}
\starttable[|r|l|c|l|]
\HL
\NC Right
@@ -29,7 +29,7 @@ Simple table with caption:
Simple table without caption:
-\placetable[here,none]{}
+\placetable[none]{}
\starttable[|r|l|c|l|]
\HL
\NC Right
@@ -58,7 +58,7 @@ Simple table without caption:
Simple table indented two spaces:
-\placetable[here]{Demonstration of simple table syntax.}
+\placetable{Demonstration of simple table syntax.}
\starttable[|r|l|c|l|]
\HL
\NC Right
@@ -87,7 +87,7 @@ Simple table indented two spaces:
Multiline table with caption:
-\placetable[here]{Here's the caption. It may span multiple lines.}
+\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
@@ -111,7 +111,7 @@ Multiline table with caption:
Multiline table without caption:
-\placetable[here,none]{}
+\placetable[none]{}
\starttable[|cp(0.15\textwidth)|lp(0.14\textwidth)|rp(0.16\textwidth)|lp(0.34\textwidth)|]
\HL
\NC Centered Header
@@ -135,7 +135,7 @@ Multiline table without caption:
Table without column headers:
-\placetable[here,none]{}
+\placetable[none]{}
\starttable[|r|l|c|r|]
\HL
\NC 12
@@ -158,7 +158,7 @@ Table without column headers:
Multiline table without column headers:
-\placetable[here,none]{}
+\placetable[none]{}
\starttable[|cp(0.15\textwidth)|lp(0.14\textwidth)|rp(0.16\textwidth)|lp(0.34\textwidth)|]
\HL
\NC First
diff --git a/tests/tables.haddock b/tests/tables.haddock
new file mode 100644
index 000000000..413ec97ad
--- /dev/null
+++ b/tests/tables.haddock
@@ -0,0 +1,77 @@
+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/tests/tables.html b/tests/tables.html
index b72aa784e..a9b2b247d 100644
--- a/tests/tables.html
+++ b/tests/tables.html
@@ -96,10 +96,12 @@
<p>Multiline table with caption:</p>
<table>
<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>
@@ -125,10 +127,12 @@
</table>
<p>Multiline table without caption:</p>
<table>
+<colgroup>
<col width="15%" />
<col width="13%" />
<col width="16%" />
<col width="33%" />
+</colgroup>
<thead>
<tr class="header">
<th align="center">Centered Header</th>
@@ -177,10 +181,12 @@
</table>
<p>Multiline table without column headers:</p>
<table>
+<colgroup>
<col width="15%" />
<col width="13%" />
<col width="16%" />
<col width="33%" />
+</colgroup>
<tbody>
<tr class="odd">
<td align="center">First</td>
diff --git a/tests/tables.icml b/tests/tables.icml
new file mode 100644
index 000000000..eb73af670
--- /dev/null
+++ b/tests/tables.icml
@@ -0,0 +1,748 @@
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Simple table with caption:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+ </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><Br />
+ </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><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Default</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+</Table>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Demonstration of simple table syntax.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Simple table without caption:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+ </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><Br />
+ </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><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Default</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+</Table>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
+ <Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Simple table indented two spaces:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+ </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><Br />
+ </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><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; TableHeader">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Default</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:3" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+</Table>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Demonstration of simple table syntax.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiline table with caption:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+ </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><Br />
+ </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><Br />
+ </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><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>First</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>row</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12.0</Content>
+ </CharacterStyleRange><Br />
+ </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><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Second</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>row</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>5.0</Content>
+ </CharacterStyleRange><Br />
+ </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><Br />
+ </ParagraphStyleRange>
+ </Cell>
+</Table>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here's the caption. It may span multiple lines.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiline table without caption:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+ </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><Br />
+ </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><Br />
+ </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><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>First</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>row</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12.0</Content>
+ </CharacterStyleRange><Br />
+ </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><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Second</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>row</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>5.0</Content>
+ </CharacterStyleRange><Br />
+ </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><Br />
+ </ParagraphStyleRange>
+ </Cell>
+</Table>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
+ <Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Table without column headers:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>123</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="3:2" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>1</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+</Table>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
+ <Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiline table without column headers:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>row</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:0" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>12.0</Content>
+ </CharacterStyleRange><Br />
+ </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><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="0:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; CenterAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Second</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="1:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; LeftAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>row</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ </Cell>
+ <Cell Name="2:1" AppliedCellStyle="CellStyle/Cell">
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TablePar &gt; RightAlign">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>5.0</Content>
+ </CharacterStyleRange><Br />
+ </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><Br />
+ </ParagraphStyleRange>
+ </Cell>
+</Table>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TableCaption">
+ <Br />
+</ParagraphStyleRange>
diff --git a/tests/tables.latex b/tests/tables.latex
index 82abeb9a5..1a87c4f71 100644
--- a/tests/tables.latex
+++ b/tests/tables.latex
@@ -1,169 +1,169 @@
Simple table with caption:
\begin{longtable}[c]{@{}rlcl@{}}
-\hline\noalign{\medskip}
+\toprule\addlinespace
Right & Left & Center & Default
-\\\noalign{\medskip}
-\hline\noalign{\medskip}
+\\\addlinespace
+\midrule\endhead
12 & 12 & 12 & 12
-\\\noalign{\medskip}
+\\\addlinespace
123 & 123 & 123 & 123
-\\\noalign{\medskip}
+\\\addlinespace
1 & 1 & 1 & 1
-\\\noalign{\medskip}
-\hline
-\noalign{\medskip}
+\\\addlinespace
+\bottomrule
+\addlinespace
\caption{Demonstration of simple table syntax.}
\end{longtable}
Simple table without caption:
\begin{longtable}[c]{@{}rlcl@{}}
-\hline\noalign{\medskip}
+\toprule\addlinespace
Right & Left & Center & Default
-\\\noalign{\medskip}
-\hline\noalign{\medskip}
+\\\addlinespace
+\midrule\endhead
12 & 12 & 12 & 12
-\\\noalign{\medskip}
+\\\addlinespace
123 & 123 & 123 & 123
-\\\noalign{\medskip}
+\\\addlinespace
1 & 1 & 1 & 1
-\\\noalign{\medskip}
-\hline
+\\\addlinespace
+\bottomrule
\end{longtable}
Simple table indented two spaces:
\begin{longtable}[c]{@{}rlcl@{}}
-\hline\noalign{\medskip}
+\toprule\addlinespace
Right & Left & Center & Default
-\\\noalign{\medskip}
-\hline\noalign{\medskip}
+\\\addlinespace
+\midrule\endhead
12 & 12 & 12 & 12
-\\\noalign{\medskip}
+\\\addlinespace
123 & 123 & 123 & 123
-\\\noalign{\medskip}
+\\\addlinespace
1 & 1 & 1 & 1
-\\\noalign{\medskip}
-\hline
-\noalign{\medskip}
+\\\addlinespace
+\bottomrule
+\addlinespace
\caption{Demonstration of simple table syntax.}
\end{longtable}
Multiline table with caption:
\begin{longtable}[c]{@{}clrl@{}}
-\hline\noalign{\medskip}
-\begin{minipage}[b]{0.15\columnwidth}\centering
+\toprule\addlinespace
+\begin{minipage}[b]{0.13\columnwidth}\centering
Centered Header
-\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright
Left Aligned
-\end{minipage} & \begin{minipage}[b]{0.16\columnwidth}\raggedleft
+\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedleft
Right Aligned
-\end{minipage} & \begin{minipage}[b]{0.34\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright
Default aligned
\end{minipage}
-\\\noalign{\medskip}
-\hline\noalign{\medskip}
-\begin{minipage}[t]{0.15\columnwidth}\centering
+\\\addlinespace
+\midrule\endhead
+\begin{minipage}[t]{0.13\columnwidth}\centering
First
-\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
row
-\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft
+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft
12.0
-\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
Example of a row that spans multiple lines.
\end{minipage}
-\\\noalign{\medskip}
-\begin{minipage}[t]{0.15\columnwidth}\centering
+\\\addlinespace
+\begin{minipage}[t]{0.13\columnwidth}\centering
Second
-\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
row
-\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft
+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft
5.0
-\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
Here's another one. Note the blank line between rows.
\end{minipage}
-\\\noalign{\medskip}
-\hline
-\noalign{\medskip}
+\\\addlinespace
+\bottomrule
+\addlinespace
\caption{Here's the caption. It may span multiple lines.}
\end{longtable}
Multiline table without caption:
\begin{longtable}[c]{@{}clrl@{}}
-\hline\noalign{\medskip}
-\begin{minipage}[b]{0.15\columnwidth}\centering
+\toprule\addlinespace
+\begin{minipage}[b]{0.13\columnwidth}\centering
Centered Header
-\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright
Left Aligned
-\end{minipage} & \begin{minipage}[b]{0.16\columnwidth}\raggedleft
+\end{minipage} & \begin{minipage}[b]{0.14\columnwidth}\raggedleft
Right Aligned
-\end{minipage} & \begin{minipage}[b]{0.34\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright
Default aligned
\end{minipage}
-\\\noalign{\medskip}
-\hline\noalign{\medskip}
-\begin{minipage}[t]{0.15\columnwidth}\centering
+\\\addlinespace
+\midrule\endhead
+\begin{minipage}[t]{0.13\columnwidth}\centering
First
-\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
row
-\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft
+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft
12.0
-\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
Example of a row that spans multiple lines.
\end{minipage}
-\\\noalign{\medskip}
-\begin{minipage}[t]{0.15\columnwidth}\centering
+\\\addlinespace
+\begin{minipage}[t]{0.13\columnwidth}\centering
Second
-\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
row
-\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft
+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft
5.0
-\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
Here's another one. Note the blank line between rows.
\end{minipage}
-\\\noalign{\medskip}
-\hline
+\\\addlinespace
+\bottomrule
\end{longtable}
Table without column headers:
\begin{longtable}[c]{@{}rlcr@{}}
-\hline\noalign{\medskip}
+\toprule\addlinespace
12 & 12 & 12 & 12
-\\\noalign{\medskip}
+\\\addlinespace
123 & 123 & 123 & 123
-\\\noalign{\medskip}
+\\\addlinespace
1 & 1 & 1 & 1
-\\\noalign{\medskip}
-\hline
+\\\addlinespace
+\bottomrule
\end{longtable}
Multiline table without column headers:
\begin{longtable}[c]{@{}clrl@{}}
-\hline\noalign{\medskip}
-\begin{minipage}[t]{0.15\columnwidth}\centering
+\toprule\addlinespace
+\begin{minipage}[t]{0.13\columnwidth}\centering
First
-\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
row
-\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft
+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft
12.0
-\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
Example of a row that spans multiple lines.
\end{minipage}
-\\\noalign{\medskip}
-\begin{minipage}[t]{0.15\columnwidth}\centering
+\\\addlinespace
+\begin{minipage}[t]{0.13\columnwidth}\centering
Second
-\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
row
-\end{minipage} & \begin{minipage}[t]{0.16\columnwidth}\raggedleft
+\end{minipage} & \begin{minipage}[t]{0.14\columnwidth}\raggedleft
5.0
-\end{minipage} & \begin{minipage}[t]{0.34\columnwidth}\raggedright
+\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
Here's another one. Note the blank line between rows.
\end{minipage}
-\\\noalign{\medskip}
-\hline
+\\\addlinespace
+\bottomrule
\end{longtable}
diff --git a/tests/tables.mediawiki b/tests/tables.mediawiki
index 4836ecd79..efde76559 100644
--- a/tests/tables.mediawiki
+++ b/tests/tables.mediawiki
@@ -1,212 +1,146 @@
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>
+{|
+|+ 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:
-<table>
-<thead>
-<tr class="header">
-<th align="right">Right</th>
-<th align="left">Left</th>
-<th align="center">Center</th>
-<th align="left">Default</th>
-</tr>
-</thead>
-<tbody>
-<tr class="odd">
-<td align="right">12</td>
-<td align="left">12</td>
-<td align="center">12</td>
-<td align="left">12</td>
-</tr>
-<tr class="even">
-<td align="right">123</td>
-<td align="left">123</td>
-<td align="center">123</td>
-<td align="left">123</td>
-</tr>
-<tr class="odd">
-<td align="right">1</td>
-<td align="left">1</td>
-<td align="center">1</td>
-<td align="left">1</td>
-</tr>
-</tbody>
-</table>
+{|
+!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:
-<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>
+{|
+|+ 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:
-<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>
+{|
+|+ 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:
-<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>
+{|
+!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:
-<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>
+{|
+|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:
-<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>
+{|
+|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/tests/tables.rtf b/tests/tables.rtf
index 011724967..e1fe4aab1 100644
--- a/tests/tables.rtf
+++ b/tests/tables.rtf
@@ -4,13 +4,13 @@
\clbrdrb\brdrs\cellx2160\clbrdrb\brdrs\cellx4320\clbrdrb\brdrs\cellx6480\clbrdrb\brdrs\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 Right\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Left\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Center\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Center\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Default\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default\par}
\cell}
}
\intbl\row}
@@ -19,13 +19,13 @@
\cellx2160\cellx4320\cellx6480\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 12\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par}
\cell}
}
\intbl\row}
@@ -34,13 +34,13 @@
\cellx2160\cellx4320\cellx6480\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 123\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par}
\cell}
}
\intbl\row}
@@ -49,13 +49,13 @@
\cellx2160\cellx4320\cellx6480\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 1\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par}
\cell}
}
\intbl\row}
@@ -66,13 +66,13 @@
\clbrdrb\brdrs\cellx2160\clbrdrb\brdrs\cellx4320\clbrdrb\brdrs\cellx6480\clbrdrb\brdrs\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 Right\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Left\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Center\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Center\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Default\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default\par}
\cell}
}
\intbl\row}
@@ -81,13 +81,13 @@
\cellx2160\cellx4320\cellx6480\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 12\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par}
\cell}
}
\intbl\row}
@@ -96,13 +96,13 @@
\cellx2160\cellx4320\cellx6480\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 123\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par}
\cell}
}
\intbl\row}
@@ -111,13 +111,13 @@
\cellx2160\cellx4320\cellx6480\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 1\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par}
\cell}
}
\intbl\row}
@@ -128,13 +128,13 @@
\clbrdrb\brdrs\cellx2160\clbrdrb\brdrs\cellx4320\clbrdrb\brdrs\cellx6480\clbrdrb\brdrs\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 Right\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Left\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Center\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Center\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Default\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default\par}
\cell}
}
\intbl\row}
@@ -143,13 +143,13 @@
\cellx2160\cellx4320\cellx6480\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 12\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par}
\cell}
}
\intbl\row}
@@ -158,13 +158,13 @@
\cellx2160\cellx4320\cellx6480\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 123\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par}
\cell}
}
\intbl\row}
@@ -173,13 +173,13 @@
\cellx2160\cellx4320\cellx6480\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 1\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par}
\cell}
}
\intbl\row}
@@ -190,13 +190,13 @@
\clbrdrb\brdrs\cellx1296\clbrdrb\brdrs\cellx2484\clbrdrb\brdrs\cellx3888\clbrdrb\brdrs\cellx6804
\trkeep\intbl
{
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Centered Header\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Centered Header\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Left Aligned\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left Aligned\par}
\cell}
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 Right Aligned\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right Aligned\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Default aligned\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default aligned\par}
\cell}
}
\intbl\row}
@@ -205,13 +205,13 @@
\cellx1296\cellx2484\cellx3888\cellx6804
\trkeep\intbl
{
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 First\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 First\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 row\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par}
\cell}
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12.0\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12.0\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par}
\cell}
}
\intbl\row}
@@ -220,13 +220,13 @@
\cellx1296\cellx2484\cellx3888\cellx6804
\trkeep\intbl
{
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Second\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Second\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 row\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par}
\cell}
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 5.0\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 5.0\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Here's another one. Note the blank line between rows.\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Here's another one. Note the blank line between rows.\par}
\cell}
}
\intbl\row}
@@ -237,13 +237,13 @@
\clbrdrb\brdrs\cellx1296\clbrdrb\brdrs\cellx2484\clbrdrb\brdrs\cellx3888\clbrdrb\brdrs\cellx6804
\trkeep\intbl
{
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Centered Header\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Centered Header\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Left Aligned\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Left Aligned\par}
\cell}
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 Right Aligned\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 Right Aligned\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Default aligned\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Default aligned\par}
\cell}
}
\intbl\row}
@@ -252,13 +252,13 @@
\cellx1296\cellx2484\cellx3888\cellx6804
\trkeep\intbl
{
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 First\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 First\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 row\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par}
\cell}
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12.0\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12.0\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par}
\cell}
}
\intbl\row}
@@ -267,13 +267,13 @@
\cellx1296\cellx2484\cellx3888\cellx6804
\trkeep\intbl
{
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Second\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Second\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 row\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par}
\cell}
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 5.0\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 5.0\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Here's another one. Note the blank line between rows.\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Here's another one. Note the blank line between rows.\par}
\cell}
}
\intbl\row}
@@ -284,13 +284,13 @@
\cellx2160\cellx4320\cellx6480\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 12\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 12\par}
\cell}
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12\par}
\cell}
}
\intbl\row}
@@ -299,13 +299,13 @@
\cellx2160\cellx4320\cellx6480\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 123\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 123\par}
\cell}
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 123\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 123\par}
\cell}
}
\intbl\row}
@@ -314,13 +314,13 @@
\cellx2160\cellx4320\cellx6480\cellx8640
\trkeep\intbl
{
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 1\par}
\cell}
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 1\par}
\cell}
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 1\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 1\par}
\cell}
}
\intbl\row}
@@ -331,13 +331,13 @@
\cellx1296\cellx2484\cellx3888\cellx6804
\trkeep\intbl
{
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 First\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 First\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 row\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par}
\cell}
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 12.0\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 12.0\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Example of a row that spans multiple lines.\par}
\cell}
}
\intbl\row}
@@ -346,13 +346,13 @@
\cellx1296\cellx2484\cellx3888\cellx6804
\trkeep\intbl
{
-{\intbl {\pard \qc \f0 \sa0 \li0 \fi0 Second\par}
+{{\pard\intbl \qc \f0 \sa0 \li0 \fi0 Second\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 row\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 row\par}
\cell}
-{\intbl {\pard \qr \f0 \sa0 \li0 \fi0 5.0\par}
+{{\pard\intbl \qr \f0 \sa0 \li0 \fi0 5.0\par}
\cell}
-{\intbl {\pard \ql \f0 \sa0 \li0 \fi0 Here's another one. Note the blank line between rows.\par}
+{{\pard\intbl \ql \f0 \sa0 \li0 \fi0 Here's another one. Note the blank line between rows.\par}
\cell}
}
\intbl\row}
diff --git a/tests/test-pandoc.hs b/tests/test-pandoc.hs
index 24b7a8261..c07a51ec5 100644
--- a/tests/test-pandoc.hs
+++ b/tests/test-pandoc.hs
@@ -7,33 +7,47 @@ import GHC.IO.Encoding
import qualified Tests.Old
import qualified Tests.Readers.LaTeX
import qualified Tests.Readers.Markdown
+import qualified Tests.Readers.Org
import qualified Tests.Readers.RST
+import qualified Tests.Readers.Docx
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.AsciiDoc
import qualified Tests.Shared
+import qualified Tests.Walk
import Text.Pandoc.Shared (inDirectory)
tests :: [Test]
tests = [ testGroup "Old" Tests.Old.tests
, testGroup "Shared" Tests.Shared.tests
+ , testGroup "Walk" Tests.Walk.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 "AsciiDoc" Tests.Writers.AsciiDoc.tests
]
, testGroup "Readers"
[ testGroup "LaTeX" Tests.Readers.LaTeX.tests
, testGroup "Markdown" Tests.Readers.Markdown.tests
+ , testGroup "Org" Tests.Readers.Org.tests
, testGroup "RST" Tests.Readers.RST.tests
+ , testGroup "Docx" Tests.Readers.Docx.tests
+
]
]
main :: IO ()
main = do
setLocaleEncoding utf8
- inDirectory "tests" $ defaultMain tests
+ -- we ignore command-line arguments, since we're having cabal pass
+ -- the build directory as first argument, and we don't want test-framework
+ -- to choke on that.
+ inDirectory "tests" $ defaultMainWithArgs tests []
diff --git a/tests/testsuite.native b/tests/testsuite.native
index d7f5f8864..678d7595f 100644
--- a/tests/testsuite.native
+++ b/tests/testsuite.native
@@ -228,45 +228,35 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
,[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:"]
-,RawBlock "html" "<div>"
-,Plain [Str "foo"]
-,RawBlock "html" "</div>\n"
+,Div ("",[],[]) [Plain [Str "foo"]]
,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"]
-,RawBlock "html" "<div>\n<div>\n<div>"
-,Plain [Str "foo"]
-,RawBlock "html" "</div>\n</div>\n<div>"
-,Plain [Str "bar"]
-,RawBlock "html" "</div>\n</div>\n"
+,Div ("",[],[]) [Div ("",[],[]) [Div ("",[],[]) [Plain [Str "foo"]]],Div ("",[],[]) [Plain [Str "bar"]]]
,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]
-,RawBlock "html" "<table>\n<tr>\n<td>"
+,RawBlock (Format "html") "<table>\n<tr>\n<td>"
,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]]
-,RawBlock "html" "</td>\n<td>"
+,RawBlock (Format "html") "</td>\n<td>"
,Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]]
-,RawBlock "html" "</td>\n</tr>\n</table>\n\n<script type=\"text/javascript\">document.write('This *should not* be interpreted as markdown');</script>\n"
+,RawBlock (Format "html") "</td>\n</tr>\n</table>\n\n<script type=\"text/javascript\">document.write('This *should not* be interpreted as markdown');</script>\n"
,Para [Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block:"]
-,RawBlock "html" "<div>\n "
-,Plain [Str "foo"]
-,RawBlock "html" "</div>\n"
+,Div ("",[],[]) [Plain [Str "foo"]]
,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"]
,CodeBlock ("",[],[]) "<div>\n foo\n</div>"
,Para [Str "As",Space,Str "should",Space,Str "this:"]
,CodeBlock ("",[],[]) "<div>foo</div>"
,Para [Str "Now,",Space,Str "nested:"]
-,RawBlock "html" "<div>\n <div>\n <div>\n "
-,Plain [Str "foo"]
-,RawBlock "html" "</div>\n </div>\n</div>\n"
+,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 "html" "<!-- Comment -->\n"
+,RawBlock (Format "html") "<!-- Comment -->\n"
,Para [Str "Multiline:"]
-,RawBlock "html" "<!--\nBlah\nBlah\n-->\n\n<!--\n This is another comment.\n-->\n"
+,RawBlock (Format "html") "<!--\nBlah\nBlah\n-->\n\n<!--\n This is another comment.\n-->\n"
,Para [Str "Code",Space,Str "block:"]
,CodeBlock ("",[],[]) "<!-- Comment -->"
,Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"]
-,RawBlock "html" "<!-- foo --> \n"
+,RawBlock (Format "html") "<!-- foo --> \n"
,Para [Str "Code:"]
,CodeBlock ("",[],[]) "<hr />"
,Para [Str "Hr\8217s:"]
-,RawBlock "html" "<hr>\n\n<hr />\n\n<hr />\n\n<hr> \n\n<hr /> \n\n<hr /> \n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\">\n"
+,RawBlock (Format "html") "<hr>\n\n<hr />\n\n<hr />\n\n<hr> \n\n<hr /> \n\n<hr /> \n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\">\n"
,HorizontalRule
,Header 1 ("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 "."]
@@ -294,7 +284,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
,HorizontalRule
,Header 1 ("latex",[],[]) [Str "LaTeX"]
,BulletList
- [[Plain [RawInline "tex" "\\cite[22-23]{smith.1899}"]]
+ [[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"]]
@@ -309,7 +299,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
,[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 "latex" "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"
+,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:"]
diff --git a/tests/testsuite.txt b/tests/testsuite.txt
index 3bb5d8cb5..4ddaae23f 100644
--- a/tests/testsuite.txt
+++ b/tests/testsuite.txt
@@ -377,7 +377,7 @@ Interpreted markdown in a table:
Here's a simple block:
<div>
- foo
+foo
</div>
This should be a code block, though:
@@ -393,11 +393,11 @@ As should this:
Now, nested:
<div>
- <div>
- <div>
- foo
- </div>
- </div>
+ <div>
+ <div>
+ foo
+ </div>
+ </div>
</div>
This should just be an HTML comment:
diff --git a/tests/textile-reader.native b/tests/textile-reader.native
index 22a338d38..a17bd8de1 100644
--- a/tests/textile-reader.native
+++ b/tests/textile-reader.native
@@ -1,96 +1,96 @@
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",Str ".",Space,Str "Part",Space,Str "of",Space,Str "it",Space,Str "comes",LineBreak,Str "from",Space,Str "John",Space,Str "Gruber",Str "\8217",Str "s",Space,Str "markdown",Space,Str "test",Space,Str "suite",Str "."]
+[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 ("",[],[]) [Str "Headers"]
-,Header 2 ("",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",Space,Link [Str "embeded",Space,Str "link"] ("http://www.example.com","")]
-,Header 3 ("",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Strong [Str "emphasis"]]
-,Header 4 ("",[],[]) [Str "Level",Space,Str "4"]
-,Header 5 ("",[],[]) [Str "Level",Space,Str "5"]
-,Header 6 ("",[],[]) [Str "Level",Space,Str "6"]
-,Header 1 ("",[],[]) [Str "Paragraphs"]
-,Para [Str "Here",Str "\8217",Str "s",Space,Str "a",Space,Str "regular",Space,Str "paragraph",Str "."]
-,Para [Str "Line",Space,Str "breaks",Space,Str "are",Space,Str "preserved",Space,Str "in",Space,Str "textile",Str ",",Space,Str "so",Space,Str "you",Space,Str "can",Space,Str "not",Space,Str "wrap",Space,Str "your",Space,Str "very",LineBreak,Str "long",Space,Str "paragraph",Space,Str "with",Space,Str "your",Space,Str "favourite",Space,Str "text",Space,Str "editor",Space,Str "and",Space,Str "have",Space,Str "it",Space,Str "rendered",LineBreak,Str "with",Space,Str "no",Space,Str "break",Str "."]
-,Para [Str "Here",Str "\8217",Str "s",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet",Str "."]
+,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",Str "."]]]
+ [[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",Str "."]
-,Para [Str "pandoc",Space,Str "converts",Space,Str "textile",Str "."]
-,Header 1 ("",[],[]) [Str "Block",Space,Str "Quotes"]
+,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",Str ".",Space,Str "He",Space,Str "had",Space,Str "a",Space,Str "lot",Space,Str "of",Space,Str "things",Space,Str "to",LineBreak,Str "say",Str ",",Space,Str "so",Space,Str "the",Space,Str "text",Space,Str "is",Space,Str "really",Space,Str "really",Space,Str "long",Space,Str "and",Space,Str "spans",Space,Str "on",Space,Str "multiple",Space,Str "lines",Str "."]]
-,Para [Str "And",Space,Str "a",Space,Str "following",Space,Str "paragraph",Str "."]
-,Header 1 ("",[],[]) [Str "Code",Space,Str "Blocks"]
-,Para [Str "Code",Str ":"]
+ [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",Str ":"]
+,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 @</\\\n"
-,Para [Str "Inline",Space,Str "code",Str ":",Space,Code ("",[],[]) "<tt>",Str ",",Space,Code ("",[],[]) "@",Str "."]
-,Header 1 ("",[],[]) [Str "Notextile"]
+,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",Str "."]
-,Header 1 ("",[],[]) [Str "Lists"]
-,Header 2 ("",[],[]) [Str "Unordered"]
-,Para [Str "Asterisks",Space,Str "tight",Str ":"]
+,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",Str ":"]
+,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 ("",[],[]) [Str "Ordered"]
-,Para [Str "Tight",Str ":"]
+,Header 2 ("ordered",[],[]) [Str "Ordered"]
+,Para [Str "Tight:"]
,OrderedList (1,DefaultStyle,DefaultDelim)
[[Plain [Str "First"]]
,[Plain [Str "Second"]]
,[Plain [Str "Third"]]]
-,Header 2 ("",[],[]) [Str "Nested"]
+,Header 2 ("nested",[],[]) [Str "Nested"]
,BulletList
[[Plain [Str "ui",Space,Str "1"]
,BulletList
- [[Plain [Str "ui",Space,Str "1",Str ".",Str "1"]
+ [[Plain [Str "ui",Space,Str "1.1"]
,OrderedList (1,DefaultStyle,DefaultDelim)
- [[Plain [Str "oi",Space,Str "1",Str ".",Str "1",Str ".",Str "1"]]
- ,[Plain [Str "oi",Space,Str "1",Str ".",Str "1",Str ".",Str "2"]]]]
- ,[Plain [Str "ui",Space,Str "1",Str ".",Str "2"]]]]
+ [[Plain [Str "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",Str ".",Str "1"]
+ [[Plain [Str "oi",Space,Str "2.1"]
,BulletList
- [[Plain [Str "ui",Space,Str "2",Str ".",Str "1",Str ".",Str "1"]]
- ,[Plain [Str "ui",Space,Str "2",Str ".",Str "1",Str ".",Str "2"]]]]]]]
-,Header 2 ("",[],[]) [Str "Definition",Space,Str "List"]
+ [[Plain [Str "ui",Space,Str "2.1.1"]]
+ ,[Plain [Str "ui",Space,Str "2.1.2"]]]]]]]
+,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",Str ",",Space,Str "but",Space,Str "a",Space,Str "little",Space,Str "less",Space,Str "black"]]])
+ [[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",Str "."]
- ,Para [Str "Cold",Space,Str "drink",Space,Str "that",Space,Str "goes",Space,Str "great",Space,Str "with",Space,Str "cookies",Str "."]]])
+ [[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 ("",[],[]) [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",Str ",",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str "strange_underscore_notation",Str ".",LineBreak,Str "A",Space,Link [Strong [Str "strong",Space,Str "link"]] ("http://www.foobar.com",""),Str "."]
-,Para [Emph [Strong [Str "This",Space,Str "is",Space,Str "strong",Space,Str "and",Space,Str "em",Str "."]],LineBreak,Str "So",Space,Str "is",Space,Strong [Emph [Str "this"]],Space,Str "word",Space,Str "and",Space,Emph [Strong [Str "that",Space,Str "one"]],Str ".",LineBreak,Strikeout [Str "This",Space,Str "is",Space,Str "strikeout",Space,Str "and",Space,Strong [Str "strong"]]]
-,Para [Str "Superscripts",Str ":",Space,Str "a",Superscript [Str "bc"],Str "d",Space,Str "a",Superscript [Strong [Str "hello"]],Space,Str "a",Superscript [Str "hello",Space,Str "there"],Str ".",LineBreak,Str "Subscripts",Str ":",Space,Subscript [Str "here"],Space,Str "H",Subscript [Str "2"],Str "O",Str ",",Space,Str "H",Subscript [Str "23"],Str "O",Str ",",Space,Str "H",Subscript [Str "many",Space,Str "of",Space,Str "them"],Str "O",Str "."]
-,Para [Str "Dashes",Space,Str ":",Space,Str "How",Space,Str "cool",Space,Str "\8212",Space,Str "automatic",Space,Str "dashes",Str "."]
-,Para [Str "Elipses",Space,Str ":",Space,Str "He",Space,Str "thought",Space,Str "and",Space,Str "thought",Space,Str "\8230",Space,Str "and",Space,Str "then",Space,Str "thought",Space,Str "some",Space,Str "more",Str "."]
-,Para [Str "Quotes",Space,Str "and",Space,Str "apostrophes",Space,Str ":",Space,Quoted DoubleQuote [Str "I",Str "\8217",Str "d",Space,Str "like",Space,Str "to",Space,Str "thank",Space,Str "you"],Space,Str "for",Space,Str "example",Str "."]
-,Header 1 ("",[],[]) [Str "Links"]
-,Header 2 ("",[],[]) [Str "Explicit"]
+,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 [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",Str "."]
-,Para [Str "A",Space,Str "link",Link [Str "with",Space,Str "brackets"] ("http://www.example.com",""),Str "and",Space,Str "no",Space,Str "spaces",Str "."]
-,Header 1 ("",[],[]) [Str "Tables"]
+,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 ("",[],[]) [Str "Without",Space,Str "headers"]
+,Header 2 ("without-headers",[],[]) [Str "Without",Space,Str "headers"]
,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0]
[]
[[[Plain [Str "name"]]
@@ -106,7 +106,7 @@ Pandoc (Meta {unMeta = fromList []})
,[Plain [Str "45"]]
,[Plain [Str "f"]]]]
,Para [Str "and",Space,Str "some",Space,Str "text",Space,Str "following",Space,Str "\8230"]
-,Header 2 ("",[],[]) [Str "With",Space,Str "headers"]
+,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"]]
@@ -120,12 +120,12 @@ Pandoc (Meta {unMeta = fromList []})
,[[Plain [Str "bella"]]
,[Plain [Str "45"]]
,[Plain [Str "f"]]]]
-,Header 1 ("",[],[]) [Str "Images"]
-,Para [Str "Textile",Space,Str "inline",Space,Str "image",Space,Str "syntax",Str ",",Space,Str "like",Space,LineBreak,Str "here",Space,Image [Str "this is the alt text"] ("this_is_an_image.png","this is the alt text"),LineBreak,Str "and",Space,Str "here",Space,Image [Str ""] ("this_is_an_image.png",""),Str "."]
-,Header 1 ("",[],[]) [Str "Attributes"]
-,Header 2 ("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",Str "."]
-,Para [Str "as",Space,Str "well",Space,Str "as",Space,Strong [Str "inline",Space,Str "attributes"],Space,Str "of",Space,Str " all kind"]
-,Para [Str "and",Space,Str "paragraph",Space,Str "attributes",Str ",",Space,Str "and",Space,Str "table",Space,Str "attributes",Str "."]
+,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."]
+,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"]]
@@ -134,34 +134,33 @@ Pandoc (Meta {unMeta = fromList []})
,[[Plain [Str "joan"]]
,[Plain [Str "24"]]
,[Plain [Str "f"]]]]
-,Header 1 ("",[],[]) [Str "Entities"]
+,Header 1 ("entities",[],[]) [Str "Entities"]
,Para [Str "*",LineBreak,Str "&"]
-,Header 1 ("",[],[]) [Str "Raw",Space,Str "HTML"]
-,Para [Str "However",Str ",",Space,RawInline "html" "<strong>",Space,Str "raw",Space,Str "HTML",Space,Str "inlines",Space,RawInline "html" "</strong>",Space,Str "are",Space,Str "accepted",Str ",",Space,Str "as",Space,Str "well",Space,Str "as",Space,Str ":"]
-,RawBlock "html" "<div class=\"foobar\">"
-,Para [Str "any",Space,Strong [Str "Raw",Space,Str "HTML",Space,Str "Block"],Space,Str "with",Space,Str "bold",LineBreak]
-,RawBlock "html" "</div>"
+,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",Space,Str "be"]
-,RawBlock "html" "<div>"
+,RawBlock (Format "html") "<div>"
,Para [Str "inlined"]
-,RawBlock "html" "</div>"
-,Para [Str "as",Space,Str "well",Str "."]
+,RawBlock (Format "html") "</div>"
+,Para [Str "as",Space,Str "well."]
,BulletList
- [[Plain [Str "this",Space,Str "<",Str "div",Str ">",Space,Str "won",Str "\8217",Str "t",Space,Str "produce",Space,Str "raw",Space,Str "html",Space,Str "blocks",Space,Str "<",Str "/div",Str ">"]]
- ,[Plain [Str "but",Space,Str "this",Space,RawInline "html" "<strong>",Space,Str "will",Space,Str "produce",Space,Str "inline",Space,Str "html",Space,RawInline "html" "</strong>"]]]
+ [[Plain [Str "this",Space,Str "<div>",Space,Str "won\8217t",Space,Str "produce",Space,Str "raw",Space,Str "html",Space,Str "blocks",Space,Str "</div>"]]
+ ,[Plain [Str "but",Space,Str "this",Space,RawInline (Format "html") "<strong>",Space,Str "will",Space,Str "produce",Space,Str "inline",Space,Str "html",Space,RawInline (Format "html") "</strong>"]]]
,Para [Str "Can",Space,Str "you",Space,Str "prove",Space,Str "that",Space,Str "2",Space,Str "<",Space,Str "3",Space,Str "?"]
-,Header 1 ("",[],[]) [Str "Raw",Space,Str "LaTeX"]
+,Header 1 ("raw-latex",[],[]) [Str "Raw",Space,Str "LaTeX"]
,Para [Str "This",Space,Str "Textile",Space,Str "reader",Space,Str "also",Space,Str "accepts",Space,Str "raw",Space,Str "LaTeX",Space,Str "for",Space,Str "blocks",Space,Str ":"]
-,RawBlock "latex" "\\begin{itemize}\n \\item one\n \\item two\n\\end{itemize}"
-,Para [Str "and",Space,Str "for",Space,RawInline "latex" "\\emph{inlines}",Str "."]
-,Header 1 ("",[],[]) [Str "Acronyms",Space,Str "and",Space,Str "marks"]
+,RawBlock (Format "latex") "\\begin{itemize}\n \\item one\n \\item two\n\\end{itemize}"
+,Para [Str "and",Space,Str "for",Space,RawInline (Format "latex") "\\emph{inlines}",Str "."]
+,Header 1 ("acronyms-and-marks",[],[]) [Str "Acronyms",Space,Str "and",Space,Str "marks"]
,Para [Str "PBS (Public Broadcasting System)"]
-,Para [Str "Hi",Str "\8482"]
+,Para [Str "Hi\8482"]
,Para [Str "Hi",Space,Str "\8482"]
-,Para [Str "\174",Space,Str "Hi",Str "\174"]
-,Para [Str "Hi",Str "\169",Str "2008",Space,Str "\169",Space,Str "2008"]
-,Header 1 ("",[],[]) [Str "Footnotes"]
-,Para [Str "A",Space,Str "note",Str ".",Note [Para [Str "The",Space,Str "note",LineBreak,Str "is",Space,Str "here",Str "!"]],Space,Str "Another",Space,Str "note",Note [Para [Str "Other",Space,Str "note",Str "."]],Str "."]
-,Header 1 ("",[],[]) [Str "Comment",Space,Str "blocks"]
-,Null
-,Para [Str "not",Space,Str "a",Space,Str "comment",Str "."]]
+,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/tests/textile-reader.textile b/tests/textile-reader.textile
index e31052b6a..73c36b0d1 100644
--- a/tests/textile-reader.textile
+++ b/tests/textile-reader.textile
@@ -139,8 +139,8 @@ _*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.
+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.
@@ -187,7 +187,7 @@ h2. With headers
h1. Images
-Textile inline image syntax, like
+Textile inline image syntax, like
here !this_is_an_image.png(this is the alt text)!
and here !this_is_an_image.png!.
diff --git a/tests/writer.context b/tests/writer.context
index 114d00b3c..0c5024d89 100644
--- a/tests/writer.context
+++ b/tests/writer.context
@@ -30,6 +30,9 @@
\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
\setupdelimitedtext
@@ -810,24 +813,22 @@ braces]\from[url26].
\subsection[autolinks]{Autolinks}
-With an ampersand:
-\useURL[url27][http://example.com/?foo=1&bar=2][][\hyphenatedurl{http://example.com/?foo=1&bar=2}]\from[url27]
+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/][][\hyphenatedurl{http://example.com/}]\from[url28]
+ \useURL[url28][http://example.com/]\from[url28]
\item
It should.
\stopitemize
An e-mail address:
-\useURL[url29][mailto:nobody@nowhere.net][][\hyphenatedurl{nobody@nowhere.net}]\from[url29]
+\useURL[url29][mailto:nobody@nowhere.net][][nobody@nowhere.net]\from[url29]
\startblockquote
-Blockquoted:
-\useURL[url30][http://example.com/][][\hyphenatedurl{http://example.com/}]\from[url30]
+Blockquoted: \useURL[url30][http://example.com/]\from[url30]
\stopblockquote
Auto-links should not occur here: \type{<http://example.com/>}
@@ -842,7 +843,7 @@ or here: <http://example.com/>
From \quotation{Voyage dans la Lune} by Georges Melies (1902):
-\placefigure[here,nonumber]{lalune}{\externalfigure[lalune.jpg]}
+\placefigure{lalune}{\externalfigure[lalune.jpg]}
Here is a movie {\externalfigure[movie.jpg]} icon.
diff --git a/tests/writer.docbook b/tests/writer.docbook
index 1e77a61ed..01daa2c30 100644
--- a/tests/writer.docbook
+++ b/tests/writer.docbook
@@ -4,14 +4,16 @@
<article>
<articleinfo>
<title>Pandoc Test Suite</title>
- <author>
- <firstname>John</firstname>
- <surname>MacFarlane</surname>
- </author>
- <author>
- <firstname></firstname>
- <surname>Anonymous</surname>
- </author>
+ <authorgroup>
+ <author>
+ <firstname>John</firstname>
+ <surname>MacFarlane</surname>
+ </author>
+ <author>
+ <firstname></firstname>
+ <surname>Anonymous</surname>
+ </author>
+ </authorgroup>
<date>July 17, 2006</date>
</articleinfo>
<para>
@@ -66,10 +68,8 @@
<para>
Here’s one with a bullet. * criminey.
</para>
- <para>
- There should be a hard line break<literallayout>
-</literallayout>here.
- </para>
+<literallayout>There should be a hard line break
+here.</literallayout>
</sect1>
<sect1 id="block-quotes">
<title>Block Quotes</title>
@@ -93,7 +93,7 @@ sub status {
<para>
A list:
</para>
- <orderedlist numeration="arabic">
+ <orderedlist numeration="arabic" spacing="compact">
<listitem>
<para>
item one
@@ -156,7 +156,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Asterisks tight:
</para>
- <itemizedlist>
+ <itemizedlist spacing="compact">
<listitem>
<para>
asterisk 1
@@ -196,7 +196,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Pluses tight:
</para>
- <itemizedlist>
+ <itemizedlist spacing="compact">
<listitem>
<para>
Plus 1
@@ -236,7 +236,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Minuses tight:
</para>
- <itemizedlist>
+ <itemizedlist spacing="compact">
<listitem>
<para>
Minus 1
@@ -279,7 +279,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Tight:
</para>
- <orderedlist numeration="arabic">
+ <orderedlist numeration="arabic" spacing="compact">
<listitem>
<para>
First
@@ -299,7 +299,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
and:
</para>
- <orderedlist numeration="arabic">
+ <orderedlist numeration="arabic" spacing="compact">
<listitem>
<para>
One
@@ -383,17 +383,17 @@ These should not be escaped: \$ \\ \&gt; \[ \{
</sect2>
<sect2 id="nested">
<title>Nested</title>
- <itemizedlist>
+ <itemizedlist spacing="compact">
<listitem>
<para>
Tab
</para>
- <itemizedlist>
+ <itemizedlist spacing="compact">
<listitem>
<para>
Tab
</para>
- <itemizedlist>
+ <itemizedlist spacing="compact">
<listitem>
<para>
Tab
@@ -407,7 +407,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Here’s another:
</para>
- <orderedlist numeration="arabic">
+ <orderedlist numeration="arabic" spacing="compact">
<listitem>
<para>
First
@@ -417,7 +417,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Second:
</para>
- <itemizedlist>
+ <itemizedlist spacing="compact">
<listitem>
<para>
Fee
@@ -454,7 +454,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Second:
</para>
- <itemizedlist>
+ <itemizedlist spacing="compact">
<listitem>
<para>
Fee
@@ -521,7 +521,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
with a continuation
</para>
- <orderedlist numeration="lowerroman">
+ <orderedlist numeration="lowerroman" spacing="compact">
<listitem override="4">
<para>
sublist with roman numerals, starting with 4
@@ -531,7 +531,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
more items
</para>
- <orderedlist numeration="upperalpha">
+ <orderedlist numeration="upperalpha" spacing="compact">
<listitem>
<para>
a subsublist
@@ -550,22 +550,22 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Nesting:
</para>
- <orderedlist numeration="upperalpha">
+ <orderedlist numeration="upperalpha" spacing="compact">
<listitem>
<para>
Upper Alpha
</para>
- <orderedlist numeration="upperroman">
+ <orderedlist numeration="upperroman" spacing="compact">
<listitem>
<para>
Upper Roman.
</para>
- <orderedlist numeration="arabic">
+ <orderedlist numeration="arabic" spacing="compact">
<listitem override="6">
<para>
Decimal start with 6
</para>
- <orderedlist numeration="loweralpha">
+ <orderedlist numeration="loweralpha" spacing="compact">
<listitem override="3">
<para>
Lower alpha with paren
@@ -581,7 +581,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Autonumbering:
</para>
- <orderedlist>
+ <orderedlist spacing="compact">
<listitem>
<para>
Autonumber.
@@ -591,7 +591,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
More.
</para>
- <orderedlist>
+ <orderedlist spacing="compact">
<listitem>
<para>
Nested.
@@ -616,7 +616,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Tight using spaces:
</para>
- <variablelist>
+ <variablelist spacing="compact">
<varlistentry>
<term>
apple
@@ -651,7 +651,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Tight using tabs:
</para>
- <variablelist>
+ <variablelist spacing="compact">
<varlistentry>
<term>
apple
@@ -757,7 +757,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Multiple definitions, tight:
</para>
- <variablelist>
+ <variablelist spacing="compact">
<varlistentry>
<term>
apple
@@ -841,7 +841,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
orange fruit
</para>
- <orderedlist numeration="arabic">
+ <orderedlist numeration="arabic" spacing="compact">
<listitem>
<para>
sublist
@@ -862,22 +862,18 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Simple block on one line:
</para>
- <div>
- foo
- </div>
+ <para>
+ foo
+ </para>
<para>
And nested without indentation:
</para>
- <div>
- <div>
- <div>
- foo
- </div>
- </div>
- <div>
- bar
- </div>
- </div>
+ <para>
+ foo
+ </para>
+ <para>
+ bar
+ </para>
<para>
Interpreted markdown in a table:
</para>
@@ -896,10 +892,9 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Here’s a simple block:
</para>
- <div>
-
- foo
- </div>
+ <para>
+ foo
+ </para>
<para>
This should be a code block, though:
</para>
@@ -917,14 +912,9 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Now, nested:
</para>
- <div>
- <div>
- <div>
-
- foo
- </div>
- </div>
- </div>
+ <para>
+ foo
+ </para>
<para>
This should just be an HTML comment:
</para>
@@ -1061,7 +1051,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
</sect1>
<sect1 id="latex">
<title>LaTeX</title>
- <itemizedlist>
+ <itemizedlist spacing="compact">
<listitem>
<para>
</para>
@@ -1094,7 +1084,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<listitem>
<para>
Here’s some display math:
- $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$
+ $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
</para>
</listitem>
<listitem>
@@ -1107,7 +1097,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
These shouldn’t be math:
</para>
- <itemizedlist>
+ <itemizedlist spacing="compact">
<listitem>
<para>
To get the famous equation, write <literal>$e = mc^2$</literal>.
@@ -1140,7 +1130,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
<para>
Here is some unicode:
</para>
- <itemizedlist>
+ <itemizedlist spacing="compact">
<listitem>
<para>
I hat: Î
@@ -1326,7 +1316,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
With an ampersand:
<ulink url="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</ulink>
</para>
- <itemizedlist>
+ <itemizedlist spacing="compact">
<listitem>
<para>
In a list?
@@ -1424,7 +1414,7 @@ or here: &lt;http://example.com/&gt;
</footnote>
</para>
</blockquote>
- <orderedlist numeration="arabic">
+ <orderedlist numeration="arabic" spacing="compact">
<listitem>
<para>
And in list items.<footnote>
diff --git a/tests/writer.fb2 b/tests/writer.fb2
index 0bcbf1c2a..8106d2b91 100644
--- a/tests/writer.fb2
+++ b/tests/writer.fb2
@@ -1,2 +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><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><empty-line /><p><code>&lt;div&gt;</code></p><empty-line />foo<empty-line /><p><code>&lt;/div&gt;</code></p><empty-line /><p>And nested without indentation:</p><empty-line /><p><code>&lt;div&gt;</code></p><p><code>&lt;div&gt;</code></p><p><code>&lt;div&gt;</code></p><empty-line />foo<empty-line /><p><code>&lt;/div&gt;</code></p><p><code>&lt;/div&gt;</code></p><p><code>&lt;div&gt;</code></p><empty-line />bar<empty-line /><p><code>&lt;/div&gt;</code></p><p><code>&lt;/div&gt;</code></p><empty-line /><p>Interpreted markdown in a table:</p><empty-line /><p><code>&lt;table&gt;</code></p><p><code>&lt;tr&gt;</code></p><p><code>&lt;td&gt;</code></p><empty-line />This is <emphasis>emphasized</emphasis><empty-line /><p><code>&lt;/td&gt;</code></p><p><code>&lt;td&gt;</code></p><empty-line />And this is <strong>strong</strong><empty-line /><p><code>&lt;/td&gt;</code></p><p><code>&lt;/tr&gt;</code></p><p><code>&lt;/table&gt;</code></p><p><code></code></p><p><code>&lt;script type=&quot;text/javascript&quot;&gt;document.write(&#39;This *should not* be interpreted as markdown&#39;);&lt;/script&gt;</code></p><empty-line /><p>Here’s a simple block:</p><empty-line /><p><code>&lt;div&gt;</code></p><p><code> </code></p><empty-line />foo<empty-line /><p><code>&lt;/div&gt;</code></p><empty-line /><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><empty-line /><p><code>&lt;div&gt;</code></p><p><code> &lt;div&gt;</code></p><p><code> &lt;div&gt;</code></p><p><code> </code></p><empty-line />foo<empty-line /><p><code>&lt;/div&gt;</code></p><p><code> &lt;/div&gt;</code></p><p><code>&lt;/div&gt;</code></p><empty-line /><p>This should just be an HTML comment:</p><empty-line /><p><code>&lt;!-- Comment --&gt;</code></p><empty-line /><p>Multiline:</p><empty-line /><p><code>&lt;!--</code></p><p><code>Blah</code></p><p><code>Blah</code></p><p><code>--&gt;</code></p><p><code></code></p><p><code>&lt;!--</code></p><p><code> This is another comment.</code></p><p><code>--&gt;</code></p><empty-line /><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><empty-line /><p><code>&lt;!-- foo --&gt; </code></p><empty-line /><p>Code:</p><empty-line /><p><code>&lt;hr /&gt;</code></p><empty-line /><p>Hr’s:</p><empty-line /><p><code>&lt;hr&gt;</code></p><p><code></code></p><p><code>&lt;hr /&gt;</code></p><p><code></code></p><p><code>&lt;hr /&gt;</code></p><p><code></code></p><p><code>&lt;hr&gt; </code></p><p><code></code></p><p><code>&lt;hr /&gt; </code></p><p><code></code></p><p><code>&lt;hr /&gt; </code></p><p><code></code></p><p><code>&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;</code></p><p><code></code></p><p><code>&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;</code></p><p><code></code></p><p><code>&lt;hr class=&quot;foo&quot; id=&quot;bar&quot;&gt;</code></p><empty-line /><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><code>\begin{tabular}{|l|l|}\hline</code></p><p><code>Animal &amp; Number \\ \hline</code></p><p><code>Dog &amp; 2 \\</code></p><p><code>Cat &amp; 1 \\ \hline</code></p><p><code>\end{tabular}</code></p><empty-line /><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">/9j/4AAQSkZJRgABAQEAeAB4AAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAD6APoDAREAAhEBAxEB/8QAHAAAAAcBAQAAAAAAAAAAAAAAAQIDBAUGBwAI/8QAPhAAAgEDAwIEBAQFAgUFAAMAAQIDAAQRBRIhBjETIkFRB2FxgRQykaEjQlKxwRXwFjNictEIJEPh8SZTgv/EABcBAQEBAQAAAAAAAAAAAAAAAAABAgT/xAAbEQEBAQEAAwEAAAAAAAAAAAAAARECEiExQf/aAAwDAQACEQMRAD8A2t0YoQpwT2qVzMV+N3UHgrDY2eoM0y58VEbgfp9K1yMRmnuJ5h40jyYHGSeKrWE8u2QAApOMdqGCsmT8h70TAJwMAZx249aKBy4c9vTNUC0zDCgmmmG7Ockjkj1PrUTAjcy5XP0ouCgHae4IomOJHhgIc55PHY0Uk5IXLMcUBQ27n96JYO2MYLebHtRBA7BcMx29sdxQJqwZRtIP+BQKpjHHc+xzigNGoAO/k+nPAoAYlee5oBiGeWySO9AJCgY5PHagFCADzj2GaA2N2TkjA/U0HMwbPPeiyBLDfkkj04FCl1cBMgn6URwYFGySR6D2oAeQDAxnHGKAhU4IbGc+tFwnwDj9aK7f8v2oNu+IHxNvJdXmt9EmKWSqArA/mPvxUxMZNe3Ml1dvNcMzSSEsxPOferJhht/OWyAPc0UfdgDcuM8n50AMCykZFARsngcY/egTcbjnJz9O9AB2kZGSQOcUCX8x83bntQCMruJ4B7D1oCyOGzxtJ9M80CAdg5UjFE0aFJrghLeNpHY4IRdx/QUNWCw6D6q1EZttEvirHAZ4ig/U4qw1b9H+CHVN3Mq6hJaWMJ5ZjJ4hA/7R3P3q3ET+pf8Ap/lWNm03XkkkA8qTW+3PHupP9qxopV78G+s7VSV0+OcAn/kzqSfscVvIKzqPTWu6XKE1LSL+Bhz5oDg/cd6lEZzGwLrtPqrA8frUCJfcw9gfegUjZsEAffNADyHt78UAjCjzDJxRcO5Pw3gwCGOVJQp8ZncMGOeNoxwMY96GCbQffFFcUXKjDDt2NEo+N3yyM5z3okKuqJgIzONoJyuMGi4QfGcqSfXBoYHJx659qKIRnnsfUGgJn/poJYoTIGLY+eDzQFlQK2G/KCTmgbspfO0qce/agPGcR7nHf9vnQFfBPlOc88Gg7uucc/M0Bd208YJJweKAYrea4kKQICRGW5IUYUZJ570DYqcknt3FE0VuVyDzj1oamOlulda6puvC0a0eZVIWSbtGn1Y1NNbX0x8ENH0qL8X1NdtqDoNxiQbIh8u+WpqL70Tc6fcxypouiRadbW8hhLFFXcB7Edz+tNFvEZxkmmgShbA9PlUA+Hgg/wBqDgmBkd6ArJuJBGR7VdEdqWgaVqMfh6hp9pcLj/5Ig2KaKJrvwW6S1EFoLaWwmPIe2fAz81ORTRm3UfwI1mzBbRL+K/ReyS/w3x/b+1Wexmev9O6xoE2zWdOubUDszr5T9G7H9auCJj2n3PPrUXTlGBB2kYx96GlQMjJJHuRRXBgDgk8DtRKH8w4OfYA0SUlIMsFXJ4oujHH8ufnRRGOSNoJNAeFC77F2jPucfvQFEqgY3nj/AKaCUY58wwq54AoCzOmVMke9QeRnGR7ZoEIF7pnaTk49KDpSSwQntQJsGKjgggZ9uDQc4OOe1Am2UCkHOR7dqA8t/cSW8MEkrGGEsUTPCk4zj9KJT3pzQtS6m1aPT9Jh8SVxlmJwqL/UfYURuuhfArR7f8NLrF1cXciKDJCrbI2b7c4+9NGtaRptrpdqltYW0VtAn5Y41wBUodvGjqUdQyn0YZqAIreOBFSFFRF7BQAKA1xcRwKplcJuOBn1NAR7y2ikWMzoZnGVQHJNAuQcD3oBKkD2FBy8jnvQFxnjjmg4rxwKBMqCBtPNA3vbCC+tngvYo54HGGSRQQR9DV0Y91n8DNOvFkuOmZmsrk5PgSNuiY98D1X+1XRhWu6DqWgX72er2j2069t/ZvmD2IoGG7jbnj1FFlB224PB+VClN4DYJHyAojmPGCck8cetCAxgjPp6UaAGKtx6+9ATAXO7nFBw8HHLN+goJhBuj2FeAcnmgNazW8U0vjweODGyqpYrsYjytx3x3oGa5LEEjH9XvQGlgmjjMmQq4HBPfPYgevagG5nhe3tkFuInQHxJQTmQntn0wKBKTlAeDx60DSY+U9zn+mgsnQvROr9Y3W2xi8KxV8SXUnCrjvj1Y/IUR6c6A6H03o6wMVgrSXMoBmuX/NIf8Djt/eiLfjJwO9ZBiOfmKDhktzQAzYBLZ8oyaDF+rOptVv8AUjNZL4tjA/lT+kr3wvqTQX/pi3Y+DqFxKXurmFWAaPaVzg4I/b0oHlxqV7penRTXFu93dPLsESYB2k8n7CgnradLq1WaIOFI/K42sPkRQCg3Kcd6Dgp3d6AdrGg5VxnjmgKWB8uQGxnFAUgKuSefSghuqNC0jXbAWGtxQyJKdsYc4YMf6T6GtDzR8S/hnqfSUz3NvuvNILYSZR5o+ezj/Pb6UGfLzyD/AJoFFySQVBHpQDJ5kGByPahAbWxn5+po0OF3D+XPtQJsNwOe+aAuygmMkebgHnHFALHYpJwSeGz2oGpOJWAI49BQEZlYAHkg4oARVOMvtBIJJ7AUAX6xxSOsUgmjViFcKRuHviiVfvhT8NZuqpk1LVFeHRkPlHZpznsP+n50qPS+mWVppdnFa2cEcFtGu1I41ChR8qyHVxK8cLPDD4kgGVQHBNAa0maaBJGTYzDJXOcUCy5JOaA2OMfoaArkheM7vlQNYNOtoWLJCgLHJwo5NApPKLaNpGRQB6j2oGmnRvcyNd3O/DkeErLhkWgklIdCyZOCRzxzQEeRxhdpUnncBkD5UCxXjJ7+tAlctMsIMLohz5mcZAH09aBQYdQwyAeaAuA7MAQxHH0oG1481nbGVInuWU5Kr+bHrgepoKB1u+o6jqlvBH05NevEBPBK0pQR4I4BHZj+1Bb9IS7lsFtNWtYwDGFYB/EXHqpJ7/WtQYx8VfhGbdZtV6Uh8gy81mpyR6koPb5UGKY4YkeYd88fbFAI5AC98c5oQBb+U9+9GnN5RgDgjOPWgAN3yMfWgAqc91/UUD2RSSRg9+49KCR6e0WfX9WS0icRwgb55WOFijH5nP0FBYNRi6dSR7HRNPmu0hOW1GaXaZMdwBwAP3oynE0XRYrFtV02wS4ECj8dp1wcsE7eJEf39qlFZ616ZttPu7Kbp9Zbi0vYzNCcgjHqoHuKsEp8LPh7P1PqjXerxywaXaviRSu1pWH8g+XuflQemIIY7S3SK3hVIo12pGoAAA7AClEL1N1RH0/oTalcwx+IACLaSQKx59Ppmshv0D1jH1ZbTubU27xkkAnKsuSMg/UUFluLlLaJXETyecKAg554zigXiubeRnSKeJ5FOGVXBIPsaBLULoWkIfw3kYsAqIOSTQJMbpm3oqlmwACeF9yfn+1A+Bx34oE5IY5P+YFbnPIzQKAckHuRQCAQOO1AL8r9KDhkZOT9M8UCcrxgAyYJzwD70CT3Itxm8kgi3fly+P7/AOKA9pskhEkZysnOfeg6RH8w3tgjAHtQRZ1uystSg0m5eRJ2UbHceV8fP3oJkBSAVII9xQFdSRwKDDvjN8L/AMSJte6chxcgFrm1QcSf9aj39x61YMH8Q+CkfhqpQncxBDH5H6VRwXJ/Ke1Am2QchuMYOaNFSAVznB9qAm8f10D2RmX8jDHP3oLbebtA6ej0m2LrfX6LcX7IMskf8kf6HcffIoG8yTadZxSTxCK3kRZUwSFfkruIJ78GhiS6Y1OS3160uZJFWO5bwZtxzuQ8bcfPNMZXvo2wsLnQ9R0q/maJNNv5Yo3bjCuMAHPzqA2jdUan0lF0/ZXcElxp9zE+5WVd/DE71IPPB7H2po1bSNXsdYthLp1ykyEcj+ZT817ioITrnoux6vs1gv5JYnjz4ckZ/Ln5etA+6N0BemdBttMina4WEFfFdQpIJJ7D60E5I4Vo9qnnsQO1A3k0yzeTxhCizZJ3qNpz9RQO449igMSxHGW5NAIwBtUAUAMORkfegMhG3jtQD8+fvQGXJz7UAHuRQA5YDI5FB0qCQA5yaCs2/SFit/Jd3AmvJ2bO64ctt5zwD2oLMilVAUDgcAelAJLbhgZz3oGN9HPIYmhtrWRw2czjt7Y+dA+h3mJS67W9gc0AvuLYANADpkZABHY85oPOnxy+Hx06Z+odGjC2jt/7qBRwjH+cY9D6/OrKMebcceHwfaqCYIyDgZ96GhHOFJI4/WjQpXnsaCz9J6fDqGvRC8OLO3Vri5PB/hqMkfc4H3oDT3UupapcXrKS9zISgDdhnAGPbsKC5aLLBHq9p01c6bbagPE23kpJYhmz5IySAAMj6nNGdRnT2lu3V9vaQQrJDHfCMFj5kAfufsMUFogu5H0jrLUYXK+Lq0aRse/lf/8AOKlFfudagvbnQpNQRmtILydCwPdCQcgMOMZFQanPoeiawBd9M6s9jeKPK1vKQp+RFA4septa6fuFtuqbRrmzx5b+BAdo927A+vsflQXfTr2z1O3W5025juIW/mjOR9KAZI914khaRNo4XdwT9KAl3b2+oWpjMoZWbOVfnI9sUCrXUNssUU8w3sQoJH5jQLvwQQC3NAKvuUPtK54waDg23v6UA7weBnNAIOBigMr+hoOjdZQdhBx3waAVG0Z7UBWfAOQSflQChyNxBAxQRutarb6bHALi9trSW4kEcJnGd7ewFA/j8QEK/IA/MBjmgWDDBB7igj9dupLTTbiaHZ4oQ7A7bQW9ATVgwXSNV6onl8azW6t45pWdxHIxWA/zNtz7A8Glg2S1u7fX+nt0J/H2c4MMhmQoW9GBUjj60g8sfEHpebpDqi4sHLG2Y77eQ486E8fcdvtVFekGW4UfegKVAAKgnFGhuDzxQXbpDTZF6a13UnUqrCOzQ5wGZmXIJ+lE0ppkEK6nJcRWcTW9hA08iKcjcowpye/mxQ0+6VRbC/jvLm48L8LG9y8pIOXxkDnuSTipqHXQMng3es9S3fhn8DbvcZI5Mr/lH700dc3Dad8NtPs4nU6jeXD6nMCwBRF5XOfU8YHrTNJFF1X8RawW1jc4GxTKNrZB385yPkBTFw1stSu7Ni9tPLGSQfK5Aphi8J8UNUm6fn0u72yvJ5fGbuF/39aYYtGgadp9/axXnRetzaXqnhqZI3bEcj4547Ak/X6UxFisPiXe6NMdO65057eQAr+LhUlHHbOPX07UwWXpQ6BqMo1LpgW0sioVI8Qgxk+684qC028M5890Y3kHKbUwF+lA4LDOzu2M4FAOG3DaoI9cntQdJxzQEyR259f/AKoGl5fSQRFo7ZpB/MhYIR9zxQdayyXKb7gqox5Yo2yB9WHc0DPUIWnhWKxkuYFRs5gcKWbPY59KBkx6isVeSGW31JNwHhyOUkA+o8v9qCfjkMo/LJFKqBmRvSgc2swnRyFcYODuXGfpQMtRsLK8vYJL+wjuGiUtHK6hghz6Z7H6UEmCsig84I9RigiruC9t0DaaVmIIHhTOQMeuGwT9qCJ1ywv9T0U29xFFiaVBJGHz5M5ODgYPY/arKJPTtLW1t44i7SKq48w8x+ZPrTRJoipGFQAAdgKgzX47dMJrXSrXkUe6807MykDkp/MP8/aro80FQyZ+tUJ7hvH0x270XQ7KGtXvIk0T4c9P2bIhkvpnvJVfjIxhf7qftRDXpu0/1DpzXltUlkvmWMBI+2zdnn64oYa6yX0XTm0i4jQ3t6wmuV53xov5UPpyeeKyLbpFtZ6Xpmn6TqNq7/ic6pqQRR/DVf8Alq2fTOP0FXBnXU+ox32o3lzeW+JrxlMXHKR9wfbJ/tVWK5f3AnaAjafCTwwcY4BOM/qKKSjA4Dg8j37UHZKkE5P0olSFlcLDdJPbTNBOigjxOVZu3+80Rbbnrq9l0t9I6isRd2rgKpPlZMdyre9An07oupoh1zo2+lea2fMlr+WZFx7ZwwqWDVug/ihDq7R6b1EPwmpMNokPlVj8xng1BqEUe1EAJOMDOc5oDSxq6YYeuaAJF4oCBUQ7mJ45zQHYB14wR86AVjBXyjge1AEcRTHlA9hQE8kbgEohJ5yQM0ETHNqMOr3IZQ9tIMQyEjKt7D3FBLqywRPJKTuxlj3zQI3Ut14e+yhWRj28Q7RjH60EfpF3rU/jLqFrHbS4/hqpJXH19aCRa8jgiVr1xGwXzYyf99qA9tc29/aRXFnKs1vINyOO2KByoxwe9AYocHGKBvdwLcWzxSLuR1KuD6gjBoPHXWujt071Nf6YSSkUnkJ4yp5H7f2rQgWAA3Y+1An4j/1t+tBrHxKuYS+gx24LRx6ZFtI/lz60FY0+/v8ASphNpd68EpXY5AGNvzFF1YOirZbzVrvX9dkNxZWH8eeaY5Lyj8qj7kcVlETqOqXd/HrPUNzcNE16Tbwxf1JkEgD2AA/etBte9R2Oq2cv+p6XHJfBFjgmjkMaRgAAEqO5o1FWfbgjsR8+9AlI5CgEggeoNAq0iug8uD7g80KKmCcZ7fPmjJzJfT/hWtjJvhOPK/OOe49u9A96X1W90/VrRtNkkSfxQF8I5yScdvX6UGidSLpfVFzcvbRiy6kgZBGysFW7B9T7HHNSjU+o9S1iz0e2uNLmX8RYxJ+KgYeVwVGTn5d6gjug/iU3UOt/6TewQpP59skL5B29x/8AYoNHPB78Ggb2l3bXO78PKsoyVyvIBHBFAoSkbfyhn4GfWgTnmWFN7ybAvc4Jz9hQRdx1dp0S3Dw+JJHbDdPIUZUjX3yRz9Bmrgzbqb4x9Oxho4bB751O5HPkXPsc80wQHT/xrJ1IHUbGKO0kdRiBiAgz+YjnsPpTKN/tLy3vLOK5t5klt5F3LKhyCPemAYLuK5XMDEj1OCP71ArGWLMPT0oIbU7h11u2t49OllWWNm/FIRsjI4AI/egfQ2ktpbww2XgxoDl9wJ49cUCHUGv2GixM13Mkcm0squwUH5/SrgxDW/jFcXOteHb3otrKEEiRISRM3zGc49v1qDT+gfiBpvV7y2unxTxywRhz4ozuHbOR2+9Bmf8A6kNIEWpaZqiooEqtBIR6kHI/atfRjDEt3AKjgVQjug9j+lQWh72e/htTOzyeCnhHPomeMYoJvQum7vVD47K9jpsQBkvZ5NoAHcgUAa7rKamE0Lp9Xh0G1OZZTwZSO8jn9cCsivdS38F9cJDZIY7G2URxKe5x/MT7nNaEKrENwAFPPlosFwS2cd/cc0UlIm3JOeKDo2LH+UA0SjgDk98URzPiJ2449e/NAbS7v8PdpKkpikQ5WQLkqccGgmYNQmXWLeQLG9wVRQVPlcj+Yn3xQa98OviAjz3WjdXSpFdliEuJCNjDtsJ7enepRdel+kdL0rqOTVdIsoYklV1dixO3nunpg9jUCnU3WMeka5b2EUcl3JInmigQs6ZPlJAHY8+vpQP9O1m3nthNo0cTwM2JDwoVj6H5gd6CbhtUiVn8TcXO4ktkZ+We1BAf8Z6fZ2uqXWpyxQrbStGseQzMB2IA961B59+IHXmodXal+HsPFh04HbHCo25+bY/zQWv4f/CCxvII73qC8iuXYb1tYZeF9txHf6U3BatX+DvSl86x6cr2dwjbnEUmcj6Enj6U8hLdJdEX/SmowJp2tTT6Oc+La3HO0442+3NBf1LmRUjjQAfmc+nyHvWQockYyQcY3CgaabaPZxGNnaUFi3mPb6f+KA2q3RstNurnBxDE0mPfCk1YPMemaP1L8RtYN9fJPc2aMUaVmCKg54H0z6VRYendf6Z6T1W56a6j6fgfwJyguhGJmPzbIzjHtSjTn0zSunbi01fSkt9Os5GAmWNCDOGxtXb6HnNZEZ8etOF90DPKFy1rKk3zAzg/3rXI8u7zvOTg4zVoTLDJ81QWDTb2SwuvFgcrkbXwM5H0PFGqsjpd6+kcT61Nc2ieb8OikFc/9PA+WfSjKA1nWBzpFlZ/hLWM4KH8zsPVj6mghN4IyQRk5NGo5BkFmyAfSgVjChdpGO/FAXYpOHLBe/FAQqoBJbA9sUBGxgtgEj/eaCf6DGjt1TZf8RNGumKS7mQZQkDIB+WaMrf8Ub/ovV7V20JIYL62K4khhCLOCcEcAdu9BmCuEQvxvyFUg42+v+/rQaj0zax/EXRY9Nns0t9TtM+BqCKAjEclXA98jn+1Si7Cz6u6O0tLjTrxLu2tQJJrDwcKE/m2M2SfeoLrpupDV9Mh1OytUS2vIN8m4BZQf6T7+vPpj50GfdK9L6rJqk1y1y0elRDKRqdjHHoyDhjx39e9BZr7fagW0j3kul3iETRqHkeF8ZBUjkZIxjtk5rQ86dW6r+O1OcW0UtvaRsY4oWfLKBxz7k/5NA46P6X1rqS6WPS7V9v88rAqi/f3oN46X6C1DSotkus+BIwKl8hn2+3PapROXPT2t20bPY6kJ5UGYmbIfIHGW5z68VBI6DrzzWSrrAjtrwFUbDja5OBlfuaCbluJLeNwIpLiVF3bVXAP0Pv8qBxLO8cYcW7vnuqkAigNFKs8CyxlwG/lcYI+1A31ayF/pt1auSFmiaM/LIxVgwfoO413o3qqfSLyUSwodogAyZVGcbPTPr71aNDvendJ6wtbu7Fi1lezK0bS4VZMjtnFZE0bC5u9Jh0qRAr2yw4uWx59vBI44PegN1tpbap0lqOk2sipLPB4aFsnHbBNOR5A1exFhqFxbeKkngyMhdOxIPcVuhiZFz/zBUEwcKvYnP6fWi0+6chjn6h062uATFLcRrIMnzAsO9EehNR+GvTV3GUh0+O2YsGaWHIf9amjIfib0no3S0VtFY3M000zMzLJtLKvvkenyx96oz0rwNjA8cj2osFLbVAbOc9jRQiXOAwxnj3oBlAxwDj37UDY+vHOQeTQBIdqjcPMfnQwJclWyBgCjJBFeefw4VaVycBUGST2wAKD0L8H9C1rSIILjWLSCytY1lZASVnlL4PI/wD8+vvUo1uwbxI5GkjdVc7isvOBjtj2qBWKFZiQ8CJCB5FHYj5jHFArDbQ20ey3RY1HOAOPsKCH1u61CPSLt9MtlXUHUrbCbJBbPdtvYetXR5T1y2udD6lni1ErJdJLvlK4wWOCePvVgsV/8Sr67UW1vA0NiowIonMe4+7FeT9ARQRmodWa9EYpPBhs1Tygw26rk9xknkn70EjonxZ17TXjAeKTkZ3L+YZ7N8vpSjX+lOpNM6umgkMG3EgBV1DYbG4kewz2NZGkC43CP8MPFBONysMAD50DaHVH8S6N1a+BaxMUjd280pA5wPb296DrXWLK9WNoJdtwybxDKPDcAnHIoJBifTBzzmgaz2UFzPFNNbwvLCcxuyglT7igdRRKg8qAZ5JAAzQEnuYoHiSWQIZW2ID/ADH2H6UERr12BY6hueIQJaO7SK/nHfnHtx3pyPGWoN4jynuCfU963RF+DL/UtQWTkjaWY/8ATnHFGql+j1VerdJY8r+KiJz/ANwoy9C/EjqSbpbRY723RJC8ojIcZ4IJ/wAVkecer9en1+9FzeLCCq4URjgDP7mtLhteadBY2kMczyHUpcO0YxtiUjgH/q9celAiLy1kjCX1ruyMLNGdrj0+h+lE0+t+kNQltJ7yKS3jgiTxUFw/hySp7qp70NV6YEBgWUNjBoaKeAODnHrRoVgDnBP0ozpxZ2f4y5trVeGuJFiBPpk4zQep9C0LTembS30fQbWP8ZsDyTugZgf6ix9fYZpbgmbXSmXULaa6kMzpltzcjJ//AGpaLCY1CDsF74PrUCgHY0HbSx7Z96BGUfxB2xjtQZ11t0Tb6jNfyw2wM18gV5AcBdpzyPnV0Yp1F0o/TEczXjXaTOQYpIk3QlT3B9Rj0zVl0VKbVppImheUSwbsgFfXHc0De0tri/ujFYQSSyfmKopPHqaDV/g9p+padr/gkSRTzKu0kZRlPLYPbOPf2pg9GWzRCMJAFxH5do4wayKX1z/G0CdzqLWRkiaTxQBLudclQvovbv3oMU/4Z67uwnUAt3u1Zw42yhmx3/Ln8v0oN86L1d00i3i1UiGQIocNnEbnkqT2xgiguEbI4DIysp7EHNAZnxQQ/Usksej3EsCl5EUthR5sY52/Mjigr6Qrp3R15LqEcIlmgdpFGAsY2navPJApyPJtwd8rnGBuJz6Gt0MzGSTyf0qCwSKA5ZsAjnn2otTXQYj/AOMNIDqCrXUZwf8AuGDRG6fF6Gyfo6+ub0CR4EPgIScLIeAcfc1keatN0661a+S3sYTPKzAbV9B7/StLrQ/iXp9pYLp8elWsUM11AzXMqt53I7g7j244oiB6W6Tn6j2TeAy2FspTeB+Z+/8AmgtnWlvpdl1Dp1pq07Ja20GFQpuDHHAwPf39KDHriVTKSPOCeBnHHtQGsrG5v5pfwcTOIlMjgEeVfck0XRIreS7uUigRpJXOEVe5PtRE/wBJ9HaxqvUcdhNFJp0lviaSWVcMgzxgdySeBipo9T6O8NppUJ1K4iW5KgSvIyqxb5jPH0paJm1NvKivE6Mp7MpyP1FQLRTwy58F0cjuAckfagOTtO3+Y8igMWCIWbOPlzQNhNBOWEbq5Q+YKc4+tAD7JEZgQfXj0oI/VtIttXsZLW5hRopByCP/ADVlGRa78Erae63aXK1tG3LAncM/Kmh10l8IZdBv4rxtTE0yggJsyoz6/P0po0zSNKEMdo9xGnjxuzkqMAEgjj7GmialjWQMgyCRyQcGoITqHT7q/a30+G2jFmwLSzl8GPBGFA9c5NBPRwJDbpHCipEi4CjtigqfWltqCaG8WhNbxyzOBIs8W8FcY4+dWQQ/wtuZdIGqadrknhy2u2QyOSEZOeRngY+XvTBZZevOmhC8janbqiZ53Zzj2FMFcs+sh1ZqsFrp8UkGkrlpbh+DNzhVX5Z5NQTfXyWUXSV2t+wW3EZ5I4HHt61eYPI0mA5C9snFaoLsPv8AvUEk5JcA8cZG480WnOlXX4PVLO4yQ0cyP244Yf8AiiPUfUump1B0/c2O8xfi4v8AmL3UcGpgw/SujNX0Trj8PpckimOMvHO/kEg9Rjs3PpV0aFq/Qqa1ZJ/qcrverEqNOwGM+uMfemiVtrKbQdMNjp9rvtkhPht6mU5yT8u1BkvXg1qXUtOvddgRY1R3j2YHiMvZSD27CgzSCyuNQ1KK0giL3Mz4VAOc/wDignoNNOnaHeiW8hgkku/Al2+Ziqgn09M0ETp0qpqSmGKOdFcEeLwMfPHag3JLuCRtPmQWsDhNphtVAcn1w3BPFSwDdWGpX1/OYdOtbbSrlQ80szHdn0GR24/c1AbWemdatLbTJdGvJIJypDQwMV3exwOPatSz9Ei/R+txy2mr3evyHV4miWIDhGwwyGA7nGRS2YNZAUBWYDdjGayEvxMYB3nYu4KCfU+woG93c2enWs1xcPFDCp8zEgDPzq4GGgz22saS1zZSZhkdsFePXt86YHWmySeLNDMYikZ4YNlvvUD+VARxQJqgwRQHUAAe2O1AWOFRM8mDlgB37fagb6reXFt4ItLZJnZsuWfaI0Hdjwcn2FAz0nWX1i4u4xY3VpFbv4eZ1x4vGdy/KgkriN2aMRlQoOW3DOR/5qwYr1P1tp2pdS3WnanKkGh24kRl2eaYgcb/AFxnnAqiv9Jno0dRLJPbtdQtkNPIALaMnODsPPpSjbdK0DTbWQXui+Gsco3BU5hPP5gPT7VkU74t6PZHpq/1N5ZZbwrtRnmOwDPOFJwPsK1xR5ybudw788VaC5X2WoJRULSBpAe5PA/aiinAZnHck4A70THq/Qr23/4Y0u4lmCpLBGA7epxjH60Du+WGOBvFlFuWOFcYyCfbPrUojri6k06xX8PFNfBUJ3ltzM3scVBjfVvVXVNit5dapNDZGQGK3shjeAe7YHIwAOT3zVggNTiu+orrR4p7m+upJFR7h3TPhggDaoBwRjnPH5hV0af0xotnoD3l5dWdrY2YjGLhwPEHoef996CC6m0HpuPpk3Wny2s9sJPHJ3AeI2D39T37UGU9QTDULuGPSLPwIyoVIYk2lj6/X70G2/DPp0hVudRuBLcwxhRGkeEjB9M+p96DSLprVHiieaAE+YxHkke4H1qUOIBawL4uAuc8nvj71AwjRtQ1eO78QNp9odyLju/qT8uf70Gb6r8SpLzryy0vp+4NxYSSCEswI2u2Rn3OOD9qC4dVamen9NlaC7tUaIFvCmnHiy4HJXJxnOeDVwed+rOvLnqSyWO4jZSru/kc7ck+30GKosXw2+KmqaDJDY3jR3OmqNoRhtZAP6SP7Ggtmt63qbTJ1XLazJpslwBFblypEOAA7L2OWANS+xrnR2vW3UmjJeWp8wJSRf6WHeoJdSPMCRmgMq8DmgBpNsgUIxBGSccD70DczmS8MDWoe28MN4+f588rj980CktuJZYpFdlKZ4B4OfegQ1hpIrVjbsRMBhBj8x9qsHnX/hm36y1O/u9V1ddPmS6aD8OkQdyxOSe4OMmqLUvwQsYY4Xjv7m4YEEhwFyMY7fXB5pRbvhp0jqfSMV7b6jqZvLGQAwxAEBDk54PuD6VkVb49a5DBpiaNaeF/FIaQDumOwpzMGDEZQZ5+VboR8In1I+9QWDY6gFn7jjHpQhtJEFbAGBnijT0P8H7qPVOh47a42yNaymPBOcDupoykep+m73V7g/8Av2itQowvJIx6j5/OpRjfUWrax051RPY6LqFy8YACkebO4Z7HjNWCY0ToW2utJbqPreW5na4O4R78cehY9+fQVKLX05p1ro97awC4kX8VFmJLeEKdoyfOxJPbHbHYVAz0rqKPWNauri9t1ktJgILYgEiNFJ/Op9STmrBBdeaFCo0y3jt444DI3jLE204Y5DD+9UPPhv0NaRtPq99mSLOy22nOfdh75oNC0vT7m1uJGvGiii3AW8UDbQAeDu9zUohLlhouqap1VciF4I1FtbxSthtobBIPuTn7VBJ2vUth1TYk2ULi9iALwyKQYz6Z9CM0Ft060/DWEcDHe2Mucdye9BFW3SekWt3LPb2cUTsd2UGCG9x7VYMzufhzdX/WmoXj+BPpx3I7XZMmXYckc8EVRKaP8I+nXikLQuxOQSTnBzj6UEjonw90XSrq3S3s7dplJcl1EhGDx396lFx1TQ4NVjaC7UNCU2lAO/8AvNWDCLp9X+E/WgWImXSp2LRq7eSRT3B9iP8AFSjd9P1+21TRodVsMS2rLmTbyUGOePXFQSltcLcW0c1vh4mXcjDswoDLdRm4FvISsgXeTghDzjAPbPyzmgVFxCzuiOC0WN3sM+5oDqySJmNg3rx7UFb60tNUubGJdFdEvhIdryflUFSM49TVgyTQenJemOorf/U4H1Fpp1edAh/hOQTuQ9375JA4q0bnbPBcxxT20wkjKkqYzlT9ayGWu38um2MbLEJ7iRtoUds+/wAgBzQeW/iHqi6j1PdzeL44HkL9txHtWhVUOVyvHNB2F9zQT8hUAhAdp5FCG0mSAzE4HGDRppvwL1bwOpJbEsFiuYyVX3deR98Zoy2ZtRgmjkSRZocEp51K7se3vUow/rfpFE124mVpfD4mk2MWdCc4A+VWCH1281/UmFnpklzPYRFBEG8uGC4yQfcn9alGgaJo95rRsbi53WaxwrHOm7BjYcHnvz/moJaw07pXSI5IW1K0CQnDhpAWB9R796CudY62msTRW+gadI8KnDXMkLLv9MA8HGOKC3dAXF1dRfh75f41moi4G0AdwcfTj7UFhv7RjqMBV5AJFZHkR8FRjIx6CgpXVNjJ1JqNn07p26CztSJLlpIydyj2J+fGaC+afplrazqLa3SKNIggx3IHYUEsBk4wQc4oK11L1z070/M9rql6wuVA3QopLcjNBDwfFboqeSO2W7kQNxuaEhQfnQLt8TuireVoV1UeXnckTFT9DigHRuv+mbu9ZV1W3Nyc4IRlVl9O47/KgtU+s6baw+JcX1umRkAuM/p3oK/1t0rYdX6cqXKESqN8Ug/Mp9P1qwZ702mo9GdUTWJsmOn3EY8CAORGXJAwScjJ5q0bJDNLb6YklxbKsgA3wwndg9sDtWQN3aw3ZKTwLLEQOGORn6ehoG1vYAw3FikRt7JSuH3Hc/GSc5P0oHn4aO2uGuYyiose044wBQIm6F1dwfh5ARs8R8L2BHGfnQHv9PS4PjxrGLtFKxysm4qD3oCxboIIo7e1jhQHzAYUJ8wP8VYM56j1ktaal1BMrS2sAaK1OQDD6eUepY9yfQVR5zv7hrmaSaRtzyHJY0DcE4BPIPb5UBwOO4oJYzFvzEYHAH9XvQhNZN7AEgDOSDRo/wBA1SXRdVtNQgb/AJUgfBHcZ/8AGaGPVlhPbarZ2t5CEeORBKje2RUrI1zYxTBhMinIwcjvUEcugWkO4AMisMEA8N69u3yoERrOhWNxNYy6hapcxAeJHM+D8u9ASLStLlm/EWdpZyxy+Z3RQ3I5B44oJKTT4blFWSNBEOeBg5+goFYbOK1TKhIxnIbGMH50Cpcyo6AMrIcM2OD68Ggb6Lbbllu5Cd88hYBu6rztWglSNkfm4P70Gaat8Rba96w0vp3R2mhufxyi4kO3YyDOV9+f8VYMw+P0cP8Ax4JVuEKzW8bEr5tuMj0+lUZ7Y2X4288GK+towRlZXYqv9uKCQi6YmbT2u11GzaJWKnYxbBB49KCFnhubdiwL+U8OhP60ElpXUFxY6nDdXQF0qYbZKxwT9vWg3npb42aHcmC11C3uLSQjEkpIdQfr3xUondP6x6e6tv7e101hczRzrNtaFiFC/wAxPYHtUF+lj8bYCTgMG59cUC4OBQQOo2eoXepFTeL/AKYQN1sEwWx6Fu+DQLX2kw3Ok3Vjas9qJ48Exd1PHb9KCE6R0G86Ut7mK71KK4gklM7TyKRIBjtjtjj96AOreudJsrMJbXksk8jBCbVdzRjONxBHP/3QQ9x1jcWGkERWWqXdpMPCt7x4wfFOOWPbA+fAqwZr8TJ9Qbp2ymvEjsrSTEVvawyHz45Lv6E4wPqaoyl8g91OKDlYEc8mgKW5PH7UE80f8PPHl7gDFAZkUjawUIQG8w5ouknAUbl9Dg59KK1X4Z9XXFvo8mlRXax3KHfBG8Rk3qe6jHOc54+dMZO7jr/qK8vWtba4tYu38TwvDOMc8N60wPLbrW10PS7pnvrnUtbAKobgBUUk9jg8f/lMC2rydMdRSaRqWoLEbx4UefwxkL2BVvvn9Klgv3Tp0lPxFno6wJ4IVmEOMEHsf2xUD2e4ks7n+NGDaCMu8q8lCMcEfPNA6tW/EwrMybEYZUHnI9Cf/FAzu7G4LXTWs38SRNqhs4Bz3z9KCO6x07UNT6altNMvEs7xkC7nPlI9R2/egwbrDT+r+kupLCeK9nu3KBYGRy+QvdWFWCU6avtA6h1iKDqLRhpmpvkxz2p8JGb3z7k557VRX77TdHteuPBut401CAouyXGcdvmASaC069030brYaay/CwPFwWspRErfUN7UGZX2hWSiY6ZrMc0CvhUlBUk/UcGgiLq2mtG8F54yDwfDfIoGkrRsSZXwOB2zmgsvw06XHVfUcFvI22xQ753Ze4H8v3OBUo9a6XodjpltHbabDHZIhVsQqBuA9DxznFQTQUe5oDYGMnn7UEbpV3JqDyz+BJFbBtsXiDBf/qx6CgDXL42cSRwGM3UzBQrHGFzy32oG2i2kKTSI80lzMow0rqQoyew+3tQO59KtJJRI9rEzgg7igz3z/egZ6paJdGGwW4eBXy7pGeXUdwT6A5qwebPjJrcOr9TvbWZQ2Onr+Gi2nIJHcj7+vyqigOuRk+vtxQAqEk4BU0ABj7j96CzzKxYD0GeM0CQG3OMAjkfOgbSZwzE4PJyfWi6caTdzaffW95akrPFIrLg/tRHpGzs9C6t0W31FrO3Y43MrcbH9c/eloZ6v0JpWoKlrHHBbScSFEHYc5Pz71NDXUoJrK1g0dvw9qsspW3nXaN6KMrHnH5ieSfan0U3Rr1uidaRbiwk8BUSS6naQkjc3ZcHaRnn70wbja6lZX+nw3NvMksM+FXnPJ9DUCeoXj2hSG2t2km7op4U/f/FAvHaNePb3N0jRzRA7VD8Akc9u/FAvcxnawZQ3HYtjJoKfDFAdeub6Vo1dSULIBtTbgYOfU8jNWUVvrm5ih0m1urixhlsI5HJliOwR5/LkkHHJPamjHdQ0HWdemlutN0+YWBYtC0rHDhjwVz3zWgx1n4e9U6QE8XT5Zd//APR5se9XBXbjS9S0zAvbO5tyWKAOhG4/KpQ3ZHXO5JFK98qRUGhfCbph77Uvx91pv463wVjR0LR7s483796WjW7rTrXpHWrSW2YK7lmXTbaIFpCRjjHOOSeeBipaNLtXuIre3R43lnkGXYADZnnmoH6Dkbzn6UDGWe9a/hKG3jsW8riQMJS3svp86B6zgMQmDtGT8qDNb6XUpOoPx72tzOkjFYowOduDwDjj70Gg6Wsq2KNeAJKRuKk52fIn5DvVkENrvW+iaSAsl0txI2Asdud5Yk4A4pgzv4l9ST6JZSXbyyprWpw+FFa5G21gz5icfzH3pgwCSQlh688+tUEwjjngZ7UHAHuWAHpn+1AXj5frQWXOGBZcKSe3c/rQIyAtnI27eBj/ADQIMAuH8vHBB9DQwVpPLjOckEZ/ahi9/Czqj/S9VhtLm6aG1uZFUsT5VOfX5Gpg9GiNJArxsrxsv1BHypYGF7pljeG3kvLZSlqzNGGxhSRjP6GoG1yLUWiWc2nSPA4KJGItyYHYHHarop3wu0jWYNUvzriNBp8ErraRMANxJ/N7nA7ZqDUHgSQLvAbacjI7H3oOuIFuYzGS68jJRyp4+lA0m0yDwGjiTw3bzBwTuDe+TQVbV+mLmW1NtbSok9weZiC2zPLEZ+/FBM6Xo40/TYdL8Jr21G4vJcuCck55HbFWUKQ/h4tR/DTz2o8TK21qmMgKOf8AfpmrokljG1i5BHI57D5VNorut9Lab1LA638W6H8sboNrqQckq3pntV0RWsfD6K7SGC3vTFahQJY2iVmkI9d+Mimie0Hp2DQ7AQacio3JZgqjcT3zxk1KHGldPWtnqMupS5uNTmGGnk5KjGNqf0r8qgmkhVGcquGblm96BDUZZYLGVrdN8+MIvux7UGKTdXdbaRrFvbaxbWN4d58BmwCjHPORycLx2q4LNe9S9TdN6I13qkWmzSXdwBCGlO4hiMKAB2A9ag0WySQwpLLtMjDcQBhVz6CgoHxF17XbnUYunulgsUsu4TTvjIUAEhR+x4qwZwtkOi7651PXJobm4tohHbQhdgecjnaPZeOfeqMy1vWLvWNQlvb+ZpJpWyT2A9gB6Cgjy5AO4A5oAGRgBR39aA7Z8MkFtxPY0AbV9UGfpQWhj5TkBQGxuBoEGG1iQCyHvj1oELgSkK6oRnIBIxzRdJ28Q3+fHiAds96LoH3AF1wCfyijNbF8JviI1rbQ6Pq/iSopxFOx5Uf0n3qUbWQk8II2SRyDPuCDUHMpSIiJQSBwDwKAgTxApnEbyIQ+APyn0+9A5B3AgfmoEWgcb3VlMpGFYjt+negSs7zxH/C3RWO9UElM8SAHG5fl/agNdXcEbJAZ1WadvDQDJO7Gf7c0ED1dqWv2enzw6Rb24nZfJd3EwREHqxyMZHzOKBbT7H8PZWTK5uZ9o3Xm1SzEry5PsT7UFF+JnUezSZ9LttRs2km2m5KSFWXDZI491AyBzVwK6J8T7CRtPjee0tbaGAtdNISdoXgLEo5JJxyfSmC6aF1fo2vELZXDJOxwkMybHYe4HtUFiJWJd8rKqjuTQcZV8SNI0dy43BlGVA+ZoBniE0RU7tp77Tg5zQUv4hNrU2tdNWOhylPEnaS5UHGYlAzn5cn74oHGt6l0z07k6nJC123HhKPFlbPptGTj9q0Kx0XMvU+ty6vqQtpWlZo4LOdGDWsak8Aflycgk+v2qC8a1q8OnaXLPOz2kCIWkZ+CqjgYx6n0xTBkmp9Sabp0KdRyI5vJkaGw08MVKIDw8jA557896QY1q2o3eqXr3N7O8skjnlnzgn5e1UMCGV/MOM0BJFOVwfX0oFtgZTjkg8UBtpOeO1B3hg85FBZXVMM+VJAA2+h96BO4IMJ/p7qvuKBKacmOKB5CYYx5UzgDPfHzoGwD5OApJHAHrQEAk8NWdNpx+XdkA0AIGhkGWOQcgg8UGw/DP4kmwhi07WCTZqAiSbstGc4+pFKNvs5o7q2Sa3kWaJxkOp4NZDOHUh/qL2k8LW78eG7kbZv+0+/yoEZp7fUpX/BXpgvYZTCSRtO7vtwe/vQdY6jeyatPp91FEPw8aSNMoYbi2cADt6Z70DS60KW7luJdV1JniJzBtURG2b0KN7+/vQKSWUWnLLqN3cSLP4ex5Y8jxiPykr23+nzzigpXUPVOu6Vqmmf8UWttb9OXDqkjRnfI3H849uRkDOKC0axLFr+nLB0rrUMM0bqCIGGGX1AH09qsGc9UfBiTV9Vhu9Pu5oPGLNeG6bczN7jHvVEr058Gre3sLeDVrmOdo3LmSFNjEH+XdntQXO51XQOl5YrCKGWa8SMYS3tzMyLjjJHb9alDqz1S5ktJ7nVdLmSVDiOONfEMiE4Xy+h9xUDm11CaTxEOn3VmpHFxKFCr9s5GPmKAus6jb9M6RJf3c88yxpjcxL7uM5OO3HrQVTSupoOuYdZMTSpptriNFtXKXDA/Pjhs9h2xQOJ7Xpnpa2S91WK2swqjbGw3ysfcnuxrQsGmapYvpwvra1FtDL52Mi+Gx49sZoMb+LXV0t+jWl3OYLGTO2zjx4h2nyszHsG4/Sgxt5ZJmEsjl3PB3GgSlyXBxkDnNADseB2PsaA8SoXQyFgmQCV70B5R/EIjYmPJxnvigEKcYDfrQF2/X9aCwqC7l2zwfT/FAJJ5747E5oGTqZArKOfccftQHZWwmOD23Z4NAEkTEBmwR7g5AoG7KSSE5HyFAMTyQsMHa/cEcEc5oL58P+v7rppdryPNAXx+GfsQe7Z9D2/Wg3zSdX0fqzT08F433eYwscOpHt9PcVkQPW632mX9vfWdrbXiRgrIdu2eHIwGD57+nIoKdc/ELVdC0u5afp27SUtta5vJMMzk+UDjzYHtQWDpj4gxXmif/wAitXZkGZzFGW8MehZO+PmM0Fibr/poWQmF6xXA2xmFg59sKRk0C2nQP1KFvdb0vwIUJNtDKcsVP8zD0Jx2oJDTNA0vR5p7qzs44pJOXkUc/SgNfa/pNvbF5L2JgTsCo2WJzjGKA1jcNcxOF/m/I0zbt4+gxgenNA5s7CCxWWYQxpNLgyMiY3nt2oHajcuexAoEL1C1uyFkVHO1ixHb17/KgwT4rdXWep6oul2OpywaTYqVLxDyySDjaM9x6Z+tWDPdB1TW7Wa9sumpGlursqMQRlpXwd3BA4571RcdN0i41G7h/wBSmNxqdkwn1O6u5/4cAXlYgcnngE/pQNvih8S211obHRyYbWInfJG/Ex9MD2+tBmNzcTXTtJcSSSSHH5jngDAH0oEdxbg5A9wKAzPwO+fegSLfLJoFoR5fUfegXOcHGAT8qAM+XaBzQCCwGDuyPlQWJpV37Q5TIweM7u/f9qA9vNYpFML2KaR8YiaJgAh55PvQRvnYoqA+MThcDnPai4PKWQlH3K6tggjnPaiEmz4ZznBPfFAVWG0AZDH1z2HzoE7lhv8AJIHI/mGRQI8AEeuOMGgndN6pu7V4RJLKY4WDLhypXj0oNL6d+MMS4ttetDdQgDNwAPEwPRh2NZGkabrvTXVZiexvba5aI+ILWZQG3Y4IDdvtQScvTdjK8chtFjkQ+VlYgqPXGKA17daV07apJrV9CsZbELTgbu3YY78UEHf9evJ4K9P6JqGoiR1XxjCUjAJ5OT3NBM9YdSWPTenwy3t7bWbSuBunUthfUhRyT+1BA2vXnS/jGdeo9LnIHljeLwSCe5zgmgejrOz1S3kGhazoaXYGAJ5Sw3e38uaCsJfX02rPD1XfXtvcCXdBJGjLbOO+EK88Y7nIoLB1H1Bb6WkN1ddSQ29io/5MZEjzt7DGTjj2FXNGUfEH4wRaxCtnp2kwGGM7llvBvIOO4XOAe/fNMwZbqusalfLBHfzSvFH+SIgKo+igYqiwWfWV30rpp03p6exJnUPJexQnxuR+Ulu2PkKCrT6jcSiTxZnbxCWcFidxPJJ96BBDlQ35fbFAbahBHJIGO+KAIwg5YnB455oDkKcbW7UAOowSMjOORQcCVXPp+9AqDkHcDmgMNpHPcUBTuzQWCJXcFvKR2Y0CMiqjnz4UcH/6oG8gKluwxyAfSjQ6ylEJBJfv37/OiYQMjbjkZXOSP/FEELAEkNn1waBCXdjORnPoc80CZeTb5wQe2BQAm4y7jlhjvQcWO3cW4GB7ZpgGC5a3uUeNyGQ5GCR+45pgt+l/EzqLTgxj1O5Zc4CSOXCj70wOE+Jd/Pq0V7qVvb3bISAWUBhnuc+/2pgvkHx0soLaNIdKkEiqR5yDg47cYpgresfELSNc1n8VrFtAw2ZBiiywwcgeb14x2xTBYNA13ozUo/GOqWVizDc1nf6crIh/7wOf1rOURvVupdE6ncpFeakiSWsZdbjSLfw1Zs+VVyMHA75xWsFDHU0idTJdf65rT28YKpPvHjKp9Bk49qYK/rGpXF/qU9zPdyzyyMSJJAAx9ifnVlwNZ7vxYEh8GAEHO8DDH5H5U0IPK8jHxSzFQAMnOKgJkFwPT6UBlAII5z3zQCjnA5OKBXeuAT9KABMA208DtxQHRhzgUC3KjJx9z2oAP6/L3NAHC8Hg/XNAcNtGe4oEy5yeaCdLk7yx2qQCAO1AmXZSSexHbPNAhJuLJkgjvzRonuAJy2cd8UCbyOi453Dj7GiYTZyVPPl74oYLJIyq68EH3Gf3oYTDEjLbiP1FEDHOUOdgOfXIBFAm77j5Mnng/WgLI5UE8Eg9iO9AnuJbuQx5wOBQFRxuIbOc54PrQK28ws76F722EyI4d4HJUOPb35yKBm8oeQsi4BPbPb71RyYIHmPGRg00GRsbsHIPY0Bg52AEEseBUCQJyOPXtQDtcdvvjtQCQ/GBwKAuXU4PrQBvZE5IGeO1AffjBJ57UBvEO045HagFWAAzktQKIzBeMg0C5kz5mOG/WgMrDJJ7jmgEnIyOccYoA3cEMRj05oC7/wDeBQTduzEoNxwcZGaAJOWfPNAlISVOT60aIQfkj+amgJ3bnnigKeFGPQUCf/x0Smw4V8exogX/AOY3+/SgKxKxeU459KAgJOckntQJkkcgkGgAAFFz/XQEmJaY7jnk96BM9yPQelAf/wCX7UBv/jagGP8AKB6ZoDf00HMfO/0oAH5TQA/5moECSMDPFAvGASMjPP8AigVX+b60BW7/AHoHEJJD55oDd4snv70CsSjCcDmgVAAbgYoGYJ3nk9qBUAYHAoP/2Q==</binary></FictionBook> \ No newline at end of file
+<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>foobar<p>Interpreted markdown in a table:</p><empty-line /><p><code>&lt;table&gt;</code></p><p><code>&lt;tr&gt;</code></p><p><code>&lt;td&gt;</code></p><empty-line />This is <emphasis>emphasized</emphasis><empty-line /><p><code>&lt;/td&gt;</code></p><p><code>&lt;td&gt;</code></p><empty-line />And this is <strong>strong</strong><empty-line /><p><code>&lt;/td&gt;</code></p><p><code>&lt;/tr&gt;</code></p><p><code>&lt;/table&gt;</code></p><p><code></code></p><p><code>&lt;script type=&quot;text/javascript&quot;&gt;document.write(&#39;This *should not* be interpreted as markdown&#39;);&lt;/script&gt;</code></p><empty-line /><p>Here’s a simple block:</p>foo<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><empty-line /><p><code>&lt;!-- Comment --&gt;</code></p><empty-line /><p>Multiline:</p><empty-line /><p><code>&lt;!--</code></p><p><code>Blah</code></p><p><code>Blah</code></p><p><code>--&gt;</code></p><p><code></code></p><p><code>&lt;!--</code></p><p><code> This is another comment.</code></p><p><code>--&gt;</code></p><empty-line /><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><empty-line /><p><code>&lt;!-- foo --&gt; </code></p><empty-line /><p>Code:</p><empty-line /><p><code>&lt;hr /&gt;</code></p><empty-line /><p>Hr’s:</p><empty-line /><p><code>&lt;hr&gt;</code></p><p><code></code></p><p><code>&lt;hr /&gt;</code></p><p><code></code></p><p><code>&lt;hr /&gt;</code></p><p><code></code></p><p><code>&lt;hr&gt; </code></p><p><code></code></p><p><code>&lt;hr /&gt; </code></p><p><code></code></p><p><code>&lt;hr /&gt; </code></p><p><code></code></p><p><code>&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;</code></p><p><code></code></p><p><code>&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;</code></p><p><code></code></p><p><code>&lt;hr class=&quot;foo&quot; id=&quot;bar&quot;&gt;</code></p><empty-line /><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><code>\begin{tabular}{|l|l|}\hline</code></p><p><code>Animal &amp; Number \\ \hline</code></p><p><code>Dog &amp; 2 \\</code></p><p><code>Cat &amp; 1 \\ \hline</code></p><p><code>\end{tabular}</code></p><empty-line /><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">/9j/4AAQSkZJRgABAQEAeAB4AAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAD6APoDAREAAhEBAxEB/8QAHAAAAAcBAQAAAAAAAAAAAAAAAQIDBAUGBwAI/8QAPhAAAgEDAwIEBAQFAgUFAAMAAQIDAAQRBRIhBjETIkFRB2FxgRQykaEjQlKxwRXwFjNictEIJEPh8SZTgv/EABcBAQEBAQAAAAAAAAAAAAAAAAABAgT/xAAbEQEBAQEAAwEAAAAAAAAAAAAAARECEiExQf/aAAwDAQACEQMRAD8A2t0YoQpwT2qVzMV+N3UHgrDY2eoM0y58VEbgfp9K1yMRmnuJ5h40jyYHGSeKrWE8u2QAApOMdqGCsmT8h70TAJwMAZx249aKBy4c9vTNUC0zDCgmmmG7Ockjkj1PrUTAjcy5XP0ouCgHae4IomOJHhgIc55PHY0Uk5IXLMcUBQ27n96JYO2MYLebHtRBA7BcMx29sdxQJqwZRtIP+BQKpjHHc+xzigNGoAO/k+nPAoAYlee5oBiGeWySO9AJCgY5PHagFCADzj2GaA2N2TkjA/U0HMwbPPeiyBLDfkkj04FCl1cBMgn6URwYFGySR6D2oAeQDAxnHGKAhU4IbGc+tFwnwDj9aK7f8v2oNu+IHxNvJdXmt9EmKWSqArA/mPvxUxMZNe3Ml1dvNcMzSSEsxPOferJhht/OWyAPc0UfdgDcuM8n50AMCykZFARsngcY/egTcbjnJz9O9AB2kZGSQOcUCX8x83bntQCMruJ4B7D1oCyOGzxtJ9M80CAdg5UjFE0aFJrghLeNpHY4IRdx/QUNWCw6D6q1EZttEvirHAZ4ig/U4qw1b9H+CHVN3Mq6hJaWMJ5ZjJ4hA/7R3P3q3ET+pf8Ap/lWNm03XkkkA8qTW+3PHupP9qxopV78G+s7VSV0+OcAn/kzqSfscVvIKzqPTWu6XKE1LSL+Bhz5oDg/cd6lEZzGwLrtPqrA8frUCJfcw9gfegUjZsEAffNADyHt78UAjCjzDJxRcO5Pw3gwCGOVJQp8ZncMGOeNoxwMY96GCbQffFFcUXKjDDt2NEo+N3yyM5z3okKuqJgIzONoJyuMGi4QfGcqSfXBoYHJx659qKIRnnsfUGgJn/poJYoTIGLY+eDzQFlQK2G/KCTmgbspfO0qce/agPGcR7nHf9vnQFfBPlOc88Gg7uucc/M0Bd208YJJweKAYrea4kKQICRGW5IUYUZJ570DYqcknt3FE0VuVyDzj1oamOlulda6puvC0a0eZVIWSbtGn1Y1NNbX0x8ENH0qL8X1NdtqDoNxiQbIh8u+WpqL70Tc6fcxypouiRadbW8hhLFFXcB7Edz+tNFvEZxkmmgShbA9PlUA+Hgg/wBqDgmBkd6ArJuJBGR7VdEdqWgaVqMfh6hp9pcLj/5Ig2KaKJrvwW6S1EFoLaWwmPIe2fAz81ORTRm3UfwI1mzBbRL+K/ReyS/w3x/b+1Wexmev9O6xoE2zWdOubUDszr5T9G7H9auCJj2n3PPrUXTlGBB2kYx96GlQMjJJHuRRXBgDgk8DtRKH8w4OfYA0SUlIMsFXJ4oujHH8ufnRRGOSNoJNAeFC77F2jPucfvQFEqgY3nj/AKaCUY58wwq54AoCzOmVMke9QeRnGR7ZoEIF7pnaTk49KDpSSwQntQJsGKjgggZ9uDQc4OOe1Am2UCkHOR7dqA8t/cSW8MEkrGGEsUTPCk4zj9KJT3pzQtS6m1aPT9Jh8SVxlmJwqL/UfYURuuhfArR7f8NLrF1cXciKDJCrbI2b7c4+9NGtaRptrpdqltYW0VtAn5Y41wBUodvGjqUdQyn0YZqAIreOBFSFFRF7BQAKA1xcRwKplcJuOBn1NAR7y2ikWMzoZnGVQHJNAuQcD3oBKkD2FBy8jnvQFxnjjmg4rxwKBMqCBtPNA3vbCC+tngvYo54HGGSRQQR9DV0Y91n8DNOvFkuOmZmsrk5PgSNuiY98D1X+1XRhWu6DqWgX72er2j2069t/ZvmD2IoGG7jbnj1FFlB224PB+VClN4DYJHyAojmPGCck8cetCAxgjPp6UaAGKtx6+9ATAXO7nFBw8HHLN+goJhBuj2FeAcnmgNazW8U0vjweODGyqpYrsYjytx3x3oGa5LEEjH9XvQGlgmjjMmQq4HBPfPYgevagG5nhe3tkFuInQHxJQTmQntn0wKBKTlAeDx60DSY+U9zn+mgsnQvROr9Y3W2xi8KxV8SXUnCrjvj1Y/IUR6c6A6H03o6wMVgrSXMoBmuX/NIf8Djt/eiLfjJwO9ZBiOfmKDhktzQAzYBLZ8oyaDF+rOptVv8AUjNZL4tjA/lT+kr3wvqTQX/pi3Y+DqFxKXurmFWAaPaVzg4I/b0oHlxqV7penRTXFu93dPLsESYB2k8n7CgnradLq1WaIOFI/K42sPkRQCg3Kcd6Dgp3d6AdrGg5VxnjmgKWB8uQGxnFAUgKuSefSghuqNC0jXbAWGtxQyJKdsYc4YMf6T6GtDzR8S/hnqfSUz3NvuvNILYSZR5o+ezj/Pb6UGfLzyD/AJoFFySQVBHpQDJ5kGByPahAbWxn5+po0OF3D+XPtQJsNwOe+aAuygmMkebgHnHFALHYpJwSeGz2oGpOJWAI49BQEZlYAHkg4oARVOMvtBIJJ7AUAX6xxSOsUgmjViFcKRuHviiVfvhT8NZuqpk1LVFeHRkPlHZpznsP+n50qPS+mWVppdnFa2cEcFtGu1I41ChR8qyHVxK8cLPDD4kgGVQHBNAa0maaBJGTYzDJXOcUCy5JOaA2OMfoaArkheM7vlQNYNOtoWLJCgLHJwo5NApPKLaNpGRQB6j2oGmnRvcyNd3O/DkeErLhkWgklIdCyZOCRzxzQEeRxhdpUnncBkD5UCxXjJ7+tAlctMsIMLohz5mcZAH09aBQYdQwyAeaAuA7MAQxHH0oG1481nbGVInuWU5Kr+bHrgepoKB1u+o6jqlvBH05NevEBPBK0pQR4I4BHZj+1Bb9IS7lsFtNWtYwDGFYB/EXHqpJ7/WtQYx8VfhGbdZtV6Uh8gy81mpyR6koPb5UGKY4YkeYd88fbFAI5AC98c5oQBb+U9+9GnN5RgDgjOPWgAN3yMfWgAqc91/UUD2RSSRg9+49KCR6e0WfX9WS0icRwgb55WOFijH5nP0FBYNRi6dSR7HRNPmu0hOW1GaXaZMdwBwAP3oynE0XRYrFtV02wS4ECj8dp1wcsE7eJEf39qlFZ616ZttPu7Kbp9Zbi0vYzNCcgjHqoHuKsEp8LPh7P1PqjXerxywaXaviRSu1pWH8g+XuflQemIIY7S3SK3hVIo12pGoAAA7AClEL1N1RH0/oTalcwx+IACLaSQKx59Ppmshv0D1jH1ZbTubU27xkkAnKsuSMg/UUFluLlLaJXETyecKAg554zigXiubeRnSKeJ5FOGVXBIPsaBLULoWkIfw3kYsAqIOSTQJMbpm3oqlmwACeF9yfn+1A+Bx34oE5IY5P+YFbnPIzQKAckHuRQCAQOO1AL8r9KDhkZOT9M8UCcrxgAyYJzwD70CT3Itxm8kgi3fly+P7/AOKA9pskhEkZysnOfeg6RH8w3tgjAHtQRZ1uystSg0m5eRJ2UbHceV8fP3oJkBSAVII9xQFdSRwKDDvjN8L/AMSJte6chxcgFrm1QcSf9aj39x61YMH8Q+CkfhqpQncxBDH5H6VRwXJ/Ke1Am2QchuMYOaNFSAVznB9qAm8f10D2RmX8jDHP3oLbebtA6ej0m2LrfX6LcX7IMskf8kf6HcffIoG8yTadZxSTxCK3kRZUwSFfkruIJ78GhiS6Y1OS3160uZJFWO5bwZtxzuQ8bcfPNMZXvo2wsLnQ9R0q/maJNNv5Yo3bjCuMAHPzqA2jdUan0lF0/ZXcElxp9zE+5WVd/DE71IPPB7H2po1bSNXsdYthLp1ykyEcj+ZT817ioITrnoux6vs1gv5JYnjz4ckZ/Ln5etA+6N0BemdBttMina4WEFfFdQpIJJ7D60E5I4Vo9qnnsQO1A3k0yzeTxhCizZJ3qNpz9RQO449igMSxHGW5NAIwBtUAUAMORkfegMhG3jtQD8+fvQGXJz7UAHuRQA5YDI5FB0qCQA5yaCs2/SFit/Jd3AmvJ2bO64ctt5zwD2oLMilVAUDgcAelAJLbhgZz3oGN9HPIYmhtrWRw2czjt7Y+dA+h3mJS67W9gc0AvuLYANADpkZABHY85oPOnxy+Hx06Z+odGjC2jt/7qBRwjH+cY9D6/OrKMebcceHwfaqCYIyDgZ96GhHOFJI4/WjQpXnsaCz9J6fDqGvRC8OLO3Vri5PB/hqMkfc4H3oDT3UupapcXrKS9zISgDdhnAGPbsKC5aLLBHq9p01c6bbagPE23kpJYhmz5IySAAMj6nNGdRnT2lu3V9vaQQrJDHfCMFj5kAfufsMUFogu5H0jrLUYXK+Lq0aRse/lf/8AOKlFfudagvbnQpNQRmtILydCwPdCQcgMOMZFQanPoeiawBd9M6s9jeKPK1vKQp+RFA4septa6fuFtuqbRrmzx5b+BAdo927A+vsflQXfTr2z1O3W5025juIW/mjOR9KAZI914khaRNo4XdwT9KAl3b2+oWpjMoZWbOVfnI9sUCrXUNssUU8w3sQoJH5jQLvwQQC3NAKvuUPtK54waDg23v6UA7weBnNAIOBigMr+hoOjdZQdhBx3waAVG0Z7UBWfAOQSflQChyNxBAxQRutarb6bHALi9trSW4kEcJnGd7ewFA/j8QEK/IA/MBjmgWDDBB7igj9dupLTTbiaHZ4oQ7A7bQW9ATVgwXSNV6onl8azW6t45pWdxHIxWA/zNtz7A8Glg2S1u7fX+nt0J/H2c4MMhmQoW9GBUjj60g8sfEHpebpDqi4sHLG2Y77eQ486E8fcdvtVFekGW4UfegKVAAKgnFGhuDzxQXbpDTZF6a13UnUqrCOzQ5wGZmXIJ+lE0ppkEK6nJcRWcTW9hA08iKcjcowpye/mxQ0+6VRbC/jvLm48L8LG9y8pIOXxkDnuSTipqHXQMng3es9S3fhn8DbvcZI5Mr/lH700dc3Dad8NtPs4nU6jeXD6nMCwBRF5XOfU8YHrTNJFF1X8RawW1jc4GxTKNrZB385yPkBTFw1stSu7Ni9tPLGSQfK5Aphi8J8UNUm6fn0u72yvJ5fGbuF/39aYYtGgadp9/axXnRetzaXqnhqZI3bEcj4547Ak/X6UxFisPiXe6NMdO65057eQAr+LhUlHHbOPX07UwWXpQ6BqMo1LpgW0sioVI8Qgxk+684qC028M5890Y3kHKbUwF+lA4LDOzu2M4FAOG3DaoI9cntQdJxzQEyR259f/AKoGl5fSQRFo7ZpB/MhYIR9zxQdayyXKb7gqox5Yo2yB9WHc0DPUIWnhWKxkuYFRs5gcKWbPY59KBkx6isVeSGW31JNwHhyOUkA+o8v9qCfjkMo/LJFKqBmRvSgc2swnRyFcYODuXGfpQMtRsLK8vYJL+wjuGiUtHK6hghz6Z7H6UEmCsig84I9RigiruC9t0DaaVmIIHhTOQMeuGwT9qCJ1ywv9T0U29xFFiaVBJGHz5M5ODgYPY/arKJPTtLW1t44i7SKq48w8x+ZPrTRJoipGFQAAdgKgzX47dMJrXSrXkUe6807MykDkp/MP8/aro80FQyZ+tUJ7hvH0x270XQ7KGtXvIk0T4c9P2bIhkvpnvJVfjIxhf7qftRDXpu0/1DpzXltUlkvmWMBI+2zdnn64oYa6yX0XTm0i4jQ3t6wmuV53xov5UPpyeeKyLbpFtZ6Xpmn6TqNq7/ic6pqQRR/DVf8Alq2fTOP0FXBnXU+ox32o3lzeW+JrxlMXHKR9wfbJ/tVWK5f3AnaAjafCTwwcY4BOM/qKKSjA4Dg8j37UHZKkE5P0olSFlcLDdJPbTNBOigjxOVZu3+80Rbbnrq9l0t9I6isRd2rgKpPlZMdyre9An07oupoh1zo2+lea2fMlr+WZFx7ZwwqWDVug/ihDq7R6b1EPwmpMNokPlVj8xng1BqEUe1EAJOMDOc5oDSxq6YYeuaAJF4oCBUQ7mJ45zQHYB14wR86AVjBXyjge1AEcRTHlA9hQE8kbgEohJ5yQM0ETHNqMOr3IZQ9tIMQyEjKt7D3FBLqywRPJKTuxlj3zQI3Ut14e+yhWRj28Q7RjH60EfpF3rU/jLqFrHbS4/hqpJXH19aCRa8jgiVr1xGwXzYyf99qA9tc29/aRXFnKs1vINyOO2KByoxwe9AYocHGKBvdwLcWzxSLuR1KuD6gjBoPHXWujt071Nf6YSSkUnkJ4yp5H7f2rQgWAA3Y+1An4j/1t+tBrHxKuYS+gx24LRx6ZFtI/lz60FY0+/v8ASphNpd68EpXY5AGNvzFF1YOirZbzVrvX9dkNxZWH8eeaY5Lyj8qj7kcVlETqOqXd/HrPUNzcNE16Tbwxf1JkEgD2AA/etBte9R2Oq2cv+p6XHJfBFjgmjkMaRgAAEqO5o1FWfbgjsR8+9AlI5CgEggeoNAq0iug8uD7g80KKmCcZ7fPmjJzJfT/hWtjJvhOPK/OOe49u9A96X1W90/VrRtNkkSfxQF8I5yScdvX6UGidSLpfVFzcvbRiy6kgZBGysFW7B9T7HHNSjU+o9S1iz0e2uNLmX8RYxJ+KgYeVwVGTn5d6gjug/iU3UOt/6TewQpP59skL5B29x/8AYoNHPB78Ggb2l3bXO78PKsoyVyvIBHBFAoSkbfyhn4GfWgTnmWFN7ybAvc4Jz9hQRdx1dp0S3Dw+JJHbDdPIUZUjX3yRz9Bmrgzbqb4x9Oxho4bB751O5HPkXPsc80wQHT/xrJ1IHUbGKO0kdRiBiAgz+YjnsPpTKN/tLy3vLOK5t5klt5F3LKhyCPemAYLuK5XMDEj1OCP71ArGWLMPT0oIbU7h11u2t49OllWWNm/FIRsjI4AI/egfQ2ktpbww2XgxoDl9wJ49cUCHUGv2GixM13Mkcm0squwUH5/SrgxDW/jFcXOteHb3otrKEEiRISRM3zGc49v1qDT+gfiBpvV7y2unxTxywRhz4ozuHbOR2+9Bmf8A6kNIEWpaZqiooEqtBIR6kHI/atfRjDEt3AKjgVQjug9j+lQWh72e/htTOzyeCnhHPomeMYoJvQum7vVD47K9jpsQBkvZ5NoAHcgUAa7rKamE0Lp9Xh0G1OZZTwZSO8jn9cCsivdS38F9cJDZIY7G2URxKe5x/MT7nNaEKrENwAFPPlosFwS2cd/cc0UlIm3JOeKDo2LH+UA0SjgDk98URzPiJ2449e/NAbS7v8PdpKkpikQ5WQLkqccGgmYNQmXWLeQLG9wVRQVPlcj+Yn3xQa98OviAjz3WjdXSpFdliEuJCNjDtsJ7enepRdel+kdL0rqOTVdIsoYklV1dixO3nunpg9jUCnU3WMeka5b2EUcl3JInmigQs6ZPlJAHY8+vpQP9O1m3nthNo0cTwM2JDwoVj6H5gd6CbhtUiVn8TcXO4ktkZ+We1BAf8Z6fZ2uqXWpyxQrbStGseQzMB2IA961B59+IHXmodXal+HsPFh04HbHCo25+bY/zQWv4f/CCxvII73qC8iuXYb1tYZeF9txHf6U3BatX+DvSl86x6cr2dwjbnEUmcj6Enj6U8hLdJdEX/SmowJp2tTT6Oc+La3HO0442+3NBf1LmRUjjQAfmc+nyHvWQockYyQcY3CgaabaPZxGNnaUFi3mPb6f+KA2q3RstNurnBxDE0mPfCk1YPMemaP1L8RtYN9fJPc2aMUaVmCKg54H0z6VRYendf6Z6T1W56a6j6fgfwJyguhGJmPzbIzjHtSjTn0zSunbi01fSkt9Os5GAmWNCDOGxtXb6HnNZEZ8etOF90DPKFy1rKk3zAzg/3rXI8u7zvOTg4zVoTLDJ81QWDTb2SwuvFgcrkbXwM5H0PFGqsjpd6+kcT61Nc2ieb8OikFc/9PA+WfSjKA1nWBzpFlZ/hLWM4KH8zsPVj6mghN4IyQRk5NGo5BkFmyAfSgVjChdpGO/FAXYpOHLBe/FAQqoBJbA9sUBGxgtgEj/eaCf6DGjt1TZf8RNGumKS7mQZQkDIB+WaMrf8Ub/ovV7V20JIYL62K4khhCLOCcEcAdu9BmCuEQvxvyFUg42+v+/rQaj0zax/EXRY9Nns0t9TtM+BqCKAjEclXA98jn+1Si7Cz6u6O0tLjTrxLu2tQJJrDwcKE/m2M2SfeoLrpupDV9Mh1OytUS2vIN8m4BZQf6T7+vPpj50GfdK9L6rJqk1y1y0elRDKRqdjHHoyDhjx39e9BZr7fagW0j3kul3iETRqHkeF8ZBUjkZIxjtk5rQ86dW6r+O1OcW0UtvaRsY4oWfLKBxz7k/5NA46P6X1rqS6WPS7V9v88rAqi/f3oN46X6C1DSotkus+BIwKl8hn2+3PapROXPT2t20bPY6kJ5UGYmbIfIHGW5z68VBI6DrzzWSrrAjtrwFUbDja5OBlfuaCbluJLeNwIpLiVF3bVXAP0Pv8qBxLO8cYcW7vnuqkAigNFKs8CyxlwG/lcYI+1A31ayF/pt1auSFmiaM/LIxVgwfoO413o3qqfSLyUSwodogAyZVGcbPTPr71aNDvendJ6wtbu7Fi1lezK0bS4VZMjtnFZE0bC5u9Jh0qRAr2yw4uWx59vBI44PegN1tpbap0lqOk2sipLPB4aFsnHbBNOR5A1exFhqFxbeKkngyMhdOxIPcVuhiZFz/zBUEwcKvYnP6fWi0+6chjn6h062uATFLcRrIMnzAsO9EehNR+GvTV3GUh0+O2YsGaWHIf9amjIfib0no3S0VtFY3M000zMzLJtLKvvkenyx96oz0rwNjA8cj2osFLbVAbOc9jRQiXOAwxnj3oBlAxwDj37UDY+vHOQeTQBIdqjcPMfnQwJclWyBgCjJBFeefw4VaVycBUGST2wAKD0L8H9C1rSIILjWLSCytY1lZASVnlL4PI/wD8+vvUo1uwbxI5GkjdVc7isvOBjtj2qBWKFZiQ8CJCB5FHYj5jHFArDbQ20ey3RY1HOAOPsKCH1u61CPSLt9MtlXUHUrbCbJBbPdtvYetXR5T1y2udD6lni1ErJdJLvlK4wWOCePvVgsV/8Sr67UW1vA0NiowIonMe4+7FeT9ARQRmodWa9EYpPBhs1Tygw26rk9xknkn70EjonxZ17TXjAeKTkZ3L+YZ7N8vpSjX+lOpNM6umgkMG3EgBV1DYbG4kewz2NZGkC43CP8MPFBONysMAD50DaHVH8S6N1a+BaxMUjd280pA5wPb296DrXWLK9WNoJdtwybxDKPDcAnHIoJBifTBzzmgaz2UFzPFNNbwvLCcxuyglT7igdRRKg8qAZ5JAAzQEnuYoHiSWQIZW2ID/ADH2H6UERr12BY6hueIQJaO7SK/nHfnHtx3pyPGWoN4jynuCfU963RF+DL/UtQWTkjaWY/8ATnHFGql+j1VerdJY8r+KiJz/ANwoy9C/EjqSbpbRY723RJC8ojIcZ4IJ/wAVkecer9en1+9FzeLCCq4URjgDP7mtLhteadBY2kMczyHUpcO0YxtiUjgH/q9celAiLy1kjCX1ruyMLNGdrj0+h+lE0+t+kNQltJ7yKS3jgiTxUFw/hySp7qp70NV6YEBgWUNjBoaKeAODnHrRoVgDnBP0ozpxZ2f4y5trVeGuJFiBPpk4zQep9C0LTembS30fQbWP8ZsDyTugZgf6ix9fYZpbgmbXSmXULaa6kMzpltzcjJ//AGpaLCY1CDsF74PrUCgHY0HbSx7Z96BGUfxB2xjtQZ11t0Tb6jNfyw2wM18gV5AcBdpzyPnV0Yp1F0o/TEczXjXaTOQYpIk3QlT3B9Rj0zVl0VKbVppImheUSwbsgFfXHc0De0tri/ujFYQSSyfmKopPHqaDV/g9p+padr/gkSRTzKu0kZRlPLYPbOPf2pg9GWzRCMJAFxH5do4wayKX1z/G0CdzqLWRkiaTxQBLudclQvovbv3oMU/4Z67uwnUAt3u1Zw42yhmx3/Ln8v0oN86L1d00i3i1UiGQIocNnEbnkqT2xgiguEbI4DIysp7EHNAZnxQQ/Usksej3EsCl5EUthR5sY52/Mjigr6Qrp3R15LqEcIlmgdpFGAsY2navPJApyPJtwd8rnGBuJz6Gt0MzGSTyf0qCwSKA5ZsAjnn2otTXQYj/AOMNIDqCrXUZwf8AuGDRG6fF6Gyfo6+ub0CR4EPgIScLIeAcfc1keatN0661a+S3sYTPKzAbV9B7/StLrQ/iXp9pYLp8elWsUM11AzXMqt53I7g7j244oiB6W6Tn6j2TeAy2FspTeB+Z+/8AmgtnWlvpdl1Dp1pq07Ja20GFQpuDHHAwPf39KDHriVTKSPOCeBnHHtQGsrG5v5pfwcTOIlMjgEeVfck0XRIreS7uUigRpJXOEVe5PtRE/wBJ9HaxqvUcdhNFJp0lviaSWVcMgzxgdySeBipo9T6O8NppUJ1K4iW5KgSvIyqxb5jPH0paJm1NvKivE6Mp7MpyP1FQLRTwy58F0cjuAckfagOTtO3+Y8igMWCIWbOPlzQNhNBOWEbq5Q+YKc4+tAD7JEZgQfXj0oI/VtIttXsZLW5hRopByCP/ADVlGRa78Erae63aXK1tG3LAncM/Kmh10l8IZdBv4rxtTE0yggJsyoz6/P0po0zSNKEMdo9xGnjxuzkqMAEgjj7GmialjWQMgyCRyQcGoITqHT7q/a30+G2jFmwLSzl8GPBGFA9c5NBPRwJDbpHCipEi4CjtigqfWltqCaG8WhNbxyzOBIs8W8FcY4+dWQQ/wtuZdIGqadrknhy2u2QyOSEZOeRngY+XvTBZZevOmhC8janbqiZ53Zzj2FMFcs+sh1ZqsFrp8UkGkrlpbh+DNzhVX5Z5NQTfXyWUXSV2t+wW3EZ5I4HHt61eYPI0mA5C9snFaoLsPv8AvUEk5JcA8cZG480WnOlXX4PVLO4yQ0cyP244Yf8AiiPUfUump1B0/c2O8xfi4v8AmL3UcGpgw/SujNX0Trj8PpckimOMvHO/kEg9Rjs3PpV0aFq/Qqa1ZJ/qcrverEqNOwGM+uMfemiVtrKbQdMNjp9rvtkhPht6mU5yT8u1BkvXg1qXUtOvddgRY1R3j2YHiMvZSD27CgzSCyuNQ1KK0giL3Mz4VAOc/wDignoNNOnaHeiW8hgkku/Al2+Ziqgn09M0ETp0qpqSmGKOdFcEeLwMfPHag3JLuCRtPmQWsDhNphtVAcn1w3BPFSwDdWGpX1/OYdOtbbSrlQ80szHdn0GR24/c1AbWemdatLbTJdGvJIJypDQwMV3exwOPatSz9Ei/R+txy2mr3evyHV4miWIDhGwwyGA7nGRS2YNZAUBWYDdjGayEvxMYB3nYu4KCfU+woG93c2enWs1xcPFDCp8zEgDPzq4GGgz22saS1zZSZhkdsFePXt86YHWmySeLNDMYikZ4YNlvvUD+VARxQJqgwRQHUAAe2O1AWOFRM8mDlgB37fagb6reXFt4ItLZJnZsuWfaI0Hdjwcn2FAz0nWX1i4u4xY3VpFbv4eZ1x4vGdy/KgkriN2aMRlQoOW3DOR/5qwYr1P1tp2pdS3WnanKkGh24kRl2eaYgcb/AFxnnAqiv9Jno0dRLJPbtdQtkNPIALaMnODsPPpSjbdK0DTbWQXui+Gsco3BU5hPP5gPT7VkU74t6PZHpq/1N5ZZbwrtRnmOwDPOFJwPsK1xR5ybudw788VaC5X2WoJRULSBpAe5PA/aiinAZnHck4A70THq/Qr23/4Y0u4lmCpLBGA7epxjH60Du+WGOBvFlFuWOFcYyCfbPrUojri6k06xX8PFNfBUJ3ltzM3scVBjfVvVXVNit5dapNDZGQGK3shjeAe7YHIwAOT3zVggNTiu+orrR4p7m+upJFR7h3TPhggDaoBwRjnPH5hV0af0xotnoD3l5dWdrY2YjGLhwPEHoef996CC6m0HpuPpk3Wny2s9sJPHJ3AeI2D39T37UGU9QTDULuGPSLPwIyoVIYk2lj6/X70G2/DPp0hVudRuBLcwxhRGkeEjB9M+p96DSLprVHiieaAE+YxHkke4H1qUOIBawL4uAuc8nvj71AwjRtQ1eO78QNp9odyLju/qT8uf70Gb6r8SpLzryy0vp+4NxYSSCEswI2u2Rn3OOD9qC4dVamen9NlaC7tUaIFvCmnHiy4HJXJxnOeDVwed+rOvLnqSyWO4jZSru/kc7ck+30GKosXw2+KmqaDJDY3jR3OmqNoRhtZAP6SP7Ggtmt63qbTJ1XLazJpslwBFblypEOAA7L2OWANS+xrnR2vW3UmjJeWp8wJSRf6WHeoJdSPMCRmgMq8DmgBpNsgUIxBGSccD70DczmS8MDWoe28MN4+f588rj980CktuJZYpFdlKZ4B4OfegQ1hpIrVjbsRMBhBj8x9qsHnX/hm36y1O/u9V1ddPmS6aD8OkQdyxOSe4OMmqLUvwQsYY4Xjv7m4YEEhwFyMY7fXB5pRbvhp0jqfSMV7b6jqZvLGQAwxAEBDk54PuD6VkVb49a5DBpiaNaeF/FIaQDumOwpzMGDEZQZ5+VboR8In1I+9QWDY6gFn7jjHpQhtJEFbAGBnijT0P8H7qPVOh47a42yNaymPBOcDupoykep+m73V7g/8Av2itQowvJIx6j5/OpRjfUWrax051RPY6LqFy8YACkebO4Z7HjNWCY0ToW2utJbqPreW5na4O4R78cehY9+fQVKLX05p1ro97awC4kX8VFmJLeEKdoyfOxJPbHbHYVAz0rqKPWNauri9t1ktJgILYgEiNFJ/Op9STmrBBdeaFCo0y3jt444DI3jLE204Y5DD+9UPPhv0NaRtPq99mSLOy22nOfdh75oNC0vT7m1uJGvGiii3AW8UDbQAeDu9zUohLlhouqap1VciF4I1FtbxSthtobBIPuTn7VBJ2vUth1TYk2ULi9iALwyKQYz6Z9CM0Ft060/DWEcDHe2Mucdye9BFW3SekWt3LPb2cUTsd2UGCG9x7VYMzufhzdX/WmoXj+BPpx3I7XZMmXYckc8EVRKaP8I+nXikLQuxOQSTnBzj6UEjonw90XSrq3S3s7dplJcl1EhGDx396lFx1TQ4NVjaC7UNCU2lAO/8AvNWDCLp9X+E/WgWImXSp2LRq7eSRT3B9iP8AFSjd9P1+21TRodVsMS2rLmTbyUGOePXFQSltcLcW0c1vh4mXcjDswoDLdRm4FvISsgXeTghDzjAPbPyzmgVFxCzuiOC0WN3sM+5oDqySJmNg3rx7UFb60tNUubGJdFdEvhIdryflUFSM49TVgyTQenJemOorf/U4H1Fpp1edAh/hOQTuQ9375JA4q0bnbPBcxxT20wkjKkqYzlT9ayGWu38um2MbLEJ7iRtoUds+/wAgBzQeW/iHqi6j1PdzeL44HkL9txHtWhVUOVyvHNB2F9zQT8hUAhAdp5FCG0mSAzE4HGDRppvwL1bwOpJbEsFiuYyVX3deR98Zoy2ZtRgmjkSRZocEp51K7se3vUow/rfpFE124mVpfD4mk2MWdCc4A+VWCH1281/UmFnpklzPYRFBEG8uGC4yQfcn9alGgaJo95rRsbi53WaxwrHOm7BjYcHnvz/moJaw07pXSI5IW1K0CQnDhpAWB9R796CudY62msTRW+gadI8KnDXMkLLv9MA8HGOKC3dAXF1dRfh75f41moi4G0AdwcfTj7UFhv7RjqMBV5AJFZHkR8FRjIx6CgpXVNjJ1JqNn07p26CztSJLlpIydyj2J+fGaC+afplrazqLa3SKNIggx3IHYUEsBk4wQc4oK11L1z070/M9rql6wuVA3QopLcjNBDwfFboqeSO2W7kQNxuaEhQfnQLt8TuireVoV1UeXnckTFT9DigHRuv+mbu9ZV1W3Nyc4IRlVl9O47/KgtU+s6baw+JcX1umRkAuM/p3oK/1t0rYdX6cqXKESqN8Ug/Mp9P1qwZ702mo9GdUTWJsmOn3EY8CAORGXJAwScjJ5q0bJDNLb6YklxbKsgA3wwndg9sDtWQN3aw3ZKTwLLEQOGORn6ehoG1vYAw3FikRt7JSuH3Hc/GSc5P0oHn4aO2uGuYyiose044wBQIm6F1dwfh5ARs8R8L2BHGfnQHv9PS4PjxrGLtFKxysm4qD3oCxboIIo7e1jhQHzAYUJ8wP8VYM56j1ktaal1BMrS2sAaK1OQDD6eUepY9yfQVR5zv7hrmaSaRtzyHJY0DcE4BPIPb5UBwOO4oJYzFvzEYHAH9XvQhNZN7AEgDOSDRo/wBA1SXRdVtNQgb/AJUgfBHcZ/8AGaGPVlhPbarZ2t5CEeORBKje2RUrI1zYxTBhMinIwcjvUEcugWkO4AMisMEA8N69u3yoERrOhWNxNYy6hapcxAeJHM+D8u9ASLStLlm/EWdpZyxy+Z3RQ3I5B44oJKTT4blFWSNBEOeBg5+goFYbOK1TKhIxnIbGMH50Cpcyo6AMrIcM2OD68Ggb6Lbbllu5Cd88hYBu6rztWglSNkfm4P70Gaat8Rba96w0vp3R2mhufxyi4kO3YyDOV9+f8VYMw+P0cP8Ax4JVuEKzW8bEr5tuMj0+lUZ7Y2X4288GK+towRlZXYqv9uKCQi6YmbT2u11GzaJWKnYxbBB49KCFnhubdiwL+U8OhP60ElpXUFxY6nDdXQF0qYbZKxwT9vWg3npb42aHcmC11C3uLSQjEkpIdQfr3xUondP6x6e6tv7e101hczRzrNtaFiFC/wAxPYHtUF+lj8bYCTgMG59cUC4OBQQOo2eoXepFTeL/AKYQN1sEwWx6Fu+DQLX2kw3Ok3Vjas9qJ48Exd1PHb9KCE6R0G86Ut7mK71KK4gklM7TyKRIBjtjtjj96AOreudJsrMJbXksk8jBCbVdzRjONxBHP/3QQ9x1jcWGkERWWqXdpMPCt7x4wfFOOWPbA+fAqwZr8TJ9Qbp2ymvEjsrSTEVvawyHz45Lv6E4wPqaoyl8g91OKDlYEc8mgKW5PH7UE80f8PPHl7gDFAZkUjawUIQG8w5ouknAUbl9Dg59KK1X4Z9XXFvo8mlRXax3KHfBG8Rk3qe6jHOc54+dMZO7jr/qK8vWtba4tYu38TwvDOMc8N60wPLbrW10PS7pnvrnUtbAKobgBUUk9jg8f/lMC2rydMdRSaRqWoLEbx4UefwxkL2BVvvn9Klgv3Tp0lPxFno6wJ4IVmEOMEHsf2xUD2e4ks7n+NGDaCMu8q8lCMcEfPNA6tW/EwrMybEYZUHnI9Cf/FAzu7G4LXTWs38SRNqhs4Bz3z9KCO6x07UNT6altNMvEs7xkC7nPlI9R2/egwbrDT+r+kupLCeK9nu3KBYGRy+QvdWFWCU6avtA6h1iKDqLRhpmpvkxz2p8JGb3z7k557VRX77TdHteuPBut401CAouyXGcdvmASaC069030brYaay/CwPFwWspRErfUN7UGZX2hWSiY6ZrMc0CvhUlBUk/UcGgiLq2mtG8F54yDwfDfIoGkrRsSZXwOB2zmgsvw06XHVfUcFvI22xQ753Ze4H8v3OBUo9a6XodjpltHbabDHZIhVsQqBuA9DxznFQTQUe5oDYGMnn7UEbpV3JqDyz+BJFbBtsXiDBf/qx6CgDXL42cSRwGM3UzBQrHGFzy32oG2i2kKTSI80lzMow0rqQoyew+3tQO59KtJJRI9rEzgg7igz3z/egZ6paJdGGwW4eBXy7pGeXUdwT6A5qwebPjJrcOr9TvbWZQ2Onr+Gi2nIJHcj7+vyqigOuRk+vtxQAqEk4BU0ABj7j96CzzKxYD0GeM0CQG3OMAjkfOgbSZwzE4PJyfWi6caTdzaffW95akrPFIrLg/tRHpGzs9C6t0W31FrO3Y43MrcbH9c/eloZ6v0JpWoKlrHHBbScSFEHYc5Pz71NDXUoJrK1g0dvw9qsspW3nXaN6KMrHnH5ieSfan0U3Rr1uidaRbiwk8BUSS6naQkjc3ZcHaRnn70wbja6lZX+nw3NvMksM+FXnPJ9DUCeoXj2hSG2t2km7op4U/f/FAvHaNePb3N0jRzRA7VD8Akc9u/FAvcxnawZQ3HYtjJoKfDFAdeub6Vo1dSULIBtTbgYOfU8jNWUVvrm5ih0m1urixhlsI5HJliOwR5/LkkHHJPamjHdQ0HWdemlutN0+YWBYtC0rHDhjwVz3zWgx1n4e9U6QE8XT5Zd//APR5se9XBXbjS9S0zAvbO5tyWKAOhG4/KpQ3ZHXO5JFK98qRUGhfCbph77Uvx91pv463wVjR0LR7s483796WjW7rTrXpHWrSW2YK7lmXTbaIFpCRjjHOOSeeBipaNLtXuIre3R43lnkGXYADZnnmoH6Dkbzn6UDGWe9a/hKG3jsW8riQMJS3svp86B6zgMQmDtGT8qDNb6XUpOoPx72tzOkjFYowOduDwDjj70Gg6Wsq2KNeAJKRuKk52fIn5DvVkENrvW+iaSAsl0txI2Asdud5Yk4A4pgzv4l9ST6JZSXbyyprWpw+FFa5G21gz5icfzH3pgwCSQlh688+tUEwjjngZ7UHAHuWAHpn+1AXj5frQWXOGBZcKSe3c/rQIyAtnI27eBj/ADQIMAuH8vHBB9DQwVpPLjOckEZ/ahi9/Czqj/S9VhtLm6aG1uZFUsT5VOfX5Gpg9GiNJArxsrxsv1BHypYGF7pljeG3kvLZSlqzNGGxhSRjP6GoG1yLUWiWc2nSPA4KJGItyYHYHHarop3wu0jWYNUvzriNBp8ErraRMANxJ/N7nA7ZqDUHgSQLvAbacjI7H3oOuIFuYzGS68jJRyp4+lA0m0yDwGjiTw3bzBwTuDe+TQVbV+mLmW1NtbSok9weZiC2zPLEZ+/FBM6Xo40/TYdL8Jr21G4vJcuCck55HbFWUKQ/h4tR/DTz2o8TK21qmMgKOf8AfpmrokljG1i5BHI57D5VNorut9Lab1LA638W6H8sboNrqQckq3pntV0RWsfD6K7SGC3vTFahQJY2iVmkI9d+Mimie0Hp2DQ7AQacio3JZgqjcT3zxk1KHGldPWtnqMupS5uNTmGGnk5KjGNqf0r8qgmkhVGcquGblm96BDUZZYLGVrdN8+MIvux7UGKTdXdbaRrFvbaxbWN4d58BmwCjHPORycLx2q4LNe9S9TdN6I13qkWmzSXdwBCGlO4hiMKAB2A9ag0WySQwpLLtMjDcQBhVz6CgoHxF17XbnUYunulgsUsu4TTvjIUAEhR+x4qwZwtkOi7651PXJobm4tohHbQhdgecjnaPZeOfeqMy1vWLvWNQlvb+ZpJpWyT2A9gB6Cgjy5AO4A5oAGRgBR39aA7Z8MkFtxPY0AbV9UGfpQWhj5TkBQGxuBoEGG1iQCyHvj1oELgSkK6oRnIBIxzRdJ28Q3+fHiAds96LoH3AF1wCfyijNbF8JviI1rbQ6Pq/iSopxFOx5Uf0n3qUbWQk8II2SRyDPuCDUHMpSIiJQSBwDwKAgTxApnEbyIQ+APyn0+9A5B3AgfmoEWgcb3VlMpGFYjt+negSs7zxH/C3RWO9UElM8SAHG5fl/agNdXcEbJAZ1WadvDQDJO7Gf7c0ED1dqWv2enzw6Rb24nZfJd3EwREHqxyMZHzOKBbT7H8PZWTK5uZ9o3Xm1SzEry5PsT7UFF+JnUezSZ9LttRs2km2m5KSFWXDZI491AyBzVwK6J8T7CRtPjee0tbaGAtdNISdoXgLEo5JJxyfSmC6aF1fo2vELZXDJOxwkMybHYe4HtUFiJWJd8rKqjuTQcZV8SNI0dy43BlGVA+ZoBniE0RU7tp77Tg5zQUv4hNrU2tdNWOhylPEnaS5UHGYlAzn5cn74oHGt6l0z07k6nJC123HhKPFlbPptGTj9q0Kx0XMvU+ty6vqQtpWlZo4LOdGDWsak8Aflycgk+v2qC8a1q8OnaXLPOz2kCIWkZ+CqjgYx6n0xTBkmp9Sabp0KdRyI5vJkaGw08MVKIDw8jA557896QY1q2o3eqXr3N7O8skjnlnzgn5e1UMCGV/MOM0BJFOVwfX0oFtgZTjkg8UBtpOeO1B3hg85FBZXVMM+VJAA2+h96BO4IMJ/p7qvuKBKacmOKB5CYYx5UzgDPfHzoGwD5OApJHAHrQEAk8NWdNpx+XdkA0AIGhkGWOQcgg8UGw/DP4kmwhi07WCTZqAiSbstGc4+pFKNvs5o7q2Sa3kWaJxkOp4NZDOHUh/qL2k8LW78eG7kbZv+0+/yoEZp7fUpX/BXpgvYZTCSRtO7vtwe/vQdY6jeyatPp91FEPw8aSNMoYbi2cADt6Z70DS60KW7luJdV1JniJzBtURG2b0KN7+/vQKSWUWnLLqN3cSLP4ex5Y8jxiPykr23+nzzigpXUPVOu6Vqmmf8UWttb9OXDqkjRnfI3H849uRkDOKC0axLFr+nLB0rrUMM0bqCIGGGX1AH09qsGc9UfBiTV9Vhu9Pu5oPGLNeG6bczN7jHvVEr058Gre3sLeDVrmOdo3LmSFNjEH+XdntQXO51XQOl5YrCKGWa8SMYS3tzMyLjjJHb9alDqz1S5ktJ7nVdLmSVDiOONfEMiE4Xy+h9xUDm11CaTxEOn3VmpHFxKFCr9s5GPmKAus6jb9M6RJf3c88yxpjcxL7uM5OO3HrQVTSupoOuYdZMTSpptriNFtXKXDA/Pjhs9h2xQOJ7Xpnpa2S91WK2swqjbGw3ysfcnuxrQsGmapYvpwvra1FtDL52Mi+Gx49sZoMb+LXV0t+jWl3OYLGTO2zjx4h2nyszHsG4/Sgxt5ZJmEsjl3PB3GgSlyXBxkDnNADseB2PsaA8SoXQyFgmQCV70B5R/EIjYmPJxnvigEKcYDfrQF2/X9aCwqC7l2zwfT/FAJJ5747E5oGTqZArKOfccftQHZWwmOD23Z4NAEkTEBmwR7g5AoG7KSSE5HyFAMTyQsMHa/cEcEc5oL58P+v7rppdryPNAXx+GfsQe7Z9D2/Wg3zSdX0fqzT08F433eYwscOpHt9PcVkQPW632mX9vfWdrbXiRgrIdu2eHIwGD57+nIoKdc/ELVdC0u5afp27SUtta5vJMMzk+UDjzYHtQWDpj4gxXmif/wAitXZkGZzFGW8MehZO+PmM0Fibr/poWQmF6xXA2xmFg59sKRk0C2nQP1KFvdb0vwIUJNtDKcsVP8zD0Jx2oJDTNA0vR5p7qzs44pJOXkUc/SgNfa/pNvbF5L2JgTsCo2WJzjGKA1jcNcxOF/m/I0zbt4+gxgenNA5s7CCxWWYQxpNLgyMiY3nt2oHajcuexAoEL1C1uyFkVHO1ixHb17/KgwT4rdXWep6oul2OpywaTYqVLxDyySDjaM9x6Z+tWDPdB1TW7Wa9sumpGlursqMQRlpXwd3BA4571RcdN0i41G7h/wBSmNxqdkwn1O6u5/4cAXlYgcnngE/pQNvih8S211obHRyYbWInfJG/Ex9MD2+tBmNzcTXTtJcSSSSHH5jngDAH0oEdxbg5A9wKAzPwO+fegSLfLJoFoR5fUfegXOcHGAT8qAM+XaBzQCCwGDuyPlQWJpV37Q5TIweM7u/f9qA9vNYpFML2KaR8YiaJgAh55PvQRvnYoqA+MThcDnPai4PKWQlH3K6tggjnPaiEmz4ZznBPfFAVWG0AZDH1z2HzoE7lhv8AJIHI/mGRQI8AEeuOMGgndN6pu7V4RJLKY4WDLhypXj0oNL6d+MMS4ttetDdQgDNwAPEwPRh2NZGkabrvTXVZiexvba5aI+ILWZQG3Y4IDdvtQScvTdjK8chtFjkQ+VlYgqPXGKA17daV07apJrV9CsZbELTgbu3YY78UEHf9evJ4K9P6JqGoiR1XxjCUjAJ5OT3NBM9YdSWPTenwy3t7bWbSuBunUthfUhRyT+1BA2vXnS/jGdeo9LnIHljeLwSCe5zgmgejrOz1S3kGhazoaXYGAJ5Sw3e38uaCsJfX02rPD1XfXtvcCXdBJGjLbOO+EK88Y7nIoLB1H1Bb6WkN1ddSQ29io/5MZEjzt7DGTjj2FXNGUfEH4wRaxCtnp2kwGGM7llvBvIOO4XOAe/fNMwZbqusalfLBHfzSvFH+SIgKo+igYqiwWfWV30rpp03p6exJnUPJexQnxuR+Ulu2PkKCrT6jcSiTxZnbxCWcFidxPJJ96BBDlQ35fbFAbahBHJIGO+KAIwg5YnB455oDkKcbW7UAOowSMjOORQcCVXPp+9AqDkHcDmgMNpHPcUBTuzQWCJXcFvKR2Y0CMiqjnz4UcH/6oG8gKluwxyAfSjQ6ylEJBJfv37/OiYQMjbjkZXOSP/FEELAEkNn1waBCXdjORnPoc80CZeTb5wQe2BQAm4y7jlhjvQcWO3cW4GB7ZpgGC5a3uUeNyGQ5GCR+45pgt+l/EzqLTgxj1O5Zc4CSOXCj70wOE+Jd/Pq0V7qVvb3bISAWUBhnuc+/2pgvkHx0soLaNIdKkEiqR5yDg47cYpgresfELSNc1n8VrFtAw2ZBiiywwcgeb14x2xTBYNA13ozUo/GOqWVizDc1nf6crIh/7wOf1rOURvVupdE6ncpFeakiSWsZdbjSLfw1Zs+VVyMHA75xWsFDHU0idTJdf65rT28YKpPvHjKp9Bk49qYK/rGpXF/qU9zPdyzyyMSJJAAx9ifnVlwNZ7vxYEh8GAEHO8DDH5H5U0IPK8jHxSzFQAMnOKgJkFwPT6UBlAII5z3zQCjnA5OKBXeuAT9KABMA208DtxQHRhzgUC3KjJx9z2oAP6/L3NAHC8Hg/XNAcNtGe4oEy5yeaCdLk7yx2qQCAO1AmXZSSexHbPNAhJuLJkgjvzRonuAJy2cd8UCbyOi453Dj7GiYTZyVPPl74oYLJIyq68EH3Gf3oYTDEjLbiP1FEDHOUOdgOfXIBFAm77j5Mnng/WgLI5UE8Eg9iO9AnuJbuQx5wOBQFRxuIbOc54PrQK28ws76F722EyI4d4HJUOPb35yKBm8oeQsi4BPbPb71RyYIHmPGRg00GRsbsHIPY0Bg52AEEseBUCQJyOPXtQDtcdvvjtQCQ/GBwKAuXU4PrQBvZE5IGeO1AffjBJ57UBvEO045HagFWAAzktQKIzBeMg0C5kz5mOG/WgMrDJJ7jmgEnIyOccYoA3cEMRj05oC7/wDeBQTduzEoNxwcZGaAJOWfPNAlISVOT60aIQfkj+amgJ3bnnigKeFGPQUCf/x0Smw4V8exogX/AOY3+/SgKxKxeU459KAgJOckntQJkkcgkGgAAFFz/XQEmJaY7jnk96BM9yPQelAf/wCX7UBv/jagGP8AKB6ZoDf00HMfO/0oAH5TQA/5moECSMDPFAvGASMjPP8AigVX+b60BW7/AHoHEJJD55oDd4snv70CsSjCcDmgVAAbgYoGYJ3nk9qBUAYHAoP/2Q==</binary></FictionBook> \ No newline at end of file
diff --git a/tests/writer.haddock b/tests/writer.haddock
new file mode 100644
index 000000000..0772331e3
--- /dev/null
+++ b/tests/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/tests/writer.html b/tests/writer.html
index b0227e21b..d00b8ca66 100644
--- a/tests/writer.html
+++ b/tests/writer.html
@@ -324,7 +324,6 @@ These should not be escaped: \$ \\ \&gt; \[ \{</code></pre>
<div>
foo
</div>
-
<p>And nested without indentation:</p>
<div>
<div>
@@ -336,7 +335,6 @@ foo
bar
</div>
</div>
-
<p>Interpreted markdown in a table:</p>
<table>
<tr>
@@ -353,10 +351,8 @@ And this is <strong>strong</strong>
<p>Here’s a simple block:</p>
<div>
-
foo
</div>
-
<p>This should be a code block, though:</p>
<pre><code>&lt;div&gt;
foo
@@ -365,14 +361,12 @@ foo
<pre><code>&lt;div&gt;foo&lt;/div&gt;</code></pre>
<p>Now, nested:</p>
<div>
- <div>
- <div>
-
+<div>
+<div>
foo
</div>
- </div>
</div>
-
+</div>
<p>This should just be an HTML comment:</p>
<!-- Comment -->
@@ -445,7 +439,7 @@ Blah
<li><span class="math"><em>α</em> ∧ <em>ω</em></span></li>
<li><span class="math">223</span></li>
<li><span class="math"><em>p</em></span>-Tree</li>
-<li>Here’s some display math: <br /><span class="math">$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</span><br /></li>
+<li>Here’s some display math: <br /><span class="math">$$\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"><em>α</em> + <em>ω</em> × <em>x</em><sup>2</sup></span>.</li>
</ul>
<p>These shouldn’t be math:</p>
@@ -550,12 +544,12 @@ document.write('<a h'+'ref'+'="ma'+'ilto'+':'+e+'">'+e+'<\/'+'a'+'>');
<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,<sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup> and another.<sup><a href="#fn2" class="footnoteRef" id="fnref2">2</a></sup> This should <em>not</em> be a footnote reference, because it contains a space.[^my note] Here is an inline note.<sup><a href="#fn3" class="footnoteRef" id="fnref3">3</a></sup></p>
+<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.<sup><a href="#fn4" class="footnoteRef" id="fnref4">4</a></sup></p>
+<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.<sup><a href="#fn5" class="footnoteRef" id="fnref5">5</a></sup></li>
+<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">
diff --git a/tests/writer.icml b/tests/writer.icml
new file mode 100644
index 000000000..ef6ddcf64
--- /dev/null
+++ b/tests/writer.icml
@@ -0,0 +1,3023 @@
+<?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/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/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>
+ <ParagraphStyle Self="ParagraphStyle/Rawblock" Name="Rawblock" 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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Headers</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header3">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 3 with </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>emphasis</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header4">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 4</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header5">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 5</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 1</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 2 with </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>emphasis</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header3">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 3</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>with no blank line</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Level 2</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>with no blank line</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Paragraphs</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s a regular paragraph.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s one with a bullet. * criminey.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Block Quotes</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>E-mail style:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This is a block quote. It is pretty short.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Code in a block quote:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>sub status {
+ print &quot;working&quot;;
+}</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>A list:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>item one</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>item two</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Nested block quotes:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>nested</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Blockquote &gt; Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>nested</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This should not be a block quote: 2 &gt; 1.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>And a following paragraph.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Code Blocks</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Code:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>And:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Lists</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Unordered</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Asterisks tight:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>asterisk 1</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>asterisk 2</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>asterisk 3</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Asterisks loose:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>asterisk 1</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>asterisk 2</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>asterisk 3</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Pluses tight:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Plus 1</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Plus 2</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Plus 3</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Pluses loose:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Plus 1</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Plus 2</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Plus 3</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minuses tight:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minus 1</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minus 2</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minus 3</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minuses loose:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minus 1</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minus 2</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minus 3</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Ordered</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Tight:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>First</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Second</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Third</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>and:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>One</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Two</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Three</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Loose using tabs:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>First</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Second</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Third</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>and using spaces:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>One</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Two</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Three</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiple paragraphs:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Item 1, graf one.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Item 2.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Item 3.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Nested</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Tab</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Tab</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; BulList &gt; BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Tab</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s another:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>First</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Second:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Fee</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Fie</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Foe</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Third</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Same thing but with paragraphs:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first &gt; Paragraph" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>First</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Second:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Fee</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Fie</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Foe</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Third</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Tabs and spaces</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>this is a list item indented with spaces</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; BulList &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>this is an example list item indented with spaces</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Fancy list markers</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange NumberingStartAt="2" AppliedParagraphStyle="ParagraphStyle/NumList &gt; first &gt; beginsWith-2" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>begins with 2</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; beginsWith-2 &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>and now 3</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; NumList &gt; beginsWith-4 &gt; lowerRoman">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>more items</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; NumList &gt; NumList &gt; first &gt; upperAlpha" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>a subsublist</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; NumList &gt; NumList &gt; upperAlpha">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>a subsublist</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Nesting:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first &gt; upperAlpha" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Upper Alpha</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; NumList &gt; first &gt; upperRoman" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Upper Roman.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Autonumbering:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Autonumber.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>More.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/NumList &gt; NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Nested.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Should not be a list item:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>M.A. 2007</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>B. Williams</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Definition Lists</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Tight using spaces:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>apple</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>red fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>banana</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>yellow fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Tight using tabs:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>apple</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>red fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>banana</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>yellow fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Loose:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>apple</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>red fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>banana</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>yellow fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiple blocks with italics:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>apple</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>red fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>contains seeds, crisp, pleasant to taste</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>orange</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>{ orange code block }</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Blockquote &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange block quote</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiple definitions, tight:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>apple</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>red fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>computer</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>bank</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiple definitions, loose:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>apple</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>red fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>computer</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>bank</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Blank line after term, indented marker, alternate markers:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>apple</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>red fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>computer</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListTerm">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>orange fruit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; NumList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>sublist</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/DefListDef &gt; NumList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>sublist</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>HTML Blocks</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Simple block on one line:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>foo</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>And nested without indentation:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>foo</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>bar</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Interpreted markdown in a table:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;table&gt;
+&lt;tr&gt;
+&lt;td&gt;</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This is </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Italic">
+ <Content>emphasized</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;/td&gt;
+&lt;td&gt;</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>And this is </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold">
+ <Content>strong</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;/td&gt;
+&lt;/tr&gt;
+&lt;/table&gt;
+
+&lt;script type=&quot;text/javascript&quot;&gt;document.write('This *should not* be interpreted as markdown');&lt;/script&gt;
+ </Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s a simple block:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>foo</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This should be a code block, though:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;div&gt;
+ foo
+&lt;/div&gt;</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>As should this:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;div&gt;foo&lt;/div&gt;</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Now, nested:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>foo</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This should just be an HTML comment:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;!-- Comment --&gt;
+ </Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Multiline:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;!--
+Blah
+Blah
+--&gt;
+
+&lt;!--
+ This is another comment.
+--&gt;
+ </Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Code block:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;!-- Comment --&gt;</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Just plain comment, with trailing spaces on the line:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;!-- foo --&gt;
+ </Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Code:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;hr /&gt;</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Hr’s:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>&lt;hr&gt;
+
+&lt;hr /&gt;
+
+&lt;hr /&gt;
+
+&lt;hr&gt;
+
+&lt;hr /&gt;
+
+&lt;hr /&gt;
+
+&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;
+
+&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;
+
+&lt;hr class=&quot;foo&quot; id=&quot;bar&quot;&gt;
+ </Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Inline Markup</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold Italic">
+ <Content>This is strong and em.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Bold Italic">
+ <Content>This is strong and em.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Smart quotes, ellipses, dashes</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Some dashes: one—two — three—four — five.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Dashes between numbers: 5–7, 255–66, 1987–1999.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Ellipses…and…and….</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>LaTeX</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>\cite[22-23]{smith.1899}</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>2+2=4</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>x \in y</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>\alpha \wedge \omega</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>223</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>p</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>-Tree</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s one that has a line break in it: </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>\alpha + \omega \times x^2</Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>These shouldn’t be math:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Shoes ($20) and socks ($5).</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here’s a LaTeX table:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Rawblock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>\begin{tabular}{|l|l|}\hline
+Animal &amp; Number \\ \hline
+Dog &amp; 2 \\
+Cat &amp; 1 \\ \hline
+\end{tabular}</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Special Characters</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here is some unicode:</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>I hat: Î</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>o umlaut: ö</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>section: §</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>set membership: ∈</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>copyright: ©</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>AT&amp;T has an ampersand in their name.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>AT&amp;T is another way to write it.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This &amp; that.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>4 &lt; 5.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>6 &gt; 5.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Backslash: \</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Backtick: `</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Asterisk: *</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Underscore: _</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Left brace: {</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Right brace: }</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Left bracket: [</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Right bracket: ]</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Left paren: (</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Right paren: )</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Greater-than: &gt;</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Hash: #</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Period: .</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Bang: !</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Plus: +</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Minus: -</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Links</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Explicit</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <HyperlinkTextSource Self="htss-10" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>with_underscore</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <HyperlinkTextSource Self="htss-11" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>Email link</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Reference</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>This should [not][] be a link.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>[not]: /url</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>With ampersands</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header2">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Autolinks</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList &gt; first" NumberingContinue="false">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>In a list?</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <HyperlinkTextSource Self="htss-28" Name="" Hidden="false">
+ <CharacterStyleRange AppliedCharacterStyle="CharacterStyle/Link">
+ <Content>http://example.com/</Content>
+ </CharacterStyleRange>
+ </HyperlinkTextSource><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/BulList">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>It should.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>or here: &lt;http://example.com/&gt;</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Images</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Rectangle Self="uec" ItemTransform="1 0 0 1 75 -50">
+ <Properties>
+ <PathGeometry>
+ <GeometryPathType PathOpen="false">
+ <PathPointArray>
+ <PathPointType Anchor="-75 -50" LeftDirection="-75 -50" RightDirection="-75 -50" />
+ <PathPointType Anchor="-75 50" LeftDirection="-75 50" RightDirection="-75 50" />
+ <PathPointType Anchor="75 50" LeftDirection="75 50" RightDirection="75 50" />
+ <PathPointType Anchor="75 -50" LeftDirection="75 -50" RightDirection="75 -50" />
+ </PathPointArray>
+ </GeometryPathType>
+ </PathGeometry>
+ </Properties>
+ <Image Self="ue6" ItemTransform="1.0 0 0 1.0 -75 -50">
+ <Properties>
+ <Profile type="string">
+ $ID/Embedded
+ <GraphicBounds Left="0" Top="0" Right="150" Bottom="100" />
+ </Profile>
+ </Properties>
+ <Link Self="ueb" LinkResourceURI="lalune.jpg" />
+ </Image>
+ </Rectangle>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Here is a movie </Content>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Rectangle Self="uec" ItemTransform="1 0 0 1 75 -50">
+ <Properties>
+ <PathGeometry>
+ <GeometryPathType PathOpen="false">
+ <PathPointArray>
+ <PathPointType Anchor="-75 -50" LeftDirection="-75 -50" RightDirection="-75 -50" />
+ <PathPointType Anchor="-75 50" LeftDirection="-75 50" RightDirection="-75 50" />
+ <PathPointType Anchor="75 50" LeftDirection="75 50" RightDirection="75 50" />
+ <PathPointType Anchor="75 -50" LeftDirection="75 -50" RightDirection="75 -50" />
+ </PathPointArray>
+ </GeometryPathType>
+ </PathGeometry>
+ </Properties>
+ <Image Self="ue6" ItemTransform="1.0 0 0 1.0 -75 -50">
+ <Properties>
+ <Profile type="string">
+ $ID/Embedded
+ <GraphicBounds Left="0" Top="0" Right="150" Bottom="100" />
+ </Profile>
+ </Properties>
+ <Link Self="ueb" LinkResourceURI="movie.jpg" />
+ </Image>
+ </Rectangle>
+ </CharacterStyleRange>
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> icon.</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Header1">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content>Footnotes</Content>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+ </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><Br />
+ </ParagraphStyleRange>
+ <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><Br />
+ </ParagraphStyleRange>
+ <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Footnote &gt; CodeBlock">
+ <CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
+ <Content> { &lt;code&gt; }</Content>
+ </CharacterStyleRange><Br />
+ </ParagraphStyleRange>
+ <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><Br />
+ </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><Br />
+ </ParagraphStyleRange>
+ </Footnote>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+ </ParagraphStyleRange>
+ </Footnote>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+ </ParagraphStyleRange>
+ </Footnote>
+ </CharacterStyleRange><Br />
+</ParagraphStyleRange>
+<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><Br />
+</ParagraphStyleRange>
+
+ </Story>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/http://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://google.com</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/http://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://example.com/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/mailto:nobody@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:nobody@nowhere.net</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/http://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://example.com/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/http://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://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://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://att.com/</Destination>
+ </Properties>
+ </Hyperlink>
+ <HyperlinkURLDestination Self="HyperlinkURLDestination/http://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://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:nobody@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:nobody@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://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://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/tests/writer.latex b/tests/writer.latex
index 9431f43b1..1ac79feca 100644
--- a/tests/writer.latex
+++ b/tests/writer.latex
@@ -1,12 +1,10 @@
\documentclass[]{article}
-\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
-% use upquote if available, for straight quotes in verbatim environments
-\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
+ \usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\else % if luatex or xelatex
\ifxetex
@@ -18,28 +16,20 @@
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\newcommand{\euro}{€}
\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}}{}
\usepackage{fancyvrb}
\usepackage{graphicx}
-% Redefine \includegraphics so that, unless explicit options are
-% given, the image width will not exceed the width of the page.
-% Images get their normal width if they fit onto the page, but
-% are scaled down if they would overflow the margins.
\makeatletter
-\def\ScaleIfNeeded{%
- \ifdim\Gin@nat@width>\linewidth
- \linewidth
- \else
- \Gin@nat@width
- \fi
-}
+\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
-\let\Oldincludegraphics\includegraphics
-{%
- \catcode`\@=11\relax%
- \gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}}%
-}%
+% 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}
\ifxetex
\usepackage[setpagesize=false, % page size defined by xetex
unicode=false, % unicode breaks when used with xetex
diff --git a/tests/writer.man b/tests/writer.man
index 54baaf791..aab588f9c 100644
--- a/tests/writer.man
+++ b/tests/writer.man
@@ -572,7 +572,7 @@ Ellipses\&...and\&...and\&....
.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}$
+$$\\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:
diff --git a/tests/writer.markdown b/tests/writer.markdown
index 2201ac8d1..9cf153637 100644
--- a/tests/writer.markdown
+++ b/tests/writer.markdown
@@ -2,7 +2,7 @@
author:
- John MacFarlane
- Anonymous
-date: July 17, 2006
+date: 'July 17, 2006'
title: Pandoc Test Suite
...
@@ -356,20 +356,31 @@ 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:
@@ -390,8 +401,9 @@ And this is **strong**
Here’s a simple block:
<div>
-
+
foo
+
</div>
This should be a code block, though:
@@ -407,12 +419,17 @@ As should this:
Now, nested:
<div>
- <div>
- <div>
-
+
+<div>
+
+<div>
+
foo
+
</div>
- </div>
+
+</div>
+
</div>
This should just be an HTML comment:
diff --git a/tests/writer.mediawiki b/tests/writer.mediawiki
index 7eccc44e8..2f3726285 100644
--- a/tests/writer.mediawiki
+++ b/tests/writer.mediawiki
@@ -311,22 +311,30 @@ Blank line after term, indented marker, alternate markers:
Simple block on one line:
<div>
+
foo
-</div>
+</div>
And nested without indentation:
<div>
+
<div>
+
<div>
+
foo
+
</div>
+
</div>
<div>
+
bar
-</div>
+
</div>
+</div>
Interpreted markdown in a table:
<table>
@@ -345,10 +353,10 @@ And this is '''strong'''
Here’s a simple block:
<div>
-
+
foo
-</div>
+</div>
This should be a code block, though:
<pre>&lt;div&gt;
@@ -360,14 +368,18 @@ As should this:
Now, nested:
<div>
- <div>
- <div>
-
+
+<div>
+
+<div>
+
foo
+
</div>
- </div>
+
</div>
+</div>
This should just be an HTML comment:
<!-- Comment -->
diff --git a/tests/writer.native b/tests/writer.native
index d7f5f8864..678d7595f 100644
--- a/tests/writer.native
+++ b/tests/writer.native
@@ -228,45 +228,35 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
,[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:"]
-,RawBlock "html" "<div>"
-,Plain [Str "foo"]
-,RawBlock "html" "</div>\n"
+,Div ("",[],[]) [Plain [Str "foo"]]
,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"]
-,RawBlock "html" "<div>\n<div>\n<div>"
-,Plain [Str "foo"]
-,RawBlock "html" "</div>\n</div>\n<div>"
-,Plain [Str "bar"]
-,RawBlock "html" "</div>\n</div>\n"
+,Div ("",[],[]) [Div ("",[],[]) [Div ("",[],[]) [Plain [Str "foo"]]],Div ("",[],[]) [Plain [Str "bar"]]]
,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]
-,RawBlock "html" "<table>\n<tr>\n<td>"
+,RawBlock (Format "html") "<table>\n<tr>\n<td>"
,Plain [Str "This",Space,Str "is",Space,Emph [Str "emphasized"]]
-,RawBlock "html" "</td>\n<td>"
+,RawBlock (Format "html") "</td>\n<td>"
,Plain [Str "And",Space,Str "this",Space,Str "is",Space,Strong [Str "strong"]]
-,RawBlock "html" "</td>\n</tr>\n</table>\n\n<script type=\"text/javascript\">document.write('This *should not* be interpreted as markdown');</script>\n"
+,RawBlock (Format "html") "</td>\n</tr>\n</table>\n\n<script type=\"text/javascript\">document.write('This *should not* be interpreted as markdown');</script>\n"
,Para [Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block:"]
-,RawBlock "html" "<div>\n "
-,Plain [Str "foo"]
-,RawBlock "html" "</div>\n"
+,Div ("",[],[]) [Plain [Str "foo"]]
,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"]
,CodeBlock ("",[],[]) "<div>\n foo\n</div>"
,Para [Str "As",Space,Str "should",Space,Str "this:"]
,CodeBlock ("",[],[]) "<div>foo</div>"
,Para [Str "Now,",Space,Str "nested:"]
-,RawBlock "html" "<div>\n <div>\n <div>\n "
-,Plain [Str "foo"]
-,RawBlock "html" "</div>\n </div>\n</div>\n"
+,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 "html" "<!-- Comment -->\n"
+,RawBlock (Format "html") "<!-- Comment -->\n"
,Para [Str "Multiline:"]
-,RawBlock "html" "<!--\nBlah\nBlah\n-->\n\n<!--\n This is another comment.\n-->\n"
+,RawBlock (Format "html") "<!--\nBlah\nBlah\n-->\n\n<!--\n This is another comment.\n-->\n"
,Para [Str "Code",Space,Str "block:"]
,CodeBlock ("",[],[]) "<!-- Comment -->"
,Para [Str "Just",Space,Str "plain",Space,Str "comment,",Space,Str "with",Space,Str "trailing",Space,Str "spaces",Space,Str "on",Space,Str "the",Space,Str "line:"]
-,RawBlock "html" "<!-- foo --> \n"
+,RawBlock (Format "html") "<!-- foo --> \n"
,Para [Str "Code:"]
,CodeBlock ("",[],[]) "<hr />"
,Para [Str "Hr\8217s:"]
-,RawBlock "html" "<hr>\n\n<hr />\n\n<hr />\n\n<hr> \n\n<hr /> \n\n<hr /> \n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\">\n"
+,RawBlock (Format "html") "<hr>\n\n<hr />\n\n<hr />\n\n<hr> \n\n<hr /> \n\n<hr /> \n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\" />\n\n<hr class=\"foo\" id=\"bar\">\n"
,HorizontalRule
,Header 1 ("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 "."]
@@ -294,7 +284,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
,HorizontalRule
,Header 1 ("latex",[],[]) [Str "LaTeX"]
,BulletList
- [[Plain [RawInline "tex" "\\cite[22-23]{smith.1899}"]]
+ [[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"]]
@@ -309,7 +299,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
,[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 "latex" "\\begin{tabular}{|l|l|}\\hline\nAnimal & Number \\\\ \\hline\nDog & 2 \\\\\nCat & 1 \\\\ \\hline\n\\end{tabular}"
+,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:"]
diff --git a/tests/writer.opendocument b/tests/writer.opendocument
index 8727373a0..81c793a62 100644
--- a/tests/writer.opendocument
+++ b/tests/writer.opendocument
@@ -1,5 +1,8 @@
<?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.0">
+<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=".">
@@ -665,37 +668,47 @@
<style:style style:name="T35" 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="T36" 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="T37" 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="T38" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
- <style:style style:name="T39" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
- <style:style style:name="T40" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
- <style:style style:name="T41" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
- <style:style style:name="T42" 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="T38" 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="T39" 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="T40" 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="T41" 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="T42" 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="T43" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
- <style:style style:name="T44" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>
- <style:style style:name="T45" 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="T46" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>
- <style:style style:name="T47" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>
- <style:style style:name="T48" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>
- <style:style style:name="T49" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>
- <style:style style:name="T50" 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="T51" 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="T52" 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="T53" 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="T54" 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="T55" 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="T44" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
+ <style:style style:name="T45" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
+ <style:style style:name="T46" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
+ <style:style style:name="T47" 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="T48" style:family="text"><style:text-properties style:text-line-through-style="solid" /></style:style>
+ <style:style style:name="T49" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>
+ <style:style style:name="T50" 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="T51" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>
+ <style:style style:name="T52" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>
+ <style:style style:name="T53" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>
+ <style:style style:name="T54" style:family="text"><style:text-properties style:text-position="sub 58%" /></style:style>
+ <style:style style:name="T55" 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="T56" 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="T57" 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="T58" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>
+ <style:style style:name="T58" 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="T59" 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="T60" 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="T61" 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="T62" 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="T63" 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="T64" 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="T65" 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="T64" style:family="text"><style:text-properties style:text-position="super 58%" /></style:style>
+ <style:style style:name="T65" 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="T66" 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="T67" 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="T67" 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="T68" 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="T69" 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="T70" 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="T71" 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="T72" 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="T73" 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="T74" 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="T75" 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="T76" 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="T77" 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="T78" 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="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>
@@ -741,25 +754,25 @@
<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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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>
@@ -768,37 +781,37 @@
<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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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" />
@@ -822,18 +835,18 @@
<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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <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" />
@@ -846,7 +859,7 @@
<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-left="0.0in" fo:margin-right="0in" fo:text-indent="0in" style:auto-text-indent="false" fo:margin-top="0in" fo:margin-bottom="0in" />
+ <style:paragraph-properties fo:margin-top="0in" fo:margin-bottom="0in" />
</style:style>
</office:automatic-styles>
<office:body>
@@ -1345,22 +1358,22 @@ Markup</text:h>
<text:p text:style-name="Text_20_body">So is
<text:span text:style-name="T37">this</text:span> word.</text:p>
<text:p text:style-name="Text_20_body">This is code:
-<text:span text:style-name="Teletype">&gt;</text:span>,
-<text:span text:style-name="Teletype">$</text:span>,
-<text:span text:style-name="Teletype">\</text:span>,
-<text:span text:style-name="Teletype">\$</text:span>,
-<text:span text:style-name="Teletype">&lt;html&gt;</text:span>.</text:p>
-<text:p text:style-name="Text_20_body"><text:span text:style-name="T38">This</text:span><text:span text:style-name="T39">
-</text:span><text:span text:style-name="T40">is</text:span><text:span text:style-name="T41">
-</text:span><text:span text:style-name="T42">strikeout</text:span><text:span text:style-name="T43">.</text:span></text:p>
+<text:span text:style-name="T38">&gt;</text:span>,
+<text:span text:style-name="T39">$</text:span>,
+<text:span text:style-name="T40">\</text:span>,
+<text:span text:style-name="T41">\$</text:span>,
+<text:span text:style-name="T42">&lt;html&gt;</text:span>.</text:p>
+<text:p text:style-name="Text_20_body"><text:span text:style-name="T43">This</text:span><text:span text:style-name="T44">
+</text:span><text:span text:style-name="T45">is</text:span><text:span text:style-name="T46">
+</text:span><text:span text:style-name="T47">strikeout</text:span><text:span text:style-name="T48">.</text:span></text:p>
<text:p text:style-name="Text_20_body">Superscripts:
-a<text:span text:style-name="T44">bc</text:span>d
-a<text:span text:style-name="T45">hello</text:span>
-a<text:span text:style-name="T46">hello there</text:span>.</text:p>
+a<text:span text:style-name="T49">bc</text:span>d
+a<text:span text:style-name="T50">hello</text:span>
+a<text:span text:style-name="T51">hello there</text:span>.</text:p>
<text:p text:style-name="Text_20_body">Subscripts:
-H<text:span text:style-name="T47">2</text:span>O,
-H<text:span text:style-name="T48">23</text:span>O,
-H<text:span text:style-name="T49">many of them</text:span>O.</text:p>
+H<text:span text:style-name="T52">2</text:span>O,
+H<text:span text:style-name="T53">23</text:span>O,
+H<text:span text:style-name="T54">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" />
@@ -1374,7 +1387,7 @@ 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="Teletype">code</text:span>’ and a
+‘<text:span text:style-name="T55">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 —
@@ -1392,35 +1405,35 @@ five.</text:p>
<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="T50">x</text:span> ∈ <text:span text:style-name="T51">y</text:span></text:p>
+ <text:p text:style-name="P51"><text:span text:style-name="T56">x</text:span> ∈ <text:span text:style-name="T57">y</text:span></text:p>
</text:list-item>
<text:list-item>
- <text:p text:style-name="P51"><text:span text:style-name="T52">α</text:span> ∧ <text:span text:style-name="T53">ω</text:span></text:p>
+ <text:p text:style-name="P51"><text:span text:style-name="T58">α</text:span> ∧ <text:span text:style-name="T59">ω</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="T54">p</text:span>-Tree</text:p>
+ <text:p text:style-name="P51"><text:span text:style-name="T60">p</text:span>-Tree</text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="P51">Here’s some display math:
- $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</text:p>
+ $$\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="T55">α</text:span> + <text:span text:style-name="T56">ω</text:span> × <text:span text:style-name="T57">x</text:span><text:span text:style-name="T58">2</text:span>.</text:p>
+ <text:span text:style-name="T61">α</text:span> + <text:span text:style-name="T62">ω</text:span> × <text:span text:style-name="T63">x</text:span><text:span text:style-name="T64">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="Teletype">$e = mc^2$</text:span>.</text:p>
+ <text:span text:style-name="T65">$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="T59">lot</text:span> of money. So is $34,000.
+ <text:span text:style-name="T66">lot</text:span> of money. So is $34,000.
(It worked if “lot” is emphasized.)</text:p>
</text:list-item>
<text:list-item>
@@ -1428,11 +1441,11 @@ five.</text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="P52">Escaped
- <text:span text:style-name="Teletype">$</text:span>: $73
- <text:span text:style-name="T60">this</text:span><text:span text:style-name="T61">
- </text:span><text:span text:style-name="T62">should</text:span><text:span text:style-name="T63">
- </text:span><text:span text:style-name="T64">be</text:span><text:span text:style-name="T65">
- </text:span><text:span text:style-name="T66">emphasized</text:span>
+ <text:span text:style-name="T67">$</text:span>: $73
+ <text:span text:style-name="T68">this</text:span><text:span text:style-name="T69">
+ </text:span><text:span text:style-name="T70">should</text:span><text:span text:style-name="T71">
+ </text:span><text:span text:style-name="T72">be</text:span><text:span text:style-name="T73">
+ </text:span><text:span text:style-name="T74">emphasized</text:span>
23$.</text:p>
</text:list-item>
</text:list>
@@ -1557,15 +1570,15 @@ link in pointy braces</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="Teletype">&lt;http://example.com/&gt;</text:span></text:p>
+<text:span text:style-name="T75">&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="Text_20_body"><draw:frame><draw:image xlink:href="lalune.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame></text:p>
+<text:p text:style-name="Text_20_body"><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="Text_20_body">Here is a movie
-<draw:frame><draw:image xlink:href="movie.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame>
+<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>
@@ -1581,14 +1594,14 @@ 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="T67">not</text:span> be a footnote
+should <text:span text:style-name="T76">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="T68">easier</text:span> to type. Inline notes
+is <text:span text:style-name="T77">easier</text:span> to type. Inline notes
may contain
<text:a xlink:type="simple" xlink:href="http://google.com" office:name=""><text:span text:style-name="Definition">links</text:span></text:a>
-and <text:span text:style-name="Teletype">]</text:span> verbatim characters,
-as well as [bracketed text].</text:p></text:note-body></text:note></text:p>
+and <text:span text:style-name="T78">]</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>
diff --git a/tests/writer.opml b/tests/writer.opml
index b0954a439..34d161fb8 100644
--- a/tests/writer.opml
+++ b/tests/writer.opml
@@ -18,7 +18,7 @@
</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 text="Level 3" _note="with no blank line&#10;">
</outline>
</outline>
<outline text="Level 2" _note="with no blank line&#10;&#10;* * * * *">
@@ -44,7 +44,7 @@
</outline>
<outline text="Definition Lists" _note="Tight using spaces:&#10;&#10;apple&#10;: red fruit&#10;orange&#10;: orange fruit&#10;banana&#10;: yellow fruit&#10;&#10;Tight using tabs:&#10;&#10;apple&#10;: red fruit&#10;orange&#10;: orange fruit&#10;banana&#10;: yellow fruit&#10;&#10;Loose:&#10;&#10;apple&#10;: red fruit&#10;&#10;orange&#10;: orange fruit&#10;&#10;banana&#10;: yellow fruit&#10;&#10;Multiple blocks with italics:&#10;&#10;*apple*&#10;: red fruit&#10;&#10; contains seeds, crisp, pleasant to taste&#10;&#10;*orange*&#10;: orange fruit&#10;&#10; { orange code block }&#10;&#10; &gt; orange block quote&#10;&#10;Multiple definitions, tight:&#10;&#10;apple&#10;: red fruit&#10;: computer&#10;orange&#10;: orange fruit&#10;: bank&#10;&#10;Multiple definitions, loose:&#10;&#10;apple&#10;: red fruit&#10;&#10;: computer&#10;&#10;orange&#10;: orange fruit&#10;&#10;: bank&#10;&#10;Blank line after term, indented marker, alternate markers:&#10;&#10;apple&#10;: red fruit&#10;&#10;: computer&#10;&#10;orange&#10;: orange fruit&#10;&#10; 1. sublist&#10; 2. sublist&#10;&#10;">
</outline>
-<outline text="HTML Blocks" _note="Simple block on one line:&#10;&#10;&lt;div&gt;&#10;foo&#10;&lt;/div&gt;&#10;&#10;And nested without indentation:&#10;&#10;&lt;div&gt;&#10;&lt;div&gt;&#10;&lt;div&gt;&#10;foo&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div&gt;&#10;bar&#10;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&#10;Interpreted markdown in a table:&#10;&#10;&lt;table&gt;&#10;&lt;tr&gt;&#10;&lt;td&gt;&#10;This is *emphasized*&#10;&lt;/td&gt;&#10;&lt;td&gt;&#10;And this is **strong**&#10;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/table&gt;&#10;&#10;&lt;script type=&quot;text/javascript&quot;&gt;document.write('This *should not* be interpreted as markdown');&lt;/script&gt;&#10;&#10;Here’s a simple block:&#10;&#10;&lt;div&gt;&#10; &#10;foo&#10;&lt;/div&gt;&#10;&#10;This should be a code block, though:&#10;&#10; &lt;div&gt;&#10; foo&#10; &lt;/div&gt;&#10;&#10;As should this:&#10;&#10; &lt;div&gt;foo&lt;/div&gt;&#10;&#10;Now, nested:&#10;&#10;&lt;div&gt;&#10; &lt;div&gt;&#10; &lt;div&gt;&#10; &#10;foo&#10;&lt;/div&gt;&#10; &lt;/div&gt;&#10;&lt;/div&gt;&#10;&#10;This should just be an HTML comment:&#10;&#10;&lt;!-- Comment --&gt;&#10;&#10;Multiline:&#10;&#10;&lt;!--&#10;Blah&#10;Blah&#10;--&gt;&#10;&#10;&lt;!--&#10; This is another comment.&#10;--&gt;&#10;&#10;Code block:&#10;&#10; &lt;!-- Comment --&gt;&#10;&#10;Just plain comment, with trailing spaces on the line:&#10;&#10;&lt;!-- foo --&gt; &#10;&#10;Code:&#10;&#10; &lt;hr /&gt;&#10;&#10;Hr’s:&#10;&#10;&lt;hr&gt;&#10;&#10;&lt;hr /&gt;&#10;&#10;&lt;hr /&gt;&#10;&#10;&lt;hr&gt; &#10;&#10;&lt;hr /&gt; &#10;&#10;&lt;hr /&gt; &#10;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;&#10;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;&#10;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot;&gt;&#10;&#10;* * * * *">
+<outline text="HTML Blocks" _note="Simple block on one line:&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;And nested without indentation:&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;bar&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;Interpreted markdown in a table:&#10;&#10;&lt;table&gt;&#10;&lt;tr&gt;&#10;&lt;td&gt;&#10;This is *emphasized*&#10;&lt;/td&gt;&#10;&lt;td&gt;&#10;And this is **strong**&#10;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/table&gt;&#10;&#10;&lt;script type=&quot;text/javascript&quot;&gt;document.write('This *should not* be interpreted as markdown');&lt;/script&gt;&#10;&#10;Here’s a simple block:&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;This should be a code block, though:&#10;&#10; &lt;div&gt;&#10; foo&#10; &lt;/div&gt;&#10;&#10;As should this:&#10;&#10; &lt;div&gt;foo&lt;/div&gt;&#10;&#10;Now, nested:&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;This should just be an HTML comment:&#10;&#10;&lt;!-- Comment --&gt;&#10;&#10;Multiline:&#10;&#10;&lt;!--&#10;Blah&#10;Blah&#10;--&gt;&#10;&#10;&lt;!--&#10; This is another comment.&#10;--&gt;&#10;&#10;Code block:&#10;&#10; &lt;!-- Comment --&gt;&#10;&#10;Just plain comment, with trailing spaces on the line:&#10;&#10;&lt;!-- foo --&gt; &#10;&#10;Code:&#10;&#10; &lt;hr /&gt;&#10;&#10;Hr’s:&#10;&#10;&lt;hr&gt;&#10;&#10;&lt;hr /&gt;&#10;&#10;&lt;hr /&gt;&#10;&#10;&lt;hr&gt; &#10;&#10;&lt;hr /&gt; &#10;&#10;&lt;hr /&gt; &#10;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;&#10;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;&#10;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot;&gt;&#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: a^bc^d a^*hello*^ a^hello there^.&#10;&#10;Subscripts: H~2~O, H~23~O, H~many of them~O.&#10;&#10;These should not be superscripts or subscripts, because of the unescaped&#10;spaces: a\^b c\^d, a\~b c\~d.&#10;&#10;* * * * *">
</outline>
@@ -55,18 +55,18 @@
<outline text="Special Characters" _note="Here is some unicode:&#10;&#10;- I hat: Î&#10;- o umlaut: ö&#10;- section: §&#10;- set membership: ∈&#10;- copyright: ©&#10;&#10;AT&amp;T has an ampersand in their name.&#10;&#10;AT&amp;T is another way to write it.&#10;&#10;This &amp; that.&#10;&#10;4 \&lt; 5.&#10;&#10;6 \&gt; 5.&#10;&#10;Backslash: \\&#10;&#10;Backtick: \`&#10;&#10;Asterisk: \*&#10;&#10;Underscore: \_&#10;&#10;Left brace: {&#10;&#10;Right brace: }&#10;&#10;Left bracket: [&#10;&#10;Right bracket: ]&#10;&#10;Left paren: (&#10;&#10;Right paren: )&#10;&#10;Greater-than: \&gt;&#10;&#10;Hash: \#&#10;&#10;Period: .&#10;&#10;Bang: !&#10;&#10;Plus: +&#10;&#10;Minus: -&#10;&#10;* * * * *">
</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 text="Explicit" _note="Just a [URL](/url/).&#10;&#10;[URL and title](/url/ &quot;title&quot;).&#10;&#10;[URL and title](/url/ &quot;title preceded by two spaces&quot;).&#10;&#10;[URL and title](/url/ &quot;title preceded by a tab&quot;).&#10;&#10;[URL and title](/url/ &quot;title with &quot;quotes&quot; in it&quot;)&#10;&#10;[URL and title](/url/ &quot;title with single quotes&quot;)&#10;&#10;[with\_underscore](/url/with_underscore)&#10;&#10;[Email link](mailto:nobody@nowhere.net)&#10;&#10;[Empty]().&#10;">
</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 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;).&#10;">
</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 text="With ampersands" _note="Here’s a [link with an ampersand in the&#10;URL](http://example.com/?foo=1&amp;bar=2).&#10;&#10;Here’s a link with an amersand in the link text:&#10;[AT&amp;T](http://att.com/ &quot;AT&amp;T&quot;).&#10;&#10;Here’s an [inline link](/script?foo=1&amp;bar=2).&#10;&#10;Here’s an [inline link in pointy braces](/script?foo=1&amp;bar=2).&#10;">
</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&#10;a footnote reference, because it contains a space.[\^my note] Here is an&#10;inline note.[^3]&#10;&#10;&gt; Notes can go in quotes.[^4]&#10;&#10;1. And in list items.[^5]&#10;&#10;This paragraph should not be part of the note, as it is not indented.&#10;&#10;[^1]: Here is the footnote. It can go anywhere after the footnote&#10; reference. It need not be placed at the end of the document.&#10;&#10;[^2]: Here’s the long note. This one contains multiple blocks.&#10;&#10; Subsequent blocks are indented to show that they belong to the&#10; footnote (as with list items).&#10;&#10; { &lt;code&gt; }&#10;&#10; If you want, you can indent every line, but you can also be lazy and&#10; just indent the first line of each block.&#10;&#10;[^3]: This is *easier* to type. Inline notes may contain&#10; [links](http://google.com) and `]` verbatim characters, as well as&#10; [bracketed text].&#10;&#10;[^4]: In quote.&#10;&#10;[^5]: In list.">
+<outline text="Footnotes" _note="Here is a footnote reference,[^1] and another.[^2] This should *not* be&#10;a footnote reference, because it contains a space.[\^my note] Here is an&#10;inline note.[^3]&#10;&#10;&gt; Notes can go in quotes.[^4]&#10;&#10;1. And in list items.[^5]&#10;&#10;This paragraph should not be part of the note, as it is not indented.&#10;&#10;[^1]: Here is the footnote. It can go anywhere after the footnote&#10; reference. It need not be placed at the end of the document.&#10;&#10;[^2]: Here’s the long note. This one contains multiple blocks.&#10;&#10; Subsequent blocks are indented to show that they belong to the&#10; footnote (as with list items).&#10;&#10; { &lt;code&gt; }&#10;&#10; If you want, you can indent every line, but you can also be lazy and&#10; just indent the first line of each block.&#10;&#10;[^3]: This is *easier* to type. Inline notes may contain&#10; [links](http://google.com) and `]` verbatim characters, as well as&#10; [bracketed text].&#10;&#10;[^4]: In quote.&#10;&#10;[^5]: In list.&#10;">
</outline>
</body>
</opml>
diff --git a/tests/writer.org b/tests/writer.org
index b8058a406..524d49305 100644
--- a/tests/writer.org
+++ b/tests/writer.org
@@ -42,7 +42,7 @@ item.
Here's one with a bullet. * criminey.
-There should be a hard line break
+There should be a hard line break\\
here.
--------------
@@ -359,7 +359,13 @@ And nested without indentation:
#+BEGIN_HTML
<div>
+#+END_HTML
+
+#+BEGIN_HTML
<div>
+#+END_HTML
+
+#+BEGIN_HTML
<div>
#+END_HTML
@@ -367,7 +373,13 @@ foo
#+BEGIN_HTML
</div>
+#+END_HTML
+
+#+BEGIN_HTML
</div>
+#+END_HTML
+
+#+BEGIN_HTML
<div>
#+END_HTML
@@ -375,6 +387,9 @@ bar
#+BEGIN_HTML
</div>
+#+END_HTML
+
+#+BEGIN_HTML
</div>
#+END_HTML
@@ -407,7 +422,6 @@ Here's a simple block:
#+BEGIN_HTML
<div>
-
#+END_HTML
foo
@@ -434,16 +448,27 @@ Now, nested:
#+BEGIN_HTML
<div>
- <div>
- <div>
-
+#+END_HTML
+
+#+BEGIN_HTML
+ <div>
+#+END_HTML
+
+#+BEGIN_HTML
+ <div>
#+END_HTML
foo
#+BEGIN_HTML
</div>
- </div>
+#+END_HTML
+
+#+BEGIN_HTML
+ </div>
+#+END_HTML
+
+#+BEGIN_HTML
</div>
#+END_HTML
diff --git a/tests/writer.plain b/tests/writer.plain
index cc61916d2..60e7bb329 100644
--- a/tests/writer.plain
+++ b/tests/writer.plain
@@ -352,10 +352,13 @@ HTML Blocks
Simple block on one line:
foo
+
And nested without indentation:
foo
+
bar
+
Interpreted markdown in a table:
This is emphasized
@@ -363,6 +366,7 @@ And this is strong
Here’s a simple block:
foo
+
This should be a code block, though:
<div>
@@ -376,6 +380,7 @@ As should this:
Now, nested:
foo
+
This should just be an HTML comment:
Multiline:
diff --git a/tests/writer.rst b/tests/writer.rst
index 41da5bc73..68bc4a06c 100644
--- a/tests/writer.rst
+++ b/tests/writer.rst
@@ -394,7 +394,13 @@ And nested without indentation:
.. raw:: html
<div>
+
+.. raw:: html
+
<div>
+
+.. raw:: html
+
<div>
foo
@@ -402,7 +408,13 @@ foo
.. raw:: html
</div>
+
+.. raw:: html
+
</div>
+
+.. raw:: html
+
<div>
bar
@@ -410,6 +422,9 @@ bar
.. raw:: html
</div>
+
+.. raw:: html
+
</div>
Interpreted markdown in a table:
@@ -442,7 +457,6 @@ Here’s a simple block:
.. raw:: html
<div>
-
foo
@@ -469,16 +483,27 @@ Now, nested:
.. raw:: html
<div>
- <div>
- <div>
-
+
+.. raw:: html
+
+ <div>
+
+.. raw:: html
+
+ <div>
foo
.. raw:: html
</div>
- </div>
+
+.. raw:: html
+
+ </div>
+
+.. raw:: html
+
</div>
This should just be an HTML comment:
diff --git a/tests/writer.rtf b/tests/writer.rtf
index 42c13d8c7..954d95cc4 100644
--- a/tests/writer.rtf
+++ b/tests/writer.rtf
@@ -269,7 +269,7 @@ quoted link
{\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 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}
diff --git a/tests/writer.textile b/tests/writer.textile
index 31789a2b0..5042f79cb 100644
--- a/tests/writer.textile
+++ b/tests/writer.textile
@@ -352,20 +352,33 @@ 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:
@@ -386,8 +399,9 @@ And this is *strong*
Here's a simple block:
<div>
-
+
foo
+
</div>
This should be a code block, though:
@@ -405,12 +419,19 @@ bc. <div>foo</div>
Now, nested:
<div>
- <div>
- <div>
-
+
+<div>
+
+<div>
+
foo
+
+</div>
+
+
</div>
- </div>
+
+
</div>
This should just be an HTML comment:
diff --git a/windows/make-windows-installer.bat b/windows/make-windows-installer.bat
index 12d873b70..0bd05a0e3 100644
--- a/windows/make-windows-installer.bat
+++ b/windows/make-windows-installer.bat
@@ -1,18 +1,20 @@
@echo off
cd ..
-rem cabal update
-cabal-dev clean
-cabal-dev install --reinstall --force-reinstall --flags="embed_data_files" citeproc-hs
+cabal update
+cabal sandbox init
+cabal clean
+cabal install hsb2hs alex happy
if %errorlevel% neq 0 exit /b %errorlevel%
-cabal-dev install --reinstall --force-reinstall --flags="embed_data_files"
+cabal install -v1 --force --reinstall --flags="embed_data_files" . pandoc-citeproc
if %errorlevel% neq 0 exit /b %errorlevel%
-strip cabal-dev\bin\pandoc.exe
-cabal-dev\bin\pandoc.exe -s --template data\templates\default.html -S README -o README.html
+strip .\.cabal-sandbox\bin\pandoc.exe
+strip .\.cabal-sandbox\bin\pandoc-citeproc.exe
+.\.cabal-sandbox\bin\pandoc.exe -s --template data\templates\default.html -S README -o README.html
if %errorlevel% neq 0 exit /b %errorlevel%
-cabal-dev\bin\pandoc.exe -s --template data\templates\default.rtf COPYING -t rtf -S -o COPYING.rtf
+.\.cabal-sandbox\bin\pandoc.exe -s --template data\templates\default.rtf COPYING -t rtf -S -o COPYING.rtf
if %errorlevel% neq 0 exit /b %errorlevel%
copy COPYRIGHT COPYRIGHT.txt
-for /f "tokens=1-2 delims= " %%a in ('cabal-dev\bin\pandoc --version') do (
+for /f "tokens=1-2 delims= " %%a in ('.\.cabal-sandbox\bin\pandoc --version') do (
@set VERSION=%%b
goto :next
)
@@ -26,7 +28,7 @@ cd windows
echo Creating msi...
candle -dVERSION=%VERSION% pandoc.wxs
if %errorlevel% neq 0 exit /b %errorlevel%
-light -sw1076 -ext WixUIExtension -out pandoc-%VERSION%.msi pandoc.wixobj
+light -sw1076 -ext WixUIExtension -out pandoc-%VERSION%-windows.msi pandoc.wixobj
if %errorlevel% neq 0 exit /b %errorlevel%
echo Starting kSign: sign, then quit kSign to complete the build...
kSign
diff --git a/windows/pandoc.wxs b/windows/pandoc.wxs
index 85edd29a8..75c316772 100644
--- a/windows/pandoc.wxs
+++ b/windows/pandoc.wxs
@@ -44,13 +44,21 @@
Name="Version" Type="string" Value="[ProductVersion]" KeyPath="yes"/>
<RemoveFolder Id="APPLICATIONFOLDER" On="uninstall"/>
<File Id="pandocEXE" Name="pandoc.exe"
- Source="..\cabal-dev\bin\pandoc.exe" />
+ Source="..\.cabal-sandbox\bin\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="..\.cabal-sandbox\bin\pandoc-citeproc.exe" />
+ </Component>
+
<Component Id="UpdatePathUser"
Guid="C7B71304-09FC-421D-9EA2-AEFB7D61759D">
<Condition><![CDATA[ ALLUSERS="" OR (ALLUSERS=2 AND (NOT Privileged)) ]]></Condition>
@@ -102,6 +110,9 @@
<ComponentRef Id="Documentation" />
<ComponentRef Id="ApplicationShortcut" />
</Feature>
+ <Feature Id="Citation" Title="Citation Support" Description="Citation support.">
+ <ComponentRef Id="CitationSupport" />
+ </Feature>
</Feature>
<Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONFOLDER" />