Skip to content

Commit

Permalink
Merge pull request #361 from xxyzz/regex
Browse files Browse the repository at this point in the history
Fix regex alerts
  • Loading branch information
kristian-clausal authored Oct 13, 2023
2 parents 08407b3 + 01ba40a commit 2a9bc51
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/wiktextract/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -1376,11 +1376,11 @@ def repl_1_syntaxhighlight(m):
# Remove <sup> with previewonly class (generated e.g. by {{taxlink|...}})
title = re.sub(r'(?si)<sup\b[^>]*?\bclass="[^"<>]*?'
r'\bpreviewonly\b[^>]*?>'
r'((<[^<>]>[^<>]*</[^<>]*>)|.)*?</sup\s*>',
r'.+?</sup\s*>',
"", title)
# Remove <strong class="error">...</strong>
title = re.sub(r'(?si)<strong\b[^>]*?\bclass="[^"]*?\berror\b[^>]*?>'
r'((<.*?</.[^>]>)|.)*?</strong\s*>',
r'.+?</strong\s*>',
"", title)
# Change <div> and </div> to newlines. Ditto for tr, li, table, dl, ul, ol
title = re.sub(r"(?si)</?(div|tr|li|table|dl|ul|ol)\b[^>]*>",
Expand Down Expand Up @@ -1438,7 +1438,7 @@ def repl_1_syntaxhighlight(m):
)
title = re.sub(r"(?s)\[\[\s*:?([^]|#<>]+?)\s*(#[^][|<>]*?)?\]\]",
repl_1, title)
title = re.sub(r"(?s)\[\[\s*(([a-zA-z0-9]+)\s*:)?\s*([^][#|<>]+?)"
title = re.sub(r"(?s)\[\[\s*(([a-zA-Z0-9]+)\s*:)?\s*([^][#|<>]+?)"
r"\s*(#[^][|]*?)?\|?\]\]",
repl_link, title)
title = re.sub(r"(?s)\[\[\s*([^][|<>]+?)\s*\|"
Expand Down

0 comments on commit 2a9bc51

Please sign in to comment.