Skip to content

Commit 33cf691

Browse files
committed
Preprocess: remove links to file info pages
This removes the info icon on images that links to the online info page for the image file.
1 parent 47f0b64 commit 33cf691

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

commands/preprocess.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,13 @@ def remove_ads(html):
311311
if el.text is not None and '#carbonads' in el.text:
312312
el.getparent().remove(el)
313313

314+
# remove links to file info pages (e.g. on images)
315+
def remove_fileinfo(html):
316+
info = etree.XPath(r"//a[re:test(@href, 'https?://[a-z]+\.cppreference\.com/w/File:')]/..",
317+
namespaces={'re':'http://exslt.org/regular-expressions'})
318+
for el in info(html):
319+
el.getparent().remove(el)
320+
314321
def preprocess_html_file(root, fn, rename_map):
315322
parser = etree.HTMLParser()
316323
html = etree.parse(fn, parser)
@@ -325,6 +332,7 @@ def preprocess_html_file(root, fn, rename_map):
325332
remove_see_also(html)
326333
remove_google_analytics(html)
327334
remove_ads(html)
335+
remove_fileinfo(html)
328336

329337
# apply changes to links caused by file renames
330338
for el in html.xpath('//*[@src or @href]'):

0 commit comments

Comments
 (0)