[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/HTML.pm (output): set BODYTE
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/HTML.pm (output): set BODYTEXT early where the other configuration variables are set. |
Date: |
Mon, 23 Oct 2023 12:55:06 -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 fe3b61d29a * tp/Texinfo/Convert/HTML.pm (output): set BODYTEXT early
where the other configuration variables are set.
fe3b61d29a is described below
commit fe3b61d29aa8799afaf1f8720b9e239e68a448f2
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Oct 23 18:54:41 2023 +0200
* tp/Texinfo/Convert/HTML.pm (output): set BODYTEXT early where
the other configuration variables are set.
* tp/Texinfo/XS/main/build_perl_info.c (newSVpv_utf8),
tp/Texinfo/XS/main/call_perl_function.c
(call_nodenamenormalization_unicode_to_transliterate): make
newSVpv_utf8 a global function and use it in
call_nodenamenormalization_unicode_to_transliterate.
* tp/Texinfo/Convert/Converter.pm (encode_converter_document),
tp/Texinfo/Convert/HTML.pm (converter_initialize),
tp/Texinfo/XS/main/get_perl_info.c (html_converter_initialize),
tp/Texinfo/XS/main/utils.c (html_formatting_reference_names)
(html_css_string_formatting_reference_names),
tp/Texinfo/XS/main/utils.h (HTML_FORMATTING_REFERENCES_LIST)
(FORMATTING_REFERENCE, CONVERTER):
pass formatting_function and default formatting references to
converter initialization.
* tp/Texinfo/Convert/HTML.pm (convert): setup simpletitle_tree
and call _reset_info to be able to really format the title.
* tp/Texinfo/Convert/HTML.pm (import, _XS_html_convert_init)
(convert), tp/Texinfo/XS/convert/ConvertXS.xs (html_convert_init),
tp/Texinfo/XS/convert/convert_html.c (html_convert_init),
tp/Texinfo/XS/main/call_perl_function.c
(call_formatting_function_format_title_titlepage):
implement convert() init phase in C with an XS interface. Consist in
in setting the title_titlepage, by calling the corresponding perl
formatting reference.
* tp/t/converters_tests.t (commands_in_settitle_with_title),
tp/Makefile.tres: test a title in convert.
---
ChangeLog | 36 ++
tp/Makefile.tres | 1 +
tp/Texinfo/Convert/Converter.pm | 7 +-
tp/Texinfo/Convert/HTML.pm | 57 +-
tp/Texinfo/XS/convert/ConvertXS.xs | 18 +-
tp/Texinfo/XS/convert/convert_html.c | 9 +
tp/Texinfo/XS/convert/convert_html.h | 2 +
tp/Texinfo/XS/main/build_perl_info.c | 2 +-
tp/Texinfo/XS/main/build_perl_info.h | 3 +
tp/Texinfo/XS/main/call_perl_function.c | 50 +-
tp/Texinfo/XS/main/get_perl_info.c | 64 ++-
tp/Texinfo/XS/main/get_perl_info.h | 3 +-
tp/Texinfo/XS/main/tree_perl_api.h | 2 +
tp/Texinfo/XS/main/utils.c | 12 +
tp/Texinfo/XS/main/utils.h | 58 ++
tp/t/converters_tests.t | 13 +
.../commands_in_settitle_with_title.pl | 630 +++++++++++++++++++++
17 files changed, 950 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b64eb8f5a4..3a91d96661 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
+2023-10-23 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (output): set BODYTEXT early where
+ the other configuration variables are set.
+
+ * tp/Texinfo/XS/main/build_perl_info.c (newSVpv_utf8),
+ tp/Texinfo/XS/main/call_perl_function.c
+ (call_nodenamenormalization_unicode_to_transliterate): make
+ newSVpv_utf8 a global function and use it in
+ call_nodenamenormalization_unicode_to_transliterate.
+
+ * tp/Texinfo/Convert/Converter.pm (encode_converter_document),
+ tp/Texinfo/Convert/HTML.pm (converter_initialize),
+ tp/Texinfo/XS/main/get_perl_info.c (html_converter_initialize),
+ tp/Texinfo/XS/main/utils.c (html_formatting_reference_names)
+ (html_css_string_formatting_reference_names),
+ tp/Texinfo/XS/main/utils.h (HTML_FORMATTING_REFERENCES_LIST)
+ (FORMATTING_REFERENCE, CONVERTER):
+ pass formatting_function and default formatting references to
+ converter initialization.
+
+ * tp/Texinfo/Convert/HTML.pm (convert): setup simpletitle_tree
+ and call _reset_info to be able to really format the title.
+
+ * tp/Texinfo/Convert/HTML.pm (import, _XS_html_convert_init)
+ (convert), tp/Texinfo/XS/convert/ConvertXS.xs (html_convert_init),
+ tp/Texinfo/XS/convert/convert_html.c (html_convert_init),
+ tp/Texinfo/XS/main/call_perl_function.c
+ (call_formatting_function_format_title_titlepage):
+ implement convert() init phase in C with an XS interface. Consist in
+ in setting the title_titlepage, by calling the corresponding perl
+ formatting reference.
+
+ * tp/t/converters_tests.t (commands_in_settitle_with_title),
+ tp/Makefile.tres: test a title in convert.
+
2023-10-22 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/HTML.pm (import)
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 295b962fe3..846c83b7de 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -162,6 +162,7 @@ test_files_generated_list =
$(test_tap_files_generated_list) \
t/results/converters_tests/combined_fonts/res_latex \
t/results/converters_tests/combined_fonts/res_xml \
t/results/converters_tests/commands_in_sc.pl \
+ t/results/converters_tests/commands_in_settitle_with_title.pl \
t/results/converters_tests/commands_in_var.pl \
t/results/converters_tests/complex_nestings.pl \
t/results/converters_tests/contents_at_document_begin.pl \
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index c4de256c40..6674ab72cb 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -442,9 +442,10 @@ sub encode_converter_document($)
# and set converter_descriptor
'document_descriptor' => $self->{'document_descriptor'}};
- if ($self->{'style_commands_formatting'}) {
- $result->{'style_commands_formatting'}
- = $self->{'style_commands_formatting'};
+ foreach my $variable ('style_commands_formatting', 'formatting_function') {
+ if ($self->{$variable}) {
+ $result->{$variable} = $self->{$variable};
+ }
}
if (defined($self->{'converter_init_conf'})) {
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 56de329566..0b2c839633 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -118,6 +118,9 @@ sub import {
Texinfo::XSLoader::override(
"Texinfo::Convert::HTML::_XS_translate_names",
"Texinfo::Convert::ConvertXS::html_translate_names");
+ Texinfo::XSLoader::override(
+ "Texinfo::Convert::HTML::_XS_html_convert_init",
+ "Texinfo::Convert::ConvertXS::html_convert_init");
$module_loaded = 1;
}
@@ -7958,7 +7961,7 @@ my %special_characters = (
'non_breaking_space' => [undef, '00A0'],
);
-sub _XS_converter_initialize($)
+sub _XS_converter_initialize($$$)
{
}
@@ -8408,7 +8411,9 @@ sub converter_initialize($)
if ($self->{'document_descriptor'}) {
my $encoded_converter = $self->encode_converter_document();
- _XS_converter_initialize($encoded_converter);
+ _XS_converter_initialize($encoded_converter,
+ \%default_formatting_references,
+ \%default_css_string_formatting_references);
}
return $self;
@@ -11018,11 +11023,16 @@ sub _XS_prepare_output_units_global_targets($$$$)
{
}
+sub _XS_html_convert_init($)
+{
+}
+
sub convert($$)
{
my $self = shift;
my $document = shift;
+ my $encoded_converter;
my $root = $document->tree();
my $result = '';
@@ -11046,7 +11056,9 @@ sub convert($$)
# unit directions is often referred to in code, so at least this
# global target needs to be setup.
if ($self->{'converter_descriptor'}) {
- my $encoded_converter = $self->encode_converter_for_output();
+ # Do it preferentially in XS, and import to perl, to have data
+ # setup in C for XS too.
+ $encoded_converter = $self->encode_converter_for_output();
my $global_units_directions =
_XS_prepare_output_units_global_targets($encoded_converter,
$output_units, $special_units, $associated_special_units);
@@ -11060,9 +11072,33 @@ sub convert($$)
# setup untranslated strings
$self->_translate_names(1);
- # title
- $self->{'title_titlepage'}
- = &{$self->formatting_function('format_title_titlepage')}($self);
+ # FIXME duplicate of code in output()
+ foreach my $simpletitle_command ('settitle', 'shorttitlepage') {
+ if ($self->{'global_commands'}->{$simpletitle_command}) {
+ my $command = $self->{'global_commands'}->{$simpletitle_command};
+ next if (!$command->{'args'} or !$command->{'args'}->[0]
+ or !$command->{'args'}->[0]->{'contents'}
+ or !scalar(@{$command->{'args'}->[0]->{'contents'}}));
+ $self->{'simpletitle_tree'} = $command->{'args'}->[0];
+ $self->{'simpletitle_command_name'} = $simpletitle_command;
+ last;
+ }
+ }
+ $self->_reset_info();
+
+ # title. Not often set in the default case, as convert() is only
+ # used in the *.t tests, and a title requires both simpletitle_tree
+ # and SHOW_TITLE set, with the default formatting function.
+ if ($self->{'converter_descriptor'}) {
+ # FIXME distinguish failure and no title? Could actually use
+ # unddef for failurre, as without title, return an empty string.
+ my $title_titlepage =
+ _XS_html_convert_init($encoded_converter);
+ $self->{'title_titlepage'} = $title_titlepage;
+ } else {
+ $self->{'title_titlepage'}
+ = &{$self->formatting_function('format_title_titlepage')}($self);
+ }
# complete information should be available.
$self->_reset_info();
@@ -11350,6 +11386,13 @@ sub output($$)
# configuration.
$self->{'output_init_conf'} = { %{$self->{'conf'}} };
+ # set BODYTEXT
+ $self->set_global_document_commands('preamble', ['documentlanguage']);
+ my $structure_preamble_document_language =
$self->get_conf('documentlanguage');
+ $self->set_conf('BODYTEXT',
+ 'lang="' . $structure_preamble_document_language . '"');
+ $self->set_global_document_commands('before', ['documentlanguage']);
+
$self->{'jslicenses'} = {};
if ($self->get_conf('HTML_MATH')
and $self->get_conf('HTML_MATH') eq 'mathjax') {
@@ -11426,8 +11469,6 @@ sub output($$)
$self->set_global_document_commands('preamble', ['documentlanguage']);
my $preamble_document_language = $self->get_conf('documentlanguage');
- $self->set_conf('BODYTEXT',
- 'lang="' . $preamble_document_language . '"');
if ($default_document_language ne $preamble_document_language) {
$self->_translate_names(1);
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 4a3aae2582..81faf0b6b0 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -94,7 +94,7 @@ text_convert_tree (text_options_in, tree_in, unused=0)
RETVAL
int
-html_converter_initialize (SV *converter_in)
+html_converter_initialize (SV *converter_in, SV
*default_formatting_references, SV *default_css_string_formatting_references)
void
html_initialize_output_state (SV *converter_in)
@@ -314,3 +314,19 @@ html_translate_names (SV *converter_in)
}
html_translate_names (self);
+
+SV *
+html_convert_init (SV *converter_in)
+ PREINIT:
+ CONVERTER *self = 0;
+ CODE:
+ /* TODO error? Return undef if not found? */
+ self = get_sv_converter (converter_in, 0);
+ html_convert_init (self);
+ if (self->title_titlepage)
+ RETVAL = newSVpv_utf8 (self->title_titlepage, 0);
+ else
+ /* should never happen as a string is always returned, possibly empty */
+ RETVAL = newSV(0);
+ OUTPUT:
+ RETVAL
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index c67319165d..b00c2b8c63 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -2167,3 +2167,12 @@ html_prepare_units_directions_files (CONVERTER *self,
return files_source_info;
}
+
+/* init phase for conversion for convert() */
+void
+html_convert_init (CONVERTER *self)
+{
+ char *title_titlepage
+ = call_formatting_function_format_title_titlepage (self);
+ self->title_titlepage = title_titlepage;
+}
diff --git a/tp/Texinfo/XS/convert/convert_html.h
b/tp/Texinfo/XS/convert/convert_html.h
index 17438b6c15..00a9bb23db 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -30,6 +30,8 @@ void html_prepare_output_units_global_targets (CONVERTER
*self,
void html_translate_names (CONVERTER *self);
+void html_convert_init (CONVERTER *self);
+
/*
char *html_convert (CONVERTER *self);
*/
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 3def7b6fc3..d5a1efa5f3 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -204,7 +204,7 @@ build_perl_directions (ELEMENT_LIST *e)
/* Used to create a "Perl-internal" string that represents a sequence
of Unicode codepoints with no specific encoding. */
-static SV *
+SV *
newSVpv_utf8 (char *str, STRLEN len)
{
SV *sv;
diff --git a/tp/Texinfo/XS/main/build_perl_info.h
b/tp/Texinfo/XS/main/build_perl_info.h
index a48a52c820..4aab36f540 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -10,6 +10,9 @@
int init (int texinfo_uninstalled, char *srcdir_in);
+/* does not exist as perl macro */
+SV *newSVpv_utf8 (char *str, STRLEN len);
+
SV *build_document (size_t document_descriptor, int no_store);
HV *build_texinfo_tree (ELEMENT *root);
diff --git a/tp/Texinfo/XS/main/call_perl_function.c
b/tp/Texinfo/XS/main/call_perl_function.c
index 950cc332e8..ac763204ae 100644
--- a/tp/Texinfo/XS/main/call_perl_function.c
+++ b/tp/Texinfo/XS/main/call_perl_function.c
@@ -53,7 +53,7 @@ call_nodenamenormalization_unicode_to_transliterate (char
*text)
PUSHMARK(SP);
EXTEND(SP, 1);
- PUSHs(sv_2mortal (newSVpvn_utf8 (text, strlen (text), 1)));
+ PUSHs(sv_2mortal (newSVpv_utf8 (text, 0)));
PUTBACK;
count = call_pv (
@@ -479,3 +479,51 @@ call_file_id_setting_unit_file_name (CONVERTER *self,
OUTPUT_UNIT *output_unit,
}
return 0;
}
+
+char *
+call_formatting_function_format_title_titlepage (CONVERTER *self)
+{
+ int count;
+ char *result;
+ char *result_ret;
+ STRLEN len;
+ SV *result_sv;
+ SV *formatting_reference
+ = self->formatting_references[FR_format_title_titlepage].sv_reference;
+
+ dTHX;
+
+ if (!self->hv)
+ return 0;
+
+ dSP;
+
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK(SP);
+ EXTEND(SP, 1);
+
+ PUSHs(sv_2mortal (newRV_inc (self->hv)));
+ PUTBACK;
+
+ count = call_sv (formatting_reference,
+ G_SCALAR);
+
+ SPAGAIN;
+
+ if (count != 1)
+ croak("format_title_titlepage 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/get_perl_info.c
b/tp/Texinfo/XS/main/get_perl_info.c
index 099a555e7b..aae561d3e5 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -384,14 +384,20 @@ set_translated_commands (CONVERTER *converter, HV *hv_in)
}
int
-html_converter_initialize (SV *sv_in)
+html_converter_initialize (SV *sv_in, SV *default_formatting_references,
+ SV *default_css_string_formatting_references)
{
+ int i;
HV *hv_in;
+ HV *default_formatting_references_hv;
+ HV *default_css_string_formatting_references_hv;
SV **converter_init_conf_sv;
SV **converter_sv;
+ SV **formatting_function_sv;
SV **sorted_special_unit_varieties_sv;
SV **no_arg_commands_formatting_sv;
SV **style_commands_formatting_sv;
+ HV *formatting_function_hv;
CONVERTER *converter = new_converter ();
int converter_descriptor = 0;
DOCUMENT *document;
@@ -400,6 +406,10 @@ html_converter_initialize (SV *sv_in)
dTHX;
hv_in = (HV *)SvRV (sv_in);
+ default_formatting_references_hv
+ = (HV *)SvRV (default_formatting_references);
+ default_css_string_formatting_references_hv
+ = (HV *)SvRV (default_css_string_formatting_references);
/* generic */
@@ -423,8 +433,58 @@ html_converter_initialize (SV *sv_in)
/* HTML specific */
+ formatting_function_sv
+ = hv_fetch (hv_in, "formatting_function",
+ strlen ("formatting_function"), 0);
+
+ /* no need to check if it exists */
+ formatting_function_hv = (HV *)SvRV (*formatting_function_sv);
+
+ for (i = 0; i < FR_format_translate_message_string+1; i++)
+ {
+ char *ref_name = html_formatting_reference_names[i];
+ FORMATTING_REFERENCE *formatting_reference
+ = &converter->formatting_references[i];
+ SV **formatting_reference_sv
+ = hv_fetch (formatting_function_hv, ref_name, strlen (ref_name), 0);
+ SV **default_formatting_reference_sv
+ = hv_fetch (default_formatting_references_hv, ref_name,
+ strlen (ref_name), 0);
+ /* no check, all should exist */
+ if (SvOK (*default_formatting_reference_sv))
+ formatting_reference->sv_default = *default_formatting_reference_sv;
+ if (formatting_reference_sv)
+ {
+ if SvOK (*formatting_reference_sv)
+ formatting_reference->sv_reference = *formatting_reference_sv;
+ }
+ else
+ fprintf (stderr, "BUG: formatting reference %s not found\n",
+ ref_name);
+ }
+ for (i = 0; i < CSSFR_format_protect_text+1; i++)
+ {
+ char *ref_name = html_css_string_formatting_reference_names[i];
+ FORMATTING_REFERENCE *formatting_reference
+ = &converter->css_string_formatting_references[i];
+ SV **default_formatting_reference_sv
+ = hv_fetch (default_css_string_formatting_references_hv, ref_name,
+ strlen (ref_name), 0);
+
+ /* no customization, current is the default */
+ if (default_formatting_reference_sv
+ && SvOK (*default_formatting_reference_sv))
+ {
+ formatting_reference->sv_default = *default_formatting_reference_sv;
+ formatting_reference->sv_reference =
*default_formatting_reference_sv;
+ }
+ else
+ fprintf (stderr, "BUG: css formatting reference %s not found\n",
+ ref_name);
+ }
+
sorted_special_unit_varieties_sv
- = hv_fetch (hv_in, "sorted_special_unit_varieties",
+ = hv_fetch (hv_in, "sorted_special_unit_varieties",
strlen ("sorted_special_unit_varieties"), 0);
if (sorted_special_unit_varieties_sv)
diff --git a/tp/Texinfo/XS/main/get_perl_info.h
b/tp/Texinfo/XS/main/get_perl_info.h
index 3233dee29a..397be575c7 100644
--- a/tp/Texinfo/XS/main/get_perl_info.h
+++ b/tp/Texinfo/XS/main/get_perl_info.h
@@ -17,7 +17,8 @@ int get_sv_output_units_descriptor (SV *output_units_in, char
*warn_string);
OPTIONS *copy_sv_options (SV *sv_in);
TEXT_OPTIONS *copy_sv_options_for_convert_text (SV *sv_in);
-int html_converter_initialize (SV *sv_in);
+int html_converter_initialize (SV *sv_in, SV *default_formatting_references,
+ SV *default_css_string_formatting_references);
CONVERTER *set_output_converter_sv (SV *sv_in, char *warn_string);
CONVERTER *get_sv_converter (SV *sv_in, char *warn_string);
diff --git a/tp/Texinfo/XS/main/tree_perl_api.h
b/tp/Texinfo/XS/main/tree_perl_api.h
index 213ecdb273..1c1bb0ed70 100644
--- a/tp/Texinfo/XS/main/tree_perl_api.h
+++ b/tp/Texinfo/XS/main/tree_perl_api.h
@@ -27,4 +27,6 @@ TARGET_CONTENTS_FILENAME *
call_file_id_setting_sectioning_command_target_name
FILE_NAME_PATH *call_file_id_setting_unit_file_name (CONVERTER *self,
OUTPUT_UNIT *output_unit,
char *filename, char *filepath);
+char *call_formatting_function_format_title_titlepage (CONVERTER *self);
+
#endif
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 9f2992ac17..790dbe2191 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -73,6 +73,18 @@ char *html_conversion_context_type_names[] = {
#undef cctx_type
};
+char *html_formatting_reference_names[] = {
+ #define html_fr_reference(name) #name,
+ HTML_FORMATTING_REFERENCES_LIST
+ #undef html_fr_reference
+};
+
+char *html_css_string_formatting_reference_names[] = {
+ #define html_fr_reference(name) #name,
+ HTML_CSS_FORMATTING_REFERENCES_LIST
+ #undef html_fr_reference
+};
+
ENCODING_CONVERSION_LIST output_conversions = {0, 0, 0, -1};
ENCODING_CONVERSION_LIST input_conversions = {0, 0, 0, 1};
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index 9e6d1bf9e9..b451b34109 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -41,6 +41,9 @@ extern const char *command_location_names[];
extern char *html_conversion_context_type_names[];
extern char *html_global_unit_direction_names[];
+extern char *html_formatting_reference_names[];
+extern char *html_css_string_formatting_reference_names[];
+
enum error_type { MSG_error, MSG_warning,
MSG_document_error, MSG_document_warning };
@@ -206,6 +209,47 @@ enum conversion_context {
#undef cctx_type
};
+/* %default_formatting_references + %default_css_string_formatting_references
+ in Texinfo::HTML */
+#define HTML_FORMATTING_REFERENCES_LIST \
+ html_fr_reference(format_begin_file) \
+ html_fr_reference(format_button) \
+ html_fr_reference(format_button_icon_img) \
+ html_fr_reference(format_css_lines) \
+ html_fr_reference(format_comment) \
+ html_fr_reference(format_contents) \
+ html_fr_reference(format_element_header) \
+ html_fr_reference(format_element_footer) \
+ html_fr_reference(format_end_file) \
+ html_fr_reference(format_footnotes_segment) \
+ html_fr_reference(format_footnotes_sequence) \
+ html_fr_reference(format_heading_text) \
+ html_fr_reference(format_navigation_header) \
+ html_fr_reference(format_navigation_panel) \
+ html_fr_reference(format_node_redirection_page) \
+ html_fr_reference(format_program_string) \
+ html_fr_reference(format_protect_text) \
+ html_fr_reference(format_separate_anchor) \
+ html_fr_reference(format_titlepage) \
+ html_fr_reference(format_title_titlepage) \
+ html_fr_reference(format_translate_message_tree) \
+ html_fr_reference(format_translate_message_string) \
+
+#define HTML_CSS_FORMATTING_REFERENCES_LIST \
+ html_fr_reference(format_protect_text)
+
+enum html_formatting_reference {
+ #define html_fr_reference(name) FR_## name,
+ HTML_FORMATTING_REFERENCES_LIST
+ #undef html_fr_reference
+};
+
+enum html_css_string_formatting_reference {
+ #define html_fr_reference(name) CSSFR_## name,
+ HTML_CSS_FORMATTING_REFERENCES_LIST
+ #undef html_fr_reference
+};
+
/* down here because it requires error data from before */
#include "document.h"
@@ -299,6 +343,13 @@ typedef struct SPECIAL_UNIT_DIRECTION {
char *direction;
} SPECIAL_UNIT_DIRECTION;
+typedef struct FORMATTING_REFERENCE {
+/* perl references. This should be SV *sv_*,
+ but we don't want to include the Perl headers everywhere; */
+ void *sv_reference;
+ void *sv_default;
+} FORMATTING_REFERENCE;
+
typedef struct CONVERTER {
int converter_descriptor;
OPTIONS *conf;
@@ -318,6 +369,9 @@ typedef struct CONVERTER {
but we don't want to include the Perl headers everywhere; */
void *hv;
+ /* maybe HTML specific */
+ char *title_titlepage;
+
/* HTML specific */
OUTPUT_UNIT **global_units_directions;
SPECIAL_UNIT_DIRECTION **special_units_direction_name;
@@ -331,6 +385,10 @@ typedef struct CONVERTER {
char **directions_strings[TDS_type_rel+1];
HTML_COMMAND_CONVERSION ***html_command_conversion;
COMMAND_ID_LIST *no_arg_formatted_cmd;
+ FORMATTING_REFERENCE
+ formatting_references[FR_format_translate_message_string+1];
+ FORMATTING_REFERENCE
+ css_string_formatting_references[CSSFR_format_protect_text+1];
} CONVERTER;
typedef struct TARGET_FILENAME {
diff --git a/tp/t/converters_tests.t b/tp/t/converters_tests.t
index 2fb44ec08e..14dcf230a7 100644
--- a/tp/t/converters_tests.t
+++ b/tp/t/converters_tests.t
@@ -200,6 +200,19 @@ in float
@listoffloats type '."\f".'
'],
+# This tests a title in convert
+['commands_in_settitle_with_title',
+'@settitle @sc{sc @~n @aa{} @TeX{}} node @"i @"{@dotless{i}} @`{@=E} @l{}
@,{@\'C} @exclamdown{}
+
+@node Top
+@top top
+
+@node chapter
+@chapter Chap
+
+Document.
+
+', {}, {'SHOW_TITLE' => 1}],
['some_at_commands_in_ref_nodes',
'
@node Top
diff --git a/tp/t/results/converters_tests/commands_in_settitle_with_title.pl
b/tp/t/results/converters_tests/commands_in_settitle_with_title.pl
new file mode 100644
index 0000000000..c93eadee43
--- /dev/null
+++ b/tp/t/results/converters_tests/commands_in_settitle_with_title.pl
@@ -0,0 +1,630 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors
+ %result_indices %result_sectioning %result_nodes %result_menus
+ %result_floats %result_converted %result_converted_errors
+ %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'commands_in_settitle_with_title'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'sc '
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'n'
+ }
+ ],
+ 'type' => 'following_arg'
+ }
+ ],
+ 'cmdname' => '~',
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ },
+ {
+ 'text' => ' '
+ },
+ {
+ 'args' => [
+ {
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => 'aa',
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ },
+ {
+ 'text' => ' '
+ },
+ {
+ 'args' => [
+ {
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => 'TeX',
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => 'sc',
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ },
+ {
+ 'text' => ' node '
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'i'
+ }
+ ],
+ 'type' => 'following_arg'
+ }
+ ],
+ 'cmdname' => '"',
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ },
+ {
+ 'text' => ' '
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'i'
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => 'dotless',
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => '"',
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ },
+ {
+ 'text' => ' '
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'E'
+ }
+ ],
+ 'type' => 'following_arg'
+ }
+ ],
+ 'cmdname' => '=',
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => '`',
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ },
+ {
+ 'text' => ' '
+ },
+ {
+ 'args' => [
+ {
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => 'l',
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ },
+ {
+ 'text' => ' '
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'C'
+ }
+ ],
+ 'type' => 'following_arg'
+ }
+ ],
+ 'cmdname' => '\'',
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => ',',
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ },
+ {
+ 'text' => ' '
+ },
+ {
+ 'args' => [
+ {
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => 'exclamdown',
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'settitle',
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ },
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ }
+ ],
+ 'type' => 'before_node_section'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'Top'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'is_target' => 1,
+ 'normalized' => 'Top'
+ },
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 3,
+ 'macro' => ''
+ }
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'top'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'top',
+ 'contents' => [
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ }
+ ],
+ 'extra' => {},
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 4,
+ 'macro' => ''
+ }
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'chapter'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'is_target' => 1,
+ 'normalized' => 'chapter'
+ },
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 6,
+ 'macro' => ''
+ }
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'Chap'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'chapter',
+ 'contents' => [
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'text' => 'Document.
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ }
+ ],
+ 'extra' => {
+ 'section_number' => '1'
+ },
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 7,
+ 'macro' => ''
+ }
+ }
+ ],
+ 'type' => 'document_root'
+};
+
+$result_texis{'commands_in_settitle_with_title'} = '@settitle @sc{sc @~n @aa{}
@TeX{}} node @"i @"{@dotless{i}} @`{@=E} @l{} @,{@\'C} @exclamdown{}
+
+@node Top
+@top top
+
+@node chapter
+@chapter Chap
+
+Document.
+
+';
+
+
+$result_texts{'commands_in_settitle_with_title'} = '
+top
+***
+
+1 Chap
+******
+
+Document.
+
+';
+
+$result_sectioning{'commands_in_settitle_with_title'} = {
+ 'extra' => {
+ 'section_childs' => [
+ {
+ 'cmdname' => 'top',
+ 'extra' => {
+ 'associated_node' => {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'normalized' => 'Top'
+ }
+ },
+ 'section_childs' => [
+ {
+ 'cmdname' => 'chapter',
+ 'extra' => {
+ 'associated_node' => {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'normalized' => 'chapter'
+ }
+ },
+ 'section_directions' => {
+ 'up' => {}
+ },
+ 'section_level' => 1,
+ 'section_number' => '1',
+ 'toplevel_directions' => {
+ 'prev' => {},
+ 'up' => {}
+ }
+ }
+ }
+ ],
+ 'section_level' => 0,
+ 'sectioning_root' => {},
+ 'toplevel_directions' => {}
+ }
+ }
+ ],
+ 'section_level' => -1
+ }
+};
+$result_sectioning{'commands_in_settitle_with_title'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'section_directions'}{'up'}
=
$result_sectioning{'commands_in_settitle_with_title'}{'extra'}{'section_childs'}[0];
+$result_sectioning{'commands_in_settitle_with_title'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'toplevel_directions'}{'prev'}
=
$result_sectioning{'commands_in_settitle_with_title'}{'extra'}{'section_childs'}[0];
+$result_sectioning{'commands_in_settitle_with_title'}{'extra'}{'section_childs'}[0]{'extra'}{'section_childs'}[0]{'extra'}{'toplevel_directions'}{'up'}
=
$result_sectioning{'commands_in_settitle_with_title'}{'extra'}{'section_childs'}[0];
+$result_sectioning{'commands_in_settitle_with_title'}{'extra'}{'section_childs'}[0]{'extra'}{'sectioning_root'}
= $result_sectioning{'commands_in_settitle_with_title'};
+
+$result_nodes{'commands_in_settitle_with_title'} = [
+ {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'associated_section' => {
+ 'cmdname' => 'top',
+ 'extra' => {}
+ },
+ 'node_directions' => {
+ 'next' => {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'associated_section' => {
+ 'cmdname' => 'chapter',
+ 'extra' => {
+ 'section_number' => '1'
+ }
+ },
+ 'node_directions' => {
+ 'prev' => {},
+ 'up' => {}
+ },
+ 'normalized' => 'chapter'
+ }
+ }
+ },
+ 'normalized' => 'Top'
+ }
+ },
+ {}
+];
+$result_nodes{'commands_in_settitle_with_title'}[0]{'extra'}{'node_directions'}{'next'}{'extra'}{'node_directions'}{'prev'}
= $result_nodes{'commands_in_settitle_with_title'}[0];
+$result_nodes{'commands_in_settitle_with_title'}[0]{'extra'}{'node_directions'}{'next'}{'extra'}{'node_directions'}{'up'}
= $result_nodes{'commands_in_settitle_with_title'}[0];
+$result_nodes{'commands_in_settitle_with_title'}[1] =
$result_nodes{'commands_in_settitle_with_title'}[0]{'extra'}{'node_directions'}{'next'};
+
+$result_menus{'commands_in_settitle_with_title'} = [
+ {
+ 'extra' => {
+ 'normalized' => 'Top'
+ }
+ },
+ {
+ 'extra' => {
+ 'normalized' => 'chapter'
+ }
+ }
+];
+
+$result_errors{'commands_in_settitle_with_title'} = [];
+
+
+$result_floats{'commands_in_settitle_with_title'} = {};
+
+
+
+$result_converted{'plaintext'}->{'commands_in_settitle_with_title'} = 'top
+***
+
+1 Chap
+******
+
+Document.
+
+';
+
+
+$result_converted{'html_text'}->{'commands_in_settitle_with_title'} = '<h1
class="settitle"><small class="sc">SC Ñ Å TeX</small> node ï
ï Ḕ ł Ḉ ¡</h1>
+<hr>
+
+<div class="top-level-extent" id="Top">
+<div class="nav-panel">
+</div>
+<h1 class="top" id="top"><span>top<a class="copiable-link" href="#top">
¶</a></span></h1>
+
+<ul class="mini-toc">
+<li><a href="#chapter" accesskey="1">Chap</a></li>
+</ul>
+<hr>
+<div class="chapter-level-extent" id="chapter">
+<div class="nav-panel">
+</div>
+<h2 class="chapter" id="Chap"><span>1 Chap<a class="copiable-link"
href="#Chap"> ¶</a></span></h2>
+
+<p>Document.
+</p>
+</div>
+</div>
+';
+
+
+$result_converted{'xml'}->{'commands_in_settitle_with_title'} = '<settitle
spaces=" "><sc>sc <accent type="tilde" bracketed="off">n</accent> å
&tex;</sc> node <accent type="uml" bracketed="off">i</accent> <accent
type="uml"><dotless>i</dotless></accent> <accent type="grave"><accent
type="macr" bracketed="off">E</accent></accent> &lslash; <accent
type="cedil"><accent type="acute" bracketed="off">C</accent></accent>
¡</settitle>
+
+<node name="Top" spaces=" "><nodename>Top</nodename><nodenext
automatic="on">chapter</nodenext></node>
+<top spaces=" "><sectiontitle>top</sectiontitle>
+
+</top>
+<node name="chapter" spaces=" "><nodename>chapter</nodename><nodeprev
automatic="on">Top</nodeprev><nodeup automatic="on">Top</nodeup></node>
+<chapter spaces=" "><sectiontitle>Chap</sectiontitle>
+
+<para>Document.
+</para>
+</chapter>
+';
+
+
+$result_converted{'docbook'}->{'commands_in_settitle_with_title'} = '<chapter
label="1" id="chapter">
+<title>Chap</title>
+
+<para>Document.
+</para>
+</chapter>
+';
+
+
+$result_converted{'latex_text'}->{'commands_in_settitle_with_title'} = '
+\\label{anchor:Top}%
+\\chapter{{Chap}}
+\\label{anchor:chapter}%
+
+Document.
+
+';
+
+1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/HTML.pm (output): set BODYTEXT early where the other configuration variables are set.,
Patrice Dumas <=