Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d02573d

Browse files
committed
Handle \p and \op in parameter lists for the environment and macro
description environments.
1 parent 4050e00 commit d02573d

1 file changed

Lines changed: 25 additions & 10 deletions

File tree

Doc/perl/ltxmarkup.perl

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,37 @@ sub ltx_next_argument{
1515
sub do_cmd_macro{
1616
local($_) = @_;
1717
my $macro = ltx_next_argument();
18-
return "<tt class='macro'>&#92;$macro</tt>" . $_;
18+
return "<tt class=macro>&#92;$macro</tt>" . $_;
1919
}
2020

2121
sub do_cmd_env{
2222
local($_) = @_;
2323
my $env = ltx_next_argument();
24-
return "<tt class='environment'>&#92;$env</tt>" . $_;
24+
return "<tt class=environment>&#92;$env</tt>" . $_;
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;
2540
}
2641

2742
sub do_env_macrodesc{
2843
local($_) = @_;
2944
my $macro = ltx_next_argument();
30-
my $params = ltx_next_argument();
31-
return "\n<dl class='macrodesc'>"
32-
. "\n<dt><b><tt class='macro'>&#92;$macro</tt></b>"
33-
. "\n $params"
45+
my $params = ltx_process_params(ltx_next_argument());
46+
return "\n<dl class=macrodesc>"
47+
. "\n<dt><b><tt class=macro>&#92;$macro</tt></b>"
48+
. "\n $params"
3449
. "\n<dd>"
3550
. $_
3651
. "</dl>";
@@ -39,10 +54,10 @@ sub do_env_macrodesc{
3954
sub do_env_envdesc{
4055
local($_) = @_;
4156
my $env = ltx_next_argument();
42-
my $params = ltx_next_argument();
43-
return "\n<dl class='envdesc'>"
44-
. "\n<dt><b><tt class='environment'>&#92;$env</tt></b>"
45-
. "\n $params"
57+
my $params = ltx_process_params(ltx_next_argument());
58+
return "\n<dl class=envdesc>"
59+
. "\n<dt><b><tt class=environment>&#92;$env</tt></b>"
60+
. "\n $params"
4661
. "\n<dd>"
4762
. $_
4863
. "</dl>";

0 commit comments

Comments
 (0)