disabeling links to wiki File pages

master
Castro0o 5 years ago
parent fa837a3791
commit 27cc21a58a

@ -53,6 +53,14 @@ def filenameforlink(href):
def rewritelinks (html): def rewritelinks (html):
t = html5lib.parseFragment(html, treebuilder = "etree", namespaceHTMLElements = False) t = html5lib.parseFragment(html, treebuilder = "etree", namespaceHTMLElements = False)
# remove links to wiki File: pages
for a in t.findall(".//a[@class='image']"): # select img wrapping a
href = a.attrib.get('href')
if a.findall(".//img") and 'File:' in href: # ensure a has child: img
a.attrib['href'] = 'javascript:void(0);' # disable href
print('a wrapping img:', ET.tostring(a))
for a in t.findall(".//*[@href]"): for a in t.findall(".//*[@href]"):
linkclass = a.attrib.get("class", "") linkclass = a.attrib.get("class", "")
href = a.attrib.get("href") href = a.attrib.get("href")

@ -11,4 +11,6 @@ a, a:visited{
a:hover { a:hover {
text-decoration: none; text-decoration: none;
color: blue; color: blue;
} }
a.image {cursor: default!important;} /* KEEP THIS: it is important to avoid images to seeming like links */
Loading…
Cancel
Save