@@ -394,7 +394,7 @@ writeDocx opts doc@(Pandoc meta _) = do
396 -- styles
396 -- styles
397− let newstyles = styleToOpenXml $ writerHighlightStyle opts
397+ let newstyles = styleToOpenXml charStyles $ writerHighlightStyle opts
398 let styledoc' = styledoc{ elContent = elContent styledoc ++
398 let styledoc' = styledoc{ elContent = elContent styledoc ++
399 [Elem x | x <- newstyles, writerHighlight opts] }
399 [Elem x | x <- newstyles, writerHighlight opts] }
400 let styleEntry = toEntry stylepath epochtime $ renderXml styledoc'
400 let styleEntry = toEntry stylepath epochtime $ renderXml styledoc'
@@ -473,10 +473,13 @@ writeDocx opts doc@(Pandoc meta _) = do
473 miscRelEntries ++ otherMediaEntries
473 miscRelEntries ++ otherMediaEntries
474 return $ fromArchive archive
474 return $ fromArchive archive
476−styleToOpenXml :: Style -> [Element]
476+styleToOpenXml :: CharStyleMap -> Style -> [Element]
477−styleToOpenXml style = parStyle : map toStyle alltoktypes
477+styleToOpenXml (CharStyleMap m) style = parStyle : mapMaybe toStyle alltoktypes
478 where alltoktypes = enumFromTo KeywordTok NormalTok
478 where alltoktypes = enumFromTo KeywordTok NormalTok
480+ if M.member (map toLower $ show toktype) m then Nothing
479− toStyle toktype = mknode "w:style" [("w:type","character"),
482+ mknode "w:style" [("w:type","character"),
480 ("w:customStyle","1"),("w:styleId",show toktype)]
483 ("w:customStyle","1"),("w:styleId",show toktype)]
481 [ mknode "w:name" [("w:val",show toktype)] ()
484 [ mknode "w:name" [("w:val",show toktype)] ()
482 , mknode "w:basedOn" [("w:val","VerbatimChar")] ()
485 , mknode "w:basedOn" [("w:val","VerbatimChar")] ()