Skip to content

Commit

Permalink
One more fix and added one more test case. All tests pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
alberti42 committed Aug 24, 2024
1 parent d71d3ba commit f700346
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/generateParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ multiline_rev_after
close_card
= $(multiline_before_close? close_line (multiline_after_close)? (newline annotation)?) {
return createParsedQuestionInfo(CardType.Cloze,text(),location().start.line-1,location().end.line-1);
return createParsedQuestionInfo(CardType.Cloze,text().trimEnd(),location().start.line-1,location().end.line-1);
}
close_line
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ test("Test parsing of multi line basic cards", () => {
[CardType.MultiLineBasic, "Question 1\n?\nAnswer line 1\nAnswer line 2", 0, 4],
[CardType.MultiLineBasic, "Question 2\n?\nAnswer line 1\nAnswer line 2", 6, 9]
]);
expect(parse("Question 1\n?\nAnswer line 1\nAnswer line 2\n\n---\nQuestion with empty line after question mark\n?\n\nAnswer line 1\nAnswer line 2\n---\n", {
singleLineCardSeparator: "::",
singleLineReversedCardSeparator: ":::",
multilineCardSeparator: "?",
multilineReversedCardSeparator: "??",
multilineCardEndMarker: "---",
convertHighlightsToClozes: false,
convertBoldTextToClozes: true,
convertCurlyBracketsToClozes: false,
})).toEqual([
[CardType.MultiLineBasic, "Question 1\n?\nAnswer line 1\nAnswer line 2", 0, 4],
[CardType.MultiLineBasic, "Question with empty line after question mark\n?\n\nAnswer line 1\nAnswer line 2", 6, 10]
]);
});

test("Test parsing of multi line reversed cards", () => {
Expand Down

0 comments on commit f700346

Please sign in to comment.