diff --git a/AUTHORS.md b/AUTHORS.md
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -137,6 +137,7 @@
 - George Stagg
 - Georgi Lyubenov
 - Gokul Rajiv
+- Gordon Woodhull
 - Gottfried Haider
 - Greg Maslov
 - Greg Rundlett
@@ -172,6 +173,7 @@
 - Jake Zimmerman
 - Jakob Voß
 - James Aspnes
+- James P. Ascher
 - James Scott-Brown
 - Jamie F. Olson
 - Jan Larres
@@ -225,6 +227,7 @@
 - Laurent P. René de Cotret
 - Lawrence Chonavel
 - Leif Metcalf
+- Leo Heitmann Ruiz
 - Leonard Rosenthol
 - Lila
 - Link Swanson
@@ -419,6 +422,7 @@
 - ebiim
 - ech0
 - favonia
+- guqicun
 - harabat
 - hseg
 - infinity0x
@@ -429,6 +433,7 @@
 - lux-lth
 - luz paz
 - lwolfsonkin
+- mbracke
 - mbrackeantidot
 - mh4ckt3mh4ckt1c4s
 - mjfs
diff --git a/COPYRIGHT b/COPYRIGHT
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,5 +1,5 @@
 Pandoc
-Copyright (C) 2006-2023 John MacFarlane <jgm at berkeley dot edu>
+Copyright (C) 2006-2024 John MacFarlane <jgm at berkeley dot edu>
 
 With the exceptions noted below, this code is released under the [GPL],
 version 2 or later:
@@ -37,7 +37,7 @@
 Text.Pandoc.Builder, Text.Pandoc.Generics, Text.Pandoc.JSON,
 Text.Pandoc.Walk) are licensed under the BSD 3-clause license:
 
-Copyright (c) 2006-2023, John MacFarlane
+Copyright (c) 2006-2024, John MacFarlane
 
 All rights reserved.
 
@@ -73,7 +73,7 @@
 GPL (v2 or higher, same as pandoc) or (at your option) the BSD
 3-clause license.
 
-Copyright (c) 2014--2023, John MacFarlane
+Copyright (c) 2014--2024, John MacFarlane
 
 ----------------------------------------------------------------------
 src/Text/Pandoc/Writers/Muse.hs
@@ -83,19 +83,19 @@
 
 ----------------------------------------------------------------------
 src/Text/Pandoc/Writers/Texinfo.hs
-Copyright (C) 2008-2023 John MacFarlane and Peter Wang
+Copyright (C) 2008-2024 John MacFarlane and Peter Wang
 
 Released under the GNU General Public License version 2 or later.
 
 ----------------------------------------------------------------------
 src/Text/Pandoc/Writers/OpenDocument.hs
-Copyright (C) 2008-2023 Andrea Rossato and John MacFarlane
+Copyright (C) 2008-2024 Andrea Rossato and John MacFarlane
 
 Released under the GNU General Public License version 2 or later.
 
 ----------------------------------------------------------------------
 src/Text/Pandoc/Writers/Org.hs
-Copyright (C) 2010-2023 Puneeth Chaganti, John MacFarlane, and
+Copyright (C) 2010-2024 Puneeth Chaganti, John MacFarlane, and
                         Albert Krewinkel
 
 Released under the GNU General Public License version 2 or later.
@@ -115,7 +115,7 @@
 
 ----------------------------------------------------------------------
 src/Text/Pandoc/Readers/Textile.hs
-Copyright (C) 2010-2023 Paul Rivier and John MacFarlane
+Copyright (C) 2010-2024 Paul Rivier and John MacFarlane
 
 Released under the GNU General Public License version 2 or later.
 
@@ -133,7 +133,7 @@
 
 ----------------------------------------------------------------------
 src/Text/Pandoc/Readers/EPUB.hs
-Copyright (C) 2014-2023 Matthew Pickering and John MacFarlane
+Copyright (C) 2014-2024 Matthew Pickering and John MacFarlane
 
 Released under the GNU General Public License version 2 or later.
 
