Docx Reader: Introduce function for resolving dependent run styles.
We always favor an explicit positive or negative in a style in a descendent, and only turn to the ancestor if nothing is set. We also introduce an (empty) list of styles that are black-listed. We won't check them. (Think underlines in hyperlinks).
This commit is contained in:
parent
99491f0d98
commit
03d5d8e596
1 changed files with 31 additions and 0 deletions
|
@ -228,6 +228,37 @@ parPartToString (InternalHyperLink _ runs) = concatMap runToString runs
|
|||
parPartToString (ExternalHyperLink _ runs) = concatMap runToString runs
|
||||
parPartToString _ = ""
|
||||
|
||||
blacklistedCharStyles :: [String]
|
||||
blacklistedCharStyles = []
|
||||
|
||||
resolveDependentRunStyle :: RunStyle -> RunStyle
|
||||
resolveDependentRunStyle rPr
|
||||
| Just (s, _) <- rStyle rPr, s `elem` blacklistedCharStyles =
|
||||
rPr{rStyle = Nothing}
|
||||
| Just (_, cs) <- rStyle rPr =
|
||||
let rPr' = resolveDependentRunStyle cs
|
||||
in
|
||||
RunStyle { isBold = case isBold rPr of
|
||||
Just bool -> Just bool
|
||||
Nothing -> isBold rPr'
|
||||
, isItalic = case isItalic rPr of
|
||||
Just bool -> Just bool
|
||||
Nothing -> isItalic rPr'
|
||||
, isSmallCaps = case isSmallCaps rPr of
|
||||
Just bool -> Just bool
|
||||
Nothing -> isSmallCaps rPr'
|
||||
, isStrike = case isStrike rPr of
|
||||
Just bool -> Just bool
|
||||
Nothing -> isStrike rPr'
|
||||
, rVertAlign = case rVertAlign rPr of
|
||||
Just valign -> Just valign
|
||||
Nothing -> rVertAlign rPr'
|
||||
, rUnderline = case rUnderline rPr of
|
||||
Just ulstyle -> Just ulstyle
|
||||
Nothing -> rUnderline rPr'
|
||||
, rStyle = Nothing }
|
||||
| otherwise = rPr{rStyle = Nothing}
|
||||
|
||||
runStyleToTransform :: RunStyle -> (Inlines -> Inlines)
|
||||
runStyleToTransform rPr
|
||||
| Just (s, _) <- rStyle rPr
|
||||
|
|
Loading…
Add table
Reference in a new issue