From 023468ea2d625516eb9ad6cef2240b2ac20091d4 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Wed, 18 Nov 2020 17:36:09 +0100 Subject: JATS writer: wrap all tables All `` elements are put inside `` elements, as the former are not valid as immediate child elements of ``. --- src/Text/Pandoc/Writers/JATS/Table.hs | 13 +- test/tables.jats_archiving | 224 ++++++++++++++++++---------------- test/tables.jats_articleauthoring | 224 ++++++++++++++++++---------------- 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 @@

Simple table without caption:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RightLeftCenterDefault
12121212
123123123123
1111
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RightLeftCenterDefault
12121212
123123123123
1111
+

Simple table indented two spaces:

@@ -148,79 +150,85 @@

Multiline table without caption:

- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here’s another one. Note the blank line between rows.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here’s another one. Note the blank line between rows.
+

Table without column headers:

- - - - - - - - - - - - - - - - - - - - - - - - - -
12121212
123123123123
1111
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
12121212
123123123123
1111
+

Multiline table without column headers:

- - - - - - - - - - - - - - - - - - - -
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here’s another one. Note the blank line between rows.
+ + + + + + + + + + + + + + + + + + + + +
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here’s another one. Note the blank line between rows.
+
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 @@

Simple table without caption:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RightLeftCenterDefault
12121212
123123123123
1111
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RightLeftCenterDefault
12121212
123123123123
1111
+

Simple table indented two spaces:

@@ -148,79 +150,85 @@

Multiline table without caption:

- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here’s another one. Note the blank line between rows.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here’s another one. Note the blank line between rows.
+

Table without column headers:

- - - - - - - - - - - - - - - - - - - - - - - - - -
12121212
123123123123
1111
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
12121212
123123123123
1111
+

Multiline table without column headers:

- - - - - - - - - - - - - - - - - - - -
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here’s another one. Note the blank line between rows.
+ + + + + + + + + + + + + + + + + + + + +
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here’s another one. Note the blank line between rows.
+
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 @@

Simple table without caption:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RightLeftCenterDefault
12121212
123123123123
1111
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RightLeftCenterDefault
12121212
123123123123
1111
+

Simple table indented two spaces:

@@ -148,79 +150,85 @@

Multiline table without caption:

- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here’s another one. Note the blank line between rows.
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Centered HeaderLeft AlignedRight AlignedDefault aligned
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here’s another one. Note the blank line between rows.
+

Table without column headers:

- - - - - - - - - - - - - - - - - - - - - - - - - -
12121212
123123123123
1111
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
12121212
123123123123
1111
+

Multiline table without column headers:

- - - - - - - - - - - - - - - - - - - -
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here’s another one. Note the blank line between rows.
+ + + + + + + + + + + + + + + + + + + + +
Firstrow12.0Example of a row that spans multiple lines.
Secondrow5.0Here’s another one. Note the blank line between rows.
+
-- cgit v1.2.3