[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: add @latex to t4h and some customization
From: |
Patrice Dumas |
Subject: |
branch master updated: add @latex to t4h and some customization |
Date: |
Sat, 15 Oct 2022 08:16:33 -0400 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 44f9893b24 add @latex to t4h and some customization
44f9893b24 is described below
commit 44f9893b2453e1941ab1c9d10576e976ab2f029f
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Oct 15 14:16:13 2022 +0200
add @latex to t4h and some customization
* doc/texinfo.texi (@command{tex4ht} Customization Variables),
tp/Texinfo/Common.pm (@variable_string_settables), tp/ext/tex4ht.pm
(tex4ht_prepare): add T4H_MATH_CONVERSION, T4H_TEX_CONVERSION and
T4H_LATEX_CONVERSION as customization variables to select which
type of conversion to use for math commands, @tex and @latex.
* tp/ext/tex4ht.pm (tex4ht_prepare): if CONVERT_TO_LATEX_IN_MATH
is set, and conversion type is latex, convert input tree element
content to LaTeX instead of Texinfo.
---
ChangeLog | 14 +++++++++
doc/texinfo.texi | 29 ++++++++++++++++++
tp/Texinfo/Common.pm | 3 ++
tp/ext/tex4ht.pm | 86 +++++++++++++++++++++++++++++++++++++---------------
4 files changed, 108 insertions(+), 24 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2cd37bac18..eb18e40417 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2022-10-15 Patrice Dumas <pertusus@free.fr>
+
+ add @latex to t4h and some customization
+
+ * doc/texinfo.texi (@command{tex4ht} Customization Variables),
+ tp/Texinfo/Common.pm (@variable_string_settables), tp/ext/tex4ht.pm
+ (tex4ht_prepare): add T4H_MATH_CONVERSION, T4H_TEX_CONVERSION and
+ T4H_LATEX_CONVERSION as customization variables to select which
+ type of conversion to use for math commands, @tex and @latex.
+
+ * tp/ext/tex4ht.pm (tex4ht_prepare): if CONVERT_TO_LATEX_IN_MATH
+ is set, and conversion type is latex, convert input tree element
+ content to LaTeX instead of Texinfo.
+
2022-10-14 Patrice Dumas <pertusus@free.fr>
Use explicit \mathit for slates @-commands in math
diff --git a/doc/texinfo.texi b/doc/texinfo.texi
index 3a977d7e19..5f01642e87 100644
--- a/doc/texinfo.texi
+++ b/doc/texinfo.texi
@@ -16659,7 +16659,36 @@ Set the directory used for temporary files. None of
the file name components
in this directory name may start with @samp{.}; otherwise, @command{latex2html}
will fail (because of @command{dvips}). The default is the empty string, which
means the current directory.
+@end vtable
+
+
+@node @command{tex4ht} Customization Variables
+@subsection @command{tex4ht} Customization Variables
+This table lists the customization variables which can be used when
+@command{tex4ht} is being used to convert @code{@@math}, @code{@@displaymath},
+@code{@@tex} and @code{@@latex} sections for HTML@. These customization
+variables are relevant only if @code{HTML_MATH} is set to @samp{t4h}.
+
+To actually convert @code{@@tex} sections, @option{--iftex} should be used,
+and to actually convert @code{@@latex} sections, @option{--iflatex} should be
+used.
+
+@vtable @code
+@item T4H_LATEX_CONVERSION
+If set, the conversion type used for @code{@@latex} sections. Possibilities
+are @samp{latex}, @samp{tex} and @samp{texi}. Set to @samp{latex} if not
+defined.
+
+@item T4H_MATH_CONVERSION
+If set, the conversion type used for @code{@@math} and @code{@@displymath}.
+Possibilities are @samp{latex}, @samp{tex} and @samp{texi}. Set to @samp{tex}
+if not defined.
+
+@item T4H_TEX_CONVERSION
+If set, the conversion type used for @code{@@tex} sections. Possibilities
+are @samp{latex}, @samp{tex} and @samp{texi}. Set to @samp{tex} if not
+defined.
@end vtable
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 49f67b6b76..72b897e695 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -400,6 +400,9 @@ my @variable_string_settables = (
'SHOW_TITLE',
'SIMPLE_MENU',
'SORT_ELEMENT_COUNT',
+'T4H_LATEX_CONVERSION',
+'T4H_MATH_CONVERSION',
+'T4H_TEX_CONVERSION',
'TEXI2HTML',
'TEXINFO_DTD_VERSION',
'TEXINFO_OUTPUT_FORMAT',
diff --git a/tp/ext/tex4ht.pm b/tp/ext/tex4ht.pm
index 0d82e466b3..772d9977e7 100644
--- a/tp/ext/tex4ht.pm
+++ b/tp/ext/tex4ht.pm
@@ -22,9 +22,9 @@
# Originally written by Patrice Dumas.
#
#-##############################################################################
-# To customize the command and the options, you could set
-# $Texinfo::TeX4HT::STYLE_MATH and $Texinfo::TeX4HT::STYLE_TEX to
tex/latex/texi
-# and/or change
+# To customize the command and the options, you can set the
+# T4H_MATH_CONVERSION, T4H_TEX_CONVERSION and T4H_LATEX_CONVERSION
+# customization variables and/or change
# $Texinfo::TeX4HT::tex4ht_command_tex
# and $Texinfo::TeX4HT::tex4ht_options_tex
# $Texinfo::TeX4HT::tex4ht_command_latex, $Texinfo::TeX4HT::tex4ht_command_texi
@@ -41,6 +41,8 @@ use Encode qw(encode);
# Also for __(
use Texinfo::Common;
use Texinfo::Convert::Texinfo;
+# to implement CONVERT_TO_LATEX_IN_MATH
+use Texinfo::Convert::LaTeX;
texinfo_register_handler('structure', \&tex4ht_prepare);
# could probably be done also in the 'structure' phase
@@ -56,8 +58,6 @@ texinfo_register_command_formatting('displaymath',
\&tex4ht_convert_command);
package Texinfo::TeX4HT;
use vars qw(
-$STYLE_MATH
-$STYLE_TEX
$tex4ht_command_tex
$tex4ht_command_latex
$tex4ht_command_texi
@@ -66,10 +66,6 @@ $tex4ht_options_latex
$tex4ht_options_texi
);
-$STYLE_MATH = 'tex' if (!defined($STYLE_MATH));
-$STYLE_TEX = 'tex' if (!defined($STYLE_TEX));
-
-
if (!defined($tex4ht_command_tex)) {
$tex4ht_command_tex = 'httex';
}
@@ -109,20 +105,6 @@ sub tex4ht_prepare($$)
return 0 if (defined($self->get_conf('OUTFILE'))
and $Texinfo::Common::null_device_file{$self->get_conf('OUTFILE')});
- $tex4ht_initial_dir = Cwd::abs_path;
- $tex4ht_out_dir = $self->get_info('destination_directory');
- $tex4ht_out_dir = File::Spec->curdir()
- if (!defined($tex4ht_out_dir) or $tex4ht_out_dir =~ /^\s*$/);
-
- my $document_name = $self->get_info('document_name');
- my $tex4ht_basename = "${document_name}_tex4ht";
-
- $commands{'math'} = {'style' => $Texinfo::TeX4HT::STYLE_MATH,
- 'results' => {}};
- $commands{'tex'} = {'style' => $Texinfo::TeX4HT::STYLE_TEX,
- 'results' => {}};
- $commands{'displaymath'} = {'style' => $Texinfo::TeX4HT::STYLE_TEX,
- 'results' => {}};
$formats{'tex'} = {'exec' => $Texinfo::TeX4HT::tex4ht_command_tex,
'commands' => [],
'results' => {}};
@@ -132,6 +114,51 @@ sub tex4ht_prepare($$)
$formats{'texi'} = {'exec' => $Texinfo::TeX4HT::tex4ht_command_texi,
'commands' => [],
'results' => {}};
+
+ my $math_conversion = $self->get_conf('T4H_MATH_CONVERSION');
+ if (defined($math_conversion) and !$formats{$math_conversion}) {
+ $self->document_error($self,
+ sprintf(__("tex4ht.pm: unknown converstion type for math: %s"),
+ $math_conversion));
+ $math_conversion = undef;
+ }
+ $math_conversion = 'tex' if (!defined($math_conversion));
+
+ my $tex_conversion = $self->get_conf('T4H_TEX_CONVERSION');
+ if (defined($tex_conversion) and !$formats{$tex_conversion}) {
+ $self->document_error($self,
+ sprintf(__("tex4ht.pm: unknown converstion type for \@tex: %s"),
+ $tex_conversion));
+ $tex_conversion = undef;
+ }
+ $tex_conversion = 'tex' if (!defined($tex_conversion));
+
+ my $latex_conversion = $self->get_conf('T4H_LATEX_CONVERSION');
+ if (defined($latex_conversion) and !$formats{$latex_conversion}) {
+ $self->document_error($self,
+ sprintf(__("tex4ht.pm: unknown converstion type for \@latex: %s"),
+ $latex_conversion));
+ $latex_conversion = undef;
+ }
+ $latex_conversion = 'latex' if (!defined($latex_conversion));
+
+ $commands{'displaymath'} = {'style' => $math_conversion,
+ 'results' => {}};
+ $commands{'math'} = {'style' => $math_conversion,
+ 'results' => {}};
+ $commands{'latex'} = {'style' => $latex_conversion,
+ 'results' => {}};
+ $commands{'tex'} = {'style' => $tex_conversion,
+ 'results' => {}};
+
+ $tex4ht_initial_dir = Cwd::abs_path;
+ $tex4ht_out_dir = $self->get_info('destination_directory');
+ $tex4ht_out_dir = File::Spec->curdir()
+ if (!defined($tex4ht_out_dir) or $tex4ht_out_dir =~ /^\s*$/);
+
+ my $document_name = $self->get_info('document_name');
+ my $tex4ht_basename = "${document_name}_tex4ht";
+
my @replaced_commands = sort(keys(%commands));
my $collected_commands = Texinfo::Common::collect_commands_list_in_tree(
$document_root, \@replaced_commands);
@@ -182,6 +209,7 @@ sub tex4ht_prepare($$)
my $comment = '@c';
$comment = '%' if ($format ne 'texi');
$comment .= " Automatically generated by the t4ht Texinfo HTML
extension\n";
+ my $options_latex_math;
if ($format eq 'texi') {
print $fh "\\input texinfo
\@setfilename $formats{$format}->{'basename'}.info\n";
@@ -189,6 +217,10 @@ sub tex4ht_prepare($$)
} else {
print $fh "$comment";
if ($format eq 'latex') {
+ if ($self->get_conf('CONVERT_TO_LATEX_IN_MATH')) {
+ $options_latex_math
+ =
{Texinfo::Convert::LaTeX::copy_options_for_convert_to_latex_math($self)};
+ }
print $fh "\\documentstyle{article}\n\\begin{document}\n";
} elsif ($format eq 'tex') {
print $fh "\\csname tex4ht\\endcsname\n";
@@ -213,7 +245,13 @@ sub tex4ht_prepare($$)
pop @{$tree->{'contents'}};
}
}
- my $text = Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
+ my $text;
+ if ($options_latex_math) {
+ $text = Texinfo::Convert::LaTeX::convert_to_latex_math(undef,
+ $tree, $options_latex_math);
+ } else {
+ $text = Texinfo::Convert::Texinfo::convert_to_texinfo($tree);
+ }
$formats{$format}->{'commands'}->[$counter-1] = $element;
# write to tex file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: add @latex to t4h and some customization,
Patrice Dumas <=