gbranden pushed a commit to branch master in repository groff. commit 6c7277e40a28297ddbe4d1a29b844685d2f64ceb Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Sun Mar 16 23:32:48 2025 -0500
[troff]: Implement recursive node dumping (10/9). * src/roff/troff/node.cpp (class composite_node): Add `dump_node` member function, overriding virtual function in `node` (remote) base class. (composite_node::dump_node): Disclose more information, namely the contents of any defined nodes within. Because these are stored in reverse order--a composite node strongly resembles an output line, including a `line_start_node` and tail-first ordering--list them in reversed order, putting them forward. Changes `pline` output as follows. $ printf ".char a xyz\nplan\n.pline\n" | tg -z -{"type": "composite_node", "diversion level": 0, "is_special_node": false, "character": "a"}, +{"type": "composite_node", "diversion level": 0, "is_special_node": false, "character": "a", "contents": [{"type": "line_start_node", "diversion level": 0, "is_special_node": false}, +{"type": "glyph_node", "diversion level": 0, "is_special_node": false, "character": "x"}, +{"type": "glyph_node", "diversion level": 0, "is_special_node": false, "character": "y"}, +{"type": "glyph_node", "diversion level": 0, "is_special_node": false, "character": "z"}] +}, --- ChangeLog | 12 ++++++++++++ src/roff/troff/node.cpp | 14 +++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 91872a259..825a215d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2025-03-16 G. Branden Robinson <g.branden.robin...@gmail.com> + + * src/roff/troff/node.cpp (class composite_node): Add + `dump_node` member function, overriding virtual function in + `node` (remote) base class. + + (composite_node::dump_node): Disclose more information, namely + the contents of any defined nodes within. Because these are + stored in reverse order--a composite node strongly resembles an + output line, including a `line_start_node` and tail-first + ordering--list them in reversed order, putting them forward. + 2025-03-16 G. Branden Robinson <g.branden.robin...@gmail.com> * src/libs/libgroff/font.cpp (glyph_to_ucs_codepoint) diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp index 6bbd1e915..e4fb3717b 100644 --- a/src/roff/troff/node.cpp +++ b/src/roff/troff/node.cpp @@ -2742,7 +2742,6 @@ void container_node::dump_node() fflush(stderr); } -// TODO: Move this into env.cpp. void dump_node_list_in_reverse(node *nlist) { // It's stored in reverse order already; this puts it forward again. @@ -4581,6 +4580,8 @@ hunits suppress_node::width() /* composite_node */ +// Not derived from `container_node`; implements custom contained node +// dumper in dump_node(). class composite_node : public charinfo_node { node *nodes; tfont *tf; @@ -4606,6 +4607,7 @@ public: void vertical_extent(vunits *, vunits *); vunits vertical_width(); void dump_properties(); + void dump_node(); }; composite_node::composite_node(node *p, charinfo *c, tfont *t, statem *s, @@ -5318,6 +5320,16 @@ void composite_node::dump_properties() fflush(stderr); } +void composite_node::dump_node() +{ + fputc('{', stderr); + dump_properties(); + fputs(", \"contents\": ", stderr); + dump_node_list_in_reverse(nodes); + fputc('}', stderr); + fflush(stderr); +} + static node *make_composite_node(charinfo *s, environment *env) { int fontno = env_definite_font(env); _______________________________________________ groff-commit mailing list groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit