[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 12 Dec 2023 06:29:58 -0500 (EST) |
branch: master
commit 689e2a43b6bf3256dbd63781f8e180f4997aeb37
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Dec 10 23:15:15 2023 +0100
* tp/Texinfo/Convert/HTML.pm (_prepare_converted_output_info)
(output): new function to be able to override setting up titles,
copying comment and documentdescription.
* tp/Texinfo/XS/convert/ConvertXS.xs (html_translate_names): do not
get conf, set_conf is already overriden.
* tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_simpletitle),
tp/Texinfo/XS/convert/build_html_perl_state.c (build_simpletitle):
separate function to build simpletitle for perl.
* tp/Texinfo/XS/convert/call_html_perl_function.c
(call_formatting_function_format_comment),
tp/Texinfo/XS/convert/convert_html.c (format_comment): add.
* tp/Texinfo/Document.pm (register, global_information),
tp/Texinfo/ParserNonXS.pm (%parser_state_initialization)
(get_parser_info, parse_texi_file, _handle_line_command)
(_handle_block_command), tp/Texinfo/XS/main/DocumentXS.xs
(rebuild_document), tp/Texinfo/XS/main/build_perl_info.c
(get_document, build_document), tp/Texinfo/XS/parsetexi/Parsetexi.pm
(_get_parser_info), tp/t/test_utils.pl (test): rename global
information info key as global_info.
* tp/Texinfo/XS/convert/ConvertXS.xs
(html_prepare_converted_output_info),
tp/Texinfo/XS/convert/convert_html.c
(html_prepare_converted_output_info, html_finalize_output_state),
tp/Texinfo/XS/main/converter_types.h (CONVERTER): implementation of
_prepare_converted_output_info in C and XS interface. Not activated,
as the output is not correct for now, because of incorrect
synchronization with perl state.
---
ChangeLog | 35 +++++
tp/Texinfo/Convert/HTML.pm | 161 ++++++++++---------
tp/Texinfo/Document.pm | 4 +-
tp/Texinfo/ParserNonXS.pm | 27 ++--
tp/Texinfo/XS/convert/ConvertXS.xs | 56 ++++---
tp/Texinfo/XS/convert/build_html_perl_state.c | 11 ++
tp/Texinfo/XS/convert/build_html_perl_state.h | 2 +
tp/Texinfo/XS/convert/call_html_perl_function.c | 61 +++++++-
tp/Texinfo/XS/convert/call_html_perl_function.h | 3 +
tp/Texinfo/XS/convert/convert_html.c | 200 ++++++++++++++++++++++++
tp/Texinfo/XS/convert/convert_html.h | 1 +
tp/Texinfo/XS/main/DocumentXS.xs | 7 +-
tp/Texinfo/XS/main/build_perl_info.c | 4 +-
tp/Texinfo/XS/main/converter_types.h | 11 +-
tp/Texinfo/XS/parsetexi/Parsetexi.pm | 8 +-
tp/t/test_utils.pl | 2 +-
16 files changed, 467 insertions(+), 126 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b33d06282d..4c7bd9d1c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+2023-12-10 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (_prepare_converted_output_info)
+ (output): new function to be able to override setting up titles,
+ copying comment and documentdescription.
+
+ * tp/Texinfo/XS/convert/ConvertXS.xs (html_translate_names): do not
+ get conf, set_conf is already overriden.
+
+ * tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_simpletitle),
+ tp/Texinfo/XS/convert/build_html_perl_state.c (build_simpletitle):
+ separate function to build simpletitle for perl.
+
+ * tp/Texinfo/XS/convert/call_html_perl_function.c
+ (call_formatting_function_format_comment),
+ tp/Texinfo/XS/convert/convert_html.c (format_comment): add.
+
+ * tp/Texinfo/Document.pm (register, global_information),
+ tp/Texinfo/ParserNonXS.pm (%parser_state_initialization)
+ (get_parser_info, parse_texi_file, _handle_line_command)
+ (_handle_block_command), tp/Texinfo/XS/main/DocumentXS.xs
+ (rebuild_document), tp/Texinfo/XS/main/build_perl_info.c
+ (get_document, build_document), tp/Texinfo/XS/parsetexi/Parsetexi.pm
+ (_get_parser_info), tp/t/test_utils.pl (test): rename global
+ information info key as global_info.
+
+ * tp/Texinfo/XS/convert/ConvertXS.xs
+ (html_prepare_converted_output_info),
+ tp/Texinfo/XS/convert/convert_html.c
+ (html_prepare_converted_output_info, html_finalize_output_state),
+ tp/Texinfo/XS/main/converter_types.h (CONVERTER): implementation of
+ _prepare_converted_output_info in C and XS interface. Not activated,
+ as the output is not correct for now, because of incorrect
+ synchronization with perl state.
+
2023-12-10 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (_command_warn, _command_error): only use
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index b03c278f5c..6633f5353b 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -120,6 +120,8 @@ my %XS_conversion_overrides = (
=> "Texinfo::Convert::ConvertXS::html_finalize_output_state",
"Texinfo::Convert::HTML::_prepare_simpletitle"
=> "Texinfo::Convert::ConvertXS::html_prepare_simpletitle",
+# "Texinfo::Convert::HTML::_prepare_converted_output_info"
+# => "Texinfo::Convert::ConvertXS::html_prepare_converted_output_info",
"Texinfo::Convert::HTML::_register_id"
=> "Texinfo::Convert::ConvertXS::html_register_id",
@@ -11659,6 +11661,91 @@ sub _do_js_files($$)
}
}
+sub _prepare_converted_output_info($)
+{
+ my $self = shift;
+ # prepare title. fulltitle uses more possibility than simpletitle for
+ # title, including @-commands found in @titlepage only. Therefore
+ # simpletitle is more in line with what makeinfo in C did.
+
+ $self->_prepare_simpletitle();
+
+ my $fulltitle_tree;
+ foreach my $fulltitle_command('settitle', 'title', 'shorttitlepage', 'top') {
+ if ($self->{'global_commands'}->{$fulltitle_command}) {
+ my $command = $self->{'global_commands'}->{$fulltitle_command};
+ next if (!$command->{'args'} or !$command->{'args'}->[0]
+ or !$command->{'args'}->[0]->{'contents'}
+ or !scalar(@{$command->{'args'}->[0]->{'contents'}}));
+ print STDERR "Using $fulltitle_command as title\n"
+ if ($self->get_conf('DEBUG'));
+ $fulltitle_tree = $command->{'args'}->[0];
+ last;
+ }
+ }
+ if (!$fulltitle_tree and $self->{'global_commands'}->{'titlefont'}
+ and $self->{'global_commands'}->{'titlefont'}->[0]->{'args'}
+ and
defined($self->{'global_commands'}->{'titlefont'}->[0]->{'args'}->[0])
+ and $self->{'global_commands'}->{'titlefont'}->[0]
+ ->{'args'}->[0]->{'contents'}
+ and @{$self->{'global_commands'}->{'titlefont'}->[0]
+
->{'args'}->[0]->{'contents'}}) {
+ $fulltitle_tree = $self->{'global_commands'}->{'titlefont'}->[0];
+ }
+
+ my $html_title_string;
+ if ($fulltitle_tree) {
+ $self->{'title_tree'} = $fulltitle_tree;
+ $html_title_string = $self->convert_tree_new_formatting_context(
+ {'type' => '_string', 'contents' => [$self->{'title_tree'}]},
+ 'title_string');
+ if ($html_title_string !~ /\S/) {
+ $html_title_string = undef;
+ }
+ }
+ if (!defined($html_title_string)) {
+ my $default_title = $self->gdt('Untitled Document');
+ $self->{'title_tree'} = $default_title;
+ $self->{'title_string'} = $self->convert_tree_new_formatting_context(
+ {'type' => '_string', 'contents' => [$self->{'title_tree'}]},
+ 'title_string');
+ # TODO it is not clear that a filename without line number is ok
+ # for line_warn. Not clear what is the right way to do. There is
+ # no file level warn, as in general document_warn is used for messages
+ # for other files than the main file name.
+ $self->line_warn($self, __(
+ "must specify a title with a title command or \@top"),
+ {'file_name' => $self->{'document_info'}->{'input_file_name'}});
+ } else {
+ $self->{'title_string'} = $html_title_string;
+ }
+
+ # copying comment
+ if ($self->{'global_commands'}->{'copying'}) {
+ my $copying_comment = Texinfo::Convert::Text::convert_to_text(
+ {'contents' => $self->{'global_commands'}->{'copying'}->{'contents'}},
+ {Texinfo::Convert::Text::copy_options_for_convert_text($self)});
+ if ($copying_comment ne '') {
+ $self->{'copying_comment'}
+ = &{$self->formatting_function('format_comment')}($self,
$copying_comment);
+ }
+ }
+
+ # documentdescription
+ if (defined($self->get_conf('documentdescription'))) {
+ $self->{'documentdescription_string'}
+ = $self->get_conf('documentdescription');
+ } elsif ($self->{'global_commands'}->{'documentdescription'}) {
+ $self->{'documentdescription_string'}
+ = $self->convert_tree_new_formatting_context(
+ {'type' => '_string',
+ 'contents' =>
+ $self->{'global_commands'}->{'documentdescription'}->{'contents'}},
+ 'documentdescription');
+ chomp($self->{'documentdescription_string'});
+ }
+}
+
# units or root conversion
sub _html_convert_output($$$$$$$$)
{
@@ -11990,79 +12077,7 @@ sub output($$)
$self->_translate_names();
}
- # prepare title. fulltitle uses more possibility than simpletitle for
- # title, including @-commands found in @titlepage only. Therefore
- # simpletitle is more in line with what makeinfo in C did.
-
- $self->_prepare_simpletitle();
-
- my $fulltitle;
- foreach my $fulltitle_command('settitle', 'title', 'shorttitlepage', 'top') {
- if ($self->{'global_commands'}->{$fulltitle_command}) {
- my $command = $self->{'global_commands'}->{$fulltitle_command};
- next if (!$command->{'args'} or !$command->{'args'}->[0]
- or !$command->{'args'}->[0]->{'contents'}
- or !scalar(@{$command->{'args'}->[0]->{'contents'}}));
- print STDERR "Using $fulltitle_command as title\n"
- if ($self->get_conf('DEBUG'));
- $fulltitle = $command->{'args'}->[0];
- last;
- }
- }
- if (!$fulltitle and $self->{'global_commands'}->{'titlefont'}
- and $self->{'global_commands'}->{'titlefont'}->[0]->{'args'}
- and
defined($self->{'global_commands'}->{'titlefont'}->[0]->{'args'}->[0])
- and $self->{'global_commands'}->{'titlefont'}->[0]
- ->{'args'}->[0]->{'contents'}
- and @{$self->{'global_commands'}->{'titlefont'}->[0]
-
->{'args'}->[0]->{'contents'}}) {
- $fulltitle = $self->{'global_commands'}->{'titlefont'}->[0];
- }
-
- my $html_title_string;
- if ($fulltitle) {
- $self->{'title_tree'} = $fulltitle;
- $html_title_string = $self->convert_tree_new_formatting_context(
- {'type' => '_string', 'contents' => [$self->{'title_tree'}]},
- 'title_string');
- }
- if (!defined($html_title_string) or $html_title_string !~ /\S/) {
- my $default_title = $self->gdt('Untitled Document');
- $self->{'title_tree'} = $default_title;
- $self->{'title_string'} = $self->convert_tree_new_formatting_context(
- {'type' => '_string', 'contents' => [$self->{'title_tree'}]},
- 'title_string');
- $self->line_warn($self, __(
- "must specify a title with a title command or \@top"),
- {'file_name' => $self->{'document_info'}->{'input_file_name'}});
- } else {
- $self->{'title_string'} = $html_title_string;
- }
-
- # copying comment
- if ($self->{'global_commands'}->{'copying'}) {
- my $copying_comment = Texinfo::Convert::Text::convert_to_text(
- {'contents' => $self->{'global_commands'}->{'copying'}->{'contents'}},
- {Texinfo::Convert::Text::copy_options_for_convert_text($self)});
- if ($copying_comment ne '') {
- $self->{'copying_comment'}
- = &{$self->formatting_function('format_comment')}($self,
$copying_comment);
- }
- }
-
- # documentdescription
- if (defined($self->get_conf('documentdescription'))) {
- $self->{'documentdescription_string'}
- = $self->get_conf('documentdescription');
- } elsif ($self->{'global_commands'}->{'documentdescription'}) {
- $self->{'documentdescription_string'}
- = $self->convert_tree_new_formatting_context(
- {'type' => '_string',
- 'contents' =>
- $self->{'global_commands'}->{'documentdescription'}->{'contents'}},
- 'documentdescription');
- chomp($self->{'documentdescription_string'});
- }
+ $self->_prepare_converted_output_info();
# set information, to have it ready for run_stage_handlers.
# Some information is not available yet.
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index 58d156b5d3..bd23650bd1 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -98,7 +98,7 @@ sub register
'listoffloats_list' => $floats_information,
'internal_references' => $internal_references_information,
'commands_info' => $global_commands_information,
- 'info' => $global_information,
+ 'global_info' => $global_information,
'identifiers_target' => $identifier_target,
'labels_list' => $labels_list,
};
@@ -155,7 +155,7 @@ sub global_commands_information($)
sub global_information($)
{
my $self = shift;
- return $self->{'info'};
+ return $self->{'global_info'};
}
sub labels_information($)
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index fca010ec64..d7a37f72fa 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -43,8 +43,8 @@
#
# The following parser information is directly determined from the
# input file name as binary strings
-# ->{'info'}->{'input_file_name'}
-# ->{'info'}->{'input_directory'}
+# ->{'global_info'}->{'input_file_name'}
+# ->{'global_info'}->{'input_directory'}
package Texinfo::Parser;
@@ -157,7 +157,7 @@ my %parser_state_initialization = (
'input_encoding_name' => 'utf-8', # current input encoding name, based on
# mime type encoding names
# initialization of information returned by global_information()
- 'info' => {},
+ 'global_info' => {},
# for get_conf, set for all the configuration keys that are also in
# %Texinfo::Common::default_parser_customization_values to the
# values set at parser initialization
@@ -876,14 +876,15 @@ sub get_parser_info($)
= Texinfo::Common::get_perl_encoding($self->{'commands_info'},
$self->{'registrar'}, $self);
if (defined($perl_encoding)) {
- $self->{'info'}->{'input_perl_encoding'} = $perl_encoding
+ $self->{'global_info'}->{'input_perl_encoding'} = $perl_encoding
} else {
- $self->{'info'}->{'input_perl_encoding'} = 'utf-8';
+ $self->{'global_info'}->{'input_perl_encoding'} = 'utf-8';
}
if (defined($self->{'input_encoding_name'})) {
- $self->{'info'}->{'input_encoding_name'} = $self->{'input_encoding_name'};
+ $self->{'global_info'}->{'input_encoding_name'}
+ = $self->{'input_encoding_name'};
} else {
- $self->{'info'}->{'input_encoding_name'} = 'utf-8';
+ $self->{'global_info'}->{'input_encoding_name'} = 'utf-8';
}
my $global_commands = $self->{'commands_info'};
my $document_language
@@ -891,11 +892,11 @@ sub get_parser_info($)
'documentlanguage',
'preamble');
if ($document_language) {
- $self->{'info'}->{'documentlanguage'}
+ $self->{'global_info'}->{'documentlanguage'}
= Texinfo::Common::informative_command_value($document_language);
}
if ($global_commands->{'novalidate'}) {
- $self->{'info'}->{'novalidate'} = 1;
+ $self->{'global_info'}->{'novalidate'} = 1;
}
}
@@ -923,8 +924,8 @@ sub parse_texi_file($$)
my $document = $self->_parse_texi_document();
get_parser_info($self);
- $self->{'info'}->{'input_file_name'} = $file_name;
- $self->{'info'}->{'input_directory'} = $directories;
+ $self->{'global_info'}->{'input_file_name'} = $file_name;
+ $self->{'global_info'}->{'input_directory'} = $directories;
return $document;
}
@@ -5735,7 +5736,7 @@ sub _handle_line_command($$$$$$)
_register_global_command($self, $command_e, $source_info)
if $command_e;
if ($command eq 'dircategory') {
- push @{$self->{'info'}->{'dircategory_direntry'}}, $command_e;
+ push @{$self->{'global_info'}->{'dircategory_direntry'}}, $command_e;
}
return ($current, $line, $retval, $command_e);
}
@@ -5823,7 +5824,7 @@ sub _handle_block_command($$$$$)
}
if ($block_commands{$command} eq 'menu') {
$self->_push_context('ct_preformatted', $command);
- push @{$self->{'info'}->{'dircategory_direntry'}}, $block
+ push @{$self->{'global_info'}->{'dircategory_direntry'}}, $block
if ($command eq 'direntry');
if ($self->{'current_node'}) {
if ($command eq 'direntry') {
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index eeffa48275..23a1a4e137 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -822,7 +822,7 @@ html_register_footnote (SV *converter_in, SV *command,
footid, docid, int number
/*
else
fprintf (stderr,
- "REMARK: footnote %d %s not directly found\n",
+ "REMARK: footnote %d %s not directly found\n",
number_in_doc, footid);
*/
}
@@ -1147,24 +1147,8 @@ void
html_translate_names (SV *converter_in)
PREINIT:
CONVERTER *self = 0;
- HV *hv_in;
- SV **converter_options_sv;
CODE:
self = get_sv_converter (converter_in, "html_translate_names");
- /* that kind of code could be in get_perl_info too */
- hv_in = (HV *)SvRV (converter_in);
- converter_options_sv = hv_fetch (hv_in, "conf",
- strlen ("conf"), 0);
-
- if (converter_options_sv)
- {
- if (self->conf)
- free_options (self->conf);
- free (self->conf);
-
- self->conf
- = copy_sv_options (*converter_options_sv, self);
- }
html_translate_names (self);
@@ -1186,15 +1170,41 @@ html_prepare_simpletitle (SV *converter_in)
if (self->simpletitle_tree)
{
HV *converter_hv = (HV *) SvRV (converter_in);
- hv_store (converter_hv, "simpletitle_tree",
- strlen ("simpletitle_tree"),
- newRV_inc ((SV *) self->simpletitle_tree->hv), 0);
- hv_store (converter_hv, "simpletitle_command_name",
- strlen ("simpletitle_command_name"),
- newSVpv (builtin_command_name (self->simpletitle_cmd), 0),
0);
+ build_simpletitle (self, converter_hv);
}
}
+void
+html_prepare_converted_output_info (SV *converter_in)
+ PREINIT:
+ CONVERTER *self = 0;
+ CODE:
+ self = get_sv_converter (converter_in,
"html_prepare_title_titlepage");
+ if (self)
+ {
+ HV *converter_hv = (HV *) SvRV (converter_in);
+
+ html_prepare_converted_output_info (self);
+ if (self->added_title_tree)
+ build_texinfo_tree (self->title_tree, 1);
+
+ if (self->simpletitle_tree)
+ build_simpletitle (self, converter_hv);
+
+ hv_store (converter_hv, "title_tree", strlen ("title_tree"),
+ newRV_inc ((SV *) self->title_tree->hv), 0);
+ hv_store (converter_hv, "title_string", strlen ("title_string"),
+ newSVpv_utf8 (self->title_string, 0), 0);
+
+ if (self->copying_comment)
+ hv_store (converter_hv, "copying_comment",
+ strlen ("copying_comment"),
+ newSVpv_utf8 (self->copying_comment, 0), 0);
+ if (self->documentdescription_string)
+ hv_store (converter_hv, "documentdescription_string",
+ strlen ("documentdescription_string"),
+ newSVpv_utf8 (self->documentdescription_string, 0),
0);
+ }
void
html_prepare_title_titlepage (SV *converter_in, SV *output_units_in,
output_file, output_filename)
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.c
b/tp/Texinfo/XS/convert/build_html_perl_state.c
index 6df4d70572..0a8f1d71de 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.c
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.c
@@ -1005,3 +1005,14 @@ build_pending_footnotes (AV *av,
HTML_PENDING_FOOTNOTE_STACK *stack)
}
}
}
+
+void
+build_simpletitle (CONVERTER *converter, HV *converter_hv)
+{
+ hv_store (converter_hv, "simpletitle_tree",
+ strlen ("simpletitle_tree"),
+ newRV_inc ((SV *) converter->simpletitle_tree->hv), 0);
+ hv_store (converter_hv, "simpletitle_command_name",
+ strlen ("simpletitle_command_name"),
+ newSVpv (builtin_command_name (converter->simpletitle_cmd), 0), 0);
+}
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.h
b/tp/Texinfo/XS/convert/build_html_perl_state.h
index c606d8574f..9771ee5ef3 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.h
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.h
@@ -36,4 +36,6 @@ SV *build_replaced_substrings (NAMED_STRING_ELEMENT_LIST
*replaced_substrings);
void build_pending_footnotes (AV *av, HTML_PENDING_FOOTNOTE_STACK *stack);
+void build_simpletitle (CONVERTER *converter, HV *converter_hv);
+
#endif
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.c
b/tp/Texinfo/XS/convert/call_html_perl_function.c
index 2112c2052c..4c14ef7d0a 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.c
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.c
@@ -694,6 +694,65 @@ call_file_id_setting_external_target_non_split_name
(CONVERTER *self,
+char *
+call_formatting_function_format_comment (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const char *text)
+{
+ int count;
+ char *result;
+ char *result_ret;
+ STRLEN len;
+ SV *result_sv;
+ SV *formatting_reference_sv;
+
+ dTHX;
+
+ if (!self->hv)
+ return 0;
+
+ formatting_reference_sv = formatting_reference->sv_reference;
+
+ if (self->modified_state)
+ {
+ build_html_formatting_state (self, self->modified_state);
+ self->modified_state = 0;
+ }
+
+ dSP;
+
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK(SP);
+ EXTEND(SP, 2);
+
+ PUSHs(sv_2mortal (newRV_inc (self->hv)));
+ PUSHs(sv_2mortal (newSVpv_utf8 (text, 0)));
+ PUTBACK;
+
+ count = call_sv (formatting_reference_sv,
+ G_SCALAR);
+
+ SPAGAIN;
+
+ if (count != 1)
+ croak("format_comment should return 1 item\n");
+
+ result_sv = POPs;
+ result_ret = SvPVutf8 (result_sv, len);
+ result = strdup (result_ret);
+
+ PUTBACK;
+
+ FREETMPS;
+ LEAVE;
+
+ get_shared_conversion_state (self);
+
+ return result;
+}
+
char *
call_formatting_function_format_program_string (CONVERTER *self,
const FORMATTING_REFERENCE *formatting_reference)
@@ -896,7 +955,7 @@ call_formatting_function_format_protect_text (CONVERTER
*self,
SAVETMPS;
PUSHMARK(SP);
- EXTEND(SP, 1);
+ EXTEND(SP, 2);
PUSHs(sv_2mortal (newRV_inc (self->hv)));
PUSHs(sv_2mortal (newSVpv_utf8 (text, 0)));
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.h
b/tp/Texinfo/XS/convert/call_html_perl_function.h
index 564c774a6a..365d974cdd 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.h
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.h
@@ -54,6 +54,9 @@ TARGET_FILENAME
*call_file_id_setting_external_target_non_split_name
const char *normalized, const ELEMENT *element,
const char *target, const char *file);
+char *call_formatting_function_format_comment (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const char *text);
char *call_formatting_function_format_program_string (CONVERTER *self,
const FORMATTING_REFERENCE *formatting_reference);
char *call_formatting_function_format_titlepage (CONVERTER *self,
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index e5b716b5fc..4f977b6cf1 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -2284,6 +2284,25 @@ format_protect_text (CONVERTER *self, const char *text,
TEXT *result)
}
}
+char *
+format_comment (CONVERTER *self, const char *text)
+{
+ FORMATTING_REFERENCE *formatting_reference
+ = &self->current_formatting_references[FR_format_comment];
+/*
+ if (formatting_reference->status == FRS_status_default_set)
+ {
+ return html_default_format_comment (self, text);
+ }
+ else
+*/
+ {
+ return call_formatting_function_format_comment (self,
+ formatting_reference,
+ text);
+ }
+}
+
static const char *reserved_unreserved_percent = "-_.!~*'()$&+,/:;=?@[]#%";
static char *
@@ -8110,10 +8129,178 @@ html_prepare_simpletitle (CONVERTER *self)
{
self->simpletitle_tree = command->args.list[0];
self->simpletitle_cmd = cmd;
+ break;
}
}
}
+const static enum command_id fulltitle_cmds[] =
+ {CM_settitle, CM_title, CM_shorttitlepage, CM_top, 0};
+
+
+void
+html_prepare_converted_output_info (CONVERTER *self)
+{
+ int i;
+ ELEMENT *fulltitle_tree = 0;
+ char *html_title_string = 0;
+ /*
+ prepare title. fulltitle uses more possibility than simpletitle for
+ title, including @-commands found in @titlepage only. Therefore
+ simpletitle is more in line with what makeinfo in C did.
+ */
+
+ html_prepare_simpletitle (self);
+
+ for (i = 0; fulltitle_cmds[i]; i++)
+ {
+ enum command_id cmd = fulltitle_cmds[i];
+ ELEMENT *command
+ = get_cmd_global_uniq_command (self->document->global_commands, cmd);
+ if (command && command->args.number > 0
+ && command->args.list[0]->contents.number > 0)
+ {
+ fulltitle_tree = command->args.list[0];
+ break;
+ }
+ }
+
+ if (!fulltitle_tree
+ && self->document->global_commands->titlefont.number > 0
+ && self->document->global_commands->titlefont.list[0]->args.number > 0
+ && self->document->global_commands->titlefont.list[0]->args.list[0]
+ ->contents.number > 0)
+ {
+ fulltitle_tree = self->document->global_commands->titlefont.list[0];
+ }
+
+ if (fulltitle_tree)
+ {
+ TREE_ADDED_ELEMENTS *string_tree = 0;
+ ELEMENT *tree_root_string;
+
+ self->title_tree = fulltitle_tree;
+
+ string_tree = new_tree_added_elements ();
+ tree_root_string = new_element_added (string_tree, ET__string);
+ add_to_contents_as_array (tree_root_string, fulltitle_tree);
+
+ add_to_element_list (&self->tree_to_build, tree_root_string);
+
+ html_title_string = convert_tree_new_formatting_context (self,
+ tree_root_string, "title_string", 0, 0, 0);
+
+ destroy_tree_added_elements (self, string_tree);
+ if (html_title_string[strspn (html_title_string, whitespace_chars)]
+ == '\0')
+ {
+ free (html_title_string);
+ html_title_string = 0;
+ }
+ }
+
+ if (!html_title_string)
+ {
+ TREE_ADDED_ELEMENTS *string_tree = 0;
+ ELEMENT *tree_root_string;
+ ELEMENT *default_title = html_gdt_tree ("Untitled Document",
+ self->document, self, 0, 0, 0);
+ SOURCE_INFO cmd_source_info;
+
+ self->title_tree = default_title;
+
+ string_tree = new_tree_added_elements ();
+ tree_root_string = new_element_added (string_tree, ET__string);
+
+ add_to_contents_as_array (tree_root_string, default_title);
+
+ add_to_element_list (&self->tree_to_build, tree_root_string);
+
+ html_title_string = convert_tree_new_formatting_context (self,
+ tree_root_string, "title_string", 0, 0, 0);
+
+ remove_element_from_list (&self->tree_to_build, tree_root_string);
+ destroy_tree_added_elements (self, string_tree);
+
+ self->added_title_tree = 1;
+
+ memset (&cmd_source_info, 0, sizeof (SOURCE_INFO));
+ cmd_source_info.file_name = self->document->global_info->input_file_name;
+ /* TODO the message is not registered for gettext. In perl source,
+ it is registered */
+ message_list_line_error_ext(&self->error_messages,
+ MSG_warning, 0, &cmd_source_info,
+ "must specify a title with a title command or @top");
+ }
+
+ self->title_string = html_title_string;
+
+ /* copying comment */
+
+ if (self->document->global_commands->copying)
+ {
+ char *copying_comment;
+ ELEMENT *tmp = new_element (ET_NONE);
+ TEXT_OPTIONS *text_conv_options
+ = copy_options_for_convert_text (self, 0);
+
+ tmp->contents = self->document->global_commands->copying->contents;
+
+ copying_comment = convert_to_text (tmp, text_conv_options);
+
+ tmp->contents.list = 0;
+ destroy_element (tmp);
+ free (text_conv_options);
+
+ if (copying_comment && strlen (copying_comment) > 0)
+ {
+ self->copying_comment = format_comment (self, copying_comment);
+ }
+ free (copying_comment);
+ }
+
+ /* documentdescription */
+ if (self->conf->documentdescription)
+ self->documentdescription_string
+ = strdup (self->conf->documentdescription);
+ else if (self->document->global_commands->documentdescription)
+ {
+ TREE_ADDED_ELEMENTS *string_tree = 0;
+ ELEMENT *tree_root_string;
+ ELEMENT *tmp = new_element (ET_NONE);
+ char *documentdescription_string;
+ size_t documentdescription_string_len;
+
+ tmp->contents
+ = self->document->global_commands->documentdescription->contents;
+
+ string_tree = new_tree_added_elements ();
+ tree_root_string = new_element_added (string_tree, ET__string);
+
+ add_to_element_contents (tree_root_string, tmp);
+
+ add_to_element_list (&self->tree_to_build, tree_root_string);
+
+ documentdescription_string
+ = convert_tree_new_formatting_context (self,
+ tree_root_string, "documentdescription", 0, 0, 0);
+
+ remove_element_from_list (&self->tree_to_build, tree_root_string);
+ destroy_tree_added_elements (self, string_tree);
+
+ tmp->contents.list = 0;
+ destroy_element (tmp);
+
+ documentdescription_string_len = strlen (documentdescription_string);
+ if (documentdescription_string_len > 0
+ && documentdescription_string[documentdescription_string_len -1]
+ == '\n')
+ documentdescription_string[documentdescription_string_len -1] = '\0';
+
+ self->documentdescription_string = documentdescription_string;
+ }
+}
+
void
reset_translated_special_unit_info_tree (CONVERTER *self)
{
@@ -8648,6 +8835,19 @@ html_finalize_output_state (CONVERTER *self)
self->special_unit_file_indices = 0;
free (self->title_titlepage);
self->title_titlepage = 0;
+ free (self->title_string);
+ self->title_string = 0;
+ free (self->documentdescription_string);
+ self->documentdescription_string = 0;
+ free (self->copying_comment);
+ self->copying_comment = 0;
+
+ if (self->added_title_tree)
+ {
+ destroy_element_and_children (self->title_tree);
+
+ self->added_title_tree = 0;
+ }
if (self->index_entries)
{
diff --git a/tp/Texinfo/XS/convert/convert_html.h
b/tp/Texinfo/XS/convert/convert_html.h
index 70ca82a7fb..a8e17a353f 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -124,6 +124,7 @@ void html_prepare_output_units_global_targets (CONVERTER
*self,
void html_translate_names (CONVERTER *self);
void html_prepare_simpletitle (CONVERTER *self);
+void html_prepare_converted_output_info (CONVERTER *self);
void html_prepare_title_titlepage (CONVERTER *self, int
output_units_descriptor,
char *output_file, char *output_filename);
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index 4f3a936059..1bbc8fc604 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -77,7 +77,8 @@ rebuild_document (SV *document_in, ...)
rebuilt_doc_sv = build_document (document_descriptor, no_store);
RETVAL = rebuilt_doc_sv;
rebuilt_doc_hv = (HV *)SvRV (rebuilt_doc_sv);
- info_sv = hv_fetch (hv_in, "info", strlen ("info"), 0);
+ info_sv = hv_fetch (hv_in, "global_info",
+ strlen ("global_info"), 0);
/* copy input document info keys values not already in new document
info. Should only happen for info keys set in perl only. */
if (info_sv)
@@ -85,8 +86,8 @@ rebuild_document (SV *document_in, ...)
I32 hv_number;
I32 i;
HV *info_hv = (HV *)SvRV (*info_sv);
- SV **rebuilt_info_sv = hv_fetch (rebuilt_doc_hv, "info",
- strlen ("info"), 0);
+ SV **rebuilt_info_sv = hv_fetch (rebuilt_doc_hv, "global_info",
+ strlen ("global_info"), 0);
HV *rebuilt_info_hv = 0;
if (!rebuilt_info_sv)
{
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 19c46fa078..afd7bc6d03 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1157,7 +1157,7 @@ get_document (size_t document_descriptor)
#define STORE(key, value) hv_store (hv, key, strlen (key), newRV_inc ((SV *)
value), 0)
STORE("tree", hv_tree);
- STORE("info", hv_info);
+ STORE("global_info", hv_info);
STORE("errors", av_errors_list);
#undef STORE
@@ -1248,7 +1248,7 @@ build_document (size_t document_descriptor, int no_store)
STORE("listoffloats_list", hv_listoffloats_list);
STORE("internal_references", av_internal_xref);
STORE("commands_info", hv_commands_info);
- STORE("info", hv_info);
+ STORE("global_info", hv_info);
STORE("identifiers_target", hv_identifiers_target);
STORE("labels_list", av_labels_list);
STORE("errors", av_errors_list);
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index 451188fcc3..7bf37d97f1 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -650,9 +650,6 @@ typedef struct CONVERTER {
/* API to open, set encoding and register files */
OUTPUT_FILES_INFORMATION output_files_information;
- /* maybe HTML specific */
- char *title_titlepage;
-
/* HTML specific */
/* set for a converter */
COMMAND_ID_LIST no_arg_formatted_cmd;
@@ -697,15 +694,20 @@ typedef struct CONVERTER {
HTML_TARGET_LIST html_targets;
HTML_TARGET_LIST html_special_targets[ST_footnote_location+1];
char **directions_strings[TDS_type_rel+1];
+ JSLICENSE_CATEGORY_LIST jslicenses;
/* associate cmd and index in special_unit_varieties STRING_LIST */
/* number in sync with command_special_unit_variety, +1 for trailing 0 */
COMMAND_ID_INDEX command_special_variety_name_index[4+1];
size_t *output_unit_file_indices; /* array of indices in
output_unit_files
each position corresponding to an output unit. */
size_t *special_unit_file_indices; /* same for special output units */
+ char *title_titlepage;
ELEMENT *simpletitle_tree;
enum command_id simpletitle_cmd;
- JSLICENSE_CATEGORY_LIST jslicenses;
+ ELEMENT *title_tree;
+ char *title_string;
+ char *documentdescription_string;
+ char *copying_comment;
/* state only in C converter */
unsigned long modified_state; /* specifies which perl state to rebuild */
@@ -726,6 +728,7 @@ typedef struct CONVERTER {
TYPE_CONVERSION_FUNCTION *current_types_conversion_function;
COMMAND_CONVERSION_FUNCTION *current_commands_conversion_function;
void (* current_format_protect_text) (const char *text, TEXT *result);
+ int added_title_tree;
/* state common with perl converter */
int document_global_context;
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index d850510f40..60d9fbecf4 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -31,8 +31,8 @@
#
# The following information is directly determined from the
# input file name as binary strings
-# ->{'info'}->{'input_file_name'}
-# ->{'info'}->{'input_directory'}
+# ->{'global_info'}->{'input_file_name'}
+# ->{'global_info'}->{'input_directory'}
package Texinfo::Parser;
@@ -224,11 +224,11 @@ sub _get_parser_info($$;$$) {
clear_document_errors($document_descriptor);
# additional info relevant in perl only.
- $document->{'info'}->{'input_perl_encoding'} = 'utf-8';
+ $document->{'global_info'}->{'input_perl_encoding'} = 'utf-8';
my $perl_encoding
= Texinfo::Common::get_perl_encoding($document->{'commands_info'},
$registrar, $configuration_information);
- $document->{'info'}->{'input_perl_encoding'} = $perl_encoding
+ $document->{'global_info'}->{'input_perl_encoding'} = $perl_encoding
if (defined($perl_encoding));
return $document;
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 8f70399fb5..8e8e9352e8 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -983,7 +983,7 @@ sub test($$)
# $test_input_file_name is already bytes?
# FIXME it is incorrect to do that outside of an API. It is actually
# more to set the output file, so maybe it should be done differently.
- $document->{'info'}->{'input_file_name'} = $test_input_file_name;
+ $document->{'global_info'}->{'input_file_name'} = $test_input_file_name;
}
} else {
print STDERR " TEST $test_name ($test_file)\n" if ($self->{'DEBUG'});