summaryrefslogtreecommitdiffstats
path: root/update_targets.py
diff options
context:
space:
mode:
Diffstat (limited to 'update_targets.py')
-rw-r--r--update_targets.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/update_targets.py b/update_targets.py
new file mode 100644
index 0000000..2052e68
--- /dev/null
+++ b/update_targets.py
@@ -0,0 +1,17 @@
+import sys
+from bs4 import BeautifulSoup
+
+html_doc = open(sys.argv[1], mode="r")
+html = html_doc.read()
+soup = BeautifulSoup(html, features="lxml")
+for link in soup.find_all("a"):
+ if "href" in link.attrs.keys():
+ if (link['href'].startswith("#")
+ and "tabindex" not in link.attrs.keys()
+ and "target" not in link.attrs.keys()):
+ link['target'] = "_self"
+html_doc.close()
+html_doc = open(sys.argv[1], mode="w")
+print(soup, file=html_doc)
+print("File written")
+