@@ -543,6 +543,10 @@ read_plain_text = fst ^&&& read_plain_text' >>% recover
543 extractText (XML.Text cData) = succeedWith (XML.cdData cData)
543 extractText (XML.Text cData) = succeedWith (XML.cdData cData)
544 extractText _ = failEmpty
544 extractText _ = failEmpty
546+read_text_seq :: InlineMatcher
547+read_text_seq = matchingElement NsText "sequence"
548+ $ matchChildContent [] read_plain_text
547-- specifically. I honor that, although the current implementation of '(<>)'
551-- specifically. I honor that, although the current implementation of '(<>)'
548-- for 'Inlines' in "Text.Pandoc.Builder" will collaps them agein.
552-- for 'Inlines' in "Text.Pandoc.Builder" will collaps them agein.
@@ -591,7 +595,8 @@ read_paragraph = matchingElement NsText "p"
591 , read_reference_start
595 , read_reference_start
592 , read_bookmark_ref
596 , read_bookmark_ref
593 , read_reference_ref
597 , read_reference_ref
594− , read_frame
598+ , read_maybe_nested_img_frame
595 ] read_plain_text
600 ] read_plain_text
@@ -616,7 +621,7 @@ read_header = matchingElement NsText "h"
616 , read_reference_start
621 , read_reference_start
617 , read_bookmark_ref
622 , read_bookmark_ref
618 , read_reference_ref
623 , read_reference_ref
619− , read_frame
624+ , read_maybe_nested_img_frame
620 ] read_plain_text
625 ] read_plain_text
621 ) -< blocks
626 ) -< blocks
622 anchor <- getHeaderAnchor -< children
627 anchor <- getHeaderAnchor -< children
@@ -726,18 +731,26 @@ read_table_cell = matchingElement NsTable "table-cell"
726----------------------
731----------------------
729−read_frame :: InlineMatcher
734+read_maybe_nested_img_frame :: InlineMatcher
730−read_frame = matchingElement NsDraw "frame"
735+read_maybe_nested_img_frame = matchingElement NsDraw "frame"
731− $ proc blocks -> do
736+ $ proc blocks -> do
737+ img <- (findChild' NsDraw "image") -< ()
739+ Just _ -> read_frame -< blocks
740+ Nothing -> matchChildContent' [ read_frame_text_box ] -< blocks
742+read_frame :: OdtReaderSafe Inlines Inlines
732− w <- ( findAttr' NsSVG "width" ) -< ()
745+ w <- ( findAttr' NsSVG "width" ) -< ()
733− h <- ( findAttr' NsSVG "height" ) -< ()
746+ h <- ( findAttr' NsSVG "height" ) -< ()
734− attr <- arr (uncurry image_attributes) -< (w, h)
735− titleNodes <- ( matchChildContent' [ read_frame_title ] ) -< blocks
747+ titleNodes <- ( matchChildContent' [ read_frame_title ] ) -< blocks
736− title <- arr inlineListToIdentifier -< (toList titleNodes)
737− src <- matchChildContent' [ read_image_src ] -< blocks
748+ src <- matchChildContent' [ read_image_src ] -< blocks
738− resource <- lookupResource -< src
749+ resource <- lookupResource -< src
739− _ <- updateMediaWithResource -< resource
750+ _ <- updateMediaWithResource -< resource
751+ alt <- (matchChildContent [] read_plain_text) -< blocks
740− arr (uncurry4 imageWith ) -< (attr, src, title, mempty)
752+ arr (uncurry4 imageWith ) -<
753+ (image_attributes w h, src, inlineListToIdentifier (toList titleNodes), alt)
742image_attributes :: Maybe String -> Maybe String -> Attr
755image_attributes :: Maybe String -> Maybe String -> Attr
743image_attributes x y =
756image_attributes x y =
@@ -749,17 +762,31 @@ image_attributes x y =
750read_image_src :: (Namespace, ElementName, OdtReader Anchor Anchor)
763read_image_src :: (Namespace, ElementName, OdtReader Anchor Anchor)
751read_image_src = matchingElement NsDraw "image"
764read_image_src = matchingElement NsDraw "image"
752− $ proc _ -> do
765+ $ proc _ -> do
753− imgSrc <- findAttr NsXLink "href" -< ()
766+ imgSrc <- findAttr NsXLink "href" -< ()
754− case imgSrc of
767+ case imgSrc of
755− Right src -> returnV src -<< ()
768+ Right src -> returnV src -<< ()
756− Left _ -> returnV "" -< ()
769+ Left _ -> returnV "" -< ()
758read_frame_title :: InlineMatcher
771read_frame_title :: InlineMatcher
759read_frame_title = matchingElement NsSVG "title"
772read_frame_title = matchingElement NsSVG "title"
760 $ (matchChildContent [] read_plain_text)
773 $ (matchChildContent [] read_plain_text)
762−
775+read_frame_text_box :: InlineMatcher
776+read_frame_text_box = matchingElement NsDraw "text-box"
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
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 _ =
764----------------------
791----------------------
765-- Internal links
792-- Internal links