Skip to content

Commit

Permalink
refactor: further simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
quantizor committed Jan 7, 2025
1 parent f96a38e commit 59fd98b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -643,22 +643,23 @@ function parseTableRow(
source
.trim()
// isolate situations where a pipe should be ignored (inline code, escaped, etc)
.split(/( *(?:`[^`]*`|\\\||\|) *)/)
.split(/(`[^`]*`|\\\||\|)/)
.filter(Boolean)
.forEach((fragment, i, arr) => {
if (fragment.trim() === '|') {
flush()

if (tableOutput && i !== 0 && i !== arr.length - 1) {
// Split the current row
cells.push([])
} else if (!tableOutput) {
acc += fragment
flush()
if (tableOutput) {
if (i !== 0 && i !== arr.length - 1) {
// Split the current row
cells.push([])
}

return
}
} else if (fragment !== '') {
acc += fragment
}

acc += fragment
})

flush()
Expand Down

0 comments on commit 59fd98b

Please sign in to comment.