diff options
-rw-r--r-- | src/Text/Pandoc/Writers/JATS/Table.hs | 13 | ||||
-rw-r--r-- | test/tables.jats_archiving | 224 | ||||
-rw-r--r-- | test/tables.jats_articleauthoring | 224 | ||||
-rw-r--r-- | test/tables.jats_publishing | 224 |
4 files changed, 355 insertions, 330 deletions
diff --git a/src/Text/Pandoc/Writers/JATS/Table.hs b/src/Text/Pandoc/Writers/JATS/Table.hs index cccd866aa..dd7678f63 100644 --- a/src/Text/Pandoc/Writers/JATS/Table.hs +++ b/src/Text/Pandoc/Writers/JATS/Table.hs @@ -32,12 +32,13 @@ tableToJATS :: PandocMonad m -> JATS m (Doc Text) tableToJATS opts _attr blkCapt specs th tb tf = do blockToJATS <- asks jatsBlockWriter - case toLegacyTable blkCapt specs th tb tf of - ([], aligns, widths, headers, rows) -> captionlessTable aligns widths headers rows - (caption, aligns, widths, headers, rows) -> do - captionDoc <- inTagsIndented "caption" <$> blockToJATS opts (Para caption) - tbl <- captionlessTable aligns widths headers rows - return $ inTags True "table-wrap" [] $ captionDoc $$ tbl + let (caption, aligns, widths, headers, rows) = + toLegacyTable blkCapt specs th tb tf + captionDoc <- if null caption + then return mempty + else inTagsIndented "caption" <$> blockToJATS opts (Para caption) + tbl <- captionlessTable aligns widths headers rows + return $ inTags True "table-wrap" [] $ captionDoc $$ tbl where captionlessTable aligns widths headers rows = do let percent w = tshow (truncate (100*w) :: Integer) <> "*" diff --git a/test/tables.jats_archiving b/test/tables.jats_archiving index 70f71e384..30bacc2e8 100644 --- a/test/tables.jats_archiving +++ b/test/tables.jats_archiving @@ -39,40 +39,42 @@ </table> </table-wrap> <p>Simple table without caption:</p> -<table> - <col align="right" /> - <col align="left" /> - <col align="center" /> - <col align="left" /> - <thead> - <tr> - <th>Right</th> - <th>Left</th> - <th>Center</th> - <th>Default</th> - </tr> - </thead> - <tbody> - <tr> - <td>12</td> - <td>12</td> - <td>12</td> - <td>12</td> - </tr> - <tr> - <td>123</td> - <td>123</td> - <td>123</td> - <td>123</td> - </tr> - <tr> - <td>1</td> - <td>1</td> - <td>1</td> - <td>1</td> - </tr> - </tbody> -</table> +<table-wrap> + <table> + <col align="right" /> + <col align="left" /> + <col align="center" /> + <col align="left" /> + <thead> + <tr> + <th>Right</th> + <th>Left</th> + <th>Center</th> + <th>Default</th> + </tr> + </thead> + <tbody> + <tr> + <td>12</td> + <td>12</td> + <td>12</td> + <td>12</td> + </tr> + <tr> + <td>123</td> + <td>123</td> + <td>123</td> + <td>123</td> + </tr> + <tr> + <td>1</td> + <td>1</td> + <td>1</td> + <td>1</td> + </tr> + </tbody> + </table> +</table-wrap> <p>Simple table indented two spaces:</p> <table-wrap> <caption> @@ -148,79 +150,85 @@ </table> </table-wrap> <p>Multiline table without caption:</p> -<table> - <col width="15*" align="center" /> - <col width="13*" align="left" /> - <col width="16*" align="right" /> - <col width="35*" align="left" /> - <thead> - <tr> - <th>Centered Header</th> - <th>Left Aligned</th> - <th>Right Aligned</th> - <th>Default aligned</th> - </tr> - </thead> - <tbody> - <tr> - <td>First</td> - <td>row</td> - <td>12.0</td> - <td>Example of a row that spans multiple lines.</td> - </tr> - <tr> - <td>Second</td> - <td>row</td> - <td>5.0</td> - <td>Here’s another one. Note the blank line between rows.</td> - </tr> - </tbody> -</table> +<table-wrap> + <table> + <col width="15*" align="center" /> + <col width="13*" align="left" /> + <col width="16*" align="right" /> + <col width="35*" align="left" /> + <thead> + <tr> + <th>Centered Header</th> + <th>Left Aligned</th> + <th>Right Aligned</th> + <th>Default aligned</th> + </tr> + </thead> + <tbody> + <tr> + <td>First</td> + <td>row</td> + <td>12.0</td> + <td>Example of a row that spans multiple lines.</td> + </tr> + <tr> + <td>Second</td> + <td>row</td> + <td>5.0</td> + <td>Here’s another one. Note the blank line between rows.</td> + </tr> + </tbody> + </table> +</table-wrap> <p>Table without column headers:</p> -<table> - <col align="right" /> - <col align="left" /> - <col align="center" /> - <col align="right" /> - <tbody> - <tr> - <td>12</td> - <td>12</td> - <td>12</td> - <td>12</td> - </tr> - <tr> - <td>123</td> - <td>123</td> - <td>123</td> - <td>123</td> - </tr> - <tr> - <td>1</td> - <td>1</td> - <td>1</td> - <td>1</td> - </tr> - </tbody> -</table> +<table-wrap> + <table> + <col align="right" /> + <col align="left" /> + <col align="center" /> + <col align="right" /> + <tbody> + <tr> + <td>12</td> + <td>12</td> + <td>12</td> + <td>12</td> + </tr> + <tr> + <td>123</td> + <td>123</td> + <td>123</td> + <td>123</td> + </tr> + <tr> + <td>1</td> + <td>1</td> + <td>1</td> + <td>1</td> + </tr> + </tbody> + </table> +</table-wrap> <p>Multiline table without column headers:</p> -<table> - <col width="15*" align="center" /> - <col width="13*" align="left" /> - <col width="16*" align="right" /> - <col width="35*" align="left" /> - <tbody> - <tr> - <td>First</td> - <td>row</td> - <td>12.0</td> - <td>Example of a row that spans multiple lines.</td> - </tr> - <tr> - <td>Second</td> - <td>row</td> - <td>5.0</td> - <td>Here’s another one. Note the blank line between rows.</td> - </tr> - </tbody> -</table> +<table-wrap> + <table> + <col width="15*" align="center" /> + <col width="13*" align="left" /> + <col width="16*" align="right" /> + <col width="35*" align="left" /> + <tbody> + <tr> + <td>First</td> + <td>row</td> + <td>12.0</td> + <td>Example of a row that spans multiple lines.</td> + </tr> + <tr> + <td>Second</td> + <td>row</td> + <td>5.0</td> + <td>Here’s another one. Note the blank line between rows.</td> + </tr> + </tbody> + </table> +</table-wrap> diff --git a/test/tables.jats_articleauthoring b/test/tables.jats_articleauthoring index 70f71e384..30bacc2e8 100644 --- a/test/tables.jats_articleauthoring +++ b/test/tables.jats_articleauthoring @@ -39,40 +39,42 @@ </table> </table-wrap> <p>Simple table without caption:</p> -<table> - <col align="right" /> - <col align="left" /> - <col align="center" /> - <col align="left" /> - <thead> - <tr> - <th>Right</th> - <th>Left</th> - <th>Center</th> - <th>Default</th> - </tr> - </thead> - <tbody> - <tr> - <td>12</td> - <td>12</td> - <td>12</td> - <td>12</td> - </tr> - <tr> - <td>123</td> - <td>123</td> - <td>123</td> - <td>123</td> - </tr> - <tr> - <td>1</td> - <td>1</td> - <td>1</td> - <td>1</td> - </tr> - </tbody> -</table> +<table-wrap> + <table> + <col align="right" /> + <col align="left" /> + <col align="center" /> + <col align="left" /> + <thead> + <tr> + <th>Right</th> + <th>Left</th> + <th>Center</th> + <th>Default</th> + </tr> + </thead> + <tbody> + <tr> + <td>12</td> + <td>12</td> + <td>12</td> + <td>12</td> + </tr> + <tr> + <td>123</td> + <td>123</td> + <td>123</td> + <td>123</td> + </tr> + <tr> + <td>1</td> + <td>1</td> + <td>1</td> + <td>1</td> + </tr> + </tbody> + </table> +</table-wrap> <p>Simple table indented two spaces:</p> <table-wrap> <caption> @@ -148,79 +150,85 @@ </table> </table-wrap> <p>Multiline table without caption:</p> -<table> - <col width="15*" align="center" /> - <col width="13*" align="left" /> - <col width="16*" align="right" /> - <col width="35*" align="left" /> - <thead> - <tr> - <th>Centered Header</th> - <th>Left Aligned</th> - <th>Right Aligned</th> - <th>Default aligned</th> - </tr> - </thead> - <tbody> - <tr> - <td>First</td> - <td>row</td> - <td>12.0</td> - <td>Example of a row that spans multiple lines.</td> - </tr> - <tr> - <td>Second</td> - <td>row</td> - <td>5.0</td> - <td>Here’s another one. Note the blank line between rows.</td> - </tr> - </tbody> -</table> +<table-wrap> + <table> + <col width="15*" align="center" /> + <col width="13*" align="left" /> + <col width="16*" align="right" /> + <col width="35*" align="left" /> + <thead> + <tr> + <th>Centered Header</th> + <th>Left Aligned</th> + <th>Right Aligned</th> + <th>Default aligned</th> + </tr> + </thead> + <tbody> + <tr> + <td>First</td> + <td>row</td> + <td>12.0</td> + <td>Example of a row that spans multiple lines.</td> + </tr> + <tr> + <td>Second</td> + <td>row</td> + <td>5.0</td> + <td>Here’s another one. Note the blank line between rows.</td> + </tr> + </tbody> + </table> +</table-wrap> <p>Table without column headers:</p> -<table> - <col align="right" /> - <col align="left" /> - <col align="center" /> - <col align="right" /> - <tbody> - <tr> - <td>12</td> - <td>12</td> - <td>12</td> - <td>12</td> - </tr> - <tr> - <td>123</td> - <td>123</td> - <td>123</td> - <td>123</td> - </tr> - <tr> - <td>1</td> - <td>1</td> - <td>1</td> - <td>1</td> - </tr> - </tbody> -</table> +<table-wrap> + <table> + <col align="right" /> + <col align="left" /> + <col align="center" /> + <col align="right" /> + <tbody> + <tr> + <td>12</td> + <td>12</td> + <td>12</td> + <td>12</td> + </tr> + <tr> + <td>123</td> + <td>123</td> + <td>123</td> + <td>123</td> + </tr> + <tr> + <td>1</td> + <td>1</td> + <td>1</td> + <td>1</td> + </tr> + </tbody> + </table> +</table-wrap> <p>Multiline table without column headers:</p> -<table> - <col width="15*" align="center" /> - <col width="13*" align="left" /> - <col width="16*" align="right" /> - <col width="35*" align="left" /> - <tbody> - <tr> - <td>First</td> - <td>row</td> - <td>12.0</td> - <td>Example of a row that spans multiple lines.</td> - </tr> - <tr> - <td>Second</td> - <td>row</td> - <td>5.0</td> - <td>Here’s another one. Note the blank line between rows.</td> - </tr> - </tbody> -</table> +<table-wrap> + <table> + <col width="15*" align="center" /> + <col width="13*" align="left" /> + <col width="16*" align="right" /> + <col width="35*" align="left" /> + <tbody> + <tr> + <td>First</td> + <td>row</td> + <td>12.0</td> + <td>Example of a row that spans multiple lines.</td> + </tr> + <tr> + <td>Second</td> + <td>row</td> + <td>5.0</td> + <td>Here’s another one. Note the blank line between rows.</td> + </tr> + </tbody> + </table> +</table-wrap> diff --git a/test/tables.jats_publishing b/test/tables.jats_publishing index 70f71e384..30bacc2e8 100644 --- a/test/tables.jats_publishing +++ b/test/tables.jats_publishing @@ -39,40 +39,42 @@ </table> </table-wrap> <p>Simple table without caption:</p> -<table> - <col align="right" /> - <col align="left" /> - <col align="center" /> - <col align="left" /> - <thead> - <tr> - <th>Right</th> - <th>Left</th> - <th>Center</th> - <th>Default</th> - </tr> - </thead> - <tbody> - <tr> - <td>12</td> - <td>12</td> - <td>12</td> - <td>12</td> - </tr> - <tr> - <td>123</td> - <td>123</td> - <td>123</td> - <td>123</td> - </tr> - <tr> - <td>1</td> - <td>1</td> - <td>1</td> - <td>1</td> - </tr> - </tbody> -</table> +<table-wrap> + <table> + <col align="right" /> + <col align="left" /> + <col align="center" /> + <col align="left" /> + <thead> + <tr> + <th>Right</th> + <th>Left</th> + <th>Center</th> + <th>Default</th> + </tr> + </thead> + <tbody> + <tr> + <td>12</td> + <td>12</td> + <td>12</td> + <td>12</td> + </tr> + <tr> + <td>123</td> + <td>123</td> + <td>123</td> + <td>123</td> + </tr> + <tr> + <td>1</td> + <td>1</td> + <td>1</td> + <td>1</td> + </tr> + </tbody> + </table> +</table-wrap> <p>Simple table indented two spaces:</p> <table-wrap> <caption> @@ -148,79 +150,85 @@ </table> </table-wrap> <p>Multiline table without caption:</p> -<table> - <col width="15*" align="center" /> - <col width="13*" align="left" /> - <col width="16*" align="right" /> - <col width="35*" align="left" /> - <thead> - <tr> - <th>Centered Header</th> - <th>Left Aligned</th> - <th>Right Aligned</th> - <th>Default aligned</th> - </tr> - </thead> - <tbody> - <tr> - <td>First</td> - <td>row</td> - <td>12.0</td> - <td>Example of a row that spans multiple lines.</td> - </tr> - <tr> - <td>Second</td> - <td>row</td> - <td>5.0</td> - <td>Here’s another one. Note the blank line between rows.</td> - </tr> - </tbody> -</table> +<table-wrap> + <table> + <col width="15*" align="center" /> + <col width="13*" align="left" /> + <col width="16*" align="right" /> + <col width="35*" align="left" /> + <thead> + <tr> + <th>Centered Header</th> + <th>Left Aligned</th> + <th>Right Aligned</th> + <th>Default aligned</th> + </tr> + </thead> + <tbody> + <tr> + <td>First</td> + <td>row</td> + <td>12.0</td> + <td>Example of a row that spans multiple lines.</td> + </tr> + <tr> + <td>Second</td> + <td>row</td> + <td>5.0</td> + <td>Here’s another one. Note the blank line between rows.</td> + </tr> + </tbody> + </table> +</table-wrap> <p>Table without column headers:</p> -<table> - <col align="right" /> - <col align="left" /> - <col align="center" /> - <col align="right" /> - <tbody> - <tr> - <td>12</td> - <td>12</td> - <td>12</td> - <td>12</td> - </tr> - <tr> - <td>123</td> - <td>123</td> - <td>123</td> - <td>123</td> - </tr> - <tr> - <td>1</td> - <td>1</td> - <td>1</td> - <td>1</td> - </tr> - </tbody> -</table> +<table-wrap> + <table> + <col align="right" /> + <col align="left" /> + <col align="center" /> + <col align="right" /> + <tbody> + <tr> + <td>12</td> + <td>12</td> + <td>12</td> + <td>12</td> + </tr> + <tr> + <td>123</td> + <td>123</td> + <td>123</td> + <td>123</td> + </tr> + <tr> + <td>1</td> + <td>1</td> + <td>1</td> + <td>1</td> + </tr> + </tbody> + </table> +</table-wrap> <p>Multiline table without column headers:</p> -<table> - <col width="15*" align="center" /> - <col width="13*" align="left" /> - <col width="16*" align="right" /> - <col width="35*" align="left" /> - <tbody> - <tr> - <td>First</td> - <td>row</td> - <td>12.0</td> - <td>Example of a row that spans multiple lines.</td> - </tr> - <tr> - <td>Second</td> - <td>row</td> - <td>5.0</td> - <td>Here’s another one. Note the blank line between rows.</td> - </tr> - </tbody> -</table> +<table-wrap> + <table> + <col width="15*" align="center" /> + <col width="13*" align="left" /> + <col width="16*" align="right" /> + <col width="35*" align="left" /> + <tbody> + <tr> + <td>First</td> + <td>row</td> + <td>12.0</td> + <td>Example of a row that spans multiple lines.</td> + </tr> + <tr> + <td>Second</td> + <td>row</td> + <td>5.0</td> + <td>Here’s another one. Note the blank line between rows.</td> + </tr> + </tbody> + </table> +</table-wrap> |