JATS writer: ensure figures are wrapped with <p> in list items.

This prevents the generation of invalid output.
This commit is contained in:
Albert Krewinkel 2021-11-12 13:07:25 +01:00
parent da96e1ff40
commit 96a01451ef
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
2 changed files with 34 additions and 15 deletions

View file

@ -551,6 +551,7 @@ inlineToJATS _ (Image (ident,_,kvs) _ (src, tit)) = do
return $ selfClosingTag "inline-graphic" attr
isParaOrList :: Block -> Bool
isParaOrList SimpleFigure{} = False -- implicit figures are not paragraphs
isParaOrList Para{} = True
isParaOrList Plain{} = True
isParaOrList BulletList{} = True

View file

@ -61,21 +61,39 @@ tests =
, "</fn></p>"
])
]
, "bullet list" =: bulletList [ plain $ text "first"
, plain $ text "second"
, plain $ text "third"
]
=?> "<list list-type=\"bullet\">\n\
\ <list-item>\n\
\ <p>first</p>\n\
\ </list-item>\n\
\ <list-item>\n\
\ <p>second</p>\n\
\ </list-item>\n\
\ <list-item>\n\
\ <p>third</p>\n\
\ </list-item>\n\
\</list>"
, testGroup "bullet list"
[ "plain items" =: bulletList [ plain $ text "first"
, plain $ text "second"
, plain $ text "third"
]
=?> "<list list-type=\"bullet\">\n\
\ <list-item>\n\
\ <p>first</p>\n\
\ </list-item>\n\
\ <list-item>\n\
\ <p>second</p>\n\
\ </list-item>\n\
\ <list-item>\n\
\ <p>third</p>\n\
\ </list-item>\n\
\</list>"
, "item with implicit figure" =:
bulletList [ simpleFigure (text "caption") "a.png" "" ] =?>
T.unlines
[ "<list list-type=\"bullet\">"
, " <list-item>"
, " <p specific-use=\"wrapper\">"
, " <fig>"
, " <caption><p>caption</p></caption>"
, " <graphic mimetype=\"image\" mime-subtype=\"png\"" <>
" xlink:href=\"a.png\" xlink:title=\"\" />"
, " </fig>"
, " </p>"
, " </list-item>"
, "</list>"
]
]
, testGroup "definition lists"
[ "with internal link" =: definitionList [(link "#go" "" (str "testing"),
[plain (text "hi there")])] =?>