diff --git a/src/bootstraparse/modules/syntax.py b/src/bootstraparse/modules/syntax.py index db1cc63..018942a 100644 --- a/src/bootstraparse/modules/syntax.py +++ b/src/bootstraparse/modules/syntax.py @@ -267,12 +267,12 @@ class DisplayToken(FinalSemanticType): class StructuralElementStartToken(AddFirstElementToLabel, OpenedSemanticType, TokensToMatch): - """<>""" + """div|article|section|aside|header|body|nav>>""" label = "se:end" def counterpart(self): @@ -470,7 +470,10 @@ structural_elements = ( pp.CaselessLiteral('div') | pp.CaselessLiteral('article') | pp.CaselessLiteral('aside') | - pp.CaselessLiteral('section') + pp.CaselessLiteral('section') | + pp.CaselessLiteral('header') | + pp.CaselessLiteral('body') | + pp.CaselessLiteral('nav') )('structural_element') header_element = pp.Word('#') display_element = pp.Word('!') @@ -535,12 +538,12 @@ one_display = ( pp.Opt(optional) ).add_parse_action(of_type(DisplayToken)) one_olist = pp.line_start + ( - pps(pp.Literal('#.')) + ( + pps(pp.Combine(pp.line_start + pp.Literal('#.'))) + ( (pp.SkipTo(optional)('text').add_parse_action(reparse(enhanced_text)) + optional) | enhanced_text) ).add_parse_action(of_type(EtOlistToken)) one_ulist = pp.line_start + ( - pps(pp.Literal('-')) + ( + pps(pp.Combine(pp.line_start + pp.Literal('-'))) + ( (pp.SkipTo(optional)('text').add_parse_action(reparse(enhanced_text)) + optional) | enhanced_text) ).add_parse_action(of_type(EtUlistToken)) diff --git a/tests/modules/test_context_mngr.py b/tests/modules/test_context_mngr.py index 895cbd6..ab5674d 100644 --- a/tests/modules/test_context_mngr.py +++ b/tests/modules/test_context_mngr.py @@ -64,6 +64,21 @@ _token_list_with_expected_result = [ ], __GLk(1), ], + [ + [ + sy.StructuralElementStartToken(["header"]), + sy.TextToken(["1"]), + sy.StructuralElementEndToken(["header"]), + ], + [ + context_mngr.SeContainer([ + sy.StructuralElementStartToken(["header"]), + context_mngr.TextContainer([sy.TextToken(["1"])]), + sy.StructuralElementEndToken(["header"]) + ]), + ], + __GLk(1), + ], [ [ sy.EtEmToken(["*"]), diff --git a/tests/modules/test_syntax.py b/tests/modules/test_syntax.py index f713087..a1daf89 100644 --- a/tests/modules/test_syntax.py +++ b/tests/modules/test_syntax.py @@ -524,7 +524,9 @@ dict_advanced_syntax_input_and_expected_output = { ), __GL()), ("|---|---|", (sy.TableSeparatorToken(["---", "---"]),), __GL()), ("- Text", (sy.EtUlistToken([sy.TextToken(["Text"])]),), __GL()), + (" - Non ulist", (sy.TextToken(["- Non ulist"]),), __GL()), ("div>>", (sy.StructuralElementEndToken(["div"]),), __GL()), + ("body>>", (sy.StructuralElementEndToken(["body"]),), __GL()), ("#. Text with *em* and __underline__ and {arguments}{{super-arguments}}[a=1, c=2,'ui']", ( sy.EtOlistToken([ sy.TextToken(["Text with"]), @@ -666,6 +668,7 @@ list_of_text_input_and_readable_output = [ # Other Mostly for testing and coverage ("'", "quotes", "'"), + (" -", "line", "-"), ]