diff --git a/rem2html/rem2html b/rem2html/rem2html
index 079250bc..04906e84 100644
--- a/rem2html/rem2html
+++ b/rem2html/rem2html
@@ -116,6 +116,7 @@ Options:
entry a link to
--forwurl url Same as --backurl, but for the next month's small calendar
--imgbase url Base URL of images and default stylesheet file
+--pngs Use external .PNG images for moon phases rater than data:
--stylesheet url.css URL of CSS stylesheet. If specified, imgbase is NOT
prepended to url.css
--nostyle Produce basic HTML that does not use a CSS stylesheet
@@ -127,11 +128,31 @@ EOM
exit($exit_status);
}
+sub smoosh
+{
+ my ($first, $second) = @_;
+ return $second unless defined ($first);
+ return $second if $first eq '';
+ return $second if ($second =~ m|^/|); # Absolute path given for second
+
+ # Squash multiple slashes
+ $first =~ s|/+|/|g;
+
+ # Special case
+ return "/$second" if ($first eq '/');
+
+ # Delete trailing slash
+ $first =~ s|/$||;
+
+ return "$first/$second";
+}
+
sub parse_options
{
local $SIG{__WARN__} = sub { print STDERR "$TIDY_PROGNAME: $_[0]\n"; };
if (!GetOptions(\%Options, "help|h",
"man",
+ "pngs",
"version",
"stylesheet=s",
"nostyle",
@@ -144,30 +165,23 @@ sub parse_options
"tableonly")) {
usage(1);
}
- $Options{'title'} ||= 'HTML Calendar';
+ $Options{title} ||= 'HTML Calendar';
- my $stylesheet = $Options{'stylesheet'};
+ my $stylesheet = $Options{stylesheet};
if ($stylesheet) {
- if ($stylesheet !~ m{^/}) {
- my $imgbase = $Options{'imgbase'};
- if ($imgbase) {
- $imgbase .= '/' unless $imgbase =~ m{/$};
- $stylesheet = $imgbase . $stylesheet;
- }
- }
- $Options{'stylesheet'} = $stylesheet;
+ $Options{stylesheet} = smoosh($Options{imgbase}, $stylesheet);
}
}
sub start_output
{
- return if ($Options{'tableonly'});
+ return if ($Options{tableonly});
- print("\n\n" . $Options{'title'} . "\n");
- if (!$Options{'nostyle'}) {
- if ($Options{'stylesheet'}) {
+ print("\n\n" . $Options{title} . "\n");
+ if (!$Options{nostyle}) {
+ if ($Options{stylesheet}) {
print('' . "\n");
+ $Options{stylesheet} . '">' . "\n");
} else {
print("