[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/HTML.pm (_default_format_nod
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/HTML.pm (_default_format_node_redirection_page): convert the body before the header in case there is CSS to be collected. Add filename argument. |
Date: |
Fri, 05 Jan 2024 16:46:47 -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 ac90b8dea5 * tp/Texinfo/Convert/HTML.pm
(_default_format_node_redirection_page): convert the body before the header in
case there is CSS to be collected. Add filename argument.
ac90b8dea5 is described below
commit ac90b8dea5d3d3abcc323dac935c810830d3cee7
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Jan 5 22:46:41 2024 +0100
* tp/Texinfo/Convert/HTML.pm (_default_format_node_redirection_page):
convert the body before the header in case there is CSS to be
collected. Add filename argument.
* tp/Texinfo/XS/convert/call_html_perl_function.c
(call_formatting_function_format_node_redirection_page): add.
* tp/Texinfo/XS/convert/convert_html.c (add_new_css_page)
(collect_css_element_class, html_get_css_elements_classes)
(html_set_pages_files, setup_output_simple_page)
(html_reset_converter), tp/Texinfo/XS/main/converter_types.h
(PAGES_CSS_LIST): add the possibility to add more files to
self->page_css in addition to output files. Use page_name for those
file names, otherwise it is 0 for output units found with their
number/index. Only use the latest added file, under the assumption
that each file not associated to output units are processed
sequentially.
* tp/Texinfo/Convert/HTML.pm (%XS_conversion_overrides)
(_prepare_node_redirection_page, output),
tp/Texinfo/XS/convert/ConvertXS.xs
(html_prepare_node_redirection_page),
tp/Texinfo/XS/convert/convert_html.c
(html_prepare_node_redirection_page, format_node_redirection_page):
setup a function to be overriden and an override wrapping setting the
current file and calling format_node_redirection_page.
* tp/Texinfo/XS/convert/convert_html.c
(html_default_format_node_redirection_page,
format_node_redirection_page): implement in C.
* tp/Makefile.am (test_files), tp/Makefile.tres, tp/t/html_tests.t
(css_in_node_redirection_page),
tp/t/init/css_in_node_redirection_page.pm: test CSS in node
redirection file.
---
ChangeLog | 38 ++++
tp/Makefile.am | 1 +
tp/Makefile.tres | 3 +
tp/Texinfo/Convert/HTML.pm | 48 ++++-
tp/Texinfo/XS/convert/ConvertXS.xs | 29 ++-
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 | 233 +++++++++++++++++++--
tp/Texinfo/XS/convert/convert_html.h | 7 +-
tp/Texinfo/XS/main/converter_types.h | 4 +-
tp/t/html_tests.t | 7 +
tp/t/init/css_in_node_redirection_page.pm | 30 +++
.../html_tests/css_in_node_redirection_page.pl | 201 ++++++++++++++++++
.../res_html/index.html | 36 ++++
.../res_html/spot.html} | 15 +-
.../res_html/Chapter-2.html | 4 +-
.../res_html/index.html | 4 +-
17 files changed, 686 insertions(+), 38 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 51985042a9..b83dd63d7e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,41 @@
+2024-01-05 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (_default_format_node_redirection_page):
+ convert the body before the header in case there is CSS to be
+ collected. Add filename argument.
+
+ * tp/Texinfo/XS/convert/call_html_perl_function.c
+ (call_formatting_function_format_node_redirection_page): add.
+
+ * tp/Texinfo/XS/convert/convert_html.c (add_new_css_page)
+ (collect_css_element_class, html_get_css_elements_classes)
+ (html_set_pages_files, setup_output_simple_page)
+ (html_reset_converter), tp/Texinfo/XS/main/converter_types.h
+ (PAGES_CSS_LIST): add the possibility to add more files to
+ self->page_css in addition to output files. Use page_name for those
+ file names, otherwise it is 0 for output units found with their
+ number/index. Only use the latest added file, under the assumption
+ that each file not associated to output units are processed
+ sequentially.
+
+ * tp/Texinfo/Convert/HTML.pm (%XS_conversion_overrides)
+ (_prepare_node_redirection_page, output),
+ tp/Texinfo/XS/convert/ConvertXS.xs
+ (html_prepare_node_redirection_page),
+ tp/Texinfo/XS/convert/convert_html.c
+ (html_prepare_node_redirection_page, format_node_redirection_page):
+ setup a function to be overriden and an override wrapping setting the
+ current file and calling format_node_redirection_page.
+
+ * tp/Texinfo/XS/convert/convert_html.c
+ (html_default_format_node_redirection_page,
+ format_node_redirection_page): implement in C.
+
+ * tp/Makefile.am (test_files), tp/Makefile.tres, tp/t/html_tests.t
+ (css_in_node_redirection_page),
+ tp/t/init/css_in_node_redirection_page.pm: test CSS in node
+ redirection file.
+
2024-01-05 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/convert_html.c (convert_printindex_command):
diff --git a/tp/Makefile.am b/tp/Makefile.am
index bd0417e8a4..eb1114906e 100644
--- a/tp/Makefile.am
+++ b/tp/Makefile.am
@@ -173,6 +173,7 @@ test_files = \
t/include/section_file_no_node.texi \
t/include/section_file_no_node_include.texi \
t/init/command_translation_modified.init \
+ t/init/css_in_node_redirection_page.pm \
t/init/cvs.init \
t/init/icons.init \
t/init/ignore_and_comments_output.init \
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index d46f256d9c..793e82fc7b 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -33,6 +33,7 @@ test_tap_files_generated_list = \
t/accents.t \
t/automatic_menus.t \
t/automatic_nodes.t \
+ t/convert_to_text.t \
t/converters_tests.t \
t/do_master_menu.t \
t/docbook_tests.t \
@@ -569,6 +570,8 @@ test_files_generated_list =
$(test_tap_files_generated_list) \
t/results/html_tests/contents_in_middle_section_inline/res_html \
t/results/html_tests/contents_in_middle_section_separate_element.pl \
t/results/html_tests/contents_in_middle_section_separate_element/res_html \
+ t/results/html_tests/css_in_node_redirection_page.pl \
+ t/results/html_tests/css_in_node_redirection_page/res_html \
t/results/html_tests/deftypefnnewline_for_copying_after.pl \
t/results/html_tests/deftypefnnewline_for_copying_before.pl \
t/results/html_tests/documentdescription.pl \
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 5e5f275f54..c73c1171b7 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -274,6 +274,8 @@ my %XS_conversion_overrides = (
=> "Texinfo::Convert::ConvertXS::html_convert_output",
#"Texinfo::Convert::HTML::_XS_html_convert_tree"
# => "Texinfo::Convert::ConvertXS::html_convert_tree",
+ "Texinfo::Convert::HTML::_prepare_node_redirection_page"
+ => "Texinfo::Convert::ConvertXS::html_prepare_node_redirection_page",
);
# XS initialization independent of customization
@@ -359,9 +361,11 @@ sub _collect_css_element_class($$)
my $self = shift;
my $element_class = shift;
- #if (not defined($self->{'current_filename'})) {
- # cluck "CFND";
+ #if (not $self->{'document_global_context'}
+ # and not defined($self->{'current_filename'})) {
+ # cluck "BUG: $element_class: CSS no current file";
#}
+
if (defined($self->{'css_element_class_styles'}->{$element_class})) {
if ($self->{'document_global_context'}) {
$self->{'document_global_context_css'}->{$element_class} = 1;
@@ -11175,22 +11179,25 @@ $after_body_open";
return $result;
}
-sub _default_format_node_redirection_page($$)
+sub _default_format_node_redirection_page($$;$)
{
my $self = shift;
my $command = shift;
-
- my ($title, $description, $encoding, $date, $css_lines,
- $doctype, $root_html_element_attributes, $bodytext, $copying_comment,
- $after_body_open, $extra_head, $program_and_version,
$program_homepage,
- $program, $generator) = $self->_file_header_information($command);
+ my $filename = shift;
my $name = $self->command_text($command);
- my $href = $self->command_href($command);
+ my $href = $self->command_href($command, $filename);
my $direction = "<a href=\"$href\">$name</a>";
my $string = $self->convert_tree(
$self->gdt('The node you are looking for is at {href}.',
{ 'href' => {'type' => '_converted', 'text' => $direction }}));
+
+ my ($title, $description, $encoding, $date, $css_lines,
+ $doctype, $root_html_element_attributes, $bodytext, $copying_comment,
+ $after_body_open, $extra_head, $program_and_version,
$program_homepage,
+ $program, $generator) = $self->_file_header_information($command,
+ $filename);
+
my $result = "$doctype
<html${root_html_element_attributes}>
<!-- Created by $program_and_version, $program_homepage -->
@@ -12230,6 +12237,23 @@ sub _XS_reset_output_init_conf($)
{
}
+# as a function for XS override
+sub _prepare_node_redirection_page($$$)
+{
+ my $self = shift;
+ my $target_element = shift;
+ my $redirection_filename = shift;
+
+ $self->{'current_filename'} = $redirection_filename;
+
+ my $redirection_page
+ = &{$self->formatting_function('format_node_redirection_page')}($self,
+ $target_element, $redirection_filename);
+ $self->{'current_filename'} = undef;
+
+ return $redirection_page;
+}
+
# Main function for outputting a manual in HTML.
# $SELF is the output converter object of class Texinfo::Convert::HTML (this
# module), and $DOCUMENT is the parsed document from the parser and structuring
@@ -12605,9 +12629,11 @@ sub output($$)
'file_info_element' => $target_element,
'file_info_path' => undef,
'file_info_label_element' => $label_element};
+
my $redirection_page
- =
&{$self->formatting_function('format_node_redirection_page')}($self,
-
$target_element);
+ = _prepare_node_redirection_page ($self, $target_element,
+ $redirection_filename);
+
my $out_filename;
if ($destination_directory ne '') {
$out_filename = File::Spec->catfile($destination_directory,
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 3adbbf25c3..66fdb52a84 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -924,7 +924,7 @@ SV *
html_command_filename (SV *converter_in, SV *element_sv)
PREINIT:
CONVERTER *self;
- char *filename = 0;
+ const char *filename = 0;
ELEMENT *element;
CODE:
element = element_converter_from_sv (converter_in, element_sv,
@@ -1988,3 +1988,30 @@ html_convert_output (SV *converter_in, SV *tree_in, SV
*output_units_in, SV *spe
RETVAL = newSV (0);
OUTPUT:
RETVAL
+
+SV *
+html_prepare_node_redirection_page (SV *converter_in, SV *element_sv,
redirection_filename)
+ char *redirection_filename = (char *)SvPVutf8_nolen($arg);
+ PREINIT:
+ CONVERTER *self;
+ char *redirection_page = 0;
+ ELEMENT *element;
+ CODE:
+ element = element_converter_from_sv (converter_in, element_sv,
+ "html_prepare_node_redirection_page", &self);
+ if (element)
+ redirection_page
+ = html_prepare_node_redirection_page (self, element,
+ redirection_filename);
+
+ if (redirection_page)
+ {
+ RETVAL = newSVpv_utf8 (redirection_page, 0);
+ free (redirection_page);
+ }
+ else
+ RETVAL = newSV (0);
+ OUTPUT:
+ RETVAL
+
+
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.c
b/tp/Texinfo/XS/convert/call_html_perl_function.c
index 9161837549..cb614fc924 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.c
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.c
@@ -1685,7 +1685,7 @@ call_formatting_function_format_contents (CONVERTER *self,
PUSHs(sv_2mortal (newRV_inc (self->hv)));
PUSHs(sv_2mortal (newSVpv (cmdname, 0)));
PUSHs(sv_2mortal (command_sv));
- PUSHs(sv_2mortal (newSVpv (filename, 0)));
+ PUSHs(sv_2mortal (newSVpv_utf8 (filename, 0)));
PUTBACK;
count = call_sv (formatting_reference_sv,
@@ -1896,6 +1896,65 @@ call_formatting_function_format_element_footer
(CONVERTER *self,
return result;
}
+char *
+call_formatting_function_format_node_redirection_page (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const ELEMENT *command, const char *filename)
+{
+ int count;
+ char *result = 0;
+ 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;
+ }
+
+ build_tree_to_build (&self->tree_to_build);
+
+ dSP;
+
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK(SP);
+ EXTEND(SP, 3);
+
+ PUSHs(sv_2mortal (newRV_inc (self->hv)));
+ PUSHs(sv_2mortal (newRV_inc (command->hv)));
+ PUSHs(sv_2mortal (newSVpv_utf8 (filename, 0)));
+ PUTBACK;
+
+ count = call_sv (formatting_reference_sv,
+ G_SCALAR);
+
+ SPAGAIN;
+
+ if (count != 1)
+ croak("format_node_redirection_page should return 1 item\n");
+
+ result_sv = POPs;
+ result_ret = SvPVutf8 (result_sv, len);
+ result = strdup (result_ret);
+
+ PUTBACK;
+
+ FREETMPS;
+ LEAVE;
+
+ return result;
+}
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.h
b/tp/Texinfo/XS/convert/call_html_perl_function.h
index d4922ec67f..098943acd7 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.h
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.h
@@ -125,6 +125,9 @@ char *call_formatting_function_format_element_footer
(CONVERTER *self,
const enum output_unit_type unit_type,
const OUTPUT_UNIT *output_unit,
const char *content, const ELEMENT *command);
+char *call_formatting_function_format_node_redirection_page (CONVERTER *self,
+ const FORMATTING_REFERENCE *formatting_reference,
+ const ELEMENT *command, const char *filename);
void call_types_conversion (CONVERTER *self, const enum element_type type,
const FORMATTING_REFERENCE *formatting_reference,
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index c09f43b802..4353907781 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -901,6 +901,7 @@ find_page_name_number
{
PAGE_NAME_NUMBER *result = 0;
static PAGE_NAME_NUMBER searched_page_name;
+
searched_page_name.page_name = page_name;
if (page_name_number->number == 0)
{
@@ -4206,6 +4207,23 @@ find_css_selector_style
return result;
}
+static void
+add_new_css_page (PAGES_CSS_LIST *css_pages, const char *page_name)
+{
+ CSS_LIST *page_css_list;
+ if (css_pages->space <= css_pages->number)
+ {
+ css_pages->list = realloc (css_pages->list,
+ (css_pages->space += 10) * sizeof (CSS_LIST));
+ }
+
+ page_css_list = &css_pages->list[css_pages->number];
+ memset (page_css_list, 0, sizeof (CSS_LIST));
+ page_css_list->page_name = strdup (page_name);
+
+ css_pages->number++;
+}
+
static void
collect_css_element_class (CONVERTER *self, const char *selector)
{
@@ -4223,6 +4241,36 @@ collect_css_element_class (CONVERTER *self, const char
*selector)
else
{
css_files_index = self->current_filename.file_number;
+ /* files not associated to output units. Only try the
+ last one, as the files should be processed sequentially */
+ if (css_files_index == 0)
+ {
+ if (self->current_filename.filename)
+ {
+ if (self->page_css.number > 1)
+ {
+ CSS_LIST *last_css_page
+ = &self->page_css.list[self->page_css.number -1];
+ if (last_css_page->page_name
+ && !strcmp (self->current_filename.filename,
+ last_css_page->page_name))
+ {
+ css_files_index = self->page_css.number -1;
+ }
+ }
+ if (css_files_index == 0)
+ {
+ add_new_css_page (&self->page_css,
+ self->current_filename.filename);
+ css_files_index = self->page_css.number -1;
+ }
+ }
+ }
+ if (css_files_index == 0)
+ {
+ fprintf (stderr, "BUG: %s: CSS no current file\n", selector);
+ return;
+ }
}
page_css_list = &self->page_css.list[css_files_index];
for (i = 0; i < page_css_list->number; i++)
@@ -4270,17 +4318,43 @@ html_get_css_elements_classes (CONVERTER *self, const
char *filename)
page_number = find_page_name_number (&self->page_name_number,
filename);
if (!page_number)
- fatal ("Could not find page number of file name");
-
- css_list = &self->page_css.list[page_number];
- if (css_list->number)
{
- /* +1 for 'span:hover a.copiable-link' */
- size_t space = css_list->number + global_context_css_list->number +1;
- selectors = (const char **) malloc (sizeof (char *) * space);
- memcpy (selectors, css_list->list,
- css_list->number * sizeof (char *));
- selector_nr = css_list->number;
+ if (self->page_css.number > 1)
+ {
+ CSS_LIST *last_css_page
+ = &self->page_css.list[self->page_css.number -1];
+ if (last_css_page->page_name
+ && !strcmp (filename, last_css_page->page_name))
+ {
+ page_number = self->page_css.number -1;
+ }
+ }
+ if (!page_number)
+ {
+ /* this happens legitimately in case of an output file not
+ associated to an output unit and not having registered
+ any CSS selector */
+ char *msg;
+ xasprintf (&msg, "%s: get CSS could not find page number",
+ filename);
+ if (self->conf->DEBUG.integer > 0)
+ fprintf (stderr, "XS|css: %s\n", msg);
+ free (msg);
+ }
+ }
+ if (page_number)
+ {
+ css_list = &self->page_css.list[page_number];
+ if (css_list->number)
+ {
+ /* +1 for 'span:hover a.copiable-link' */
+ size_t space
+ = css_list->number + global_context_css_list->number +1;
+ selectors = (const char **) malloc (sizeof (char *) * space);
+ memcpy (selectors, css_list->list,
+ css_list->number * sizeof (char *));
+ selector_nr = css_list->number;
+ }
}
}
@@ -5474,8 +5548,9 @@ html_set_pages_files (CONVERTER *self, OUTPUT_UNIT_LIST
*output_units,
/* 0 is for document_global_context_css, the remaining indices
for the output unit files */
self->page_css.number = self->output_unit_files.number +1;
+ self->page_css.space = self->page_css.number;
self->page_css.list = (CSS_LIST *)
- malloc (self->page_css.number * sizeof (CSS_LIST));
+ malloc (self->page_css.space * sizeof (CSS_LIST));
memset (self->page_css.list, 0,
self->page_css.number * sizeof (CSS_LIST));
@@ -5495,8 +5570,9 @@ setup_output_simple_page (CONVERTER *self, const char
*output_filename)
{
PAGE_NAME_NUMBER *page_name_number;
self->page_css.number = 1+1;
+ self->page_css.space = self->page_css.number;
self->page_css.list = (CSS_LIST *)
- malloc (self->page_css.number * sizeof (CSS_LIST));
+ malloc (self->page_css.space * sizeof (CSS_LIST));
memset (self->page_css.list, 0,
self->page_css.number * sizeof (CSS_LIST));
@@ -6570,7 +6646,7 @@ static char *root_html_element_attributes_string
(CONVERTER *self)
redirection file headers. $COMMAND is the tree element for
a @node that is being output in the file. */
static BEGIN_FILE_INFORMATION *
-file_header_information (CONVERTER *self, ELEMENT *command,
+file_header_information (CONVERTER *self, const ELEMENT *command,
const char *filename)
{
BEGIN_FILE_INFORMATION *begin_info = (BEGIN_FILE_INFORMATION *)
@@ -7858,6 +7934,133 @@ format_element_footer (CONVERTER *self,
}
}
+char *
+html_default_format_node_redirection_page (CONVERTER *self,
+ const ELEMENT *element,
+ const char *filename)
+{
+ TEXT result;
+ TEXT body;
+ BEGIN_FILE_INFORMATION *begin_info;
+ char *href = html_command_href (self, element, filename, 0, 0);
+ char *name = html_command_text (self, element, 0);
+ ELEMENT *direction_element = new_element (ET__converted);
+ NAMED_STRING_ELEMENT_LIST *substrings = new_named_string_element_list ();
+
+ text_printf (&direction_element->text, "<a href=\"%s\">%s</a>", href, name);
+ free (name);
+
+ add_element_to_named_string_element_list (substrings,
+ "href", direction_element);
+
+ /* do it before in case there is CSS */
+
+ text_init (&body);
+ translate_convert_to_html_internal (
+ "The node you are looking for is at {href}.", self->document,
+ self, substrings, 0, 0, &body, 0);
+
+ begin_info = file_header_information (self, element, filename);
+
+ text_init (&result);
+
+ text_append (&result, self->conf->DOCTYPE.string);
+ text_append_n (&result, "\n", 1);
+ text_printf (&result, "<html%s>\n",
begin_info->root_html_element_attributes);
+ text_printf (&result, "<!-- Created by %s, %s -->\n"
+ "<!-- This file redirects to the location of a node or anchor -->\n"
+ "<head>\n",
+ self->conf->PACKAGE_AND_VERSION_OPTION.string,
+ self->conf->PACKAGE_URL_OPTION.string);
+ if (begin_info->encoding)
+ text_append (&result, begin_info->encoding);
+ text_append_n (&result, "\n", 1);
+ if (self->copying_comment)
+ text_append (&result, self->copying_comment);
+ text_printf (&result, "<title>%s</title>\n\n", begin_info->title);
+ if (begin_info->description)
+ text_append (&result, begin_info->description);
+ text_append_n (&result, "\n", 1);
+ text_printf (&result, "<meta name=\"keywords\" content=\"%s\"",
+ begin_info->title);
+ close_html_lone_element (self, &result);
+ text_append_n (&result, "\n", 1);
+ text_append (&result, "<meta name=\"resource-type\" content=\"document\"");
+ close_html_lone_element (self, &result);
+ text_append_n (&result, "\n", 1);
+ text_append (&result, "<meta name=\"distribution\" content=\"global\"");
+ close_html_lone_element (self, &result);
+ text_append_n (&result, "\n", 1);
+ if (begin_info->generator)
+ text_append (&result, begin_info->generator);
+ if (self->date_in_header)
+ text_append (&result, self->date_in_header);
+ text_append (&result, begin_info->css_lines);
+ text_append_n (&result, "\n", 1);
+ text_printf (&result, "<meta http-equiv=\"Refresh\" content=\"0; url=%s\"",
+ href);
+ close_html_lone_element (self, &result);
+ text_append_n (&result, "\n", 1);
+ text_append (&result,
+ "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"");
+ close_html_lone_element (self, &result);
+ text_append_n (&result, "\n", 1);
+
+ if (begin_info->extra_head)
+ text_append (&result, begin_info->extra_head);
+ text_append_n (&result, "\n</head>\n\n", 10);
+ text_printf (&result, "<body %s>\n", begin_info->bodytext);
+ if (self->conf->AFTER_BODY_OPEN.string)
+ text_append (&result, self->conf->AFTER_BODY_OPEN.string);
+
+ text_append_n (&result, "\n<p>", 4);
+ text_append (&result, body.text);
+ free (body.text);
+ text_append_n (&result, "</p>\n</body>\n", 13);
+
+ destroy_named_string_element_list (substrings);
+ free (href);
+
+ return result.text;
+}
+
+char *format_node_redirection_page (CONVERTER *self, const ELEMENT *element,
+ const char *filename)
+{
+ FORMATTING_REFERENCE *formatting_reference
+ = &self->current_formatting_references[FR_format_node_redirection_page];
+
+ if (formatting_reference->status == FRS_status_default_set)
+ {
+ return html_default_format_node_redirection_page (self, element,
+ filename);
+ }
+ else
+ {
+ return call_formatting_function_format_node_redirection_page (self,
+ formatting_reference,
+ element, filename);
+ }
+}
+
+char *
+html_prepare_node_redirection_page (CONVERTER *self, const ELEMENT *element,
+ const char *filename)
+{
+ char *result;
+
+ self->current_filename.filename = filename;
+ self->current_filename.file_number = 0;
+ self->modified_state |= HMSF_current_filename;
+
+ result = format_node_redirection_page (self, element, filename);
+
+ self->current_filename.filename = 0;
+ self->modified_state |= HMSF_current_filename;
+
+ return result;
+}
+
static void
text_element_conversion (CONVERTER *self,
const HTML_COMMAND_CONVERSION *specification,
@@ -15877,6 +16080,7 @@ html_reset_converter (CONVERTER *self)
for (j = 0; j < page_css_list->number; j++)
free (page_css_list->list[j]);
free (page_css_list->list);
+ free (page_css_list->page_name);
}
free (self->page_css.list);
@@ -17533,7 +17737,8 @@ convert_output_output_unit_internal (CONVERTER *self,
void
html_prepare_title_titlepage (CONVERTER *self, int output_units_descriptor,
- char *output_file, char *output_filename)
+ const char *output_file,
+ const char *output_filename)
{
OUTPUT_UNIT_LIST *output_units
= retrieve_output_units (output_units_descriptor);
diff --git a/tp/Texinfo/XS/convert/convert_html.h
b/tp/Texinfo/XS/convert/convert_html.h
index 4e7174d2a5..82cdc81329 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -183,7 +183,8 @@ 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);
+ const char *output_file,
+ const char *output_filename);
char *html_convert_convert (CONVERTER *self, const ELEMENT *root,
int output_units_descriptor,
@@ -197,6 +198,10 @@ char *html_convert_output (CONVERTER *self, const ELEMENT
*root,
char *output_file, char *destination_directory,
char *output_filename, char *document_name);
+char *html_prepare_node_redirection_page (CONVERTER *self,
+ const ELEMENT *element,
+ const char *filename);
+
void html_check_transfer_state_finalization (CONVERTER *self);
void html_free_converter (CONVERTER *self);
void html_reset_converter (CONVERTER *self);
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index 443dcc9095..fe75adc168 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -266,7 +266,7 @@ typedef struct ELEMENT_REFERENCE_STACK {
typedef struct FILE_NUMBER_NAME {
size_t file_number;
- char *filename;
+ const char *filename;
} FILE_NUMBER_NAME;
typedef struct VARIETY_DIRECTION_INDEX {
@@ -387,6 +387,7 @@ typedef struct PAGE_NAME_NUMBER_LIST {
} PAGE_NAME_NUMBER_LIST;
typedef struct CSS_LIST {
+ /* 0 if associated to output units and found by number */
char *page_name;
size_t number;
size_t space;
@@ -395,6 +396,7 @@ typedef struct CSS_LIST {
typedef struct PAGES_CSS_LIST {
size_t number;
+ size_t space;
CSS_LIST *list; /* index 0 is for document_global_context_css
others for the output files */
} PAGES_CSS_LIST;
diff --git a/tp/t/html_tests.t b/tp/t/html_tests.t
index a817495741..599ca0e823 100644
--- a/tp/t/html_tests.t
+++ b/tp/t/html_tests.t
@@ -1274,6 +1274,13 @@ $mathjax_with_texinfo,
{'HTML_MATH' => 'mathjax'}],
['info_js_dir_html_file',
$info_js_dir_test, {}, {'INFO_JS_DIR' => 'js'}],
+['css_in_node_redirection_page',
+'@node Top
+@top top
+
+@sansserif{SANS}.
+@anchor{spot}
+', {'init_files' => ['css_in_node_redirection_page.pm']}],
);
diff --git a/tp/t/init/css_in_node_redirection_page.pm
b/tp/t/init/css_in_node_redirection_page.pm
new file mode 100644
index 0000000000..3a21204a9f
--- /dev/null
+++ b/tp/t/init/css_in_node_redirection_page.pm
@@ -0,0 +1,30 @@
+
+use utf8;
+
+package Texinfo::Config;
+
+use strict;
+
+my %translations = (
+ 'en' => { "The node you are looking for is at {href}."
+ => {'' => "The \@sansserif{node} you are looking for is at {href}."}
+ }
+);
+
+sub
_texi2any_tests_css_in_node_redirection_page_format_translate_message($$$;$)
+{
+ my ($self, $string, $lang, $translation_context) = @_;
+ $translation_context = '' if (!defined($translation_context));
+ if (exists($translations{$lang})
+ and exists($translations{$lang}->{$string})
+ and exists($translations{$lang}->{$string}->{$translation_context})) {
+ my $translation = $translations{$lang}->{$string}->{$translation_context};
+ return $translation;
+ }
+ return undef;
+}
+
+texinfo_register_formatting_function('format_translate_message',
+ \&_texi2any_tests_css_in_node_redirection_page_format_translate_message);
+
+1;
diff --git a/tp/t/results/html_tests/css_in_node_redirection_page.pl
b/tp/t/results/html_tests/css_in_node_redirection_page.pl
new file mode 100644
index 0000000000..8333e680e9
--- /dev/null
+++ b/tp/t/results/html_tests/css_in_node_redirection_page.pl
@@ -0,0 +1,201 @@
+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{'css_in_node_redirection_page'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'type' => 'preamble_before_content'
+ }
+ ],
+ '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' => {
+ 'line_nr' => 1
+ }
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'top'
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'top',
+ 'contents' => [
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'SANS'
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => 'sansserif',
+ 'source_info' => {
+ 'line_nr' => 4
+ }
+ },
+ {
+ 'text' => '.
+'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'spot'
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => 'anchor',
+ 'extra' => {
+ 'is_target' => 1,
+ 'normalized' => 'spot'
+ },
+ 'source_info' => {
+ 'line_nr' => 5
+ }
+ },
+ {
+ 'text' => '
+',
+ 'type' => 'spaces_after_close_brace'
+ }
+ ],
+ 'type' => 'paragraph'
+ }
+ ],
+ 'extra' => {},
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'line_nr' => 2
+ }
+ }
+ ],
+ 'type' => 'document_root'
+};
+
+$result_texis{'css_in_node_redirection_page'} = '@node Top
+@top top
+
+@sansserif{SANS}.
+@anchor{spot}
+';
+
+
+$result_texts{'css_in_node_redirection_page'} = 'top
+***
+
+SANS.
+';
+
+$result_sectioning{'css_in_node_redirection_page'} = {
+ 'extra' => {
+ 'section_childs' => [
+ {
+ 'cmdname' => 'top',
+ 'extra' => {
+ 'associated_node' => {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'normalized' => 'Top'
+ }
+ },
+ 'section_level' => 0,
+ 'sectioning_root' => {}
+ }
+ }
+ ],
+ 'section_level' => -1
+ }
+};
+$result_sectioning{'css_in_node_redirection_page'}{'extra'}{'section_childs'}[0]{'extra'}{'sectioning_root'}
= $result_sectioning{'css_in_node_redirection_page'};
+
+$result_nodes{'css_in_node_redirection_page'} = [
+ {
+ 'cmdname' => 'node',
+ 'extra' => {
+ 'associated_section' => {
+ 'cmdname' => 'top',
+ 'extra' => {}
+ },
+ 'normalized' => 'Top'
+ }
+ }
+];
+
+$result_menus{'css_in_node_redirection_page'} = [
+ {
+ 'extra' => {
+ 'normalized' => 'Top'
+ }
+ }
+];
+
+$result_errors{'css_in_node_redirection_page'} = [];
+
+
+$result_floats{'css_in_node_redirection_page'} = {};
+
+
+1;
diff --git
a/tp/t/results/html_tests/css_in_node_redirection_page/res_html/index.html
b/tp/t/results/html_tests/css_in_node_redirection_page/res_html/index.html
new file mode 100644
index 0000000000..87679e1ae2
--- /dev/null
+++ b/tp/t/results/html_tests/css_in_node_redirection_page/res_html/index.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>Top (top)</title>
+
+<meta name="description" content="Top (top)">
+<meta name="keywords" content="Top (top)">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+
+<link href="#Top" rel="start" title="Top">
+<style type="text/css">
+<!--
+a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
+span.sansserif {font-family: sans-serif; font-weight: normal}
+span:hover a.copiable-link {visibility: visible}
+-->
+</style>
+
+
+</head>
+
+<body lang="en">
+<div class="top-level-extent" id="Top">
+<h1 class="top" id="top"><span>top<a class="copiable-link" href="#top">
¶</a></span></h1>
+
+<p><span class="sansserif">SANS</span>.
+<a class="anchor" id="spot"></a></p></div>
+
+
+
+</body>
+</html>
diff --git
a/tp/t/results/html_tests/file_name_conflict_with_user_defined/res_html/Chapter-2.html
b/tp/t/results/html_tests/css_in_node_redirection_page/res_html/spot.html
similarity index 52%
copy from
tp/t/results/html_tests/file_name_conflict_with_user_defined/res_html/Chapter-2.html
copy to tp/t/results/html_tests/css_in_node_redirection_page/res_html/spot.html
index 475a4199be..ed16bee270 100644
---
a/tp/t/results/html_tests/file_name_conflict_with_user_defined/res_html/Chapter-2.html
+++ b/tp/t/results/html_tests/css_in_node_redirection_page/res_html/spot.html
@@ -4,19 +4,24 @@
<!-- This file redirects to the location of a node or anchor -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-<title>Chapter 2 (top)</title>
+<title>spot (top)</title>
-<meta name="description" content="Chapter 2 (top)">
-<meta name="keywords" content="Chapter 2 (top)">
+<meta name="description" content="spot (top)">
+<meta name="keywords" content="spot (top)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
+<style type="text/css">
+<!--
+span.sansserif {font-family: sans-serif; font-weight: normal}
+-->
+</style>
-<meta http-equiv="Refresh" content="0; url=myanchor.html#Chapter-2">
+<meta http-equiv="Refresh" content="0; url=index.html#spot">
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body lang="en">
-<p>The node you are looking for is at <a
href="myanchor.html#Chapter-2">Chapter 2</a>.</p>
+<p>The <span class="sansserif">node</span> you are looking for is at <a
href="index.html#spot">spot</a>.</p>
</body>
diff --git
a/tp/t/results/html_tests/file_name_conflict_with_user_defined/res_html/Chapter-2.html
b/tp/t/results/html_tests/file_name_conflict_with_user_defined/res_html/Chapter-2.html
index 475a4199be..fa05c2beb5 100644
---
a/tp/t/results/html_tests/file_name_conflict_with_user_defined/res_html/Chapter-2.html
+++
b/tp/t/results/html_tests/file_name_conflict_with_user_defined/res_html/Chapter-2.html
@@ -11,12 +11,12 @@
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
-<meta http-equiv="Refresh" content="0; url=myanchor.html#Chapter-2">
+<meta http-equiv="Refresh" content="0; url=myanchor.html">
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body lang="en">
-<p>The node you are looking for is at <a
href="myanchor.html#Chapter-2">Chapter 2</a>.</p>
+<p>The node you are looking for is at <a href="myanchor.html">Chapter
2</a>.</p>
</body>
diff --git
a/tp/t/results/html_tests/filenameconflictwithnonsplit/res_html/index.html
b/tp/t/results/html_tests/filenameconflictwithnonsplit/res_html/index.html
index e743d7451f..f30fd627b7 100644
--- a/tp/t/results/html_tests/filenameconflictwithnonsplit/res_html/index.html
+++ b/tp/t/results/html_tests/filenameconflictwithnonsplit/res_html/index.html
@@ -11,12 +11,12 @@
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
-<meta http-equiv="Refresh" content="0;
url=filenameconflictwithnonsplit.html#Top">
+<meta http-equiv="Refresh" content="0; url=filenameconflictwithnonsplit.html">
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body lang="en">
-<p>The node you are looking for is at <a
href="filenameconflictwithnonsplit.html#Top">Top</a>.</p>
+<p>The node you are looking for is at <a
href="filenameconflictwithnonsplit.html">Top</a>.</p>
</body>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/HTML.pm (_default_format_node_redirection_page): convert the body before the header in case there is CSS to be collected. Add filename argument.,
Patrice Dumas <=