Creates <a href="URL">{optional text|URL}</a> link in HTML.
* img URL[ optional text]
Creates <img src="URL" [alt="optional text"] /> in HTML.
-* raw ...
- Just inserts ... line to HTML output as-is.
-* # ...
+* |...
+ Just inserts raw ... line to HTML output as-is.
+* #...
Does nothing, commented line.
* do-backs
Forcefully creates a table with all backlinks to the page.
-* include [page]
- Include contents of the specified page. Brackets here are
- for making a link to page.
+* <<[indent][page]
+ Include contents of the specified page. Brackets around
+ [page] are for making a link to page. indent is optional.
my $lines = 0;
my sub procline;
sub procline {
- if (/^include \[(.*)\]\r$/) {
+ if (/^<<.*\[(.*)\]\r$/) {
$found{$1} = 1;
open(my $fh, "<:encoding(UTF-8)", $1) or die "$!";
while (<$fh>) { $lines++; procline $_ }
}
print $out "\n</head>\n<body>\n<pre>";
}
+ my $indent = "";
my sub procline;
sub procline {
$_ = $_[0];
chop;
if (/\r$/) {
chop;
- s/^(\s*)//g;
+ /^(\s*)(.*)$/;
my $head = $1;
- my @cols = split /\s+/;
+ my @cols = split /\s+/, $2;
if ($cols[0] eq "=>") {
my $t = ($#cols > 1) ? (join " ", @cols[2..$#cols]) : $cols[1];
$t = htmlescape $t;
$t =~ s/"/\&guot;/g;
- $_ = "${head}=> <a href=\"$cols[1]\">$t</a>";
+ $_ = "$head=> <a href=\"$cols[1]\">$t</a>";
} elsif ($cols[0] eq "img") {
if ($#cols > 1) {
my $t = htmlescape join " ", @cols[2..$#cols];
$t =~ s/"/\&guot;/g;
- $_ = "<img src=\"$cols[1]\" alt=\"$t\" />";
+ $_ = "$head<img src=\"$cols[1]\" alt=\"$t\" />";
} else {
- $_ = "<img src=\"$cols[1]\" />";
+ $_ = "$head<img src=\"$cols[1]\" />";
}
} elsif ($cols[0] eq "do-backs") {
$doBacks = 1;
return;
- } elsif ($cols[0] eq "raw") {
- $_ = join " ", @cols[1..$#cols];
- } elsif ($cols[0] eq "#") {
+ } elsif (/^\s*#/) {
return;
- } elsif ($cols[0] eq "include") {
- open(my $fh, "<:encoding(UTF-8)", substr $cols[1], 1, -1) or die "$!";
+ } elsif (/^\s*\|/) {
+ $_ = $head . substr $_, 1 + (index $_, "|");
+ } elsif (/^\s*<<(.*)\[([^[]+)\]/) {
+ my $indentOrig = $indent;
+ $indent .= "${head}$1";
+ open(my $fh, "<:encoding(UTF-8)", $2) or die "$!";
while (<$fh>) { procline $_ }
close $fh;
+ $indent = $indentOrig;
return;
} else {
die "unknown $cols[0] command: $page\n";
}
}
}
- print $out "$_\n";
+ print $out "${indent}$_\n";
}
{
my $fh;