97
97
-- @treturn List[Blocks] : The table with {label} in the caption,
98
98
-- optionally wrapped in shortcaption code
99
99
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
100
106
-- Escape if there is no caption present.
101
- if not tbl . caption then
107
+ if not caption or # caption == 0 then
102
108
return nil
103
109
end
104
110
@@ -107,7 +113,7 @@ function rewrite_longtable_caption(tbl)
107
113
return (inl .t ) and (inl .t == " Span" ) -- is span
108
114
and (inl .content ) and (# inl .content == 0 ) -- is empty span
109
115
end
110
- local propspan , idx = tbl . caption :find_if (is_properties_span )
116
+ local propspan , idx = caption :find_if (is_properties_span )
111
117
112
118
-- If we couldn't find properties, escape.
113
119
if not propspan then
@@ -118,11 +124,21 @@ function rewrite_longtable_caption(tbl)
118
124
local label , short_caption , unlisted = parse_table_attrs (propspan .attr )
119
125
120
126
-- Excise the span from the caption
121
- tbl . caption [idx ] = nil
127
+ caption [idx ] = nil
122
128
123
129
-- Put label back into caption for pandoc-crossref
124
130
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
126
142
end
127
143
128
144
-- Place new table
0 commit comments