diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2012-07-08 22:48:39 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2012-07-08 22:48:39 +0000 |
commit | e57685c4530485e61c0d1c56e09c61f0c6de6ea7 (patch) | |
tree | a4d4c20468a70887820aca2d9f521a0810804892 | |
parent | 6d9366534dc066a3f291dba7a1d1dba88c425af6 (diff) |
fix .Lk for -Tascii and implement it for -Tman
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Lk/Makefile | 5 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Lk/link.in | 14 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Lk/link.out_ascii | 12 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Lk/noarg.in | 14 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Lk/noarg.out_ascii | 10 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/mdoc/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_man.c | 33 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 33 |
8 files changed, 104 insertions, 21 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Lk/Makefile b/regress/usr.bin/mandoc/mdoc/Lk/Makefile new file mode 100644 index 00000000000..11e920e8e69 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Lk/Makefile @@ -0,0 +1,5 @@ +# $OpenBSD: Makefile,v 1.1 2012/07/08 22:48:38 schwarze Exp $ + +REGRESS_TARGETS = link noarg + +.include <bsd.regress.mk> diff --git a/regress/usr.bin/mandoc/mdoc/Lk/link.in b/regress/usr.bin/mandoc/mdoc/Lk/link.in new file mode 100644 index 00000000000..766448a9698 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Lk/link.in @@ -0,0 +1,14 @@ +.Dd August 8, 2010 +.Dt LK-LINK 1 +.Os OpenBSD +.Sh NAME +.Nm Lk-link +.Nd formatting of hyperlinks +.Sh DESCRIPTION +Here are some web sites of BSD operating systems: +.br +.Lk http://www.freebsd.org/ FreeBSD +.br +.Lk http://www.netbsd.org/ NetBSD +.br +.Lk http://www.openbsd.org/ OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Lk/link.out_ascii b/regress/usr.bin/mandoc/mdoc/Lk/link.out_ascii new file mode 100644 index 00000000000..9fa11cb5aee --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Lk/link.out_ascii @@ -0,0 +1,12 @@ +LK-LINK(1) OpenBSD Reference Manual LK-LINK(1) + +NNAAMMEE + LLkk--lliinnkk - formatting of hyperlinks + +DDEESSCCRRIIPPTTIIOONN + Here are some web sites of BSD operating systems: + _F_r_e_e_B_S_D_: hhttttpp::////wwwwww..ffrreeeebbssdd..oorrgg// + _N_e_t_B_S_D_: hhttttpp::////wwwwww..nneettbbssdd..oorrgg// + _O_p_e_n_B_S_D_: hhttttpp::////wwwwww..ooppeennbbssdd..oorrgg// + +OpenBSD August 8, 2010 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Lk/noarg.in b/regress/usr.bin/mandoc/mdoc/Lk/noarg.in new file mode 100644 index 00000000000..068c57f678a --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Lk/noarg.in @@ -0,0 +1,14 @@ +.Dd January 19, 2011 +.Dt LK-NOARG 1 +.Os OpenBSD +.Sh NAME +.Nm Lk-noarg +.Nd hyperlink macro without arguments +.Sh DESCRIPTION +two arguments +.Lk http://mdocml.bsd.lv/ mandoc +one argument +.Lk http://www.openbsd.org/ +no argument +.Lk +end of test document diff --git a/regress/usr.bin/mandoc/mdoc/Lk/noarg.out_ascii b/regress/usr.bin/mandoc/mdoc/Lk/noarg.out_ascii new file mode 100644 index 00000000000..6a8cc08399f --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Lk/noarg.out_ascii @@ -0,0 +1,10 @@ +LK-NOARG(1) OpenBSD Reference Manual LK-NOARG(1) + +NNAAMMEE + LLkk--nnooaarrgg - hyperlink macro without arguments + +DDEESSCCRRIIPPTTIIOONN + two arguments _m_a_n_d_o_c_: hhttttpp::////mmddooccmmll..bbssdd..llvv// one argument + hhttttpp::////wwwwww..ooppeennbbssdd..oorrgg// no argument end of test document + +OpenBSD January 19, 2011 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Makefile b/regress/usr.bin/mandoc/mdoc/Makefile index bbc61f82c50..b1baf23d852 100644 --- a/regress/usr.bin/mandoc/mdoc/Makefile +++ b/regress/usr.bin/mandoc/mdoc/Makefile @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.20 2012/07/08 18:38:07 schwarze Exp $ +# $OpenBSD: Makefile,v 1.21 2012/07/08 22:48:38 schwarze Exp $ SUBDIR += Ad An Ap Aq Ar At Bd Bk Bl Brq Bx Cd Cm D1 Dl Dq Dv Er Ev Fl Fo -SUBDIR += Ic In Lb Li Ms Mt Nd Nm No Ns Oo Op Ox Pf Pp Qq Rs +SUBDIR += Ic In Lb Lk Li Ms Mt Nd Nm No Ns Oo Op Ox Pf Pp Qq Rs SUBDIR += Sm Sq St Sx Sy Tn Ux Va Vt Xr blank # disabled, mandoc must be fixed: diff --git a/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c index 0085bdf020b..ef354c1c151 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.21 2012/07/08 18:38:07 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.22 2012/07/08 22:48:38 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org> * @@ -66,6 +66,7 @@ static int pre_fo(DECL_ARGS); static int pre_ft(DECL_ARGS); static int pre_in(DECL_ARGS); static int pre_it(DECL_ARGS); +static int pre_lk(DECL_ARGS); static int pre_nm(DECL_ARGS); static int pre_ns(DECL_ARGS); static int pre_pp(DECL_ARGS); @@ -195,7 +196,7 @@ static const struct manact manacts[MDOC_MAX + 1] = { { NULL, pre_ux, NULL, "currently under development.", NULL }, /* Ud */ { NULL, NULL, post_lb, NULL, NULL }, /* Lb */ { NULL, pre_pp, NULL, NULL, NULL }, /* Lp */ - { NULL, NULL, NULL, NULL, NULL }, /* _Lk */ + { NULL, pre_lk, NULL, NULL, NULL }, /* Lk */ { NULL, NULL, NULL, NULL, NULL }, /* _Mt */ { cond_body, pre_enc, post_enc, "{", "}" }, /* Brq */ { cond_body, pre_enc, post_enc, "{", "}" }, /* Bro */ @@ -827,6 +828,34 @@ post_lb(DECL_ARGS) } static int +pre_lk(DECL_ARGS) +{ + const struct mdoc_node *link, *descr; + + if (NULL == (link = n->child)) + return(0); + + if (NULL != (descr = link->next)) { + print_word("\\fI"); + outflags &= ~MMAN_spc; + while (NULL != descr) { + print_word(descr->string); + descr = descr->next; + } + print_word(":"); + outflags &= ~MMAN_spc; + print_word("\\fP"); + } + + print_word("\\fB"); + outflags &= ~MMAN_spc; + print_word(link->string); + outflags &= ~MMAN_spc; + print_word("\\fP"); + return(0); +} + +static int pre_nm(DECL_ARGS) { diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index c1b0a4e5957..4f724dadf2c 100644 --- a/usr.bin/mandoc/mdoc_term.c +++ b/usr.bin/mandoc/mdoc_term.c @@ -1,7 +1,7 @@ -/* $Id: mdoc_term.c,v 1.141 2012/07/08 16:50:36 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.142 2012/07/08 22:48:38 schwarze Exp $ */ /* * 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 * purpose with or without fee is hereby granted, provided that the above @@ -2155,25 +2155,24 @@ termp_li_pre(DECL_ARGS) static int termp_lk_pre(DECL_ARGS) { - const struct mdoc_node *nn, *sv; + const struct mdoc_node *link, *descr; - term_fontpush(p, TERMFONT_UNDER); - - nn = sv = n->child; - - if (NULL == nn || NULL == nn->next) - return(1); - - for (nn = nn->next; nn; nn = nn->next) - term_word(p, nn->string); - - term_fontpop(p); + if (NULL == (link = n->child)) + return(0); - p->flags |= TERMP_NOSPACE; - term_word(p, ":"); + 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); + } term_fontpush(p, TERMFONT_BOLD); - term_word(p, sv->string); + term_word(p, link->string); term_fontpop(p); return(0); |