diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -206,6 +206,31 @@
 they had the expected result, and mention the Word/Powerpoint
 version and OS in your commit comment.
 
+Code style
+----------
+
+Pandoc uses [hlint] to identify opportunities for code improvements
+like redundant brackets or unnecessary `Language` extensions.
+However, sometimes there are cases where there are good reasons to
+use code different from what hlint proposes. In these cases, the
+respective warning should be disabled in the file `.hlint.yaml`.
+
+There should be no errors when running `hlint .`; this is checked by
+the continuous integration (CI) setup. It is recommended that
+contributors check their code with a local hlint installation, but
+relying on the CI is fine, too.
+
+A good way to ensure no new warnings are introduced is to use a Git
+[pre-commit hook] which runs hlint on all updated Haskell files
+before creating a commit:
+
+    #!/bin/sh
+    git diff --cached --name-only | grep '.hs$' | xargs hlint
+
+Saving this to `.git/hooks/pre-commit`, and making the script
+executable, will prevent accidental introduction of potentially
+problematic code.
+
 Benchmarks
 ----------
 
@@ -359,7 +384,9 @@
 [FAQs]:  http://pandoc.org/faqs.html
 [EditorConfig]: http://editorconfig.org/
 [Haskell platform]: http://www.haskell.org/platform/
+[hlint]: https://hackage.haskell.org/package/hlint
 [hsb2hs]: http://hackage.haskell.org/package/hsb2hs
+[pre-commit hook]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
 [GitHub labels]: https://github.com/jgm/pandoc/labels
 [good first issue]:https://github.com/jgm/pandoc/labels/good%20first%20issue
 [enhancement]: https://github.com/jgm/pandoc/labels/enhancement
diff --git a/INSTALL.md b/INSTALL.md
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -49,10 +49,6 @@
 
      brew install pandoc
 
-To include pandoc's citation parser:
-
-     brew install pandoc-citeproc
-
 Homebrew can also install other software that integrates with Pandoc.
 For example, to install [librsvg] (its `rsvg-convert` covers formats
 without SVG support), [Python] (to use Pandoc filters), and
@@ -86,9 +82,8 @@
 To get the latest release, we provide a binary package for amd64
 architecture on the **[download page]**.
 
-This provides both `pandoc` and `pandoc-citeproc`.
-The executables are statically linked and
-have no dynamic dependencies or dependencies on external
+The executable is statically linked and
+has no dynamic dependencies or dependencies on external
 data files.  Note:  because of the static
 linking, the pandoc binary from this package cannot use lua
 filters that require external lua modules written in C.
@@ -98,8 +93,7 @@
     sudo dpkg -i $DEB
 
 where `$DEB` is the path to the downloaded deb.  This will
-install the `pandoc` and `pandoc-citeproc` executables and
-man pages.
+install the `pandoc` executable and man page.
 
 If you use an RPM-based distro, you may be able to install
 the deb from our download page using `alien`.
