diff options
| author | Ben Bridle <bridle.benjamin@gmail.com> | 2026-01-30 19:14:24 +1300 |
|---|---|---|
| committer | Ben Bridle <bridle.benjamin@gmail.com> | 2026-01-30 19:14:42 +1300 |
| commit | d93aad7ee0a10ba5a86a27bdbc3a2d5f504282df (patch) | |
| tree | 4ca03792dd63d87914427e5923f624f030c8a77f | |
| parent | 2bff486208df17cae8498f602f81c6e2024a1a11 (diff) | |
| download | markdown-d93aad7ee0a10ba5a86a27bdbc3a2d5f504282df.zip | |
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.
| -rw-r--r-- | src/table.rs | 20 |
1 files changed, 12 insertions, 8 deletions
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<Vec<(String, bool)>> { 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); } |
