Added a couple of things inside << and >> detection (body, nav, header)

This commit is contained in:
Maximilien Rigaut 2022-06-15 13:26:00 +02:00
parent bd2fdd8519
commit 4de49410a0
No known key found for this signature in database
GPG Key ID: 4F14B23709ADA5B1
3 changed files with 22 additions and 3 deletions

View File

@ -267,12 +267,12 @@ class DisplayToken(FinalSemanticType):
class StructuralElementStartToken(AddFirstElementToLabel, OpenedSemanticType, TokensToMatch):
"""<<div|article|section|aside"""
"""<<div|article|section|aside|header|body|nav"""
label = 'se:start'
class StructuralElementEndToken(AddFirstElementToLabel, ClosedSemanticType):
"""div|article|section|aside>>"""
"""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('!')

View File

@ -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(["*"]),

View File

@ -525,6 +525,7 @@ dict_advanced_syntax_input_and_expected_output = {
("|---|---|", (sy.TableSeparatorToken(["---", "---"]),), __GL()),
("- Text", (sy.EtUlistToken([sy.TextToken(["Text"])]),), __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"]),