From 219cb22723b29e968bc740d1f34b3b09265a9c08 Mon Sep 17 00:00:00 2001
From: Mischa POSLAWSKY
Date: Sun, 23 Apr 2017 03:02:31 +0200
Subject: [PATCH] common: replace html links by common function
---
browser.plp | 8 ++++----
digits.plp | 2 +-
emoji.plp | 2 +-
sc.plp | 12 +++++-------
source.plp | 8 ++++----
writing.plp | 2 +-
6 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/browser.plp b/browser.plp
index 0d4d4e7..a78e0ec 100644
--- a/browser.plp
+++ b/browser.plp
@@ -107,7 +107,7 @@ given ($get{usage} // 'wm') {
};
$usage = $_;
my $ref = $canihas->{-title} || 'unknown';
- $ref = sprintf '%s', $_, $ref
+ $ref = showlink($ref, $_)
for $canihas->{-site} || $canihas->{-source} || ();
$ref .= " $_" for $canihas->{-date} || ();
print "\nwith $ref browser usage statistics";
@@ -339,10 +339,10 @@ sub saytitlecol {
say '
';
}
printf 'Resources: %s.', join(', ', map {
- sprintf '%s', EscapeHTML($_->{url}), EscapeHTML($_->{title})
+ showlink($_->{title}, $_->{url})
} @$_) for grep { @$_ } $row->{links} // ();
printf '
Parent feature: %s.', join(', ', map {
- sprintf '%s', EscapeHTML("#$_"), $caniuse->{data}->{$_}->{title}
+ showlink($caniuse->{data}->{$_}->{title}, "#$_")
} $_) for $row->{parent} || ();
print '';
}
@@ -353,7 +353,7 @@ sub saystatuscol {
for ($row->{status}) {
my $cell = $_ // '-';
- $cell = sprintf '%s', $_, $cell for $row->{spec} // ();
+ $cell = showlink($cell, $_) for $row->{spec} // ();
printf '%s',
$caniuse->{statuses}->{$_}, $CSTATUS{$_} // '', $cell;
}
diff --git a/digits.plp b/digits.plp
index 2bef8f3..2f95616 100644
--- a/digits.plp
+++ b/digits.plp
@@ -38,7 +38,7 @@ unless (exists $get{v}) {
}
my $scriptname = do 'writing-script.inc.pl';
-$_ = qq{$_} for $scriptname->{latn} || ();
+$_ = showlink($_, "/latin") for $scriptname->{latn} || ();
my $table = do "writing-digits.inc.pl";
die "Table data not found: $_\n" for $@ || $! || ();
diff --git a/emoji.plp b/emoji.plp
index ac3be58..2a546b4 100644
--- a/emoji.plp
+++ b/emoji.plp
@@ -25,7 +25,7 @@ for my $system (qw'gmail msn yahoo') {
my $meta = shift @info or die $@;
ref $meta eq 'HASH' or die "invalid $system definitions";
my $title = $meta->{name} // $system;
- $title = qq{$title} for $meta->{source} || ();
+ $title = showlink($title, $_) for $meta->{source} || ();
say sprintf '%s', $meta->{name} // $system;
say ' ';
diff --git a/sc.plp b/sc.plp
index b5d81ec..3437f8f 100644
--- a/sc.plp
+++ b/sc.plp
@@ -49,8 +49,8 @@ my $patch = shift @{$units}
say "Unit properties as seen or measured in $scver{name}\n$patch.";
say "Also see the $_ table." for join(', ',
- ('StarCraft 2: HotS') x ($scver{major} < 2),
- ('original SC: Brood War') x ($scver{major} > 1),
+ (showlink('StarCraft 2: HotS', '/sc/2')) x ($scver{major} < 2),
+ (showlink('original SC: Brood War', '/sc')) x ($scver{major} > 1),
);
say " \n";
@@ -85,11 +85,9 @@ for my $unit (@{$units}) {
sub coltoggle {
my ($name, $id, $nolink) = @_;
- return sprintf(
- (defined $get{order} ? $get{order} eq $id : !$id) ? '%2$s â¼'
- : $nolink ? '%2$s' : '%s',
- $id && "order=$id", $name
- );
+ return "$name â¼" if defined $get{order} ? $get{order} eq $id : !$id;
+ return $name if $nolink;
+ return showlink($name, '?'.($id && "order=$id"));
}
:>
diff --git a/source.plp b/source.plp
index 56193fb..2b13371 100644
--- a/source.plp
+++ b/source.plp
@@ -47,7 +47,7 @@ if (not $source) {
say '';
for (glob '*.plp') {
chomp;
- say sprintf '- %1$s
', EscapeHTML($_);
+ say '- ', showlink($_, "/source/$_");
}
say "
\n";
}
@@ -90,16 +90,16 @@ else {
if (!$type || $type eq 'Constant'
and $contents =~ s{^(['"]?)(/?[a-z0-9_.]+\.(?:plp?|css|js))(?=\1$)}{}) {
# link other page sources, stylesheets, and javascript
- printf '%s%s', $1, "/source/$2", $2;
+ print $1 . showlink($2, "/source/$2");
}
if (!$type and $contents =~ s/^(\s*)([A-Z]\w+(?:::\w+)+)(?![^;\s])//) {
# link perl module names (Xx::Xx...)
- printf '%s%s', $1, "/source/$2", $2;
+ print $1 . showlink($2, "/source/$2");
}
if ($type && $type eq 'Comment'
and $contents =~ s{^(.*? by )(tools/\S+)}{}) {
# link generator scripts (by tools/...)
- printf '%s%s', $1, "/source/$2", $2;
+ print $1 . showlink($2, "/source/$2");
}
print Text::VimColor::_xml_escape($contents);
print "$tag>" if $tag;
diff --git a/writing.plp b/writing.plp
index a718c88..ee2d825 100644
--- a/writing.plp
+++ b/writing.plp
@@ -36,7 +36,7 @@ unless (exists $get{v}) {
}
my $scriptname = do 'writing-script.inc.pl';
-$_ = qq{$_} for $scriptname->{latn} || ();
+$_ = showlink($_, "/latin") for $scriptname->{latn} || ();
for (
[phnx => 'Phoenician'],
--
2.30.0
|