gbranden pushed a commit to branch master
in repository groff.

commit a729e70ffdc93cc68ed58f402b66c85478b4852e
Author: Nguyễn Gia Phong <[email protected]>
AuthorDate: Wed Jul 8 11:14:03 2026 +0900

    [eqn]: Emit better-formed XHTML/MathML. (2/3)
    
    * src/preproc/eqn/text.cpp: Stop mapping special characters to named
      entities when outputting MathML.  Preprocessor-include "unicode.h".
    
      (special_char_box::output): Use libgroff's
      `valid_unicode_code_sequence()` to obtain its Unicode sequence
      representation if it is in groff Unicode special character escape
      sequence syntax.  If not, use `glyph_name_to_unicode()` to look up its
      Unicode representation.
    
    Continues fixing <https://savannah.gnu.org/bugs/?68499>.
---
 ChangeLog                | 13 +++++++++++++
 src/preproc/eqn/text.cpp |  9 ++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a0b3a0319..a52fe8b39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2026-07-08  Nguyễn Gia Phong <[email protected]>
+
+       * src/preproc/eqn/text.cpp: Stop mapping special characters to
+       named entities when outputting MathML.  Preprocessor-include
+       "unicode.h".
+       (special_char_box::output): Use libgroff's
+       `valid_unicode_code_sequence()` to obtain its Unicode sequence
+       representation if it is in groff Unicode special character
+       escape sequence syntax.  If not, use `glyph_name_to_unicode()`
+       to look up its Unicode representation.
+
+       Continues fixing <https://savannah.gnu.org/bugs/?68499>.
+
 2026-07-08  Nguyễn Gia Phong <[email protected]>
 
        * src/preproc/eqn/box.cpp
diff --git a/src/preproc/eqn/text.cpp b/src/preproc/eqn/text.cpp
index 7753fd36f..dc0c33d9f 100644
--- a/src/preproc/eqn/text.cpp
+++ b/src/preproc/eqn/text.cpp
@@ -28,6 +28,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #include "eqn.h"
 #include "pbox.h"
 #include "ptable.h"
+#include "unicode.h" // valid_unicode_code_sequence()
 
 struct map {
   const char *from;
@@ -666,9 +667,11 @@ void special_char_box::output()
       printf("\\fP");
   }
   else if (output_format == mathml) {
-    const char *entity = special_to_entity(s);
-    if (entity != NULL)
-      printf("<mo>%s</mo>", entity);
+    const char *unicode_code_point = valid_unicode_code_sequence(s);
+    if (unicode_code_point == NULL)
+      unicode_code_point = glyph_name_to_unicode(s);
+    if (unicode_code_point != NULL)
+      printf("<mo>&#x%s;</mo>", unicode_code_point);
     else
       printf("<merror>unknown eqn/troff special char %s</merror>", s);
   }

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to