git.iko.soy/typeable/pandoc
on master help sign in
Do not lookup custom styles
47c70b9Nikolay Yakimov
src/Text/Pandoc/Writers/Docx.hs+13−9
@@ -646,6 +646,9 @@ pStyle sty (ParaStyleMap m) = mknode "w:pStyle" [("w:val",sty')] ()
646 where
646 where
647 sty' = getStyleId sty m
647 sty' = getStyleId sty m
648
648
649+pCustomStyle :: String -> Element
650+pCustomStyle sty = mknode "w:pStyle" [("w:val",sty)] ()
651+
649pStyleM :: String -> WS XML.Element
652pStyleM :: String -> WS XML.Element
650pStyleM = flip fmap (gets stParaStyles) . pStyle
653pStyleM = flip fmap (gets stParaStyles) . pStyle
651
654
@@ -654,6 +657,9 @@ rStyle sty (CharStyleMap m) = mknode "w:rStyle" [("w:val",sty')] ()
654 where
657 where
655 sty' = getStyleId sty m
658 sty' = getStyleId sty m
656
659
660+rCustomStyle :: String -> Element
661+rCustomStyle sty = mknode "w:rStyle" [("w:val",sty)] ()
662+
657rStyleM :: String -> WS XML.Element
663rStyleM :: String -> WS XML.Element
658rStyleM = flip fmap (gets stCharStyles) . rStyle
664rStyleM = flip fmap (gets stCharStyles) . rStyle
659
665
@@ -720,7 +726,7 @@ blockToOpenXML opts (BlockQuote blocks) = do
720 setFirstPara
726 setFirstPara
721 return p
727 return p
722blockToOpenXML opts (CodeBlock attrs str) = do
728blockToOpenXML opts (CodeBlock attrs str) = do
723− p <- withParaPropM (pStyleM "Source Code") (blockToOpenXML opts $ Para [Code attrs str])
729+ p <- withParaProp (pCustomStyle "SourceCode") (blockToOpenXML opts $ Para [Code attrs str])
724 setFirstPara
730 setFirstPara
725 return p
731 return p
726blockToOpenXML _ HorizontalRule = do
732blockToOpenXML _ HorizontalRule = do
@@ -978,15 +984,14 @@ inlineToOpenXML opts (Math mathType str) = do
978 Left _ -> inlinesToOpenXML opts (texMathToInlines mathType str)
984 Left _ -> inlinesToOpenXML opts (texMathToInlines mathType str)
979inlineToOpenXML opts (Cite _ lst) = inlinesToOpenXML opts lst
985inlineToOpenXML opts (Cite _ lst) = inlinesToOpenXML opts lst
980inlineToOpenXML opts (Code attrs str) = do
986inlineToOpenXML opts (Code attrs str) = do
981− rSM <- gets stCharStyles
982 let unhighlighted = intercalate [br] `fmap`
987 let unhighlighted = intercalate [br] `fmap`
983 (mapM formattedString $ lines str)
988 (mapM formattedString $ lines str)
984 formatOpenXML _fmtOpts = intercalate [br] . map (map toHlTok)
989 formatOpenXML _fmtOpts = intercalate [br] . map (map toHlTok)
985 toHlTok (toktype,tok) = mknode "w:r" []
990 toHlTok (toktype,tok) = mknode "w:r" []
986 [ mknode "w:rPr" []
991 [ mknode "w:rPr" []
987− [ rStyle (show toktype) rSM ]
992+ [ rCustomStyle (show toktype) ]
988 , mknode "w:t" [("xml:space","preserve")] tok ]
993 , mknode "w:t" [("xml:space","preserve")] tok ]
989− withTextProp (rStyle "Verbatim Char" rSM)
994+ withTextProp (rCustomStyle "VerbatimChar")
990 $ if writerHighlight opts
995 $ if writerHighlight opts
991 then case highlight formatOpenXML attrs str of
996 then case highlight formatOpenXML attrs str of
992 Nothing -> unhighlighted
997 Nothing -> unhighlighted
@@ -995,9 +1000,8 @@ inlineToOpenXML opts (Code attrs str) = do
995inlineToOpenXML opts (Note bs) = do
1000inlineToOpenXML opts (Note bs) = do
996 notes <- gets stFootnotes
1001 notes <- gets stFootnotes
997 notenum <- getUniqueId
1002 notenum <- getUniqueId
998− rSM <- gets stCharStyles
999 let notemarker = mknode "w:r" []
1003 let notemarker = mknode "w:r" []
1000− [ mknode "w:rPr" [] (rStyle "Footnote Ref" rSM)
1004+ [ mknode "w:rPr" [] (rCustomStyle "FootnoteRef")
1001 , mknode "w:footnoteRef" [] () ]
1005 , mknode "w:footnoteRef" [] () ]
1002 let notemarkerXml = RawInline (Format "openxml") $ ppElement notemarker
1006 let notemarkerXml = RawInline (Format "openxml") $ ppElement notemarker
1003 let insertNoteRef (Plain ils : xs) = Plain (notemarkerXml : ils) : xs
1007 let insertNoteRef (Plain ils : xs) = Plain (notemarkerXml : ils) : xs
@@ -1014,15 +1018,15 @@ inlineToOpenXML opts (Note bs) = do
1014 let newnote = mknode "w:footnote" [("w:id", notenum)] $ contents
1018 let newnote = mknode "w:footnote" [("w:id", notenum)] $ contents
1015 modify $ \s -> s{ stFootnotes = newnote : notes }
1019 modify $ \s -> s{ stFootnotes = newnote : notes }
1016 return [ mknode "w:r" []
1020 return [ mknode "w:r" []
1017− [ mknode "w:rPr" [] (rStyle "Footnote Ref" rSM)
1021+ [ mknode "w:rPr" [] (rCustomStyle "FootnoteRef")
1018 , mknode "w:footnoteReference" [("w:id", notenum)] () ] ]
1022 , mknode "w:footnoteReference" [("w:id", notenum)] () ] ]
1019-- internal link:
1023-- internal link:
1020inlineToOpenXML opts (Link txt ('#':xs,_)) = do
1024inlineToOpenXML opts (Link txt ('#':xs,_)) = do
1021− contents <- withTextPropM (rStyleM "Link") $ inlinesToOpenXML opts txt
1025+ contents <- withTextProp (rCustomStyle "Link") $ inlinesToOpenXML opts txt
1022 return [ mknode "w:hyperlink" [("w:anchor",xs)] contents ]
1026 return [ mknode "w:hyperlink" [("w:anchor",xs)] contents ]
1023-- external link:
1027-- external link:
1024inlineToOpenXML opts (Link txt (src,_)) = do
1028inlineToOpenXML opts (Link txt (src,_)) = do
1025− contents <- withTextPropM (rStyleM "Link") $ inlinesToOpenXML opts txt
1029+ contents <- withTextProp (rCustomStyle "Link") $ inlinesToOpenXML opts txt
1026 extlinks <- gets stExternalLinks
1030 extlinks <- gets stExternalLinks
1027 id' <- case M.lookup src extlinks of
1031 id' <- case M.lookup src extlinks of
1028 Just i -> return i
1032 Just i -> return i