Skip to content

Commit

Permalink
doc/rdsrc.pl: add \w{...} to reduce the verbosity of web links
Browse files Browse the repository at this point in the history
Create a shorthand for a web link where the URL itself is also the text.

Signed-off-by: H. Peter Anvin (Intel) <[email protected]>
  • Loading branch information
H. Peter Anvin committed May 20, 2024
1 parent 0421148 commit 2e0212b
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions doc/rdsrc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
# the \W prefix is ignored except in HTML; in HTML the last part
# becomes a hyperlink to the first part.
#
# Web URL \w{http://foobar/}
# equivalent to \W{http://foobar}\c{http://foobar/}.
#
# Literals \{ \} \\
# In case it's necessary, they expand to the real versions.
#
Expand Down Expand Up @@ -123,8 +126,8 @@
# insert the {something} string associated with metadata {key}
#
# Include subfile
# \&{filename}
# Includes filename. Recursion is allowed.
# \& filename
# includes filename. Recursion is allowed. Must be on a separate line.
#

use File::Spec;
Expand Down Expand Up @@ -474,22 +477,31 @@ sub got_para {
die "badly formatted \\k: \\k$_\n" if !/\{([^\}]*)\}(.*)$/;
$_ = $2;
push @$para,"$t$1";
} elsif (/^\\W/) {
s/^\\W//;
die "badly formatted \\W: \\W$_\n"
if !/\{([^\}]*)\}(\\i)?(\\c)?\{(([^\\}]|\\.)*)\}(.*)$/;
$l = $1;
$w = $4;
$_ = $6;
$t = "w ";
$t = "wc" if $3 eq "\\c";
$indexing = 1 if $2;
$w =~ s/\\\{/\{/g;
$w =~ s/\\\}/\}/g;
$w =~ s/\\-/-/g;
$w =~ s/\\\\/\\/g;
push(@$para, addidx($node, $w, "c $w")) if $indexing;
push(@$para, "$t<$l>$w");
} elsif (/^\\[Ww]/) {
if (/^\\w/) {
die "badly formatted \\w: $_\n"
if !/^\\w(\\i)?\{([^\\}]*)\}(.*)$/;
$l = $2;
$w = $2;
$indexing = $1;
$c = 1;
$_ = $3;
} else {
die "badly formatted \\W: $_\n"
if !/^\\W\{([^\\}]*)\}(\\i)?(\\c)?\{(([^\\}]|\\.)*)\}(.*)$/;
$l = $1;
$w = $4;
$_ = $6;
$indexing = $2;
$c = $3;
}
$t = $c ? 'wc' : 'w ';
$w =~ s/\\\{/\{/g;
$w =~ s/\\\}/\}/g;
$w =~ s/\\-/-/g;
$w =~ s/\\\\/\\/g;
push(@$para, addidx($node, $w, "c $w")) if $indexing;
push(@$para, "$t<$l>$w");
} else {
die "what the hell? $_\n" if !/^(([^\s\\\-]|\\[\\{}\-])*-?)(.*)$/;
die "painful death! $_\n" if !length $1;
Expand Down

0 comments on commit 2e0212b

Please sign in to comment.