version 1.289, 2014/11/10 21:56:43 |
version 1.297, 2014/11/28 16:54:23 |
Line 91 static int termp_bt_pre(DECL_ARGS); |
|
Line 91 static int termp_bt_pre(DECL_ARGS); |
|
static int termp_bx_pre(DECL_ARGS); |
static int termp_bx_pre(DECL_ARGS); |
static int termp_cd_pre(DECL_ARGS); |
static int termp_cd_pre(DECL_ARGS); |
static int termp_d1_pre(DECL_ARGS); |
static int termp_d1_pre(DECL_ARGS); |
static int termp_es_pre(DECL_ARGS); |
|
static int termp_ex_pre(DECL_ARGS); |
static int termp_ex_pre(DECL_ARGS); |
static int termp_fa_pre(DECL_ARGS); |
static int termp_fa_pre(DECL_ARGS); |
static int termp_fd_pre(DECL_ARGS); |
static int termp_fd_pre(DECL_ARGS); |
Line 111 static int termp_quote_pre(DECL_ARGS); |
|
Line 110 static int termp_quote_pre(DECL_ARGS); |
|
static int termp_rs_pre(DECL_ARGS); |
static int termp_rs_pre(DECL_ARGS); |
static int termp_rv_pre(DECL_ARGS); |
static int termp_rv_pre(DECL_ARGS); |
static int termp_sh_pre(DECL_ARGS); |
static int termp_sh_pre(DECL_ARGS); |
|
static int termp_skip_pre(DECL_ARGS); |
static int termp_sm_pre(DECL_ARGS); |
static int termp_sm_pre(DECL_ARGS); |
static int termp_sp_pre(DECL_ARGS); |
static int termp_sp_pre(DECL_ARGS); |
static int termp_ss_pre(DECL_ARGS); |
static int termp_ss_pre(DECL_ARGS); |
Line 183 static const struct termact termacts[MDOC_MAX] = { |
|
Line 183 static const struct termact termacts[MDOC_MAX] = { |
|
{ termp_quote_pre, termp_quote_post }, /* Bq */ |
{ termp_quote_pre, termp_quote_post }, /* Bq */ |
{ termp_xx_pre, NULL }, /* Bsx */ |
{ termp_xx_pre, NULL }, /* Bsx */ |
{ termp_bx_pre, NULL }, /* Bx */ |
{ termp_bx_pre, NULL }, /* Bx */ |
{ NULL, NULL }, /* Db */ |
{ termp_skip_pre, NULL }, /* Db */ |
{ NULL, NULL }, /* Dc */ |
{ NULL, NULL }, /* Dc */ |
{ termp_quote_pre, termp_quote_post }, /* Do */ |
{ termp_quote_pre, termp_quote_post }, /* Do */ |
{ termp_quote_pre, termp_quote_post }, /* Dq */ |
{ termp_quote_pre, termp_quote_post }, /* Dq */ |
Line 193 static const struct termact termacts[MDOC_MAX] = { |
|
Line 193 static const struct termact termacts[MDOC_MAX] = { |
|
{ termp_quote_pre, termp_quote_post }, /* Eo */ |
{ termp_quote_pre, termp_quote_post }, /* Eo */ |
{ termp_xx_pre, NULL }, /* Fx */ |
{ termp_xx_pre, NULL }, /* Fx */ |
{ termp_bold_pre, NULL }, /* Ms */ |
{ termp_bold_pre, NULL }, /* Ms */ |
{ NULL, NULL }, /* No */ |
{ termp_li_pre, NULL }, /* No */ |
{ termp_ns_pre, NULL }, /* Ns */ |
{ termp_ns_pre, NULL }, /* Ns */ |
{ termp_xx_pre, NULL }, /* Nx */ |
{ termp_xx_pre, NULL }, /* Nx */ |
{ termp_xx_pre, NULL }, /* Ox */ |
{ termp_xx_pre, NULL }, /* Ox */ |
Line 235 static const struct termact termacts[MDOC_MAX] = { |
|
Line 235 static const struct termact termacts[MDOC_MAX] = { |
|
{ termp_quote_pre, termp_quote_post }, /* Bro */ |
{ termp_quote_pre, termp_quote_post }, /* Bro */ |
{ NULL, NULL }, /* Brc */ |
{ NULL, NULL }, /* Brc */ |
{ NULL, termp____post }, /* %C */ |
{ NULL, termp____post }, /* %C */ |
{ termp_es_pre, NULL }, /* Es */ |
{ termp_skip_pre, NULL }, /* Es */ |
{ termp_quote_pre, termp_quote_post }, /* En */ |
{ termp_quote_pre, termp_quote_post }, /* En */ |
{ termp_xx_pre, NULL }, /* Dx */ |
{ termp_xx_pre, NULL }, /* Dx */ |
{ NULL, termp____post }, /* %Q */ |
{ NULL, termp____post }, /* %Q */ |
Line 350 print_mdoc_node(DECL_ARGS) |
|
Line 350 print_mdoc_node(DECL_ARGS) |
|
term_tbl(p, n->span); |
term_tbl(p, n->span); |
break; |
break; |
default: |
default: |
if (termacts[n->tok].pre && ENDBODY_NOT == n->end) |
if (termacts[n->tok].pre && |
|
(n->end == ENDBODY_NOT || n->nchild)) |
chld = (*termacts[n->tok].pre) |
chld = (*termacts[n->tok].pre) |
(p, &npair, meta, n); |
(p, &npair, meta, n); |
break; |
break; |
|
|
print_mdoc_foot(struct termp *p, const void *arg) |
print_mdoc_foot(struct termp *p, const void *arg) |
{ |
{ |
const struct mdoc_meta *meta; |
const struct mdoc_meta *meta; |
|
size_t sz; |
|
|
meta = (const struct mdoc_meta *)arg; |
meta = (const struct mdoc_meta *)arg; |
|
|
Line 421 print_mdoc_foot(struct termp *p, const void *arg) |
|
Line 423 print_mdoc_foot(struct termp *p, const void *arg) |
|
term_vspace(p); |
term_vspace(p); |
|
|
p->offset = 0; |
p->offset = 0; |
p->rmargin = (p->maxrmargin - |
sz = term_strlen(p, meta->date); |
term_strlen(p, meta->date) + term_len(p, 1)) / 2; |
p->rmargin = p->maxrmargin > sz ? |
|
(p->maxrmargin + term_len(p, 1) - sz) / 2 : 0; |
p->trailspace = 1; |
p->trailspace = 1; |
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; |
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; |
|
|
Line 430 print_mdoc_foot(struct termp *p, const void *arg) |
|
Line 433 print_mdoc_foot(struct termp *p, const void *arg) |
|
term_flushln(p); |
term_flushln(p); |
|
|
p->offset = p->rmargin; |
p->offset = p->rmargin; |
p->rmargin = p->maxrmargin - term_strlen(p, meta->os); |
sz = term_strlen(p, meta->os); |
|
p->rmargin = p->maxrmargin > sz ? p->maxrmargin - sz : 0; |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
|
|
term_word(p, meta->date); |
term_word(p, meta->date); |
Line 492 print_mdoc_head(struct termp *p, const void *arg) |
|
Line 496 print_mdoc_head(struct termp *p, const void *arg) |
|
p->offset = 0; |
p->offset = 0; |
p->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ? |
p->rmargin = 2 * (titlen+1) + vollen < p->maxrmargin ? |
(p->maxrmargin - vollen + term_len(p, 1)) / 2 : |
(p->maxrmargin - vollen + term_len(p, 1)) / 2 : |
p->maxrmargin - vollen; |
vollen < p->maxrmargin ? p->maxrmargin - vollen : 0; |
|
|
term_word(p, title); |
term_word(p, title); |
term_flushln(p); |
term_flushln(p); |
Line 873 termp_it_pre(DECL_ARGS) |
|
Line 877 termp_it_pre(DECL_ARGS) |
|
assert(width); |
assert(width); |
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
p->rmargin = p->offset + width; |
p->rmargin = p->offset + width; |
else { |
else |
p->offset += width; |
p->offset += width; |
if (p->rmargin < p->offset) |
|
p->rmargin = p->offset; |
|
} |
|
break; |
break; |
case LIST_column: |
case LIST_column: |
assert(width); |
assert(width); |
Line 994 termp_it_post(DECL_ARGS) |
|
Line 995 termp_it_post(DECL_ARGS) |
|
static int |
static int |
termp_nm_pre(DECL_ARGS) |
termp_nm_pre(DECL_ARGS) |
{ |
{ |
|
const char *cp; |
|
|
if (MDOC_BLOCK == n->type) { |
if (MDOC_BLOCK == n->type) { |
p->flags |= TERMP_PREKEEP; |
p->flags |= TERMP_PREKEEP; |
Line 1004 termp_nm_pre(DECL_ARGS) |
|
Line 1006 termp_nm_pre(DECL_ARGS) |
|
if (NULL == n->child) |
if (NULL == n->child) |
return(0); |
return(0); |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
p->offset += term_len(p, 1) + |
cp = NULL; |
(NULL == n->prev->child ? |
if (n->prev->child != NULL) |
term_strlen(p, meta->name) : |
cp = n->prev->child->string; |
MDOC_TEXT == n->prev->child->type ? |
if (cp == NULL) |
term_strlen(p, n->prev->child->string) : |
cp = meta->name; |
term_len(p, 5)); |
if (cp == NULL) |
if (p->rmargin < p->offset) |
p->offset += term_len(p, 6); |
p->rmargin = p->offset; |
else |
|
p->offset += term_len(p, 1) + term_strlen(p, cp); |
return(1); |
return(1); |
} |
} |
|
|
|
|
termp_nd_pre(DECL_ARGS) |
termp_nd_pre(DECL_ARGS) |
{ |
{ |
|
|
if (MDOC_BODY != n->type) |
if (n->type == MDOC_BODY) |
return(1); |
term_word(p, "\\(en"); |
|
|
#if defined(__OpenBSD__) || defined(__linux__) |
|
term_word(p, "\\(en"); |
|
#else |
|
term_word(p, "\\(em"); |
|
#endif |
|
return(1); |
return(1); |
} |
} |
|
|
|
|
termp_sh_pre(DECL_ARGS) |
termp_sh_pre(DECL_ARGS) |
{ |
{ |
|
|
/* No vspace between consecutive `Sh' calls. */ |
|
|
|
switch (n->type) { |
switch (n->type) { |
case MDOC_BLOCK: |
case MDOC_BLOCK: |
if (n->prev && MDOC_Sh == n->prev->tok) |
/* |
if (NULL == n->prev->body->child) |
* Vertical space before sections, except |
break; |
* when the previous section was empty. |
term_vspace(p); |
*/ |
|
if (n->prev == NULL || |
|
MDOC_Sh != n->prev->tok || |
|
(n->prev->body != NULL && |
|
n->prev->body->child != NULL)) |
|
term_vspace(p); |
break; |
break; |
case MDOC_HEAD: |
case MDOC_HEAD: |
term_fontpush(p, TERMFONT_BOLD); |
term_fontpush(p, TERMFONT_BOLD); |
Line 1837 termp_sp_pre(DECL_ARGS) |
|
Line 1837 termp_sp_pre(DECL_ARGS) |
|
} |
} |
|
|
static int |
static int |
termp_es_pre(DECL_ARGS) |
termp_skip_pre(DECL_ARGS) |
{ |
{ |
|
|
return(0); |
return(0); |
Line 1854 termp_quote_pre(DECL_ARGS) |
|
Line 1854 termp_quote_pre(DECL_ARGS) |
|
case MDOC_Ao: |
case MDOC_Ao: |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case MDOC_Aq: |
case MDOC_Aq: |
term_word(p, "<"); |
term_word(p, n->parent->prev != NULL && |
|
n->parent->prev->tok == MDOC_An ? "<" : "\\(la"); |
break; |
break; |
case MDOC_Bro: |
case MDOC_Bro: |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
|
|
termp_quote_post(DECL_ARGS) |
termp_quote_post(DECL_ARGS) |
{ |
{ |
|
|
if (MDOC_BODY != n->type && MDOC_ELEM != n->type) |
if (n->type != MDOC_BODY && n->type != MDOC_ELEM) |
return; |
return; |
|
|
if (MDOC_En != n->tok) |
if ( ! (n->tok == MDOC_En || |
|
(n->tok == MDOC_Eo && n->end == ENDBODY_SPACE))) |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
|
|
switch (n->tok) { |
switch (n->tok) { |
case MDOC_Ao: |
case MDOC_Ao: |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case MDOC_Aq: |
case MDOC_Aq: |
term_word(p, ">"); |
term_word(p, n->parent->prev != NULL && |
|
n->parent->prev->tok == MDOC_An ? ">" : "\\(ra"); |
break; |
break; |
case MDOC_Bro: |
case MDOC_Bro: |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |