-/* $Id: mdoc_term.c,v 1.44 2009/07/17 10:56:57 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.47 2009/07/19 08:24:16 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
static int termp_rv_pre(DECL_ARGS);
static int termp_sh_pre(DECL_ARGS);
static int termp_sm_pre(DECL_ARGS);
+static int termp_sp_pre(DECL_ARGS);
static int termp_sq_pre(DECL_ARGS);
static int termp_ss_pre(DECL_ARGS);
static int termp_sx_pre(DECL_ARGS);
{ termp_xx_pre, NULL }, /* Dx */
{ NULL, NULL }, /* %Q */
{ termp_br_pre, NULL }, /* br */
- { NULL, NULL }, /* sp */
+ { termp_sp_pre, NULL }, /* sp */
};
#ifdef __linux__
npair.flag = 0;
npair.count = 0;
+ /*
+ * Note on termpair. This allows a pre function to set a termp
+ * flag that is automatically unset after the body, but before
+ * the post function. Thus, if a pre uses a termpair flag, it
+ * must be reapplied in the post for use.
+ */
+
if (MDOC_TEXT != node->type) {
if (termacts[node->tok].pre)
if ( ! (*termacts[node->tok].pre)(p, &npair, meta, node))
if (dochild && node->child)
print_body(p, &npair, meta, node->child);
+ p->flags &= ~npair.flag;
+
/* Post-processing. */
if (MDOC_TEXT != node->type)
p->offset = offset;
p->rmargin = rmargin;
- p->flags &= ~npair.flag;
}
* Ew.
*/
- p->flags |= TERMP_LITERAL;
ln = node->child ? node->child->line : 0;
for (node = node->child; node; node = node->next) {
if (MDOC_BODY != node->type)
return;
-
term_flushln(p);
- p->flags &= ~TERMP_LITERAL;
- p->flags |= TERMP_NOSPACE;
}
termp_in_post(DECL_ARGS)
{
- p->flags |= TERMP_NOSPACE;
+ p->flags |= TERMP_NOSPACE | ttypes[TTYPE_INCLUDE];
term_word(p, ">");
+ p->flags &= ~ttypes[TTYPE_INCLUDE];
if (SEC_SYNOPSIS != node->sec)
return;
}
+/* ARGSUSED */
+static int
+termp_sp_pre(DECL_ARGS)
+{
+ int i, len;
+
+ if (NULL == node->child) {
+ term_vspace(p);
+ return(0);
+ }
+
+ len = atoi(node->child->string);
+ if (0 == len)
+ term_newln(p);
+ for (i = 0; i < len; i++)
+ term_vspace(p);
+
+ return(0);
+}
+
+
/* ARGSUSED */
static int
termp_br_pre(DECL_ARGS)