minor code cosmetics (declare version first)
[sheet.git] / source.plp
index 5359dbe01e37224b0f263e28be4d2714dcc6dccf..295f9e068ec295cedda2577dd306f4b91ec5d831 100644 (file)
@@ -1,11 +1,5 @@
-<:
-use utf8;
-use strict;
-use warnings;
-
-our $VERSION = 'v1.0';
-
-$header{content_type} = "text/html; charset=utf-8";
+<(common.inc.plp)><:
+       our $VERSION = 'v1.0';
 
 :><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">
 
 :><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">
@@ -14,13 +8,7 @@ $header{content_type} = "text/html; charset=utf-8";
 <head>
 <meta http-equiv="content-type" content="<:= $header{content_type} :>">
 <title>sheet page source code</title>
 <head>
 <meta http-equiv="content-type" content="<:= $header{content_type} :>">
 <title>sheet page source code</title>
-<link rel="stylesheet" type="text/css" media="all" href="/base.css"><:
-       my %styles = map {$_ => $_} qw(dark mono red);
-       our $style = exists $get{style} && $styles{$get{style}} || 'light';
-       printf(qq{\n<link rel="%s" type="text/css" media="all" href="%s" title="%s">},
-               $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css", $_
-       ) for keys %styles;
-:>
+<:= stylesheet(qw'light dark mono red') :>
 </head>
 
 <body id="source">
 </head>
 
 <body id="source">
@@ -74,8 +62,8 @@ else {
                my $tag = $_->[0] && ($TYPETAG{ $_->[0] } || 'span');
                my $arg = '';
                print "<$tag$arg class=\"sy-\l$_->[0]\">" if $tag;
                my $tag = $_->[0] && ($TYPETAG{ $_->[0] } || 'span');
                my $arg = '';
                print "<$tag$arg class=\"sy-\l$_->[0]\">" if $tag;
-               if ($_->[0] eq 'Constant'
-               and $_->[1] =~ s{^(['"])(/?[a-z0-9_.]+\.(?:plp?|css|js))(?=\1$)}{}) {
+               if (!$_->[0] || $_->[0] eq 'Constant'
+               and $_->[1] =~ s{^(['"]?)(/?[a-z0-9_.]+\.(?:plp?|css|js))(?=\1$)}{}) {
                        printf '%s<a href="%s">%s</a>', $1, "/source/$2", $2;
                }
                if (!$_->[0] and $_->[1] =~ s/^(\s*)([A-Z]\w+(?:::\w+)+)(?![^;\s])//) {
                        printf '%s<a href="%s">%s</a>', $1, "/source/$2", $2;
                }
                if (!$_->[0] and $_->[1] =~ s/^(\s*)([A-Z]\w+(?:::\w+)+)(?![^;\s])//) {