Skip to content

Commit

Permalink
Only parse ---- as horizontal rule if it's at the start of line
Browse files Browse the repository at this point in the history
  • Loading branch information
xxyzz committed Jun 21, 2024
1 parent 0136956 commit 4bfab84
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/wikitextprocessor/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2256,7 +2256,7 @@ def process_text(ctx: "Wtp", text: str) -> None:
subtitle_end_fn(ctx, token)
elif token.startswith("<"): # HTML tag like construct
tag_fn(ctx, token)
elif token.startswith("----"):
elif token.startswith("----") and ctx.beginning_of_line:
hline_fn(ctx, token)
elif re.match(list_prefix_re, token):
list_fn(ctx, token)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2920,6 +2920,18 @@ def test_zh_x_html(self):
self.assertEqual(span_text, "example text")
self.assertEqual(dd_text, "translation text")

def test_horizontal_rule_in_template_arg(self):
# GitHub issue tatuylonen/wiktextract#536
self.ctx.start_page("shithole")
root = self.ctx.parse("{{alt|en|—hole|----hole}}")
template_node = root.children[0]
self.assertIsInstance(template_node, TemplateNode)
self.assertEqual(len(root.children), 1)
self.assertEqual(
template_node.template_parameters,
{1: "en", 2: "—hole", 3: "----hole"},
)


# XXX implement <nowiki/> marking for links, templates
# - https://en.wikipedia.org/wiki/Help:Wikitext#Nowiki
Expand Down

0 comments on commit 4bfab84

Please sign in to comment.