ltxmarkup.perl 1.88 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# LaTeX2HTML support for the ltxmarkup package.  Doesn't do indexing.

package main;


sub ltx_next_argument{
    my $param;
    $param = missing_braces()
      unless ((s/$next_pair_pr_rx/$param=$2;''/eo)
	      ||(s/$next_pair_rx/$param=$2;''/eo));
    return $param;
}


sub do_cmd_macro{
    local($_) = @_;
    my $macro = ltx_next_argument();
18
    return "<tt class='macro'>&#92;$macro</tt>" . $_;
19 20 21 22 23
}

sub do_cmd_env{
    local($_) = @_;
    my $env = ltx_next_argument();
24
    return "<tt class='environment'>&#92;$env</tt>" . $_;
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
}

sub ltx_process_params{
    # Handle processing of \p and \op for parameter specifications for
    # envdesc and macrodesc.  It's done this way to avoid defining do_cmd_p()
    # and do_cmd_op() functions, which would be interpreted outside the context
    # in which these commands are legal, and cause LaTeX2HTML to think they're
    # defined.  This way, other uses of \p and \op are properly flagged as
    # unknown macros.
    my $s = @_[0];
    $s =~ s%\\op<<(\d+)>>(.+)<<\1>>%<tt>[</tt><var>$2</var><tt>]</tt>%;
    while ($s =~ /\\p<<(\d+)>>(.+)<<\1>>/) {
	$s =~ s%\\p<<(\d+)>>(.+)<<\1>>%<tt>{</tt><var>$2</var><tt>}</tt>%;
    }
    return $s;
40 41 42 43 44
}

sub do_env_macrodesc{
    local($_) = @_;
    my $macro = ltx_next_argument();
45
    my $params = ltx_process_params(ltx_next_argument());
46 47
    return "\n<dl class='macrodesc'>"
         . "\n<dt><b><tt class='macro'>&#92;$macro</tt></b>"
48
         . "\n    $params"
49 50 51 52 53 54 55 56
	 . "\n<dd>"
	 . $_
	 . "</dl>";
}

sub do_env_envdesc{
    local($_) = @_;
    my $env = ltx_next_argument();
57
    my $params = ltx_process_params(ltx_next_argument());
58 59
    return "\n<dl class='envdesc'>"
         . "\n<dt><tt>&#92;begin{<b class='environment'>$env</b>}</tt>"
60
         . "\n    $params"
61
         . "\n<br /><tt>&#92;end{<b class='environment'>$env</b>}</tt>"
62 63 64 65 66 67
	 . "\n<dd>"
	 . $_
	 . "</dl>";
}

1;				# Must end with this, because Perl is bogus.