mirror of
https://github.com/Kozea/Radicale.git
synced 2025-07-02 16:58:30 +00:00
Check for duplicate ids and dead internal links
This commit is contained in:
parent
8a40233824
commit
958150ae61
1 changed files with 16 additions and 0 deletions
|
@ -43,6 +43,22 @@ def main():
|
||||||
header.append(" ")
|
header.append(" ")
|
||||||
header.append(link)
|
header.append(link)
|
||||||
|
|
||||||
|
# Check for duplicate ids
|
||||||
|
visited_ids = set()
|
||||||
|
for element in soup.select("*[id]"):
|
||||||
|
if element["id"] in visited_ids:
|
||||||
|
print("ERROR: Duplicate id %r" % element["id"],
|
||||||
|
file=sys.stderr)
|
||||||
|
exit(1)
|
||||||
|
visited_ids.add(element["id"])
|
||||||
|
|
||||||
|
# Check for dead internal links
|
||||||
|
for link in soup.select("a[href^=\\#]"):
|
||||||
|
if link["href"][1:] not in visited_ids:
|
||||||
|
print("ERROR: Dead internal link %r" % link["href"],
|
||||||
|
file=sys.stderr)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
sys.stdout.buffer.write(soup.encode(formatter="html5") + b"\n")
|
sys.stdout.buffer.write(soup.encode(formatter="html5") + b"\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue