From bc1ebfa54d5e1e65953b4d83791ca66f9fb16a87 Mon Sep 17 00:00:00 2001 From: Ike Saunders Date: Tue, 31 Oct 2023 16:56:57 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20close=20lists=20correctly=20when?= =?UTF-8?q?=20table=20cell=20terminates=20with=20a=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/model/Gdoc/gdocToArchie.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db/model/Gdoc/gdocToArchie.ts b/db/model/Gdoc/gdocToArchie.ts index 8d41c82a39e..73db17e1d91 100644 --- a/db/model/Gdoc/gdocToArchie.ts +++ b/db/model/Gdoc/gdocToArchie.ts @@ -86,7 +86,6 @@ function tableToString( ): string { if (!table) return "" let text = "" - const context = { isInList: false } const { tableRows = [] } = table const rows: RawBlockTableRow[] = [] @@ -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) @@ -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)