aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Docx
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2014-08-12 22:15:09 -0400
committerJesse Rosenthal <jrosenthal@jhu.edu>2014-08-12 22:39:18 -0400
commit194ed8885236d8446b34f44ecf16d4fa9e5c5cbe (patch)
treeacb4c8a1d0e8337201d5f3cca8f50cd5dcb9c796 /src/Text/Pandoc/Readers/Docx
parentaae71ad595f78f6cb7dd1cc5cb0aaef0d3aaf5f1 (diff)
downloadpandoc-194ed8885236d8446b34f44ecf16d4fa9e5c5cbe.tar.gz
Docx reader: accept explicit "Italic" and "Bold" rStyles.
Note that "Italic" can be on, and, from the last commit, `<w:i>` can be present, but be turned off. In that case, the turned-off tag takes precedence. So, we have to distinguish between something being off and something not being there. Hence, isItalic, isBold, isStrike, and isSmallCaps have become Maybes.
Diffstat (limited to 'src/Text/Pandoc/Readers/Docx')
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse.hs26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
index 32b0f8d93..939fcde27 100644
--- a/src/Text/Pandoc/Readers/Docx/Parse.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -196,10 +196,10 @@ data Run = Run RunStyle [RunElem]
data RunElem = TextRun String | LnBrk | Tab
deriving Show
-data RunStyle = RunStyle { isBold :: Bool
- , isItalic :: Bool
- , isSmallCaps :: Bool
- , isStrike :: Bool
+data RunStyle = RunStyle { isBold :: Maybe Bool
+ , isItalic :: Maybe Bool
+ , isSmallCaps :: Maybe Bool
+ , isStrike :: Maybe Bool
, isSuperScript :: Bool
, isSubScript :: Bool
, rUnderline :: Maybe String
@@ -207,10 +207,10 @@ data RunStyle = RunStyle { isBold :: Bool
deriving Show
defaultRunStyle :: RunStyle
-defaultRunStyle = RunStyle { isBold = False
- , isItalic = False
- , isSmallCaps = False
- , isStrike = False
+defaultRunStyle = RunStyle { isBold = Nothing
+ , isItalic = Nothing
+ , isSmallCaps = Nothing
+ , isStrike = Nothing
, isSuperScript = False
, isSubScript = False
, rUnderline = Nothing
@@ -652,20 +652,20 @@ elemToParagraphStyle ns element
}
elemToParagraphStyle _ _ = defaultParagraphStyle
-checkOnOff :: NameSpaces -> Element -> QName -> Bool
+checkOnOff :: NameSpaces -> Element -> QName -> Maybe Bool
checkOnOff ns rPr tag
| Just t <- findChild tag rPr
, Just val <- findAttr (elemName ns "w" "val") t =
- case val of
- "true" -> True
+ Just $ case val of
+ "true" -> True
"false" -> False
"on" -> True
"off" -> False
"1" -> True
"0" -> False
_ -> False
- | Just _ <- findChild tag rPr = True
-checkOnOff _ _ _ = False
+ | Just _ <- findChild tag rPr = Just True
+checkOnOff _ _ _ = Nothing
elemToRunStyle :: NameSpaces -> Element -> RunStyle