From 3aaace71df52a8311f2e358e64b96fff63aa57f2 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Wed, 30 Jul 2014 17:06:26 +0000 Subject: Get rid of the useless FATAL error "child violates parent syntax". When finding items outside lists, simply skip them and throw an ERROR. Handle subsections before the first section instead of bailing out. --- mdoc_macro.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'mdoc_macro.c') diff --git a/mdoc_macro.c b/mdoc_macro.c index f4384ced..3cefdfe9 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.137 2014/07/07 21:36:20 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.138 2014/07/30 17:06:26 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013 Ingo Schwarze @@ -424,6 +424,8 @@ rew_dohalt(enum mdoct tok, enum mdoc_type type, return(REWIND_NONE); /* FALLTHROUGH */ case MDOC_Sh: + if (MDOC_ROOT == p->parent->type) + return(REWIND_THIS); if (MDOC_Nd == p->tok || MDOC_Ss == p->tok || MDOC_Sh == p->tok) return(REWIND_MORE); @@ -1035,6 +1037,22 @@ blk_full(MACRO_PROT_ARGS) nl = MDOC_NEWLINE & mdoc->flags; + /* Skip items outside lists. */ + + if (tok == MDOC_It) { + for (n = mdoc->last; n; n = n->parent) + if (n->tok == MDOC_Bl) + break; + if (n == NULL) { + mandoc_vmsg(MANDOCERR_IT_STRAY, mdoc->parse, + line, ppos, "It %s", buf + *pos); + if ( ! mdoc_elem_alloc(mdoc, line, ppos, + MDOC_br, NULL)) + return(0); + return(rew_elem(mdoc, MDOC_br)); + } + } + /* Close out prior implicit scope. */ if ( ! (MDOC_EXPLICIT & mdoc_macros[tok].flags)) { -- cgit v1.2.3-56-ge451