aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Docx
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2014-08-12 22:04:07 -0400
committerJesse Rosenthal <jrosenthal@jhu.edu>2014-08-12 22:04:07 -0400
commitd4748038d76dd430f7c760e73487172a3264c5de (patch)
tree4de65a775e270bcfdd6bf17e959e78932b1f2f03 /src/Text/Pandoc/Readers/Docx
parent5b1d841a6fe1713837344922bc53d08b550b4337 (diff)
downloadpandoc-d4748038d76dd430f7c760e73487172a3264c5de.tar.gz
Docx Reader: Fix font style parsing.
Before we just checked for the existence of a tag. Now, we make sure to check for its on/off value.
Diffstat (limited to 'src/Text/Pandoc/Readers/Docx')
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse.hs39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
index 175bf2784..32b0f8d93 100644
--- a/src/Text/Pandoc/Readers/Docx/Parse.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -652,30 +652,45 @@ elemToParagraphStyle ns element
}
elemToParagraphStyle _ _ = defaultParagraphStyle
+checkOnOff :: NameSpaces -> Element -> QName -> Bool
+checkOnOff ns rPr tag
+ | Just t <- findChild tag rPr
+ , Just val <- findAttr (elemName ns "w" "val") t =
+ case val of
+ "true" -> True
+ "false" -> False
+ "on" -> True
+ "off" -> False
+ "1" -> True
+ "0" -> False
+ _ -> False
+ | Just _ <- findChild tag rPr = True
+checkOnOff _ _ _ = False
+
elemToRunStyle :: NameSpaces -> Element -> RunStyle
elemToRunStyle ns element
| Just rPr <- findChild (elemName ns "w" "rPr") element =
RunStyle
{
- isBold = isJust $ findChild (QName "b" (lookup "w" ns) (Just "w")) rPr
- , isItalic = isJust $ findChild (QName "i" (lookup "w" ns) (Just "w")) rPr
- , isSmallCaps = isJust $ findChild (QName "smallCaps" (lookup "w" ns) (Just "w")) rPr
- , isStrike = isJust $ findChild (QName "strike" (lookup "w" ns) (Just "w")) rPr
+ isBold = checkOnOff ns rPr (elemName ns "w" "b")
+ , isItalic = checkOnOff ns rPr (elemName ns "w" "i")
+ , isSmallCaps = checkOnOff ns rPr (elemName ns "w" "smallCaps")
+ , isStrike = checkOnOff ns rPr (elemName ns "w" "strike")
, isSuperScript =
(Just "superscript" ==
- (findChild (QName "vertAlign" (lookup "w" ns) (Just "w")) rPr >>=
- findAttr (QName "val" (lookup "w" ns) (Just "w"))))
+ (findChild (elemName ns "w" "vertAlign") rPr >>=
+ findAttr (elemName ns "w" "val")))
, isSubScript =
(Just "subscript" ==
- (findChild (QName "vertAlign" (lookup "w" ns) (Just "w")) rPr >>=
- findAttr (QName "val" (lookup "w" ns) (Just "w"))))
+ (findChild (elemName ns "w" "vertAlign") rPr >>=
+ findAttr (elemName ns "w" "val")))
, rUnderline =
- findChild (QName "u" (lookup "w" ns) (Just "w")) rPr >>=
- findAttr (QName "val" (lookup "w" ns) (Just "w"))
+ findChild (elemName ns "w" "u") rPr >>=
+ findAttr (elemName ns "w" "val")
, rStyle =
- findChild (QName "rStyle" (lookup "w" ns) (Just "w")) rPr >>=
- findAttr (QName "val" (lookup "w" ns) (Just "w"))
+ findChild (elemName ns "w" "rStyle") rPr >>=
+ findAttr (elemName ns "w" "val")
}
elemToRunStyle _ _ = defaultRunStyle