Fred Drake | 03dffcc | 1999-03-18 16:42:28 +0000 | [diff] [blame] | 1 | # LaTeX2HTML support for the ltxmarkup package. Doesn't do indexing. |
| 2 | |
| 3 | package main; |
| 4 | |
| 5 | |
| 6 | sub ltx_next_argument{ |
| 7 | my $param; |
| 8 | $param = missing_braces() |
| 9 | unless ((s/$next_pair_pr_rx/$param=$2;''/eo) |
| 10 | ||(s/$next_pair_rx/$param=$2;''/eo)); |
| 11 | return $param; |
| 12 | } |
| 13 | |
| 14 | |
| 15 | sub do_cmd_macro{ |
| 16 | local($_) = @_; |
| 17 | my $macro = ltx_next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 18 | return "<tt class='macro'>\$macro</tt>" . $_; |
Fred Drake | 03dffcc | 1999-03-18 16:42:28 +0000 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | sub do_cmd_env{ |
| 22 | local($_) = @_; |
| 23 | my $env = ltx_next_argument(); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 24 | return "<tt class='environment'>\$env</tt>" . $_; |
Fred Drake | d02573d | 1999-04-28 16:33:04 +0000 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | sub ltx_process_params{ |
| 28 | # Handle processing of \p and \op for parameter specifications for |
| 29 | # envdesc and macrodesc. It's done this way to avoid defining do_cmd_p() |
| 30 | # and do_cmd_op() functions, which would be interpreted outside the context |
| 31 | # in which these commands are legal, and cause LaTeX2HTML to think they're |
| 32 | # defined. This way, other uses of \p and \op are properly flagged as |
| 33 | # unknown macros. |
| 34 | my $s = @_[0]; |
| 35 | $s =~ s%\\op<<(\d+)>>(.+)<<\1>>%<tt>[</tt><var>$2</var><tt>]</tt>%; |
| 36 | while ($s =~ /\\p<<(\d+)>>(.+)<<\1>>/) { |
| 37 | $s =~ s%\\p<<(\d+)>>(.+)<<\1>>%<tt>{</tt><var>$2</var><tt>}</tt>%; |
| 38 | } |
| 39 | return $s; |
Fred Drake | 03dffcc | 1999-03-18 16:42:28 +0000 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | sub do_env_macrodesc{ |
| 43 | local($_) = @_; |
| 44 | my $macro = ltx_next_argument(); |
Fred Drake | d02573d | 1999-04-28 16:33:04 +0000 | [diff] [blame] | 45 | my $params = ltx_process_params(ltx_next_argument()); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 46 | return "\n<dl class='macrodesc'>" |
| 47 | . "\n<dt><b><tt class='macro'>\$macro</tt></b>" |
Fred Drake | e0c1740 | 2003-08-05 03:48:29 +0000 | [diff] [blame] | 48 | . "\n $params</dt>" |
Fred Drake | 03dffcc | 1999-03-18 16:42:28 +0000 | [diff] [blame] | 49 | . "\n<dd>" |
| 50 | . $_ |
Fred Drake | e0c1740 | 2003-08-05 03:48:29 +0000 | [diff] [blame] | 51 | . '</dd></dl>'; |
Fred Drake | 03dffcc | 1999-03-18 16:42:28 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | sub do_env_envdesc{ |
| 55 | local($_) = @_; |
| 56 | my $env = ltx_next_argument(); |
Fred Drake | d02573d | 1999-04-28 16:33:04 +0000 | [diff] [blame] | 57 | my $params = ltx_process_params(ltx_next_argument()); |
Fred Drake | e15956b | 2000-04-03 04:51:13 +0000 | [diff] [blame] | 58 | return "\n<dl class='envdesc'>" |
| 59 | . "\n<dt><tt>\begin{<b class='environment'>$env</b>}</tt>" |
Fred Drake | ac3dc83 | 1999-04-28 16:42:29 +0000 | [diff] [blame] | 60 | . "\n $params" |
Fred Drake | e0c1740 | 2003-08-05 03:48:29 +0000 | [diff] [blame] | 61 | . "\n<br /><tt>\end{<b class='environment'>$env</b>}</tt></dt>" |
Fred Drake | 03dffcc | 1999-03-18 16:42:28 +0000 | [diff] [blame] | 62 | . "\n<dd>" |
| 63 | . $_ |
Fred Drake | e0c1740 | 2003-08-05 03:48:29 +0000 | [diff] [blame] | 64 | . '</dd></dl>'; |
Fred Drake | 03dffcc | 1999-03-18 16:42:28 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | 1; # Must end with this, because Perl is bogus. |