source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Allow leading and trailing vertical lines,  and format them in
@ 2014-03-28 23:26 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-03-28 23:26 UTC (permalink / raw)
  To: source

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-03-28 23:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-28 23:26 mdocml: Allow leading and trailing vertical lines, and format them in schwarze

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).