gbranden pushed a commit to branch master
in repository groff.

commit db0923eb021615c5efa235e223a48b4168c88b78
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Sep 17 22:21:14 2025 -0500

    [troff]: "Asciify" zero-width nodes.
    
    (Zero-width nodes are produced by the `\Z` drawing position reset escape
    sequence--and internally to represent some forms of combining
    character.)
    
    * src/roff/troff/node.h (class zero_width_node): Declare `asciify`
      member function, thus overriding base class.
    
    * src/roff/troff/node.cpp (zero_width_node::asciify): New member
      "asciifies" each contained node unless output is suppressed.
---
 ChangeLog                                     |  7 +++++++
 src/roff/groff/tests/asciify-request-works.sh |  4 ++--
 src/roff/troff/node.cpp                       | 16 ++++++++++++++++
 src/roff/troff/node.h                         |  1 +
 4 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dae19130d..80065558e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-09-17  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/node.h (class zero_width_node): Declare
+       `asciify` member function, thus overriding base class.
+       * src/roff/troff/node.cpp (zero_width_node::asciify): New member
+       "asciifies" each contained node unless output is suppressed.
+
 2025-09-15  G. Branden Robinson <[email protected]>
 
        * src/roff/groff/tests/asciify-request-works.sh: Add test case
diff --git a/src/roff/groff/tests/asciify-request-works.sh 
b/src/roff/groff/tests/asciify-request-works.sh
index 9d20e4961..9061976ea 100755
--- a/src/roff/groff/tests/asciify-request-works.sh
+++ b/src/roff/groff/tests/asciify-request-works.sh
@@ -56,7 +56,7 @@ $%antimatter15@$b"hup"16@$c
 !sp
 .c2
 17@$D"l 1i 1i"18@$x".5v"19@$l"1i"20@$L"1i"21@$o"o+"22@$
-$O[0]fnord$O[1]23@$Z"unseen"24@
+$O[0]fnord$O[1]23@$Z"visible"24@
 .br
 .box
 .asciify DIV2
@@ -162,7 +162,7 @@ echo "checking textification of overstriking escape 
sequence" >&2
 echo "$output" | grep -q '21@22' || wail
 
 echo "checking textification of drawing position reset escape sequence" >&2
-echo "$output" | grep -q '23@24' || wail
+echo "$output" | grep -q '23@visible24' || wail
 
 test -z "$fail"
 
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 11e82f0bb..b1fe66844 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -4085,6 +4085,22 @@ void vline_node::asciify(macro *)
 {
 }
 
+// We probably would asciify zero-width nodes as nothing, but they're
+// used internally to represent some forms of combining character, as
+// with \[u015E] -> S<ac>.
+void zero_width_node::asciify(macro *m)
+{
+  assert(nodes != 0 /* nullptr */);
+  if (!is_output_supressed) {
+    node *n = nodes;
+    while (n != 0 /* nullptr */) {
+      n->asciify(m);
+      n = n->next;
+    }
+    nodes = 0 /* nullptr */;
+  }
+}
+
 breakpoint *node::get_breakpoints(hunits /* width */, int /* nspaces */,
                                  breakpoint *rest, bool /* is_inner */)
 {
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index 90640975b..9092734d5 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -498,6 +498,7 @@ class zero_width_node : public container_node {
 public:
   zero_width_node(node *);
   zero_width_node(node *, statem *, int);
+  void asciify(macro *);
   node *copy();
   void tprint(troff_output_file *);
   void ascii_print(ascii_output_file *);

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

Reply via email to