git.iko.soy/typeable/pandoc
on master help sign in
Do not lookup custom styles
commit47c70b91313dd5e907efd34d5a26d908b625c476 authorNikolay Yakimov <root@livid.pp.ru> dateMon 23 Feb 2015, 02:05 (12 years ago) parent7ae7f0c
1 file changed+13−9
src/Text/Pandoc/Writers/Docx.hs+13−9
src/Text/Pandoc/Writers/Docx.hs+13−9
@@ -646,6 +646,9 @@ pStyle sty (ParaStyleMap m) = mknode "w:pStyle" [("w:val",sty')] ()
646646 where
647647 sty' = getStyleId sty m
648648
649+pCustomStyle :: String -> Element
650+pCustomStyle sty = mknode "w:pStyle" [("w:val",sty)] ()
651+
649652pStyleM :: String -> WS XML.Element
650653pStyleM = flip fmap (gets stParaStyles) . pStyle
651654
@@ -654,6 +657,9 @@ rStyle sty (CharStyleMap m) = mknode "w:rStyle" [("w:val",sty')] ()
654657 where
655658 sty' = getStyleId sty m
656659
660+rCustomStyle :: String -> Element
661+rCustomStyle sty = mknode "w:rStyle" [("w:val",sty)] ()
662+
657663rStyleM :: String -> WS XML.Element
658664rStyleM = flip fmap (gets stCharStyles) . rStyle
659665
@@ -720,7 +726,7 @@ blockToOpenXML opts (BlockQuote blocks) = do
720726 setFirstPara
721727 return p
722728blockToOpenXML 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])
724730 setFirstPara
725731 return p
726732blockToOpenXML _ HorizontalRule = do
@@ -978,15 +984,14 @@ inlineToOpenXML opts (Math mathType str) = do
978984 Left _ -> inlinesToOpenXML opts (texMathToInlines mathType str)
979985inlineToOpenXML opts (Cite _ lst) = inlinesToOpenXML opts lst
980986inlineToOpenXML opts (Code attrs str) = do
981− rSM <- gets stCharStyles
982987 let unhighlighted = intercalate [br] `fmap`
983988 (mapM formattedString $ lines str)
984989 formatOpenXML _fmtOpts = intercalate [br] . map (map toHlTok)
985990 toHlTok (toktype,tok) = mknode "w:r" []
986991 [ mknode "w:rPr" []
987− [ rStyle (show toktype) rSM ]
992+ [ rCustomStyle (show toktype) ]
988993 , mknode "w:t" [("xml:space","preserve")] tok ]
989− withTextProp (rStyle "Verbatim Char" rSM)
994+ withTextProp (rCustomStyle "VerbatimChar")
990995 $ if writerHighlight opts
991996 then case highlight formatOpenXML attrs str of
992997 Nothing -> unhighlighted
@@ -995,9 +1000,8 @@ inlineToOpenXML opts (Code attrs str) = do
9951000inlineToOpenXML opts (Note bs) = do
9961001 notes <- gets stFootnotes
9971002 notenum <- getUniqueId
998− rSM <- gets stCharStyles
9991003 let notemarker = mknode "w:r" []
1000− [ mknode "w:rPr" [] (rStyle "Footnote Ref" rSM)
1004+ [ mknode "w:rPr" [] (rCustomStyle "FootnoteRef")
10011005 , mknode "w:footnoteRef" [] () ]
10021006 let notemarkerXml = RawInline (Format "openxml") $ ppElement notemarker
10031007 let insertNoteRef (Plain ils : xs) = Plain (notemarkerXml : ils) : xs
@@ -1014,15 +1018,15 @@ inlineToOpenXML opts (Note bs) = do
10141018 let newnote = mknode "w:footnote" [("w:id", notenum)] $ contents
10151019 modify $ \s -> s{ stFootnotes = newnote : notes }
10161020 return [ mknode "w:r" []
1017− [ mknode "w:rPr" [] (rStyle "Footnote Ref" rSM)
1021+ [ mknode "w:rPr" [] (rCustomStyle "FootnoteRef")
10181022 , mknode "w:footnoteReference" [("w:id", notenum)] () ] ]
10191023-- internal link:
10201024inlineToOpenXML opts (Link txt ('#':xs,_)) = do
1021− contents <- withTextPropM (rStyleM "Link") $ inlinesToOpenXML opts txt
1025+ contents <- withTextProp (rCustomStyle "Link") $ inlinesToOpenXML opts txt
10221026 return [ mknode "w:hyperlink" [("w:anchor",xs)] contents ]
10231027-- external link:
10241028inlineToOpenXML opts (Link txt (src,_)) = do
1025− contents <- withTextPropM (rStyleM "Link") $ inlinesToOpenXML opts txt
1029+ contents <- withTextProp (rCustomStyle "Link") $ inlinesToOpenXML opts txt
10261030 extlinks <- gets stExternalLinks
10271031 id' <- case M.lookup src extlinks of
10281032 Just i -> return i