* doc/coreutils.texi (optAnchor): A new macro that we can
call at each option description to output an anchor.
* doc/local.mk (html-local): Post-process the texinfo generated HTML
(`make html`) to remove our "-option" tag, and replace all
escaped _002d with a standard hyphen, which is fine in URLs.
---
 doc/coreutils.texi |  4 ++++
 doc/local.mk       | 10 ++++++++++
 2 files changed, 14 insertions(+)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 098fa4761..8baf93357 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -568,6 +568,10 @@ manuals for textutils, fileutils, and sh-utils to produce 
the present
 omnibus manual.  Richard Stallman contributed his usual invaluable
 insights to the overall process.
 
+@macro optAnchor{command,option}
+@anchor{\command\-option\option\}
+@end macro
+
 @node Common options
 @chapter Common options
 
diff --git a/doc/local.mk b/doc/local.mk
index 3a46e0820..da5d21240 100644
--- a/doc/local.mk
+++ b/doc/local.mk
@@ -131,3 +131,13 @@ sc-lower-case-var:
          $(PERL) -lne $(find_upper_case_var) $(texi_files)
 
 check-local: check-texinfo
+
+# Post-process generated HTML to clean up anchor IDs
+_sed_anchor_cleanup = \
+  -e '/id=.*_002doption/ { s/id="\([^"]*\)_002doption/id="\1/g; s/_002d/-/g; }'
+html-local:
+       $(AM_V_GEN)htmlfile=$(info_TEXINFOS:.texi=.html); \
+       sed $(_sed_anchor_cleanup) $$htmlfile > $$htmlfile-t \
+         && mv $$htmlfile-t $$htmlfile
+
+.PHONY: html-local
-- 
2.51.1


Reply via email to