Skip to content

Commit 2e0212b

Browse files
author
H. Peter Anvin
committed
doc/rdsrc.pl: add \w{...} to reduce the verbosity of web links
Create a shorthand for a web link where the URL itself is also the text. Signed-off-by: H. Peter Anvin (Intel) <[email protected]>
1 parent 0421148 commit 2e0212b

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

doc/rdsrc.pl

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
# the \W prefix is ignored except in HTML; in HTML the last part
8787
# becomes a hyperlink to the first part.
8888
#
89+
# Web URL \w{http://foobar/}
90+
# equivalent to \W{http://foobar}\c{http://foobar/}.
91+
#
8992
# Literals \{ \} \\
9093
# In case it's necessary, they expand to the real versions.
9194
#
@@ -123,8 +126,8 @@
123126
# insert the {something} string associated with metadata {key}
124127
#
125128
# Include subfile
126-
# \&{filename}
127-
# Includes filename. Recursion is allowed.
129+
# \& filename
130+
# includes filename. Recursion is allowed. Must be on a separate line.
128131
#
129132

130133
use File::Spec;
@@ -474,22 +477,31 @@ sub got_para {
474477
die "badly formatted \\k: \\k$_\n" if !/\{([^\}]*)\}(.*)$/;
475478
$_ = $2;
476479
push @$para,"$t$1";
477-
} elsif (/^\\W/) {
478-
s/^\\W//;
479-
die "badly formatted \\W: \\W$_\n"
480-
if !/\{([^\}]*)\}(\\i)?(\\c)?\{(([^\\}]|\\.)*)\}(.*)$/;
481-
$l = $1;
482-
$w = $4;
483-
$_ = $6;
484-
$t = "w ";
485-
$t = "wc" if $3 eq "\\c";
486-
$indexing = 1 if $2;
487-
$w =~ s/\\\{/\{/g;
488-
$w =~ s/\\\}/\}/g;
489-
$w =~ s/\\-/-/g;
490-
$w =~ s/\\\\/\\/g;
491-
push(@$para, addidx($node, $w, "c $w")) if $indexing;
492-
push(@$para, "$t<$l>$w");
480+
} elsif (/^\\[Ww]/) {
481+
if (/^\\w/) {
482+
die "badly formatted \\w: $_\n"
483+
if !/^\\w(\\i)?\{([^\\}]*)\}(.*)$/;
484+
$l = $2;
485+
$w = $2;
486+
$indexing = $1;
487+
$c = 1;
488+
$_ = $3;
489+
} else {
490+
die "badly formatted \\W: $_\n"
491+
if !/^\\W\{([^\\}]*)\}(\\i)?(\\c)?\{(([^\\}]|\\.)*)\}(.*)$/;
492+
$l = $1;
493+
$w = $4;
494+
$_ = $6;
495+
$indexing = $2;
496+
$c = $3;
497+
}
498+
$t = $c ? 'wc' : 'w ';
499+
$w =~ s/\\\{/\{/g;
500+
$w =~ s/\\\}/\}/g;
501+
$w =~ s/\\-/-/g;
502+
$w =~ s/\\\\/\\/g;
503+
push(@$para, addidx($node, $w, "c $w")) if $indexing;
504+
push(@$para, "$t<$l>$w");
493505
} else {
494506
die "what the hell? $_\n" if !/^(([^\s\\\-]|\\[\\{}\-])*-?)(.*)$/;
495507
die "painful death! $_\n" if !length $1;

0 commit comments

Comments
 (0)