From 69a962dac9f14997706a29398116e2b531b5a8ca Mon Sep 17 00:00:00 2001 From: vky Date: Fri, 18 Mar 2022 23:46:32 +0100 Subject: [PATCH] corrected table_separators and their tests --- src/bootstraparse/modules/syntax.py | 11 ++++++++--- tests/modules/test_syntax.py | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/bootstraparse/modules/syntax.py b/src/bootstraparse/modules/syntax.py index d001ea9..dcd261c 100644 --- a/src/bootstraparse/modules/syntax.py +++ b/src/bootstraparse/modules/syntax.py @@ -246,7 +246,8 @@ table_row = ( pp.SkipTo('|')('table_cell').add_parse_action(of_type(TableCellToken)) + '|' ).add_parse_action(of_type(TableRowToken)) table_separator = pp.OneOrMore( - pp.Regex(r'\|-+'))('table_separator').add_parse_action(of_type(TableSeparatorToken)) + '|' + pps('|') + pp.Word(':-') +)('table_separator').add_parse_action(of_type(TableSeparatorToken)) + pps('|') table = table_row + pp.Opt(table_separator) + pp.OneOrMore(table_row) + optional # multi_line sums up all multi-line elements multi_line = se | table @@ -255,6 +256,7 @@ multi_line = se | table one_header = ( header_element + pp.SkipTo(pp.match_previous_literal(header_element)) ).add_parse_action(of_type(HeaderToken)) +# TODO : Add display to tests one_display = ( display_element + pp.SkipTo(pp.match_previous_literal(display_element)) ).add_parse_action(of_type(DisplayToken)) @@ -271,7 +273,7 @@ one_line = one_header | one_display | one_olist | one_ulist enhanced_text = pp.ZeroOrMore( markup | pp.SkipTo(markup)('text').add_parse_action(of_type(TextToken)) + markup ) + pp.Opt(pp.rest_of_line("text").add_parse_action(of_type(TextToken))) -line = enhanced_text | one_line | multi_line | markup +line = enhanced_text | one_line | multi_line ############################################################################## @@ -297,4 +299,7 @@ if __name__ == '__main__': # pragma: no cover if not os.path.exists('../../../dev_outputs/'): os.mkdir('../../../dev_outputs/') - enhanced_text.create_diagram("../../../dev_outputs/diagram.html") + line.create_diagram("../../../dev_outputs/diagram_line.html") + multi_line.create_diagram("../../../dev_outputs/diagram_multi_line.html") + one_line.create_diagram("../../../dev_outputs/diagram_one_line.html") + enhanced_text.create_diagram("../../../dev_outputs/diagram_enchanced_text.html") diff --git a/tests/modules/test_syntax.py b/tests/modules/test_syntax.py index a32fb62..4823c74 100644 --- a/tests/modules/test_syntax.py +++ b/tests/modules/test_syntax.py @@ -278,8 +278,8 @@ list_of_text_input_and_readable_output = [ # Tables ("| Text1 | Text2 |", "table", ""), ("| Text1 |3 Text2 |", "table", ""), - ("|---|---|", "table_separator", ""), - ("|:--|-:-|--:|--:|", "table_separator", ""), + ("|---|---|", "table_separator", ""), + ("|:--|-:-|--:|--:|", "table_separator", ""), # Other Mostly for testing and coverage ("'", "quotes", "'"),