aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--mdoc.h4
-rw-r--r--mdoc_term.c17
-rw-r--r--mdoc_validate.c4
3 files changed, 18 insertions, 7 deletions
diff --git a/mdoc.h b/mdoc.h
index 6b63b4e7..58ad8131 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.130 2014/07/02 03:48:07 schwarze Exp $ */
+/* $Id: mdoc.h,v 1.131 2014/07/29 13:58:18 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -280,7 +280,7 @@ enum mdoc_list {
enum mdoc_disp {
DISP__NONE = 0,
- DISP_centred, /* -centered */
+ DISP_centered, /* -centered */
DISP_ragged, /* -ragged */
DISP_unfilled, /* -unfilled */
DISP_filled, /* -filled */
diff --git a/mdoc_term.c b/mdoc_term.c
index 4629e43a..a7f5b36d 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.271 2014/07/07 15:03:43 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.272 2014/07/29 13:58:18 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1571,7 +1571,7 @@ termp_fa_pre(DECL_ARGS)
static int
termp_bd_pre(DECL_ARGS)
{
- size_t tabwidth, rm, rmax;
+ size_t tabwidth, lm, len, rm, rmax;
struct mdoc_node *nn;
if (MDOC_BLOCK == n->type) {
@@ -1592,18 +1592,29 @@ termp_bd_pre(DECL_ARGS)
*/
if (DISP_literal != n->norm->Bd.type &&
- DISP_unfilled != n->norm->Bd.type)
+ DISP_unfilled != n->norm->Bd.type &&
+ DISP_centered != n->norm->Bd.type)
return(1);
tabwidth = p->tabwidth;
if (DISP_literal == n->norm->Bd.type)
p->tabwidth = term_len(p, 8);
+ lm = p->offset;
rm = p->rmargin;
rmax = p->maxrmargin;
p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
for (nn = n->child; nn; nn = nn->next) {
+ if (DISP_centered == n->norm->Bd.type) {
+ if (MDOC_TEXT == nn->type) {
+ len = term_strlen(p, nn->string);
+ p->offset = len >= rm ? 0 :
+ lm + len >= rm ? rm - len :
+ (lm + rm - len) / 2;
+ } else
+ p->offset = lm;
+ }
print_mdoc_node(p, pair, meta, nn);
/*
* If the printed node flushes its own line, then we
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 9e52365a..a122ac3b 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.230 2014/07/07 16:12:20 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.231 2014/07/29 13:58:18 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -802,7 +802,7 @@ pre_bd(PRE_ARGS)
switch (argv->arg) {
case MDOC_Centred:
- dt = DISP_centred;
+ dt = DISP_centered;
break;
case MDOC_Ragged:
dt = DISP_ragged;