gbranden pushed a commit to branch master
in repository groff.
commit 4103c1e309296fe0347a05b28b4f3476c2cc7472
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Mar 3 08:33:43 2025 -0600
[troff]: Implement recursive node dumping (5q/9).
* src/roff/troff/node.h (class tag_node): Specialize (override)
`dump_properties()` for this class.
* src/roff/troff/node.cpp (tag_node::dump_properties): New member
function reports values of `string` and `delayed` properties.
"Tag nodes", like "suppress nodes", are some of groff's blacker magic,
and are entangled with grohtml. Given the following simple input
document:
.NH 1
Introduction
.pline
.LP
Hello tag node world.
...processed with `groff -z -ms -Thtml`, this commit changes `pline`
request output as follows.
-{"type": "tag_node", "diversion level": 0, "is_special_node": true,
"state": "<state [br] [sp 1]>"},
+{"type": "tag_node", "diversion level": 0, "is_special_node": true,
"state": "<state [br] [sp 1]>", "string": "x X devtag:.NH 1\n", "delayed":
false},
It's worth noting that the "string" gets populated with a trailing
newline (this is impossible for *roff strings, but this `string` type
is implemented as a C++ class). This may or may not be a bug, depending
on how tag appending works. If it's not a bug, we may want to rename
this property to something other than "string" to reduce potential user
confusion.
---
ChangeLog | 8 ++++++++
src/roff/troff/node.cpp | 9 +++++++++
src/roff/troff/node.h | 1 +
3 files changed, 18 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 5b78df7d1..fd9398e2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-03-03 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/node.h (class tag_node): Specialize (override)
+ `dump_properties()` for this class.
+ * src/roff/troff/node.cpp (tag_node::dump_properties): New
+ member function reports values of `string` and `delayed`
+ properties.
+
2025-03-03 G. Branden Robinson <[email protected]>
* src/roff/troff/node.h (struct width_list): Declare `dump()`
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index c9595a8a5..423fb69e0 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -4220,6 +4220,15 @@ tag_node::tag_node(string s, statem *st, int divlevel,
int delay)
is_special = !delay;
}
+void tag_node::dump_properties()
+{
+ node::dump_properties();
+ fputs(", \"string\": ", stderr);
+ tag_string.json_dump();
+ fprintf(stderr, ", \"delayed\": %s", delayed ? "true" : "false");
+ fflush(stderr);
+}
+
node *tag_node::copy()
{
return new tag_node(tag_string, state, div_nest_level, delayed);
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index 1d522bb41..e16869917 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -636,6 +636,7 @@ public:
bool causes_tprint();
bool is_tag();
int ends_sentence(); // three-valued Boolean :-|
+ void dump_properties();
};
struct hvpair {
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit