MoinLight

Changeset

311:4b86f7f894b8
2021-10-26 Paul Boddie raw files shortlog changelog graph Fixed table feature padding patterns to consume only a single line.
moinformat/parsers/table.py (file) tests/test_table_parser.tree (file) tests/test_table_parser.txt (file)
     1.1 --- a/moinformat/parsers/table.py	Mon Oct 25 23:03:10 2021 +0200
     1.2 +++ b/moinformat/parsers/table.py	Tue Oct 26 01:32:32 2021 +0200
     1.3 @@ -114,25 +114,25 @@
     1.4      syntax.update({
     1.5          # At start of line:
     1.6  
     1.7 -        "rowsep"        : join((group("leading", r"\s*"),   # ws... (optional)
     1.8 -                                "^==",                      # ==
     1.9 -                                excl(r".*==\s*?$"),         # not-heading
    1.10 -                                group("padding", r"\s*"))), # ws... (optional)
    1.11 +        "rowsep"        : join((group("leading", r"\s*"),       # ws... (optional)
    1.12 +                                "^==",                          # ==
    1.13 +                                excl(r".*==\s*?$"),             # not-heading
    1.14 +                                group("padding", r"\N*\n?"))),  # ws-excl-nl... nl (optional)
    1.15  
    1.16          "continuation"  : group("feature",
    1.17 -                          join((group("leading", r"\s*"),   # ws... (optional)
    1.18 +                          join((group("leading", r"\s*"),       # ws... (optional)
    1.19                                  "^",
    1.20 -                                group("indent", r"\s*"),    # ws... (optional)
    1.21 -                                r"\.\.",                    # ..
    1.22 -                                excl(r"\."),                # not-.
    1.23 -                                group("padding", r"\s*")))),# ws... (optional)
    1.24 +                                group("indent", r"\s*"),        # ws... (optional)
    1.25 +                                r"\.\.",                        # ..
    1.26 +                                excl(r"\."),                    # not-.
    1.27 +                                group("padding", r"\N*")))),    # ws-excl-nl... (optional)
    1.28  
    1.29          # Within text:
    1.30  
    1.31 -        "columnsep"     : join((group("leading", r"\s*"),   # ws... (optional)
    1.32 -                                r"\|\|",                    # ||
    1.33 -                                excl(r"\|"),                # not-|
    1.34 -                                group("padding", r"\s*"))), # ws... (optional)
    1.35 +        "columnsep"     : join((group("leading", r"\s*"),       # ws... (optional)
    1.36 +                                r"\|\|",                        # ||
    1.37 +                                excl(r"\|"),                    # not-|
    1.38 +                                group("padding", r"\N*\n?"))),  # ws-excl-nl... nl (optional)
    1.39          })
    1.40  
    1.41      patterns = get_patterns(syntax)
     2.1 --- a/tests/test_table_parser.tree	Mon Oct 25 23:03:10 2021 +0200
     2.2 +++ b/tests/test_table_parser.tree	Tue Oct 26 01:32:32 2021 +0200
     2.3 @@ -75,4 +75,37 @@
     2.4          TableCell
     2.5            Block
     2.6              Text
     2.7 +  Break
     2.8 +  Region
     2.9 +    Table
    2.10 +      TableRow
    2.11 +        TableCell
    2.12 +          List
    2.13 +            ListItem
    2.14 +              Text
    2.15 +            ListItem
    2.16 +              Text
    2.17 +          Block
    2.18 +        TableCell
    2.19 +          List
    2.20 +            ListItem
    2.21 +              Text
    2.22 +            ListItem
    2.23 +              Text
    2.24 +          Block
    2.25 +      TableRow
    2.26 +        TableCell
    2.27 +          List
    2.28 +            ListItem
    2.29 +              Text
    2.30 +            ListItem
    2.31 +              Text
    2.32 +          Block
    2.33 +        TableCell
    2.34 +          List
    2.35 +            ListItem
    2.36 +              Text
    2.37 +            ListItem
    2.38 +              Text
    2.39 +          Block
    2.40    Block
     3.1 --- a/tests/test_table_parser.txt	Mon Oct 25 23:03:10 2021 +0200
     3.2 +++ b/tests/test_table_parser.txt	Tue Oct 26 01:32:32 2021 +0200
     3.3 @@ -39,3 +39,21 @@
     3.4  
     3.5  Separated by break || Some text
     3.6  }}}
     3.7 +
     3.8 +{{{#!table
     3.9 + * A
    3.10 + * B
    3.11 +||
    3.12 + * C
    3.13 + * D
    3.14 +==
    3.15 +
    3.16 + * E
    3.17 + * F
    3.18 +
    3.19 +||
    3.20 +
    3.21 + * G
    3.22 + * H
    3.23 +
    3.24 +}}}