[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/convert/get_html_perl_info.c (htm
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/convert/get_html_perl_info.c (html_converter_initialize_sv): fix comparison of default reference formatting and customized reference formating to use SvRV. |
Date: |
Sun, 26 Nov 2023 19:07:12 -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 900bc96a18 * tp/Texinfo/XS/convert/get_html_perl_info.c
(html_converter_initialize_sv): fix comparison of default reference formatting
and customized reference formating to use SvRV.
900bc96a18 is described below
commit 900bc96a189f12e9b05490447d71189227ab30be
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Nov 27 01:07:04 2023 +0100
* tp/Texinfo/XS/convert/get_html_perl_info.c
(html_converter_initialize_sv): fix comparison of default reference
formatting and customized reference formating to use SvRV.
* tp/Texinfo/XS/convert/call_html_perl_function.c
(call_formatting_function_format_footnotes_sequence),
tp/Texinfo/XS/convert/convert_html.c
(default_format_footnotes_segment, format_footnotes_segment)
(convert_unit_type, html_convert_convert, html_convert_output): add
call_formatting_function_format_footnotes_sequence, implement
default_format_footnotes_segment in C.
---
ChangeLog | 14 +++
tp/Texinfo/XS/convert/call_html_perl_function.c | 56 +++++++++++
tp/Texinfo/XS/convert/call_html_perl_function.h | 1 +
tp/Texinfo/XS/convert/convert_html.c | 124 +++++++++++++++++++-----
tp/Texinfo/XS/convert/get_html_perl_info.c | 3 +-
5 files changed, 173 insertions(+), 25 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index cf15e2d27d..876794b007 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-11-26 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/get_html_perl_info.c
+ (html_converter_initialize_sv): fix comparison of default reference
+ formatting and customized reference formating to use SvRV.
+
+ * tp/Texinfo/XS/convert/call_html_perl_function.c
+ (call_formatting_function_format_footnotes_sequence),
+ tp/Texinfo/XS/convert/convert_html.c
+ (default_format_footnotes_segment, format_footnotes_segment)
+ (convert_unit_type, html_convert_convert, html_convert_output): add
+ call_formatting_function_format_footnotes_sequence, implement
+ default_format_footnotes_segment in C.
+
2023-11-26 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/convert_html.c (convert_unit_type)
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.c
b/tp/Texinfo/XS/convert/call_html_perl_function.c
index a1f8d1d6f1..229a76dca6 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.c
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.c
@@ -567,6 +567,62 @@ call_formatting_function_format_footnotes_segment
(CONVERTER *self)
return result;
}
+char *
+call_formatting_function_format_footnotes_sequence (CONVERTER *self)
+{
+ 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
+ = self->formatting_references[FR_format_footnotes_sequence].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, 1);
+
+ PUSHs(sv_2mortal (newRV_inc (self->hv)));
+ PUTBACK;
+
+ count = call_sv (formatting_reference_sv,
+ G_SCALAR);
+
+ SPAGAIN;
+
+ if (count != 1)
+ croak("format_footnotes_sequence 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;
+}
+
char *
call_formatting_function_format_end_file (CONVERTER *self, char *filename,
const OUTPUT_UNIT *output_unit)
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.h
b/tp/Texinfo/XS/convert/call_html_perl_function.h
index 5f41bb3535..76c2807c69 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.h
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.h
@@ -39,6 +39,7 @@ FILE_NAME_PATH *call_file_id_setting_unit_file_name
(CONVERTER *self,
char *filename, char *filepath);
char *call_formatting_function_format_title_titlepage (CONVERTER *self);
+char *call_formatting_function_format_footnotes_sequence (CONVERTER *self);
char *call_formatting_function_format_footnotes_segment (CONVERTER *self);
char *call_formatting_function_format_end_file (CONVERTER *self,
char *filename,
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index eec6c8d12d..53f2340d6f 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -3541,6 +3541,103 @@ convert_text (CONVERTER *self, const enum element_type
type,
free (content_used);
}
+void
+default_format_footnotes_segment (CONVERTER *self, TEXT *result)
+{
+ char *class_base;
+ char *attribute_class;
+ char *class;
+ STRING_LIST *classes;
+ ELEMENT *footnote_heading_tree;
+ char *footnote_heading;
+ int level;
+ char *formatted_heading;
+ char *foot_lines = call_formatting_function_format_footnotes_sequence (self);
+
+ if (!foot_lines || !strlen (foot_lines))
+ {
+ free (foot_lines);
+ return;
+ }
+
+ classes = (STRING_LIST *) malloc (sizeof (STRING_LIST));
+ memset (classes, 0, sizeof (STRING_LIST));
+
+ class_base = special_unit_info (self, SUI_type_class,
+ "footnotes");
+ xasprintf (&class, "%s-segment", class_base);
+
+ add_string (class, classes);
+ free (class);
+ attribute_class = html_attribute_class (self, "div", classes);
+ clear_strings_list (classes);
+
+ text_append (result, attribute_class);
+ free (attribute_class);
+
+ text_append_n (result, ">\n", 2);
+
+ if (self->conf->DEFAULT_RULE && strlen (self->conf->DEFAULT_RULE))
+ {
+ text_append (result, self->conf->DEFAULT_RULE);
+ text_append_n (result, "\n", 1);
+ }
+
+ footnote_heading_tree = special_unit_info_tree (self,
+ SUIT_type_heading, "footnotes");
+ if (footnote_heading_tree)
+ {
+ footnote_heading = html_convert_tree (self, footnote_heading_tree,
+ "convert footnotes special heading");
+ }
+ else
+ {
+ footnote_heading = "";
+ }
+
+ level = self->conf->FOOTNOTE_END_HEADER_LEVEL;
+
+ xasprintf (&class, "%s-heading", class_base);
+
+ add_string (class, classes);
+ free (class);
+
+ formatted_heading
+ = call_formatting_function_format_heading_text (self, 0, classes,
+ footnote_heading,
+ level, 0, 0, 0);
+ destroy_strings_list (classes);
+ text_append (result, formatted_heading);
+ text_append_n (result, "\n", 1);
+
+ free (formatted_heading);
+
+ if (footnote_heading_tree)
+ free (footnote_heading);
+
+ text_append (result, foot_lines);
+ text_append (result, "</div>\n");
+}
+
+void
+format_footnotes_segment (CONVERTER *self, TEXT *result)
+{
+ if (self->formatting_references[FR_format_footnotes_segment].status
+ == FRS_status_default_set)
+ {
+ default_format_footnotes_segment (self, result);
+ }
+ else
+ {
+ char *footnotes_segment
+ = call_formatting_function_format_footnotes_segment (self);
+ if (footnotes_segment)
+ {
+ text_append (result, footnotes_segment);
+ free (footnotes_segment);
+ }
+ }
+}
void
convert_table_term_type (CONVERTER *self, const enum element_type type,
@@ -3606,20 +3703,13 @@ void convert_unit_type (CONVERTER *self,
text_append (result, self->title_titlepage);
if (!output_unit->tree_unit_directions[D_next])
{
- char *footnotes_segment;
/* only one unit, use simplified formatting */
if (content)
text_append (result, content);
/* if there is one unit it also means that there is no formatting
of footnotes in a separate unit. And if footnotestyle is end
the footnotes won't be done in format_element_footer either. */
- footnotes_segment
- = call_formatting_function_format_footnotes_segment (self);
- if (footnotes_segment)
- {
- text_append (result, footnotes_segment);
- free (footnotes_segment);
- }
+ format_footnotes_segment (self, result);
if (self->conf->DEFAULT_RULE
&& self->conf->PROGRAM_NAME_IN_FOOTER > 0)
{
@@ -5717,20 +5807,13 @@ html_convert_convert (CONVERTER *self, const ELEMENT
*root,
if (!output_units || !output_units->number)
{
- char *footnotes_segment;
if (self->conf->DEBUG > 0)
fprintf (stderr, "\nC NO UNIT\n");
convert_to_html_internal (self, root, &result,
"convert no unit");
- footnotes_segment
- = call_formatting_function_format_footnotes_segment (self);
- if (footnotes_segment)
- {
- text_append (&result, footnotes_segment);
- free (footnotes_segment);
- }
+ format_footnotes_segment (self, &result);
}
else
{
@@ -6020,20 +6103,13 @@ html_convert_output (CONVERTER *self, const ELEMENT
*root,
}
else
{
- char *footnotes_segment;
if (self->conf->DEBUG > 0)
fprintf (stderr, "\nNO UNIT NO PAGE\n");
text_append (&text, self->title_titlepage);
convert_to_html_internal (self, root, &text,
"no-page output no unit");
- footnotes_segment
- = call_formatting_function_format_footnotes_segment (self);
- if (footnotes_segment)
- {
- text_append (&text, footnotes_segment);
- free (footnotes_segment);
- }
+ format_footnotes_segment (self, &result);
}
/* do end file first, in case it needs some CSS */
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index 398ef5ced7..37e9026004 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -203,7 +203,8 @@ html_converter_initialize_sv (SV *converter_sv,
{
formatting_reference->sv_reference = *formatting_reference_sv;
if (formatting_reference->status != FRS_status_default_set
- || *formatting_reference_sv !=
*default_formatting_reference_sv)
+ || SvRV (*formatting_reference_sv)
+ != SvRV (*default_formatting_reference_sv))
formatting_reference->status = FRS_status_customization_set;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/convert/get_html_perl_info.c (html_converter_initialize_sv): fix comparison of default reference formatting and customized reference formating to use SvRV.,
Patrice Dumas <=