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