forked from ARM-software/acle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhyperref-check.sh
executable file
·30 lines (25 loc) · 1.45 KB
/
hyperref-check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
# SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates <[email protected]>
# SPDX-License-Identifier: Apache-2.0
set -ex
# Convert svg image to pdf for use in pdf generation via pandoc.
mkdir -p pdfs tmp
inkscape -z Arm_logo_blue_RGB.svg -e tmp/Arm-logo-blue-RGB.pdf
# Extracting all broken hyperref detected by PDFTex
for file in "./main/acle.md" "./morello/morello.md" "./mve_intrinsics/mve.md" "./neon_intrinsics/advsimd.md" \
"./cmse/cmse.md"; do
echo "Checking $file..."
# The following string of pipes extracts the unresolved internal links by:
# - Using tee to output the error and warning messages generated by pandoc pdf conversion into a file
# - Using grep to extract all unresolved links from the file, for instance, "pdfTeX warning (dest): name{ssec-bf16-scalar}"
# - Using wc to count all the lines and thus all the warnings/detected broken links
pandoc --template=tools/acle_template.tex $file --verbose -o pdfs/tmp.pdf --resource-path=$(dirname $file) 2>&1 | tee tmp/output
number_of_broken_refs=`cat tmp/output | grep 'pdfTeX warning (dest): name' | wc -l`
rm pdfs/tmp.pdf tmp/output
if [[ $number_of_broken_refs -gt 0 ]]; then
echo "**** ERROR! There are $number_of_broken_refs unresolved internal references in $file."
echo "Please use this command on your local terminal for more information:"
echo "pandoc $file --verbose -o pdfs/tmp.pdf"
exit 1
fi
done