From bde3d7622ddd2cda7adabc309335bb2865c1d520 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 16 May 2020 14:39:20 -0700 Subject: OpenDocument writer: add custom-style "Abstract" in metadata abstract. This ensures that the abstract is rendered with style Abstract. --- src/Text/Pandoc/Writers/OpenDocument.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 6fd0dd5dd..c6b66382b 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -28,6 +28,7 @@ import Text.Pandoc.BCP47 (Lang (..), parseBCP47) import Text.Pandoc.Class.PandocMonad (PandocMonad, report, translateTerm, setTranslations, toLang) import Text.Pandoc.Definition +import qualified Text.Pandoc.Builder as B import Text.Pandoc.Logging import Text.Pandoc.Options import Text.DocLayout @@ -223,12 +224,18 @@ writeOpenDocument opts (Pandoc meta blocks) = do let colwidth = if writerWrapText opts == WrapAuto then Just $ writerColumns opts else Nothing + let meta' = case lookupMetaBlocks "abstract" meta of + [] -> meta + xs -> B.setMeta "abstract" + (B.divWith ("",[],[("custom-style","Abstract")]) + (B.fromList xs)) + meta ((body, metadata),s) <- flip runStateT defaultWriterState $ do m <- metaToContext opts (blocksToOpenDocument opts) (fmap chomp . inlinesToOpenDocument opts) - meta + meta' b <- blocksToOpenDocument opts blocks return (b, m) let styles = stTableStyles s ++ stParaStyles s ++ formulaStyles ++ -- cgit v1.2.3