diff options
-rw-r--r-- | wikimini/__init__.py | 7 | ||||
-rw-r--r-- | wikimini/document.py | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/wikimini/__init__.py b/wikimini/__init__.py index d6e49a1..876c7a7 100644 --- a/wikimini/__init__.py +++ b/wikimini/__init__.py @@ -1,3 +1,5 @@ +import re + import mwparserfromhell as mwp import requests @@ -184,10 +186,7 @@ class Wikimini: else: return template(self, obj) elif isinstance(obj, mwp.nodes.wikilink.Wikilink): - if (str(obj.title).startswith("File:") - or str(obj.text).startswith("thumb|")): - return [] - elif str(obj.title).startswith("Category:"): + if re.match("\\w+:", str(obj.title)): return [] else: return [InlineLink( diff --git a/wikimini/document.py b/wikimini/document.py index a363c25..c72aa78 100644 --- a/wikimini/document.py +++ b/wikimini/document.py @@ -238,7 +238,7 @@ class Paragraph(Block): # (mainly if their text also contains links, in which case it'd require # multiple parsing passes). As a quick and dirty fix, we just delete # that stuff here: - while match := re.search("\\[\\[File:.+?\\]\\]", self.plain()): + while match := re.search("\\[\\[\\w+:.+?\\]\\]", self.plain()): start_node, start_pos = self._find_index(match.start()) end_node, end_pos = self._find_index(match.end()) |