texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Patrice Dumas
Date: Sun, 25 Feb 2024 09:29:21 -0500 (EST)

branch: master
commit 1a96086a77d86f63be847ca30b399c96f24aba08
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Feb 25 15:25:26 2024 +0100

    * tp/Texinfo/Convert/Utils.pm (find_innermost_accent_contents),
    tp/Texinfo/XS/main/convert_utils.c (find_innermost_accent_contents):
    take everything and do not nest if current accent command is
    tieaccent.
    
    * tp/Texinfo/XS/convert/convert_html.c (css_string_accent): call
    text_init early and once.  Fixes in tieaccent code.
    
    * tp/Makefile.tres, tp/t/html_tests.t (itemize_tieaccent): add test of
    tieaccent in itemize argument.
---
 ChangeLog                                       | 13 +++++++++++++
 tp/Makefile.tres                                |  2 ++
 tp/Texinfo/Convert/Utils.pm                     |  5 ++++-
 tp/Texinfo/XS/convert/convert_html.c            | 26 +++++++++++++++----------
 tp/Texinfo/XS/main/convert_utils.c              |  5 ++++-
 tp/t/html_tests.t                               | 26 +++++++++++++++++++++++++
 tp/t/results/float/float_type_with_tieaccent.pl | 10 +++++-----
 7 files changed, 70 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f736b546aa..eec716b0f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-02-25  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/Utils.pm (find_innermost_accent_contents),
+       tp/Texinfo/XS/main/convert_utils.c (find_innermost_accent_contents):
+       take everything and do not nest if current accent command is
+       tieaccent.
+
+       * tp/Texinfo/XS/convert/convert_html.c (css_string_accent): call
+       text_init early and once.  Fixes in tieaccent code.
+
+       * tp/Makefile.tres, tp/t/html_tests.t (itemize_tieaccent): add test of
+       tieaccent in itemize argument.
+
 2024-02-25  Patrice Dumas  <pertusus@free.fr>
 
        Add const.
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index ca3c72be6b..84a7d39b08 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -671,6 +671,8 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/html_tests/itemize_arguments/res_html \
   t/results/html_tests/itemize_arguments_enable_encoding.pl \
   t/results/html_tests/itemize_arguments_enable_encoding/res_html \
+  t/results/html_tests/itemize_tieaccent.pl \
+  t/results/html_tests/itemize_tieaccent/res_html \
   t/results/html_tests/letter_command_in_index.pl \
   t/results/html_tests/mathjax_with_texinfo.pl \
   t/results/html_tests/mathjax_with_texinfo_enable_encoding.pl \
