From de8c47eae807ae8ecc96eb24cd1fed6cf8e6b932 Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Fri, 22 Dec 2017 18:29:03 +1300 Subject: jats writer: Self closing tags for empty xref (#4187) --- src/Text/Pandoc/Writers/JATS.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/JATS.hs b/src/Text/Pandoc/Writers/JATS.hs index 8824eeb24..ee3d61015 100644 --- a/src/Text/Pandoc/Writers/JATS.hs +++ b/src/Text/Pandoc/Writers/JATS.hs @@ -405,8 +405,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"), -- cgit v1.2.3 From a5d7be075d6aa3afd817bfb754b5c84cac63614b Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Fri, 22 Dec 2017 18:30:22 +1300 Subject: JATS writer: Make

optional in and (#4178) If the contents are single `Plain` block then do not wrap them with a

element. --- src/Text/Pandoc/Writers/JATS.hs | 3 + test/tables.jats | 368 ++++++++++------------------------------ 2 files changed, 95 insertions(+), 276 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/JATS.hs b/src/Text/Pandoc/Writers/JATS.hs index ee3d61015..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 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 @@ -

- Right -

+ Right -

- Left -

+ Left -

- Center -

+ Center -

- Default -

+ Default -

- 12 -

+ 12 -

- 12 -

+ 12 -

- 12 -

+ 12 -

- 12 -

+ 12 -

- 123 -

+ 123 -

- 123 -

+ 123 -

- 123 -

+ 123 -

- 123 -

+ 123 -

- 1 -

+ 1 -

- 1 -

+ 1 -

- 1 -

+ 1 -

- 1 -

+ 1 @@ -117,92 +85,60 @@ -

- Right -

+ Right -

- Left -

+ Left -

- Center -

+ Center -

- Default -

+ Default -

- 12 -

+ 12 -

- 12 -

+ 12 -

- 12 -

+ 12 -

- 12 -

+ 12 -

- 123 -

+ 123 -

- 123 -

+ 123 -

- 123 -

+ 123 -

- 123 -

+ 123 -

- 1 -

+ 1 -

- 1 -

+ 1 -

- 1 -

+ 1 -

- 1 -

+ 1 @@ -224,92 +160,60 @@ -

- Right -

+ Right -

- Left -

+ Left -

- Center -

+ Center -

- Default -

+ Default -

- 12 -

+ 12 -

- 12 -

+ 12 -

- 12 -

+ 12 -

- 12 -

+ 12 -

- 123 -

+ 123 -

- 123 -

+ 123 -

- 123 -

+ 123 -

- 123 -

+ 123 -

- 1 -

+ 1 -

- 1 -

+ 1 -

- 1 -

+ 1 -

- 1 -

+ 1 @@ -332,70 +236,46 @@ -

- Centered Header -

+ Centered Header -

- Left Aligned -

+ Left Aligned -

- Right Aligned -

+ Right Aligned -

- Default aligned -

+ Default aligned -

- First -

+ First -

- row -

+ row -

- 12.0 -

+ 12.0 -

- Example of a row that spans multiple lines. -

+ Example of a row that spans multiple lines. -

- Second -

+ Second -

- row -

+ row -

- 5.0 -

+ 5.0 -

- Here’s another one. Note the blank line between rows. -

+ Here’s another one. Note the blank line between rows. @@ -412,70 +292,46 @@ -

- Centered Header -

+ Centered Header -

- Left Aligned -

+ Left Aligned -

- Right Aligned -

+ Right Aligned -

- Default aligned -

+ Default aligned -

- First -

+ First -

- row -

+ row -

- 12.0 -

+ 12.0 -

- Example of a row that spans multiple lines. -

+ Example of a row that spans multiple lines. -

- Second -

+ Second -

- row -

+ row -

- 5.0 -

+ 5.0 -

- Here’s another one. Note the blank line between rows. -

+ Here’s another one. Note the blank line between rows. @@ -491,68 +347,44 @@ -

- 12 -

+ 12 -

- 12 -

+ 12 -

- 12 -

+ 12 -

- 12 -

+ 12 -

- 123 -

+ 123 -

- 123 -

+ 123 -

- 123 -

+ 123 -

- 123 -

+ 123 -

- 1 -

+ 1 -

- 1 -

+ 1 -

- 1 -

+ 1 -

- 1 -

+ 1 @@ -568,46 +400,30 @@ -

- First -

+ First -

- row -

+ row -

- 12.0 -

+ 12.0 -

- Example of a row that spans multiple lines. -

+ Example of a row that spans multiple lines. -

- Second -

+ Second -

- row -

+ row -

- 5.0 -

+ 5.0 -

- Here’s another one. Note the blank line between rows. -

+ Here’s another one. Note the blank line between rows. -- cgit v1.2.3