Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Wikicode.matches() handle namespaces. #335

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

roysmith
Copy link

Wikicode.matches() currently does not handle page names with namespaces and/or interwiki links. This makes them do so.

Fixes #302.


If either side has any colons, everything before the last colon is taken to be
a namespace and/or interwiki prefix. The parts before and after the colon are
normalized and compared separately; both must match for the result to be True.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not make sense - if something is not a valid namespace/interwiki prefix, it should not be normalized.

@roysmith
Copy link
Author

roysmith commented Jan 10, 2025

OK, I've just spent some time reading https://www.mediawiki.org/wiki/Manual:Page_title and have come to the realization that this (as with so many things about MediaWiki) is way more complicated than I originally thought.

So, one possibility would be to have matches() optionally accept something like a ws.parser_helpers.title.Context, but I don't think anybody would be happy if this required pulling in wiki-scripts as a dependency. And the fact that wiki-scripts is GPL3 while mwp is MIT makes doing any kind of copy-paste integration problematic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wikicode.matches() doesn't handle lower-case page title
2 participants