[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/convert/convert_html.c (html_open
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/convert/convert_html.c (html_open_command_update_context, convert_to_html_internal) tp/Texinfo/XS/main/call_perl_function.c (call_latex_convert_to_latex_math): add call_latex_convert_to_latex_math to call Texinfo::Convert::LaTeX::convert_to_latex_math from XS, and use it in convert_to_html_internal. |
Date: |
Sat, 18 Nov 2023 17:17:36 -0500 |
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 183ee40e75 * tp/Texinfo/XS/convert/convert_html.c
(html_open_command_update_context, convert_to_html_internal)
tp/Texinfo/XS/main/call_perl_function.c (call_latex_convert_to_latex_math): add
call_latex_convert_to_latex_math to call
Texinfo::Convert::LaTeX::convert_to_latex_math from XS, and use it in
convert_to_html_internal.
183ee40e75 is described below
commit 183ee40e7511f8b7cb882e729a67a7717909de60
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Nov 18 23:12:44 2023 +0100
* tp/Texinfo/XS/convert/convert_html.c
(html_open_command_update_context, convert_to_html_internal)
tp/Texinfo/XS/main/call_perl_function.c
(call_latex_convert_to_latex_math): add
call_latex_convert_to_latex_math to call
Texinfo::Convert::LaTeX::convert_to_latex_math from XS, and use it in
convert_to_html_internal.
* tp/t/html_tests.t: do not skip mathjax tests with XS.
---
ChangeLog | 12 ++++++
tp/TODO | 10 +++++
tp/Texinfo/Convert/HTML.pm | 5 ++-
tp/Texinfo/XS/convert/convert_html.c | 43 +++++++++++++------
tp/Texinfo/XS/main/call_perl_function.c | 74 +++++++++++++++++++++++++++++++++
tp/Texinfo/XS/main/call_perl_function.h | 5 +++
tp/t/html_tests.t | 7 ++--
7 files changed, 137 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fa4812dc71..6b748fd32c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -48,6 +48,18 @@
to read and does not match the current Perl code in
Texinfo/Translations.pm.
+2023-11-18 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/convert_html.c
+ (html_open_command_update_context, convert_to_html_internal)
+ tp/Texinfo/XS/main/call_perl_function.c
+ (call_latex_convert_to_latex_math): add
+ call_latex_convert_to_latex_math to call
+ Texinfo::Convert::LaTeX::convert_to_latex_math from XS, and use it in
+ convert_to_html_internal.
+
+ * tp/t/html_tests.t: do not skip mathjax tests with XS.
+
2023-11-18 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/HTML.pm (_open_command_update_context)
diff --git a/tp/TODO b/tp/TODO
index 6903b55795..a2b1049e17 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -26,6 +26,16 @@ Document that Texinfo::Document::rebuild_document or
Texinfo::Document::rebuild_tree should be called after tree modifications
if the parser is XS but converters are perl.
+Add a comment/TODO somewhere that explains that the need to maintain
+perl and C document contexts exactly in sync is probably a bug somewhere.
+Indeed, the change in perl document context should not need to be
+transmitted to C (through overriding of _new_document_context
+and _pop_document_context) as perl does not call any XS/C formatting
+function -- with the exception of translate_names -- and therefore the
+contexts should be back to where they were before perl was called. The code
+in C already registers what changed compared to last time perl was called,
+only applying that should be good.
+
the code in _parsed_manual_tree in Pod-Simple-Texinfo/pod2texi.pl
does not work perfectly with XS. See FIXME in the code. Tested in
./manual_tests/manual_sectioning_gap_test.sh
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index ca8f2dca41..d4fc249714 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -12338,10 +12338,11 @@ sub _convert($$;$)
}
my $content_formatted = '';
if ($element->{'contents'}) {
- if ($convert_to_latex) {
+ if ($convert_to_latex and !$brace_commands{$command_name}) {
+ # displaymath
$content_formatted
= Texinfo::Convert::LaTeX::convert_to_latex_math(undef,
- {'contents' => $element->{'contents'}},
+ {'contents' => $element->{'contents'}},
$self->{'options_latex_math'});
} else {
my $content_idx = 0;
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 0e67912897..1d836c9e37 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -39,6 +39,7 @@
#include "translations.h"
#include "convert_utils.h"
#include "convert_to_text.h"
+#include "call_perl_function.h"
#include "call_html_perl_function.h"
/* for TREE_AND_STRINGS */
#include "document.h"
@@ -3686,7 +3687,6 @@ html_open_command_update_context (CONVERTER *self, enum
command_id data_cmd)
if (html_commands_data[data_cmd].flags & HF_composition_context)
{
- /* FIXME or cmd? */
push_command_or_type (&top_document_ctx->composition_context,
data_cmd, 0);
push_integer_stack_integer (&top_document_ctx->preformatted_context,
@@ -3726,9 +3726,8 @@ html_open_command_update_context (CONVERTER *self, enum
command_id data_cmd)
{
top_document_ctx->math_ctx++;
self->modified_state |= HMSF_top_document_ctx;
- /*
- $convert_to_latex = 1 if ($self->get_conf('CONVERT_TO_LATEX_IN_MATH'));
- */
+ if (self->conf->CONVERT_TO_LATEX_IN_MATH > 0)
+ convert_to_latex = 1;
}
if (data_cmd == CM_verb)
{
@@ -4073,15 +4072,23 @@ convert_to_html_internal (CONVERTER *self, const
ELEMENT *element,
if (element->contents.number > 0)
{
- if (convert_to_latex)
+ if (convert_to_latex
+ && !(builtin_command_data[data_cmd].flags & CF_brace))
{
- /*
- $content_formatted
- = Texinfo::Convert::LaTeX::convert_to_latex_math(undef,
- {'contents' => $element->{'contents'}},
- $self->{'options_latex_math'});
+ ELEMENT *tmp = new_element (ET_NONE);
+ char *latex_content;
+
+ tmp->contents = element->contents;
+ latex_content = call_latex_convert_to_latex_math (self,
+ tmp);
+ tmp->contents.list = 0;
+ destroy_element (tmp);
- */
+ if (latex_content)
+ {
+ text_append (&content_formatted, latex_content);
+ free (latex_content);
+ }
}
else
{
@@ -4129,7 +4136,10 @@ convert_to_html_internal (CONVERTER *self, const ELEMENT
*element,
{
char *explanation;
unsigned long arg_flags = 0;
- const ELEMENT *arg = element->args.list[arg_idx];
+ /* actually const, but cannot be marked as such because
+ the argument of call_latex_convert_to_latex_math
+ cannot be const in case perl element has to be built
*/
+ ELEMENT *arg = element->args.list[arg_idx];
HTML_ARG_FORMATTED *arg_formatted
= &args_formatted->args[arg_idx];
@@ -4152,7 +4162,14 @@ convert_to_html_internal (CONVERTER *self, const ELEMENT
*element,
text_reset (&formatted_arg);
if (convert_to_latex)
{
- /* */
+ char *latex_content
+ = call_latex_convert_to_latex_math (self,
+ arg);
+ if (latex_content)
+ {
+ text_append (&formatted_arg, latex_content);
+ free (latex_content);
+ }
}
else
{
diff --git a/tp/Texinfo/XS/main/call_perl_function.c
b/tp/Texinfo/XS/main/call_perl_function.c
index 81bc61e798..9638e6046a 100644
--- a/tp/Texinfo/XS/main/call_perl_function.c
+++ b/tp/Texinfo/XS/main/call_perl_function.c
@@ -32,6 +32,8 @@
#include <string.h>
+#include "tree_types.h"
+#include "converter_types.h"
#include "build_perl_info.h"
#include "call_perl_function.h"
@@ -78,3 +80,75 @@ call_nodenamenormalization_unicode_to_transliterate (char
*text)
return result;
}
+
+char *
+call_latex_convert_to_latex_math (CONVERTER *self, ELEMENT *element)
+{
+ int count;
+ char *result;
+ char *result_ret;
+ STRLEN len;
+ SV *result_sv;
+ SV **options_latex_math_sv;
+ SV *options_latex_math;
+
+ dTHX;
+
+ if (!self->hv)
+ return 0;
+
+ /* in case of @displaymath a element containing the contents
+ of the displaymath element is passed, it is not registered in perl */
+ if (!element->hv)
+ {
+ element_to_perl_hash (element);
+ }
+
+ dSP;
+
+ options_latex_math_sv = hv_fetch (self->hv, "options_latex_math",
+ strlen ("options_latex_math"), 0);
+
+ if (options_latex_math_sv)
+ {
+ options_latex_math = *options_latex_math_sv;
+ SvREFCNT_inc (options_latex_math);
+ }
+ else
+ {
+ options_latex_math = newSV (0);
+ }
+
+
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK(SP);
+ EXTEND(SP, 3);
+
+ PUSHs(sv_2mortal (newSV (0)));
+ PUSHs(sv_2mortal (newRV_inc (element->hv)));
+ PUSHs(sv_2mortal (options_latex_math));
+ PUTBACK;
+
+ count = call_pv (
+ "Texinfo::Convert::LaTeX::convert_to_latex_math",
+ G_SCALAR);
+
+ SPAGAIN;
+
+ if (count != 1)
+ croak("convert_to_latex_math should return 1 item\n");
+
+ result_sv = POPs;
+ /* FIXME encoding */
+ result_ret = SvPV (result_sv, len);
+ result = strdup (result_ret);
+
+ PUTBACK;
+
+ FREETMPS;
+ LEAVE;
+
+ return result;
+}
diff --git a/tp/Texinfo/XS/main/call_perl_function.h
b/tp/Texinfo/XS/main/call_perl_function.h
index b9c3f1f6a1..c1e5a89af9 100644
--- a/tp/Texinfo/XS/main/call_perl_function.h
+++ b/tp/Texinfo/XS/main/call_perl_function.h
@@ -2,6 +2,11 @@
#ifndef CALL_PERL_FUNCTION_H
#define CALL_PERL_FUNCTION_H
+#include "tree_types.h"
+#include "converter_types.h"
+
char *call_nodenamenormalization_unicode_to_transliterate (char *text);
+char *call_latex_convert_to_latex_math (CONVERTER *self, ELEMENT *element);
+
#endif
diff --git a/tp/t/html_tests.t b/tp/t/html_tests.t
index 5cf5bda258..db8c34e9f0 100644
--- a/tp/t/html_tests.t
+++ b/tp/t/html_tests.t
@@ -654,13 +654,12 @@ in html
', {'FORMAT_MENU' => 'menu'}, {'FORMAT_MENU' => 'menu'},],
['mathjax_with_texinfo',
$mathjax_with_texinfo,
-{'skip' => $XS_convert ? 'No conversion to LaTeX in HTML XS' : undef, },
+{},
{'HTML_MATH' => 'mathjax'}],
['mathjax_with_texinfo_enable_encoding',
$mathjax_with_texinfo, {'test_formats' => ['latex_text', 'file_latex'],
'full_document' => 1,
- 'test_input_file_name' => 'mathjax_with_texinfo_enable_encoding.texi',
- 'skip' => $XS_convert ? 'No conversion to LaTeX in HTML XS' : undef,},
+ 'test_input_file_name' => 'mathjax_with_texinfo_enable_encoding.texi',},
{'HTML_MATH' => 'mathjax', 'ENABLE_ENCODING' => 1, 'OUTPUT_CHARACTERS' => 1}],
['mathjax_with_texinfo_no_convert_to_latex',
$mathjax_with_texinfo, {}, {'HTML_MATH' => 'mathjax',
@@ -1269,7 +1268,7 @@ $check_htmlxref_text
],
['mathjax_with_texinfo_html_file',
$mathjax_with_texinfo,
-{'skip' => $XS_convert ? 'No conversion to LaTeX in HTML XS' : undef, },
+{},
{'HTML_MATH' => 'mathjax'}],
['info_js_dir_html_file',
$info_js_dir_test, {}, {'INFO_JS_DIR' => 'js'}],
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/convert/convert_html.c (html_open_command_update_context, convert_to_html_internal) tp/Texinfo/XS/main/call_perl_function.c (call_latex_convert_to_latex_math): add call_latex_convert_to_latex_math to call Texinfo::Convert::LaTeX::convert_to_latex_math from XS, and use it in convert_to_html_internal.,
Patrice Dumas <=