version 1.236, 2011/10/16 12:20:34 |
version 1.240, 2012/07/08 22:49:29 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010, 2012 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
|
#include "mdoc.h" |
#include "mdoc.h" |
#include "main.h" |
#include "main.h" |
|
|
#define INDENT 5 |
|
#define HALFINDENT 3 |
|
|
|
struct termpair { |
struct termpair { |
struct termpair *ppair; |
struct termpair *ppair; |
int count; |
int count; |
Line 194 static const struct termact termacts[MDOC_MAX] = { |
|
Line 191 static const struct termact termacts[MDOC_MAX] = { |
|
{ NULL, NULL }, /* Ec */ /* FIXME: no space */ |
{ NULL, NULL }, /* Ec */ /* FIXME: no space */ |
{ NULL, NULL }, /* Ef */ |
{ NULL, NULL }, /* Ef */ |
{ termp_under_pre, NULL }, /* Em */ |
{ termp_under_pre, NULL }, /* Em */ |
{ NULL, NULL }, /* 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 */ |
{ termp_igndelim_pre, NULL }, /* No */ |
{ termp_igndelim_pre, NULL }, /* No */ |
Line 259 terminal_mdoc(void *arg, const struct mdoc *mdoc) |
|
Line 256 terminal_mdoc(void *arg, const struct mdoc *mdoc) |
|
|
|
p = (struct termp *)arg; |
p = (struct termp *)arg; |
|
|
|
if (0 == p->defindent) |
|
p->defindent = 5; |
|
|
p->overstep = 0; |
p->overstep = 0; |
p->maxrmargin = p->defrmargin; |
p->maxrmargin = p->defrmargin; |
p->tabwidth = term_len(p, 5); |
p->tabwidth = term_len(p, 5); |
Line 562 a2offs(const struct termp *p, const char *v) |
|
Line 562 a2offs(const struct termp *p, const char *v) |
|
else if (0 == strcmp(v, "left")) |
else if (0 == strcmp(v, "left")) |
return(0); |
return(0); |
else if (0 == strcmp(v, "indent")) |
else if (0 == strcmp(v, "indent")) |
return(term_len(p, INDENT + 1)); |
return(term_len(p, p->defindent + 1)); |
else if (0 == strcmp(v, "indent-two")) |
else if (0 == strcmp(v, "indent-two")) |
return(term_len(p, (INDENT + 1) * 2)); |
return(term_len(p, (p->defindent + 1) * 2)); |
else if ( ! a2roffsu(v, &su, SCALE_MAX)) |
else if ( ! a2roffsu(v, &su, SCALE_MAX)) |
SCALE_HS_INIT(&su, term_strlen(p, v)); |
SCALE_HS_INIT(&su, term_strlen(p, v)); |
|
|
Line 1424 termp_sh_pre(DECL_ARGS) |
|
Line 1424 termp_sh_pre(DECL_ARGS) |
|
term_fontpush(p, TERMFONT_BOLD); |
term_fontpush(p, TERMFONT_BOLD); |
break; |
break; |
case (MDOC_BODY): |
case (MDOC_BODY): |
p->offset = term_len(p, INDENT); |
p->offset = term_len(p, p->defindent); |
|
if (SEC_AUTHORS == n->sec) |
|
p->flags &= ~(TERMP_SPLIT|TERMP_NOSPLIT); |
break; |
break; |
default: |
default: |
break; |
break; |
Line 1492 termp_d1_pre(DECL_ARGS) |
|
Line 1494 termp_d1_pre(DECL_ARGS) |
|
if (MDOC_BLOCK != n->type) |
if (MDOC_BLOCK != n->type) |
return(1); |
return(1); |
term_newln(p); |
term_newln(p); |
p->offset += term_len(p, (INDENT + 1)); |
p->offset += term_len(p, p->defindent + 1); |
return(1); |
return(1); |
} |
} |
|
|
Line 1797 termp_ss_pre(DECL_ARGS) |
|
Line 1799 termp_ss_pre(DECL_ARGS) |
|
break; |
break; |
case (MDOC_HEAD): |
case (MDOC_HEAD): |
term_fontpush(p, TERMFONT_BOLD); |
term_fontpush(p, TERMFONT_BOLD); |
p->offset = term_len(p, HALFINDENT); |
p->offset = term_len(p, (p->defindent+1)/2); |
break; |
break; |
default: |
default: |
break; |
break; |
Line 1925 termp_quote_pre(DECL_ARGS) |
|
Line 1927 termp_quote_pre(DECL_ARGS) |
|
case (MDOC_Dq): |
case (MDOC_Dq): |
term_word(p, "``"); |
term_word(p, "``"); |
break; |
break; |
|
case (MDOC_Eo): |
|
break; |
case (MDOC_Po): |
case (MDOC_Po): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Pq): |
case (MDOC_Pq): |
Line 1989 termp_quote_post(DECL_ARGS) |
|
Line 1993 termp_quote_post(DECL_ARGS) |
|
case (MDOC_Dq): |
case (MDOC_Dq): |
term_word(p, "''"); |
term_word(p, "''"); |
break; |
break; |
|
case (MDOC_Eo): |
|
break; |
case (MDOC_Po): |
case (MDOC_Po): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Pq): |
case (MDOC_Pq): |
Line 2153 termp_li_pre(DECL_ARGS) |
|
Line 2159 termp_li_pre(DECL_ARGS) |
|
static int |
static int |
termp_lk_pre(DECL_ARGS) |
termp_lk_pre(DECL_ARGS) |
{ |
{ |
const struct mdoc_node *nn, *sv; |
const struct mdoc_node *link, *descr; |
|
|
term_fontpush(p, TERMFONT_UNDER); |
if (NULL == (link = n->child)) |
|
return(0); |
|
|
nn = sv = n->child; |
if (NULL != (descr = link->next)) { |
|
term_fontpush(p, TERMFONT_UNDER); |
|
while (NULL != descr) { |
|
term_word(p, descr->string); |
|
descr = descr->next; |
|
} |
|
p->flags |= TERMP_NOSPACE; |
|
term_word(p, ":"); |
|
term_fontpop(p); |
|
} |
|
|
if (NULL == nn || NULL == nn->next) |
|
return(1); |
|
|
|
for (nn = nn->next; nn; nn = nn->next) |
|
term_word(p, nn->string); |
|
|
|
term_fontpop(p); |
|
|
|
p->flags |= TERMP_NOSPACE; |
|
term_word(p, ":"); |
|
|
|
term_fontpush(p, TERMFONT_BOLD); |
term_fontpush(p, TERMFONT_BOLD); |
term_word(p, sv->string); |
term_word(p, link->string); |
term_fontpop(p); |
term_fontpop(p); |
|
|
return(0); |
return(0); |