Skip to content

Commit 5d133ca

Browse files
committed
abstract-to-meta: only set abstract field if abstract is not empty
Fixes: #97
1 parent d4e076d commit 5d133ca

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

abstract-to-meta/abstract-to-meta.lua

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ abstract-to-meta – move an "abstract" section into document metadata
44
Copyright: © 2017–2020 Albert Krewinkel
55
License: MIT – see LICENSE file for details
66
]]
7-
local abstract = pandoc.List:new{}
7+
local abstract = {}
88

99
--- Extract abstract from a list of blocks.
1010
function abstract_from_blocklist (blocks)
@@ -34,7 +34,9 @@ if PANDOC_VERSION >= {2,9,2} then
3434
return {{
3535
Blocks = abstract_from_blocklist,
3636
Meta = function (meta)
37-
meta.abstract = meta.abstract or abstract
37+
if not meta.abstract and #abstract > 0 then
38+
meta.abstract = pandoc.MetaBlocks(abstract)
39+
end
3840
return meta
3941
end
4042
}}
@@ -44,7 +46,9 @@ else
4446
Pandoc = function (doc)
4547
local meta = doc.meta
4648
local other_blocks = abstract_from_blocklist(doc.blocks)
47-
meta.abstract = meta.abstract or abstract
49+
if not meta.abstract and #abstract > 0 then
50+
meta.abstract = pandoc.MetaBlocks(abstract)
51+
end
4852
return pandoc.Pandoc(other_blocks, meta)
4953
end,
5054
}}

0 commit comments

Comments
 (0)