@@ -451,6 +451,14 @@ t_table = ( Table
451451 tCell' i = Cell (" id" , [" kls" ], [(" k1" , " v1" ), (" k2" , " v2" )]) AlignDefault 1 1 [Plain i]
452452 tRow = Row (" id" , [" kls" ], [(" k1" , " v1" ), (" k2" , " v2" )])
453453
454+ t_figure :: (Block , ByteString )
455+ t_figure = (Figure
456+ (" id" , [" kls" ], [(" k1" , " v1" ), (" k2" , " v2" )])
457+ (Caption (Just [Str " hello" ]) [Para [Str " cap content" ]])
458+ [Para [Str " fig content" ]]
459+ ,[s |{"t":"Figure","c":[["id",["kls"],[["k1","v1"],["k2","v2"]]],[[{"t":"Str","c":"hello"}],[{"t":"Para","c":[{"t":"Str","c":"cap content"}]}]],[{"t":"Para","c":[{"t":"Str","c":"fig content"}]}]]}|]
460+ )
461+
454462t_div :: (Block , ByteString )
455463t_div = ( Div (" id" , [" kls" ], [(" k1" , " v1" ), (" k2" , " v2" )]) [Para [Str " Hello" ]]
456464 , [s |{"t":"Div","c":[["id",["kls"],[["k1","v1"],["k2","v2"]]],[{"t":"Para","c":[{"t":"Str","c":"Hello"}]}]]}|]
@@ -658,15 +666,17 @@ t_tableNormExample = testCase "table normalization example" assertion
658666 generated = table emptyCaption spec (th initialHeads) [initialTB] (tf initialHeads)
659667
660668p_figureRepresentation :: Property
661- p_figureRepresentation = forAll (arbitrary :: Gen [Inline ]) ( \ figureCaption ->
669+ p_figureRepresentation = forAll (arbitrary :: Gen [Inline ]) $ \ figureCaption ->
662670 simpleFigureWith
663671 (" " , [] , [] )
664672 (Builder. fromList figureCaption)
665673 " url"
666674 " title" ==
667675 Builder. fromList
668- [Para [Image (" " , [] , [] ) figureCaption (" url" , " fig:title" ) ]]
669- )
676+ [Figure
677+ nullAttr
678+ (Caption Nothing [Plain figureCaption | not (null figureCaption)])
679+ [Plain [Image (" " , [] , [] ) [Str " title" ] (" url" , " title" ) ]]]
670680
671681tests :: [Test ]
672682tests =
@@ -745,6 +755,7 @@ tests =
745755 , testEncodeDecode " DefinitionList" t_definitionlist
746756 , testEncodeDecode " Header" t_header
747757 , testEncodeDecode " Table" t_table
758+ , testEncodeDecode " Figure" t_figure
748759 , testEncodeDecode " Div" t_div
749760 , testEncodeDecode " Null" t_null
750761 ]
0 commit comments