@@ -463,6 +463,20 @@ def process_double_brackets(text, tvar_id=0):
463463 file_aliases = ['File:' , 'file:' , 'Image:' , 'image:' ]
464464 skip_namespaces = category_aliases + file_aliases + ['Special:' , 'User:' , 'User talk:' ]
465465
466+ # Known internal MediaWiki namespace prefixes — anything else with a colon is an interwiki link
467+ internal_namespaces = {
468+ 'Talk:' , 'talk:' , 'User:' , 'user:' , 'User talk:' , 'user talk:' ,
469+ 'Project:' , 'project:' , 'Project talk:' , 'project talk:' ,
470+ 'File:' , 'file:' , 'File talk:' , 'file talk:' ,
471+ 'MediaWiki:' , 'mediawiki:' , 'MediaWiki talk:' , 'mediawiki talk:' ,
472+ 'Template:' , 'template:' , 'Template talk:' , 'template talk:' ,
473+ 'Help:' , 'help:' , 'Help talk:' , 'help talk:' ,
474+ 'Category:' , 'category:' , 'Category talk:' , 'category talk:' ,
475+ 'Special:' , 'special:' , 'Media:' , 'media:' ,
476+ 'Image:' , 'image:' , 'Image talk:' , 'image talk:' ,
477+ 'Cat:' , 'cat:' ,
478+ }
479+
466480 ns = None
467481 if ':' in parts [0 ]:
468482 ns = parts [0 ].split (':' , 1 )[0 ] + ':'
@@ -474,6 +488,11 @@ def process_double_brackets(text, tvar_id=0):
474488 return _process_file (text )
475489 if ns in skip_namespaces :
476490 return text , double_brackets_types .special if ns == 'Special:' else double_brackets_types .wikilink
491+ # Interwiki links: colon-prefixed but not a known internal MediaWiki namespace
492+ if ns is not None and ns not in internal_namespaces :
493+ link_target = capitalise_first_letter (parts [0 ])
494+ display_text = parts [0 ] if len (parts ) == 1 else parts [1 ]
495+ return f'[[<tvar name={ tvar_id } >{ link_target } </tvar>|{ display_text } ]]' , double_brackets_types .wikilink
477496 if len (parts ) == 1 :
478497 return f'[[<tvar name={ tvar_id } >Special:MyLanguage</tvar>/{ capitalise_first_letter (parts [0 ])} |{ parts [0 ]} ]]' , double_brackets_types .wikilink
479498 if len (parts ) == 2 :
0 commit comments