diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2023-03-17 20:06:17 -0700 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2023-03-17 20:06:17 -0700 |
| commit | 80e750aa5e7ac03add8a3ef5a8f2725b1d0ff901 (patch) | |
| tree | 1f50cdc1eba8b12886d70f7144ee3d0b46b0b887 | |
| parent | a23d14079c056af3c63d7903dfd17b30c1e1b8d6 (diff) | |
Docx writer: include abstract title.
Closes #8702.
Uses localized term for abstract.
| -rw-r--r-- | MANUAL.txt | 1 | ||||
| -rw-r--r-- | data/docx/word/styles.xml | 20 | ||||
| -rw-r--r-- | src/Text/Pandoc/Writers/Docx.hs | 12 | ||||
| -rw-r--r-- | test/docx/golden/document-properties.docx | bin | 10314 -> 10324 bytes |
4 files changed, 30 insertions, 3 deletions
diff --git a/MANUAL.txt b/MANUAL.txt index 0afe048e3..cc97a5167 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -1166,6 +1166,7 @@ header when requesting a document from a URL: - Author - Date - Abstract + - AbstractTitle - Bibliography - Heading 1 - Heading 2 diff --git a/data/docx/word/styles.xml b/data/docx/word/styles.xml index 832b1b25b..578c3ba5d 100644 --- a/data/docx/word/styles.xml +++ b/data/docx/word/styles.xml @@ -99,6 +99,24 @@ <w:jc w:val="center" /> </w:pPr> </w:style> + <w:style w:type="paragraph" w:customStyle="1" w:styleId="AbstractTitle"> + <w:name w:val="Abstract Title" /> + <w:basedOn w:val="Normal" /> + <w:next w:val="Abstract" /> + <w:qFormat /> + <w:pPr> + <w:keepNext /> + <w:keepLines /> + <w:jc w:val="center" /> + <w:spacing w:before="300" w:after="0" /> + </w:pPr> + <w:rPr> + <w:sz w:val="20" /> + <w:szCs w:val="20" /> + <w:b /> + <w:color w:val="345A8A" />> + </w:rPr> + </w:style> <w:style w:type="paragraph" w:customStyle="1" w:styleId="Abstract"> <w:name w:val="Abstract" /> <w:basedOn w:val="Normal" /> @@ -107,7 +125,7 @@ <w:pPr> <w:keepNext /> <w:keepLines /> - <w:spacing w:before="300" w:after="300" /> + <w:spacing w:before="100" w:after="300" /> </w:pPr> <w:rPr> <w:sz w:val="20" /> diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index e3956c5ef..d33f2aca6 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -48,7 +48,7 @@ import Data.Time.Clock.POSIX import Data.Digest.Pure.SHA (sha1, showDigest) import Skylighting import Text.Pandoc.Class (PandocMonad, report, toLang, getMediaBag) -import Text.Pandoc.Translations (translateTerm) +import Text.Pandoc.Translations (Term(Abstract), translateTerm) import Text.Pandoc.MediaBag (lookupMedia, MediaItem(..)) import qualified Text.Pandoc.Translations as Term import qualified Text.Pandoc.Class.PandocMonad as P @@ -767,7 +767,15 @@ writeOpenXML opts (Pandoc meta blocks) = do date <- withParaPropM (pStyleM "Date") $ blocksToOpenXML opts [Para dat | not (null dat)] abstract <- if null abstract' then return [] - else withParaPropM (pStyleM "Abstract") $ blocksToOpenXML opts abstract' + else do + abstractTitle <- translateTerm Abstract + abstractTit <- withParaPropM (pStyleM "AbstractTitle") $ + blocksToOpenXML opts + [Para [Str abstractTitle]] + abstractContents <- withParaPropM (pStyleM "Abstract") $ + blocksToOpenXML opts abstract' + return $ abstractTit <> abstractContents + let convertSpace (Str x : Space : Str y : xs) = Str (x <> " " <> y) : xs convertSpace (Str x : Str y : xs) = Str (x <> y) : xs convertSpace xs = xs diff --git a/test/docx/golden/document-properties.docx b/test/docx/golden/document-properties.docx Binary files differindex d8f091956..5bc62090b 100644 --- a/test/docx/golden/document-properties.docx +++ b/test/docx/golden/document-properties.docx |
