aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne Georg Gleditsch <argggh@lxr.linpro.no>2007-12-03 16:42:39 +0100
committerArne Georg Gleditsch <argggh@lxr.linpro.no>2007-12-03 16:42:39 +0100
commit8c290c3b917b1683a8f4355019366d45d5ddb42f (patch)
treeb047b57ae676ba26bc35c8253b954cfb82f83ed5
parent02697c25211adb329cf49b47545bfb52a6d47b4c (diff)
Subst::Complex is overkill here, as we're only returning a flat string.
-rw-r--r--lib/LXRng/Markup/File.pm31
1 files changed, 18 insertions, 13 deletions
diff --git a/lib/LXRng/Markup/File.pm b/lib/LXRng/Markup/File.pm
index 084d4a6..986f05c 100644
--- a/lib/LXRng/Markup/File.pm
+++ b/lib/LXRng/Markup/File.pm
@@ -78,19 +78,24 @@ sub format_code {
my $tree = $self->context->vtree();
my $path = $self->context->path();
- Subst::Complex::s($frag,
- $idre => sub {
- my $sym = $_[1];
- unless (exists($$res{$sym})) {
- $sym = safe_html($sym);
- return qq{<a href="+code=$sym" class="sref">$sym</a>}
- }
- else {
- return safe_html($sym);
- }
- },
- qr/(.*?)/ => sub { return safe_html($_[0]) },
- );
+
+ $frag =~ s{(.*?)$idre|(.+)}{
+ if ($2) {
+ unless (exists($$res{$2})) {
+ my $pre = $1;
+ my $sym = safe_html($2);
+ safe_html($pre).
+ qq{<a href="+code=$sym" class="sref">$sym</a>};
+ }
+ else {
+ safe_html($1.$2);
+ }
+ }
+ else {
+ safe_html($3);
+ }
+ }ge;
+ return $frag;
}
sub format_raw {