source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Allow leading and trailing vertical lines,  and format them in
Date: Fri, 28 Mar 2014 19:26:25 -0400 (EDT)	[thread overview]
Message-ID: <201403282326.s2SNQPMH018082@krisdoz.my.domain> (raw)

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 source+unsubscribe@mdocml.bsd.lv

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

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=201403282326.s2SNQPMH018082@krisdoz.my.domain \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@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).