@@ -18,7 +18,7 @@ import Prelude
1818import Control.Arrow ((***), (>>>))
1919import Control.Monad.State.Strict hiding (when)
2020import Data.Char (chr)
21−import Data.List (sortBy)
21+import Data.List (sortBy, foldl')
2222import qualified Data.Map as Map
2323import Data.Maybe (fromMaybe)
2424import Data.Ord (comparing)
@@ -159,7 +159,8 @@ inTextStyle d = do
159159 [("style:name", styleName)
160160 ,("style:family", "text")]
161161 $ selfClosingTag "style:text-properties"
162− (concatMap textStyleAttr (Set.toList at)))
162+ (sortBy (comparing fst) . Map.toList
163+ $ foldl' textStyleAttr mempty (Set.toList at)))
163164 return $ inTags False
164165 "text:span" [("text:style-name",styleName)] d
165166
@@ -692,25 +693,27 @@ data TextStyle = Italic
692693 | Language Lang
693694 deriving ( Eq,Ord )
694695
695−textStyleAttr :: TextStyle -> [(String,String)]
696−textStyleAttr s
697− | Italic <- s = [("fo:font-style" ,"italic" )
698− ,("style:font-style-asian" ,"italic" )
699− ,("style:font-style-complex" ,"italic" )]
700− | Bold <- s = [("fo:font-weight" ,"bold" )
701− ,("style:font-weight-asian" ,"bold" )
702− ,("style:font-weight-complex" ,"bold" )]
703− | Strike <- s = [("style:text-line-through-style", "solid" )]
704− | Sub <- s = [("style:text-position" ,"sub 58%" )]
705− | Sup <- s = [("style:text-position" ,"super 58%" )]
706− | SmallC <- s = [("fo:font-variant" ,"small-caps")]
707− | Pre <- s = [("style:font-name" ,"Courier New")
708− ,("style:font-name-asian" ,"Courier New")
709− ,("style:font-name-complex" ,"Courier New")]
696+textStyleAttr :: Map.Map String String
697+ -> TextStyle
698+ -> Map.Map String String
699+textStyleAttr m s
700+ | Italic <- s = Map.insert "fo:font-style" "italic" .
701+ Map.insert "style:font-style-asian" "italic" .
702+ Map.insert "style:font-style-complex" "italic" $ m
703+ | Bold <- s = Map.insert "fo:font-weight" "bold" .
704+ Map.insert "style:font-weight-asian" "bold" .
705+ Map.insert "style:font-weight-complex" "bold" $ m
706+ | Strike <- s = Map.insert "style:text-line-through-style" "solid" m
707+ | Sub <- s = Map.insert "style:text-position" "sub 58%" m
708+ | Sup <- s = Map.insert "style:text-position" "super 58%" m
709+ | SmallC <- s = Map.insert "fo:font-variant" "small-caps" m
710+ | Pre <- s = Map.insert "style:font-name" "Courier New" .
711+ Map.insert "style:font-name-asian" "Courier New" .
712+ Map.insert "style:font-name-complex" "Courier New" $ m
710713 | Language lang <- s
711− = [("fo:language" ,langLanguage lang)
712− ,("fo:country" ,langRegion lang)]
713− | otherwise = []
714+ = Map.insert "fo:language" (langLanguage lang) .
715+ Map.insert "fo:country" (langRegion lang) $ m
716+ | otherwise = m
714717
715718withLangFromAttr :: PandocMonad m => Attr -> OD m a -> OD m a
716719withLangFromAttr (_,_,kvs) action =