@@ -149,7 +143,7 @@
 [dockerhub](https://hub.docker.com/).
 
 The [pandoc/core](https://hub.docker.com/r/pandoc/core)
-image contains `pandoc` and `pandoc-citeproc`.
+image contains `pandoc`.
 
 The [pandoc/latex](https://hub.docker.com/r/pandoc/latex)
 image also contains the minimal LaTeX installation needed
@@ -246,26 +240,20 @@
 
     [Not sure where `$CABALDIR` is?](http://www.haskell.org/haskellwiki/Cabal-Install#The_cabal-install_configuration_file)
 
-5.  If you want to process citations with pandoc, you will also need to
-    install a separate package, `pandoc-citeproc`.  This can be installed
-    using cabal:
-
-        cabal install pandoc-citeproc
-
-    By default `pandoc-citeproc` uses the "i;unicode-casemap" method
+5.  By default `pandoc` uses the "i;unicode-casemap" method
     to sort bibliography entries (RFC 5051).  If you would like to
     use the locale-sensitive unicode collation algorithm instead,
-    specify the `unicode_collation` flag:
+    specify the `icu` flag (which affects the dependency `citeproc`):
 
-        cabal install pandoc-citeproc -funicode_collation
+        cabal install pandoc -ficu
 
     Note that this requires the `text-icu` library, which in turn
     depends on the C library `icu4c`.  Installation directions
     vary by platform.  Here is how it might work on macOS with Homebrew:
 
         brew install icu4c
-        stack install pandoc-citeproc \
-          --flag "pandoc-citeproc:unicode_collation" \
+        stack install pandoc \
+          --flag "citeproc:icu" \
           --extra-lib-dirs=/usr/local/opt/icu4c/lib \
           --extra-include-dirs=/usr/local/opt/icu4c/include
 
@@ -273,8 +261,6 @@
     you where it is installed: you may need to set your `MANPATH`
     accordingly. If `MANUAL.txt` has been modified, the man page can be
     rebuilt: `make man/pandoc.1`.
-
-    The `pandoc-citeproc.1` man page will also be installed automatically.
 
 
 ### Custom cabal method
diff --git a/MANUAL.txt b/MANUAL.txt
--- a/MANUAL.txt
+++ b/MANUAL.txt
@@ -1,7 +1,7 @@
 ---
 title: Pandoc User's Guide
 author: John MacFarlane
-date: November 7, 2020
+date: November 19, 2020
 ---
 
 # Synopsis
@@ -914,7 +914,7 @@
 
 `--no-check-certificate`
 
-:   Disable the certificate verification to allow access to 
+:   Disable the certificate verification to allow access to
     unsecure HTTP resources (for example when the certificate
     is no longer valid or self signed).
 
@@ -963,32 +963,40 @@
     placement of link references is affected by the
     `--reference-location` option.
 
-`--reference-location = block`|`section`|`document`
+`--reference-location=block`|`section`|`document`
 
 :   Specify whether footnotes (and references, if `reference-links` is
     set) are placed at the end of the current (top-level) block, the
     current section, or the document. The default is
     `document`. Currently only affects the markdown writer.
 
+`--markdown-headings=setext`|`atx`
+
+:   Specify whether to use ATX-style (`#`-prefixed) or
+    Setext-style (underlined) headings for level 1 and 2
+    headings in Markdown output.  (The default is `atx`.)
+    ATX-style headings are always used for levels 3+.
+    This option also affects Markdown cells in `ipynb` output.
+
 `--atx-headers`
 
-:   Use ATX-style headings in Markdown output. The default is
-    to use setext-style headings for levels 1 to 2, and then ATX headings.
-    (Note: for `gfm` output, ATX headings are always used.)
-    This option also affects markdown cells in `ipynb` output.
+:   *Deprecated synonym for `--markdown-headings=atx`.*
 
-`--top-level-division=[default|section|chapter|part]`
+`--top-level-division=default`|`section`|`chapter`|`part`
 
-:   Treat top-level headings as the given division type in LaTeX, ConTeXt,
-    DocBook, and  TEI output. The hierarchy order is part, chapter, then section;
-    all headings are shifted such that the top-level heading becomes the specified
-    type. The default behavior is to determine the best division type via
-    heuristics: unless other conditions apply, `section` is chosen. When the
-    `documentclass` variable is set to `report`, `book`, or `memoir` (unless the
-    `article` option is specified), `chapter` is implied as the setting for this
-    option. If `beamer` is the output format, specifying either `chapter` or
-    `part` will cause top-level headings to become `\part{..}`, while
-    second-level headings remain as their default type.
+:   Treat top-level headings as the given division type in
+    LaTeX, ConTeXt, DocBook, and  TEI output. The hierarchy
+    order is part, chapter, then section; all headings are
+    shifted such that the top-level heading becomes the
+    specified type. The default behavior is to determine the
+    best division type via heuristics: unless other conditions
+    apply, `section` is chosen. When the `documentclass`
+    variable is set to `report`, `book`, or `memoir` (unless the
+    `article` option is specified), `chapter` is implied as the
+    setting for this option. If `beamer` is the output format,
+    specifying either `chapter` or `part` will cause top-level
+    headings to become `\part{..}`, while second-level headings
+    remain as their default type.
 
 `-N`, `--number-sections`
 
@@ -1350,23 +1358,26 @@
 
 `--natbib`
 
-:   Use [`natbib`] for citations in LaTeX output.  This option is not for use
-    with the `--citeproc` option or with PDF output.  It is intended for
-    use in producing a LaTeX file that can be processed with [`bibtex`].
+:   Use [`natbib`] for citations in LaTeX output.  This option
+    is not for use with the `--citeproc` option or with PDF
+    output.  It is intended for use in producing a LaTeX file
+    that can be processed with [`bibtex`].
 
 `--biblatex`
 
-:   Use [`biblatex`] for citations in LaTeX output.  This option is not for use
-    with the `--citeproc` option or with PDF output. It is intended for
-    use in producing a LaTeX file that can be processed with [`bibtex`] or [`biber`].
+:   Use [`biblatex`] for citations in LaTeX output.  This option
+    is not for use with the `--citeproc` option or with PDF
+    output. It is intended for use in producing a LaTeX file
+    that can be processed with [`bibtex`] or [`biber`].
 
 ## Math rendering in HTML {.options}
 
-The default is to render TeX math as far as possible using Unicode characters.
-Formulas are put inside a `span` with `class="math"`, so that they may be styled
-differently from the surrounding text if needed. However, this gives acceptable
-results only for basic math, usually you will want to use `--mathjax` or another
-of the following options.
+The default is to render TeX math as far as possible using
+Unicode characters.  Formulas are put inside a `span` with
+`class="math"`, so that they may be styled differently from the
+surrounding text if needed. However, this gives acceptable
+results only for basic math, usually you will want to use
+`--mathjax` or another of the following options.
 
 `--mathjax`[`=`*URL*]
 
@@ -1380,10 +1391,11 @@
 
 `--mathml`
 
-:   Convert TeX math to [MathML] (in `epub3`, `docbook4`, `docbook5`, `jats`,
-    `html4` and `html5`).  This is the default in `odt` output. Note that
-    currently only Firefox and Safari (and select e-book readers) natively
-    support MathML.
+:   Convert TeX math to [MathML] (in `epub3`, `docbook4`,
+    `docbook5`, `jats`, `html4` and `html5`).  This is the
+    default in `odt` output. Note that currently only Firefox
+    and Safari (and select e-book readers) natively support
+    MathML.
 
 `--webtex`[`=`*URL*]
 
@@ -1624,7 +1636,7 @@
 reference-links: true
 # block, section, or document
 reference-location: block
-atx-headers: false
+markdown-headings: setext
 
 # accept, reject, or all
 track-changes: accept
@@ -2099,7 +2111,8 @@
     including a title block in the document itself, you can
     set the `title-meta`, `author-meta`, and `date-meta`
     variables.  (By default these are set automatically, based
-    on `title`, `author`, and `date`.)
+    on `title`, `author`, and `date`.) The page title in HTML
+    is set by `pagetitle`, which is equal to `title` by default.
 
 `subtitle`
 :   document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, and docx
@@ -2173,15 +2186,16 @@
 :   the base script direction, either `rtl` (right-to-left)
     or `ltr` (left-to-right).
 
-    For bidirectional documents, native pandoc `span`s and `div`s
-    with the `dir` attribute (value `rtl` or `ltr`) can be used to
-    override the base direction in some output formats.
-    This may not always be necessary if the final renderer
-    (e.g. the browser, when generating HTML) supports the
-    [Unicode Bidirectional Algorithm].
+    For bidirectional documents, native pandoc `span`s and
+    `div`s with the `dir` attribute (value `rtl` or `ltr`) can
+    be used to override the base direction in some output
+    formats.  This may not always be necessary if the final
+    renderer (e.g. the browser, when generating HTML) supports
+    the [Unicode Bidirectional Algorithm].
 
-    When using LaTeX for bidirectional documents, only the `xelatex` engine
-    is fully supported (use `--pdf-engine=xelatex`).
+    When using LaTeX for bidirectional documents, only the
+    `xelatex` engine is fully supported (use
+    `--pdf-engine=xelatex`).
 
 [BCP 47]: https://tools.ietf.org/html/bcp47
 [Unicode Bidirectional Algorithm]: https://www.w3.org/International/articles/inline-bidi-markup/uba-basics
@@ -2253,8 +2267,9 @@
 ### Variables for HTML math
 
 `classoption`
-:   when using [KaTeX](#option--katex), you can render display math equations
-    flush left using [YAML metadata](#layout) or with `-M classoption=fleqn`.
+:   when using [KaTeX](#option--katex), you can render display
+math equations flush left using [YAML metadata](#layout) or with
+`-M classoption=fleqn`.
 
 ### Variables for HTML slides
 
@@ -2366,9 +2381,10 @@
         ...
 
 `documentclass`
-:   document class: usually one of the standard classes, [`article`], [`book`],
-    and [`report`]; the [KOMA-Script] equivalents, `scrartcl`, `scrbook`,
-    and `scrreprt`, which default to smaller margins; or [`memoir`]
+:   document class: usually one of the standard classes,
+    [`article`], [`book`], and [`report`]; the [KOMA-Script]
+    equivalents, `scrartcl`, `scrbook`, and `scrreprt`, which
+    default to smaller margins; or [`memoir`]
 
 `geometry`
 :   option for [`geometry`] package, e.g. `margin=1in`;
@@ -2393,8 +2409,9 @@
         ...
 
 `indent`
-:   if true, pandoc will use document class settings for indentation (the default LaTeX template
-    otherwise removes indentation and adds space between paragraphs)
+:   if true, pandoc will use document class settings for
+    indentation (the default LaTeX template otherwise removes
+    indentation and adds space between paragraphs)
 
 `linestretch`
 :   adjusts line spacing using the [`setspace`]
@@ -2419,8 +2436,8 @@
 #### Fonts
 
 `fontenc`
-:   allows font encoding to be specified through `fontenc` package (with `pdflatex`);
-    default is `T1` (see [LaTeX font encodings guide])
+:   allows font encoding to be specified through `fontenc` package (with
+    `pdflatex`); default is `T1` (see [LaTeX font encodings guide])
 
 `fontfamily`
 :   font package for use with `pdflatex`:
@@ -2490,7 +2507,8 @@
 :   contents of acknowledgments footnote after document title
 
 `toc`
-:   include table of contents (can also be set using `--toc/--table-of-contents`)
+:   include table of contents (can also be set using
+    `--toc/--table-of-contents`)
 
 `toc-depth`
 :   level of section to include in table of contents
@@ -2532,12 +2550,12 @@
 :   font size for body text (e.g. `10pt`, `12pt`)
 
 `headertext`, `footertext`
-:   text to be placed in running header or footer (see [ConTeXt Headers and Footers]);
-    repeat up to four times for different placement
+:   text to be placed in running header or footer (see [ConTeXt Headers and
+    Footers]); repeat up to four times for different placement
 
 `indenting`
-:   controls indentation of paragraphs, e.g. `yes,small,next` (see [ConTeXt Indentation]);
-    repeat for multiple options
+:   controls indentation of paragraphs, e.g. `yes,small,next` (see
+    [ConTeXt Indentation]); repeat for multiple options
 
 `interlinespace`
 :   adjusts line spacing, e.g. `4ex` (using [`setupinterlinespace`]);
@@ -2548,16 +2566,19 @@
     repeat for multiple options
 
 `linkcolor`, `contrastcolor`
-:   color for links outside and inside a page, e.g. `red`, `blue` (see [ConTeXt Color])
+:   color for links outside and inside a page, e.g. `red`, `blue` (see
+    [ConTeXt Color])
 
 `linkstyle`
-:   typeface style for links, e.g. `normal`, `bold`, `slanted`, `boldslanted`, `type`, `cap`, `small`
+:   typeface style for links, e.g. `normal`, `bold`, `slanted`, `boldslanted`,
+    `type`, `cap`, `small`
 
 `lof`, `lot`
 :   include list of figures, list of tables
 
 `mainfont`, `sansfont`, `monofont`, `mathfont`
-:   font families: take the name of any system font (see [ConTeXt Font Switching])
+:   font families: take the name of any system font (see
+    [ConTeXt Font Switching])
 
 `margin-left`, `margin-right`, `margin-top`, `margin-bottom`
 :   sets margins, if `layout` is not used (otherwise `layout`
@@ -2572,16 +2593,18 @@
     repeat for multiple options
 
 `pdfa`
-:   adds to the preamble the setup necessary to generate PDF/A of the type
-    specified, e.g. `1a:2005`, `2a`. If no type is specified (i.e. the value
-    is set to True, by e.g. `--metadata=pdfa` or `pdfa: true` in a YAML metadata
-    block), `1b:2005` will be used as default, for reasons of backwards
-    compatibility. Using `--variable=pdfa` without specified value is not supported.
-    To successfully generate PDF/A the required ICC color profiles have to
-    be available and the content and all included files (such as images)
-    have to be standard conforming.  The ICC profiles and output intent
-    may be specified using the variables `pdfaiccprofile` and `pdfaintent`.
-    See also [ConTeXt PDFA] for more details.
+:   adds to the preamble the setup necessary to generate PDF/A
+    of the type specified, e.g. `1a:2005`, `2a`. If no type is
+    specified (i.e. the value is set to True, by e.g.
+    `--metadata=pdfa` or `pdfa: true` in a YAML metadata block),
+    `1b:2005` will be used as default, for reasons of backwards
+    compatibility. Using `--variable=pdfa` without specified value
+    is not supported.  To successfully generate PDF/A the required
+    ICC color profiles have to be available and the content and all
+    included files (such as images) have to be standard conforming.
+    The ICC profiles and output intent may be specified using the
+    variables `pdfaiccprofile` and `pdfaintent`.  See also [ConTeXt
+    PDFA] for more details.
 
 `pdfaiccprofile`
 :   when used in conjunction with `pdfa`, specifies the ICC profile to use
@@ -2596,10 +2619,12 @@
     If left unspecified, `sRGB IEC61966-2.1` is used as default.
 
 `toc`
-:   include table of contents (can also be set using `--toc/--table-of-contents`)
+:   include table of contents (can also be set using
+    `--toc/--table-of-contents`)
 
 `whitespace`
-:   spacing between paragraphs, e.g. `none`, `small` (using [`setupwhitespace`])
+:   spacing between paragraphs, e.g. `none`, `small` (using
+    [`setupwhitespace`])
 
 `includesource`
 :   include all source documents as file attachments in the PDF file
@@ -3028,8 +3053,8 @@
 
 #### Extension: `citations` {#org-citations}
 
-Some aspects of [Pandoc's Markdown citation syntax](#citations) are also accepted
-in `org` input.
+Some aspects of [Pandoc's Markdown citation syntax](#citations)
+are also accepted in `org` input.
 
 #### Extension: `ntb` ####
 
@@ -3137,7 +3162,8 @@
 
 ### Heading identifiers ###
 
-See also the [`auto_identifiers` extension](#extension-auto_identifiers) above.
+See also the [`auto_identifiers`
+extension](#extension-auto_identifiers) above.
 
 #### Extension: `header_attributes` ####
 
@@ -3259,11 +3285,12 @@
 
 #### Extension: `blank_before_blockquote` ####
 
-Standard Markdown syntax does not require a blank line before a block
-quote.  Pandoc does require this (except, of course, at the beginning of the
-document). The reason for the requirement is that it is all too easy for a
-`>` to end up at the beginning of a line by accident (perhaps through line
-wrapping). So, unless the `markdown_strict` format is used, the following does
+Standard Markdown syntax does not require a blank line before a
+block quote.  Pandoc does require this (except, of course, at
+the beginning of the document). The reason for the requirement
+is that it is all too easy for a `>` to end up at the beginning
+of a line by accident (perhaps through line wrapping). So,
+unless the `markdown_strict` format is used, the following does
 not produce a nested block quote in pandoc:
 
     > This is a block quote.
@@ -3332,14 +3359,16 @@
                    qsort (filter (>= x) xs)
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-Here `mycode` is an identifier, `haskell` and `numberLines` are classes, and
-`startFrom` is an attribute with value `100`. Some output formats can use this
-information to do syntax highlighting. Currently, the only output formats
-that uses this information are HTML, LaTeX, Docx, Ms, and PowerPoint. If
-highlighting is supported for your output format and language, then the code
-block above will appear highlighted, with numbered lines. (To see which
-languages are supported, type `pandoc --list-highlight-languages`.) Otherwise,
-the code block above will appear as follows:
+Here `mycode` is an identifier, `haskell` and `numberLines` are
+classes, and `startFrom` is an attribute with value `100`. Some
+output formats can use this information to do syntax
+highlighting. Currently, the only output formats that uses this
+information are HTML, LaTeX, Docx, Ms, and PowerPoint. If
+highlighting is supported for your output format and language,
+then the code block above will appear highlighted, with numbered
+lines. (To see which languages are supported, type `pandoc
+--list-highlight-languages`.) Otherwise, the code block above
+will appear as follows:
 
     <pre id="mycode" class="haskell numberLines" startFrom="100">
       <code>
@@ -3605,11 +3634,12 @@
 A definition begins with a colon or tilde, which may be indented one
 or two spaces.
 
-A term may have multiple definitions, and each definition may consist of one or
-more block elements (paragraph, code block, list, etc.), each indented four
-spaces or one tab stop.  The body of the definition (including the first line,
-aside from the colon or tilde) should be indented four spaces. However,
-as with other Markdown lists, you can "lazily" omit indentation except
+A term may have multiple definitions, and each definition may
+consist of one or more block elements (paragraph, code block,
+list, etc.), each indented four spaces or one tab stop.  The
+body of the definition (including the first line, aside from the
+colon or tilde) should be indented four spaces. However, as with
+other Markdown lists, you can "lazily" omit indentation except
 at the beginning of a paragraph or other block element:
 
     Term 1
@@ -3637,7 +3667,8 @@
 hard wrapping, can be activated with `compact_definition_lists`: see
 [Non-pandoc extensions], below.)
 
-[^3]:  I have been influenced by the suggestions of [David Wheeler](https://justatheory.com/2009/02/modest-markdown-proposal/).
+[^3]:  I have been influenced by the suggestions of [David
+  Wheeler](https://justatheory.com/2009/02/modest-markdown-proposal/).
 
 ### Numbered example lists ###
 
@@ -5266,11 +5297,11 @@
 editing styles].
 
 The `--citation-abbreviations` option (or the
-`citation-abbreviations` metadata field) may be used to
-specify a JSON file containing abbreviations of journals
-that should be used in formatted bibliographies when
-`form="short"` is specified.  The format of the file
-can be illustrated with an example:
+`citation-abbreviations` metadata field) may be used to specify
+a JSON file containing abbreviations of journals that should be
+used in formatted bibliographies when `form="short"` is
+specified.  The format of the file can be illustrated with an
+example:
 
 
     { "default": {
@@ -5360,7 +5391,7 @@
 
 A few other metadata fields affect bibliography formatting:
 
-`link-citation`
+`link-citations`
 :   If true, citations will be
     hyperlinked to the corresponding bibliography entries
     (for author-date and numerical styles only).
@@ -5436,18 +5467,21 @@
 
 where `FORMAT` is either `s5`, `slidy`, `slideous`, `dzslides`, or `revealjs`.
 
-For Slidy, Slideous, reveal.js, and S5, the file produced by pandoc with the
-`-s/--standalone` option embeds a link to JavaScript and CSS files, which are
-assumed to be available at the relative path `s5/default` (for S5), `slideous`
-(for Slideous), `reveal.js` (for reveal.js), or at the Slidy website at
-`w3.org` (for Slidy).  (These paths can be changed by setting the `slidy-url`,
-`slideous-url`, `revealjs-url`, or `s5-url` variables; see [Variables for HTML slides],
-above.) For DZSlides, the (relatively short) JavaScript and CSS are included in
-the file by default.
+For Slidy, Slideous, reveal.js, and S5, the file produced by
+pandoc with the `-s/--standalone` option embeds a link to
+JavaScript and CSS files, which are assumed to be available at
+the relative path `s5/default` (for S5), `slideous` (for
+Slideous), `reveal.js` (for reveal.js), or at the Slidy website
+at `w3.org` (for Slidy).  (These paths can be changed by setting
+the `slidy-url`, `slideous-url`, `revealjs-url`, or `s5-url`
+variables; see [Variables for HTML slides], above.) For
+DZSlides, the (relatively short) JavaScript and CSS are included
+in the file by default.
 
-With all HTML slide formats, the `--self-contained` option can be used to
-produce a single file that contains all of the data necessary to display the
-slide show, including linked scripts, stylesheets, images, and videos.
+With all HTML slide formats, the `--self-contained` option can
+be used to produce a single file that contains all of the data
+necessary to display the slide show, including linked scripts,
+stylesheets, images, and videos.
 
 To produce a PDF slide show using beamer, type
 
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -3,8 +3,7 @@
 pandoc --lua-filter tools/update-readme.lua README.template -o README.md
 -->
 
-Pandoc
-======
+# Pandoc
 
 [![github
 release](https://img.shields.io/github/release/jgm/pandoc.svg?label=current+release)](https://github.com/jgm/pandoc/releases)
@@ -19,8 +18,7 @@
 [![pandoc-discuss on google
 groups](https://img.shields.io/badge/pandoc-discuss-red.svg?style=social)](https://groups.google.com/forum/#!forum/pandoc-discuss)
 
-The universal markup converter
-------------------------------
+## The universal markup converter
 
 Pandoc is a [Haskell](http://haskell.org) library for converting from
 one markup format to another, and a command-line tool that uses this
@@ -217,13 +215,11 @@
 perfect, conversions from formats more expressive than pandoc’s Markdown
 can be expected to be lossy.
 
-Installing
-----------
+## Installing
 
 Here’s [how to install pandoc](INSTALL.md).
 
-Documentation
--------------
+## Documentation
 
 Pandoc’s website contains a full [User’s
 Guide](https://pandoc.org/MANUAL.html). It is also available
@@ -232,15 +228,13 @@
 pandoc](https://pandoc.org/demos.html) and a limited [online
 demo](https://pandoc.org/try).
 
-Contributing
-------------
+## Contributing
 
 Pull requests, bug reports, and feature requests are welcome. Please
 make sure to read [the contributor guidelines](CONTRIBUTING.md) before
 opening a new issue.
 
-License
--------
+## License
 
 © 2006-2020 John MacFarlane (jgm@berkeley.edu). Released under the
 [GPL](http://www.gnu.org/copyleft/gpl.html "GNU General Public License"),
diff --git a/changelog.md b/changelog.md
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,125 @@
 # Revision history for pandoc
 
+## pandoc 2.11.2 (2020-11-19)
+
+  * Default to using ATX (`##`-style) headings for Markdown output
+    (#6662, Aner Lucero).  Previously we used Setext (underlined) headings
+    by default for levels 1--2.
+
+  * Add option `--markdown-headings=atx|setext`, and deprecate
+    `--atx-headers` (#6662, Aner Lucero).
+
+  * Support `markdown-headings` in defaults files.
+
+  * Fix corner case in YAML metadata parsing (#6823).  Previously YAML
+    metadata would sometimes not get recognized if a field ended with a
+    newline followed by spaces.
+
+  * `--self-contained`: increase coverage (#6854).
+    Previously we only self-contained attributes for certain tag names
+    (`img`, `embed`, `video`, `input`, `audio`, `source`, `track`,
+    `section`).  Now we self-contain any occurrence of `src`,
+    `data-src`, `poster`, or `data-background-image`, on any tag; and
+    also `href` on `link` tags.
+
+  * Markdown reader:
+
+    + Fix detection of locators following in-text citations.
+      Prevously, if we had `@foo [p. 33; @bar]`, the `p. 33` would be
+      incorrectly parsed as a prefix of `@bar` rather than a suffix of
+      `@foo`.
+    + Improve period suppression algorithm for citations in notes
+      in note citation styles (#6835).
+    + Don't increment `stateNoteNumber` for example list references.
+      This helps with #6836 (a bug in which example list references
+      disturb calculation of citation note number and affect when
+      `ibid` is triggered).
+
+  * LaTeX reader:
+
+    + Move `getNextNumber` from Readers.LaTeX to Readers.LaTeX.Parsing.
+    + Fix negative numbers in siunitx commands.  A change in pandoc 2.11
+      broke negative numbers, e.g.  `\SI{-33}{\celcius}` or `\num{-3}`.
+      This fixes the regression.
+
+  * DocBook reader: drop period in formalpara title
+    and put it in a div with class `formalpara-title`, so that
+    people can reformat with filters (#6562).
+
+  * Man reader: improve handling of `.IP` (#6858).  We now better handle
+    `.IP` when it is used with non-bullet, non-numbered lists, creating a
+    definition list.  We also skip blank lines like groff itself.
+
+  * Bibtex reader: fall back on `en-US` if locale for LANG not found.
+    This reproduces earlier pandoc-citeproc behavior (jgm/citeproc#26).
+
+  * JATS writer:
+
+    + Wrap all tables (Albert Krewinkel).
+      All `<table>` elements are put inside `<table-wrap>` elements, as the
+      former are not valid as immediate child elements of `<body>`.
+    + Move Table handling to separate module (Albert Krewinkel).
+      Adds two new unexported modules:
+      Text.Pandoc.Writers.JATS.Types, Text.Pandoc.Writers.JATS.Table.
+
+  * Org writer:
+
+    + Replace org #+KEYWORDS with #+keywords (TEC).
+      As of ~2 years ago, lower case keywords became the standard (though
+      they are handled case insensitive, as always).
+    + Update org supported languages and identifiers according to the
+      current list contained in
+      <https://orgmode.org/worg/org-contrib/babel/languages/index.html>
+      (TEC).
+
+  * Only use `filterIpynbOutput` if input format is ipynb (#6841).
+    Before this change content could go missing from divs with class
+    `output`, even when non-ipynb was being converted.
+
+  * When checking reader/writer name, check base name now that we permit
+    extensions on formats other than markdown.
+
+  * Text.Pandoc.PDF: Fix `changePathSeparators` for Windows (#6173).
+    Previously a path beginning with a drive, like `C:\foo\bar`, was
+    translated to `C:\/foo/bar`, which caused problems.
+    With this fix, the backslashes are removed.
+
+  * Text.Pandoc.Logging: Add constructor `ATXHeadingInLHS` constructor
+    to `LogMessage` [API change].
+
+  * Fix error that is given when people specify `doc` output (#6834,
+    gison93).
+
+  * LaTeX template:  add a `\break` after parbox in `CSLRightInline`.
+    This should fix spacing problems between entries with numeric styles.
+    Also fix number of params on `CSLReferences`.
+
+  * reveal.js template: Put quotes around `controlsLayout`,
+    `controlsBackArrows`, and `display`, since these require strings.
+    Add `showSlideNumber`, `hashOneBasedIndex`, `pause`.
+
+  * Use citeproc 0.2.  This fixes a bug with title case around parentheses.
+
+  * pandoc.cabal: remove 'static' flag.
+    This isn't really necessary and can be misleading (e.g. on macOS,
+    where a fully static build isn't possible). cabal's new option
+    `--enable-executable-static` does the same. On stack you can add
+    something like this to the options for your executable in package.yaml:
+
+        ld-options: -static -pthread
+
+  * Remove obsolete bibutils flag setting in `linux/make_artifacts.sh`.
+
+  * Manual:
+
+    + Correct `link-citation` -> `link-citations`.
+    + Add a sentence about `pagetitle` for HTML (#6843, Alex Toldaiev).
+
+  * INSTALL.md: Remove references to `pandoc-citeproc` (#6857).
+
+  * CONTRIBUTING: describe hlint and how it's used (#6840, Albert
+    Krewinkel).
+
 ## pandoc 2.11.1.1 (2020-11-07)
 
   * Citeproc: improve punctuation in in-text note citations (#6813).
diff --git a/data/templates/default.latex b/data/templates/default.latex
--- a/data/templates/default.latex
+++ b/data/templates/default.latex
@@ -373,7 +373,7 @@
 \setlength{\cslhangindent}{1.5em}
 \newlength{\csllabelwidth}
 \setlength{\csllabelwidth}{3em}
-\newenvironment{CSLReferences}[3] % #1 hanging-ident, #2 entry spacing
+\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
  {% don't indent paragraphs
   \setlength{\parindent}{0pt}
   % turn on hanging indent if param 1 is 1
@@ -387,7 +387,7 @@
 \usepackage{calc}
 \newcommand{\CSLBlock}[1]{#1\hfill\break}
 \newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
-\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}}
+\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
 \newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
 $endif$
 
diff --git a/data/templates/default.org b/data/templates/default.org
--- a/data/templates/default.org
+++ b/data/templates/default.org
@@ -1,12 +1,12 @@
 $if(title)$
-#+TITLE: $title$
+#+title: $title$
 
 $endif$
 $if(author)$
-#+AUTHOR: $for(author)$$author$$sep$; $endfor$
+#+author: $for(author)$$author$$sep$; $endfor$
 $endif$
 $if(date)$
-#+DATE: $date$
+#+date: $date$
 
 $endif$
 $for(header-includes)$
diff --git a/data/templates/default.revealjs b/data/templates/default.revealjs
--- a/data/templates/default.revealjs
+++ b/data/templates/default.revealjs
@@ -93,12 +93,12 @@
 $endif$
 $if(controlsLayout)$
         // Determines where controls appear, "edges" or "bottom-right"
-        controlsLayout: $controlsLayout$,
+        controlsLayout: '$controlsLayout$',
 $endif$
 $if(controlsBackArrows)$
         // Visibility rule for backwards navigation arrows; "faded", "hidden"
         // or "visible"
-        controlsBackArrows: $controlsBackArrows$,
+        controlsBackArrows: '$controlsBackArrows$',
 $endif$
 $if(progress)$
         // Display a presentation progress bar
@@ -108,17 +108,21 @@
         // Display the page number of the current slide
         slideNumber: $slideNumber$,
 $endif$
+$if(showSlideNumber)$
+        // 'all', 'print', or 'speaker'
+        showSlideNumber: '$showSlideNumber$',
+$endif$
 $if(hash)$
         // Add the current slide number to the URL hash so that reloading the
         // page/copying the URL will return you to the same slide
         hash: $hash$,
 $endif$
-        // Push each slide change to the browser history
-$if(history)$
-        history: $history$,
-$else$
-        history: true,
+$if(hashOneBasedIndex)$
+        // Start with 1 for the hash rather than 0
+        hashOneBasedIndex: $hashOneBasedIndex$,
 $endif$
+        // Push each slide change to the browser history
+        history: $if(history)$$history$$else$true$endif$,
 $if(keyboard)$
         // Enable keyboard shortcuts for navigation
         keyboard: $keyboard$,
@@ -170,6 +174,10 @@
         // key is pressed
         help: $help$,
 $endif$
+$if(pause)$
+       // Flags if it should be possible to pause the presentation (blackout)
+       pause: $pause$,
+$endif$
 $if(showNotes)$
         // Flags if speaker notes should be visible to all viewers
         showNotes: $showNotes$,
@@ -317,7 +325,7 @@
 $endif$
 $if(display)$
         // The display mode that will be used to show slides
-        display: $display$,
+        display: '$display$',
 $endif$
 $if(mathjax)$
         math: {
diff --git a/man/pandoc.1 b/man/pandoc.1
--- a/man/pandoc.1
+++ b/man/pandoc.1
@@ -1,7 +1,7 @@
 '\" t
-.\" Automatically generated by Pandoc 2.11.1
+.\" Automatically generated by Pandoc 2.11.2
 .\"
-.TH "Pandoc User\[cq]s Guide" "" "November 7, 2020" "pandoc 2.11.1.1" ""
+.TH "Pandoc User\[cq]s Guide" "" "November 19, 2020" "pandoc 2.11.2" ""
 .hy
 .SH NAME
 pandoc - general markup converter
@@ -1000,21 +1000,24 @@
 The placement of link references is affected by the
 \f[C]--reference-location\f[R] option.
 .TP
-\f[B]\f[CB]--reference-location = block\f[B]\f[R]|\f[B]\f[CB]section\f[B]\f[R]|\f[B]\f[CB]document\f[B]\f[R]
+\f[B]\f[CB]--reference-location=block\f[B]\f[R]|\f[B]\f[CB]section\f[B]\f[R]|\f[B]\f[CB]document\f[B]\f[R]
 Specify whether footnotes (and references, if \f[C]reference-links\f[R]
 is set) are placed at the end of the current (top-level) block, the
 current section, or the document.
 The default is \f[C]document\f[R].
 Currently only affects the markdown writer.
 .TP
+\f[B]\f[CB]--markdown-headings=setext\f[B]\f[R]|\f[B]\f[CB]atx\f[B]\f[R]
+Specify whether to use ATX-style (\f[C]#\f[R]-prefixed) or Setext-style
+(underlined) headings for level 1 and 2 headings in Markdown output.
+(The default is \f[C]atx\f[R].) ATX-style headings are always used for
+levels 3+.
+This option also affects Markdown cells in \f[C]ipynb\f[R] output.
+.TP
 \f[B]\f[CB]--atx-headers\f[B]\f[R]
-Use ATX-style headings in Markdown output.
-The default is to use setext-style headings for levels 1 to 2, and then
-ATX headings.
-(Note: for \f[C]gfm\f[R] output, ATX headings are always used.) This
-option also affects markdown cells in \f[C]ipynb\f[R] output.
+\f[I]Deprecated synonym for \f[CI]--markdown-headings=atx\f[I].\f[R]
 .TP
-\f[B]\f[CB]--top-level-division=[default|section|chapter|part]\f[B]\f[R]
+\f[B]\f[CB]--top-level-division=default\f[B]\f[R]|\f[B]\f[CB]section\f[B]\f[R]|\f[B]\f[CB]chapter\f[B]\f[R]|\f[B]\f[CB]part\f[B]\f[R]
 Treat top-level headings as the given division type in LaTeX, ConTeXt,
 DocBook, and TEI output.
 The hierarchy order is part, chapter, then section; all headings are
@@ -1839,7 +1842,7 @@
 reference-links: true
 # block, section, or document
 reference-location: block
-atx-headers: false
+markdown-headings: setext
 
 # accept, reject, or all
 track-changes: accept
@@ -2365,7 +2368,8 @@
 \f[C]title-meta\f[R], \f[C]author-meta\f[R], and \f[C]date-meta\f[R]
 variables.
 (By default these are set automatically, based on \f[C]title\f[R],
-\f[C]author\f[R], and \f[C]date\f[R].)
+\f[C]author\f[R], and \f[C]date\f[R].) The page title in HTML is set by
+\f[C]pagetitle\f[R], which is equal to \f[C]title\f[R] by default.
 .RE
 .TP
 \f[B]\f[CB]subtitle\f[B]\f[R]
@@ -2888,10 +2892,10 @@
 \f[B]\f[CB]pdfa\f[B]\f[R]
 adds to the preamble the setup necessary to generate PDF/A of the type
 specified, e.g.\ \f[C]1a:2005\f[R], \f[C]2a\f[R].
-If no type is specified (i.e.\ the value is set to True, by
-e.g.\ \f[C]--metadata=pdfa\f[R] or \f[C]pdfa: true\f[R] in a YAML
-metadata block), \f[C]1b:2005\f[R] will be used as default, for reasons
-of backwards compatibility.
+If no type is specified (i.e.\ the value is set to True, by e.g.
+\f[C]--metadata=pdfa\f[R] or \f[C]pdfa: true\f[R] in a YAML metadata
+block), \f[C]1b:2005\f[R] will be used as default, for reasons of
+backwards compatibility.
 Using \f[C]--variable=pdfa\f[R] without specified value is not
 supported.
 To successfully generate PDF/A the required ICC color profiles have to
@@ -6314,7 +6318,7 @@
 .PP
 A few other metadata fields affect bibliography formatting:
 .TP
-\f[B]\f[CB]link-citation\f[B]\f[R]
+\f[B]\f[CB]link-citations\f[B]\f[R]
 If true, citations will be hyperlinked to the corresponding bibliography
 entries (for author-date and numerical styles only).
 .TP
diff --git a/pandoc.cabal b/pandoc.cabal
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -1,6 +1,6 @@
 cabal-version:   2.2
 name:            pandoc
-version:         2.11.1.1
+version:         2.11.2
 build-type:      Simple
 license:         GPL-2.0-or-later
 license-file:    COPYING.md
@@ -376,10 +376,6 @@
   type:          git
   location:      git://github.com/jgm/pandoc.git
 
-flag static
-  Description:   Use static linking for pandoc executable.
-  Default:       False
-
 flag embed_data_files
   Description:   Embed data files in binary for relocatable executable.
   Default:       False
@@ -404,7 +400,7 @@
                  blaze-markup          >= 0.8      && < 0.9,
                  bytestring            >= 0.9      && < 0.12,
                  case-insensitive      >= 1.2      && < 1.3,
-                 citeproc              >= 0.1.1.1  && < 0.2,
+                 citeproc              >= 0.2      && < 0.3,
                  commonmark            >= 0.1.1.2  && < 0.2,
                  commonmark-extensions >= 0.2.0.4  && < 0.3,
                  commonmark-pandoc     >= 0.2      && < 0.3,
@@ -629,6 +625,8 @@
                    Text.Pandoc.Readers.Metadata,
                    Text.Pandoc.Readers.Roff,
                    Text.Pandoc.Writers.Docx.StyleMap,
+                   Text.Pandoc.Writers.JATS.Table,
+                   Text.Pandoc.Writers.JATS.Types,
                    Text.Pandoc.Writers.Roff,
                    Text.Pandoc.Writers.Powerpoint.Presentation,
                    Text.Pandoc.Writers.Powerpoint.Output,
@@ -679,8 +677,6 @@
      hs-source-dirs: prelude
      other-modules:  Prelude
      build-depends:  base-compat >= 0.9
-  if flag(static)
-    ld-options:     -static
   default-language: Haskell2010
   other-extensions: NoImplicitPrelude
   hs-source-dirs:  .
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
@@ -131,9 +131,10 @@
                                  (map (T.pack . takeExtension) sources) "markdown"
                              return "markdown"
 
+    let readerNameBase = T.takeWhile (\c -> c /= '+' && c /= '-') readerName
     let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"
 
-    when (pdfOutput && readerName == "latex") $
+    when (pdfOutput && readerNameBase == "latex") $
       case optInputFiles opts of
         Just (inputFile:_) -> report $ UnusualConversion $ T.pack $
           "to convert a .tex file to PDF, you get better results by using pdflatex "
@@ -144,8 +145,8 @@
     (reader :: Reader PandocIO, readerExts) <- getReader readerName
 
     let convertTabs = tabFilter (if optPreserveTabs opts ||
-                                      readerName == "t2t" ||
-                                      readerName == "man"
+                                      readerNameBase == "t2t" ||
+                                      readerNameBase == "man"
                                     then 0
                                     else optTabStop opts)
 
@@ -159,11 +160,12 @@
     let format = outputFormat outputSettings
     let writer = outputWriter outputSettings
     let writerName = outputWriterName outputSettings
+    let writerNameBase = T.takeWhile (\c -> c /= '+' && c /= '-') writerName
     let writerOptions = outputWriterOptions outputSettings
 
-    let bibOutput = writerName == "bibtex" ||
-                    writerName == "biblatex" ||
-                    writerName == "csljson"
+    let bibOutput = writerNameBase == "bibtex" ||
+                    writerNameBase == "biblatex" ||
+                    writerNameBase == "csljson"
 
     let standalone = optStandalone opts ||
                      not (isTextFormat format) ||
@@ -239,6 +241,7 @@
                          then (eastAsianLineBreakFilter :)
                          else id) .
                      (case optIpynbOutput opts of
+                       _ | readerNameBase /= "ipynb" -> id
                        IpynbOutputAll  -> id
                        IpynbOutputNone -> (filterIpynbOutput Nothing :)
                        IpynbOutputBest -> (filterIpynbOutput (Just $
@@ -255,7 +258,7 @@
         sourceToDoc sources' =
            case reader of
                 TextReader r
-                  | optFileScope opts || readerName == "json" ->
+                  | optFileScope opts || readerNameBase == "json" ->
                       mconcat <$> mapM (readSource >=> r readerOpts) sources'
                   | otherwise ->
                       readSources sources' >>= r readerOpts
@@ -263,8 +266,8 @@
                   mconcat <$> mapM (readFile' >=> r readerOpts) sources'
 
 
-    when (readerName == "markdown_github" ||
-          writerName == "markdown_github") $
+    when (readerNameBase == "markdown_github" ||
+          writerNameBase == "markdown_github") $
       report $ Deprecated "markdown_github" "Use gfm instead."
 
     mapM_ (uncurry setRequestHeader) (optRequestHeaders opts)
diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs
--- a/src/Text/Pandoc/App/CommandLineOptions.hs
+++ b/src/Text/Pandoc/App/CommandLineOptions.hs
@@ -529,8 +529,25 @@
 
     , Option "" ["atx-headers"]
                  (NoArg
-                  (\opt -> return opt { optSetextHeaders = False } ))
+                  (\opt -> do
+                    deprecatedOption "--atx-headers"
+                      "Use --markdown-headings=atx instead."
+                    return opt { optSetextHeaders = False } ))
                  "" -- "Use atx-style headers for markdown"
+
+    , Option "" ["markdown-headings"]
+                  (ReqArg
+                    (\arg opt -> do
+                      headingFormat <- case arg of
+                        "setext" -> pure True
+                        "atx" -> pure False
+                        _ -> E.throwIO $ PandocOptionError $ T.pack
+                          ("Unknown markdown heading format: " ++ arg ++
+                            ". Expecting atx or setext")
+                      pure opt { optSetextHeaders = headingFormat }
+                    )
+                  "setext|atx")
+                  ""
 
     , Option "" ["listings"]
                  (NoArg
diff --git a/src/Text/Pandoc/App/Opt.hs b/src/Text/Pandoc/App/Opt.hs
--- a/src/Text/Pandoc/App/Opt.hs
+++ b/src/Text/Pandoc/App/Opt.hs
@@ -330,6 +330,12 @@
       parseYAML v >>= \x -> return (\o -> o{ optSlideLevel = x })
     "atx-headers" ->
       parseYAML v >>= \x -> return (\o -> o{ optSetextHeaders = not x })
+    "markdown-headings" ->
+      parseYAML v >>= \x -> return (\o ->
+        case T.toLower x of
+          "atx"    -> o{ optSetextHeaders = False }
+          "setext" -> o{ optSetextHeaders = True }
+          _        -> o)
     "ascii" ->
       parseYAML v >>= \x -> return (\o -> o{ optAscii = x })
     "default-image-extension" ->
@@ -469,7 +475,7 @@
     , optPdfEngine             = Nothing
     , optPdfEngineOpts         = []
     , optSlideLevel            = Nothing
-    , optSetextHeaders         = True
+    , optSetextHeaders         = False
     , optAscii                 = False
     , optDefaultImageExtension = ""
     , optExtractMedia          = Nothing
diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs
--- a/src/Text/Pandoc/Citeproc.hs
+++ b/src/Text/Pandoc/Citeproc.hs
@@ -532,7 +532,9 @@
       = Cite cs (concatMap noteInParens ils) : go zs
   go (x:xs) = x : go xs
   needsPeriod [] = True
-  needsPeriod (Str t:_) = not (T.null t) && isUpper (T.head t)
+  needsPeriod (Str t:_) = case T.uncons t of
+                            Nothing    -> False
+                            Just (c,_) -> isUpper c
   needsPeriod (Space:zs) = needsPeriod zs
   needsPeriod _ = False
   noteInParens (Note bs')
@@ -555,6 +557,25 @@
 removeFinalPeriod :: [Inline] -> [Inline]
 removeFinalPeriod ils =
   case lastMay ils of
+    Just (Span attr ils')
+      -> initSafe ils ++ [Span attr (removeFinalPeriod ils')]
+    Just (Emph ils')
+      -> initSafe ils ++ [Emph (removeFinalPeriod ils')]
+    Just (Strong ils')
+      -> initSafe ils ++ [Strong (removeFinalPeriod ils')]
+    Just (SmallCaps ils')
+      -> initSafe ils ++ [SmallCaps (removeFinalPeriod ils')]
     Just (Str t)
       | T.takeEnd 1 t == "." -> initSafe ils ++ [Str (T.dropEnd 1 t)]
+      | isRightQuote (T.takeEnd 1 t)
+        -> removeFinalPeriod
+             (initSafe ils ++ [Str tInit | not (T.null tInit)]) ++ [Str tEnd]
+             where
+               tEnd  = T.takeEnd 1 t
+               tInit = T.dropEnd 1 t
     _ -> ils
+ where
+  isRightQuote "\8221" = True
+  isRightQuote "\8217" = True
+  isRightQuote "\187"  = True
+  isRightQuote _       = False
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
@@ -137,7 +137,7 @@
                   " -t latex|beamer|context|ms|html5" <>
                  "\nand specify an output file with " <>
                  ".pdf extension (-o filename.pdf)."
-         "doc" -> "\nPandoc can convert to DOCX, but not from DOC."
+         "doc" -> "\nPandoc can convert to DOCX, but not to DOC."
          _     -> ""
     PandocUnsupportedExtensionError ext f -> err 23 $
       "The extension " <> ext <> " is not supported " <>
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
@@ -31,6 +31,7 @@
 import qualified Data.ByteString.Lazy as BL
 import Data.Data (Data, toConstr)
 import qualified Data.Text as Text
+import Data.Text (Text)
 import Data.Typeable (Typeable)
 import GHC.Generics (Generic)
 import Text.Pandoc.Definition
@@ -59,45 +60,46 @@
          _         -> mzero
 
 data LogMessage =
-    SkippedContent Text.Text SourcePos
-  | IgnoredElement Text.Text
-  | DuplicateLinkReference Text.Text SourcePos
-  | DuplicateNoteReference Text.Text SourcePos
-  | NoteDefinedButNotUsed Text.Text SourcePos
-  | DuplicateIdentifier Text.Text SourcePos
-  | ReferenceNotFound Text.Text SourcePos
-  | CircularReference Text.Text SourcePos
-  | UndefinedToggle Text.Text SourcePos
-  | ParsingUnescaped Text.Text SourcePos
-  | CouldNotLoadIncludeFile Text.Text SourcePos
-  | MacroAlreadyDefined Text.Text SourcePos
+    SkippedContent Text SourcePos
+  | IgnoredElement Text
+  | DuplicateLinkReference Text SourcePos
+  | DuplicateNoteReference Text SourcePos
+  | NoteDefinedButNotUsed Text SourcePos
+  | DuplicateIdentifier Text SourcePos
+  | ReferenceNotFound Text SourcePos
+  | CircularReference Text SourcePos
+  | UndefinedToggle Text SourcePos
+  | ParsingUnescaped Text SourcePos
+  | CouldNotLoadIncludeFile Text SourcePos
+  | MacroAlreadyDefined Text SourcePos
   | InlineNotRendered Inline
   | BlockNotRendered Block
-  | DocxParserWarning Text.Text
-  | IgnoredIOError Text.Text
-  | CouldNotFetchResource Text.Text Text.Text
-  | CouldNotDetermineImageSize Text.Text Text.Text
-  | CouldNotConvertImage Text.Text Text.Text
-  | CouldNotDetermineMimeType Text.Text
-  | CouldNotConvertTeXMath Text.Text Text.Text
-  | CouldNotParseCSS Text.Text
-  | Fetching Text.Text
-  | Extracting Text.Text
-  | NoTitleElement Text.Text
+  | DocxParserWarning Text
+  | IgnoredIOError Text
+  | CouldNotFetchResource Text Text
+  | CouldNotDetermineImageSize Text Text
+  | CouldNotConvertImage Text Text
+  | CouldNotDetermineMimeType Text
+  | CouldNotConvertTeXMath Text Text
+  | CouldNotParseCSS Text
+  | Fetching Text
+  | Extracting Text
+  | NoTitleElement Text
   | NoLangSpecified
-  | InvalidLang Text.Text
-  | CouldNotHighlight Text.Text
-  | MissingCharacter Text.Text
-  | Deprecated Text.Text Text.Text
-  | NoTranslation Text.Text
-  | CouldNotLoadTranslations Text.Text Text.Text
-  | UnusualConversion Text.Text
-  | UnexpectedXmlElement Text.Text Text.Text
-  | UnknownOrgExportOption Text.Text
-  | CouldNotDeduceFormat [Text.Text] Text.Text
+  | InvalidLang Text
+  | CouldNotHighlight Text
+  | MissingCharacter Text
+  | Deprecated Text Text
+  | NoTranslation Text
+  | CouldNotLoadTranslations Text Text
+  | UnusualConversion Text
+  | UnexpectedXmlElement Text Text
+  | UnknownOrgExportOption Text
+  | CouldNotDeduceFormat [Text] Text
   | RunningFilter FilePath
   | FilterCompleted FilePath Integer
-  | CiteprocWarning Text.Text
+  | CiteprocWarning Text
+  | ATXHeadingInLHS Int Text
   deriving (Show, Eq, Data, Ord, Typeable, Generic)
 
 instance ToJSON LogMessage where
@@ -224,8 +226,11 @@
            ,"milliseconds" .= Text.pack (show ms) ]
       CiteprocWarning msg ->
            ["message" .= msg]
+      ATXHeadingInLHS lvl contents ->
+           ["level" .= lvl
+           ,"contents" .= contents]
 
-showPos :: SourcePos -> Text.Text
+showPos :: SourcePos -> Text
 showPos pos = Text.pack $ sn ++ "line " ++
      show (sourceLine pos) ++ " column " ++ show (sourceColumn pos)
   where sn = if sourceName pos == "source" || sourceName pos == ""
@@ -238,7 +243,7 @@
       keyOrder [ "type", "verbosity", "contents", "message", "path",
                  "source", "line", "column" ] } ms
 
-showLogMessage :: LogMessage -> Text.Text
+showLogMessage :: LogMessage -> Text
 showLogMessage msg =
   case msg of
        SkippedContent s pos ->
@@ -333,6 +338,13 @@
        FilterCompleted fp ms -> "Completed filter " <> Text.pack fp <>
           " in " <> Text.pack (show ms) <> " ms"
        CiteprocWarning ms -> "Citeproc: " <> ms
+       ATXHeadingInLHS lvl contents ->
+         "Rendering heading '" <> contents <> "' as a paragraph.\n" <>
+         "ATX headings cannot be used in literate Haskell, because " <>
+         "'#' is not\nallowed in column 1." <>
+         if lvl < 3
+            then " Consider using --markdown-headings=setext."
+            else ""
 
 messageVerbosity :: LogMessage -> Verbosity
 messageVerbosity msg =
@@ -378,3 +390,4 @@
        RunningFilter{}               -> INFO
        FilterCompleted{}             -> INFO
        CiteprocWarning{}             -> WARNING
+       ATXHeadingInLHS{}             -> WARNING
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
@@ -289,7 +289,7 @@
                       , writerTopLevelDivision = TopLevelDefault
                       , writerListings         = False
                       , writerHighlightStyle   = Just pygments
-                      , writerSetextHeaders    = True
+                      , writerSetextHeaders    = False
                       , writerEpubSubdirectory = "EPUB"
                       , writerEpubMetadata     = Nothing
                       , writerEpubFonts        = []
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
@@ -60,7 +60,10 @@
 
 #ifdef _WINDOWS
 changePathSeparators :: FilePath -> FilePath
-changePathSeparators = intercalate "/" . splitDirectories
+changePathSeparators =
+  -- We filter out backslashes because an initial `C:\` gets
+  -- retained by `splitDirectories`, see #6173:
+  intercalate "/" . map (filter (/='\\')) . splitDirectories
 #endif
 
 makePDF :: String              -- ^ pdf creator (pdflatex, lualatex, xelatex,
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
@@ -798,7 +798,11 @@
            => ParserT s ParserState m (ListNumberStyle, Int)
 exampleNum = do
   char '@'
-  lab <- T.pack <$> many (alphaNum <|> satisfy (\c -> c == '_' || c == '-'))
+  lab <- mconcat . map T.pack <$>
+                    many (many1 alphaNum <|>
+                          try (do c <- char '_' <|> char '-'
+                                  cs <- many1 alphaNum
+                                  return (c:cs)))
   st <- getState
   let num = stateNextExample st
   let newlabels = if T.null lab
diff --git a/src/Text/Pandoc/Readers/BibTeX.hs b/src/Text/Pandoc/Readers/BibTeX.hs
--- a/src/Text/Pandoc/Readers/BibTeX.hs
+++ b/src/Text/Pandoc/Readers/BibTeX.hs
@@ -51,7 +51,10 @@
   lang <- maybe (Lang "en" (Just "US")) parseLang
              <$> lookupEnv "LANG"
   locale <- case getLocale lang of
-               Left e  -> throwError $ PandocCiteprocError e
+               Left e  ->
+                 case getLocale (Lang "en" (Just "US")) of
+                   Right l -> return l
+                   Left _  -> throwError $ PandocCiteprocError e
                Right l -> return l
   case BibTeX.readBibtexString variant locale (const True) t of
     Left e -> throwError $ PandocParsecError t e
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
@@ -782,8 +782,8 @@
         "para"  -> parseMixed para (elContent e)
         "formalpara" -> do
            tit <- case filterChild (named "title") e of
-                        Just t  -> para . strong . (<> str ".") <$>
-                                     getInlines t
+                        Just t  -> divWith ("",["formalpara-title"],[]) .
+                                   para .  strong <$> getInlines t
                         Nothing -> return mempty
            (tit <>) <$> parseMixed para (elContent e)
         "simpara"  -> parseMixed para (elContent e)
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
@@ -1923,32 +1923,6 @@
           return $ Image attr' alt' (src, tit')
         go x = return x
 
-getNextNumber :: Monad m
-              => (LaTeXState -> DottedNum) -> LP m DottedNum
-getNextNumber getCurrentNum = do
-  st <- getState
-  let chapnum =
-        case sLastHeaderNum st of
-             DottedNum (n:_) | sHasChapters st -> Just n
-             _                                 -> Nothing
-  return . DottedNum $
-    case getCurrentNum st of
-       DottedNum [m,n]  ->
-         case chapnum of
-              Just m' | m' == m   -> [m, n+1]
-                      | otherwise -> [m', 1]
-              Nothing             -> [1]
-                                      -- shouldn't happen
-       DottedNum [n]   ->
-         case chapnum of
-              Just m  -> [m, 1]
-              Nothing -> [n + 1]
-       _               ->
-         case chapnum of
-               Just n  -> [n, 1]
-               Nothing -> [1]
-
-
 coloredBlock :: PandocMonad m => Text -> LP m Blocks
 coloredBlock stylename = try $ do
   skipopts
diff --git a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
--- a/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Parsing.hs
@@ -77,6 +77,7 @@
   , skipopts
   , rawopt
   , overlaySpecification
+  , getNextNumber
   ) where
 
 import Control.Applicative (many, (<|>))
@@ -847,4 +848,29 @@
 isFontSizeCommand "huge" = True
 isFontSizeCommand "Huge" = True
 isFontSizeCommand _ = False
+
+getNextNumber :: Monad m
+              => (LaTeXState -> DottedNum) -> LP m DottedNum
+getNextNumber getCurrentNum = do
+  st <- getState
+  let chapnum =
+        case sLastHeaderNum st of
+             DottedNum (n:_) | sHasChapters st -> Just n
+             _                                 -> Nothing
+  return . DottedNum $
+    case getCurrentNum st of
+       DottedNum [m,n]  ->
+         case chapnum of
+              Just m' | m' == m   -> [m, n+1]
+                      | otherwise -> [m', 1]
+              Nothing             -> [1]
+                                      -- shouldn't happen
+       DottedNum [n]   ->
+         case chapnum of
+              Just m  -> [m, 1]
+              Nothing -> [n + 1]
+       _               ->
+         case chapnum of
+               Just n  -> [n, 1]
+               Nothing -> [1]
 
diff --git a/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs b/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs
--- a/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs
@@ -58,7 +58,7 @@
              text ", & " <> last xs
 
 parseNum :: Parser Text () Inlines
-parseNum = mconcat <$> many parseNumPart
+parseNum = (mconcat <$> many parseNumPart) <* eof
 
 parseNumPart :: Parser Text () Inlines
 parseNumPart =
@@ -71,7 +71,9 @@
   parseSpace
  where
   parseDecimalNum = do
-    basenum <- T.pack <$> many1 (satisfy (\c -> isDigit c || c == '.'))
+    pref <- option mempty $ (mempty <$ char '+') <|> ("\x2212" <$ char '-')
+    basenum <- (pref <>) . T.pack
+                <$> many1 (satisfy (\c -> isDigit c || c == '.'))
     uncertainty <- option mempty $ T.pack <$> parseParens
     if T.null uncertainty
        then return $ str basenum
diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs
--- a/src/Text/Pandoc/Readers/Man.hs
+++ b/src/Text/Pandoc/Readers/Man.hs
@@ -407,12 +407,14 @@
 
 data ListType = Ordered ListAttributes
               | Bullet
+              | Definition T.Text
 
 listTypeMatches :: Maybe ListType -> ListType -> Bool
 listTypeMatches Nothing _            = True
 listTypeMatches (Just Bullet) Bullet = True
 listTypeMatches (Just (Ordered (_,x,y))) (Ordered (_,x',y'))
                                      = x == x' && y == y'
+listTypeMatches (Just (Definition _)) (Definition _) = True
 listTypeMatches (Just _) _           = False
 
 listItem :: PandocMonad m => Maybe ListType -> ManParser m (ListType, Blocks)
@@ -427,20 +429,28 @@
                   Right (start, listtype, listdelim)
                     | cs == cs' -> Ordered (start, listtype, listdelim)
                     | otherwise -> Ordered (start, listtype, DefaultDelim)
-                  Left _        -> Bullet
+                  Left _
+                    | cs == "\183" || cs == "-" || cs == "*" || cs == "+"
+                                   -> Bullet
+                    | otherwise    -> Definition cs
       guard $ listTypeMatches mbListType lt
+      skipMany memptyLine
       inls <- option mempty parseInlines
+      skipMany memptyLine
       continuations <- mconcat <$> many continuation
       return (lt, para inls <> continuations)
     []          -> mzero
 
 parseList :: PandocMonad m => ManParser m Blocks
 parseList = try $ do
-  (lt, x) <- listItem Nothing
-  xs <- map snd <$> many (listItem (Just lt))
+  x@(lt, _) <- listItem Nothing
+  xs <- many (listItem (Just lt))
+  let toDefItem (Definition t, bs) = (B.text t, [bs])
+      toDefItem _ = mempty
   return $ case lt of
-             Bullet        -> bulletList (x:xs)
-             Ordered lattr -> orderedListWith lattr (x:xs)
+             Bullet        -> bulletList $ map snd (x:xs)
+             Ordered lattr -> orderedListWith lattr $ map snd (x:xs)
+             Definition _  -> definitionList $ map toDefItem (x:xs)
 
 continuation :: PandocMonad m => ManParser m Blocks
 continuation =
@@ -453,11 +463,15 @@
                    => ManParser m (Inlines, [Blocks])
 definitionListItem = try $ do
   mmacro "TP"  -- args specify indent level, can ignore
+  skipMany memptyLine
   term <- parseInline
+  skipMany memptyLine
   moreterms <- many $ try $ do
                  mmacro "TQ"
                  parseInline
+  skipMany memptyLine
   inls <- option mempty parseInlines
+  skipMany memptyLine
   continuations <- mconcat <$> many continuation
   return ( mconcat (intersperse B.linebreak (term:moreterms))
          , [para inls <> continuations])
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
@@ -1535,11 +1535,20 @@
   char '<'
   return $ return $ B.str "<"
 
+-- Note that if the citations extension is enabled, example refs will be
+-- parsed as citations, and handled by a clause in the parser for citations,
+-- since we won't know whether we have an example ref until the
+-- whole document has been parsed.  But we need this parser
+-- here in case citations is disabled.
 exampleRef :: PandocMonad m => MarkdownParser m (F Inlines)
 exampleRef = try $ do
   guardEnabled Ext_example_lists
   char '@'
-  lab <- many1Char (alphaNum <|> oneOf "-_")
+  lab <- mconcat . map T.pack <$>
+                    many (many1 alphaNum <|>
+                          try (do c <- char '_' <|> char '-'
+                                  cs <- many1 alphaNum
+                                  return (c:cs)))
   return $ do
     st <- askF
     return $ case M.lookup lab (stateExamples st) of
@@ -2066,6 +2075,13 @@
 textualCite :: PandocMonad m => MarkdownParser m (F Inlines)
 textualCite = try $ do
   (suppressAuthor, key) <- citeKey
+  -- If this is a reference to an earlier example list item,
+  -- then don't parse it as a citation.  If the example list
+  -- item comes later, we'll parse it here and figure out in
+  -- the runF stage if it's a citation.  But it helps with
+  -- issue #6836 to filter out known example list references
+  -- at this stage, so that we don't increment stateNoteNumber.
+  getState >>= guard . isNothing . M.lookup key . stateExamples
   noteNum <- stateNoteNumber <$> getState
   let first = Citation{ citationId      = key
                       , citationPrefix  = []
@@ -2076,30 +2092,29 @@
                       , citationNoteNum = noteNum
                       , citationHash    = 0
                       }
-  mbrest <- option Nothing $ try $ spnl >> Just <$> withRaw normalCite
-  case mbrest of
-       Just (rest, raw) ->
-         return $ flip B.cite (B.text $ "@" <> key <> " " <> raw) . (first:)
-               <$> rest
-       Nothing   ->
-         (do
-          (cs, raw) <- withRaw $ bareloc first
-          let (spaces',raw') = T.span isSpace raw
-              spc | T.null spaces' = mempty
-                  | otherwise      = B.space
-          lab <- parseFromString' inlines $ dropBrackets raw'
-          fallback <- referenceLink B.linkWith (lab,raw')
-          return $ do
-            fallback' <- fallback
-            cs' <- cs
-            return $
-              case B.toList fallback' of
-                Link{}:_ -> B.cite [first] (B.str $ "@" <> key) <> spc <> fallback'
-                _        -> B.cite cs' (B.text $ "@" <> key <> " " <> raw))
-         <|> return (do st <- askF
-                        return $ case M.lookup key (stateExamples st) of
-                                 Just n -> B.str $ tshow n
-                                 _      -> B.cite [first] $ B.str $ "@" <> key)
+  (do -- parse [braced] material after author-in-text cite
+      (cs, raw) <- withRaw $
+                        (fmap (first:) <$> try (spnl *> normalCite))
+                    <|> bareloc first
+      let (spaces',raw') = T.span isSpace raw
+          spc | T.null spaces' = mempty
+              | otherwise      = B.space
+      lab <- parseFromString' inlines $ dropBrackets raw'
+      fallback <- referenceLink B.linkWith (lab,raw')
+      -- undo any incrementing of stateNoteNumber from last step:
+      updateState $ \st -> st{ stateNoteNumber = noteNum }
+      return $ do
+        fallback' <- fallback
+        cs' <- cs
+        return $
+          case B.toList fallback' of
+            Link{}:_ -> B.cite [first] (B.str $ "@" <> key) <> spc <> fallback'
+            _        -> B.cite cs' (B.text $ "@" <> key <> " " <> raw))
+    <|> -- no braced material
+        return (do st <- askF
+                   return $ case M.lookup key (stateExamples st) of
+                            Just n -> B.str $ tshow n
+                            _      -> B.cite [first] $ B.str $ "@" <> key)
 
 bareloc :: PandocMonad m => Citation -> MarkdownParser m (F [Citation])
 bareloc c = try $ do
@@ -2107,7 +2122,7 @@
   char '['
   notFollowedBy $ char '^'
   suff <- suffix
-  rest <- option (return []) $ try $ char ';' >> citeList
+  rest <- option (return []) $ try $ char ';' >> spnl >> citeList
   spnl
   char ']'
   notFollowedBy $ oneOf "[("
@@ -2136,7 +2151,11 @@
 
 prefix :: PandocMonad m => MarkdownParser m (F Inlines)
 prefix = trimInlinesF . mconcat <$>
-  manyTill inline (char ']' <|> fmap (const ']') (lookAhead citeKey))
+  manyTill inline (char ']'
+   <|> lookAhead
+         (try $ do optional (try (char ';' >> spnl))
+                   citeKey
+                   return ']'))
 
 citeList :: PandocMonad m => MarkdownParser m (F [Citation])
 citeList = fmap sequence $ sepBy1 citation (try $ char ';' >> spnl)
diff --git a/src/Text/Pandoc/Readers/Metadata.hs b/src/Text/Pandoc/Readers/Metadata.hs
--- a/src/Text/Pandoc/Readers/Metadata.hs
+++ b/src/Text/Pandoc/Readers/Metadata.hs
@@ -112,13 +112,16 @@
    -- Note: a standard quoted or unquoted YAML value will
    -- not end in a newline, but a "block" set off with
    -- `|` or `>` will.
-   if "\n" `T.isSuffixOf` x
+   if "\n" `T.isSuffixOf` T.dropWhileEnd isSpaceChar x -- see #6823
       then parseFromString' pMetaValue (x <> "\n")
       else parseFromString' asInlines x
   where asInlines = fmap b2i <$> pMetaValue
         b2i (MetaBlocks [Plain ils]) = MetaInlines ils
         b2i (MetaBlocks [Para ils]) = MetaInlines ils
         b2i bs = bs
+        isSpaceChar ' '  = True
+        isSpaceChar '\t' = True
+        isSpaceChar _    = False
 
 checkBoolean :: Text -> Maybe Bool
 checkBoolean t
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
@@ -111,23 +111,23 @@
 stringyMetaAttribute :: Monad m => OrgParser m (Text, Text)
 stringyMetaAttribute = try $ do
   metaLineStart
-  attrName <- T.toUpper <$> many1TillChar nonspaceChar (char ':')
+  attrName <- T.toLower <$> many1TillChar nonspaceChar (char ':')
   skipSpaces
   attrValue <- anyLine <|> ("" <$ newline)
   return (attrName, attrValue)
 
 -- | Parse a set of block attributes. Block attributes are given through
--- lines like @#+CAPTION: block caption@ or @#+ATTR_HTML: :width 20@.
+-- lines like @#+caption: block caption@ or @#+attr_html: :width 20@.
 -- Parsing will fail if any line contains an attribute different from
 -- those attributes known to work on blocks.
 blockAttributes :: PandocMonad m => OrgParser m BlockAttributes
 blockAttributes = try $ do
   kv <- many stringyMetaAttribute
   guard $ all (isBlockAttr . fst) kv
-  let caption = foldl' (appendValues "CAPTION") Nothing kv
-  let kvAttrs = foldl' (appendValues "ATTR_HTML") Nothing kv
-  let name    = lookup "NAME" kv
-  let label   = lookup "LABEL" kv
+  let caption = foldl' (appendValues "caption") Nothing kv
+  let kvAttrs = foldl' (appendValues "attr_html") Nothing kv
+  let name    = lookup "name" kv
+  let label   = lookup "label" kv
   caption' <- traverse (parseFromString inlines . (<> "\n")) caption
   kvAttrs' <- parseFromString keyValues . (<> "\n") $ fromMaybe mempty kvAttrs
   return BlockAttributes
@@ -139,9 +139,9 @@
  where
    isBlockAttr :: Text -> Bool
    isBlockAttr = flip elem
-                 [ "NAME", "LABEL", "CAPTION"
-                 , "ATTR_HTML", "ATTR_LATEX"
-                 , "RESULTS"
+                 [ "name", "label", "caption"
+                 , "attr_html", "attr_latex"
+                 , "results"
                  ]
 
    appendValues :: Text -> Maybe Text -> (Text, Text) -> Maybe Text
@@ -170,10 +170,10 @@
 
 
 --
--- Org Blocks (#+BEGIN_... / #+END_...)
+-- Org Blocks (#+begin_... / #+end_...)
 --
 
--- | Read an org-mode block delimited by #+BEGIN_TYPE and #+END_TYPE.
+-- | Read an org-mode block delimited by #+begin_type and #+end_type.
 orgBlock :: PandocMonad m => OrgParser m (F Blocks)
 orgBlock = try $ do
   blockAttrs <- blockAttributes
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
@@ -50,19 +50,26 @@
                    then mime <> ";charset=utf-8"
                    else mime  -- mime type already has charset
 
+isSourceAttribute :: T.Text -> (T.Text, T.Text) -> Bool
+isSourceAttribute tagname (x,_) =
+  x == "src" ||
+  x == "data-src" ||
+  (x == "href" && tagname == "link") ||
+  x == "poster" ||
+  x == "data-background-image"
+
 convertTags :: PandocMonad m => [Tag T.Text] -> m [Tag T.Text]
 convertTags [] = return []
 convertTags (t@TagOpen{}:ts)
   | fromAttrib "data-external" t == "1" = (t:) <$> convertTags ts
 convertTags (t@(TagOpen tagname as):ts)
-  | tagname `elem`
-     ["img", "embed", "video", "input", "audio", "source", "track",
-      "section"] = do
+  | any (isSourceAttribute tagname) as
+     = do
        as' <- mapM processAttribute as
        rest <- convertTags ts
        return $ TagOpen tagname as' : rest
   where processAttribute (x,y) =
-           if x `elem` ["src", "data-src", "href", "poster", "data-background-image"]
+           if isSourceAttribute tagname (x,y)
               then do
                 enc <- getDataURI (fromAttrib "type" t) y
                 return (x, enc)
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
@@ -40,26 +40,14 @@
 import Text.Pandoc.Shared
 import Text.Pandoc.Templates (renderTemplate)
 import Text.DocTemplates (Context(..), Val(..))
+import Text.Pandoc.Writers.JATS.Table (tableToJATS)
+import Text.Pandoc.Writers.JATS.Types
 import Text.Pandoc.Writers.Math
 import Text.Pandoc.Writers.Shared
 import Text.Pandoc.XML
 import Text.TeXMath
 import qualified Text.XML.Light as Xml
 
--- | JATS tag set variant
-data JATSTagSet
-  = TagSetArchiving         -- ^ Archiving and Interchange Tag Set
-  | TagSetPublishing        -- ^ Journal Publishing Tag Set
-  | TagSetArticleAuthoring  -- ^ Article Authoring Tag Set
-  deriving (Eq)
-
--- | Internal state used by the writer.
-newtype JATSState = JATSState
-  { jatsNotes :: [(Int, Doc Text)] }
-
--- | JATS writer type
-type JATS a = StateT JATSState (ReaderT JATSTagSet a)
-
 -- | Convert a @'Pandoc'@ document to JATS (Archiving and Interchange
 -- Tag Set.)
 writeJatsArchiving :: PandocMonad m => WriterOptions -> Pandoc -> m Text
@@ -83,9 +71,14 @@
 -- | Convert a @'Pandoc'@ document to JATS.
 writeJats :: PandocMonad m => JATSTagSet -> WriterOptions -> Pandoc -> m Text
 writeJats tagSet opts d =
-  runReaderT (evalStateT (docToJATS opts d)
-               (JATSState{ jatsNotes = [] }))
-             tagSet
+  runReaderT (evalStateT (docToJATS opts d) initialState)
+             environment
+  where initialState = JATSState { jatsNotes = [] }
+        environment = JATSEnv
+          { jatsTagSet = tagSet
+          , jatsInlinesWriter = inlinesToJATS
+          , jatsBlockWriter = blockToJATS
+          }
 
 -- | Convert Pandoc document to string in JATS format.
 docToJATS :: PandocMonad m => WriterOptions -> Pandoc -> JATS m Text
@@ -110,7 +103,7 @@
   main <- fromBlocks bodyblocks
   notes <- gets (reverse . map snd . jatsNotes)
   backs <- fromBlocks backblocks
-  tagSet <- ask
+  tagSet <- asks jatsTagSet
   -- In the "Article Authoring" tag set, occurrence of fn-group elements
   -- is restricted to table footers. Footnotes have to be placed inline.
   let fns = if null notes || tagSet == TagSetArticleAuthoring
@@ -311,7 +304,7 @@
 blockToJATS opts (LineBlock lns) =
   blockToJATS opts $ linesToPara lns
 blockToJATS opts (BlockQuote blocks) = do
-  tagSet <- ask
+  tagSet <- asks jatsTagSet
   let blocksToJats' = if tagSet == TagSetArticleAuthoring
                       then wrappedBlocksToJATS (not . isPara)
                       else blocksToJATS
@@ -326,7 +319,7 @@
   listItemsToJATS opts Nothing lst
 blockToJATS _ (OrderedList _ []) = return empty
 blockToJATS opts (OrderedList (start, numstyle, delimstyle) items) = do
-  tagSet <- ask
+  tagSet <- asks jatsTagSet
   let listType =
         -- The Article Authoring tag set doesn't allow a more specific
         -- @list-type@ attribute than "order".
@@ -356,52 +349,8 @@
       report $ BlockNotRendered b
       return empty
 blockToJATS _ HorizontalRule = return empty -- not semantic
-blockToJATS opts (Table _ blkCapt specs th tb tf) =
-  case toLegacyTable blkCapt specs th tb tf of
-    ([], aligns, widths, headers, rows) -> captionlessTable aligns widths headers rows
-    (caption, aligns, widths, headers, rows) -> do
-      captionDoc <- inTagsIndented "caption" <$> blockToJATS opts (Para caption)
-      tbl <- captionlessTable aligns widths headers rows
-      return $ inTags True "table-wrap" [] $ captionDoc $$ tbl
-  where
-    captionlessTable aligns widths headers rows = do
-      let percent w = tshow (truncate (100*w) :: Integer) <> "*"
-      let coltags = vcat $ zipWith (\w al -> selfClosingTag "col"
-                           ([("width", percent w) | w > 0] ++
-                            [("align", alignmentToText al)])) widths aligns
-      thead <- if all null headers
-                  then return empty
-                  else inTagsIndented "thead" <$> tableRowToJATS opts True headers
-      tbody <- inTagsIndented "tbody" . vcat <$>
-                    mapM (tableRowToJATS opts False) rows
-      return $ inTags True "table" [] $ coltags $$ thead $$ tbody
-
-alignmentToText :: Alignment -> Text
-alignmentToText alignment = case alignment of
-                                 AlignLeft    -> "left"
-                                 AlignRight   -> "right"
-                                 AlignCenter  -> "center"
-                                 AlignDefault -> "left"
-
-tableRowToJATS :: PandocMonad m
-                  => WriterOptions
-                  -> Bool
-                  -> [[Block]]
-                  -> JATS m (Doc Text)
-tableRowToJATS opts isHeader cols =
-  inTagsIndented "tr" . vcat <$> mapM (tableItemToJATS opts isHeader) cols
-
-tableItemToJATS :: PandocMonad m
-                   => WriterOptions
-                   -> Bool
-                   -> [Block]
-                   -> JATS m (Doc Text)
-tableItemToJATS opts isHeader [Plain item] =
-  inTags False (if isHeader then "th" else "td") [] <$>
-    inlinesToJATS opts item
-tableItemToJATS opts isHeader item =
-  inTags False (if isHeader then "th" else "td") [] . vcat <$>
-    mapM (blockToJATS opts) item
+blockToJATS opts (Table attr blkCapt specs th tb tf) =
+  tableToJATS opts attr blkCapt specs th tb tf
 
 -- | Convert a list of inline elements to JATS.
 inlinesToJATS :: PandocMonad m => WriterOptions -> [Inline] -> JATS m (Doc Text)
@@ -458,7 +407,7 @@
   | writerWrapText opts == WrapPreserve = return cr
   | otherwise = return space
 inlineToJATS opts (Note contents) = do
-  tagSet <- ask
+  tagSet <- asks jatsTagSet
   -- Footnotes must occur inline when using the Article Authoring tag set.
   if tagSet == TagSetArticleAuthoring
     then inTagsIndented "fn" <$> wrappedBlocksToJATS (not . isPara) opts contents
@@ -504,7 +453,7 @@
   let rawtex = text "<![CDATA[" <> literal str <> text "]]>"
   let texMath = inTagsSimple "tex-math" rawtex
 
-  tagSet <- ask
+  tagSet <- asks jatsTagSet
   return . inTagsSimple tagtype $
     case res of
       Right r  -> let mathMl = text (Xml.ppcElement conf $ fixNS r)
diff --git a/src/Text/Pandoc/Writers/JATS/Table.hs b/src/Text/Pandoc/Writers/JATS/Table.hs
new file mode 100644
--- /dev/null
+++ b/src/Text/Pandoc/Writers/JATS/Table.hs
@@ -0,0 +1,82 @@
+{-# LANGUAGE OverloadedStrings #-}
+{- |
+   Module      : Text.Pandoc.Writers.JATS.Table
+   Copyright   : © 2020 Albert Krewinkel
+   License     : GNU GPL, version 2 or above
+
+   Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>
+   Stability   : alpha
+   Portability : portable
+
+Conversion of 'Pandoc' tables to JATS XML.
+-}
+module Text.Pandoc.Writers.JATS.Table
+  ( tableToJATS
+  ) where
+import Control.Monad.Reader (asks)
+import Data.Text (Text)
+import Text.Pandoc.Class.PandocMonad (PandocMonad)
+import Text.Pandoc.Definition
+import Text.Pandoc.Options (WriterOptions)
+import Text.DocLayout (Doc, empty, vcat, ($$))
+import Text.Pandoc.Shared (tshow)
+import Text.Pandoc.Writers.JATS.Types
+import Text.Pandoc.Writers.Shared (toLegacyTable)
+import Text.Pandoc.XML (inTags, inTagsIndented, selfClosingTag)
+
+
+tableToJATS :: PandocMonad m
+            => WriterOptions
+            -> Attr -> Caption -> [ColSpec] -> TableHead
+            -> [TableBody] -> TableFoot
+            -> JATS m (Doc Text)
+tableToJATS opts _attr blkCapt specs th tb tf = do
+  blockToJATS <- asks jatsBlockWriter
+  let (caption, aligns, widths, headers, rows) =
+        toLegacyTable blkCapt specs th tb tf
+  captionDoc <- if null caption
+                then return mempty
+                else inTagsIndented "caption" <$> blockToJATS opts (Para caption)
+  tbl <- captionlessTable aligns widths headers rows
+  return $ inTags True "table-wrap" [] $ captionDoc $$ tbl
+  where
+    captionlessTable aligns widths headers rows = do
+      let percent w = tshow (truncate (100*w) :: Integer) <> "*"
+      let coltags = vcat $ zipWith (\w al -> selfClosingTag "col"
+                           ([("width", percent w) | w > 0] ++
+                            [("align", alignmentToText al)])) widths aligns
+      thead <- if all null headers
+                  then return empty
+                  else inTagsIndented "thead" <$> tableRowToJATS opts True headers
+      tbody <- inTagsIndented "tbody" . vcat <$>
+                    mapM (tableRowToJATS opts False) rows
+      return $ inTags True "table" [] $ coltags $$ thead $$ tbody
+
+alignmentToText :: Alignment -> Text
+alignmentToText alignment = case alignment of
+                                 AlignLeft    -> "left"
+                                 AlignRight   -> "right"
+                                 AlignCenter  -> "center"
+                                 AlignDefault -> "left"
+
+tableRowToJATS :: PandocMonad m
+               => WriterOptions
+               -> Bool
+               -> [[Block]]
+               -> JATS m (Doc Text)
+tableRowToJATS opts isHeader cols =
+  inTagsIndented "tr" . vcat <$> mapM (tableItemToJATS opts isHeader) cols
+
+tableItemToJATS :: PandocMonad m
+                => WriterOptions
+                -> Bool
+                -> [Block]
+                -> JATS m (Doc Text)
+tableItemToJATS opts isHeader [Plain item] = do
+  inlinesToJATS <- asks jatsInlinesWriter
+  inTags False (if isHeader then "th" else "td") [] <$>
+    inlinesToJATS opts item
+tableItemToJATS opts isHeader item = do
+  blockToJATS <- asks jatsBlockWriter
+  inTags False (if isHeader then "th" else "td") [] . vcat <$>
+    mapM (blockToJATS opts) item
diff --git a/src/Text/Pandoc/Writers/JATS/Types.hs b/src/Text/Pandoc/Writers/JATS/Types.hs
new file mode 100644
--- /dev/null
+++ b/src/Text/Pandoc/Writers/JATS/Types.hs
@@ -0,0 +1,46 @@
+{- |
+   Module      : Text.Pandoc.Writers.JATS.Types
+   Copyright   : Copyright (C) 2017-2020 John MacFarlane
+   License     : GNU GPL, version 2 or above
+
+   Maintainer  : John MacFarlane <jgm@berkeley.edu>
+   Stability   : alpha
+   Portability : portable
+
+Types for pandoc's JATS writer.
+-}
+module Text.Pandoc.Writers.JATS.Types
+  ( JATS
+  , JATSEnv (..)
+  , JATSState (..)
+  , JATSTagSet (..)
+  )
+where
+
+import Control.Monad.Reader (ReaderT)
+import Control.Monad.State (StateT)
+import Data.Text (Text)
+import Text.DocLayout (Doc)
+import Text.Pandoc.Definition (Block, Inline)
+import Text.Pandoc.Options (WriterOptions)
+
+-- | JATS tag set variant
+data JATSTagSet
+  = TagSetArchiving         -- ^ Archiving and Interchange Tag Set
+  | TagSetPublishing        -- ^ Journal Publishing Tag Set
+  | TagSetArticleAuthoring  -- ^ Article Authoring Tag Set
+  deriving (Eq)
+
+-- | Internal state used by the writer.
+newtype JATSState = JATSState
+  { jatsNotes :: [(Int, Doc Text)]
+  }
+
+data JATSEnv m = JATSEnv
+  { jatsTagSet :: JATSTagSet
+  , jatsInlinesWriter :: WriterOptions -> [Inline] -> JATS m (Doc Text)
+  , jatsBlockWriter   :: WriterOptions -> Block    -> JATS m (Doc Text)
+  }
+
+-- | JATS writer type
+type JATS m = StateT JATSState (ReaderT (JATSEnv m) m)
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
@@ -514,6 +514,7 @@
 blockToMarkdown' opts HorizontalRule =
   return $ blankline <> literal (T.replicate (writerColumns opts) "-") <> blankline
 blockToMarkdown' opts (Header level attr inlines) = do
+
   -- first, if we're putting references at the end of a section, we
   -- put them here.
   blkLevel <- asks envBlockLevel
@@ -543,8 +544,12 @@
                       isEnabled Ext_gutenberg opts
                       then capitalize inlines
                       else inlines
+
   let setext = writerSetextHeaders opts
-      hdr = nowrap $ case level of
+  when (not setext && isEnabled Ext_literate_haskell opts) $
+    report $ ATXHeadingInLHS level (render Nothing contents)
+
+  let hdr = nowrap $ case level of
             1 | variant == PlainText ->
                 if isEnabled Ext_gutenberg opts
                    then blanklines 3 <> contents <> blanklines 2
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
@@ -106,7 +106,7 @@
   | Just tit <- T.stripPrefix "fig:" tgt = do
       capt <- if null txt
               then return empty
-              else ("#+CAPTION: " <>) `fmap` inlineListToOrg txt
+              else ("#+caption: " <>) `fmap` inlineListToOrg txt
       img <- inlineToOrg (Image attr txt (src,tit))
       return $ capt $$ img $$ blankline
 blockToOrg (Para inlines) = do
@@ -121,11 +121,11 @@
   let joinWithBlankLines = mconcat . intersperse blankline
   let prettifyStanza ls  = joinWithLinefeeds <$> mapM inlineListToOrg ls
   contents <- joinWithBlankLines <$> mapM prettifyStanza (splitStanza lns)
-  return $ blankline $$ "#+BEGIN_VERSE" $$
-           nest 2 contents $$ "#+END_VERSE" <> blankline
+  return $ blankline $$ "#+begin_verse" $$
+           nest 2 contents $$ "#+end_verse" <> blankline
 blockToOrg (RawBlock "html" str) =
-  return $ blankline $$ "#+BEGIN_HTML" $$
-           nest 2 (literal str) $$ "#+END_HTML" $$ blankline
+  return $ blankline $$ "#+begin_html" $$
+           nest 2 (literal str) $$ "#+end_html" $$ blankline
 blockToOrg b@(RawBlock f str)
   | isRawFormat f = return $ literal str
   | otherwise     = do
@@ -148,19 +148,19 @@
                       else ""
   let at = map pandocLangToOrg classes `intersect` orgLangIdentifiers
   let (beg, end) = case at of
-                      []    -> ("#+BEGIN_EXAMPLE" <> numberlines, "#+END_EXAMPLE")
-                      (x:_) -> ("#+BEGIN_SRC " <> x <> numberlines, "#+END_SRC")
+                      []    -> ("#+begin_example" <> numberlines, "#+end_example")
+                      (x:_) -> ("#+begin_src " <> x <> numberlines, "#+end_src")
   return $ literal beg $$ nest 2 (literal str) $$ text end $$ blankline
 blockToOrg (BlockQuote blocks) = do
   contents <- blockListToOrg blocks
-  return $ blankline $$ "#+BEGIN_QUOTE" $$
-           nest 2 contents $$ "#+END_QUOTE" $$ blankline
+  return $ blankline $$ "#+begin_quote" $$
+           nest 2 contents $$ "#+end_quote" $$ blankline
 blockToOrg (Table _ blkCapt specs thead tbody tfoot) =  do
   let (caption', _, _, headers, rows) = toLegacyTable blkCapt specs thead tbody tfoot
   caption'' <- inlineListToOrg caption'
   let caption = if null caption'
                    then empty
-                   else "#+CAPTION: " <> caption''
+                   else "#+caption: " <> caption''
   headers' <- mapM blockListToOrg headers
   rawRows <- mapM (mapM blockListToOrg) rows
   let numChars = maximum . map offset
@@ -292,12 +292,12 @@
   case divBlockType attr of
     GreaterBlock blockName attr' ->
       -- Write as greater block. The ID, if present, is added via
-      -- the #+NAME keyword; other classes and key-value pairs
-      -- are kept as #+ATTR_HTML attributes.
+      -- the #+name keyword; other classes and key-value pairs
+      -- are kept as #+attr_html attributes.
       return $ blankline $$ attrHtml attr'
-            $$ "#+BEGIN_" <> literal blockName
+            $$ "#+begin_" <> literal blockName
             $$ contents
-            $$ "#+END_" <> literal blockName $$ blankline
+            $$ "#+end_" <> literal blockName $$ blankline
     Drawer drawerName (_,_,kvs) -> do
       -- Write as drawer. Only key-value pairs are retained.
       let keys = vcat $ map (\(k,v) ->
@@ -320,8 +320,8 @@
 attrHtml (""   , []     , []) = mempty
 attrHtml (ident, classes, kvs) =
   let
-    name = if T.null ident then mempty else "#+NAME: " <> literal ident <> cr
-    keyword = "#+ATTR_HTML"
+    name = if T.null ident then mempty else "#+name: " <> literal ident <> cr
+    keyword = "#+attr_html"
     classKv = ("class", T.unwords classes)
     kvStrings = map (\(k,v) -> ":" <> k <> " " <> v) (classKv:kvs)
   in name <> keyword <> ": " <> literal (T.unwords kvStrings) <> cr
@@ -439,18 +439,22 @@
 pandocLangToOrg cs =
   case cs of
     "c"          -> "C"
-    "cpp"        -> "C++"
     "commonlisp" -> "lisp"
     "r"          -> "R"
-    "bash"       -> "sh"
+    "bash"       -> "shell"
+    "lillypond"  -> "ly"
     _            -> cs
 
 -- | List of language identifiers recognized by org-mode.
 orgLangIdentifiers :: [Text]
 orgLangIdentifiers =
-  [ "asymptote", "awk", "C", "C++", "clojure", "css", "d", "ditaa", "dot"
-  , "calc", "emacs-lisp", "fortran", "gnuplot", "haskell", "java", "js"
-  , "latex", "ledger", "lisp", "lilypond", "matlab", "mscgen", "ocaml"
-  , "octave", "org", "oz", "perl", "plantuml", "processing", "python", "R"
-  , "ruby", "sass", "scheme", "screen", "sed", "sh", "sql", "sqlite"
+  [ "abc", "asymptote", "awk", "axiom", "C", "cpp", "calc", "clojure","comint"
+  , "coq", "css", "D", "ditaa", "dot", "ebnf", "elixir", "eukleides", "fomus"
+  , "forth", "F90", "gnuplot", "Translate", "groovy", "haskell" , "browser"
+  , "request", "io", "ipython", "J", "java", "js", "julia", "kotlin", "latex"
+  , "ledger", "ly", "lisp", "Flavored", "makefile", "mathematica", "mathomatic"
+  , "matlab", "max", "mongo", "mscgen", "cypher", "Caml", "octave" , "org", "oz"
+  , "perl", "picolisp", "plantuml", "processing", "prolog", "python" , "R"
+  , "rec", "ruby", "sass", "scala", "scheme", "screen", "sed", "shell", "shen"
+  , "sql", "sqlite", "stan", "ML", "stata", "tcl", "typescript", "vala"
   ]
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
-    static: false
 packages:
 - '.'
 extra-deps:
@@ -22,7 +21,7 @@
 - commonmark-0.1.1.2
 - commonmark-extensions-0.2.0.4
 - commonmark-pandoc-0.2.0.1
-- citeproc-0.1.1.1
+- citeproc-0.2
 ghc-options:
    "$locals": -fhide-source-paths -Wno-missing-home-modules
 resolver: lts-14.6
diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs
--- a/test/Tests/Old.hs
+++ b/test/Tests/Old.hs
@@ -215,7 +215,8 @@
     [ test' "reader" ["-f", "ipynb-raw_html-raw_tex+raw_attribute",
                       "-t", "native", "-s"]
       "ipynb/simple.ipynb" "ipynb/simple.out.native"
-    , test' "writer" ["-f", "native", "-t",
+    , test' "writer" ["-f", "native",
+                      "--markdown-headings=setext", "-t",
                       "ipynb-raw_html-raw_tex+raw_attribute", "-s"]
       "ipynb/simple.in.native" "ipynb/simple.ipynb"
     ]
@@ -241,7 +242,8 @@
     ]
   where
     t n f = test pandocPath
-             n ["--wrap=preserve", "-r", "native", "-s", "-w", f]
+             n ["--wrap=preserve", "-r", "native", "-s",
+              "--markdown-headings=setext", "-w", f]
              "lhs-test.native" ("lhs-test" <.> f)
 
 lhsReaderTest :: FilePath -> String -> TestTree
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
@@ -75,10 +75,10 @@
 
   , testGroup "Comments"
     [ "Comment Block" =:
-      T.unlines [ "#+BEGIN_COMMENT"
+      T.unlines [ "#+begin_comment"
                 , "stuff"
                 , "bla"
-                , "#+END_COMMENT"] =?>
+                , "#+end_comment"] =?>
       (mempty::Blocks)
 
     , "Comment line" =:
@@ -92,16 +92,16 @@
 
   , testGroup "Blocks and fragments"
     [ "HTML block" =:
-      T.unlines [ "#+BEGIN_HTML"
+      T.unlines [ "#+begin_html"
                 , "<aside>HTML5 is pretty nice.</aside>"
-                , "#+END_HTML"
+                , "#+end_html"
                 ] =?>
       rawBlock "html" "<aside>HTML5 is pretty nice.</aside>\n"
 
     , "Quote block" =:
-      T.unlines [ "#+BEGIN_QUOTE"
+      T.unlines [ "#+begin_quote"
                 , "/Niemand/ hat die Absicht, eine Mauer zu errichten!"
-                , "#+END_QUOTE"
+                , "#+end_quote"
                 ] =?>
       blockQuote (para (spcSep [ emph "Niemand", "hat", "die", "Absicht,"
                                , "eine", "Mauer", "zu", "errichten!"
@@ -128,31 +128,31 @@
         ]
 
     , "Verse block with blank lines" =:
-      T.unlines [ "#+BEGIN_VERSE"
+      T.unlines [ "#+begin_verse"
                 , "foo"
                 , ""
                 , "bar"
-                , "#+END_VERSE"
+                , "#+end_verse"
                 ] =?>
       lineBlock [ "foo", mempty, "bar" ]
 
     , "Verse block with varying indentation" =:
-      T.unlines [ "#+BEGIN_VERSE"
+      T.unlines [ "#+begin_verse"
                 , "  hello darkness"
                 , "my old friend"
-                , "#+END_VERSE"
+                , "#+end_verse"
                 ] =?>
       lineBlock [ "\160\160hello darkness", "my old friend" ]
 
     , "Raw block LaTeX" =:
-      T.unlines [ "#+BEGIN_LaTeX"
+      T.unlines [ "#+begin_latex"
                 , "The category $\\cat{Set}$ is adhesive."
-                , "#+END_LaTeX"
+                , "#+end_latex"
                 ] =?>
       rawBlock "latex" "The category $\\cat{Set}$ is adhesive.\n"
 
     , "Raw LaTeX line" =:
-      "#+LATEX: \\let\\foo\\bar" =?>
+      "#+latex: \\let\\foo\\bar" =?>
       rawBlock "latex" "\\let\\foo\\bar"
 
     , "Raw Beamer line" =:
@@ -160,13 +160,13 @@
       rawBlock "beamer" "\\pause"
 
     , "Raw HTML line" =:
-      "#+HTML: <aside>not important</aside>" =?>
+      "#+html: <aside>not important</aside>" =?>
       rawBlock "html" "<aside>not important</aside>"
 
     , "Export block HTML" =:
-      T.unlines [ "#+BEGIN_export html"
+      T.unlines [ "#+begin_export html"
                 , "<samp>Hello, World!</samp>"
-                , "#+END_export"
+                , "#+end_export"
                 ] =?>
       rawBlock "html" "<samp>Hello, World!</samp>\n"
 
@@ -197,13 +197,13 @@
                 ] =?>
       rawBlock "html" "\n<span>boring</span>\n\n"
 
-    , "Accept `ATTR_HTML` attributes for generic block" =:
-      T.unlines [ "#+ATTR_HTML: :title hello, world :id test :class fun code"
-                , "#+BEGIN_TEST"
+    , "Accept `attr_html` attributes for generic block" =:
+      T.unlines [ "#+attr_html: :title hello, world :id test :class fun code"
+                , "#+begin_test"
                 , "nonsense"
-                , "#+END_TEST"
+                , "#+end_test"
                 ] =?>
-      let attr = ("test", ["fun", "code", "TEST"], [("title", "hello, world")])
+      let attr = ("test", ["fun", "code", "test"], [("title", "hello, world")])
       in divWith attr (para "nonsense")
     ]
 
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
@@ -23,48 +23,48 @@
 tests :: [TestTree]
 tests =
   [ "Source block" =:
-       T.unlines [ "  #+BEGIN_SRC haskell"
+       T.unlines [ "  #+begin_src haskell"
                  , "  main = putStrLn greeting"
                  , "    where greeting = \"moin\""
-                 , "  #+END_SRC" ] =?>
+                 , "  #+end_src" ] =?>
        let attr' = ("", ["haskell"], [])
            code' = "main = putStrLn greeting\n" <>
                    "  where greeting = \"moin\"\n"
        in codeBlockWith attr' code'
 
   , "Source block with indented code" =:
-       T.unlines [ "  #+BEGIN_SRC haskell"
+       T.unlines [ "  #+begin_src haskell"
                  , "    main = putStrLn greeting"
                  , "      where greeting = \"moin\""
-                 , "  #+END_SRC" ] =?>
+                 , "  #+end_src" ] =?>
        let attr' = ("", ["haskell"], [])
            code' = "main = putStrLn greeting\n" <>
                    "  where greeting = \"moin\"\n"
        in codeBlockWith attr' code'
 
   , "Source block with tab-indented code" =:
-       T.unlines [ "\t#+BEGIN_SRC haskell"
+       T.unlines [ "\t#+begin_src haskell"
                  , "\tmain = putStrLn greeting"
                  , "\t  where greeting = \"moin\""
-                 , "\t#+END_SRC" ] =?>
+                 , "\t#+end_src" ] =?>
        let attr' = ("", ["haskell"], [])
            code' = "main = putStrLn greeting\n" <>
                    "  where greeting = \"moin\"\n"
        in codeBlockWith attr' code'
 
   , "Empty source block" =:
-       T.unlines [ "  #+BEGIN_SRC haskell"
-                 , "  #+END_SRC" ] =?>
+       T.unlines [ "  #+begin_src haskell"
+                 , "  #+end_src" ] =?>
        let attr' = ("", ["haskell"], [])
            code' = ""
        in codeBlockWith attr' code'
 
   , "Source block between paragraphs" =:
        T.unlines [ "Low German greeting"
-                 , "  #+BEGIN_SRC haskell"
+                 , "  #+begin_src haskell"
                  , "  main = putStrLn greeting"
                  , "    where greeting = \"Moin!\""
-                 , "  #+END_SRC" ] =?>
+                 , "  #+end_src" ] =?>
        let attr' = ("", ["haskell"], [])
            code' = "main = putStrLn greeting\n" <>
                     "  where greeting = \"Moin!\"\n"
@@ -72,10 +72,10 @@
                   , codeBlockWith attr' code'
                   ]
   , "Source block with babel arguments" =:
-       T.unlines [ "#+BEGIN_SRC emacs-lisp :exports both"
+       T.unlines [ "#+begin_src emacs-lisp :exports both"
                  , "(progn (message \"Hello, World!\")"
                  , "       (+ 23 42))"
-                 , "#+END_SRC" ] =?>
+                 , "#+end_src" ] =?>
        let classes = [ "commonlisp" ] -- as kate doesn't know emacs-lisp syntax
            params = [ ("org-language", "emacs-lisp")
                     , ("exports", "both")
@@ -85,10 +85,10 @@
        in codeBlockWith ("", classes, params) code'
 
   , "Source block with results and :exports both" =:
-       T.unlines [ "#+BEGIN_SRC emacs-lisp :exports both"
+       T.unlines [ "#+begin_src emacs-lisp :exports both"
                  , "(progn (message \"Hello, World!\")"
                  , "       (+ 23 42))"
-                 , "#+END_SRC"
+                 , "#+end_src"
                  , ""
                  , "#+RESULTS:"
                  , ": 65"] =?>
@@ -104,10 +104,10 @@
           codeBlockWith ("", ["example"], []) results'
 
   , "Source block with results and :exports code" =:
-       T.unlines [ "#+BEGIN_SRC emacs-lisp :exports code"
+       T.unlines [ "#+begin_src emacs-lisp :exports code"
                  , "(progn (message \"Hello, World!\")"
                  , "       (+ 23 42))"
-                 , "#+END_SRC"
+                 , "#+end_src"
                  , ""
                  , "#+RESULTS:"
                  , ": 65" ] =?>
@@ -120,10 +120,10 @@
        in codeBlockWith ("", classes, params) code'
 
   , "Source block with results and :exports results" =:
-       T.unlines [ "#+BEGIN_SRC emacs-lisp :exports results"
+       T.unlines [ "#+begin_src emacs-lisp :exports results"
                  , "(progn (message \"Hello, World!\")"
                  , "       (+ 23 42))"
-                 , "#+END_SRC"
+                 , "#+end_src"
                  , ""
                  , "#+RESULTS:"
                  , ": 65" ] =?>
@@ -131,37 +131,37 @@
        in codeBlockWith ("", ["example"], []) results'
 
   , "Source block with results and :exports none" =:
-       T.unlines [ "#+BEGIN_SRC emacs-lisp :exports none"
+       T.unlines [ "#+begin_src emacs-lisp :exports none"
                  , "(progn (message \"Hello, World!\")"
                  , "       (+ 23 42))"
-                 , "#+END_SRC"
+                 , "#+end_src"
                  , ""
                  , "#+RESULTS:"
                  , ": 65" ] =?>
        (mempty :: Blocks)
 
   , "Source block with toggling header arguments" =:
-    T.unlines [ "#+BEGIN_SRC sh :noeval"
+    T.unlines [ "#+begin_src sh :noeval"
               , "echo $HOME"
-              , "#+END_SRC"
+              , "#+end_src"
               ] =?>
     let classes = [ "bash" ]
         params = [ ("org-language", "sh"), ("noeval", "yes") ]
     in codeBlockWith ("", classes, params) "echo $HOME\n"
 
   , "Source block with line number switch" =:
-    T.unlines [ "#+BEGIN_SRC sh -n 10"
+    T.unlines [ "#+begin_src sh -n 10"
               , ":() { :|:& };:"
-              , "#+END_SRC"
+              , "#+end_src"
               ] =?>
     let classes = [ "bash", "numberLines" ]
         params = [ ("org-language", "sh"), ("startFrom", "10") ]
     in codeBlockWith ("", classes, params) ":() { :|:& };:\n"
 
   , "Source block with multi-word parameter values" =:
-    T.unlines [ "#+BEGIN_SRC dot :cmdline -Kdot -Tpng "
+    T.unlines [ "#+begin_src dot :cmdline -Kdot -Tpng "
               , "digraph { id [label=\"ID\"] }"
-              , "#+END_SRC"
+              , "#+end_src"
               ] =?>
     let classes = [ "dot" ]
         params = [ ("cmdline", "-Kdot -Tpng") ]
@@ -177,12 +177,12 @@
                      "A chosen representation of\na rule.\n"
 
   , "Code block with caption" =:
-      T.unlines [ "#+CAPTION: Functor laws in Haskell"
-                , "#+NAME: functor-laws"
-                , "#+BEGIN_SRC haskell"
+      T.unlines [ "#+caption: Functor laws in Haskell"
+                , "#+name: functor-laws"
+                , "#+begin_src haskell"
                 , "fmap id = id"
                 , "fmap (p . q) = (fmap p) . (fmap q)"
-                , "#+END_SRC"
+                , "#+end_src"
                 ] =?>
       divWith
          nullAttr
@@ -195,9 +195,9 @@
                                     ])))
 
   , "Non-letter chars in source block parameters" =:
-      T.unlines [ "#+BEGIN_SRC C :tangle xxxx.c :city Zürich"
+      T.unlines [ "#+begin_src C :tangle xxxx.c :city Zürich"
                 , "code body"
-                , "#+END_SRC"
+                , "#+end_src"
                 ] =?>
       let params  = [ ("org-language", "C")
                     , ("tangle", "xxxx.c")
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
@@ -44,9 +44,9 @@
                   "Used as a metapher in evolutionary biology.")
 
   , "Figure with HTML attributes" =:
-      T.unlines [ "#+CAPTION: mah brain just explodid"
-                , "#+NAME: lambdacat"
-                , "#+ATTR_HTML: :style color: blue :role button"
+      T.unlines [ "#+caption: mah brain just explodid"
+                , "#+name: lambdacat"
+                , "#+attr_html: :style color: blue :role button"
                 , "[[file:lambdacat.jpg]]"
                 ] =?>
       let kv = [("style", "color: blue"), ("role", "button")]
@@ -55,22 +55,22 @@
       in para (imageWith (mempty, mempty, kv) "lambdacat.jpg" name caption)
 
   , "LaTeX attributes are ignored" =:
-      T.unlines [ "#+CAPTION: Attribute after caption"
-                , "#+ATTR_LATEX: :float nil"
+      T.unlines [ "#+caption: Attribute after caption"
+                , "#+attr_latex: :float nil"
                 , "[[file:test.png]]"
                 ] =?>
       para (image "test.png" "fig:" "Attribute after caption")
 
   , "Labelled figure" =:
-      T.unlines [ "#+CAPTION: My figure"
-                , "#+LABEL: fig:myfig"
+      T.unlines [ "#+caption: My figure"
+                , "#+label: fig:myfig"
                 , "[[file:blub.png]]"
                 ] =?>
       let attr = ("fig:myfig", mempty, mempty)
       in para (imageWith attr "blub.png" "fig:" "My figure")
 
   , "Figure with empty caption" =:
-      T.unlines [ "#+CAPTION:"
+      T.unlines [ "#+caption:"
                 , "[[file:guess.jpg]]"
                 ] =?>
       para (image "guess.jpg" "fig:" "")
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
@@ -99,7 +99,7 @@
         headerWith ("waiting-header", [], []) 1 "WAITING header"
 
     , "Custom todo keywords" =:
-        T.unlines [ "#+TODO: WAITING CANCELLED"
+        T.unlines [ "#+todo: WAITING CANCELLED"
                   , "* WAITING compile"
                   , "* CANCELLED lunch"
                   ] =?>
@@ -109,7 +109,7 @@
         <> headerWith ("lunch", [], []) 1 (doneSpan <> space <> "lunch")
 
     , "Custom todo keywords with multiple done-states" =:
-        T.unlines [ "#+TODO: WAITING | DONE CANCELLED "
+        T.unlines [ "#+todo: WAITING | DONE CANCELLED "
                   , "* WAITING compile"
                   , "* CANCELLED lunch"
                   , "* DONE todo-feature"
@@ -248,7 +248,7 @@
       headerWith ("look", [], []) 1 "important"
 
     , "third and forth level headers" =:
-      T.unlines [ "#+OPTIONS: p:t h:3"
+      T.unlines [ "#+options: p:t h:3"
                 , "*** Third"
                 , "    CLOSED: [2018-09-05 Wed 13:58]"
                 , "    Text 3"
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
@@ -167,7 +167,7 @@
         ]
 
   , "Table with caption" =:
-      T.unlines [ "#+CAPTION: Hitchhiker's Multiplication Table"
+      T.unlines [ "#+caption: Hitchhiker's Multiplication Table"
                 , "| x |  6 |"
                 , "| 9 | 42 |"
                 ] =?>
@@ -180,7 +180,7 @@
         ]
 
   , "named table" =:
-      T.unlines [ "#+NAME: x-marks-the-spot"
+      T.unlines [ "#+name: x-marks-the-spot"
                 , "| x |"
                 ] =?>
       divWith ("x-marks-the-spot", mempty, mempty)
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
@@ -210,7 +210,7 @@
              <> image "sunset.jpg" "" "")
 
     , "Image with html attributes" =:
-      T.unlines [ "#+ATTR_HTML: :width 50%"
+      T.unlines [ "#+attr_html: :width 50%"
                 , "[[file:guinea-pig.gif]]"
                 ] =?>
       para (imageWith ("", [], [("width", "50%")]) "guinea-pig.gif" "" "")
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
@@ -44,7 +44,7 @@
 
   , testGroup "Export settings"
     [ "Title" =:
-      "#+TITLE: Hello, World" =?>
+      "#+title: Hello, World" =?>
       let titleInline = toList $ "Hello," <> space <> "World"
           meta = setMeta "title" (MetaInlines titleInline) nullMeta
       in Pandoc meta mempty
@@ -69,21 +69,21 @@
       ]
 
     , "Date" =:
-      "#+Date: Feb. *28*, 2014" =?>
+      "#+date: Feb. *28*, 2014" =?>
       let date = toList . spcSep $ [ "Feb.", strong "28" <> ",", "2014" ]
           meta = setMeta "date" (MetaInlines date) nullMeta
       in Pandoc meta mempty
 
     , testGroup "Description"
       [ "Single line" =:
-        "#+DESCRIPTION: Explanatory text" =?>
+        "#+description: Explanatory text" =?>
         let description = [Str "Explanatory", Space, Str "text"]
             meta = setMeta "description" (MetaInlines description) nullMeta
         in Pandoc meta mempty
 
       , "Multiline" =:
-        T.unlines [ "#+DESCRIPTION: /Short/ introduction"
-                  , "#+DESCRIPTION: to Org-mode"
+        T.unlines [ "#+description: /Short/ introduction"
+                  , "#+description: to Org-mode"
                   ] =?>
         let description = [ Emph [Str "Short"], Space, Str "introduction"
                           , SoftBreak
@@ -94,54 +94,54 @@
       ]
 
     , "Subtitle" =:
-      T.unlines [ "#+SUBTITLE: Your Life in"
-                , "#+SUBTITLE: /Plain/ Text"
+      T.unlines [ "#+subtitle: Your Life in"
+                , "#+subtitle: /Plain/ Text"
                 ] =?>
       let subtitle = "Your Life in" <> softbreak <> emph "Plain" <> " Text"
       in Pandoc (setMeta "subtitle" (toMetaValue subtitle) nullMeta) mempty
 
     , "Keywords" =:
-      T.unlines [ "#+KEYWORDS: pandoc, testing,"
-                , "#+KEYWORDS: Org"
+      T.unlines [ "#+keywords: pandoc, testing,"
+                , "#+keywords: Org"
                 ] =?>
       let keywords = toList $ "pandoc, testing," <> softbreak <> "Org"
           meta = setMeta "keywords" (MetaInlines keywords) nullMeta
       in Pandoc meta mempty
 
     , "Institute" =:
-      "#+INSTITUTE: ACME Inc." =?>
+      "#+institute: ACME Inc." =?>
       Pandoc (setMeta "institute" ("ACME Inc." :: Inlines) nullMeta) mempty
 
     , testGroup "LaTeX"
       [ "LATEX_HEADER" =:
-        "#+LaTeX_header: \\usepackage{tikz}" =?>
+        "#+latex_header: \\usepackage{tikz}" =?>
         let latexInlines = rawInline "latex" "\\usepackage{tikz}"
             inclList = MetaList [MetaInlines (toList latexInlines)]
             meta = setMeta "header-includes" inclList nullMeta
         in Pandoc meta mempty
 
       , "LATEX_HEADER_EXTRA" =:
-        "#+LATEX_HEADER_EXTRA: \\usepackage{calc}" =?>
+        "#+latex_header_extra: \\usepackage{calc}" =?>
         let latexInlines = rawInline "latex" "\\usepackage{calc}"
             inclList = toMetaValue [latexInlines]
         in Pandoc (setMeta "header-includes" inclList nullMeta) mempty
 
       , testGroup "LaTeX_CLASS"
         [ "stored as documentclass" =:
-          "#+LATEX_CLASS: article" =?>
+          "#+latex_class: article" =?>
           let meta = setMeta "documentclass" (MetaString "article") nullMeta
           in Pandoc meta mempty
 
         , "last definition takes precedence" =:
-          T.unlines [ "#+LATEX_CLASS: this will not be used"
-                    , "#+LATEX_CLASS: report"
+          T.unlines [ "#+latex_class: this will not be used"
+                    , "#+latex_class: report"
                     ] =?>
           let meta = setMeta "documentclass" (MetaString "report") nullMeta
           in Pandoc meta mempty
         ]
 
       , "LATEX_CLASS_OPTIONS as classoption" =:
-        "#+LATEX_CLASS_OPTIONS: [a4paper]" =?>
+        "#+latex_class_options: [a4paper]" =?>
         let meta = setMeta "classoption" (MetaString "a4paper") nullMeta
         in Pandoc meta mempty
       ]
@@ -155,8 +155,8 @@
         in Pandoc meta mempty
 
       , "HTML_HEAD_EXTRA behaves like HTML_HEAD" =:
-        T.unlines [ "#+HTML_HEAD: <meta name=\"generator\" content=\"pandoc\">"
-                  , "#+HTML_HEAD_EXTRA: <meta charset=\"utf-8\">"
+        T.unlines [ "#+html_head: <meta name=\"generator\" content=\"pandoc\">"
+                  , "#+html_head_extra: <meta charset=\"utf-8\">"
                   ] =?>
         let generator = rawInline "html"
                                   "<meta name=\"generator\" content=\"pandoc\">"
@@ -167,9 +167,9 @@
     ]
 
   , testGroup "Non-export keywords"
-    [ testGroup "#+LINK"
+    [ testGroup "#+link"
       [ "Link abbreviation" =:
-        T.unlines [ "#+LINK: wp https://en.wikipedia.org/wiki/%s"
+        T.unlines [ "#+link: wp https://en.wikipedia.org/wiki/%s"
                   , "[[wp:Org_mode][Wikipedia on Org-mode]]"
                   ] =?>
         para (link "https://en.wikipedia.org/wiki/Org_mode" ""
@@ -177,7 +177,7 @@
 
       , "Link abbreviation, defined after first use" =:
         T.unlines [ "[[zl:non-sense][Non-sense articles]]"
-                  , "#+LINK: zl http://zeitlens.com/tags/%s.html"
+                  , "#+link: zl http://zeitlens.com/tags/%s.html"
                   ] =?>
         para (link "http://zeitlens.com/tags/non-sense.html" ""
                ("Non-sense" <> space <> "articles"))
@@ -214,11 +214,11 @@
       ]
 
     , "Unknown keyword" =:
-      T.unlines [ "#+UNKNOWN_KEYWORD: Chumbawamba"
-                , "#+ANOTHER_UNKNOWN: Blur"
+      T.unlines [ "#+unknown_keyword: Chumbawamba"
+                , "#+another_unknown: Blur"
                 ] =?>
-      rawBlock "org" "#+UNKNOWN_KEYWORD: Chumbawamba" <>
-      rawBlock "org" "#+ANOTHER_UNKNOWN: Blur"
+      rawBlock "org" "#+unknown_keyword: Chumbawamba" <>
+      rawBlock "org" "#+another_unknown: Blur"
     ]
 
   , "Properties drawer" =:
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
@@ -12,7 +12,9 @@
 import Text.Pandoc.Builder
 
 defopts :: WriterOptions
-defopts = def{ writerExtensions = pandocExtensions }
+defopts = def
+  { writerExtensions = pandocExtensions
+  , writerSetextHeaders = True }
 
 markdown :: (ToPandoc a) => a -> String
 markdown = unpack . purely (writeMarkdown defopts) . toPandoc
diff --git a/test/command/3674.md b/test/command/3674.md
--- a/test/command/3674.md
+++ b/test/command/3674.md
@@ -2,7 +2,7 @@
 `--reference-location=section`.
 
 ```
-% pandoc --reference-links -t markdown --reference-location=section --atx-headers
+% pandoc --reference-links -t markdown --reference-location=section
 # a
 
 ![](a)
diff --git a/test/command/3706.md b/test/command/3706.md
--- a/test/command/3706.md
+++ b/test/command/3706.md
@@ -2,12 +2,12 @@
 
 ```
 pandoc -f org -t native
-#+BEGIN_SRC R :exports results :colnames yes
+#+begin_src r :exports results :colnames yes
    data.frame(Id = 1:3, Desc = rep("La",3))
-#+END_SRC
+#+end_src
 
-#+CAPTION: Lalelu.
-#+LABEL: tab
+#+caption: Lalelu.
+#+label: tab
 #+RESULTS:
 | Id | Desc |
 |----+------|
@@ -49,12 +49,12 @@
 
 ```
 pandoc -f org -t native
-#+BEGIN_SRC R :exports none :colnames yes
+#+begin_src R :exports none :colnames yes
    data.frame(Id = 1:2, Desc = rep("La",2))
-#+END_SRC
+#+end_src
 
-#+CAPTION: Lalelu.
-#+LABEL: tab
+#+caption: Lalelu.
+#+label: tab
 #+RESULTS:
 | Id | Desc |
 |----+------|
diff --git a/test/command/3736.md b/test/command/3736.md
--- a/test/command/3736.md
+++ b/test/command/3736.md
@@ -3,8 +3,7 @@
 <h2>hi
 there</h2>
 ^D
-hi there
---------
+## hi there
 ```
 
 ```
@@ -12,14 +11,12 @@
 <h2>hi <em>there
 again</em></h2>
 ^D
-hi *there again*
-----------------
+## hi *there again*
 ```
 
 ```
 % pandoc --wrap=preserve -f html -t markdown
 <h2>hi<br>there</h2>
 ^D
-hi there
---------
+## hi there
 ```
diff --git a/test/command/4038.md b/test/command/4038.md
--- a/test/command/4038.md
+++ b/test/command/4038.md
@@ -1,5 +1,5 @@
 ```
-% pandoc -f gfm -t gfm --atx-headers
+% pandoc -f gfm -t gfm
 # ~~Header~~
 ^D
 # ~~Header~~
diff --git a/test/command/4164.md b/test/command/4164.md
--- a/test/command/4164.md
+++ b/test/command/4164.md
@@ -2,11 +2,9 @@
 % pandoc -f opml -t markdown
 <?xml version="1.0"?> <opml version="1.0"> <head> <title> test </title> </head> <body> <outline text="test"> <outline text="try" _note="Here is inline html:&#xA;&#xA;&lt;div&gt; &#xA;&lt;balise&gt;&#xA;bla bla&#xA;&lt;/div&gt;"/> </outline> </body> </opml>
 ^D
-test
-====
+# test
 
-try
----
+## try
 
 Here is inline html:
 
@@ -22,11 +20,9 @@
 % pandoc -f opml-raw_html-native_divs -t markdown
 <?xml version="1.0"?> <opml version="1.0"> <head> <title> test </title> </head> <body> <outline text="test"> <outline text="try" _note="Here is inline html:&#xA;&#xA;&lt;div&gt; &#xA;&lt;balise&gt;&#xA;bla bla&#xA;&lt;/div&gt;"/> </outline> </body> </opml>
 ^D
-test
-====
+# test
 
-try
----
+## try
 
 Here is inline html:
 
diff --git a/test/command/4186.md b/test/command/4186.md
--- a/test/command/4186.md
+++ b/test/command/4186.md
@@ -1,8 +1,8 @@
 ```
 % pandoc -f org -t native
-#+BEGIN_EXAMPLE -i
+#+begin_example -i
     This should retain the four leading spaces
-#+END_EXAMPLE
+#+end_example
 ^D
 [CodeBlock ("",["example"],[]) "    This should retain the four leading spaces\n"]
 ```
@@ -10,10 +10,10 @@
 ```
 % pandoc -f org -t html
 - depth 1
-  #+NAME: bob
-  #+BEGIN_EXAMPLE -i
+  #+name: bob
+  #+begin_example -i
     Vertical alignment is four spaces beyond the appearance of the word "depth".
-  #+END_EXAMPLE
+  #+end_example
        - depth 2
          #+begin_example
                           Vertically aligned with the second appearance of the word "depth".
@@ -27,10 +27,10 @@
     inner list element.
     #+end_example
          Still inside the inner list element
-   #+NAME: carrie
-                         #+BEGIN_EXAMPLE
+   #+name: carrie
+                         #+begin_example
                            This belongs to the outer list element, and is aligned accordingly, since the NAME attribute is not indented deeply enough. It is not enough for the BEGIN alone to be aligned deeply if the block is meant to have a NAME.
-                           #+END_EXAMPLE
+                           #+end_example
                  Still in the shallower list element since the preceding example
                  block forced the deeper list element to terminate.
 Outside all lists.
diff --git a/test/command/5121.md b/test/command/5121.md
--- a/test/command/5121.md
+++ b/test/command/5121.md
@@ -8,6 +8,5 @@
 <img src="./my-figure.jpg" width="500" alt="My caption" /><figcaption aria-hidden="true">My caption</figcaption>
 </figure>
 
-Header 2
---------
+## Header 2
 ```
diff --git a/test/command/5178.md b/test/command/5178.md
--- a/test/command/5178.md
+++ b/test/command/5178.md
@@ -6,21 +6,21 @@
    main = putStrLn "Hello World!"
    unsafePerformIO main
 ^D
-#+BEGIN_SRC haskell -n 42
+#+begin_src haskell -n 42
   main = putStrLn "Hello World!"
   unsafePerformIO main
-#+END_SRC
+#+end_src
 ```
 
 ```
 % pandoc -f org -t native
-#+BEGIN_SRC lisp -n 20
+#+begin_src lisp -n 20
   (+ 1 1)
-#+END_SRC
+#+end_src
 
-#+BEGIN_SRC lisp +n 10
+#+begin_src lisp +n 10
   (+ 2 2)
-#+END_SRC
+#+end_src
 ^D
 [CodeBlock ("",["commonlisp","numberLines"],[("org-language","lisp"),("startFrom","20")]) "(+ 1 1)\n"
 ,CodeBlock ("",["commonlisp","numberLines","continuedSourceBlock"],[("org-language","lisp"),("startFrom","10")]) "(+ 2 2)\n"]
@@ -31,11 +31,11 @@
 [CodeBlock ("",["commonlisp","numberLines"],[("org-language","lisp"),("startFrom","20")]) "(+ 1 1)\n"
 ,CodeBlock ("",["commonlisp","numberLines","continuedSourceBlock"],[("org-language","lisp"),("startFrom","10")]) "(+ 2 2)\n"]
 ^D
-#+BEGIN_SRC lisp -n 20
+#+begin_src lisp -n 20
   (+ 1 1)
-#+END_SRC
+#+end_src
 
-#+BEGIN_SRC lisp +n 10
+#+begin_src lisp +n 10
   (+ 2 2)
-#+END_SRC
+#+end_src
 ```
diff --git a/test/command/6723.md b/test/command/6723.md
--- a/test/command/6723.md
+++ b/test/command/6723.md
@@ -20,8 +20,7 @@
 ^D
 Blah.[^1]
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent}
 ::: {#ref-doe .csl-entry}
diff --git a/test/command/6836.md b/test/command/6836.md
new file mode 100644
--- /dev/null
+++ b/test/command/6836.md
@@ -0,0 +1,17 @@
+```
+pandoc -t native
+[@buchanan]
+
+(@foo)
+
+See @foo.
+
+[@buchanan]
+^D
+[Para [Cite [Citation {citationId = "buchanan", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 1, citationHash = 0}] [Str "[@buchanan]"]]
+,OrderedList (1,Example,TwoParens)
+ [[]]
+,Para [Str "See",Space,Str "1."]
+,Para [Cite [Citation {citationId = "buchanan", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 2, citationHash = 0}] [Str "[@buchanan]"]]]
+```
+
diff --git a/test/command/6837.md b/test/command/6837.md
new file mode 100644
--- /dev/null
+++ b/test/command/6837.md
@@ -0,0 +1,29 @@
+```
+% pandoc -t markdown --markdown-headings=setext
+## Hi
+
+### Ok
+^D
+Hi
+--
+
+### Ok
+```
+
+```
+% pandoc -t markdown+lhs
+# Hi
+^D
+[WARNING] Rendering heading 'Hi' as a paragraph.
+  ATX headings cannot be used in literate Haskell, because '#' is not
+  allowed in column 1. Consider using --markdown-headings=setext.
+Hi
+```
+
+```
+% pandoc -t markdown --markdown-headings=atx
+Hi
+--
+^D
+## Hi
+```
diff --git a/test/command/6844.md b/test/command/6844.md
new file mode 100644
--- /dev/null
+++ b/test/command/6844.md
@@ -0,0 +1,27 @@
+Negative numbers with siunitx
+
+```
+% pandoc -f latex -t native
+\SI{123}{\celsius}
+
+^D
+[Para [Str "123\160\176C"]]
+```
+
+```
+% pandoc -f latex -t native
+\SI{-123}{\celsius}
+
+^D
+[Para [Str "\8722\&123\160\176C"]]
+```
+
+```
+% pandoc -f latex -t native
+\SI{+123}{\celsius}
+
+^D
+[Para [Str "123\160\176C"]]
+```
+
+
diff --git a/test/command/6855.md b/test/command/6855.md
new file mode 100644
--- /dev/null
+++ b/test/command/6855.md
@@ -0,0 +1,12 @@
+```
+% pandoc -t markdown
+(@a) one
+(@b) two
+
+See (@a--@b)
+^D
+(1) one
+(2) two
+
+See (1--2)
+```
diff --git a/test/command/6858.md b/test/command/6858.md
new file mode 100644
--- /dev/null
+++ b/test/command/6858.md
@@ -0,0 +1,52 @@
+```
+% pandoc -t markdown -f man
+.TH FvwmAnimate 1 "Date" Fvwm "Fvwm Modules"
+.UC
+.SH NAME
+\fBFvwmAnimate\fP \- the fvwm animate module
+.SH SYNOPSIS
+Module FvwmAnimate [ModuleAlias]
+
+.IP "*FvwmAnimate: Color \fBcolor\fP"
+
+Tells \fBFvwmAnimate\fP what color to draw with.
+The color is "XOR'ed" (exclusive ORed) onto the background.
+
+.IP "*FvwmAnimate: Pixmap \fBpixmap\fP"
+
+Tells \fBFvwmAnimate\fP to use \fBpixmap\fP to draw with. This can be useful
+if \fB*FvwmAnimate: Color\fP gives poor results.
+^D
+# NAME
+
+**FvwmAnimate** - the fvwm animate module
+
+# SYNOPSIS
+
+Module FvwmAnimate \[ModuleAlias\]
+
+\*FvwmAnimate: Color color
+
+:   Tells **FvwmAnimate** what color to draw with. The color is
+    \"XOR\'ed\" (exclusive ORed) onto the background.
+
+\*FvwmAnimate: Pixmap pixmap
+
+:   Tells **FvwmAnimate** to use **pixmap** to draw with. This can be
+    useful if **\*FvwmAnimate: Color** gives poor results.
+```
+
+```
+% pandoc -t markdown -f man
+.IP "\[bu]"
+
+hi
+
+.IP "\[bu]"
+
+there
+^D
+-   hi
+
+-   there
+```
diff --git a/test/command/citeproc-author-in-text-suffix.md b/test/command/citeproc-author-in-text-suffix.md
new file mode 100644
--- /dev/null
+++ b/test/command/citeproc-author-in-text-suffix.md
@@ -0,0 +1,6 @@
+```
+% pandoc -t native
+@a [p. 33; @b]
+^D
+[Para [Cite [Citation {citationId = "a", citationPrefix = [], citationSuffix = [Str "p.\160\&33"], citationMode = AuthorInText, citationNoteNum = 1, citationHash = 0},Citation {citationId = "b", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 1, citationHash = 0}] [Str "@a",Space,Str "[p.",Space,Str "33;",Space,Str "@b]"]]]
+```
diff --git a/test/command/pandoc-citeproc-119.md b/test/command/pandoc-citeproc-119.md
--- a/test/command/pandoc-citeproc-119.md
+++ b/test/command/pandoc-citeproc-119.md
@@ -12,8 +12,7 @@
 ^D
 Averroes (1982); Averroes (1892); Averroes (1869)
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent line-spacing="2"}
 ::: {#ref-averroes/hercz .csl-entry}
diff --git a/test/command/pandoc-citeproc-14.md b/test/command/pandoc-citeproc-14.md
--- a/test/command/pandoc-citeproc-14.md
+++ b/test/command/pandoc-citeproc-14.md
@@ -54,8 +54,7 @@
 Foo (Pelikan 1971b, 1:12). Bar (Pelikan 1971c, 1:12). Baz (Pelikan
 1971a, 12).
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent}
 ::: {#ref-CTv1c2 .csl-entry}
diff --git a/test/command/pandoc-citeproc-152.md b/test/command/pandoc-citeproc-152.md
--- a/test/command/pandoc-citeproc-152.md
+++ b/test/command/pandoc-citeproc-152.md
@@ -43,13 +43,11 @@
 References
 ==========
 ^D
-Test
-====
+# Test
 
 I have two citations ("Communities," 2011; "Geek Feminism," 2013).
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent line-spacing="2"}
 ::: {#ref-Feminism2011ces .csl-entry}
diff --git a/test/command/pandoc-citeproc-160.md b/test/command/pandoc-citeproc-160.md
--- a/test/command/pandoc-citeproc-160.md
+++ b/test/command/pandoc-citeproc-160.md
@@ -26,13 +26,11 @@
 >
 > \[Jane11\] Jane Doe. A book. 2011.
 ^D
-No citation-label
------------------
+## No citation-label
 
 Foo \[Jane11\].
 
-Expected
---------
+## Expected
 
 > Foo \[Jane11\].
 >
diff --git a/test/command/pandoc-citeproc-175.md b/test/command/pandoc-citeproc-175.md
--- a/test/command/pandoc-citeproc-175.md
+++ b/test/command/pandoc-citeproc-175.md
@@ -27,13 +27,11 @@
 
 > Doe, Jane. 2011. "A Title." *A Magazine*, January--February.
 ^D
-Missing en-dash between months
-------------------------------
+## Missing en-dash between months
 
 Foo (Doe 2011).
 
-Expected
---------
+## Expected
 
 > Doe, Jane. 2011. "A Title." *A Magazine*, January--February.
 
diff --git a/test/command/pandoc-citeproc-213.md b/test/command/pandoc-citeproc-213.md
--- a/test/command/pandoc-citeproc-213.md
+++ b/test/command/pandoc-citeproc-213.md
@@ -23,8 +23,7 @@
 ^D
 Foo (Doe 1999).
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent}
 ::: {#ref-doe1 .csl-entry}
diff --git a/test/command/pandoc-citeproc-25.md b/test/command/pandoc-citeproc-25.md
--- a/test/command/pandoc-citeproc-25.md
+++ b/test/command/pandoc-citeproc-25.md
@@ -20,8 +20,7 @@
 ^D
 Foo (Author 1998).
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent}
 ::: {#ref-item1 .csl-entry}
diff --git a/test/command/pandoc-citeproc-27.md b/test/command/pandoc-citeproc-27.md
--- a/test/command/pandoc-citeproc-27.md
+++ b/test/command/pandoc-citeproc-27.md
@@ -25,8 +25,7 @@
 
 Here is some text that needs a citation [@AuthorOne2014].
 ^D
-Minimal example
-===============
+# Minimal example
 
 Here is some text that needs a citation (*1*).
 
diff --git a/test/command/pandoc-citeproc-371.md b/test/command/pandoc-citeproc-371.md
--- a/test/command/pandoc-citeproc-371.md
+++ b/test/command/pandoc-citeproc-371.md
@@ -26,8 +26,7 @@
 ^D
 Foo (Doe 2018, in press).
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent}
 ::: {#ref-item2 .csl-entry}
diff --git a/test/command/pandoc-citeproc-416.md b/test/command/pandoc-citeproc-416.md
--- a/test/command/pandoc-citeproc-416.md
+++ b/test/command/pandoc-citeproc-416.md
@@ -42,8 +42,7 @@
 ^D
 Blah blah (Doe 2010, 2007, 2008).
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent}
 ::: {#ref-item2 .csl-entry}
diff --git a/test/command/pandoc-citeproc-47.md b/test/command/pandoc-citeproc-47.md
--- a/test/command/pandoc-citeproc-47.md
+++ b/test/command/pandoc-citeproc-47.md
@@ -90,8 +90,7 @@
 chronological order is maintained, regardless of the added abbreviation.
 \[ed., trans., comp., or whatever\]"
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent}
 ::: {#ref-doe .csl-entry}
diff --git a/test/command/pandoc-citeproc-57.md b/test/command/pandoc-citeproc-57.md
--- a/test/command/pandoc-citeproc-57.md
+++ b/test/command/pandoc-citeproc-57.md
@@ -25,8 +25,7 @@
 ^D
 (Faraday, forthcoming)
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent}
 ::: {#ref-Faraday-forthcoming .csl-entry}
diff --git a/test/command/pandoc-citeproc-58.md b/test/command/pandoc-citeproc-58.md
--- a/test/command/pandoc-citeproc-58.md
+++ b/test/command/pandoc-citeproc-58.md
@@ -22,8 +22,7 @@
 In this item, the title replaces the (unknown) author (see 14.79)
 (*Stanze in lode della donna brutta* 1547, 12).
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent}
 ::: {#ref-stanze .csl-entry}
diff --git a/test/command/pandoc-citeproc-61.md b/test/command/pandoc-citeproc-61.md
--- a/test/command/pandoc-citeproc-61.md
+++ b/test/command/pandoc-citeproc-61.md
@@ -41,8 +41,7 @@
 References
 ==========
 ^D
-Text
-====
+# Text
 
 Foo[^1]
 
@@ -54,8 +53,7 @@
 
 Foo[^5]
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent}
 ::: {#ref-doe .csl-entry}
diff --git a/test/command/pandoc-citeproc-82.md b/test/command/pandoc-citeproc-82.md
--- a/test/command/pandoc-citeproc-82.md
+++ b/test/command/pandoc-citeproc-82.md
@@ -22,10 +22,9 @@
 
 Some text.[^1]
 
-[^1]: Comment regarding text, supported by citation [@OCLC_i1099]
+[^1]: Comment regarding text, supported by citation [@OCLC_i1099].
 ^D
-Title
-=====
+# Title
 
 Some text.[^1]
 
@@ -36,5 +35,5 @@
 :::
 :::
 
-[^1]: Comment regarding text, supported by citation (OCLC, "WorldCat.")
+[^1]: Comment regarding text, supported by citation (OCLC, "WorldCat").
 ```
diff --git a/test/command/pandoc-citeproc-87.md b/test/command/pandoc-citeproc-87.md
--- a/test/command/pandoc-citeproc-87.md
+++ b/test/command/pandoc-citeproc-87.md
@@ -120,8 +120,7 @@
 
 Doe (2006b) -- article-newspaper YM
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent}
 ::: {#ref-item2a .csl-entry}
diff --git a/test/command/pandoc-citeproc-chicago-author-date.md b/test/command/pandoc-citeproc-chicago-author-date.md
--- a/test/command/pandoc-citeproc-chicago-author-date.md
+++ b/test/command/pandoc-citeproc-chicago-author-date.md
@@ -48,8 +48,7 @@
     locator [-@item2 p. 44].
 ^D
 [WARNING] Citeproc: citation nonexistent not found
-Pandoc with citeproc-hs
-=======================
+# Pandoc with citeproc-hs
 
 ([**nonexistent?**](#ref-nonexistent))
 
@@ -82,8 +81,7 @@
 
 With some markup (*see* [Doe 2005, 32](#ref-item1)).
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent}
 ::: {#ref-item1 .csl-entry}
diff --git a/test/command/pandoc-citeproc-chicago-fullnote-bibliography.md b/test/command/pandoc-citeproc-chicago-fullnote-bibliography.md
--- a/test/command/pandoc-citeproc-chicago-fullnote-bibliography.md
+++ b/test/command/pandoc-citeproc-chicago-fullnote-bibliography.md
@@ -49,8 +49,7 @@
     [-@item1], and now Doe with a locator [-@item2 p. 44].
 ^D
 [WARNING] Citeproc: citation nonexistent not found
-Pandoc with citeproc-hs
-=======================
+# Pandoc with citeproc-hs
 
 [^1]
 
@@ -80,8 +79,7 @@
 
 With some markup.[^14]
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body .hanging-indent}
 ::: {#ref-item2 .csl-entry}
diff --git a/test/command/pandoc-citeproc-ieee.md b/test/command/pandoc-citeproc-ieee.md
--- a/test/command/pandoc-citeproc-ieee.md
+++ b/test/command/pandoc-citeproc-ieee.md
@@ -49,8 +49,7 @@
     locator [-@item2 p. 44].
 ^D
 [WARNING] Citeproc: citation nonexistent not found
-Pandoc with citeproc-hs
-=======================
+# Pandoc with citeproc-hs
 
 [**nonexistent?**](#ref-nonexistent)
 
@@ -83,8 +82,7 @@
 
 With some markup *see* [\[1, p. 32\]](#ref-item1).
 
-References {#references .unnumbered}
-==========
+# References {#references .unnumbered}
 
 ::: {#refs .references .csl-bib-body}
 ::: {#ref-item1 .csl-entry}
diff --git a/test/command/toc.md b/test/command/toc.md
--- a/test/command/toc.md
+++ b/test/command/toc.md
@@ -23,34 +23,25 @@
 -   [E](#e)
     -   [e](#e-1)
 
-A
-=
+# A
 
-b
--
+## b
 
-B
-=
+# B
 
-b
--
+## b
 
 ::: {.interior}
-C
-=
+# C
 
-cc
---
+## cc
 
-D
-=
+# D
 :::
 
 ::: {.blue}
-E
-=
+# E
 
-e
--
+## e
 :::
 ```
diff --git a/test/markdown-reader-more.native b/test/markdown-reader-more.native
--- a/test/markdown-reader-more.native
+++ b/test/markdown-reader-more.native
@@ -328,7 +328,7 @@
 ,Header 2 ("reference-link-fallbacks",[],[]) [Str "Reference",Space,Str "link",Space,Str "fallbacks"]
 ,Para [Str "[",Emph [Str "not",Space,Str "a",Space,Str "link"],Str "]",Space,Str "[",Emph [Str "nope"],Str "]\8230"]
 ,Header 2 ("reference-link-followed-by-a-citation",[],[]) [Str "Reference",Space,Str "link",Space,Str "followed",Space,Str "by",Space,Str "a",Space,Str "citation"]
-,Para [Str "MapReduce",Space,Str "is",Space,Str "a",Space,Str "paradigm",Space,Str "popularized",Space,Str "by",Space,Link ("",[],[]) [Str "Google"] ("http://google.com",""),Space,Cite [Citation {citationId = "mapreduce", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 3, citationHash = 0}] [Str "[@mapreduce]"],Space,Str "as",Space,Str "its",SoftBreak,Str "most",Space,Str "vocal",Space,Str "proponent."]
+,Para [Str "MapReduce",Space,Str "is",Space,Str "a",Space,Str "paradigm",Space,Str "popularized",Space,Str "by",Space,Link ("",[],[]) [Str "Google"] ("http://google.com",""),Space,Cite [Citation {citationId = "mapreduce", citationPrefix = [], citationSuffix = [], citationMode = NormalCitation, citationNoteNum = 2, citationHash = 0}] [Str "[@mapreduce]"],Space,Str "as",Space,Str "its",SoftBreak,Str "most",Space,Str "vocal",Space,Str "proponent."]
 ,Header 2 ("empty-reference-links",[],[]) [Str "Empty",Space,Str "reference",Space,Str "links"]
 ,Para [Str "bar"]
 ,Para [Link ("",[],[]) [Str "foo2"] ("","")]
diff --git a/test/org-select-tags.org b/test/org-select-tags.org
--- a/test/org-select-tags.org
+++ b/test/org-select-tags.org
@@ -1,5 +1,5 @@
-#+SELECT_TAGS: yes no
-#+EXCLUDE_TAGS: no
+#+select_tags: yes no
+#+exclude_tags: no
 
 In a document containing one or more trees containing a tag
 listed in SELECT_TAGS, only those trees and their ancestor nodes will appear;
diff --git a/test/tables.jats_archiving b/test/tables.jats_archiving
--- a/test/tables.jats_archiving
+++ b/test/tables.jats_archiving
@@ -39,40 +39,42 @@
   </table>
 </table-wrap>
 <p>Simple table without caption:</p>
-<table>
-  <col align="right" />
-  <col align="left" />
-  <col align="center" />
-  <col align="left" />
-  <thead>
-    <tr>
-      <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>
-    </tr>
-    <tr>
-      <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>
-    </tr>
-  </tbody>
-</table>
+<table-wrap>
+  <table>
+    <col align="right" />
+    <col align="left" />
+    <col align="center" />
+    <col align="left" />
+    <thead>
+      <tr>
+        <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>
+      </tr>
+      <tr>
+        <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>
+      </tr>
+    </tbody>
+  </table>
+</table-wrap>
 <p>Simple table indented two spaces:</p>
 <table-wrap>
   <caption>
@@ -148,79 +150,85 @@
   </table>
 </table-wrap>
 <p>Multiline table without caption:</p>
-<table>
-  <col width="15*" align="center" />
-  <col width="13*" align="left" />
-  <col width="16*" align="right" />
-  <col width="35*" align="left" />
-  <thead>
-    <tr>
-      <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>
-    </tr>
-    <tr>
-      <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>
+  <table>
+    <col width="15*" align="center" />
+    <col width="13*" align="left" />
+    <col width="16*" align="right" />
+    <col width="35*" align="left" />
+    <thead>
+      <tr>
+        <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>
+      </tr>
+      <tr>
+        <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>Table without column headers:</p>
-<table>
-  <col align="right" />
-  <col align="left" />
-  <col align="center" />
-  <col align="right" />
-  <tbody>
-    <tr>
-      <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>
-    </tr>
-    <tr>
-      <td>1</td>
-      <td>1</td>
-      <td>1</td>
-      <td>1</td>
-    </tr>
-  </tbody>
-</table>
+<table-wrap>
+  <table>
+    <col align="right" />
+    <col align="left" />
+    <col align="center" />
+    <col align="right" />
+    <tbody>
+      <tr>
+        <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>
+      </tr>
+      <tr>
+        <td>1</td>
+        <td>1</td>
+        <td>1</td>
+        <td>1</td>
+      </tr>
+    </tbody>
+  </table>
+</table-wrap>
 <p>Multiline table without column headers:</p>
-<table>
-  <col width="15*" align="center" />
-  <col width="13*" align="left" />
-  <col width="16*" align="right" />
-  <col width="35*" align="left" />
-  <tbody>
-    <tr>
-      <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>
-    </tr>
-  </tbody>
-</table>
+<table-wrap>
+  <table>
+    <col width="15*" align="center" />
+    <col width="13*" align="left" />
+    <col width="16*" align="right" />
+    <col width="35*" align="left" />
+    <tbody>
+      <tr>
+        <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>
+      </tr>
+    </tbody>
+  </table>
+</table-wrap>
diff --git a/test/tables.jats_articleauthoring b/test/tables.jats_articleauthoring
--- a/test/tables.jats_articleauthoring
+++ b/test/tables.jats_articleauthoring
@@ -39,40 +39,42 @@
   </table>
 </table-wrap>
 <p>Simple table without caption:</p>
-<table>
-  <col align="right" />
-  <col align="left" />
-  <col align="center" />
-  <col align="left" />
-  <thead>
-    <tr>
-      <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>
-    </tr>
-    <tr>
-      <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>
-    </tr>
-  </tbody>
-</table>
+<table-wrap>
+  <table>
+    <col align="right" />
+    <col align="left" />
+    <col align="center" />
+    <col align="left" />
+    <thead>
+      <tr>
+        <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>
+      </tr>
+      <tr>
+        <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>
+      </tr>
+    </tbody>
+  </table>
+</table-wrap>
 <p>Simple table indented two spaces:</p>
 <table-wrap>
   <caption>
@@ -148,79 +150,85 @@
   </table>
 </table-wrap>
 <p>Multiline table without caption:</p>
-<table>
-  <col width="15*" align="center" />
-  <col width="13*" align="left" />
-  <col width="16*" align="right" />
-  <col width="35*" align="left" />
-  <thead>
-    <tr>
-      <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>
-    </tr>
-    <tr>
-      <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>
+  <table>
+    <col width="15*" align="center" />
+    <col width="13*" align="left" />
+    <col width="16*" align="right" />
+    <col width="35*" align="left" />
+    <thead>
+      <tr>
+        <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>
+      </tr>
+      <tr>
+        <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>Table without column headers:</p>
-<table>
-  <col align="right" />
-  <col align="left" />
-  <col align="center" />
-  <col align="right" />
-  <tbody>
-    <tr>
-      <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>
-    </tr>
-    <tr>
-      <td>1</td>
-      <td>1</td>
-      <td>1</td>
-      <td>1</td>
-    </tr>
-  </tbody>
-</table>
+<table-wrap>
+  <table>
+    <col align="right" />
+    <col align="left" />
+    <col align="center" />
+    <col align="right" />
+    <tbody>
+      <tr>
+        <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>
+      </tr>
+      <tr>
+        <td>1</td>
+        <td>1</td>
+        <td>1</td>
+        <td>1</td>
+      </tr>
+    </tbody>
+  </table>
+</table-wrap>
 <p>Multiline table without column headers:</p>
-<table>
-  <col width="15*" align="center" />
-  <col width="13*" align="left" />
-  <col width="16*" align="right" />
-  <col width="35*" align="left" />
-  <tbody>
-    <tr>
-      <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>
-    </tr>
-  </tbody>
-</table>
+<table-wrap>
+  <table>
+    <col width="15*" align="center" />
+    <col width="13*" align="left" />
+    <col width="16*" align="right" />
+    <col width="35*" align="left" />
+    <tbody>
+      <tr>
+        <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>
+      </tr>
+    </tbody>
+  </table>
+</table-wrap>
diff --git a/test/tables.jats_publishing b/test/tables.jats_publishing
--- a/test/tables.jats_publishing
+++ b/test/tables.jats_publishing
@@ -39,40 +39,42 @@
   </table>
 </table-wrap>
 <p>Simple table without caption:</p>
-<table>
-  <col align="right" />
-  <col align="left" />
-  <col align="center" />
-  <col align="left" />
-  <thead>
-    <tr>
-      <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>
-    </tr>
-    <tr>
-      <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>
-    </tr>
-  </tbody>
-</table>
+<table-wrap>
+  <table>
+    <col align="right" />
+    <col align="left" />
+    <col align="center" />
+    <col align="left" />
+    <thead>
+      <tr>
+        <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>
+      </tr>
+      <tr>
+        <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>
+      </tr>
+    </tbody>
+  </table>
+</table-wrap>
 <p>Simple table indented two spaces:</p>
 <table-wrap>
   <caption>
@@ -148,79 +150,85 @@
   </table>
 </table-wrap>
 <p>Multiline table without caption:</p>
-<table>
-  <col width="15*" align="center" />
-  <col width="13*" align="left" />
-  <col width="16*" align="right" />
-  <col width="35*" align="left" />
-  <thead>
-    <tr>
-      <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>
-    </tr>
-    <tr>
-      <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>
+  <table>
+    <col width="15*" align="center" />
+    <col width="13*" align="left" />
+    <col width="16*" align="right" />
+    <col width="35*" align="left" />
+    <thead>
+      <tr>
+        <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>
+      </tr>
+      <tr>
+        <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>Table without column headers:</p>
-<table>
-  <col align="right" />
-  <col align="left" />
-  <col align="center" />
-  <col align="right" />
-  <tbody>
-    <tr>
-      <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>
-    </tr>
-    <tr>
-      <td>1</td>
-      <td>1</td>
-      <td>1</td>
-      <td>1</td>
-    </tr>
-  </tbody>
-</table>
+<table-wrap>
+  <table>
+    <col align="right" />
+    <col align="left" />
+    <col align="center" />
+    <col align="right" />
+    <tbody>
+      <tr>
+        <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>
+      </tr>
+      <tr>
+        <td>1</td>
+        <td>1</td>
+        <td>1</td>
+        <td>1</td>
+      </tr>
+    </tbody>
+  </table>
+</table-wrap>
 <p>Multiline table without column headers:</p>
-<table>
-  <col width="15*" align="center" />
-  <col width="13*" align="left" />
-  <col width="16*" align="right" />
-  <col width="35*" align="left" />
-  <tbody>
-    <tr>
-      <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>
-    </tr>
-  </tbody>
-</table>
+<table-wrap>
+  <table>
+    <col width="15*" align="center" />
+    <col width="13*" align="left" />
+    <col width="16*" align="right" />
+    <col width="35*" align="left" />
+    <tbody>
+      <tr>
+        <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>
+      </tr>
+    </tbody>
+  </table>
+</table-wrap>
diff --git a/test/tables.org b/test/tables.org
--- a/test/tables.org
+++ b/test/tables.org
@@ -5,7 +5,7 @@
 | 12    | 12   | 12     | 12      |
 | 123   | 123  | 123    | 123     |
 | 1     | 1    | 1      | 1       |
-#+CAPTION: Demonstration of simple table syntax.
+#+caption: Demonstration of simple table syntax.
 
 Simple table without caption:
 
@@ -22,7 +22,7 @@
 | 12    | 12   | 12     | 12      |
 | 123   | 123  | 123    | 123     |
 | 1     | 1    | 1      | 1       |
-#+CAPTION: Demonstration of simple table syntax.
+#+caption: Demonstration of simple table syntax.
 
 Multiline table with caption:
 
@@ -30,7 +30,7 @@
 |-----------------+--------------+---------------+-------------------------------------------------------|
 | First           | row          | 12.0          | Example of a row that spans multiple lines.           |
 | Second          | row          | 5.0           | Here's another one. Note the blank line between rows. |
-#+CAPTION: Here's the caption. It may span multiple lines.
+#+caption: Here's the caption. It may span multiple lines.
 
 Multiline table without caption:
 
diff --git a/test/writer.markdown b/test/writer.markdown
--- a/test/writer.markdown
+++ b/test/writer.markdown
@@ -11,11 +11,9 @@
 
 ------------------------------------------------------------------------------
 
-Headers
-=======
+# Headers
 
-Level 2 with an [embedded link](/url)
--------------------------------------
+## Level 2 with an [embedded link](/url)
 
 ### Level 3 with *emphasis*
 
@@ -23,25 +21,21 @@
 
 ##### Level 5
 
-Level 1
-=======
+# Level 1
 
-Level 2 with *emphasis*
------------------------
+## Level 2 with *emphasis*
 
 ### Level 3
 
 with no blank line
 
-Level 2
--------
+## Level 2
 
 with no blank line
 
 ------------------------------------------------------------------------------
 
-Paragraphs
-==========
+# Paragraphs
 
 Here's a regular paragraph.
 
@@ -56,8 +50,7 @@
 
 ------------------------------------------------------------------------------
 
-Block Quotes
-============
+# Block Quotes
 
 E-mail style:
 
@@ -86,8 +79,7 @@
 
 ------------------------------------------------------------------------------
 
-Code Blocks
-===========
+# Code Blocks
 
 Code:
 
@@ -107,11 +99,9 @@
 
 ------------------------------------------------------------------------------
 
-Lists
-=====
+# Lists
 
-Unordered
----------
+## Unordered
 
 Asterisks tight:
 
@@ -155,8 +145,7 @@
 
 -   Minus 3
 
-Ordered
--------
+## Ordered
 
 Tight:
 
@@ -196,8 +185,7 @@
 
 3.  Item 3.
 
-Nested
-------
+## Nested
 
 -   Tab
     -   Tab
@@ -224,8 +212,7 @@
 
 3.  Third
 
-Tabs and spaces
----------------
+## Tabs and spaces
 
 -   this is a list item indented with tabs
 
@@ -235,8 +222,7 @@
 
     -   this is an example list item indented with spaces
 
-Fancy list markers
-------------------
+## Fancy list markers
 
 (2) begins with 2
 
@@ -270,8 +256,7 @@
 
 ------------------------------------------------------------------------------
 
-Definition Lists
-================
+# Definition Lists
 
 Tight using spaces:
 
@@ -364,8 +349,7 @@
     1.  sublist
     2.  sublist
 
-HTML Blocks
-===========
+# HTML Blocks
 
 Simple block on one line:
 
@@ -525,8 +509,7 @@
 
 ------------------------------------------------------------------------------
 
-Inline Markup
-=============
+# Inline Markup
 
 This is *emphasized*, and so *is this*.
 
@@ -555,8 +538,7 @@
 
 ------------------------------------------------------------------------------
 
-Smart quotes, ellipses, dashes
-==============================
+# Smart quotes, ellipses, dashes
 
 "Hello," said the spider. "'Shelob' is my name."
 
@@ -577,8 +559,7 @@
 
 ------------------------------------------------------------------------------
 
-LaTeX
-=====
+# LaTeX
 
 -   `\cite[22-23]{smith.1899}`{=tex}
 -   $2+2=4$
@@ -610,8 +591,7 @@
 
 ------------------------------------------------------------------------------
 
-Special Characters
-==================
+# Special Characters
 
 Here is some unicode:
 
@@ -665,11 +645,9 @@
 
 ------------------------------------------------------------------------------
 
-Links
-=====
+# Links
 
-Explicit
---------
+## Explicit
 
 Just a [URL](/url/).
 
@@ -689,8 +667,7 @@
 
 [Empty]().
 
-Reference
----------
+## Reference
 
 Foo [bar](/url/).
 
@@ -712,8 +689,7 @@
 
 Foo [biz](/url/ "Title with "quote" inside").
 
-With ampersands
----------------
+## With ampersands
 
 Here's a [link with an ampersand in the URL](http://example.com/?foo=1&bar=2).
 
@@ -724,8 +700,7 @@
 
 Here's an [inline link in pointy braces](/script?foo=1&bar=2).
 
-Autolinks
----------
+## Autolinks
 
 With an ampersand: <http://example.com/?foo=1&bar=2>
 
@@ -743,8 +718,7 @@
 
 ------------------------------------------------------------------------------
 
-Images
-======
+# Images
 
 From "Voyage dans la Lune" by Georges Melies (1902):
 
@@ -754,8 +728,7 @@
 
 ------------------------------------------------------------------------------
 
-Footnotes
-=========
+# Footnotes
 
 Here is a footnote reference,[^1] and another.[^2] This should *not* be a
 footnote reference, because it contains a space.\[\^my note\] Here is an
diff --git a/test/writer.org b/test/writer.org
--- a/test/writer.org
+++ b/test/writer.org
@@ -1,7 +1,7 @@
-#+TITLE: Pandoc Test Suite
+#+title: Pandoc Test Suite
 
-#+AUTHOR: John MacFarlane; Anonymous
-#+DATE: July 17, 2006
+#+author: John MacFarlane; Anonymous
+#+date: July 17, 2006
 
 This is a set of tests for pandoc. Most of them are adapted from John Gruber's
 markdown test suite.
@@ -73,18 +73,18 @@
   :END:
 E-mail style:
 
-#+BEGIN_QUOTE
+#+begin_quote
   This is a block quote. It is pretty short.
-#+END_QUOTE
+#+end_quote
 
-#+BEGIN_QUOTE
+#+begin_quote
   Code in a block quote:
 
-  #+BEGIN_EXAMPLE
+  #+begin_example
     sub status {
         print "working";
     }
-  #+END_EXAMPLE
+  #+end_example
 
   A list:
 
@@ -93,14 +93,14 @@
 
   Nested block quotes:
 
-  #+BEGIN_QUOTE
+  #+begin_quote
     nested
-  #+END_QUOTE
+  #+end_quote
 
-  #+BEGIN_QUOTE
+  #+begin_quote
     nested
-  #+END_QUOTE
-#+END_QUOTE
+  #+end_quote
+#+end_quote
 
 This should not be a block quote: 2 > 1.
 
@@ -114,7 +114,7 @@
   :END:
 Code:
 
-#+BEGIN_EXAMPLE
+#+begin_example
   ---- (should be four hyphens)
 
   sub status {
@@ -122,15 +122,15 @@
   }
 
   this code block is indented by one tab
-#+END_EXAMPLE
+#+end_example
 
 And:
 
-#+BEGIN_EXAMPLE
+#+begin_example
       this code block is indented by two tabs
 
   These should not be escaped:  \$ \\ \> \[ \{
-#+END_EXAMPLE
+#+end_example
 
 --------------
 
@@ -347,13 +347,13 @@
 
 - /orange/ :: orange fruit
 
-  #+BEGIN_EXAMPLE
+  #+begin_example
     { orange code block }
-  #+END_EXAMPLE
+  #+end_example
 
-  #+BEGIN_QUOTE
+  #+begin_quote
     orange block quote
-  #+END_QUOTE
+  #+end_quote
 
 Multiple definitions, tight:
 
@@ -399,45 +399,45 @@
 
 Interpreted markdown in a table:
 
-#+BEGIN_HTML
+#+begin_html
   <table>
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   <tr>
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   <td>
-#+END_HTML
+#+end_html
 
 This is /emphasized/
 
-#+BEGIN_HTML
+#+begin_html
   </td>
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   <td>
-#+END_HTML
+#+end_html
 
 And this is *strong*
 
-#+BEGIN_HTML
+#+begin_html
   </td>
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   </tr>
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   </table>
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   <script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
-#+END_HTML
+#+end_html
 
 Here's a simple block:
 
@@ -445,17 +445,17 @@
 
 This should be a code block, though:
 
-#+BEGIN_EXAMPLE
+#+begin_example
   <div>
       foo
   </div>
-#+END_EXAMPLE
+#+end_example
 
 As should this:
 
-#+BEGIN_EXAMPLE
+#+begin_example
   <div>foo</div>
-#+END_EXAMPLE
+#+end_example
 
 Now, nested:
 
@@ -463,80 +463,80 @@
 
 This should just be an HTML comment:
 
-#+BEGIN_HTML
+#+begin_html
   <!-- Comment -->
-#+END_HTML
+#+end_html
 
 Multiline:
 
-#+BEGIN_HTML
+#+begin_html
   <!--
   Blah
   Blah
   -->
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   <!--
       This is another comment.
   -->
-#+END_HTML
+#+end_html
 
 Code block:
 
-#+BEGIN_EXAMPLE
+#+begin_example
   <!-- Comment -->
-#+END_EXAMPLE
+#+end_example
 
 Just plain comment, with trailing spaces on the line:
 
-#+BEGIN_HTML
+#+begin_html
   <!-- foo -->
-#+END_HTML
+#+end_html
 
 Code:
 
-#+BEGIN_EXAMPLE
+#+begin_example
   <hr />
-#+END_EXAMPLE
+#+end_example
 
 Hr's:
 
-#+BEGIN_HTML
+#+begin_html
   <hr>
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   <hr />
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   <hr />
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   <hr>
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   <hr />
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   <hr />
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   <hr class="foo" id="bar" />
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   <hr class="foo" id="bar" />
-#+END_HTML
+#+end_html
 
-#+BEGIN_HTML
+#+begin_html
   <hr class="foo" id="bar">
-#+END_HTML
+#+end_html
 
 --------------
 
@@ -727,9 +727,9 @@
 
 This should [not][] be a link.
 
-#+BEGIN_EXAMPLE
+#+begin_example
   [not]: /url
-#+END_EXAMPLE
+#+end_example
 
 Foo [[/url/][bar]].
 
@@ -760,15 +760,15 @@
 
 An e-mail address: [[mailto:nobody@nowhere.net][nobody@nowhere.net]]
 
-#+BEGIN_QUOTE
+#+begin_quote
   Blockquoted: [[http://example.com/]]
-#+END_QUOTE
+#+end_quote
 
 Auto-links should not occur here: =<http://example.com/>=
 
-#+BEGIN_EXAMPLE
+#+begin_example
   or here: <http://example.com/>
-#+END_EXAMPLE
+#+end_example
 
 --------------
 
@@ -778,7 +778,7 @@
   :END:
 From "Voyage dans la Lune" by Georges Melies (1902):
 
-#+CAPTION: lalune
+#+caption: lalune
 [[file:lalune.jpg]]
 
 Here is a movie [[file:movie.jpg]] icon.
@@ -793,9 +793,9 @@
 footnote reference, because it contains a space.[^my note] Here is an inline
 note.[fn:3]
 
-#+BEGIN_QUOTE
+#+begin_quote
   Notes can go in quotes.[fn:4]
-#+END_QUOTE
+#+end_quote
 
 1. And in list items.[fn:5]
 
@@ -809,9 +809,9 @@
        Subsequent blocks are indented to show that they belong to the footnote
        (as with list items).
 
-       #+BEGIN_EXAMPLE
+       #+begin_example
            { <code> }
-       #+END_EXAMPLE
+       #+end_example
 
        If you want, you can indent every line, but you can also be lazy and
        just indent the first line of each block.
