mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-21 05:43:39 +08:00
Docx reader: Support parsing of highlighted text.
This commit is contained in:
@@ -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 =
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" >>=
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
```
|
||||
% pandoc -f markdown+mark -t html
|
||||
==Hi==
|
||||
^D
|
||||
<p><mark>Hi</mark></p>
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f markdown+mark -t latex
|
||||
==Hi==
|
||||
^D
|
||||
\hl{Hi}
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f markdown+mark -t rst
|
||||
==Hi==
|
||||
^D
|
||||
:mark:`Hi`
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f html -t markdown+mark
|
||||
<mark>Hi</mark>
|
||||
^D
|
||||
==Hi==
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f html -t markdown
|
||||
<mark>Hi</mark>
|
||||
^D
|
||||
[Hi]{.mark}
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f rst -t markdown+mark
|
||||
:mark:`Hi`
|
||||
^D
|
||||
==Hi==
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f markdown+mark -t docx | pandoc -f docx -t markdown+mark
|
||||
==Hi==
|
||||
^D
|
||||
==Hi==
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f latex -t markdown+mark
|
||||
\hl{Hi}
|
||||
^D
|
||||
==Hi==
|
||||
```
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
,OrderedList (1,LowerAlpha,DefaultDelim)
|
||||
[[Para [Str "This",Space,Str "is",Space,Str "at",Space,Str "the",Space,Str "second",Space,Str "level"]
|
||||
,OrderedList (1,LowerRoman,DefaultDelim)
|
||||
[[Para [Str "This",Space,Str "is",Space,Emph [Str "at",Space,Strong [Str "the",Space,Str "third",Space,Str "level"],Str ",",Space,Str "and",Space,Str "I",Space,Str "want",Space,Str "to"],Space,Str "test",Space,Str "normalization",Space,Str "here."]]]]]]]]
|
||||
[[Para [Str "This",Space,Str "is",Space,Emph [Str "at",Space,Strong [Str "the",Space,Span ("",["mark"],[]) [Str "th"],Str "i",Span ("",["mark"],[]) [Str "rd"],Space,Str "level"],Str ",",Space,Str "and",Space,Str "I",Space,Str "want",Space,Str "to"],Space,Str "test",Space,Str "normalization",Space,Str "here."]]]]]]]]
|
||||
|
||||
Reference in New Issue
Block a user