]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
doc: html: support defined anchors for command options
authorPádraig Brady <P@draigBrady.com>
Thu, 27 Nov 2025 20:45:44 +0000 (20:45 +0000)
committerPádraig Brady <P@draigBrady.com>
Fri, 5 Dec 2025 16:32:14 +0000 (16:32 +0000)
* doc/coreutils.texi (optAnchor): A new macro to output a
referencable anchor, called from ...
(optItem): ... here; a new macro to output all index entries
for each option item.
(optZero,optZeroTerminated): Show an example of the adjustment
done to each option description.
* 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
doc/local.mk

index 71fb01649739313a5d088804ec86abea52159c68..84102725a50f0a6492b82e0b1705673440268e2d 100644 (file)
@@ -568,6 +568,22 @@ 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
+
+@macro optItem{command,option,param}
+@optAnchor{\command\,\option\}
+@item \option\\param\
+@opindex \option\
+@end macro
+
+@macro optItemx{command,option,param}
+@optAnchor{\command\,\option\}
+@itemx \option\\param\
+@opindex \option\
+@end macro
+
 @node Common options
 @chapter Common options
 
@@ -628,19 +644,15 @@ output even when that output would contain data with embedded newlines.
 @outputNUL
 @end macro
 
-@macro optZero
-@item -z
-@itemx --zero
-@opindex -z
-@opindex --zero
+@macro optZero{cmd}
+@optItem{\cmd\,-z}
+@optItemx{\cmd\,--zero}
 @outputNUL
 @end macro
 
-@macro optZeroTerminated
-@item -z
-@itemx --zero-terminated
-@opindex -z
-@opindex --zero-terminated
+@macro optZeroTerminated{cmd}
+@optItem{\cmd\,-z}
+@optItemx{\cmd\,--zero-terminated}
 @cindex process zero-terminated items
 Delimit items with a zero byte rather than a newline (ASCII LF).
 I.e., treat input as items separated by ASCII NUL
index 3a46e082048564526a6e1f47e41add897c908d6a..da5d21240d6f9ff959bbb5f283706a43545a9743 100644 (file)
@@ -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