+void
+man_addeqn(struct man *man, const struct eqn *ep)
+{
+ struct man_node *n;
+
+ n = man_node_alloc(man, ep->ln, ep->pos, MAN_EQN, MAN_MAX);
+ n->eqn = ep;
+ if (ep->ln > man->last->line)
+ n->flags |= MAN_LINE;
+ man_node_append(man, n);
+ man->next = MAN_NEXT_SIBLING;
+ man_descope(man, ep->ln, ep->pos);
+}
+
+void
+man_addspan(struct man *man, const struct tbl_span *sp)
+{
+ struct man_node *n;
+
+ n = man_node_alloc(man, sp->line, 0, MAN_TBL, MAN_MAX);
+ n->span = sp;
+ man_node_append(man, n);
+ man->next = MAN_NEXT_SIBLING;
+ man_descope(man, sp->line, 0);
+}
+
+static void
+man_descope(struct man *man, int line, int offs)
+{
+ /*
+ * Co-ordinate what happens with having a next-line scope open:
+ * first close out the element scope (if applicable), then close
+ * out the block scope (also if applicable).
+ */
+
+ if (man->flags & MAN_ELINE) {
+ man->flags &= ~MAN_ELINE;
+ man_unscope(man, man->last->parent);
+ }
+ if ( ! (man->flags & MAN_BLINE))
+ return;
+ man->flags &= ~MAN_BLINE;
+ man_unscope(man, man->last->parent);
+ man_body_alloc(man, line, offs, man->last->tok);
+}