* => URL[ optional text]
Creates <a href="URL">{optional text|URL}</a> link in HTML.
-* img URL[ optional text]
+* img URL[ optional text][ => URL-A]
Creates <img src="URL" [alt="optional text"] /> in HTML.
+ If "=> URL" is specified, then <a href="URL-A"><img ... /></a>.
* |...
Just inserts raw ... line to HTML output as-is.
* #...
* do-backs
Forcefully creates a table with all backlinks to the page.
* <<[indent][page]
- Include contents of the specified page. Brackets around
- [page] are for making a link to page. indent is optional.
+ Include contents of the specified page. indent is optional.
+ Brackets around [page] are for making a link to page.
if (/${CR}$/) {
chop;
my $head = q{};
- my @cols;
- if (/^(\s*)(.*)$/) {
+ my $cmd = $_;
+ if (/^(\s+)(.*)$/) {
$head = $1;
- @cols = split /\s+/, $2;
- } else {
- @cols = split /\s+/;
+ $cmd = $2;
}
- if ($cols[0] eq q{=>}) {
- my $t = ($#cols > 1) ? (join q{ }, @cols[2..$#cols]) : $cols[1];
+ if ($cmd =~ /^=> (\S+)\s?(.*)$/) {
+ my $t = ($2 eq q{}) ? $1 : $2;
$t = htmlescape $t;
$t =~ s/"/\&guot;/g;
- $_ = "$head=> <a href=\"$cols[1]\">$t</a>";
- } elsif ($cols[0] eq q{img}) {
- if ($#cols > 1) {
- my $t = htmlescape join q{ }, @cols[2..$#cols];
+ $_ = "$head=> <a href=\"$1\">$t</a>";
+ } elsif ($cmd =~ /^img (\S+)\s?(.*) => (\S+)$/) {
+ if ($2 eq q{}) {
+ $_ = "$head<a href=\"$3\"><img src=\"$1\" /></a>";
+ } else {
+ my $t = $2;
+ $t = htmlescape $t;
$t =~ s/"/\&guot;/g;
- $_ = "$head<img src=\"$cols[1]\" alt=\"$t\" />";
+ $_ = "$head<a href=\"$3\"><img src=\"$1\" alt=\"$t\" /></a>";
+ }
+ } elsif ($cmd =~ /^img (\S+)\s?(.*)$/) {
+ if ($2 eq q{}) {
+ $_ = "$head<img src=\"$1\" />";
} else {
- $_ = "$head<img src=\"$cols[1]\" />";
+ my $t = $2;
+ $t = htmlescape $t;
+ $t =~ s/"/\&guot;/g;
+ $_ = "$head<img src=\"$1\" alt=\"$t\" />";
}
- } elsif ($cols[0] eq q{do-backs}) {
+ } elsif ($cmd eq q{do-backs}) {
$doBacks = 1;
return;
- } elsif (/^\s*#/) {
+ } elsif ($cmd =~ /^#/) {
return;
- } elsif (/^\s*[|]/) {
- $_ = $head . substr $_, 1 + (index $_, q{|});
- } elsif (/^\s*<<(.*)\[([^[]+)\]/) {
+ } elsif ($cmd =~ /^[|]/) {
+ $_ = $head . substr $cmd, 1 + (index $cmd, q{|});
+ } elsif ($cmd =~ /^<<(.*)\[([^[]+)\]$/) {
my $indentOrig = $indent;
$indent .= "${head}$1";
open my $fh, q{<:encoding(UTF-8)}, $2 or croak "$!";
$indent = $indentOrig;
return;
} else {
- croak "unknown $cols[0] command: $page\n";
+ croak "unknown \"$cmd\" command: $page\n";
}
} else {
$_ = htmlescape $_;