- for (i = 0; i < indent; i++)
- xprintf(" ");
- xprintf("%s (%s)", p, t);
-
- for (i = 0; i < (int)argc; i++) {
- xprintf(" -%s", mdoc_argnames[argv[i].arg]);
- if (argv[i].sz > 0)
- xprintf(" [");
- for (j = 0; j < (int)argv[i].sz; j++)
- xprintf(" [%s]", argv[i].value[j]);
- if (argv[i].sz > 0)
- xprintf(" ]");
+ if (n->span) {
+ assert(NULL == p);
+ print_span(n->span, indent);
+ } else {
+ for (i = 0; i < indent; i++)
+ putchar('\t');
+
+ printf("%s (%s)", p, t);
+
+ for (i = 0; i < (int)argc; i++) {
+ printf(" -%s", mdoc_argnames[argv[i].arg]);
+ if (argv[i].sz > 0)
+ printf(" [");
+ for (j = 0; j < (int)argv[i].sz; j++)
+ printf(" [%s]", argv[i].value[j]);
+ if (argv[i].sz > 0)
+ printf(" ]");
+ }
+
+ for (i = 0; i < (int)sz; i++)
+ printf(" [%s]", params[i]);
+
+ printf(" %d:%d", n->line, n->pos);
+ }
+
+ putchar('\n');
+
+ if (n->child)
+ print_mdoc(n->child, indent + 1);
+ if (n->next)
+ print_mdoc(n->next, indent);
+}
+
+
+static void
+print_man(const struct man_node *n, int indent)
+{
+ const char *p, *t;
+ int i;
+
+ switch (n->type) {
+ case (MAN_ROOT):
+ t = "root";
+ break;
+ case (MAN_ELEM):
+ t = "elem";
+ break;
+ case (MAN_TEXT):
+ t = "text";
+ break;
+ case (MAN_BLOCK):
+ t = "block";
+ break;
+ case (MAN_HEAD):
+ t = "block-head";
+ break;
+ case (MAN_BODY):
+ t = "block-body";
+ break;
+ case (MAN_TBL):
+ t = "tbl";
+ break;
+ default:
+ abort();
+ /* NOTREACHED */