git.iko.soy/typeable/pandoc
on master help sign in
Update Docx writer for 1cb601d reference.docx
13daf3eNikolay Yakimov
src/Text/Pandoc/Writers/Docx.hs+14−13
@@ -652,16 +652,16 @@ pCustomStyle sty = mknode "w:pStyle" [("w:val",sty)] ()
652pStyleM :: String -> WS XML.Element
652pStyleM :: String -> WS XML.Element
653pStyleM = flip fmap (gets stParaStyles) . pStyle
653pStyleM = flip fmap (gets stParaStyles) . pStyle
654
654
655−-- rStyle :: String -> CharStyleMap -> Element
655+rStyle :: String -> CharStyleMap -> Element
656−-- rStyle sty (CharStyleMap m) = mknode "w:rStyle" [("w:val",sty')] ()
656+rStyle sty (CharStyleMap m) = mknode "w:rStyle" [("w:val",sty')] ()
657−-- where
657+ where
658−-- sty' = getStyleId sty m
658+ sty' = getStyleId sty m
659
659
660rCustomStyle :: String -> Element
660rCustomStyle :: String -> Element
661rCustomStyle sty = mknode "w:rStyle" [("w:val",sty)] ()
661rCustomStyle sty = mknode "w:rStyle" [("w:val",sty)] ()
662
662
663−-- rStyleM :: String -> WS XML.Element
663+rStyleM :: String -> WS XML.Element
664−-- rStyleM = flip fmap (gets stCharStyles) . rStyle
664+rStyleM = flip fmap (gets stCharStyles) . rStyle
665
665
666getUniqueId :: MonadIO m => m String
666getUniqueId :: MonadIO m => m String
667-- the + 20 is to ensure that there are no clashes with the rIds
667-- the + 20 is to ensure that there are no clashes with the rIds
@@ -722,7 +722,7 @@ blockToOpenXML _ (RawBlock format str)
722 | format == Format "openxml" = return [ x | Elem x <- parseXML str ]
722 | format == Format "openxml" = return [ x | Elem x <- parseXML str ]
723 | otherwise = return []
723 | otherwise = return []
724blockToOpenXML opts (BlockQuote blocks) = do
724blockToOpenXML opts (BlockQuote blocks) = do
725− p <- withParaPropM (pStyleM "Block Quote") $ blocksToOpenXML opts blocks
725+ p <- withParaPropM (pStyleM "Block Text") $ blocksToOpenXML opts blocks
726 setFirstPara
726 setFirstPara
727 return p
727 return p
728blockToOpenXML opts (CodeBlock attrs str) = do
728blockToOpenXML opts (CodeBlock attrs str) = do
@@ -866,8 +866,8 @@ withTextProp d p = do
866 popTextProp
866 popTextProp
867 return res
867 return res
868
868
869−-- withTextPropM :: WS Element -> WS a -> WS a
869+withTextPropM :: WS Element -> WS a -> WS a
870−-- withTextPropM = (. flip withTextProp) . (>>=)
870+withTextPropM = (. flip withTextProp) . (>>=)
871
871
872getParaProps :: Bool -> WS [Element]
872getParaProps :: Bool -> WS [Element]
873getParaProps displayMathPara = do
873getParaProps displayMathPara = do
@@ -999,8 +999,9 @@ inlineToOpenXML opts (Code attrs str) = do
999inlineToOpenXML opts (Note bs) = do
999inlineToOpenXML opts (Note bs) = do
1000 notes <- gets stFootnotes
1000 notes <- gets stFootnotes
1001 notenum <- getUniqueId
1001 notenum <- getUniqueId
1002+ footnoteStyle <- rStyleM "Footnote Reference"
1002 let notemarker = mknode "w:r" []
1003 let notemarker = mknode "w:r" []
1003− [ mknode "w:rPr" [] (rCustomStyle "FootnoteRef")
1004+ [ mknode "w:rPr" [] footnoteStyle
1004 , mknode "w:footnoteRef" [] () ]
1005 , mknode "w:footnoteRef" [] () ]
1005 let notemarkerXml = RawInline (Format "openxml") $ ppElement notemarker
1006 let notemarkerXml = RawInline (Format "openxml") $ ppElement notemarker
1006 let insertNoteRef (Plain ils : xs) = Plain (notemarkerXml : ils) : xs
1007 let insertNoteRef (Plain ils : xs) = Plain (notemarkerXml : ils) : xs
@@ -1017,15 +1018,15 @@ inlineToOpenXML opts (Note bs) = do
1017 let newnote = mknode "w:footnote" [("w:id", notenum)] $ contents
1018 let newnote = mknode "w:footnote" [("w:id", notenum)] $ contents
1018 modify $ \s -> s{ stFootnotes = newnote : notes }
1019 modify $ \s -> s{ stFootnotes = newnote : notes }
1019 return [ mknode "w:r" []
1020 return [ mknode "w:r" []
1020− [ mknode "w:rPr" [] (rCustomStyle "FootnoteRef")
1021+ [ mknode "w:rPr" [] footnoteStyle
1021 , mknode "w:footnoteReference" [("w:id", notenum)] () ] ]
1022 , mknode "w:footnoteReference" [("w:id", notenum)] () ] ]
1022-- internal link:
1023-- internal link:
1023inlineToOpenXML opts (Link txt ('#':xs,_)) = do
1024inlineToOpenXML opts (Link txt ('#':xs,_)) = do
1024− contents <- withTextProp (rCustomStyle "Link") $ inlinesToOpenXML opts txt
1025+ contents <- withTextPropM (rStyleM "Hyperlink") $ inlinesToOpenXML opts txt
1025 return [ mknode "w:hyperlink" [("w:anchor",xs)] contents ]
1026 return [ mknode "w:hyperlink" [("w:anchor",xs)] contents ]
1026-- external link:
1027-- external link:
1027inlineToOpenXML opts (Link txt (src,_)) = do
1028inlineToOpenXML opts (Link txt (src,_)) = do
1028− contents <- withTextProp (rCustomStyle "Link") $ inlinesToOpenXML opts txt
1029+ contents <- withTextPropM (rStyleM "Hyperlink") $ inlinesToOpenXML opts txt
1029 extlinks <- gets stExternalLinks
1030 extlinks <- gets stExternalLinks
1030 id' <- case M.lookup src extlinks of
1031 id' <- case M.lookup src extlinks of
1031 Just i -> return i
1032 Just i -> return i