]> Savannah Git Hosting - gnulib.git/commitdiff
unilbrk: Restore deviation for (IS,AL) pair.
authorBruno Haible <bruno@clisp.org>
Tue, 28 Dec 2021 23:06:00 +0000 (00:06 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 28 Dec 2021 23:06:00 +0000 (00:06 +0100)
* lib/gen-uni-tables.c (output_lbrk_rules_as_tables): Disable rule LB29.
* lib/unilbrk/lbrktables.c: Regenerated.
* tests/unilbrk/test-u8-possible-linebreaks.c (main): Add test case with
HTML markup.
* tests/unilbrk/test-u16-possible-linebreaks.c (main): Likewise.
* tests/unilbrk/test-u32-possible-linebreaks.c (main): Likewise.
* tests/unilbrk/test-ulc-possible-linebreaks.c (main): Likewise.

ChangeLog
lib/gen-uni-tables.c
lib/unilbrk/lbrktables.c
tests/unilbrk/test-u16-possible-linebreaks.c
tests/unilbrk/test-u32-possible-linebreaks.c
tests/unilbrk/test-u8-possible-linebreaks.c
tests/unilbrk/test-ulc-possible-linebreaks.c

index 9f5cd5b6e6aef160a44714ee557afa0c18fb4b12..193dd3921004a79b9b062887e3a8a7ee1c487243 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2021-12-28  Bruno Haible  <bruno@clisp.org>
+
+       unilbrk: Restore deviation for (IS,AL) pair.
+       * lib/gen-uni-tables.c (output_lbrk_rules_as_tables): Disable rule LB29.
+       * lib/unilbrk/lbrktables.c: Regenerated.
+       * tests/unilbrk/test-u8-possible-linebreaks.c (main): Add test case with
+       HTML markup.
+       * tests/unilbrk/test-u16-possible-linebreaks.c (main): Likewise.
+       * tests/unilbrk/test-u32-possible-linebreaks.c (main): Likewise.
+       * tests/unilbrk/test-ulc-possible-linebreaks.c (main): Likewise.
+
 2021-12-28  Bruno Haible  <bruno@clisp.org>
 
        unilbrk: Change algorithm to be closer to Unicode Standard Annex #14.
index d9f81943b5a27e3a87415e5233df224ddf13bf15..3d1b71806751792ffc0cc29ad02c880212e8c77c 100644 (file)
@@ -8149,8 +8149,12 @@ output_lbrk_rules_as_tables (const char *filename, const char *version)
 
   /* (LB29) Do not break between numeric punctuation and alphabetics
      ("e.g.").  */
+  /* We don't implement this rule, because we find it desirable to break before
+     the HTML tag "</P>" in strings like "<P>Some sentence.</P>".  */
+#if 0
   before = LBP_IS; after = LBP_AL; table[before][after].prohibited_no_sp = true;
   before = LBP_IS; after = LBP_HL; table[before][after].prohibited_no_sp = true;
+#endif
 
   /* (LB28) Do not break between alphabetics ("at").  */
   before = LBP_AL; after = LBP_AL; table[before][after].prohibited_no_sp = true;
index dc6b3931cfc25db25c607bd3765168db3e7d2726..fd72a5cd8442dda82eceebf9614d5de0486c3e0f 100644 (file)
@@ -50,7 +50,7 @@ const unsigned char unilbrk_table[30][30] =
 /*  NS */ {  P,  I,  D,  I,  D,  I,  P,  P,  P,  D,  I,  D,  I,  P,  D,  D,  D,  P,  D,  D,  D,  D,  D,  D,  D,  D,  D,  D,  D,  D, },
 /*  OP */ {  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P,  P, },
 /*  QU */ {  P,  I,  I,  I,  I,  I,  P,  P,  P,  I,  I,  P,  I,  P,  I,  I,  I,  P,  I,  I,  I,  I,  I,  I,  I,  I,  I,  I,  I,  I, },
-/*  IS */ {  P,  I,  D,  I,  D,  I,  P,  P,  P,  D,  I,  D,  I,  P,  I,  D,  D,  P,  I,  D,  D,  D,  D,  D,  D,  I,  D,  I,  D,  D, },
+/*  IS */ {  P,  I,  D,  I,  D,  I,  P,  P,  P,  D,  I,  D,  I,  P,  I,  D,  D,  P,  D,  D,  D,  D,  D,  D,  D,  D,  D,  D,  D,  D, },
 /*  NU */ {  P,  I,  D,  I,  D,  I,  P,  P,  P,  I,  I,  I,  I,  P,  I,  I,  I,  P,  I,  D,  D,  D,  D,  D,  D,  I,  D,  I,  D,  D, },
 /*  PO */ {  P,  I,  D,  I,  D,  I,  P,  P,  P,  D,  I,  I,  I,  P,  I,  D,  D,  P,  I,  D,  D,  D,  D,  D,  D,  I,  D,  I,  D,  D, },
 /*  PR */ {  P,  I,  D,  I,  D,  I,  P,  P,  P,  D,  I,  I,  I,  P,  I,  D,  D,  P,  I,  I,  I,  I,  I,  I,  I,  I,  D,  I,  I,  I, },
index b27d75b2bcfafe4874ddf4ab4f605b47c8d1dc07..c8c5c50a7a3a15befd90e8cc8f0d6c2d276dc212 100644 (file)
@@ -95,5 +95,24 @@ main ()
     free (p);
   }
 