diff --git a/tp/Texinfo/Convert/Utils.pm b/tp/Texinfo/Convert/Utils.pm
index bae8e916e7..45eeb42c4e 100644
--- a/tp/Texinfo/Convert/Utils.pm
+++ b/tp/Texinfo/Convert/Utils.pm
@@ -239,7 +239,10 @@ sub find_innermost_accent_contents($)
     foreach my $content (@{$arg->{'contents'}}) {
       if (!($content->{'cmdname'} and ($content->{'cmdname'} eq 'c'
                                        or $content->{'cmdname'} eq 
'comment'))) {
-        if ($content->{'cmdname'}
+        # if accent is tieaccent, keep everything and do not try to
+        # nest more
+        if ($current->{'cmdname'} ne 'tieaccent'
+            and $content->{'cmdname'}
             and $Texinfo::Commands::accent_commands{$content->{'cmdname'}}) {
           $current = $content;
           next ACCENT;
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index e423faab32..6c29fa86c7 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -9465,6 +9465,7 @@ css_string_accent (CONVERTER *self, const char *text,
       char *accent_and_diacritic;
       char *normalized_accent_text;
       static TEXT accented_text;
+      text_init (&accented_text);
       if (element->cmd == CM_tieaccent)
         {
           /* tieaccent diacritic is naturally and correctly composed
@@ -9504,8 +9505,8 @@ css_string_accent (CONVERTER *self, const char *text,
                 {
                   const uint8_t *remaining;
                   if (!next)
-                    {
-                      encoded_u8 = utf8_from_string (text);
+                    {/* next_text should be equal to p */
+                      encoded_u8 = utf8_from_string (p);
                       next = encoded_u8;
                     }
                   remaining = u8_next (&second_char, next);
@@ -9518,13 +9519,16 @@ css_string_accent (CONVERTER *self, const char *text,
                          the diacritic */
                     }
                   else
-                    next_text = 0;
+                    {
+                      if (!p)
+                        free (next_text);
+                      next_text = 0;
+                    }
                 }
 
               if (next_text)
                 {
                   /* add the first character or escaped text */
-                  text_init (&accented_text);
                   if (!p)
                     {
                       char *first_char_text;
@@ -9540,7 +9544,7 @@ css_string_accent (CONVERTER *self, const char *text,
                       free (first_char_text);
                     }
                   else
-                    text_append_n (&accented_text, p, p - text_set);
+                    text_append_n (&accented_text, text_set, p - text_set);
 
                   /* add the tie accent */
                   text_printf (&accented_text, "\\%s ",
@@ -9549,18 +9553,20 @@ css_string_accent (CONVERTER *self, const char *text,
                      and everything else after (which is in general invalid
                      but we do not care) */
                   text_append (&accented_text, next_text);
-                  if (!p)
-                    free (next_text);
                 }
             }
           free (encoded_u8);
-          if (next_text)
-            return accented_text.text;
+          if (!p)
+            free (next_text);
+          if (accented_text.end > 0)
+            {
+              free (text_set);
+              return accented_text.text;
+            }
         }
 
       /* case of text and diacritic (including fallback for invalid tie
          accent) */
-      text_init (&accented_text);
       /* check if the normalization leads to merging text and diacritic,
          if yes use the merged character, if not output text and diacitic
          to be set up for composition */
diff --git a/tp/Texinfo/XS/main/convert_utils.c 
b/tp/Texinfo/XS/main/convert_utils.c
index 822097728c..cebe172625 100644
--- a/tp/Texinfo/XS/main/convert_utils.c
+++ b/tp/Texinfo/XS/main/convert_utils.c
@@ -149,7 +149,10 @@ find_innermost_accent_contents (const ELEMENT *element)
           if (!(content_data_cmd && (content_data_cmd == CM_c
                                      || content_data_cmd == CM_comment)))
             {
-              if (content_data_cmd && content_flags & CF_accent)
+         /* if accent is tieaccent, keep everything and do not try to
+            nest more */
+              if (current->cmd != CM_tieaccent
+                  && content_data_cmd && content_flags & CF_accent)
                 {
                   current = content;
                   if (argument)
diff --git a/tp/t/html_tests.t b/tp/t/html_tests.t
index bb7199d31e..4160f6f968 100644
--- a/tp/t/html_tests.t
+++ b/tp/t/html_tests.t
@@ -1184,6 +1184,32 @@ $itemize_arguments_text
 $itemize_arguments_text
 , {'ENABLE_ENCODING' => 1}, {'OUTPUT_CHARACTERS' => 1}
 ],
+['itemize_tieaccent',
+'@itemize @tieaccent{ab}
+@item item @tieaccent{ab}
+@end itemize
+
+@itemize @tieaccent{@aa{}@^e}
+@item item @tieaccent{@aa{}@^e}
+@end itemize
+
+@itemize @tieaccent{@aa{}d}
+@item item @tieaccent{@aa{}d}
+@end itemize
+
+@itemize @tieaccent{x@^e}
+@item item @tieaccent{x@^e}
+@end itemize
+
+@itemize @tieaccent{g}
+@item item @tieaccent{g}
+@end itemize
+
+@itemize @tieaccent{@^e}
+@item item @tieaccent{@^e}
+@end itemize
+',
+],
 ['check_htmlxref_no_use_nodes',
 $check_htmlxref_text
 , {}, {'CHECK_HTMLXREF' => 1, 'USE_NODES', 0}],
diff --git a/tp/t/results/float/float_type_with_tieaccent.pl 
b/tp/t/results/float/float_type_with_tieaccent.pl
index 9a89a8521b..f920c5e170 100644
--- a/tp/t/results/float/float_type_with_tieaccent.pl
+++ b/tp/t/results/float/float_type_with_tieaccent.pl
@@ -286,7 +286,7 @@ inside
 ';
 
 
-$result_texts{'float_type_with_tieaccent'} = 'A 1a[ 第H[ e^[, label
+$result_texts{'float_type_with_tieaccent'} = 'A 1a[ 第H[ e^一 and text[, label
 inside
 
 ';
@@ -311,11 +311,11 @@ $result_floats{'float_type_with_tieaccent'} = {
 
 $result_converted{'plaintext'}->{'float_type_with_tieaccent'} = 'inside
 
-A 1͡a 第͡H ê͡ 1
+A 1͡a 第͡H ê͡一 and text 1
 
 * Menu:
 
-* A 1͡a 第͡H ê͡ 1: label.                   
+* A 1͡a 第͡H ê͡一 and text 1: label.        
 
 ';
 
@@ -340,9 +340,9 @@ $result_converted{'html'}->{'float_type_with_tieaccent'} = 
'<!DOCTYPE html>
 <body lang="en">
 <div class="float" id="label">
 <p>inside
-</p><div class="type-number-float"><p><strong class="strong">A 1&#865;a 
第&#865;H &ecirc;&#865; 1</strong></p></div></div>
+</p><div class="type-number-float"><p><strong class="strong">A 1&#865;a 
第&#865;H &ecirc;&#865;一 and text 1</strong></p></div></div>
 <dl class="listoffloats">
-<dt><a href="#label">A 1&#865;a 第&#865;H &ecirc;&#865; 1</a></dt><dd></dd>
+<dt><a href="#label">A 1&#865;a 第&#865;H &ecirc;&#865;一 and text 
1</a></dt><dd></dd>
 </dl>
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]