diff options
Diffstat (limited to 'mht')
-rwxr-xr-x | mht | 73 |
1 files changed, 27 insertions, 46 deletions
@@ -22,47 +22,33 @@ my $opel = ''; # currently opened block element # 1.2.1 Contiguous elements my %ctels = ( - Qp_0 => '<blockquote>{<p>%</p>}</blockquote>', + Qp => '<blockquote>{<p>%</p>}</blockquote>', ); # 1.2.2 Block elements my %blels = ( - Pp_0 => '<p>%</p>', - Pr_0 => '<pre>%</pre>', - Sh_0 => '<h3>%</h3>', - Sh_1 => '<h\\$1>%</h\\$1>', - Ti_0 => '<title>%</title>', + Hh => '<h\\$1>%</h\\$1>', + Pp => '<p>%</p>', + Pr => '<pre>%</pre>', + Sh => '<h3>%</h3>', + Ti => '<title>%</title>', ); # 1.2.3 Inline elements my %inels = ( - Au_1 => '<meta name="author" content="\\$1"/>', - Bd_1 => '<b>\\$1</b>', - Bd_2 => '<b>\\$1</b>\\$2', - Bd_3 => '\\$3<b>\\$1</b>\\$2', - br_0 => '<br/>', - Cd_1 => '<code>\\$1</code>', - Cd_2 => '<code>\\$1</code>\\$2', - Cd_3 => '\\$3<code>\\$1</code>\\$2', - Cs_1 => '<meta http-equiv="Content-Type" content="text/html; charset=\\$1"/>', - Da_0 => '<meta name="created" content="\\$1"/>', - Em_1 => '<em>\\$1</em>', - Em_2 => '<em>\\$1</em>\\$2', - Em_3 => '\\$3<em>\\$1</em>\\$2', - Hy_2 => '<a href="\\$2">\\$1</a>', - Im_2 => '<img src="\\$1" alt="\\$2"/>', - It_1 => '<i>\\$1</i>', - It_2 => '<i>\\$1</i>\\$2', - It_3 => '\\$3<i>\\$1</i>\\$2', - St_1 => '<strong>\\$1</strong>', - St_2 => '<strong>\\$1</strong>\\$2', - St_3 => '\\$3<strong>\\$1</strong>\\$2', - Tt_1 => '<tt>\\$1</tt>', - Tt_2 => '<tt>\\$1</tt>\\$2', - Tt_3 => '\\$3<tt>\\$1</tt>\\$2', - Ul_1 => '<u>\\$1</u>', - Ul_2 => '<u>\\$1</u>\\$2', - Ul_3 => '\\$3<u>\\$1</u>\\$2', + Au => '<meta name="author" content="\\$1"/>', + Bd => '\\$3<b>\\$1</b>\\$2', + br => '<br/>', + Cd => '\\$3<code>\\$1</code>\\$2', + Cs => '<meta http-equiv="Content-Type" content="text/html; charset=\\$1"/>', + Da => '<meta name="created" content="\\$1"/>', + Em => '\\$3<em>\\$1</em>\\$2', + Hy => '\\$4<a href="\\$2">\\$1</a>\\$3', + Im => '<img src="\\$1" alt="\\$2"/>', + It => '\\$3<i>\\$1</i>\\$2', + St => '\\$3<strong>\\$1</strong>\\$2', + Tt => '\\$3<tt>\\$1</tt>\\$2', + Ul => '\\$3<u>\\$1</u>\\$2', ); @@ -73,21 +59,20 @@ sub request { my ($el, $args) = @_; my @argv = quotewords('\s+', 0, $args); my $n = @argv; - my $elkey = "${el}_$n"; - if (exists $blels{$elkey} or exists $ctels{$elkey}) { + if (exists $blels{$el} or exists $ctels{$el}) { # Clear empty line buffer $empty = ''; # Close currently open block element, open new my ($base, $prestart, $newpostclose) = ('', '', ''); - if (exists $ctels{$elkey}) { - $base = $ctels{$elkey}; + if (exists $ctels{$el}) { + $base = $ctels{$el}; $prestart = prestart($base); $newpostclose = postclose($base); $base = inner($base); } else { - $base = $blels{$elkey}; + $base = $blels{$el}; } my $start = start($base); my $newclose = interpol(_close($base), @argv) . "\n"; @@ -102,8 +87,8 @@ sub request { print interpol($start, @argv) . "\n"; $opel = $el; - } elsif (exists $inels{$elkey}) { - print interpol($inels{$elkey}, @argv) . "\n"; + } elsif (exists $inels{$el}) { + print interpol($inels{$el}, @argv) . "\n"; } else { print STDERR "Error: $el/$n not implemented\n"; exit 1; @@ -113,12 +98,8 @@ sub request { # 1.3.2 Interpolate \$n parameters sub interpol { my $s = shift; - my $i = 1; - my $arg; - while ($arg = shift) { - $s =~ s/\\\$$i/$arg/g; - $i++; - } + no warnings qw/uninitialized/; + $s =~ s/\\\$(\d+)/$_[$1-1]/g; return $s; } |