diff options
-rw-r--r-- | src/Text/Pandoc/Writers/JATS.hs | 10 | ||||
-rw-r--r-- | test/tables.jats | 368 |
2 files changed, 100 insertions, 278 deletions
diff --git a/src/Text/Pandoc/Writers/JATS.hs b/src/Text/Pandoc/Writers/JATS.hs index 8824eeb24..901bcb646 100644 --- a/src/Text/Pandoc/Writers/JATS.hs +++ b/src/Text/Pandoc/Writers/JATS.hs @@ -316,6 +316,9 @@ tableItemToJATS :: PandocMonad m -> Bool -> [Block] -> JATS m Doc +tableItemToJATS opts isHeader [Plain item] = + inTags True (if isHeader then "th" else "td") [] <$> + inlinesToJATS opts item tableItemToJATS opts isHeader item = (inTags True (if isHeader then "th" else "td") [] . vcat) <$> mapM (blockToJATS opts) item @@ -405,8 +408,11 @@ inlineToJATS opts (Link (ident,_,kvs) txt ('#':src, _)) = do [("alt", stringify txt) | not (null txt)] ++ [("rid", src)] ++ [(k,v) | (k,v) <- kvs, k `elem` ["ref-type", "specific-use"]] - contents <- inlinesToJATS opts txt - return $ inTags False "xref" attr contents + if null txt + then return $ selfClosingTag "xref" attr + else do + contents <- inlinesToJATS opts txt + return $ inTags False "xref" attr contents inlineToJATS opts (Link (ident,_,kvs) txt (src, tit)) = do let attr = [("id", ident) | not (null ident)] ++ [("ext-link-type", "uri"), diff --git a/test/tables.jats b/test/tables.jats index b213a83bb..46af61635 100644 --- a/test/tables.jats +++ b/test/tables.jats @@ -15,92 +15,60 @@ <thead> <tr> <th> - <p> - Right - </p> + Right </th> <th> - <p> - Left - </p> + Left </th> <th> - <p> - Center - </p> + Center </th> <th> - <p> - Default - </p> + Default </th> </tr> </thead> <tbody> <tr> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> </tr> <tr> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> </tr> <tr> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> </tr> </tbody> @@ -117,92 +85,60 @@ <thead> <tr> <th> - <p> - Right - </p> + Right </th> <th> - <p> - Left - </p> + Left </th> <th> - <p> - Center - </p> + Center </th> <th> - <p> - Default - </p> + Default </th> </tr> </thead> <tbody> <tr> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> </tr> <tr> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> </tr> <tr> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> </tr> </tbody> @@ -224,92 +160,60 @@ <thead> <tr> <th> - <p> - Right - </p> + Right </th> <th> - <p> - Left - </p> + Left </th> <th> - <p> - Center - </p> + Center </th> <th> - <p> - Default - </p> + Default </th> </tr> </thead> <tbody> <tr> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> </tr> <tr> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> </tr> <tr> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> </tr> </tbody> @@ -332,70 +236,46 @@ <thead> <tr> <th> - <p> - Centered Header - </p> + Centered Header </th> <th> - <p> - Left Aligned - </p> + Left Aligned </th> <th> - <p> - Right Aligned - </p> + Right Aligned </th> <th> - <p> - Default aligned - </p> + Default aligned </th> </tr> </thead> <tbody> <tr> <td> - <p> - First - </p> + First </td> <td> - <p> - row - </p> + row </td> <td> - <p> - 12.0 - </p> + 12.0 </td> <td> - <p> - Example of a row that spans multiple lines. - </p> + Example of a row that spans multiple lines. </td> </tr> <tr> <td> - <p> - Second - </p> + Second </td> <td> - <p> - row - </p> + row </td> <td> - <p> - 5.0 - </p> + 5.0 </td> <td> - <p> - Here’s another one. Note the blank line between rows. - </p> + Here’s another one. Note the blank line between rows. </td> </tr> </tbody> @@ -412,70 +292,46 @@ <thead> <tr> <th> - <p> - Centered Header - </p> + Centered Header </th> <th> - <p> - Left Aligned - </p> + Left Aligned </th> <th> - <p> - Right Aligned - </p> + Right Aligned </th> <th> - <p> - Default aligned - </p> + Default aligned </th> </tr> </thead> <tbody> <tr> <td> - <p> - First - </p> + First </td> <td> - <p> - row - </p> + row </td> <td> - <p> - 12.0 - </p> + 12.0 </td> <td> - <p> - Example of a row that spans multiple lines. - </p> + Example of a row that spans multiple lines. </td> </tr> <tr> <td> - <p> - Second - </p> + Second </td> <td> - <p> - row - </p> + row </td> <td> - <p> - 5.0 - </p> + 5.0 </td> <td> - <p> - Here’s another one. Note the blank line between rows. - </p> + Here’s another one. Note the blank line between rows. </td> </tr> </tbody> @@ -491,68 +347,44 @@ <tbody> <tr> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> <td> - <p> - 12 - </p> + 12 </td> </tr> <tr> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> <td> - <p> - 123 - </p> + 123 </td> </tr> <tr> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> <td> - <p> - 1 - </p> + 1 </td> </tr> </tbody> @@ -568,46 +400,30 @@ <tbody> <tr> <td> - <p> - First - </p> + First </td> <td> - <p> - row - </p> + row </td> <td> - <p> - 12.0 - </p> + 12.0 </td> <td> - <p> - Example of a row that spans multiple lines. - </p> + Example of a row that spans multiple lines. </td> </tr> <tr> <td> - <p> - Second - </p> + Second </td> <td> - <p> - row - </p> + row </td> <td> - <p> - 5.0 - </p> + 5.0 </td> <td> - <p> - Here’s another one. Note the blank line between rows. - </p> + Here’s another one. Note the blank line between rows. </td> </tr> </tbody> |