aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs23
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse.hs26
2 files changed, 31 insertions, 18 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index bcfa4082e..2c436f76f 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -202,17 +202,30 @@ runStyleToContainers rPr =
[Container $ (\ils -> Code ("", [], []) (concatMap ilToCode ils))]
spanClassToContainers s | s `elem` spansToKeep =
[Container $ Span ("", [s], [])]
- spanClassToContainers _ = []
+ spanClassToContainers _ = []
classContainers = case rStyle rPr of
Nothing -> []
Just s -> spanClassToContainers s
+ resolveFmt :: Bool -> Maybe Bool -> Bool
+ resolveFmt _ (Just True) = True
+ resolveFmt _ (Just False) = False
+ resolveFmt bool Nothing = bool
+
formatters = map Container $ mapMaybe id
- [ if isBold rPr then (Just Strong) else Nothing
- , if isItalic rPr then (Just Emph) else Nothing
- , if isSmallCaps rPr then (Just SmallCaps) else Nothing
- , if isStrike rPr then (Just Strikeout) else Nothing
+ [ if resolveFmt (rStyle rPr == Just "Bold") (isBold rPr)
+ then (Just Strong)
+ else Nothing
+ , if resolveFmt (rStyle rPr == Just "Italic") (isItalic rPr)
+ then (Just Emph)
+ else Nothing
+ , if resolveFmt False (isSmallCaps rPr)
+ then (Just SmallCaps)
+ else Nothing
+ , if resolveFmt False (isStrike rPr)
+ then (Just Strikeout)
+ else Nothing
, if isSuperScript rPr then (Just Superscript) else Nothing
, if isSubScript rPr then (Just Subscript) else Nothing
, rUnderline rPr >>=
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