[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/convert/convert_html.c (convert_e
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/convert/convert_html.c (convert_email_command) (commands_internal_conversion_table): implement in C. |
Date: |
Fri, 22 Dec 2023 12:39:07 -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 1890b43d2c * tp/Texinfo/XS/convert/convert_html.c
(convert_email_command) (commands_internal_conversion_table): implement in C.
1890b43d2c is described below
commit 1890b43d2c4bf1d64c707e21c9e319708c3bffe6
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Dec 22 18:39:03 2023 +0100
* tp/Texinfo/XS/convert/convert_html.c (convert_email_command)
(commands_internal_conversion_table): implement in C.
---
ChangeLog | 5 +++
tp/Texinfo/Convert/HTML.pm | 3 +-
tp/Texinfo/XS/convert/convert_html.c | 65 ++++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index e991832811..828489af5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-12-22 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/convert_html.c (convert_email_command)
+ (commands_internal_conversion_table): implement in C.
+
2023-12-22 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/HTML.pm (_convert_explained_command): remove
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 764c22a4fe..9380307baf 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -3287,7 +3287,8 @@ sub _convert_email_command($$$$)
}
$text = $mail_string unless ($text ne '');
# match a non-space character. Both ascii and non-ascii spaces are
- # considered as spaces.
+ # considered as spaces. When perl 5.18 is the oldest version
+ # supported, it could become [^\s]
return $text unless ($mail =~ /[^\v\h\s]/);
if (in_string($self)) {
return "$mail_string ($text)";
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index f2bf334065..9714cc0c66 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -8157,6 +8157,70 @@ convert_value_command (CONVERTER *self, const enum
command_id cmd,
destroy_named_string_element_list (substrings);
}
+void
+convert_email_command (CONVERTER *self, const enum command_id cmd,
+ const ELEMENT *element,
+ const HTML_ARGS_FORMATTED *args_formatted,
+ const char *content, TEXT *result)
+{
+ char *mail = 0;
+ char *mail_string = 0;
+ char *text = 0;
+
+ if (args_formatted->number > 0)
+ {
+ mail = args_formatted->args[0].formatted[AFT_type_url];
+ mail_string
+ = args_formatted->args[0].formatted[AFT_type_monospacestring];
+ }
+
+ if (args_formatted->number > 1
+ && args_formatted->args[1].formatted[AFT_type_normal])
+ {
+ text = args_formatted->args[1].formatted[AFT_type_normal];
+ }
+
+ if (!text || !strlen (text))
+ {
+ text = mail_string;
+ }
+
+ /* FIXME match unicode spaces in perl */
+ if (!mail || mail[strspn (mail, whitespace_chars)] == '\0')
+ {
+ if (text)
+ text_append (result, text);
+ return;
+ }
+
+ if (html_in_string (self))
+ {
+ text_printf (result, "%s (%s)", mail_string, text);
+ }
+ else
+ {
+ char *attribute_class;
+ char *protected_mailto;
+ char *mailto;
+ STRING_LIST *classes;
+ classes = (STRING_LIST *) malloc (sizeof (STRING_LIST));
+ memset (classes, 0, sizeof (STRING_LIST));
+ add_string (builtin_command_name (cmd), classes);
+
+ attribute_class = html_attribute_class (self, "a", classes);
+ destroy_strings_list (classes);
+ text_append (result, attribute_class);
+ free (attribute_class);
+
+ xasprintf (&mailto, "mailto:%s", mail);
+ protected_mailto = url_protect_url_text (self, mailto);
+ free (mailto);
+
+ text_printf (result, " href=\"%s\">%s</a>", protected_mailto, text);
+ free (protected_mailto);
+ }
+}
+
void
convert_indicateurl_command (CONVERTER *self, const enum command_id cmd,
const ELEMENT *element,
@@ -9645,6 +9709,7 @@ static COMMAND_INTERNAL_CONVERSION
commands_internal_conversion_table[] = {
{CM_w, &convert_w_command},
{CM_today, &convert_today_command},
{CM_value, &convert_value_command},
+ {CM_email, &convert_email_command},
/* note that if indicateurl had been in self->style_formatted_cmd this
would have prevented indicateurl to be associated to
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/convert/convert_html.c (convert_email_command) (commands_internal_conversion_table): implement in C.,
Patrice Dumas <=