diff options
author | 2012-07-09 18:55:40 +0000 | |
---|---|---|
committer | 2012-07-09 18:55:40 +0000 | |
commit | 0129f95f0303ffbacfb18ade84637bc1c83e29f4 (patch) | |
tree | 2100c8b28b447eba6b1f6bede9b590e2cc929aec | |
parent | second fuckup in implicit detection (diff) | |
download | wireguard-openbsd-0129f95f0303ffbacfb18ade84637bc1c83e29f4.tar.xz wireguard-openbsd-0129f95f0303ffbacfb18ade84637bc1c83e29f4.zip |
Implement -Tman .Bf.
To get the spacing right,
* avoid man(7) code line breaks at places where no spacing is allowed
* allow spacing right after .Sm on
* allow spacing after empty .Fl at the end of an input line
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bf/Makefile | 5 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bf/nest.in | 33 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Bf/nest.out_ascii | 11 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_man.c | 48 |
4 files changed, 91 insertions, 6 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Bf/Makefile b/regress/usr.bin/mandoc/mdoc/Bf/Makefile new file mode 100644 index 00000000000..bf943fcd0e3 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Bf/Makefile @@ -0,0 +1,5 @@ +# $OpenBSD: Makefile,v 1.1 2012/07/09 18:55:40 schwarze Exp $ + +REGRESS_TARGETS = nest + +.include <bsd.regress.mk> diff --git a/regress/usr.bin/mandoc/mdoc/Bf/nest.in b/regress/usr.bin/mandoc/mdoc/Bf/nest.in new file mode 100644 index 00000000000..90de861aa25 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Bf/nest.in @@ -0,0 +1,33 @@ +.Dd July 9, 2012 +.Dt BF-NEST 1 +.Os OpenBSD +.Sh NAME +.Nm Bf-nest +.Nd nesting font blocks +.Sh DESCRIPTION +normal text +.Bf -emphasis +emphasis +.Bf -literal +literal +.Bf -symbolic +symbolic +.Bf Em +Em +.Bf Li +Li +.Bf Sy +Sy +.Em in-line \&Em \\fRroman\\fP again \&Em +.Ef +back to Li +.Ef +back to Em +.Ef +back to symbolic +.Ef +back to literal +.Ef +back to emphasis +.Ef +back to normal diff --git a/regress/usr.bin/mandoc/mdoc/Bf/nest.out_ascii b/regress/usr.bin/mandoc/mdoc/Bf/nest.out_ascii new file mode 100644 index 00000000000..80455dcce96 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Bf/nest.out_ascii @@ -0,0 +1,11 @@ +BF-NEST(1) OpenBSD Reference Manual BF-NEST(1) + +NNAAMMEE + BBff--nneesstt - nesting font blocks + +DDEESSCCRRIIPPTTIIOONN + normal text _e_m_p_h_a_s_i_s literal ssyymmbboolliicc _E_m Li SSyy _i_n_-_l_i_n_e _E_m roman _a_g_a_i_n _E_m + back to Li _b_a_c_k _t_o _E_m bbaacckk ttoo ssyymmbboolliicc back to literal _b_a_c_k _t_o _e_m_p_h_a_s_i_s + back to normal + +OpenBSD July 9, 2012 OpenBSD diff --git a/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c index 32254712e64..91f67d81626 100644 --- a/usr.bin/mandoc/mdoc_man.c +++ b/usr.bin/mandoc/mdoc_man.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_man.c,v 1.24 2012/07/09 17:52:09 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.25 2012/07/09 18:55:40 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org> * @@ -40,6 +40,7 @@ static int cond_head(DECL_ARGS); static void font_push(char); static void font_pop(void); static void post_bd(DECL_ARGS); +static void post_bf(DECL_ARGS); static void post_bk(DECL_ARGS); static void post_dl(DECL_ARGS); static void post_enc(DECL_ARGS); @@ -59,6 +60,7 @@ static void post_vt(DECL_ARGS); static int pre_an(DECL_ARGS); static int pre_ap(DECL_ARGS); static int pre_bd(DECL_ARGS); +static int pre_bf(DECL_ARGS); static int pre_bk(DECL_ARGS); static int pre_br(DECL_ARGS); static int pre_bx(DECL_ARGS); @@ -154,7 +156,7 @@ static const struct manact manacts[MDOC_MAX + 1] = { { cond_body, pre_enc, post_enc, "<", ">" }, /* Aq */ { NULL, NULL, NULL, NULL, NULL }, /* At */ { NULL, NULL, NULL, NULL, NULL }, /* Bc */ - { NULL, NULL, NULL, NULL, NULL }, /* _Bf */ + { NULL, pre_bf, post_bf, NULL, NULL }, /* Bf */ { cond_body, pre_enc, post_enc, "[", "]" }, /* Bo */ { cond_body, pre_enc, post_enc, "[", "]" }, /* Bq */ { NULL, pre_ux, NULL, "BSD/OS", NULL }, /* Bsx */ @@ -392,8 +394,7 @@ print_node(DECL_ARGS) * This makes the page structure be more consistent. */ prev = n->prev ? n->prev : n->parent; - if (prev && prev->line < n->line && - MDOC_Fo != prev->tok && MDOC_Ns != prev->tok) + if (MMAN_spc & outflags && prev && prev->line < n->line) outflags |= MMAN_nl; act = NULL; @@ -640,6 +641,40 @@ post_bd(DECL_ARGS) } static int +pre_bf(DECL_ARGS) +{ + + switch (n->type) { + case (MDOC_BLOCK): + return(1); + case (MDOC_BODY): + break; + default: + return(0); + } + switch (n->norm->Bf.font) { + case (FONT_Em): + font_push('I'); + break; + case (FONT_Sy): + font_push('B'); + break; + default: + font_push('R'); + break; + } + return(1); +} + +static void +post_bf(DECL_ARGS) +{ + + if (MDOC_BODY == n->type) + font_pop(); +} + +static int pre_bk(DECL_ARGS) { @@ -757,7 +792,8 @@ post_fl(DECL_ARGS) { font_pop(); - if (0 == n->nchild) + if (0 == n->nchild && NULL != n->next && + n->next->line == n->line) outflags &= ~MMAN_spc; } @@ -1003,7 +1039,7 @@ pre_sm(DECL_ARGS) assert(n->child && MDOC_TEXT == n->child->type); if (0 == strcmp("on", n->child->string)) - outflags |= MMAN_Sm; + outflags |= MMAN_Sm | MMAN_spc; else outflags &= ~MMAN_Sm; return(0); |