discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: "Anthony J. Bentley" <anthony@cathet.us>
Cc: discuss@mdocml.bsd.lv
Subject: Re: tbl(7) text blocks
Date: Sat, 29 Mar 2014 00:37:32 +0100	[thread overview]
Message-ID: <20140328233732.GC10236@iris.usta.de> (raw)
In-Reply-To: <20140328213059.GB10236@iris.usta.de>

Hi Anthony,

Ingo Schwarze wrote on Fri, Mar 28, 2014 at 10:30:59PM +0100:
> Anthony J. Bentley wrote on Fri, Mar 28, 2014 at 01:21:04AM -0600:

>> .TS
>> center;
>> |l|l|.

> Hum.  What mandoc doesn't seem to support is leading vertical lines
> (ignored, see tbl_term.c, term_tbl(), 
>  if (NULL != hp->prev) tbl_vrule(tp, hp); )
> and trailing vertical lines
> (errors out, see tbl_layout.c, cell() handles '|' at the beginning,
>  but not at the end).

That was easier than i thought.

I have committed the following patch to both OpenBSD and bsd.lv.

It would be nice if you could

  cd /usr/src/usr.bin/mandoc; cvs up -dP;
  make obj; make depend; make; sudo make install

and look whether the page now formats better for you.

Yours,
  Ingo


 ----- 8< ----- schnipp ----- >8 ----- 8< ----- schnapp ----- >8 -----

Log Message:
-----------
Allow leading and trailing vertical lines, 
and format them in the same way as groff.
While here, do not require whitespace before vertical lines 
in layout specifications.
Issues found by bentley@ in mpv(1).

Modified Files:
--------------
    mdocml:
        mandoc.h
        tbl_layout.c
        tbl_term.c

Revision Data
-------------
Index: tbl_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/tbl_term.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -Ltbl_term.c -Ltbl_term.c -u -p -r1.25 -r1.26
--- tbl_term.c
+++ tbl_term.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011, 2012, 2014 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
@@ -105,7 +105,8 @@ term_tbl(struct termp *tp, const struct 
 
 	/* Vertical frame at the start of each row. */
 
-	if (TBL_OPT_BOX & sp->opts->opts || TBL_OPT_DBOX & sp->opts->opts)
+	if ((TBL_OPT_BOX | TBL_OPT_DBOX) & sp->opts->opts ||
+	    sp->head->vert)
 		term_word(tp, TBL_SPAN_HORIZ == sp->pos ||
 			TBL_SPAN_DHORIZ == sp->pos ? "+" : "|");
 
@@ -159,7 +160,8 @@ term_tbl(struct termp *tp, const struct 
 
 	/* Vertical frame at the end of each row. */
 
-	if (TBL_OPT_BOX & sp->opts->opts || TBL_OPT_DBOX & sp->opts->opts)
+	if ((TBL_OPT_BOX | TBL_OPT_DBOX) & sp->opts->opts ||
+	    sp->layout->vert)
 		term_word(tp, TBL_SPAN_HORIZ == sp->pos ||
 			TBL_SPAN_DHORIZ == sp->pos ? "+" : " |");
 	term_flushln(tp);
Index: tbl_layout.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/tbl_layout.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -Ltbl_layout.c -Ltbl_layout.c -u -p -r1.24 -r1.25
--- tbl_layout.c
+++ tbl_layout.c
@@ -1,7 +1,7 @@
 /*	$Id$ */
 /*
  * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2012 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2012, 2014 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
@@ -100,6 +100,8 @@ mod:
 	case (','):
 		/* FALLTHROUGH */
 	case ('.'):
+		/* FALLTHROUGH */
+	case ('|'):
 		return(1);
 	default:
 		break;
@@ -217,6 +219,13 @@ cell(struct tbl_node *tbl, struct tbl_ro
 		vert++;
 	while (' ' == p[*pos])
 		(*pos)++;
+
+	/* Handle trailing vertical lines */
+
+	if ('.' == p[*pos] || '\0' == p[*pos]) {
+		rp->vert = vert;
+		return(1);
+	}
 
 	/* Parse the column position (`c', `l', `r', ...). */
 
Index: mandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.h,v
retrieving revision 1.118
retrieving revision 1.119
diff -Lmandoc.h -Lmandoc.h -u -p -r1.118 -r1.119
--- mandoc.h
+++ mandoc.h
@@ -240,6 +240,7 @@ struct	tbl_row {
 	struct tbl_row	 *next;
 	struct tbl_cell	 *first;
 	struct tbl_cell	 *last;
+	int		  vert; /* trailing vertical line */
 };
 
 enum	tbl_datt {
--
 To unsubscribe send an email to discuss+unsubscribe@mdocml.bsd.lv

  reply	other threads:[~2014-03-28 23:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-28  7:21 Anthony J. Bentley
2014-03-28 21:30 ` Ingo Schwarze
2014-03-28 23:37   ` Ingo Schwarze [this message]
2014-03-29  0:02     ` Anthony J. Bentley
2014-03-28 21:50 ` Guy Harris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140328233732.GC10236@iris.usta.de \
    --to=schwarze@usta.de \
    --cc=anthony@cathet.us \
    --cc=discuss@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).