aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/Docx
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-08-15 15:05:54 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-08-15 15:05:54 -0700
commit4340bd52c49b987087e123de2eae4464b300332f (patch)
tree0d8c9931dc4847521cc015dbcd7c9f68fec9da0d /src/Text/Pandoc/Writers/Docx
parent2c466a15afed3edad3159791f38685c6656e8261 (diff)
downloadpandoc-4340bd52c49b987087e123de2eae4464b300332f.tar.gz
Make docx writer sensitive to `native_numbering` extension.
Figure and table numbers are now only included if `native_numbering` is enabled. (By default it is disabled.) This is a behavior change with respect to 2.14.1, but the behavior is that of previous versions. The change was necessary to avoid incompatibilities between pandoc's native numbering and third-party cross reference filters like pandoc-crossref. Closes #7499.
Diffstat (limited to 'src/Text/Pandoc/Writers/Docx')
-rw-r--r--src/Text/Pandoc/Writers/Docx/Table.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/Docx/Table.hs b/src/Text/Pandoc/Writers/Docx/Table.hs
index 7a84c5278..e23856f28 100644
--- a/src/Text/Pandoc/Writers/Docx/Table.hs
+++ b/src/Text/Pandoc/Writers/Docx/Table.hs
@@ -20,6 +20,8 @@ import Text.Pandoc.Definition
import Text.Pandoc.Class.PandocMonad (PandocMonad, translateTerm)
import Text.Pandoc.Writers.Docx.Types
import Text.Pandoc.Shared
+import Text.Pandoc.Options (WriterOptions, isEnabled)
+import Text.Pandoc.Extensions (Extension(Ext_native_numbering))
import Text.Printf (printf)
import Text.Pandoc.Writers.GridTable hiding (Table)
import Text.Pandoc.Writers.OOXML
@@ -29,10 +31,11 @@ import qualified Text.Pandoc.Translations as Term
import qualified Text.Pandoc.Writers.GridTable as Grid
tableToOpenXML :: PandocMonad m
- => ([Block] -> WS m [Content])
+ => WriterOptions
+ -> ([Block] -> WS m [Content])
-> Grid.Table
-> WS m [Content]
-tableToOpenXML blocksToOpenXML gridTable = do
+tableToOpenXML opts blocksToOpenXML gridTable = do
setFirstPara
let (Grid.Table (ident,_,_) caption colspecs _rowheads thead tbodies tfoot) =
gridTable
@@ -50,7 +53,9 @@ tableToOpenXML blocksToOpenXML gridTable = do
then return []
else withParaPropM (pStyleM "Table Caption")
$ blocksToOpenXML
- $ addLabel tableid tablename tablenum captionBlocks
+ $ if isEnabled Ext_native_numbering opts
+ then addLabel tableid tablename tablenum captionBlocks
+ else captionBlocks
-- We set "in table" after processing the caption, because we don't
-- want the "Table Caption" style to be overwritten with "Compact".
modify $ \s -> s { stInTable = True }