@@ -407,13 +407,21 @@ writeDocx opts doc@(Pandoc meta _) = do
407407 $ renderXml $ mknode "Relationships" [("xmlns","http://schemas.openxmlformats.org/package/2006/relationships")]
408408 linkrels
409409
410− -- styles We only want to inject paragraph properties that are not
411− -- already in the style map. Note that keys in the stylemap are
412− -- normalized as lowercase.
410+ -- styles
411+
412+ -- We only want to inject paragraph and text properties that
413+ -- are not already in the style map. Note that keys in the stylemap
414+ -- are normalized as lowercase.
413415 let newDynamicParaProps = filter
414416 (\sty -> isNothing $ M.lookup (toLower <$> sty) $ getMap $ sParaStyleMap styleMaps)
415417 (stDynamicParaProps st)
418+
419+ newDynamicTextProps = filter
420+ (\sty -> isNothing $ M.lookup (toLower <$> sty) $ getMap $ sCharStyleMap styleMaps)
421+ (stDynamicTextProps st)
422+
416423 let newstyles = map newParaPropToOpenXml newDynamicParaProps ++
424+ map newTextPropToOpenXml newDynamicTextProps ++
417425 (styleToOpenXml styleMaps $ writerHighlightStyle opts)
418426 let styledoc' = styledoc{ elContent = modifyContent (elContent styledoc) }
419427 where
@@ -521,6 +529,15 @@ newParaPropToOpenXml s =
521529 , mknode "w:qFormat" [] ()
522530 ]
523531
532+newTextPropToOpenXml :: String -> Element
533+newTextPropToOpenXml s =
534+ let styleId = filter (not . isSpace) s
535+ in mknode "w:style" [ ("w:type", "character")
536+ , ("w:customStyle", "1")
537+ , ("w:styleId", styleId)]
538+ [ mknode "w:name" [("w:val", s)] ()
539+ , mknode "w:basedOn" [("w:val","BodyTextChar")] ()
540+ ]
524541
525542styleToOpenXml :: StyleMaps -> Style -> [Element]
526543styleToOpenXml sm style =