From ec0964154520279233e2df3f0374b2a01bbcc8b5 Mon Sep 17 00:00:00 2001 From: Benjamin Mako Hill Date: Thu, 6 Aug 2026 16:05:44 -0700 Subject: [PATCH] only prefix namespace names onto titles that lack them WikiqPage unconditionally prepended the namespace name to titles of pages outside the main namespace. mwxml >= 0.3.7 keeps the namespace prefix on the title when the dump carries tags (it previously stripped it), which made wikiq emit double-prefixed titles like "Category:Category:Alaska". Check for the prefix before adding it. mwxml still strips the prefix on its fallback path for dumps without tags, so those titles are still prefixed as before. Co-Authored-By: Claude Fable 5 --- src/wikiq/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wikiq/__init__.py b/src/wikiq/__init__.py index 9d3cb7a..5a6728f 100755 --- a/src/wikiq/__init__.py +++ b/src/wikiq/__init__.py @@ -385,8 +385,12 @@ class WikiqPage: # page.namespace is inconsistent with namespace_map if page.namespace not in namespace_map: page.namespace = 0 + # mwxml >= 0.3.7 keeps the namespace prefix on the title when the dump + # has tags, but strips it on the no- fallback path if page.namespace != 0: - page.title = ":".join([namespace_map[page.namespace], page.title]) + ns_prefix = namespace_map[page.namespace] + ":" + if not page.title.startswith(ns_prefix): + page.title = ns_prefix + page.title self.restrictions = page.restrictions self.collapse_user = collapse_user self.mwpage = page