Skip to content

Commit 6e1b2cc

Browse files
committed
table-short-captions: add support for pandoc 2.10
The new table representation of pandoc 2.10 is now accounted for.
1 parent c162972 commit 6e1b2cc

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

table-short-captions/table-short-captions.lua

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,14 @@ end
9797
-- @treturn List[Blocks] : The table with {label} in the caption,
9898
-- optionally wrapped in shortcaption code
9999
function rewrite_longtable_caption(tbl)
100+
local caption
101+
if PANDOC_VERSION >= {2,10} then
102+
caption = pandoc.List(tbl.caption.long)
103+
else
104+
caption = tbl.caption
105+
end
100106
-- Escape if there is no caption present.
101-
if not tbl.caption then
107+
if not caption or #caption == 0 then
102108
return nil
103109
end
104110

@@ -107,7 +113,7 @@ function rewrite_longtable_caption(tbl)
107113
return (inl.t) and (inl.t == "Span") -- is span
108114
and (inl.content) and (#inl.content == 0) -- is empty span
109115
end
110-
local propspan, idx = tbl.caption:find_if(is_properties_span)
116+
local propspan, idx = caption:find_if(is_properties_span)
111117

112118
-- If we couldn't find properties, escape.
113119
if not propspan then
@@ -118,11 +124,21 @@ function rewrite_longtable_caption(tbl)
118124
local label, short_caption, unlisted = parse_table_attrs(propspan.attr)
119125

120126
-- Excise the span from the caption
121-
tbl.caption[idx] = nil
127+
caption[idx] = nil
122128

123129
-- Put label back into caption for pandoc-crossref
124130
if label then
125-
tbl.caption:extend {pandoc.Str("{#"..label.."}")}
131+
caption:extend {pandoc.Str("{#"..label.."}")}
132+
end
133+
134+
-- set new caption
135+
if PANDOC_VERSION >= {2,10} then
136+
tbl.caption.long = caption
137+
tbl.caption.short = short_caption
138+
and pandoc.read(short_caption, FORMAT).blocks[1].content
139+
or nil
140+
else
141+
tbl.caption = caption
126142
end
127143

128144
-- Place new table

0 commit comments

Comments
 (0)