1#!/bin/sh
2#
3# Copyright 2015-2023 The Khronos Group Inc.
4#
5# SPDX-License-Identifier: Apache-2.0
6
7# checkXrefs - check internal links in a Vulkan HTML spec
8# Usage: checkXrefs file.html
9# Prints a list of internal hrefs with no corresponding anchors.
10# (There are many anchors with no corresponding hrefs - this is OK).
11
12xrefs=`tempfile`
13ids=`tempfile`
14
15sed -e 's/ href="#/\nhref="#/g' < $1 | \
16    grep 'href="#' | \
17    sed -e 's/href="#//g' -e 's/"[ >].*//g' | \
18    sort | uniq > $xrefs
19sed -e 's/ id="/\nid="/g' < $1 | \
20    grep 'id="' | \
21    sed -e 's/id="//g' -e 's/"[ >].*//g' | \
22    sort | uniq > $ids
23
24comm -23 $xrefs $ids
25
26rm $xrefs $ids 1>&2
27