diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2022-11-19 13:28:10 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2022-11-19 13:28:10 -0800 |
| commit | 4b4771f062a227153109d0ba2f9d125c82f411a8 (patch) | |
| tree | 4c1b752c619e1951a7d1eff72a2a6bc0c4460b9a /src/Text | |
| parent | bb0fd13bcba5459e48bafc9be2b2e2d573e22863 (diff) | |
Docx reader: Support parsing of highlighted text.
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Readers/Docx.hs | 2 | ||||
| -rw-r--r-- | src/Text/Pandoc/Readers/Docx/Parse.hs | 1 | ||||
| -rw-r--r-- | src/Text/Pandoc/Readers/Docx/Parse/Styles.hs | 5 |
3 files changed, 8 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index 4e60f412c..0fe9a3b9f 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -305,6 +305,8 @@ runStyleToTransform rPr' = do emph . go rPr{isItalic = Nothing, isItalicCTL = Nothing} | Just True <- bold rPr = strong . go rPr{isBold = Nothing, isBoldCTL = Nothing} + | Just _ <- rHighlight rPr = + spanWith ("",["mark"],[]) . go rPr{rHighlight = Nothing} | Just True <- isSmallCaps rPr = smallcaps . go rPr{isSmallCaps = Nothing} | Just True <- isStrike rPr = diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs index ad67d6170..c36107da7 100644 --- a/src/Text/Pandoc/Readers/Docx/Parse.hs +++ b/src/Text/Pandoc/Readers/Docx/Parse.hs @@ -313,6 +313,7 @@ leftBiasedMergeRunStyle a b = RunStyle , isStrike = isStrike a <|> isStrike b , isRTL = isRTL a <|> isRTL b , isForceCTL = isForceCTL a <|> isForceCTL b + , rHighlight = rHighlight a <|> rHighlight 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 df942579a..050bfecbc 100644 --- a/src/Text/Pandoc/Readers/Docx/Parse/Styles.hs +++ b/src/Text/Pandoc/Readers/Docx/Parse/Styles.hs @@ -111,6 +111,7 @@ data RunStyle = RunStyle { isBold :: Maybe Bool , isStrike :: Maybe Bool , isRTL :: Maybe Bool , isForceCTL :: Maybe Bool + , rHighlight :: Maybe Text , rVertAlign :: Maybe VertAlign , rUnderline :: Maybe Text , rParentStyle :: Maybe CharStyle @@ -140,6 +141,7 @@ defaultRunStyle = RunStyle { isBold = Nothing , isStrike = Nothing , isRTL = Nothing , isForceCTL = Nothing + , rHighlight = Nothing , rVertAlign = Nothing , rUnderline = Nothing , rParentStyle = Nothing @@ -275,6 +277,9 @@ elemToRunStyle ns element parentStyle , isStrike = checkOnOff ns rPr (elemName ns "w" "strike") , isRTL = checkOnOff ns rPr (elemName ns "w" "rtl") , isForceCTL = checkOnOff ns rPr (elemName ns "w" "cs") + , rHighlight = + findChildByName ns "w" "highlight" rPr >>= + findAttrByName ns "w" "val" , rVertAlign = findChildByName ns "w" "vertAlign" rPr >>= findAttrByName ns "w" "val" >>= |
