fix(tables): don't skip escaped \| in cell scan — match the server
CI / editor tests (push) Successful in 46s
CI / editor tests (push) Successful in 46s
The server lexer (nuwiki-rs) splits table cells on a backslash-escaped `\|`
(it can't skip it yet without leaving a stray backslash in the output), but
the client's cell_bar_positions was skipping `\|`. That made the editor
auto-align keep `a\|b` as one cell while HTML export split it into two.
Drop the `\|` case from both clients so buffer alignment and export agree.
`[[…]]` / `{{…}}` / `` `code` `` pipes are still treated as literal. A
coordinated `\|` follow-up (server unescaping + client re-adding the skip)
is tracked in nuwiki-rs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -823,18 +823,19 @@ local is_table_row = require('nuwiki.util').is_table_row
|
||||
|
||||
-- 1-based byte positions of the cell-separator `|` characters in `s`. Pipes
|
||||
-- that are literal cell content are skipped: those inside `[[…]]` wikilinks,
|
||||
-- `{{…}}` transclusions, `` `…` `` inline code, and backslash-escaped `\|`.
|
||||
-- This keeps a `[[url|title]]` link in one cell instead of splitting on its
|
||||
-- internal pipe.
|
||||
-- `{{…}}` transclusions, and `` `…` `` inline code. This keeps a
|
||||
-- `[[url|title]]` link in one cell instead of splitting on its internal pipe.
|
||||
--
|
||||
-- Backslash-escaped `\|` is intentionally NOT skipped, to match the server
|
||||
-- lexer (nuwiki-rs), which can't skip it yet without leaving a stray backslash
|
||||
-- in the output. See nuwiki-rs issue for the coordinated `\|` follow-up.
|
||||
local function cell_bar_positions(s)
|
||||
local out = {}
|
||||
local i = 1
|
||||
local n = #s
|
||||
while i <= n do
|
||||
local c = s:sub(i, i)
|
||||
if c == '\\' then
|
||||
i = i + 2 -- skip the escaped char (e.g. `\|`)
|
||||
elseif c == '`' then
|
||||
if c == '`' then
|
||||
local close = s:find('`', i + 1, true)
|
||||
i = (close or n) + 1
|
||||
elseif s:sub(i, i + 1) == '[[' then
|
||||
|
||||
Reference in New Issue
Block a user