Skip to content

Commit 1fb2efe

Browse files
committed
Unroll divs in JATS
Divs are converted to boxedtext by pandoc, which isn’t really what we’re looking for, so unroll them to avoid this behavior.
1 parent d7ee29b commit 1fb2efe

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-- jats.lua
2+
-- Copyright (C) 2021-2022 Posit Software, PBC
3+
4+
5+
6+
7+
function jats()
8+
return {
9+
-- clear out divs
10+
Div = function(div)
11+
if _quarto.format.isJatsOutput() then
12+
-- unroll blocks contained in divs
13+
local blocks = pandoc.List()
14+
for _, childBlock in ipairs(div.content) do
15+
if childBlock.t == "Div" then
16+
tappend(blocks, childBlock.content)
17+
else
18+
blocks:insert(childBlock)
19+
end
20+
end
21+
return blocks
22+
end
23+
end
24+
}
25+
end

src/resources/filters/quarto-post/quarto-post.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import("latexdiv.lua")
1717
import("foldcode.lua")
1818
import("fig-cleanup.lua")
1919
import("ipynb.lua")
20+
import("jats.lua")
2021
import("ojs.lua")
2122
import("reveal.lua")
2223
import("tikz.lua")
@@ -50,6 +51,7 @@ return {
5051
figCleanup(),
5152
pdfImages()
5253
}),
54+
jats(),
5355
ojs(),
5456
quartoPostMetaInject(),
5557
}

src/resources/pandoc/datadir/_format.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ local function isAstOutput()
181181
return isNativeOutput() or isJsonOutput()
182182
end
183183

184+
local function isJatsOutput()
185+
local formats = {
186+
"jats",
187+
"jats_archiving",
188+
"jats_articleauthoring",
189+
"jats_publishing",
190+
}
191+
return tcontains(formats, FORMAT)
192+
end
193+
184194

185195
return {
186196
isRawHtml = isRawHtml,
@@ -204,5 +214,6 @@ return {
204214
isBibliographyOutput = isBibliographyOutput,
205215
isNativeOutput = isNativeOutput,
206216
isJsonOutput = isJsonOutput,
207-
isAstOutput = isAstOutput
217+
isAstOutput = isAstOutput,
218+
isJatsOutput = isJatsOutput
208219
}

0 commit comments

Comments
 (0)