File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1571,8 +1571,15 @@ def table_row_fn(ctx: "Wtp", token: str) -> None:
15711571 return text_fn (ctx , token )
15721572
15731573 if not (ctx .beginning_of_line or ctx .wsp_beginning_of_line ):
1574- vbar_fn (ctx , "|" )
1575- return text_fn (ctx , "-" )
1574+ node = ctx .parser_stack [- 1 ]
1575+ # ignore "|-" token before first row and not at line beginning
1576+ if node .kind == NodeKind .TABLE and not node .contain_node (
1577+ NodeKind .TABLE_ROW
1578+ ):
1579+ return
1580+ else :
1581+ vbar_fn (ctx , "|" )
1582+ return text_fn (ctx , "-" )
15761583
15771584 close_begline_lists (ctx )
15781585 table_check_attrs (ctx )
Original file line number Diff line number Diff line change @@ -3394,6 +3394,22 @@ def test_newline_in_ref(self):
33943394 url_node .largs , [["http://purl.uni-rostock.de/demel/d00649426" ]]
33953395 )
33963396
3397+ def test_incorrt_row_separator (self ):
3398+ # tatuylonen/wiktextract#1509
3399+ self .ctx .start_page ("αζωικός" )
3400+ root = self .ctx .parse ("""{| class="wikitable"|-
3401+ ! Header A
3402+ |-
3403+ | row 1 A
3404+ |}""" )
3405+ table = root .children [0 ]
3406+ first_row = table .children [0 ]
3407+ self .assertEqual (first_row .kind , NodeKind .TABLE_ROW )
3408+ self .assertEqual (len (first_row .children ), 1 )
3409+ header = first_row .children [0 ]
3410+ self .assertEqual (header .kind , NodeKind .TABLE_HEADER_CELL )
3411+ self .assertEqual (header .children , [" Header A\n " ])
3412+
33973413
33983414# XXX implement <nowiki/> marking for links, templates
33993415# - https://en.wikipedia.org/wiki/Help:Wikitext#Nowiki
You can’t perform that action at this time.
0 commit comments