OpenDocument writer: add custom-style "Abstract" in metadata abstract.

This ensures that the abstract is rendered with style Abstract.
This commit is contained in:
John MacFarlane 2020-05-16 14:39:20 -07:00
parent cc7dcf2a92
commit bde3d7622d

View file

@ -28,6 +28,7 @@ import Text.Pandoc.BCP47 (Lang (..), parseBCP47)
import Text.Pandoc.Class.PandocMonad (PandocMonad, report, translateTerm, import Text.Pandoc.Class.PandocMonad (PandocMonad, report, translateTerm,
setTranslations, toLang) setTranslations, toLang)
import Text.Pandoc.Definition import Text.Pandoc.Definition
import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Logging import Text.Pandoc.Logging
import Text.Pandoc.Options import Text.Pandoc.Options
import Text.DocLayout import Text.DocLayout
@ -223,12 +224,18 @@ writeOpenDocument opts (Pandoc meta blocks) = do
let colwidth = if writerWrapText opts == WrapAuto let colwidth = if writerWrapText opts == WrapAuto
then Just $ writerColumns opts then Just $ writerColumns opts
else Nothing 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 ((body, metadata),s) <- flip runStateT
defaultWriterState $ do defaultWriterState $ do
m <- metaToContext opts m <- metaToContext opts
(blocksToOpenDocument opts) (blocksToOpenDocument opts)
(fmap chomp . inlinesToOpenDocument opts) (fmap chomp . inlinesToOpenDocument opts)
meta meta'
b <- blocksToOpenDocument opts blocks b <- blocksToOpenDocument opts blocks
return (b, m) return (b, m)
let styles = stTableStyles s ++ stParaStyles s ++ formulaStyles ++ let styles = stTableStyles s ++ stParaStyles s ++ formulaStyles ++