]*$id>\Q$del\E)([^$esc_del]*?)(\Q$del\E|$comment_mark(\d+)\n?)/
$contents=$2;
@@ -3226,7 +3249,7 @@
if ($style_names) { $envS = "$style_names" }
elsif (($envS =~ /^pre$/)&&
- (/^\\begin.*preform($O|$OP)\d+($C|$CP)$verbatim_mark(\w*[vV]erbatim|lstlisting)(\*?)/))
+ (/^\\begin.*preform($O|$OP)\d+($C|$CP)$verbatim_mark(\w*[vV]erbatim|lstlisting|minted)(\*?)/))
{ $envS = $3.($4 ? 'star' : '') };
$env_style{$envS} = " " unless (($style_names)||($env_style{$envS}));
$env_id = " ID=\"$env_id\"".(($envS) ? " CLASS=\"$envS\"" : '');
@@ -7643,7 +7666,7 @@
print STYLESHEET "SPAN.$env\t\t{ $style }\n";
} elsif ($env =~ /\./) {
print STYLESHEET "$env\t\t{ $style }\n";
- } elsif ($env =~ /^(preform|lstlisting|\w*[Vv]erbatim(star)?)$/) {
+ } elsif ($env =~ /^(preform|lstlisting|minted|\w*[Vv]erbatim(star)?)$/) {
print STYLESHEET "PRE.$env\t\t{ $style }\n";
} elsif ($env =~ /figure|table|tabular|equation|$array_env_rx/) {
print STYLESHEET "TABLE.$env\t\t{ $style }\n";
@@ -8159,7 +8182,7 @@
if (defined &replace_verbatim_hook) {&replace_verbatim_hook;}
else {&replace_verbatim_marks if /$verbatim_mark/;}
if (defined &replace_verb_hook) {&replace_verb_hook;}
- else {&replace_verb_marks if /$verb_mark|$verbstar_mark|$verblst_mark/;}
+ else {&replace_verb_marks if /$verb_mark|$verbstar_mark|$verblst_mark|$verbmint_mark|$verbminted_mark/;}
s/;SPMdollar;/\$/g; s/;SPMtilde;/\~/g; s/;SPMpct;/\%/g;
s/;SPM/\&/go;
s/$percent_mark/%/go;
@@ -9071,6 +9094,8 @@
# "\n".$tmp.(($tmp =~/\n\s*$/s)? '':"\n")!eg;
s/(]*>)?$verbatim_mark(lstlisting|lstset|lststyle|lstfile)(\d+)#(<\/PRE>)?\n?/
&process_lstlisting($1, $4, $2, $verbatim{$3})/eg;
+ s/(]*>)?$verbatim_mark(minted|setminted|setmintedinline|usemintedstyle|mintfile)(\d+)#(<\/PRE>)?\n?/
+ &process_minted($1, $4, $2, $verbatim{$3})/eg;
# s/$verbatim_mark(rawhtml)(\d+)#/$verbatim{$2}/eg; # Raw HTML
s/$verbatim_mark(imagesonly)(\d+)#//eg; # imagesonly is *not* replaced
# Raw HTML, but replacements may have protected characters
@@ -9080,6 +9105,7 @@
}
# Actual lstlisting engine, except initialization, moved to styles/listings.perl
+# Actual minted engine, except initialization, moved to styles/minted.perl
# TeX's special characters may have been escaped with a '\'; remove it.
sub unprotect_raw_html {
@@ -9102,17 +9128,22 @@
s/$verbatim_mark(\w*[Vv]erbatim\w*\*?)(\d+)#//go;
s/$verbatim_mark(rawhtml|imagesonly)(\d+)#//go;
s/$verbatim_mark(lstlisting)(\d+)#//go;
+ s/$verbatim_mark(minted)(\d+)#//go;
s/$verbatim_mark$keepcomments_rx(\d+)#//go;
s/$unfinished_mark$keepcomments_rx(\d+)#//go;
}
sub replace_verb_marks {
# Modifies $_
- s/($verb_mark|$verbstar_mark|$verblst_mark)(\d+)$verb_mark/
+ s/($verb_mark|$verbstar_mark|$verblst_mark|$verbmint_mark|$verbminted_mark)(\d+)$verb_mark/
$code = $verb{$2};
$code = &replace_comments($code) if ($code =~ m:$comment_mark:);
if ($1 eq $verblst_mark)
{$code=&process_lstinline($verb_lstopt{$2},$code);}
+ elsif ($1 eq $verbmint_mark)
+ {$code=&process_mintinline($verb_mintopt{$2},$verb_mintlang{$2},$code);}
+ elsif ($1 eq $verbminted_mark)
+ {$code=&process_mint($verb_mintopt{$2},$verb_mintlang{$2},$code);}
else {$code="$code<\/code>";}
$code/eg;
}
@@ -9126,7 +9157,7 @@
sub remove_verb_marks {
# Modifies $_
- s/($verb_mark|$verbstar_mark|$verblst_mark)(\d+)$verb_mark//go;
+ s/($verb_mark|$verbstar_mark|$verblst_mark|$verbmint_mark|$verbminted_mark)(\d+)$verb_mark//go;
}
# This is used by revert_to_raw_tex
@@ -9135,6 +9166,7 @@
# s/$verbatim_mark(verbatim)(\d+)#/\\begin{verbatim}$verbatim{$2}\\end{verbatim}\n/go;
s/$verbatim_mark(\w*[Vv]erbatim)(\d+)#/\\begin{$1}\n$verbatim{$2}\\end{$1}\n/go;
s/$verbatim_mark(lstlisting)(\d+)#/\\begin{lstlisting}\n$verbatim{$2}\\end{lstlisting}\n/go;
+ s/$verbatim_mark(minted)(\d+)#/\\begin{minted}\n$verbatim{$2}\\end{minted}\n/go;
s/$verbatim_mark(rawhtml)(\d+)#/\\begin{rawhtml}\n$verbatim{$2}\\end{rawhtml}\n/go;
s/$verbatim_mark(imagesonly|tex2html_code)(\d+)#\n?/$verbatim{$2}/go;
s/$verbatim_mark$image_env_rx(\d+)#/\\begin{$1}\n$verbatim{$2}\\end{$1}\n/go;
@@ -9146,6 +9178,8 @@
s/$verbstar_mark(\d+)$verb_mark/\\verb*$verb_delim{$1}$verb{$1}$verb_delim{$1}/go;
s/$verb_mark(\d+)$verb_mark/\\verb$verb_delim{$1}$verb{$1}$verb_delim{$1}/go;
s/$verblst_mark(\d+)$verb_mark/\\lstinline$verb_lstopt{$1}$verb_delim{$1}$verb{$1}$verb_delim{$1}/go;
+ s/$verbmint_mark(\d+)$verb_mark/\\mintinline$verb_mintopt{$1}$verb_mintlang{$1}$verb_delim{$1}$verb{$1}$verb_delim{$1}/go;
+ s/$verbminted_mark(\d+)$verb_mark/\\mint$verb_mintopt{$1}$verb_mintlang{$1}$verb_delim{$1}$verb{$1}$verb_delim{$1}/go;
}
sub replace_cross_ref_marks {
@@ -10258,7 +10292,7 @@
local($pre_bit);
if ($lastbit =~/>([^>]*)$/) {
$word = $1; $pre_bit = $`.'>';
- if ($pre_bit =~ /($verb_mark|$verbstar_mark|$verblst_mark)$/) {
+ if ($pre_bit =~ /($verb_mark|$verbstar_mark|$verblst_mark|$verbmint_mark|$verbminted_mark)$/) {
$word = $lastbit;
} elsif ($pre_bit =~ /<\w+_mark>$/) {
$word = $& . $word;
@@ -16305,6 +16339,8 @@
$verb_mark = '';
$verbstar_mark = '';
$verblst_mark = '';
+ $verbmint_mark = '';
+ $verbminted_mark = '';
$image_mark = '';
$mydb_mark = '';
$percent_mark = '';
@@ -16750,7 +16786,23 @@
'framesep' => '3pt',
'framerule' => '0.4pt',
'backgroundcolor' => '',
- 'rulecolor' => '' );
+ 'rulecolor' => '',
+ 'language' => '' );
+ # Languages having different names in lstlisting and source-highlight
+ %lstset_langs = (
+ 'assembler' => 'asm',
+ 'c++' => 'cpp',
+ 'command.com' => 'bat',
+ 'elisp' => 'el',
+ 'make' => 'makefile' );
+ # Languages having different names in lstlisting and pygmentize
+ %lstset_pylangs = (
+ 'ant' => 'antlr',
+ 'assembler' => 'asm',
+ 'c++' => 'cpp',
+ 'caml' => 'ocaml',
+ 'command.com' => 'bat',
+ 'modula-2' => 'modula2' );
# Option sets defined by lstdefinestyle
%lstset_style = ();
# Placeholder for \lstname
@@ -16759,6 +16811,38 @@
$lst_last_counter = 1;
%lst_auto_counter = ();
+ # Initializations block for verbatim-like minted environment
+ # Actual minted engine moved to styles/minted.perl
+ # Currently default option values for minted environment
+ %minted_current = (
+ 'linenos' => 'false',
+ 'numbers' => 'none',
+ 'stepnumber' => 1,
+ 'numberfirstline' => 'false',
+ 'numbersep' => '12pt',
+ 'firstnumber' => 'auto',
+ 'style' => '',
+ 'frame' => 'none',
+ 'framesep' => '3pt',
+ 'framerule' => '0.4pt',
+ 'bgcolor' => '',
+ 'rulecolor' => '' );
+ # Language specific option values for minted environment
+ %minted_lex = ();
+ # Currently default option values for mintinline environment
+ %mintinline_current = ();
+ # Language specific option values for mintinline environment
+ %mintinline_lex = ();
+ # Languages having different names in minted and source-highlight
+ %mint_langs = (
+ 'elisp' => 'el',
+ 'make' => 'makefile',
+ 'ocaml' => 'caml',
+ 'text' => 'txt' );
+ # Languages in minted and pygmentize share the same names
+ # For line counters
+ $mint_last_counter = 1;
+
# Inclusion in this list will cause a command or an environment to be ignored.
# This is suitable for commands without arguments and for environments.
@@ -17392,7 +17476,7 @@
# Matches environments that should not be touched during the translation
# $verbatim_env_rx = "\\s*{(verbatim|rawhtml|LVerbatim)[*]?}";
- $verbatim_env_rx = "\\s*(\\w*[Vv]erbatim|lstlisting|rawhtml|imagesonly|tex2html_code)[*]?";
+ $verbatim_env_rx = "\\s*(\\w*[Vv]erbatim|lstlisting|minted|rawhtml|imagesonly|tex2html_code)[*]?";
$image_env_rx = "\\s*(picture|xy|diagram)[*]?";
$keepcomments_rx = "\\s*(picture|makeimage|xy|diagram)[*]?";
@@ -17709,6 +17793,8 @@
S<[ B<->(B)B ]>
S<[ B<->(B)B ]>
S<[ B<->(B)B ]>
+S<[ B<->(B)B ]>
+S<[ B<-hilite_opts> I ]>
S<[ B<->(B)B ]>
S<[ B<-init_file> I ]>
S<[ B<-up_url> I ]>
@@ -18096,6 +18182,19 @@
Generate intermediate images with dvilualatex instead of plain latex.
Produced DVI output will then be translated into images with dvips or dvipng.
+=item B<->(B)B
+
+Additional support for the listings and minted packages: generate colorized
+syntax highlighting of lstlisting/minted environments and lstinline/mintinline
+snippets via the external pygmentize or source-highlight tool. For this option
+to work, either Pygments or GNU source-highlight package must be installed.
+
+=item B<-hilite_opts> I
+
+Additional options to pygmentize or GNU source-highlight. See the appropriate
+manpage for the list of possible options, and the console output for the actual
+source highlighting command lines generated by latex2html.
+
=item B<->(B)B
MISSING_DESCRIPTION
diff -Naur latex2html-2024.orig/prefs.pm latex2html-2024/prefs.pm
--- latex2html-2024.orig/prefs.pm 2024-01-01 22:13:03.000000000 +0700
+++ latex2html-2024/prefs.pm 2024-08-22 13:22:27.793033258 +0700
@@ -383,6 +383,9 @@
# the giftrans executable needed for making GIFs transparent
$prefs{'GIFTRANS'} = 'giftrans';
+# either pygmentize or source-highlight executable needed for colorized listings
+$prefs{'SRCHILITE'} = 'pygmentize,source-highlight,pygmentize3,pygmentize2';
+
# to speed things up, pstoimg issues piped commands. This may fail on
# some systems. On unsafe systems, this is automatically set to 0.
# Say 1 for pipe usage and 0 for no pipes.
diff -Naur latex2html-2024.orig/styles/listings.perl latex2html-2024/styles/listings.perl
--- latex2html-2024.orig/styles/listings.perl 2024-01-01 22:13:03.000000000 +0700
+++ latex2html-2024/styles/listings.perl 2024-08-22 11:55:53.711776147 +0700
@@ -24,6 +24,8 @@
# of the LaTeX2HTML main program:
#
# %lstset_current
+# %lstset_langs
+# %lstset_pylangs
# %lstset_style
# $lst_name
# $lst_last_counter
@@ -47,7 +49,7 @@
$outer = $_;
local($closures,$reopens) = &preserve_open_tags;
- my ($verb_pre, $verb_post) = ('','
');
+ my ($verb_pre,$verb_post) = ('','
');
if ($USING_STYLES) {
$env_id .= ' CLASS="verbatim"' unless ($env_id =~ /(^|\s)CLASS\s*\=/i);
$verb_pre =~ s/>/ $env_id>/;
@@ -56,7 +58,7 @@
# %verbatim not coupled to a dbm => will not work in subprocesses, but don't mind
$verbatim{++$global{'verbatim_counter'}} = $option.$file;
- # Do nothing here, just wrap into a verbatim-like lstlisting environment.
+ # Do nothing here, just wrap into a verbatim-like lstfile environment.
# File reading and decorating postponed to &process_lstlisting.
join('', $closures, $verb_pre
, $verbatim_mark, 'lstfile', $global{'verbatim_counter'}
@@ -323,42 +325,131 @@
$rulecolor = $_;
$rulecolor = " BORDERCOLOR=\"$rulecolor\"" unless ($rulecolor eq '');
+ # Evtl use Pygments or GNU source-highlight to produce colorized output
+ my($lst_lang,$lst_lnum) = ('','');
+ if ($USE_HILITE) {
+ unless ($SRCHILITE ne '' && -x $SRCHILITE) {
+ if ($SRCHILITE ne '') {
+ print "\n\n$SRCHILITE cannot be executed\n";
+ &write_warnings("\n$SRCHILITE cannot be executed");
+ } else {
+ print "\n\npygmentize or source-highlight executable not available\n";
+ &write_warnings("\npygmentize or source-highlight executable not available");
+ }
+ print "Generating listings via builtin engine\n\n";
+ &write_warnings("Generating listings via builtin engine");
+ $USE_HILITE = 0;
+ }
+ }
+ if ($USE_HILITE) {
+ unless (open (HILITE, ">.$dd${PREFIX}hilite.in")) {
+ print "\n\nCannot create pygmentize or source-highlight input file: $!\n";
+ print "Generating listings via builtin engine\n\n";
+ &write_warnings("\nCannot create pygmentize or source-highlight input file: $!");
+ &write_warnings("Generating listings via builtin engine");
+ $USE_HILITE = 0;
+ }
+ }
+ if ($USE_HILITE) {
+ $lst_pre =~ s/]*>//;# highlighting engine inserts by itself
+ $lst_post =~ s/<\/PRE>//;
+ $_ = $curopts{'language'};
+ s/$O\d+$C//go; # Get rid of bracket id's
+ s/$OP\d+$CP//go; # Get rid of processed bracket id's
+ ($option,$dum) = &get_verb_optional_argument;
+ s/\s+//; # Remove white space and make lowercase
+ $_ = "\L$_";
+ $option =~ s/\s+//;
+ $option = "\L$option";
+ # evtl language rewriting
+ if ($_ eq 'c') {
+ if ($option eq 'sharp') {
+ $_ = 'csharp';
+ } elsif ($option eq 'objective') {
+ $_ = 'objc';
+ }
+ } elsif ($_ eq 'java') {
+ if ($option eq 'aspectj') {
+ $_ = 'aspectj';
+ }
+ } elsif ($_ eq '') {
+ if ($SRCHILITE =~ /pygmentize/) {
+ $_ = 'text';
+ } else {
+ $_ = 'txt';
+ }
+ } else {
+ if ($SRCHILITE =~ /pygmentize/) {
+ $_ = $lstset_pylangs{$_} if exists ($lstset_pylangs{$_});
+ } else {
+ $_ = $lstset_langs{$_} if exists ($lstset_langs{$_});
+ }
+ }
+ $lst_lang = $_;
+ if ($curopts{'numbers'} eq 'left')
+ {
+ if ($SRCHILITE =~ /pygmentize/) {
+ $lst_lnum = ",linenos=table";
+ } else {
+ $lst_lnum = "--line-number=' '";
+ }
+ }
+ }
+
$lst_pre = $bstyle_open.$lst_pre."\n";
$lst_post = "\n".$lst_post.$bstyle_close;
$_ = $contents;
- # Evtl generate line numbers
- if ($curopts{'numbers'} eq 'left') {
- # Insert numbers from the left side.
- $counter = $fcount-$incr;
- s/^/$i++; $counter+=$incr;
- (($counter % $step) && ($curopts{'numberfirstline'} ne 'true' || $i > 1)) ?
+ if ($USE_HILITE) {
+ # Pygments and source-highlight can generate line numbers by themselves
+ s/^\n//; # remove leading vertical space
+ $_ = &revert_to_raw_tex ($_);
+ print HILITE $_;
+ close (HILITE);
+ if ($SRCHILITE =~ /pygmentize/) {
+ print "\n\nRunning $SRCHILITE $HILITE_OPTS -l $lst_lang -f html -O noclasses,nobackground$lst_lnum .$dd${PREFIX}hilite.in\n\n";
+ $_ = `$SRCHILITE $HILITE_OPTS -l $lst_lang -f html -O noclasses,nobackground$lst_lnum .$dd${PREFIX}hilite.in`;
+ s///; # clear extra style
+ } else {
+ print "\n\nRunning $SRCHILITE $HILITE_OPTS --failsafe $lst_lnum -s $lst_lang -i .$dd${PREFIX}hilite.in\n\n";
+ $_ = `$SRCHILITE $HILITE_OPTS --failsafe $lst_lnum -s $lst_lang -i .$dd${PREFIX}hilite.in`;
+ }
+ unlink (".$dd${PREFIX}hilite.in");
+ s/\n$//; # remove trailing vertical space
+ } else {
+ # Evtl generate line numbers by builtin engine
+ if ($curopts{'numbers'} eq 'left') {
+ # Insert numbers from the left side.
+ $counter = $fcount-$incr;
+ s/^/$i++; $counter+=$incr;
+ (($counter % $step) &&
+ ($curopts{'numberfirstline'} ne 'true' || $i > 1)) ?
(' ' . ' ' x $nspaces) :
(sprintf("%5d",$counter) . ' ' x $nspaces)/mge;
- $lst_last_counter = $counter+$incr;
- $lst_auto_counter{$lst_name} = $lst_last_counter
- if ($curopts{'firstnumber'} eq 'auto' && $lst_name ne '');
- }
- elsif ($curopts{'numbers'} eq 'right' && $HTML_VERSION > 2.1) {
- # Inserting right padded numbers for every line is tricky.
- # Do it as a table with two huge columns with verbatim contents.
- # But only if HTML version is high enough...
- s/$/$nlines++;''/mge;
- for ($counter=$fcount; $i<$nlines; $i++) {
- $cline .= (($counter % $step) &&
- ($curopts{'numberfirstline'} ne 'true' || $i > 0)) ?
- (' ' x $nspaces . " \n") :
- (' ' x $nspaces . sprintf("%d\n",$counter));
- $counter += $incr;
- }
- $lst_last_counter = $counter;
- $lst_auto_counter{$lst_name} = $lst_last_counter
- if ($curopts{'firstnumber'} eq 'auto' && $lst_name ne '');
- $cline =~ s/\n$//;
- $_ = "
"
- .$lst_pre.$_.$lst_post." | "
- .$lst_pre.$cline.$lst_post." |
";
- $lst_pre = $lst_post = '';
+ $lst_last_counter = $counter+$incr;
+ $lst_auto_counter{$lst_name} = $lst_last_counter
+ if $curopts{'firstnumber'} eq 'auto' && $lst_name ne '';
+ } elsif ($curopts{'numbers'} eq 'right' && $HTML_VERSION > 2.1) {
+ # Inserting right padded numbers for every line is tricky.
+ # Do it as a table with two huge columns with verbatim contents.
+ # But only if HTML version is high enough...
+ s/$/$nlines++;''/mge;
+ for ($counter=$fcount; $i<$nlines; $i++) {
+ $cline .= (($counter % $step) &&
+ ($curopts{'numberfirstline'} ne 'true' || $i > 0)) ?
+ (' ' x $nspaces . " \n") :
+ (' ' x $nspaces . sprintf("%d\n",$counter));
+ $counter += $incr;
+ }
+ $lst_last_counter = $counter;
+ $lst_auto_counter{$lst_name} = $lst_last_counter
+ if $curopts{'firstnumber'} eq 'auto' && $lst_name ne '';
+ $cline =~ s/\n$//;
+ $_ = ""
+ .$lst_pre.$_.$lst_post." | "
+ .$lst_pre.$cline.$lst_post." |
";
+ $lst_pre = $lst_post = '';
+ }
}
# Frames, captions and coloring are generated also as a synthetic table
@@ -409,6 +500,83 @@
$bstyle_open = $bstyle_close = ''
unless (s/^\s*((<\w+[^>]*>\s*)+)[^<]*((<\/\w+>\s*)+)$/$bstyle_open=$1;$bstyle_close=$3;''/eo);
+ # Evtl use Pygments or GNU source-highlight to produce colorized output
+ my($lst_lang) = '';
+ if ($USE_HILITE) {
+ unless ($SRCHILITE ne '' && -x $SRCHILITE) {
+ if ($SRCHILITE ne '') {
+ print "\n\n$SRCHILITE cannot be executed\n";
+ &write_warnings("\n$SRCHILITE cannot be executed");
+ } else {
+ print "\n\npygmentize or source-highlight executable not available\n";
+ &write_warnings("\npygmentize or source-highlight executable not available");
+ }
+ print "Generating listings via builtin engine\n\n";
+ &write_warnings("Generating listings via builtin engine");
+ $USE_HILITE = 0;
+ }
+ }
+ if ($USE_HILITE) {
+ unless (open (HILITE, ">.$dd${PREFIX}hilite.in")) {
+ print "\n\nCannot create pygmentize or source-highlight input file: $!\n";
+ print "Generating listings via builtin engine\n\n";
+ &write_warnings("\nCannot create pygmentize or source-highlight input file: $!");
+ &write_warnings("Generating listings via builtin engine");
+ $USE_HILITE = 0;
+ }
+ }
+ if ($USE_HILITE) {
+ $_ = $curopts{'language'};
+ s/$O\d+$C//go; # Get rid of bracket id's
+ s/$OP\d+$CP//go; # Get rid of processed bracket id's
+ ($option,$dum) = &get_verb_optional_argument;
+ s/\s+//; # Remove white space and make lowercase
+ $_ = "\L$_";
+ $option =~ s/\s+//;
+ $option = "\L$option";
+ # evtl language rewriting
+ if ($_ eq 'c') {
+ if ($option eq 'sharp') {
+ $_ = 'csharp';
+ } elsif ($option eq 'objective') {
+ $_ = 'objc';
+ }
+ } elsif ($_ eq 'java') {
+ if ($option eq 'aspectj') {
+ $_ = 'aspectj';
+ }
+ } elsif ($_ eq '') {
+ if ($SRCHILITE =~ /pygmentize/) {
+ $_ = 'text';
+ } else {
+ $_ = 'txt';
+ }
+ } else {
+ if ($SRCHILITE =~ /pygmentize/) {
+ $_ = $lstset_pylangs{$_} if exists ($lstset_pylangs{$_});
+ } else {
+ $_ = $lstset_langs{$_} if exists ($lstset_langs{$_});
+ }
+ }
+ $lst_lang = $_;
+ $contents =~ s/^\n//; # remove leading vertical space
+ $contents = &revert_to_raw_tex ($contents);
+ print HILITE $contents;
+ close (HILITE);
+ if ($SRCHILITE =~ /pygmentize/) {
+ print "\n\nRunning $SRCHILITE $HILITE_OPTS -l $lst_lang -f html -O noclasses,nobackground .$dd${PREFIX}hilite.in\n\n";
+ $contents = `$SRCHILITE $HILITE_OPTS -l $lst_lang -f html -O noclasses,nobackground .$dd${PREFIX}hilite.in`;
+ $contents =~ s///;
+ } else {
+ print "\n\nRunning $SRCHILITE $HILITE_OPTS --failsafe -s $lst_lang -i .$dd${PREFIX}hilite.in\n\n";
+ $contents = `$SRCHILITE $HILITE_OPTS --failsafe -s $lst_lang -i .$dd${PREFIX}hilite.in`;
+ }
+ unlink (".$dd${PREFIX}hilite.in");
+ $contents =~ s/^.*?//s; # remove obstructive starting stuff
+ $contents =~ s/<\/pre>.*?$//s; # remove obstructive trailing stuff
+ $contents =~ s/\n$//; # remove trailing vertical space
+ }
+
# Make the actual lstinline output
$bstyle_open.''.$contents.'
'.$bstyle_close;
}
diff -Naur latex2html-2024.orig/styles/minted.perl latex2html-2024/styles/minted.perl
--- latex2html-2024.orig/styles/minted.perl 1970-01-01 07:00:00.000000000 +0700
+++ latex2html-2024/styles/minted.perl 2024-08-22 11:56:57.482531443 +0700
@@ -0,0 +1,787 @@
+# -*- perl -*-
+#
+# $Id: $
+#
+# minted.perl
+# Georgy Salnikov 24/08/20
+#
+# Extension to LaTeX2HTML V2024 to partly support the "minted" package.
+#
+# Partly derived from listings.perl
+#
+# Change Log:
+# ===========
+#
+# $Log: $
+#
+# Note:
+# This module provides translation for the \minted environment
+# and for some more commands of the minted.sty package
+#
+# Handling decisions are done together with verbatim by LaTeX2HTML main program
+#
+# Several global variables and arrays are defined in the initialization block
+# of the LaTeX2HTML main program:
+#
+# %minted_current
+# %minted_lex
+# %mintinline_current
+# %mintinline_lex
+# %mint_langs
+# $mint_last_counter
+#
+
+package main;
+
+# This package very probably may be used in minted
+&do_require_package("color");
+
+# Implementation of \inputminted[]{}{}, preparation only
+sub do_cmd_inputminted {
+ local($_) = @_;
+ local($outer,$lexer,$file);
+
+ local($dum,$option) = &get_verb_optional_argument;
+ $lexer = &missing_braces unless (
+ (s/$next_pair_pr_rx/$lexer=$2;''/eo)
+ ||(s/$next_pair_rx/$lexer=$2;''/eo));
+ $lexer = "\L$lexer";
+ $file = &missing_braces unless (
+ (s/$next_pair_pr_rx/$file=$2;''/eo)
+ ||(s/$next_pair_rx/$file=$2;''/eo));
+ $outer = $_;
+
+ local($closures,$reopens) = &preserve_open_tags;
+ my ($verb_pre,$verb_post) = ('','
');
+ if ($USING_STYLES) {
+ $env_id .= ' CLASS="verbatim"' unless ($env_id =~ /(^|\s)CLASS\s*\=/i);
+ $verb_pre =~ s/>/ $env_id>/;
+ }
+
+ # %verbatim not coupled to a dbm => will not work in subprocesses, but don't mind
+ $verbatim{++$global{'verbatim_counter'}} = $option.'{'.$lexer.'}'.$file;
+
+ # Do nothing here, just wrap into a verbatim-like minted environment.
+ # File reading and decorating postponed to &process_minted.
+ join('', $closures, $verb_pre
+ , $verbatim_mark, 'mintfile', $global{'verbatim_counter'}
+ , '#', $verb_post, $reopens, $outer);
+}
+
+# Implementation of \setminted[]{}, preparation only
+sub do_cmd_setminted {
+ local($_) = @_;
+ local($dum,$lexer) = &get_verb_optional_argument;
+ $lexer = "\L$lexer";
+ local($option) = &missing_braces unless (
+ (s/$next_pair_pr_rx/$option=$2;''/eo)
+ ||(s/$next_pair_rx/$option=$2;''/eo));
+ local($outer) = $_;
+
+ # In preamble this just initializes the defaults
+ if ($PREAMBLE) {
+ $dum = "\L$dum";
+ my(%opts) = &lst_parse_options($option);
+ if ($dum eq '') {
+ @minted_current{keys %opts} = (values %opts);
+ } else {
+ @{$minted_lex{$dum}}{keys %opts} = (values %opts);
+ }
+ return $outer;
+ }
+
+ # Do nothing here, just wrap into a verbatim-like setminted environment.
+ # Processing options will be done later by &process_minted.
+ local($closures,$reopens) = &preserve_open_tags;
+ $verbatim{++$global{'verbatim_counter'}} = $lexer.$option;
+ join('', $closures, $verbatim_mark, 'setminted', $global{'verbatim_counter'},
+ '#', $reopens, $outer);
+}
+
+# Implementation of \setmintedinline[]{}, preparation only
+sub do_cmd_setmintedinline {
+ local($_) = @_;
+ local($dum,$lexer) = &get_verb_optional_argument;
+ $lexer = "\L$lexer";
+ local($option) = &missing_braces unless (
+ (s/$next_pair_pr_rx/$option=$2;''/eo)
+ ||(s/$next_pair_rx/$option=$2;''/eo));
+ local($outer) = $_;
+
+ # In preamble this just initializes the defaults
+ if ($PREAMBLE) {
+ $dum = "\L$dum";
+ my(%opts) = &lst_parse_options($option);
+ if ($dum eq '') {
+ @mintinline_current{keys %opts} = (values %opts);
+ } else {
+ @{$mintinline_lex{$dum}}{keys %opts} = (values %opts);
+ }
+ return $outer;
+ }
+
+ # Do nothing here, just wrap into a verbatim-like setmintedinline environment.
+ # Processing options will be done later by &process_minted.
+ local($closures,$reopens) = &preserve_open_tags;
+ $verbatim{++$global{'verbatim_counter'}} = $lexer.$option;
+ join('', $closures, $verbatim_mark, 'setmintedinline',
+ $global{'verbatim_counter'}, '#', $reopens, $outer);
+}
+
+# Implementation of \usemintedstyle[]{}, preparation only
+sub do_cmd_usemintedstyle {
+ local($_) = @_;
+ local($dum,$lexer) = &get_verb_optional_argument;
+ $lexer = "\L$lexer";
+ local($style) = &missing_braces unless (
+ (s/$next_pair_pr_rx/$style=$2;''/eo)
+ ||(s/$next_pair_rx/$style=$2;''/eo));
+ local($outer) = $_;
+
+ # In preamble this just initializes the defaults
+ if ($PREAMBLE) {
+ $dum = "\L$dum";
+ if ($dum eq '') {
+ $minted_current{'style'} = $style;
+ } else {
+ $minted_lex{$dum}{'style'} = $style;
+ }
+ return $outer;
+ }
+
+ # Do nothing here, just wrap into a verbatim-like setminted environment.
+ # Processing options will be done later by &process_minted.
+ local($closures,$reopens) = &preserve_open_tags;
+ $verbatim{++$global{'verbatim_counter'}} = $lexer.$style;
+ join('', $closures, $verbatim_mark, 'usemintedstyle',
+ $global{'verbatim_counter'}, '#', $reopens, $outer);
+}
+
+# This is the main driver subroutine for the minted environment
+sub process_minted {
+ local($lst_pre, $lst_post, $lst_cmd, $_) = @_;
+
+ # Check if it was an auxiliary command wrapped into an environment
+ if ($lst_cmd eq 'setminted') { return &set_setminted($_); }
+ if ($lst_cmd eq 'setmintedinline') { return &set_setmintedinline($_); }
+ if ($lst_cmd eq 'usemintedstyle') { return &set_usemintedstyle($_); }
+
+ # Process an actual minted environment
+ local($option,$dum) = &get_verb_optional_argument;
+ local($lexer) = &missing_braces unless (
+ (s/$next_pair_pr_rx/$lexer=$2;''/eo)
+ ||(s/$next_pair_rx/$lexer=$2;''/eo)
+ ||(s/$verb_braces_rx/$lexer=$1;''/eo));
+ $lexer = "\L$lexer";
+ local($contents) = $_;
+
+ # Fetch current defaults and apply specified options...
+ my(%curopts) = %minted_current;
+ my(%opts) = &lst_parse_options($option);
+
+ # First of all, apply language specific options if any
+ @curopts{keys %{$minted_lex{$lexer}}} = (values %{$minted_lex{$lexer}});
+
+ # Now apply all the other specified options
+ @curopts{keys %opts} = (values %opts);
+
+ # For wrapped inputminted - replace file name with file contents
+ if ($lst_cmd eq 'mintfile') {
+ my($dir);
+ my($file) = $contents;
+ my($file2) = "$file.tex";
+ if ($file !~ /\.tex$/) {
+ # 2nd choice is better than 1st - TeXnical quirk
+ ($file,$file2) = ($file2,$file);
+ }
+ my($found) = 0;
+ foreach $dir ("$texfilepath", split(/:/,$ENV{'TEXINPUTS'})) {
+ if (-f ($_ = "$dir/$file") || -f ($_ = "$dir/$file2")) {
+ $found = 1;
+ # overread $_ with file contents
+ &slurp_input($_);
+ last;
+ }
+ }
+ &write_warnings("No file <$file> for inputminted.") unless $found;
+ # pre_process file contents
+ if (defined &replace_all_html_special_chars) {
+ &replace_all_html_special_chars;
+ } else {
+ &replace_html_special_chars;
+ }
+ s/\n$//; # vertical space is contributed by
already.
+ $contents = $_;
+ }
+
+ # Interpret the rest of options in sequence...
+ # Line numbering (linenos,numbers,stepnumber,numberfirstline,numbersep,firstnumber)
+ my($i, $counter, $cline, $nlines);
+ $cline = '';
+ $i = $counter = $nlines = 0;
+ my($step) = sprintf("%.0f", $curopts{'stepnumber'});
+ my($incr) = $step<=>0;
+ $curopts{'linenos'} = 'true' if ($curopts{'numbers'} ne 'none');
+ $curopts{'numbers'} = 'none' if ($curopts{'linenos'} ne 'true' || !$incr);
+ $curopts{'numbers'} = 'left' if ($curopts{'linenos'} eq 'true' &&
+ $curopts{'numbers'} eq 'none' && $incr);
+ my($nspaces);
+ ($nspaces, $dum) = &convert_length ($curopts{'numbersep'}, 1);
+ $nspaces = sprintf("%.0f", $nspaces/10);
+ my($fcount) = $curopts{'firstnumber'};
+ if ($fcount eq 'auto') {
+ $fcount = 1;
+ } elsif ($fcount eq 'last') {
+ $fcount = $mint_last_counter;
+ } else {
+ $fcount = sprintf("%.0f", $fcount);
+ }
+
+ # Framing options group (frame, framesep, framerule)
+ my($frame) = 'VOID';
+ $frame = 'LHS' if ($curopts{'frame'} eq 'leftline');
+ $frame = 'ABOVE' if ($curopts{'frame'} eq 'topline');
+ $frame = 'BELOW' if ($curopts{'frame'} eq 'bottomline');
+ $frame = 'HSIDES' if ($curopts{'frame'} eq 'lines');
+ $frame = 'BORDER' if ($curopts{'frame'} eq 'single');
+ my($framesep);
+ ($framesep, $dum) = &convert_length ($curopts{'framesep'}, 1);
+ $framesep = sprintf("%.0f", $framesep);
+ my($framerule);
+ ($framerule, $dum) = &convert_length ($curopts{'framerule'}, 1);
+ $framerule = sprintf("%.0f", $framerule);
+ if ($framerule == 1) { # Special case specifying a very thin border
+ $framerule = '';
+ } else {
+ $framerule = " BORDER=\"$framerule\"";
+ }
+
+ # Coloring options group (bgcolor, rulecolor)
+ my($bgcolor) = $curopts{'bgcolor'};
+ $bgcolor = " BGCOLOR=\"$bgcolor\"" unless ($bgcolor eq '');
+ my($rulecolor);
+ $_ = $curopts{'rulecolor'};
+ if (/^\s*\\/) {
+ # Translate as a command and extract color value from the HTML tag
+ &lst_translate_option;
+ s/$O\d+$C//go; # Get rid of bracket id's
+ s/$OP\d+$CP//go; # Get rid of processed bracket id's
+ # Extract color value or clear the malformed contents
+ $_ = ''
+ unless (s/^\s*\s*<\/FONT>\s*$//);
+ }
+ $rulecolor = $_;
+ $rulecolor = " BORDERCOLOR=\"$rulecolor\"" unless ($rulecolor eq '');
+
+ # Evtl use Pygments or GNU source-highlight to produce colorized output
+ my($lst_lnum,$mint_style) = ('','');
+ if ($USE_HILITE) {
+ unless ($SRCHILITE ne '' && -x $SRCHILITE) {
+ if ($SRCHILITE ne '') {
+ print "\n\n$SRCHILITE cannot be executed\n";
+ &write_warnings("\n$SRCHILITE cannot be executed");
+ } else {
+ print "\n\npygmentize or source-highlight executable not available\n";
+ &write_warnings("\npygmentize or source-highlight executable not available");
+ }
+ print "Generating listings via builtin engine\n\n";
+ &write_warnings("Generating listings via builtin engine");
+ $USE_HILITE = 0;
+ }
+ }
+ if ($USE_HILITE) {
+ unless (open (HILITE, ">.$dd${PREFIX}hilite.in")) {
+ print "\n\nCannot create pygmentize or source-highlight input file: $!\n";
+ print "Generating listings via builtin engine\n\n";
+ &write_warnings("\nCannot create pygmentize or source-highlight input file: $!");
+ &write_warnings("Generating listings via builtin engine");
+ $USE_HILITE = 0;
+ }
+ }
+ if ($USE_HILITE) {
+ $lst_pre =~ s/]*>//;# highlighting engine inserts by itself
+ $lst_post =~ s/<\/PRE>//;
+ # evtl language rewriting (for source-highlight only)
+ $lexer = 'text' if $lexer eq '';
+ unless ($SRCHILITE =~ /pygmentize/) {
+ $lexer = $mint_langs{$lexer} if exists ($mint_langs{$lexer});
+ }
+ if ($curopts{'numbers'} eq 'left')
+ {
+ if ($SRCHILITE =~ /pygmentize/) {
+ $lst_lnum = ",linenos=table";
+ } else {
+ $lst_lnum = "--line-number=' '";
+ }
+ }
+ $mint_style = ",style=$curopts{'style'}" if $curopts{'style'} ne '';
+ }
+
+ $_ = $contents;
+
+ if ($USE_HILITE) {
+ # Pygments and source-highlight can generate line numbers by themselves
+ s/^\n//; # remove leading vertical space
+ $_ = &revert_to_raw_tex ($_);
+ print HILITE $_;
+ close (HILITE);
+ if ($SRCHILITE =~ /pygmentize/) {
+ print "\n\nRunning $SRCHILITE $HILITE_OPTS -l $lexer -f html -O noclasses,nobackground$mint_style$lst_lnum .$dd${PREFIX}hilite.in\n\n";
+ $_ = `$SRCHILITE $HILITE_OPTS -l $lexer -f html -O noclasses,nobackground$mint_style$lst_lnum .$dd${PREFIX}hilite.in`;
+ s///; # clear extra style
+ } else {
+ print "\n\nRunning $SRCHILITE $HILITE_OPTS --failsafe $lst_lnum -s $lexer -i .$dd${PREFIX}hilite.in\n\n";
+ $_ = `$SRCHILITE $HILITE_OPTS --failsafe $lst_lnum -s $lexer -i .$dd${PREFIX}hilite.in`;
+ }
+ unlink (".$dd${PREFIX}hilite.in");
+ s/\n$//; # remove trailing vertical space
+ } else {
+ # Evtl generate line numbers by builtin engine
+ if ($curopts{'numbers'} eq 'left') {
+ # Insert numbers from the left side.
+ $counter = $fcount-$incr;
+ s/^/$i++; $counter+=$incr;
+ (($counter % $step) &&
+ ($curopts{'numberfirstline'} ne 'true' || $i > 1)) ?
+ (' ' . ' ' x $nspaces) :
+ (sprintf("%5d",$counter) . ' ' x $nspaces)/mge;
+ $mint_last_counter = $counter+$incr;
+ } elsif ($curopts{'numbers'} eq 'right' && $HTML_VERSION > 2.1) {
+ # Inserting right padded numbers for every line is tricky.
+ # Do it as a table with two huge columns with verbatim contents.
+ # But only if HTML version is high enough...
+ s/$/$nlines++;''/mge;
+ for ($counter=$fcount; $i<$nlines; $i++) {
+ $cline .= (($counter % $step) &&
+ ($curopts{'numberfirstline'} ne 'true' || $i > 0)) ?
+ (' ' x $nspaces . " \n") :
+ (' ' x $nspaces . sprintf("%d\n",$counter));
+ $counter += $incr;
+ }
+ $mint_last_counter = $counter;
+ $cline =~ s/\n$//;
+ $_ = "
"
+ .$lst_pre.$_.$lst_post." | "
+ .$lst_pre.$cline.$lst_post." |
";
+ $lst_pre = $lst_post = '';
+ }
+ }
+
+ # Frames and coloring are generated also as a synthetic table
+ if ($HTML_VERSION > 2.1) {
+ $lst_pre = ""
+ ."\n".$lst_pre;
+ $lst_post = $lst_post."\n |
";
+ }
+
+ # WHEW !!!
+ $lst_pre.$_.$lst_post."\n";
+}
+
+# Driver subroutine for the real processing of \mint command
+sub process_mint {
+ local($_, $lexer, $contents) = @_;
+ local($lst_pre, $lst_post) = ('', '
');
+
+ # Process an actual mint command
+ local($option,$dum) = &get_verb_optional_argument;
+ $_ = $lexer;
+ $lexer = &missing_braces unless (
+ (s/$next_pair_pr_rx/$lexer=$2;''/eo)
+ ||(s/$next_pair_rx/$lexer=$2;''/eo)
+ ||(s/$verb_braces_rx/$lexer=$1;''/eo));
+ $lexer = "\L$lexer";
+
+ # Fetch current defaults and apply specified options...
+ my(%curopts) = %minted_current;
+ my(%opts) = &lst_parse_options($option);
+
+ # First of all, apply language specific options if any
+ @curopts{keys %{$minted_lex{$lexer}}} = (values %{$minted_lex{$lexer}});
+
+ # Now apply all the other specified options
+ @curopts{keys %opts} = (values %opts);
+
+ # Interpret the rest of options in sequence...
+ # Line numbering (linenos,numbers,stepnumber,numberfirstline,numbersep,firstnumber)
+ my($i, $counter, $cline, $nlines);
+ $cline = '';
+ $i = $counter = $nlines = 0;
+ my($step) = sprintf("%.0f", $curopts{'stepnumber'});
+ my($incr) = $step<=>0;
+ $curopts{'linenos'} = 'true' if ($curopts{'numbers'} ne 'none');
+ $curopts{'numbers'} = 'none' if ($curopts{'linenos'} ne 'true' || !$incr);
+ $curopts{'numbers'} = 'left' if ($curopts{'linenos'} eq 'true' &&
+ $curopts{'numbers'} eq 'none' && $incr);
+ my($nspaces);
+ ($nspaces, $dum) = &convert_length ($curopts{'numbersep'}, 1);
+ $nspaces = sprintf("%.0f", $nspaces/10);
+ my($fcount) = $curopts{'firstnumber'};
+ if ($fcount eq 'auto') {
+ $fcount = 1;
+ } elsif ($fcount eq 'last') {
+ $fcount = $mint_last_counter;
+ } else {
+ $fcount = sprintf("%.0f", $fcount);
+ }
+
+ # Framing options group (frame, framesep, framerule)
+ my($frame) = 'VOID';
+ $frame = 'LHS' if ($curopts{'frame'} eq 'leftline');
+ $frame = 'ABOVE' if ($curopts{'frame'} eq 'topline');
+ $frame = 'BELOW' if ($curopts{'frame'} eq 'bottomline');
+ $frame = 'HSIDES' if ($curopts{'frame'} eq 'lines');
+ $frame = 'BORDER' if ($curopts{'frame'} eq 'single');
+ my($framesep);
+ ($framesep, $dum) = &convert_length ($curopts{'framesep'}, 1);
+ $framesep = sprintf("%.0f", $framesep);
+ my($framerule);
+ ($framerule, $dum) = &convert_length ($curopts{'framerule'}, 1);
+ $framerule = sprintf("%.0f", $framerule);
+ if ($framerule == 1) { # Special case specifying a very thin border
+ $framerule = '';
+ } else {
+ $framerule = " BORDER=\"$framerule\"";
+ }
+
+ # Coloring options group (bgcolor, rulecolor)
+ my($bgcolor) = $curopts{'bgcolor'};
+ $bgcolor = " BGCOLOR=\"$bgcolor\"" unless ($bgcolor eq '');
+ my($rulecolor);
+ $_ = $curopts{'rulecolor'};
+ if (/^\s*\\/) {
+ # Translate as a command and extract color value from the HTML tag
+ &lst_translate_option;
+ s/$O\d+$C//go; # Get rid of bracket id's
+ s/$OP\d+$CP//go; # Get rid of processed bracket id's
+ # Extract color value or clear the malformed contents
+ $_ = ''
+ unless (s/^\s*\s*<\/FONT>\s*$//);
+ }
+ $rulecolor = $_;
+ $rulecolor = " BORDERCOLOR=\"$rulecolor\"" unless ($rulecolor eq '');
+
+ # Evtl use Pygments or GNU source-highlight to produce colorized output
+ my($lst_lnum,$mint_style) = ('','');
+ if ($USE_HILITE) {
+ unless ($SRCHILITE ne '' && -x $SRCHILITE) {
+ if ($SRCHILITE ne '') {
+ print "\n\n$SRCHILITE cannot be executed\n";
+ &write_warnings("\n$SRCHILITE cannot be executed");
+ } else {
+ print "\n\npygmentize or source-highlight executable not available\n";
+ &write_warnings("\npygmentize or source-highlight executable not available");
+ }
+ print "Generating listings via builtin engine\n\n";
+ &write_warnings("Generating listings via builtin engine");
+ $USE_HILITE = 0;
+ }
+ }
+ if ($USE_HILITE) {
+ unless (open (HILITE, ">.$dd${PREFIX}hilite.in")) {
+ print "\n\nCannot create pygmentize or source-highlight input file: $!\n";
+ print "Generating listings via builtin engine\n\n";
+ &write_warnings("\nCannot create pygmentize or source-highlight input file: $!");
+ &write_warnings("Generating listings via builtin engine");
+ $USE_HILITE = 0;
+ }
+ }
+ if ($USE_HILITE) {
+ $lst_pre =~ s/]*>//;# highlighting engine inserts by itself
+ $lst_post =~ s/<\/PRE>//;
+ # evtl language rewriting (for source-highlight only)
+ $lexer = 'text' if $lexer eq '';
+ unless ($SRCHILITE =~ /pygmentize/) {
+ $lexer = $mint_langs{$lexer} if exists ($mint_langs{$lexer});
+ }
+ if ($curopts{'numbers'} eq 'left')
+ {
+ if ($SRCHILITE =~ /pygmentize/) {
+ $lst_lnum = ",linenos=table";
+ } else {
+ $lst_lnum = "--line-number=' '";
+ }
+ }
+ $mint_style = ",style=$curopts{'style'}" if $curopts{'style'} ne '';
+ }
+
+ $_ = $contents;
+
+ if ($USE_HILITE) {
+ # Pygments and source-highlight can generate line numbers by themselves
+ s/^\n//; # remove leading vertical space
+ $_ = &revert_to_raw_tex ($_);
+ print HILITE $_;
+ close (HILITE);
+ if ($SRCHILITE =~ /pygmentize/) {
+ print "\n\nRunning $SRCHILITE $HILITE_OPTS -l $lexer -f html -O noclasses,nobackground$mint_style$lst_lnum .$dd${PREFIX}hilite.in\n\n";
+ $_ = `$SRCHILITE $HILITE_OPTS -l $lexer -f html -O noclasses,nobackground$mint_style$lst_lnum .$dd${PREFIX}hilite.in`;
+ s///; # clear extra style
+ } else {
+ print "\n\nRunning $SRCHILITE $HILITE_OPTS --failsafe $lst_lnum -s $lexer -i .$dd${PREFIX}hilite.in\n\n";
+ $_ = `$SRCHILITE $HILITE_OPTS --failsafe $lst_lnum -s $lexer -i .$dd${PREFIX}hilite.in`;
+ }
+ unlink (".$dd${PREFIX}hilite.in");
+ s/\n$//; # remove trailing vertical space
+ } else {
+ # Evtl generate line numbers by builtin engine
+ if ($curopts{'numbers'} eq 'left') {
+ # Insert numbers from the left side.
+ $counter = $fcount-$incr;
+ s/^/$i++; $counter+=$incr;
+ (($counter % $step) &&
+ ($curopts{'numberfirstline'} ne 'true' || $i > 1)) ?
+ (' ' . ' ' x $nspaces) :
+ (sprintf("%5d",$counter) . ' ' x $nspaces)/mge;
+ $mint_last_counter = $counter+$incr;
+ } elsif ($curopts{'numbers'} eq 'right' && $HTML_VERSION > 2.1) {
+ # Inserting right padded numbers for every line is tricky.
+ # Do it as a table with two huge columns with verbatim contents.
+ # But only if HTML version is high enough...
+ s/$/$nlines++;''/mge;
+ for ($counter=$fcount; $i<$nlines; $i++) {
+ $cline .= (($counter % $step) &&
+ ($curopts{'numberfirstline'} ne 'true' || $i > 0)) ?
+ (' ' x $nspaces . " \n") :
+ (' ' x $nspaces . sprintf("%d\n",$counter));
+ $counter += $incr;
+ }
+ $mint_last_counter = $counter;
+ $cline =~ s/\n$//;
+ $_ = "
"
+ .$lst_pre.$_.$lst_post." | "
+ .$lst_pre.$cline.$lst_post." |
";
+ $lst_pre = $lst_post = '';
+ }
+ }
+
+ # Frames and coloring are generated also as a synthetic table
+ if ($HTML_VERSION > 2.1) {
+ $lst_pre = ""
+ ."\n".$lst_pre;
+ $lst_post = $lst_post."\n |
";
+ }
+
+ # WHEW !!!
+ $lst_pre.$_.$lst_post."\n";
+}
+
+# Driver subroutine for the real processing of \mintinline command
+sub process_mintinline {
+ local($_, $lexer, $contents) = @_;
+
+ # Get mintinline options
+ local($option,$dum) = &get_verb_optional_argument;
+ $_ = $lexer;
+ $lexer = &missing_braces unless (
+ (s/$next_pair_pr_rx/$lexer=$2;''/eo)
+ ||(s/$next_pair_rx/$lexer=$2;''/eo)
+ ||(s/$verb_braces_rx/$lexer=$1;''/eo));
+ $lexer = "\L$lexer";
+
+ # Fetch current defaults and apply specified options...
+ my(%curopts) = %minted_current;
+ my(%opts) = &lst_parse_options($option);
+
+ # First of all, apply language specific options if any
+ @curopts{keys %{$minted_lex{$lexer}}} = (values %{$minted_lex{$lexer}});
+
+ # Now apply mintinline specific options if any
+ @curopts{keys %mintinline_current} = (values %mintinline_current);
+ @curopts{keys %{$mintinline_lex{$lexer}}} = (values %{$mintinline_lex{$lexer}});
+
+ # Now apply all the other specified options
+ @curopts{keys %opts} = (values %opts);
+
+ # Evtl use Pygments or GNU source-highlight to produce colorized output
+ my($mint_style) = '';
+ if ($USE_HILITE) {
+ unless ($SRCHILITE ne '' && -x $SRCHILITE) {
+ if ($SRCHILITE ne '') {
+ print "\n\n$SRCHILITE cannot be executed\n";
+ &write_warnings("\n$SRCHILITE cannot be executed");
+ } else {
+ print "\n\npygmentize or source-highlight executable not available\n";
+ &write_warnings("\npygmentize or source-highlight executable not available");
+ }
+ print "Generating listings via builtin engine\n\n";
+ &write_warnings("Generating listings via builtin engine");
+ $USE_HILITE = 0;
+ }
+ }
+ if ($USE_HILITE) {
+ unless (open (HILITE, ">.$dd${PREFIX}hilite.in")) {
+ print "\n\nCannot create pygmentize or source-highlight input file: $!\n";
+ print "Generating listings via builtin engine\n\n";
+ &write_warnings("\nCannot create pygmentize or source-highlight input file: $!");
+ &write_warnings("Generating listings via builtin engine");
+ $USE_HILITE = 0;
+ }
+ }
+ if ($USE_HILITE) {
+ # evtl language rewriting (for source-highlight only)
+ $lexer = 'text' if $lexer eq '';
+ unless ($SRCHILITE =~ /pygmentize/) {
+ $lexer = $mint_langs{$lexer} if exists ($mint_langs{$lexer});
+ }
+ # style seems the only option which can be really useful for mintinline
+ $mint_style = ",style=$curopts{'style'}" if $curopts{'style'} ne '';
+ # Pygments and source-highlight can generate line numbers by themselves
+ $contents =~ s/^\n//; # remove leading vertical space
+ $contents = &revert_to_raw_tex ($contents);
+ print HILITE $contents;
+ close (HILITE);
+ if ($SRCHILITE =~ /pygmentize/) {
+ print "\n\nRunning $SRCHILITE $HILITE_OPTS -l $lexer -f html -O noclasses,nobackground$mint_style .$dd${PREFIX}hilite.in\n\n";
+ $contents = `$SRCHILITE $HILITE_OPTS -l $lexer -f html -O noclasses,nobackground$mint_style .$dd${PREFIX}hilite.in`;
+ $contents =~ s///;
+ } else {
+ print "\n\nRunning $SRCHILITE $HILITE_OPTS --failsafe -s $lexer -i .$dd${PREFIX}hilite.in\n\n";
+ $contents = `$SRCHILITE $HILITE_OPTS --failsafe -s $lexer -i .$dd${PREFIX}hilite.in`;
+ }
+ unlink (".$dd${PREFIX}hilite.in");
+ $contents =~ s/^.*?//s; # remove obstructive starting stuff
+ $contents =~ s/<\/pre>.*?$//s; # remove obstructive trailing stuff
+ $contents =~ s/\n$//; # remove trailing vertical space
+ }
+
+ # Make the actual mintinline output
+ ''.$contents.'
';
+}
+
+# Driver subroutine for \setminted processing
+# Just copy the given set of options to the default options set
+sub set_setminted {
+ local($_) = @_;
+ local($lexer,$dum) = &get_verb_optional_argument;
+ $lexer = "\L$lexer";
+ my(%opts) = &lst_parse_options($_);
+ if ($lexer eq '') {
+ @minted_current{keys %opts} = (values %opts);
+ } else {
+ @{$minted_lex{$lexer}}{keys %opts} = (values %opts);
+ }
+ '';
+}
+
+# Driver subroutine for \setmintedinline processing
+# Just copy the given set of options to the default options set
+sub set_setmintedinline {
+ local($_) = @_;
+ local($lexer,$dum) = &get_verb_optional_argument;
+ $lexer = "\L$lexer";
+ my(%opts) = &lst_parse_options($_);
+ if ($lexer eq '') {
+ @mintinline_current{keys %opts} = (values %opts);
+ } else {
+ @{$mintinline_lex{$lexer}}{keys %opts} = (values %opts);
+ }
+ '';
+}
+
+# Driver subroutine for \usemintedstyle processing
+# Just copy the given style to the default options set
+sub set_usemintedstyle {
+ local($_) = @_;
+ local($lexer,$dum) = &get_verb_optional_argument;
+ $lexer = "\L$lexer";
+ local($style) = $_;
+ if ($lexer eq '') {
+ $minted_current{'style'} = $style;
+ } else {
+ $minted_lex{$lexer}{'style'} = $style;
+ }
+ '';
+}
+
+# Option parser for minted commands/envs family, this can be tricky
+sub lst_parse_options {
+ local($_) = @_;
+
+ # First get rid of comment marks
+ s/(\\\w+)$comment_mark\d*\s*?\n[ \t]*/$1 \n/go;
+ s/($comment_mark\d*\s*)+\n[ \t]*/\n/go;
+
+ # Find any kinds of brackets to keep them intact
+ # for the case if they might have commas inside
+ my(@fields, @chunks);
+ my($before, $match, $after);
+ while (/$any_next_pair_pr_rx|$any_next_pair_rx4|$opt_arg_rx|$verb_braces_rx/)
+ {
+ ($before, $match, $after) = ($`, $&, $');
+ @chunks = split(/,/, $before);
+ $fields[$#fields] .= shift(@chunks) if @fields;
+ push(@fields, @chunks);
+ $fields[$#fields] .= $match;
+ $_ = $after;
+ }
+ @chunks = split(/,/);
+ $fields[$#fields] .= shift(@chunks) if @fields;
+ push(@fields, @chunks);
+
+ # All options are separated, now split them to option name and value
+ my(%opts);
+ my($par, $val);
+ foreach (@fields) {
+ if (($par, $val) = /^\s*(\w+?)\s*=\s*(.*)\s*$/s) {
+ $opts{$par} = $val;
+ } elsif (($par) = /^\s*(\w+?)\s*$/s) { # boolean option
+ $opts{$par} = 'true';
+ }
+ }
+ %opts;
+}
+
+# Replace braces with marks and try to interpret this as a bracketed command
+sub lst_translate_option {
+ # Modifies $_
+ &mark_string($_);
+ my($br_id) = ++$global{'max_id'};
+ $_ = $O.$br_id.$C.$_.$O.$br_id.$C;
+ $_ = &translate_environments($_);
+ $_ = &translate_commands($_);
+}
+
+# &get_next_optional_argument is not well suited for minted
+# Here is a special version of &get_next_optional_argument
+sub get_verb_optional_argument {
+ local($next, $pat);
+ my($before, $match, $after);
+ $next = $pat = $match = '';
+ if (s/^(\[)/$pat=$1;''/eo) {
+ # Find any kinds of braces not to stuck on [] evtl nested between them
+ while (/$any_next_pair_pr_rx|$any_next_pair_rx4|$verb_braces_rx|\]/) {
+ ($before, $match, $after) = ($`, $&, $');
+ $next .= $before;
+ $pat .= $before;
+ if ($match eq ']') {
+ $pat .= $match;
+ $_ = $after;
+ # Before returning, remove comment mark and newline after closing ]
+ s/^[ \t]*($comment_mark\d*[ \t]*)*\n//o;
+ last;
+ }
+ $next .= $match;
+ $pat .= $match;
+ $_ = $after;
+ }
+ if ($match ne ']') {
+ # Closing ] not found, revert back $_ and clear arguments
+ $_ = $pat . $_;
+ $next = $pat = '';
+ }
+ }
+ # Imitate return of &get_next_optional_argument
+ ($next, $pat);
+}
+
+&process_commands_wrap_deferred (<<_RAW_ARG_DEFERRED_CMDS_);
+inputminted # [] # {} # {}
+setminted # [] # {}
+setmintedinline # [] # {}
+usemintedstyle # [] # {}
+_RAW_ARG_DEFERRED_CMDS_
+
+1; # Must be last line
diff -Naur latex2html-2024.orig/tests/minted.tex latex2html-2024/tests/minted.tex
--- latex2html-2024.orig/tests/minted.tex 1970-01-01 07:00:00.000000000 +0700
+++ latex2html-2024/tests/minted.tex 2024-08-22 13:33:41.371031509 +0700
@@ -0,0 +1,32 @@
+% Translation command example to produce listing with syntax highlighting:
+% latex2html -html_version 4.0 -use_pdftex -local_icons -use_hilite minted.tex
+\documentclass{article}
+\usepackage{minted}
+\begin{document}
+\begin{minted}[numbers=left,style=colorful,frame=single,rulecolor=red]{c}
+/************************************************************
+ * Convert 24-bit ASPECT integer into 32-bit native integer *
+ ************************************************************/
+int conv_integer (void *pntr)
+{
+ unsigned par;
+ INTEGER *par3000 = (INTEGER *)pntr;
+
+ par = par3000->l | (par3000->m<<8) | (par3000->h<<16);
+ if (par3000->h & 0x80) par |= 0xff000000; /* negative ? */
+ return (int)par;
+}
+\end{minted}
+Now inline test \mintinline[style=colorful]{c}$if (par3000->h & 0x80) par |= 0xff000000;$ here.
+\setminted{style=colorful,frame=single,rulecolor=red}
+\setminted[perl]{rulecolor=green}
+\usemintedstyle{default}
+\usemintedstyle[perl]{bw}
+\begin{minted}{c}
+printf ("Hello world !\n");
+\end{minted}
+\begin{minted}{perl}
+print "Hello world !\n";
+\end{minted}
+Now test \mint[numbers=left,frame=single,rulecolor=red]{c}$if (par3000->h & 0x80) par |= 0xff000000;$ here.
+\end{document}
diff -Naur latex2html-2024.orig/texexpand.pin latex2html-2024/texexpand.pin
--- latex2html-2024.orig/texexpand.pin 2024-01-01 22:13:03.000000000 +0700
+++ latex2html-2024/texexpand.pin 2024-08-22 09:33:08.050384343 +0700
@@ -14,8 +14,9 @@
# Recognizes \documentclass, \documentstyle, \usepackage, \RequirePackage,
# \begin{verbatim}...\end{verbatim}, \begin{lstlisting}...\end{lstlisting},
+# \begin{minted}...\end{minted},
# %begin{latexonly}...%end{latexonly}, \begin{latexonly}...\end{latexonly},
-# \input, \include, \verb, \lstinline, \latex
+# \input, \include, \verb, \lstinline, \mintinline, \mint, \latex
# \endinput, \end{document}
# \includecomment, \excludecomment
# \begin{"to exclude"}, \end{"to exclude"}
@@ -42,8 +43,9 @@
# d) %begin{any}
# e) \begin{verbatim}
# f) \begin{lstlisting}
-# g) \begin{latexonly}
-# h) %begin{latexonly}
+# g) \begin{minted}
+# h) \begin{latexonly}
+# i) %begin{latexonly}
#
# a)-d) cause texexpand to drop its contents, it will not show up in the
# output file. You can use this to 'comment out' a bunch of files, say.
@@ -68,17 +70,17 @@
# 3. [%\]begin{"to exclude"} and [%\]end{"to exclude"} have to be on a
# separate line.
# Anything between these tags (including the tags) is discarded.
-# 4. \begin{verbatim/verbatim*/lstlisting} and
-# \end{verbatim/verbatim*/lstlisting} have to be on a separate line.
+# 4. \begin{verbatim/verbatim*/lstlisting/minted} and
+# \end{verbatim/verbatim*/lstlisting/minted} have to be on a separate line.
# Anything between these tags (including the tags) is not expanded.
# 5. The scope of any such tags may extend over several files.
# The opening tag for latexonly may occur on a different include level
# than the closing tag.
-# The opening tag for verbatim/lstlisting/"to exclude" must occur
+# The opening tag for verbatim/lstlisting/minted/"to exclude" must occur
# within the same file than the closing tag.
# 6. Warnings are printed when the document has been parsed and open
# tags remain.
-# 7. When in a "to exclude"/verbatim/lstlisting environment, texexpand
+# 7. When in a "to exclude"/verbatim/lstlisting/minted environment, texexpand
# won't recognize ANY command except the corresponding closing tag.
# There cannot be any nested constructions.
# This behaviour is identical to that of LaTeX.
@@ -90,7 +92,8 @@
# 11. Everything behind a `%' that isn't preceded by a `\' is regarded as
# a comment, i.e. it is printed but not interpreted.
# 12. If any command listed in 10. is preceded by an occurrence of
-# `\verb', `\lstinline' or `\latex' then it is NOT interpreted.
+# `\verb', `\lstinline', `\mintinline', `\mint', `\latex'
+# then it is NOT interpreted.
# This crashes on lines like this:
# blah blah \verb+foo foo+ \input{bar} % bar won't be loaded!
# 13. Packages provided via \usepackage are handled the same way as
@@ -495,8 +498,8 @@
# Create generic regexp's:
# If this matches before a command, the command is ignored.
$ignore_cmd_rx =
-# '(\\latex\W|\\verb|\\lstinline|\\expandafter|\\ifx|\\else\W|[\|\[\@]$)';
- "(\\\\latex\\W|\\\\verb|\\\\lstinline|\\\\expandafter|\\\\ifx|\\\\else\\W|[\\|\\[\\@]\$)";
+# '(\\latex\W|\\verb|\\lstinline|\\mintinline|\\mint|\\expandafter|\\ifx|\\else\W|[\|\[\@]$)';
+ "(\\\\latex\\W|\\\\verb|\\\\lstinline|\\\\mintinline|\\\\mint|\\\\expandafter|\\\\ifx|\\\\else\\W|[\\|\\[\\@]\$)";
# This matches a square bracket pair (typically an option list).
$options_rx = '(\[[^\]]*\]|)';
# This matches a single argument.
@@ -537,7 +540,7 @@
sub main {
-# Note that verbatim/lstlisting/latexonly may split over different files!
+# Note that verbatim/lstlisting/minted/latexonly may split over different files!
# $verbatim is 1 if inside a verbatim environment,
# $latexonly is > 0 if inside latexonly environments
# $includelevel indicates the depth of include/input
@@ -602,17 +605,17 @@
# also would retain its body from LaTeX.
# => $active false, $mute true
# 3) interprete minimal and pass the lines to the out file
-# This is inside a verbatim, lstlisting or latexonly environment.
+# This is inside a verbatim, lstlisting, minted or latexonly environment.
# The line of course must be at least interpreted to
# determine the closing tag.
# => $active false, $mute false
#
# Any environment may extend over several include files.
-# Any environment except verbatim, lstlisting and latexonly may have its
+# Any environment except verbatim, lstlisting, minted and latexonly may have its
# opening or closing tag on different input levels.
-# The comment and verbatim/lstlisting environments cannot be nested, as
+# The comment and verbatim/lstlisting/minted environments cannot be nested, as
# is with LaTeX.
-# We must at least parse verbatim/lstlisting/comment environments in
+# We must at least parse verbatim/lstlisting/minted/comment environments in
# latexonly environments, to catch fake latexonly tags.
#
# The work scheme:
@@ -775,7 +778,7 @@
$mute=1 unless $latexonly;
}
# elsif (!$fakeenv && !$verbatim && /\\begin\s*\{\s*verbatim(\*)?\s*\}/) {
- elsif (!$fakeenv && !$verbatim && /\\begin\s*\{\s*((\w*[Vv]erbatim\w*|lstlisting)\*?)\s*\}/) {
+ elsif (!$fakeenv && !$verbatim && /\\begin\s*\{\s*((\w*[Vv]erbatim\w*|lstlisting|minted)\*?)\s*\}/) {
($before,$verbatimname) = ($`,$1);
($active,$verbatim) = (0,1)
unless ($before =~ /$ignore_cmd_rx/o);
@@ -847,7 +850,7 @@
}
}
# elsif ( /\\end\s*\{\s*verbatim(\*)?\s*\}/) {
- elsif ( /\\end\s*\{\s*((\w*[Vv]erbatim\w*|lstlisting)\*?)\s*\}/) {
+ elsif ( /\\end\s*\{\s*((\w*[Vv]erbatim\w*|lstlisting|minted)\*?)\s*\}/) {
if ($1 eq $verbatimname) {
$verbatim=0;
$active = ($latexonly ? 0 : 1);