From 73fc6cf53e8885ff81c66227196fc37d5facc69a Mon Sep 17 00:00:00 2001 From: acxz <17132214+acxz@users.noreply.github.com> Date: Tue, 30 Jul 2024 20:22:38 -0500 Subject: [PATCH] use lofTitle, lotTitle from Translations instead of WriterState --- src/Text/Pandoc/Writers/Docx.hs | 10 ---------- src/Text/Pandoc/Writers/Docx/OpenXML.hs | 7 +++---- src/Text/Pandoc/Writers/Docx/Types.hs | 4 ---- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index a5e8d29b39f7..ec1c682afd59 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -175,19 +175,9 @@ writeDocx opts doc = do [] -> stTocTitle defaultWriterState ls -> ls - let lofTitle = case lookupMetaInlines "lof-title" meta of - [] -> stLofTitle defaultWriterState - ls -> ls - - let lotTitle = case lookupMetaInlines "lot-title" meta of - [] -> stLotTitle defaultWriterState - ls -> ls - let initialSt = defaultWriterState { stStyleMaps = styleMaps , stTocTitle = tocTitle - , stLofTitle = lofTitle - , stLotTitle = lotTitle , stCurId = 20 } diff --git a/src/Text/Pandoc/Writers/Docx/OpenXML.hs b/src/Text/Pandoc/Writers/Docx/OpenXML.hs index 845c0a99f81e..9f23a30d8265 100644 --- a/src/Text/Pandoc/Writers/Docx/OpenXML.hs +++ b/src/Text/Pandoc/Writers/Docx/OpenXML.hs @@ -45,6 +45,7 @@ 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 +import qualified Text.Pandoc.Builder as B import Text.Pandoc.UTF8 (fromTextLazy) import Text.Pandoc.Definition import Text.Pandoc.Highlighting (highlight) @@ -174,8 +175,7 @@ makeTOC opts = do makeLOF :: (PandocMonad m) => WriterOptions -> WS m [Element] makeLOF opts = do let lofCmd = "TOC \\h \\z \\t \"Image Caption\" \\c" :: Text - lofTitle <- gets stLofTitle - -- Create a separate style for LOF Heading? + lofTitle <- B.text <$> translateTerm Term.ListOfFigures :: Inline title <- withParaPropM (pStyleM "TOC Heading") (blocksToOpenXML opts [Para lofTitle]) return [mknode "w:sdt" [] [ @@ -200,8 +200,7 @@ makeLOF opts = do makeLOT :: (PandocMonad m) => WriterOptions -> WS m [Element] makeLOT opts = do let lotCmd = "TOC \\h \\z \\t \"Table Caption\" \\c" :: Text - lotTitle <- gets stLotTitle - -- Create a separate style for LOT Heading? + lotTitle <- B.text <$> translateTerm Term.ListOfTables title <- withParaPropM (pStyleM "TOC Heading") (blocksToOpenXML opts [Para lotTitle]) return [mknode "w:sdt" [] [ diff --git a/src/Text/Pandoc/Writers/Docx/Types.hs b/src/Text/Pandoc/Writers/Docx/Types.hs index 753331ddfd01..afa98be646ed 100644 --- a/src/Text/Pandoc/Writers/Docx/Types.hs +++ b/src/Text/Pandoc/Writers/Docx/Types.hs @@ -124,8 +124,6 @@ data WriterState = WriterState{ , stInTable :: Bool , stInList :: Bool , stTocTitle :: [Inline] - , stLofTitle :: [Inline] - , stLotTitle :: [Inline] , stDynamicParaProps :: Set.Set ParaStyleName , stDynamicTextProps :: Set.Set CharStyleName , stCurId :: Int @@ -150,8 +148,6 @@ defaultWriterState = WriterState{ , stInTable = False , stInList = False , stTocTitle = [Str "Table of Contents"] - , stLofTitle = [Str "List of Figures"] - , stLotTitle = [Str "List of Tables"] , stDynamicParaProps = Set.empty , stDynamicTextProps = Set.empty , stCurId = 20