summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2013-05-19 21:40:19 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2013-05-19 21:40:19 +0000
commitbffb353f5aa0b007f5d26ac002592a8729f538a6 (patch)
tree27a0ce26b82c84e74dd434169cdb3b7148c372e2
parent34c372a3097ff834e96ec1755a592aff3963fe29 (diff)
Support .Bl -offset in -mdoc -Tman.
Issue found when Thomas Klausner <wiz at NetBSD dot org> made me look at the manuals of his http://www.nih.at/libzip library.
-rw-r--r--regress/usr.bin/mandoc/mdoc/Bl/nested.in11
-rw-r--r--regress/usr.bin/mandoc/mdoc/Bl/nested.out_ascii9
-rw-r--r--regress/usr.bin/mandoc/mdoc/Bl/tag.in10
-rw-r--r--regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii8
-rw-r--r--usr.bin/mandoc/mdoc_man.c26
5 files changed, 56 insertions, 8 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Bl/nested.in b/regress/usr.bin/mandoc/mdoc/Bl/nested.in
index c02a433230e..380e2e623b7 100644
--- a/regress/usr.bin/mandoc/mdoc/Bl/nested.in
+++ b/regress/usr.bin/mandoc/mdoc/Bl/nested.in
@@ -1,4 +1,4 @@
-.Dd December 31, 2012
+.Dd May 19, 2013
.Dt BL-NESTED 1
.Os OpenBSD
.Sh NAME
@@ -71,4 +71,13 @@ inner text
.El
outer text
.El
+.Bl -tag -width 4n -offset 3n
+.It outer tag (indented 3n)
+outer text
+.Bl -tag -width 4n -offset 6n
+.It inner tag (indented 6n)
+inner text
+.El
+outer text
+.El
final text
diff --git a/regress/usr.bin/mandoc/mdoc/Bl/nested.out_ascii b/regress/usr.bin/mandoc/mdoc/Bl/nested.out_ascii
index c4185625125..e866f16f5f1 100644
--- a/regress/usr.bin/mandoc/mdoc/Bl/nested.out_ascii
+++ b/regress/usr.bin/mandoc/mdoc/Bl/nested.out_ascii
@@ -42,6 +42,13 @@ DDEESSCCRRIIPPTTIIOONN
inner tag
inner text
outer text
+
+ outer tag (indented 3n)
+ outer text
+
+ inner tag (indented 6n)
+ inner text
+ outer text
final text
-OpenBSD December 31, 2012 OpenBSD
+OpenBSD May 19, 2013 OpenBSD
diff --git a/regress/usr.bin/mandoc/mdoc/Bl/tag.in b/regress/usr.bin/mandoc/mdoc/Bl/tag.in
index aa363567be0..bbf12de82d7 100644
--- a/regress/usr.bin/mandoc/mdoc/Bl/tag.in
+++ b/regress/usr.bin/mandoc/mdoc/Bl/tag.in
@@ -1,4 +1,4 @@
-.Dd December 31, 2012
+.Dd May 19, 2013
.Dt BL-TAG 1
.Os OpenBSD
.Sh NAME
@@ -58,6 +58,14 @@ text
text
.El
.Pp
+Indented list:
+.Bl -tag -offset 6n -width xxx
+.It one
+first text
+.It two
+second text
+.El
+.Pp
Embedded paragraph:
.Bl -tag -width Ds
.It tag
diff --git a/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii b/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii
index 4de81918454..930c7281e8b 100644
--- a/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii
+++ b/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii
@@ -47,10 +47,16 @@ DDEESSCCRRIIPPTTIIOONN
tag text
+ Indented list:
+
+ one first text
+
+ two second text
+
Embedded paragraph:
tag first paragraph
second paragraph
-OpenBSD December 31, 2012 OpenBSD
+OpenBSD May 19, 2013 OpenBSD
diff --git a/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c
index eb2b0da45db..0b172127d9e 100644
--- a/usr.bin/mandoc/mdoc_man.c
+++ b/usr.bin/mandoc/mdoc_man.c
@@ -1,6 +1,6 @@
-/* $Id: mdoc_man.c,v 1.47 2013/05/19 21:05:29 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.48 2013/05/19 21:40:18 schwarze Exp $ */
/*
- * Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011, 2012, 2013 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
@@ -906,6 +906,16 @@ pre_bl(DECL_ARGS)
{
size_t icol;
+ /*
+ * print_offs() will increase the -offset to account for
+ * a possible enclosing .It, but any enclosed .It blocks
+ * just nest and do not add up their indentation.
+ */
+ if (n->norm->Bl.offs) {
+ print_offs(n->norm->Bl.offs);
+ Bl_stack[Bl_stack_len++] = 0;
+ }
+
switch (n->norm->Bl.type) {
case (LIST_enum):
n->norm->Bl.count = 0;
@@ -938,8 +948,16 @@ post_bl(DECL_ARGS)
default:
break;
}
- outflags |= MMAN_PP | MMAN_nl;
- outflags &= ~(MMAN_sp | MMAN_br);
+
+ if (n->norm->Bl.offs) {
+ print_line(".RE", MMAN_nl);
+ assert(Bl_stack_len);
+ Bl_stack_len--;
+ assert(0 == Bl_stack[Bl_stack_len]);
+ } else {
+ outflags |= MMAN_PP | MMAN_nl;
+ outflags &= ~(MMAN_sp | MMAN_br);
+ }
/* Maybe we are inside an enclosing list? */
if (NULL != n->parent->next)