summaryrefslogtreecommitdiffstats
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-12-15 23:39:40 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-12-15 23:39:40 +0000
commitc4788e9b021a0c7106d8aeb617d236222ebe19b6 (patch)
tree079a228cbab677524c865c3412275b27be4d17c1 /mdoc_validate.c
parent170e9dcf90a5e92a66337dd469337bb728efe516 (diff)
downloadmandoc-c4788e9b021a0c7106d8aeb617d236222ebe19b6.tar.gz
Add a "last child" member of struct mdoc_node.
Remove `Pp' or `Lp' if it is the FIRST or LAST child of an `Sh' or `Sh' body. Make "skipping paragraph" be an error, not a warning, as information (an invoked macro) is ignored.
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 2e4f93f2..e2ada6d5 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -107,6 +107,7 @@ static int post_it(POST_ARGS);
static int post_lb(POST_ARGS);
static int post_nm(POST_ARGS);
static int post_os(POST_ARGS);
+static int post_ignpar(POST_ARGS);
static int post_prol(POST_ARGS);
static int post_root(POST_ARGS);
static int post_rs(POST_ARGS);
@@ -150,9 +151,9 @@ static v_post posts_nm[] = { post_nm, NULL };
static v_post posts_notext[] = { ewarn_eq0, NULL };
static v_post posts_os[] = { post_os, post_prol, NULL };
static v_post posts_rs[] = { berr_ge1, herr_eq0, post_rs, NULL };
-static v_post posts_sh[] = { herr_ge1, bwarn_ge1, post_sh, NULL };
+static v_post posts_sh[] = { post_ignpar, herr_ge1, bwarn_ge1, post_sh, NULL };
static v_post posts_sp[] = { eerr_le1, NULL };
-static v_post posts_ss[] = { herr_ge1, NULL };
+static v_post posts_ss[] = { post_ignpar, herr_ge1, bwarn_ge1, NULL };
static v_post posts_st[] = { eerr_eq1, post_st, NULL };
static v_post posts_std[] = { post_std, NULL };
static v_post posts_text[] = { eerr_ge1, NULL };
@@ -894,10 +895,6 @@ pre_it(PRE_ARGS)
if (MDOC_BLOCK != n->type)
return(1);
- /*
- * FIXME: this can probably be lifted if we make the It into
- * something else on-the-fly?
- */
return(check_parent(mdoc, n, MDOC_Bl, MDOC_BODY));
}
@@ -1883,6 +1880,29 @@ post_sh_head(POST_ARGS)
}
static int
+post_ignpar(POST_ARGS)
+{
+ struct mdoc_node *np;
+
+ if (MDOC_BODY != mdoc->last->type)
+ return(1);
+
+ if (NULL != (np = mdoc->last->child))
+ if (MDOC_Pp == np->tok || MDOC_Lp == np->tok) {
+ mdoc_nmsg(mdoc, np, MANDOCERR_IGNPAR);
+ mdoc_node_delete(mdoc, np);
+ }
+
+ if (NULL != (np = mdoc->last->last))
+ if (MDOC_Pp == np->tok || MDOC_Lp == np->tok) {
+ mdoc_nmsg(mdoc, np, MANDOCERR_IGNPAR);
+ mdoc_node_delete(mdoc, np);
+ }
+
+ return(1);
+}
+
+static int
pre_par(PRE_ARGS)
{