From 4c7036f39cd338c9cd69fe37813577f0f4a1bc69 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Tue, 29 Jun 2010 19:20:38 +0000 Subject: Support for badly nested blocks, written around the time of the Rostock mandoc hackathon and tested and polished since, supporting constructs like: .Ao Bo Ac Bc (exp breaking exp) .Aq Bo eol Bc (imp breaking exp) .Ao Bq Ac eol (exp breaking imp) .Ao Bo So Bc Ac Sc (double break, inner before outer) .Ao Bo So Ac Bc Sc (double break, outer before inner) .Ao Bo Ac So Bc Sc (broken breaker) .Ao Bo So Bc Do Ac Sc Dc (broken double breaker) There are still two known issues which are tricky: 1) Breaking two identical explicit blocks (Ao Bo Bo Ac or Aq Bo Bo eol) fails outright, triggering a bogus syntax error. 2) Breaking a block by two identical explicit blocks (Ao Ao Bo Ac Ac Bc or Ao Ao Bq Ac Ac eol) still has a minor rendering error left: " ac1> bc]>" should not have the final ">". We can fix these later in the tree, let's not grow this diff too large. "get it in" kristaps@ --- mdoc.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'mdoc.c') diff --git a/mdoc.c b/mdoc.c index 1184c641..4544e785 100644 --- a/mdoc.c +++ b/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.151 2010/06/27 16:36:22 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.152 2010/06/29 19:20:38 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -332,6 +332,8 @@ node_append(struct mdoc *mdoc, struct mdoc_node *p) p->parent->tail = p; break; case (MDOC_BODY): + if (p->end) + break; assert(MDOC_BLOCK == p->parent->type); p->parent->body = p; break; @@ -435,6 +437,22 @@ mdoc_body_alloc(struct mdoc *m, int line, int pos, enum mdoct tok) } +int +mdoc_endbody_alloc(struct mdoc *m, int line, int pos, enum mdoct tok, + struct mdoc_node *body, enum mdoc_endbody end) +{ + struct mdoc_node *p; + + p = node_alloc(m, line, pos, tok, MDOC_BODY); + p->pending = body; + p->end = end; + if ( ! node_append(m, p)) + return(0); + m->next = MDOC_NEXT_SIBLING; + return(1); +} + + int mdoc_block_alloc(struct mdoc *m, int line, int pos, enum mdoct tok, struct mdoc_arg *args) -- cgit v1.2.3