1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-02-13 02:42:18 +02:00
Files
coreutils/build-aux/makeinfo-wrapper.sh.in
Collin Funk 740d33b8da doc: post process html with non-GNU make programs
* .gitignore (/build-aux/makeinfo-wrapper.sh):
* Makefile.am (EXTRA_DIST): Remove build-aux/makeinfo-wrapper.sh.
* build-aux/makeinfo-wrapper.sh.in: New file, renamed from
build-aux/makeinfo-wrapper.sh and modified to use @MAKEINFO@ instead of
makeinfo.
* cfg.mk (MAKEINFO): Remove variable.
* configure.ac: Add build-aux/makeinfo-wrapper.sh as a configure file.
* doc/local.mk (MAKEINFO): Define to
$(abs_top_builddir)/build-aux/makeinfo-wrapper.sh.
(AM_MAKEINFOFLAGS): Move over some values from the previous MAKEINFO
definition.
2026-01-18 12:09:47 -08:00

42 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# makeinfo wrapper that post-processes HTML output to replace _002d with -,
# only on lines containing "option", corresponding to our @optAnchor macro.
# Note texi uses "-" in anchors for spaces, hence why it escapes - with _002d.
@MAKEINFO@ "$@" || exit
process_html()
{
sed_anchor_cleanup=\
'/id=.*_002doption/{ s/id="\([^"]*\)_002doption/id="\1/g; s/_002d/-/g; }'
sed -e "$sed_anchor_cleanup" "$1" > "$1.t" &&
mv "$1.t" "$1"
}
case " $* " in
*" --html"*)
# Find the output file/directory
output=""
next_is_output=false
for arg in "$@"; do
if [ "$next_is_output" = true ]; then
output="$arg"
break
fi
case "$arg" in
-o) next_is_output=true ;;
--output=*) output="${arg#--output=}" ;;
esac
done
# Process the output file/directory
if test -n "$output"; then
test -f "$output" && NAMES='*' || NAMES='*.html'
find "$output" -name "$NAMES" -type f |
# dash doesn't support read -d '' yet.
while IFS= read -r htmlfile; do process_html "$htmlfile"; done
fi
;;
esac