[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sat, 30 Dec 2023 13:57:13 -0500 (EST) |
branch: master
commit fd6346a6728e5adbc9cffc9f6dab5b40aec66665
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Dec 30 19:42:59 2023 +0100
* tp/Texinfo/XS/convert/converter.c (xml_comment): add.
* tp/Texinfo/XS/convert/convert_html.c (html_default_format_comment)
(format_comment): implement format_comment.
---
ChangeLog | 7 +++++++
tp/Texinfo/XS/convert/convert_html.c | 14 ++++++++++++--
tp/Texinfo/XS/convert/converter.c | 33 +++++++++++++++++++++++++++++++++
tp/Texinfo/XS/convert/converter.h | 1 +
4 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 46216baf86..629e29c1f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-12-30 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/converter.c (xml_comment): add.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_default_format_comment)
+ (format_comment): implement format_comment.
+
2023-12-30 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/convert_html.c (convert_U_command)
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 9dd9561a2f..ba9094a71b 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -2450,18 +2450,28 @@ format_protect_text (CONVERTER *self, const char *text,
TEXT *result)
}
}
+char *
+html_default_format_comment (CONVERTER *self, const char *text)
+{
+ char *with_space;
+ char *result;
+
+ xasprintf (&with_space, " %s", text);
+ result = xml_comment (self, with_space);
+ free (with_space);
+ return 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,
diff --git a/tp/Texinfo/XS/convert/converter.c
b/tp/Texinfo/XS/convert/converter.c
index 5d65130a17..eaa64d0b32 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -910,3 +910,36 @@ xml_numeric_entity_accent (enum command_id cmd, const char
*text)
return 0;
}
+/* return to be freed by the caller */
+char *
+xml_comment (CONVERTER *converter, const char *text)
+{
+ const char *p = text;
+
+ TEXT result;
+
+ text_init (&result);
+ text_append_n (&result, "<!--", 4);
+ while (*p)
+ {
+ char *q = strchr (p, '-');
+ if (q)
+ {
+ if (q - p)
+ text_append_n (&result, p, q +1 - p);
+ p = q + 1;
+ p += strspn (p, "-");
+ }
+ else
+ {
+ text_append (&result, p);
+ break;
+ }
+ }
+ if (result.end > 0 && result.text[result.end - 1] == '\n')
+ {
+ result.end--;
+ }
+ text_append_n (&result, " -->\n", 5);
+ return result.text;
+}
diff --git a/tp/Texinfo/XS/convert/converter.h
b/tp/Texinfo/XS/convert/converter.h
index 364a1b052c..79fe02e6e9 100644
--- a/tp/Texinfo/XS/convert/converter.h
+++ b/tp/Texinfo/XS/convert/converter.h
@@ -111,4 +111,5 @@ void free_generic_converter (CONVERTER *self);
void xml_format_text_with_numeric_entities (const char *text, TEXT *result);
char *xml_numeric_entity_accent (enum command_id cmd, const char *text);
+char *xml_comment (CONVERTER *converter, const char *text);
#endif