From f04af4fca2ac3e188c56a9c84f7add6d563f1c07 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 15 May 2021 02:15:00 +0200 Subject: [PATCH] Correctly handle empty lines inside @BeginCode/@EndCode Don't translate empty to `

` if inside a CDATA section. --- gap/Markdown.gi | 13 ++++++++++++- tst/worksheets/general.expected/_Chunks.xml | 1 + tst/worksheets/general.sheet/worksheet.g | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gap/Markdown.gi b/gap/Markdown.gi index c274eec5..24b08d65 100644 --- a/gap/Markdown.gi +++ b/gap/Markdown.gi @@ -25,8 +25,20 @@ InstallGlobalFunction( CONVERT_LIST_OF_STRINGS_IN_MARKDOWN_TO_GAPDOC_XML, ## Check for paragraphs by turning an empty string into

+ skipped := false; already_inserted_paragraph := false; for i in [ 1 .. Length( string_list ) ] do + if PositionSublist( string_list[ i ], " fail then + skipped := true; + fi; + if PositionSublist( string_list[ i ], "]]>" ) <> fail then + skipped := false; + continue; + fi; + if skipped = true then + continue; + fi; + if NormalizedWhitespace( string_list[ i ] ) = "" then if already_inserted_paragraph = false then string_list[ i ] := "

"; @@ -35,7 +47,6 @@ InstallGlobalFunction( CONVERT_LIST_OF_STRINGS_IN_MARKDOWN_TO_GAPDOC_XML, else already_inserted_paragraph := false; fi; - i := i + 1; od; ## We need to find lists. Lists are indicated by a beginning diff --git a/tst/worksheets/general.expected/_Chunks.xml b/tst/worksheets/general.expected/_Chunks.xml index a39b48ec..6396ba5e 100644 --- a/tst/worksheets/general.expected/_Chunks.xml +++ b/tst/worksheets/general.expected/_Chunks.xml @@ -7,6 +7,7 @@