From d93aad7ee0a10ba5a86a27bdbc3a2d5f504282df Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Fri, 30 Jan 2026 19:14:24 +1300 Subject: Ignore delimiters within line elements in tables Commit d812466 had an issue where, when scanning for unstyled pipe characters within a table row, any delimiter found within a line element would be treated as the start of a new line element, even though line elements cannot be nested. The correct behaviour is to ignore delimiters for all other line elements while inside a line element. --- src/table.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/table.rs b/src/table.rs index f4a0573..bfd9177 100644 --- a/src/table.rs +++ b/src/table.rs @@ -75,15 +75,19 @@ fn split_columns(line: &str) -> Option> { for c in head.chars() { if Some(c) == context { context = None; - } else if "$`*_".contains(c) { - context = Some(c); - } else if c == '|' && context.is_none() { - if !cell.is_empty() { - cells.push((std::mem::take(&mut cell), false)); - } else if let Some(prev_cell) = cells.last_mut() { - prev_cell.1 = true; + } else if Some(c) == context { + context = None; + } else if context.is_none() { + if "$`*_".contains(c) { + context = Some(c); + } else if c == '|' && context.is_none() { + if !cell.is_empty() { + cells.push((std::mem::take(&mut cell), false)); + } else if let Some(prev_cell) = cells.last_mut() { + prev_cell.1 = true; + } + continue; } - continue; } cell.push(c); } -- cgit v1.2.3-70-g09d2