diff --git a/src/wikitextprocessor/core.py b/src/wikitextprocessor/core.py index 64044a75..94cb64c8 100644 --- a/src/wikitextprocessor/core.py +++ b/src/wikitextprocessor/core.py @@ -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: