@@ -50,7 +50,8 @@ import Text.Pandoc.Shared (stringify)
50import Text.Pandoc.UTF8 (fromStringLazy, fromTextLazy, toStringLazy)
50import Text.Pandoc.UTF8 (fromStringLazy, fromTextLazy, toStringLazy)
51import Text.Pandoc.Walk
51import Text.Pandoc.Walk
52import Text.Pandoc.Writers.OpenDocument (writeOpenDocument)
52import Text.Pandoc.Writers.OpenDocument (writeOpenDocument)
53−import Text.Pandoc.Writers.Shared (fixDisplayMath, getLang, splitLang)
53+import Text.Pandoc.Writers.Shared (fixDisplayMath, getLang, Lang(..),
54import Text.Pandoc.XML
55import Text.Pandoc.XML
55import Text.TeXMath
56import Text.TeXMath
56import Text.XML.Light
57import Text.XML.Light
@@ -79,7 +80,7 @@ pandocToODT :: PandocMonad m
79pandocToODT opts doc@(Pandoc meta _) = do
80pandocToODT opts doc@(Pandoc meta _) = do
80 let datadir = writerUserDataDir opts
81 let datadir = writerUserDataDir opts
81 let title = docTitle meta
82 let title = docTitle meta
82− let lang = getLang opts meta
83+ lang <- getLang opts meta
83 refArchive <-
84 refArchive <-
84 case writerReferenceDoc opts of
85 case writerReferenceDoc opts of
85 Just f -> liftM toArchive $ lift $ P.readFileLazy f
86 Just f -> liftM toArchive $ lift $ P.readFileLazy f
@@ -140,7 +141,7 @@ pandocToODT opts doc@(Pandoc meta _) = do
141 case lang of
142 case lang of
142 Just l -> inTagsSimple "dc:language"
143 Just l -> inTagsSimple "dc:language"
143− (text (escapeStringForXML l))
144+ (text (escapeStringForXML (renderLang l)))
144 Nothing -> empty
145 Nothing -> empty
@@ -153,10 +154,9 @@ pandocToODT opts doc@(Pandoc meta _) = do
153 $ addEntryToArchive metaEntry archive'
154 $ addEntryToArchive metaEntry archive'
154 return $ fromArchive archive''
155 return $ fromArchive archive''
156−updateStyleWithLang :: PandocMonad m => Maybe String -> Archive -> O m Archive
157+updateStyleWithLang :: PandocMonad m => Maybe Lang -> Archive -> O m Archive
157updateStyleWithLang Nothing arch = return arch
158updateStyleWithLang Nothing arch = return arch
158−updateStyleWithLang (Just l) arch = do
159+updateStyleWithLang (Just lang) arch = do
159− (mblang, mbcountry) <- splitLang l
160 epochtime <- floor `fmap` (lift P.getPOSIXTime)
160 epochtime <- floor `fmap` (lift P.getPOSIXTime)
161 return arch{ zEntries = [if eRelativePath e == "styles.xml"
161 return arch{ zEntries = [if eRelativePath e == "styles.xml"
162 then case parseXMLDoc
162 then case parseXMLDoc
@@ -166,16 +166,16 @@ updateStyleWithLang (Just l) arch = do
166 toEntry "styles.xml" epochtime
166 toEntry "styles.xml" epochtime
167 ( fromStringLazy
167 ( fromStringLazy
168 . ppTopElement
168 . ppTopElement
169− . addLang mblang mbcountry $ d )
169+ . addLang lang $ d )
171 | e <- zEntries arch] }
171 | e <- zEntries arch] }
173−addLang :: Maybe String -> Maybe String -> Element -> Element
173+addLang :: Lang -> Element -> Element
174−addLang mblang mbcountry = everywhere' (mkT updateLangAttr)
174+addLang (Lang lang country) = everywhere' (mkT updateLangAttr)
175− where updateLangAttr (Attr n@(QName "language" _ (Just "fo")) l)
175+ where updateLangAttr (Attr n@(QName "language" _ (Just "fo")) _)
176− = Attr n (maybe l id mblang)
176+ = Attr n lang
177− updateLangAttr (Attr n@(QName "country" _ (Just "fo")) c)
177+ updateLangAttr (Attr n@(QName "country" _ (Just "fo")) _)
178− = Attr n (maybe c id mbcountry)
178+ = Attr n country
179 updateLangAttr x = x
179 updateLangAttr x = x
181-- | transform both Image and Math elements
181-- | transform both Image and Math elements