JATS writer: put references in <back>
.
Modified template to include a `<back>` and `<body>` section. This should give authors more flexibility, e.g. to put acknowledgements metadata in `<back>`. References are automatically extracted and put into `<back>`.
This commit is contained in:
parent
136a53edc8
commit
3217bc192e
4 changed files with 1792 additions and 1782 deletions
|
@ -192,5 +192,12 @@ $if(notes)$
|
|||
<notes>$notes$</notes>
|
||||
$endif$
|
||||
</front>
|
||||
<body>
|
||||
$body$
|
||||
</body>
|
||||
$if(back)$
|
||||
<back>
|
||||
$back$
|
||||
</back>
|
||||
$endif$
|
||||
</article>
|
||||
|
|
|
@ -34,7 +34,7 @@ module Text.Pandoc.Writers.JATS ( writeJATS ) where
|
|||
import Control.Monad.Reader
|
||||
import Data.Char (toLower)
|
||||
import Data.Generics (everywhere, mkT)
|
||||
import Data.List (intercalate, isSuffixOf)
|
||||
import Data.List (intercalate, isSuffixOf, partition)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import qualified Text.Pandoc.Builder as B
|
||||
import Text.Pandoc.Class (PandocMonad, report)
|
||||
|
@ -88,7 +88,11 @@ writeJATS opts d =
|
|||
-- | Convert Pandoc document to string in JATS format.
|
||||
docToJATS :: PandocMonad m => WriterOptions -> Pandoc -> DB m String
|
||||
docToJATS opts (Pandoc meta blocks) = do
|
||||
let elements = hierarchicalize blocks
|
||||
let isBackBlock (Div ("refs",_,_) _) = True
|
||||
isBackBlock _ = False
|
||||
let (backblocks, bodyblocks) = partition isBackBlock blocks
|
||||
let elements = hierarchicalize bodyblocks
|
||||
let backElements = hierarchicalize backblocks
|
||||
let colwidth = if writerWrapText opts == WrapAuto
|
||||
then Just $ writerColumns opts
|
||||
else Nothing
|
||||
|
@ -112,9 +116,12 @@ docToJATS opts (Pandoc meta blocks) = do
|
|||
hierarchicalize))
|
||||
(fmap (render colwidth) . inlinesToJATS opts')
|
||||
meta'
|
||||
main <- (render' . inTagsIndented "body" . vcat) <$>
|
||||
main <- (render' . vcat) <$>
|
||||
(mapM (elementToJATS opts' startLvl) elements)
|
||||
back <- (render' . vcat) <$>
|
||||
(mapM (elementToJATS opts' startLvl) backElements)
|
||||
let context = defField "body" main
|
||||
$ defField "back" back
|
||||
$ defField "mathml" (case writerHTMLMathMethod opts of
|
||||
MathML -> True
|
||||
_ -> False)
|
||||
|
|
882
test/tables.jats
882
test/tables.jats
|
@ -1,115 +1,12 @@
|
|||
<body>
|
||||
<p>
|
||||
Simple table with caption:
|
||||
</p>
|
||||
<table-wrap>
|
||||
<caption>
|
||||
<p>
|
||||
Demonstration of simple table syntax.
|
||||
</p>
|
||||
</caption>
|
||||
<table>
|
||||
<col align="right" />
|
||||
<col align="left" />
|
||||
<col align="center" />
|
||||
<col align="left" />
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<p>
|
||||
Right
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Left
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Center
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Default
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</table-wrap>
|
||||
<p>
|
||||
Simple table without caption:
|
||||
</p>
|
||||
<p>
|
||||
Simple table with caption:
|
||||
</p>
|
||||
<table-wrap>
|
||||
<caption>
|
||||
<p>
|
||||
Demonstration of simple table syntax.
|
||||
</p>
|
||||
</caption>
|
||||
<table>
|
||||
<col align="right" />
|
||||
<col align="left" />
|
||||
|
@ -208,203 +105,225 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
Simple table indented two spaces:
|
||||
</p>
|
||||
<table-wrap>
|
||||
<caption>
|
||||
<p>
|
||||
Demonstration of simple table syntax.
|
||||
</p>
|
||||
</caption>
|
||||
<table>
|
||||
<col align="right" />
|
||||
<col align="left" />
|
||||
<col align="center" />
|
||||
<col align="left" />
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<p>
|
||||
Right
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Left
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Center
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Default
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</table-wrap>
|
||||
<p>
|
||||
Multiline table with caption:
|
||||
</p>
|
||||
<table-wrap>
|
||||
<caption>
|
||||
<p>
|
||||
Here’s the caption. It may span multiple lines.
|
||||
</p>
|
||||
</caption>
|
||||
<table>
|
||||
<col width="15*" align="center" />
|
||||
<col width="13*" align="left" />
|
||||
<col width="16*" align="right" />
|
||||
<col width="33*" align="left" />
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<p>
|
||||
Centered Header
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Left Aligned
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Right Aligned
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Default aligned
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
First
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
row
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12.0
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Example of a row that spans multiple lines.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Second
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
row
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
5.0
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Here’s another one. Note the blank line between rows.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</table-wrap>
|
||||
<p>
|
||||
Multiline table without caption:
|
||||
</p>
|
||||
</table-wrap>
|
||||
<p>
|
||||
Simple table without caption:
|
||||
</p>
|
||||
<table>
|
||||
<col align="right" />
|
||||
<col align="left" />
|
||||
<col align="center" />
|
||||
<col align="left" />
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<p>
|
||||
Right
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Left
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Center
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Default
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
Simple table indented two spaces:
|
||||
</p>
|
||||
<table-wrap>
|
||||
<caption>
|
||||
<p>
|
||||
Demonstration of simple table syntax.
|
||||
</p>
|
||||
</caption>
|
||||
<table>
|
||||
<col align="right" />
|
||||
<col align="left" />
|
||||
<col align="center" />
|
||||
<col align="left" />
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<p>
|
||||
Right
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Left
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Center
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Default
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</table-wrap>
|
||||
<p>
|
||||
Multiline table with caption:
|
||||
</p>
|
||||
<table-wrap>
|
||||
<caption>
|
||||
<p>
|
||||
Here’s the caption. It may span multiple lines.
|
||||
</p>
|
||||
</caption>
|
||||
<table>
|
||||
<col width="15*" align="center" />
|
||||
<col width="13*" align="left" />
|
||||
|
@ -481,136 +400,215 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
Table without column headers:
|
||||
</p>
|
||||
<table>
|
||||
<col align="right" />
|
||||
<col align="left" />
|
||||
<col align="center" />
|
||||
<col align="right" />
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<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="33*" align="left" />
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
First
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
row
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12.0
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Example of a row that spans multiple lines.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Second
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
row
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
5.0
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Here’s another one. Note the blank line between rows.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</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="33*" align="left" />
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<p>
|
||||
Centered Header
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Left Aligned
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Right Aligned
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Default aligned
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
First
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
row
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12.0
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Example of a row that spans multiple lines.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Second
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
row
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
5.0
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Here’s another one. Note the blank line between rows.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
Table without column headers:
|
||||
</p>
|
||||
<table>
|
||||
<col align="right" />
|
||||
<col align="left" />
|
||||
<col align="center" />
|
||||
<col align="right" />
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
123
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
1
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<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="33*" align="left" />
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
First
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
row
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
12.0
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Example of a row that spans multiple lines.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
Second
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
row
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
5.0
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
Here’s another one. Note the blank line between rows.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
2672
test/writer.jats
2672
test/writer.jats
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue