diff --git a/src/wikitextprocessor/core.py b/src/wikitextprocessor/core.py index 741abe5..0aa2463 100644 --- a/src/wikitextprocessor/core.py +++ b/src/wikitextprocessor/core.py @@ -723,7 +723,12 @@ def _save_value( assert isinstance(args, (list, tuple)) assert nowiki in (True, False) # print("save_value", kind, args, nowiki) - args = tuple(args) + args = tuple( + arg.replace(MAGIC_LBRACKET_CHAR, "[").replace( + MAGIC_RBRACKET_CHAR, "]" + ) + for arg in args + ) v: CookieData = (kind, args, nowiki) if v in self.rev_ht: return self.rev_ht[v] @@ -962,8 +967,9 @@ def repl_extlink(m: re.Match) -> CookieChar: # text = re.sub(r"[^|]\}", r"\1}", text) # text = re.sub(r"[^|]\}", r"\1}", text) # text = re.sub(r"\|", "|", text) - text = text.replace(MAGIC_LBRACKET_CHAR, "[") - text = text.replace(MAGIC_RBRACKET_CHAR, "]") + text = text.replace(MAGIC_LBRACKET_CHAR, "[").replace( + MAGIC_RBRACKET_CHAR, "]" + ) return text def _template_to_body(self, title: str, text: Optional[str]) -> str: