aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-09-05 20:19:13 +0200
committerJohn MacFarlane <[email protected]>2025-09-06 10:48:22 +0200
commit536d548335e028c01021dc7ddddf9b88e43d1a78 (patch)
treec7a15fa917be880e787414559303a280e38a7b49 /src/Text
parent1e7138823b8916ecae236532181092491f57367b (diff)
Docx reader: better handling of AlternateContent.
This revises the solution to #9214 in commit 2e8ecb3 in order to handle a standard Word way of inserting emojis. Closes #11113.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse.hs22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
index 322cc8f92..826f723f6 100644
--- a/src/Text/Pandoc/Readers/Docx/Parse.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -158,6 +158,19 @@ unwrapElement ns element
= concatMap (unwrapElement ns) (elChildren sdtContent)
| isElem ns "w" "smartTag" element
= concatMap (unwrapElement ns) (elChildren element)
+ | isElem ns "w" "p" element
+ , textboxes@(_:_) <- findChildrenByName ns "w" "r" element >>=
+ findChildrenByName ns "mc" "AlternateContent" >>=
+ findChildrenByName ns "mc" "Fallback" >>=
+ findChildrenByName ns "w" "pict" >>=
+ findChildrenByName ns "v" "shape" >>=
+ findChildrenByName ns "v" "textbox" >>=
+ findChildrenByName ns "w" "txbxContent"
+ = concatMap (unwrapElement ns) (concatMap elChildren textboxes) -- handle #9214
+ | isElem ns "w" "r" element
+ , Just fallback <- findChildByName ns "mc" "AlternateContent" element >>=
+ findChildByName ns "mc" "Fallback"
+ = [element{ elContent = concatMap (unwrapContent ns) (elContent fallback) }]
| otherwise
= [element{ elContent = concatMap (unwrapContent ns) (elContent element) }]
@@ -1159,15 +1172,6 @@ childElemToRun _ _ = throwError WrongElem
elemToRun :: NameSpaces -> Element -> D [Run]
elemToRun ns element
| isElem ns "w" "r" element
- , Just altCont <- findChildByName ns "mc" "AlternateContent" element =
- do let choices = findChildrenByName ns "mc" "Choice" altCont
- choiceChildren = concatMap (take 1 . elChildren) choices
- outputs <- mapD (childElemToRun ns) choiceChildren
- case outputs of
- r : _ -> return r
- [] -> throwError WrongElem
-elemToRun ns element
- | isElem ns "w" "r" element
, Just drawingElem <- findChildByName ns "w" "drawing" element =
childElemToRun ns drawingElem
elemToRun ns element