From 42d16b1c7807124136cdc1c78919bd91678b3c79 Mon Sep 17 00:00:00 2001 From: Chris Hubbard Date: Fri, 24 Jan 2025 13:27:04 -0500 Subject: [PATCH] Add paragraphs around table rows There is a bug in Proskomma where the generation of events is messed up if you have a series of table row markers \tr. A work-around is to put paragraph makers \p around the series of table row markers. --- convert/convertBooks.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/convert/convertBooks.ts b/convert/convertBooks.ts index 3818355c6..82c41ec49 100644 --- a/convert/convertBooks.ts +++ b/convert/convertBooks.ts @@ -190,6 +190,10 @@ function isImageMissing(imageSource: string): boolean { return !fs.existsSync(path.join('data', 'illustrations', imageSource)); } +function addParagraphMarkersAroundTableRows(text: string): string { + return text.replace(/((?:\\tr [^\n]*\n)+)/g, '\n\\p\n$1\\p\n'); +} + type FilterFunction = (text: string, bcId: string, bookId: string) => string; const usfmFilterFunctions: FilterFunction[] = [ @@ -199,7 +203,8 @@ const usfmFilterFunctions: FilterFunction[] = [ convertMarkdownsToMilestones, handleNoCaptionFigures, removeMissingFigures, - trimTrailingWhitespace + trimTrailingWhitespace, + addParagraphMarkersAroundTableRows ]; const htmlFilterFunctions: FilterFunction[] = [updateImgTags, trimTrailingWhitespace];