diff --git a/AUTHORS.md b/AUTHORS.md
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -51,6 +51,7 @@
 - Eric Seidel
 - Felix Yan
 - Florian Eitel
+- Francesco Occhipinti
 - François Gannaz
 - Freiric Barral
 - Freirich Raabe
@@ -129,6 +130,7 @@
 - Nick Bart
 - Nicolas Kaiser
 - Nikolay Yakimov
+- Nokome Bentley
 - Oliver Matthews
 - Ophir Lifshitz
 - Or Neeman
diff --git a/INSTALL.md b/INSTALL.md
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -125,7 +125,7 @@
 2.  Change to the pandoc source directory and issue the following commands:
 
         stack setup
-        stack install --test
+        stack install
 
     `stack setup` will automatically download the ghc compiler
     if you don't have it.  `stack install` will install the
@@ -145,7 +145,7 @@
 
 3.  Use `cabal` to install pandoc and its dependencies:
 
-        cabal install pandoc --enable-tests
+        cabal install pandoc
 
     This procedure will install the released version of pandoc,
     which will be downloaded automatically from HackageDB.
@@ -272,6 +272,7 @@
 To run particular tests (pattern-matching on their names), use
 the `-p` option:
 
+    cabal install pandoc --enable-tests
     cabal test --test-options='-p markdown'
 
 Or with stack:
diff --git a/MANUAL.txt b/MANUAL.txt
--- a/MANUAL.txt
+++ b/MANUAL.txt
@@ -1,6 +1,6 @@
 % Pandoc User's Guide
 % John MacFarlane
-% March 2, 2018
+% March 17, 2018
 
 Synopsis
 ========
@@ -1624,12 +1624,22 @@
 `lof`, `lot`
 :   include list of figures, list of tables
 
+`pdfa`
+:   adds to the preamble the setup necessary to generate PDF/A-1b:2005.
+    To successfully generate PDF/A the required ICC color profiles have to
+    be available and the content and all included files (such as images)
+    have to be standard conforming.  The ICC profiles can be obtained
+    from [ConTeXt ICC Profiles].  See also [ConTeXt PDFA] for more
+    details.
+
 [ConTeXt Paper Setup]: http://wiki.contextgarden.net/PaperSetup
 [ConTeXt Layout]: http://wiki.contextgarden.net/Layout
 [ConTeXt Font Switching]: http://wiki.contextgarden.net/Font_Switching
 [ConTeXt Color]: http://wiki.contextgarden.net/Color
 [ConTeXt Headers and Footers]: http://wiki.contextgarden.net/Headers_and_Footers
 [ConTeXt Indentation]: http://wiki.contextgarden.net/Indentation
+[ConTeXt ICC Profiles]: http://wiki.contextgarden.net/PDFX#ICC_profiles
+[ConTeXt PDFA]: http://wiki.contextgarden.net/PDF/A
 [`setupwhitespace`]: http://wiki.contextgarden.net/Command/setupwhitespace
 [`setupinterlinespace`]: http://wiki.contextgarden.net/Command/setupinterlinespace
 [`setuppagenumbering`]: http://wiki.contextgarden.net/Command/setuppagenumbering
@@ -4383,6 +4393,50 @@
 the [Beamer User's Guide] may also be used: `allowdisplaybreaks`,
 `allowframebreaks`, `b`, `c`, `t`, `environment`, `label`, `plain`,
 `shrink`.
+
+Background in reveal.js
+-----------------------
+
+Background images can be added to self-contained reveal.js slideshows.
+
+For the same image on every slide, use the reveal.js configuration
+option `parallaxBackgroundImage` either in the YAML metadata block
+or as a command-line variable. You can also set
+`parallaxBackgroundHorizontal` and `parallaxBackgroundVertical` the same
+way and must also set `parallaxBackgroundSize` to have your values
+take effect.
+
+To set an image for a particular slide, add
+`{data-background-image="/path/to/image"}`
+to the first slide-level header on the slide (which may even be empty).
+
+In reveal.js's overview mode, the parallaxBackgroundImage will show up
+only on the first slide.
+
+Other background settings also work on individual slides, including
+`data-background-size`, `data-background-repeat`, `data-background-color`,
+`data-transition`, and `data-transition-speed`.
+
+See the [reveal.js
+documentation](https://github.com/hakimel/reveal.js#slide-backgrounds)
+for more details.
+
+For example:
+
+```
+---
+title: My Slideshow
+parallaxBackgroundImage: /path/to/my/background_image.png
+---
+
+## Slide One
+
+Slide 1 has background_image.png as its background.
+
+## {data-background-image="/path/to/special_image.jpg"}
+
+Slide 2 has a special image for its background, even though the header has no content.
+```
 
 Creating EPUBs with pandoc
 ==========================
diff --git a/benchmark/benchmark-pandoc.hs b/benchmark/benchmark-pandoc.hs
--- a/benchmark/benchmark-pandoc.hs
+++ b/benchmark/benchmark-pandoc.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE TupleSections #-}
 {-
 Copyright (C) 2012-2018 John MacFarlane <jgm@berkeley.edu>
@@ -16,6 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 -}
+import Prelude
 import Text.Pandoc
 import qualified Text.Pandoc.UTF8 as UTF8
 import qualified Data.ByteString as B
diff --git a/benchmark/weigh-pandoc.hs b/benchmark/weigh-pandoc.hs
--- a/benchmark/weigh-pandoc.hs
+++ b/benchmark/weigh-pandoc.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+import Prelude
 import Weigh
 import Text.Pandoc
 import Data.Text (Text)
diff --git a/changelog b/changelog
--- a/changelog
+++ b/changelog
@@ -1,3 +1,150 @@
+pandoc (2.1.3)
+
+  * Docx reader (Jesse Rosenthal):
+
+    + Add tests for nested smart tags.
+    + Parse nested smart tags.
+    + Make unwrapSDT into a general `unwrap` function that can unwrap both
+      nested SDT tags and smartTags. This makes the SmartTags constructor in
+      the Docx type unnecessary, so we remove it (#4446).
+    + Remove unused `docxWarnings` (Alexander Krotov).
+
+  * RST reader: Allow unicode bullet characters (#4454).
+
+  * Haddock reader:  Better table handling, using haddock-library's
+    new table support, if compiled against a version that
+    includes it.  Note that tables with col/rowspans will not
+    translate well into Pandoc.
+
+  * Muse reader (Alexander Krotov):
+
+    + Various internal improvements.
+    + Require closing tag to have the same indentation as opening.
+    + Do not reparse blocks inside unclosed block tag (#4425).
+    + Parse `<class>` tag (supported by Emacs Muse).
+    + Do not produce empty Str element for unindented verse lines.
+
+  * LaTeX reader:
+
+    + Add support to parse unit string of `\SI` command (closes #4296,
+      Marc Schreiber).
+
+  * Haddock writer:  In the writer, we now render tables always as
+    grid tables, since Haddock supports these.
+
+  * DokuWiki writer: rewrite backSlashLineBreaks (#4445, Mauro Bieg).
+
+  * Docx writer: Fixed formatting of `DefaultStyle` ordered lists in
+    docx writer.  We want decimal for the top level, not lower roman.
+
+  * RST writer:
+
+    + Strip whitespace at beginning and ending of inline containers
+      (#4327, Francesco Occhipinti).
+    + Filter out empty inline containers (#4434).  There is nothing in
+      RST that corresponds to e.g. `Emph []`, so we just ignore elements
+      like this (Francesco Occhipinti).
+
+  * Muse writer (Alexander Krotov):
+
+    + Support spans with anchors.
+    + Replace smallcaps with emphasis before normalization.
+    + Output smallcaps as emphasis.
+    + Expand Cite before list normalization.
+    + Write empty inline lists as `<verbatim></verbatim>`.
+    + Remove empty Str from the beginning of inline lists during normalization.
+    + Escape "-" to avoid creating bullet lists.
+    + Fix math expansion for more than one expression per paragraph.
+    + Expand math before inline list normalization.
+
+  * Dokuwiki writer: fix LineBreaks in Tables (#4313, Mauro Bieg).
+
+  * Ms writer:
+
+    + Asciify pdf anchors, since unicode anchors don't work (#4436).
+      Internal links should be converted automatically, so this shouldn't
+      affect users directly.
+    + Don't escape hyphens as `\-`; that's for a minus sign (#4467).
+
+  * Beamer writer: put hyperlink after `\begin{frame}` and not in the title
+    (#4307).  If it's in the title, then we get a titlebar on slides with
+    the `plain` attribute, when the id is non-null.  This fixes a regression
+    in 2.0.
+
+  * EPUB writer: Remove notes from TOC in nav.xhtml (#4453, Mauro Bieg).
+
+  * JATS writer: Remove extraneous, significant whitespace (#4335,
+    Nokome Bentley).
+
+  * html2pdf: inject base tag wih current working directory (#4413, Mauro
+    Bieg).  This helps ensure that linked resources are included.
+
+  * Add Semigroup instances for everything for which we defined a
+    Monoid instance previously (API change):
+
+    + Text.Pandoc.Class.FileTree.
+    + Text.Pandoc.Translations.Translations.
+    + Text.Pandoc.Extensions.Extensions.
+    + Text.Pandoc.Readers.Odt.StyleReader.Styles.
+    + Text.Pandoc.Pretty.Doc.
+    + Text.Pandoc.MediaBag.MediaBag.
+
+  * Add custom Prelude to give clean code for Monoid and Semigroup
+    that works with ghc 7.10-8.4.  The custom Prelude (`prelude/Prelude`)
+    is used for ghc versions < 8.4.  `NoImplicitPrelude` is used
+    in all source files, and Prelude is explicitly imported
+    (this is necessary for ghci to work properly with the custom prelude).
+
+  * Text.Pandoc.Writers.Shared (Francesco Occhipinti):
+
+    + Export `stripLeadingTrailingSpace`.
+    + Don't wrap lines in grid tables when `--wrap=none` (#4320).
+    + `gridTable`: Don't wrap lines in tables when `--wrap=none`.  Instead,
+      expand cells, even if it results in cells that don't respect relative
+      widths or surpass page column width.  This change affects RST,
+      Markdown, and Haddock writers.
+
+  * Raise error if someone tries to print docx, odt, etc. template (#4441).
+
+  * LaTeX template: Provide `bidi` package's option using
+    `\PassOptionsToPackage`  (#4357, Václav Haisman).  This avoid a
+    clash when   `polyglossia` loads it first and then it is loaded again
+    for XeLaTeX.
+
+  * ConTeXt template: Added `pdfa` variable to generate PDF/A (#4294, Henri
+    Menke).  Instructions on how to install the ICC profiles on ConTeXt
+    standalone can be found in the wiki:
+    <http://wiki.contextgarden.net/PDFX#ICC_profiles>.
+    If the ICC profiles are not available the log will contain error
+    messages.
+
+  * Use latest pandoc-types, skylighting
+
+  * Use latest pandoc-citeproc in binary package.
+
+  * Bump upper bound for time, criterion, haddock-library, exceptions,
+    http-types, aeson, haddock-library.
+
+  * Bump upper bound tasty-quickcheck 0.10 (#4429, Felix Yan).
+
+  * pandoc.cabal:  fix up other-extensions and language fields.
+    Language is now consistently `Haskell2010`, and other-extensions
+    is consistently `NoImplicitPrelude`. Everything else to be specified
+    in the module header as needed.
+
+  * Removed `old-locale` flag and Text.Pandoc.Compat.Time.
+    This is no longer necessary since we no longer support ghc 7.8.
+
+  * Make `weigh-pandoc` into a benchmark program.
+    Remove `weigh-pandoc` flag.  `weigh-pandoc` is now built (and run)
+    automatically when you build (and run) benchmarks.
+
+  * MANUAL: add instructions for background images reveal.js (#4325, John
+    Muccigrosso).
+
+  * appveyor: use VS 2013 environment instead of VS 2015 for Windows builds.
+
+
 pandoc (2.1.2)
 
   * Markdown reader:
@@ -1571,7 +1718,7 @@
     directory.  However, the working directory must be explicitly
     specified if the `--resource-path` option is used.
 
-  * Added --abbreviations=FILE option for custom abbreviations file
+  * Added `--abbreviations=FILE` option for custom abbreviations file
     (#256).  Default abbreviations file (`data/abbreviations`) contains
     a list of strings that will be recognized by pandoc's
     Markdown parser as abbreviations.  (A nonbreaking space will
diff --git a/data/templates/default.context b/data/templates/default.context
--- a/data/templates/default.context
+++ b/data/templates/default.context
@@ -38,6 +38,13 @@
 $if(pagenumbering)$
 \setuppagenumbering[$for(pagenumbering)$$pagenumbering$$sep$,$endfor$]
 $endif$
+$if(pdfa)$
+% attempt to generate PDF/A
+\setupbackend
+  [format=PDF/A-1b:2005,
+   intent=sRGB IEC61966-2.1,
+   profile=sRGB.icc]
+$endif$
 
 % use microtypography
 \definefontfeature[default][default][script=latn, protrusion=quality, expansion=quality, itlc=yes, textitalics=yes, onum=yes, pnum=yes]
diff --git a/data/templates/default.latex b/data/templates/default.latex
--- a/data/templates/default.latex
+++ b/data/templates/default.latex
@@ -2,8 +2,9 @@
 \PassOptionsToPackage{hyphens}{url}
 $if(colorlinks)$
 \PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor}
-$endif$
-%
+$endif$$if(dir)$$if(latex-dir-rtl)$
+\PassOptionsToPackage{RTLdocument}{bidi}
+$endif$$endif$%
 \documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$babel-lang$,$endif$$if(papersize)$$papersize$paper,$endif$$if(beamer)$ignorenonframetext,$if(handout)$handout,$endif$$if(aspectratio)$aspectratio=$aspectratio$,$endif$$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
 $if(beamer)$
 \setbeamertemplate{caption}[numbered]
@@ -287,11 +288,7 @@
 $if(dir)$
 \ifxetex
   % load bidi as late as possible as it modifies e.g. graphicx
-  $if(latex-dir-rtl)$
-  \usepackage[RTLdocument]{bidi}
-  $else$
   \usepackage{bidi}
-  $endif$
 \fi
 \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
   \TeXXeTstate=1
diff --git a/man/pandoc.1 b/man/pandoc.1
--- a/man/pandoc.1
+++ b/man/pandoc.1
@@ -1,5 +1,5 @@
 .\"t
-.TH PANDOC 1 "March 2, 2018" "pandoc 2.1.2"
+.TH PANDOC 1 "March 17, 2018" "pandoc 2.1.3"
 .SH NAME
 pandoc - general markup converter
 .SH SYNOPSIS
@@ -1921,6 +1921,16 @@
 include list of figures, list of tables
 .RS
 .RE
+.TP
+.B \f[C]pdfa\f[]
+adds to the preamble the setup necessary to generate PDF/A\-1b:2005.
+To successfully generate PDF/A the required ICC color profiles have to
+be available and the content and all included files (such as images)
+have to be standard conforming.
+The ICC profiles can be obtained from ConTeXt ICC Profiles.
+See also ConTeXt PDFA for more details.
+.RS
+.RE
 .SS Variables for man pages
 .TP
 .B \f[C]section\f[]
@@ -5420,6 +5430,49 @@
 User\[aq]s Guide may also be used: \f[C]allowdisplaybreaks\f[],
 \f[C]allowframebreaks\f[], \f[C]b\f[], \f[C]c\f[], \f[C]t\f[],
 \f[C]environment\f[], \f[C]label\f[], \f[C]plain\f[], \f[C]shrink\f[].
+.SS Background in reveal.js
+.PP
+Background images can be added to self\-contained reveal.js slideshows.
+.PP
+For the same image on every slide, use the reveal.js configuration
+option \f[C]parallaxBackgroundImage\f[] either in the YAML metadata
+block or as a command\-line variable.
+You can also set \f[C]parallaxBackgroundHorizontal\f[] and
+\f[C]parallaxBackgroundVertical\f[] the same way and must also set
+\f[C]parallaxBackgroundSize\f[] to have your values take effect.
+.PP
+To set an image for a particular slide, add
+\f[C]{data\-background\-image="/path/to/image"}\f[] to the first
+slide\-level header on the slide (which may even be empty).
+.PP
+In reveal.js\[aq]s overview mode, the parallaxBackgroundImage will show
+up only on the first slide.
+.PP
+Other background settings also work on individual slides, including
+\f[C]data\-background\-size\f[], \f[C]data\-background\-repeat\f[],
+\f[C]data\-background\-color\f[], \f[C]data\-transition\f[], and
+\f[C]data\-transition\-speed\f[].
+.PP
+See the reveal.js documentation for more details.
+.PP
+For example:
+.IP
+.nf
+\f[C]
+\-\-\-
+title:\ My\ Slideshow
+parallaxBackgroundImage:\ /path/to/my/background_image.png
+\-\-\-
+
+##\ Slide\ One
+
+Slide\ 1\ has\ background_image.png\ as\ its\ background.
+
+##\ {data\-background\-image="/path/to/special_image.jpg"}
+
+Slide\ 2\ has\ a\ special\ image\ for\ its\ background,\ even\ though\ the\ header\ has\ no\ content.
+\f[]
+.fi
 .SH CREATING EPUBS WITH PANDOC
 .SS EPUB Metadata
 .PP
diff --git a/pandoc.cabal b/pandoc.cabal
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -1,17 +1,17 @@
 name:            pandoc
-version:         2.1.2
+version:         2.1.3
 cabal-version:   >= 1.10
 build-type:      Custom
-license:         GPL
+license:         GPL-2
 license-file:    COPYING.md
 copyright:       (c) 2006-2018 John MacFarlane
 author:          John MacFarlane <jgm@berkeley.edu>
 maintainer:      John MacFarlane <jgm@berkeley.edu>
 bug-reports:     https://github.com/jgm/pandoc/issues
 stability:       alpha
-homepage:        http://pandoc.org
+homepage:        https://pandoc.org
 category:        Text
-tested-with:     GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2
+tested-with:     GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.1
 synopsis:        Conversion between markup formats
 description:     Pandoc is a Haskell library for converting from one markup
                  format to another, and a command-line tool that uses
@@ -335,18 +335,10 @@
   Description:   Build trypandoc cgi executable.
   Default:       False
 
-flag weigh-pandoc
-  Description:   Build weigh-pandoc to measure memory usage.
-  Default:       False
-
 flag network-uri
   Description:   Get Network.URI from the network-uri package
   Default:       True
 
-flag old-locale
-  Description:   Use old-locale and time < 1.5
-  Default:       False
-
 custom-setup
   setup-depends: base, Cabal
 
@@ -357,12 +349,13 @@
                  unordered-containers >= 0.2 && < 0.3,
                  parsec >= 3.1 && < 3.2,
                  mtl >= 2.2 && < 2.3,
-                 exceptions >= 0.8 && < 0.10,
+                 exceptions >= 0.8 && < 0.11,
                  filepath >= 1.1 && < 1.5,
                  process >= 1.2.3 && < 1.7,
                  directory >= 1 && < 1.4,
                  bytestring >= 0.9 && < 0.11,
                  text >= 0.11 && < 1.3,
+                 time >= 1.5 && < 1.10,
                  safe >= 0.3 && < 0.4,
                  zip-archive >= 0.2.3.4 && < 0.4,
                  HTTP >= 4000.0.5 && < 4000.4,
@@ -370,13 +363,13 @@
                  xml >= 1.3.12 && < 1.4,
                  split >= 0.2 && < 0.3,
                  random >= 1 && < 1.2,
-                 pandoc-types >= 1.17.3 && < 1.18,
-                 aeson >= 0.7 && < 1.3,
+                 pandoc-types >= 1.17.4.2 && < 1.18,
+                 aeson >= 0.7 && < 1.4,
                  aeson-pretty >= 0.8.5 && < 0.9,
                  tagsoup >= 0.14.6 && < 0.15,
                  base64-bytestring >= 0.1 && < 1.1,
                  zlib >= 0.5 && < 0.7,
-                 skylighting >= 0.5.1 && < 0.7,
+                 skylighting >= 0.5.1 && < 0.8,
                  data-default >= 0.4 && < 0.8,
                  temporary >= 1.1 && < 1.3,
                  blaze-html >= 0.9 && < 0.10,
@@ -388,7 +381,7 @@
                  hslua-module-text >= 0.1.2 && < 0.2,
                  binary >= 0.5 && < 0.10,
                  SHA >= 1.6 && < 1.7,
-                 haddock-library >= 1.1 && < 1.5,
+                 haddock-library >= 1.1 && < 1.6,
                  deepseq >= 1.3 && < 1.5,
                  JuicyPixels >= 3.1.6.1 && < 3.3,
                  Glob >= 0.7 && < 0.10,
@@ -396,17 +389,18 @@
                  doctemplates >= 0.2.1 && < 0.3,
                  http-client >= 0.4.30 && < 0.6,
                  http-client-tls >= 0.2.4 && < 0.4,
-                 http-types >= 0.8 && < 0.12,
+                 http-types >= 0.8 && < 0.13,
                  case-insensitive >= 1.2 && < 1.3
+  if impl(ghc < 8.0)
+    build-depends: semigroups == 0.18.*
+  if impl(ghc < 8.4)
+     hs-source-dirs: prelude
+     other-modules:  Prelude
+     build-depends:  base-compat >= 0.9
   if os(windows)
     cpp-options:      -D_WINDOWS
   else
     build-depends:  unix >= 2.4 && < 2.8
-  if flag(old-locale)
-     build-depends: old-locale >= 1 && < 1.1,
-                    time >= 1.2 && < 1.5
-  else
-     build-depends: time >= 1.5 && < 1.9
   if flag(network-uri)
      build-depends: network-uri >= 2.6 && < 2.7, network >= 2.6
   else
@@ -418,11 +412,8 @@
   if os(windows)
     cpp-options:      -D_WINDOWS
   ghc-options:   -Wall -fno-warn-unused-do-bind
-  default-language: Haskell98
-  other-extensions:   PatternGuards, OverloadedStrings,
-                      ScopedTypeVariables, GeneralizedNewtypeDeriving,
-                      RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,
-                      FlexibleInstances
+  default-language: Haskell2010
+  other-extensions: NoImplicitPrelude
   hs-source-dirs:  src
 
   exposed-modules: Text.Pandoc,
@@ -553,21 +544,23 @@
                    Text.Pandoc.UUID,
                    Text.Pandoc.Translations,
                    Text.Pandoc.Slides,
-                   Text.Pandoc.Compat.Time,
                    Paths_pandoc
 
   buildable:       True
 
 executable pandoc
   build-depends: pandoc, base >= 4.7 && < 5
+  if impl(ghc < 8.0)
+    build-depends: semigroups == 0.18.*
+  if impl(ghc < 8.4)
+     hs-source-dirs: prelude
+     other-modules:  Prelude
+     build-depends:  base-compat >= 0.9
   ghc-options:   -rtsopts -with-rtsopts=-K16m -Wall -fno-warn-unused-do-bind -threaded
   if flag(static)
     ld-options:     -static
-  default-language: Haskell98
-  other-extensions: PatternGuards, OverloadedStrings,
-                    ScopedTypeVariables, GeneralizedNewtypeDeriving,
-                    RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,
-                    FlexibleInstances
+  default-language: Haskell2010
+  other-extensions: NoImplicitPrelude
   hs-source-dirs:  .
   main-is:         pandoc.hs
   buildable:       True
@@ -577,27 +570,38 @@
   main-is:         trypandoc.hs
   hs-source-dirs:  trypandoc
   default-language: Haskell2010
+  other-extensions: NoImplicitPrelude
   if flag(trypandoc)
     build-depends: base, aeson, pandoc,
                    text, wai-extra, wai >= 0.3, http-types
     buildable:     True
   else
     buildable:     False
+  if impl(ghc < 8.0)
+    build-depends: semigroups == 0.18.*
+  if impl(ghc < 8.4)
+     hs-source-dirs: prelude
+     other-modules:  Prelude
+     build-depends:  base-compat >= 0.9
 
-executable weigh-pandoc
+benchmark weigh-pandoc
+  type:            exitcode-stdio-1.0
   main-is:         weigh-pandoc.hs
   hs-source-dirs:  benchmark
-  if flag(weigh-pandoc)
-     build-depends:   pandoc,
-                      base >= 4.2 && < 5,
-                      text,
-                      weigh >= 0.0 && < 0.1,
-                      mtl >= 2.2 && < 2.3
-     buildable:       True
-  else
-    buildable:     False
+  build-depends:   pandoc,
+                   base >= 4.2 && < 5,
+                   text,
+                   weigh >= 0.0 && < 0.1,
+                   mtl >= 2.2 && < 2.3
+  if impl(ghc < 8.0)
+    build-depends: semigroups == 0.18.*
+  if impl(ghc < 8.4)
+     hs-source-dirs: prelude
+     other-modules:  Prelude
+     build-depends:  base-compat >= 0.9
   ghc-options:   -rtsopts -Wall -fno-warn-unused-do-bind
-  default-language: Haskell98
+  default-language: Haskell2010
+  other-extensions: NoImplicitPrelude
 
 test-suite test-pandoc
   type:           exitcode-stdio-1.0
@@ -605,11 +609,11 @@
   hs-source-dirs: test
   build-depends:  base >= 4.2 && < 5,
                   pandoc,
-                  pandoc-types >= 1.17.3 && < 1.18,
+                  pandoc-types >= 1.17.4.2 && < 1.18,
                   bytestring >= 0.9 && < 0.11,
                   base64-bytestring >= 0.1 && < 1.1,
                   text >= 0.11 && < 1.3,
-                  time >= 1.5 && < 1.9,
+                  time >= 1.5 && < 1.10,
                   directory >= 1 && < 1.4,
                   filepath >= 1.1 && < 1.5,
                   hslua >= 0.9.5 && < 0.9.6,
@@ -618,7 +622,7 @@
                   Diff >= 0.2 && < 0.4,
                   tasty >= 0.11 && < 1.1,
                   tasty-hunit >= 0.9 && < 0.11,
-                  tasty-quickcheck >= 0.8 && < 0.10,
+                  tasty-quickcheck >= 0.8 && < 0.11,
                   tasty-golden >= 2.3 && < 2.4,
                   QuickCheck >= 2.4 && < 2.12,
                   containers >= 0.4.2.1 && < 0.6,
@@ -626,11 +630,12 @@
                   zip-archive >= 0.2.3.4 && < 0.4,
                   xml >= 1.3.12 && < 1.4,
                   Glob >= 0.7 && < 0.10
-  if flag(old-locale)
-     build-depends: old-locale >= 1 && < 1.1,
-                    time >= 1.2 && < 1.5
-  else
-     build-depends: time >= 1.5 && < 1.9
+  if impl(ghc < 8.0)
+    build-depends: semigroups == 0.18.*
+  if impl(ghc < 8.4)
+     hs-source-dirs: prelude
+     other-modules:  Prelude
+     build-depends:  base-compat >= 0.9
   other-modules:  Tests.Old
                   Tests.Command
                   Tests.Helpers
@@ -679,7 +684,8 @@
                   Tests.Writers.Powerpoint
                   Tests.Writers.OOXML
   ghc-options:  -rtsopts -Wall -fno-warn-unused-do-bind -threaded
-  default-language: Haskell98
+  default-language: Haskell2010
+  other-extensions: NoImplicitPrelude
 
 benchmark benchmark-pandoc
   type:            exitcode-stdio-1.0
@@ -689,6 +695,13 @@
                    time, bytestring, containers,
                    base >= 4.2 && < 5,
                    text >= 0.11 && < 1.3,
-                   criterion >= 1.0 && < 1.4
+                   criterion >= 1.0 && < 1.5
+  if impl(ghc < 8.0)
+    build-depends: semigroups == 0.18.*
+  if impl(ghc < 8.4)
+     hs-source-dirs: prelude
+     other-modules:  Prelude
+     build-depends:  base-compat >= 0.9
   ghc-options:   -rtsopts -Wall -fno-warn-unused-do-bind
-  default-language: Haskell98
+  default-language: Haskell2010
+  other-extensions: NoImplicitPrelude
diff --git a/pandoc.hs b/pandoc.hs
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -29,6 +30,7 @@
 writers.
 -}
 module Main where
+import Prelude
 import qualified Control.Exception as E
 import Text.Pandoc.App (convertWithOpts, defaultOpts, options, parseOptions)
 import Text.Pandoc.Error (handleError)
diff --git a/prelude/Prelude.hs b/prelude/Prelude.hs
new file mode 100644
--- /dev/null
+++ b/prelude/Prelude.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE PackageImports #-}
+{-# LANGUAGE CPP #-}
+
+-- The intent is that this Prelude provide the API of
+-- the base 4.11 Prelude in a way that is portable for
+-- all base versions.
+
+module Prelude
+(
+  module Prelude.Compat
+, Semigroup(..)
+)
+where
+
+import Prelude.Compat
+import Data.Semigroup (Semigroup(..))  -- includes (<>)
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE CPP                 #-}
 {-# LANGUAGE DeriveGeneric       #-}
 {-# LANGUAGE ScopedTypeVariables #-}
@@ -42,6 +43,7 @@
           , options
           , applyFilters
           ) where
+import Prelude
 import qualified Control.Exception as E
 import Control.Monad
 import Control.Monad.Except (catchError, throwError)
@@ -54,7 +56,6 @@
 import Data.List (find, intercalate, isPrefixOf, isSuffixOf, sort)
 import qualified Data.Map as M
 import Data.Maybe (fromMaybe, isJust, isNothing)
-import Data.Monoid
 import qualified Data.Set as Set
 import Data.Text (Text)
 import qualified Data.Text as T
@@ -967,6 +968,9 @@
                                 setUserDataDir Nothing
                                 getDefaultTemplate arg
                      case templ of
+                          Right "" -> do -- e.g. for docx, odt, json:
+                            E.throwIO $ PandocCouldNotFindDataFileError
+                               ("templates/default." ++ arg)
                           Right t -> UTF8.hPutStr stdout t
                           Left e  -> E.throwIO e
                      exitSuccess)
diff --git a/src/Text/Pandoc/Asciify.hs b/src/Text/Pandoc/Asciify.hs
--- a/src/Text/Pandoc/Asciify.hs
+++ b/src/Text/Pandoc/Asciify.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2013-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -30,6 +31,7 @@
 -}
 module Text.Pandoc.Asciify (toAsciiChar)
 where
+import Prelude
 import Data.Char (isAscii)
 import qualified Data.Map as M
 
diff --git a/src/Text/Pandoc/BCP47.hs b/src/Text/Pandoc/BCP47.hs
--- a/src/Text/Pandoc/BCP47.hs
+++ b/src/Text/Pandoc/BCP47.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2017–2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -34,6 +35,7 @@
                      , renderLang
                      )
 where
+import Prelude
 import Control.Monad (guard)
 import Data.Char (isAlphaNum, isAscii, isLetter, isLower, isUpper, toLower,
                   toUpper)
diff --git a/src/Text/Pandoc/CSS.hs b/src/Text/Pandoc/CSS.hs
--- a/src/Text/Pandoc/CSS.hs
+++ b/src/Text/Pandoc/CSS.hs
@@ -1,9 +1,11 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Text.Pandoc.CSS ( foldOrElse
                        , pickStyleAttrProps
                        , pickStylesToKVs
                        )
 where
 
+import Prelude
 import Text.Pandoc.Shared (trim)
 import Text.Parsec
 import Text.Parsec.String
diff --git a/src/Text/Pandoc/CSV.hs b/src/Text/Pandoc/CSV.hs
--- a/src/Text/Pandoc/CSV.hs
+++ b/src/Text/Pandoc/CSV.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2017–2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -34,6 +35,7 @@
   ParseError
 ) where
 
+import Prelude
 import Control.Monad (void)
 import Data.Text (Text)
 import qualified Data.Text as T
diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs
--- a/src/Text/Pandoc/Class.hs
+++ b/src/Text/Pandoc/Class.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE CPP #-}
 {-# LANGUAGE PatternGuards #-}
 {-# LANGUAGE DeriveFunctor #-}
@@ -96,6 +97,7 @@
                          , Translations
                          ) where
 
+import Prelude
 import Prelude hiding (readFile)
 import System.Random (StdGen, next, mkStdGen)
 import qualified System.Random as IO (newStdGen)
@@ -106,10 +108,10 @@
 import qualified Data.Unique as IO (newUnique)
 import qualified Text.Pandoc.UTF8 as UTF8
 import qualified System.Directory as Directory
-import Text.Pandoc.Compat.Time (UTCTime)
+import Data.Time (UTCTime)
 import Text.Pandoc.Logging
 import Text.Parsec (ParsecT, getPosition, sourceLine, sourceName)
-import qualified Text.Pandoc.Compat.Time as IO (getCurrentTime)
+import qualified Data.Time as IO (getCurrentTime)
 import Text.Pandoc.MIME (MimeType, getMimeType, extensionFromMimeType)
 import Text.Pandoc.Definition
 import Data.Digest.Pure.SHA (sha1, showDigest)
@@ -923,7 +925,7 @@
                          }
 
 newtype FileTree = FileTree {unFileTree :: M.Map FilePath FileInfo}
-  deriving (Monoid)
+  deriving (Semigroup, Monoid)
 
 getFileInfo :: FilePath -> FileTree -> Maybe FileInfo
 getFileInfo fp tree =
diff --git a/src/Text/Pandoc/Compat/Time.hs b/src/Text/Pandoc/Compat/Time.hs
deleted file mode 100644
--- a/src/Text/Pandoc/Compat/Time.hs
+++ /dev/null
@@ -1,30 +0,0 @@
-{-# LANGUAGE CPP #-}
-
-{-
-This compatibility module is needed because, in time 1.5, the
-`defaultTimeLocale` function was moved from System.Locale (in the
-old-locale library) into Data.Time.
-
-We support both behaviors because time 1.4 is a boot library for GHC
-7.8. time 1.5 is a boot library for GHC 7.10.
-
-When support is dropped for GHC 7.8, this module may be obsoleted.
--}
-
-#if MIN_VERSION_time(1,5,0)
-module Text.Pandoc.Compat.Time (
-  module Data.Time
-)
-where
-import Data.Time
-
-#else
-module Text.Pandoc.Compat.Time (
-  module Data.Time,
-  defaultTimeLocale
-)
-where
-import Data.Time
-import System.Locale ( defaultTimeLocale )
-
-#endif
diff --git a/src/Text/Pandoc/Data.hs b/src/Text/Pandoc/Data.hs
--- a/src/Text/Pandoc/Data.hs
+++ b/src/Text/Pandoc/Data.hs
@@ -1,7 +1,9 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE TemplateHaskell #-}
 
 module Text.Pandoc.Data (dataFiles) where
 
+import Prelude
 import qualified Data.ByteString as B
 import Data.FileEmbed
 import System.FilePath (splitDirectories)
diff --git a/src/Text/Pandoc/Emoji.hs b/src/Text/Pandoc/Emoji.hs
--- a/src/Text/Pandoc/Emoji.hs
+++ b/src/Text/Pandoc/Emoji.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2015 John MacFarlane <jgm@berkeley.edu>
 
@@ -28,6 +29,7 @@
 Emoji symbol lookup from canonical string identifier.
 -}
 module Text.Pandoc.Emoji ( emojis ) where
+import Prelude
 import qualified Data.Map as M
 
 emojis :: M.Map String String
diff --git a/src/Text/Pandoc/Error.hs b/src/Text/Pandoc/Error.hs
--- a/src/Text/Pandoc/Error.hs
+++ b/src/Text/Pandoc/Error.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE DeriveDataTypeable #-}
 {-# LANGUAGE DeriveGeneric      #-}
 {-
@@ -34,6 +35,7 @@
   PandocError(..),
   handleError) where
 
+import Prelude
 import Control.Exception (Exception)
 import Data.Typeable (Typeable)
 import GHC.Generics (Generic)
diff --git a/src/Text/Pandoc/Extensions.hs b/src/Text/Pandoc/Extensions.hs
--- a/src/Text/Pandoc/Extensions.hs
+++ b/src/Text/Pandoc/Extensions.hs
@@ -1,3 +1,9 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE CPP                        #-}
+{-# LANGUAGE DeriveDataTypeable         #-}
+{-# LANGUAGE DeriveGeneric              #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE TemplateHaskell            #-}
 {-
 Copyright (C) 2012-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -15,10 +21,6 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 -}
-{-# LANGUAGE DeriveDataTypeable         #-}
-{-# LANGUAGE DeriveGeneric              #-}
-{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE TemplateHaskell            #-}
 
 {- |
    Module      : Text.Pandoc.Extensions
@@ -47,6 +49,7 @@
                               , githubMarkdownExtensions
                               , multimarkdownExtensions )
 where
+import Prelude
 import Data.Aeson (FromJSON (..), ToJSON (..), defaultOptions)
 import Data.Aeson.TH (deriveJSON)
 import Data.Bits (clearBit, setBit, testBit, (.|.))
@@ -59,9 +62,11 @@
 newtype Extensions = Extensions Integer
   deriving (Show, Read, Eq, Ord, Data, Typeable, Generic, ToJSON, FromJSON)
 
+instance Semigroup Extensions where
+  (Extensions a) <> (Extensions b) = Extensions (a .|. b)
 instance Monoid Extensions where
   mempty = Extensions 0
-  mappend (Extensions a) (Extensions b) = Extensions (a .|. b)
+  mappend = (<>)
 
 extensionsFromList :: [Extension] -> Extensions
 extensionsFromList = foldr enableExtension emptyExtensions
diff --git a/src/Text/Pandoc/Filter.hs b/src/Text/Pandoc/Filter.hs
--- a/src/Text/Pandoc/Filter.hs
+++ b/src/Text/Pandoc/Filter.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2006-2017 John MacFarlane <jgm@berkeley.edu>
 
@@ -33,6 +34,7 @@
   , applyFilters
   ) where
 
+import Prelude
 import Data.Aeson (defaultOptions)
 import Data.Aeson.TH (deriveJSON)
 import Data.Foldable (foldrM)
diff --git a/src/Text/Pandoc/Filter/JSON.hs b/src/Text/Pandoc/Filter/JSON.hs
--- a/src/Text/Pandoc/Filter/JSON.hs
+++ b/src/Text/Pandoc/Filter/JSON.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -29,6 +30,7 @@
 -}
 module Text.Pandoc.Filter.JSON (apply) where
 
+import Prelude
 import Control.Monad (unless, when)
 import Control.Monad.Trans (MonadIO (liftIO))
 import Data.Aeson (eitherDecode', encode)
diff --git a/src/Text/Pandoc/Filter/Lua.hs b/src/Text/Pandoc/Filter/Lua.hs
--- a/src/Text/Pandoc/Filter/Lua.hs
+++ b/src/Text/Pandoc/Filter/Lua.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -29,6 +30,7 @@
 -}
 module Text.Pandoc.Filter.Lua (apply) where
 
+import Prelude
 import Control.Exception (throw)
 import Text.Pandoc.Class (PandocIO)
 import Text.Pandoc.Definition (Pandoc)
diff --git a/src/Text/Pandoc/Filter/Path.hs b/src/Text/Pandoc/Filter/Path.hs
--- a/src/Text/Pandoc/Filter/Path.hs
+++ b/src/Text/Pandoc/Filter/Path.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -31,6 +32,7 @@
   ( expandFilterPath
   ) where
 
+import Prelude
 import Text.Pandoc.Class (PandocMonad, fileExists, getUserDataDir)
 import System.FilePath ((</>), isRelative)
 
diff --git a/src/Text/Pandoc/Highlighting.hs b/src/Text/Pandoc/Highlighting.hs
--- a/src/Text/Pandoc/Highlighting.hs
+++ b/src/Text/Pandoc/Highlighting.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2008-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -49,6 +50,7 @@
                                 , fromListingsLanguage
                                 , toListingsLanguage
                                 ) where
+import Prelude
 import Control.Monad
 import Data.Char (toLower)
 import qualified Data.Map as M
diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs
--- a/src/Text/Pandoc/ImageSize.hs
+++ b/src/Text/Pandoc/ImageSize.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings, ScopedTypeVariables, CPP #-}
 {-# OPTIONS_GHC -fno-warn-type-defaults #-}
 {-
@@ -49,6 +50,7 @@
                              , showInPixel
                              , showFl
                              ) where
+import Prelude
 import Data.ByteString (ByteString, unpack)
 import qualified Data.ByteString.Char8 as B
 import qualified Data.ByteString.Lazy as BL
@@ -126,7 +128,7 @@
                        |  B.take 4 (B.drop 1 $ B.dropWhile (/=' ') img) == "EPSF"
                                         -> return Eps
                      "\x01\x00\x00\x00"
-                       | B.take 4 (B.drop 40 img) == " EMF" 
+                       | B.take 4 (B.drop 40 img) == " EMF"
                                         -> return Emf
                      _                  -> mzero
 
@@ -361,9 +363,9 @@
   , dpiX = dpi
   , dpiY = dpi
   }
-  
+
 emfSize :: ByteString -> Maybe ImageSize
-emfSize img = 
+emfSize img =
   let
     parseheader = runGetOrFail $ do
       skip 0x18             -- 0x00
@@ -388,11 +390,11 @@
         , dpiX = fromIntegral dpiW
         , dpiY = fromIntegral dpiH
         }
-  in 
+  in
     case parseheader . BL.fromStrict $ img of
       Left _ -> Nothing
       Right (_, _, size) -> Just size
-  
+
 
 jpegSize :: ByteString -> Either String ImageSize
 jpegSize img =
diff --git a/src/Text/Pandoc/Logging.hs b/src/Text/Pandoc/Logging.hs
--- a/src/Text/Pandoc/Logging.hs
+++ b/src/Text/Pandoc/Logging.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE DeriveDataTypeable #-}
 {-# LANGUAGE DeriveGeneric      #-}
 {-# LANGUAGE OverloadedStrings  #-}
@@ -39,6 +40,7 @@
   , messageVerbosity
   ) where
 
+import Prelude
 import Control.Monad (mzero)
 import Data.Aeson
 import Data.Aeson.Encode.Pretty (Config (..), defConfig, encodePretty',
diff --git a/src/Text/Pandoc/Lua.hs b/src/Text/Pandoc/Lua.hs
--- a/src/Text/Pandoc/Lua.hs
+++ b/src/Text/Pandoc/Lua.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright © 2017–2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
 
@@ -31,6 +32,7 @@
   , runPandocLua
   ) where
 
+import Prelude
 import Control.Monad ((>=>))
 import Foreign.Lua (FromLuaStack (peek), Lua, LuaException (..),
                     Status (OK), ToLuaStack (push))
diff --git a/src/Text/Pandoc/Lua/Filter.hs b/src/Text/Pandoc/Lua/Filter.hs
--- a/src/Text/Pandoc/Lua/Filter.hs
+++ b/src/Text/Pandoc/Lua/Filter.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleContexts #-}
 
 module Text.Pandoc.Lua.Filter ( LuaFilterFunction
@@ -10,6 +11,7 @@
                               , blockElementNames
                               , inlineElementNames
                               ) where
+import Prelude
 import Control.Monad (mplus, unless, when, (>=>))
 import Control.Monad.Catch (finally)
 import Text.Pandoc.Definition
diff --git a/src/Text/Pandoc/Lua/Init.hs b/src/Text/Pandoc/Lua/Init.hs
--- a/src/Text/Pandoc/Lua/Init.hs
+++ b/src/Text/Pandoc/Lua/Init.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright © 2017-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
 
@@ -34,6 +35,7 @@
   , registerScriptPath
   ) where
 
+import Prelude
 import Control.Monad.Trans (MonadIO (..))
 import Data.Data (Data, dataTypeConstrs, dataTypeOf, showConstr)
 import Data.IORef (newIORef, readIORef)
diff --git a/src/Text/Pandoc/Lua/Module/MediaBag.hs b/src/Text/Pandoc/Lua/Module/MediaBag.hs
--- a/src/Text/Pandoc/Lua/Module/MediaBag.hs
+++ b/src/Text/Pandoc/Lua/Module/MediaBag.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright © 2017-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
 
@@ -29,6 +30,7 @@
   ( pushModule
   ) where
 
+import Prelude
 import Control.Monad (zipWithM_)
 import Data.IORef (IORef, modifyIORef', readIORef)
 import Data.Maybe (fromMaybe)
diff --git a/src/Text/Pandoc/Lua/Module/Pandoc.hs b/src/Text/Pandoc/Lua/Module/Pandoc.hs
--- a/src/Text/Pandoc/Lua/Module/Pandoc.hs
+++ b/src/Text/Pandoc/Lua/Module/Pandoc.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright © 2017-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
 
@@ -30,6 +31,7 @@
   ( pushModule
   ) where
 
+import Prelude
 import Control.Monad (when)
 import Data.Default (Default (..))
 import Data.Maybe (fromMaybe)
diff --git a/src/Text/Pandoc/Lua/Module/Utils.hs b/src/Text/Pandoc/Lua/Module/Utils.hs
--- a/src/Text/Pandoc/Lua/Module/Utils.hs
+++ b/src/Text/Pandoc/Lua/Module/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright © 2017-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
 
@@ -29,6 +30,7 @@
   ( pushModule
   ) where
 
+import Prelude
 import Control.Applicative ((<|>))
 import Data.Default (def)
 import Foreign.Lua (FromLuaStack, Lua, LuaInteger, NumResults)
diff --git a/src/Text/Pandoc/Lua/Packages.hs b/src/Text/Pandoc/Lua/Packages.hs
--- a/src/Text/Pandoc/Lua/Packages.hs
+++ b/src/Text/Pandoc/Lua/Packages.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright © 2017-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
 
@@ -32,6 +33,7 @@
   , installPandocPackageSearcher
   ) where
 
+import Prelude
 import Control.Monad (forM_)
 import Data.ByteString.Char8 (unpack)
 import Data.IORef (IORef)
diff --git a/src/Text/Pandoc/Lua/StackInstances.hs b/src/Text/Pandoc/Lua/StackInstances.hs
--- a/src/Text/Pandoc/Lua/StackInstances.hs
+++ b/src/Text/Pandoc/Lua/StackInstances.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright © 2012-2018 John MacFarlane <jgm@berkeley.edu>
             2017-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
@@ -33,6 +34,7 @@
 -}
 module Text.Pandoc.Lua.StackInstances () where
 
+import Prelude
 import Control.Applicative ((<|>))
 import Control.Monad (when)
 import Control.Monad.Catch (finally)
diff --git a/src/Text/Pandoc/Lua/Util.hs b/src/Text/Pandoc/Lua/Util.hs
--- a/src/Text/Pandoc/Lua/Util.hs
+++ b/src/Text/Pandoc/Lua/Util.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright © 2012-2018 John MacFarlane <jgm@berkeley.edu>
             2017-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
@@ -46,6 +47,7 @@
   , dostring'
   ) where
 
+import Prelude
 import Control.Monad (when)
 import Control.Monad.Catch (finally)
 import Data.ByteString.Char8 (unpack)
@@ -132,7 +134,7 @@
 instance PushViaCall (Lua ()) where
   pushViaCall' fn pushArgs num = do
     Lua.push fn
-    Lua.rawget (Lua.registryindex)
+    Lua.rawget Lua.registryindex
     pushArgs
     call num 1
 
diff --git a/src/Text/Pandoc/MIME.hs b/src/Text/Pandoc/MIME.hs
--- a/src/Text/Pandoc/MIME.hs
+++ b/src/Text/Pandoc/MIME.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2011-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -29,6 +30,7 @@
 -}
 module Text.Pandoc.MIME ( MimeType, getMimeType, getMimeTypeDef,
                           extensionFromMimeType )where
+import Prelude
 import Data.Char (toLower)
 import Data.List (isPrefixOf, isSuffixOf)
 import qualified Data.Map as M
diff --git a/src/Text/Pandoc/MediaBag.hs b/src/Text/Pandoc/MediaBag.hs
--- a/src/Text/Pandoc/MediaBag.hs
+++ b/src/Text/Pandoc/MediaBag.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE CPP                        #-}
 {-# LANGUAGE DeriveDataTypeable         #-}
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
 {-
@@ -36,6 +38,7 @@
                      insertMedia,
                      mediaDirectory,
                      ) where
+import Prelude
 import qualified Data.ByteString.Lazy as BL
 import Data.Data (Data)
 import qualified Data.Map as M
@@ -50,7 +53,7 @@
 -- can be used for an empty 'MediaBag', and '<>' can be used to append
 -- two 'MediaBag's.
 newtype MediaBag = MediaBag (M.Map [String] (MimeType, BL.ByteString))
-        deriving (Monoid, Data, Typeable)
+        deriving (Semigroup, Monoid, Data, Typeable)
 
 instance Show MediaBag where
   show bag = "MediaBag " ++ show (mediaDirectory bag)
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE DeriveDataTypeable #-}
 {-# LANGUAGE DeriveGeneric      #-}
 {-# LANGUAGE TemplateHaskell    #-}
@@ -46,6 +47,7 @@
                            , def
                            , isEnabled
                            ) where
+import Prelude
 import Data.Aeson (defaultOptions)
 import Data.Aeson.TH (deriveJSON)
 import Data.Data (Data)
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE CPP                 #-}
 {-# LANGUAGE OverloadedStrings   #-}
 {-# LANGUAGE ScopedTypeVariables #-}
@@ -32,6 +33,7 @@
 -}
 module Text.Pandoc.PDF ( makePDF ) where
 
+import Prelude
 import qualified Codec.Picture as JP
 import qualified Control.Exception as E
 import Control.Monad (unless, when)
@@ -41,7 +43,6 @@
 import qualified Data.ByteString.Lazy as BL
 import qualified Data.ByteString.Lazy.Char8 as BC
 import Data.Maybe (fromMaybe)
-import Data.Monoid ((<>))
 import Data.Text (Text)
 import qualified Data.Text as T
 import qualified Data.Text.IO as TextIO
@@ -56,6 +57,8 @@
 #else
 import System.IO.Error (isDoesNotExistError)
 #endif
+import Text.HTML.TagSoup
+import Text.HTML.TagSoup.Match
 import Text.Pandoc.Definition
 import Text.Pandoc.Error (PandocError (PandocPDFProgramNotFoundError))
 import Text.Pandoc.MIME (getMimeType)
@@ -353,7 +356,13 @@
           -> [String]     -- ^ Args to program
           -> Text         -- ^ HTML5 source
           -> IO (Either ByteString ByteString)
-html2pdf verbosity program args source = do
+html2pdf verbosity program args htmlSource = do
+  cwd <- getCurrentDirectory
+  let tags = parseTags htmlSource
+      (hd, tl) = break (tagClose (== "head")) tags
+      baseTag = TagOpen "base"
+        [("href", T.pack cwd <> T.singleton pathSeparator)] : [TagText "\n"]
+      source = renderTags $ hd ++ baseTag ++ tl
   pdfFile <- withTempFile "." "html2pdf.pdf" $ \fp _ -> return fp
   let pdfFileArgName = ["-o" | program == "prince"]
   let programArgs = args ++ ["-"] ++ pdfFileArgName ++ [pdfFile]
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE CPP                        #-}
 {-# LANGUAGE ExplicitForAll             #-}
 {-# LANGUAGE FlexibleContexts           #-}
 {-# LANGUAGE FlexibleInstances          #-}
@@ -194,6 +196,7 @@
                              )
 where
 
+import Prelude
 import Control.Monad.Identity
 import Control.Monad.Reader
 import Data.Char (chr, isAlphaNum, isAscii, isAsciiUpper, isHexDigit,
@@ -202,7 +205,6 @@
 import Data.List (intercalate, isSuffixOf, transpose)
 import qualified Data.Map as M
 import Data.Maybe (mapMaybe, fromMaybe)
-import Data.Monoid ((<>))
 import qualified Data.Set as Set
 import Data.Text (Text)
 import Text.HTML.TagSoup.Entity (lookupEntity)
@@ -250,10 +252,11 @@
 trimInlinesF :: Future s Inlines -> Future s Inlines
 trimInlinesF = liftM trimInlines
 
-instance Monoid a => Monoid (Future s a) where
+instance Semigroup a => Semigroup (Future s a) where
+  (<>) = liftM2 (<>)
+instance (Semigroup a, Monoid a) => Monoid (Future s a) where
   mempty = return mempty
-  mappend = liftM2 mappend
-  mconcat = liftM mconcat . sequence
+  mappend = (<>)
 
 -- | Parse characters while a predicate is true.
 takeWhileP :: Monad m
@@ -1437,7 +1440,7 @@
 
 infixr 5 <+?>
 (<+?>) :: (Monoid a) => ParserT s st m a -> ParserT s st m a -> ParserT s st m a
-a <+?> b = a >>= flip fmap (try b <|> return mempty) . (<>)
+a <+?> b = a >>= flip fmap (try b <|> return mempty) . mappend
 
 extractIdClass :: Attr -> Attr
 extractIdClass (ident, cls, kvs) = (ident', cls', kvs')
diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs
--- a/src/Text/Pandoc/Pretty.hs
+++ b/src/Text/Pandoc/Pretty.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE CPP                        #-}
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
 {-
@@ -77,12 +78,12 @@
      )
 
 where
+import Prelude
 import Control.Monad
 import Control.Monad.State.Strict
 import Data.Char (isSpace)
 import Data.Foldable (toList)
 import Data.List (intersperse)
-import Data.Monoid ((<>))
 import Data.Sequence (Seq, ViewL (..), fromList, mapWithIndex, singleton, viewl,
                       (<|))
 import qualified Data.Sequence as Seq
@@ -112,7 +113,7 @@
        deriving (Show, Eq)
 
 newtype Doc = Doc { unDoc :: Seq D }
-              deriving (Monoid, Show, Eq)
+              deriving (Semigroup, Monoid, Show, Eq)
 
 instance IsString Doc where
   fromString = text
diff --git a/src/Text/Pandoc/Process.hs b/src/Text/Pandoc/Process.hs
--- a/src/Text/Pandoc/Process.hs
+++ b/src/Text/Pandoc/Process.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2013-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -29,6 +30,7 @@
 -}
 module Text.Pandoc.Process (pipeProcess)
 where
+import Prelude
 import Control.Concurrent (forkIO, newEmptyMVar, putMVar, takeMVar)
 import Control.Exception
 import Control.Monad (unless)
diff --git a/src/Text/Pandoc/Readers.hs b/src/Text/Pandoc/Readers.hs
--- a/src/Text/Pandoc/Readers.hs
+++ b/src/Text/Pandoc/Readers.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleInstances   #-}
 {-# LANGUAGE GADTs               #-}
 {-# LANGUAGE ScopedTypeVariables #-}
@@ -69,6 +70,7 @@
   , getDefaultExtensions
   ) where
 
+import Prelude
 import Control.Monad.Except (throwError)
 import Data.Aeson
 import qualified Data.ByteString.Lazy as BL
diff --git a/src/Text/Pandoc/Readers/CommonMark.hs b/src/Text/Pandoc/Readers/CommonMark.hs
--- a/src/Text/Pandoc/Readers/CommonMark.hs
+++ b/src/Text/Pandoc/Readers/CommonMark.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2015-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -32,6 +33,7 @@
 module Text.Pandoc.Readers.CommonMark (readCommonMark)
 where
 
+import Prelude
 import CMarkGFM
 import Control.Monad.State
 import Data.Char (isAlphaNum, isLetter, isSpace, toLower)
diff --git a/src/Text/Pandoc/Readers/Creole.hs b/src/Text/Pandoc/Readers/Creole.hs
--- a/src/Text/Pandoc/Readers/Creole.hs
+++ b/src/Text/Pandoc/Readers/Creole.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
   Copyright (C) 2017 Sascha Wilde <wilde@sha-bang.de>
 
@@ -35,10 +36,10 @@
 module Text.Pandoc.Readers.Creole ( readCreole
                                   ) where
 
+import Prelude
 import Control.Monad.Except (guard, liftM2, throwError)
 import qualified Data.Foldable as F
 import Data.Maybe (fromMaybe)
-import Data.Monoid
 import Data.Text (Text)
 import qualified Data.Text as T
 import qualified Text.Pandoc.Builder as B
@@ -67,7 +68,7 @@
 -- Utility functions
 --
 
-(<+>) :: (Monad m, Monoid a) => m a -> m a -> m a
+(<+>) :: (Monad m, Semigroup a) => m a -> m a -> m a
 (<+>) = liftM2 (<>)
 
 -- we have to redefine `enclosed' from Text.Pandoc.Parsing, because it
diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs
--- a/src/Text/Pandoc/Readers/DocBook.hs
+++ b/src/Text/Pandoc/Readers/DocBook.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE ExplicitForAll #-}
 module Text.Pandoc.Readers.DocBook ( readDocBook ) where
+import Prelude
 import Control.Monad.State.Strict
 import Data.Char (isSpace, toUpper)
 import Data.Default
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE CPP               #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE PatternGuards     #-}
@@ -74,6 +75,7 @@
        ( readDocx
        ) where
 
+import Prelude
 import Codec.Archive.Zip
 import Control.Monad.Reader
 import Control.Monad.State.Strict
@@ -122,7 +124,6 @@
                      , docxImmedPrevAnchor :: Maybe String
                      , docxMediaBag  :: MediaBag
                      , docxDropCap   :: Inlines
-                     , docxWarnings  :: [String]
                      -- keep track of (numId, lvl) values for
                      -- restarting
                      , docxListState :: M.Map (String, String) Integer
@@ -135,7 +136,6 @@
                , docxImmedPrevAnchor = Nothing
                , docxMediaBag  = mempty
                , docxDropCap   = mempty
-               , docxWarnings  = []
                , docxListState = M.empty
                , docxPrevPara  = mempty
                }
@@ -369,7 +369,7 @@
 parPartToInlines :: PandocMonad m => ParPart -> DocxContext m Inlines
 parPartToInlines parPart =
   case parPart of
-    (BookMark _ anchor) | notElem anchor dummyAnchors -> do
+    (BookMark _ anchor) | anchor `notElem` dummyAnchors -> do
       inHdrBool <- asks docxInHeaderBlock
       ils <- parPartToInlines' parPart
       immedPrevAnchor <- gets docxImmedPrevAnchor
@@ -462,8 +462,6 @@
   return $ link target "" ils
 parPartToInlines' (PlainOMath exps) =
   return $ math $ writeTeX exps
-parPartToInlines' (SmartTag runs) =
-  smushInlines <$> mapM runToInlines runs
 parPartToInlines' (Field info runs) =
   case info of
     HyperlinkField url -> parPartToInlines' $ ExternalHyperLink url runs
diff --git a/src/Text/Pandoc/Readers/Docx/Combine.hs b/src/Text/Pandoc/Readers/Docx/Combine.hs
--- a/src/Text/Pandoc/Readers/Docx/Combine.hs
+++ b/src/Text/Pandoc/Readers/Docx/Combine.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleInstances    #-}
 {-# LANGUAGE PatternGuards        #-}
 {-# LANGUAGE TypeSynonymInstances #-}
@@ -7,6 +8,7 @@
                                         )
        where
 
+import Prelude
 import Data.List
 import Data.Sequence (ViewL (..), ViewR (..), viewl, viewr, (><), (|>))
 import qualified Data.Sequence as Seq (null)
diff --git a/src/Text/Pandoc/Readers/Docx/Fields.hs b/src/Text/Pandoc/Readers/Docx/Fields.hs
--- a/src/Text/Pandoc/Readers/Docx/Fields.hs
+++ b/src/Text/Pandoc/Readers/Docx/Fields.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2014-2018 Jesse Rosenthal <jrosenthal@jhu.edu>
 
@@ -32,6 +33,7 @@
                                        , parseFieldInfo
                                        ) where
 
+import Prelude
 import Text.Parsec
 import Text.Parsec.String (Parser)
 
diff --git a/src/Text/Pandoc/Readers/Docx/Lists.hs b/src/Text/Pandoc/Readers/Docx/Lists.hs
--- a/src/Text/Pandoc/Readers/Docx/Lists.hs
+++ b/src/Text/Pandoc/Readers/Docx/Lists.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2014-2018 Jesse Rosenthal <jrosenthal@jhu.edu>
 
@@ -33,6 +34,7 @@
                                       , listParagraphDivs
                                       ) where
 
+import Prelude
 import Data.List
 import Data.Maybe
 import Text.Pandoc.Generic (bottomUp)
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
--- a/src/Text/Pandoc/Readers/Docx/Parse.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE PatternGuards     #-}
 {-# LANGUAGE ViewPatterns      #-}
@@ -58,6 +59,7 @@
                                       , archiveToDocx
                                       , archiveToDocxWithWarnings
                                       ) where
+import Prelude
 import Codec.Archive.Zip
 import Control.Applicative ((<|>))
 import Control.Monad.Except
@@ -132,21 +134,23 @@
   in
    concatMapM handler xs
 
-unwrapSDT :: NameSpaces -> Content -> [Content]
-unwrapSDT ns (Elem element)
+unwrap :: NameSpaces -> Content -> [Content]
+unwrap ns (Elem element)
   | isElem ns "w" "sdt" element
   , Just sdtContent <- findChildByName ns "w" "sdtContent" element
-  = concatMap (unwrapSDT ns) $ map Elem $ elChildren sdtContent
-unwrapSDT _ content = [content]
+  = concatMap ((unwrap ns) . Elem) (elChildren sdtContent)
+  | isElem ns "w" "smartTag" element
+  = concatMap ((unwrap ns) . Elem) (elChildren element)
+unwrap _ content = [content]
 
-unwrapSDTchild :: NameSpaces -> Content -> Content
-unwrapSDTchild ns (Elem element) =
-  Elem $ element { elContent = concatMap (unwrapSDT ns) (elContent element) }
-unwrapSDTchild _ content = content
+unwrapChild :: NameSpaces -> Content -> Content
+unwrapChild ns (Elem element) =
+  Elem $ element { elContent = concatMap (unwrap ns) (elContent element) }
+unwrapChild _ content = content
 
 walkDocument' :: NameSpaces -> XMLC.Cursor -> XMLC.Cursor
 walkDocument' ns cur =
-  let modifiedCur = XMLC.modifyContent (unwrapSDTchild ns) cur
+  let modifiedCur = XMLC.modifyContent (unwrapChild ns) cur
   in
     case XMLC.nextDF modifiedCur of
       Just cur' -> walkDocument' ns cur'
@@ -275,7 +279,6 @@
              | Drawing FilePath String String B.ByteString Extent -- title, alt
              | Chart                                              -- placeholder for now
              | PlainOMath [Exp]
-             | SmartTag [Run]
              | Field FieldInfo [Run]
              | NullParPart      -- when we need to return nothing, but
                                 -- not because of an error.
@@ -825,10 +828,6 @@
   | Just change <- getTrackedChange ns element = do
       runs <- mapD (elemToRun ns) (elChildren element)
       return $ ChangedRuns change runs
-elemToParPart ns element
-  | isElem ns "w" "smartTag" element = do
-    runs <- mapD (elemToRun ns) (elChildren element)
-    return $ SmartTag runs
 elemToParPart ns element
   | isElem ns "w" "bookmarkStart" element
   , Just bmId <- findAttrByName ns "w" "id" element
diff --git a/src/Text/Pandoc/Readers/Docx/StyleMap.hs b/src/Text/Pandoc/Readers/Docx/StyleMap.hs
--- a/src/Text/Pandoc/Readers/Docx/StyleMap.hs
+++ b/src/Text/Pandoc/Readers/Docx/StyleMap.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Text.Pandoc.Readers.Docx.StyleMap (  StyleMaps(..)
                                           , alterMap
                                           , getMap
@@ -7,6 +8,7 @@
                                           , hasStyleName
                                           ) where
 
+import Prelude
 import Control.Monad.State.Strict
 import Data.Char (toLower)
 import qualified Data.Map as M
diff --git a/src/Text/Pandoc/Readers/Docx/Util.hs b/src/Text/Pandoc/Readers/Docx/Util.hs
--- a/src/Text/Pandoc/Readers/Docx/Util.hs
+++ b/src/Text/Pandoc/Readers/Docx/Util.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Text.Pandoc.Readers.Docx.Util (
                                         NameSpaces
                                       , elemName
@@ -8,6 +9,7 @@
                                       , findAttrByName
                                       ) where
 
+import Prelude
 import Data.Maybe (mapMaybe)
 import Text.XML.Light
 
diff --git a/src/Text/Pandoc/Readers/EPUB.hs b/src/Text/Pandoc/Readers/EPUB.hs
--- a/src/Text/Pandoc/Readers/EPUB.hs
+++ b/src/Text/Pandoc/Readers/EPUB.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleContexts #-}
 
 {-# LANGUAGE TupleSections    #-}
@@ -7,6 +8,7 @@
   (readEPUB)
   where
 
+import Prelude
 import Codec.Archive.Zip (Archive (..), Entry, findEntryByPath, fromEntry,
                           toArchiveOrFail)
 import Control.DeepSeq (NFData, deepseq)
@@ -16,7 +18,6 @@
 import Data.List (isInfixOf, isPrefixOf)
 import qualified Data.Map as M (Map, elems, fromList, lookup)
 import Data.Maybe (fromMaybe, mapMaybe)
-import Data.Monoid ((<>))
 import qualified Data.Text.Lazy as TL
 import qualified Data.Text.Lazy.Encoding as TL
 import Network.URI (unEscapeString)
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleContexts      #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
@@ -42,6 +43,7 @@
                                 , isCommentTag
                                 ) where
 
+import Prelude
 import Control.Applicative ((<|>))
 import Control.Arrow (first)
 import Control.Monad (guard, mplus, msum, mzero, unless, void)
@@ -54,7 +56,7 @@
 import Data.List.Split (wordsBy, splitWhen)
 import qualified Data.Map as M
 import Data.Maybe (fromMaybe, isJust, isNothing)
-import Data.Monoid (First (..), (<>))
+import Data.Monoid (First (..))
 import qualified Data.Set as Set
 import Data.Text (Text)
 import qualified Data.Text as T
diff --git a/src/Text/Pandoc/Readers/Haddock.hs b/src/Text/Pandoc/Readers/Haddock.hs
--- a/src/Text/Pandoc/Readers/Haddock.hs
+++ b/src/Text/Pandoc/Readers/Haddock.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE CPP #-}
 {- |
    Module      : Text.Pandoc.Readers.Haddock
@@ -14,13 +15,13 @@
     ( readHaddock
     ) where
 
+import Prelude
 import Control.Monad.Except (throwError)
 import Data.List (intersperse, stripPrefix)
 import Data.Maybe (fromMaybe)
-import Data.Monoid ((<>))
 import Data.Text (Text, unpack)
 import Documentation.Haddock.Parser
-import Documentation.Haddock.Types
+import Documentation.Haddock.Types as H
 import Text.Pandoc.Builder (Blocks, Inlines)
 import qualified Text.Pandoc.Builder as B
 import Text.Pandoc.Class (PandocMonad)
@@ -86,6 +87,20 @@
     DocProperty s -> B.codeBlockWith ("",["property","haskell"],[]) (trim s)
     DocExamples es -> mconcat $ map (\e ->
        makeExample ">>>" (exampleExpression e) (exampleResult e)) es
+#if MIN_VERSION_haddock_library(1,5,0)
+    DocTable H.Table{ tableHeaderRows = headerRows
+                    , tableBodyRows = bodyRows
+                    }
+      -> let toCells = map (docHToBlocks . tableCellContents) . tableRowCells
+             (header, body) =
+               if null headerRows
+                  then ([], map toCells bodyRows)
+                  else (toCells (head headerRows),
+                        map toCells (tail headerRows ++ bodyRows))
+             colspecs = replicate (maximum (map length body))
+                             (AlignDefault, 0.0)
+         in  B.table mempty colspecs header body
+#endif
 
   where inlineFallback = B.plain $ docHToInlines False d'
         consolidatePlains = B.fromList . consolidatePlains' . B.toList
@@ -134,6 +149,9 @@
     DocAName s -> B.spanWith (s,["anchor"],[]) mempty
     DocProperty _ -> mempty
     DocExamples _ -> mempty
+#if MIN_VERSION_haddock_library(1,5,0)
+    DocTable _ -> mempty
+#endif
 
 -- | Create an 'Example', stripping superfluous characters as appropriate
 makeExample :: String -> String -> [String] -> Blocks
diff --git a/src/Text/Pandoc/Readers/JATS.hs b/src/Text/Pandoc/Readers/JATS.hs
--- a/src/Text/Pandoc/Readers/JATS.hs
+++ b/src/Text/Pandoc/Readers/JATS.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE ExplicitForAll, TupleSections #-}
 module Text.Pandoc.Readers.JATS ( readJATS ) where
+import Prelude
 import Control.Monad.State.Strict
 import Data.Char (isDigit, isSpace, toUpper)
 import Data.Default
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE OverloadedStrings     #-}
@@ -42,6 +43,7 @@
                                    untokenize
                                  ) where
 
+import Prelude
 import Control.Applicative (many, optional, (<|>))
 import Control.Monad
 import Control.Monad.Except (throwError)
@@ -666,7 +668,7 @@
   skipopts
   value <- tok
   valueprefix <- option "" $ bracketed tok
-  unit <- tok
+  unit <- inlineCommand' <|> tok
   let emptyOr160 "" = ""
       emptyOr160 _  = "\160"
   return . mconcat $ [valueprefix,
@@ -675,6 +677,12 @@
                       emptyOr160 unit,
                       unit]
 
+-- siunitx's \square command
+dosquare :: PandocMonad m => LP m Inlines
+dosquare = do
+  unit <- inlineCommand' <|> tok
+  return . mconcat $ [unit, "\178"]
+
 lit :: String -> LP m Inlines
 lit = pure . str
 
@@ -1468,6 +1476,13 @@
   , ("acsp", doAcronymPlural "abbrv")
   -- siuntix
   , ("SI", dosiunitx)
+  -- units of siuntix
+  , ("celsius", lit "°C")
+  , ("degreeCelsius", lit "°C")
+  , ("gram", lit "g")
+  , ("meter", lit "m")
+  , ("milli", lit "m")
+  , ("square", dosquare)
   -- hyphenat
   , ("bshyp", lit "\\\173")
   , ("fshyp", lit "/\173")
diff --git a/src/Text/Pandoc/Readers/LaTeX/Types.hs b/src/Text/Pandoc/Readers/LaTeX/Types.hs
--- a/src/Text/Pandoc/Readers/LaTeX/Types.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Types.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2017-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -34,6 +35,7 @@
                                        , SourcePos
                                        )
 where
+import Prelude
 import Data.Text (Text)
 import Text.Parsec.Pos (SourcePos)
 
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE RelaxedPolyRec      #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 
@@ -32,6 +33,7 @@
 -}
 module Text.Pandoc.Readers.Markdown ( readMarkdown ) where
 
+import Prelude
 import Control.Monad
 import Control.Monad.Except (throwError)
 import Data.Char (isAlphaNum, isPunctuation, isSpace, toLower)
@@ -39,7 +41,6 @@
 import Data.List (intercalate, sortBy, transpose, elemIndex)
 import qualified Data.Map as M
 import Data.Maybe
-import Data.Monoid ((<>))
 import Data.Ord (comparing)
 import Data.Scientific (base10Exponent, coefficient)
 import qualified Data.Set as Set
@@ -162,7 +163,7 @@
         stripBracket xs = if last xs == ']' then init xs else xs
         go :: PandocMonad m => Int -> MarkdownParser m ()
         go 0 = return ()
-        go openBrackets = 
+        go openBrackets =
           (() <$ (escapedChar <|>
                 code <|>
                 rawHtmlInline <|>
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs
--- a/src/Text/Pandoc/Readers/MediaWiki.hs
+++ b/src/Text/Pandoc/Readers/MediaWiki.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleInstances    #-}
 {-# LANGUAGE RelaxedPolyRec       #-}
 {-# LANGUAGE TypeSynonymInstances #-}
@@ -38,6 +39,7 @@
 -}
 module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where
 
+import Prelude
 import Control.Monad
 import Control.Monad.Except (throwError)
 import Data.Char (isDigit, isSpace)
@@ -45,7 +47,6 @@
 import Data.List (intercalate, intersperse, isPrefixOf)
 import qualified Data.Map as M
 import Data.Maybe (fromMaybe, maybeToList)
-import Data.Monoid ((<>))
 import Data.Sequence (ViewL (..), viewl, (<|))
 import qualified Data.Set as Set
 import Data.Text (Text, unpack)
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleContexts      #-}
 {-
   Copyright (C) 2017-2018 Alexander Krotov <ilabdsf@gmail.com>
@@ -39,6 +40,7 @@
 -}
 module Text.Pandoc.Readers.Muse (readMuse) where
 
+import Prelude
 import Control.Monad
 import Control.Monad.Except (throwError)
 import Data.Char (isLetter)
@@ -169,9 +171,10 @@
                  => String -> MuseParser m (Attr, F Blocks)
 parseHtmlContent tag = try $ do
   many spaceChar
+  pos <- getPosition
   (TagOpen _ attr, _) <- htmlTag (~== TagOpen tag [])
   manyTill spaceChar eol
-  content <- parseBlocksTill (try $ manyTill spaceChar endtag)
+  content <- parseBlocksTill (try $ ((count (sourceColumn pos - 1) spaceChar) >> endtag))
   manyTill spaceChar eol -- closing tag must be followed by optional whitespace and newline
   return (htmlAttrToPandoc attr, content)
   where
@@ -242,10 +245,10 @@
 parseBlocks :: PandocMonad m
             => MuseParser m (F Blocks)
 parseBlocks =
-  try parseEnd <|>
-  try blockStart <|>
-  try listStart <|>
-  try paraStart
+  try (parseEnd <|>
+       blockStart <|>
+       listStart <|>
+       paraStart)
   where
     parseEnd = mempty <$ eof
     blockStart = do first <- header <|> blockElements <|> emacsNoteBlock
@@ -265,10 +268,10 @@
                 => MuseParser m a
                 -> MuseParser m (F Blocks)
 parseBlocksTill end =
-  try parseEnd <|>
-  try blockStart <|>
-  try listStart <|>
-  try paraStart
+  try (parseEnd <|>
+       blockStart <|>
+       listStart <|>
+       paraStart)
   where
     parseEnd = mempty <$ end
     blockStart = do first <- blockElements
@@ -506,9 +509,10 @@
 lineVerseLine :: PandocMonad m => MuseParser m (F Inlines)
 lineVerseLine = try $ do
   string "> "
-  indent <- B.str <$> many (char ' ' >> pure '\160')
+  indent <- many (char ' ' >> pure '\160')
+  let indentEl = if null indent then mempty else B.str indent
   rest <- manyTill (choice inlineList) eol
-  return $ trimInlinesF $ mconcat (pure indent : rest)
+  return $ trimInlinesF $ mconcat (pure indentEl : rest)
 
 blanklineVerseLine :: PandocMonad m => MuseParser m (F Inlines)
 blanklineVerseLine = try $ do
@@ -755,6 +759,7 @@
              , subscriptTag
              , strikeoutTag
              , verbatimTag
+             , classTag
              , nbsp
              , link
              , code
@@ -856,6 +861,13 @@
 
 verbatimTag :: PandocMonad m => MuseParser m (F Inlines)
 verbatimTag = return . B.text . snd <$> htmlElement "verbatim"
+
+classTag :: PandocMonad m => MuseParser m (F Inlines)
+classTag = do
+  (TagOpen _ attrs, _) <- htmlTag (~== TagOpen "class" [])
+  res <- manyTill inline (void $ htmlTag (~== TagClose "class"))
+  let classes = maybe [] words $ lookup "name" attrs
+  return $ B.spanWith ("", classes, []) <$> mconcat res
 
 nbsp :: PandocMonad m => MuseParser m (F Inlines)
 nbsp = try $ do
diff --git a/src/Text/Pandoc/Readers/Native.hs b/src/Text/Pandoc/Readers/Native.hs
--- a/src/Text/Pandoc/Readers/Native.hs
+++ b/src/Text/Pandoc/Readers/Native.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2011-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -30,6 +31,7 @@
 -}
 module Text.Pandoc.Readers.Native ( readNative ) where
 
+import Prelude
 import Text.Pandoc.Definition
 import Text.Pandoc.Options (ReaderOptions)
 import Text.Pandoc.Shared (safeRead)
diff --git a/src/Text/Pandoc/Readers/OPML.hs b/src/Text/Pandoc/Readers/OPML.hs
--- a/src/Text/Pandoc/Readers/OPML.hs
+++ b/src/Text/Pandoc/Readers/OPML.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleContexts #-}
 module Text.Pandoc.Readers.OPML ( readOPML ) where
+import Prelude
 import Control.Monad.State.Strict
 import Data.Char (toUpper)
 import Data.Default
diff --git a/src/Text/Pandoc/Readers/Odt.hs b/src/Text/Pandoc/Readers/Odt.hs
--- a/src/Text/Pandoc/Readers/Odt.hs
+++ b/src/Text/Pandoc/Readers/Odt.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE PatternGuards #-}
 
 {-
@@ -32,6 +33,7 @@
 
 module Text.Pandoc.Readers.Odt ( readOdt ) where
 
+import Prelude
 import Codec.Archive.Zip
 import qualified Text.XML.Light as XML
 
diff --git a/src/Text/Pandoc/Readers/Odt/Arrows/State.hs b/src/Text/Pandoc/Readers/Odt/Arrows/State.hs
--- a/src/Text/Pandoc/Readers/Odt/Arrows/State.hs
+++ b/src/Text/Pandoc/Readers/Odt/Arrows/State.hs
@@ -1,4 +1,4 @@
-
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE TupleSections     #-}
 {-
@@ -38,15 +38,13 @@
 
 module Text.Pandoc.Readers.Odt.Arrows.State where
 
+import Prelude
 import Prelude hiding (foldl, foldr)
 
 import Control.Arrow
 import qualified Control.Category as Cat
 import Control.Monad
 
-import Data.Foldable
-import Data.Monoid
-
 import Text.Pandoc.Readers.Odt.Arrows.Utils
 import Text.Pandoc.Readers.Odt.Generic.Fallible
 
@@ -131,7 +129,7 @@
 -- and one with any function.
 foldS :: (Foldable f, Monoid m) => ArrowState s x m -> ArrowState s (f x) m
 foldS a = ArrowState $ \(s,f) -> foldr a' (s,mempty) f
-  where a' x (s',m) = second (m <>)  $ runArrowState a (s',x)
+  where a' x (s',m) = second (mappend m)  $ runArrowState a (s',x)
 
 -- | Fold a state arrow through something 'Foldable'. Collect the results in a
 -- 'MonadPlus'.
diff --git a/src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs b/src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs
--- a/src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs
+++ b/src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
 
@@ -39,6 +40,7 @@
 -- We export everything
 module Text.Pandoc.Readers.Odt.Arrows.Utils where
 
+import Prelude
 import Control.Arrow
 import Control.Monad (join)
 
@@ -61,13 +63,13 @@
      => a b c0->a b c1->a b c2->a b c3->a b c4->a b c5
      -> a b (c0,c1,c2,c3,c4,c5      )
 
-and3 a b c           = (and2 a b          ) &&& c
+and3 a b c           = and2 a b &&& c
                        >>^ \((z,y          ) , x) -> (z,y,x          )
-and4 a b c d         = (and3 a b c        ) &&& d
+and4 a b c d         = and3 a b c &&& d
                        >>^ \((z,y,x        ) , w) -> (z,y,x,w        )
-and5 a b c d e       = (and4 a b c d      ) &&& e
+and5 a b c d e       = and4 a b c d &&& e
                        >>^ \((z,y,x,w      ) , v) -> (z,y,x,w,v      )
-and6 a b c d e f     = (and5 a b c d e    ) &&& f
+and6 a b c d e f     = and5 a b c d e &&& f
                        >>^ \((z,y,x,w,v    ) , u) -> (z,y,x,w,v,u    )
 
 liftA2 :: (Arrow a) => (x -> y -> z) -> a b x -> a b y -> a b z
diff --git a/src/Text/Pandoc/Readers/Odt/Base.hs b/src/Text/Pandoc/Readers/Odt/Base.hs
--- a/src/Text/Pandoc/Readers/Odt/Base.hs
+++ b/src/Text/Pandoc/Readers/Odt/Base.hs
@@ -1,5 +1,3 @@
-
-
 {-
 Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
 
diff --git a/src/Text/Pandoc/Readers/Odt/ContentReader.hs b/src/Text/Pandoc/Readers/Odt/ContentReader.hs
--- a/src/Text/Pandoc/Readers/Odt/ContentReader.hs
+++ b/src/Text/Pandoc/Readers/Odt/ContentReader.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE Arrows          #-}
 {-# LANGUAGE PatternGuards   #-}
 {-# LANGUAGE RecordWildCards #-}
@@ -39,6 +40,7 @@
 , read_body
 ) where
 
+import Prelude
 import Control.Applicative hiding (liftA, liftA2, liftA3)
 import Control.Arrow
 
@@ -520,7 +522,7 @@
 matchingElement ns name reader = (ns, name, asResultAccumulator reader)
   where
    asResultAccumulator :: (ArrowChoice a, Monoid m) => a m m -> a m (Fallible m)
-   asResultAccumulator a = liftAsSuccess $ keepingTheValue a >>% (<>)
+   asResultAccumulator a = liftAsSuccess $ keepingTheValue a >>% mappend
 
 --
 matchChildContent'   :: (Monoid result)
@@ -554,7 +556,7 @@
     read_plain_text' =      (     second ( arr extractText )
                               >>^ spreadChoice >>?! second text
                             )
-                       >>?% (<>)
+                       >>?% mappend
     --
     extractText     :: XML.Content -> Fallible String
     extractText (XML.Text cData) = succeedWith (XML.cdData cData)
@@ -565,7 +567,7 @@
                  $ matchChildContent [] read_plain_text
 
 
--- specifically. I honor that, although the current implementation of '(<>)'
+-- specifically. I honor that, although the current implementation of 'mappend'
 -- for 'Inlines' in "Text.Pandoc.Builder" will collapse them again.
 -- The rational is to be prepared for future modifications.
 read_spaces      :: InlineMatcher
diff --git a/src/Text/Pandoc/Readers/Odt/Generic/Fallible.hs b/src/Text/Pandoc/Readers/Odt/Generic/Fallible.hs
--- a/src/Text/Pandoc/Readers/Odt/Generic/Fallible.hs
+++ b/src/Text/Pandoc/Readers/Odt/Generic/Fallible.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 
 
 {-
@@ -38,8 +39,7 @@
 
 -- We export everything
 module Text.Pandoc.Readers.Odt.Generic.Fallible where
-
-import Data.Monoid ((<>))
+import Prelude
 
 -- | Default for now. Will probably become a class at some point.
 type Failure = ()
@@ -90,7 +90,7 @@
 -- (possibly combined) non-error. If both values represent an error, an error
 -- is returned.
 chooseMax :: (Monoid a, Monoid b) => Either a b -> Either a b -> Either a b
-chooseMax = chooseMaxWith (<>)
+chooseMax = chooseMaxWith mappend
 
 -- | If either of the values represents a non-error, the result is a
 -- (possibly combined) non-error. If both values represent an error, an error
@@ -100,7 +100,7 @@
                             -> Either a b
                             -> Either a b
 chooseMaxWith (><) (Right a) (Right b) = Right $ a >< b
-chooseMaxWith  _   (Left  a) (Left  b) = Left  $ a <> b
+chooseMaxWith  _   (Left  a) (Left  b) = Left  $ a `mappend` b
 chooseMaxWith  _   (Right a)     _     = Right a
 chooseMaxWith  _       _     (Right b) = Right b
 
diff --git a/src/Text/Pandoc/Readers/Odt/Generic/Namespaces.hs b/src/Text/Pandoc/Readers/Odt/Generic/Namespaces.hs
--- a/src/Text/Pandoc/Readers/Odt/Generic/Namespaces.hs
+++ b/src/Text/Pandoc/Readers/Odt/Generic/Namespaces.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
 
@@ -31,6 +32,7 @@
 
 module Text.Pandoc.Readers.Odt.Generic.Namespaces where
 
+import Prelude
 import qualified Data.Map as M
 
 --
diff --git a/src/Text/Pandoc/Readers/Odt/Generic/SetMap.hs b/src/Text/Pandoc/Readers/Odt/Generic/SetMap.hs
--- a/src/Text/Pandoc/Readers/Odt/Generic/SetMap.hs
+++ b/src/Text/Pandoc/Readers/Odt/Generic/SetMap.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
 
@@ -30,6 +31,7 @@
 
 module Text.Pandoc.Readers.Odt.Generic.SetMap where
 
+import Prelude
 import qualified Data.Map as M
 import qualified Data.Set as S
 
diff --git a/src/Text/Pandoc/Readers/Odt/Generic/Utils.hs b/src/Text/Pandoc/Readers/Odt/Generic/Utils.hs
--- a/src/Text/Pandoc/Readers/Odt/Generic/Utils.hs
+++ b/src/Text/Pandoc/Readers/Odt/Generic/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 
 
 {-# LANGUAGE TypeOperators #-}
@@ -51,6 +52,7 @@
 , composition
 ) where
 
+import Prelude
 import Control.Category (Category, (<<<), (>>>))
 import qualified Control.Category as Cat (id)
 import Control.Monad (msum)
diff --git a/src/Text/Pandoc/Readers/Odt/Generic/XMLConverter.hs b/src/Text/Pandoc/Readers/Odt/Generic/XMLConverter.hs
--- a/src/Text/Pandoc/Readers/Odt/Generic/XMLConverter.hs
+++ b/src/Text/Pandoc/Readers/Odt/Generic/XMLConverter.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE Arrows          #-}
 {-# LANGUAGE TupleSections   #-}
 {-# LANGUAGE GADTs           #-}
@@ -67,6 +68,7 @@
 , matchContent
 ) where
 
+import Prelude
 import           Control.Applicative  hiding ( liftA, liftA2 )
 import           Control.Monad               ( MonadPlus )
 import           Control.Arrow
diff --git a/src/Text/Pandoc/Readers/Odt/Namespaces.hs b/src/Text/Pandoc/Readers/Odt/Namespaces.hs
--- a/src/Text/Pandoc/Readers/Odt/Namespaces.hs
+++ b/src/Text/Pandoc/Readers/Odt/Namespaces.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2015 Martin Linnemann <theCodingMarlin@googlemail.com>
 
@@ -31,6 +32,7 @@
 module Text.Pandoc.Readers.Odt.Namespaces ( Namespace (..)
                                           ) where
 
+import Prelude
 import Data.List (isPrefixOf)
 import qualified Data.Map as M (empty, insert)
 import Data.Maybe (fromMaybe, listToMaybe)
diff --git a/src/Text/Pandoc/Readers/Odt/StyleReader.hs b/src/Text/Pandoc/Readers/Odt/StyleReader.hs
--- a/src/Text/Pandoc/Readers/Odt/StyleReader.hs
+++ b/src/Text/Pandoc/Readers/Odt/StyleReader.hs
@@ -1,5 +1,6 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE CPP             #-}
 {-# LANGUAGE Arrows          #-}
-
 {-# LANGUAGE RecordWildCards #-}
 {-# LANGUAGE TupleSections   #-}
 
@@ -57,6 +58,7 @@
 , readStylesAt
 ) where
 
+import Prelude
 import Control.Applicative hiding (liftA, liftA2, liftA3)
 import Control.Arrow
 
@@ -80,7 +82,6 @@
 import Text.Pandoc.Readers.Odt.Base
 import Text.Pandoc.Readers.Odt.Namespaces
 
-
 readStylesAt :: XML.Element -> Fallible Styles
 readStylesAt e = runConverter' readAllStyles mempty e
 
@@ -183,13 +184,14 @@
   deriving ( Show )
 
 -- Styles from a monoid under union
-instance Monoid Styles where
-  mempty  = Styles M.empty M.empty M.empty
-  mappend  (Styles sBn1 dSm1 lsBn1)
-           (Styles sBn2 dSm2 lsBn2)
+instance Semigroup Styles where
+  (Styles sBn1 dSm1 lsBn1) <> (Styles sBn2 dSm2 lsBn2)
           = Styles (M.union sBn1  sBn2)
                    (M.union dSm1  dSm2)
                    (M.union lsBn1 lsBn2)
+instance Monoid Styles where
+  mempty  = Styles M.empty M.empty M.empty
+  mappend = (<>)
 
 -- Not all families from the specifications are implemented, only those we need.
 -- But there are none that are not mentioned here.
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
--- a/src/Text/Pandoc/Readers/Org.hs
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2014-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
 
@@ -27,6 +28,7 @@
 -}
 module Text.Pandoc.Readers.Org ( readOrg ) where
 
+import Prelude
 import Text.Pandoc.Readers.Org.Blocks (blockList, meta)
 import Text.Pandoc.Readers.Org.ParserState (optionsToParserState)
 import Text.Pandoc.Readers.Org.Parsing (OrgParser, readWithM)
diff --git a/src/Text/Pandoc/Readers/Org/BlockStarts.hs b/src/Text/Pandoc/Readers/Org/BlockStarts.hs
--- a/src/Text/Pandoc/Readers/Org/BlockStarts.hs
+++ b/src/Text/Pandoc/Readers/Org/BlockStarts.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2014-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
 
@@ -40,6 +41,7 @@
   , endOfBlock
   ) where
 
+import Prelude
 import Control.Monad (void)
 import Text.Pandoc.Readers.Org.Parsing
 
diff --git a/src/Text/Pandoc/Readers/Org/Blocks.hs b/src/Text/Pandoc/Readers/Org/Blocks.hs
--- a/src/Text/Pandoc/Readers/Org/Blocks.hs
+++ b/src/Text/Pandoc/Readers/Org/Blocks.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2014-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
 
@@ -31,6 +32,7 @@
   , meta
   ) where
 
+import Prelude
 import Text.Pandoc.Readers.Org.BlockStarts
 import Text.Pandoc.Readers.Org.DocumentTree (documentTree, headlineToBlocks)
 import Text.Pandoc.Readers.Org.Inlines
@@ -51,7 +53,6 @@
 import Data.Default (Default)
 import Data.List (foldl', isPrefixOf)
 import Data.Maybe (fromMaybe, isJust, isNothing)
-import Data.Monoid ((<>))
 
 import qualified Text.Pandoc.Builder as B
 import qualified Text.Pandoc.Walk as Walk
diff --git a/src/Text/Pandoc/Readers/Org/DocumentTree.hs b/src/Text/Pandoc/Readers/Org/DocumentTree.hs
--- a/src/Text/Pandoc/Readers/Org/DocumentTree.hs
+++ b/src/Text/Pandoc/Readers/Org/DocumentTree.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2014-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
 
@@ -32,11 +33,11 @@
   , headlineToBlocks
   ) where
 
+import Prelude
 import Control.Arrow ((***))
 import Control.Monad (guard, void)
 import Data.Char (toLower, toUpper)
 import Data.List (intersperse)
-import Data.Monoid ((<>))
 import Text.Pandoc.Builder (Blocks, Inlines)
 import Text.Pandoc.Class (PandocMonad)
 import Text.Pandoc.Definition
diff --git a/src/Text/Pandoc/Readers/Org/ExportSettings.hs b/src/Text/Pandoc/Readers/Org/ExportSettings.hs
--- a/src/Text/Pandoc/Readers/Org/ExportSettings.hs
+++ b/src/Text/Pandoc/Readers/Org/ExportSettings.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2016-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
 
@@ -29,6 +30,7 @@
   ( exportSettings
   ) where
 
+import Prelude
 import Text.Pandoc.Readers.Org.ParserState
 import Text.Pandoc.Readers.Org.Parsing
 
diff --git a/src/Text/Pandoc/Readers/Org/Inlines.hs b/src/Text/Pandoc/Readers/Org/Inlines.hs
--- a/src/Text/Pandoc/Readers/Org/Inlines.hs
+++ b/src/Text/Pandoc/Readers/Org/Inlines.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-
 Copyright (C) 2014-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
@@ -33,6 +34,7 @@
   , linkTarget
   ) where
 
+import Prelude
 import Text.Pandoc.Readers.Org.BlockStarts (endOfBlock, noteMarker)
 import Text.Pandoc.Readers.Org.ParserState
 import Text.Pandoc.Readers.Org.Parsing
@@ -55,9 +57,6 @@
 import Data.List (intersperse)
 import qualified Data.Map as M
 import Data.Maybe (fromMaybe)
-import Data.Monoid ((<>))
-import Data.Traversable (sequence)
-import Prelude hiding (sequence)
 
 --
 -- Functions acting on the parser state
diff --git a/src/Text/Pandoc/Readers/Org/Meta.hs b/src/Text/Pandoc/Readers/Org/Meta.hs
--- a/src/Text/Pandoc/Readers/Org/Meta.hs
+++ b/src/Text/Pandoc/Readers/Org/Meta.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE TupleSections    #-}
 {-
@@ -33,6 +34,7 @@
   , metaLine
   ) where
 
+import Prelude
 import Text.Pandoc.Readers.Org.BlockStarts
 import Text.Pandoc.Readers.Org.ExportSettings (exportSettings)
 import Text.Pandoc.Readers.Org.Inlines
diff --git a/src/Text/Pandoc/Readers/Org/ParserState.hs b/src/Text/Pandoc/Readers/Org/ParserState.hs
--- a/src/Text/Pandoc/Readers/Org/ParserState.hs
+++ b/src/Text/Pandoc/Readers/Org/ParserState.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleInstances     #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-
@@ -54,6 +55,7 @@
   , optionsToParserState
   ) where
 
+import Prelude
 import Control.Monad.Reader (ReaderT, asks, local)
 
 import Data.Default (Default (..))
diff --git a/src/Text/Pandoc/Readers/Org/Parsing.hs b/src/Text/Pandoc/Readers/Org/Parsing.hs
--- a/src/Text/Pandoc/Readers/Org/Parsing.hs
+++ b/src/Text/Pandoc/Readers/Org/Parsing.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2014-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
 
@@ -112,6 +113,7 @@
   , getPosition
   ) where
 
+import Prelude
 import Text.Pandoc.Readers.Org.ParserState
 
 import Text.Pandoc.Parsing hiding (F, anyLine, blanklines, newline,
diff --git a/src/Text/Pandoc/Readers/Org/Shared.hs b/src/Text/Pandoc/Readers/Org/Shared.hs
--- a/src/Text/Pandoc/Readers/Org/Shared.hs
+++ b/src/Text/Pandoc/Readers/Org/Shared.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-
 Copyright (C) 2014-2018 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
@@ -33,6 +34,7 @@
   , translateLang
   ) where
 
+import Prelude
 import Data.Char (isAlphaNum)
 import Data.List (isPrefixOf, isSuffixOf)
 
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleContexts    #-}
 {-# LANGUAGE OverloadedStrings   #-}
 {-# LANGUAGE ScopedTypeVariables #-}
@@ -31,6 +32,7 @@
 Conversion from reStructuredText to 'Pandoc' document.
 -}
 module Text.Pandoc.Readers.RST ( readRST ) where
+import Prelude
 import Control.Arrow (second)
 import Control.Monad (forM_, guard, liftM, mplus, mzero, when)
 import Control.Monad.Except (throwError)
@@ -40,7 +42,6 @@
                   nub, sort, transpose, union)
 import qualified Data.Map as M
 import Data.Maybe (fromMaybe, isJust)
-import Data.Monoid ((<>))
 import Data.Sequence (ViewR (..), viewr)
 import Data.Text (Text)
 import qualified Data.Text as T
@@ -80,7 +81,7 @@
 ---
 
 bulletListMarkers :: [Char]
-bulletListMarkers = "*+-"
+bulletListMarkers = "*+-•‣⁃"
 
 underlineChars :: [Char]
 underlineChars = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
diff --git a/src/Text/Pandoc/Readers/TWiki.hs b/src/Text/Pandoc/Readers/TWiki.hs
--- a/src/Text/Pandoc/Readers/TWiki.hs
+++ b/src/Text/Pandoc/Readers/TWiki.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleContexts     #-}
 {-# LANGUAGE FlexibleInstances    #-}
 {-# LANGUAGE RelaxedPolyRec       #-}
@@ -35,6 +36,7 @@
 module Text.Pandoc.Readers.TWiki ( readTWiki
                                  ) where
 
+import Prelude
 import Control.Monad
 import Control.Monad.Except (throwError)
 import Data.Char (isAlphaNum)
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs
--- a/src/Text/Pandoc/Readers/Textile.hs
+++ b/src/Text/Pandoc/Readers/Textile.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2010-2012 Paul Rivier <paul*rivier#demotera*com> | tr '*#' '.@'
               2010-2018 John MacFarlane
@@ -52,11 +53,11 @@
 
 
 module Text.Pandoc.Readers.Textile ( readTextile) where
+import Prelude
 import Control.Monad (guard, liftM)
 import Control.Monad.Except (throwError)
 import Data.Char (digitToInt, isUpper)
 import Data.List (intercalate, intersperse, transpose)
-import Data.Monoid ((<>))
 import Data.Text (Text)
 import qualified Data.Text as T
 import Text.HTML.TagSoup (Tag (..), fromAttrib)
diff --git a/src/Text/Pandoc/Readers/TikiWiki.hs b/src/Text/Pandoc/Readers/TikiWiki.hs
--- a/src/Text/Pandoc/Readers/TikiWiki.hs
+++ b/src/Text/Pandoc/Readers/TikiWiki.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleContexts     #-}
 {-# LANGUAGE FlexibleInstances    #-}
 {-# LANGUAGE OverloadedStrings    #-}
@@ -19,6 +20,7 @@
 module Text.Pandoc.Readers.TikiWiki ( readTikiWiki
                                     ) where
 
+import Prelude
 import Control.Monad
 import Control.Monad.Except (throwError)
 import qualified Data.Foldable as F
diff --git a/src/Text/Pandoc/Readers/Txt2Tags.hs b/src/Text/Pandoc/Readers/Txt2Tags.hs
--- a/src/Text/Pandoc/Readers/Txt2Tags.hs
+++ b/src/Text/Pandoc/Readers/Txt2Tags.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2014 Matthew Pickering <matthewtpickering@gmail.com>
 
@@ -31,6 +32,7 @@
                                     )
                                     where
 
+import Prelude
 import Control.Monad (guard, void, when)
 import Control.Monad.Except (catchError, throwError)
 import Control.Monad.Reader (Reader, asks, runReader)
@@ -38,7 +40,6 @@
 import Data.Default
 import Data.List (intercalate, transpose)
 import Data.Maybe (fromMaybe)
-import Data.Monoid ((<>))
 import Data.Text (Text)
 import qualified Data.Text as T
 import Data.Time.Format (formatTime)
@@ -46,7 +47,7 @@
 import qualified Text.Pandoc.Builder as B
 import Text.Pandoc.Class (PandocMonad)
 import qualified Text.Pandoc.Class as P
-import Text.Pandoc.Compat.Time (defaultTimeLocale)
+import Data.Time (defaultTimeLocale)
 import Text.Pandoc.Definition
 import Text.Pandoc.Options
 import Text.Pandoc.Parsing hiding (space, spaces, uri)
@@ -444,7 +445,7 @@
       let end' = case drop 2 end of
                           "" -> mempty
                           xs -> special xs
-      return $ f (start' <> body' <> end')
+      return $ f (start' `mappend` body' `mappend` end')
     Nothing -> do -- Either bad or case such as *****
       guard (l >= 5)
       let body' = replicate (l - 4) c
diff --git a/src/Text/Pandoc/Readers/Vimwiki.hs b/src/Text/Pandoc/Readers/Vimwiki.hs
--- a/src/Text/Pandoc/Readers/Vimwiki.hs
+++ b/src/Text/Pandoc/Readers/Vimwiki.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE CPP #-}
 {-
   Copyright (C) 2017-2018 Yuchen Pei <me@ypei.me>
 
@@ -63,12 +65,12 @@
 
 module Text.Pandoc.Readers.Vimwiki ( readVimwiki
                                  ) where
+import Prelude
 import Control.Monad (guard)
 import Control.Monad.Except (throwError)
 import Data.Default
 import Data.List (isInfixOf, isPrefixOf)
 import Data.Maybe
-import Data.Monoid ((<>))
 import Data.Text (Text, unpack)
 import Text.Pandoc.Builder (Blocks, Inlines, fromList, toList, trimInlines)
 import qualified Text.Pandoc.Builder as B (blockQuote, bulletList, code,
diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs
--- a/src/Text/Pandoc/SelfContained.hs
+++ b/src/Text/Pandoc/SelfContained.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-
 Copyright (C) 2011-2018 John MacFarlane <jgm@berkeley.edu>
@@ -31,6 +32,7 @@
 the HTML using data URIs.
 -}
 module Text.Pandoc.SelfContained ( makeDataURI, makeSelfContained ) where
+import Prelude
 import Codec.Compression.GZip as Gzip
 import Control.Applicative ((<|>))
 import Control.Monad.Except (throwError)
@@ -41,7 +43,6 @@
 import qualified Data.ByteString.Lazy as L
 import Data.Char (isAlphaNum, isAscii, toLower)
 import Data.List (isPrefixOf)
-import Data.Monoid ((<>))
 import Network.URI (escapeURIString)
 import System.FilePath (takeDirectory, takeExtension, (</>))
 import Text.HTML.TagSoup
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE CPP                   #-}
 {-# LANGUAGE DeriveDataTypeable    #-}
 {-# LANGUAGE FlexibleContexts      #-}
@@ -100,6 +101,7 @@
                      pandocVersion
                     ) where
 
+import Prelude
 import Codec.Archive.Zip
 import qualified Control.Exception as E
 import Control.Monad (MonadPlus (..), msum, unless)
@@ -111,7 +113,6 @@
 import Data.List (find, intercalate, intersperse, stripPrefix)
 import qualified Data.Map as M
 import Data.Maybe (mapMaybe)
-import Data.Monoid ((<>))
 import Data.Sequence (ViewL (..), ViewR (..), viewl, viewr)
 import qualified Data.Set as Set
 import qualified Data.Text as T
@@ -126,7 +127,7 @@
                           renderTagsOptions)
 import Text.Pandoc.Builder (Blocks, Inlines, ToMetaValue (..))
 import qualified Text.Pandoc.Builder as B
-import Text.Pandoc.Compat.Time
+import Data.Time
 import Text.Pandoc.Definition
 import Text.Pandoc.Generic (bottomUp)
 import Text.Pandoc.Pretty (charWidth)
@@ -286,12 +287,7 @@
   where rejectBadYear day = case toGregorian day of
           (y, _, _) | y >= 1601 && y <= 9999 -> Just day
           _         -> Nothing
-        parsetimeWith =
-#if MIN_VERSION_time(1,5,0)
-             parseTimeM True defaultTimeLocale
-#else
-             parseTime defaultTimeLocale
-#endif
+        parsetimeWith = parseTimeM True defaultTimeLocale
         formats = ["%x","%m/%d/%Y", "%D","%F", "%d %b %Y",
                     "%e %B %Y", "%b. %e, %Y", "%B %e, %Y",
                     "%Y%m%d", "%Y%m", "%Y"]
@@ -447,7 +443,7 @@
     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
+  query f (Sec _ _ _ ils elts) = query f ils `mappend` query f elts
 
 instance Walkable Block Element where
   walk f (Blk x) = Blk (walk f x)
@@ -458,7 +454,7 @@
     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
+  query f (Sec _ _ _ ils elts) = query f ils `mappend` query f elts
 
 
 -- | Convert Pandoc inline list to plain text identifier.  HTML
diff --git a/src/Text/Pandoc/Slides.hs b/src/Text/Pandoc/Slides.hs
--- a/src/Text/Pandoc/Slides.hs
+++ b/src/Text/Pandoc/Slides.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2012-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -29,6 +30,7 @@
 show formats (dzslides, revealjs, s5, slidy, slideous, beamer).
 -}
 module Text.Pandoc.Slides ( getSlideLevel, prepSlides ) where
+import Prelude
 import Text.Pandoc.Definition
 
 -- | Find level of header that starts slides (defined as the least header
diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs
--- a/src/Text/Pandoc/Templates.hs
+++ b/src/Text/Pandoc/Templates.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleInstances    #-}
 
 {-# LANGUAGE OverloadedStrings    #-}
@@ -38,6 +39,7 @@
                              , getDefaultTemplate
                              ) where
 
+import Prelude
 import Control.Monad.Except (throwError)
 import Data.Aeson (ToJSON (..))
 import qualified Data.Text as T
diff --git a/src/Text/Pandoc/Translations.hs b/src/Text/Pandoc/Translations.hs
--- a/src/Text/Pandoc/Translations.hs
+++ b/src/Text/Pandoc/Translations.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE CPP                        #-}
 {-# LANGUAGE DeriveGeneric              #-}
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
 {-
@@ -45,6 +47,7 @@
                          , readTranslations
                          )
 where
+import Prelude
 import Data.Aeson.Types (typeMismatch)
 import qualified Data.HashMap.Strict as HM
 import qualified Data.Map as M
@@ -80,7 +83,7 @@
   deriving (Show, Eq, Ord, Generic, Enum, Read)
 
 newtype Translations = Translations (M.Map Term String)
-        deriving (Show, Generic, Monoid)
+        deriving (Show, Generic, Semigroup, Monoid)
 
 instance FromJSON Term where
   parseJSON (String t) = case safeRead (T.unpack t) of
diff --git a/src/Text/Pandoc/UTF8.hs b/src/Text/Pandoc/UTF8.hs
--- a/src/Text/Pandoc/UTF8.hs
+++ b/src/Text/Pandoc/UTF8.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-
 Copyright (C) 2010-2018 John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/UUID.hs b/src/Text/Pandoc/UUID.hs
--- a/src/Text/Pandoc/UUID.hs
+++ b/src/Text/Pandoc/UUID.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2010-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -31,6 +32,7 @@
 
 module Text.Pandoc.UUID ( UUID(..), getRandomUUID, getUUID ) where
 
+import Prelude
 import Data.Bits (clearBit, setBit)
 import Data.Word
 import System.Random (RandomGen, getStdGen, randoms)
diff --git a/src/Text/Pandoc/Writers.hs b/src/Text/Pandoc/Writers.hs
--- a/src/Text/Pandoc/Writers.hs
+++ b/src/Text/Pandoc/Writers.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -82,6 +83,7 @@
     , getWriter
     ) where
 
+import Prelude
 import Data.Aeson
 import qualified Data.ByteString.Lazy as BL
 import Data.List (intercalate)
diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs
--- a/src/Text/Pandoc/Writers/AsciiDoc.hs
+++ b/src/Text/Pandoc/Writers/AsciiDoc.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-
 Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu>
@@ -37,6 +38,7 @@
 AsciiDoc:  <http://www.methods.co.nz/asciidoc/>
 -}
 module Text.Pandoc.Writers.AsciiDoc (writeAsciiDoc) where
+import Prelude
 import Control.Monad.State.Strict
 import Data.Aeson (Result (..), Value (String), fromJSON, toJSON)
 import Data.Char (isPunctuation, isSpace)
diff --git a/src/Text/Pandoc/Writers/CommonMark.hs b/src/Text/Pandoc/Writers/CommonMark.hs
--- a/src/Text/Pandoc/Writers/CommonMark.hs
+++ b/src/Text/Pandoc/Writers/CommonMark.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-
 Copyright (C) 2015-2018 John MacFarlane <jgm@berkeley.edu>
@@ -32,11 +33,12 @@
 -}
 module Text.Pandoc.Writers.CommonMark (writeCommonMark) where
 
+import Prelude
 import CMarkGFM
 import Control.Monad.State.Strict (State, get, modify, runState)
 import Data.Foldable (foldrM)
 import Data.List (transpose)
-import Data.Monoid (Any (..), (<>))
+import Data.Monoid (Any (..))
 import Data.Text (Text)
 import qualified Data.Text as T
 import Network.HTTP (urlEncode)
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs
--- a/src/Text/Pandoc/Writers/ConTeXt.hs
+++ b/src/Text/Pandoc/Writers/ConTeXt.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings   #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 {-
@@ -30,6 +31,7 @@
 Conversion of 'Pandoc' format into ConTeXt.
 -}
 module Text.Pandoc.Writers.ConTeXt ( writeConTeXt ) where
+import Prelude
 import Control.Monad.State.Strict
 import Data.Char (ord, isDigit)
 import Data.List (intercalate, intersperse)
diff --git a/src/Text/Pandoc/Writers/Custom.hs b/src/Text/Pandoc/Writers/Custom.hs
--- a/src/Text/Pandoc/Writers/Custom.hs
+++ b/src/Text/Pandoc/Writers/Custom.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE DeriveDataTypeable   #-}
 {-# LANGUAGE FlexibleInstances    #-}
 {- Copyright (C) 2012-2018 John MacFarlane <jgm@berkeley.edu>
@@ -30,6 +31,7 @@
 a lua writer.
 -}
 module Text.Pandoc.Writers.Custom ( writeCustom ) where
+import Prelude
 import Control.Arrow ((***))
 import Control.Exception
 import Control.Monad (when)
diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs
--- a/src/Text/Pandoc/Writers/Docbook.hs
+++ b/src/Text/Pandoc/Writers/Docbook.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE PatternGuards     #-}
 {-
@@ -30,6 +31,7 @@
 Conversion of 'Pandoc' documents to Docbook XML.
 -}
 module Text.Pandoc.Writers.Docbook ( writeDocbook4, writeDocbook5 ) where
+import Prelude
 import Control.Monad.Reader
 import Data.Char (toLower)
 import Data.Generics (everywhere, mkT)
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE PatternGuards       #-}
 {-# LANGUAGE RankNTypes          #-}
 {-# LANGUAGE ScopedTypeVariables #-}
@@ -32,6 +33,7 @@
 Conversion of 'Pandoc' documents to docx.
 -}
 module Text.Pandoc.Writers.Docx ( writeDocx ) where
+import Prelude
 import Codec.Archive.Zip
 import Control.Applicative ((<|>))
 import Control.Monad.Except (catchError)
@@ -51,7 +53,7 @@
 import Text.Pandoc.BCP47 (getLang, renderLang)
 import Text.Pandoc.Class (PandocMonad, report, toLang)
 import qualified Text.Pandoc.Class as P
-import Text.Pandoc.Compat.Time
+import Data.Time
 import Text.Pandoc.Definition
 import Text.Pandoc.Generic
 import Text.Pandoc.Highlighting (highlight)
@@ -708,12 +710,12 @@
           styleFor UpperRoman _   = "upperRoman"
           styleFor LowerRoman _   = "lowerRoman"
           styleFor Decimal _      = "decimal"
-          styleFor DefaultStyle 1 = "decimal"
-          styleFor DefaultStyle 2 = "lowerLetter"
-          styleFor DefaultStyle 3 = "lowerRoman"
-          styleFor DefaultStyle 4 = "decimal"
-          styleFor DefaultStyle 5 = "lowerLetter"
-          styleFor DefaultStyle 0 = "lowerRoman"
+          styleFor DefaultStyle 0 = "decimal"
+          styleFor DefaultStyle 1 = "lowerLetter"
+          styleFor DefaultStyle 2 = "lowerRoman"
+          styleFor DefaultStyle 3 = "decimal"
+          styleFor DefaultStyle 4 = "lowerLetter"
+          styleFor DefaultStyle 5 = "lowerRoman"
           styleFor DefaultStyle x = styleFor DefaultStyle (x `mod` 6)
           styleFor _ _            = "decimal"
           patternFor OneParen s  = s ++ ")"
@@ -1337,7 +1339,7 @@
         imgElt
 
   case stImage of
-    Just imgData -> return $ [generateImgElt imgData]
+    Just imgData -> return [generateImgElt imgData]
     Nothing -> ( do --try
       (img, mt) <- P.fetchItem src
       ident <- ("rId"++) `fmap` getUniqueId
@@ -1386,12 +1388,12 @@
 defaultFootnotes :: [Element]
 defaultFootnotes = [ mknode "w:footnote"
                      [("w:type", "separator"), ("w:id", "-1")]
-                     [ mknode "w:p" [] $
+                     [ mknode "w:p" []
                        [mknode "w:r" [] $
                         [ mknode "w:separator" [] ()]]]
                    , mknode "w:footnote"
                      [("w:type", "continuationSeparator"), ("w:id", "0")]
-                     [ mknode "w:p" [] $
+                     [ mknode "w:p" []
                        [ mknode "w:r" [] $
                          [ mknode "w:continuationSeparator" [] ()]]]]
 
diff --git a/src/Text/Pandoc/Writers/DokuWiki.hs b/src/Text/Pandoc/Writers/DokuWiki.hs
--- a/src/Text/Pandoc/Writers/DokuWiki.hs
+++ b/src/Text/Pandoc/Writers/DokuWiki.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2008-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -39,6 +40,7 @@
 -}
 
 module Text.Pandoc.Writers.DokuWiki ( writeDokuWiki ) where
+import Prelude
 import Control.Monad (zipWithM)
 import Control.Monad.Reader (ReaderT, ask, local, runReaderT)
 import Control.Monad.State.Strict (StateT, evalStateT)
@@ -366,12 +368,16 @@
 vcat :: [String] -> String
 vcat = intercalate "\n"
 
-backSlashLineBreaks :: String -> String
-backSlashLineBreaks cs = reverse $ g $ reverse $ concatMap f cs
-  where f '\n' = "\\\\ "
-        f c    = [c]
-        g (' ' : '\\':'\\': xs) = xs
-        g s                     = s
+-- | For each string in the input list, convert all newlines to
+-- dokuwiki escaped newlines. Then concat the list using double linebreaks.
+backSlashLineBreaks :: [String] -> String
+backSlashLineBreaks ls = vcatBackSlash $ map escape ls
+  where
+    vcatBackSlash = intercalate "\\\\ \\\\ " -- simulate paragraphs.
+    escape ['\n'] = "" -- remove trailing newlines
+    escape ('\n':cs) = "\\\\ " ++ escape cs
+    escape (c:cs)    = c : escape cs
+    escape []        = []
 
 -- Auxiliary functions for tables:
 
@@ -400,7 +406,7 @@
   backSlash <- stBackSlashLB <$> ask
   let blocks' = consolidateRawBlocks blocks
   if backSlash
-    then (backSlashLineBreaks . vcat) <$> mapM (blockToDokuWiki opts) blocks'
+    then backSlashLineBreaks <$> mapM (blockToDokuWiki opts) blocks'
     else vcat <$> mapM (blockToDokuWiki opts) blocks'
 
 consolidateRawBlocks :: [Block] -> [Block]
@@ -479,7 +485,11 @@
   | f == Format "html"     = return $ "<html>" ++ str ++ "</html>"
   | otherwise              = "" <$ report (InlineNotRendered il)
 
-inlineToDokuWiki _ LineBreak = return "\\\\\n"
+inlineToDokuWiki _ LineBreak = do
+  backSlash <- stBackSlashLB <$> ask
+  return $ if backSlash
+           then "\n"
+           else "\\\\\n"
 
 inlineToDokuWiki opts SoftBreak =
   case writerWrapText opts of
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE CPP                 #-}
 {-# LANGUAGE FlexibleContexts    #-}
 {-# LANGUAGE PatternGuards       #-}
@@ -32,6 +33,7 @@
 Conversion of 'Pandoc' documents to EPUB.
 -}
 module Text.Pandoc.Writers.EPUB ( writeEPUB2, writeEPUB3 ) where
+import Prelude
 import Codec.Archive.Zip (Entry, addEntryToArchive, eRelativePath, emptyArchive,
                           fromArchive, fromEntry, toEntry)
 import Control.Monad (mplus, unless, when, zipWithM)
@@ -53,7 +55,7 @@
 import Text.Pandoc.Builder (fromList, setMeta)
 import Text.Pandoc.Class (PandocMonad, report)
 import qualified Text.Pandoc.Class as P
-import Text.Pandoc.Compat.Time
+import Data.Time
 import Text.Pandoc.Definition
 import Text.Pandoc.Error
 import Text.Pandoc.Logging
@@ -458,7 +460,7 @@
   -- mediaRef <- P.newIORef []
   Pandoc _ blocks <- walkM (transformInline opts') doc >>=
                      walkM transformBlock
-  picEntries <- (mapMaybe (snd . snd)) <$> gets stMediaPaths
+  picEntries <- mapMaybe (snd . snd) <$> gets stMediaPaths
   -- handle fonts
   let matchingGlob f = do
         xs <- lift $ P.glob f
@@ -749,12 +751,13 @@
                                (writeHtmlStringForEPUB version
                                  opts{ writerTemplate = Nothing }
                                  (Pandoc nullMeta
-                                   [Plain $ walk delink tit])) of
+                                   [Plain $ walk clean tit])) of
                                 Left _  -> TS.pack $ stringify tit
                                 Right x -> x
-                -- can't have a element inside a...
-                delink (Link _ ils _) = Span ("", [], []) ils
-                delink x              = x
+                -- can't have <a> elements inside generated links...
+                clean (Link _ ils _) = Span ("", [], []) ils
+                clean (Note _)       = Str ""
+                clean x              = x
 
   let navtag = if epub3 then "nav" else "div"
   tocBlocks <- lift $ evalStateT (mapM (navPointNode navXhtmlFormatter) secs) 1
@@ -872,7 +875,7 @@
         dcTag' n s = [dcTag n s]
         toIdentifierNode id' (Identifier txt scheme)
           | version == EPUB2 = [dcNode "identifier" !
-              ([("id",id')] ++ maybe [] (\x -> [("opf:scheme", x)]) scheme) $
+              (("id",id') : maybe [] (\x -> [("opf:scheme", x)]) scheme) $
               txt]
           | otherwise = [dcNode "identifier" ! [("id",id')] $ txt] ++
               maybe [] (\x -> [unode "meta" !
diff --git a/src/Text/Pandoc/Writers/FB2.hs b/src/Text/Pandoc/Writers/FB2.hs
--- a/src/Text/Pandoc/Writers/FB2.hs
+++ b/src/Text/Pandoc/Writers/FB2.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE PatternGuards #-}
 
 {-
@@ -37,6 +38,7 @@
 -}
 module Text.Pandoc.Writers.FB2 (writeFB2)  where
 
+import Prelude
 import Control.Monad (zipWithM)
 import Control.Monad.Except (catchError)
 import Control.Monad.State.Strict (StateT, evalStateT, get, lift, liftM, modify)
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE CPP                 #-}
 {-# LANGUAGE OverloadedStrings   #-}
 {-# LANGUAGE ScopedTypeVariables #-}
@@ -45,11 +46,11 @@
   writeRevealJs,
   tagWithAttributes
   ) where
+import Prelude
 import Control.Monad.State.Strict
 import Data.Char (ord, toLower)
 import Data.List (intercalate, intersperse, isPrefixOf, partition)
 import Data.Maybe (catMaybes, fromMaybe, isJust, isNothing)
-import Data.Monoid ((<>))
 import qualified Data.Set as Set
 import Data.String (fromString)
 import Data.Text (Text)
@@ -277,17 +278,15 @@
                          H.script ! A.src (toValue url)
                                   ! A.type_ "text/javascript"
                                   $ mempty
-                      KaTeX url ->
-                         (H.script !
-                           A.src (toValue $ url ++ "katex.min.js") $ mempty) <>
-                         (H.script !
-                           A.src (toValue $ url ++ "contrib/auto-render.min.js")
-                             $ mempty) <>
-                         (
-                                  H.script
-                            "document.addEventListener(\"DOMContentLoaded\", function() {\n  renderMathInElement(document.body);\n});") <>
-                         (H.link ! A.rel "stylesheet" !
-                           A.href (toValue $ url ++ "katex.min.css"))
+                      KaTeX url -> do
+                         H.script !
+                           A.src (toValue $ url ++ "katex.min.js") $ mempty
+                         H.script !
+                           A.src (toValue $ url ++ "contrib/auto-render.min.js") $ mempty
+                         H.script
+                            "document.addEventListener(\"DOMContentLoaded\", function() {\n  renderMathInElement(document.body);\n});"
+                         H.link ! A.rel "stylesheet" !
+                           A.href (toValue $ url ++ "katex.min.css")
 
                       _ -> case lookup "mathml-script" (writerVariables opts) of
                                  Just s | not (stHtml5 st) ->
@@ -962,8 +961,9 @@
                                      WrapNone     -> preEscapedString " "
                                      WrapAuto     -> preEscapedString " "
                                      WrapPreserve -> preEscapedString "\n"
-    LineBreak      -> return $ (if html5 then H5.br else H.br)
-                                 <> strToHtml "\n"
+    LineBreak      -> return $ do
+                        if html5 then H5.br else H.br
+                        strToHtml "\n"
     (Span (id',classes,kvs) ils)
                      -> inlineListToHtml opts ils >>=
                            addAttrs opts attr' . H.span
diff --git a/src/Text/Pandoc/Writers/Haddock.hs b/src/Text/Pandoc/Writers/Haddock.hs
--- a/src/Text/Pandoc/Writers/Haddock.hs
+++ b/src/Text/Pandoc/Writers/Haddock.hs
@@ -1,6 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings   #-}
 {-# LANGUAGE ScopedTypeVariables #-}
-{-# LANGUAGE TupleSections       #-}
+
 {-
 Copyright (C) 2014-2015, 2017-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -33,9 +34,9 @@
 Haddock:  <http://www.haskell.org/haddock/doc/html/>
 -}
 module Text.Pandoc.Writers.Haddock (writeHaddock) where
+import Prelude
 import Control.Monad.State.Strict
 import Data.Default
-import Data.List (intersperse, transpose)
 import Data.Text (Text)
 import Text.Pandoc.Class (PandocMonad, report)
 import Text.Pandoc.Definition
@@ -136,29 +137,15 @@
 -- 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 -> (nest 2,) <$>
-                         pandocTable opts (all null headers) aligns widths
-                             rawHeaders rawRows
-                  | not hasBlocks -> (nest 2,) <$>
-                         pandocTable opts (all null headers) aligns widths
-                             rawHeaders rawRows
-                  | otherwise -> (id,) <$>
-                         gridTable opts blockListToHaddock
-                          (all null headers) aligns widths headers rows
-  return $ prefixed "> " (nst $ tbl $$ blankline $$ caption'') $$ blankline
+  tbl <- gridTable opts blockListToHaddock
+              (all null headers) (map (const AlignDefault) aligns)
+                widths headers rows
+  return $ prefixed "> " (tbl $$ blankline $$ caption'') $$ blankline
 blockToHaddock opts (BulletList items) = do
   contents <- mapM (bulletListItemToHaddock opts) items
   return $ cat contents <> blankline
@@ -173,46 +160,6 @@
 blockToHaddock opts (DefinitionList items) = do
   contents <- mapM (definitionListItemToHaddock opts) items
   return $ cat contents <> blankline
-
-pandocTable :: PandocMonad m
-            => WriterOptions -> Bool -> [Alignment] -> [Double]
-            -> [Doc] -> [[Doc]] -> StateT WriterState m Doc
-pandocTable opts headless aligns widths rawHeaders rawRows =  do
-  let isSimple = all (==0) widths
-  let alignHeader alignment = case alignment of
-                                AlignLeft    -> lblock
-                                AlignCenter  -> cblock
-                                AlignRight   -> rblock
-                                AlignDefault -> lblock
-  let numChars = maximum . map offset
-  let widthsInChars = if isSimple
-                         then map ((+2) . numChars)
-                              $ transpose (rawHeaders : rawRows)
-                         else map
-                              (floor . (fromIntegral (writerColumns opts) *))
-                              widths
-  let makeRow = hcat . intersperse (lblock 1 (text " ")) .
-                   zipWith3 alignHeader aligns widthsInChars
-  let rows' = map makeRow rawRows
-  let head' = makeRow rawHeaders
-  let maxRowHeight = maximum $ map height (head':rows')
-  let underline = cat $ intersperse (text " ") $
-                  map (\width -> text (replicate width '-')) widthsInChars
-  let border
-        | maxRowHeight > 1 = text (replicate (sum widthsInChars +
-                 length widthsInChars - 1) '-')
-        | headless = underline
-        | otherwise = 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
 
 -- | Convert bullet list item (list of blocks) to haddock
 bulletListItemToHaddock :: PandocMonad m
diff --git a/src/Text/Pandoc/Writers/ICML.hs b/src/Text/Pandoc/Writers/ICML.hs
--- a/src/Text/Pandoc/Writers/ICML.hs
+++ b/src/Text/Pandoc/Writers/ICML.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleContexts    #-}
 {-# LANGUAGE OverloadedStrings   #-}
 {-# LANGUAGE ScopedTypeVariables #-}
@@ -16,6 +17,7 @@
 into InDesign with File -> Place.
 -}
 module Text.Pandoc.Writers.ICML (writeICML) where
+import Prelude
 import Control.Monad.Except (catchError)
 import Control.Monad.State.Strict
 import Data.List (intersperse, isInfixOf, isPrefixOf, stripPrefix)
diff --git a/src/Text/Pandoc/Writers/JATS.hs b/src/Text/Pandoc/Writers/JATS.hs
--- a/src/Text/Pandoc/Writers/JATS.hs
+++ b/src/Text/Pandoc/Writers/JATS.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 
 {-
@@ -28,9 +29,10 @@
 
 Conversion of 'Pandoc' documents to JATS XML.
 Reference:
-https://jats.nlm.nih.gov/publishing/tag-library/1.1d3/element/mml-math.html
+https://jats.nlm.nih.gov/publishing/tag-library
 -}
 module Text.Pandoc.Writers.JATS ( writeJATS ) where
+import Prelude
 import Control.Monad.Reader
 import Data.Char (toLower)
 import Data.Generics (everywhere, mkT)
@@ -139,7 +141,7 @@
   term' <- inlinesToJATS opts term
   def' <- blocksToJATS opts $ concatMap (map plainToPara) defs
   return $ inTagsIndented "def-item" $
-      inTagsIndented "term" term' $$
+      inTagsSimple "term" term' $$
       inTagsIndented "def" def'
 
 -- | Convert a list of lists of blocks to a list of JATS list items.
@@ -156,7 +158,7 @@
 listItemToJATS opts mbmarker item = do
   contents <- blocksToJATS opts item
   return $ inTagsIndented "list-item" $
-           maybe empty (\lbl -> inTagsIndented "label" (text lbl)) mbmarker
+           maybe empty (\lbl -> inTagsSimple "label" (text lbl)) mbmarker
            $$ contents
 
 imageMimeType :: String -> [(String, String)] -> (String, String)
@@ -250,7 +252,7 @@
                         "xlink:type"]]
   return $ selfClosingTag "graphic" attr
 blockToJATS opts (Para lst) =
-  inTagsIndented "p" <$> inlinesToJATS opts lst
+  inTagsSimple "p" <$> inlinesToJATS opts lst
 blockToJATS opts (LineBlock lns) =
   blockToJATS opts $ linesToPara lns
 blockToJATS opts (BlockQuote blocks) =
@@ -326,10 +328,10 @@
                    -> [Block]
                    -> JATS m Doc
 tableItemToJATS opts isHeader [Plain item] =
-  inTags True (if isHeader then "th" else "td") [] <$>
+  inTags False (if isHeader then "th" else "td") [] <$>
     inlinesToJATS opts item
 tableItemToJATS opts isHeader item =
-  (inTags True (if isHeader then "th" else "td") [] . vcat) <$>
+  (inTags False (if isHeader then "th" else "td") [] . vcat) <$>
     mapM (blockToJATS opts) item
 
 -- | Convert a list of inline elements to JATS.
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings   #-}
 {-# LANGUAGE PatternGuards       #-}
 {-# LANGUAGE ScopedTypeVariables #-}
@@ -34,6 +35,7 @@
     writeLaTeX
   , writeBeamer
   ) where
+import Prelude
 import Control.Applicative ((<|>))
 import Control.Monad.State.Strict
 import Data.Aeson (FromJSON, object, (.=))
@@ -411,15 +413,15 @@
       slideTitle <-
             if tit == [Str "\0"] -- marker for hrule
                then return []
-               else
-                 if null ident
-                    then return $ latex "{" : tit ++ [latex "}"]
-                    else do
-                      ref <- toLabel ident
-                      return $ latex ("{%\n\\protect\\hypertarget{" ++
-                                ref ++ "}{%\n") : tit ++ [latex "}}"]
+               else return $ latex "{" : tit ++ [latex "}"]
+      ref <- toLabel ident
+      let slideAnchor = if null ident
+                           then []
+                           else [latex ("\n\\protect\\hypertarget{" ++
+                                  ref ++ "}{}")]
       let slideStart = Para $
-              RawInline "latex" ("\\begin{frame}" ++ options) : slideTitle
+              RawInline "latex" ("\\begin{frame}" ++ options) :
+                 slideTitle ++ slideAnchor
       let slideEnd = RawBlock "latex" "\\end{frame}"
       -- now carve up slide into blocks if there are sections inside
       bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs
--- a/src/Text/Pandoc/Writers/Man.hs
+++ b/src/Text/Pandoc/Writers/Man.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-
 Copyright (C) 2007-2018 John MacFarlane <jgm@berkeley.edu>
@@ -30,6 +31,7 @@
 
 -}
 module Text.Pandoc.Writers.Man ( writeMan) where
+import Prelude
 import Control.Monad.State.Strict
 import Data.List (intercalate, intersperse, sort, stripPrefix)
 import qualified Data.Map as Map
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE MultiWayIf          #-}
 {-# LANGUAGE OverloadedStrings   #-}
 {-# LANGUAGE ScopedTypeVariables #-}
@@ -34,6 +35,7 @@
 Markdown:  <http://daringfireball.net/projects/markdown/>
 -}
 module Text.Pandoc.Writers.Markdown (writeMarkdown, writePlain) where
+import Prelude
 import Control.Monad.Reader
 import Control.Monad.State.Strict
 import Data.Char (chr, isPunctuation, isSpace, ord, isAlphaNum)
diff --git a/src/Text/Pandoc/Writers/Math.hs b/src/Text/Pandoc/Writers/Math.hs
--- a/src/Text/Pandoc/Writers/Math.hs
+++ b/src/Text/Pandoc/Writers/Math.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Text.Pandoc.Writers.Math
   ( texMathToInlines
   , convertMath
@@ -6,6 +7,7 @@
   )
 where
 
+import Prelude
 import Text.Pandoc.Class
 import Text.Pandoc.Definition
 import Text.Pandoc.Logging
diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs
--- a/src/Text/Pandoc/Writers/MediaWiki.hs
+++ b/src/Text/Pandoc/Writers/MediaWiki.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2008-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -30,6 +31,7 @@
 MediaWiki:  <http://www.mediawiki.org/wiki/MediaWiki>
 -}
 module Text.Pandoc.Writers.MediaWiki ( writeMediaWiki ) where
+import Prelude
 import Control.Monad.Reader
 import Control.Monad.State.Strict
 import Data.List (intercalate)
diff --git a/src/Text/Pandoc/Writers/Ms.hs b/src/Text/Pandoc/Writers/Ms.hs
--- a/src/Text/Pandoc/Writers/Ms.hs
+++ b/src/Text/Pandoc/Writers/Ms.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2007-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -36,8 +37,9 @@
 -}
 
 module Text.Pandoc.Writers.Ms ( writeMs ) where
+import Prelude
 import Control.Monad.State.Strict
-import Data.Char (isLower, isUpper, toUpper)
+import Data.Char (isLower, isUpper, toUpper, ord)
 import Data.List (intercalate, intersperse, sort)
 import qualified Data.Map as Map
 import Data.Maybe (catMaybes, fromMaybe)
@@ -46,6 +48,7 @@
 import Network.URI (escapeURIString, isAllowedInURI)
 import Skylighting
 import System.FilePath (takeExtension)
+import Text.Pandoc.Asciify (toAsciiChar)
 import Text.Pandoc.Class (PandocMonad, report)
 import Text.Pandoc.Definition
 import Text.Pandoc.Highlighting
@@ -139,7 +142,6 @@
               , ('\x2026', "\\&...")
               , ('~', "\\[ti]")
               , ('^', "\\[ha]")
-              , ('-', "\\-")
               , ('@', "\\@")
               , ('\\', "\\\\")
               ]
@@ -266,7 +268,8 @@
   let anchor = if null ident
                   then empty
                   else nowrap $
-                         text ".pdfhref M " <> doubleQuotes (text ident)
+                         text ".pdfhref M "
+                         <> doubleQuotes (text (toAscii ident))
   let bookmark = text ".pdfhref O " <> text (show level ++ " ") <>
                       doubleQuotes (text $ secnum ++
                                       (if null secnum
@@ -274,7 +277,7 @@
                                           else "  ") ++
                                       escapeString (stringify inlines))
   let backlink = nowrap (text ".pdfhref L -D " <>
-       doubleQuotes (text ident) <> space <> text "\\") <> cr <>
+       doubleQuotes (text (toAscii ident)) <> space <> text "\\") <> cr <>
        text " -- "
   let tocEntry = if writerTableOfContents opts &&
                      level <= writerTOCDepth opts
@@ -513,7 +516,7 @@
   -- internal link
   contents <- inlineListToMs' opts $ map breakToSpace txt
   return $ text "\\c" <> cr <> nowrap (text ".pdfhref L -D " <>
-       doubleQuotes (text ident) <> text " -A " <>
+       doubleQuotes (text (toAscii ident)) <> text " -A " <>
        doubleQuotes (text "\\c") <> space <> text "\\") <> cr <>
        text " -- " <> doubleQuotes (nowrap contents) <> cr <> text "\\&"
 inlineToMs opts (Link _ txt (src, _)) = do
@@ -637,3 +640,8 @@
          Right h -> do
            modify (\st -> st{ stHighlighting = True })
            return h
+
+toAscii :: String -> String
+toAscii = concatMap (\c -> case toAsciiChar c of
+                                     Nothing -> 'u':show (ord c)
+                                     Just c' -> [c'])
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs
--- a/src/Text/Pandoc/Writers/Muse.hs
+++ b/src/Text/Pandoc/Writers/Muse.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-
 Copyright (C) 2017-2018 Alexander Krotov <ilabdsf@gmail.com>
@@ -42,6 +43,7 @@
 even though it is supported only in Emacs Muse.
 -}
 module Text.Pandoc.Writers.Muse (writeMuse) where
+import Prelude
 import Control.Monad.State.Strict
 import Data.Text (Text)
 import Data.List (intersperse, transpose, isInfixOf)
@@ -185,8 +187,8 @@
                               -> [Block]  -- ^ list item (list of blocks)
                               -> StateT WriterState m Doc
         orderedListItemToMuse marker item = do
-        contents <- blockListToMuse item
-        return $ hang (length marker + 1) (text marker <> space) contents
+          contents <- blockListToMuse item
+          return $ hang (length marker + 1) (text marker <> space) contents
 blockToMuse (BulletList items) = do
   contents <- mapM bulletListItemToMuse items
   -- ensure that sublists have preceding blank line
@@ -287,11 +289,31 @@
   if any (`elem` ("#*<=>[]|" :: String)) s ||
      "::" `isInfixOf` s ||
      "----" `isInfixOf` s ||
-     "~~" `isInfixOf` s
+     "~~" `isInfixOf` s ||
+     "-" == s
     then escapeString s
     else s
 
+-- Expand Math and Cite before normalizing inline list
+preprocessInlineList :: PandocMonad m
+                     => [Inline]
+                     -> m [Inline]
+preprocessInlineList (Math t str:xs) = (++) <$> texMathToInlines t str <*> preprocessInlineList xs
+-- Amusewiki does not support <cite> tag,
+-- and Emacs Muse citation support is limited
+-- (https://www.gnu.org/software/emacs-muse/manual/html_node/Citations.html#Citation)
+-- so just fallback to expanding inlines.
+preprocessInlineList (Cite _  lst:xs) = (lst ++) <$> preprocessInlineList xs
+preprocessInlineList (x:xs) = (x:) <$> preprocessInlineList xs
+preprocessInlineList [] = return []
+
+replaceSmallCaps :: Inline -> Inline
+replaceSmallCaps (SmallCaps lst) = Emph lst
+replaceSmallCaps x = x
+
 normalizeInlineList :: [Inline] -> [Inline]
+normalizeInlineList (Str "" : xs)
+  = normalizeInlineList xs
 normalizeInlineList (x : Str "" : xs)
   = normalizeInlineList (x:xs)
 normalizeInlineList (Str x1 : Str x2 : xs)
@@ -327,7 +349,11 @@
 inlineListToMuse :: PandocMonad m
                  => [Inline]
                  -> StateT WriterState m Doc
-inlineListToMuse lst = hcat <$> mapM inlineToMuse (fixNotes $ normalizeInlineList lst)
+inlineListToMuse lst = do
+  lst' <- normalizeInlineList <$> preprocessInlineList (map replaceSmallCaps lst)
+  if null lst'
+    then pure "<verbatim></verbatim>"
+    else hcat <$> mapM inlineToMuse (fixNotes lst')
 
 -- | Convert Pandoc inline element to Muse.
 inlineToMuse :: PandocMonad m
@@ -349,22 +375,20 @@
 inlineToMuse (Subscript lst) = do
   contents <- inlineListToMuse lst
   return $ "<sub>" <> contents <> "</sub>"
-inlineToMuse (SmallCaps lst) = inlineListToMuse lst
+inlineToMuse SmallCaps {} =
+  fail "SmallCaps should be expanded before normalization"
 inlineToMuse (Quoted SingleQuote lst) = do
   contents <- inlineListToMuse lst
   return $ "‘" <> contents <> "’"
 inlineToMuse (Quoted DoubleQuote lst) = do
   contents <- inlineListToMuse lst
   return $ "“" <> contents <> "”"
--- Amusewiki does not support <cite> tag,
--- and Emacs Muse citation support is limited
--- (https://www.gnu.org/software/emacs-muse/manual/html_node/Citations.html#Citation)
--- so just fallback to expanding inlines.
-inlineToMuse (Cite _  lst) = inlineListToMuse lst
+inlineToMuse Cite {} =
+  fail "Citations should be expanded before normalization"
 inlineToMuse (Code _ str) = return $
   "<code>" <> text (substitute "</code>" "<</code><code>/code>" str) <> "</code>"
-inlineToMuse (Math t str) =
-  lift (texMathToInlines t str) >>= inlineListToMuse
+inlineToMuse Math{} =
+  fail "Math should be expanded before normalization"
 inlineToMuse (RawInline (Format f) str) =
   return $ "<literal style=\"" <> text f <> "\">" <> text str <> "</literal>"
 inlineToMuse LineBreak = return $ "<br>" <> cr
@@ -402,7 +426,11 @@
   modify $ \st -> st { stNotes = contents:notes }
   let ref = show $ length notes + 1
   return $ "[" <> text ref <> "]"
-inlineToMuse (Span (_,name:_,_) inlines) = do
+inlineToMuse (Span (anchor,names,_) inlines) = do
   contents <- inlineListToMuse inlines
-  return $ "<class name=\"" <> text name <> "\">" <> contents <> "</class>"
-inlineToMuse (Span _ lst) = inlineListToMuse lst
+  let anchorDoc = if null anchor
+                     then mempty
+                     else text ('#':anchor) <> space
+  return $ anchorDoc <> if null names
+                           then contents
+                           else "<class name=\"" <> text (head names) <> "\">" <> contents <> "</class>"
diff --git a/src/Text/Pandoc/Writers/Native.hs b/src/Text/Pandoc/Writers/Native.hs
--- a/src/Text/Pandoc/Writers/Native.hs
+++ b/src/Text/Pandoc/Writers/Native.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-
 Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu>
@@ -30,6 +31,7 @@
 -}
 module Text.Pandoc.Writers.Native ( writeNative )
 where
+import Prelude
 import Data.List (intersperse)
 import Data.Text (Text)
 import Text.Pandoc.Class (PandocMonad)
diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs
--- a/src/Text/Pandoc/Writers/ODT.hs
+++ b/src/Text/Pandoc/Writers/ODT.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 {-
 Copyright (C) 2008-2018 John MacFarlane <jgm@berkeley.edu>
@@ -29,6 +30,7 @@
 Conversion of 'Pandoc' documents to ODT.
 -}
 module Text.Pandoc.Writers.ODT ( writeODT ) where
+import Prelude
 import Codec.Archive.Zip
 import Control.Monad.Except (catchError)
 import Control.Monad.State.Strict
diff --git a/src/Text/Pandoc/Writers/OOXML.hs b/src/Text/Pandoc/Writers/OOXML.hs
--- a/src/Text/Pandoc/Writers/OOXML.hs
+++ b/src/Text/Pandoc/Writers/OOXML.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2012-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -39,13 +40,13 @@
                                  , fitToPage
                                  ) where
 
+import Prelude
 import Codec.Archive.Zip
 import Control.Monad.Reader
 import qualified Data.ByteString as B
 import qualified Data.ByteString.Lazy as BL
 import qualified Data.ByteString.Lazy.Char8 as BL8
 import Data.Maybe (mapMaybe)
-import Data.Monoid ((<>))
 import Text.Pandoc.Class (PandocMonad)
 import qualified Text.Pandoc.UTF8 as UTF8
 import Text.XML.Light as XML
diff --git a/src/Text/Pandoc/Writers/OPML.hs b/src/Text/Pandoc/Writers/OPML.hs
--- a/src/Text/Pandoc/Writers/OPML.hs
+++ b/src/Text/Pandoc/Writers/OPML.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE CPP #-}
 {-
 Copyright (C) 2013-2018 John MacFarlane <jgm@berkeley.edu>
@@ -29,12 +30,13 @@
 Conversion of 'Pandoc' documents to OPML XML.
 -}
 module Text.Pandoc.Writers.OPML ( writeOPML) where
+import Prelude
 import Control.Monad.Except (throwError)
 import Data.Text (Text, unpack)
 import qualified Data.Text as T
 import qualified Text.Pandoc.Builder as B
 import Text.Pandoc.Class (PandocMonad)
-import Text.Pandoc.Compat.Time
+import Data.Time
 import Text.Pandoc.Definition
 import Text.Pandoc.Error
 import Text.Pandoc.Options
@@ -75,12 +77,7 @@
 
 convertDate :: [Inline] -> String
 convertDate ils = maybe "" showDateTimeRFC822 $
-#if MIN_VERSION_time(1,5,0)
-  parseTimeM True
-#else
-  parseTime
-#endif
-  defaultTimeLocale "%F" =<< normalizeDate (stringify ils)
+  parseTimeM True defaultTimeLocale "%F" =<< normalizeDate (stringify ils)
 
 -- | Convert an Element to OPML.
 elementToOPML :: PandocMonad m => WriterOptions -> Element -> m Doc
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleContexts  #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE PatternGuards     #-}
@@ -32,6 +33,7 @@
 Conversion of 'Pandoc' documents to OpenDocument XML.
 -}
 module Text.Pandoc.Writers.OpenDocument ( writeOpenDocument ) where
+import Prelude
 import Control.Arrow ((***), (>>>))
 import Control.Monad.State.Strict hiding (when)
 import Data.Char (chr)
diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs
--- a/src/Text/Pandoc/Writers/Org.hs
+++ b/src/Text/Pandoc/Writers/Org.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-
 Copyright (C) 2010-2015 Puneeth Chaganti <punchagan@gmail.com>
@@ -35,6 +36,7 @@
 Org-Mode:  <http://orgmode.org>
 -}
 module Text.Pandoc.Writers.Org (writeOrg) where
+import Prelude
 import Control.Monad.State.Strict
 import Data.Char (isAlphaNum, toLower)
 import Data.List (intersect, intersperse, isPrefixOf, partition, transpose)
diff --git a/src/Text/Pandoc/Writers/Powerpoint.hs b/src/Text/Pandoc/Writers/Powerpoint.hs
--- a/src/Text/Pandoc/Writers/Powerpoint.hs
+++ b/src/Text/Pandoc/Writers/Powerpoint.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 
 
 {-
@@ -41,6 +42,7 @@
 
 module Text.Pandoc.Writers.Powerpoint (writePowerpoint) where
 
+import Prelude
 import Codec.Archive.Zip
 import Text.Pandoc.Definition
 import Text.Pandoc.Walk
diff --git a/src/Text/Pandoc/Writers/Powerpoint/Output.hs b/src/Text/Pandoc/Writers/Powerpoint/Output.hs
--- a/src/Text/Pandoc/Writers/Powerpoint/Output.hs
+++ b/src/Text/Pandoc/Writers/Powerpoint/Output.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE PatternGuards #-}
 
 {-
@@ -34,6 +35,7 @@
 module Text.Pandoc.Writers.Powerpoint.Output ( presentationToArchive
                                              ) where
 
+import Prelude
 import Control.Monad.Except (throwError, catchError)
 import Control.Monad.Reader
 import Control.Monad.State
@@ -41,7 +43,7 @@
 import Data.Char (toUpper)
 import Data.List (intercalate, stripPrefix, nub, union, isPrefixOf, intersperse)
 import Data.Default
-import Text.Pandoc.Compat.Time (formatTime, defaultTimeLocale)
+import Data.Time (formatTime, defaultTimeLocale)
 import Data.Time.Clock (UTCTime)
 import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds, posixSecondsToUTCTime)
 import System.FilePath.Posix (splitDirectories, splitExtension, takeExtension)
diff --git a/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs b/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs
--- a/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs
+++ b/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE PatternGuards #-}
 
 {-
@@ -57,6 +58,7 @@
                                                    ) where
 
 
+import Prelude
 import Control.Monad.Reader
 import Control.Monad.State
 import Data.List (intercalate)
@@ -67,7 +69,7 @@
 import Text.Pandoc.Options
 import Text.Pandoc.Logging
 import Text.Pandoc.Walk
-import Text.Pandoc.Compat.Time (UTCTime)
+import Data.Time (UTCTime)
 import qualified Text.Pandoc.Shared as Shared -- so we don't overlap "Element"
 import Text.Pandoc.Writers.Shared (metaValueToInlines)
 import qualified Data.Map as M
@@ -474,7 +476,7 @@
         definition <- concatMapM (blockToParagraphs . BlockQuote) blksLst
         return $ term ++ definition
   concatMapM go entries
-blockToParagraphs (Div (_, "notes" : [], _) blks) =
+blockToParagraphs (Div (_, ["notes"], _) blks) =
   local (\env -> env{envInSpeakerNotes=True}) $ do
   sldId <- asks envCurSlideId
   spkNotesMap <- gets stSpeakerNotesMap
@@ -558,7 +560,7 @@
 combineShapes :: [Shape] -> [Shape]
 combineShapes [] = []
 combineShapes[s] = [s]
-combineShapes (pic@(Pic{}) : ss) = pic : combineShapes ss
+combineShapes (pic@Pic{} : ss) = pic : combineShapes ss
 combineShapes (TextBox [] : ss) = combineShapes ss
 combineShapes (s : TextBox [] : ss) = combineShapes (s : ss)
 combineShapes (TextBox (p:ps) : TextBox (p':ps') : ss) =
@@ -569,8 +571,8 @@
 blocksToShapes blks = combineShapes <$> mapM blockToShape blks
 
 isImage :: Inline -> Bool
-isImage (Image{}) = True
-isImage (Link _ (Image _ _ _ : _) _) = True
+isImage Image{} = True
+isImage (Link _ (Image{} : _) _) = True
 isImage _ = False
 
 splitBlocks' :: [Block] -> [[Block]] -> [Block] -> Pres [[Block]]
@@ -589,23 +591,23 @@
 splitBlocks' cur acc (Para (il:ils) : blks) | isImage il = do
   slideLevel <- asks envSlideLevel
   case cur of
-    [(Header n _ _)] | n == slideLevel ->
+    [Header n _ _] | n == slideLevel ->
                             splitBlocks' []
                             (acc ++ [cur ++ [Para [il]]])
                             (if null ils then blks else Para ils : blks)
     _ -> splitBlocks' []
          (acc ++ (if null cur then [] else [cur]) ++ [[Para [il]]])
          (if null ils then blks else Para ils : blks)
-splitBlocks' cur acc (tbl@(Table{}) : blks) = do
+splitBlocks' cur acc (tbl@Table{} : blks) = do
   slideLevel <- asks envSlideLevel
   case cur of
-    [(Header n _ _)] | n == slideLevel ->
+    [Header n _ _] | n == slideLevel ->
                             splitBlocks' [] (acc ++ [cur ++ [tbl]]) blks
     _ ->  splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[tbl]]) blks
 splitBlocks' cur acc (d@(Div (_, classes, _) _): blks) | "columns" `elem` classes =  do
   slideLevel <- asks envSlideLevel
   case cur of
-    [(Header n _ _)] | n == slideLevel ->
+    [Header n _ _] | n == slideLevel ->
                             splitBlocks' [] (acc ++ [cur ++ [d]]) blks
     _ ->  splitBlocks' [] (acc ++ (if null cur then [] else [cur]) ++ [[d]]) blks
 splitBlocks' cur acc (blk : blks) = splitBlocks' (cur ++ [blk]) acc blks
@@ -617,7 +619,7 @@
 getSpeakerNotes = do
   sldId <- asks envCurSlideId
   spkNtsMap <- gets stSpeakerNotesMap
-  return $ (SpeakerNotes . concat . reverse) <$> (M.lookup sldId spkNtsMap)
+  return $ (SpeakerNotes . concat . reverse) <$> M.lookup sldId spkNtsMap
 
 blocksToSlide' :: Int -> [Block] -> Pres Slide
 blocksToSlide' lvl (Header n (ident, _, _) ils : blks)
@@ -864,7 +866,7 @@
 
 
 emptyShape :: Shape -> Bool
-emptyShape (TextBox paras) = all emptyParagraph $ paras
+emptyShape (TextBox paras) = all emptyParagraph paras
 emptyShape _ = False
 
 emptyLayout :: Layout -> Bool
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-
 Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu>
@@ -31,6 +32,7 @@
 reStructuredText:  <http://docutils.sourceforge.net/rst.html>
 -}
 module Text.Pandoc.Writers.RST ( writeRST ) where
+import Prelude
 import Control.Monad.State.Strict
 import Data.Char (isSpace, toLower)
 import Data.List (isPrefixOf, stripPrefix)
@@ -46,6 +48,7 @@
 import Text.Pandoc.Shared
 import Text.Pandoc.Templates (renderTemplate')
 import Text.Pandoc.Writers.Shared
+import Text.Pandoc.Walk
 
 type Refs = [([Inline], Target)]
 
@@ -376,12 +379,25 @@
                -> RST m Doc
 blockListToRST = blockListToRST' False
 
--- | Convert list of Pandoc inline elements to RST.
-inlineListToRST :: PandocMonad m => [Inline] -> RST m Doc
-inlineListToRST lst =
-  mapM inlineToRST (removeSpaceAfterDisplayMath $ insertBS lst) >>=
-    return . hcat
-  where -- remove spaces after displaymath, as they screw up indentation:
+transformInlines :: [Inline] -> [Inline]
+transformInlines =  stripLeadingTrailingSpace . insertBS
+                    . filter hasContents . removeSpaceAfterDisplayMath
+  where -- empty inlines are not valid RST syntax
+        hasContents :: Inline -> Bool
+        hasContents (Str "")              = False
+        hasContents (Emph [])             = False
+        hasContents (Strong [])           = False
+        hasContents (Strikeout [])        = False
+        hasContents (Superscript [])      = False
+        hasContents (Subscript [])        = False
+        hasContents (SmallCaps [])        = False
+        hasContents (Quoted _ [])         = False
+        hasContents (Cite _ [])           = False
+        hasContents (Span _ [])           = False
+        hasContents (Link _ [] ("", ""))  = False
+        hasContents (Image _ [] ("", "")) = False
+        hasContents _                     = True
+        -- 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
@@ -436,44 +452,51 @@
         isComplex (Span _ (x:_))  = isComplex x
         isComplex _               = False
 
+inlineListToRST :: PandocMonad m => [Inline] -> RST m Doc
+inlineListToRST = writeInlines . walk transformInlines
+
+-- | Convert list of Pandoc inline elements to RST.
+writeInlines :: PandocMonad m => [Inline] -> RST m Doc
+writeInlines lst = mapM inlineToRST lst >>= return . hcat
+
 -- | Convert Pandoc inline element to RST.
 inlineToRST :: PandocMonad m => Inline -> RST m Doc
 inlineToRST (Span (_,_,kvs) ils) = do
-  contents <- inlineListToRST ils
+  contents <- writeInlines ils
   return $
     case lookup "role" kvs of
           Just role -> ":" <> text role <> ":`" <> contents <> "`"
           Nothing   -> contents
 inlineToRST (Emph lst) = do
-  contents <- inlineListToRST lst
+  contents <- writeInlines lst
   return $ "*" <> contents <> "*"
 inlineToRST (Strong lst) = do
-  contents <- inlineListToRST lst
+  contents <- writeInlines lst
   return $ "**" <> contents <> "**"
 inlineToRST (Strikeout lst) = do
-  contents <- inlineListToRST lst
+  contents <- writeInlines lst
   return $ "[STRIKEOUT:" <> contents <> "]"
 inlineToRST (Superscript lst) = do
-  contents <- inlineListToRST lst
+  contents <- writeInlines lst
   return $ ":sup:`" <> contents <> "`"
 inlineToRST (Subscript lst) = do
-  contents <- inlineListToRST lst
+  contents <- writeInlines lst
   return $ ":sub:`" <> contents <> "`"
-inlineToRST (SmallCaps lst) = inlineListToRST lst
+inlineToRST (SmallCaps lst) = writeInlines lst
 inlineToRST (Quoted SingleQuote lst) = do
-  contents <- inlineListToRST lst
+  contents <- writeInlines lst
   opts <- gets stOptions
   if isEnabled Ext_smart opts
      then return $ "'" <> contents <> "'"
      else return $ "‘" <> contents <> "’"
 inlineToRST (Quoted DoubleQuote lst) = do
-  contents <- inlineListToRST lst
+  contents <- writeInlines lst
   opts <- gets stOptions
   if isEnabled Ext_smart opts
      then return $ "\"" <> contents <> "\""
      else return $ "“" <> contents <> "”"
 inlineToRST (Cite _  lst) =
-  inlineListToRST lst
+  writeInlines lst
 inlineToRST (Code _ str) = do
   opts <- gets stOptions
   -- we trim the string because the delimiters must adjoin a
@@ -524,7 +547,7 @@
   return $ "|" <> label <> "|"
 inlineToRST (Link _ txt (src, tit)) = do
   useReferenceLinks <- gets $ writerReferenceLinks . stOptions
-  linktext <- inlineListToRST $ B.toList . B.trimInlines . B.fromList $ txt
+  linktext <- writeInlines $ B.toList . B.trimInlines . B.fromList $ txt
   if useReferenceLinks
     then do refs <- gets stLinks
             case lookup txt refs of
diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs
--- a/src/Text/Pandoc/Writers/RTF.hs
+++ b/src/Text/Pandoc/Writers/RTF.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 {-
 Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu>
@@ -30,6 +31,7 @@
 -}
 module Text.Pandoc.Writers.RTF ( writeRTF
                                ) where
+import Prelude
 import Control.Monad.Except (catchError, throwError)
 import Control.Monad
 import qualified Data.ByteString as B
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs
--- a/src/Text/Pandoc/Writers/Shared.hs
+++ b/src/Text/Pandoc/Writers/Shared.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-
 Copyright (C) 2013-2018 John MacFarlane <jgm@berkeley.edu>
@@ -41,8 +42,10 @@
                      , unsmartify
                      , gridTable
                      , metaValueToInlines
+                     , stripLeadingTrailingSpace
                      )
 where
+import Prelude
 import Control.Monad (zipWithM)
 import Data.Aeson (FromJSON (..), Result (..), ToJSON (..), Value (Object),
                    encode, fromJSON)
@@ -240,40 +243,58 @@
           -> [[[Block]]]
           -> m Doc
 gridTable opts blocksToDoc headless aligns widths headers rows = do
+  -- the number of columns will be used in case of even widths
   let numcols = maximum (length aligns : length widths :
                            map length (headers:rows))
+  -- handleGivenWidths wraps the given blocks in order for them to fit
+  -- in cells with given widths. the returned content can be
+  -- concatenated with borders and frames
   let handleGivenWidths widths' = do
         let widthsInChars' = map (
                       (\x -> if x < 1 then 1 else x) .
                       (\x -> x - 3) . floor .
                       (fromIntegral (writerColumns opts) *)
                       ) widths'
-        rawHeaders' <- zipWithM blocksToDoc
-            (map (\w -> opts{writerColumns =
-                      min (w - 2) (writerColumns opts)}) widthsInChars')
-            headers
+            -- replace page width (in columns) in the options with a
+            -- given width if smaller (adjusting by two)
+            useWidth w = opts{writerColumns = min (w - 2) (writerColumns opts)}
+            -- prepare options to use with header and row cells
+            columnOptions = map useWidth widthsInChars'
+        rawHeaders' <- zipWithM blocksToDoc columnOptions headers
         rawRows' <- mapM
-             (\cs -> zipWithM blocksToDoc
-               (map (\w -> opts{writerColumns =
-                         min (w - 2) (writerColumns opts)}) widthsInChars')
-               cs)
+             (\cs -> zipWithM blocksToDoc columnOptions cs)
              rows
         return (widthsInChars', rawHeaders', rawRows')
-  let handleZeroWidths = do
+  -- handleFullWidths tries to wrap cells to the page width or even
+  -- more in cases where `--wrap=none`. thus the content here is left
+  -- as wide as possible
+  let handleFullWidths = do
         rawHeaders' <- mapM (blocksToDoc opts) headers
         rawRows' <- mapM (mapM (blocksToDoc opts)) rows
         let numChars [] = 0
             numChars xs = maximum . map offset $ xs
         let widthsInChars' =
                 map numChars $ transpose (rawHeaders' : rawRows')
+        return (widthsInChars', rawHeaders', rawRows')
+  -- handleZeroWidths calls handleFullWidths to check whether a wide
+  -- table would fit in the page. if the produced table is too wide,
+  -- it calculates even widths and passes the content to
+  -- handleGivenWidths
+  let handleZeroWidths = do
+        (widthsInChars', rawHeaders', rawRows') <- handleFullWidths
         if sum widthsInChars' > writerColumns opts
            then -- use even widths
                 handleGivenWidths
                   (replicate numcols (1.0 / fromIntegral numcols) :: [Double])
            else return (widthsInChars', rawHeaders', rawRows')
-  (widthsInChars, rawHeaders, rawRows) <- if all (== 0) widths
-                                             then handleZeroWidths
-                                             else handleGivenWidths widths
+  -- render the contents of header and row cells differently depending
+  -- on command line options, widths given in this specific table, and
+  -- cells' contents
+  let handleWidths
+        | writerWrapText opts == WrapNone  = handleFullWidths
+        | all (== 0) widths                  = handleZeroWidths
+        | otherwise                          = handleGivenWidths widths
+  (widthsInChars, rawHeaders, rawRows) <- handleWidths
   let hpipeBlocks blocks = hcat [beg, middle, end]
         where h       = maximum (1 : map height blocks)
               sep'    = lblock 3 $ vcat (replicate h (text " | "))
diff --git a/src/Text/Pandoc/Writers/TEI.hs b/src/Text/Pandoc/Writers/TEI.hs
--- a/src/Text/Pandoc/Writers/TEI.hs
+++ b/src/Text/Pandoc/Writers/TEI.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE PatternGuards     #-}
 {-
@@ -30,6 +31,7 @@
 Conversion of 'Pandoc' documents to Docbook XML.
 -}
 module Text.Pandoc.Writers.TEI (writeTEI) where
+import Prelude
 import Data.Char (toLower)
 import Data.List (isPrefixOf, stripPrefix)
 import Data.Text (Text)
diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs
--- a/src/Text/Pandoc/Writers/Texinfo.hs
+++ b/src/Text/Pandoc/Writers/Texinfo.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-
 Copyright (C) 2008-2018 John MacFarlane
@@ -31,6 +32,7 @@
 Conversion of 'Pandoc' format into Texinfo.
 -}
 module Text.Pandoc.Writers.Texinfo ( writeTexinfo ) where
+import Prelude
 import Control.Monad.Except (throwError)
 import Control.Monad.State.Strict
 import Data.Char (chr, ord)
diff --git a/src/Text/Pandoc/Writers/Textile.hs b/src/Text/Pandoc/Writers/Textile.hs
--- a/src/Text/Pandoc/Writers/Textile.hs
+++ b/src/Text/Pandoc/Writers/Textile.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2010-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -30,6 +31,7 @@
 Textile:  <http://thresholdstate.com/articles/4312/the-textile-reference-manual>
 -}
 module Text.Pandoc.Writers.Textile ( writeTextile ) where
+import Prelude
 import Control.Monad.State.Strict
 import Data.Char (isSpace)
 import Data.List (intercalate)
diff --git a/src/Text/Pandoc/Writers/ZimWiki.hs b/src/Text/Pandoc/Writers/ZimWiki.hs
--- a/src/Text/Pandoc/Writers/ZimWiki.hs
+++ b/src/Text/Pandoc/Writers/ZimWiki.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2008-2018 John MacFarlane <jgm@berkeley.edu>
               2017-2018 Alex Ivkin
@@ -32,6 +33,7 @@
 -}
 
 module Text.Pandoc.Writers.ZimWiki ( writeZimWiki ) where
+import Prelude
 import Control.Monad (zipWithM)
 import Control.Monad.State.Strict (StateT, evalStateT, gets, modify)
 import Data.Default (Default (..))
diff --git a/src/Text/Pandoc/XML.hs b/src/Text/Pandoc/XML.hs
--- a/src/Text/Pandoc/XML.hs
+++ b/src/Text/Pandoc/XML.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-
 Copyright (C) 2006-2018 John MacFarlane <jgm@berkeley.edu>
 
@@ -36,6 +37,7 @@
                          toEntities,
                          fromEntities ) where
 
+import Prelude
 import Data.Char (isAscii, isSpace, ord)
 import Data.Text (Text)
 import qualified Data.Text as T
diff --git a/stack.yaml b/stack.yaml
--- a/stack.yaml
+++ b/stack.yaml
@@ -2,7 +2,6 @@
   pandoc:
     trypandoc: false
     embed_data_files: true
-    old-locale: false
     network-uri: true
   pandoc-citeproc:
     bibutils: true
@@ -13,13 +12,12 @@
 packages:
 - '.'
 extra-deps:
-- pandoc-citeproc-0.14.1.5
-- hslua-0.9.5
-- skylighting-0.6
-- ansi-terminal-0.7.1.1
-- tasty-1.0.0.1
-- texmath-0.10.1.1
-- tagsoup-0.14.6
+- pandoc-citeproc-0.14.2
+- skylighting-0.7.0.2
+- skylighting-core-0.7.0.2
+- ansi-terminal-0.8.0.2
+- tasty-1.0.1.1
+- pandoc-types-1.17.4.2
 ghc-options:
-   "$locals": -fhide-source-paths
-resolver: lts-10.3
+   "$locals": -fhide-source-paths -XNoImplicitPrelude
+resolver: lts-10.10
diff --git a/test/Tests/Command.hs b/test/Tests/Command.hs
--- a/test/Tests/Command.hs
+++ b/test/Tests/Command.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Tests.Command (findPandoc, runTest, tests)
 where
 
+import Prelude
 import Data.Algorithm.Diff
 import qualified Data.ByteString as BS
 import Data.List (isSuffixOf)
diff --git a/test/Tests/Helpers.hs b/test/Tests/Helpers.hs
--- a/test/Tests/Helpers.hs
+++ b/test/Tests/Helpers.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE FlexibleInstances    #-}
 {-# LANGUAGE TypeSynonymInstances #-}
 -- Utility functions for the test suite.
@@ -13,6 +14,7 @@
                      )
                      where
 
+import Prelude
 import Data.Algorithm.Diff
 import qualified Data.Map as M
 import Data.Text (Text, unpack)
diff --git a/test/Tests/Lua.hs b/test/Tests/Lua.hs
--- a/test/Tests/Lua.hs
+++ b/test/Tests/Lua.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Lua ( tests ) where
 
+import Prelude
 import Control.Monad (when)
 import Data.Version (Version (versionBranch))
 import System.FilePath ((</>))
@@ -10,7 +12,7 @@
 import Text.Pandoc.Arbitrary ()
 import Text.Pandoc.Builder (bulletList, divWith, doc, doubleQuoted, emph,
                             header, linebreak, para, plain, rawBlock,
-                            singleQuoted, space, str, strong, (<>))
+                            singleQuoted, space, str, strong)
 import Text.Pandoc.Class (runIOorExplode, setUserDataDir)
 import Text.Pandoc.Definition (Block (BlockQuote, Div, Para), Inline (Emph, Str),
                                Attr, Meta, Pandoc, pandocTypesVersion)
diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs
--- a/test/Tests/Old.hs
+++ b/test/Tests/Old.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Tests.Old (tests) where
 
+import Prelude
 import Data.Algorithm.Diff
 import Prelude hiding (readFile)
 import System.Exit
@@ -286,4 +288,3 @@
 findDynlibDir []           = Nothing
 findDynlibDir ("build":xs) = Just $ joinPath (reverse xs) </> "build"
 findDynlibDir (_:xs)       = findDynlibDir xs
-
diff --git a/test/Tests/Readers/Creole.hs b/test/Tests/Readers/Creole.hs
--- a/test/Tests/Readers/Creole.hs
+++ b/test/Tests/Readers/Creole.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Creole (tests) where
 
+import Prelude
 import Data.Text (Text)
 import qualified Data.Text as T
 import Test.Tasty
diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs
--- a/test/Tests/Readers/Docx.hs
+++ b/test/Tests/Readers/Docx.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Tests.Readers.Docx (tests) where
 
+import Prelude
 import Codec.Archive.Zip
 import qualified Data.ByteString as BS
 import qualified Data.ByteString.Lazy as B
@@ -182,6 +184,10 @@
             "nested Structured Document Tags"
             "docx/nested_sdt.docx"
             "docx/nested_sdt.native"
+          , testCompare
+            "nested Smart Tags"
+            "docx/nested_smart_tags.docx"
+            "docx/nested_smart_tags.native"
           , testCompare
             "remove anchor spans with nothing pointing to them"
             "docx/unused_anchors.docx"
diff --git a/test/Tests/Readers/EPUB.hs b/test/Tests/Readers/EPUB.hs
--- a/test/Tests/Readers/EPUB.hs
+++ b/test/Tests/Readers/EPUB.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Tests.Readers.EPUB (tests) where
 
+import Prelude
 import qualified Data.ByteString.Lazy as BL
 import Test.Tasty
 import Test.Tasty.HUnit
diff --git a/test/Tests/Readers/HTML.hs b/test/Tests/Readers/HTML.hs
--- a/test/Tests/Readers/HTML.hs
+++ b/test/Tests/Readers/HTML.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.HTML (tests) where
 
+import Prelude
 import Data.Text (Text)
 import Test.Tasty
 import Tests.Helpers
diff --git a/test/Tests/Readers/JATS.hs b/test/Tests/Readers/JATS.hs
--- a/test/Tests/Readers/JATS.hs
+++ b/test/Tests/Readers/JATS.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.JATS (tests) where
 
+import Prelude
 import Data.Text (Text)
 import Test.Tasty
 import Tests.Helpers
diff --git a/test/Tests/Readers/LaTeX.hs b/test/Tests/Readers/LaTeX.hs
--- a/test/Tests/Readers/LaTeX.hs
+++ b/test/Tests/Readers/LaTeX.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.LaTeX (tests) where
 
+import Prelude
 import Data.Text (Text)
 import qualified Data.Text as T
 import qualified Text.Pandoc.UTF8 as UTF8
diff --git a/test/Tests/Readers/Markdown.hs b/test/Tests/Readers/Markdown.hs
--- a/test/Tests/Readers/Markdown.hs
+++ b/test/Tests/Readers/Markdown.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Markdown (tests) where
 
+import Prelude
 import Data.Text (Text, unpack)
 import qualified Data.Text as T
 import Test.Tasty
diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs
--- a/test/Tests/Readers/Muse.hs
+++ b/test/Tests/Readers/Muse.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Muse (tests) where
 
+import Prelude
 import Data.List (intersperse)
 import Data.Text (Text)
 import qualified Data.Text as T
@@ -36,14 +38,12 @@
 makeRoundTrip x = x
 
 -- Demand that any AST produced by Muse reader and written by Muse writer can be read back exactly the same way.
--- Currently we remove tables and compare third rewrite to the second.
--- First and second rewrites are not equal yet.
+-- Currently we remove tables and compare first rewrite to the second.
 roundTrip :: Block -> Bool
-roundTrip b = d'' == d'''
+roundTrip b = d' == d''
   where d = walk makeRoundTrip $ Pandoc nullMeta [b]
         d' = rewrite d
         d'' = rewrite d'
-        d''' = rewrite d''
         rewrite = amuse . T.pack . (++ "\n") . T.unpack .
                   purely (writeMuse def { writerExtensions = extensionsFromList [Ext_amuse]
                                           , writerWrapText = WrapPreserve
@@ -173,8 +173,11 @@
 
       , "Verbatim tag after text" =: "Foo <verbatim>bar</verbatim>" =?> para "Foo bar"
 
+      , "Class tag" =: "<class name=\"foo\">bar</class>" =?> para (spanWith ("", ["foo"], []) "bar")
+      , "Class tag without name" =: "<class>foobar</class>" =?> para (spanWith ("", [], []) "foobar")
+
       -- <em> tag should match with the last </em> tag, not verbatim one
-      , "Nested \"</em>\" inside em tag" =: "<em>foo<verbatim></em></verbatim>bar</em>" =?> para (emph ("foo</em>bar"))
+      , "Nested \"</em>\" inside em tag" =: "<em>foo<verbatim></em></verbatim>bar</em>" =?> para (emph "foo</em>bar")
 
       , testGroup "Links"
         [ "Link without description" =:
@@ -210,9 +213,10 @@
         ]
       ]
 
-  , testGroup "Blocks"
-      [ testProperty "Round trip" roundTrip,
-        "Block elements end paragraphs" =:
+  , testGroup "Blocks" $
+      [ -- round-trip commented out for now, because it fails too often:
+        testProperty "Round trip" roundTrip | False ] ++
+      [  "Block elements end paragraphs" =:
         T.unlines [ "First paragraph"
                   , "----"
                   , "Second paragraph"
@@ -296,6 +300,7 @@
                     ]
         ]
       , "Verse in list" =: " - > foo" =?> bulletList [ lineBlock [ "foo" ] ]
+      , "Verse line starting with emphasis" =: "> *foo* bar" =?> lineBlock [ emph "foo" <> text " bar" ]
       , "Multiline verse in list" =:
         T.unlines [ " - > foo"
                   , "   > bar"
@@ -1220,5 +1225,41 @@
           , "</quote>"
           ] =?>
         blockQuote (bulletList [ blockQuote $ para "foo" ] <> para "bar")
+
+      , "Unclosed quote tag" =:
+        T.unlines
+          [ "<quote>"
+          , "<verse>"
+          , "</quote>"
+          , "</verse>"
+          ] =?>
+        para "<quote>" <> lineBlock [ "</quote>" ]
+
+      , "Unclosed quote tag inside list" =:
+        T.unlines
+          [ " - <quote>"
+          , "   <verse>"
+          , "   </quote>"
+          , "   </verse>"
+          ] =?>
+        bulletList [ para "<quote>" <> lineBlock [ "</quote>" ] ]
+
+      -- Allowing indented closing tags is dangerous,
+      -- as they may terminate lists
+      , "No indented closing tags" =:
+        T.unlines
+          [ "<quote>"
+          , ""
+          , " - Foo"
+          , ""
+          , "   </quote>"
+          , ""
+          , "   bar"
+          , ""
+          , "   <verse>"
+          , "   </quote>"
+          , "   </verse>"
+          ] =?>
+        para "<quote>" <> bulletList [ para "Foo" <> para "</quote>" <> para "bar" <> lineBlock [ "</quote>" ] ]
       ]
   ]
diff --git a/test/Tests/Readers/Odt.hs b/test/Tests/Readers/Odt.hs
--- a/test/Tests/Readers/Odt.hs
+++ b/test/Tests/Readers/Odt.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Tests.Readers.Odt (tests) where
 
+import Prelude
 import Control.Monad (liftM)
 import qualified Data.ByteString as BS
 import qualified Data.ByteString.Lazy as B
diff --git a/test/Tests/Readers/Org/Block.hs b/test/Tests/Readers/Org/Block.hs
--- a/test/Tests/Readers/Org/Block.hs
+++ b/test/Tests/Readers/Org/Block.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Org.Block (tests) where
 
+import Prelude
 import Test.Tasty (TestTree, testGroup)
 import Tests.Helpers ((=?>))
 import Tests.Readers.Org.Shared ((=:), spcSep)
diff --git a/test/Tests/Readers/Org/Block/CodeBlock.hs b/test/Tests/Readers/Org/Block/CodeBlock.hs
--- a/test/Tests/Readers/Org/Block/CodeBlock.hs
+++ b/test/Tests/Readers/Org/Block/CodeBlock.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Org.Block.CodeBlock (tests) where
 
+import Prelude
 import Test.Tasty (TestTree)
 import Tests.Helpers ((=?>))
 import Tests.Readers.Org.Shared ((=:), spcSep)
diff --git a/test/Tests/Readers/Org/Block/Figure.hs b/test/Tests/Readers/Org/Block/Figure.hs
--- a/test/Tests/Readers/Org/Block/Figure.hs
+++ b/test/Tests/Readers/Org/Block/Figure.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Org.Block.Figure (tests) where
 
+import Prelude
 import Test.Tasty (TestTree)
 import Tests.Helpers ((=?>))
 import Tests.Readers.Org.Shared ((=:))
diff --git a/test/Tests/Readers/Org/Block/Header.hs b/test/Tests/Readers/Org/Block/Header.hs
--- a/test/Tests/Readers/Org/Block/Header.hs
+++ b/test/Tests/Readers/Org/Block/Header.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Org.Block.Header (tests) where
 
+import Prelude
 import Test.Tasty (TestTree, testGroup)
 import Tests.Helpers ((=?>))
 import Tests.Readers.Org.Shared ((=:), spcSep, tagSpan)
diff --git a/test/Tests/Readers/Org/Block/List.hs b/test/Tests/Readers/Org/Block/List.hs
--- a/test/Tests/Readers/Org/Block/List.hs
+++ b/test/Tests/Readers/Org/Block/List.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Org.Block.List (tests) where
 
+import Prelude
 import Test.Tasty (TestTree)
 import Tests.Helpers ((=?>))
 import Tests.Readers.Org.Shared ((=:), spcSep)
diff --git a/test/Tests/Readers/Org/Block/Table.hs b/test/Tests/Readers/Org/Block/Table.hs
--- a/test/Tests/Readers/Org/Block/Table.hs
+++ b/test/Tests/Readers/Org/Block/Table.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Org.Block.Table (tests) where
 
+import Prelude
 import Test.Tasty (TestTree)
 import Tests.Helpers ((=?>))
 import Tests.Readers.Org.Shared ((=:), spcSep)
diff --git a/test/Tests/Readers/Org/Directive.hs b/test/Tests/Readers/Org/Directive.hs
--- a/test/Tests/Readers/Org/Directive.hs
+++ b/test/Tests/Readers/Org/Directive.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Org.Directive (tests) where
 
+import Prelude
 import Data.Time (UTCTime (UTCTime), secondsToDiffTime)
 import Data.Time.Calendar (Day (ModifiedJulianDay))
 import Test.Tasty (TestTree, testGroup)
diff --git a/test/Tests/Readers/Org/Inline.hs b/test/Tests/Readers/Org/Inline.hs
--- a/test/Tests/Readers/Org/Inline.hs
+++ b/test/Tests/Readers/Org/Inline.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Org.Inline (tests) where
 
+import Prelude
 import Data.List (intersperse)
 import Test.Tasty (TestTree, testGroup)
 import Tests.Helpers ((=?>))
diff --git a/test/Tests/Readers/Org/Inline/Citation.hs b/test/Tests/Readers/Org/Inline/Citation.hs
--- a/test/Tests/Readers/Org/Inline/Citation.hs
+++ b/test/Tests/Readers/Org/Inline/Citation.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Org.Inline.Citation (tests) where
 
+import Prelude
 import Test.Tasty (TestTree, testGroup)
 import Tests.Helpers ((=?>))
 import Tests.Readers.Org.Shared ((=:))
diff --git a/test/Tests/Readers/Org/Inline/Note.hs b/test/Tests/Readers/Org/Inline/Note.hs
--- a/test/Tests/Readers/Org/Inline/Note.hs
+++ b/test/Tests/Readers/Org/Inline/Note.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Org.Inline.Note (tests) where
 
+import Prelude
 import Test.Tasty (TestTree)
 import Tests.Helpers ((=?>))
 import Tests.Readers.Org.Shared ((=:))
diff --git a/test/Tests/Readers/Org/Inline/Smart.hs b/test/Tests/Readers/Org/Inline/Smart.hs
--- a/test/Tests/Readers/Org/Inline/Smart.hs
+++ b/test/Tests/Readers/Org/Inline/Smart.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Org.Inline.Smart (tests) where
 
+import Prelude
 import Data.Text (Text)
 import Test.Tasty (TestTree)
 import Tests.Helpers ((=?>), purely, test)
diff --git a/test/Tests/Readers/Org/Meta.hs b/test/Tests/Readers/Org/Meta.hs
--- a/test/Tests/Readers/Org/Meta.hs
+++ b/test/Tests/Readers/Org/Meta.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Org.Meta (tests) where
 
+import Prelude
 import Test.Tasty (TestTree, testGroup)
 import Tests.Helpers ((=?>))
 import Tests.Readers.Org.Shared ((=:), spcSep)
diff --git a/test/Tests/Readers/Org/Shared.hs b/test/Tests/Readers/Org/Shared.hs
--- a/test/Tests/Readers/Org/Shared.hs
+++ b/test/Tests/Readers/Org/Shared.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Tests.Readers.Org.Shared
   ( (=:)
   , org
@@ -5,6 +6,7 @@
   , tagSpan
   ) where
 
+import Prelude
 import Data.List (intersperse)
 import Data.Text (Text)
 import Tests.Helpers (ToString, purely, test)
diff --git a/test/Tests/Readers/RST.hs b/test/Tests/Readers/RST.hs
--- a/test/Tests/Readers/RST.hs
+++ b/test/Tests/Readers/RST.hs
@@ -1,7 +1,9 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings   #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 module Tests.Readers.RST (tests) where
 
+import Prelude
 import Data.Text (Text)
 import qualified Data.Text as T
 import Test.Tasty
@@ -184,6 +186,6 @@
             , ".. [1]"
             , "   bar"
             ] =?>
-              para ("foo" <> (note $ para "bar"))
+              para ("foo" <> note (para "bar"))
           ]
         ]
diff --git a/test/Tests/Readers/Txt2Tags.hs b/test/Tests/Readers/Txt2Tags.hs
--- a/test/Tests/Readers/Txt2Tags.hs
+++ b/test/Tests/Readers/Txt2Tags.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Readers.Txt2Tags (tests) where
 
+import Prelude
 import Data.List (intersperse)
 import Data.Text (Text)
 import qualified Data.Text as T
@@ -143,7 +145,7 @@
 
       , "Header with label" =:
           "= header =[label]" =?>
-            headerWith ("label", [], []) 1 ("header")
+            headerWith ("label", [], []) 1 "header"
 
       , "Invalid header, mismatched delimiters" =:
           "== header =" =?>
diff --git a/test/Tests/Shared.hs b/test/Tests/Shared.hs
--- a/test/Tests/Shared.hs
+++ b/test/Tests/Shared.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Tests.Shared (tests) where
 
+import Prelude
 import System.FilePath.Posix (joinPath)
 import Test.Tasty
 import Test.Tasty.HUnit (assertBool, testCase, (@?=))
diff --git a/test/Tests/Writers/AsciiDoc.hs b/test/Tests/Writers/AsciiDoc.hs
--- a/test/Tests/Writers/AsciiDoc.hs
+++ b/test/Tests/Writers/AsciiDoc.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Tests.Writers.AsciiDoc (tests) where
 
+import Prelude
 import Data.Text (unpack)
 import Test.Tasty
 import Tests.Helpers
diff --git a/test/Tests/Writers/ConTeXt.hs b/test/Tests/Writers/ConTeXt.hs
--- a/test/Tests/Writers/ConTeXt.hs
+++ b/test/Tests/Writers/ConTeXt.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Writers.ConTeXt (tests) where
 
+import Prelude
 import Data.Text (unpack)
 import Test.Tasty
 import Test.Tasty.QuickCheck
diff --git a/test/Tests/Writers/Docbook.hs b/test/Tests/Writers/Docbook.hs
--- a/test/Tests/Writers/Docbook.hs
+++ b/test/Tests/Writers/Docbook.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Writers.Docbook (tests) where
 
+import Prelude
 import Data.Text (unpack)
 import Test.Tasty
 import Tests.Helpers
diff --git a/test/Tests/Writers/Docx.hs b/test/Tests/Writers/Docx.hs
--- a/test/Tests/Writers/Docx.hs
+++ b/test/Tests/Writers/Docx.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Tests.Writers.Docx (tests) where
 
+import Prelude
 import Text.Pandoc
 import Test.Tasty
 import Tests.Writers.OOXML
diff --git a/test/Tests/Writers/FB2.hs b/test/Tests/Writers/FB2.hs
--- a/test/Tests/Writers/FB2.hs
+++ b/test/Tests/Writers/FB2.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Writers.FB2 (tests) where
 
+import Prelude
 import Test.Tasty
 import Tests.Helpers
 import Text.Pandoc
diff --git a/test/Tests/Writers/HTML.hs b/test/Tests/Writers/HTML.hs
--- a/test/Tests/Writers/HTML.hs
+++ b/test/Tests/Writers/HTML.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Writers.HTML (tests) where
 
+import Prelude
 import Data.Text (unpack)
 import Test.Tasty
 import Tests.Helpers
diff --git a/test/Tests/Writers/JATS.hs b/test/Tests/Writers/JATS.hs
--- a/test/Tests/Writers/JATS.hs
+++ b/test/Tests/Writers/JATS.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Writers.JATS (tests) where
 
+import Prelude
 import Data.Text (unpack)
 import Test.Tasty
 import Tests.Helpers
@@ -30,8 +32,8 @@
 
 tests :: [TestTree]
 tests = [ testGroup "inline code"
-          [ "basic" =: code "@&" =?> "<p>\n  <monospace>@&amp;</monospace>\n</p>"
-          , "lang" =: codeWith ("", ["c"], []) "@&" =?> "<p>\n  <code language=\"c\">@&amp;</code>\n</p>"
+          [ "basic" =: code "@&" =?> "<p><monospace>@&amp;</monospace></p>"
+          , "lang" =: codeWith ("", ["c"], []) "@&" =?> "<p><code language=\"c\">@&amp;</code></p>"
           ]
         , testGroup "block code"
           [ "basic" =: codeBlock "@&" =?> "<preformat>@&amp;</preformat>"
@@ -44,7 +46,7 @@
           ]
         , testGroup "inlines"
           [ "Emphasis" =: emph "emphasized"
-            =?> "<p>\n  <italic>emphasized</italic>\n</p>"
+            =?> "<p><italic>emphasized</italic></p>"
           ]
         , "bullet list" =: bulletList [ plain $ text "first"
                                       , plain $ text "second"
@@ -52,19 +54,13 @@
                                       ]
             =?> "<list list-type=\"bullet\">\n\
                 \  <list-item>\n\
-                \    <p>\n\
-                \      first\n\
-                \    </p>\n\
+                \    <p>first</p>\n\
                 \  </list-item>\n\
                 \  <list-item>\n\
-                \    <p>\n\
-                \      second\n\
-                \    </p>\n\
+                \    <p>second</p>\n\
                 \  </list-item>\n\
                 \  <list-item>\n\
-                \    <p>\n\
-                \      third\n\
-                \    </p>\n\
+                \    <p>third</p>\n\
                 \  </list-item>\n\
                 \</list>"
         , testGroup "definition lists"
@@ -72,24 +68,18 @@
              [plain (text "hi there")])] =?>
             "<def-list>\n\
             \  <def-item>\n\
-            \    <term>\n\
-            \      <xref alt=\"testing\" rid=\"go\">testing</xref>\n\
-            \    </term>\n\
+            \    <term><xref alt=\"testing\" rid=\"go\">testing</xref></term>\n\
             \    <def>\n\
-            \      <p>\n\
-            \        hi there\n\
-            \      </p>\n\
+            \      <p>hi there</p>\n\
             \    </def>\n\
             \  </def-item>\n\
             \</def-list>"
           ]
         , testGroup "math"
           [ "escape |" =: para (math "\\sigma|_{\\{x\\}}") =?>
-            "<p>\n\
-            \  <inline-formula><alternatives>\n\
-            \  <tex-math><![CDATA[\\sigma|_{\\{x\\}}]]></tex-math>\n\
-            \  <mml:math display=\"inline\" xmlns:mml=\"http://www.w3.org/1998/Math/MathML\"><mml:mrow><mml:mi>σ</mml:mi><mml:msub><mml:mo stretchy=\"false\" form=\"prefix\">|</mml:mo><mml:mrow><mml:mo stretchy=\"false\" form=\"prefix\">{</mml:mo><mml:mi>x</mml:mi><mml:mo stretchy=\"false\" form=\"postfix\">}</mml:mo></mml:mrow></mml:msub></mml:mrow></mml:math></alternatives></inline-formula>\n\
-            \</p>"
+            "<p><inline-formula><alternatives>\n\
+            \<tex-math><![CDATA[\\sigma|_{\\{x\\}}]]></tex-math>\n\
+            \<mml:math display=\"inline\" xmlns:mml=\"http://www.w3.org/1998/Math/MathML\"><mml:mrow><mml:mi>σ</mml:mi><mml:msub><mml:mo stretchy=\"false\" form=\"prefix\">|</mml:mo><mml:mrow><mml:mo stretchy=\"false\" form=\"prefix\">{</mml:mo><mml:mi>x</mml:mi><mml:mo stretchy=\"false\" form=\"postfix\">}</mml:mo></mml:mrow></mml:msub></mml:mrow></mml:math></alternatives></inline-formula></p>"
           ]
         , testGroup "headers"
           [ "unnumbered header" =:
@@ -97,9 +87,7 @@
               (text "Header 1" <> note (plain $ text "note")) =?>
             "<sec id=\"foo\">\n\
             \  <title>Header 1<fn>\n\
-            \    <p>\n\
-            \      note\n\
-            \    </p>\n\
+            \    <p>note</p>\n\
             \  </fn></title>\n\
             \</sec>"
           , "unnumbered sub header" =:
diff --git a/test/Tests/Writers/LaTeX.hs b/test/Tests/Writers/LaTeX.hs
--- a/test/Tests/Writers/LaTeX.hs
+++ b/test/Tests/Writers/LaTeX.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Writers.LaTeX (tests) where
 
+import Prelude
 import Data.Text (unpack)
 import Test.Tasty
 import Tests.Helpers
diff --git a/test/Tests/Writers/Markdown.hs b/test/Tests/Writers/Markdown.hs
--- a/test/Tests/Writers/Markdown.hs
+++ b/test/Tests/Writers/Markdown.hs
@@ -1,7 +1,9 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-# OPTIONS_GHC -fno-warn-name-shadowing #-}
 module Tests.Writers.Markdown (tests) where
 
+import Prelude
 import Data.Text (unpack)
 import Test.Tasty
 import Tests.Helpers
diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs
--- a/test/Tests/Writers/Muse.hs
+++ b/test/Tests/Writers/Muse.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Tests.Writers.Muse (tests) where
 
+import Prelude
 import Data.Text (unpack)
 import Test.Tasty
 import Tests.Helpers
@@ -101,6 +103,15 @@
                             , "                  :: second description"
                             , " second definition :: third description"
                             ]
+              , "definition list with empty term" =:
+                definitionList [ (text "first definition", [plain $ text "first description"])
+                               , (mempty, [plain $ text "second description"])
+                               , (str "", [plain $ text "third description"])
+                               ]
+                =?> unlines [ " first definition :: first description"
+                            , " <verbatim></verbatim> :: second description"
+                            , " <verbatim></verbatim> :: third description"
+                            ]
               ]
             -- Test that lists of the same type and style are separated with two blanklines
             , testGroup "sequential lists"
@@ -301,6 +312,15 @@
             -- We don't want colons to be escaped if they can't be confused
             -- with definition list item markers.
             , "do not escape colon" =: str ":" =?> ":"
+            , "escape - to avoid accidental unordered lists" =: text " - foo" =?> " <verbatim>-</verbatim> foo"
+            , "escape - inside a list to avoid accidental nested unordered lists" =:
+              bulletList [ (para $ text "foo") <>
+                           (para $ text "- bar")
+                         ] =?>
+              unlines [ " - foo"
+                      , ""
+                      , "   <verbatim>-</verbatim> bar"
+                      ]
             ]
           , testGroup "emphasis"
             [ "emph" =: emph (text "foo") =?> "<em>foo</em>"
@@ -309,7 +329,8 @@
             ]
           , "superscript" =: superscript (text "foo") =?> "<sup>foo</sup>"
           , "subscript" =: subscript (text "foo") =?> "<sub>foo</sub>"
-          , "smallcaps" =: smallcaps (text "foo") =?> "foo"
+          , "smallcaps" =: smallcaps (text "foo") =?> "<em>foo</em>"
+          , "smallcaps near emphasis" =: emph (str "foo") <> smallcaps (str "bar") =?> "<em>foobar</em>"
           , "single quoted" =: singleQuoted (text "foo") =?> "‘foo’"
           , "double quoted" =: doubleQuoted (text "foo") =?> "“foo”"
           -- Cite is trivial
@@ -332,6 +353,8 @@
             [ "inline math" =: math "2^3" =?> "2<sup>3</sup>"
             , "display math" =: displayMath "2^3" =?> "2<sup>3</sup>"
             , "multiple letters in inline math" =: math "abc" =?> "<em>abc</em>"
+            , "expand math before normalization" =: math "[" <> str "2]" =?> "<verbatim>[2]</verbatim>"
+            , "multiple math expressions inside one inline list" =: math "5_4" <> text ", " <> displayMath "3^2" =?> "5<sub>4</sub>, 3<sup>2</sup>"
             ]
           , "raw inline"
             =: rawInline "html" "<mark>marked text</mark>"
@@ -359,8 +382,12 @@
                                , ""
                                , "[1] Foo"
                                ]
-          , "span" =: spanWith ("",["foobar"],[]) (str "Some text")
+          , "span with class" =: spanWith ("",["foobar"],[]) (text "Some text")
                    =?> "<class name=\"foobar\">Some text</class>"
+          , "span with anchor" =: spanWith ("anchor", [], []) (text "Foo bar")
+                               =?> "#anchor Foo bar"
+          , "span with class and anchor" =: spanWith ("anchor", ["foo"], []) (text "bar")
+                                         =?> "#anchor <class name=\"foo\">bar</class>"
           , testGroup "combined"
             [ "emph word before" =:
                 para (text "foo" <> emph (text "bar")) =?>
diff --git a/test/Tests/Writers/Native.hs b/test/Tests/Writers/Native.hs
--- a/test/Tests/Writers/Native.hs
+++ b/test/Tests/Writers/Native.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Tests.Writers.Native (tests) where
 
+import Prelude
 import Data.Text (unpack)
 import Test.Tasty
 import Test.Tasty.QuickCheck
diff --git a/test/Tests/Writers/OOXML.hs b/test/Tests/Writers/OOXML.hs
--- a/test/Tests/Writers/OOXML.hs
+++ b/test/Tests/Writers/OOXML.hs
@@ -1,8 +1,10 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE PatternGuards     #-}
 {-# LANGUAGE OverloadedStrings #-}
 
 module Tests.Writers.OOXML (ooxmlTest) where
 
+import Prelude
 import Text.Pandoc
 import Test.Tasty
 import Test.Tasty.Golden.Advanced
diff --git a/test/Tests/Writers/Org.hs b/test/Tests/Writers/Org.hs
--- a/test/Tests/Writers/Org.hs
+++ b/test/Tests/Writers/Org.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Writers.Org (tests) where
 
+import Prelude
 import Test.Tasty
 import Tests.Helpers
 import Text.Pandoc
diff --git a/test/Tests/Writers/Plain.hs b/test/Tests/Writers/Plain.hs
--- a/test/Tests/Writers/Plain.hs
+++ b/test/Tests/Writers/Plain.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Writers.Plain (tests) where
 
+import Prelude
 import Test.Tasty
 import Tests.Helpers
 import Text.Pandoc
diff --git a/test/Tests/Writers/Powerpoint.hs b/test/Tests/Writers/Powerpoint.hs
--- a/test/Tests/Writers/Powerpoint.hs
+++ b/test/Tests/Writers/Powerpoint.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 module Tests.Writers.Powerpoint (tests) where
 
+import Prelude
 import Tests.Writers.OOXML (ooxmlTest)
 import Text.Pandoc
 import Test.Tasty
diff --git a/test/Tests/Writers/RST.hs b/test/Tests/Writers/RST.hs
--- a/test/Tests/Writers/RST.hs
+++ b/test/Tests/Writers/RST.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Writers.RST (tests) where
 
+import Prelude
 import Test.Tasty
 import Tests.Helpers
 import Text.Pandoc
@@ -49,6 +51,19 @@
               , ".."
               , ""
               , "    quoted"]
+          ]
+        , testGroup "inlines"
+          [ "are removed when empty" =: -- #4434
+            plain (strong (str "")) =?> ""
+          , "do not cause the introduction of extra spaces when removed" =:
+            plain (strong (str "") <> emph (str "text")) =?> "*text*"
+          , "spaces are stripped at beginning and end" =:
+            -- pandoc issue 4327 "The text within inline markup may not
+            -- begin or end with whitespace"
+            -- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup
+            strong (space <> str "text" <> space <> space) =?> "**text**"
+          , "single space stripped" =:
+            strong space =?> ""
           ]
         , testGroup "headings"
           [ "normal heading" =:
diff --git a/test/Tests/Writers/TEI.hs b/test/Tests/Writers/TEI.hs
--- a/test/Tests/Writers/TEI.hs
+++ b/test/Tests/Writers/TEI.hs
@@ -1,6 +1,8 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Tests.Writers.TEI (tests) where
 
+import Prelude
 import Test.Tasty
 import Tests.Helpers
 import Text.Pandoc
diff --git a/test/command/1710.md b/test/command/1710.md
--- a/test/command/1710.md
+++ b/test/command/1710.md
@@ -54,9 +54,8 @@
 </div>
 </div>
 ^D
-\begin{frame}{%
-\protect\hypertarget{slide-one}{%
-Slide one}}
+\begin{frame}{Slide one}
+\protect\hypertarget{slide-one}{}
 
 \begin{columns}[T]
 \begin{column}{0.40\textwidth}
diff --git a/test/command/3587.md b/test/command/3587.md
--- a/test/command/3587.md
+++ b/test/command/3587.md
@@ -19,3 +19,39 @@
 ^D
 [Para [Str "{}\160{}\160{}"]]
 ```
+
+```
+% pandoc -f latex -t native
+\SI{30}{\milli\meter}
+^D
+[Para [Str "30\160mm"]]
+```
+
+```
+% pandoc -f latex -t native
+\SI{6}{\gram}
+^D
+[Para [Str "6\160g"]]
+```
+
+```
+% pandoc -f latex -t native
+\SI{25}{\square\meter}
+^D
+[Para [Str "25\160m\178"]]
+```
+
+```
+% pandoc -f latex -t native
+\SI{18.2}{\degreeCelsius}
+^D
+[Para [Str "18.2\160\176C"]]
+```
+
+```
+% pandoc -f latex -t native
+\SI{18.2}{\celsius}
+^D
+[Para [Str "18.2\160\176C"]]
+```
+
diff --git a/test/command/4016.md b/test/command/4016.md
--- a/test/command/4016.md
+++ b/test/command/4016.md
@@ -13,9 +13,8 @@
 </div>
 </div>
 ^D
-\begin{frame}{%
-\protect\hypertarget{level-2-blocks}{%
-Level 2 blocks}}
+\begin{frame}{Level 2 blocks}
+\protect\hypertarget{level-2-blocks}{}
 
 \begin{columns}[T]
 \begin{column}{0.40\textwidth}
diff --git a/test/command/4320.md b/test/command/4320.md
new file mode 100644
--- /dev/null
+++ b/test/command/4320.md
@@ -0,0 +1,15 @@
+```
+% pandoc -f native -t rst --wrap=none
+[Table [] [AlignDefault,AlignDefault] [0.47368421052631576,0.5263157894736842]
+ [[Plain [Str "one"]]
+ ,[Plain [Str "two"]]]
+ [[[Plain [Str "ports"]]
+  ,[BlockQuote
+    [Para [Strong [Str "thisIsGoingToBeTooLongAnyway"]]]]]]]
+^D
++-------+--------------------------------------+
+| one   | two                                  |
++=======+======================================+
+| ports |     **thisIsGoingToBeTooLongAnyway** |
++-------+--------------------------------------+
+```
diff --git a/test/command/4454.md b/test/command/4454.md
new file mode 100644
--- /dev/null
+++ b/test/command/4454.md
@@ -0,0 +1,9 @@
+```
+% pandoc -f rst -t native
+• a
+• b
+^D
+[BulletList
+ [[Plain [Str "a"]]
+ ,[Plain [Str "b"]]]]
+```
diff --git a/test/docx/nested_smart_tags.docx b/test/docx/nested_smart_tags.docx
new file mode 100644
Binary files /dev/null and b/test/docx/nested_smart_tags.docx differ
diff --git a/test/docx/nested_smart_tags.native b/test/docx/nested_smart_tags.native
new file mode 100644
--- /dev/null
+++ b/test/docx/nested_smart_tags.native
@@ -0,0 +1,7 @@
+[Header 2 ("and-it-came-to-pass-in-the-course-of-those-many-days",["Myheading2"],[]) [Str "159.",Space,Str "And",Space,Str "It",Space,Str "Came",Space,Str "to",Space,Str "Pass",Space,Str "in",Space,Str "the",Space,Str "Course",Space,Str "of",Space,Str "Those",Space,Str "Many",Space,Str "Days"]
+,Para [Str "I",Space,Str "heard"]
+,Para [Str "\8220And",Space,Str "it",Space,Str "came",Space,Str "to",Space,Str "pass",Space,Str "in",Space,Str "the",Space,Str "course",Space,Str "of",Space,Str "those",Space,Str "many",Space,Str "days",Space,Str "that",Space,Str "the",Space,Str "king",Space,Str "of",Space,Str "Egypt",Space,Str "died;",Space,Str "and",Space,Str "the",Space,Str "children",Space,Str "of",Space,Str "Israel",Space,Str "sighed",Space,Str "by",Space,Str "reason",Space,Str "of",Space,Str "the",Space,Str "bondage,",Space,Str "and",Space,Str "they",Space,Str "cried,",Space,Str "and",Space,Str "their",Space,Str "cry",Space,Str "came",Space,Str "up",Space,Str "unto",Space,Str "God",Space,Str "by",Space,Str "reason",Space,Str "of",Space,Str "the",Space,Str "bondage.",Space,Str "And",Space,Str "God",Space,Str "heard",Space,Str "their",Space,Str "groaning\8221",Space,Str "(Exodus",Space,Str "2:23-4).",Space,Str "This",Space,Str "means",Space,Str "that",Space,Str "they",Space,Str "suffered",Space,Str "so",Space,Str "much",Space,Str "that",Space,Str "they",Space,Str "could",Space,Str "not",Space,Str "bear",Space,Str "it",Space,Str "any",Space,Str "longer.",Space,Str "And",Space,Str "they",Space,Str "so",Space,Str "pleaded",Space,Str "with",Space,Str "prayer,",Space,Str "that",Space,Str "\8220their",Space,Str "cry",Space,Str "came",Space,Str "up",Space,Str "unto",Space,Str "God.\8221"]
+,Para [Str "But",Space,Str "we",Space,Str "can",Space,Str "see",Space,Str "that",Space,Str "they",Space,Str "were",Space,Str "saying,",Space,Str "\8220Would",Space,Str "that",Space,Str "we",Space,Str "had\8230",Space,Str "when",Space,Str "we",Space,Str "sat",Space,Str "by",Space,Str "the",Space,Str "flesh-pots,",Space,Str "when",Space,Str "we",Space,Str "did",Space,Str "eat",Space,Str "bread",Space,Str "to",Space,Str "the",Space,Str "full.\8221",Space,Str "And",Space,Str "they",Space,Str "also",Space,Str "said,",Space,Str "\8220We",Space,Str "remember",Space,Str "the",Space,Str "fish,",Space,Str "which",Space,Str "we",Space,Str "would",Space,Str "eat",Space,Str "in",Space,Str "Egypt",Space,Str "for",Space,Str "naught;",Space,Str "the",Space,Str "cucumbers,",Space,Str "and",Space,Str "the",Space,Str "melons,",Space,Str "and",Space,Str "the",Space,Str "leeks,",Space,Str "and",Space,Str "the",Space,Str "onions,",Space,Str "and",Space,Str "the",Space,Str "garlic.\8221"]
+,Para [Str "The",Space,Str "thing",Space,Str "is",Space,Str "that,",Space,Str "indeed,",Space,Str "they",Space,Str "were",Space,Str "very",Space,Str "fond",Space,Str "of",Space,Str "the",Space,Str "work",Space,Str "in",Space,Str "Egypt.",Space,Str "This",Space,Str "is",Space,Str "the",Space,Str "meaning",Space,Str "of",Space,Str "\8220But",Space,Str "mingled",Space,Str "themselves",Space,Str "with",Space,Str "the",Space,Str "nations,",Space,Str "and",Space,Str "learned",Space,Str "their",Space,Str "works.\8221",Space,Str "It",Space,Str "means",Space,Str "that",Space,Str "if",Space,Str "Israel",Space,Str "are",Space,Str "under",Space,Str "the",Space,Str "dominion",Space,Str "of",Space,Str "a",Space,Str "certain",Space,Str "nation,",Space,Str "that",Space,Str "nation",Space,Str "controls",Space,Str "them",Space,Str "and",Space,Str "they",Space,Str "cannot",Space,Str "retire",Space,Str "from",Space,Str "their",Space,Str "dominion.",Space,Str "Thus,",Space,Str "they",Space,Str "tasted",Space,Str "sufficient",Space,Str "flavor",Space,Str "in",Space,Str "that",Space,Str "work",Space,Str "and",Space,Str "could",Space,Str "not",Space,Str "be",Space,Str "redeemed."]
+,Para [Str "So",Space,Str "what",Space,Str "did",Space,Str "the",Space,Str "Creator",Space,Str "do?",Space,Str "\8220The",Space,Str "king",Space,Str "of",Space,Str "Egypt",Space,Str "died,\8221",Space,Str "meaning",Space,Str "they",Space,Str "had",Space,Str "lost",Space,Str "this",Space,Str "servitude.",Space,Str "Thus",Space,Str "they",Space,Str "could",Space,Str "no",Space,Str "longer",Space,Str "work;",Space,Str "they",Space,Str "understood",Space,Str "that",Space,Str "if",Space,Str "there",Space,Str "is",Space,Str "no",Space,Str "perfection",Space,Str "of",Space,Str "the",Space,Emph [Str "Mochin"],Str ",",Space,Str "the",Space,Str "servitude",Space,Str "is",Space,Str "also",Space,Str "incomplete.",Space,Str "Hence,",Space,Str "\8220and",Space,Str "the",Space,Str "children",Space,Str "of",Space,Str "Israel",Space,Str "sighed",Space,Str "by",Space,Str "reason",Space,Str "of",Space,Str "the",Space,Str "bondage.\8221",Space,Str "The",Space,Str "work",Space,Str "means",Space,Str "that",Space,Str "they",Space,Str "did",Space,Str "not",Space,Str "suffice",Space,Str "for",Space,Str "the",Space,Str "work,",Space,Str "that",Space,Str "they",Space,Str "had",Space,Str "no",Space,Str "liveliness",Space,Str "in",Space,Str "the",Space,Str "servitude."]
+,Para [Str "This",Space,Str "is",Space,Str "the",Space,Str "meaning",Space,Str "of",Space,Str "\8220the",Space,Str "king",Space,Str "of",Space,Str "Egypt",Space,Str "died,\8221",Space,Str "that",Space,Str "all",Space,Str "the",Space,Str "dominations",Space,Str "of",Space,Str "the",Space,Str "king",Space,Str "of",Space,Str "Egypt,",Space,Str "which",Space,Str "he",Space,Str "was",Space,Str "providing",Space,Str "for",Space,Str "and",Space,Str "nourishing,",Space,Str "had",Space,Str "died.",Space,Str "This",Space,Str "is",Space,Str "why",Space,Str "they",Space,Str "had",Space,Str "room",Space,Str "for",Space,Str "prayer.",Space,Str "And",Space,Str "they",Space,Str "were",Space,Str "immediately",Space,Str "salvaged.",Space,Str "And",Space,Str "afterwards,",Space,Str "when",Space,Str "they",Space,Str "walked",Space,Str "in",Space,Str "the",Space,Str "desert",Space,Str "and",Space,Str "came",Space,Str "to",Space,Str "a",Space,Str "state",Space,Str "of",Space,Emph [Str "Katnut"],Space,Str "(smallness),",Space,Str "they",Space,Str "craved",Space,Str "the",Space,Str "servitude",Space,Str "that",Space,Str "they",Space,Str "had",Space,Str "had",Space,Str "prior",Space,Str "to",Space,Str "the",Space,Str "death",Space,Str "of",Space,Str "the",Space,Str "king",Space,Str "of",Space,Str "Egypt."]]
diff --git a/test/dokuwiki_multiblock_table.dokuwiki b/test/dokuwiki_multiblock_table.dokuwiki
--- a/test/dokuwiki_multiblock_table.dokuwiki
+++ b/test/dokuwiki_multiblock_table.dokuwiki
@@ -1,4 +1,5 @@
 Sample grid table.
-^Fruit  ^Price^Advantages                     ^
-|Bananas|$1.34|built-in wrapper\\ \\ potassium|
-|Oranges|$2.10|* cures scurvy\\ * tasty       |
+^Fruit  ^Price^Advantages                         ^
+|Bananas|$1.34|built-in wrapper\\ \\ potassium    |
+|Oranges|$2.10|* cures scurvy\\ * tasty           |
+|Apples |$1.10|Some text\\ \\ after two linebreaks|
diff --git a/test/dokuwiki_multiblock_table.native b/test/dokuwiki_multiblock_table.native
--- a/test/dokuwiki_multiblock_table.native
+++ b/test/dokuwiki_multiblock_table.native
@@ -10,4 +10,9 @@
   ,[Para [Str "$2.10"]]
   ,[BulletList
     [[Plain [Str "cures",Space,Str "scurvy"]]
-    ,[Plain [Str "tasty"]]]]]]]
+    ,[Plain [Str "tasty"]]]]]
+ ,[[Para [Str "Apples"]]
+  ,[Para [Str "$1.10"]]
+  ,[Para [Str "Some",Space,Str "text",LineBreak,LineBreak,Str "after",Space,Str "two",Space,Str "linebreaks"] 
+    ]]
+ ]]
diff --git a/test/jats-reader.native b/test/jats-reader.native
--- a/test/jats-reader.native
+++ b/test/jats-reader.native
@@ -1,5 +1,5 @@
 Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Space,Str "MacFarlane"]]),("title",MetaInlines [Str "Pandoc",Space,Str "Test",Space,Str "Suite"])]})
-[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc.",Space,Str "Most",Space,Str "of",Space,Str "them",Space,Str "are",Space,Str "adapted",Space,Str "from",Space,Str "John",SoftBreak,Str "Gruber's",Space,Str "markdown",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."]
 ,Header 1 ("headers",[],[]) [Str "Headers"]
 ,Header 2 ("level-2-with-an-embedded-link",[],[]) [Str "Level",Space,Str "2",Space,Str "with",Space,Str "an",SoftBreak,Link ("",[],[]) [Str "embedded",SoftBreak,Str "link"] ("/url","")]
 ,Header 3 ("level-3-with-emphasis",[],[]) [Str "Level",Space,Str "3",Space,Str "with",Space,Emph [Str "emphasis"]]
@@ -13,7 +13,7 @@
 ,Para [Str "with",Space,Str "no",Space,Str "blank",Space,Str "line"]
 ,Header 1 ("paragraphs",[],[]) [Str "Paragraphs"]
 ,Para [Str "Here's",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
-,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",SoftBreak,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",SoftBreak,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]
+,Para [Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]
 ,Para [Str "Here's",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "bullet.",Space,Str "*",Space,Str "criminey."]
 ,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break",LineBreak,Str "here."]
 ,Header 1 ("block-quotes",[],[]) [Str "Block",Space,Str "Quotes"]
diff --git a/test/jats-reader.xml b/test/jats-reader.xml
--- a/test/jats-reader.xml
+++ b/test/jats-reader.xml
@@ -29,1754 +29,1129 @@
 </article-meta>
 </front>
 <body>
-<p>
-  This is a set of tests for pandoc. Most of them are adapted from John
-  Gruber's markdown test suite.
-</p>
-<sec id="headers">
-  <title>Headers</title>
-  <sec id="level-2-with-an-embedded-link">
-    <title>Level 2 with an
-    <ext-link ext-link-type="uri" xlink:href="/url">embedded
-    link</ext-link></title>
-    <sec id="level-3-with-emphasis">
-      <title>Level 3 with <italic>emphasis</italic></title>
-      <sec id="level-4">
-        <title>Level 4</title>
-        <sec id="level-5">
-          <title>Level 5</title>
-        </sec>
-      </sec>
-    </sec>
-  </sec>
-</sec>
-<sec id="level-1">
-  <title>Level 1</title>
-  <sec id="level-2-with-emphasis">
-    <title>Level 2 with <italic>emphasis</italic></title>
-    <sec id="level-3">
-      <title>Level 3</title>
-      <p>
-        with no blank line
-      </p>
-    </sec>
-  </sec>
-  <sec id="level-2">
-    <title>Level 2</title>
-    <p>
-      with no blank line
-    </p>
-  </sec>
-</sec>
-<sec id="paragraphs">
-  <title>Paragraphs</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<break />here.
-  </p>
-</sec>
-<sec id="block-quotes">
-  <title>Block Quotes</title>
-  <p>
-    E-mail style:
-  </p>
-  <disp-quote>
-    <p>
-      This is a block quote. It is pretty short.
-    </p>
-  </disp-quote>
-  <disp-quote>
-    <p>
-      Code in a block quote:
-    </p>
-    <preformat>sub status {
-    print &quot;working&quot;;
-}</preformat>
-    <p>
-      A list:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          item one
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          item two
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Nested block quotes:
-    </p>
-    <disp-quote>
-      <p>
-        nested
-      </p>
-    </disp-quote>
-    <disp-quote>
-      <p>
-        nested
-      </p>
-    </disp-quote>
-  </disp-quote>
-  <p>
-    This should not be a block quote: 2 &gt; 1.
-  </p>
-  <p>
-    Box-style:
-  </p>
-  <disp-quote>
-    <p>
-      Example:
-    </p>
-    <preformat>sub status {
-    print &quot;working&quot;;
-}</preformat>
-  </disp-quote>
-  <disp-quote>
-    <list list-type="order">
-      <list-item>
-        <p>
-          do laundry
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          take out the trash
-        </p>
-      </list-item>
-    </list>
-  </disp-quote>
-  <p>
-    Here's a nested one:
-  </p>
-  <disp-quote>
-    <p>
-      Joe said:
-    </p>
-    <disp-quote>
-      <p>
-        Don't quote me.
-      </p>
-    </disp-quote>
-  </disp-quote>
-  <p>
-    And a following paragraph.
-  </p>
-</sec>
-<sec id="code-blocks">
-  <title>Code Blocks</title>
-  <p>
-    Code:
-  </p>
-  <preformat>---- (should be four hyphens)
-
-sub status {
-    print &quot;working&quot;;
-}
-
-this code block is indented by one tab</preformat>
-  <p>
-    And:
-  </p>
-  <preformat>    this code block is indented by two tabs
-
-These should not be escaped:  \$ \\ \&gt; \[ \{</preformat>
-</sec>
-<sec id="lists">
-  <title>Lists</title>
-  <sec id="unordered">
-    <title>Unordered</title>
-    <p>
-      Asterisks tight:
-    </p>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          asterisk 1
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          asterisk 2
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          asterisk 3
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Asterisks loose:
-    </p>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          asterisk 1
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          asterisk 2
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          asterisk 3
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Pluses tight:
-    </p>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          Plus 1
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Plus 2
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Plus 3
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Pluses loose:
-    </p>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          Plus 1
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Plus 2
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Plus 3
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Minuses tight:
-    </p>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          Minus 1
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Minus 2
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Minus 3
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Minuses loose:
-    </p>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          Minus 1
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Minus 2
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Minus 3
-        </p>
-      </list-item>
-    </list>
-  </sec>
-  <sec id="ordered">
-    <title>Ordered</title>
-    <p>
-      Tight:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          First
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Second
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Third
-        </p>
-      </list-item>
-    </list>
-    <p>
-      and:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          One
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Two
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Three
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Loose using tabs:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          First
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Second
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Third
-        </p>
-      </list-item>
-    </list>
-    <p>
-      and using spaces:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          One
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Two
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Three
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Multiple paragraphs:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          Item 1, graf one.
-        </p>
-        <p>
-          Item 1. graf two. The quick brown fox jumped over the lazy
-          dog's back.
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Item 2.
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Item 3.
-        </p>
-      </list-item>
-    </list>
-    <p>
-      List styles:
-    </p>
-    <list list-type="order"></list>
-    <list list-type="roman-lower"></list>
-  </sec>
-  <sec id="nested">
-    <title>Nested</title>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          Tab
-        </p>
-        <list list-type="bullet">
-          <list-item>
-            <p>
-              Tab
-            </p>
-            <list list-type="bullet">
-              <list-item>
-                <p>
-                  Tab
-                </p>
-              </list-item>
-            </list>
-          </list-item>
-        </list>
-      </list-item>
-    </list>
-    <p>
-      Here's another:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          First
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Second:
-        </p>
-        <list list-type="bullet">
-          <list-item>
-            <p>
-              Fee
-            </p>
-          </list-item>
-          <list-item>
-            <p>
-              Fie
-            </p>
-          </list-item>
-          <list-item>
-            <p>
-              Foe
-            </p>
-          </list-item>
-        </list>
-      </list-item>
-      <list-item>
-        <p>
-          Third
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Same thing but with paragraphs:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          First
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Second:
-        </p>
-        <list list-type="bullet">
-          <list-item>
-            <p>
-              Fee
-            </p>
-          </list-item>
-          <list-item>
-            <p>
-              Fie
-            </p>
-          </list-item>
-          <list-item>
-            <p>
-              Foe
-            </p>
-          </list-item>
-        </list>
-      </list-item>
-      <list-item>
-        <p>
-          Third
-        </p>
-      </list-item>
-    </list>
-  </sec>
-  <sec id="tabs-and-spaces">
-    <title>Tabs and spaces</title>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          this is a list item indented with tabs
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          this is a list item indented with spaces
-        </p>
-        <list list-type="bullet">
-          <list-item>
-            <p>
-              this is an example list item indented with tabs
-            </p>
-          </list-item>
-          <list-item>
-            <p>
-              this is an example list item indented with spaces
-            </p>
-          </list-item>
-        </list>
-      </list-item>
-    </list>
-  </sec>
-  <sec id="fancy-list-markers">
-    <title>Fancy list markers</title>
-    <p>
-      Autonumbering:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          Autonumber.
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          More.
-        </p>
-        <list list-type="order">
-          <list-item>
-            <p>
-              Nested.
-            </p>
-          </list-item>
-        </list>
-      </list-item>
-    </list>
-  </sec>
-  <sec id="definition">
-    <title>Definition</title>
-    <def-list>
-      <def-item>
-        <term>
-          Violin
-        </term>
-        <def>
-          <p>
-            Stringed musical instrument.
-          </p>
-          <p>
-            Torture device.
-          </p>
-        </def>
-      </def-item>
-      <def-item>
-        <term>
-          Cello<break />Violoncello
-        </term>
-        <def>
-          <p>
-            Low-voiced stringed instrument.
-          </p>
-        </def>
-      </def-item>
-    </def-list>
-  </sec>
-</sec>
-<sec id="inline-markup">
-  <title>Inline Markup</title>
-  <p>
-    This is <italic>emphasized</italic>, and so <italic>is
-    this</italic>.
-  </p>
-  <p>
-    This is <bold role="strong">strong</bold>, and so
-    <bold role="strong">is this</bold>.
-  </p>
-  <p>
-    Empty <bold role="strong"></bold> and <italic></italic>.
-  </p>
-  <p>
-    An
-    <italic><ext-link ext-link-type="uri" xlink:href="/url">emphasized
-    link</ext-link></italic>.
-  </p>
-  <p>
-    <bold role="strong"><italic>This is strong and em.</italic></bold>
-  </p>
-  <p>
-    So is <bold role="strong"><italic>this</italic></bold> word.
-  </p>
-  <p>
-    <bold role="strong"><italic>This is strong and em.</italic></bold>
-  </p>
-  <p>
-    So is <bold role="strong"><italic>this</italic></bold> word.
-  </p>
-  <p>
-    This is code: <monospace>&gt;</monospace>, <monospace>$</monospace>,
-    <monospace>\</monospace>, <monospace>\$</monospace>,
-    <monospace>&lt;html&gt;</monospace>.
-  </p>
-  <p>
-    This is <sc role="smallcaps">small caps</sc>.
-  </p>
-  <p>
-    These are all underlined: foo and bar.
-  </p>
-  <p>
-    These are all strikethrough: <strike>foo</strike>,
-    <strike>bar</strike>, and <strike>baz</strike>.
-  </p>
-</sec>
-<sec id="smart-quotes-ellipses-dashes">
-  <title>Smart quotes, ellipses, dashes</title>
-  <p>
-    &quot;Hello,&quot; said the spider. &quot;'Shelob' is my name.&quot;
-  </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, &quot;I want to go.&quot;' Were you alive in the 70's?
-  </p>
-  <p>
-    Here is some quoted '<monospace>code</monospace>' and a
-    &quot;<ext-link ext-link-type="uri" xlink:href="http://example.com/?foo=1&amp;bar=2">quoted
-    link</ext-link>&quot;.
-  </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>
-</sec>
-<sec id="latex">
-  <title>LaTeX</title>
-  <list list-type="bullet">
-    <list-item>
-      <p>
-        \cite[22-23]{smith.1899}
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        \doublespacing
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        $2+2=4$
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        $x \in y$
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        $\alpha \wedge \omega$
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        $223$
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        $p$-Tree
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        $\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        Here's one that has a line break in it: $\alpha + \omega \times
-        x^2$.
-      </p>
-    </list-item>
-  </list>
-  <p>
-    These shouldn't be math:
-  </p>
-  <list list-type="bullet">
-    <list-item>
-      <p>
-        To get the famous equation, write
-        <monospace>$e = mc^2$</monospace>.
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        $22,000 is a <italic>lot</italic> of money. So is $34,000. (It
-        worked if &quot;lot&quot; is emphasized.)
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        Escaped <monospace>$</monospace>: $73 <italic>this should be
-        emphasized</italic> 23$.
-      </p>
-    </list-item>
-  </list>
-  <p>
-    Here's a LaTeX table:
-  </p>
-  <p>
-    \begin{tabular}{|l|l|}\hline Animal &amp; Number \\ \hline Dog &amp;
-    2 \\ Cat &amp; 1 \\ \hline \end{tabular}
-  </p>
-</sec>
-<sec id="special-characters">
-  <title>Special Characters</title>
-  <p>
-    Here is some unicode:
-  </p>
-  <list list-type="bullet">
-    <list-item>
-      <p>
-        I hat: Î
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        o umlaut: ö
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        section: §
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        set membership: elem
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        copyright: ©
-      </p>
-    </list-item>
-  </list>
-  <p>
-    AT&amp;T has an ampersand in their name.
-  </p>
-  <p>
-    AT&amp;T is another way to write it.
-  </p>
-  <p>
-    This &amp; that.
-  </p>
-  <p>
-    4 &lt; 5.
-  </p>
-  <p>
-    6 &gt; 5.
-  </p>
-  <p>
-    Backslash: \
-  </p>
-  <p>
-    Backtick: `
-  </p>
-  <p>
-    Asterisk: *
-  </p>
-  <p>
-    Underscore: _
-  </p>
-  <p>
-    Left brace: {
-  </p>
-  <p>
-    Right brace: }
-  </p>
-  <p>
-    Left bracket: [
-  </p>
-  <p>
-    Right bracket: ]
-  </p>
-  <p>
-    Left paren: (
-  </p>
-  <p>
-    Right paren: )
-  </p>
-  <p>
-    Greater-than: &gt;
-  </p>
-  <p>
-    Hash: #
-  </p>
-  <p>
-    Period: .
-  </p>
-  <p>
-    Bang: !
-  </p>
-  <p>
-    Plus: +
-  </p>
-  <p>
-    Minus: -
-  </p>
-</sec>
-<sec id="links">
-  <title>Links</title>
-  <sec id="explicit">
-    <title>Explicit</title>
-    <p>
-      Just a
-      <ext-link ext-link-type="uri" xlink:href="/url/">URL</ext-link>.
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title">URL
-      and title</ext-link>.
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title preceded by two spaces">URL
-      and title</ext-link>.
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title preceded by a tab">URL
-      and title</ext-link>.
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title with &quot;quotes&quot; in it">URL
-      and title</ext-link>
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title with single quotes">URL
-      and title</ext-link>
-    </p>
-    <p>
-      Email link (nobody [at] nowhere.net)
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="">Empty</ext-link>.
-    </p>
-  </sec>
-  <sec id="reference">
-    <title>Reference</title>
-    <p>
-      Foo
-      <ext-link ext-link-type="uri" xlink:href="/url/">bar</ext-link>.
-    </p>
-    <p>
-      Foo
-      <ext-link ext-link-type="uri" xlink:href="/url/">bar</ext-link>.
-    </p>
-    <p>
-      Foo
-      <ext-link ext-link-type="uri" xlink:href="/url/">bar</ext-link>.
-    </p>
-    <p>
-      With <ext-link ext-link-type="uri" xlink:href="/url/">embedded
-      [brackets]</ext-link>.
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="/url/">b</ext-link> by
-      itself should be a link.
-    </p>
-    <p>
-      Indented
-      <ext-link ext-link-type="uri" xlink:href="/url">once</ext-link>.
-    </p>
-    <p>
-      Indented
-      <ext-link ext-link-type="uri" xlink:href="/url">twice</ext-link>.
-    </p>
-    <p>
-      Indented
-      <ext-link ext-link-type="uri" xlink:href="/url">thrice</ext-link>.
-    </p>
-    <p>
-      This should [not] be a link.
-    </p>
-    <preformat>[not]: /url</preformat>
-    <p>
-      Foo
-      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="Title with &quot;quotes&quot; inside">bar</ext-link>.
-    </p>
-    <p>
-      Foo
-      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="Title with &quot;quote&quot; inside">biz</ext-link>.
-    </p>
-  </sec>
-  <sec id="with-ampersands">
-    <title>With ampersands</title>
-    <p>
-      Here's a
-      <ext-link ext-link-type="uri" xlink:href="http://example.com/?foo=1&amp;bar=2">link
-      with an ampersand in the URL</ext-link>.
-    </p>
-    <p>
-      Here's a link with an amersand in the link text:
-      <ext-link ext-link-type="uri" xlink:href="http://att.com/" xlink:title="AT&amp;T">AT&amp;T</ext-link>.
-    </p>
-    <p>
-      Here's an
-      <ext-link ext-link-type="uri" xlink:href="/script?foo=1&amp;bar=2">inline
-      link</ext-link>.
-    </p>
-    <p>
-      Here's an
-      <ext-link ext-link-type="uri" xlink:href="/script?foo=1&amp;bar=2">inline
-      link in pointy braces</ext-link>.
-    </p>
-  </sec>
-  <sec id="autolinks">
-    <title>Autolinks</title>
-    <p>
-      With an ampersand:
-      <ext-link ext-link-type="uri" xlink:href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</ext-link>
-    </p>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          In a list?
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          <ext-link ext-link-type="uri" xlink:href="http://example.com/">http://example.com/</ext-link>
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          It should.
-        </p>
-      </list-item>
-    </list>
-    <p>
-      An e-mail address: nobody [at] nowhere.net
-    </p>
-    <disp-quote>
-      <p>
-        Blockquoted:
-        <ext-link ext-link-type="uri" xlink:href="http://example.com/">http://example.com/</ext-link>
-      </p>
-    </disp-quote>
-    <p>
-      Auto-links should not occur here:
-      <monospace>&lt;http://example.com/&gt;</monospace>
-    </p>
-    <preformat>or here: &lt;http://example.com/&gt;</preformat>
-  </sec>
-</sec>
-<sec id="images">
-  <title>Images</title>
-  <p>
-    From &quot;Voyage dans la Lune&quot; by Georges Melies (1902):
-  </p>
-  <p>
-    <inline-graphic mimetype="image" mime-subtype="jpeg" xlink:href="lalune.jpg" xlink:title="Voyage dans la Lune" />
-  </p>
-  <p>
-    Here is a movie
-    <inline-graphic mimetype="image" mime-subtype="jpeg" xlink:href="movie.jpg" />
-    icon.
-  </p>
-</sec>
-<sec id="footnotes">
-  <title>Footnotes</title>
-  <p>
-    Here is a footnote reference<xref alt="(1)" rid="note_1">(1)</xref>,
-    and
-    another<xref alt="(longnote)" rid="note_longnote">(longnote)</xref>.
-    This should <italic>not</italic> be a footnote reference, because it
-    contains a space^(my note).
-  </p>
-  <p>
-    <xref alt="(1)" rid="ref_1">(1)</xref> Here is the footnote. It can
-    go anywhere in the document, not just at the end.
-  </p>
-  <p>
-    <xref alt="(longnote)" rid="ref_longnote">(longnote)</xref> Here's
-    the other note. This one contains multiple blocks.
-  </p>
-  <p>
-    Caret characters are used to indicate that the blocks all belong to
-    a single footnote (as with block quotes).
-  </p>
-  <preformat>  { &lt;code&gt; }</preformat>
-  <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 <italic>Leading space</italic>
-  </p>
-  <p>
-    <italic>Trailing space</italic> text
-  </p>
-  <p>
-    text <italic>Leading spaces</italic>
-  </p>
-  <p>
-    <italic>Trailing spaces</italic> text
-  </p>
-</sec>
-<sec id="tables">
-  <title>Tables</title>
-  <sec id="tables-with-headers">
-    <title>Tables with Headers</title>
-    <table>
-      <col align="left" />
-      <col align="left" />
-      <col align="left" />
-      <thead>
-        <tr>
-          <th>
-            <p>
-              X
-            </p>
-          </th>
-          <th>
-            <p>
-              Y
-            </p>
-          </th>
-          <th>
-            <p>
-              Z
-            </p>
-          </th>
-        </tr>
-      </thead>
-      <tbody>
-        <tr>
-          <td>
-            <p>
-              1
-            </p>
-          </td>
-          <td>
-            <p>
-              2
-            </p>
-          </td>
-          <td>
-            <p>
-              3
-            </p>
-          </td>
-        </tr>
-        <tr>
-          <td>
-            <p>
-              4
-            </p>
-          </td>
-          <td>
-            <p>
-              5
-            </p>
-          </td>
-          <td>
-            <p>
-              6
-            </p>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-    <table>
-      <col align="left" />
-      <col align="left" />
-      <col align="left" />
-      <thead>
-        <tr>
-          <th>
-            <p>
-              X
-            </p>
-          </th>
-          <th>
-            <p>
-              Y
-            </p>
-          </th>
-          <th>
-            <p>
-              Z
-            </p>
-          </th>
-        </tr>
-      </thead>
-      <tbody>
-        <tr>
-          <td>
-            <p>
-              1
-            </p>
-          </td>
-          <td>
-            <p>
-              2
-            </p>
-          </td>
-          <td>
-            <p>
-              3
-            </p>
-          </td>
-        </tr>
-        <tr>
-          <td>
-            <p>
-              4
-            </p>
-          </td>
-          <td>
-            <p>
-              5
-            </p>
-          </td>
-          <td>
-            <p>
-              6
-            </p>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-    <table>
-      <col align="left" />
-      <col align="left" />
-      <col align="left" />
-      <thead>
-        <tr>
-          <th>
-            <p>
-              X
-            </p>
-          </th>
-          <th>
-            <p>
-              Y
-            </p>
-          </th>
-          <th>
-            <p>
-              Z
-            </p>
-          </th>
-        </tr>
-      </thead>
-      <tbody>
-        <tr>
-          <td>
-            <p>
-              1
-            </p>
-          </td>
-          <td>
-            <p>
-              2
-            </p>
-          </td>
-          <td>
-            <p>
-              3
-            </p>
-          </td>
-        </tr>
-        <tr>
-          <td>
-            <p>
-              4
-            </p>
-          </td>
-          <td>
-            <p>
-              5
-            </p>
-          </td>
-          <td>
-            <p>
-              6
-            </p>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-    <table>
-      <col align="left" />
-      <col align="left" />
-      <col align="left" />
-      <thead>
-        <tr>
-          <th>
-            <p>
-              X
-            </p>
-          </th>
-          <th>
-            <p>
-              Y
-            </p>
-          </th>
-          <th>
-            <p>
-              Z
-            </p>
-          </th>
-        </tr>
-      </thead>
-      <tbody>
-        <tr>
-          <td>
-            <p>
-              1
-            </p>
-          </td>
-          <td>
-            <p>
-              2
-            </p>
-          </td>
-          <td>
-            <p>
-              3
-            </p>
-          </td>
-        </tr>
-        <tr>
-          <td>
-            <p>
-              4
-            </p>
-          </td>
-          <td>
-            <p>
-              5
-            </p>
-          </td>
-          <td>
-            <p>
-              6
-            </p>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-    <table>
-      <col align="left" />
-      <col align="left" />
-      <col align="left" />
-      <thead>
-        <tr>
-          <th>
-            <p>
-              X
-            </p>
-          </th>
-          <th>
-            <p>
-              Y
-            </p>
-          </th>
-          <th>
-            <p>
-              Z
-            </p>
-          </th>
-        </tr>
-      </thead>
-      <tbody>
-        <tr>
-          <td>
-            <p>
-              1
-            </p>
-          </td>
-          <td>
-            <p>
-              2
-            </p>
-          </td>
-          <td>
-            <p>
-              3
-            </p>
-          </td>
-        </tr>
-        <tr>
-          <td>
-            <p>
-              4
-            </p>
-          </td>
-          <td>
-            <p>
-              5
-            </p>
-          </td>
-          <td>
-            <p>
-              6
-            </p>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-    <table>
-      <col align="left" />
-      <col align="left" />
-      <col align="left" />
-      <thead>
-        <tr>
-          <th>
-            <p>
-              X
-            </p>
-          </th>
-          <th>
-            <p>
-              Y
-            </p>
-          </th>
-          <th>
-            <p>
-              Z
-            </p>
-          </th>
-        </tr>
-      </thead>
-      <tbody>
-        <tr>
-          <td>
-            <p>
-              1
-            </p>
-          </td>
-          <td>
-            <p>
-              2
-            </p>
-          </td>
-          <td>
-            <p>
-              3
-            </p>
-          </td>
-        </tr>
-        <tr>
-          <td>
-            <p>
-              4
-            </p>
-          </td>
-          <td>
-            <p>
-              5
-            </p>
-          </td>
-          <td>
-            <p>
-              6
-            </p>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-    <table>
-      <col align="left" />
-      <col align="left" />
-      <col align="left" />
-      <thead>
-        <tr>
-          <th>
-            <p>
-              X
-            </p>
-          </th>
-          <th>
-            <p>
-              Y
-            </p>
-          </th>
-          <th>
-            <p>
-              Z
-            </p>
-          </th>
-        </tr>
-      </thead>
-      <tbody>
-        <tr>
-          <td>
-            <p>
-              1
-            </p>
-          </td>
-          <td>
-            <p>
-              2
-            </p>
-          </td>
-          <td>
-            <p>
-              3
-            </p>
-          </td>
-        </tr>
-        <tr>
-          <td>
-            <p>
-              4
-            </p>
-          </td>
-          <td>
-            <p>
-              5
-            </p>
-          </td>
-          <td>
-            <p>
-              6
-            </p>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-    <table>
-      <col align="left" />
-      <col align="left" />
-      <col align="left" />
-      <thead>
-        <tr>
-          <th>
-            <p>
-              X
-            </p>
-          </th>
-          <th>
-            <p>
-              Y
-            </p>
-          </th>
-          <th>
-            <p>
-              Z
-            </p>
-          </th>
-        </tr>
-      </thead>
-      <tbody>
-        <tr>
-          <td>
-            <p>
-              1
-            </p>
-          </td>
-          <td>
-            <p>
-              2
-            </p>
-          </td>
-          <td>
-            <p>
-              3
-            </p>
-          </td>
-        </tr>
-        <tr>
-          <td>
-            <p>
-              4
-            </p>
-          </td>
-          <td>
-            <p>
-              5
-            </p>
-          </td>
-          <td>
-            <p>
-              6
-            </p>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-    <table>
-      <col width="33*" align="left" />
-      <col width="33*" align="left" />
-      <col width="33*" align="left" />
-      <thead>
-        <tr>
-          <th>
-            <p>
-              X
-            </p>
-          </th>
-          <th>
-            <p>
-              Y
-            </p>
-          </th>
-          <th>
-            <p>
-              Z
-            </p>
-          </th>
-        </tr>
-      </thead>
-      <tbody>
-        <tr>
-          <td>
-            <p>
-              1
-            </p>
-          </td>
-          <td>
-            <p>
-              2
-            </p>
-          </td>
-          <td>
-            <p>
-              3
-            </p>
-          </td>
-        </tr>
-        <tr>
-          <td>
-            <p>
-              4
-            </p>
-          </td>
-          <td>
-            <p>
-              5
-            </p>
-          </td>
-          <td>
-            <p>
-              6
-            </p>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-  </sec>
-  <sec id="tables-without-headers">
-    <title>Tables without Headers</title>
-    <table>
-      <col align="left" />
-      <col align="left" />
-      <col align="left" />
-      <tbody>
-        <tr>
-          <td>
-            <p>
-              1
-            </p>
-          </td>
-          <td>
-            <p>
-              2
-            </p>
-          </td>
-          <td>
-            <p>
-              3
-            </p>
-          </td>
-        </tr>
-        <tr>
-          <td>
-            <p>
-              4
-            </p>
-          </td>
-          <td>
-            <p>
-              5
-            </p>
-          </td>
-          <td>
-            <p>
-              6
-            </p>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-    <table>
-      <col align="left" />
-      <col align="left" />
-      <col align="left" />
-      <tbody>
-        <tr>
-          <td>
-            <p>
-              1
-            </p>
-          </td>
-          <td>
-            <p>
-              2
-            </p>
-          </td>
-          <td>
-            <p>
-              3
-            </p>
-          </td>
-        </tr>
-        <tr>
-          <td>
-            <p>
-              4
-            </p>
-          </td>
-          <td>
-            <p>
-              5
-            </p>
-          </td>
-          <td>
-            <p>
-              6
-            </p>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-    <table>
-      <col align="left" />
-      <col align="left" />
-      <col align="left" />
-      <tbody>
-        <tr>
-          <td>
-            <p>
-              1
-            </p>
-          </td>
-          <td>
-            <p>
-              2
-            </p>
-          </td>
-          <td>
-            <p>
-              3
-            </p>
-          </td>
-        </tr>
-        <tr>
-          <td>
-            <p>
-              4
-            </p>
-          </td>
-          <td>
-            <p>
-              5
-            </p>
-          </td>
-          <td>
-            <p>
-              6
-            </p>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-    <table>
-      <col align="left" />
-      <col align="left" />
-      <col align="left" />
-      <tbody>
-        <tr>
-          <td>
-            <p>
-              1
-            </p>
-          </td>
-          <td>
-            <p>
-              2
-            </p>
-          </td>
-          <td>
-            <p>
-              3
-            </p>
-          </td>
-        </tr>
-        <tr>
-          <td>
-            <p>
-              4
-            </p>
-          </td>
-          <td>
-            <p>
-              5
-            </p>
-          </td>
-          <td>
-            <p>
-              6
-            </p>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-  </sec>
-  <sec id="empty-tables">
-    <title>Empty Tables</title>
-    <p>
-      This section should be empty.
-    </p>
+<p>This is a set of tests for pandoc. Most of them are adapted from John Gruber's markdown test suite.</p>
+<sec id="headers">
+  <title>Headers</title>
+  <sec id="level-2-with-an-embedded-link">
+    <title>Level 2 with an
+    <ext-link ext-link-type="uri" xlink:href="/url">embedded
+    link</ext-link></title>
+    <sec id="level-3-with-emphasis">
+      <title>Level 3 with <italic>emphasis</italic></title>
+      <sec id="level-4">
+        <title>Level 4</title>
+        <sec id="level-5">
+          <title>Level 5</title>
+        </sec>
+      </sec>
+    </sec>
+  </sec>
+</sec>
+<sec id="level-1">
+  <title>Level 1</title>
+  <sec id="level-2-with-emphasis">
+    <title>Level 2 with <italic>emphasis</italic></title>
+    <sec id="level-3">
+      <title>Level 3</title>
+      <p>with no blank line</p>
+    </sec>
+  </sec>
+  <sec id="level-2">
+    <title>Level 2</title>
+    <p>with no blank line</p>
+  </sec>
+</sec>
+<sec id="paragraphs">
+  <title>Paragraphs</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<break />here.</p>
+</sec>
+<sec id="block-quotes">
+  <title>Block Quotes</title>
+  <p>E-mail style:</p>
+  <disp-quote>
+    <p>This is a block quote. It is pretty short.</p>
+  </disp-quote>
+  <disp-quote>
+    <p>Code in a block quote:</p>
+    <preformat>sub status {
+    print &quot;working&quot;;
+}</preformat>
+    <p>A list:</p>
+    <list list-type="order">
+      <list-item>
+        <p>item one</p>
+      </list-item>
+      <list-item>
+        <p>item two</p>
+      </list-item>
+    </list>
+    <p>Nested block quotes:</p>
+    <disp-quote>
+      <p>nested</p>
+    </disp-quote>
+    <disp-quote>
+      <p>nested</p>
+    </disp-quote>
+  </disp-quote>
+  <p>This should not be a block quote: 2 &gt; 1.</p>
+  <p>Box-style:</p>
+  <disp-quote>
+    <p>Example:</p>
+    <preformat>sub status {
+    print &quot;working&quot;;
+}</preformat>
+  </disp-quote>
+  <disp-quote>
+    <list list-type="order">
+      <list-item>
+        <p>do laundry</p>
+      </list-item>
+      <list-item>
+        <p>take out the trash</p>
+      </list-item>
+    </list>
+  </disp-quote>
+  <p>Here's a nested one:</p>
+  <disp-quote>
+    <p>Joe said:</p>
+    <disp-quote>
+      <p>Don't quote me.</p>
+    </disp-quote>
+  </disp-quote>
+  <p>And a following paragraph.</p>
+</sec>
+<sec id="code-blocks">
+  <title>Code Blocks</title>
+  <p>Code:</p>
+  <preformat>---- (should be four hyphens)
+
+sub status {
+    print &quot;working&quot;;
+}
+
+this code block is indented by one tab</preformat>
+  <p>And:</p>
+  <preformat>    this code block is indented by two tabs
+
+These should not be escaped:  \$ \\ \&gt; \[ \{</preformat>
+</sec>
+<sec id="lists">
+  <title>Lists</title>
+  <sec id="unordered">
+    <title>Unordered</title>
+    <p>Asterisks tight:</p>
+    <list list-type="bullet">
+      <list-item>
+        <p>asterisk 1</p>
+      </list-item>
+      <list-item>
+        <p>asterisk 2</p>
+      </list-item>
+      <list-item>
+        <p>asterisk 3</p>
+      </list-item>
+    </list>
+    <p>Asterisks loose:</p>
+    <list list-type="bullet">
+      <list-item>
+        <p>asterisk 1</p>
+      </list-item>
+      <list-item>
+        <p>asterisk 2</p>
+      </list-item>
+      <list-item>
+        <p>asterisk 3</p>
+      </list-item>
+    </list>
+    <p>Pluses tight:</p>
+    <list list-type="bullet">
+      <list-item>
+        <p>Plus 1</p>
+      </list-item>
+      <list-item>
+        <p>Plus 2</p>
+      </list-item>
+      <list-item>
+        <p>Plus 3</p>
+      </list-item>
+    </list>
+    <p>Pluses loose:</p>
+    <list list-type="bullet">
+      <list-item>
+        <p>Plus 1</p>
+      </list-item>
+      <list-item>
+        <p>Plus 2</p>
+      </list-item>
+      <list-item>
+        <p>Plus 3</p>
+      </list-item>
+    </list>
+    <p>Minuses tight:</p>
+    <list list-type="bullet">
+      <list-item>
+        <p>Minus 1</p>
+      </list-item>
+      <list-item>
+        <p>Minus 2</p>
+      </list-item>
+      <list-item>
+        <p>Minus 3</p>
+      </list-item>
+    </list>
+    <p>Minuses loose:</p>
+    <list list-type="bullet">
+      <list-item>
+        <p>Minus 1</p>
+      </list-item>
+      <list-item>
+        <p>Minus 2</p>
+      </list-item>
+      <list-item>
+        <p>Minus 3</p>
+      </list-item>
+    </list>
+  </sec>
+  <sec id="ordered">
+    <title>Ordered</title>
+    <p>Tight:</p>
+    <list list-type="order">
+      <list-item>
+        <p>First</p>
+      </list-item>
+      <list-item>
+        <p>Second</p>
+      </list-item>
+      <list-item>
+        <p>Third</p>
+      </list-item>
+    </list>
+    <p>and:</p>
+    <list list-type="order">
+      <list-item>
+        <p>One</p>
+      </list-item>
+      <list-item>
+        <p>Two</p>
+      </list-item>
+      <list-item>
+        <p>Three</p>
+      </list-item>
+    </list>
+    <p>Loose using tabs:</p>
+    <list list-type="order">
+      <list-item>
+        <p>First</p>
+      </list-item>
+      <list-item>
+        <p>Second</p>
+      </list-item>
+      <list-item>
+        <p>Third</p>
+      </list-item>
+    </list>
+    <p>and using spaces:</p>
+    <list list-type="order">
+      <list-item>
+        <p>One</p>
+      </list-item>
+      <list-item>
+        <p>Two</p>
+      </list-item>
+      <list-item>
+        <p>Three</p>
+      </list-item>
+    </list>
+    <p>Multiple paragraphs:</p>
+    <list list-type="order">
+      <list-item>
+        <p>Item 1, graf one.</p>
+        <p>Item 1. graf two. The quick brown fox jumped over the lazy
+          dog's back.</p>
+      </list-item>
+      <list-item>
+        <p>Item 2.</p>
+      </list-item>
+      <list-item>
+        <p>Item 3.</p>
+      </list-item>
+    </list>
+    <p>List styles:</p>
+    <list list-type="order"></list>
+    <list list-type="roman-lower"></list>
+  </sec>
+  <sec id="nested">
+    <title>Nested</title>
+    <list list-type="bullet">
+      <list-item>
+        <p>Tab</p>
+        <list list-type="bullet">
+          <list-item>
+            <p>Tab</p>
+            <list list-type="bullet">
+              <list-item>
+                <p>Tab</p>
+              </list-item>
+            </list>
+          </list-item>
+        </list>
+      </list-item>
+    </list>
+    <p>Here's another:</p>
+    <list list-type="order">
+      <list-item>
+        <p>First</p>
+      </list-item>
+      <list-item>
+        <p>Second:</p>
+        <list list-type="bullet">
+          <list-item>
+            <p>Fee</p>
+          </list-item>
+          <list-item>
+            <p>Fie</p>
+          </list-item>
+          <list-item>
+            <p>Foe</p>
+          </list-item>
+        </list>
+      </list-item>
+      <list-item>
+        <p>Third</p>
+      </list-item>
+    </list>
+    <p>Same thing but with paragraphs:</p>
+    <list list-type="order">
+      <list-item>
+        <p>First</p>
+      </list-item>
+      <list-item>
+        <p>Second:</p>
+        <list list-type="bullet">
+          <list-item>
+            <p>Fee</p>
+          </list-item>
+          <list-item>
+            <p>Fie</p>
+          </list-item>
+          <list-item>
+            <p>Foe</p>
+          </list-item>
+        </list>
+      </list-item>
+      <list-item>
+        <p>Third</p>
+      </list-item>
+    </list>
+  </sec>
+  <sec id="tabs-and-spaces">
+    <title>Tabs and spaces</title>
+    <list list-type="bullet">
+      <list-item>
+        <p>this is a list item indented with tabs</p>
+      </list-item>
+      <list-item>
+        <p>this is a list item indented with spaces</p>
+        <list list-type="bullet">
+          <list-item>
+            <p>this is an example list item indented with tabs</p>
+          </list-item>
+          <list-item>
+            <p>this is an example list item indented with spaces</p>
+          </list-item>
+        </list>
+      </list-item>
+    </list>
+  </sec>
+  <sec id="fancy-list-markers">
+    <title>Fancy list markers</title>
+    <p>Autonumbering:</p>
+    <list list-type="order">
+      <list-item>
+        <p>Autonumber.</p>
+      </list-item>
+      <list-item>
+        <p>More.</p>
+        <list list-type="order">
+          <list-item>
+            <p>Nested.</p>
+          </list-item>
+        </list>
+      </list-item>
+    </list>
+  </sec>
+  <sec id="definition">
+    <title>Definition</title>
+    <def-list>
+      <def-item>
+        <term>
+          Violin
+        </term>
+        <def>
+          <p>Stringed musical instrument.</p>
+          <p>Torture device.</p>
+        </def>
+      </def-item>
+      <def-item>
+        <term>
+          Cello<break />Violoncello
+        </term>
+        <def>
+          <p>Low-voiced stringed instrument.</p>
+        </def>
+      </def-item>
+    </def-list>
+  </sec>
+</sec>
+<sec id="inline-markup">
+  <title>Inline Markup</title>
+  <p>This is <italic>emphasized</italic>, and so <italic>is
+    this</italic>.</p>
+  <p>This is <bold role="strong">strong</bold>, and so
+    <bold role="strong">is this</bold>.</p>
+  <p>Empty <bold role="strong"></bold> and <italic></italic>.</p>
+  <p>An
+    <italic><ext-link ext-link-type="uri" xlink:href="/url">emphasized
+    link</ext-link></italic>.</p>
+  <p><bold role="strong"><italic>This is strong and em.</italic></bold></p>
+  <p>So is <bold role="strong"><italic>this</italic></bold> word.</p>
+  <p><bold role="strong"><italic>This is strong and em.</italic></bold></p>
+  <p>So is <bold role="strong"><italic>this</italic></bold> word.</p>
+  <p>This is code: <monospace>&gt;</monospace>, <monospace>$</monospace>,
+    <monospace>\</monospace>, <monospace>\$</monospace>,
+    <monospace>&lt;html&gt;</monospace>.</p>
+  <p>This is <sc role="smallcaps">small caps</sc>.</p>
+  <p>These are all underlined: foo and bar.</p>
+  <p>These are all strikethrough: <strike>foo</strike>,
+    <strike>bar</strike>, and <strike>baz</strike>.</p>
+</sec>
+<sec id="smart-quotes-ellipses-dashes">
+  <title>Smart quotes, ellipses, dashes</title>
+  <p>&quot;Hello,&quot; said the spider. &quot;'Shelob' is my name.&quot;</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, &quot;I want to go.&quot;' Were you alive in the 70's?</p>
+  <p>Here is some quoted '<monospace>code</monospace>' and a
+    &quot;<ext-link ext-link-type="uri" xlink:href="http://example.com/?foo=1&amp;bar=2">quoted
+    link</ext-link>&quot;.</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>
+</sec>
+<sec id="latex">
+  <title>LaTeX</title>
+  <list list-type="bullet">
+    <list-item>
+      <p>\cite[22-23]{smith.1899}</p>
+    </list-item>
+    <list-item>
+      <p>\doublespacing</p>
+    </list-item>
+    <list-item>
+      <p>$2+2=4$</p>
+    </list-item>
+    <list-item>
+      <p>$x \in y$</p>
+    </list-item>
+    <list-item>
+      <p>$\alpha \wedge \omega$</p>
+    </list-item>
+    <list-item>
+      <p>$223$</p>
+    </list-item>
+    <list-item>
+      <p>$p$-Tree</p>
+    </list-item>
+    <list-item>
+      <p>$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$</p>
+    </list-item>
+    <list-item>
+      <p>Here's one that has a line break in it: $\alpha + \omega \times
+        x^2$.</p>
+    </list-item>
+  </list>
+  <p>These shouldn't be math:</p>
+  <list list-type="bullet">
+    <list-item>
+      <p>To get the famous equation, write
+        <monospace>$e = mc^2$</monospace>.</p>
+    </list-item>
+    <list-item>
+      <p>$22,000 is a <italic>lot</italic> of money. So is $34,000. (It
+        worked if &quot;lot&quot; is emphasized.)</p>
+    </list-item>
+    <list-item>
+      <p>Escaped <monospace>$</monospace>: $73 <italic>this should be
+        emphasized</italic> 23$.</p>
+    </list-item>
+  </list>
+  <p>Here's a LaTeX table:</p>
+  <p>\begin{tabular}{|l|l|}\hline Animal &amp; Number \\ \hline Dog &amp;
+    2 \\ Cat &amp; 1 \\ \hline \end{tabular}</p>
+</sec>
+<sec id="special-characters">
+  <title>Special Characters</title>
+  <p>Here is some unicode:</p>
+  <list list-type="bullet">
+    <list-item>
+      <p>I hat: Î</p>
+    </list-item>
+    <list-item>
+      <p>o umlaut: ö</p>
+    </list-item>
+    <list-item>
+      <p>section: §</p>
+    </list-item>
+    <list-item>
+      <p>set membership: elem</p>
+    </list-item>
+    <list-item>
+      <p>copyright: ©</p>
+    </list-item>
+  </list>
+  <p>AT&amp;T has an ampersand in their name.</p>
+  <p>AT&amp;T is another way to write it.</p>
+  <p>This &amp; that.</p>
+  <p>4 &lt; 5.</p>
+  <p>6 &gt; 5.</p>
+  <p>Backslash: \</p>
+  <p>Backtick: `</p>
+  <p>Asterisk: *</p>
+  <p>Underscore: _</p>
+  <p>Left brace: {</p>
+  <p>Right brace: }</p>
+  <p>Left bracket: [</p>
+  <p>Right bracket: ]</p>
+  <p>Left paren: (</p>
+  <p>Right paren: )</p>
+  <p>Greater-than: &gt;</p>
+  <p>Hash: #</p>
+  <p>Period: .</p>
+  <p>Bang: !</p>
+  <p>Plus: +</p>
+  <p>Minus: -</p>
+</sec>
+<sec id="links">
+  <title>Links</title>
+  <sec id="explicit">
+    <title>Explicit</title>
+    <p>Just a
+      <ext-link ext-link-type="uri" xlink:href="/url/">URL</ext-link>.</p>
+    <p><ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title">URL
+      and title</ext-link>.</p>
+    <p><ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title preceded by two spaces">URL
+      and title</ext-link>.</p>
+    <p><ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title preceded by a tab">URL
+      and title</ext-link>.</p>
+    <p><ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title with &quot;quotes&quot; in it">URL
+      and title</ext-link></p>
+    <p><ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title with single quotes">URL
+      and title</ext-link></p>
+    <p>Email link (nobody [at] nowhere.net)</p>
+    <p><ext-link ext-link-type="uri" xlink:href="">Empty</ext-link>.</p>
+  </sec>
+  <sec id="reference">
+    <title>Reference</title>
+    <p>Foo
+      <ext-link ext-link-type="uri" xlink:href="/url/">bar</ext-link>.</p>
+    <p>Foo
+      <ext-link ext-link-type="uri" xlink:href="/url/">bar</ext-link>.</p>
+    <p>Foo
+      <ext-link ext-link-type="uri" xlink:href="/url/">bar</ext-link>.</p>
+    <p>With <ext-link ext-link-type="uri" xlink:href="/url/">embedded
+      [brackets]</ext-link>.</p>
+    <p><ext-link ext-link-type="uri" xlink:href="/url/">b</ext-link> by
+      itself should be a link.</p>
+    <p>Indented
+      <ext-link ext-link-type="uri" xlink:href="/url">once</ext-link>.</p>
+    <p>Indented
+      <ext-link ext-link-type="uri" xlink:href="/url">twice</ext-link>.</p>
+    <p>Indented
+      <ext-link ext-link-type="uri" xlink:href="/url">thrice</ext-link>.</p>
+    <p>This should [not] be a link.</p>
+    <preformat>[not]: /url</preformat>
+    <p>Foo
+      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="Title with &quot;quotes&quot; inside">bar</ext-link>.</p>
+    <p>Foo
+      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="Title with &quot;quote&quot; inside">biz</ext-link>.</p>
+  </sec>
+  <sec id="with-ampersands">
+    <title>With ampersands</title>
+    <p>Here's a
+      <ext-link ext-link-type="uri" xlink:href="http://example.com/?foo=1&amp;bar=2">link
+      with an ampersand in the URL</ext-link>.</p>
+    <p>Here's a link with an amersand in the link text:
+      <ext-link ext-link-type="uri" xlink:href="http://att.com/" xlink:title="AT&amp;T">AT&amp;T</ext-link>.</p>
+    <p>Here's an
+      <ext-link ext-link-type="uri" xlink:href="/script?foo=1&amp;bar=2">inline
+      link</ext-link>.</p>
+    <p>Here's an
+      <ext-link ext-link-type="uri" xlink:href="/script?foo=1&amp;bar=2">inline
+      link in pointy braces</ext-link>.</p>
+  </sec>
+  <sec id="autolinks">
+    <title>Autolinks</title>
+    <p>With an ampersand:
+      <ext-link ext-link-type="uri" xlink:href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</ext-link></p>
+    <list list-type="bullet">
+      <list-item>
+        <p>In a list?</p>
+      </list-item>
+      <list-item>
+        <p><ext-link ext-link-type="uri" xlink:href="http://example.com/">http://example.com/</ext-link></p>
+      </list-item>
+      <list-item>
+        <p>It should.</p>
+      </list-item>
+    </list>
+    <p>An e-mail address: nobody [at] nowhere.net</p>
+    <disp-quote>
+      <p>Blockquoted:
+        <ext-link ext-link-type="uri" xlink:href="http://example.com/">http://example.com/</ext-link></p>
+    </disp-quote>
+    <p>Auto-links should not occur here:
+      <monospace>&lt;http://example.com/&gt;</monospace></p>
+    <preformat>or here: &lt;http://example.com/&gt;</preformat>
+  </sec>
+</sec>
+<sec id="images">
+  <title>Images</title>
+  <p>From &quot;Voyage dans la Lune&quot; by Georges Melies (1902):</p>
+  <p><inline-graphic mimetype="image" mime-subtype="jpeg" xlink:href="lalune.jpg" xlink:title="Voyage dans la Lune" /></p>
+  <p>Here is a movie
+    <inline-graphic mimetype="image" mime-subtype="jpeg" xlink:href="movie.jpg" />
+    icon.</p>
+</sec>
+<sec id="footnotes">
+  <title>Footnotes</title>
+  <p>Here is a footnote reference<xref alt="(1)" rid="note_1">(1)</xref>,
+    and
+    another<xref alt="(longnote)" rid="note_longnote">(longnote)</xref>.
+    This should <italic>not</italic> be a footnote reference, because it
+    contains a space^(my note).</p>
+  <p><xref alt="(1)" rid="ref_1">(1)</xref> Here is the footnote. It can
+    go anywhere in the document, not just at the end.</p>
+  <p><xref alt="(longnote)" rid="ref_longnote">(longnote)</xref> Here's
+    the other note. This one contains multiple blocks.</p>
+  <p>Caret characters are used to indicate that the blocks all belong to
+    a single footnote (as with block quotes).</p>
+  <preformat>  { &lt;code&gt; }</preformat>
+  <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 <italic>Leading space</italic></p>
+  <p><italic>Trailing space</italic> text</p>
+  <p>text <italic>Leading spaces</italic></p>
+  <p><italic>Trailing spaces</italic> text</p>
+</sec>
+<sec id="tables">
+  <title>Tables</title>
+  <sec id="tables-with-headers">
+    <title>Tables with Headers</title>
+    <table>
+      <col align="left" />
+      <col align="left" />
+      <col align="left" />
+      <thead>
+        <tr>
+          <th>
+            <p>X</p>
+          </th>
+          <th>
+            <p>Y</p>
+          </th>
+          <th>
+            <p>Z</p>
+          </th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td>
+            <p>1</p>
+          </td>
+          <td>
+            <p>2</p>
+          </td>
+          <td>
+            <p>3</p>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <p>4</p>
+          </td>
+          <td>
+            <p>5</p>
+          </td>
+          <td>
+            <p>6</p>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    <table>
+      <col align="left" />
+      <col align="left" />
+      <col align="left" />
+      <thead>
+        <tr>
+          <th>
+            <p>X</p>
+          </th>
+          <th>
+            <p>Y</p>
+          </th>
+          <th>
+            <p>Z</p>
+          </th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td>
+            <p>1</p>
+          </td>
+          <td>
+            <p>2</p>
+          </td>
+          <td>
+            <p>3</p>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <p>4</p>
+          </td>
+          <td>
+            <p>5</p>
+          </td>
+          <td>
+            <p>6</p>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    <table>
+      <col align="left" />
+      <col align="left" />
+      <col align="left" />
+      <thead>
+        <tr>
+          <th>
+            <p>X</p>
+          </th>
+          <th>
+            <p>Y</p>
+          </th>
+          <th>
+            <p>Z</p>
+          </th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td>
+            <p>1</p>
+          </td>
+          <td>
+            <p>2</p>
+          </td>
+          <td>
+            <p>3</p>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <p>4</p>
+          </td>
+          <td>
+            <p>5</p>
+          </td>
+          <td>
+            <p>6</p>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    <table>
+      <col align="left" />
+      <col align="left" />
+      <col align="left" />
+      <thead>
+        <tr>
+          <th>
+            <p>X</p>
+          </th>
+          <th>
+            <p>Y</p>
+          </th>
+          <th>
+            <p>Z</p>
+          </th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td>
+            <p>1</p>
+          </td>
+          <td>
+            <p>2</p>
+          </td>
+          <td>
+            <p>3</p>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <p>4</p>
+          </td>
+          <td>
+            <p>5</p>
+          </td>
+          <td>
+            <p>6</p>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    <table>
+      <col align="left" />
+      <col align="left" />
+      <col align="left" />
+      <thead>
+        <tr>
+          <th>
+            <p>X</p>
+          </th>
+          <th>
+            <p>Y</p>
+          </th>
+          <th>
+            <p>Z</p>
+          </th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td>
+            <p>1</p>
+          </td>
+          <td>
+            <p>2</p>
+          </td>
+          <td>
+            <p>3</p>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <p>4</p>
+          </td>
+          <td>
+            <p>5</p>
+          </td>
+          <td>
+            <p>6</p>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    <table>
+      <col align="left" />
+      <col align="left" />
+      <col align="left" />
+      <thead>
+        <tr>
+          <th>
+            <p>X</p>
+          </th>
+          <th>
+            <p>Y</p>
+          </th>
+          <th>
+            <p>Z</p>
+          </th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td>
+            <p>1</p>
+          </td>
+          <td>
+            <p>2</p>
+          </td>
+          <td>
+            <p>3</p>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <p>4</p>
+          </td>
+          <td>
+            <p>5</p>
+          </td>
+          <td>
+            <p>6</p>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    <table>
+      <col align="left" />
+      <col align="left" />
+      <col align="left" />
+      <thead>
+        <tr>
+          <th>
+            <p>X</p>
+          </th>
+          <th>
+            <p>Y</p>
+          </th>
+          <th>
+            <p>Z</p>
+          </th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td>
+            <p>1</p>
+          </td>
+          <td>
+            <p>2</p>
+          </td>
+          <td>
+            <p>3</p>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <p>4</p>
+          </td>
+          <td>
+            <p>5</p>
+          </td>
+          <td>
+            <p>6</p>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    <table>
+      <col align="left" />
+      <col align="left" />
+      <col align="left" />
+      <thead>
+        <tr>
+          <th>
+            <p>X</p>
+          </th>
+          <th>
+            <p>Y</p>
+          </th>
+          <th>
+            <p>Z</p>
+          </th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td>
+            <p>1</p>
+          </td>
+          <td>
+            <p>2</p>
+          </td>
+          <td>
+            <p>3</p>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <p>4</p>
+          </td>
+          <td>
+            <p>5</p>
+          </td>
+          <td>
+            <p>6</p>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    <table>
+      <col width="33*" align="left" />
+      <col width="33*" align="left" />
+      <col width="33*" align="left" />
+      <thead>
+        <tr>
+          <th>
+            <p>X</p>
+          </th>
+          <th>
+            <p>Y</p>
+          </th>
+          <th>
+            <p>Z</p>
+          </th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td>
+            <p>1</p>
+          </td>
+          <td>
+            <p>2</p>
+          </td>
+          <td>
+            <p>3</p>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <p>4</p>
+          </td>
+          <td>
+            <p>5</p>
+          </td>
+          <td>
+            <p>6</p>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+  </sec>
+  <sec id="tables-without-headers">
+    <title>Tables without Headers</title>
+    <table>
+      <col align="left" />
+      <col align="left" />
+      <col align="left" />
+      <tbody>
+        <tr>
+          <td>
+            <p>1</p>
+          </td>
+          <td>
+            <p>2</p>
+          </td>
+          <td>
+            <p>3</p>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <p>4</p>
+          </td>
+          <td>
+            <p>5</p>
+          </td>
+          <td>
+            <p>6</p>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    <table>
+      <col align="left" />
+      <col align="left" />
+      <col align="left" />
+      <tbody>
+        <tr>
+          <td>
+            <p>1</p>
+          </td>
+          <td>
+            <p>2</p>
+          </td>
+          <td>
+            <p>3</p>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <p>4</p>
+          </td>
+          <td>
+            <p>5</p>
+          </td>
+          <td>
+            <p>6</p>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    <table>
+      <col align="left" />
+      <col align="left" />
+      <col align="left" />
+      <tbody>
+        <tr>
+          <td>
+            <p>1</p>
+          </td>
+          <td>
+            <p>2</p>
+          </td>
+          <td>
+            <p>3</p>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <p>4</p>
+          </td>
+          <td>
+            <p>5</p>
+          </td>
+          <td>
+            <p>6</p>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    <table>
+      <col align="left" />
+      <col align="left" />
+      <col align="left" />
+      <tbody>
+        <tr>
+          <td>
+            <p>1</p>
+          </td>
+          <td>
+            <p>2</p>
+          </td>
+          <td>
+            <p>3</p>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <p>4</p>
+          </td>
+          <td>
+            <p>5</p>
+          </td>
+          <td>
+            <p>6</p>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+  </sec>
+  <sec id="empty-tables">
+    <title>Empty Tables</title>
+    <p>This section should be empty.</p>
   </sec>
 </sec>
 </body>
diff --git a/test/tables.haddock b/test/tables.haddock
--- a/test/tables.haddock
+++ b/test/tables.haddock
@@ -1,76 +1,90 @@
 Simple table with caption:
 
->     Right Left    Center  Default
->   ------- ------ -------- ---------
->        12 12        12    12
->       123 123      123    123
->         1 1         1     1
+> +-------+------+--------+---------+
+> | Right | Left | Center | Default |
+> +=======+======+========+=========+
+> | 12    | 12   | 12     | 12      |
+> +-------+------+--------+---------+
+> | 123   | 123  | 123    | 123     |
+> +-------+------+--------+---------+
+> | 1     | 1    | 1      | 1       |
+> +-------+------+--------+---------+
 >
->   Demonstration of simple table syntax.
+> 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
+> +-------+------+--------+---------+
+> | 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
+> +-------+------+--------+---------+
+> | Right | Left | Center | Default |
+> +=======+======+========+=========+
+> | 12    | 12   | 12     | 12      |
+> +-------+------+--------+---------+
+> | 123   | 123  | 123    | 123     |
+> +-------+------+--------+---------+
+> | 1     | 1    | 1      | 1       |
+> +-------+------+--------+---------+
 >
->   Demonstration of simple table syntax.
+> 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.
->   --------------------------------------------------------------
+> +----------+---------+-----------+-------------------------+
+> | 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.
+> 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.
->   --------------------------------------------------------------
+> +----------+---------+-----------+-------------------------+
+> | 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
->   ----- ----- ----- -----
+> +-----+-----+-----+-----+
+> | 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.
->   ----------- ---------- ------------ --------------------------
+> +----------+---------+-----------+-------------------------+
+> | First    | row     | 12.0      | Example of a row that   |
+> |          |         |           | spans multiple lines.   |
+> +----------+---------+-----------+-------------------------+
+> | Second   | row     | 5.0       | Here’s another one.     |
+> |          |         |           | Note the blank line     |
+> |          |         |           | between rows.           |
+> +----------+---------+-----------+-------------------------+
diff --git a/test/tables.jats b/test/tables.jats
--- a/test/tables.jats
+++ b/test/tables.jats
@@ -1,11 +1,7 @@
-<p>
-  Simple table with caption:
-</p>
+<p>Simple table with caption:</p>
 <table-wrap>
   <caption>
-    <p>
-      Demonstration of simple table syntax.
-    </p>
+    <p>Demonstration of simple table syntax.</p>
   </caption>
   <table>
     <col align="right" />
@@ -14,69 +10,35 @@
     <col align="left" />
     <thead>
       <tr>
-        <th>
-          Right
-        </th>
-        <th>
-          Left
-        </th>
-        <th>
-          Center
-        </th>
-        <th>
-          Default
-        </th>
+        <th>Right</th>
+        <th>Left</th>
+        <th>Center</th>
+        <th>Default</th>
       </tr>
     </thead>
     <tbody>
       <tr>
-        <td>
-          12
-        </td>
-        <td>
-          12
-        </td>
-        <td>
-          12
-        </td>
-        <td>
-          12
-        </td>
+        <td>12</td>
+        <td>12</td>
+        <td>12</td>
+        <td>12</td>
       </tr>
       <tr>
-        <td>
-          123
-        </td>
-        <td>
-          123
-        </td>
-        <td>
-          123
-        </td>
-        <td>
-          123
-        </td>
+        <td>123</td>
+        <td>123</td>
+        <td>123</td>
+        <td>123</td>
       </tr>
       <tr>
-        <td>
-          1
-        </td>
-        <td>
-          1
-        </td>
-        <td>
-          1
-        </td>
-        <td>
-          1
-        </td>
+        <td>1</td>
+        <td>1</td>
+        <td>1</td>
+        <td>1</td>
       </tr>
     </tbody>
   </table>
 </table-wrap>
-<p>
-  Simple table without caption:
-</p>
+<p>Simple table without caption:</p>
 <table>
   <col align="right" />
   <col align="left" />
@@ -84,73 +46,37 @@
   <col align="left" />
   <thead>
     <tr>
-      <th>
-        Right
-      </th>
-      <th>
-        Left
-      </th>
-      <th>
-        Center
-      </th>
-      <th>
-        Default
-      </th>
+      <th>Right</th>
+      <th>Left</th>
+      <th>Center</th>
+      <th>Default</th>
     </tr>
   </thead>
   <tbody>
     <tr>
-      <td>
-        12
-      </td>
-      <td>
-        12
-      </td>
-      <td>
-        12
-      </td>
-      <td>
-        12
-      </td>
+      <td>12</td>
+      <td>12</td>
+      <td>12</td>
+      <td>12</td>
     </tr>
     <tr>
-      <td>
-        123
-      </td>
-      <td>
-        123
-      </td>
-      <td>
-        123
-      </td>
-      <td>
-        123
-      </td>
+      <td>123</td>
+      <td>123</td>
+      <td>123</td>
+      <td>123</td>
     </tr>
     <tr>
-      <td>
-        1
-      </td>
-      <td>
-        1
-      </td>
-      <td>
-        1
-      </td>
-      <td>
-        1
-      </td>
+      <td>1</td>
+      <td>1</td>
+      <td>1</td>
+      <td>1</td>
     </tr>
   </tbody>
 </table>
-<p>
-  Simple table indented two spaces:
-</p>
+<p>Simple table indented two spaces:</p>
 <table-wrap>
   <caption>
-    <p>
-      Demonstration of simple table syntax.
-    </p>
+    <p>Demonstration of simple table syntax.</p>
   </caption>
   <table>
     <col align="right" />
@@ -159,74 +85,38 @@
     <col align="left" />
     <thead>
       <tr>
-        <th>
-          Right
-        </th>
-        <th>
-          Left
-        </th>
-        <th>
-          Center
-        </th>
-        <th>
-          Default
-        </th>
+        <th>Right</th>
+        <th>Left</th>
+        <th>Center</th>
+        <th>Default</th>
       </tr>
     </thead>
     <tbody>
       <tr>
-        <td>
-          12
-        </td>
-        <td>
-          12
-        </td>
-        <td>
-          12
-        </td>
-        <td>
-          12
-        </td>
+        <td>12</td>
+        <td>12</td>
+        <td>12</td>
+        <td>12</td>
       </tr>
       <tr>
-        <td>
-          123
-        </td>
-        <td>
-          123
-        </td>
-        <td>
-          123
-        </td>
-        <td>
-          123
-        </td>
+        <td>123</td>
+        <td>123</td>
+        <td>123</td>
+        <td>123</td>
       </tr>
       <tr>
-        <td>
-          1
-        </td>
-        <td>
-          1
-        </td>
-        <td>
-          1
-        </td>
-        <td>
-          1
-        </td>
+        <td>1</td>
+        <td>1</td>
+        <td>1</td>
+        <td>1</td>
       </tr>
     </tbody>
   </table>
 </table-wrap>
-<p>
-  Multiline table with caption:
-</p>
+<p>Multiline table with caption:</p>
 <table-wrap>
   <caption>
-    <p>
-      Here’s the caption. It may span multiple lines.
-    </p>
+    <p>Here’s the caption. It may span multiple lines.</p>
   </caption>
   <table>
     <col width="15*" align="center" />
@@ -235,55 +125,29 @@
     <col width="33*" align="left" />
     <thead>
       <tr>
-        <th>
-          Centered Header
-        </th>
-        <th>
-          Left Aligned
-        </th>
-        <th>
-          Right Aligned
-        </th>
-        <th>
-          Default aligned
-        </th>
+        <th>Centered Header</th>
+        <th>Left Aligned</th>
+        <th>Right Aligned</th>
+        <th>Default aligned</th>
       </tr>
     </thead>
     <tbody>
       <tr>
-        <td>
-          First
-        </td>
-        <td>
-          row
-        </td>
-        <td>
-          12.0
-        </td>
-        <td>
-          Example of a row that spans multiple lines.
-        </td>
+        <td>First</td>
+        <td>row</td>
+        <td>12.0</td>
+        <td>Example of a row that spans multiple lines.</td>
       </tr>
       <tr>
-        <td>
-          Second
-        </td>
-        <td>
-          row
-        </td>
-        <td>
-          5.0
-        </td>
-        <td>
-          Here’s another one. Note the blank line between rows.
-        </td>
+        <td>Second</td>
+        <td>row</td>
+        <td>5.0</td>
+        <td>Here’s another one. Note the blank line between rows.</td>
       </tr>
     </tbody>
   </table>
 </table-wrap>
-<p>
-  Multiline table without caption:
-</p>
+<p>Multiline table without caption:</p>
 <table>
   <col width="15*" align="center" />
   <col width="13*" align="left" />
@@ -291,54 +155,28 @@
   <col width="33*" align="left" />
   <thead>
     <tr>
-      <th>
-        Centered Header
-      </th>
-      <th>
-        Left Aligned
-      </th>
-      <th>
-        Right Aligned
-      </th>
-      <th>
-        Default aligned
-      </th>
+      <th>Centered Header</th>
+      <th>Left Aligned</th>
+      <th>Right Aligned</th>
+      <th>Default aligned</th>
     </tr>
   </thead>
   <tbody>
     <tr>
-      <td>
-        First
-      </td>
-      <td>
-        row
-      </td>
-      <td>
-        12.0
-      </td>
-      <td>
-        Example of a row that spans multiple lines.
-      </td>
+      <td>First</td>
+      <td>row</td>
+      <td>12.0</td>
+      <td>Example of a row that spans multiple lines.</td>
     </tr>
     <tr>
-      <td>
-        Second
-      </td>
-      <td>
-        row
-      </td>
-      <td>
-        5.0
-      </td>
-      <td>
-        Here’s another one. Note the blank line between rows.
-      </td>
+      <td>Second</td>
+      <td>row</td>
+      <td>5.0</td>
+      <td>Here’s another one. Note the blank line between rows.</td>
     </tr>
   </tbody>
 </table>
-<p>
-  Table without column headers:
-</p>
+<p>Table without column headers:</p>
 <table>
   <col align="right" />
   <col align="left" />
@@ -346,52 +184,26 @@
   <col align="right" />
   <tbody>
     <tr>
-      <td>
-        12
-      </td>
-      <td>
-        12
-      </td>
-      <td>
-        12
-      </td>
-      <td>
-        12
-      </td>
+      <td>12</td>
+      <td>12</td>
+      <td>12</td>
+      <td>12</td>
     </tr>
     <tr>
-      <td>
-        123
-      </td>
-      <td>
-        123
-      </td>
-      <td>
-        123
-      </td>
-      <td>
-        123
-      </td>
+      <td>123</td>
+      <td>123</td>
+      <td>123</td>
+      <td>123</td>
     </tr>
     <tr>
-      <td>
-        1
-      </td>
-      <td>
-        1
-      </td>
-      <td>
-        1
-      </td>
-      <td>
-        1
-      </td>
+      <td>1</td>
+      <td>1</td>
+      <td>1</td>
+      <td>1</td>
     </tr>
   </tbody>
 </table>
-<p>
-  Multiline table without column headers:
-</p>
+<p>Multiline table without column headers:</p>
 <table>
   <col width="15*" align="center" />
   <col width="13*" align="left" />
@@ -399,32 +211,16 @@
   <col width="33*" align="left" />
   <tbody>
     <tr>
-      <td>
-        First
-      </td>
-      <td>
-        row
-      </td>
-      <td>
-        12.0
-      </td>
-      <td>
-        Example of a row that spans multiple lines.
-      </td>
+      <td>First</td>
+      <td>row</td>
+      <td>12.0</td>
+      <td>Example of a row that spans multiple lines.</td>
     </tr>
     <tr>
-      <td>
-        Second
-      </td>
-      <td>
-        row
-      </td>
-      <td>
-        5.0
-      </td>
-      <td>
-        Here’s another one. Note the blank line between rows.
-      </td>
+      <td>Second</td>
+      <td>row</td>
+      <td>5.0</td>
+      <td>Here’s another one. Note the blank line between rows.</td>
     </tr>
   </tbody>
 </table>
diff --git a/test/test-pandoc.hs b/test/test-pandoc.hs
--- a/test/test-pandoc.hs
+++ b/test/test-pandoc.hs
@@ -1,7 +1,9 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# OPTIONS_GHC -Wall #-}
 
 module Main where
 
+import Prelude
 import GHC.IO.Encoding
 import Test.Tasty
 import qualified Tests.Command
diff --git a/test/writer.jats b/test/writer.jats
--- a/test/writer.jats
+++ b/test/writer.jats
@@ -32,1415 +32,849 @@
 </article-meta>
 </front>
 <body>
-<p>
-  This is a set of tests for pandoc. Most of them are adapted from John
-  Gruber’s markdown test suite.
-</p>
-<sec id="headers">
-  <title>Headers</title>
-  <sec id="level-2-with-an-embedded-link">
-    <title>Level 2 with an
-    <ext-link ext-link-type="uri" xlink:href="/url">embedded
-    link</ext-link></title>
-    <sec id="level-3-with-emphasis">
-      <title>Level 3 with <italic>emphasis</italic></title>
-      <sec id="level-4">
-        <title>Level 4</title>
-        <sec id="level-5">
-          <title>Level 5</title>
-        </sec>
-      </sec>
-    </sec>
-  </sec>
-</sec>
-<sec id="level-1">
-  <title>Level 1</title>
-  <sec id="level-2-with-emphasis">
-    <title>Level 2 with <italic>emphasis</italic></title>
-    <sec id="level-3">
-      <title>Level 3</title>
-      <p>
-        with no blank line
-      </p>
-    </sec>
-  </sec>
-  <sec id="level-2">
-    <title>Level 2</title>
-    <p>
-      with no blank line
-    </p>
-  </sec>
-</sec>
-<sec id="paragraphs">
-  <title>Paragraphs</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<break />here.
-  </p>
-</sec>
-<sec id="block-quotes">
-  <title>Block Quotes</title>
-  <p>
-    E-mail style:
-  </p>
-  <disp-quote>
-    <p>
-      This is a block quote. It is pretty short.
-    </p>
-  </disp-quote>
-  <disp-quote>
-    <p>
-      Code in a block quote:
-    </p>
-    <preformat>sub status {
-    print &quot;working&quot;;
-}</preformat>
-    <p>
-      A list:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          item one
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          item two
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Nested block quotes:
-    </p>
-    <disp-quote>
-      <p>
-        nested
-      </p>
-    </disp-quote>
-    <disp-quote>
-      <p>
-        nested
-      </p>
-    </disp-quote>
-  </disp-quote>
-  <p>
-    This should not be a block quote: 2 &gt; 1.
-  </p>
-  <p>
-    And a following paragraph.
-  </p>
-</sec>
-<sec id="code-blocks">
-  <title>Code Blocks</title>
-  <p>
-    Code:
-  </p>
-  <preformat>---- (should be four hyphens)
-
-sub status {
-    print &quot;working&quot;;
-}
-
-this code block is indented by one tab</preformat>
-  <p>
-    And:
-  </p>
-  <preformat>    this code block is indented by two tabs
-
-These should not be escaped:  \$ \\ \&gt; \[ \{</preformat>
-</sec>
-<sec id="lists">
-  <title>Lists</title>
-  <sec id="unordered">
-    <title>Unordered</title>
-    <p>
-      Asterisks tight:
-    </p>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          asterisk 1
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          asterisk 2
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          asterisk 3
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Asterisks loose:
-    </p>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          asterisk 1
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          asterisk 2
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          asterisk 3
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Pluses tight:
-    </p>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          Plus 1
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Plus 2
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Plus 3
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Pluses loose:
-    </p>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          Plus 1
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Plus 2
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Plus 3
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Minuses tight:
-    </p>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          Minus 1
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Minus 2
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Minus 3
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Minuses loose:
-    </p>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          Minus 1
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Minus 2
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Minus 3
-        </p>
-      </list-item>
-    </list>
-  </sec>
-  <sec id="ordered">
-    <title>Ordered</title>
-    <p>
-      Tight:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          First
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Second
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Third
-        </p>
-      </list-item>
-    </list>
-    <p>
-      and:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          One
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Two
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Three
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Loose using tabs:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          First
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Second
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Third
-        </p>
-      </list-item>
-    </list>
-    <p>
-      and using spaces:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          One
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Two
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Three
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Multiple paragraphs:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          Item 1, graf one.
-        </p>
-        <p>
-          Item 1. graf two. The quick brown fox jumped over the lazy dog’s
-          back.
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Item 2.
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Item 3.
-        </p>
-      </list-item>
-    </list>
-  </sec>
-  <sec id="nested">
-    <title>Nested</title>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          Tab
-        </p>
-        <list list-type="bullet">
-          <list-item>
-            <p>
-              Tab
-            </p>
-            <list list-type="bullet">
-              <list-item>
-                <p>
-                  Tab
-                </p>
-              </list-item>
-            </list>
-          </list-item>
-        </list>
-      </list-item>
-    </list>
-    <p>
-      Here’s another:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          First
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Second:
-        </p>
-        <list list-type="bullet">
-          <list-item>
-            <p>
-              Fee
-            </p>
-          </list-item>
-          <list-item>
-            <p>
-              Fie
-            </p>
-          </list-item>
-          <list-item>
-            <p>
-              Foe
-            </p>
-          </list-item>
-        </list>
-      </list-item>
-      <list-item>
-        <p>
-          Third
-        </p>
-      </list-item>
-    </list>
-    <p>
-      Same thing but with paragraphs:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          First
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          Second:
-        </p>
-        <list list-type="bullet">
-          <list-item>
-            <p>
-              Fee
-            </p>
-          </list-item>
-          <list-item>
-            <p>
-              Fie
-            </p>
-          </list-item>
-          <list-item>
-            <p>
-              Foe
-            </p>
-          </list-item>
-        </list>
-      </list-item>
-      <list-item>
-        <p>
-          Third
-        </p>
-      </list-item>
-    </list>
-  </sec>
-  <sec id="tabs-and-spaces">
-    <title>Tabs and spaces</title>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          this is a list item indented with tabs
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          this is a list item indented with spaces
-        </p>
-        <list list-type="bullet">
-          <list-item>
-            <p>
-              this is an example list item indented with tabs
-            </p>
-          </list-item>
-          <list-item>
-            <p>
-              this is an example list item indented with spaces
-            </p>
-          </list-item>
-        </list>
-      </list-item>
-    </list>
-  </sec>
-  <sec id="fancy-list-markers">
-    <title>Fancy list markers</title>
-    <list list-type="order">
-      <list-item>
-        <label>
-          (2)
-        </label>
-        <p>
-          begins with 2
-        </p>
-      </list-item>
-      <list-item>
-        <label>
-          (3)
-        </label>
-        <p>
-          and now 3
-        </p>
-        <p>
-          with a continuation
-        </p>
-        <list list-type="roman-lower">
-          <list-item>
-            <label>
-              iv.
-            </label>
-            <p>
-              sublist with roman numerals, starting with 4
-            </p>
-          </list-item>
-          <list-item>
-            <label>
-              v.
-            </label>
-            <p>
-              more items
-            </p>
-            <list list-type="alpha-upper">
-              <list-item>
-                <label>
-                  (A)
-                </label>
-                <p>
-                  a subsublist
-                </p>
-              </list-item>
-              <list-item>
-                <label>
-                  (B)
-                </label>
-                <p>
-                  a subsublist
-                </p>
-              </list-item>
-            </list>
-          </list-item>
-        </list>
-      </list-item>
-    </list>
-    <p>
-      Nesting:
-    </p>
-    <list list-type="alpha-upper">
-      <list-item>
-        <p>
-          Upper Alpha
-        </p>
-        <list list-type="roman-upper">
-          <list-item>
-            <p>
-              Upper Roman.
-            </p>
-            <list list-type="order">
-              <list-item>
-                <label>
-                  (6)
-                </label>
-                <p>
-                  Decimal start with 6
-                </p>
-                <list list-type="alpha-lower">
-                  <list-item>
-                    <label>
-                      c)
-                    </label>
-                    <p>
-                      Lower alpha with paren
-                    </p>
-                  </list-item>
-                </list>
-              </list-item>
-            </list>
-          </list-item>
-        </list>
-      </list-item>
-    </list>
-    <p>
-      Autonumbering:
-    </p>
-    <list list-type="order">
-      <list-item>
-        <p>
-          Autonumber.
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          More.
-        </p>
-        <list list-type="order">
-          <list-item>
-            <p>
-              Nested.
-            </p>
-          </list-item>
-        </list>
-      </list-item>
-    </list>
-    <p>
-      Should not be a list item:
-    </p>
-    <p>
-      M.A. 2007
-    </p>
-    <p>
-      B. Williams
-    </p>
-  </sec>
-</sec>
-<sec id="definition-lists">
-  <title>Definition Lists</title>
-  <p>
-    Tight using spaces:
-  </p>
-  <def-list>
-    <def-item>
-      <term>
-        apple
-      </term>
-      <def>
-        <p>
-          red fruit
-        </p>
-      </def>
-    </def-item>
-    <def-item>
-      <term>
-        orange
-      </term>
-      <def>
-        <p>
-          orange fruit
-        </p>
-      </def>
-    </def-item>
-    <def-item>
-      <term>
-        banana
-      </term>
-      <def>
-        <p>
-          yellow fruit
-        </p>
-      </def>
-    </def-item>
-  </def-list>
-  <p>
-    Tight using tabs:
-  </p>
-  <def-list>
-    <def-item>
-      <term>
-        apple
-      </term>
-      <def>
-        <p>
-          red fruit
-        </p>
-      </def>
-    </def-item>
-    <def-item>
-      <term>
-        orange
-      </term>
-      <def>
-        <p>
-          orange fruit
-        </p>
-      </def>
-    </def-item>
-    <def-item>
-      <term>
-        banana
-      </term>
-      <def>
-        <p>
-          yellow fruit
-        </p>
-      </def>
-    </def-item>
-  </def-list>
-  <p>
-    Loose:
-  </p>
-  <def-list>
-    <def-item>
-      <term>
-        apple
-      </term>
-      <def>
-        <p>
-          red fruit
-        </p>
-      </def>
-    </def-item>
-    <def-item>
-      <term>
-        orange
-      </term>
-      <def>
-        <p>
-          orange fruit
-        </p>
-      </def>
-    </def-item>
-    <def-item>
-      <term>
-        banana
-      </term>
-      <def>
-        <p>
-          yellow fruit
-        </p>
-      </def>
-    </def-item>
-  </def-list>
-  <p>
-    Multiple blocks with italics:
-  </p>
-  <def-list>
-    <def-item>
-      <term>
-        <italic>apple</italic>
-      </term>
-      <def>
-        <p>
-          red fruit
-        </p>
-        <p>
-          contains seeds, crisp, pleasant to taste
-        </p>
-      </def>
-    </def-item>
-    <def-item>
-      <term>
-        <italic>orange</italic>
-      </term>
-      <def>
-        <p>
-          orange fruit
-        </p>
-        <preformat>{ orange code block }</preformat>
-        <disp-quote>
-          <p>
-            orange block quote
-          </p>
-        </disp-quote>
-      </def>
-    </def-item>
-  </def-list>
-  <p>
-    Multiple definitions, tight:
-  </p>
-  <def-list>
-    <def-item>
-      <term>
-        apple
-      </term>
-      <def>
-        <p>
-          red fruit
-        </p>
-        <p>
-          computer
-        </p>
-      </def>
-    </def-item>
-    <def-item>
-      <term>
-        orange
-      </term>
-      <def>
-        <p>
-          orange fruit
-        </p>
-        <p>
-          bank
-        </p>
-      </def>
-    </def-item>
-  </def-list>
-  <p>
-    Multiple definitions, loose:
-  </p>
-  <def-list>
-    <def-item>
-      <term>
-        apple
-      </term>
-      <def>
-        <p>
-          red fruit
-        </p>
-        <p>
-          computer
-        </p>
-      </def>
-    </def-item>
-    <def-item>
-      <term>
-        orange
-      </term>
-      <def>
-        <p>
-          orange fruit
-        </p>
-        <p>
-          bank
-        </p>
-      </def>
-    </def-item>
-  </def-list>
-  <p>
-    Blank line after term, indented marker, alternate markers:
-  </p>
-  <def-list>
-    <def-item>
-      <term>
-        apple
-      </term>
-      <def>
-        <p>
-          red fruit
-        </p>
-        <p>
-          computer
-        </p>
-      </def>
-    </def-item>
-    <def-item>
-      <term>
-        orange
-      </term>
-      <def>
-        <p>
-          orange fruit
-        </p>
-        <list list-type="order">
-          <list-item>
-            <p>
-              sublist
-            </p>
-          </list-item>
-          <list-item>
-            <p>
-              sublist
-            </p>
-          </list-item>
-        </list>
-      </def>
-    </def-item>
-  </def-list>
-</sec>
-<sec id="html-blocks">
-  <title>HTML Blocks</title>
-  <p>
-    Simple block on one line:
-  </p>
-  <boxed-text>
-    <p>
-      foo
-    </p>
-  </boxed-text>
-  <p>
-    And nested without indentation:
-  </p>
-  <boxed-text>
-    <boxed-text>
-      <boxed-text>
-        <p>
-          foo
-        </p>
-      </boxed-text>
-    </boxed-text>
-    <boxed-text>
-      <p>
-        bar
-      </p>
-    </boxed-text>
-  </boxed-text>
-  <p>
-    Interpreted markdown in a table:
-  </p>
-  <p>
-    This is <italic>emphasized</italic>
-  </p>
-  <p>
-    And this is <bold role="strong">strong</bold>
-  </p>
-  <p>
-    Here’s a simple block:
-  </p>
-  <boxed-text>
-    <p>
-      foo
-    </p>
-  </boxed-text>
-  <p>
-    This should be a code block, though:
-  </p>
-  <preformat>&lt;div&gt;
-    foo
-&lt;/div&gt;</preformat>
-  <p>
-    As should this:
-  </p>
-  <preformat>&lt;div&gt;foo&lt;/div&gt;</preformat>
-  <p>
-    Now, nested:
-  </p>
-  <boxed-text>
-    <boxed-text>
-      <boxed-text>
-        <p>
-          foo
-        </p>
-      </boxed-text>
-    </boxed-text>
-  </boxed-text>
-  <p>
-    This should just be an HTML comment:
-  </p>
-  <p>
-    Multiline:
-  </p>
-  <p>
-    Code block:
-  </p>
-  <preformat>&lt;!-- Comment --&gt;</preformat>
-  <p>
-    Just plain comment, with trailing spaces on the line:
-  </p>
-  <p>
-    Code:
-  </p>
-  <preformat>&lt;hr /&gt;</preformat>
-  <p>
-    Hr’s:
-  </p>
-</sec>
-<sec id="inline-markup">
-  <title>Inline Markup</title>
-  <p>
-    This is <italic>emphasized</italic>, and so <italic>is this</italic>.
-  </p>
-  <p>
-    This is <bold role="strong">strong</bold>, and so <bold role="strong">is
-    this</bold>.
-  </p>
-  <p>
-    An <italic><ext-link ext-link-type="uri" xlink:href="/url">emphasized
-    link</ext-link></italic>.
-  </p>
-  <p>
-    <bold role="strong"><italic>This is strong and em.</italic></bold>
-  </p>
-  <p>
-    So is <bold role="strong"><italic>this</italic></bold> word.
-  </p>
-  <p>
-    <bold role="strong"><italic>This is strong and em.</italic></bold>
-  </p>
-  <p>
-    So is <bold role="strong"><italic>this</italic></bold> word.
-  </p>
-  <p>
-    This is code: <monospace>&gt;</monospace>, <monospace>$</monospace>,
-    <monospace>\</monospace>, <monospace>\$</monospace>,
-    <monospace>&lt;html&gt;</monospace>.
-  </p>
-  <p>
-    <strike>This is <italic>strikeout</italic>.</strike>
-  </p>
-  <p>
-    Superscripts: a<sup>bc</sup>d a<sup><italic>hello</italic></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>
-</sec>
-<sec id="smart-quotes-ellipses-dashes">
-  <title>Smart quotes, ellipses, dashes</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 ‘<monospace>code</monospace>’ and a
-    “<ext-link ext-link-type="uri" xlink:href="http://example.com/?foo=1&amp;bar=2">quoted
-    link</ext-link>”.
-  </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>
-</sec>
-<sec id="latex">
-  <title>LaTeX</title>
-  <list list-type="bullet">
-    <list-item>
-      <p>
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        <inline-formula><alternatives>
-        <tex-math><![CDATA[2+2=4]]></tex-math>
-        <mml:math display="inline" xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mrow><mml:mn>2</mml:mn><mml:mo>+</mml:mo><mml:mn>2</mml:mn><mml:mo>=</mml:mo><mml:mn>4</mml:mn></mml:mrow></mml:math></alternatives></inline-formula>
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        <inline-formula><alternatives>
-        <tex-math><![CDATA[x \in y]]></tex-math>
-        <mml:math display="inline" xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mrow><mml:mi>x</mml:mi><mml:mo>∈</mml:mo><mml:mi>y</mml:mi></mml:mrow></mml:math></alternatives></inline-formula>
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        <inline-formula><alternatives>
-        <tex-math><![CDATA[\alpha \wedge \omega]]></tex-math>
-        <mml:math display="inline" xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mrow><mml:mi>α</mml:mi><mml:mo>∧</mml:mo><mml:mi>ω</mml:mi></mml:mrow></mml:math></alternatives></inline-formula>
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        <inline-formula><alternatives>
-        <tex-math><![CDATA[223]]></tex-math>
-        <mml:math display="inline" xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mn>223</mml:mn></mml:math></alternatives></inline-formula>
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        <inline-formula><alternatives>
-        <tex-math><![CDATA[p]]></tex-math>
-        <mml:math display="inline" xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mi>p</mml:mi></mml:math></alternatives></inline-formula>-Tree
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        Here’s some display math: <disp-formula><alternatives>
-        <tex-math><![CDATA[\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}]]></tex-math>
-        <mml:math display="block" xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mrow><mml:mfrac><mml:mi>d</mml:mi><mml:mrow><mml:mi>d</mml:mi><mml:mi>x</mml:mi></mml:mrow></mml:mfrac><mml:mi>f</mml:mi><mml:mo stretchy="false" form="prefix">(</mml:mo><mml:mi>x</mml:mi><mml:mo stretchy="false" form="postfix">)</mml:mo><mml:mo>=</mml:mo><mml:munder><mml:mo>lim</mml:mo><mml:mrow><mml:mi>h</mml:mi><mml:mo>→</mml:mo><mml:mn>0</mml:mn></mml:mrow></mml:munder><mml:mfrac><mml:mrow><mml:mi>f</mml:mi><mml:mo stretchy="false" form="prefix">(</mml:mo><mml:mi>x</mml:mi><mml:mo>+</mml:mo><mml:mi>h</mml:mi><mml:mo stretchy="false" form="postfix">)</mml:mo><mml:mo>−</mml:mo><mml:mi>f</mml:mi><mml:mo stretchy="false" form="prefix">(</mml:mo><mml:mi>x</mml:mi><mml:mo stretchy="false" form="postfix">)</mml:mo></mml:mrow><mml:mi>h</mml:mi></mml:mfrac></mml:mrow></mml:math></alternatives></disp-formula>
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        Here’s one that has a line break in it: <inline-formula><alternatives>
-        <tex-math><![CDATA[\alpha + \omega \times x^2]]></tex-math>
-        <mml:math display="inline" xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mrow><mml:mi>α</mml:mi><mml:mo>+</mml:mo><mml:mi>ω</mml:mi><mml:mo>×</mml:mo><mml:msup><mml:mi>x</mml:mi><mml:mn>2</mml:mn></mml:msup></mml:mrow></mml:math></alternatives></inline-formula>.
-      </p>
-    </list-item>
-  </list>
-  <p>
-    These shouldn’t be math:
-  </p>
-  <list list-type="bullet">
-    <list-item>
-      <p>
-        To get the famous equation, write <monospace>$e = mc^2$</monospace>.
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        $22,000 is a <italic>lot</italic> of money. So is $34,000. (It worked
-        if “lot” is emphasized.)
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        Shoes ($20) and socks ($5).
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        Escaped <monospace>$</monospace>: $73 <italic>this should be
-        emphasized</italic> 23$.
-      </p>
-    </list-item>
-  </list>
-  <p>
-    Here’s a LaTeX table:
-  </p>
-</sec>
-<sec id="special-characters">
-  <title>Special Characters</title>
-  <p>
-    Here is some unicode:
-  </p>
-  <list list-type="bullet">
-    <list-item>
-      <p>
-        I hat: Î
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        o umlaut: ö
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        section: §
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        set membership: ∈
-      </p>
-    </list-item>
-    <list-item>
-      <p>
-        copyright: ©
-      </p>
-    </list-item>
-  </list>
-  <p>
-    AT&amp;T has an ampersand in their name.
-  </p>
-  <p>
-    AT&amp;T is another way to write it.
-  </p>
-  <p>
-    This &amp; that.
-  </p>
-  <p>
-    4 &lt; 5.
-  </p>
-  <p>
-    6 &gt; 5.
-  </p>
-  <p>
-    Backslash: \
-  </p>
-  <p>
-    Backtick: `
-  </p>
-  <p>
-    Asterisk: *
-  </p>
-  <p>
-    Underscore: _
-  </p>
-  <p>
-    Left brace: {
-  </p>
-  <p>
-    Right brace: }
-  </p>
-  <p>
-    Left bracket: [
-  </p>
-  <p>
-    Right bracket: ]
-  </p>
-  <p>
-    Left paren: (
-  </p>
-  <p>
-    Right paren: )
-  </p>
-  <p>
-    Greater-than: &gt;
-  </p>
-  <p>
-    Hash: #
-  </p>
-  <p>
-    Period: .
-  </p>
-  <p>
-    Bang: !
-  </p>
-  <p>
-    Plus: +
-  </p>
-  <p>
-    Minus: -
-  </p>
-</sec>
-<sec id="links">
-  <title>Links</title>
-  <sec id="explicit">
-    <title>Explicit</title>
-    <p>
-      Just a <ext-link ext-link-type="uri" xlink:href="/url/">URL</ext-link>.
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title">URL
-      and title</ext-link>.
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title preceded by two spaces">URL
-      and title</ext-link>.
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title preceded by a tab">URL
-      and title</ext-link>.
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title with &quot;quotes&quot; in it">URL
-      and title</ext-link>
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title with single quotes">URL
-      and title</ext-link>
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="/url/with_underscore">with_underscore</ext-link>
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="mailto:nobody@nowhere.net">Email
-      link</ext-link>
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="">Empty</ext-link>.
-    </p>
-  </sec>
-  <sec id="reference">
-    <title>Reference</title>
-    <p>
-      Foo <ext-link ext-link-type="uri" xlink:href="/url/">bar</ext-link>.
-    </p>
-    <p>
-      With <ext-link ext-link-type="uri" xlink:href="/url/">embedded
-      [brackets]</ext-link>.
-    </p>
-    <p>
-      <ext-link ext-link-type="uri" xlink:href="/url/">b</ext-link> by itself
-      should be a link.
-    </p>
-    <p>
-      Indented
-      <ext-link ext-link-type="uri" xlink:href="/url">once</ext-link>.
-    </p>
-    <p>
-      Indented
-      <ext-link ext-link-type="uri" xlink:href="/url">twice</ext-link>.
-    </p>
-    <p>
-      Indented
-      <ext-link ext-link-type="uri" xlink:href="/url">thrice</ext-link>.
-    </p>
-    <p>
-      This should [not][] be a link.
-    </p>
-    <preformat>[not]: /url</preformat>
-    <p>
-      Foo
-      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="Title with &quot;quotes&quot; inside">bar</ext-link>.
-    </p>
-    <p>
-      Foo
-      <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="Title with &quot;quote&quot; inside">biz</ext-link>.
-    </p>
-  </sec>
-  <sec id="with-ampersands">
-    <title>With ampersands</title>
-    <p>
-      Here’s a
-      <ext-link ext-link-type="uri" xlink:href="http://example.com/?foo=1&amp;bar=2">link
-      with an ampersand in the URL</ext-link>.
-    </p>
-    <p>
-      Here’s a link with an amersand in the link text:
-      <ext-link ext-link-type="uri" xlink:href="http://att.com/" xlink:title="AT&amp;T">AT&amp;T</ext-link>.
-    </p>
-    <p>
-      Here’s an
-      <ext-link ext-link-type="uri" xlink:href="/script?foo=1&amp;bar=2">inline
-      link</ext-link>.
-    </p>
-    <p>
-      Here’s an
-      <ext-link ext-link-type="uri" xlink:href="/script?foo=1&amp;bar=2">inline
-      link in pointy braces</ext-link>.
-    </p>
-  </sec>
-  <sec id="autolinks">
-    <title>Autolinks</title>
-    <p>
-      With an ampersand:
-      <ext-link ext-link-type="uri" xlink:href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</ext-link>
-    </p>
-    <list list-type="bullet">
-      <list-item>
-        <p>
-          In a list?
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          <ext-link ext-link-type="uri" xlink:href="http://example.com/">http://example.com/</ext-link>
-        </p>
-      </list-item>
-      <list-item>
-        <p>
-          It should.
-        </p>
-      </list-item>
-    </list>
-    <p>
-      An e-mail address: <email>nobody@nowhere.net</email>
-    </p>
-    <disp-quote>
-      <p>
-        Blockquoted:
-        <ext-link ext-link-type="uri" xlink:href="http://example.com/">http://example.com/</ext-link>
-      </p>
-    </disp-quote>
-    <p>
-      Auto-links should not occur here:
-      <monospace>&lt;http://example.com/&gt;</monospace>
-    </p>
-    <preformat>or here: &lt;http://example.com/&gt;</preformat>
-  </sec>
-</sec>
-<sec id="images">
-  <title>Images</title>
-  <p>
-    From “Voyage dans la Lune” by Georges Melies (1902):
-  </p>
-  <fig>
-    <caption>lalune</caption>
-    <graphic mimetype="image" mime-subtype="jpeg" xlink:href="lalune.jpg" xlink:title="Voyage dans la Lune" />
-  </fig>
-  <p>
-    Here is a movie
-    <inline-graphic mimetype="image" mime-subtype="jpeg" xlink:href="movie.jpg" />
-    icon.
-  </p>
-</sec>
-<sec id="footnotes">
-  <title>Footnotes</title>
-  <p>
-    Here is a footnote reference,<fn>
-      <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>
-    </fn> and another.<fn>
-      <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>
-      <preformat>  { &lt;code&gt; }</preformat>
-      <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>
-    </fn> This should <italic>not</italic> be a footnote reference, because it
-    contains a space.[^my note] Here is an inline note.<fn>
-      <p>
-        This is <italic>easier</italic> to type. Inline notes may contain
-        <ext-link ext-link-type="uri" xlink:href="http://google.com">links</ext-link>
-        and <monospace>]</monospace> verbatim characters, as well as
-        [bracketed text].
-      </p>
-    </fn>
-  </p>
-  <disp-quote>
-    <p>
-      Notes can go in quotes.<fn>
-        <p>
-          In quote.
-        </p>
-      </fn>
-    </p>
-  </disp-quote>
-  <list list-type="order">
-    <list-item>
-      <p>
-        And in list items.<fn>
-          <p>
-            In list.
-          </p>
-        </fn>
-      </p>
-    </list-item>
-  </list>
-  <p>
-    This paragraph should not be part of the note, as it is not indented.
-  </p>
+<p>This is a set of tests for pandoc. Most of them are adapted from John
+Gruber’s markdown test suite.</p>
+<sec id="headers">
+  <title>Headers</title>
+  <sec id="level-2-with-an-embedded-link">
+    <title>Level 2 with an
+    <ext-link ext-link-type="uri" xlink:href="/url">embedded
+    link</ext-link></title>
+    <sec id="level-3-with-emphasis">
+      <title>Level 3 with <italic>emphasis</italic></title>
+      <sec id="level-4">
+        <title>Level 4</title>
+        <sec id="level-5">
+          <title>Level 5</title>
+        </sec>
+      </sec>
+    </sec>
+  </sec>
+</sec>
+<sec id="level-1">
+  <title>Level 1</title>
+  <sec id="level-2-with-emphasis">
+    <title>Level 2 with <italic>emphasis</italic></title>
+    <sec id="level-3">
+      <title>Level 3</title>
+      <p>with no blank line</p>
+    </sec>
+  </sec>
+  <sec id="level-2">
+    <title>Level 2</title>
+    <p>with no blank line</p>
+  </sec>
+</sec>
+<sec id="paragraphs">
+  <title>Paragraphs</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<break />here.</p>
+</sec>
+<sec id="block-quotes">
+  <title>Block Quotes</title>
+  <p>E-mail style:</p>
+  <disp-quote>
+    <p>This is a block quote. It is pretty short.</p>
+  </disp-quote>
+  <disp-quote>
+    <p>Code in a block quote:</p>
+    <preformat>sub status {
+    print &quot;working&quot;;
+}</preformat>
+    <p>A list:</p>
+    <list list-type="order">
+      <list-item>
+        <p>item one</p>
+      </list-item>
+      <list-item>
+        <p>item two</p>
+      </list-item>
+    </list>
+    <p>Nested block quotes:</p>
+    <disp-quote>
+      <p>nested</p>
+    </disp-quote>
+    <disp-quote>
+      <p>nested</p>
+    </disp-quote>
+  </disp-quote>
+  <p>This should not be a block quote: 2 &gt; 1.</p>
+  <p>And a following paragraph.</p>
+</sec>
+<sec id="code-blocks">
+  <title>Code Blocks</title>
+  <p>Code:</p>
+  <preformat>---- (should be four hyphens)
+
+sub status {
+    print &quot;working&quot;;
+}
+
+this code block is indented by one tab</preformat>
+  <p>And:</p>
+  <preformat>    this code block is indented by two tabs
+
+These should not be escaped:  \$ \\ \&gt; \[ \{</preformat>
+</sec>
+<sec id="lists">
+  <title>Lists</title>
+  <sec id="unordered">
+    <title>Unordered</title>
+    <p>Asterisks tight:</p>
+    <list list-type="bullet">
+      <list-item>
+        <p>asterisk 1</p>
+      </list-item>
+      <list-item>
+        <p>asterisk 2</p>
+      </list-item>
+      <list-item>
+        <p>asterisk 3</p>
+      </list-item>
+    </list>
+    <p>Asterisks loose:</p>
+    <list list-type="bullet">
+      <list-item>
+        <p>asterisk 1</p>
+      </list-item>
+      <list-item>
+        <p>asterisk 2</p>
+      </list-item>
+      <list-item>
+        <p>asterisk 3</p>
+      </list-item>
+    </list>
+    <p>Pluses tight:</p>
+    <list list-type="bullet">
+      <list-item>
+        <p>Plus 1</p>
+      </list-item>
+      <list-item>
+        <p>Plus 2</p>
+      </list-item>
+      <list-item>
+        <p>Plus 3</p>
+      </list-item>
+    </list>
+    <p>Pluses loose:</p>
+    <list list-type="bullet">
+      <list-item>
+        <p>Plus 1</p>
+      </list-item>
+      <list-item>
+        <p>Plus 2</p>
+      </list-item>
+      <list-item>
+        <p>Plus 3</p>
+      </list-item>
+    </list>
+    <p>Minuses tight:</p>
+    <list list-type="bullet">
+      <list-item>
+        <p>Minus 1</p>
+      </list-item>
+      <list-item>
+        <p>Minus 2</p>
+      </list-item>
+      <list-item>
+        <p>Minus 3</p>
+      </list-item>
+    </list>
+    <p>Minuses loose:</p>
+    <list list-type="bullet">
+      <list-item>
+        <p>Minus 1</p>
+      </list-item>
+      <list-item>
+        <p>Minus 2</p>
+      </list-item>
+      <list-item>
+        <p>Minus 3</p>
+      </list-item>
+    </list>
+  </sec>
+  <sec id="ordered">
+    <title>Ordered</title>
+    <p>Tight:</p>
+    <list list-type="order">
+      <list-item>
+        <p>First</p>
+      </list-item>
+      <list-item>
+        <p>Second</p>
+      </list-item>
+      <list-item>
+        <p>Third</p>
+      </list-item>
+    </list>
+    <p>and:</p>
+    <list list-type="order">
+      <list-item>
+        <p>One</p>
+      </list-item>
+      <list-item>
+        <p>Two</p>
+      </list-item>
+      <list-item>
+        <p>Three</p>
+      </list-item>
+    </list>
+    <p>Loose using tabs:</p>
+    <list list-type="order">
+      <list-item>
+        <p>First</p>
+      </list-item>
+      <list-item>
+        <p>Second</p>
+      </list-item>
+      <list-item>
+        <p>Third</p>
+      </list-item>
+    </list>
+    <p>and using spaces:</p>
+    <list list-type="order">
+      <list-item>
+        <p>One</p>
+      </list-item>
+      <list-item>
+        <p>Two</p>
+      </list-item>
+      <list-item>
+        <p>Three</p>
+      </list-item>
+    </list>
+    <p>Multiple paragraphs:</p>
+    <list list-type="order">
+      <list-item>
+        <p>Item 1, graf one.</p>
+        <p>Item 1. graf two. The quick brown fox jumped over the lazy dog’s
+        back.</p>
+      </list-item>
+      <list-item>
+        <p>Item 2.</p>
+      </list-item>
+      <list-item>
+        <p>Item 3.</p>
+      </list-item>
+    </list>
+  </sec>
+  <sec id="nested">
+    <title>Nested</title>
+    <list list-type="bullet">
+      <list-item>
+        <p>Tab</p>
+        <list list-type="bullet">
+          <list-item>
+            <p>Tab</p>
+            <list list-type="bullet">
+              <list-item>
+                <p>Tab</p>
+              </list-item>
+            </list>
+          </list-item>
+        </list>
+      </list-item>
+    </list>
+    <p>Here’s another:</p>
+    <list list-type="order">
+      <list-item>
+        <p>First</p>
+      </list-item>
+      <list-item>
+        <p>Second:</p>
+        <list list-type="bullet">
+          <list-item>
+            <p>Fee</p>
+          </list-item>
+          <list-item>
+            <p>Fie</p>
+          </list-item>
+          <list-item>
+            <p>Foe</p>
+          </list-item>
+        </list>
+      </list-item>
+      <list-item>
+        <p>Third</p>
+      </list-item>
+    </list>
+    <p>Same thing but with paragraphs:</p>
+    <list list-type="order">
+      <list-item>
+        <p>First</p>
+      </list-item>
+      <list-item>
+        <p>Second:</p>
+        <list list-type="bullet">
+          <list-item>
+            <p>Fee</p>
+          </list-item>
+          <list-item>
+            <p>Fie</p>
+          </list-item>
+          <list-item>
+            <p>Foe</p>
+          </list-item>
+        </list>
+      </list-item>
+      <list-item>
+        <p>Third</p>
+      </list-item>
+    </list>
+  </sec>
+  <sec id="tabs-and-spaces">
+    <title>Tabs and spaces</title>
+    <list list-type="bullet">
+      <list-item>
+        <p>this is a list item indented with tabs</p>
+      </list-item>
+      <list-item>
+        <p>this is a list item indented with spaces</p>
+        <list list-type="bullet">
+          <list-item>
+            <p>this is an example list item indented with tabs</p>
+          </list-item>
+          <list-item>
+            <p>this is an example list item indented with spaces</p>
+          </list-item>
+        </list>
+      </list-item>
+    </list>
+  </sec>
+  <sec id="fancy-list-markers">
+    <title>Fancy list markers</title>
+    <list list-type="order">
+      <list-item>
+        <label>(2)</label>
+        <p>begins with 2</p>
+      </list-item>
+      <list-item>
+        <label>(3)</label>
+        <p>and now 3</p>
+        <p>with a continuation</p>
+        <list list-type="roman-lower">
+          <list-item>
+            <label>iv.</label>
+            <p>sublist with roman numerals, starting with 4</p>
+          </list-item>
+          <list-item>
+            <label>v.</label>
+            <p>more items</p>
+            <list list-type="alpha-upper">
+              <list-item>
+                <label>(A)</label>
+                <p>a subsublist</p>
+              </list-item>
+              <list-item>
+                <label>(B)</label>
+                <p>a subsublist</p>
+              </list-item>
+            </list>
+          </list-item>
+        </list>
+      </list-item>
+    </list>
+    <p>Nesting:</p>
+    <list list-type="alpha-upper">
+      <list-item>
+        <p>Upper Alpha</p>
+        <list list-type="roman-upper">
+          <list-item>
+            <p>Upper Roman.</p>
+            <list list-type="order">
+              <list-item>
+                <label>(6)</label>
+                <p>Decimal start with 6</p>
+                <list list-type="alpha-lower">
+                  <list-item>
+                    <label>c)</label>
+                    <p>Lower alpha with paren</p>
+                  </list-item>
+                </list>
+              </list-item>
+            </list>
+          </list-item>
+        </list>
+      </list-item>
+    </list>
+    <p>Autonumbering:</p>
+    <list list-type="order">
+      <list-item>
+        <p>Autonumber.</p>
+      </list-item>
+      <list-item>
+        <p>More.</p>
+        <list list-type="order">
+          <list-item>
+            <p>Nested.</p>
+          </list-item>
+        </list>
+      </list-item>
+    </list>
+    <p>Should not be a list item:</p>
+    <p>M.A. 2007</p>
+    <p>B. Williams</p>
+  </sec>
+</sec>
+<sec id="definition-lists">
+  <title>Definition Lists</title>
+  <p>Tight using spaces:</p>
+  <def-list>
+    <def-item>
+      <term>apple</term>
+      <def>
+        <p>red fruit</p>
+      </def>
+    </def-item>
+    <def-item>
+      <term>orange</term>
+      <def>
+        <p>orange fruit</p>
+      </def>
+    </def-item>
+    <def-item>
+      <term>banana</term>
+      <def>
+        <p>yellow fruit</p>
+      </def>
+    </def-item>
+  </def-list>
+  <p>Tight using tabs:</p>
+  <def-list>
+    <def-item>
+      <term>apple</term>
+      <def>
+        <p>red fruit</p>
+      </def>
+    </def-item>
+    <def-item>
+      <term>orange</term>
+      <def>
+        <p>orange fruit</p>
+      </def>
+    </def-item>
+    <def-item>
+      <term>banana</term>
+      <def>
+        <p>yellow fruit</p>
+      </def>
+    </def-item>
+  </def-list>
+  <p>Loose:</p>
+  <def-list>
+    <def-item>
+      <term>apple</term>
+      <def>
+        <p>red fruit</p>
+      </def>
+    </def-item>
+    <def-item>
+      <term>orange</term>
+      <def>
+        <p>orange fruit</p>
+      </def>
+    </def-item>
+    <def-item>
+      <term>banana</term>
+      <def>
+        <p>yellow fruit</p>
+      </def>
+    </def-item>
+  </def-list>
+  <p>Multiple blocks with italics:</p>
+  <def-list>
+    <def-item>
+      <term><italic>apple</italic></term>
+      <def>
+        <p>red fruit</p>
+        <p>contains seeds, crisp, pleasant to taste</p>
+      </def>
+    </def-item>
+    <def-item>
+      <term><italic>orange</italic></term>
+      <def>
+        <p>orange fruit</p>
+        <preformat>{ orange code block }</preformat>
+        <disp-quote>
+          <p>orange block quote</p>
+        </disp-quote>
+      </def>
+    </def-item>
+  </def-list>
+  <p>Multiple definitions, tight:</p>
+  <def-list>
+    <def-item>
+      <term>apple</term>
+      <def>
+        <p>red fruit</p>
+        <p>computer</p>
+      </def>
+    </def-item>
+    <def-item>
+      <term>orange</term>
+      <def>
+        <p>orange fruit</p>
+        <p>bank</p>
+      </def>
+    </def-item>
+  </def-list>
+  <p>Multiple definitions, loose:</p>
+  <def-list>
+    <def-item>
+      <term>apple</term>
+      <def>
+        <p>red fruit</p>
+        <p>computer</p>
+      </def>
+    </def-item>
+    <def-item>
+      <term>orange</term>
+      <def>
+        <p>orange fruit</p>
+        <p>bank</p>
+      </def>
+    </def-item>
+  </def-list>
+  <p>Blank line after term, indented marker, alternate markers:</p>
+  <def-list>
+    <def-item>
+      <term>apple</term>
+      <def>
+        <p>red fruit</p>
+        <p>computer</p>
+      </def>
+    </def-item>
+    <def-item>
+      <term>orange</term>
+      <def>
+        <p>orange fruit</p>
+        <list list-type="order">
+          <list-item>
+            <p>sublist</p>
+          </list-item>
+          <list-item>
+            <p>sublist</p>
+          </list-item>
+        </list>
+      </def>
+    </def-item>
+  </def-list>
+</sec>
+<sec id="html-blocks">
+  <title>HTML Blocks</title>
+  <p>Simple block on one line:</p>
+  <boxed-text>
+    <p>foo</p>
+  </boxed-text>
+  <p>And nested without indentation:</p>
+  <boxed-text>
+    <boxed-text>
+      <boxed-text>
+        <p>foo</p>
+      </boxed-text>
+    </boxed-text>
+    <boxed-text>
+      <p>bar</p>
+    </boxed-text>
+  </boxed-text>
+  <p>Interpreted markdown in a table:</p>
+  <p>This is <italic>emphasized</italic></p>
+  <p>And this is <bold role="strong">strong</bold></p>
+  <p>Here’s a simple block:</p>
+  <boxed-text>
+    <p>foo</p>
+  </boxed-text>
+  <p>This should be a code block, though:</p>
+  <preformat>&lt;div&gt;
+    foo
+&lt;/div&gt;</preformat>
+  <p>As should this:</p>
+  <preformat>&lt;div&gt;foo&lt;/div&gt;</preformat>
+  <p>Now, nested:</p>
+  <boxed-text>
+    <boxed-text>
+      <boxed-text>
+        <p>foo</p>
+      </boxed-text>
+    </boxed-text>
+  </boxed-text>
+  <p>This should just be an HTML comment:</p>
+  <p>Multiline:</p>
+  <p>Code block:</p>
+  <preformat>&lt;!-- Comment --&gt;</preformat>
+  <p>Just plain comment, with trailing spaces on the line:</p>
+  <p>Code:</p>
+  <preformat>&lt;hr /&gt;</preformat>
+  <p>Hr’s:</p>
+</sec>
+<sec id="inline-markup">
+  <title>Inline Markup</title>
+  <p>This is <italic>emphasized</italic>, and so <italic>is this</italic>.</p>
+  <p>This is <bold role="strong">strong</bold>, and so <bold role="strong">is
+  this</bold>.</p>
+  <p>An <italic><ext-link ext-link-type="uri" xlink:href="/url">emphasized
+  link</ext-link></italic>.</p>
+  <p><bold role="strong"><italic>This is strong and em.</italic></bold></p>
+  <p>So is <bold role="strong"><italic>this</italic></bold> word.</p>
+  <p><bold role="strong"><italic>This is strong and em.</italic></bold></p>
+  <p>So is <bold role="strong"><italic>this</italic></bold> word.</p>
+  <p>This is code: <monospace>&gt;</monospace>, <monospace>$</monospace>,
+  <monospace>\</monospace>, <monospace>\$</monospace>,
+  <monospace>&lt;html&gt;</monospace>.</p>
+  <p><strike>This is <italic>strikeout</italic>.</strike></p>
+  <p>Superscripts: a<sup>bc</sup>d a<sup><italic>hello</italic></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>
+</sec>
+<sec id="smart-quotes-ellipses-dashes">
+  <title>Smart quotes, ellipses, dashes</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 ‘<monospace>code</monospace>’ and a
+  “<ext-link ext-link-type="uri" xlink:href="http://example.com/?foo=1&amp;bar=2">quoted
+  link</ext-link>”.</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>
+</sec>
+<sec id="latex">
+  <title>LaTeX</title>
+  <list list-type="bullet">
+    <list-item>
+      <p></p>
+    </list-item>
+    <list-item>
+      <p><inline-formula><alternatives>
+      <tex-math><![CDATA[2+2=4]]></tex-math>
+      <mml:math display="inline" xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mrow><mml:mn>2</mml:mn><mml:mo>+</mml:mo><mml:mn>2</mml:mn><mml:mo>=</mml:mo><mml:mn>4</mml:mn></mml:mrow></mml:math></alternatives></inline-formula></p>
+    </list-item>
+    <list-item>
+      <p><inline-formula><alternatives>
+      <tex-math><![CDATA[x \in y]]></tex-math>
+      <mml:math display="inline" xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mrow><mml:mi>x</mml:mi><mml:mo>∈</mml:mo><mml:mi>y</mml:mi></mml:mrow></mml:math></alternatives></inline-formula></p>
+    </list-item>
+    <list-item>
+      <p><inline-formula><alternatives>
+      <tex-math><![CDATA[\alpha \wedge \omega]]></tex-math>
+      <mml:math display="inline" xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mrow><mml:mi>α</mml:mi><mml:mo>∧</mml:mo><mml:mi>ω</mml:mi></mml:mrow></mml:math></alternatives></inline-formula></p>
+    </list-item>
+    <list-item>
+      <p><inline-formula><alternatives>
+      <tex-math><![CDATA[223]]></tex-math>
+      <mml:math display="inline" xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mn>223</mml:mn></mml:math></alternatives></inline-formula></p>
+    </list-item>
+    <list-item>
+      <p><inline-formula><alternatives>
+      <tex-math><![CDATA[p]]></tex-math>
+      <mml:math display="inline" xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mi>p</mml:mi></mml:math></alternatives></inline-formula>-Tree</p>
+    </list-item>
+    <list-item>
+      <p>Here’s some display math: <disp-formula><alternatives>
+      <tex-math><![CDATA[\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}]]></tex-math>
+      <mml:math display="block" xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mrow><mml:mfrac><mml:mi>d</mml:mi><mml:mrow><mml:mi>d</mml:mi><mml:mi>x</mml:mi></mml:mrow></mml:mfrac><mml:mi>f</mml:mi><mml:mo stretchy="false" form="prefix">(</mml:mo><mml:mi>x</mml:mi><mml:mo stretchy="false" form="postfix">)</mml:mo><mml:mo>=</mml:mo><mml:munder><mml:mo>lim</mml:mo><mml:mrow><mml:mi>h</mml:mi><mml:mo>→</mml:mo><mml:mn>0</mml:mn></mml:mrow></mml:munder><mml:mfrac><mml:mrow><mml:mi>f</mml:mi><mml:mo stretchy="false" form="prefix">(</mml:mo><mml:mi>x</mml:mi><mml:mo>+</mml:mo><mml:mi>h</mml:mi><mml:mo stretchy="false" form="postfix">)</mml:mo><mml:mo>−</mml:mo><mml:mi>f</mml:mi><mml:mo stretchy="false" form="prefix">(</mml:mo><mml:mi>x</mml:mi><mml:mo stretchy="false" form="postfix">)</mml:mo></mml:mrow><mml:mi>h</mml:mi></mml:mfrac></mml:mrow></mml:math></alternatives></disp-formula></p>
+    </list-item>
+    <list-item>
+      <p>Here’s one that has a line break in it:
+      <inline-formula><alternatives>
+      <tex-math><![CDATA[\alpha + \omega \times x^2]]></tex-math>
+      <mml:math display="inline" xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mrow><mml:mi>α</mml:mi><mml:mo>+</mml:mo><mml:mi>ω</mml:mi><mml:mo>×</mml:mo><mml:msup><mml:mi>x</mml:mi><mml:mn>2</mml:mn></mml:msup></mml:mrow></mml:math></alternatives></inline-formula>.</p>
+    </list-item>
+  </list>
+  <p>These shouldn’t be math:</p>
+  <list list-type="bullet">
+    <list-item>
+      <p>To get the famous equation, write
+      <monospace>$e = mc^2$</monospace>.</p>
+    </list-item>
+    <list-item>
+      <p>$22,000 is a <italic>lot</italic> of money. So is $34,000. (It worked
+      if “lot” is emphasized.)</p>
+    </list-item>
+    <list-item>
+      <p>Shoes ($20) and socks ($5).</p>
+    </list-item>
+    <list-item>
+      <p>Escaped <monospace>$</monospace>: $73 <italic>this should be
+      emphasized</italic> 23$.</p>
+    </list-item>
+  </list>
+  <p>Here’s a LaTeX table:</p>
+</sec>
+<sec id="special-characters">
+  <title>Special Characters</title>
+  <p>Here is some unicode:</p>
+  <list list-type="bullet">
+    <list-item>
+      <p>I hat: Î</p>
+    </list-item>
+    <list-item>
+      <p>o umlaut: ö</p>
+    </list-item>
+    <list-item>
+      <p>section: §</p>
+    </list-item>
+    <list-item>
+      <p>set membership: ∈</p>
+    </list-item>
+    <list-item>
+      <p>copyright: ©</p>
+    </list-item>
+  </list>
+  <p>AT&amp;T has an ampersand in their name.</p>
+  <p>AT&amp;T is another way to write it.</p>
+  <p>This &amp; that.</p>
+  <p>4 &lt; 5.</p>
+  <p>6 &gt; 5.</p>
+  <p>Backslash: \</p>
+  <p>Backtick: `</p>
+  <p>Asterisk: *</p>
+  <p>Underscore: _</p>
+  <p>Left brace: {</p>
+  <p>Right brace: }</p>
+  <p>Left bracket: [</p>
+  <p>Right bracket: ]</p>
+  <p>Left paren: (</p>
+  <p>Right paren: )</p>
+  <p>Greater-than: &gt;</p>
+  <p>Hash: #</p>
+  <p>Period: .</p>
+  <p>Bang: !</p>
+  <p>Plus: +</p>
+  <p>Minus: -</p>
+</sec>
+<sec id="links">
+  <title>Links</title>
+  <sec id="explicit">
+    <title>Explicit</title>
+    <p>Just a
+    <ext-link ext-link-type="uri" xlink:href="/url/">URL</ext-link>.</p>
+    <p><ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title">URL
+    and title</ext-link>.</p>
+    <p><ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title preceded by two spaces">URL
+    and title</ext-link>.</p>
+    <p><ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title preceded by a tab">URL
+    and title</ext-link>.</p>
+    <p><ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title with &quot;quotes&quot; in it">URL
+    and title</ext-link></p>
+    <p><ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="title with single quotes">URL
+    and title</ext-link></p>
+    <p><ext-link ext-link-type="uri" xlink:href="/url/with_underscore">with_underscore</ext-link></p>
+    <p><ext-link ext-link-type="uri" xlink:href="mailto:nobody@nowhere.net">Email
+    link</ext-link></p>
+    <p><ext-link ext-link-type="uri" xlink:href="">Empty</ext-link>.</p>
+  </sec>
+  <sec id="reference">
+    <title>Reference</title>
+    <p>Foo
+    <ext-link ext-link-type="uri" xlink:href="/url/">bar</ext-link>.</p>
+    <p>With <ext-link ext-link-type="uri" xlink:href="/url/">embedded
+    [brackets]</ext-link>.</p>
+    <p><ext-link ext-link-type="uri" xlink:href="/url/">b</ext-link> by itself
+    should be a link.</p>
+    <p>Indented
+    <ext-link ext-link-type="uri" xlink:href="/url">once</ext-link>.</p>
+    <p>Indented
+    <ext-link ext-link-type="uri" xlink:href="/url">twice</ext-link>.</p>
+    <p>Indented
+    <ext-link ext-link-type="uri" xlink:href="/url">thrice</ext-link>.</p>
+    <p>This should [not][] be a link.</p>
+    <preformat>[not]: /url</preformat>
+    <p>Foo
+    <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="Title with &quot;quotes&quot; inside">bar</ext-link>.</p>
+    <p>Foo
+    <ext-link ext-link-type="uri" xlink:href="/url/" xlink:title="Title with &quot;quote&quot; inside">biz</ext-link>.</p>
+  </sec>
+  <sec id="with-ampersands">
+    <title>With ampersands</title>
+    <p>Here’s a
+    <ext-link ext-link-type="uri" xlink:href="http://example.com/?foo=1&amp;bar=2">link
+    with an ampersand in the URL</ext-link>.</p>
+    <p>Here’s a link with an amersand in the link text:
+    <ext-link ext-link-type="uri" xlink:href="http://att.com/" xlink:title="AT&amp;T">AT&amp;T</ext-link>.</p>
+    <p>Here’s an
+    <ext-link ext-link-type="uri" xlink:href="/script?foo=1&amp;bar=2">inline
+    link</ext-link>.</p>
+    <p>Here’s an
+    <ext-link ext-link-type="uri" xlink:href="/script?foo=1&amp;bar=2">inline
+    link in pointy braces</ext-link>.</p>
+  </sec>
+  <sec id="autolinks">
+    <title>Autolinks</title>
+    <p>With an ampersand:
+    <ext-link ext-link-type="uri" xlink:href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</ext-link></p>
+    <list list-type="bullet">
+      <list-item>
+        <p>In a list?</p>
+      </list-item>
+      <list-item>
+        <p><ext-link ext-link-type="uri" xlink:href="http://example.com/">http://example.com/</ext-link></p>
+      </list-item>
+      <list-item>
+        <p>It should.</p>
+      </list-item>
+    </list>
+    <p>An e-mail address: <email>nobody@nowhere.net</email></p>
+    <disp-quote>
+      <p>Blockquoted:
+      <ext-link ext-link-type="uri" xlink:href="http://example.com/">http://example.com/</ext-link></p>
+    </disp-quote>
+    <p>Auto-links should not occur here:
+    <monospace>&lt;http://example.com/&gt;</monospace></p>
+    <preformat>or here: &lt;http://example.com/&gt;</preformat>
+  </sec>
+</sec>
+<sec id="images">
+  <title>Images</title>
+  <p>From “Voyage dans la Lune” by Georges Melies (1902):</p>
+  <fig>
+    <caption>lalune</caption>
+    <graphic mimetype="image" mime-subtype="jpeg" xlink:href="lalune.jpg" xlink:title="Voyage dans la Lune" />
+  </fig>
+  <p>Here is a movie
+  <inline-graphic mimetype="image" mime-subtype="jpeg" xlink:href="movie.jpg" />
+  icon.</p>
+</sec>
+<sec id="footnotes">
+  <title>Footnotes</title>
+  <p>Here is a footnote reference,<fn>
+    <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>
+  </fn> and another.<fn>
+    <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>
+    <preformat>  { &lt;code&gt; }</preformat>
+    <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>
+  </fn> This should <italic>not</italic> be a footnote reference, because it
+  contains a space.[^my note] Here is an inline note.<fn>
+    <p>This is <italic>easier</italic> to type. Inline notes may contain
+    <ext-link ext-link-type="uri" xlink:href="http://google.com">links</ext-link>
+    and <monospace>]</monospace> verbatim characters, as well as [bracketed
+    text].</p>
+  </fn></p>
+  <disp-quote>
+    <p>Notes can go in quotes.<fn>
+      <p>In quote.</p>
+    </fn></p>
+  </disp-quote>
+  <list list-type="order">
+    <list-item>
+      <p>And in list items.<fn>
+        <p>In list.</p>
+      </fn></p>
+    </list-item>
+  </list>
+  <p>This paragraph should not be part of the note, as it is not indented.</p>
 </sec>
 </body>
 <back>
diff --git a/test/writer.ms b/test/writer.ms
--- a/test/writer.ms
+++ b/test/writer.ms
@@ -128,7 +128,7 @@
 In Markdown 1.0.0 and earlier.
 Version 8.
 This line turns into a list item.
-Because a hard\-wrapped line in the middle of a paragraph looked like a list
+Because a hard-wrapped line in the middle of a paragraph looked like a list
 item.
 .PP
 Here's one with a bullet.
@@ -143,7 +143,7 @@
 .pdfhref O 1 "Block Quotes"
 .pdfhref M "block-quotes"
 .LP
-E\-mail style:
+E-mail style:
 .RS
 .LP
 This is a block quote.
@@ -191,7 +191,7 @@
 .IP
 .nf
 \f[C]
-\-\-\-\-\ (should\ be\ four\ hyphens)
+----\ (should\ be\ four\ hyphens)
 
 sub\ status\ {
 \ \ \ \ print\ \[dq]working\[dq];
@@ -600,7 +600,7 @@
 .IP
 .nf
 \f[C]
-<!\-\-\ Comment\ \-\->
+<!--\ Comment\ -->
 \f[]
 .fi
 .LP
@@ -690,7 +690,7 @@
 .IP \[bu] 3
 @223@
 .IP \[bu] 3
-@p@\-Tree
+@p@-Tree
 .IP \[bu] 3
 Here's some display math:
 .EQ
@@ -760,7 +760,7 @@
 .PP
 Right paren: )
 .PP
-Greater\-than: >
+Greater-than: >
 .PP
 Hash: #
 .PP
@@ -770,7 +770,7 @@
 .PP
 Plus: +
 .PP
-Minus: \-
+Minus: -
 .HLINE
 .SH 1
 Links
@@ -920,7 +920,7 @@
 .IP \[bu] 3
 It should.
 .LP
-An e\-mail address: \c
+An e-mail address: \c
 .pdfhref W -D "mailto:nobody%40nowhere.net" -A "\c" \
  -- "nobody\@nowhere.net"
 \&
@@ -932,7 +932,7 @@
 \&
 .RE
 .LP
-Auto\-links should not occur here: \f[C]<http://example.com/>\f[]
+Auto-links should not occur here: \f[C]<http://example.com/>\f[]
 .IP
 .nf
 \f[C]
diff --git a/test/writer.muse b/test/writer.muse
--- a/test/writer.muse
+++ b/test/writer.muse
@@ -594,7 +594,7 @@
 
 Plus: +
 
-Minus: -
+Minus: <verbatim>-</verbatim>
 
 ----
 
diff --git a/test/writers-lang-and-dir.latex b/test/writers-lang-and-dir.latex
--- a/test/writers-lang-and-dir.latex
+++ b/test/writers-lang-and-dir.latex
@@ -74,8 +74,8 @@
 \fi
 \ifxetex
   % load bidi as late as possible as it modifies e.g. graphicx
-    \usepackage{bidi}
-  \fi
+  \usepackage{bidi}
+\fi
 \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
   \TeXXeTstate=1
   \newcommand{\RL}[1]{\beginR #1\endR}
diff --git a/trypandoc/trypandoc.hs b/trypandoc/trypandoc.hs
--- a/trypandoc/trypandoc.hs
+++ b/trypandoc/trypandoc.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE NoImplicitPrelude #-}
 {-# LANGUAGE OverloadedStrings #-}
 module Main where
+import Prelude
 import Network.Wai.Handler.CGI
 import Network.Wai
 import Control.Applicative ((<$>))
