From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (schwarze@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id s6TDwKET003190 for ; Tue, 29 Jul 2014 09:58:20 -0400 (EDT) Received: (from schwarze@localhost) by krisdoz.my.domain (8.14.5/8.14.3/Submit) id s6TDwIs4022390; Tue, 29 Jul 2014 09:58:18 -0400 (EDT) Date: Tue, 29 Jul 2014 09:58:18 -0400 (EDT) Message-Id: <201407291358.s6TDwIs4022390@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Partial implementation of .Bd -centered. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Partial implementation of .Bd -centered. In groff, .Bd -centered operates in fill mode, which is relatively hard to implement, while this implementation operates in non-fill mode so far. As long as you pay attention that your lines do not overflow, it works. To make sure that rendering is the same for mandoc and groff, it is recommended to insert .br between lines for now. This implementation will need improvement later. Modified Files: -------------- mdocml: mdoc.h mdoc_term.c mdoc_validate.c Revision Data ------------- Index: mdoc_validate.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v retrieving revision 1.230 retrieving revision 1.231 diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.230 -r1.231 --- mdoc_validate.c +++ mdoc_validate.c @@ -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; Index: mdoc_term.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v retrieving revision 1.271 retrieving revision 1.272 diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.271 -r1.272 --- mdoc_term.c +++ mdoc_term.c @@ -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 Index: mdoc.h =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.h,v retrieving revision 1.130 retrieving revision 1.131 diff -Lmdoc.h -Lmdoc.h -u -p -r1.130 -r1.131 --- mdoc.h +++ mdoc.h @@ -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 */ -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv