Skip to content

Commit

Permalink
🐛 close lists correctly when table cell terminates with a list
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesau committed Oct 31, 2023
1 parent 1db33bc commit bc1ebfa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion db/model/Gdoc/gdocToArchie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ function tableToString(
): string {
if (!table) return ""
let text = ""
const context = { isInList: false }
const { tableRows = [] } = table

const rows: RawBlockTableRow[] = []
Expand All @@ -105,6 +104,7 @@ function tableToString(
value: [],
}
const { content = [] } = tableCell
const context = { isInList: false }
for (const item of content) {
if (item.paragraph) {
const text = paragraphToString(item.paragraph, context)
Expand All @@ -115,6 +115,10 @@ function tableToString(
rawCell.value!.push(rawTextBlock)
}
}
// Close the list if paragraphToString didn't close it itself (because the last item was still in a list)
if (context.isInList) {
rawCell.value!.push({ type: "text", value: "[]" })
}
rawRow.value!.cells!.push(rawCell)
}
rows.push(rawRow)
Expand Down

0 comments on commit bc1ebfa

Please sign in to comment.