Skip to content

Commit

Permalink
Merge pull request #269 from tatuylonen/empty-links
Browse files Browse the repository at this point in the history
Return empty links ("[[ ]]") as escaped text
  • Loading branch information
kristian-clausal committed Apr 16, 2024
2 parents be4df6b + 7e1b55c commit 5cb0836
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/wikitextprocessor/core.py
Expand Up @@ -741,6 +741,12 @@ def repl_link(m: re.Match) -> CookieChar:
break
args = vbar_split(orig)
# print("REPL_LINK: orig={!r}".format(orig))
if not any(s.strip() for s in args):
# empty [[ ]] links should really be rendered as
# [[#Language]], where language is the section we're in,
# but if something relies on this behavior I will eat my
# chocolate hat. Let's just return escaped brackets.
return "[[" + m.group(0)[2:-2] + "]]"
return self._save_value("L", args, nowiki)

def repl_extlink(m: re.Match) -> CookieChar:
Expand Down

0 comments on commit 5cb0836

Please sign in to comment.