+  /* Test line breaking in a string with HTML markup.  */
+  {
+    static const uint16_t input[21] =
+      {
+        '<', 'P', '>', 'S', 'o', 'm', 'e', ' ', 's', 'e', 'n', 't',
+        'e', 'n', 'c', 'e', '.', '<', '/', 'P', '>'
+      };
+    char *p = (char *) malloc (SIZEOF (input));
+    size_t i;
+
+    u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+    for (i = 0; i < 21; i++)
+      {
+        ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE :
+                         UC_BREAK_PROHIBITED));
+      }
+    free (p);
+  }
+
   return 0;
 }
index 1474ae1c27c1fb4e3a8e0513800a67ed648ba4aa..b41f49cf2d3d094344607ac95df9ff38071092e4 100644 (file)
@@ -95,5 +95,24 @@ main ()
     free (p);
   }
 
+  /* Test line breaking in a string with HTML markup.  */
+  {
+    static const uint32_t input[21] =
+      {
+        '<', 'P', '>', 'S', 'o', 'm', 'e', ' ', 's', 'e', 'n', 't',
+        'e', 'n', 'c', 'e', '.', '<', '/', 'P', '>'
+      };
+    char *p = (char *) malloc (SIZEOF (input));
+    size_t i;
+
+    u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+    for (i = 0; i < 21; i++)
+      {
+        ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE :
+                         UC_BREAK_PROHIBITED));
+      }
+    free (p);
+  }
+
   return 0;
 }
index c55e900696cd7a4d4e6e600a4aef236967349b20..b07464c289cd3083ed0b14270e3c8f0ca2314dfd 100644 (file)
@@ -82,12 +82,27 @@ main ()
     size_t i;
 
     u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
-    for (i = 0; i < 4; i++)
+    for (i = 0; i < 6; i++)
       {
         ASSERT (p[i] == (i == 5 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED));
       }
     free (p);
   }
 
+  /* Test line breaking in a string with HTML markup.  */
+  {
+    static const uint8_t input[21] = "<P>Some sentence.</P>";
+    char *p = (char *) malloc (SIZEOF (input));
+    size_t i;
+
+    u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+    for (i = 0; i < 21; i++)
+      {
+        ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE :
+                         UC_BREAK_PROHIBITED));
+      }
+    free (p);
+  }
+
   return 0;
 }
index 24bae4b717e778faa6316d26d027e398a8bfc175..f3ad7f9222c6d8102efdb201a74535eb483ac172 100644 (file)
@@ -48,6 +48,21 @@ main ()
       }
     free (p);
   }
+
+  /* Test line breaking in a string with HTML markup.  */
+  {
+    static const char input[21] = "<P>Some sentence.</P>";
+    char *p = (char *) malloc (SIZEOF (input));
+    size_t i;
+
+    ulc_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+    for (i = 0; i < 21; i++)
+      {
+        ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE :
+                         UC_BREAK_PROHIBITED));
+      }
+    free (p);
+  }
 #endif
 
   return 0;