@@ -395,8 +395,16 @@ writeDocx opts doc@(Pandoc meta _) = do
395395
396396 -- styles
397397 let newstyles = styleToOpenXml charStyles $ writerHighlightStyle opts
398− let styledoc' = styledoc{ elContent = elContent styledoc ++
399− [Elem x | x <- newstyles, writerHighlight opts] }
398+ let styledoc' = styledoc{ elContent = modifyContent (elContent styledoc) }
399+ where
400+ modifyContent
401+ | writerHighlight opts = (++ map Elem newstyles)
402+ | otherwise = filter notTokStyle
403+ notTokStyle (Elem el) = notStyle el || notTokId el
404+ notTokStyle _ = True
405+ notStyle = (/= myName "style") . elName
406+ notTokId = maybe True (`notElem` tokStys) . getAttrStyleId
407+ tokStys = map show $ enumFromTo KeywordTok NormalTok
400408 let styleEntry = toEntry stylepath epochtime $ renderXml styledoc'
401409
402410 -- construct word/numbering.xml