gbranden pushed a commit to branch master in repository groff. commit 45e77e894ec19a38ffa8722a76b6c9b2bdf5c7b3 Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Mon Mar 3 04:08:58 2025 -0600
[troff]: Implement recursive node dumping (5n/9). * src/roff/troff/node.h (class suppress_node): Specialize (override) `dump_properties()` for this class. * src/roff/troff/node.cpp (suppress_node::dump_properties): New member function reports values of `is_on`, `emit_limits`, `filename` (if not null), `position` (if not a null character), and `image_id` properties. "Suppress nodes" are some of groff's blacker magic, and are entangled with grohtml. Given the following simple input document: .EQ x = 1 .EN .pline Hello suppress node world. ...processed with `groff -e -Thtml` (and application of `sort -u` to stderr), this commit changes `pline` request output as follows. -{"type": "suppress_node", "diversion level": 0, "is_special_node": false}, -{"type": "suppress_node", "diversion level": 0, "is_special_node": true, "state": "<state>"}, -{"type": "suppress_node", "diversion level": 0, "is_special_node": true}, +{"type": "suppress_node", "diversion level": 0, "is_special_node": false, "is_on": 0, "emit_limits": false, "image_id": 0}, +{"type": "suppress_node", "diversion level": 0, "is_special_node": false, "is_on": 0, "emit_limits": false, "image_id": 0}, +{"type": "suppress_node", "diversion level": 0, "is_special_node": false, "is_on": 1, "emit_limits": false, "image_id": 0}, +{"type": "suppress_node", "diversion level": 0, "is_special_node": false, "is_on": 1, "emit_limits": false, "image_id": 0}, +{"type": "suppress_node", "diversion level": 0, "is_special_node": false, "is_on": 1, "emit_limits": true, "image_id": 0}, +{"type": "suppress_node", "diversion level": 0, "is_special_node": false, "is_on": 1, "emit_limits": true, "image_id": 0}, +{"type": "suppress_node", "diversion level": 0, "is_special_node": true, "state": "<state>", "is_on": 2, "emit_limits": false, "filename": "1.png", "position": "c", "image_id": 1}, +{"type": "suppress_node", "diversion level": 0, "is_special_node": true, "state": "<state>", "is_on": 2, "emit_limits": false, "filename": "2.png", "position": "c", "image_id": 2}, --- ChangeLog | 10 ++++++++++ src/roff/troff/node.cpp | 14 ++++++++++++++ src/roff/troff/node.h | 1 + 3 files changed, 25 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7928e4771..acb820702 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2025-03-03 G. Branden Robinson <g.branden.robin...@gmail.com> + + * src/roff/troff/node.h (class suppress_node): Specialize + {override} `dump_properties()` for this class. + * src/roff/troff/node.cpp + (suppress_node::dump_properties): New member function + reports values of `is_on`, `emit_limits`, `filename` (if not + null), `position` (if not a null character), and `image_id` + properties. + 2025-03-03 G. Branden Robinson <g.branden.robin...@gmail.com> * src/roff/troff/node.h (class device_extension_node): diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp index 83df3e903..e665e71da 100644 --- a/src/roff/troff/node.cpp +++ b/src/roff/troff/node.cpp @@ -4167,6 +4167,20 @@ suppress_node::suppress_node(int issue_limits, int on_or_off, { } +void suppress_node::dump_properties() +{ + node::dump_properties(); + fprintf(stderr, ", \"is_on\": %d", is_on); + fprintf(stderr, ", \"emit_limits\": %s", + emit_limits ? "true" : "false"); + if (filename.contents() != 0 /* nullptr */) + fprintf(stderr, ", \"filename\": \"%s\"", filename.contents()); + if (position != '\0') + fprintf(stderr, ", \"position\": \"%c\"", position); + fprintf(stderr, ", \"image_id\": %d", image_id); + fflush(stderr); +} + bool suppress_node::is_same_as(node *n) { return ((is_on == ((suppress_node *)n)->is_on) diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h index f4a527999..b2fc1e521 100644 --- a/src/roff/troff/node.h +++ b/src/roff/troff/node.h @@ -615,6 +615,7 @@ public: const char *type(); bool causes_tprint(); bool is_tag(); + void dump_properties(); private: void put(troff_output_file *, const char *); }; _______________________________________________ groff-commit mailing list groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit