diff options
author | Nikolay Yakimov <root@livid.pp.ru> | 2020-07-13 19:03:31 +0300 |
---|---|---|
committer | Nikolay Yakimov <root@livid.pp.ru> | 2020-07-13 19:50:06 +0300 |
commit | 22c373370ce6eb414f4e9fe4e70b2a2a1feb6e52 (patch) | |
tree | a5f906f35f8c2e129e9842768f00d745fb836e7e /src/Text/Pandoc/Readers/Docx | |
parent | 804e8eeed2fbcd0b4a52ad908b8ccccf89563097 (diff) | |
download | pandoc-22c373370ce6eb414f4e9fe4e70b2a2a1feb6e52.tar.gz |
[Docx Reader] Only use bCs/iCs on runs with rtl or cs property
Fixes #6514
Diffstat (limited to 'src/Text/Pandoc/Readers/Docx')
-rw-r--r-- | src/Text/Pandoc/Readers/Docx/Parse.hs | 3 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Docx/Parse/Styles.hs | 18 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs index 199ca6d03..eab4f4e0d 100644 --- a/src/Text/Pandoc/Readers/Docx/Parse.hs +++ b/src/Text/Pandoc/Readers/Docx/Parse.hs @@ -259,10 +259,13 @@ newtype Cell = Cell [BodyPart] leftBiasedMergeRunStyle :: RunStyle -> RunStyle -> RunStyle leftBiasedMergeRunStyle a b = RunStyle { isBold = isBold a <|> isBold b + , isBoldCTL = isBoldCTL a <|> isBoldCTL b , isItalic = isItalic a <|> isItalic b + , isItalicCTL = isItalicCTL a <|> isItalicCTL b , isSmallCaps = isSmallCaps a <|> isSmallCaps b , isStrike = isStrike a <|> isStrike b , isRTL = isRTL a <|> isRTL b + , isForceCTL = isForceCTL a <|> isForceCTL b , rVertAlign = rVertAlign a <|> rVertAlign b , rUnderline = rUnderline a <|> rUnderline b , rParentStyle = rParentStyle a diff --git a/src/Text/Pandoc/Readers/Docx/Parse/Styles.hs b/src/Text/Pandoc/Readers/Docx/Parse/Styles.hs index bfbc65cb0..236167187 100644 --- a/src/Text/Pandoc/Readers/Docx/Parse/Styles.hs +++ b/src/Text/Pandoc/Readers/Docx/Parse/Styles.hs @@ -44,7 +44,6 @@ module Text.Pandoc.Readers.Docx.Parse.Styles ( ) where import Codec.Archive.Zip import Control.Applicative ((<|>)) -import Control.Monad.Except import Data.Function (on) import Data.String (IsString(..)) import qualified Data.Map as M @@ -101,10 +100,13 @@ data CharStyle = CharStyle { cStyleId :: CharStyleId } deriving (Show) data RunStyle = RunStyle { isBold :: Maybe Bool + , isBoldCTL :: Maybe Bool , isItalic :: Maybe Bool + , isItalicCTL :: Maybe Bool , isSmallCaps :: Maybe Bool , isStrike :: Maybe Bool , isRTL :: Maybe Bool + , isForceCTL :: Maybe Bool , rVertAlign :: Maybe VertAlign , rUnderline :: Maybe String , rParentStyle :: Maybe CharStyle @@ -121,10 +123,13 @@ data ParStyle = ParStyle { headingLev :: Maybe (ParaStyleName, Int) defaultRunStyle :: RunStyle defaultRunStyle = RunStyle { isBold = Nothing + , isBoldCTL = Nothing , isItalic = Nothing + , isItalicCTL = Nothing , isSmallCaps = Nothing , isStrike = Nothing , isRTL = Nothing + , isForceCTL = Nothing , rVertAlign = Nothing , rUnderline = Nothing , rParentStyle = Nothing @@ -240,20 +245,21 @@ elemToCharStyle :: NameSpaces elemToCharStyle ns element parentStyle = CharStyle <$> (CharStyleId <$> findAttrTextByName ns "w" "styleId" element) <*> getElementStyleName ns element - <*> (Just $ elemToRunStyle ns element parentStyle) + <*> Just (elemToRunStyle ns element parentStyle) elemToRunStyle :: NameSpaces -> Element -> Maybe CharStyle -> RunStyle elemToRunStyle ns element parentStyle | Just rPr <- findChildByName ns "w" "rPr" element = RunStyle { - isBold = checkOnOff ns rPr (elemName ns "w" "b") `mplus` - checkOnOff ns rPr (elemName ns "w" "bCs") - , isItalic = checkOnOff ns rPr (elemName ns "w" "i") `mplus` - checkOnOff ns rPr (elemName ns "w" "iCs") + isBold = checkOnOff ns rPr (elemName ns "w" "b") + , isBoldCTL = checkOnOff ns rPr (elemName ns "w" "bCs") + , isItalic = checkOnOff ns rPr (elemName ns "w" "i") + , isItalicCTL = checkOnOff ns rPr (elemName ns "w" "iCs") , isSmallCaps = checkOnOff ns rPr (elemName ns "w" "smallCaps") , isStrike = checkOnOff ns rPr (elemName ns "w" "strike") , isRTL = checkOnOff ns rPr (elemName ns "w" "rtl") + , isForceCTL = checkOnOff ns rPr (elemName ns "w" "cs") , rVertAlign = findChildByName ns "w" "vertAlign" rPr >>= findAttrByName ns "w" "val" >>= |