@@ -543,6 +543,10 @@ read_plain_text = fst ^&&& read_plain_text' >>% recover
543543 extractText (XML.Text cData) = succeedWith (XML.cdData cData)
544544 extractText _ = failEmpty
545545
546+read_text_seq :: InlineMatcher
547+read_text_seq = matchingElement NsText "sequence"
548+ $ matchChildContent [] read_plain_text
549+
546550
547551-- specifically. I honor that, although the current implementation of '(<>)'
548552-- for 'Inlines' in "Text.Pandoc.Builder" will collaps them agein.
@@ -591,7 +595,8 @@ read_paragraph = matchingElement NsText "p"
591595 , read_reference_start
592596 , read_bookmark_ref
593597 , read_reference_ref
594− , read_frame
598+ , read_maybe_nested_img_frame
599+ , read_text_seq
595600 ] read_plain_text
596601
597602
@@ -616,7 +621,7 @@ read_header = matchingElement NsText "h"
616621 , read_reference_start
617622 , read_bookmark_ref
618623 , read_reference_ref
619− , read_frame
624+ , read_maybe_nested_img_frame
620625 ] read_plain_text
621626 ) -< blocks
622627 anchor <- getHeaderAnchor -< children
@@ -726,18 +731,26 @@ read_table_cell = matchingElement NsTable "table-cell"
726731----------------------
727732
728733--
729−read_frame :: InlineMatcher
730−read_frame = matchingElement NsDraw "frame"
731− $ proc blocks -> do
732− w <- ( findAttr' NsSVG "width" ) -< ()
733− h <- ( findAttr' NsSVG "height" ) -< ()
734− attr <- arr (uncurry image_attributes) -< (w, h)
735− titleNodes <- ( matchChildContent' [ read_frame_title ] ) -< blocks
736− title <- arr inlineListToIdentifier -< (toList titleNodes)
737− src <- matchChildContent' [ read_image_src ] -< blocks
738− resource <- lookupResource -< src
739− _ <- updateMediaWithResource -< resource
740− arr (uncurry4 imageWith ) -< (attr, src, title, mempty)
734+read_maybe_nested_img_frame :: InlineMatcher
735+read_maybe_nested_img_frame = matchingElement NsDraw "frame"
736+ $ proc blocks -> do
737+ img <- (findChild' NsDraw "image") -< ()
738+ case img of
739+ Just _ -> read_frame -< blocks
740+ Nothing -> matchChildContent' [ read_frame_text_box ] -< blocks
741+
742+read_frame :: OdtReaderSafe Inlines Inlines
743+read_frame =
744+ proc blocks -> do
745+ w <- ( findAttr' NsSVG "width" ) -< ()
746+ h <- ( findAttr' NsSVG "height" ) -< ()
747+ titleNodes <- ( matchChildContent' [ read_frame_title ] ) -< blocks
748+ src <- matchChildContent' [ read_image_src ] -< blocks
749+ resource <- lookupResource -< src
750+ _ <- updateMediaWithResource -< resource
751+ alt <- (matchChildContent [] read_plain_text) -< blocks
752+ arr (uncurry4 imageWith ) -<
753+ (image_attributes w h, src, inlineListToIdentifier (toList titleNodes), alt)
741754
742755image_attributes :: Maybe String -> Maybe String -> Attr
743756image_attributes x y =
@@ -749,17 +762,31 @@ image_attributes x y =
749762
750763read_image_src :: (Namespace, ElementName, OdtReader Anchor Anchor)
751764read_image_src = matchingElement NsDraw "image"
752− $ proc _ -> do
753− imgSrc <- findAttr NsXLink "href" -< ()
754− case imgSrc of
755− Right src -> returnV src -<< ()
756− Left _ -> returnV "" -< ()
765+ $ proc _ -> do
766+ imgSrc <- findAttr NsXLink "href" -< ()
767+ case imgSrc of
768+ Right src -> returnV src -<< ()
769+ Left _ -> returnV "" -< ()
757770
758771read_frame_title :: InlineMatcher
759772read_frame_title = matchingElement NsSVG "title"
760773 $ (matchChildContent [] read_plain_text)
761774
762−
775+read_frame_text_box :: InlineMatcher
776+read_frame_text_box = matchingElement NsDraw "text-box"
777+ $ proc blocks -> do
778+ paragraphs <- (matchChildContent' [ read_paragraph ]) -< blocks
779+ case toList paragraphs of
780+ (p : []) -> -- require only a single paragraph
781+ arr read_img_with_caption -< p
782+ _ ->
783+ arr fromList -< []
784+
785+read_img_with_caption :: Block -> Inlines
786+read_img_with_caption (Para ((Image attr _ target) : txt)) =
787+ singleton (Image attr txt target) -- override caption with the text that follows
788+read_img_with_caption _ =
789+ fromList []
763790
764791----------------------
765792-- Internal links