aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/Docx/Parse.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs
index 5d54d70a8..c2ad9e837 100644
--- a/src/Text/Pandoc/Readers/Docx/Parse.hs
+++ b/src/Text/Pandoc/Readers/Docx/Parse.hs
@@ -1361,14 +1361,20 @@ findBlip el = do
-- return svg if present:
filterElementName (\(QName tag _ _) -> tag == "svgBlip") el `mplus` pure blip
+-- | Checks if any style in the style hierarchy is a caption style.
hasCaptionStyle :: ParagraphStyle -> Bool
-hasCaptionStyle parstyle = any (isCaptionStyleName . pStyleName) (pStyle parstyle)
+hasCaptionStyle =
+ any (isCaptionStyleName . pStyleName) . concatMap nestedStyles . pStyle
where -- note that these are case insensitive:
isCaptionStyleName "caption" = True
isCaptionStyleName "table caption" = True
isCaptionStyleName "image caption" = True
isCaptionStyleName _ = False
+ -- Gets all the style names in the style hierarchy
+ nestedStyles :: ParStyle -> [ParStyle]
+ nestedStyles ps = ps : maybe [] nestedStyles (psParentStyle ps)
+
stripCaptionLabel :: [Element] -> [Element]
stripCaptionLabel els =
if any isNumberElt els