@@ -141,7 +141,7 @@
 src/Text/Pandoc/Readers/Org.hs
 src/Text/Pandoc/Readers/Org/*
 test/Tests/Readers/Org/*
-Copyright (C) 2014-2023 Albert Krewinkel
+Copyright (C) 2014-2024 Albert Krewinkel
 
 Released under the GNU General Public License version 2 or later.
 
@@ -149,7 +149,7 @@
 pandoc-lua-engine/src/Text/Pandoc/Lua.hs
 pandoc-lua-engine/src/Text/Pandoc/Lua/*
 pandoc-lua-engine/test/lua/*
-Copyright (C) 2017--2023 Albert Krewinkel and John MacFarlane
+Copyright (C) 2017--2024 Albert Krewinkel and John MacFarlane
 
 Released under the GNU General Public License version 2 or later.
 
@@ -157,7 +157,7 @@
 src/Text/Pandoc/Readers/Jira.hs
 src/Text/Pandoc/Writers/Jira.hs
 test/Tests/Readers/Jira.hs
-Copyright (C) 2019--2023 Albert Krewinkel
+Copyright (C) 2019--2024 Albert Krewinkel
 
 Released under the GNU General Public License version 2 or later.
 
diff --git a/INSTALL.md b/INSTALL.md
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -90,7 +90,7 @@
 
 Check whether the pandoc version in your package manager is
 not outdated. Pandoc is in the [Debian], [Ubuntu], [Slackware],
-[Arch], [Fedora], [NiXOS], [openSUSE], [gentoo] and [Void] repositories.
+[Arch], [Fedora], [NixOS], [openSUSE], [gentoo] and [Void] repositories.
 
 To get the latest release, we provide a binary package for amd64
 architecture on the **[download page]**.
@@ -148,7 +148,7 @@
 
 ## BSD
 
-Pandoc is in the [NetBSD] and [FreeBSD ports] repositories.
+Pandoc is in the [NetBSD], [FreeBSD], and [OpenBSD ports] repositories.
 
 ## Docker
 
@@ -370,12 +370,13 @@
 [Cabal User's Guide]: https://cabal.readthedocs.io/
 [Debian]: https://packages.debian.org/search?keywords=pandoc
 [Fedora]: https://packages.fedoraproject.org/pkgs/pandoc/pandoc/
-[FreeBSD ports]: https://www.freshports.org/textproc/hs-pandoc/
+[FreeBSD]: https://www.freshports.org/textproc/hs-pandoc/
 [GHC]:  https://www.haskell.org/ghc/
 [GitLab CI/CD]: https://about.gitlab.com/stages-devops-lifecycle/continuous-integration/
 [Haskell platform]: https://hackage.haskell.org/platform/
 [MacPorts]: https://trac.macports.org/browser/trunk/dports/textproc/pandoc/Portfile
 [MacTeX]: https://tug.org/mactex/
+[OpenBSD ports]: https://cvsweb.openbsd.org/ports/textproc/pandoc/
 [BasicTeX]: https://www.tug.org/mactex/morepackages.html
 [LaTeX]: https://www.latex-project.org
 [MiKTeX]: https://miktex.org/
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: April 7, 2024
+date: May 11, 2024
 ---
 
 # Synopsis
@@ -138,14 +138,17 @@
 [`amsfonts`], [`amsmath`], [`lm`], [`unicode-math`],
 [`iftex`], [`listings`] (if the
 `--listings` option is used), [`fancyvrb`], [`longtable`],
-[`booktabs`], [`graphicx`] (if the document
+[`booktabs`], [`multirow`] (if the document contains a table with
+cells that cross multiple rows), [`graphicx`] (if the document
 contains images), [`bookmark`], [`xcolor`],
 [`soul`], [`geometry`] (with the `geometry` variable set),
 [`setspace`] (with `linestretch`), and
 [`babel`] (with `lang`).  If `CJKmainfont` is set, [`xeCJK`]
-is needed.  The use of `xelatex` or `lualatex` as
-the PDF engine requires [`fontspec`].  `lualatex` uses
-[`selnolig`]. `xelatex` uses [`bidi`] (with the `dir` variable set).
+is needed. [`framed`] is required if code is highlighted in a
+scheme that use a colored background. The use of `xelatex` or
+`lualatex` as the PDF engine requires [`fontspec`]. `lualatex`
+uses [`selnolig`] and [`lua-ul`]. `xelatex` uses [`bidi`] (with
+the `dir` variable set).
 If the `mathspec` variable is set, `xelatex` will use [`mathspec`]
 instead of [`unicode-math`].  The [`upquote`] and [`microtype`]
 packages are used if available, and [`csquotes`] will be used
@@ -175,13 +178,14 @@
 [`fontspec`]: https://ctan.org/pkg/fontspec
 [`footnote`]: https://ctan.org/pkg/footnote
 [`footnotehyper`]: https://ctan.org/pkg/footnotehyper
+[`framed`]: https://ctan.org/pkg/framed
 [`geometry`]: https://ctan.org/pkg/geometry
 [`graphicx`]: https://ctan.org/pkg/graphicx
-[`grffile`]: https://ctan.org/pkg/grffile
 [`hyperref`]: https://ctan.org/pkg/hyperref
 [`iftex`]: https://ctan.org/pkg/iftex
 [`listings`]: https://ctan.org/pkg/listings
 [`lm`]: https://ctan.org/pkg/lm
+[`lua-ul`]: https://ctan.org/pkg/lua-ul
 [`longtable`]: https://ctan.org/pkg/longtable
 [`mathspec`]: https://ctan.org/pkg/mathspec
 [`microtype`]: https://ctan.org/pkg/microtype
@@ -259,7 +263,7 @@
     - `man` ([roff man])
     - `muse` ([Muse])
     - `native` (native Haskell)
-    - `odt` ([ODT])
+    - `odt` ([OpenOffice text document][ODT])
     - `opml` ([OPML])
     - `org` ([Emacs Org mode])
     - `ris` ([RIS] bibliography)
@@ -555,7 +559,7 @@
 
 `--indented-code-classes=`*CLASSES*
 
-:   Specify classes to use for indented code blocks--for example,
+:   Specify classes to use for indented code blocks---for example,
     `perl,numberLines` or `haskell`. Multiple classes may be separated
     by spaces or commas.
 
@@ -581,10 +585,6 @@
     identifier `foo` in `subdir/file1.txt` will have its
     identifier changed to `subdir__file1.txt__foo`.
 
-    In addition, a Div with an identifier based on the filename
-    will be added around the file's content, so that internal
-    links to the filename will point to this Div's identifier.
-
 `-F` *PROGRAM*, `--filter=`*PROGRAM*
 
 :   Specify an executable to be used as a filter transforming the
@@ -1095,14 +1095,16 @@
 `--slide-level=`*NUMBER*
 
 :   Specifies that headings with the specified level create
-    slides (for `beamer`, `s5`, `slidy`, `slideous`, `dzslides`).  Headings
-    above this level in the hierarchy are used to divide the slide show
-    into sections; headings below this level create subheads within a slide.
-    Valid values are 0-6.  If a slide level of 0 is specified, slides will
-    not be split automatically on headings, and horizontal rules must be used
-    to indicate slide boundaries.  If a slide level is not specified
-    explicitly, the slide level will be set automatically based on
-    the contents of the document; see [Structuring the slide show].
+    slides (for `beamer`, `revealjs`, `pptx`, `s5`, `slidy`,
+    `slideous`, `dzslides`). Headings above this level in the
+    hierarchy are used to divide the slide show into sections;
+    headings below this level create subheads within a slide.
+    Valid values are 0-6. If a slide level of 0 is specified,
+    slides will not be split automatically on headings, and
+    horizontal rules must be used to indicate slide boundaries.
+    If a slide level is not specified explicitly, the slide level
+    will be set automatically based on the contents of the
+    document; see [Structuring the slide show].
 
 `--section-divs[=true|false]`
 
@@ -2234,9 +2236,24 @@
 matched delimiters) and ends with `endif` (enclosed in matched
 delimiters).  It may optionally contain an `else` (enclosed in
 matched delimiters).  The `if` section is used if
-`variable` has a non-empty value, otherwise the `else`
-section is used (if present).  Examples:
+`variable` has a true value, otherwise the `else`
+section is used (if present).  The following values count
+as true:
 
+- any map
+- any array containing at least one true value
+- any nonempty string
+- boolean True
+
+Note that in YAML metadata (and metadata specified on the
+command line using `-M/--metadata`), unquoted `true` and `false` will be
+interpreted as Boolean values. But a variable specified on the
+command line using `-V/--variable` will always be given a string
+value. Hence a conditional `if(foo)` will be triggered if you
+use `-V foo=false`, but not if you use `-M foo=false`.
+
+Examples:
+
 ```
 $if(foo)$bar$endif$
 
@@ -2798,6 +2815,9 @@
 `titlegraphic`
 :   image for title slide
 
+`titlegraphicoptions`
+:   options for title slide image
+
 ### Variables for PowerPoint
 
 These variables control the visual aspects of a slide show that
@@ -2899,6 +2919,10 @@
 `beamerarticle`
 :   produce an article from Beamer slides
 
+`handout`
+:   produce a handout version of Beamer slides (with overlays condensed
+    into single slides)
+
 #### Fonts
 
 `fontenc`
@@ -3286,7 +3310,9 @@
 
 `toc-title`
 :   title of table of contents (works only with EPUB,
-    HTML, revealjs, opendocument, odt, docx, pptx, beamer, LaTeX)
+    HTML, revealjs, opendocument, odt, docx, pptx, beamer, LaTeX).
+    Note that in docx and pptx a custom `toc-title` will be
+    picked up from metadata, but cannot be set as a variable.
 
 [pandoc-templates]: https://github.com/jgm/pandoc-templates
 
@@ -3689,7 +3715,7 @@
 
 > A Markdown-formatted document should be publishable as-is, as plain
 > text, without looking like it's been marked up with tags or formatting
-> instructions.
+> instructions.\
 > -- [John Gruber](https://daringfireball.net/projects/markdown/syntax#philosophy)
 
 This principle has guided pandoc's decisions in finding syntax for
@@ -4322,14 +4348,27 @@
 The label can be any string of alphanumeric characters, underscores,
 or hyphens.
 
-Note:  continuation paragraphs in example lists must always
+Continuation paragraphs in example lists must always
 be indented four spaces, regardless of the length of the
 list marker.  That is, example lists always behave as if the
 `four_space_rule` extension is set.  This is because example
 labels tend to be long, and indenting content to the
 first non-space character after the label would be awkward.
 
+You can repeat an earlier numbered example by re-using its label:
 
+    (@foo) Sample sentence.
+
+    Intervening text...
+
+    This theory can explain the case we saw earlier (repeated):
+
+    (@foo) Sample sentence.
+
+This only works reliably, though, if the repeated item is in a list
+by itself, because each numbered example list will be numbered
+continuously from its starting number.
+
 ### Ending a list ###
 
 What if you want to put an indented code block after a list?
@@ -4682,8 +4721,8 @@
 
 Title blocks will always be parsed, but they will affect the output only
 when the `--standalone` (`-s`) option is chosen. In HTML output, titles
-will appear twice: once in the document head -- this is the title that
-will appear at the top of the window in a browser -- and once at the
+will appear twice: once in the document head---this is the title that
+will appear at the top of the window in a browser---and once at the
 beginning of the document body. The title in the document head can have
 an optional prefix attached (`--title-prefix` or `-T` option). The title
 in the body appears as an H1 element with class "title", so it can be
@@ -6304,12 +6343,12 @@
     syntax (after `-u-`) may be used to specify options for
     collation (sorting) more precisely. Here are some examples:
 
-    - `zh-u-co-pinyin` -- Chinese with the Pinyin collation.
-    - `es-u-co-trad` -- Spanish with the traditional collation
+    - `zh-u-co-pinyin`: Chinese with the Pinyin collation.
+    - `es-u-co-trad`: Spanish with the traditional collation
       (with `Ch` sorting after `C`).
-    - `fr-u-kb` -- French with "backwards" accent sorting
+    - `fr-u-kb`: French with "backwards" accent sorting
       (with `coté` sorting after `côte`).
-    - `en-US-u-kf-upper` -- English with uppercase letters sorting
+    - `en-US-u-kf-upper`: English with uppercase letters sorting
        before lower (default is lower before upper).
 
 `notes-after-punctuation`
@@ -7163,16 +7202,16 @@
 
 # Custom Styles
 
-Custom styles can be used in the docx and ICML formats.
+Custom styles can be used in the docx, odt and ICML formats.
 
 ## Output
 
-By default, pandoc's docx and ICML output applies a predefined set of styles
-for blocks such as paragraphs and block quotes, and uses largely default
-formatting (italics, bold) for inlines. This will work for most
-purposes, especially alongside a `reference.docx` file. However, if you
-need to apply your own styles to blocks, or match a preexisting set of
-styles, pandoc allows you to define custom styles for blocks and text
+By default, pandoc's odt, docx and ICML output applies a predefined set of
+styles for blocks such as paragraphs and block quotes, and uses largely
+default formatting (italics, bold) for inlines. This will work for most
+purposes, especially alongside a [reference doc]{#option--reference-doc} file.
+However, if you need to apply your own styles to blocks, or match a preexisting
+set of styles, pandoc allows you to define custom styles for blocks and text
 using `div`s and `span`s, respectively.
 
 If you define a `div` or `span` with the attribute `custom-style`,
@@ -7183,7 +7222,7 @@
 
     [Get out]{custom-style="Emphatically"}, he said.
 
-would produce a docx file with "Get out" styled with character
+would produce a file with "Get out" styled with character
 style `Emphatically`. Similarly, using the `fenced_divs` syntax,
 
     Dickinson starts the poem simply:
@@ -7195,8 +7234,9 @@
 
 would style the two contained lines with the `Poetry` paragraph style.
 
-For docx output, styles will be defined in the output file as inheriting
-from normal text, if the styles are not yet in your reference.docx.
+Styles will be defined in the output file as inheriting
+from normal text (docx) or Default Paragraph Style (odt), if the
+styles are not yet in your [reference doc]{#option--reference-doc}.
 If they are already defined, pandoc will not alter the definition.
 
 This feature allows for greatest customization in conjunction with
@@ -7207,7 +7247,7 @@
 transform all italicized inlines to inlines within an `Emphasis`
 custom-style `span`.
 
-For docx output, you don't need to enable any extensions for
+For docx or odt output, you don't need to enable any extensions for
 custom styles to work.
 
 [pandoc filters]: https://pandoc.org/filters.html
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -83,7 +83,8 @@
 - `man` ([roff man](https://man.cx/groff_man(7)))
 - `muse` ([Muse](https://amusewiki.org/library/manual))
 - `native` (native Haskell)
-- `odt` ([ODT](https://en.wikipedia.org/wiki/OpenDocument))
+- `odt` ([OpenOffice text
+  document](https://en.wikipedia.org/wiki/OpenDocument))
 - `opml` ([OPML](http://dev.opml.org/spec2.html))
 - `org` ([Emacs Org mode](https://orgmode.org))
 - `ris` ([RIS](https://en.wikipedia.org/wiki/RIS_(file_format))
@@ -265,7 +266,7 @@
 
 ## License
 
-© 2006-2023 John MacFarlane (jgm@berkeley.edu). Released under the
+© 2006-2024 John MacFarlane (jgm@berkeley.edu). Released under the
 [GPL](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html "GNU General Public License"),
 version 2 or greater. This software carries no warranty of any kind.
 (See COPYRIGHT for full copyright and warranty notices.)
diff --git a/benchmark/benchmark-pandoc.hs b/benchmark/benchmark-pandoc.hs
--- a/benchmark/benchmark-pandoc.hs
+++ b/benchmark/benchmark-pandoc.hs
@@ -1,6 +1,6 @@
 {-# LANGUAGE OverloadedStrings #-}
 {-
-Copyright (C) 2012-2023 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2012-2024 John MacFarlane <jgm@berkeley.edu>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
diff --git a/changelog.md b/changelog.md
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,206 @@
 # Revision history for pandoc
 
+## pandoc 3.2 (2024-05-11)
+
+  * Change to `--file-scope` behavior (#8741): previously a Div with an
+    identifier derived from the filename would be added around the contents
+    of each file. This caused problems for "chunking" files into chapters,
+    e.g. in EPUB. We no longer add the surrounding Div. This cooperates
+    better with chunking. Note, however, that if you have relied on the old
+    behavior to link to the beginning of the contents of a file using
+    its filename as identifier, that will no longer work.
+
+  * Markdown reader:
+
+    + Allow repeated labels in numbered example lists.
+      Previously if you tried to use the same label as an earlier
+      example list item, you'd get a new number, not the old one,
+      and references to the label would go to the second occurrence.
+      Now an existing label will be reused, and no new number will
+      be generated.  Caveat:  this only works reliably when the
+      re-used example list item occurs by itself in a list, or
+      occurs in a list of previously used example list items that
+      occur in exactly the same order as previously.
+    + Fix `normalCite` so it doesn't consume past a closing `]` boundary
+      (#9710).  This was causing an exponential performance bug on long
+      lists of links containing potential emphasis characters.
+    + Generalize `inlinesInBalancedBrackets` to `inBalancedBrackets`,
+      with a parameter for the inner parser.
+    + Auto-close unclosed divs (#9635). This applies to both fenced and
+      HTML-ish varieties. Otherwise we face an exponential performance
+      problem with backtracking. A warning is issued when a div is
+      implicitly closed.
+
+  * RST reader:
+
+    + Fix `figclass` and `align` annotations for figures (#7473, Gokul
+      Rajiv).
+
+  * LaTeX writer:
+
+    + Use `polytonicgreek` instead of `polutonikogreek` with babel (#9698).
+      `polutonikogreek` is outdated. Also recognize both in the LaTeX
+      reader.
+    + Improve treatment of math inside soul commands (#1294, #5529).
+      soul commands (`ul`, `hl`, `st`) are very fragile and the math
+      must be handled specially.
+
+  * LaTeX reader:
+
+    + Fix over-eager macro expansion in conditionals (#9676).
+    + Parse `flalign`, `flalign*` math environments (#9679). We parse
+      these as Math elements with an `aligned` environment. Semantically
+      it's not exactly the same, but better than falling back to raw LaTeX.
+
+  * LaTeX template: add `titlegraphicoptions` variable (#9207, Guilhem
+    Saurel).
+
+  * Docx reader:
+
+    + Issue warning rather than error when we can't parse EndNote citations
+      (see #8433).
+    + Fix anchor in header after anchor (#9626, mbracke).
+
+  * RTF reader:
+
+    + Don't try to handle non-default code pages (#9683). Emit a warning
+      instead.
+
+  * OpenDocument writer:
+
+    + Implement custom-style for spans (#9657).
+
+  * Typst writer:
+
+    + Add blank line in definition lists with multiple definitions (see
+      #9704).
+    + Property output (#9648, Gordon Woodhull). The Typst writer will pass
+      on specially marked attributes as raw Typst parameters on selected
+      elements. This allows extensive customization using filters.
+      A separate document (`doc/typst-property-output.md`) has been added
+      that provides extensive documentation and examples of the use of
+      this feature.
+
+  * Markdown writer:
+
+    + Don't try to align columns in pipe tables with lines greater than
+      COLUMNS. The alignment just reduces readibility when the lines
+      soft wrap.
+    + Don't use `raw_attribute` syntax for raw blocks, unless there is no
+      other option (see #9677).  Macros in a `raw_attribute` block don't
+      get interpreted when it is read again by pandoc's markdown reader.
+
+  * ConTeXt writer:
+
+    + Replace depreciated `\sc` with `\setsmallcaps` (#9518, James P.
+      Ascher).
+
+  * Docx writer:
+
+    + Use conventional styles/indents for Word bullet lists (#7280).
+
+  * `reference.docx`:
+
+    + Use current standard Word theme (#7280). This includes using the
+      sans-serif font Aptos instead of the serif font Cambria, and
+      default colors for headings.
+    + Remove duplicate `DefaultParagraphFont` in `styles.xml`.
+
+  * New module Text.Pandoc.Transforms [API change] (Albert Krewinkel).
+    This module exports the following functions which were formerly
+    exported from Tetx.Pnadoc.Shared: `headerShift`,
+    `filterIpynbOutput`, `eastAsianLineBreakFilter`, as well as some
+    functions that were previously not exported.
+
+  * Text.Pandoc.Shared:
+
+    + `headerShift`, `filterIpynbOutput`, and `eastAsianLineBreakFilter`
+      are no longer exported from this module; they are now exported
+      from Text.Pandoc.Transforms (Albert Krewinkel).
+
+  * Text.Pandoc.Error:
+
+    + Improve reporting of unsupported extensions errors (#9247, Albert
+      Krewinkel).
+
+  * Text.Pandoc.App:
+
+    + Move "transforms" after filters (#9664). This will mean that
+      `--shift-heading-level-by` affects a heading added by
+      `reference-section-title`.
+
+  * Text.Pandoc.App.CommandLineOptions:
+
+    + Simplify output for `OptVersion`. Omit the information about versions
+      of dependencies. We no longer emit version info at this level anyway;
+      `pandoc-cli` intercepts and handles `--version`. This code would
+      only be called if someone used the pandoc library function
+      `handleWithOptInfo` in their own program.
+
+  * Text.Pandoc.ImageSize:
+
+    + Export `ImageSize` datatype.
+
+  * Text.Pandoc.SelfContained:
+
+    + Merge class attribute when both img and svg specify it (#9652,
+      Carlos Scheidegger).
+
+  * Text.Pandoc.Logging:
+
+    + Add `ScriptingInfo` constructor for `LogMessage` [API change]
+      (Albert Krewinkel).
+    + Make `DocxParserWarning` a WARNING, not INFO. [API change].
+    + Add `UnsupportedCodePage` constructor to `LogMessage` [API change].
+    + Add `UnclosedDiv` constructor for `LogMessage` [API change].
+
+  * Lua subsystem (Albert Krewinkel:
+
+    + Add a `pandoc.log` module.
+    + Uupdate to pandoc-lua-marshal version 0.2.7 (#8916).
+      This fixes counterintuitive behavior of the `content` property on
+      BulletList and OrderedList items. Unmarshalling of that field now
+      matches the behavior of the constructor.
+    + Use newest zip module. This adds a `symlink` function to Entry objects,
+      allowing to check if an entry represents a symbolic link.
+    + Improve `pandoc.json.decode` docs.
+    + Update and fix docs for `pandoc.types.Version` and `pandoc.utils.type`.
+    + Add new module `pandoc.image` The module provides basic querying
+      functions for image properties.
+    + Bump pandoc-lua-engine to 0.2.1.4.
+
+  * Use latest KaTeX CDN asset (#9707, Salim B).
+
+  * `pandoc-cli`: ensure UTF8 when emitting version info.
+
+  * tools/update-lua-module-docs.lua: improve script-internal docs, cleanup
+    (Albert Krewinkel).
+
+  * Allow network 3.2.
+
+  * Use latest versions of texmath, djot, skylighting-core, skylighting.
+
+  * Fix command test for #9652.
+
+  * Fix some typos in code comments (#9638, guqicun).
+
+  * Command tests: include regular PATH after directory with the test
+    executable (ensures that DLLs will be found on Windows).
+
+  * MANUAL.txt:
+
+    + Document `handout` variable for beamer (#9742).
+    + Document formats affected by `--slide-level` (#9745).
+    + Update the list of required LaTeX packages (#9728, Albert Krewinkel).
+    + Use more descriptive link text for ODT (#9673).
+    + Add clarification about `toc-title` in `docx`, `pptx` (#9645).
+    + Better document truthiness for conditionals (#9661).
+    + Mention that `custom-style` works with ODT (Ian Max Andolina).
+    + Harmonize typographic dashes (#9688, Salim B). Standardize on `---`
+      with no space.
+
+  * INSTALL.md: Minor tweaks (#9705, Leo Heitmann Ruiz).
+
 ## pandoc 3.1.13 (2024-04-07)
 
   * Org reader:
@@ -31,7 +232,7 @@
   * ConTeXt writer:
 
     + Fix options order with `\externalfigure`. The dimensions should
-      come before the class if both are present.
+      come after the class if both are present.
 
   * Typst writer:
 
diff --git a/data/docx/word/fontTable.xml b/data/docx/word/fontTable.xml
--- a/data/docx/word/fontTable.xml
+++ b/data/docx/word/fontTable.xml
@@ -1,52 +1,52 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <w:fonts xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
-&#9;<w:font w:name="Symbol">
-&#9;&#9;<w:panose1 w:val="02000500000000000000" />
-&#9;&#9;<w:charset w:val="02" />
-&#9;&#9;<w:family w:val="auto" />
-&#9;&#9;<w:pitch w:val="variable" />
-&#9;&#9;<w:sig w:usb0="00000000" w:usb1="00000000" w:usb2="00010000" w:usb3="00000000" w:csb0="80000000" w:csb1="00000000" />
-&#9;</w:font>
-&#9;<w:font w:name="Times New Roman">
-&#9;&#9;<w:panose1 w:val="02020603050405020304" />
-&#9;&#9;<w:charset w:val="00" />
-&#9;&#9;<w:family w:val="auto" />
-&#9;&#9;<w:pitch w:val="variable" />
-&#9;&#9;<w:sig w:usb0="00000003" w:usb1="00000000" w:usb2="00000000" w:usb3="00000000" w:csb0="00000001" w:csb1="00000000" />
-&#9;</w:font>
-&#9;<w:font w:name="Courier New">
-&#9;&#9;<w:panose1 w:val="02070309020205020404" />
-&#9;&#9;<w:charset w:val="00" />
-&#9;&#9;<w:family w:val="auto" />
-&#9;&#9;<w:pitch w:val="variable" />
-&#9;&#9;<w:sig w:usb0="00000003" w:usb1="00000000" w:usb2="00000000" w:usb3="00000000" w:csb0="00000001" w:csb1="00000000" />
-&#9;</w:font>
-&#9;<w:font w:name="Wingdings">
-&#9;&#9;<w:panose1 w:val="05020102010804080708" />
-&#9;&#9;<w:charset w:val="02" />
-&#9;&#9;<w:family w:val="auto" />
-&#9;&#9;<w:pitch w:val="variable" />
-&#9;&#9;<w:sig w:usb0="00000000" w:usb1="00000000" w:usb2="00010000" w:usb3="00000000" w:csb0="80000000" w:csb1="00000000" />
-&#9;</w:font>
-&#9;<w:font w:name="Cambria">
-&#9;&#9;<w:panose1 w:val="02040503050406030204" />
-&#9;&#9;<w:charset w:val="00" />
-&#9;&#9;<w:family w:val="auto" />
-&#9;&#9;<w:pitch w:val="variable" />
-&#9;&#9;<w:sig w:usb0="00000003" w:usb1="00000000" w:usb2="00000000" w:usb3="00000000" w:csb0="00000001" w:csb1="00000000" />
-&#9;</w:font>
-&#9;<w:font w:name="Calibri">
-&#9;&#9;<w:panose1 w:val="020F0502020204030204" />
-&#9;&#9;<w:charset w:val="00" />
-&#9;&#9;<w:family w:val="auto" />
-&#9;&#9;<w:pitch w:val="variable" />
-&#9;&#9;<w:sig w:usb0="00000003" w:usb1="00000000" w:usb2="00000000" w:usb3="00000000" w:csb0="00000001" w:csb1="00000000" />
-&#9;</w:font>
-&#9;<w:font w:name="Arial">
-&#9;&#9;<w:panose1 w:val="020B0604020202020204" />
-&#9;&#9;<w:charset w:val="00" />
-&#9;&#9;<w:family w:val="auto" />
-&#9;&#9;<w:pitch w:val="variable" />
-&#9;&#9;<w:sig w:usb0="00000003" w:usb1="00000000" w:usb2="00000000" w:usb3="00000000" w:csb0="00000001" w:csb1="00000000" />
-&#9;</w:font>
+  <w:font w:name="Aptos">
+    <w:panose1 w:val="020B0004020202020204"/>
+    <w:charset w:val="00"/>
+    <w:family w:val="swiss"/>
+    <w:pitch w:val="variable"/>
+    <w:sig w:usb0="20000287" w:usb1="00000003" w:usb2="00000000" w:usb3="00000000" w:csb0="0000019F" w:csb1="00000000"/>
+  </w:font>
+  <w:font w:name="Times New Roman">
+    <w:panose1 w:val="02020603050405020304"/>
+    <w:charset w:val="00"/>
+    <w:family w:val="roman"/>
+    <w:pitch w:val="variable"/>
+    <w:sig w:usb0="E0002EFF" w:usb1="C000785B" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/>
+  </w:font>
+  <w:font w:name="Aptos Display">
+    <w:panose1 w:val="020B0004020202020204"/>
+    <w:charset w:val="00"/>
+    <w:family w:val="swiss"/>
+    <w:pitch w:val="variable"/>
+    <w:sig w:usb0="20000287" w:usb1="00000003" w:usb2="00000000" w:usb3="00000000" w:csb0="0000019F" w:csb1="00000000"/>
+  </w:font>
+  <w:font w:name="Cambria Math">
+    <w:panose1 w:val="02040503050406030204"/>
+    <w:charset w:val="00"/>
+    <w:family w:val="roman"/>
+    <w:pitch w:val="variable"/>
+    <w:sig w:usb0="E00002FF" w:usb1="420024FF" w:usb2="00000000" w:usb3="00000000" w:csb0="0000019F" w:csb1="00000000"/>
+  </w:font>
+  <w:font w:name="Courier New">
+    <w:panose1 w:val="02070309020205020404"/>
+    <w:charset w:val="00"/>
+    <w:family w:val="modern"/>
+    <w:pitch w:val="fixed"/>
+    <w:sig w:usb0="E0002AFF" w:usb1="C0007843" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/>
+  </w:font>
+  <w:font w:name="Cambria">
+    <w:panose1 w:val="02040503050406030204"/>
+    <w:charset w:val="00"/>
+    <w:family w:val="roman"/>
+    <w:pitch w:val="variable"/>
+    <w:sig w:usb0="E00002FF" w:usb1="400004FF" w:usb2="00000000" w:usb3="00000000" w:csb0="0000019F" w:csb1="00000000"/>
+  </w:font>
+  <w:font w:name="Calibri">
+    <w:panose1 w:val="020F0502020204030204"/>
+    <w:charset w:val="00"/>
+    <w:family w:val="swiss"/>
+    <w:pitch w:val="variable"/>
+    <w:sig w:usb0="E0002AFF" w:usb1="C000247B" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/>
+  </w:font>
 </w:fonts>
diff --git a/data/docx/word/styles.xml b/data/docx/word/styles.xml
--- a/data/docx/word/styles.xml
+++ b/data/docx/word/styles.xml
@@ -20,7 +20,7 @@
     <w:name w:val="Normal" />
     <w:qFormat />
   </w:style>
-    <w:style w:type="paragraph" w:styleId="BodyText">
+  <w:style w:type="paragraph" w:styleId="BodyText">
     <w:name w:val="Body Text" />
     <w:basedOn w:val="Normal" />
     <w:link w:val="BodyTextChar" />
@@ -47,38 +47,82 @@
     <w:name w:val="Title" />
     <w:basedOn w:val="Normal" />
     <w:next w:val="BodyText" />
+    <w:link w:val="TitleChar" />
+    <w:uiPriority w:val="10" />
     <w:qFormat />
+    <w:rsid w:val="00A10FD9" />
     <w:pPr>
-      <w:keepNext />
-      <w:keepLines />
-      <w:spacing w:before="480" w:after="240" />
+      <w:spacing w:after="80" w:line="240" w:lineRule="auto" />
+      <w:contextualSpacing />
       <w:jc w:val="center" />
     </w:pPr>
     <w:rPr>
-      <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
-      <w:b />
-      <w:bCs />
-      <w:color w:val="345A8A" w:themeColor="accent1" w:themeShade="B5" />
-      <w:sz w:val="36" />
-      <w:szCs w:val="36" />
+      <w:rFonts w:asciiTheme="majorHAnsi"
+      w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi"
+      w:cstheme="majorBidi" />
+      <w:spacing w:val="-10" />
+      <w:kern w:val="28" />
+      <w:sz w:val="56" />
+      <w:szCs w:val="56" />
     </w:rPr>
   </w:style>
- <w:style w:type="paragraph" w:styleId="Subtitle">
+  <w:style w:type="character" w:customStyle="1"
+  w:styleId="TitleChar">
+    <w:name w:val="Title Char" />
+    <w:basedOn w:val="DefaultParagraphFont" />
+    <w:link w:val="Title" />
+    <w:uiPriority w:val="10" />
+    <w:rsid w:val="00A10FD9" />
+    <w:rPr>
+      <w:rFonts w:asciiTheme="majorHAnsi"
+      w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi"
+      w:cstheme="majorBidi" />
+      <w:spacing w:val="-10" />
+      <w:kern w:val="28" />
+      <w:sz w:val="56" />
+      <w:szCs w:val="56" />
+    </w:rPr>
+  </w:style>
+  <w:style w:type="paragraph" w:styleId="Subtitle">
     <w:name w:val="Subtitle" />
-    <w:basedOn w:val="Title" />
+    <w:basedOn w:val="Normal" />
     <w:next w:val="BodyText" />
+    <w:link w:val="SubtitleChar" />
+    <w:uiPriority w:val="11" />
     <w:qFormat />
+    <w:rsid w:val="00A10FD9" />
     <w:pPr>
-      <w:keepNext />
-      <w:keepLines />
-      <w:spacing w:before="240" w:after="240" />
-      <w:jc w:val="center" />
+      <w:numPr>
+        <w:ilvl w:val="1" />
+      </w:numPr>
     </w:pPr>
     <w:rPr>
-      <w:sz w:val="30" />
-      <w:szCs w:val="30" />
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:color w:val="595959" w:themeColor="text1"
+      w:themeTint="A6" />
+      <w:spacing w:val="15" />
+      <w:sz w:val="28" />
+      <w:szCs w:val="28" />
     </w:rPr>
- </w:style>
+  </w:style>
+  <w:style w:type="character" w:customStyle="1"
+  w:styleId="SubtitleChar">
+    <w:name w:val="Subtitle Char" />
+    <w:basedOn w:val="DefaultParagraphFont" />
+    <w:link w:val="Subtitle" />
+    <w:uiPriority w:val="11" />
+    <w:rsid w:val="00A10FD9" />
+    <w:rPr>
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:color w:val="595959" w:themeColor="text1"
+      w:themeTint="A6" />
+      <w:spacing w:val="15" />
+      <w:sz w:val="28" />
+      <w:szCs w:val="28" />
+    </w:rPr>
+  </w:style>
   <w:style w:type="paragraph" w:customStyle="1" w:styleId="Author">
     <w:name w:val="Author" />
     <w:next w:val="BodyText" />
@@ -141,193 +185,371 @@
     <w:rPr />
   </w:style>
   <w:style w:type="paragraph" w:styleId="Heading1">
-    <w:name w:val="Heading 1" />
+    <w:name w:val="heading 1" />
     <w:basedOn w:val="Normal" />
     <w:next w:val="BodyText" />
+    <w:link w:val="Heading1Char" />
     <w:uiPriority w:val="9" />
     <w:qFormat />
+    <w:rsid w:val="00A10FD9" />
     <w:pPr>
       <w:keepNext />
       <w:keepLines />
-      <w:spacing w:before="480" w:after="0" />
+      <w:spacing w:before="360" w:after="80" />
       <w:outlineLvl w:val="0" />
     </w:pPr>
     <w:rPr>
-      <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
-      <w:b />
-      <w:bCs />
-      <w:color w:val="4F81BD" w:themeColor="accent1" />
-      <w:sz w:val="32" />
-      <w:szCs w:val="32" />
+      <w:rFonts w:asciiTheme="majorHAnsi"
+      w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi"
+      w:cstheme="majorBidi" />
+      <w:color w:val="0F4761" w:themeColor="accent1"
+      w:themeShade="BF" />
+      <w:sz w:val="40" />
+      <w:szCs w:val="40" />
     </w:rPr>
   </w:style>
   <w:style w:type="paragraph" w:styleId="Heading2">
-    <w:name w:val="Heading 2" />
+    <w:name w:val="heading 2" />
     <w:basedOn w:val="Normal" />
     <w:next w:val="BodyText" />
+    <w:link w:val="Heading2Char" />
     <w:uiPriority w:val="9" />
+    <w:semiHidden />
     <w:unhideWhenUsed />
     <w:qFormat />
+    <w:rsid w:val="00A10FD9" />
     <w:pPr>
       <w:keepNext />
       <w:keepLines />
-      <w:spacing w:before="200" w:after="0" />
+      <w:spacing w:before="160" w:after="80" />
       <w:outlineLvl w:val="1" />
     </w:pPr>
     <w:rPr>
-      <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
-      <w:b />
-      <w:bCs />
-      <w:color w:val="4F81BD" w:themeColor="accent1" />
-      <w:sz w:val="28" />
-      <w:szCs w:val="28" />
+      <w:rFonts w:asciiTheme="majorHAnsi"
+      w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi"
+      w:cstheme="majorBidi" />
+      <w:color w:val="0F4761" w:themeColor="accent1"
+      w:themeShade="BF" />
+      <w:sz w:val="32" />
+      <w:szCs w:val="32" />
     </w:rPr>
   </w:style>
   <w:style w:type="paragraph" w:styleId="Heading3">
-    <w:name w:val="Heading 3" />
+    <w:name w:val="heading 3" />
     <w:basedOn w:val="Normal" />
     <w:next w:val="BodyText" />
+    <w:link w:val="Heading3Char" />
     <w:uiPriority w:val="9" />
+    <w:semiHidden />
     <w:unhideWhenUsed />
     <w:qFormat />
+    <w:rsid w:val="00A10FD9" />
     <w:pPr>
       <w:keepNext />
       <w:keepLines />
-      <w:spacing w:before="200" w:after="0" />
+      <w:spacing w:before="160" w:after="80" />
       <w:outlineLvl w:val="2" />
     </w:pPr>
     <w:rPr>
-      <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
-      <w:b />
-      <w:bCs />
-      <w:color w:val="4F81BD" w:themeColor="accent1" />
-      <w:sz w:val="24" />
-      <w:szCs w:val="24" />
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:color w:val="0F4761" w:themeColor="accent1"
+      w:themeShade="BF" />
+      <w:sz w:val="28" />
+      <w:szCs w:val="28" />
     </w:rPr>
   </w:style>
   <w:style w:type="paragraph" w:styleId="Heading4">
-    <w:name w:val="Heading 4" />
+    <w:name w:val="heading 4" />
     <w:basedOn w:val="Normal" />
     <w:next w:val="BodyText" />
+    <w:link w:val="Heading4Char" />
     <w:uiPriority w:val="9" />
+    <w:semiHidden />
     <w:unhideWhenUsed />
     <w:qFormat />
+    <w:rsid w:val="00A10FD9" />
     <w:pPr>
       <w:keepNext />
       <w:keepLines />
-      <w:spacing w:before="200" w:after="0" />
+      <w:spacing w:before="80" w:after="40" />
       <w:outlineLvl w:val="3" />
     </w:pPr>
     <w:rPr>
-      <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
-      <w:bCs />
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
       <w:i />
-      <w:color w:val="4F81BD" w:themeColor="accent1" />
-      <w:sz w:val="24" />
-      <w:szCs w:val="24" />
+      <w:iCs />
+      <w:color w:val="0F4761" w:themeColor="accent1"
+      w:themeShade="BF" />
     </w:rPr>
   </w:style>
   <w:style w:type="paragraph" w:styleId="Heading5">
-    <w:name w:val="Heading 5" />
+    <w:name w:val="heading 5" />
     <w:basedOn w:val="Normal" />
     <w:next w:val="BodyText" />
+    <w:link w:val="Heading5Char" />
     <w:uiPriority w:val="9" />
+    <w:semiHidden />
     <w:unhideWhenUsed />
     <w:qFormat />
+    <w:rsid w:val="00A10FD9" />
     <w:pPr>
       <w:keepNext />
       <w:keepLines />
-      <w:spacing w:before="200" w:after="0" />
+      <w:spacing w:before="80" w:after="40" />
       <w:outlineLvl w:val="4" />
     </w:pPr>
     <w:rPr>
-      <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
-      <w:iCs />
-      <w:color w:val="4F81BD" w:themeColor="accent1" />
-      <w:sz w:val="24" />
-      <w:szCs w:val="24" />
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:color w:val="0F4761" w:themeColor="accent1"
+      w:themeShade="BF" />
     </w:rPr>
   </w:style>
   <w:style w:type="paragraph" w:styleId="Heading6">
-    <w:name w:val="Heading 6" />
+    <w:name w:val="heading 6" />
     <w:basedOn w:val="Normal" />
     <w:next w:val="BodyText" />
+    <w:link w:val="Heading6Char" />
     <w:uiPriority w:val="9" />
+    <w:semiHidden />
     <w:unhideWhenUsed />
     <w:qFormat />
+    <w:rsid w:val="00A10FD9" />
     <w:pPr>
       <w:keepNext />
       <w:keepLines />
-      <w:spacing w:before="200" w:after="0" />
+      <w:spacing w:before="40" w:after="0" />
       <w:outlineLvl w:val="5" />
     </w:pPr>
     <w:rPr>
-      <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
-      <w:color w:val="4F81BD" w:themeColor="accent1" />
-      <w:sz w:val="24" />
-      <w:szCs w:val="24" />
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:i />
+      <w:iCs />
+      <w:color w:val="595959" w:themeColor="text1"
+      w:themeTint="A6" />
     </w:rPr>
   </w:style>
   <w:style w:type="paragraph" w:styleId="Heading7">
-    <w:name w:val="Heading 7" />
+    <w:name w:val="heading 7" />
     <w:basedOn w:val="Normal" />
     <w:next w:val="BodyText" />
+    <w:link w:val="Heading7Char" />
     <w:uiPriority w:val="9" />
+    <w:semiHidden />
     <w:unhideWhenUsed />
     <w:qFormat />
+    <w:rsid w:val="00A10FD9" />
     <w:pPr>
       <w:keepNext />
       <w:keepLines />
-      <w:spacing w:before="200" w:after="0" />
+      <w:spacing w:before="40" w:after="0" />
       <w:outlineLvl w:val="6" />
     </w:pPr>
     <w:rPr>
-      <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
-      <w:color w:val="4F81BD" w:themeColor="accent1" />
-      <w:sz w:val="24" />
-      <w:szCs w:val="24" />
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:color w:val="595959" w:themeColor="text1"
+      w:themeTint="A6" />
     </w:rPr>
   </w:style>
   <w:style w:type="paragraph" w:styleId="Heading8">
-    <w:name w:val="Heading 8" />
+    <w:name w:val="heading 8" />
     <w:basedOn w:val="Normal" />
     <w:next w:val="BodyText" />
+    <w:link w:val="Heading8Char" />
     <w:uiPriority w:val="9" />
+    <w:semiHidden />
     <w:unhideWhenUsed />
     <w:qFormat />
+    <w:rsid w:val="00A10FD9" />
     <w:pPr>
       <w:keepNext />
       <w:keepLines />
-      <w:spacing w:before="200" w:after="0" />
+      <w:spacing w:after="0" />
       <w:outlineLvl w:val="7" />
     </w:pPr>
     <w:rPr>
-      <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
-      <w:color w:val="4F81BD" w:themeColor="accent1" />
-      <w:sz w:val="24" />
-      <w:szCs w:val="24" />
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:i />
+      <w:iCs />
+      <w:color w:val="272727" w:themeColor="text1"
+      w:themeTint="D8" />
     </w:rPr>
   </w:style>
   <w:style w:type="paragraph" w:styleId="Heading9">
-    <w:name w:val="Heading 9" />
+    <w:name w:val="heading 9" />
     <w:basedOn w:val="Normal" />
     <w:next w:val="BodyText" />
+    <w:link w:val="Heading9Char" />
     <w:uiPriority w:val="9" />
+    <w:semiHidden />
     <w:unhideWhenUsed />
     <w:qFormat />
+    <w:rsid w:val="00A10FD9" />
     <w:pPr>
       <w:keepNext />
       <w:keepLines />
-      <w:spacing w:before="200" w:after="0" />
+      <w:spacing w:after="0" />
       <w:outlineLvl w:val="8" />
     </w:pPr>
     <w:rPr>
-      <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
-      <w:color w:val="4F81BD" w:themeColor="accent1" />
-      <w:sz w:val="24" />
-      <w:szCs w:val="24" />
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:color w:val="272727" w:themeColor="text1"
+      w:themeTint="D8" />
     </w:rPr>
   </w:style>
+  <w:style w:type="character" w:customStyle="1" w:styleId="Heading1Char">
+    <w:name w:val="Heading 1 Char" />
+    <w:basedOn w:val="DefaultParagraphFont" />
+    <w:link w:val="Heading1" />
+    <w:uiPriority w:val="9" />
+    <w:rsid w:val="00A10FD9" />
+    <w:rPr>
+      <w:rFonts w:asciiTheme="majorHAnsi"
+      w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi"
+      w:cstheme="majorBidi" />
+      <w:color w:val="0F4761" w:themeColor="accent1"
+      w:themeShade="BF" />
+      <w:sz w:val="40" />
+      <w:szCs w:val="40" />
+    </w:rPr>
+  </w:style>
+  <w:style w:type="character" w:customStyle="1"
+  w:styleId="Heading2Char">
+    <w:name w:val="Heading 2 Char" />
+    <w:basedOn w:val="DefaultParagraphFont" />
+    <w:link w:val="Heading2" />
+    <w:uiPriority w:val="9" />
+    <w:semiHidden />
+    <w:rsid w:val="00A10FD9" />
+    <w:rPr>
+      <w:rFonts w:asciiTheme="majorHAnsi"
+      w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi"
+      w:cstheme="majorBidi" />
+      <w:color w:val="0F4761" w:themeColor="accent1"
+      w:themeShade="BF" />
+      <w:sz w:val="32" />
+      <w:szCs w:val="32" />
+    </w:rPr>
+  </w:style>
+  <w:style w:type="character" w:customStyle="1"
+  w:styleId="Heading3Char">
+    <w:name w:val="Heading 3 Char" />
+    <w:basedOn w:val="DefaultParagraphFont" />
+    <w:link w:val="Heading3" />
+    <w:uiPriority w:val="9" />
+    <w:semiHidden />
+    <w:rsid w:val="00A10FD9" />
+    <w:rPr>
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:color w:val="0F4761" w:themeColor="accent1"
+      w:themeShade="BF" />
+      <w:sz w:val="28" />
+      <w:szCs w:val="28" />
+    </w:rPr>
+  </w:style>
+  <w:style w:type="character" w:customStyle="1"
+  w:styleId="Heading4Char">
+    <w:name w:val="Heading 4 Char" />
+    <w:basedOn w:val="DefaultParagraphFont" />
+    <w:link w:val="Heading4" />
+    <w:uiPriority w:val="9" />
+    <w:semiHidden />
+    <w:rsid w:val="00A10FD9" />
+    <w:rPr>
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:i />
+      <w:iCs />
+      <w:color w:val="0F4761" w:themeColor="accent1"
+      w:themeShade="BF" />
+    </w:rPr>
+  </w:style>
+  <w:style w:type="character" w:customStyle="1"
+  w:styleId="Heading5Char">
+    <w:name w:val="Heading 5 Char" />
+    <w:basedOn w:val="DefaultParagraphFont" />
+    <w:link w:val="Heading5" />
+    <w:uiPriority w:val="9" />
+    <w:semiHidden />
+    <w:rsid w:val="00A10FD9" />
+    <w:rPr>
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:color w:val="0F4761" w:themeColor="accent1"
+      w:themeShade="BF" />
+    </w:rPr>
+  </w:style>
+  <w:style w:type="character" w:customStyle="1"
+  w:styleId="Heading6Char">
+    <w:name w:val="Heading 6 Char" />
+    <w:basedOn w:val="DefaultParagraphFont" />
+    <w:link w:val="Heading6" />
+    <w:uiPriority w:val="9" />
+    <w:semiHidden />
+    <w:rsid w:val="00A10FD9" />
+    <w:rPr>
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:i />
+      <w:iCs />
+      <w:color w:val="595959" w:themeColor="text1"
+      w:themeTint="A6" />
+    </w:rPr>
+  </w:style>
+  <w:style w:type="character" w:customStyle="1"
+  w:styleId="Heading7Char">
+    <w:name w:val="Heading 7 Char" />
+    <w:basedOn w:val="DefaultParagraphFont" />
+    <w:link w:val="Heading7" />
+    <w:uiPriority w:val="9" />
+    <w:semiHidden />
+    <w:rsid w:val="00A10FD9" />
+    <w:rPr>
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:color w:val="595959" w:themeColor="text1"
+      w:themeTint="A6" />
+    </w:rPr>
+  </w:style>
+  <w:style w:type="character" w:customStyle="1"
+  w:styleId="Heading8Char">
+    <w:name w:val="Heading 8 Char" />
+    <w:basedOn w:val="DefaultParagraphFont" />
+    <w:link w:val="Heading8" />
+    <w:uiPriority w:val="9" />
+    <w:semiHidden />
+    <w:rsid w:val="00A10FD9" />
+    <w:rPr>
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:i />
+      <w:iCs />
+      <w:color w:val="272727" w:themeColor="text1"
+      w:themeTint="D8" />
+    </w:rPr>
+  </w:style>
+  <w:style w:type="character" w:customStyle="1"
+  w:styleId="Heading9Char">
+    <w:name w:val="Heading 9 Char" />
+    <w:basedOn w:val="DefaultParagraphFont" />
+    <w:link w:val="Heading9" />
+    <w:uiPriority w:val="9" />
+    <w:semiHidden />
+    <w:rsid w:val="00A10FD9" />
+    <w:rPr>
+      <w:rFonts w:eastAsiaTheme="majorEastAsia"
+      w:cstheme="majorBidi" />
+      <w:color w:val="272727" w:themeColor="text1"
+      w:themeTint="D8" />
+    </w:rPr>
+  </w:style>
   <w:style w:type="paragraph" w:styleId="BlockText">
     <w:name w:val="Block Text" />
     <w:basedOn w:val="BodyText" />
@@ -350,8 +572,8 @@
   </w:style>
   <w:style w:type="paragraph" w:styleId="FootnoteBlockText">
     <w:name w:val="Footnote Block Text" />
-    <w:basedOn w:val="Footnote Text" />
-    <w:next w:val="Footnote Text" />
+    <w:basedOn w:val="FootnoteText" />
+    <w:next w:val="FootnoteText" />
     <w:uiPriority w:val="9" />
     <w:unhideWhenUsed />
     <w:qFormat />
diff --git a/data/docx/word/theme/theme1.xml b/data/docx/word/theme/theme1.xml
--- a/data/docx/word/theme/theme1.xml
+++ b/data/docx/word/theme/theme1.xml
@@ -1,2 +1,293 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000" /></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF" /></a:lt1><a:dk2><a:srgbClr val="1F497D" /></a:dk2><a:lt2><a:srgbClr val="EEECE1" /></a:lt2><a:accent1><a:srgbClr val="4F81BD" /></a:accent1><a:accent2><a:srgbClr val="C0504D" /></a:accent2><a:accent3><a:srgbClr val="9BBB59" /></a:accent3><a:accent4><a:srgbClr val="8064A2" /></a:accent4><a:accent5><a:srgbClr val="4BACC6" /></a:accent5><a:accent6><a:srgbClr val="F79646" /></a:accent6><a:hlink><a:srgbClr val="0000FF" /></a:hlink><a:folHlink><a:srgbClr val="800080" /></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Calibri" /><a:ea typeface="" /><a:cs typeface="" /><a:font script="Jpan" typeface="ＭＳ ゴシック" /><a:font script="Hang" typeface="맑은 고딕" /><a:font script="Hans" typeface="宋体" /><a:font script="Hant" typeface="新細明體" /><a:font script="Arab" typeface="Times New Roman" /><a:font script="Hebr" typeface="Times New Roman" /><a:font script="Thai" typeface="Angsana New" /><a:font script="Ethi" typeface="Nyala" /><a:font script="Beng" typeface="Vrinda" /><a:font script="Gujr" typeface="Shruti" /><a:font script="Khmr" typeface="MoolBoran" /><a:font script="Knda" typeface="Tunga" /><a:font script="Guru" typeface="Raavi" /><a:font script="Cans" typeface="Euphemia" /><a:font script="Cher" typeface="Plantagenet Cherokee" /><a:font script="Yiii" typeface="Microsoft Yi Baiti" /><a:font script="Tibt" typeface="Microsoft Himalaya" /><a:font script="Thaa" typeface="MV Boli" /><a:font script="Deva" typeface="Mangal" /><a:font script="Telu" typeface="Gautami" /><a:font script="Taml" typeface="Latha" /><a:font script="Syrc" typeface="Estrangelo Edessa" /><a:font script="Orya" typeface="Kalinga" /><a:font script="Mlym" typeface="Kartika" /><a:font script="Laoo" typeface="DokChampa" /><a:font script="Sinh" typeface="Iskoola Pota" /><a:font script="Mong" typeface="Mongolian Baiti" /><a:font script="Viet" typeface="Times New Roman" /><a:font script="Uigh" typeface="Microsoft Uighur" /></a:majorFont><a:minorFont><a:latin typeface="Cambria" /><a:ea typeface="" /><a:cs typeface="" /><a:font script="Jpan" typeface="ＭＳ 明朝" /><a:font script="Hang" typeface="맑은 고딕" /><a:font script="Hans" typeface="宋体" /><a:font script="Hant" typeface="新細明體" /><a:font script="Arab" typeface="Arial" /><a:font script="Hebr" typeface="Arial" /><a:font script="Thai" typeface="Cordia New" /><a:font script="Ethi" typeface="Nyala" /><a:font script="Beng" typeface="Vrinda" /><a:font script="Gujr" typeface="Shruti" /><a:font script="Khmr" typeface="DaunPenh" /><a:font script="Knda" typeface="Tunga" /><a:font script="Guru" typeface="Raavi" /><a:font script="Cans" typeface="Euphemia" /><a:font script="Cher" typeface="Plantagenet Cherokee" /><a:font script="Yiii" typeface="Microsoft Yi Baiti" /><a:font script="Tibt" typeface="Microsoft Himalaya" /><a:font script="Thaa" typeface="MV Boli" /><a:font script="Deva" typeface="Mangal" /><a:font script="Telu" typeface="Gautami" /><a:font script="Taml" typeface="Latha" /><a:font script="Syrc" typeface="Estrangelo Edessa" /><a:font script="Orya" typeface="Kalinga" /><a:font script="Mlym" typeface="Kartika" /><a:font script="Laoo" typeface="DokChampa" /><a:font script="Sinh" typeface="Iskoola Pota" /><a:font script="Mong" typeface="Mongolian Baiti" /><a:font script="Viet" typeface="Arial" /><a:font script="Uigh" typeface="Microsoft Uighur" /></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr" /></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000" /><a:satMod val="300000" /></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000" /><a:satMod val="300000" /></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000" /><a:satMod val="350000" /></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1" /></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="100000" /><a:shade val="100000" /><a:satMod val="130000" /></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="50000" /><a:shade val="100000" /><a:satMod val="350000" /></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0" /></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000" /><a:satMod val="105000" /></a:schemeClr></a:solidFill><a:prstDash val="solid" /></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr" /></a:solidFill><a:prstDash val="solid" /></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr" /></a:solidFill><a:prstDash val="solid" /></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000" /></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000" /></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000" /></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0" /></a:camera><a:lightRig rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000" /></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400" /></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr" /></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000" /><a:satMod val="350000" /></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000" /><a:shade val="99000" /><a:satMod val="350000" /></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000" /><a:satMod val="255000" /></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000" /></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000" /><a:satMod val="300000" /></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000" /><a:satMod val="200000" /></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000" /></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults><a:spDef><a:spPr /><a:bodyPr /><a:lstStyle /><a:style><a:lnRef idx="1"><a:schemeClr val="accent1" /></a:lnRef><a:fillRef idx="3"><a:schemeClr val="accent1" /></a:fillRef><a:effectRef idx="2"><a:schemeClr val="accent1" /></a:effectRef><a:fontRef idx="minor"><a:schemeClr val="lt1" /></a:fontRef></a:style></a:spDef><a:lnDef><a:spPr /><a:bodyPr /><a:lstStyle /><a:style><a:lnRef idx="2"><a:schemeClr val="accent1" /></a:lnRef><a:fillRef idx="0"><a:schemeClr val="accent1" /></a:fillRef><a:effectRef idx="1"><a:schemeClr val="accent1" /></a:effectRef><a:fontRef idx="minor"><a:schemeClr val="tx1" /></a:fontRef></a:style></a:lnDef></a:objectDefaults><a:extraClrSchemeLst /></a:theme>
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme">
+  <a:themeElements>
+    <a:clrScheme name="Office">
+      <a:dk1>
+        <a:sysClr val="windowText" lastClr="000000"/>
+      </a:dk1>
+      <a:lt1>
+        <a:sysClr val="window" lastClr="FFFFFF"/>
+      </a:lt1>
+      <a:dk2>
+        <a:srgbClr val="0E2841"/>
+      </a:dk2>
+      <a:lt2>
+        <a:srgbClr val="E8E8E8"/>
+      </a:lt2>
+      <a:accent1>
+        <a:srgbClr val="156082"/>
+      </a:accent1>
+      <a:accent2>
+        <a:srgbClr val="E97132"/>
+      </a:accent2>
+      <a:accent3>
+        <a:srgbClr val="196B24"/>
+      </a:accent3>
+      <a:accent4>
+        <a:srgbClr val="0F9ED5"/>
+      </a:accent4>
+      <a:accent5>
+        <a:srgbClr val="A02B93"/>
+      </a:accent5>
+      <a:accent6>
+        <a:srgbClr val="4EA72E"/>
+      </a:accent6>
+      <a:hlink>
+        <a:srgbClr val="467886"/>
+      </a:hlink>
+      <a:folHlink>
+        <a:srgbClr val="96607D"/>
+      </a:folHlink>
+    </a:clrScheme>
+    <a:fontScheme name="Office">
+      <a:majorFont>
+        <a:latin typeface="Aptos Display" panose="02110004020202020204"/>
+        <a:ea typeface=""/>
+        <a:cs typeface=""/>
+        <a:font script="Jpan" typeface="游ゴシック Light"/>
+        <a:font script="Hang" typeface="맑은 고딕"/>
+        <a:font script="Hans" typeface="等线 Light"/>
+        <a:font script="Hant" typeface="新細明體"/>
+        <a:font script="Arab" typeface="Times New Roman"/>
+        <a:font script="Hebr" typeface="Times New Roman"/>
+        <a:font script="Thai" typeface="Angsana New"/>
+        <a:font script="Ethi" typeface="Nyala"/>
+        <a:font script="Beng" typeface="Vrinda"/>
+        <a:font script="Gujr" typeface="Shruti"/>
+        <a:font script="Khmr" typeface="MoolBoran"/>
+        <a:font script="Knda" typeface="Tunga"/>
+        <a:font script="Guru" typeface="Raavi"/>
+        <a:font script="Cans" typeface="Euphemia"/>
+        <a:font script="Cher" typeface="Plantagenet Cherokee"/>
+        <a:font script="Yiii" typeface="Microsoft Yi Baiti"/>
+        <a:font script="Tibt" typeface="Microsoft Himalaya"/>
+        <a:font script="Thaa" typeface="MV Boli"/>
+        <a:font script="Deva" typeface="Mangal"/>
+        <a:font script="Telu" typeface="Gautami"/>
+        <a:font script="Taml" typeface="Latha"/>
+        <a:font script="Syrc" typeface="Estrangelo Edessa"/>
+        <a:font script="Orya" typeface="Kalinga"/>
+        <a:font script="Mlym" typeface="Kartika"/>
+        <a:font script="Laoo" typeface="DokChampa"/>
+        <a:font script="Sinh" typeface="Iskoola Pota"/>
+        <a:font script="Mong" typeface="Mongolian Baiti"/>
+        <a:font script="Viet" typeface="Times New Roman"/>
+        <a:font script="Uigh" typeface="Microsoft Uighur"/>
+        <a:font script="Geor" typeface="Sylfaen"/>
+        <a:font script="Armn" typeface="Arial"/>
+        <a:font script="Bugi" typeface="Leelawadee UI"/>
+        <a:font script="Bopo" typeface="Microsoft JhengHei"/>
+        <a:font script="Java" typeface="Javanese Text"/>
+        <a:font script="Lisu" typeface="Segoe UI"/>
+        <a:font script="Mymr" typeface="Myanmar Text"/>
+        <a:font script="Nkoo" typeface="Ebrima"/>
+        <a:font script="Olck" typeface="Nirmala UI"/>
+        <a:font script="Osma" typeface="Ebrima"/>
+        <a:font script="Phag" typeface="Phagspa"/>
+        <a:font script="Syrn" typeface="Estrangelo Edessa"/>
+        <a:font script="Syrj" typeface="Estrangelo Edessa"/>
+        <a:font script="Syre" typeface="Estrangelo Edessa"/>
+        <a:font script="Sora" typeface="Nirmala UI"/>
+        <a:font script="Tale" typeface="Microsoft Tai Le"/>
+        <a:font script="Talu" typeface="Microsoft New Tai Lue"/>
+        <a:font script="Tfng" typeface="Ebrima"/>
+      </a:majorFont>
+      <a:minorFont>
+        <a:latin typeface="Aptos" panose="02110004020202020204"/>
+        <a:ea typeface=""/>
+        <a:cs typeface=""/>
+        <a:font script="Jpan" typeface="游明朝"/>
+        <a:font script="Hang" typeface="맑은 고딕"/>
+        <a:font script="Hans" typeface="等线"/>
+        <a:font script="Hant" typeface="新細明體"/>
+        <a:font script="Arab" typeface="Arial"/>
+        <a:font script="Hebr" typeface="Arial"/>
+        <a:font script="Thai" typeface="Cordia New"/>
+        <a:font script="Ethi" typeface="Nyala"/>
+        <a:font script="Beng" typeface="Vrinda"/>
+        <a:font script="Gujr" typeface="Shruti"/>
+        <a:font script="Khmr" typeface="DaunPenh"/>
+        <a:font script="Knda" typeface="Tunga"/>
+        <a:font script="Guru" typeface="Raavi"/>
+        <a:font script="Cans" typeface="Euphemia"/>
+        <a:font script="Cher" typeface="Plantagenet Cherokee"/>
+        <a:font script="Yiii" typeface="Microsoft Yi Baiti"/>
+        <a:font script="Tibt" typeface="Microsoft Himalaya"/>
+        <a:font script="Thaa" typeface="MV Boli"/>
+        <a:font script="Deva" typeface="Mangal"/>
+        <a:font script="Telu" typeface="Gautami"/>
+        <a:font script="Taml" typeface="Latha"/>
+        <a:font script="Syrc" typeface="Estrangelo Edessa"/>
+        <a:font script="Orya" typeface="Kalinga"/>
+        <a:font script="Mlym" typeface="Kartika"/>
+        <a:font script="Laoo" typeface="DokChampa"/>
+        <a:font script="Sinh" typeface="Iskoola Pota"/>
+        <a:font script="Mong" typeface="Mongolian Baiti"/>
+        <a:font script="Viet" typeface="Arial"/>
+        <a:font script="Uigh" typeface="Microsoft Uighur"/>
+        <a:font script="Geor" typeface="Sylfaen"/>
+        <a:font script="Armn" typeface="Arial"/>
+        <a:font script="Bugi" typeface="Leelawadee UI"/>
+        <a:font script="Bopo" typeface="Microsoft JhengHei"/>
+        <a:font script="Java" typeface="Javanese Text"/>
+        <a:font script="Lisu" typeface="Segoe UI"/>
+        <a:font script="Mymr" typeface="Myanmar Text"/>
+        <a:font script="Nkoo" typeface="Ebrima"/>
+        <a:font script="Olck" typeface="Nirmala UI"/>
+        <a:font script="Osma" typeface="Ebrima"/>
+        <a:font script="Phag" typeface="Phagspa"/>
+        <a:font script="Syrn" typeface="Estrangelo Edessa"/>
+        <a:font script="Syrj" typeface="Estrangelo Edessa"/>
+        <a:font script="Syre" typeface="Estrangelo Edessa"/>
+        <a:font script="Sora" typeface="Nirmala UI"/>
+        <a:font script="Tale" typeface="Microsoft Tai Le"/>
+        <a:font script="Talu" typeface="Microsoft New Tai Lue"/>
+        <a:font script="Tfng" typeface="Ebrima"/>
+      </a:minorFont>
+    </a:fontScheme>
+    <a:fmtScheme name="Office">
+      <a:fillStyleLst>
+        <a:solidFill>
+          <a:schemeClr val="phClr"/>
+        </a:solidFill>
+        <a:gradFill rotWithShape="1">
+          <a:gsLst>
+            <a:gs pos="0">
+              <a:schemeClr val="phClr">
+                <a:lumMod val="110000"/>
+                <a:satMod val="105000"/>
+                <a:tint val="67000"/>
+              </a:schemeClr>
+            </a:gs>
+            <a:gs pos="50000">
+              <a:schemeClr val="phClr">
+                <a:lumMod val="105000"/>
+                <a:satMod val="103000"/>
+                <a:tint val="73000"/>
+              </a:schemeClr>
+            </a:gs>
+            <a:gs pos="100000">
+              <a:schemeClr val="phClr">
+                <a:lumMod val="105000"/>
+                <a:satMod val="109000"/>
+                <a:tint val="81000"/>
+              </a:schemeClr>
+            </a:gs>
+          </a:gsLst>
+          <a:lin ang="5400000" scaled="0"/>
+        </a:gradFill>
+        <a:gradFill rotWithShape="1">
+          <a:gsLst>
+            <a:gs pos="0">
+              <a:schemeClr val="phClr">
+                <a:satMod val="103000"/>
+                <a:lumMod val="102000"/>
+                <a:tint val="94000"/>
+              </a:schemeClr>
+            </a:gs>
+            <a:gs pos="50000">
+              <a:schemeClr val="phClr">
+                <a:satMod val="110000"/>
+                <a:lumMod val="100000"/>
+                <a:shade val="100000"/>
+              </a:schemeClr>
+            </a:gs>
+            <a:gs pos="100000">
+              <a:schemeClr val="phClr">
+                <a:lumMod val="99000"/>
+                <a:satMod val="120000"/>
+                <a:shade val="78000"/>
+              </a:schemeClr>
+            </a:gs>
+          </a:gsLst>
+          <a:lin ang="5400000" scaled="0"/>
+        </a:gradFill>
+      </a:fillStyleLst>
+      <a:lnStyleLst>
+        <a:ln w="6350" cap="flat" cmpd="sng" algn="ctr">
+          <a:solidFill>
+            <a:schemeClr val="phClr"/>
+          </a:solidFill>
+          <a:prstDash val="solid"/>
+          <a:miter lim="800000"/>
+        </a:ln>
+        <a:ln w="12700" cap="flat" cmpd="sng" algn="ctr">
+          <a:solidFill>
+            <a:schemeClr val="phClr"/>
+          </a:solidFill>
+          <a:prstDash val="solid"/>
+          <a:miter lim="800000"/>
+        </a:ln>
+        <a:ln w="19050" cap="flat" cmpd="sng" algn="ctr">
+          <a:solidFill>
+            <a:schemeClr val="phClr"/>
+          </a:solidFill>
+          <a:prstDash val="solid"/>
+          <a:miter lim="800000"/>
+        </a:ln>
+      </a:lnStyleLst>
+      <a:effectStyleLst>
+        <a:effectStyle>
+          <a:effectLst/>
+        </a:effectStyle>
+        <a:effectStyle>
+          <a:effectLst/>
+        </a:effectStyle>
+        <a:effectStyle>
+          <a:effectLst>
+            <a:outerShdw blurRad="57150" dist="19050" dir="5400000" algn="ctr" rotWithShape="0">
+              <a:srgbClr val="000000">
+                <a:alpha val="63000"/>
+              </a:srgbClr>
+            </a:outerShdw>
+          </a:effectLst>
+        </a:effectStyle>
+      </a:effectStyleLst>
+      <a:bgFillStyleLst>
+        <a:solidFill>
+          <a:schemeClr val="phClr"/>
+        </a:solidFill>
+        <a:solidFill>
+          <a:schemeClr val="phClr">
+            <a:tint val="95000"/>
+            <a:satMod val="170000"/>
+          </a:schemeClr>
+        </a:solidFill>
+        <a:gradFill rotWithShape="1">
+          <a:gsLst>
+            <a:gs pos="0">
+              <a:schemeClr val="phClr">
+                <a:tint val="93000"/>
+                <a:satMod val="150000"/>
+                <a:shade val="98000"/>
+                <a:lumMod val="102000"/>
+              </a:schemeClr>
+            </a:gs>
+            <a:gs pos="50000">
+              <a:schemeClr val="phClr">
+                <a:tint val="98000"/>
+                <a:satMod val="130000"/>
+                <a:shade val="90000"/>
+                <a:lumMod val="103000"/>
+              </a:schemeClr>
+            </a:gs>
+            <a:gs pos="100000">
+              <a:schemeClr val="phClr">
+                <a:shade val="63000"/>
+                <a:satMod val="120000"/>
+              </a:schemeClr>
+            </a:gs>
+          </a:gsLst>
+          <a:lin ang="5400000" scaled="0"/>
+        </a:gradFill>
+      </a:bgFillStyleLst>
+    </a:fmtScheme>
+  </a:themeElements>
+  <a:objectDefaults/>
+  <a:extraClrSchemeLst/>
+  <a:extLst>
+    <a:ext uri="{05A4C25C-085E-4340-85A3-A5531E510DB2}">
+      <thm15:themeFamily xmlns:thm15="http://schemas.microsoft.com/office/thememl/2012/main" name="Office Theme" id="{2E142A2C-CD16-42D6-873A-C26D2A0506FA}" vid="{1BDDFF52-6CD6-40A5-AB3C-68EB2F1E4D0A}"/>
+    </a:ext>
+  </a:extLst>
+</a:theme>
diff --git a/data/templates/default.latex b/data/templates/default.latex
--- a/data/templates/default.latex
+++ b/data/templates/default.latex
@@ -534,7 +534,7 @@
 \institute{$for(institute)$$institute$$sep$ \and $endfor$}
 $endif$
 $if(titlegraphic)$
-\titlegraphic{\includegraphics{$titlegraphic$}}
+\titlegraphic{\includegraphics$if(titlegraphicoptions)$[$for(titlegraphicoptions)$$titlegraphicoptions$$sep$, $endfor$]$endif${$titlegraphic$}}
 $endif$
 $if(logo)$
 \logo{\includegraphics{$logo$}}
diff --git a/pandoc.cabal b/pandoc.cabal
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -1,10 +1,10 @@
 cabal-version:   2.4
 name:            pandoc
-version:         3.1.13
+version:         3.2
 build-type:      Simple
 license:         GPL-2.0-or-later
 license-file:    COPYING.md
-copyright:       (c) 2006-2023 John MacFarlane
+copyright:       (c) 2006-2024 John MacFarlane
 author:          John MacFarlane <jgm@berkeley.edu>
 maintainer:      John MacFarlane <jgm@berkeley.edu>
 bug-reports:     https://github.com/jgm/pandoc/issues
@@ -501,7 +501,7 @@
                  jira-wiki-markup      >= 1.5.1    && < 1.6,
                  mime-types            >= 0.1.1    && < 0.2,
                  mtl                   >= 2.2      && < 2.4,
-                 network               >= 2.6      && < 3.2,
+                 network               >= 2.6      && < 3.3,
                  network-uri           >= 2.6      && < 2.8,
                  pandoc-types          >= 1.23.1   && < 1.24,
                  parsec                >= 3.1      && < 3.2,
@@ -511,13 +511,13 @@
                  random                >= 1        && < 1.3,
                  safe                  >= 0.3.18   && < 0.4,
                  scientific            >= 0.3      && < 0.4,
-                 skylighting           >= 0.14.1.1 && < 0.15,
-                 skylighting-core      >= 0.14.1.1 && < 0.15,
+                 skylighting           >= 0.14.1.2 && < 0.15,
+                 skylighting-core      >= 0.14.1.2 && < 0.15,
                  split                 >= 0.2      && < 0.3,
                  syb                   >= 0.1      && < 0.8,
                  tagsoup               >= 0.14.6   && < 0.15,
                  temporary             >= 1.1      && < 1.4,
-                 texmath               >= 0.12.8.8 && < 0.13,
+                 texmath               >= 0.12.8.9 && < 0.13,
                  text                  >= 1.1.1.0  && < 2.2,
                  text-conversions      >= 0.3      && < 0.4,
                  time                  >= 1.5      && < 1.14,
@@ -529,7 +529,7 @@
                  xml                   >= 1.3.12   && < 1.4,
                  typst                 >= 0.5.0.3  && < 0.5.1,
                  vector                >= 0.12     && < 0.14,
-                 djot                  >= 0.1.1.3  && < 0.2,
+                 djot                  >= 0.1.2    && < 0.2,
                  tls                   >= 2.0.1    && < 2.1,
                  crypton-x509-system   >= 1.6.7    && < 1.7
 
@@ -651,6 +651,7 @@
                    Text.Pandoc.Class.IO,
                    Text.Pandoc.Citeproc,
                    Text.Pandoc.Chunks,
+                   Text.Pandoc.Transforms,
                    Text.Pandoc.Version
   other-modules:   Text.Pandoc.App.CommandLineOptions,
                    Text.Pandoc.App.Input,
diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs
--- a/src/Text/Pandoc.hs
+++ b/src/Text/Pandoc.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 {- |
    Module      : Text.Pandoc
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
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
@@ -4,7 +4,7 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 {- |
    Module      : Text.Pandoc.App
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley@edu>
@@ -57,6 +57,8 @@
                                            options, handleOptInfo)
 import Text.Pandoc.App.Input (InputParameters (..), readInput)
 import Text.Pandoc.App.OutputSettings (OutputSettings (..), optToOutputSettings)
+import Text.Pandoc.Transforms (applyTransforms, filterIpynbOutput,
+                               headerShift, eastAsianLineBreakFilter)
 import Text.Collate.Lang (Lang (..), parseLang)
 import Text.Pandoc.Filter (Filter (JSONFilter, LuaFilter), Environment (..),
                            applyFilters)
@@ -64,8 +66,7 @@
 import Text.Pandoc.PDF (makePDF)
 import Text.Pandoc.Scripting (ScriptingEngine (..), CustomComponents(..))
 import Text.Pandoc.SelfContained (makeSelfContained)
-import Text.Pandoc.Shared (eastAsianLineBreakFilter,
-         headerShift, filterIpynbOutput, tshow)
+import Text.Pandoc.Shared (tshow)
 import Text.Pandoc.URI (isURI)
 import Text.Pandoc.Writers.Shared (lookupMetaString)
 import Text.Pandoc.Readers.Markdown (yamlToMeta)
@@ -297,8 +298,8 @@
           >>= ( return . adjustMetadata (metadataFromFile <>)
             >=> return . adjustMetadata (<> optMetadata opts)
             >=> return . adjustMetadata (<> cslMetadata)
-            >=> applyTransforms transforms
             >=> applyFilters scriptingEngine filterEnv filters [T.unpack format]
+            >=> applyTransforms transforms
             >=> (if not (optSandbox opts) &&
                     (isJust (optExtractMedia opts)
                      || format == "docx") -- for fallback pngs
@@ -341,8 +342,6 @@
     | ZipOutput BL.ByteString
   deriving (Show)
 
-type Transform = Pandoc -> Pandoc
-
 -- | Configure the common state
 configureCommonState :: PandocMonad m => Maybe FilePath -> Opt -> m ()
 configureCommonState datadir opts = do
@@ -411,11 +410,6 @@
 
 adjustMetadata :: (Meta -> Meta) -> Pandoc -> Pandoc
 adjustMetadata f (Pandoc meta bs) = Pandoc (f meta) bs
-
--- Transformations of a Pandoc document post-parsing:
-
-applyTransforms :: Monad m => [Transform] -> Pandoc -> m Pandoc
-applyTransforms transforms d = return $ foldr ($) d transforms
 
 writeFnBinary :: FilePath -> BL.ByteString -> IO ()
 writeFnBinary "-" = BL.putStr
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
@@ -1,12 +1,11 @@
 {-# LANGUAGE CPP                 #-}
-{-# LANGUAGE LambdaCase          #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 {-# LANGUAGE TupleSections       #-}
 {-# LANGUAGE OverloadedStrings   #-}
 {-# LANGUAGE FlexibleContexts    #-}
 {- |
    Module      : Text.Pandoc.App.CommandLineOptions
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley@edu>
@@ -199,7 +198,6 @@
       UTF8.hPutStrLn stdout
        $ T.pack
        $ prg ++ " " ++ T.unpack pandocVersionText ++
-         compileInfo ++
          "\nUser data directory: " ++ defaultDatadir ++
          ('\n':copyrightMessage)
     Help -> do
@@ -1104,16 +1102,9 @@
 
 copyrightMessage :: String
 copyrightMessage = intercalate "\n" [
- "Copyright (C) 2006-2023 John MacFarlane. Web:  https://pandoc.org",
+ "Copyright (C) 2006-2024 John MacFarlane. Web:  https://pandoc.org",
  "This is free software; see the source for copying conditions. There is no",
  "warranty, not even for merchantability or fitness for a particular purpose." ]
-
-compileInfo :: String
-compileInfo =
-  "\nCompiled with pandoc-types " ++ VERSION_pandoc_types ++
-  ", texmath " ++ VERSION_texmath ++ ", skylighting " ++
-  VERSION_skylighting ++ ",\nciteproc " ++ VERSION_citeproc ++
-  ", ipynb " ++ VERSION_ipynb
 
 handleUnrecognizedOption :: String -> [String] -> [String]
 handleUnrecognizedOption "--smart" =
diff --git a/src/Text/Pandoc/App/Input.hs b/src/Text/Pandoc/App/Input.hs
--- a/src/Text/Pandoc/App/Input.hs
+++ b/src/Text/Pandoc/App/Input.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE TupleSections       #-}
 {- |
    Module      : Text.Pandoc.App.Input
-   Copyright   : © 2006-2023 John MacFarlane
+   Copyright   : © 2006-2024 John MacFarlane
    License     : GPL-2.0-or-later
    Maintainer  : John MacFarlane <jgm@berkeley@edu>
 
@@ -17,18 +17,18 @@
 import Control.Monad ((>=>))
 import Control.Monad.Except (throwError, catchError)
 import Data.Text (Text)
-import Network.URI (URI (..), parseURI, unEscapeString)
+import Network.URI (URI (..), parseURI)
+import Text.Pandoc.Transforms (adjustLinksAndIds)
 import Text.Pandoc.Class ( PandocMonad, openURL, toTextM
                          , readFileStrict, readStdinStrict, report)
-import Text.Pandoc.Definition (Pandoc (..), Attr, Block (..), Inline (..))
+import Text.Pandoc.Definition (Pandoc)
 import Text.Pandoc.Error (PandocError (..))
 import Text.Pandoc.Logging (LogMessage (..))
 import Text.Pandoc.MIME (getCharset, MimeType)
-import Text.Pandoc.Options (Extensions, ReaderOptions (..))
+import Text.Pandoc.Options (ReaderOptions (..))
 import Text.Pandoc.Readers (Reader (..))
-import Text.Pandoc.Shared (tabFilter, textToIdentifier)
+import Text.Pandoc.Shared (tabFilter)
 import Text.Pandoc.URI (uriPathToPath)
-import Text.Pandoc.Walk (walk)
 import qualified Data.ByteString as BS
 import qualified Data.ByteString.Char8 as B8
 import qualified Data.ByteString.Lazy as BL
@@ -119,57 +119,3 @@
 inputToLazyByteString :: (FilePath, (BS.ByteString, Maybe MimeType))
                       -> BL.ByteString
 inputToLazyByteString (_, (bs,_)) = BL.fromStrict bs
-
-adjustLinksAndIds :: Extensions -> Text -> [Text] -> Pandoc -> Pandoc
-adjustLinksAndIds exts thisfile allfiles
-  | length allfiles > 1 = addDiv . walk fixInline . walk fixBlock
-  | otherwise           = id
- where
-  toIdent :: Text -> Text
-  toIdent = textToIdentifier exts . T.intercalate "__" .
-            T.split (\c -> c == '/' || c == '\\')
-
-  addDiv :: Pandoc -> Pandoc
-  addDiv (Pandoc m bs)
-    | T.null thisfile = Pandoc m bs
-    | otherwise = Pandoc m [Div (toIdent thisfile,[],[]) bs]
-
-  fixBlock :: Block -> Block
-  fixBlock (CodeBlock attr t) = CodeBlock (fixAttrs attr) t
-  fixBlock (Header lev attr ils) = Header lev (fixAttrs attr) ils
-  fixBlock (Table attr cap cols th tbs tf) =
-     Table (fixAttrs attr) cap cols th tbs tf
-  fixBlock (Div attr bs) = Div (fixAttrs attr) bs
-  fixBlock x = x
-
-  -- add thisfile as prefix of identifier
-  fixAttrs :: Attr -> Attr
-  fixAttrs (i,cs,kvs)
-    | T.null i = (i,cs,kvs)
-    | otherwise =
-        (T.intercalate "__"
-          (filter (not . T.null) [toIdent thisfile, i]),
-        cs, kvs)
-
-  -- if URL begins with file from allfiles, convert to
-  -- an internal link with the appropriate identifier
-  fixURL :: Text -> Text
-  fixURL u =
-    let (a,b) = T.break (== '#') $ T.pack . unEscapeString . T.unpack $ u
-        filepart = if T.null a
-                      then toIdent thisfile
-                      else toIdent a
-        fragpart = T.dropWhile (== '#') b
-     in if T.null a || a `elem` allfiles
-           then "#" <> T.intercalate "__"
-                         (filter (not . T.null) [filepart, fragpart])
-           else u
-
-  fixInline :: Inline -> Inline
-  fixInline (Code attr t) = Code (fixAttrs attr) t
-  fixInline (Link attr ils (url,tit)) =
-    Link (fixAttrs attr) ils (fixURL url,tit)
-  fixInline (Image attr ils (url,tit)) =
-    Image (fixAttrs attr) ils (fixURL url,tit)
-  fixInline (Span attr ils) = Span (fixAttrs attr) ils
-  fixInline x = x
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
@@ -7,7 +7,7 @@
 {-# LANGUAGE FlexibleContexts    #-}
 {- |
    Module      : Text.Pandoc.App.Opt
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley@edu>
diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs
--- a/src/Text/Pandoc/App/OutputSettings.hs
+++ b/src/Text/Pandoc/App/OutputSettings.hs
@@ -6,7 +6,7 @@
 {-# LANGUAGE TupleSections       #-}
 {- |
    Module      : Text.Pandoc.App
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley@edu>
diff --git a/src/Text/Pandoc/Asciify.hs b/src/Text/Pandoc/Asciify.hs
--- a/src/Text/Pandoc/Asciify.hs
+++ b/src/Text/Pandoc/Asciify.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Text.Pandoc.Asciify
-   Copyright   : Copyright (C) 2013-2023 John MacFarlane
+   Copyright   : Copyright (C) 2013-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/CSS.hs b/src/Text/Pandoc/CSS.hs
--- a/src/Text/Pandoc/CSS.hs
+++ b/src/Text/Pandoc/CSS.hs
@@ -1,6 +1,6 @@
 {- |
 Module      : Text.Pandoc.CSS
-Copyright   : © 2006-2023 John MacFarlane <jgm@berkeley.edu>,
+Copyright   : © 2006-2024 John MacFarlane <jgm@berkeley.edu>,
                 2015-2016 Mauro Bieg,
                 2015      Ophir Lifshitz <hangfromthefloor@gmail.com>
 License     : GNU GPL, version 2 or above
diff --git a/src/Text/Pandoc/CSV.hs b/src/Text/Pandoc/CSV.hs
--- a/src/Text/Pandoc/CSV.hs
+++ b/src/Text/Pandoc/CSV.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Text.Pandoc.CSV
-   Copyright   : Copyright (C) 2017-2023 John MacFarlane <jgm@berkeley.edu>
+   Copyright   : Copyright (C) 2017-2024 John MacFarlane <jgm@berkeley.edu>
    License     : GNU GPL, version 2 or above
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
    Stability   : alpha
diff --git a/src/Text/Pandoc/Chunks.hs b/src/Text/Pandoc/Chunks.hs
--- a/src/Text/Pandoc/Chunks.hs
+++ b/src/Text/Pandoc/Chunks.hs
@@ -7,7 +7,7 @@
 {-# LANGUAGE DeriveGeneric #-}
 {- |
    Module      : Text.Pandoc.Chunks
-   Copyright   : Copyright (C) 2022-2023 John MacFarlane
+   Copyright   : Copyright (C) 2022-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Citeproc/Util.hs b/src/Text/Pandoc/Citeproc/Util.hs
--- a/src/Text/Pandoc/Citeproc/Util.hs
+++ b/src/Text/Pandoc/Citeproc/Util.hs
@@ -48,6 +48,7 @@
 toIETF "ngerman"         = "de-DE"
 toIETF "greek"           = "el-GR"
 toIETF "polutonikogreek" = "el-GR"
+toIETF "polytonicgreek"  = "el-GR"
 toIETF "hebrew"          = "he-IL"
 toIETF "hungarian"       = "hu-HU"
 toIETF "icelandic"       = "is-IS"
diff --git a/src/Text/Pandoc/Class/Sandbox.hs b/src/Text/Pandoc/Class/Sandbox.hs
--- a/src/Text/Pandoc/Class/Sandbox.hs
+++ b/src/Text/Pandoc/Class/Sandbox.hs
@@ -1,6 +1,6 @@
 {- |
 Module      : Text.Pandoc.Class.Sandbox
-Copyright   : Copyright (C) 2021-2023 John MacFarlane
+Copyright   : Copyright (C) 2021-2024 John MacFarlane
 License     : GNU GPL, version 2 or above
 
 Maintainer  : John MacFarlane (<jgm@berkeley.edu>)
diff --git a/src/Text/Pandoc/Data.hs b/src/Text/Pandoc/Data.hs
--- a/src/Text/Pandoc/Data.hs
+++ b/src/Text/Pandoc/Data.hs
@@ -5,7 +5,7 @@
 #endif
 {- |
 Module      : Text.Pandoc.Data
-Copyright   : Copyright (C) 2013-2023 John MacFarlane
+Copyright   : Copyright (C) 2013-2024 John MacFarlane
 License     : GNU GPL, version 2 or above
 
 Maintainer  : John MacFarlane <jgm@berkeley@edu>
diff --git a/src/Text/Pandoc/Data/BakedIn.hs b/src/Text/Pandoc/Data/BakedIn.hs
--- a/src/Text/Pandoc/Data/BakedIn.hs
+++ b/src/Text/Pandoc/Data/BakedIn.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE TemplateHaskell #-}
 {- |
 Module      : Text.Pandoc.Data.BakedIn
-Copyright   : Copyright (C) 2013-2023 John MacFarlane
+Copyright   : Copyright (C) 2013-2024 John MacFarlane
 License     : GNU GPL, version 2 or above
 
 Maintainer  : John MacFarlane <jgm@berkeley@edu>
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
@@ -3,7 +3,7 @@
 {-# LANGUAGE OverloadedStrings  #-}
 {- |
    Module      : Text.Pandoc.Error
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -136,7 +136,8 @@
          _     -> ""
     PandocUnsupportedExtensionError ext f ->
       "The extension " <> ext <> " is not supported " <>
-      "for " <> f
+      "for " <> f <> ".\nUse --list-extensions=" <> f <> " to " <>
+      "list supported extensions."
     PandocCiteprocError e' ->
       prettyCiteprocError e'
     PandocBibliographyError fp msg ->
diff --git a/src/Text/Pandoc/Extensions.hs b/src/Text/Pandoc/Extensions.hs
--- a/src/Text/Pandoc/Extensions.hs
+++ b/src/Text/Pandoc/Extensions.hs
@@ -4,7 +4,7 @@
 {-# LANGUAGE OverloadedStrings          #-}
 {- |
    Module      : Text.Pandoc.Extensions
-   Copyright   : Copyright (C) 2012-2023 John MacFarlane
+   Copyright   : Copyright (C) 2012-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Filter.hs b/src/Text/Pandoc/Filter.hs
--- a/src/Text/Pandoc/Filter.hs
+++ b/src/Text/Pandoc/Filter.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Filter
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley@edu>
diff --git a/src/Text/Pandoc/Filter/JSON.hs b/src/Text/Pandoc/Filter/JSON.hs
--- a/src/Text/Pandoc/Filter/JSON.hs
+++ b/src/Text/Pandoc/Filter/JSON.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Filter
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley@edu>
diff --git a/src/Text/Pandoc/Format.hs b/src/Text/Pandoc/Format.hs
--- a/src/Text/Pandoc/Format.hs
+++ b/src/Text/Pandoc/Format.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Format
-   Copyright   : © 2022-2023 Albert Krewinkel
+   Copyright   : © 2022-2024 Albert Krewinkel
    License     : GPL-2.0-or-later
    Maintainer  : Albert Krewinkel <pandoc@tarleb.com>
 
diff --git a/src/Text/Pandoc/Highlighting.hs b/src/Text/Pandoc/Highlighting.hs
--- a/src/Text/Pandoc/Highlighting.hs
+++ b/src/Text/Pandoc/Highlighting.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Highlighting
-   Copyright   : Copyright (C) 2008-2023 John MacFarlane
+   Copyright   : Copyright (C) 2008-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Image.hs b/src/Text/Pandoc/Image.hs
--- a/src/Text/Pandoc/Image.hs
+++ b/src/Text/Pandoc/Image.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings, ScopedTypeVariables, CPP #-}
 {- |
 Module      : Text.Pandoc.Image
-Copyright   : Copyright (C) 2020-2023 John MacFarlane
+Copyright   : Copyright (C) 2020-2024 John MacFarlane
 License     : GNU GPL, version 2 or above
 
 Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs
--- a/src/Text/Pandoc/ImageSize.hs
+++ b/src/Text/Pandoc/ImageSize.hs
@@ -3,7 +3,7 @@
 {-# OPTIONS_GHC -fno-warn-type-defaults #-}
 {- |
 Module      : Text.Pandoc.ImageSize
-Copyright   : Copyright (C) 2011-2023 John MacFarlane
+Copyright   : Copyright (C) 2011-2024 John MacFarlane
 License     : GNU GPL, version 2 or above
 
 Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -13,6 +13,7 @@
 Functions for determining the size of a PNG, JPEG, or GIF image.
 -}
 module Text.Pandoc.ImageSize ( ImageType(..)
+                             , ImageSize(..)
                              , imageType
                              , imageSize
                              , sizeInPixels
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
@@ -3,7 +3,7 @@
 {-# LANGUAGE OverloadedStrings  #-}
 {- |
    Module      : Text.Pandoc.Logging
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -79,6 +79,7 @@
   | Fetching Text
   | Extracting Text
   | LoadedResource FilePath FilePath
+  | ScriptingInfo Text (Maybe SourcePos)
   | ScriptingWarning Text (Maybe SourcePos)
   | NoTitleElement Text
   | NoLangSpecified
@@ -101,6 +102,8 @@
   | NotUTF8Encoded FilePath
   | MakePDFInfo Text Text
   | MakePDFWarning Text
+  | UnclosedDiv SourcePos SourcePos
+  | UnsupportedCodePage Int
   deriving (Show, Eq, Data, Ord, Typeable, Generic)
 
 instance ToJSON LogMessage where
@@ -203,6 +206,14 @@
       LoadedResource orig found ->
            ["for"  .= orig
            ,"from" .= found]
+      ScriptingInfo msg mbpos ->
+           ["message" .= msg] <>
+           case mbpos of
+             Nothing  -> []
+             Just pos -> ["source" .= sourceName pos
+                         ,"line" .= toJSON (sourceLine pos)
+                         ,"column" .= toJSON (sourceColumn pos)
+                         ]
       ScriptingWarning msg mbpos ->
            ["message" .= msg] <>
            case mbpos of
@@ -260,6 +271,18 @@
            ,"contents" .= contents]
       MakePDFWarning message ->
            ["message" .= message]
+      UnclosedDiv openpos closepos ->
+           ["openpos" .= object
+             [ "source" .= sourceName openpos,
+               "line" .= toJSON (sourceLine openpos),
+               "column" .= toJSON (sourceColumn openpos)]
+           ,"closepos" .= object
+             [ "source" .= sourceName closepos,
+               "line" .= toJSON (sourceLine closepos),
+               "column" .= toJSON (sourceColumn closepos)]
+           ]
+      UnsupportedCodePage cpg ->
+           ["codepage" .= cpg]
 
 showPos :: SourcePos -> Text
 showPos pos = Text.pack $ sn ++ "line " ++
@@ -338,6 +361,9 @@
          "Extracting " <> fp <> "..."
        LoadedResource orig found ->
          "Loaded " <> Text.pack orig <> " from " <> Text.pack found
+       ScriptingInfo s mbpos ->
+         "Scripting info" <>
+         maybe "" (\pos -> " at " <> showPos pos) mbpos  <> ": " <> s
        ScriptingWarning s mbpos ->
          "Scripting warning" <>
          maybe "" (\pos -> " at " <> showPos pos) mbpos  <> ": " <> s
@@ -400,6 +426,10 @@
              then mempty
              else "\n" <> contents
        MakePDFWarning message -> "[makePDF] " <> message
+       UnclosedDiv openpos closepos -> "Div at " <> showPos openpos <>
+          " unclosed at " <> showPos closepos <> ", closing implicitly."
+       UnsupportedCodePage cpg -> "Unsupported code page " <> tshow cpg <>
+          ". Text will likely be garbled."
 
 messageVerbosity :: LogMessage -> Verbosity
 messageVerbosity msg =
@@ -421,7 +451,7 @@
        ParsingUnescaped{}            -> INFO
        InlineNotRendered{}           -> INFO
        BlockNotRendered{}            -> INFO
-       DocxParserWarning{}           -> INFO
+       DocxParserWarning{}           -> WARNING
        PowerpointTemplateWarning{}   -> WARNING
        IgnoredIOError{}              -> WARNING
        CouldNotFetchResource{}       -> WARNING
@@ -433,6 +463,7 @@
        Fetching{}                    -> INFO
        Extracting{}                  -> INFO
        LoadedResource{}              -> INFO
+       ScriptingInfo{}               -> INFO
        ScriptingWarning{}            -> WARNING
        NoTitleElement{}              -> WARNING
        NoLangSpecified               -> INFO
@@ -455,3 +486,5 @@
        NotUTF8Encoded{}              -> WARNING
        MakePDFInfo{}                 -> INFO
        MakePDFWarning{}              -> WARNING
+       UnclosedDiv{}                 -> WARNING
+       UnsupportedCodePage{}         -> WARNING
diff --git a/src/Text/Pandoc/MIME.hs b/src/Text/Pandoc/MIME.hs
--- a/src/Text/Pandoc/MIME.hs
+++ b/src/Text/Pandoc/MIME.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.MIME
-   Copyright   : Copyright (C) 2011-2023 John MacFarlane
+   Copyright   : Copyright (C) 2011-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/MediaBag.hs b/src/Text/Pandoc/MediaBag.hs
--- a/src/Text/Pandoc/MediaBag.hs
+++ b/src/Text/Pandoc/MediaBag.hs
@@ -4,7 +4,7 @@
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
 {- |
    Module      : Text.Pandoc.MediaBag
-   Copyright   : Copyright (C) 2014-2015, 2017-2023 John MacFarlane
+   Copyright   : Copyright (C) 2014-2015, 2017-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
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
@@ -6,7 +6,7 @@
 {-# LANGUAGE TemplateHaskell    #-}
 {- |
    Module      : Text.Pandoc.Options
-   Copyright   : Copyright (C) 2012-2023 John MacFarlane
+   Copyright   : Copyright (C) 2012-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -376,7 +376,7 @@
 defaultMathJaxURL = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js"
 
 defaultKaTeXURL :: Text
-defaultKaTeXURL = "https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/"
+defaultKaTeXURL = "https://cdn.jsdelivr.net/npm/katex@latest/dist/"
 
 -- Update documentation in doc/filters.md if this is changed.
 $(deriveJSON defaultOptions{ fieldLabelModifier =
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
@@ -5,7 +5,7 @@
 {-# LANGUAGE FlexibleContexts    #-}
 {- |
    Module      : Text.Pandoc.PDF
-   Copyright   : Copyright (C) 2012-2023 John MacFarlane
+   Copyright   : Copyright (C) 2012-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Text.Pandoc.Parsing
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Parsing/Capabilities.hs b/src/Text/Pandoc/Parsing/Capabilities.hs
--- a/src/Text/Pandoc/Parsing/Capabilities.hs
+++ b/src/Text/Pandoc/Parsing/Capabilities.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE MultiParamTypeClasses      #-}
 {- |
    Module      : Text.Pandoc.Parsing
-   Copyright   : © 2006-2023 John MacFarlane
+   Copyright   : © 2006-2024 John MacFarlane
    License     : GPL-2.0-or-later
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
 
diff --git a/src/Text/Pandoc/Parsing/Citations.hs b/src/Text/Pandoc/Parsing/Citations.hs
--- a/src/Text/Pandoc/Parsing/Citations.hs
+++ b/src/Text/Pandoc/Parsing/Citations.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings          #-}
 {- |
 Module      : Text.Pandoc.Parsing.Citations
-Copyright   : © 2006-2023 John MacFarlane
+Copyright   : © 2006-2024 John MacFarlane
 License     : GPL-2.0-or-later
 Maintainer  : John MacFarlane <jgm@berkeley.edu>
 
diff --git a/src/Text/Pandoc/Parsing/Future.hs b/src/Text/Pandoc/Parsing/Future.hs
--- a/src/Text/Pandoc/Parsing/Future.hs
+++ b/src/Text/Pandoc/Parsing/Future.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
 {- |
    Module      : Text.Pandoc.Parsing.Future
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GPL-2.0-or-later
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
 
diff --git a/src/Text/Pandoc/Parsing/General.hs b/src/Text/Pandoc/Parsing/General.hs
--- a/src/Text/Pandoc/Parsing/General.hs
+++ b/src/Text/Pandoc/Parsing/General.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings          #-}
 {- |
 Module      : Text.Pandoc.Parsing.General
-Copyright   : © 2006-2023 John MacFarlane
+Copyright   : © 2006-2024 John MacFarlane
 License     : GPL-2.0-or-later
 Maintainer  : John MacFarlane <jgm@berkeley.edu>
 
diff --git a/src/Text/Pandoc/Parsing/GridTable.hs b/src/Text/Pandoc/Parsing/GridTable.hs
--- a/src/Text/Pandoc/Parsing/GridTable.hs
+++ b/src/Text/Pandoc/Parsing/GridTable.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE OverloadedStrings          #-}
 {- |
    Module      : Text.Pandoc.Parsing.GridTable
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GPL-2.0-or-later
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
 
diff --git a/src/Text/Pandoc/Parsing/Lists.hs b/src/Text/Pandoc/Parsing/Lists.hs
--- a/src/Text/Pandoc/Parsing/Lists.hs
+++ b/src/Text/Pandoc/Parsing/Lists.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings          #-}
 {- |
 Module      : Text.Pandoc.Parsing.Lists
-Copyright   : © 2006-2023 John MacFarlane
+Copyright   : © 2006-2024 John MacFarlane
 License     : GPL-2.0-or-later
 Maintainer  : John MacFarlane <jgm@berkeley.edu>
 
@@ -119,13 +119,17 @@
                                   cs <- many1 alphaNum
                                   return (c:cs)))
   st <- getState
-  let num = stateNextExample st
-  let newlabels = if T.null lab
-                     then stateExamples st
-                     else M.insert lab num $ stateExamples st
-  updateState $ \s -> s{ stateNextExample = num + 1
-                       , stateExamples    = newlabels }
-  return (Example, num)
+  case M.lookup lab (stateExamples st) of
+    Nothing -> do -- new label
+      let num = stateNextExample st
+      let newlabels = if T.null lab
+                         then stateExamples st
+                         else M.insert lab num $ stateExamples st
+      updateState $ \s -> s{ stateNextExample = num + 1
+                           , stateExamples    = newlabels }
+      return (Example, num)
+    Just num -> -- reuse existing label
+      return (Example, num)
 
 -- | Parses a '#' returns (DefaultStyle, 1).
 defaultNum :: (Stream s m Char, UpdateSourcePos s Char) => ParsecT s st m (ListNumberStyle, Int)
diff --git a/src/Text/Pandoc/Parsing/Math.hs b/src/Text/Pandoc/Parsing/Math.hs
--- a/src/Text/Pandoc/Parsing/Math.hs
+++ b/src/Text/Pandoc/Parsing/Math.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings          #-}
 {- |
 Module      : Text.Pandoc.Parsing.Math
-Copyright   : © 2006-2023 John MacFarlane
+Copyright   : © 2006-2024 John MacFarlane
 License     : GPL-2.0-or-later
 Maintainer  : John MacFarlane <jgm@berkeley.edu>
 
diff --git a/src/Text/Pandoc/Parsing/Smart.hs b/src/Text/Pandoc/Parsing/Smart.hs
--- a/src/Text/Pandoc/Parsing/Smart.hs
+++ b/src/Text/Pandoc/Parsing/Smart.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings          #-}
 {- |
 Module      : Text.Pandoc.Parsing.Smart
-Copyright   : © 2006-2023 John MacFarlane
+Copyright   : © 2006-2024 John MacFarlane
 License     : GPL-2.0-or-later
 Maintainer  : John MacFarlane <jgm@berkeley.edu>
 
diff --git a/src/Text/Pandoc/Parsing/State.hs b/src/Text/Pandoc/Parsing/State.hs
--- a/src/Text/Pandoc/Parsing/State.hs
+++ b/src/Text/Pandoc/Parsing/State.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE OverloadedStrings          #-}
 {- |
    Module      : Text.Pandoc.Parsing
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GPL-2.0-or-later
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
 
diff --git a/src/Text/Pandoc/Process.hs b/src/Text/Pandoc/Process.hs
--- a/src/Text/Pandoc/Process.hs
+++ b/src/Text/Pandoc/Process.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Text.Pandoc.Process
-   Copyright   : Copyright (C) 2013-2023 John MacFarlane
+   Copyright   : Copyright (C) 2013-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers.hs b/src/Text/Pandoc/Readers.hs
--- a/src/Text/Pandoc/Readers.hs
+++ b/src/Text/Pandoc/Readers.hs
@@ -5,7 +5,7 @@
 {-# LANGUAGE TupleSections       #-}
 {- |
    Module      : Text.Pandoc.Readers
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
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
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.BibTeX
-   Copyright   : Copyright (C) 2020-2023 John MacFarlane
+   Copyright   : Copyright (C) 2020-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers/CSV.hs b/src/Text/Pandoc/Readers/CSV.hs
--- a/src/Text/Pandoc/Readers/CSV.hs
+++ b/src/Text/Pandoc/Readers/CSV.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 {- |
    Module      : Text.Pandoc.Readers.CSV
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers/CommonMark.hs b/src/Text/Pandoc/Readers/CommonMark.hs
--- a/src/Text/Pandoc/Readers/CommonMark.hs
+++ b/src/Text/Pandoc/Readers/CommonMark.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 {- |
    Module      : Text.Pandoc.Readers.CommonMark
-   Copyright   : Copyright (C) 2015-2023 John MacFarlane
+   Copyright   : Copyright (C) 2015-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers/CslJson.hs b/src/Text/Pandoc/Readers/CslJson.hs
--- a/src/Text/Pandoc/Readers/CslJson.hs
+++ b/src/Text/Pandoc/Readers/CslJson.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.CslJson
-   Copyright   : Copyright (C) 2020-2023 John MacFarlane
+   Copyright   : Copyright (C) 2020-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
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
@@ -4,7 +4,7 @@
 {-# LANGUAGE TemplateHaskell #-}
 {- |
    Module      : Text.Pandoc.Readers.DocBook
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -44,8 +44,9 @@
 import Text.Pandoc.Class.PandocMonad (PandocMonad, report)
 import Text.Pandoc.Options
 import Text.Pandoc.Logging (LogMessage(..))
-import Text.Pandoc.Shared (safeRead, extractSpaces, headerShift)
+import Text.Pandoc.Shared (safeRead, extractSpaces)
 import Text.Pandoc.Sources (ToSources(..), sourcesToText)
+import Text.Pandoc.Transforms (headerShift)
 import Text.TeXMath (readMathML, writeTeX)
 import qualified Data.Map as M
 import Text.Pandoc.XML.Light
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -2,6 +2,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE PatternGuards     #-}
 {-# LANGUAGE FlexibleContexts  #-}
+{-# LANGUAGE LambdaCase        #-}
 {-# LANGUAGE ViewPatterns      #-}
 {- |
    Module      : Text.Pandoc.Readers.Docx
@@ -92,7 +93,7 @@
 import Text.Pandoc.Shared
 import Text.Pandoc.Walk
 import Text.TeXMath (writeTeX)
-import Control.Monad.Except (throwError)
+import Control.Monad.Except (throwError, catchError)
 import Text.Pandoc.Class.PandocMonad (PandocMonad)
 import qualified Text.Pandoc.Class.PandocMonad as P
 import Text.Pandoc.Error
@@ -103,7 +104,6 @@
 import Text.Pandoc.UTF8 (fromTextLazy)
 import Text.Pandoc.Citeproc.MetaValue (referenceToMetaValue)
 import Text.Pandoc.Readers.EndNote (readEndNoteXMLCitation)
-import Text.Pandoc.Sources (toSources)
 
 readDocx :: PandocMonad m
          => ReaderOptions
@@ -439,11 +439,10 @@
     -- avoid an extra pass.
     immedPrevAnchor <- gets docxImmedPrevAnchor
     case immedPrevAnchor of
-      Just prevAnchor -> do
-        unless inHdrBool
-          (modify $ \s -> s { docxAnchorMap = M.insert anchor prevAnchor anchorMap})
+      Just prevAnchor | not inHdrBool -> do
+        (modify $ \s -> s { docxAnchorMap = M.insert anchor prevAnchor anchorMap})
         return mempty
-      Nothing -> do
+      _ -> do
         exts <- asks (readerExtensions . docxOptions)
         let newAnchor =
               if not inHdrBool && anchor `elem` M.elems anchorMap
@@ -478,10 +477,16 @@
       formattedCite <- smushInlines <$> mapM parPartToInlines' children
       opts <- asks docxOptions
       if isEnabled Ext_citations opts
-         then do
-           citation <- readEndNoteXMLCitation (toSources t)
-           cs <- handleCitation citation
-           return $ cite cs formattedCite
+         then catchError
+              (do citation <- readEndNoteXMLCitation t
+                  cs <- handleCitation citation
+                  return $ cite cs formattedCite)
+              (\case
+                  PandocXMLError _ msg -> do
+                    P.report $ DocxParserWarning
+                             ("Cannot parse EndNote citation: " <> msg)
+                    return formattedCite
+                  e -> throwError e)
          else return formattedCite
     CslCitation t -> do
       formattedCite <- smushInlines <$> mapM parPartToInlines' children
diff --git a/src/Text/Pandoc/Readers/Docx/Combine.hs b/src/Text/Pandoc/Readers/Docx/Combine.hs
--- a/src/Text/Pandoc/Readers/Docx/Combine.hs
+++ b/src/Text/Pandoc/Readers/Docx/Combine.hs
@@ -2,7 +2,7 @@
 {- |
    Module      : Text.Pandoc.Readers.Docx.Combine
    Copyright   : © 2014-2020 Jesse Rosenthal <jrosenthal@jhu.edu>,
-                   2014-2023 John MacFarlane <jgm@berkeley.edu>,
+                   2014-2024 John MacFarlane <jgm@berkeley.edu>,
                    2020 Nikolay Yakimov <root@livid.pp.ru>
    License     : GNU GPL, version 2 or above
 
diff --git a/src/Text/Pandoc/Readers/Docx/Util.hs b/src/Text/Pandoc/Readers/Docx/Util.hs
--- a/src/Text/Pandoc/Readers/Docx/Util.hs
+++ b/src/Text/Pandoc/Readers/Docx/Util.hs
@@ -2,7 +2,7 @@
 {- |
    Module      : Text.Pandoc.Readers.Docx.Util
    Copyright   : © 2014-2020 Jesse Rosenthal <jrosenthal@jhu.edu>,
-                   2014-2023 John MacFarlane <jgm@berkeley.edu>,
+                   2014-2024 John MacFarlane <jgm@berkeley.edu>,
                    2015 Nikolay Yakimov <root@livid.pp.ru>
    License     : GNU GPL, version 2 or above
 
diff --git a/src/Text/Pandoc/Readers/EndNote.hs b/src/Text/Pandoc/Readers/EndNote.hs
--- a/src/Text/Pandoc/Readers/EndNote.hs
+++ b/src/Text/Pandoc/Readers/EndNote.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.EndNote
-   Copyright   : Copyright (C) 2022-2023 John MacFarlane
+   Copyright   : Copyright (C) 2022-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -72,10 +72,10 @@
     B.doc mempty
 
 readEndNoteXMLCitation :: PandocMonad m
-                    => Sources -> m (Citeproc.Citation Text)
-readEndNoteXMLCitation sources = do
+                    => Text -> m (Citeproc.Citation Text)
+readEndNoteXMLCitation xml = do
   tree <- either (throwError . PandocXMLError "EndNote references") return $
-              parseXMLElement (TL.fromStrict . sourcesToText $ sources)
+              parseXMLElement (TL.fromStrict xml)
   unless (qName (elName tree) == "EndNote") $
     throwError $ PandocXMLError "EndNote references" "Expected EndNote element"
   let items = map toCitationItem $ filterElementsName (name "Cite") tree
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -5,7 +5,7 @@
 {-# LANGUAGE ViewPatterns          #-}
 {- |
    Module      : Text.Pandoc.Readers.HTML
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers/HTML/Parsing.hs b/src/Text/Pandoc/Readers/HTML/Parsing.hs
--- a/src/Text/Pandoc/Readers/HTML/Parsing.hs
+++ b/src/Text/Pandoc/Readers/HTML/Parsing.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings     #-}
 {- |
    Module      : Text.Pandoc.Readers.HTML.Parsing
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers/HTML/Table.hs b/src/Text/Pandoc/Readers/HTML/Table.hs
--- a/src/Text/Pandoc/Readers/HTML/Table.hs
+++ b/src/Text/Pandoc/Readers/HTML/Table.hs
@@ -3,8 +3,8 @@
 {-# LANGUAGE ViewPatterns      #-}
 {- |
    Module      : Text.Pandoc.Readers.HTML.Table
-   Copyright   : © 2006-2023 John MacFarlane,
-                   2020-2023 Albert Krewinkel
+   Copyright   : © 2006-2024 John MacFarlane,
+                   2020-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/src/Text/Pandoc/Readers/HTML/TagCategories.hs b/src/Text/Pandoc/Readers/HTML/TagCategories.hs
--- a/src/Text/Pandoc/Readers/HTML/TagCategories.hs
+++ b/src/Text/Pandoc/Readers/HTML/TagCategories.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings     #-}
 {- |
    Module      : Text.Pandoc.Readers.HTML.TagCategories
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers/HTML/Types.hs b/src/Text/Pandoc/Readers/HTML/Types.hs
--- a/src/Text/Pandoc/Readers/HTML/Types.hs
+++ b/src/Text/Pandoc/Readers/HTML/Types.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE MultiParamTypeClasses #-}
 {- |
    Module      : Text.Pandoc.Readers.HTML.Types
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers/Ipynb.hs b/src/Text/Pandoc/Readers/Ipynb.hs
--- a/src/Text/Pandoc/Readers/Ipynb.hs
+++ b/src/Text/Pandoc/Readers/Ipynb.hs
@@ -4,7 +4,7 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 {- |
    Module      : Text.Pandoc.Readers.Ipynb
-   Copyright   : Copyright (C) 2019-2023 John MacFarlane
+   Copyright   : Copyright (C) 2019-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers/Jira.hs b/src/Text/Pandoc/Readers/Jira.hs
--- a/src/Text/Pandoc/Readers/Jira.hs
+++ b/src/Text/Pandoc/Readers/Jira.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.Jira
-   Copyright   : © 2019-2023 Albert Krewinkel
+   Copyright   : © 2019-2024 Albert Krewinkel
    License     : GPL-2.0-or-later
 
    Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
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
@@ -4,7 +4,7 @@
 {-# LANGUAGE ViewPatterns          #-}
 {- |
    Module      : Text.Pandoc.Readers.LaTeX
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -533,9 +533,9 @@
 ifToggle = do
   name <- braced
   spaces
-  yes <- braced
+  yes <- withVerbatimMode braced
   spaces
-  no <- braced
+  no <- withVerbatimMode braced
   toggles <- sToggles <$> getState
   TokStream _ inp <- getInput
   let name' = untokenize name
@@ -551,8 +551,8 @@
 ifstrequal = do
   str1 <- tok
   str2 <- tok
-  ifequal <- braced
-  ifnotequal <- braced
+  ifequal <- withVerbatimMode braced
+  ifnotequal <- withVerbatimMode braced
   TokStream _ ts <- getInput
   if str1 == str2
      then setInput $ TokStream False (ifequal ++ ts)
diff --git a/src/Text/Pandoc/Readers/LaTeX/Inline.hs b/src/Text/Pandoc/Readers/LaTeX/Inline.hs
--- a/src/Text/Pandoc/Readers/LaTeX/Inline.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Inline.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE ViewPatterns          #-}
 {- |
    Module      : Text.Pandoc.Readers.LaTeX.Inline
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers/LaTeX/Lang.hs b/src/Text/Pandoc/Readers/LaTeX/Lang.hs
--- a/src/Text/Pandoc/Readers/LaTeX/Lang.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Lang.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.LaTeX.Lang
-   Copyright   : Copyright (C) 2018-2023 John MacFarlane
+   Copyright   : Copyright (C) 2018-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -226,6 +226,7 @@
        "ngerman" -> Just $ Lang "de" Nothing (Just "DE") [] [] []
        "lowersorbian" -> Just $ Lang "dsb" Nothing Nothing [] [] []
        "uppersorbian" -> Just $ Lang "hsb" Nothing Nothing [] [] []
+       "polytonicgreek" -> Just $ Lang "el" Nothing Nothing ["polyton"] [] []
        "polutonikogreek" -> Just $ Lang "el" Nothing Nothing ["polyton"] [] []
        "slovene" -> Just $ simpleLang "sl"
        "australian" -> Just $ Lang "en" Nothing (Just "AU") [] [] []
diff --git a/src/Text/Pandoc/Readers/LaTeX/Math.hs b/src/Text/Pandoc/Readers/LaTeX/Math.hs
--- a/src/Text/Pandoc/Readers/LaTeX/Math.hs
+++ b/src/Text/Pandoc/Readers/LaTeX/Math.hs
@@ -97,6 +97,8 @@
   , ("align*", mathEnvWith id (Just "aligned") "align*")
   , ("alignat", mathEnvWith id (Just "aligned") "alignat")
   , ("alignat*", mathEnvWith id (Just "aligned") "alignat*")
+  , ("flalign", mathEnvWith id (Just "aligned") "flalign")
+  , ("flalign*", mathEnvWith id (Just "aligned") "flalign*")
   , ("dmath", mathEnvWith id Nothing "dmath")
   , ("dmath*", mathEnvWith id Nothing "dmath*")
   , ("dgroup", mathEnvWith id (Just "aligned") "dgroup")
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
@@ -7,7 +7,7 @@
 {-# LANGUAGE ScopedTypeVariables   #-}
 {- |
    Module      : Text.Pandoc.Readers.LaTeX.Parsing
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
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
@@ -6,7 +6,7 @@
 {-# LANGUAGE ViewPatterns        #-}
 {- |
    Module      : Text.Pandoc.Readers.Markdown
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -189,12 +189,15 @@
        <|> T.singleton <$> noneOf "\n"
        <|> try (newline >> notFollowedBy blankline >> return " ")
 
--- | Parse a sequence of inline elements between square brackets,
--- including inlines between balanced pairs of square brackets.
-inlinesInBalancedBrackets :: PandocMonad m => MarkdownParser m (F Inlines)
-inlinesInBalancedBrackets =
+-- | Parse a sequence of elements between square brackets,
+-- including between balanced pairs of square brackets.
+-- Skip brackets in standard inline escapes, code, raw HTML or LaTeX.
+inBalancedBrackets :: PandocMonad m
+                   => MarkdownParser m (F a)
+                   -> MarkdownParser m (F a)
+inBalancedBrackets innerParser =
   try $ char '[' >> withRaw (go 1) >>=
-          parseFromString inlines . stripBracket . snd
+          parseFromString innerParser . stripBracket . snd
   where stripBracket t = case T.unsnoc t of
           Just (t', ']') -> t'
           _              -> t
@@ -1813,7 +1816,7 @@
 reference :: PandocMonad m => MarkdownParser m (F Inlines, Text)
 reference = do
   guardDisabled Ext_footnotes <|> notFollowedBy' noteMarker
-  withRaw $ trimInlinesF <$> inlinesInBalancedBrackets
+  withRaw $ trimInlinesF <$> inBalancedBrackets inlines
 
 parenthesizedChars :: PandocMonad m => MarkdownParser m Text
 parenthesizedChars = do
@@ -2060,7 +2063,7 @@
     char '^'
     updateState $ \st -> st{ stateInNote = True
                            , stateNoteNumber = stateNoteNumber st + 1 }
-    contents <- inlinesInBalancedBrackets
+    contents <- inBalancedBrackets inlines
     updateState $ \st -> st{ stateInNote = False }
     return $ B.note . B.para <$> contents
 
@@ -2102,30 +2105,29 @@
 divHtml = do
   guardEnabled Ext_native_divs
   try $ do
-    (TagOpen _ attrs, rawtag) <- htmlTag (~== TagOpen ("div" :: Text) [])
+    openpos <- getPosition
+    (TagOpen _ attrs, _) <- htmlTag (~== TagOpen ("div" :: Text) [])
     -- we set stateInHtmlBlock so that closing tags that can be either block
     -- or inline will not be parsed as inline tags
     oldInHtmlBlock <- stateInHtmlBlock <$> getState
     updateState $ \st -> st{ stateInHtmlBlock = Just "div" }
-    bls <- option "" (blankline >> option "" blanklines)
+    optional blanklines
     contents <- mconcat <$>
                 many (notFollowedBy' (htmlTag (~== TagClose ("div" :: Text)))
                       >> block)
-    closed <- option False (True <$ htmlTag (~== TagClose ("div" :: Text)))
-    if closed
-       then do
-         updateState $ \st -> st{ stateInHtmlBlock = oldInHtmlBlock }
-         let ident = fromMaybe "" $ lookup "id" attrs
-         let classes = maybe [] T.words $ lookup "class" attrs
-         let keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"]
-         return $ B.divWith (ident, classes, keyvals) <$> contents
-       else -- avoid backtracing
-         return $ return (B.rawBlock "html" (rawtag <> bls)) <> contents
+    void (htmlTag (~== TagClose ("div" :: Text))) <|>
+       (getPosition >>= report . UnclosedDiv openpos)
+    let ident = fromMaybe "" $ lookup "id" attrs
+    let classes = maybe [] T.words $ lookup "class" attrs
+    let keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"]
+    updateState $ \st -> st{ stateInHtmlBlock = oldInHtmlBlock }
+    return $ B.divWith (ident, classes, keyvals) <$> contents
 
 divFenced :: PandocMonad m => MarkdownParser m (F Blocks)
 divFenced = do
   guardEnabled Ext_fenced_divs
   try $ do
+    openpos <- getPosition
     string ":::"
     skipMany (char ':')
     skipMany spaceChar
@@ -2135,7 +2137,8 @@
     blankline
     updateState $ \st ->
       st{ stateFencedDivLevel = stateFencedDivLevel st + 1 }
-    bs <- mconcat <$> manyTill block divFenceEnd
+    bs <- mconcat <$> many (notFollowedBy divFenceEnd >> block)
+    divFenceEnd <|> (getPosition >>= report . UnclosedDiv openpos)
     updateState $ \st ->
       st{ stateFencedDivLevel = stateFencedDivLevel st - 1 }
     return $ B.divWith attribs <$> bs
@@ -2253,11 +2256,7 @@
 
 normalCite :: PandocMonad m => MarkdownParser m (F [Citation])
 normalCite = try $ do
-  char '['
-  spnl
-  citations <- citeList
-  spnl
-  char ']'
+  citations <- inBalancedBrackets (spnl *> citeList <* spnl)
   -- not a link or a bracketed span
   notFollowedBy (try (void source) <|>
                   (guardEnabled Ext_bracketed_spans *> void attributes) <|>
@@ -2268,8 +2267,9 @@
 suffix = try $ do
   hasSpace <- option False (notFollowedBy nonspaceChar >> return True)
   spnl
-  rest <- trimInlinesF . mconcat <$> many (notFollowedBy (oneOf ";]") >> inline)
-  return $ if hasSpace
+  ils <- many (notFollowedBy (oneOf ";]") >> inline)
+  let rest = trimInlinesF (mconcat ils)
+  return $ if hasSpace && not (null ils)
               then (B.space <>) <$> rest
               else rest
 
diff --git a/src/Text/Pandoc/Readers/MediaWiki.hs b/src/Text/Pandoc/Readers/MediaWiki.hs
--- a/src/Text/Pandoc/Readers/MediaWiki.hs
+++ b/src/Text/Pandoc/Readers/MediaWiki.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.MediaWiki
-   Copyright   : Copyright (C) 2012-2023 John MacFarlane
+   Copyright   : Copyright (C) 2012-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
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
@@ -2,7 +2,7 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 {- |
    Module      : Text.Pandoc.Readers.Metadata
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers/Native.hs b/src/Text/Pandoc/Readers/Native.hs
--- a/src/Text/Pandoc/Readers/Native.hs
+++ b/src/Text/Pandoc/Readers/Native.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.Native
-   Copyright   : Copyright (C) 2011-2023 John MacFarlane
+   Copyright   : Copyright (C) 2011-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers/OPML.hs b/src/Text/Pandoc/Readers/OPML.hs
--- a/src/Text/Pandoc/Readers/OPML.hs
+++ b/src/Text/Pandoc/Readers/OPML.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.OPML
-   Copyright   : Copyright (C) 2013-2023 John MacFarlane
+   Copyright   : Copyright (C) 2013-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
--- a/src/Text/Pandoc/Readers/Org.hs
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Text.Pandoc.Readers.Org
-   Copyright   : Copyright (C) 2014-2023 Albert Krewinkel
+   Copyright   : Copyright (C) 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
diff --git a/src/Text/Pandoc/Readers/Org/BlockStarts.hs b/src/Text/Pandoc/Readers/Org/BlockStarts.hs
--- a/src/Text/Pandoc/Readers/Org/BlockStarts.hs
+++ b/src/Text/Pandoc/Readers/Org/BlockStarts.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.Org.BlockStarts
-   Copyright   : Copyright (C) 2014-2023 Albert Krewinkel
+   Copyright   : Copyright (C) 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
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
@@ -4,7 +4,7 @@
 {-# LANGUAGE RecordWildCards   #-}
 {- |
    Module      : Text.Pandoc.Readers.Org.Blocks
-   Copyright   : Copyright (C) 2014-2023 Albert Krewinkel
+   Copyright   : Copyright (C) 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
diff --git a/src/Text/Pandoc/Readers/Org/DocumentTree.hs b/src/Text/Pandoc/Readers/Org/DocumentTree.hs
--- a/src/Text/Pandoc/Readers/Org/DocumentTree.hs
+++ b/src/Text/Pandoc/Readers/Org/DocumentTree.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE TupleSections     #-}
 {- |
    Module      : Text.Pandoc.Readers.Org.DocumentTree
-   Copyright   : Copyright (C) 2014-2023 Albert Krewinkel
+   Copyright   : Copyright (C) 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
diff --git a/src/Text/Pandoc/Readers/Org/ExportSettings.hs b/src/Text/Pandoc/Readers/Org/ExportSettings.hs
--- a/src/Text/Pandoc/Readers/Org/ExportSettings.hs
+++ b/src/Text/Pandoc/Readers/Org/ExportSettings.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.Org.ExportSettings
-   Copyright   : © 2016-2023 Albert Krewinkel
+   Copyright   : © 2016-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
diff --git a/src/Text/Pandoc/Readers/Org/Inlines.hs b/src/Text/Pandoc/Readers/Org/Inlines.hs
--- a/src/Text/Pandoc/Readers/Org/Inlines.hs
+++ b/src/Text/Pandoc/Readers/Org/Inlines.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.Org.Inlines
-   Copyright   : Copyright (C) 2014-2023 Albert Krewinkel
+   Copyright   : Copyright (C) 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
diff --git a/src/Text/Pandoc/Readers/Org/Meta.hs b/src/Text/Pandoc/Readers/Org/Meta.hs
--- a/src/Text/Pandoc/Readers/Org/Meta.hs
+++ b/src/Text/Pandoc/Readers/Org/Meta.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.Org.Meta
-   Copyright   : Copyright (C) 2014-2023 Albert Krewinkel
+   Copyright   : Copyright (C) 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
diff --git a/src/Text/Pandoc/Readers/Org/ParserState.hs b/src/Text/Pandoc/Readers/Org/ParserState.hs
--- a/src/Text/Pandoc/Readers/Org/ParserState.hs
+++ b/src/Text/Pandoc/Readers/Org/ParserState.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE OverloadedStrings     #-}
 {- |
    Module      : Text.Pandoc.Readers.Org.ParserState
-   Copyright   : Copyright (C) 2014-2023 Albert Krewinkel
+   Copyright   : Copyright (C) 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
diff --git a/src/Text/Pandoc/Readers/Org/Parsing.hs b/src/Text/Pandoc/Readers/Org/Parsing.hs
--- a/src/Text/Pandoc/Readers/Org/Parsing.hs
+++ b/src/Text/Pandoc/Readers/Org/Parsing.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Text.Pandoc.Readers.Org.Parsing
-   Copyright   : Copyright (C) 2014-2023 Albert Krewinkel
+   Copyright   : Copyright (C) 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
diff --git a/src/Text/Pandoc/Readers/Org/Shared.hs b/src/Text/Pandoc/Readers/Org/Shared.hs
--- a/src/Text/Pandoc/Readers/Org/Shared.hs
+++ b/src/Text/Pandoc/Readers/Org/Shared.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.Org.Shared
-   Copyright   : Copyright (C) 2014-2023 Albert Krewinkel
+   Copyright   : Copyright (C) 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
diff --git a/src/Text/Pandoc/Readers/RIS.hs b/src/Text/Pandoc/Readers/RIS.hs
--- a/src/Text/Pandoc/Readers/RIS.hs
+++ b/src/Text/Pandoc/Readers/RIS.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.RIS
-   Copyright   : Copyright (C) 2022-2023 John MacFarlane
+   Copyright   : Copyright (C) 2022-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -4,7 +4,7 @@
 {-# LANGUAGE ViewPatterns        #-}
 {- |
    Module      : Text.Pandoc.Readers.RST
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -634,7 +634,7 @@
       name = trim $ fromMaybe "" (lookup "name" fields)
       classes = T.words $ maybe "" trim (lookup "class" fields)
       keyvals = [(k, trim v) | (k, v) <- fields, k /= "name", k /= "class"]
-      imgAttr cl = (name, classes ++ alignClasses, widthAttr ++ heightAttr)
+      imgAttr cl = (name, classes, alignClasses, widthAttr ++ heightAttr)
         where
           alignClasses = T.words $ maybe "" trim (lookup cl fields) <>
                           maybe "" (\x -> "align-" <> trim x)
@@ -731,16 +731,18 @@
         "figure" -> do
            (caption, legend) <- parseFromString' extractCaption body'
            let src = escapeURI $ trim top
-           let (ident, cls, kvs) = imgAttr "class"
-           let (figclasskv, kvs') = partition ((== "figclass") . fst) kvs
-           let figattr = ("", concatMap (T.words . snd) figclasskv, [])
+           let (imgident, imgcls, aligncls, imgkvs) = imgAttr "class"
+           let (figclasskv, _) = partition ((== "figclass") . fst) keyvals
+           let figcls = concatMap (T.words . snd) figclasskv
+           let figattr = ("", figcls ++ aligncls, [])
            let capt = B.caption Nothing (B.plain caption <> legend)
            return $ B.figureWith figattr capt $
-             B.plain (B.imageWith (ident, cls, kvs') src "" (B.text src))
+             B.plain (B.imageWith (imgident, imgcls, imgkvs) src "" (B.text src))
         "image" -> do
            let src = escapeURI $ trim top
            let alt = B.str $ maybe "image" trim $ lookup "alt" fields
-           let attr = imgAttr "class"
+           let attr = (ident, cls ++ align, dims) where
+                 (ident, cls, align, dims) = imgAttr "class"
            return $ B.para
                   $ case lookup "target" fields of
                           Just t  -> B.link (escapeURI $ trim t) ""
diff --git a/src/Text/Pandoc/Readers/RTF.hs b/src/Text/Pandoc/Readers/RTF.hs
--- a/src/Text/Pandoc/Readers/RTF.hs
+++ b/src/Text/Pandoc/Readers/RTF.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Readers.RTF
-   Copyright   : Copyright (C) 2021-2023 John MacFarlane
+   Copyright   : Copyright (C) 2021-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane (<jgm@berkeley.edu>)
@@ -27,10 +27,11 @@
 import qualified Data.Text.Read as TR
 import Text.Pandoc.Builder (Blocks, Inlines)
 import qualified Text.Pandoc.Builder as B
-import Text.Pandoc.Class.PandocMonad (PandocMonad (..), insertMedia)
+import Text.Pandoc.Class (PandocMonad (..), insertMedia, report)
 import Text.Pandoc.Definition
 import Text.Pandoc.Options
 import Text.Pandoc.Parsing
+import Text.Pandoc.Logging (LogMessage(UnsupportedCodePage))
 import Text.Pandoc.Shared (tshow)
 import Data.Char (isAlphaNum, chr, isAscii, isLetter, isSpace, ord)
 import qualified Data.ByteString.Lazy as BL
@@ -217,7 +218,7 @@
   | ControlSymbol !Char
   | UnformattedText !Text
   | BinData !BL.ByteString
-  | HexVal !Word8
+  | HexVals [Word8]
   | Grouped [Tok]
   deriving (Show, Eq)
 
@@ -229,7 +230,7 @@
   controlThing = do
     char '\\' *>
       ( controlWord
-     <|> (HexVal <$> hexVal)
+     <|> (HexVals <$> many1 hexVal)
      <|> (ControlSymbol <$> anyChar) )
   controlWord = do
     name <- letterSequence
@@ -423,7 +424,7 @@
 processTok bs (Tok pos tok') = do
   setPosition pos
   case tok' of
-    HexVal{} -> return ()
+    HexVals{} -> return ()
     UnformattedText{} -> return ()
     _ -> updateState $ \s -> s{ sEatChars = 0 }
   case tok' of
@@ -498,19 +499,22 @@
              addText (T.drop n t)
           | otherwise -> do
              updateState $ \s -> s{ sEatChars = n - T.length t }
-    HexVal n -> bs <$ do
+    HexVals ws -> bs <$ do
       eatChars <- sEatChars <$> getState
-      if eatChars == 0
-         then do
-           charset <- sCharSet <$> getState
-           case charset of
-             ANSI -> addText (T.singleton $ ansiToChar n)
-             Mac  -> addText (T.singleton $ macToChar n)
-             Pc   -> addText (T.singleton $ pcToChar n)
-             Pca  -> addText (T.singleton $ pcaToChar n)
-         else updateState $ \s -> s{ sEatChars = eatChars - 1 }
+      let ws' = drop eatChars ws
+      updateState $ \s -> s{ sEatChars = if null ws'
+                                            then eatChars - length ws
+                                            else 0 }
+      charset <- sCharSet <$> getState
+      case charset of
+        ANSI -> addText $ T.pack $ map defaultAnsiWordToChar ws'
+        Mac  -> addText $ T.pack $ map macToChar ws'
+        Pc   -> addText $ T.pack $ map pcToChar ws'
+        Pca  -> addText $ T.pack $ map pcaToChar ws'
     ControlWord "ansi" _ -> bs <$
       updateState (\s -> s{ sCharSet = ANSI })
+    ControlWord "ansicpg" (Just cpg) | cpg /= 1252 -> bs <$
+      report (UnsupportedCodePage cpg)
     ControlWord "mac" _ -> bs <$
       updateState (\s -> s{ sCharSet = Mac })
     ControlWord "pc" _ -> bs <$
@@ -950,39 +954,38 @@
      (Grouped ts) -> foldl' go (fontnum, tbl) ts
      _ -> (fontnum, tbl)
 
-
-ansiToChar :: Word8 -> Char
-ansiToChar i = chr $
+defaultAnsiWordToChar :: Word8 -> Char
+defaultAnsiWordToChar i =
   case i of
-    128 -> 8364
-    130 -> 8218
-    131 -> 402
-    132 -> 8222
-    133 -> 8230
-    134 -> 8224
-    135 -> 8225
-    136 -> 710
-    137 -> 8240
-    138 -> 352
-    139 -> 8249
-    140 -> 338
-    142 -> 381
-    145 -> 8216
-    146 -> 8217
-    147 -> 8220
-    148 -> 8221
-    149 -> 8226
-    150 -> 8211
-    151 -> 8212
-    152 -> 732
-    153 -> 8482
-    154 -> 353
-    155 -> 8250
-    156 -> 339
-    158 -> 382
-    159 -> 376
-    173 -> 0xAD
-    _ -> fromIntegral i
+    128 -> '\8364'
+    130 -> '\8218'
+    131 -> '\402'
+    132 -> '\8222'
+    133 -> '\8230'
+    134 -> '\8224'
+    135 -> '\8225'
+    136 -> '\710'
+    137 -> '\8240'
+    138 -> '\352'
+    139 -> '\8249'
+    140 -> '\338'
+    142 -> '\381'
+    145 -> '\8216'
+    146 -> '\8217'
+    147 -> '\8220'
+    148 -> '\8221'
+    149 -> '\8226'
+    150 -> '\8211'
+    151 -> '\8212'
+    152 -> '\732'
+    153 -> '\8482'
+    154 -> '\353'
+    155 -> '\8250'
+    156 -> '\339'
+    158 -> '\382'
+    159 -> '\376'
+    173 -> '\xAD'
+    _ -> chr (fromIntegral i)
 
 macToChar :: Word8 -> Char
 macToChar i = chr $
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs
--- a/src/Text/Pandoc/Readers/Textile.hs
+++ b/src/Text/Pandoc/Readers/Textile.hs
@@ -3,7 +3,7 @@
 {- |
    Module      : Text.Pandoc.Readers.Textile
    Copyright   : Copyright (C) 2010-2012 Paul Rivier
-                               2010-2023 John MacFarlane
+                               2010-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Paul Rivier <paul*rivier#demotera*com>
diff --git a/src/Text/Pandoc/RoffChar.hs b/src/Text/Pandoc/RoffChar.hs
--- a/src/Text/Pandoc/RoffChar.hs
+++ b/src/Text/Pandoc/RoffChar.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.RoffChar
-   Copyright   : Copyright (C) 2007-2023 John MacFarlane
+   Copyright   : Copyright (C) 2007-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Scripting.hs b/src/Text/Pandoc/Scripting.hs
--- a/src/Text/Pandoc/Scripting.hs
+++ b/src/Text/Pandoc/Scripting.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE ScopedTypeVariables  #-}
 {- |
 Module      : Text.Pandoc.Scripting
-Copyright   : © 2022-2023 Albert Krewinkel
+Copyright   : © 2022-2024 Albert Krewinkel
 License     : GPL-2.0-or-later
 Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
 
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
@@ -4,7 +4,7 @@
 {-# LANGUAGE TupleSections     #-}
 {- |
    Module      : Text.Pandoc.SelfContained
-   Copyright   : Copyright (C) 2011-2023 John MacFarlane
+   Copyright   : Copyright (C) 2011-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -258,10 +258,13 @@
   dropPointZero t = case T.stripSuffix ".0" t of
                        Nothing -> t
                        Just t' -> t'
-  combinedAttrs = imgAttrs ++
+  combinedAttrs =
+    [(k, v) | (k, v) <- imgAttrs
+            , k /= "class"] ++
     [(k, v) | (k, v) <- svgAttrs
             , isNothing (lookup k imgAttrs)
-            , k `notElem` ["xmlns", "xmlns:xlink", "version"]]
+            , k `notElem` ["xmlns", "xmlns:xlink", "version", "class"]] ++
+    mergedClasses
   parseViewBox t =
     case map (safeRead . addZero) $ T.words t of
       [Just llx, Just lly, Just urx, Just ury] -> Just (llx, lly, urx, ury)
@@ -274,6 +277,9 @@
         lookup "viewBox" svgAttrs >>= parseViewBox
   (mbHeight :: Maybe Int) = lookup "height" combinedAttrs >>= safeRead
   (mbWidth :: Maybe Int) = lookup "width" combinedAttrs >>= safeRead
+  mergedClasses = case (lookup "class" imgAttrs, lookup "class" svgAttrs) of
+                    (Just c1, Just c2) -> [("class", c1 <> " " <> c2)]
+                    _ -> []
 
 cssURLs :: PandocMonad m
         => FilePath -> ByteString -> m ByteString
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -8,7 +8,7 @@
 {-# LANGUAGE OverloadedStrings     #-}
 {- |
    Module      : Text.Pandoc.Shared
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -55,7 +55,6 @@
                      inlineListToIdentifier,
                      textToIdentifier,
                      isHeaderBlock,
-                     headerShift,
                      stripEmptyParagraphs,
                      onlySimpleTableCells,
                      isTightList,
@@ -63,9 +62,7 @@
                      taskListItemToAscii,
                      handleTaskListItem,
                      addMetaField,
-                     eastAsianLineBreakFilter,
                      htmlSpanLikeElements,
-                     filterIpynbOutput,
                      formatCode,
                      -- * TagSoup HTML handling
                      renderTags',
@@ -93,8 +90,7 @@
 import Data.Char (isAlpha, isLower, isSpace, isUpper, toLower, isAlphaNum,
                   generalCategory, GeneralCategory(NonSpacingMark,
                   SpacingCombiningMark, EnclosingMark, ConnectorPunctuation))
-import Data.List (find, foldl', groupBy, intercalate, intersperse,
-                  union, sortOn)
+import Data.List (find, foldl', groupBy, intercalate, intersperse, union)
 import qualified Data.Map as M
 import Data.Maybe (mapMaybe)
 import Data.Monoid (Any (..) )
@@ -113,7 +109,6 @@
 import Text.Pandoc.Asciify (toAsciiText)
 import Text.Pandoc.Definition
 import Text.Pandoc.Extensions (Extensions, Extension(..), extensionEnabled)
-import Text.Pandoc.Generic (bottomUp)
 import Text.DocLayout (charWidth)
 import Text.Pandoc.Walk
 -- for addPandocAttributes:
@@ -600,21 +595,6 @@
 isHeaderBlock Header{} = True
 isHeaderBlock _        = False
 
--- | Shift header levels up or down.
-headerShift :: Int -> Pandoc -> Pandoc
-headerShift n (Pandoc meta (Header m _ ils : bs))
-  | n < 0
-  , m + n == 0 = headerShift n $
-                 B.setTitle (B.fromList ils) $ Pandoc meta bs
-headerShift n (Pandoc meta bs) = Pandoc meta (walk shift bs)
-
- where
-   shift :: Block -> Block
-   shift (Header level attr inner)
-     | level + n > 0  = Header (level + n) attr inner
-     | otherwise      = Para inner
-   shift x            = x
-
 -- | Remove empty paragraphs.
 stripEmptyParagraphs :: Pandoc -> Pandoc
 stripEmptyParagraphs = walk go
@@ -692,64 +672,10 @@
         tolist (MetaList ys) = ys
         tolist y             = [y]
 
--- | Remove soft breaks between East Asian characters.
-eastAsianLineBreakFilter :: Pandoc -> Pandoc
-eastAsianLineBreakFilter = bottomUp go
-  where go (x:SoftBreak:y:zs)
-          | Just (_, b) <- T.unsnoc $ stringify x
-          , Just (c, _) <- T.uncons $ stringify y
-          , charWidth b == 2
-          , charWidth c == 2
-          = x:y:zs
-          | otherwise
-          = x:SoftBreak:y:zs
-        go xs
-          = xs
-
 -- | Set of HTML elements that are represented as Span with a class equal as
 -- the element tag itself.
 htmlSpanLikeElements :: Set.Set T.Text
 htmlSpanLikeElements = Set.fromList ["kbd", "mark", "dfn"]
-
--- | Process ipynb output cells.  If mode is Nothing,
--- remove all output.  If mode is Just format, select
--- best output for the format.  If format is not ipynb,
--- strip out ANSI escape sequences from CodeBlocks (see #5633).
-filterIpynbOutput :: Maybe Format -> Pandoc -> Pandoc
-filterIpynbOutput mode = walk go
-  where go (Div (ident, "output":os, kvs) bs) =
-          case mode of
-            Nothing  -> Div (ident, "output":os, kvs) []
-            -- "best" for ipynb includes all formats:
-            Just fmt
-              | fmt == Format "ipynb"
-                          -> Div (ident, "output":os, kvs) bs
-              | otherwise -> Div (ident, "output":os, kvs) $
-                              walk removeANSI $
-                              take 1 $ sortOn rank bs
-                 where
-                  rank (RawBlock (Format "html") _)
-                    | fmt == Format "html" = 1 :: Int
-                    | fmt == Format "markdown" = 3
-                    | otherwise = 4
-                  rank (RawBlock (Format "latex") _)
-                    | fmt == Format "latex" = 1
-                    | fmt == Format "markdown" = 3
-                    | otherwise = 4
-                  rank (RawBlock f _)
-                    | fmt == f = 1
-                    | otherwise = 4
-                  rank (Para [Image{}]) = 2
-                  rank _ = 3
-                  removeANSI (CodeBlock attr code) =
-                    CodeBlock attr (removeANSIEscapes code)
-                  removeANSI x = x
-                  removeANSIEscapes t
-                    | Just cs <- T.stripPrefix "\x1b[" t =
-                        removeANSIEscapes $ T.drop 1 $ T.dropWhile (/='m') cs
-                    | Just (c, cs) <- T.uncons t = T.cons c $ removeANSIEscapes cs
-                    | otherwise = ""
-        go x = x
 
 -- | Reformat 'Inlines' as code, putting the stringlike parts in 'Code'
 -- elements while bringing other inline formatting outside.
diff --git a/src/Text/Pandoc/Slides.hs b/src/Text/Pandoc/Slides.hs
--- a/src/Text/Pandoc/Slides.hs
+++ b/src/Text/Pandoc/Slides.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Slides
-   Copyright   : Copyright (C) 2012-2023 John MacFarlane
+   Copyright   : Copyright (C) 2012-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Sources.hs b/src/Text/Pandoc/Sources.hs
--- a/src/Text/Pandoc/Sources.hs
+++ b/src/Text/Pandoc/Sources.hs
@@ -6,7 +6,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Sources
-   Copyright   : Copyright (C) 2021-2023 John MacFarlane
+   Copyright   : Copyright (C) 2021-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/TeX.hs b/src/Text/Pandoc/TeX.hs
--- a/src/Text/Pandoc/TeX.hs
+++ b/src/Text/Pandoc/TeX.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE FlexibleInstances #-}
 {- |
    Module      : Text.Pandoc.TeX
-   Copyright   : Copyright (C) 2017-2023 John MacFarlane
+   Copyright   : Copyright (C) 2017-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs
--- a/src/Text/Pandoc/Templates.hs
+++ b/src/Text/Pandoc/Templates.hs
@@ -4,7 +4,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Templates
-   Copyright   : Copyright (C) 2009-2023 John MacFarlane
+   Copyright   : Copyright (C) 2009-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Transforms.hs b/src/Text/Pandoc/Transforms.hs
new file mode 100644
--- /dev/null
+++ b/src/Text/Pandoc/Transforms.hs
@@ -0,0 +1,164 @@
+{-# LANGUAGE OverloadedStrings   #-}
+{-# LANGUAGE StrictData          #-}
+{- |
+   Module      : Text.Pandoc.Transforms
+   Copyright   : © 2006-2024 John MacFarlane
+   License     : GPL-2.0-or-later
+   Maintainer  : John MacFarlane <jgm@berkeley@edu>
+
+Transformation of a Pandoc document post-parsing
+-}
+module Text.Pandoc.Transforms
+  ( Transform
+  , applyTransforms
+  , adjustLinksAndIds
+  , eastAsianLineBreakFilter
+  , filterIpynbOutput
+  , headerShift
+  ) where
+
+import Data.List (sortOn)
+import Data.Text (Text)
+import Network.URI (unEscapeString)
+import Text.DocLayout (charWidth)
+import Text.Pandoc.Definition
+  ( Pandoc (..), Attr, Block (..), Format (..), Inline (..) )
+import Text.Pandoc.Generic (bottomUp)
+import Text.Pandoc.Options (Extensions)
+import Text.Pandoc.Shared (stringify, textToIdentifier)
+import Text.Pandoc.Walk (walk)
+import qualified Data.Text as T
+import qualified Text.Pandoc.Builder as B
+
+-- | Transformation of a Pandoc document post-parsing
+type Transform = Pandoc -> Pandoc
+
+-- | Apply a list of transforms to a document, in order.
+applyTransforms :: Monad m => [Transform] -> Pandoc -> m Pandoc
+applyTransforms transforms d = return $ foldr ($) d transforms
+
+-- | Prefixes identifiers with a string derived from the filepath of
+-- @thisfile@; fixes links to targets in @allfiles@ accordingly.
+adjustLinksAndIds :: Extensions        -- ^ defines how IDs are generated
+                  -> Text              -- ^ thisfile
+                  -> [Text]            -- ^ allfiles
+                  -> Transform
+adjustLinksAndIds exts thisfile allfiles
+  | length allfiles > 1 = walk fixInline . walk fixBlock
+  | otherwise           = id
+ where
+  -- fix ids in blocks
+  fixBlock :: Block -> Block
+  fixBlock (CodeBlock attr t) = CodeBlock (fixAttrs attr) t
+  fixBlock (Header lev attr ils) = Header lev (fixAttrs attr) ils
+  fixBlock (Table attr cap cols th tbs tf) =
+     Table (fixAttrs attr) cap cols th tbs tf
+  fixBlock (Div attr bs) = Div (fixAttrs attr) bs
+  fixBlock x = x
+
+  -- fix ids and links in inlines
+  fixInline :: Inline -> Inline
+  fixInline (Code attr t) = Code (fixAttrs attr) t
+  fixInline (Link attr ils (url,tit)) =
+    Link (fixAttrs attr) ils (fixURL url,tit)
+  fixInline (Image attr ils (url,tit)) =
+    Image (fixAttrs attr) ils (fixURL url,tit)
+  fixInline (Span attr ils) = Span (fixAttrs attr) ils
+  fixInline x = x
+
+  -- add thisfile as prefix of identifier
+  fixAttrs :: Attr -> Attr
+  fixAttrs (i,cs,kvs)
+    | T.null i = (i,cs,kvs)
+    | otherwise =
+        (T.intercalate "__"
+          (filter (not . T.null) [toIdent thisfile, i]),
+        cs, kvs)
+
+  -- turns a filepath into an identifier
+  toIdent :: Text -> Text
+  toIdent = textToIdentifier exts . T.intercalate "__" .
+            T.split (\c -> c == '/' || c == '\\')
+
+  -- if URL begins with file from allfiles, convert to
+  -- an internal link with the appropriate identifier
+  fixURL :: Text -> Text
+  fixURL u =
+    let (a,b) = T.break (== '#') $ T.pack . unEscapeString . T.unpack $ u
+        filepart = if T.null a
+                      then toIdent thisfile
+                      else toIdent a
+        fragpart = T.dropWhile (== '#') b
+     in if T.null a || a `elem` allfiles
+           then "#" <> T.intercalate "__"
+                         (filter (not . T.null) [filepart, fragpart])
+           else u
+
+-- | Process ipynb output cells.  If mode is Nothing,
+-- remove all output.  If mode is Just format, select
+-- best output for the format.  If format is not ipynb,
+-- strip out ANSI escape sequences from CodeBlocks (see #5633).
+filterIpynbOutput :: Maybe Format -> Pandoc -> Pandoc
+filterIpynbOutput mode = walk go
+  where go (Div (ident, "output":os, kvs) bs) =
+          case mode of
+            Nothing  -> Div (ident, "output":os, kvs) []
+            -- "best" for ipynb includes all formats:
+            Just fmt
+              | fmt == Format "ipynb"
+                          -> Div (ident, "output":os, kvs) bs
+              | otherwise -> Div (ident, "output":os, kvs) $
+                              walk removeANSI $
+                              take 1 $ sortOn rank bs
+                 where
+                  rank (RawBlock (Format "html") _)
+                    | fmt == Format "html" = 1 :: Int
+                    | fmt == Format "markdown" = 3
+                    | otherwise = 4
+                  rank (RawBlock (Format "latex") _)
+                    | fmt == Format "latex" = 1
+                    | fmt == Format "markdown" = 3
+                    | otherwise = 4
+                  rank (RawBlock f _)
+                    | fmt == f = 1
+                    | otherwise = 4
+                  rank (Para [Image{}]) = 2
+                  rank _ = 3
+                  removeANSI (CodeBlock attr code) =
+                    CodeBlock attr (removeANSIEscapes code)
+                  removeANSI x = x
+                  removeANSIEscapes t
+                    | Just cs <- T.stripPrefix "\x1b[" t =
+                        removeANSIEscapes $ T.drop 1 $ T.dropWhile (/='m') cs
+                    | Just (c, cs) <- T.uncons t = T.cons c $ removeANSIEscapes cs
+                    | otherwise = ""
+        go x = x
+
+-- | Remove soft breaks between East Asian characters.
+eastAsianLineBreakFilter :: Pandoc -> Pandoc
+eastAsianLineBreakFilter = bottomUp go
+  where go (x:SoftBreak:y:zs)
+          | Just (_, b) <- T.unsnoc $ stringify x
+          , Just (c, _) <- T.uncons $ stringify y
+          , charWidth b == 2
+          , charWidth c == 2
+          = x:y:zs
+          | otherwise
+          = x:SoftBreak:y:zs
+        go xs
+          = xs
+
+-- | Shift header levels up or down.
+headerShift :: Int -> Pandoc -> Pandoc
+headerShift n (Pandoc meta (Header m _ ils : bs))
+  | n < 0
+  , m + n == 0 = headerShift n $
+                 B.setTitle (B.fromList ils) $ Pandoc meta bs
+headerShift n (Pandoc meta bs) = Pandoc meta (walk shift bs)
+
+ where
+   shift :: Block -> Block
+   shift (Header level attr inner)
+     | level + n > 0  = Header (level + n) attr inner
+     | otherwise      = Para inner
+   shift x            = x
diff --git a/src/Text/Pandoc/Translations.hs b/src/Text/Pandoc/Translations.hs
--- a/src/Text/Pandoc/Translations.hs
+++ b/src/Text/Pandoc/Translations.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings          #-}
 {- |
    Module      : Text.Pandoc.Translations
-   Copyright   : Copyright (C) 2017-2023 John MacFarlane
+   Copyright   : Copyright (C) 2017-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Translations/Types.hs b/src/Text/Pandoc/Translations/Types.hs
--- a/src/Text/Pandoc/Translations/Types.hs
+++ b/src/Text/Pandoc/Translations/Types.hs
@@ -4,7 +4,7 @@
 {-# LANGUAGE OverloadedStrings          #-}
 {- |
    Module      : Text.Pandoc.Translations.Types
-   Copyright   : Copyright (C) 2017-2023 John MacFarlane
+   Copyright   : Copyright (C) 2017-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/URI.hs b/src/Text/Pandoc/URI.hs
--- a/src/Text/Pandoc/URI.hs
+++ b/src/Text/Pandoc/URI.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE CPP #-}
 {- |
    Module      : Text.Pandoc.URI
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/UTF8.hs b/src/Text/Pandoc/UTF8.hs
--- a/src/Text/Pandoc/UTF8.hs
+++ b/src/Text/Pandoc/UTF8.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.UTF8
-   Copyright   : Copyright (C) 2010-2023 John MacFarlane
+   Copyright   : Copyright (C) 2010-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/UUID.hs b/src/Text/Pandoc/UUID.hs
--- a/src/Text/Pandoc/UUID.hs
+++ b/src/Text/Pandoc/UUID.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Text.Pandoc.UUID
-   Copyright   : Copyright (C) 2010-2023 John MacFarlane
+   Copyright   : Copyright (C) 2010-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Version.hs b/src/Text/Pandoc/Version.hs
--- a/src/Text/Pandoc/Version.hs
+++ b/src/Text/Pandoc/Version.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE CPP                   #-}
 {- |
    Module      : Text.Pandoc.Version
-   Copyright   : Copyright (C) 2022-2023 John MacFarlane
+   Copyright   : Copyright (C) 2022-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers.hs b/src/Text/Pandoc/Writers.hs
--- a/src/Text/Pandoc/Writers.hs
+++ b/src/Text/Pandoc/Writers.hs
@@ -5,7 +5,7 @@
 {-# LANGUAGE TupleSections       #-}
 {- |
    Module      : Text.Pandoc
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs
--- a/src/Text/Pandoc/Writers/AsciiDoc.hs
+++ b/src/Text/Pandoc/Writers/AsciiDoc.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.AsciiDoc
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/BibTeX.hs b/src/Text/Pandoc/Writers/BibTeX.hs
--- a/src/Text/Pandoc/Writers/BibTeX.hs
+++ b/src/Text/Pandoc/Writers/BibTeX.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.BibTeX
-   Copyright   : Copyright (C) 2021-2023 John MacFarlane
+   Copyright   : Copyright (C) 2021-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/Blaze.hs b/src/Text/Pandoc/Writers/Blaze.hs
--- a/src/Text/Pandoc/Writers/Blaze.hs
+++ b/src/Text/Pandoc/Writers/Blaze.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.Blaze
-   Copyright   : Copyright (C) 2021-2023 John MacFarlane
+   Copyright   : Copyright (C) 2021-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/CommonMark.hs b/src/Text/Pandoc/Writers/CommonMark.hs
--- a/src/Text/Pandoc/Writers/CommonMark.hs
+++ b/src/Text/Pandoc/Writers/CommonMark.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Text.Pandoc.Writers.CommonMark
-   Copyright   : Copyright (C) 2015-2023 John MacFarlane
+   Copyright   : Copyright (C) 2015-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs
--- a/src/Text/Pandoc/Writers/ConTeXt.hs
+++ b/src/Text/Pandoc/Writers/ConTeXt.hs
@@ -4,7 +4,7 @@
 {-# LANGUAGE ViewPatterns        #-}
 {- |
    Module      : Text.Pandoc.Writers.ConTeXt
-   Copyright   : Copyright (C) 2007-2023 John MacFarlane
+   Copyright   : Copyright (C) 2007-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -587,7 +587,7 @@
                 -> WM m (Doc Text)
 inlineToConTeXt (Emph lst)      = highlightInlines "emph"      "\\em" lst
 inlineToConTeXt (Strong lst)    = highlightInlines "strong"    "\\bf" lst
-inlineToConTeXt (SmallCaps lst) = highlightInlines "smallcaps" "\\sc" lst
+inlineToConTeXt (SmallCaps lst) = highlightInlines "smallcaps" "\\setsmallcaps" lst
 inlineToConTeXt (Underline lst) = do
   contents <- inlineListToConTeXt lst
   return $ "\\underbar" <> braces contents
diff --git a/src/Text/Pandoc/Writers/CslJson.hs b/src/Text/Pandoc/Writers/CslJson.hs
--- a/src/Text/Pandoc/Writers/CslJson.hs
+++ b/src/Text/Pandoc/Writers/CslJson.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.CslJson
-   Copyright   : Copyright (C) 2020-2023 John MacFarlane
+   Copyright   : Copyright (C) 2020-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/DocBook.hs b/src/Text/Pandoc/Writers/DocBook.hs
--- a/src/Text/Pandoc/Writers/DocBook.hs
+++ b/src/Text/Pandoc/Writers/DocBook.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE PatternGuards     #-}
 {- |
    Module      : Text.Pandoc.Writers.DocBook
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -8,7 +8,7 @@
 {-# LANGUAGE TypeApplications    #-}
 {- |
    Module      : Text.Pandoc.Writers.Docx
-   Copyright   : Copyright (C) 2012-2023 John MacFarlane
+   Copyright   : Copyright (C) 2012-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -820,28 +820,32 @@
     [ mknode "w:numFmt" [("w:val",fmt)] ()
     , mknode "w:lvlText" [("w:val", lvltxt)] ()
     , mknode "w:lvlJc" [("w:val","left")] ()
-    , mknode "w:pPr" []
-      [ mknode "w:ind" [ ("w:left",tshow $ lvl * step + step)
-                       , ("w:hanging",tshow (hang :: Int))
+    , mknode "w:pPr" [] $
+        mknode "w:ind" [ ("w:left",tshow $ lvl * step + step)
+                       , ("w:hanging",tshow hang)
                        ] ()
-      ]
-    ]
-    where (fmt, lvltxt, start) =
+    ] ++
+    maybe [] (\font ->
+                [ mknode "w:rPr" []
+                  [ mknode "w:rFonts" [ ("w:ascii", font)
+                                      , ("w:hAnsi", font)
+                                      , ("w:cs", font)
+                                      , ("w:hint", "default") ] () ]]) mbfont
+    where (fmt, lvltxt, mbfont, start) =
             case marker of
-                 NoMarker             -> ("bullet"," ","1")
-                 BulletMarker         -> ("bullet",bulletFor lvl,"1")
+                 NoMarker             -> ("bullet"," ", Nothing, "1")
+                 BulletMarker         -> bulletFor lvl
                  NumberMarker st de n -> (styleFor st lvl
                                          ,patternFor de ("%" <> tshow (lvl + 1))
+                                         ,Nothing
                                          ,tshow n)
           step = 720
-          hang = 480
-          bulletFor 0 = "\x2022"  -- filled circle
-          bulletFor 1 = "\x2013"  -- en dash
-          bulletFor 2 = "\x2022"  -- hyphen bullet
-          bulletFor 3 = "\x2013"
-          bulletFor 4 = "\x2022"
-          bulletFor 5 = "\x2013"
-          bulletFor x = bulletFor (x `mod` 6)
+          hang :: Int
+          hang = 360
+          bulletFor 0 = ("bullet", "\xf0b7", Just "Symbol", "1") -- filled circle
+          bulletFor 1 = ("bullet", "o", Just "Courier New", "1") -- open o
+          bulletFor 2 = ("bullet", "\xf0a7", Just "Wingdings", "1")  -- closed box
+          bulletFor x = bulletFor (x `mod` 3)
           styleFor UpperAlpha _   = "upperLetter"
           styleFor LowerAlpha _   = "lowerLetter"
           styleFor UpperRoman _   = "upperRoman"
diff --git a/src/Text/Pandoc/Writers/Docx/StyleMap.hs b/src/Text/Pandoc/Writers/Docx/StyleMap.hs
--- a/src/Text/Pandoc/Writers/Docx/StyleMap.hs
+++ b/src/Text/Pandoc/Writers/Docx/StyleMap.hs
@@ -2,7 +2,7 @@
 {- |
    Module : Text.Pandoc.Writers.Docx.StyleMap
    Copyright   : © 2014-2020 Jesse Rosenthal <jrosenthal@jhu.edu>,
-                   2014-2023 John MacFarlane <jgm@berkeley.edu>,
+                   2014-2024 John MacFarlane <jgm@berkeley.edu>,
                    2015-2019 Nikolay Yakimov <root@livid.pp.ru>
    License     : GNU GPL, version 2 or above
 
diff --git a/src/Text/Pandoc/Writers/Docx/Table.hs b/src/Text/Pandoc/Writers/Docx/Table.hs
--- a/src/Text/Pandoc/Writers/Docx/Table.hs
+++ b/src/Text/Pandoc/Writers/Docx/Table.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 {- |
 Module      : Text.Pandoc.Writers.Docx.Table
-Copyright   : Copyright (C) 2012-2023 John MacFarlane
+Copyright   : Copyright (C) 2012-2024 John MacFarlane
 License     : GNU GPL, version 2 or above
 Maintainer  : John MacFarlane <jgm@berkeley.edu>
 
diff --git a/src/Text/Pandoc/Writers/Docx/Types.hs b/src/Text/Pandoc/Writers/Docx/Types.hs
--- a/src/Text/Pandoc/Writers/Docx/Types.hs
+++ b/src/Text/Pandoc/Writers/Docx/Types.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings   #-}
 {- |
 Module      : Text.Pandoc.Writers.Docx
-Copyright   : Copyright (C) 2012-2023 John MacFarlane
+Copyright   : Copyright (C) 2012-2024 John MacFarlane
 License     : GNU GPL, version 2 or above
 Maintainer  : John MacFarlane <jgm@berkeley.edu>
 
diff --git a/src/Text/Pandoc/Writers/DokuWiki.hs b/src/Text/Pandoc/Writers/DokuWiki.hs
--- a/src/Text/Pandoc/Writers/DokuWiki.hs
+++ b/src/Text/Pandoc/Writers/DokuWiki.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.DokuWiki
-   Copyright   : Copyright (C) 2008-2023 John MacFarlane
+   Copyright   : Copyright (C) 2008-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Clare Macrae <clare.macrae@googlemail.com>
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -5,7 +5,7 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 {- |
    Module      : Text.Pandoc.Writers.EPUB
-   Copyright   : Copyright (C) 2010-2023 John MacFarlane
+   Copyright   : Copyright (C) 2010-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/FB2.hs b/src/Text/Pandoc/Writers/FB2.hs
--- a/src/Text/Pandoc/Writers/FB2.hs
+++ b/src/Text/Pandoc/Writers/FB2.hs
@@ -3,7 +3,7 @@
 {- |
 Module      : Text.Pandoc.Writers.FB2
 Copyright   : Copyright (C) 2011-2012 Sergey Astanin
-                            2012-2023 John MacFarlane
+                            2012-2024 John MacFarlane
 License     : GNU GPL, version 2 or above
 
 Maintainer  : John MacFarlane
diff --git a/src/Text/Pandoc/Writers/GridTable.hs b/src/Text/Pandoc/Writers/GridTable.hs
--- a/src/Text/Pandoc/Writers/GridTable.hs
+++ b/src/Text/Pandoc/Writers/GridTable.hs
@@ -5,7 +5,7 @@
 
 {- |
 Module      : Text.Pandoc.Writers.GridTable
-Copyright   : © 2020-2023 Albert Krewinkel
+Copyright   : © 2020-2024 Albert Krewinkel
 License     : GNU GPL, version 2 or above
 
 Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -8,7 +8,7 @@
 {-# LANGUAGE ViewPatterns        #-}
 {- |
    Module      : Text.Pandoc.Writers.HTML
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -889,7 +889,7 @@
                  | "nonincremental" `elem` classes -> opts{ writerIncremental = False }
                  | otherwise -> opts
       -- we remove "incremental" and "nonincremental" if we're in a
-      -- slide presentaiton format.
+      -- slide presentation format.
       classes' = case slideVariant of
         NoSlides -> classes
         _ -> filter (\k -> k /= "incremental" && k /= "nonincremental") classes
diff --git a/src/Text/Pandoc/Writers/Ipynb.hs b/src/Text/Pandoc/Writers/Ipynb.hs
--- a/src/Text/Pandoc/Writers/Ipynb.hs
+++ b/src/Text/Pandoc/Writers/Ipynb.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 {- |
    Module      : Text.Pandoc.Writers.Ipynb
-   Copyright   : Copyright (C) 2019-2023 John MacFarlane
+   Copyright   : Copyright (C) 2019-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
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
@@ -4,7 +4,7 @@
 {-# LANGUAGE ViewPatterns        #-}
 {- |
    Module      : Text.Pandoc.Writers.JATS
-   Copyright   : 2017-2023 John MacFarlane
+   Copyright   : 2017-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/JATS/References.hs b/src/Text/Pandoc/Writers/JATS/References.hs
--- a/src/Text/Pandoc/Writers/JATS/References.hs
+++ b/src/Text/Pandoc/Writers/JATS/References.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.JATS.References
-   Copyright   : © 2021-2023 Albert Krewinkel
+   Copyright   : © 2021-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>
diff --git a/src/Text/Pandoc/Writers/JATS/Table.hs b/src/Text/Pandoc/Writers/JATS/Table.hs
--- a/src/Text/Pandoc/Writers/JATS/Table.hs
+++ b/src/Text/Pandoc/Writers/JATS/Table.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE TupleSections #-}
 {- |
    Module      : Text.Pandoc.Writers.JATS.Table
-   Copyright   : © 2020-2023 Albert Krewinkel
+   Copyright   : © 2020-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>
diff --git a/src/Text/Pandoc/Writers/JATS/Types.hs b/src/Text/Pandoc/Writers/JATS/Types.hs
--- a/src/Text/Pandoc/Writers/JATS/Types.hs
+++ b/src/Text/Pandoc/Writers/JATS/Types.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Text.Pandoc.Writers.JATS.Types
-   Copyright   : Copyright (C) 2017-2023 John MacFarlane
+   Copyright   : Copyright (C) 2017-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/Jira.hs b/src/Text/Pandoc/Writers/Jira.hs
--- a/src/Text/Pandoc/Writers/Jira.hs
+++ b/src/Text/Pandoc/Writers/Jira.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE PatternGuards #-}
 {- |
    Module      : Text.Pandoc.Writers.Jira
-   Copyright   : © 2010-2023 Albert Krewinkel, John MacFarlane
+   Copyright   : © 2010-2024 Albert Krewinkel, John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -7,7 +7,7 @@
 {-# LANGUAGE ViewPatterns        #-}
 {- |
    Module      : Text.Pandoc.Writers.LaTeX
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -821,7 +821,7 @@
               -> LW m (Doc Text)
 inlineToLaTeX (Span ("",["mark"],[]) lst) = do
   modify $ \st -> st{ stStrikeout = True } -- this gives us the soul package
-  inCmd "hl" <$> inlineListToLaTeX lst
+  inCmd "hl" <$> inSoulCommand (inlineListToLaTeX lst)
 inlineToLaTeX (Span (id',classes,kvs) ils) = do
   linkAnchor <- hypertarget id'
   lang <- toLang $ lookup "lang" kvs
@@ -859,19 +859,11 @@
 inlineToLaTeX (Emph lst) = inCmd "emph" <$> inlineListToLaTeX lst
 inlineToLaTeX (Underline lst) = do
   modify $ \st -> st{ stStrikeout = True } -- this gives us the soul package
-  inCmd "ul" <$> inlineListToLaTeX lst
+  inCmd "ul" <$> inSoulCommand (inlineListToLaTeX lst)
 inlineToLaTeX (Strong lst) = inCmd "textbf" <$> inlineListToLaTeX lst
 inlineToLaTeX (Strikeout lst) = do
-  -- we need to protect VERB in an mbox or we get an error
-  -- see #1294
-  -- with regular texttt we don't get an error, but we get
-  -- incorrect results if there is a space, see #5529
-  contents <- inlineListToLaTeX $ walk (concatMap protectCode) lst
   modify $ \s -> s{ stStrikeout = True }
-  -- soul doesn't like \(..\) delimiters, so we change these to $ (#9597):
-  let fixMath = T.replace "\\(" "$" . T.replace "\\)" "$" .
-                T.replace "\\[" "$$" . T.replace "\\]" "$$"
-  return $ inCmd "st" $ fixMath <$> contents
+  inCmd "st" <$> inSoulCommand (inlineListToLaTeX lst)
 inlineToLaTeX (Superscript lst) =
   inCmd "textsuperscript" <$> inlineListToLaTeX lst
 inlineToLaTeX (Subscript lst) =
@@ -892,6 +884,7 @@
   opts <- gets stOptions
   inHeading <- gets stInHeading
   inItem <- gets stInItem
+  inSoul <- gets stInSoulCommand
   let listingsCode = do
         let listingsopts = (case getListingsLanguage classes of
                                 Just l  -> (("language", mbBraced l):)
@@ -940,7 +933,12 @@
                  rawCode
                Right h -> modify (\st -> st{ stHighlighting = True }) >>
                           return (text (T.unpack h))
-  case () of
+  -- for soul commands we need to protect VERB in an mbox or we get an error
+  -- (see #1294). with regular texttt we don't get an error, but we get
+  -- incorrect results if there is a space (see #5529).
+  let inMbox x = "\\mbox" <> braces x
+  (if inSoul then inMbox else id) <$>
+   case () of
      _ | inHeading || inItem  -> rawCode  -- see #5574
        | writerListings opts  -> listingsCode
        | isJust (writerHighlightStyle opts) && not (null classes)
@@ -984,10 +982,20 @@
   liftM literal $ stringToLaTeX TextString str
 inlineToLaTeX (Math InlineMath str) = do
   setEmptyLine False
-  return $ "\\(" <> literal (handleMathComment str) <> "\\)"
+  inSoul <- gets stInSoulCommand
+  let contents = literal (handleMathComment str)
+  return $
+    if inSoul -- #9597
+       then "$" <> contents <> "$"
+       else "\\(" <> contents <> "\\)"
 inlineToLaTeX (Math DisplayMath str) = do
   setEmptyLine False
-  return $ "\\[" <> literal (handleMathComment str) <> "\\]"
+  inSoul <- gets stInSoulCommand
+  let contents = literal (handleMathComment str)
+  return $
+    if inSoul -- # 9597
+       then "$$" <> contents <> "$$"
+       else "\\[" <> contents <> "\\]"
 inlineToLaTeX il@(RawInline f str) = do
   beamer <- gets stBeamer
   if f == Format "latex" || f == Format "tex" ||
@@ -1121,11 +1129,6 @@
           _              -> s <> "\n"
         _                -> s
 
-protectCode :: Inline -> [Inline]
-protectCode x@(Code _ _) = [ltx "\\mbox{" , x , ltx "}"]
-  where ltx = RawInline (Format "latex")
-protectCode x = [x]
-
 setEmptyLine :: PandocMonad m => Bool -> LW m ()
 setEmptyLine b = modify $ \st -> st{ stEmptyLine = b }
 
@@ -1145,3 +1148,13 @@
 -- Look up a key in an attribute and give a list of its values
 lookKey :: Text -> Attr -> [Text]
 lookKey key (_,_,kvs) =  maybe [] T.words $ lookup key kvs
+
+-- soul doesn't like \(..\) delimiters, so we change these to $ (#9597)
+-- when processing their contents.
+inSoulCommand :: PandocMonad m => LW m a -> LW m a
+inSoulCommand pa = do
+  oldInSoulCommand <- gets stInSoulCommand
+  modify $ \st -> st{ stInSoulCommand = True }
+  result <- pa
+  modify $ \st -> st{ stInSoulCommand = oldInSoulCommand }
+  pure result
diff --git a/src/Text/Pandoc/Writers/LaTeX/Caption.hs b/src/Text/Pandoc/Writers/LaTeX/Caption.hs
--- a/src/Text/Pandoc/Writers/LaTeX/Caption.hs
+++ b/src/Text/Pandoc/Writers/LaTeX/Caption.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Text.Pandoc.Writers.LaTeX.Caption
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/LaTeX/Citation.hs b/src/Text/Pandoc/Writers/LaTeX/Citation.hs
--- a/src/Text/Pandoc/Writers/LaTeX/Citation.hs
+++ b/src/Text/Pandoc/Writers/LaTeX/Citation.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.LaTeX.Citation
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/LaTeX/Lang.hs b/src/Text/Pandoc/Writers/LaTeX/Lang.hs
--- a/src/Text/Pandoc/Writers/LaTeX/Lang.hs
+++ b/src/Text/Pandoc/Writers/LaTeX/Lang.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 {- |
    Module      : Text.Pandoc.Writers.LaTeX.Lang
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -33,7 +33,7 @@
   | otherwise                           = Just "ngerman"
 toBabel (Lang "dsb" _ _ _ _ _)          = Just "lowersorbian"
 toBabel (Lang "el" _ _ vars _ _)
-  | "polyton" `elem` vars               = Just "polutonikogreek"
+  | "polyton" `elem` vars               = Just "polytonicgreek"
 toBabel (Lang "en" _ (Just "AU") _ _ _) = Just "australian"
 toBabel (Lang "en" _ (Just "CA") _ _ _) = Just "canadian"
 toBabel (Lang "en" _ (Just "GB") _ _ _) = Just "british"
diff --git a/src/Text/Pandoc/Writers/LaTeX/Notes.hs b/src/Text/Pandoc/Writers/LaTeX/Notes.hs
--- a/src/Text/Pandoc/Writers/LaTeX/Notes.hs
+++ b/src/Text/Pandoc/Writers/LaTeX/Notes.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.LaTeX.Notes
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/LaTeX/Table.hs b/src/Text/Pandoc/Writers/LaTeX/Table.hs
--- a/src/Text/Pandoc/Writers/LaTeX/Table.hs
+++ b/src/Text/Pandoc/Writers/LaTeX/Table.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.LaTeX.Table
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/LaTeX/Types.hs b/src/Text/Pandoc/Writers/LaTeX/Types.hs
--- a/src/Text/Pandoc/Writers/LaTeX/Types.hs
+++ b/src/Text/Pandoc/Writers/LaTeX/Types.hs
@@ -52,6 +52,7 @@
   , stHasCslRefs    :: Bool          -- ^ has a Div with class refs
   , stIsFirstInDefinition :: Bool    -- ^ first block in a defn list
   , stLang          :: Maybe Lang    -- ^ lang specified in metadata
+  , stInSoulCommand :: Bool          -- ^ in a soul command like ul
   }
 
 startingState :: WriterOptions -> WriterState
@@ -91,4 +92,5 @@
   , stHasCslRefs = False
   , stIsFirstInDefinition = False
   , stLang = Nothing
+  , stInSoulCommand = False
   }
diff --git a/src/Text/Pandoc/Writers/LaTeX/Util.hs b/src/Text/Pandoc/Writers/LaTeX/Util.hs
--- a/src/Text/Pandoc/Writers/LaTeX/Util.hs
+++ b/src/Text/Pandoc/Writers/LaTeX/Util.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings   #-}
 {- |
    Module      : Text.Pandoc.Writers.LaTeX.Util
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs
--- a/src/Text/Pandoc/Writers/Man.hs
+++ b/src/Text/Pandoc/Writers/Man.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE ViewPatterns      #-}
 {- |
    Module      : Text.Pandoc.Writers.Man
-   Copyright   : Copyright (C) 2007-2023 John MacFarlane
+   Copyright   : Copyright (C) 2007-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
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
@@ -5,7 +5,7 @@
 {-# LANGUAGE BangPatterns        #-}
 {- |
    Module      : Text.Pandoc.Writers.Markdown
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -474,8 +474,7 @@
                   "markdown_mmd", "markdown_strict"]
          -> return $ literal str <> literal "\n"
     Markua -> renderEmpty
-    _ | isEnabled Ext_raw_attribute opts -> rawAttribBlock
-      | f `elem` ["html", "html5", "html4"]
+    _ | f `elem` ["html", "html5", "html4"]
       , isEnabled Ext_markdown_attribute opts
          -> return $ literal (addMarkdownAttribute str) <> literal "\n"
       | f `elem` ["html", "html5", "html4"]
@@ -484,6 +483,7 @@
       | f `elem` ["latex", "tex"]
       , isEnabled Ext_raw_tex opts
          -> return $ literal str <> literal "\n"
+      | isEnabled Ext_raw_attribute opts -> rawAttribBlock
     _ -> renderEmpty
 blockToMarkdown' opts HorizontalRule = do
   variant <- asks envVariant
diff --git a/src/Text/Pandoc/Writers/Markdown/Inline.hs b/src/Text/Pandoc/Writers/Markdown/Inline.hs
--- a/src/Text/Pandoc/Writers/Markdown/Inline.hs
+++ b/src/Text/Pandoc/Writers/Markdown/Inline.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE ViewPatterns        #-}
 {- |
    Module      : Text.Pandoc.Writers.Markdown.Inline
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/Markdown/Table.hs b/src/Text/Pandoc/Writers/Markdown/Table.hs
--- a/src/Text/Pandoc/Writers/Markdown/Table.hs
+++ b/src/Text/Pandoc/Writers/Markdown/Table.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings   #-}
 {- |
    Module      : Text.Pandoc.Writers.Markdown
-   Copyright   : © 2006-2023 John MacFarlane
+   Copyright   : © 2006-2024 John MacFarlane
    License     : GPL-2.0-or-later
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
 
@@ -36,15 +36,18 @@
           -> MD m (Doc Text)
 pipeTable opts headless aligns widths rawHeaders rawRows = do
   let sp = literal " "
-  let blockFor AlignLeft   x y = lblock (x + 2) (sp <> y) <> lblock 0 empty
-      blockFor AlignCenter x y = cblock (x + 2) (sp <> y <> sp) <> lblock 0 empty
-      blockFor AlignRight  x y = rblock (x + 2) (y <> sp) <> lblock 0 empty
-      blockFor _           x y = lblock (x + 2) (sp <> y) <> lblock 0 empty
   let contentWidths = map (max 3 . maybe 3 maximum . nonEmpty . map offset) $
                        transpose (rawHeaders : rawRows)
   let colwidth = writerColumns opts
   let numcols = length contentWidths
   let maxwidth = sum contentWidths
+  -- if cell contents are > COLUMNS, adding padding looks bad
+  let pad = maxwidth <= writerColumns opts
+  let blockFor _ _ y | not pad = sp <> y <> sp <> lblock 0 empty
+      blockFor AlignLeft   x y = lblock (x + 2) (sp <> y) <> lblock 0 empty
+      blockFor AlignCenter x y = cblock (x + 2) (sp <> y <> sp) <> lblock 0 empty
+      blockFor AlignRight  x y = rblock (x + 2) (y <> sp) <> lblock 0 empty
+      blockFor AlignDefault x y = lblock (x + 2) (sp <> y) <> lblock 0 empty
   variant <- asks envVariant
   let pipeWidths = if variant == Markdown &&
                       not (all (== 0) widths) &&
@@ -54,7 +57,9 @@
                               floor .
                                 (* fromIntegral (colwidth - (numcols +1))))
                             widths
-                      else contentWidths
+                      else if pad
+                              then contentWidths
+                              else map (const 2) widths
   let torow cs = nowrap $ literal "|" <>
                     hcat (intersperse (literal "|") $
                           zipWith3 blockFor aligns contentWidths (map chomp cs))
diff --git a/src/Text/Pandoc/Writers/Markdown/Types.hs b/src/Text/Pandoc/Writers/Markdown/Types.hs
--- a/src/Text/Pandoc/Writers/Markdown/Types.hs
+++ b/src/Text/Pandoc/Writers/Markdown/Types.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Text.Pandoc.Writers.Markdown.Types
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs
--- a/src/Text/Pandoc/Writers/MediaWiki.hs
+++ b/src/Text/Pandoc/Writers/MediaWiki.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.MediaWiki
-   Copyright   : Copyright (C) 2008-2023 John MacFarlane
+   Copyright   : Copyright (C) 2008-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/Ms.hs b/src/Text/Pandoc/Writers/Ms.hs
--- a/src/Text/Pandoc/Writers/Ms.hs
+++ b/src/Text/Pandoc/Writers/Ms.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE ViewPatterns      #-}
 {- |
    Module      : Text.Pandoc.Writers.Ms
-   Copyright   : Copyright (C) 2007-2023 John MacFarlane
+   Copyright   : Copyright (C) 2007-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/Native.hs b/src/Text/Pandoc/Writers/Native.hs
--- a/src/Text/Pandoc/Writers/Native.hs
+++ b/src/Text/Pandoc/Writers/Native.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Text.Pandoc.Writers.Native
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/ODT.hs b/src/Text/Pandoc/Writers/ODT.hs
--- a/src/Text/Pandoc/Writers/ODT.hs
+++ b/src/Text/Pandoc/Writers/ODT.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings   #-}
 {- |
    Module      : Text.Pandoc.Writers.ODT
-   Copyright   : Copyright (C) 2008-2023 John MacFarlane
+   Copyright   : Copyright (C) 2008-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/OOXML.hs b/src/Text/Pandoc/Writers/OOXML.hs
--- a/src/Text/Pandoc/Writers/OOXML.hs
+++ b/src/Text/Pandoc/Writers/OOXML.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.OOXML
-   Copyright   : Copyright (C) 2012-2023 John MacFarlane
+   Copyright   : Copyright (C) 2012-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/OPML.hs b/src/Text/Pandoc/Writers/OPML.hs
--- a/src/Text/Pandoc/Writers/OPML.hs
+++ b/src/Text/Pandoc/Writers/OPML.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE CPP               #-}
 {- |
    Module      : Text.Pandoc.Writers.OPML
-   Copyright   : Copyright (C) 2013-2023 John MacFarlane
+   Copyright   : Copyright (C) 2013-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -660,8 +660,12 @@
                                                  , ("xlink:show"   , "embed" )
                                                  , ("xlink:actuate", "onLoad")]
       mkSpan attr xs =  do
-        let (ident,_,_) = attr
-            i = withLangFromAttr attr (inlinesToOpenDocument o xs)
+        let (ident,_,kvs) = attr
+            i = maybe id (\sty ->
+                           fmap (inTags False "text:span"
+                                  [ ("text:style-name", sty) ]))
+                  (lookup "custom-style" kvs) .
+                 withLangFromAttr attr $ inlinesToOpenDocument o xs
             mkBookmarkedSpan b =
               if isEmpty b
                 then selfClosingBookmark ident
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
@@ -3,8 +3,8 @@
 {- |
    Module      : Text.Pandoc.Writers.Org
    Copyright   : © 2010-2015 Puneeth Chaganti <punchagan@gmail.com>
-                   2010-2023 John MacFarlane <jgm@berkeley.edu>
-                   2016-2023 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
+                   2010-2024 John MacFarlane <jgm@berkeley.edu>
+                   2016-2024 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE ViewPatterns      #-}
 {- |
    Module      : Text.Pandoc.Writers.RST
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs
--- a/src/Text/Pandoc/Writers/RTF.hs
+++ b/src/Text/Pandoc/Writers/RTF.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings   #-}
 {- |
    Module      : Text.Pandoc.Writers.RTF
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/Roff.hs b/src/Text/Pandoc/Writers/Roff.hs
--- a/src/Text/Pandoc/Writers/Roff.hs
+++ b/src/Text/Pandoc/Writers/Roff.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.Roff
-   Copyright   : Copyright (C) 2007-2023 John MacFarlane
+   Copyright   : Copyright (C) 2007-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs
--- a/src/Text/Pandoc/Writers/Shared.hs
+++ b/src/Text/Pandoc/Writers/Shared.hs
@@ -5,7 +5,7 @@
 {-# LANGUAGE LambdaCase #-}
 {- |
    Module      : Text.Pandoc.Writers.Shared
-   Copyright   : Copyright (C) 2013-2023 John MacFarlane
+   Copyright   : Copyright (C) 2013-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/TEI.hs b/src/Text/Pandoc/Writers/TEI.hs
--- a/src/Text/Pandoc/Writers/TEI.hs
+++ b/src/Text/Pandoc/Writers/TEI.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE PatternGuards     #-}
 {- |
    Module      : Text.Pandoc.Writers.Docbook
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs
--- a/src/Text/Pandoc/Writers/Texinfo.hs
+++ b/src/Text/Pandoc/Writers/Texinfo.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.Texinfo
-   Copyright   : Copyright (C) 2008-2023 John MacFarlane
+   Copyright   : Copyright (C) 2008-2024 John MacFarlane
                                2012 Peter Wang
    License     : GNU GPL, version 2 or above
 
diff --git a/src/Text/Pandoc/Writers/Textile.hs b/src/Text/Pandoc/Writers/Textile.hs
--- a/src/Text/Pandoc/Writers/Textile.hs
+++ b/src/Text/Pandoc/Writers/Textile.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.Textile
-   Copyright   : Copyright (C) 2010-2023 John MacFarlane
+   Copyright   : Copyright (C) 2010-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/src/Text/Pandoc/Writers/Typst.hs b/src/Text/Pandoc/Writers/Typst.hs
--- a/src/Text/Pandoc/Writers/Typst.hs
+++ b/src/Text/Pandoc/Writers/Typst.hs
@@ -21,6 +21,7 @@
 import Text.Pandoc.Options ( WriterOptions(..), WrapOption(..), isEnabled )
 import Data.Text (Text)
 import Data.List (intercalate, intersperse)
+import Data.Bifunctor (first, second)
 import Network.URI (unEscapeString)
 import qualified Data.Text as T
 import Control.Monad.State ( StateT, evalStateT, gets, modify )
@@ -88,6 +89,37 @@
        Nothing  -> main
        Just tpl -> renderTemplate tpl context
 
+pickTypstAttrs :: [(Text, Text)] -> ([(Text, Text)],[(Text, Text)])
+pickTypstAttrs = foldr go ([],[])
+  where
+    go (k,v) =
+      case T.splitOn ":" k of
+        "typst":"text":x:[] -> second ((x,v):)
+        "typst":x:[] -> first ((x,v):)
+        _ -> id
+
+formatTypstProp :: (Text, Text) -> Text
+formatTypstProp (k,v) = k <> ": " <> v
+
+toTypstPropsListSep :: [(Text, Text)] -> Doc Text
+toTypstPropsListSep = hsep . intersperse "," . (map $ literal . formatTypstProp)
+
+toTypstPropsListTerm :: [(Text, Text)] -> Doc Text
+toTypstPropsListTerm [] = ""
+toTypstPropsListTerm typstAttrs = toTypstPropsListSep typstAttrs <> ","
+
+toTypstPropsListParens :: [(Text, Text)] -> Doc Text
+toTypstPropsListParens [] = ""
+toTypstPropsListParens typstAttrs = parens $ toTypstPropsListSep typstAttrs
+
+toTypstTextElement :: [(Text, Text)] -> Doc Text -> Doc Text
+toTypstTextElement [] content = content
+toTypstTextElement typstTextAttrs content = "#text" <> toTypstPropsListParens typstTextAttrs <> brackets content
+
+toTypstSetText :: [(Text, Text)] -> Doc Text
+toTypstSetText [] = ""
+toTypstSetText typstTextAttrs = "#set text" <> parens (toTypstPropsListSep typstTextAttrs) <> "; " -- newline?
+
 blocksToTypst :: PandocMonad m => [Block] -> TW m (Doc Text)
 blocksToTypst blocks = vcat <$> mapM blockToTypst blocks
 
@@ -163,7 +195,7 @@
                    else vsep items') $$ blankline
     DefinitionList items ->
       ($$ blankline) . vsep <$> mapM defListItemToTypst items
-    Table (ident,_,_) (Caption _ caption) colspecs thead tbodies tfoot -> do
+    Table (ident,_,tabkvs) (Caption _ caption) colspecs thead tbodies tfoot -> do
       let lab = toLabel FreestandingLabel ident
       capt' <- if null caption
                   then return mempty
@@ -185,26 +217,40 @@
           formatalign AlignCenter = "center,"
           formatalign AlignDefault = "auto,"
       let alignarray = parens $ mconcat $ map formatalign aligns
-      let fromCell (Cell _attr alignment rowspan colspan bs) = do
-            let cellattrs =
+
+      let fromCell (Cell (_,_,kvs) alignment rowspan colspan bs) = do
+            let (typstAttrs, typstTextAttrs) = pickTypstAttrs kvs
+            let valign =
+                  (case lookup "align" typstAttrs of
+                    Just va -> [va]
+                    _ -> [])
+            let typstAttrs2 = filter ((/="align") . fst) typstAttrs
+            let halign =
                   (case alignment of
-                     AlignDefault -> []
-                     AlignLeft -> [ "align: left" ]
-                     AlignRight -> [ "align: right" ]
-                     AlignCenter -> [ "align: center" ]) ++
+                    AlignDefault -> []
+                    AlignLeft -> [ "left" ]
+                    AlignRight -> [ "right" ]
+                    AlignCenter -> [ "center" ])
+            let cellaligns = valign ++ halign
+            let cellattrs =
+                  (case cellaligns of
+                    [] -> []
+                    _ -> [ "align: " <> T.intercalate " + " cellaligns ]) ++
                   (case rowspan of
                      RowSpan 1 -> []
                      RowSpan n -> [ "rowspan: " <> tshow n ]) ++
                   (case colspan of
                      ColSpan 1 -> []
-                     ColSpan n -> [ "colspan: " <> tshow n ])
+                     ColSpan n -> [ "colspan: " <> tshow n ]) ++
+                  map formatTypstProp typstAttrs2
             cellContents <- blocksToTypst bs
+            let contents2 = brackets (toTypstSetText typstTextAttrs <> cellContents)
             pure $ if null cellattrs
-                      then brackets cellContents
+                      then contents2
                       else "table.cell" <>
                             parens
                              (literal (T.intercalate ", " cellattrs)) <>
-                            brackets cellContents
+                            contents2
       let fromRow (Row _ cs) =
             (<> ",") . commaSep <$> mapM fromCell cs
       let fromHead (TableHead _attr headRows) =
@@ -223,6 +269,7 @@
             hrows <- mapM fromRow headRows
             brows <- mapM fromRow bodyRows
             pure $ vcat (hrows ++ ["table.hline()," | not (null hrows)] ++ brows)
+      let (typstAttrs, typstTextAttrs) = pickTypstAttrs tabkvs
       header <- fromHead thead
       footer <- fromFoot tfoot
       body <- vcat <$> mapM fromTableBody tbodies
@@ -230,10 +277,11 @@
         "#figure("
         $$
         nest 2
-         ("align(center)[#table("
+         ("align(center)[" <> toTypstSetText typstTextAttrs <> "#table("
           $$ nest 2
              (  "columns: " <> columns <> ","
              $$ "align: " <> alignarray <> ","
+             $$ toTypstPropsListTerm typstAttrs
              $$ header
              $$ body
              $$ footer
@@ -261,10 +309,13 @@
                           $$ ")" $$ lab $$ blankline
     Div (ident,_,_) (Header lev ("",cls,kvs) ils:rest) ->
       blocksToTypst (Header lev (ident,cls,kvs) ils:rest)
-    Div (ident,_,_) blocks -> do
+    Div (ident,_,kvs) blocks -> do
       let lab = toLabel FreestandingLabel ident
+      let (typstAttrs,typstTextAttrs) = pickTypstAttrs kvs
       contents <- blocksToTypst blocks
-      return $ "#block[" $$ contents $$ ("]" <+> lab)
+      return $ "#block" <> toTypstPropsListParens typstAttrs <> "["
+        $$ toTypstSetText typstTextAttrs <> contents
+        $$ ("]" <+> lab)
 
 defListItemToTypst :: PandocMonad m => ([Inline], [[Block]]) -> TW m (Doc Text)
 defListItemToTypst (term, defns) = do
@@ -273,7 +324,7 @@
   modify $ \st -> st{ stEscapeContext = NormalContext }
   defns' <- mapM blocksToTypst defns
   return $ nowrap ("/ " <> term' <> ": " <> "#block[") $$
-            chomp (vcat defns') $$ "]"
+            chomp (vsep defns') $$ "]"
 
 listItemToTypst :: PandocMonad m => Int -> Doc Text -> [Block] -> TW m (Doc Text)
 listItemToTypst ind marker blocks = do
@@ -323,9 +374,14 @@
     Superscript inlines -> textstyle "#super" inlines
     Subscript inlines -> textstyle "#sub" inlines
     SmallCaps inlines -> textstyle "#smallcaps" inlines
-    Span (ident,_,_) inlines -> do
+    Span (ident,_,kvs) inlines -> do
       let lab = toLabel FreestandingLabel ident
-      (<> lab) <$> inlinesToTypst inlines
+      let (_, typstTextAttrs) = pickTypstAttrs kvs
+      case typstTextAttrs of
+        [] -> (<> lab) <$> inlinesToTypst inlines
+        _ -> do
+          contents <- inlinesToTypst inlines
+          return $ toTypstTextElement typstTextAttrs contents <> lab
     Quoted quoteType inlines -> do
       let q = case quoteType of
                    DoubleQuote -> literal "\""
diff --git a/src/Text/Pandoc/Writers/XWiki.hs b/src/Text/Pandoc/Writers/XWiki.hs
--- a/src/Text/Pandoc/Writers/XWiki.hs
+++ b/src/Text/Pandoc/Writers/XWiki.hs
@@ -1,6 +1,6 @@
 {-# LANGUAGE OverloadedStrings #-}
 {-
-Copyright (C) 2008-2023 John MacFarlane <jgm@berkeley.edu>
+Copyright (C) 2008-2024 John MacFarlane <jgm@berkeley.edu>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
 
 {- |
    Module      : Text.Pandoc.Writers.XWiki
-   Copyright   : Copyright (C) 2008-2023 John MacFarlane
+   Copyright   : Copyright (C) 2008-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Derek Chen-Becker <dchenbecker@gmail.com>
diff --git a/src/Text/Pandoc/Writers/ZimWiki.hs b/src/Text/Pandoc/Writers/ZimWiki.hs
--- a/src/Text/Pandoc/Writers/ZimWiki.hs
+++ b/src/Text/Pandoc/Writers/ZimWiki.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.Writers.ZimWiki
-   Copyright   : © 2008-2023 John MacFarlane,
+   Copyright   : © 2008-2024 John MacFarlane,
                    2017-2019 Alex Ivkin
    License     : GNU GPL, version 2 or above
 
diff --git a/src/Text/Pandoc/XML.hs b/src/Text/Pandoc/XML.hs
--- a/src/Text/Pandoc/XML.hs
+++ b/src/Text/Pandoc/XML.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.XML
-   Copyright   : Copyright (C) 2006-2023 John MacFarlane
+   Copyright   : Copyright (C) 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/test/Tests/Command.hs b/test/Tests/Command.hs
--- a/test/Tests/Command.hs
+++ b/test/Tests/Command.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE BangPatterns #-}
 {- |
    Module      : Tests.Command
-   Copyright   : © 2006-2023 John MacFarlane
+   Copyright   : © 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley@edu>
diff --git a/test/Tests/Helpers.hs b/test/Tests/Helpers.hs
--- a/test/Tests/Helpers.hs
+++ b/test/Tests/Helpers.hs
@@ -3,7 +3,7 @@
 {-# LANGUAGE FlexibleInstances    #-}
 {- |
    Module      : Tests.Helpers
-   Copyright   : © 2006-2023 John MacFarlane
+   Copyright   : © 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley@edu>
@@ -89,12 +89,14 @@
   mldpath   <- Env.lookupEnv "LD_LIBRARY_PATH"
   mdyldpath <- Env.lookupEnv "DYLD_LIBRARY_PATH"
   mpdd <- Env.lookupEnv "pandoc_datadir"
+  mbpath <- Env.lookupEnv "PATH"
   -- Note that Cabal sets the pandoc_datadir environment variable
   -- to point to the source directory, since otherwise getDataFilename
   -- will look in the data directory into which pandoc will be installed
   -- (but has not yet been).  So when we spawn a new process with
   -- pandoc, we need to make sure this environment variable is set.
-  return $ ("PATH",takeDirectory testExePath) :
+  return $ ("PATH",takeDirectory testExePath <>
+                    maybe mempty (searchPathSeparator:) mbpath) :
            ("TMP",".") :
            ("LANG","en_US.UTF-8") :
            ("HOME", "./") :
diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs
--- a/test/Tests/Old.hs
+++ b/test/Tests/Old.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Tests.Old
-   Copyright   : © 2006-2023 John MacFarlane
+   Copyright   : © 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley@edu>
diff --git a/test/Tests/Readers/Creole.hs b/test/Tests/Readers/Creole.hs
--- a/test/Tests/Readers/Creole.hs
+++ b/test/Tests/Readers/Creole.hs
@@ -2,7 +2,7 @@
 {- |
    Module      : Tests.Readers.Creole
    Copyright   : © 2017 Sascha Wilde
-                   2017-2023 John MacFarlane
+                   2017-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Sascha Wilde <wilde@sha-bang.de>
diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs
--- a/test/Tests/Readers/Docx.hs
+++ b/test/Tests/Readers/Docx.hs
@@ -236,6 +236,10 @@
             "docx/overlapping_targets.docx"
             "docx/overlapping_targets.native"
           , testCompare
+            "anchor in header after anchor"
+            "docx/anchor_header_after_anchor.docx"
+            "docx/anchor_header_after_anchor.native"
+          , testCompare
             "text in shape format"
             "docx/text_in_shape_format.docx"
             "docx/text_in_shape_format.native"
diff --git a/test/Tests/Readers/EPUB.hs b/test/Tests/Readers/EPUB.hs
--- a/test/Tests/Readers/EPUB.hs
+++ b/test/Tests/Readers/EPUB.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Tests.Readers.EPUB
-   Copyright   : © 2006-2023 John MacFarlane
+   Copyright   : © 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.eu>
diff --git a/test/Tests/Readers/HTML.hs b/test/Tests/Readers/HTML.hs
--- a/test/Tests/Readers/HTML.hs
+++ b/test/Tests/Readers/HTML.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.HTML
-   Copyright   : © 2006-2023 John MacFarlane
+   Copyright   : © 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/test/Tests/Readers/Jira.hs b/test/Tests/Readers/Jira.hs
--- a/test/Tests/Readers/Jira.hs
+++ b/test/Tests/Readers/Jira.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 {- |
    Module      : Tests.Readers.Jira
-   Copyright   : © 2019-2023 Albert Krewinel
+   Copyright   : © 2019-2024 Albert Krewinel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <tarleb@zeitkraut.de>
diff --git a/test/Tests/Readers/LaTeX.hs b/test/Tests/Readers/LaTeX.hs
--- a/test/Tests/Readers/LaTeX.hs
+++ b/test/Tests/Readers/LaTeX.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.LaTeX
-   Copyright   : © 2006-2023 John MacFarlane
+   Copyright   : © 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/test/Tests/Readers/Man.hs b/test/Tests/Readers/Man.hs
--- a/test/Tests/Readers/Man.hs
+++ b/test/Tests/Readers/Man.hs
@@ -2,7 +2,7 @@
 {- |
    Module      : Tests.Readers.Man
    Copyright   : © 2018-2019 Yan Pas <yanp.bugz@gmail.com>,
-                   2018-2023 John MacFarlane
+                   2018-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/test/Tests/Readers/Markdown.hs b/test/Tests/Readers/Markdown.hs
--- a/test/Tests/Readers/Markdown.hs
+++ b/test/Tests/Readers/Markdown.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Markdown
-   Copyright   : © 2006-2023 John MacFarlane
+   Copyright   : © 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
@@ -449,7 +449,7 @@
                   <>
                   codeBlockWith ("",["haskell"],[]) "b"
                   <>
-                  rawBlock "html" "<div>\n\n"
+                  divWith ("",[],[]) mempty
           ]
 -- the round-trip properties frequently fail
 --        , testGroup "round trip"
diff --git a/test/Tests/Readers/ODT.hs b/test/Tests/Readers/ODT.hs
--- a/test/Tests/Readers/ODT.hs
+++ b/test/Tests/Readers/ODT.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.ODT
-   Copyright   : © 2015-2023 John MacFarlane
+   Copyright   : © 2015-2024 John MacFarlane
                    2015 Martin Linnemann
    License     : GNU GPL, version 2 or above
 
diff --git a/test/Tests/Readers/Org.hs b/test/Tests/Readers/Org.hs
--- a/test/Tests/Readers/Org.hs
+++ b/test/Tests/Readers/Org.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Shared
-   Copyright   : © 2014-2023 Albert Krewinkel
+   Copyright   : © 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/test/Tests/Readers/Org/Block.hs b/test/Tests/Readers/Org/Block.hs
--- a/test/Tests/Readers/Org/Block.hs
+++ b/test/Tests/Readers/Org/Block.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Org.Block
-   Copyright   : © 2014-2023 Albert Krewinkel
+   Copyright   : © 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/test/Tests/Readers/Org/Block/CodeBlock.hs b/test/Tests/Readers/Org/Block/CodeBlock.hs
--- a/test/Tests/Readers/Org/Block/CodeBlock.hs
+++ b/test/Tests/Readers/Org/Block/CodeBlock.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Org.Block.CodeBlock
-   Copyright   : © 2014-2023 Albert Krewinkel
+   Copyright   : © 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/test/Tests/Readers/Org/Block/Figure.hs b/test/Tests/Readers/Org/Block/Figure.hs
--- a/test/Tests/Readers/Org/Block/Figure.hs
+++ b/test/Tests/Readers/Org/Block/Figure.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Org.Block.Figure
-   Copyright   : © 2014-2023 Albert Krewinkel
+   Copyright   : © 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/test/Tests/Readers/Org/Block/Header.hs b/test/Tests/Readers/Org/Block/Header.hs
--- a/test/Tests/Readers/Org/Block/Header.hs
+++ b/test/Tests/Readers/Org/Block/Header.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Org.Block.Header
-   Copyright   : © 2014-2023 Albert Krewinkel
+   Copyright   : © 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/test/Tests/Readers/Org/Block/List.hs b/test/Tests/Readers/Org/Block/List.hs
--- a/test/Tests/Readers/Org/Block/List.hs
+++ b/test/Tests/Readers/Org/Block/List.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Org.Block.Header
-   Copyright   : © 2014-2023 Albert Krewinkel
+   Copyright   : © 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/test/Tests/Readers/Org/Block/Table.hs b/test/Tests/Readers/Org/Block/Table.hs
--- a/test/Tests/Readers/Org/Block/Table.hs
+++ b/test/Tests/Readers/Org/Block/Table.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Org.Block.Table
-   Copyright   : © 2014-2023 Albert Krewinkel
+   Copyright   : © 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/test/Tests/Readers/Org/Directive.hs b/test/Tests/Readers/Org/Directive.hs
--- a/test/Tests/Readers/Org/Directive.hs
+++ b/test/Tests/Readers/Org/Directive.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Org.Directive
-   Copyright   : © 2014-2023 Albert Krewinkel
+   Copyright   : © 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/test/Tests/Readers/Org/Inline.hs b/test/Tests/Readers/Org/Inline.hs
--- a/test/Tests/Readers/Org/Inline.hs
+++ b/test/Tests/Readers/Org/Inline.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Org.Inline
-   Copyright   : © 2014-2023 Albert Krewinkel
+   Copyright   : © 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/test/Tests/Readers/Org/Inline/Citation.hs b/test/Tests/Readers/Org/Inline/Citation.hs
--- a/test/Tests/Readers/Org/Inline/Citation.hs
+++ b/test/Tests/Readers/Org/Inline/Citation.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Org.Inline.Citation
-   Copyright   : © 2014-2023 Albert Krewinkel
+   Copyright   : © 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/test/Tests/Readers/Org/Inline/Note.hs b/test/Tests/Readers/Org/Inline/Note.hs
--- a/test/Tests/Readers/Org/Inline/Note.hs
+++ b/test/Tests/Readers/Org/Inline/Note.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Org.Inline.Note
-   Copyright   : © 2014-2023 Albert Krewinkel
+   Copyright   : © 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/test/Tests/Readers/Org/Inline/Smart.hs b/test/Tests/Readers/Org/Inline/Smart.hs
--- a/test/Tests/Readers/Org/Inline/Smart.hs
+++ b/test/Tests/Readers/Org/Inline/Smart.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Org.Inline.Smart
-   Copyright   : © 2014-2023 Albert Krewinkel
+   Copyright   : © 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/test/Tests/Readers/Org/Meta.hs b/test/Tests/Readers/Org/Meta.hs
--- a/test/Tests/Readers/Org/Meta.hs
+++ b/test/Tests/Readers/Org/Meta.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Org.Meta
-   Copyright   : © 2014-2023 Albert Krewinkel
+   Copyright   : © 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/test/Tests/Readers/Org/Shared.hs b/test/Tests/Readers/Org/Shared.hs
--- a/test/Tests/Readers/Org/Shared.hs
+++ b/test/Tests/Readers/Org/Shared.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Org.Shared
-   Copyright   : © 2014-2023 Albert Krewinkel
+   Copyright   : © 2014-2024 Albert Krewinkel
    License     : GNU GPL, version 2 or above
 
    Maintainer  : Albert Krewinkel <albert@zeitkraut.de>
diff --git a/test/Tests/Readers/RST.hs b/test/Tests/Readers/RST.hs
--- a/test/Tests/Readers/RST.hs
+++ b/test/Tests/Readers/RST.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 {- |
    Module      : Tests.Readers.RST
-   Copyright   : © 2006-2023 John MacFarlane
+   Copyright   : © 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/test/Tests/Readers/RTF.hs b/test/Tests/Readers/RTF.hs
--- a/test/Tests/Readers/RTF.hs
+++ b/test/Tests/Readers/RTF.hs
@@ -1,6 +1,6 @@
 {- |
    Module      : Tests.Readers.RTF
-   Copyright   : © 2021-2023 John MacFarlane
+   Copyright   : © 2021-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : jgm@berkeley.edu
diff --git a/test/Tests/Readers/Txt2Tags.hs b/test/Tests/Readers/Txt2Tags.hs
--- a/test/Tests/Readers/Txt2Tags.hs
+++ b/test/Tests/Readers/Txt2Tags.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Readers.Txt2Tags
-   Copyright   : © 2014-2023 John MacFarlane,
+   Copyright   : © 2014-2024 John MacFarlane,
                  © 2014 Matthew Pickering
    License     : GNU GPL, version 2 or above
 
diff --git a/test/Tests/Shared.hs b/test/Tests/Shared.hs
--- a/test/Tests/Shared.hs
+++ b/test/Tests/Shared.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Tests.Shared
-   Copyright   : © 2006-2023 John MacFarlane
+   Copyright   : © 2006-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley@edu>
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
@@ -41,7 +41,7 @@
 tests :: [TestTree]
 tests = [ "indented code after list"
              =: (orderedList [ para "one" <> para "two" ] <> codeBlock "test")
-             =?> "1.  one\n\n    two\n\n```{=html}\n<!-- -->\n```\n    test"
+             =?> "1.  one\n\n    two\n\n<!-- -->\n\n    test"
         , "list with tight sublist"
              =: bulletList [ plain "foo" <> bulletList [ plain "bar" ],
                              plain "baz" ]
diff --git a/test/command/3734.md b/test/command/3734.md
--- a/test/command/3734.md
+++ b/test/command/3734.md
@@ -4,9 +4,9 @@
 |--------------|-------|--------------------------------------------------------------------------|
 | aaaaaaaaaaaa |       | cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
 ^D
-| aaaaaaaaaaaa | bbbbb | ccccccccccc                                                              |
+| aaaaaaaaaaaa | bbbbb | ccccccccccc |
 |------------|-------|------------------------------------------------------|
-| aaaaaaaaaaaa |       | cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
+| aaaaaaaaaaaa |  | cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
 ```
 
 ```
@@ -15,9 +15,9 @@
 |--------------|-------|--------------------------------------------------------------------------|
 | aaaaaaaaaaaa |       | cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
 ^D
-| aaaaaaaaaaaa | bbbbb | ccccccccccc                                                              |
+| aaaaaaaaaaaa | bbbbb | ccccccccccc |
 |------------|-------|------------------------------------------------------|
-| aaaaaaaaaaaa |       | cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
+| aaaaaaaaaaaa |  | cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
 ```
 
 ```
@@ -26,7 +26,7 @@
 |--------------|-------|--------------------------------------------------------------------------|
 | aaaaaaaaaaaa |       | cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
 ^D
-| aaaaaaaaaaaa | bbbbb | ccccccccccc                                                              |
-|--------------|-------|--------------------------------------------------------------------------|
-| aaaaaaaaaaaa |       | cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
+| aaaaaaaaaaaa | bbbbb | ccccccccccc |
+|----|----|----|
+| aaaaaaaaaaaa |  | cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
 ```
diff --git a/test/command/6384.md b/test/command/6384.md
--- a/test/command/6384.md
+++ b/test/command/6384.md
@@ -1,16 +1,12 @@
 ```
 % pandoc --wrap=preserve --file-scope command/file1.txt command/file2.txt
 ^D
-<div id="command__file1.txt">
 <h1 id="command__file1.txt__zed">Zed</h1>
 <p><a href="bar">foo</a>
 and <a href="#command__file1.txt__zed">Zed</a>
 and <a href="#command__file2.txt__zed">other Zed</a>
 and <a href="#command__file2.txt">other file</a>
 and <a href="c.md#zed">foreign Zed</a></p>
-</div>
-<div id="command__file2.txt">
 <h2 id="command__file2.txt__zed">Zed</h2>
 <p><a href="baz">foo</a></p>
-</div>
 ```
diff --git a/test/command/7473.md b/test/command/7473.md
new file mode 100644
--- /dev/null
+++ b/test/command/7473.md
@@ -0,0 +1,32 @@
+```
+% pandoc -f rst -t native
+.. figure:: example.png
+   :figclass: foo bar
+   :align: right
+   :width: 1in
+
+   This is a caption.
+^D
+[ Figure
+    ( "" , [ "foo" , "bar" , "align-right" ] , [] )
+    (Caption
+       Nothing
+       [ Plain
+           [ Str "This"
+           , Space
+           , Str "is"
+           , Space
+           , Str "a"
+           , Space
+           , Str "caption."
+           ]
+       ])
+    [ Plain
+        [ Image
+            ( "" , [] , [ ( "width" , "1in" ) ] )
+            [ Str "example.png" ]
+            ( "example.png" , "" )
+        ]
+    ]
+]
+```
diff --git a/test/command/7847.md b/test/command/7847.md
--- a/test/command/7847.md
+++ b/test/command/7847.md
@@ -23,9 +23,9 @@
 </tbody>
 </table>
 ^D
-| aaa                                                                                                         | bbb | ccc |
+| aaa | bbb | ccc |
 |---------------|------------------------------------------|---------------|
-| Consequat nisi sit amet nibh. Nunc mi tortor, tristique sit amet, rhoncus porta, malesuada elementum, nisi. |     | ccc |
+| Consequat nisi sit amet nibh. Nunc mi tortor, tristique sit amet, rhoncus porta, malesuada elementum, nisi. |  | ccc |
 
 ```
 
@@ -45,9 +45,9 @@
 </tr>
 </table>
 ^D
-| aaa                                                                                                         | bbb | ccc |
-|-------------------------------------------------------------------------------------------------------------|-----|-----|
-| Consequat nisi sit amet nibh. Nunc mi tortor, tristique sit amet, rhoncus porta, malesuada elementum, nisi. |     | ccc |
+| aaa | bbb | ccc |
+|----|----|----|
+| Consequat nisi sit amet nibh. Nunc mi tortor, tristique sit amet, rhoncus porta, malesuada elementum, nisi. |  | ccc |
 
 ```
 
@@ -76,8 +76,8 @@
 </tbody>
 </table>
 ^D
-| aaa                                                                                                         | bbb | ccc |
-|-------------------------------------------------------------------------------------------------------------|-----|-----|
+| aaa | bbb | ccc |
+|----|----|----|
 | Consequat nisi sit amet nibh. Nunc mi tortor, tristique sit amet, rhoncus porta, malesuada elementum, nisi. | bbb | ccc |
 
 ```
diff --git a/test/command/9346.md b/test/command/9346.md
--- a/test/command/9346.md
+++ b/test/command/9346.md
@@ -3,6 +3,6 @@
 |V1 |V2 |V3 |V4 |V5 |V6 |V7 |V8 |V9 |V10 |V11 |V12 |V13 |V14 |V15 |V16 |V17 |V18 |V19 |V20 |V21 |V22 |V23 |V24 |V25 |V26 |V27 |V28 |V29 |V30 |V31 |V32 |V33 |V34 |V35 |V36 |V37 |V38 |V39 |V40 |V41 |V42 |V43 |V44 |V45 |V46 |V47 |V48 |V49 |V50 |V51 |V52 |V53 |V54 |V55 |V56 |V57 |V58 |V59 |V60 |V61 |V62 |V63 |V64 |V65 |V66 |V67 |V68 |V69 |V70 |V71 |V72 |
 |:--|:--|:--|:--|:--|:--|:--|:--|:--|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|
 ^D
-| V1  | V2  | V3  | V4  | V5  | V6  | V7  | V8  | V9  | V10 | V11 | V12 | V13 | V14 | V15 | V16 | V17 | V18 | V19 | V20 | V21 | V22 | V23 | V24 | V25 | V26 | V27 | V28 | V29 | V30 | V31 | V32 | V33 | V34 | V35 | V36 | V37 | V38 | V39 | V40 | V41 | V42 | V43 | V44 | V45 | V46 | V47 | V48 | V49 | V50 | V51 | V52 | V53 | V54 | V55 | V56 | V57 | V58 | V59 | V60 | V61 | V62 | V63 | V64 | V65 | V66 | V67 | V68 | V69 | V70 | V71 | V72 |
+| V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9 | V10 | V11 | V12 | V13 | V14 | V15 | V16 | V17 | V18 | V19 | V20 | V21 | V22 | V23 | V24 | V25 | V26 | V27 | V28 | V29 | V30 | V31 | V32 | V33 | V34 | V35 | V36 | V37 | V38 | V39 | V40 | V41 | V42 | V43 | V44 | V45 | V46 | V47 | V48 | V49 | V50 | V51 | V52 | V53 | V54 | V55 | V56 | V57 | V58 | V59 | V60 | V61 | V62 | V63 | V64 | V65 | V66 | V67 | V68 | V69 | V70 | V71 | V72 |
 |:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|
 ```
diff --git a/test/command/9635.md b/test/command/9635.md
new file mode 100644
--- /dev/null
+++ b/test/command/9635.md
@@ -0,0 +1,16 @@
+```
+% pandoc
+> ::: {.fence}
+> that is
+> not closed
+
+okay
+^D
+2> [WARNING] Div at _chunk line 1 column 1 unclosed at _chunk line 5 column 1, closing implicitly.
+<blockquote>
+<div class="fence">
+<p>that is not closed</p>
+</div>
+</blockquote>
+<p>okay</p>
+```
diff --git a/test/command/9644.md b/test/command/9644.md
new file mode 100644
--- /dev/null
+++ b/test/command/9644.md
@@ -0,0 +1,7 @@
+```
+% pandoc -t latex
+[$T$]{.underline}
+[$T$]{.mark}
+^D
+\ul{$T$} \hl{$T$}
+```
diff --git a/test/command/9652.md b/test/command/9652.md
new file mode 100644
--- /dev/null
+++ b/test/command/9652.md
@@ -0,0 +1,9 @@
+````
+% pandoc -f markdown -t html --embed-resources
+```{=html}
+<img class="something" src="command/9652.svg" />
+```
+^D
+<svg id="svg_b627f92299158b36552b" role="img" width="504.00pt" height="360.00pt" viewBox="0 0 504.00 360.00" class="something please-do-not-delete-me">
+</svg>
+````
diff --git a/test/command/9652.svg b/test/command/9652.svg
new file mode 100644
--- /dev/null
+++ b/test/command/9652.svg
@@ -0,0 +1,3 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' class='please-do-not-delete-me' width='504.00pt' height='360.00pt' viewBox='0 0 504.00 360.00'>
+</svg>
diff --git a/test/command/9657.md b/test/command/9657.md
new file mode 100644
--- /dev/null
+++ b/test/command/9657.md
@@ -0,0 +1,7 @@
+```
+% pandoc -t opendocument
+[Text here]{custom-style="Strikethrough"}
+^D
+<text:p text:style-name="Text_20_body"><text:span text:style-name="Strikethrough">Text
+here</text:span></text:p>
+```
diff --git a/test/command/9676.md b/test/command/9676.md
new file mode 100644
--- /dev/null
+++ b/test/command/9676.md
@@ -0,0 +1,9 @@
+```
+% pandoc -f latex
+\def\foo{BAR}
+\foo
+\ifstrequal{BAR}{BAR}{\def\foo{BAZ}}{}
+\foo
+^D
+<p>BAR BAZ</p>
+```
diff --git a/test/command/typst-property-output.md b/test/command/typst-property-output.md
new file mode 100644
--- /dev/null
+++ b/test/command/typst-property-output.md
@@ -0,0 +1,154 @@
+```
+% pandoc -f html -t typst
+<span typst:text:fill="orange">foo</span>
+^D
+#text(fill: orange)[foo]
+```
+
+```
+% pandoc -f html -t typst
+<span>foo</span>
+^D
+foo
+```
+
+```
+% pandoc -f html -t typst
+<div typst:inset="10pt">foo</div>
+^D
+#block(inset: 10pt)[
+foo
+]
+```
+
+```
+% pandoc -f html -t typst
+<div typst:text:fill="purple">foo</div>
+^D
+#block[
+#set text(fill: purple); foo
+]
+```
+
+```
+% pandoc -f html -t typst
+<div>foo</div>
+^D
+#block[
+foo
+]
+```
+
+```
+% pandoc -f html -t typst
+<table typst:fill="blue">
+  <tr><td>A</td><td>B</td></tr>
+</table>
+^D
+#figure(
+  align(center)[#table(
+    columns: 2,
+    align: (auto,auto,),
+    fill: blue,
+    [A], [B],
+  )]
+  , kind: table
+  )
+```
+
+```
+% pandoc -f html -t typst
+<table typst:text:fill="orange">
+  <tr><td>A</td><td>B</td></tr>
+</table>
+^D
+#figure(
+  align(center)[#set text(fill: orange); #table(
+    columns: 2,
+    align: (auto,auto,),
+    [A], [B],
+  )]
+  , kind: table
+  )
+```
+
+```
+% pandoc -f html -t typst
+<table>
+  <tr><td>A</td><td typst:fill="green">B</td></tr>
+</table>
+^D
+#figure(
+  align(center)[#table(
+    columns: 2,
+    align: (auto,auto,),
+    [A], table.cell(fill: green)[B],
+  )]
+  , kind: table
+  )
+```
+
+```
+% pandoc -f html -t typst
+<table>
+  <tr><td>A</td><td typst:text:fill="fuchsia">B</td></tr>
+</table>
+^D
+#figure(
+  align(center)[#table(
+    columns: 2,
+    align: (auto,auto,),
+    [A], [#set text(fill: fuchsia); B],
+  )]
+  , kind: table
+  )
+```
+
+```
+% pandoc -f html -t typst
+<table>
+  <tr><td>A</td><td typst:text:fill="maroon" align="center">B</td></tr>
+</table>
+^D
+#figure(
+  align(center)[#table(
+    columns: 2,
+    align: (auto,center,),
+    [A], table.cell(align: center)[#set text(fill: maroon); B],
+  )]
+  , kind: table
+  )
+```
+
+```
+% pandoc -f html -t typst
+<table>
+  <tr><td>A</td><td typst:align="horizon" align="center">B</td></tr>
+</table>
+^D
+#figure(
+  align(center)[#table(
+    columns: 2,
+    align: (auto,center,),
+    [A], table.cell(align: horizon + center)[B],
+  )]
+  , kind: table
+  )
+```
+
+
+```
+% pandoc -f html -t typst
+<table>
+  <tr><td>A</td><td>B</td></tr>
+</table>
+^D
+#figure(
+  align(center)[#table(
+    columns: 2,
+    align: (auto,auto,),
+    [A], [B],
+  )]
+  , kind: table
+  )
+```
diff --git a/test/docx/anchor_header_after_anchor.docx b/test/docx/anchor_header_after_anchor.docx
new file mode 100644
Binary files /dev/null and b/test/docx/anchor_header_after_anchor.docx differ
diff --git a/test/docx/anchor_header_after_anchor.native b/test/docx/anchor_header_after_anchor.native
new file mode 100644
--- /dev/null
+++ b/test/docx/anchor_header_after_anchor.native
@@ -0,0 +1,6 @@
+[Para [Link ("",[],[]) [Str "A",Space,Str "link",Space,Str "to",Space,Str "the",Space,Str "bookmark"] ("#referenced-title" , "")]
+,Para [Strong [Str "Accomplices:"]]
+,Para [Str "There",Space,Str "are",Space,Str "bookmarks",Space,Str "around",Space,Str "here."]
+,Para []
+,Header 1 ("referenced-title",[],[]) [Str "Referenced" ,Space ,Str "title"]
+,Para [Str "Content"]]
diff --git a/test/docx/golden/block_quotes.docx b/test/docx/golden/block_quotes.docx
Binary files a/test/docx/golden/block_quotes.docx and b/test/docx/golden/block_quotes.docx differ
diff --git a/test/docx/golden/codeblock.docx b/test/docx/golden/codeblock.docx
Binary files a/test/docx/golden/codeblock.docx and b/test/docx/golden/codeblock.docx differ
diff --git a/test/docx/golden/comments.docx b/test/docx/golden/comments.docx
Binary files a/test/docx/golden/comments.docx and b/test/docx/golden/comments.docx differ
diff --git a/test/docx/golden/custom_style_no_reference.docx b/test/docx/golden/custom_style_no_reference.docx
Binary files a/test/docx/golden/custom_style_no_reference.docx and b/test/docx/golden/custom_style_no_reference.docx differ
diff --git a/test/docx/golden/custom_style_preserve.docx b/test/docx/golden/custom_style_preserve.docx
Binary files a/test/docx/golden/custom_style_preserve.docx and b/test/docx/golden/custom_style_preserve.docx differ
diff --git a/test/docx/golden/custom_style_reference.docx b/test/docx/golden/custom_style_reference.docx
Binary files a/test/docx/golden/custom_style_reference.docx and b/test/docx/golden/custom_style_reference.docx differ
diff --git a/test/docx/golden/definition_list.docx b/test/docx/golden/definition_list.docx
Binary files a/test/docx/golden/definition_list.docx and b/test/docx/golden/definition_list.docx differ
diff --git a/test/docx/golden/document-properties-short-desc.docx b/test/docx/golden/document-properties-short-desc.docx
Binary files a/test/docx/golden/document-properties-short-desc.docx and b/test/docx/golden/document-properties-short-desc.docx differ
diff --git a/test/docx/golden/document-properties.docx b/test/docx/golden/document-properties.docx
Binary files a/test/docx/golden/document-properties.docx and b/test/docx/golden/document-properties.docx differ
diff --git a/test/docx/golden/headers.docx b/test/docx/golden/headers.docx
Binary files a/test/docx/golden/headers.docx and b/test/docx/golden/headers.docx differ
diff --git a/test/docx/golden/image.docx b/test/docx/golden/image.docx
Binary files a/test/docx/golden/image.docx and b/test/docx/golden/image.docx differ
diff --git a/test/docx/golden/inline_code.docx b/test/docx/golden/inline_code.docx
Binary files a/test/docx/golden/inline_code.docx and b/test/docx/golden/inline_code.docx differ
diff --git a/test/docx/golden/inline_formatting.docx b/test/docx/golden/inline_formatting.docx
Binary files a/test/docx/golden/inline_formatting.docx and b/test/docx/golden/inline_formatting.docx differ
diff --git a/test/docx/golden/inline_images.docx b/test/docx/golden/inline_images.docx
Binary files a/test/docx/golden/inline_images.docx and b/test/docx/golden/inline_images.docx differ
diff --git a/test/docx/golden/link_in_notes.docx b/test/docx/golden/link_in_notes.docx
Binary files a/test/docx/golden/link_in_notes.docx and b/test/docx/golden/link_in_notes.docx differ
diff --git a/test/docx/golden/links.docx b/test/docx/golden/links.docx
Binary files a/test/docx/golden/links.docx and b/test/docx/golden/links.docx differ
diff --git a/test/docx/golden/lists.docx b/test/docx/golden/lists.docx
Binary files a/test/docx/golden/lists.docx and b/test/docx/golden/lists.docx differ
diff --git a/test/docx/golden/lists_continuing.docx b/test/docx/golden/lists_continuing.docx
Binary files a/test/docx/golden/lists_continuing.docx and b/test/docx/golden/lists_continuing.docx differ
diff --git a/test/docx/golden/lists_div_bullets.docx b/test/docx/golden/lists_div_bullets.docx
Binary files a/test/docx/golden/lists_div_bullets.docx and b/test/docx/golden/lists_div_bullets.docx differ
diff --git a/test/docx/golden/lists_multiple_initial.docx b/test/docx/golden/lists_multiple_initial.docx
Binary files a/test/docx/golden/lists_multiple_initial.docx and b/test/docx/golden/lists_multiple_initial.docx differ
diff --git a/test/docx/golden/lists_restarting.docx b/test/docx/golden/lists_restarting.docx
Binary files a/test/docx/golden/lists_restarting.docx and b/test/docx/golden/lists_restarting.docx differ
diff --git a/test/docx/golden/nested_anchors_in_header.docx b/test/docx/golden/nested_anchors_in_header.docx
Binary files a/test/docx/golden/nested_anchors_in_header.docx and b/test/docx/golden/nested_anchors_in_header.docx differ
diff --git a/test/docx/golden/notes.docx b/test/docx/golden/notes.docx
Binary files a/test/docx/golden/notes.docx and b/test/docx/golden/notes.docx differ
diff --git a/test/docx/golden/raw-blocks.docx b/test/docx/golden/raw-blocks.docx
Binary files a/test/docx/golden/raw-blocks.docx and b/test/docx/golden/raw-blocks.docx differ
diff --git a/test/docx/golden/raw-bookmarks.docx b/test/docx/golden/raw-bookmarks.docx
Binary files a/test/docx/golden/raw-bookmarks.docx and b/test/docx/golden/raw-bookmarks.docx differ
diff --git a/test/docx/golden/table_one_row.docx b/test/docx/golden/table_one_row.docx
Binary files a/test/docx/golden/table_one_row.docx and b/test/docx/golden/table_one_row.docx differ
diff --git a/test/docx/golden/table_with_list_cell.docx b/test/docx/golden/table_with_list_cell.docx
Binary files a/test/docx/golden/table_with_list_cell.docx and b/test/docx/golden/table_with_list_cell.docx differ
diff --git a/test/docx/golden/tables-default-widths.docx b/test/docx/golden/tables-default-widths.docx
Binary files a/test/docx/golden/tables-default-widths.docx and b/test/docx/golden/tables-default-widths.docx differ
diff --git a/test/docx/golden/tables.docx b/test/docx/golden/tables.docx
Binary files a/test/docx/golden/tables.docx and b/test/docx/golden/tables.docx differ
diff --git a/test/docx/golden/tables_separated_with_rawblock.docx b/test/docx/golden/tables_separated_with_rawblock.docx
Binary files a/test/docx/golden/tables_separated_with_rawblock.docx and b/test/docx/golden/tables_separated_with_rawblock.docx differ
diff --git a/test/docx/golden/track_changes_deletion.docx b/test/docx/golden/track_changes_deletion.docx
Binary files a/test/docx/golden/track_changes_deletion.docx and b/test/docx/golden/track_changes_deletion.docx differ
diff --git a/test/docx/golden/track_changes_insertion.docx b/test/docx/golden/track_changes_insertion.docx
Binary files a/test/docx/golden/track_changes_insertion.docx and b/test/docx/golden/track_changes_insertion.docx differ
diff --git a/test/docx/golden/track_changes_move.docx b/test/docx/golden/track_changes_move.docx
Binary files a/test/docx/golden/track_changes_move.docx and b/test/docx/golden/track_changes_move.docx differ
diff --git a/test/docx/golden/track_changes_scrubbed_metadata.docx b/test/docx/golden/track_changes_scrubbed_metadata.docx
Binary files a/test/docx/golden/track_changes_scrubbed_metadata.docx and b/test/docx/golden/track_changes_scrubbed_metadata.docx differ
diff --git a/test/docx/golden/unicode.docx b/test/docx/golden/unicode.docx
Binary files a/test/docx/golden/unicode.docx and b/test/docx/golden/unicode.docx differ
diff --git a/test/docx/golden/verbatim_subsuper.docx b/test/docx/golden/verbatim_subsuper.docx
Binary files a/test/docx/golden/verbatim_subsuper.docx and b/test/docx/golden/verbatim_subsuper.docx differ
diff --git a/test/jats-reader.xml b/test/jats-reader.xml
--- a/test/jats-reader.xml
+++ b/test/jats-reader.xml
@@ -84,7 +84,7 @@
 <sec id="statements">
   <title> Statements </title>
   <statement>
-    <label> A label for a statment</label>
+    <label> A label for a statement</label>
     <title> CAP TITLE </title>
     <p> Some text to make this regular </p>
   </statement>
diff --git a/test/tables.markua b/test/tables.markua
--- a/test/tables.markua
+++ b/test/tables.markua
@@ -28,19 +28,19 @@
 
 Multiline table with caption:
 
-| Centered Header | Left Aligned | Right Aligned | Default aligned                                       |
-|:---------------:|:-------------|--------------:|:------------------------------------------------------|
-|      First      | row          |          12.0 | Example of a row that spans multiple lines.           |
-|     Second      | row          |           5.0 | Here’s another one. Note the blank line between rows. |
+| Centered Header | Left Aligned | Right Aligned | Default aligned |
+|:--:|:---|---:|:---|
+| First | row | 12.0 | Example of a row that spans multiple lines. |
+| Second | row | 5.0 | Here’s another one. Note the blank line between rows. |
 
 Here’s the caption. It may span multiple lines.
 
 Multiline table without caption:
 
-| Centered Header | Left Aligned | Right Aligned | Default aligned                                       |
-|:---------------:|:-------------|--------------:|:------------------------------------------------------|
-|      First      | row          |          12.0 | Example of a row that spans multiple lines.           |
-|     Second      | row          |           5.0 | Here’s another one. Note the blank line between rows. |
+| Centered Header | Left Aligned | Right Aligned | Default aligned |
+|:--:|:---|---:|:---|
+| First | row | 12.0 | Example of a row that spans multiple lines. |
+| Second | row | 5.0 | Here’s another one. Note the blank line between rows. |
 
 Table without column headers:
 
diff --git a/test/writer.markdown b/test/writer.markdown
--- a/test/writer.markdown
+++ b/test/writer.markdown
@@ -383,35 +383,18 @@
 
 Interpreted markdown in a table:
 
-```{=html}
 <table>
-```
-```{=html}
 <tr>
-```
-```{=html}
 <td>
-```
 This is *emphasized*
-```{=html}
 </td>
-```
-```{=html}
 <td>
-```
 And this is **strong**
-```{=html}
 </td>
-```
-```{=html}
 </tr>
-```
-```{=html}
 </table>
-```
-```{=html}
 <script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
-```
+
 Here's a simple block:
 
 <div>
@@ -448,64 +431,41 @@
 
 This should just be an HTML comment:
 
-```{=html}
 <!-- Comment -->
-```
+
 Multiline:
 
-```{=html}
 <!--
 Blah
 Blah
 -->
-```
-```{=html}
 <!--
     This is another comment.
 -->
-```
+
 Code block:
 
     <!-- Comment -->
 
 Just plain comment, with trailing spaces on the line:
 
-```{=html}
 <!-- foo -->
-```
+
 Code:
 
     <hr />
 
 Hr's:
 
-```{=html}
 <hr>
-```
-```{=html}
 <hr />
-```
-```{=html}
 <hr />
-```
-```{=html}
 <hr>
-```
-```{=html}
 <hr />
-```
-```{=html}
 <hr />
-```
-```{=html}
 <hr class="foo" id="bar" />
-```
-```{=html}
 <hr class="foo" id="bar" />
-```
-```{=html}
 <hr class="foo" id="bar">
-```
 
 --------------------------------------------------------------------------------
 
@@ -581,13 +541,11 @@
 
 Here's a LaTeX table:
 
-```{=tex}
 \begin{tabular}{|l|l|}\hline
 Animal & Number \\ \hline
 Dog    & 2      \\
 Cat    & 1      \\ \hline
 \end{tabular}
-```
 
 --------------------------------------------------------------------------------
 
diff --git a/test/writer.opml b/test/writer.opml
--- a/test/writer.opml
+++ b/test/writer.opml
@@ -44,13 +44,13 @@
 </outline>
 <outline text="Definition Lists" _note="Tight using spaces:&#10;&#10;apple&#10;:   red fruit&#10;&#10;orange&#10;:   orange fruit&#10;&#10;banana&#10;:   yellow fruit&#10;&#10;Tight using tabs:&#10;&#10;apple&#10;:   red fruit&#10;&#10;orange&#10;:   orange fruit&#10;&#10;banana&#10;:   yellow fruit&#10;&#10;Loose:&#10;&#10;apple&#10;&#10;:   red fruit&#10;&#10;orange&#10;&#10;:   orange fruit&#10;&#10;banana&#10;&#10;:   yellow fruit&#10;&#10;Multiple blocks with italics:&#10;&#10;*apple*&#10;&#10;:   red fruit&#10;&#10;    contains seeds, crisp, pleasant to taste&#10;&#10;*orange*&#10;&#10;:   orange fruit&#10;&#10;        { orange code block }&#10;&#10;    &gt; orange block quote&#10;&#10;Multiple definitions, tight:&#10;&#10;apple&#10;:   red fruit&#10;:   computer&#10;&#10;orange&#10;:   orange fruit&#10;:   bank&#10;&#10;Multiple definitions, loose:&#10;&#10;apple&#10;&#10;:   red fruit&#10;&#10;:   computer&#10;&#10;orange&#10;&#10;:   orange fruit&#10;&#10;:   bank&#10;&#10;Blank line after term, indented marker, alternate markers:&#10;&#10;apple&#10;&#10;:   red fruit&#10;&#10;:   computer&#10;&#10;orange&#10;&#10;:   orange fruit&#10;&#10;    1.  sublist&#10;    2.  sublist">
 </outline>
-<outline text="HTML Blocks" _note="Simple block on one line:&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;And nested without indentation:&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;bar&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;Interpreted markdown in a table:&#10;&#10;```{=html}&#10;&lt;table&gt;&#10;```&#10;```{=html}&#10;&lt;tr&gt;&#10;```&#10;```{=html}&#10;&lt;td&gt;&#10;```&#10;This is *emphasized*&#10;```{=html}&#10;&lt;/td&gt;&#10;```&#10;```{=html}&#10;&lt;td&gt;&#10;```&#10;And this is **strong**&#10;```{=html}&#10;&lt;/td&gt;&#10;```&#10;```{=html}&#10;&lt;/tr&gt;&#10;```&#10;```{=html}&#10;&lt;/table&gt;&#10;```&#10;```{=html}&#10;&lt;script type=&quot;text/javascript&quot;&gt;document.write('This *should not* be interpreted as markdown');&lt;/script&gt;&#10;```&#10;Here's a simple block:&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;This should be a code block, though:&#10;&#10;    &lt;div&gt;&#10;        foo&#10;    &lt;/div&gt;&#10;&#10;As should this:&#10;&#10;    &lt;div&gt;foo&lt;/div&gt;&#10;&#10;Now, nested:&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;This should just be an HTML comment:&#10;&#10;```{=html}&#10;&lt;!-- Comment --&gt;&#10;```&#10;Multiline:&#10;&#10;```{=html}&#10;&lt;!--&#10;Blah&#10;Blah&#10;--&gt;&#10;```&#10;```{=html}&#10;&lt;!--&#10;    This is another comment.&#10;--&gt;&#10;```&#10;Code block:&#10;&#10;    &lt;!-- Comment --&gt;&#10;&#10;Just plain comment, with trailing spaces on the line:&#10;&#10;```{=html}&#10;&lt;!-- foo --&gt;&#10;```&#10;Code:&#10;&#10;    &lt;hr /&gt;&#10;&#10;Hr's:&#10;&#10;```{=html}&#10;&lt;hr&gt;&#10;```&#10;```{=html}&#10;&lt;hr /&gt;&#10;```&#10;```{=html}&#10;&lt;hr /&gt;&#10;```&#10;```{=html}&#10;&lt;hr&gt;&#10;```&#10;```{=html}&#10;&lt;hr /&gt;&#10;```&#10;```{=html}&#10;&lt;hr /&gt;&#10;```&#10;```{=html}&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;&#10;```&#10;```{=html}&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;&#10;```&#10;```{=html}&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot;&gt;&#10;```&#10;&#10;--------------------------------------------------------------------------------">
+<outline text="HTML Blocks" _note="Simple block on one line:&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;And nested without indentation:&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;bar&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;Interpreted markdown in a table:&#10;&#10;&lt;table&gt;&#10;&lt;tr&gt;&#10;&lt;td&gt;&#10;This is *emphasized*&#10;&lt;/td&gt;&#10;&lt;td&gt;&#10;And this is **strong**&#10;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/table&gt;&#10;&lt;script type=&quot;text/javascript&quot;&gt;document.write('This *should not* be interpreted as markdown');&lt;/script&gt;&#10;&#10;Here's a simple block:&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;This should be a code block, though:&#10;&#10;    &lt;div&gt;&#10;        foo&#10;    &lt;/div&gt;&#10;&#10;As should this:&#10;&#10;    &lt;div&gt;foo&lt;/div&gt;&#10;&#10;Now, nested:&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;&lt;div&gt;&#10;&#10;foo&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;&lt;/div&gt;&#10;&#10;This should just be an HTML comment:&#10;&#10;&lt;!-- Comment --&gt;&#10;&#10;Multiline:&#10;&#10;&lt;!--&#10;Blah&#10;Blah&#10;--&gt;&#10;&lt;!--&#10;    This is another comment.&#10;--&gt;&#10;&#10;Code block:&#10;&#10;    &lt;!-- Comment --&gt;&#10;&#10;Just plain comment, with trailing spaces on the line:&#10;&#10;&lt;!-- foo --&gt;&#10;&#10;Code:&#10;&#10;    &lt;hr /&gt;&#10;&#10;Hr's:&#10;&#10;&lt;hr&gt;&#10;&lt;hr /&gt;&#10;&lt;hr /&gt;&#10;&lt;hr&gt;&#10;&lt;hr /&gt;&#10;&lt;hr /&gt;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot; /&gt;&#10;&lt;hr class=&quot;foo&quot; id=&quot;bar&quot;&gt;&#10;&#10;--------------------------------------------------------------------------------">
 </outline>
 <outline text="Inline Markup" _note="This is *emphasized*, and so *is this*.&#10;&#10;This is **strong**, and so **is this**.&#10;&#10;An *[emphasized link](/url)*.&#10;&#10;***This is strong and em.***&#10;&#10;So is ***this*** word.&#10;&#10;***This is strong and em.***&#10;&#10;So is ***this*** word.&#10;&#10;This is code: `&gt;`, `$`, `\`, `\$`, `&lt;html&gt;`.&#10;&#10;~~This is *strikeout*.~~&#10;&#10;Superscripts: a^bc^d a^*hello*^ a^hello there^.&#10;&#10;Subscripts: H~2~O, H~23~O, H~many of them~O.&#10;&#10;These should not be superscripts or subscripts, because of the unescaped spaces:&#10;a\^b c\^d, a\~b c\~d.&#10;&#10;--------------------------------------------------------------------------------">
 </outline>
 <outline text="Smart quotes, ellipses, dashes" _note="&quot;Hello,&quot; said the spider. &quot;'Shelob' is my name.&quot;&#10;&#10;'A', 'B', and 'C' are letters.&#10;&#10;'Oak,' 'elm,' and 'beech' are names of trees. So is 'pine.'&#10;&#10;'He said, &quot;I want to go.&quot;' Were you alive in the 70's?&#10;&#10;Here is some quoted '`code`' and a &quot;[quoted&#10;link](http://example.com/?foo=1&amp;bar=2)&quot;.&#10;&#10;Some dashes: one---two --- three---four --- five.&#10;&#10;Dashes between numbers: 5--7, 255--66, 1987--1999.&#10;&#10;Ellipses...and...and....&#10;&#10;--------------------------------------------------------------------------------">
 </outline>
-<outline text="LaTeX" _note="-   `\cite[22-23]{smith.1899}`{=tex}&#10;-   $2+2=4$&#10;-   $x \in y$&#10;-   $\alpha \wedge \omega$&#10;-   $223$&#10;-   $p$-Tree&#10;-   Here's some display math:&#10;    $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$&#10;-   Here's one that has a line break in it: $\alpha + \omega \times x^2$.&#10;&#10;These shouldn't be math:&#10;&#10;-   To get the famous equation, write `$e = mc^2$`.&#10;-   \$22,000 is a *lot* of money. So is \$34,000. (It worked if &quot;lot&quot; is&#10;    emphasized.)&#10;-   Shoes (\$20) and socks (\$5).&#10;-   Escaped `$`: \$73 *this should be emphasized* 23\$.&#10;&#10;Here's a LaTeX table:&#10;&#10;```{=tex}&#10;\begin{tabular}{|l|l|}\hline&#10;Animal &amp; Number \\ \hline&#10;Dog    &amp; 2      \\&#10;Cat    &amp; 1      \\ \hline&#10;\end{tabular}&#10;```&#10;&#10;--------------------------------------------------------------------------------">
+<outline text="LaTeX" _note="-   `\cite[22-23]{smith.1899}`{=tex}&#10;-   $2+2=4$&#10;-   $x \in y$&#10;-   $\alpha \wedge \omega$&#10;-   $223$&#10;-   $p$-Tree&#10;-   Here's some display math:&#10;    $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$&#10;-   Here's one that has a line break in it: $\alpha + \omega \times x^2$.&#10;&#10;These shouldn't be math:&#10;&#10;-   To get the famous equation, write `$e = mc^2$`.&#10;-   \$22,000 is a *lot* of money. So is \$34,000. (It worked if &quot;lot&quot; is&#10;    emphasized.)&#10;-   Shoes (\$20) and socks (\$5).&#10;-   Escaped `$`: \$73 *this should be emphasized* 23\$.&#10;&#10;Here's a LaTeX table:&#10;&#10;\begin{tabular}{|l|l|}\hline&#10;Animal &amp; Number \\ \hline&#10;Dog    &amp; 2      \\&#10;Cat    &amp; 1      \\ \hline&#10;\end{tabular}&#10;&#10;--------------------------------------------------------------------------------">
 </outline>
 <outline text="Special Characters" _note="Here is some unicode:&#10;&#10;-   I hat: Î&#10;-   o umlaut: ö&#10;-   section: §&#10;-   set membership: ∈&#10;-   copyright: ©&#10;&#10;AT&amp;T has an ampersand in their name.&#10;&#10;AT&amp;T is another way to write it.&#10;&#10;This &amp; that.&#10;&#10;4 \&lt; 5.&#10;&#10;6 \&gt; 5.&#10;&#10;Backslash: \\&#10;&#10;Backtick: \`&#10;&#10;Asterisk: \*&#10;&#10;Underscore: \_&#10;&#10;Left brace: {&#10;&#10;Right brace: }&#10;&#10;Left bracket: \[&#10;&#10;Right bracket: \]&#10;&#10;Left paren: (&#10;&#10;Right paren: )&#10;&#10;Greater-than: \&gt;&#10;&#10;Hash: \#&#10;&#10;Period: .&#10;&#10;Bang: !&#10;&#10;Plus: +&#10;&#10;Minus: -&#10;&#10;--------------------------------------------------------------------------------">
 </outline>
diff --git a/test/writer.typst b/test/writer.typst
--- a/test/writer.typst
+++ b/test/writer.typst
@@ -462,11 +462,13 @@
 
 / apple: #block[
 red fruit
+
 computer
 ]
 
 / orange: #block[
 orange fruit
+
 bank
 ]
 
diff --git a/xml-light/Text/Pandoc/XML/Light.hs b/xml-light/Text/Pandoc/XML/Light.hs
--- a/xml-light/Text/Pandoc/XML/Light.hs
+++ b/xml-light/Text/Pandoc/XML/Light.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.XML.Light
-   Copyright   : Copyright (C) 2021-2023 John MacFarlane
+   Copyright   : Copyright (C) 2021-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/xml-light/Text/Pandoc/XML/Light/Output.hs b/xml-light/Text/Pandoc/XML/Light/Output.hs
--- a/xml-light/Text/Pandoc/XML/Light/Output.hs
+++ b/xml-light/Text/Pandoc/XML/Light/Output.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE OverloadedStrings #-}
 {- |
    Module      : Text.Pandoc.XML.Light.Output
-   Copyright   : Copyright (C) 2007 Galois, Inc., 2021-2023 John MacFarlane
+   Copyright   : Copyright (C) 2007 Galois, Inc., 2021-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
 
diff --git a/xml-light/Text/Pandoc/XML/Light/Proc.hs b/xml-light/Text/Pandoc/XML/Light/Proc.hs
--- a/xml-light/Text/Pandoc/XML/Light/Proc.hs
+++ b/xml-light/Text/Pandoc/XML/Light/Proc.hs
@@ -1,7 +1,7 @@
 {-# LANGUAGE FlexibleInstances #-}
 {- |
    Module      : Text.Pandoc.XML.Light.Proc
-   Copyright   : Copyright (C) 2007 Galois, Inc., 2021-2023 John MacFarlane
+   Copyright   : Copyright (C) 2007 Galois, Inc., 2021-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
diff --git a/xml-light/Text/Pandoc/XML/Light/Types.hs b/xml-light/Text/Pandoc/XML/Light/Types.hs
--- a/xml-light/Text/Pandoc/XML/Light/Types.hs
+++ b/xml-light/Text/Pandoc/XML/Light/Types.hs
@@ -2,7 +2,7 @@
 {-# LANGUAGE DeriveDataTypeable #-}
 {- |
    Module      : Text.Pandoc.XML.Light.Types
-   Copyright   : Copyright (C) 2007 Galois, Inc., 2021-2023 John MacFarlane
+   Copyright   : Copyright (C) 2007 Galois, Inc., 2021-2024 John MacFarlane
    License     : GNU GPL, version 2 or above
 
    Maintainer  : John MacFarlane <jgm@berkeley.edu>
