Skip to content

Commit 7a66c94

Browse files
committed
Docx writer: use styleIds not styleNames for Title, Subtitle, etc.
This change affects the default openxml template as well as the OpenXML writer. Closes #10282 (regression introduced in pandoc 3.5).
1 parent d6edb57 commit 7a66c94

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

data/templates/default.openxml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
44
$if(title)$
55
<w:p>
66
<w:pPr>
7-
<w:pStyle w:val="Title" />
7+
<w:pStyle w:val="$title-style-id$" />
88
</w:pPr>
99
$title$
1010
</w:p>
1111
$endif$
1212
$if(subtitle)$
1313
<w:p>
1414
<w:pPr>
15-
<w:pStyle w:val="Subtitle" />
15+
<w:pStyle w:val="$subtitle-style-id$" />
1616
</w:pPr>
1717
$subtitle$
1818
</w:p>
1919
$endif$
2020
$for(author)$
2121
<w:p>
2222
<w:pPr>
23-
<w:pStyle w:val="Author" />
23+
<w:pStyle w:val="$author-style-id$" />
2424
</w:pPr>
2525
$author$
2626
</w:p>
2727
$endfor$
2828
$if(date)$
2929
<w:p>
3030
<w:pPr>
31-
<w:pStyle w:val="Date" />
31+
<w:pStyle w:val="$date-style-id$" />
3232
</w:pPr>
3333
$date$
3434
</w:p>
@@ -37,7 +37,7 @@ $if(abstract)$
3737
$if(abstract-title)$
3838
<w:p>
3939
<w:pPr>
40-
<w:pStyle w:val="AbstractTitle" />
40+
<w:pStyle w:val="$abstract-title-style-id$" />
4141
</w:pPr>
4242
<w:r><w:t xml:space="preserve">$abstract-title$</w:t></w:r>
4343
</w:p>

src/Text/Pandoc/Writers/Docx/OpenXML.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ writeOpenXML opts (Pandoc meta blocks) = do
286286
(fmap (vcat . map (literal . showContent)) . blocksToOpenXML opts)
287287
(fmap (hcat . map (literal . showContent)) . inlinesToOpenXML opts)
288288
meta
289+
cStyleMap <- gets (smParaStyle . stStyleMaps)
290+
let styleIdOf name = fromStyleId $ getStyleIdFromName name cStyleMap
289291
let context = resetField "body" body
290292
. resetField "toc"
291293
(vcat (map (literal . showElement) toc))
@@ -299,6 +301,12 @@ writeOpenXML opts (Pandoc meta blocks) = do
299301
. resetField "date" date
300302
. resetField "abstract-title" abstractTitle
301303
. resetField "abstract" abstract
304+
. resetField "title-style-id" (styleIdOf "Title")
305+
. resetField "subtitle-style-id" (styleIdOf "Subtitle")
306+
. resetField "author-style-id" (styleIdOf "Author")
307+
. resetField "date-style-id" (styleIdOf "Date")
308+
. resetField "abstract-title-style-id" (styleIdOf "AbstractTitle")
309+
. resetField "abstract-style-id" (styleIdOf "Abstract")
302310
$ metadata
303311
tpl <- maybe (lift $ compileDefaultTemplate "openxml") pure $ writerTemplate opts
304312
let rendered = render Nothing $ renderTemplate tpl context

0 commit comments

Comments
 (0)