Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle empty lines inside @BeginCode/@EndCode #253

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion gap/Markdown.gi
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,20 @@ InstallGlobalFunction( CONVERT_LIST_OF_STRINGS_IN_MARKDOWN_TO_GAPDOC_XML,

## Check for paragraphs by turning an empty string into <P/>

skipped := false;
already_inserted_paragraph := false;
for i in [ 1 .. Length( string_list ) ] do
if PositionSublist( string_list[ i ], "<![CDATA[" ) <> 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 ] := "<P/>";
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions tst/worksheets/general.expected/_Chunks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<Listing Type="Code"><![CDATA[
Hello, world.
x := 1 + 1;

if x = 2 then
Print("1 + 1 = 2 holds, all is good\n");
else
Expand Down
1 change: 1 addition & 0 deletions tst/worksheets/general.sheet/worksheet.g
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ DeclareOperation( "ThirdOperation", [ IsGroup, IsInt ] );
#! @BeginCode MyCode
#! Hello, world.
x := 1 + 1;

if x = 2 then
Print("1 + 1 = 2 holds, all is good\n");
else
Expand Down