Skip to content

Commit 7058d8b

Browse files
committed
consider all latex table env pattern to mathc with or without position options
1 parent 6b9db02 commit 7058d8b

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/resources/filters/modules/patterns.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ local function match_all_in_table(pattern_table)
6565
return inner
6666
end
6767

68+
-- return the matched content for the first pattern in the list that matches
69+
local function match_in_list_of_patterns(raw_tex, list_of_patterns)
70+
for _,pattern in ipairs(list_of_patterns) do
71+
local matched = { match_all_in_table(pattern)(raw_tex) }
72+
if matched then
73+
return table.unpack(matched)
74+
end
75+
end
76+
return nil
77+
end
78+
6879
return {
6980
attr_identifier = attr_identifier,
7081
engine_escape = engine_escape,
@@ -93,5 +104,6 @@ return {
93104
latex_table_star = latex_table_star,
94105

95106
match_all_in_table = match_all_in_table,
107+
match_in_list_of_patterns = match_in_list_of_patterns,
96108
combine_patterns = combine_patterns
97109
}

src/resources/filters/quarto-pre/parsefiguredivs.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,8 @@ function parse_floatreftargets()
743743

744744
-- finally, if the user passed a \\begin{table} float environment
745745
-- we just remove it because we'll re-emit later ourselves
746-
747-
local b, e, begin_table, table_body, end_table = raw.text:find(patterns.latex_table)
748-
if b ~= nil then
746+
local begin_table, table_body, _ = _quarto.modules.patterns.match_in_list_of_patterns(raw.text, _quarto.patterns.latexTableEnvPatterns)
747+
if begin_table ~= nil then
749748
raw.text = table_body
750749
end
751750

src/resources/pandoc/datadir/init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,10 @@ _quarto = {
18761876
processDependencies = processDependencies,
18771877
format = format,
18781878
patterns = {
1879+
latexTableEnvPatterns = pandoc.List({
1880+
latexTablePatternWithPos_table,
1881+
latexTablePattern_table
1882+
}),
18791883
latexTabularPattern = latexTabularPattern_table,
18801884
latexTablePattern = latexTablePattern_table,
18811885
latexLongtablePattern = latexLongtablePattern_table,

0 commit comments

Comments
 (0)