From 2949830f0c450e87bba22fd9d2daafe1cab0e725 Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Sat, 26 Mar 2022 13:14:24 +0100 Subject: [PATCH] Added test for quotations --- src/bootstraparse/modules/syntax.py | 4 +-- tests/modules/test_syntax.py | 38 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/bootstraparse/modules/syntax.py b/src/bootstraparse/modules/syntax.py index 5ef3956..c9e61b0 100644 --- a/src/bootstraparse/modules/syntax.py +++ b/src/bootstraparse/modules/syntax.py @@ -310,9 +310,9 @@ table_separator = pp.OneOrMore( pps('|') + pp.Word(':-') )('table_separator').add_parse_action(of_type(TableSeparatorToken)) + pps('|') # Future: Add Blockquote element -blockquote = pp.LineStart + '>' + \ +blockquote = pp.Literal('>') + \ pp.SkipTo(pp.line_end)('text').add_parse_action(of_type(BlockQuoteToken)) # TODO: add reparse -blockquote_author = pp.LineStart + '> --' + \ +blockquote_author = pp.Literal('> --') + \ pp.SkipTo(pp.line_end)('author').add_parse_action(of_type(BlockQuoteAuthorToken)) table = table_separator | table_row quotation = blockquote_author | blockquote diff --git a/tests/modules/test_syntax.py b/tests/modules/test_syntax.py index 8e14adf..4325ee4 100644 --- a/tests/modules/test_syntax.py +++ b/tests/modules/test_syntax.py @@ -527,6 +527,44 @@ dict_advanced_syntax_input_and_expected_output = { ]), ), __GL(),), ], + "blockquote": [ + ("> Text", (sy.BlockQuoteToken([sy.TextToken(["Text"])]),), __GL(), __XF), + ("> Text with *em* and __underline__", ( + sy.BlockQuoteToken([ + sy.TextToken(["Text with"]), + sy.EtEmToken(["*"]), + sy.TextToken(["em"]), + sy.EtEmToken(["*"]), + sy.TextToken(["and"]), + sy.EtUnderlineToken(["__"]), + sy.TextToken(["underline"]), + sy.EtUnderlineToken(["__"]), + ]), + ), __GL(), __XF), + ], + "blockquote_author": [ + ("> -- Author Name", ( + sy.BlockQuoteAuthorToken(["Author Name"]), + ), __GL(), __XF), + ], + "quotation": [ + ("> Text", (sy.BlockQuoteToken([sy.TextToken(["Text"])]),), __GL(), __XF), + ("> Text with *em* and __underline__", ( + sy.BlockQuoteToken([ + sy.TextToken(["Text with"]), + sy.EtEmToken(["*"]), + sy.TextToken(["em"]), + sy.EtEmToken(["*"]), + sy.TextToken(["and"]), + sy.EtUnderlineToken(["__"]), + sy.TextToken(["underline"]), + sy.EtUnderlineToken(["__"]), + ]), + ), __GL(), __XF), + ("> -- Author Name", ( + sy.BlockQuoteAuthorToken(["Author Name"]), + ), __GL(), __XF), + ], } # Cursed zipping oneline