From 36c0ecf6f8ef5a22eef8b52e61ed50299522ca05 Mon Sep 17 00:00:00 2001 From: cparks-ucla <165213172+cparks-ucla@users.noreply.github.com> Date: Wed, 24 Jun 2026 12:40:53 -0700 Subject: [PATCH 1/2] Update floatreftarget.lua Working around using ut8.codepoint since that was causing a stack overflow with rather large tables --- src/resources/filters/customnodes/floatreftarget.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/resources/filters/customnodes/floatreftarget.lua b/src/resources/filters/customnodes/floatreftarget.lua index 7b4f457a6cc..e0f71c71d02 100644 --- a/src/resources/filters/customnodes/floatreftarget.lua +++ b/src/resources/filters/customnodes/floatreftarget.lua @@ -15,7 +15,10 @@ local function split_longtable_start(content_str) -- we do this by counting the number of open braces -- we need to do this through utf8 because lua strings are not unicode-aware - local codepoints = table.pack(utf8.codepoint(content_str, 1, #content_str)) + local codepoints = {} + for _, c in utf8.codes(content_str) do + table.insert(codepoints, c) + end local function find_codepoint(start_idx, ...) if start_idx > #codepoints then return nil From 53f72f41b2b58867d9555683baf12f668db519c2 Mon Sep 17 00:00:00 2001 From: Charles Parks <165213172+cparks-ucla@users.noreply.github.com> Date: Thu, 25 Jun 2026 09:25:01 -0700 Subject: [PATCH 2/2] Update floatreftarget.lua Speed things up using index assignment instead of table.insert --- src/resources/filters/customnodes/floatreftarget.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/resources/filters/customnodes/floatreftarget.lua b/src/resources/filters/customnodes/floatreftarget.lua index e0f71c71d02..165fb0a3efe 100644 --- a/src/resources/filters/customnodes/floatreftarget.lua +++ b/src/resources/filters/customnodes/floatreftarget.lua @@ -16,8 +16,10 @@ local function split_longtable_start(content_str) -- we need to do this through utf8 because lua strings are not unicode-aware local codepoints = {} + local n = 0 for _, c in utf8.codes(content_str) do - table.insert(codepoints, c) + n = n + 1 + codepoints[n] = c end local function find_codepoint(start_idx, ...) if start_idx > #codepoints then